fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
factoredNumbers.map_prime_pow_mul {F : Type*} [Mul F] {f : ℕ → F} (hmul : ∀ {m n}, Coprime m n → f (m * n) = f m * f n) {s : Finset ℕ} {p : ℕ} (hp : p.Prime) (hs : p ∉ s) (e : ℕ) {m : factoredNumbers s} : f (p ^ e * m) = f (p ^ e) * f m := hmul <| Coprime.pow_left _ <| hp.factoredNumbers_coprime hs <| Sub...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
factoredNumbers.map_prime_pow_mul
If `f : ℕ → F` is multiplicative on coprime arguments, `p ∉ s` is a prime and `m` is `s`-factored, then `f (p^e * m) = f (p^e) * f m`.
equivProdNatFactoredNumbers {s : Finset ℕ} {p : ℕ} (hp : p.Prime) (hs : p ∉ s) : ℕ × factoredNumbers s ≃ factoredNumbers (insert p s) where toFun := fun ⟨e, n⟩ ↦ ⟨p ^ e * n, pow_mul_mem_factoredNumbers hp e n.2⟩ invFun := fun ⟨m, _⟩ ↦ (m.factorization p, ⟨(m.primeFactorsList.filter ...
def
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatFactoredNumbers
We establish the bijection from `ℕ × factoredNumbers s` to `factoredNumbers (s ∪ {p})` given by `(e, n) ↦ p^e * n` when `p ∉ s` is a prime. See `Nat.factoredNumbers_insert` for when `p` is not prime.
equivProdNatFactoredNumbers_apply {s : Finset ℕ} {p e m : ℕ} (hp : p.Prime) (hs : p ∉ s) (hm : m ∈ factoredNumbers s) : equivProdNatFactoredNumbers hp hs (e, ⟨m, hm⟩) = p ^ e * m := rfl @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatFactoredNumbers_apply
null
equivProdNatFactoredNumbers_apply' {s : Finset ℕ} {p : ℕ} (hp : p.Prime) (hs : p ∉ s) (x : ℕ × factoredNumbers s) : equivProdNatFactoredNumbers hp hs x = p ^ x.1 * x.2 := rfl /-!
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatFactoredNumbers_apply'
null
smoothNumbers (n : ℕ) : Set ℕ := {m | m ≠ 0 ∧ ∀ p ∈ primeFactorsList m, p < n}
def
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers
`smoothNumbers n` is the set of *`n`-smooth positive natural numbers*, i.e., the positive natural numbers all of whose prime factors are less than `n`.
mem_smoothNumbers {n m : ℕ} : m ∈ smoothNumbers n ↔ m ≠ 0 ∧ ∀ p ∈ primeFactorsList m, p < n := Iff.rfl
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers
null
smoothNumbers_eq_factoredNumbers (n : ℕ) : smoothNumbers n = factoredNumbers (Finset.range n) := by simp only [smoothNumbers, ne_eq, mem_primeFactorsList', and_imp, factoredNumbers, Finset.mem_range]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers_eq_factoredNumbers
The `n`-smooth numbers agree with the `Finset.range n`-factored numbers.
smoothNumbers_eq_factoredNumbers_primesBelow (n : ℕ) : smoothNumbers n = factoredNumbers n.primesBelow := by rw [smoothNumbers_eq_factoredNumbers] refine Set.Subset.antisymm (fun m hm ↦ ?_) <| factoredNumbers_mono Finset.mem_of_mem_filter simp_rw [mem_factoredNumbers'] at hm ⊢ exact fun p hp hp' ↦ mem_prime...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers_eq_factoredNumbers_primesBelow
The `n`-smooth numbers agree with the `primesBelow n`-factored numbers.
mem_smoothNumbers_of_dvd {n m k : ℕ} (h : m ∈ smoothNumbers n) (h' : k ∣ m) : k ∈ smoothNumbers n := by simp only [smoothNumbers_eq_factoredNumbers] at h ⊢ exact mem_factoredNumbers_of_dvd h h'
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers_of_dvd
Membership in `Nat.smoothNumbers n` is decidable. -/ instance (n : ℕ) : DecidablePred (· ∈ smoothNumbers n) := inferInstanceAs <| DecidablePred fun x ↦ x ∈ {m | m ≠ 0 ∧ ∀ p ∈ primeFactorsList m, p < n} /-- A number that divides an `n`-smooth number is itself `n`-smooth.
mem_smoothNumbers_iff_forall_le {n m : ℕ} : m ∈ smoothNumbers n ↔ m ≠ 0 ∧ ∀ p ≤ m, p.Prime → p ∣ m → p < n := by simp only [smoothNumbers_eq_factoredNumbers, mem_factoredNumbers_iff_forall_le, Finset.mem_range]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers_iff_forall_le
`m` is `n`-smooth if and only if `m` is nonzero and all prime divisors `≤ m` of `m` are less than `n`.
mem_smoothNumbers' {n m : ℕ} : m ∈ smoothNumbers n ↔ ∀ p, p.Prime → p ∣ m → p < n := by simp only [smoothNumbers_eq_factoredNumbers, mem_factoredNumbers', Finset.mem_range]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers'
`m` is `n`-smooth if and only if all prime divisors of `m` are less than `n`.
primeFactors_subset_of_mem_smoothNumbers {m n : ℕ} (hms : m ∈ n.smoothNumbers) : m.primeFactors ⊆ n.primesBelow := primeFactors_subset_of_mem_factoredNumbers <| smoothNumbers_eq_factoredNumbers_primesBelow n ▸ hms
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
primeFactors_subset_of_mem_smoothNumbers
The `Finset` of prime factors of an `n`-smooth number is contained in the `Finset` of primes below `n`.
mem_smoothNumbers_of_primeFactors_subset {m n : ℕ} (hm : m ≠ 0) (hp : m.primeFactors ⊆ Finset.range n) : m ∈ n.smoothNumbers := smoothNumbers_eq_factoredNumbers n ▸ mem_factoredNumbers_of_primeFactors_subset hm hp
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers_of_primeFactors_subset
`m` is an `n`-smooth number if the `Finset` of its prime factors consists of numbers `< n`.
mem_smoothNumbers_iff_primeFactors_subset {m n : ℕ} : m ∈ n.smoothNumbers ↔ m ≠ 0 ∧ m.primeFactors ⊆ n.primesBelow := ⟨fun h ↦ ⟨h.1, primeFactors_subset_of_mem_smoothNumbers h⟩, fun h ↦ mem_smoothNumbers_of_primeFactors_subset h.1 <| h.2.trans <| Finset.filter_subset ..⟩
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers_iff_primeFactors_subset
`m` is an `n`-smooth number if and only if `m ≠ 0` and the `Finset` of its prime factors is contained in the `Finset` of primes below `n`
ne_zero_of_mem_smoothNumbers {n m : ℕ} (h : m ∈ smoothNumbers n) : m ≠ 0 := h.1 @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
ne_zero_of_mem_smoothNumbers
Zero is never a smooth number
smoothNumbers_zero : smoothNumbers 0 = {1} := by simp only [smoothNumbers_eq_factoredNumbers, Finset.range_zero, factoredNumbers_empty]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers_zero
null
mul_mem_smoothNumbers {m₁ m₂ n : ℕ} (hm1 : m₁ ∈ n.smoothNumbers) (hm2 : m₂ ∈ n.smoothNumbers) : m₁ * m₂ ∈ n.smoothNumbers := by rw [smoothNumbers_eq_factoredNumbers] at hm1 hm2 ⊢ exact mul_mem_factoredNumbers hm1 hm2
theorem
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mul_mem_smoothNumbers
The product of two `n`-smooth numbers is an `n`-smooth number.
prod_mem_smoothNumbers (n N : ℕ) : (n.primeFactorsList.filter (· < N)).prod ∈ smoothNumbers N := by simp only [smoothNumbers_eq_factoredNumbers, ← Finset.mem_range, prod_mem_factoredNumbers]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
prod_mem_smoothNumbers
The product of the prime factors of `n` that are less than `N` is an `N`-smooth number.
smoothNumbers_succ {N : ℕ} (hN : ¬ N.Prime) : (N + 1).smoothNumbers = N.smoothNumbers := by simp only [smoothNumbers_eq_factoredNumbers, Finset.range_add_one, factoredNumbers_insert _ hN] @[simp] lemma smoothNumbers_one : smoothNumbers 1 = {1} := by simp +decide only [not_false_eq_true, smoothNumbers_succ, smoothNu...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers_succ
The sets of `N`-smooth and of `(N+1)`-smooth numbers are the same when `N` is not prime. See `Nat.equivProdNatSmoothNumbers` for when `N` is prime.
mem_smoothNumbers_of_lt {m n : ℕ} (hm : 0 < m) (hmn : m < n) : m ∈ n.smoothNumbers := smoothNumbers_eq_factoredNumbers _ ▸ ⟨ne_zero_of_lt hm, fun _ h => Finset.mem_range.mpr <| lt_of_le_of_lt (le_of_mem_primeFactorsList h) hmn⟩
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbers_of_lt
All `m`, `0 < m < n` are `n`-smooth numbers
smoothNumbers_compl (N : ℕ) : (N.smoothNumbers)ᶜ \ {0} ⊆ {n | N ≤ n} := by simpa only [smoothNumbers_eq_factoredNumbers] using factoredNumbers_compl <| Finset.filter_subset _ (Finset.range N)
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbers_compl
The non-zero non-`N`-smooth numbers are `≥ N`.
pow_mul_mem_smoothNumbers {p n : ℕ} (hp : p ≠ 0) (e : ℕ) (hn : n ∈ smoothNumbers p) : p ^ e * n ∈ smoothNumbers (succ p) := by have : NoZeroDivisors ℕ := inferInstance -- this is needed twice --> speed-up have hp' := pow_ne_zero e hp refine ⟨mul_ne_zero hp' hn.1, fun q hq ↦ ?_⟩ rcases (mem_primeFactorsList_...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
pow_mul_mem_smoothNumbers
If `p` is positive and `n` is `p`-smooth, then every product `p^e * n` is `(p+1)`-smooth.
Prime.smoothNumbers_coprime {p n : ℕ} (hp : p.Prime) (hn : n ∈ smoothNumbers p) : Nat.Coprime p n := by simp only [smoothNumbers_eq_factoredNumbers] at hn exact hp.factoredNumbers_coprime Finset.notMem_range_self hn
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
Prime.smoothNumbers_coprime
If `p` is a prime and `n` is `p`-smooth, then `p` and `n` are coprime.
map_prime_pow_mul {F : Type*} [Mul F] {f : ℕ → F} (hmul : ∀ {m n}, Nat.Coprime m n → f (m * n) = f m * f n) {p : ℕ} (hp : p.Prime) (e : ℕ) {m : p.smoothNumbers} : f (p ^ e * m) = f (p ^ e) * f m := hmul <| Coprime.pow_left _ <| hp.smoothNumbers_coprime <| Subtype.mem m open List Perm Equiv in
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
map_prime_pow_mul
If `f : ℕ → F` is multiplicative on coprime arguments, `p` is a prime and `m` is `p`-smooth, then `f (p^e * m) = f (p^e) * f m`.
equivProdNatSmoothNumbers {p : ℕ} (hp : p.Prime) : ℕ × smoothNumbers p ≃ smoothNumbers (p + 1) := ((prodCongrRight fun _ ↦ setCongr <| smoothNumbers_eq_factoredNumbers p).trans <| equivProdNatFactoredNumbers hp Finset.notMem_range_self).trans <| setCongr <| (smoothNumbers_eq_factoredNumbers (p + 1)) ▸ Fin...
def
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatSmoothNumbers
We establish the bijection from `ℕ × smoothNumbers p` to `smoothNumbers (p+1)` given by `(e, n) ↦ p^e * n` when `p` is a prime. See `Nat.smoothNumbers_succ` for when `p` is not prime.
equivProdNatSmoothNumbers_apply {p e m : ℕ} (hp : p.Prime) (hm : m ∈ p.smoothNumbers) : equivProdNatSmoothNumbers hp (e, ⟨m, hm⟩) = p ^ e * m := rfl @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatSmoothNumbers_apply
null
equivProdNatSmoothNumbers_apply' {p : ℕ} (hp : p.Prime) (x : ℕ × p.smoothNumbers) : equivProdNatSmoothNumbers hp x = p ^ x.1 * x.2 := rfl /-!
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
equivProdNatSmoothNumbers_apply'
null
smoothNumbersUpTo (N k : ℕ) : Finset ℕ := {n ∈ Finset.range (N + 1) | n ∈ smoothNumbers k}
def
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbersUpTo
The `k`-smooth numbers up to and including `N` as a `Finset`
mem_smoothNumbersUpTo {N k n : ℕ} : n ∈ smoothNumbersUpTo N k ↔ n ≤ N ∧ n ∈ smoothNumbers k := by simp [smoothNumbersUpTo, lt_succ]
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
mem_smoothNumbersUpTo
null
roughNumbersUpTo (N k : ℕ) : Finset ℕ := {n ∈ Finset.range (N + 1) | n ≠ 0 ∧ n ∉ smoothNumbers k}
def
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
roughNumbersUpTo
The positive non-`k`-smooth (so "`k`-rough") numbers up to and including `N` as a `Finset`
smoothNumbersUpTo_card_add_roughNumbersUpTo_card (N k : ℕ) : #(smoothNumbersUpTo N k) + #(roughNumbersUpTo N k) = N := by rw [smoothNumbersUpTo, roughNumbersUpTo, ← Finset.card_union_of_disjoint <| Finset.disjoint_filter.mpr fun n _ hn₂ h ↦ h.2 hn₂, Finset.filter_union_right] suffices #{x ∈ Finset.range...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbersUpTo_card_add_roughNumbersUpTo_card
null
eq_prod_primes_mul_sq_of_mem_smoothNumbers {n k : ℕ} (h : n ∈ smoothNumbers k) : ∃ s ∈ k.primesBelow.powerset, ∃ m, n = m ^ 2 * (s.prod id) := by obtain ⟨l, m, H₁, H₂⟩ := sq_mul_squarefree n have hl : l ∈ smoothNumbers k := mem_smoothNumbers_of_dvd h (Dvd.intro_left (m ^ 2) H₁) refine ⟨l.primeFactorsList.toFi...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
eq_prod_primes_mul_sq_of_mem_smoothNumbers
A `k`-smooth number can be written as a square times a product of distinct primes `< k`.
smoothNumbersUpTo_subset_image (N k : ℕ) : smoothNumbersUpTo N k ⊆ Finset.image (fun (s, m) ↦ m ^ 2 * (s.prod id)) (k.primesBelow.powerset ×ˢ (Finset.range (N.sqrt + 1)).erase 0) := by intro n hn obtain ⟨hn₁, hn₂⟩ := mem_smoothNumbersUpTo.mp hn obtain ⟨s, hs, m, hm⟩ := eq_prod_primes_mul_sq_of_mem_smoot...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbersUpTo_subset_image
The set of `k`-smooth numbers `≤ N` is contained in the set of numbers of the form `m^2 * P`, where `m ≤ √N` and `P` is a product of distinct primes `< k`.
smoothNumbersUpTo_card_le (N k : ℕ) : #(smoothNumbersUpTo N k) ≤ 2 ^ #k.primesBelow * N.sqrt := by convert (Finset.card_le_card <| smoothNumbersUpTo_subset_image N k).trans <| Finset.card_image_le simp only [Finset.card_product, Finset.card_powerset, Finset.mem_range, zero_lt_succ, Finset.card_erase_of_...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
smoothNumbersUpTo_card_le
The cardinality of the set of `k`-smooth numbers `≤ N` is bounded by `2^π(k-1) * √N`.
roughNumbersUpTo_eq_biUnion (N k) : roughNumbersUpTo N k = ((N + 1).primesBelow \ k.primesBelow).biUnion fun p ↦ {m ∈ Finset.range (N + 1) | m ≠ 0 ∧ p ∣ m} := by ext m simp only [roughNumbersUpTo, mem_smoothNumbers_iff_forall_le, not_and, not_forall, not_lt, exists_prop, Finset.mem_range, Fins...
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
roughNumbersUpTo_eq_biUnion
The set of `k`-rough numbers `≤ N` can be written as the union of the sets of multiples `≤ N` of primes `k ≤ p ≤ N`.
roughNumbersUpTo_card_le (N k : ℕ) : #(roughNumbersUpTo N k) ≤ ((N + 1).primesBelow \ k.primesBelow).sum (fun p ↦ N / p) := by rw [roughNumbersUpTo_eq_biUnion] exact Finset.card_biUnion_le.trans <| Finset.sum_le_sum fun p _ ↦ (card_multiples' N p).le
lemma
NumberTheory
[ "Mathlib.Data.Nat.Factorization.Defs", "Mathlib.Data.Nat.Squarefree" ]
Mathlib/NumberTheory/SmoothNumbers.lean
roughNumbersUpTo_card_le
The cardinality of the set of `k`-rough numbers `≤ N` is bounded by the sum of `⌊N/p⌋` over the primes `k ≤ p ≤ N`.
euler_four_squares {R : Type*} [CommRing R] (a b c d x y z w : R) : (a * x - b * y - c * z - d * w) ^ 2 + (a * y + b * x + c * w - d * z) ^ 2 + (a * z - b * w + c * x + d * y) ^ 2 + (a * w + b * z - c * y + d * x) ^ 2 = (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2) := by ring
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
euler_four_squares
**Euler's four-square identity**.
Nat.euler_four_squares (a b c d x y z w : ℕ) : ((a : ℤ) * x - b * y - c * z - d * w).natAbs ^ 2 + ((a : ℤ) * y + b * x + c * w - d * z).natAbs ^ 2 + ((a : ℤ) * z - b * w + c * x + d * y).natAbs ^ 2 + ((a : ℤ) * w + b * z - c * y + d * x).natAbs ^ 2 = (a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 ...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
Nat.euler_four_squares
**Euler's four-square identity**, a version for natural numbers.
sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x ^ 2 + y ^ 2) : m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 := have : Even (x ^ 2 + y ^ 2) := by simp [← h] mul_right_injective₀ (show (2 * 2 : ℤ) ≠ 0 by decide) <| calc 2 * 2 * m = (x - y) ^ 2 + (x + y) ^ 2 := by rw [mul_assoc, h]; ring _ =...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
sq_add_sq_of_two_mul_sq_add_sq
null
lt_of_sum_four_squares_eq_mul {a b c d k m : ℕ} (h : a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = k * m) (ha : 2 * a < m) (hb : 2 * b < m) (hc : 2 * c < m) (hd : 2 * d < m) : k < m := by nlinarith
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
lt_of_sum_four_squares_eq_mul
null
exists_sq_add_sq_add_one_eq_mul (p : ℕ) [hp : Fact p.Prime] : ∃ (a b k : ℕ), 0 < k ∧ k < p ∧ a ^ 2 + b ^ 2 + 1 = k * p := by rcases hp.1.eq_two_or_odd' with (rfl | hodd) · use 1, 0, 1; simp rcases Nat.sq_add_sq_zmodEq p (-1) with ⟨a, b, ha, hb, hab⟩ rcases Int.modEq_iff_dvd.1 hab.symm with ⟨k, hk⟩ rw [sub...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
exists_sq_add_sq_add_one_eq_mul
null
private sum_four_squares_of_two_mul_sum_four_squares {m a b c d : ℤ} (h : a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = 2 * m) : ∃ w x y z : ℤ, w ^ 2 + x ^ 2 + y ^ 2 + z ^ 2 = m := by have : ∀ f : Fin 4 → ZMod 2, f 0 ^ 2 + f 1 ^ 2 + f 2 ^ 2 + f 3 ^ 2 = 0 → ∃ i : Fin 4, f i ^ 2 + f (swap i 0 1) ^ 2 = 0 ∧ f (swap i 0 2...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
sum_four_squares_of_two_mul_sum_four_squares
null
protected Prime.sum_four_squares {p : ℕ} (hp : p.Prime) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = p := by classical have := Fact.mk hp have natAbs_iff {a b c d : ℤ} {k : ℕ} : a.natAbs ^ 2 + b.natAbs ^ 2 + c.natAbs ^ 2 + d.natAbs ^ 2 = k ↔ a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = k := by rw [← ...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
Prime.sum_four_squares
Lagrange's **four squares theorem** for a prime number. Use `Nat.sum_four_squares` instead.
sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n := by induction n using Nat.recOnMul with | zero => exact ⟨0, 0, 0, 0, rfl⟩ | one => exact ⟨1, 0, 0, 0, rfl⟩ | prime p hp => exact hp.sum_four_squares | mul m n hm hn => rcases hm with ⟨a, b, c, d, rfl⟩ rcases hn with ⟨w, x, y...
theorem
NumberTheory
[ "Mathlib.FieldTheory.Finite.Basic" ]
Mathlib/NumberTheory/SumFourSquares.lean
sum_four_squares
**Four squares theorem**
one_half_le_sum_primes_ge_one_div (k : ℕ) : 1 / 2 ≤ ∑ p ∈ (4 ^ (k.primesBelow.card + 1)).succ.primesBelow \ k.primesBelow, (1 / p : ℝ) := by set m : ℕ := 2 ^ k.primesBelow.card set N₀ : ℕ := 2 * m ^ 2 with hN₀ let S : ℝ := ((2 * N₀).succ.primesBelow \ k.primesBelow).sum (fun p ↦ (1 / p : ℝ)) suffices ...
lemma
NumberTheory
[ "Mathlib.Algebra.Order.Group.Indicator", "Mathlib.Analysis.PSeries", "Mathlib.NumberTheory.SmoothNumbers" ]
Mathlib/NumberTheory/SumPrimeReciprocals.lean
one_half_le_sum_primes_ge_one_div
The cardinality of the set of `k`-rough numbers `≤ N` is bounded by `N` times the sum of `1/p` over the primes `k ≤ p ≤ N`. -/ -- This needs `Mathlib/Analysis/RCLike/Basic.lean`, so we put it here -- instead of in `Mathlib/NumberTheory/SmoothNumbers.lean`. lemma Nat.roughNumbersUpTo_card_le' (N k : ℕ) : (roughNumbe...
not_summable_one_div_on_primes : ¬ Summable (indicator {p | p.Prime} (fun n : ℕ ↦ (1 : ℝ) / n)) := by intro h obtain ⟨k, hk⟩ := h.nat_tsum_vanishing (Iio_mem_nhds one_half_pos : Iio (1 / 2 : ℝ) ∈ 𝓝 0) specialize hk ({p | Nat.Prime p} ∩ {p | k ≤ p}) inter_subset_right rw [tsum_subtype, indicator_indicator, ...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Group.Indicator", "Mathlib.Analysis.PSeries", "Mathlib.NumberTheory.SmoothNumbers" ]
Mathlib/NumberTheory/SumPrimeReciprocals.lean
not_summable_one_div_on_primes
The sum over the reciprocals of the primes diverges.
Nat.Primes.not_summable_one_div : ¬ Summable (fun p : Nat.Primes ↦ (1 / p : ℝ)) := by convert summable_subtype_iff_indicator.mp.mt not_summable_one_div_on_primes
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Group.Indicator", "Mathlib.Analysis.PSeries", "Mathlib.NumberTheory.SmoothNumbers" ]
Mathlib/NumberTheory/SumPrimeReciprocals.lean
Nat.Primes.not_summable_one_div
The sum over the reciprocals of the primes diverges.
Nat.Primes.summable_rpow {r : ℝ} : Summable (fun p : Nat.Primes ↦ (p : ℝ) ^ r) ↔ r < -1 := by by_cases h : r < -1 · -- case `r < -1` simp only [h, iff_true] exact (Real.summable_nat_rpow.mpr h).subtype _ · -- case `-1 ≤ r` simp only [h, iff_false] refine fun H ↦ Nat.Primes.not_summable_one_div...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Group.Indicator", "Mathlib.Analysis.PSeries", "Mathlib.NumberTheory.SmoothNumbers" ]
Mathlib/NumberTheory/SumPrimeReciprocals.lean
Nat.Primes.summable_rpow
The series over `p^r` for primes `p` converges if and only if `r < -1`.
Nat.Prime.sq_add_sq {p : ℕ} [Fact p.Prime] (hp : p % 4 ≠ 3) : ∃ a b : ℕ, a ^ 2 + b ^ 2 = p := by apply sq_add_sq_of_nat_prime_of_not_irreducible p rwa [_root_.irreducible_iff_prime, prime_iff_mod_four_eq_three_of_nat_prime p]
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.Prime.sq_add_sq
**Fermat's theorem on the sum of two squares**. Every prime not congruent to 3 mod 4 is the sum of two squares. Also known as **Fermat's Christmas theorem**.
sq_add_sq_mul {R} [CommRing R] {a b x y u v : R} (ha : a = x ^ 2 + y ^ 2) (hb : b = u ^ 2 + v ^ 2) : ∃ r s : R, a * b = r ^ 2 + s ^ 2 := ⟨x * u - y * v, x * v + y * u, by rw [ha, hb]; ring⟩
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
sq_add_sq_mul
The set of sums of two squares is closed under multiplication in any commutative ring. See also `sq_add_sq_mul_sq_add_sq`.
Nat.sq_add_sq_mul {a b x y u v : ℕ} (ha : a = x ^ 2 + y ^ 2) (hb : b = u ^ 2 + v ^ 2) : ∃ r s : ℕ, a * b = r ^ 2 + s ^ 2 := by zify at ha hb ⊢ obtain ⟨r, s, h⟩ := _root_.sq_add_sq_mul ha hb refine ⟨r.natAbs, s.natAbs, ?_⟩ simpa only [Int.natCast_natAbs, sq_abs]
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.sq_add_sq_mul
The set of natural numbers that are sums of two squares is closed under multiplication.
ZMod.isSquare_neg_one_of_dvd {m n : ℕ} (hd : m ∣ n) (hs : IsSquare (-1 : ZMod n)) : IsSquare (-1 : ZMod m) := by let f : ZMod n →+* ZMod m := ZMod.castHom hd _ rw [← RingHom.map_one f, ← RingHom.map_neg] exact hs.map f
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_of_dvd
If `-1` is a square modulo `n` and `m` divides `n`, then `-1` is also a square modulo `m`.
ZMod.isSquare_neg_one_mul {m n : ℕ} (hc : m.Coprime n) (hm : IsSquare (-1 : ZMod m)) (hn : IsSquare (-1 : ZMod n)) : IsSquare (-1 : ZMod (m * n)) := by have : IsSquare (-1 : ZMod m × ZMod n) := by rw [show (-1 : ZMod m × ZMod n) = ((-1 : ZMod m), (-1 : ZMod n)) from rfl] obtain ⟨x, hx⟩ := hm obtain ⟨y...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_mul
If `-1` is a square modulo coprime natural numbers `m` and `n`, then `-1` is also a square modulo `m*n`.
Nat.Prime.mod_four_ne_three_of_dvd_isSquare_neg_one {p n : ℕ} (hpp : p.Prime) (hp : p ∣ n) (hs : IsSquare (-1 : ZMod n)) : p % 4 ≠ 3 := by obtain ⟨y, h⟩ := ZMod.isSquare_neg_one_of_dvd hp hs rw [← sq, eq_comm, show (-1 : ZMod p) = -1 ^ 2 by ring] at h haveI : Fact p.Prime := ⟨hpp⟩ exact ZMod.mod_four_ne_thr...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.Prime.mod_four_ne_three_of_dvd_isSquare_neg_one
If a prime `p` divides `n` such that `-1` is a square modulo `n`, then `p % 4 ≠ 3`.
ZMod.isSquare_neg_one_iff {n : ℕ} (hn : Squarefree n) : IsSquare (-1 : ZMod n) ↔ ∀ {q : ℕ}, q.Prime → q ∣ n → q % 4 ≠ 3 := by refine ⟨fun H q hqp hqd => hqp.mod_four_ne_three_of_dvd_isSquare_neg_one hqd H, fun H => ?_⟩ induction n using induction_on_primes with | zero => exact False.elim (hn.ne_zero rfl) | ...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_iff
If `n` is a squarefree natural number, then `-1` is a square modulo `n` if and only if `n` is not divisible by a prime `q` such that `q % 4 = 3`.
ZMod.isSquare_neg_one_iff' {n : ℕ} (hn : Squarefree n) : IsSquare (-1 : ZMod n) ↔ ∀ {q : ℕ}, q ∣ n → q % 4 ≠ 3 := by have help : ∀ a b : ZMod 4, a ≠ 3 → b ≠ 3 → a * b ≠ 3 := by decide rw [ZMod.isSquare_neg_one_iff hn] refine ⟨?_, fun H q _ => H⟩ intro H refine @induction_on_primes _ ?_ ?_ (fun p q hp hq h...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_iff'
If `n` is a squarefree natural number, then `-1` is a square modulo `n` if and only if `n` has no divisor `q` that is `≡ 3 mod 4`.
Nat.eq_sq_add_sq_of_isSquare_mod_neg_one {n : ℕ} (h : IsSquare (-1 : ZMod n)) : ∃ x y : ℕ, n = x ^ 2 + y ^ 2 := by induction n using induction_on_primes with | zero => exact ⟨0, 0, rfl⟩ | one => exact ⟨0, 1, rfl⟩ | prime_mul p n hpp ih => haveI : Fact p.Prime := ⟨hpp⟩ have hp : IsSquare (-1 : ZMod p...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.eq_sq_add_sq_of_isSquare_mod_neg_one
If `-1` is a square modulo the natural number `n`, then `n` is a sum of two squares.
ZMod.isSquare_neg_one_of_eq_sq_add_sq_of_isCoprime {n x y : ℤ} (h : n = x ^ 2 + y ^ 2) (hc : IsCoprime x y) : IsSquare (-1 : ZMod n.natAbs) := by obtain ⟨u, v, huv⟩ : IsCoprime x n := by have hc2 : IsCoprime (x ^ 2) (y ^ 2) := hc.pow rw [show y ^ 2 = n + -1 * x ^ 2 by cutsat] at hc2 exact (IsCoprime.p...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_of_eq_sq_add_sq_of_isCoprime
If the integer `n` is a sum of two squares of coprime integers, then `-1` is a square modulo `n`.
ZMod.isSquare_neg_one_of_eq_sq_add_sq_of_coprime {n x y : ℕ} (h : n = x ^ 2 + y ^ 2) (hc : x.Coprime y) : IsSquare (-1 : ZMod n) := by zify at h exact ZMod.isSquare_neg_one_of_eq_sq_add_sq_of_isCoprime h hc.isCoprime
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
ZMod.isSquare_neg_one_of_eq_sq_add_sq_of_coprime
If the natural number `n` is a sum of two squares of coprime natural numbers, then `-1` is a square modulo `n`.
Nat.eq_sq_add_sq_iff_eq_sq_mul {n : ℕ} : (∃ x y : ℕ, n = x ^ 2 + y ^ 2) ↔ ∃ a b : ℕ, n = a ^ 2 * b ∧ IsSquare (-1 : ZMod b) := by constructor · rintro ⟨x, y, h⟩ by_cases hxy : x = 0 ∧ y = 0 · exact ⟨0, 1, by rw [h, hxy.1, hxy.2, zero_pow two_ne_zero, add_zero, zero_mul], ⟨0, by rw [zero_mul, neg...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.eq_sq_add_sq_iff_eq_sq_mul
A natural number `n` is a sum of two squares if and only if `n = a^2 * b` with natural numbers `a` and `b` such that `-1` is a square modulo `b`.
Nat.eq_sq_add_sq_iff {n : ℕ} : (∃ x y : ℕ, n = x ^ 2 + y ^ 2) ↔ ∀ {q : ℕ}, q.Prime → q % 4 = 3 → Even (padicValNat q n) := by rcases n.eq_zero_or_pos with (rfl | hn₀) · exact ⟨fun _ q _ _ => (@padicValNat.zero q).symm ▸ Even.zero, fun _ => ⟨0, 0, rfl⟩⟩ rw [Nat.eq_sq_add_sq_iff_eq_sq_mul] refine ⟨fun H q hq ...
theorem
NumberTheory
[ "Mathlib.Data.Nat.Squarefree", "Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity", "Mathlib.NumberTheory.Padics.PadicVal.Basic" ]
Mathlib/NumberTheory/SumTwoSquares.lean
Nat.eq_sq_add_sq_iff
A (positive) natural number `n` is a sum of two squares if and only if the exponent of every prime `q` such that `q % 4 = 3` in the prime factorization of `n` is even. (The assumption `0 < n` is not present, since for `n = 0`, both sides are satisfied; the right-hand side holds, since `padicValNat q 0 = 0` by definitio...
divisorsAntidiagonalFactors (n : ℕ+) : Nat.divisorsAntidiagonal n → ℕ+ × ℕ+ := fun x ↦ ⟨⟨x.1.1, Nat.pos_of_mem_divisors (Nat.fst_mem_divisors_of_mem_antidiagonal x.2)⟩, (⟨x.1.2, Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_antidiagonal x.2)⟩ : ℕ+), Nat.pos_of_mem_divisors (Nat.snd_mem_divisors_of_mem_...
def
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
divisorsAntidiagonalFactors
The map from `Nat.divisorsAntidiagonal n` to `ℕ+ × ℕ+` given by sending `n = a * b` to `(a, b)`.
divisorsAntidiagonalFactors_eq {n : ℕ+} (x : Nat.divisorsAntidiagonal n) : (divisorsAntidiagonalFactors n x).1.1 * (divisorsAntidiagonalFactors n x).2.1 = n := by simp [divisorsAntidiagonalFactors, (Nat.mem_divisorsAntidiagonal.mp x.2).1]
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
divisorsAntidiagonalFactors_eq
null
divisorsAntidiagonalFactors_one (x : Nat.divisorsAntidiagonal 1) : (divisorsAntidiagonalFactors 1 x) = (1, 1) := by have h := Nat.mem_divisorsAntidiagonal.mp x.2 simp only [mul_eq_one, ne_eq, one_ne_zero, not_false_eq_true, and_true] at h simp [divisorsAntidiagonalFactors, h.1, h.2]
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
divisorsAntidiagonalFactors_one
null
sigmaAntidiagonalEquivProd : (Σ n : ℕ+, Nat.divisorsAntidiagonal n) ≃ ℕ+ × ℕ+ where toFun x := divisorsAntidiagonalFactors x.1 x.2 invFun x := ⟨⟨x.1.val * x.2.val, mul_pos x.1.2 x.2.2⟩, ⟨x.1, x.2⟩, by simp [Nat.mem_divisorsAntidiagonal]⟩ left_inv := by rintro ⟨n, ⟨k, l⟩, h⟩ rw [Nat.mem_divisorsAntidia...
def
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
sigmaAntidiagonalEquivProd
The equivalence from the union over `n` of `Nat.divisorsAntidiagonal n` to `ℕ+ × ℕ+` given by sending `n = a * b` to `(a, b)`.
sigmaAntidiagonalEquivProd_symm_apply_fst (x : ℕ+ × ℕ+) : (sigmaAntidiagonalEquivProd.symm x).1 = x.1.1 * x.2.1 := rfl
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
sigmaAntidiagonalEquivProd_symm_apply_fst
null
sigmaAntidiagonalEquivProd_symm_apply_snd (x : ℕ+ × ℕ+) : (sigmaAntidiagonalEquivProd.symm x).2 = (x.1.1, x.2.1) := rfl
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
sigmaAntidiagonalEquivProd_symm_apply_snd
null
summable_norm_pow_mul_geometric_div_one_sub (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : Summable fun n : ℕ ↦ n ^ k * r ^ n / (1 - r ^ n) := by simp only [div_eq_mul_one_div ( _ * _ ^ _)] apply Summable.mul_tendsto_const (c := 1 / (1 - 0)) (by simpa using summable_norm_pow_mul_geometric_of_norm_lt_one k hr) simpa on...
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
summable_norm_pow_mul_geometric_div_one_sub
null
private summable_divisorsAntidiagonal_aux (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : Summable fun c : (n : ℕ+) × {x // x ∈ (n : ℕ).divisorsAntidiagonal} ↦ (c.2.1.2) ^ k * (r ^ (c.2.1.1 * c.2.1.2)) := by apply Summable.of_norm rw [summable_sigma_of_nonneg (fun a ↦ by positivity)] constructor · exact fun n ↦ (hasS...
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
summable_divisorsAntidiagonal_aux
null
summable_prod_mul_pow (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : Summable fun c : (ℕ+ × ℕ+) ↦ c.2 ^ k * (r ^ (c.1 * c.2 : ℕ)) := by simpa [sigmaAntidiagonalEquivProd.summable_iff.symm] using summable_divisorsAntidiagonal_aux k hr
theorem
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
summable_prod_mul_pow
null
tsum_prod_pow_eq_tsum_sigma (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : ∑' d : ℕ+, ∑' c : ℕ+, c ^ k * r ^ (d * c : ℕ) = ∑' e : ℕ+, σ k e * r ^ (e : ℕ) := by suffices ∑' c : ℕ+ × ℕ+, c.2 ^ k * r ^ (c.1 * c.2 : ℕ) = ∑' e : ℕ+, σ k e * r ^ (e : ℕ) by rwa [← (summable_prod_mul_pow k hr).tsum_prod] simp only [← sigmaAntid...
theorem
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
tsum_prod_pow_eq_tsum_sigma
null
tsum_pow_div_one_sub_eq_tsum_sigma {r : 𝕜} (hr : ‖r‖ < 1) (k : ℕ) : ∑' n : ℕ+, n ^ k * r ^ (n : ℕ) / (1 - r ^ (n : ℕ)) = ∑' n : ℕ+, σ k n * r ^ (n : ℕ) := by have (m : ℕ) [NeZero m] := tsum_geometric_of_norm_lt_one (ξ := r ^ m) (by simpa using pow_lt_one₀ (by simp) hr (NeZero.ne _)) simp only [div_eq_mul_i...
lemma
NumberTheory
[ "Mathlib.Analysis.SpecificLimits.Normed", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/TsumDivsorsAntidiagonal.lean
tsum_pow_div_one_sub_eq_tsum_sigma
null
noncomputable log : ArithmeticFunction ℝ := ⟨fun n => Real.log n, by simp⟩ @[simp]
def
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
log
`log` as an arithmetic function `ℕ → ℝ`. Note this is in the `ArithmeticFunction` namespace to indicate that it is bundled as an `ArithmeticFunction` rather than being the usual real logarithm.
log_apply {n : ℕ} : log n = Real.log n := rfl
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
log_apply
null
noncomputable vonMangoldt : ArithmeticFunction ℝ := ⟨fun n => if IsPrimePow n then Real.log (minFac n) else 0, if_neg not_isPrimePow_zero⟩ @[inherit_doc] scoped[ArithmeticFunction] notation "Λ" => ArithmeticFunction.vonMangoldt @[inherit_doc] scoped[ArithmeticFunction.vonMangoldt] notation "Λ" => ArithmeticFunction...
def
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt
The `vonMangoldt` function is the function on natural numbers that returns `log p` if the input can be expressed as `p^k` for a prime `p`. In the case when `n` is a prime power, `Nat.minFac` will give the appropriate prime, as it is the smallest prime factor. In the `ArithmeticFunction` locale, we have the notation `Λ...
vonMangoldt_apply {n : ℕ} : Λ n = if IsPrimePow n then Real.log (minFac n) else 0 := rfl @[simp]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_apply
null
vonMangoldt_apply_one : Λ 1 = 0 := by simp [vonMangoldt_apply] @[simp]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_apply_one
null
vonMangoldt_nonneg {n : ℕ} : 0 ≤ Λ n := by rw [vonMangoldt_apply] split_ifs · exact Real.log_nonneg (one_le_cast.2 (Nat.minFac_pos n)) rfl
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_nonneg
null
vonMangoldt_apply_pow {n k : ℕ} (hk : k ≠ 0) : Λ (n ^ k) = Λ n := by simp only [vonMangoldt_apply, isPrimePow_pow_iff hk, pow_minFac hk]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_apply_pow
null
vonMangoldt_apply_prime {p : ℕ} (hp : p.Prime) : Λ p = Real.log p := by rw [vonMangoldt_apply, Prime.minFac_eq hp, if_pos hp.prime.isPrimePow]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_apply_prime
null
vonMangoldt_ne_zero_iff {n : ℕ} : Λ n ≠ 0 ↔ IsPrimePow n := by rcases eq_or_ne n 1 with (rfl | hn); · simp [not_isPrimePow_one] exact (Real.log_pos (one_lt_cast.2 (minFac_prime hn).one_lt)).ne'.ite_ne_right_iff
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_ne_zero_iff
null
vonMangoldt_pos_iff {n : ℕ} : 0 < Λ n ↔ IsPrimePow n := vonMangoldt_nonneg.lt_iff_ne.trans (ne_comm.trans vonMangoldt_ne_zero_iff)
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_pos_iff
null
vonMangoldt_eq_zero_iff {n : ℕ} : Λ n = 0 ↔ ¬IsPrimePow n := vonMangoldt_ne_zero_iff.not_right
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_eq_zero_iff
null
vonMangoldt_sum {n : ℕ} : ∑ i ∈ n.divisors, Λ i = Real.log n := by refine recOnPrimeCoprime ?_ ?_ ?_ n · simp · intro p k hp rw [sum_divisors_prime_pow hp, cast_pow, Real.log_pow, Finset.sum_range_succ', Nat.pow_zero, vonMangoldt_apply_one] simp [vonMangoldt_apply_pow (Nat.succ_ne_zero _), vonMangol...
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_sum
null
vonMangoldt_mul_zeta : Λ * ζ = log := by ext n; rw [coe_mul_zeta_apply, vonMangoldt_sum]; rfl @[simp]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_mul_zeta
null
zeta_mul_vonMangoldt : (ζ : ArithmeticFunction ℝ) * Λ = log := by rw [mul_comm]; simp @[simp]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
zeta_mul_vonMangoldt
null
log_mul_moebius_eq_vonMangoldt : log * μ = Λ := by rw [← vonMangoldt_mul_zeta, mul_assoc, coe_zeta_mul_coe_moebius, mul_one] @[simp]
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
log_mul_moebius_eq_vonMangoldt
null
moebius_mul_log_eq_vonMangoldt : (μ : ArithmeticFunction ℝ) * log = Λ := by rw [mul_comm]; simp
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
moebius_mul_log_eq_vonMangoldt
null
sum_moebius_mul_log_eq {n : ℕ} : (∑ d ∈ n.divisors, (μ d : ℝ) * log d) = -Λ n := by simp only [← log_mul_moebius_eq_vonMangoldt, mul_comm log, mul_apply, log_apply, intCoe_apply, ← Finset.sum_neg_distrib, neg_mul_eq_mul_neg] rw [sum_divisorsAntidiagonal fun i j => (μ i : ℝ) * -Real.log j] have : (∑ i ∈ n.divi...
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
sum_moebius_mul_log_eq
null
vonMangoldt_le_log : ∀ {n : ℕ}, Λ n ≤ Real.log (n : ℝ) | 0 => by simp | n + 1 => by rw [← vonMangoldt_sum] exact single_le_sum (by exact fun _ _ => vonMangoldt_nonneg) (mem_divisors_self _ n.succ_ne_zero)
theorem
NumberTheory
[ "Mathlib.Analysis.SpecialFunctions.Log.Basic", "Mathlib.Data.Nat.Cast.Field", "Mathlib.Data.Nat.Factorization.PrimePow", "Mathlib.NumberTheory.ArithmeticFunction" ]
Mathlib/NumberTheory/VonMangoldt.lean
vonMangoldt_le_log
null
@[to_additive /-- In a seminormed additive group `A`, given `n : ℕ` and `δ : ℝ`, `approxAddOrderOf A n δ` is the set of elements within a distance `δ` of a point of order `n`. -/] approxOrderOf (A : Type*) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A := thickening δ {y | orderOf y = n} @[to_additive mem_approx_add_ord...
def
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
approxOrderOf
In a seminormed group `A`, given `n : ℕ` and `δ : ℝ`, `approxOrderOf A n δ` is the set of elements within a distance `δ` of a point of order `n`.
mem_approxOrderOf_iff {A : Type*} [SeminormedGroup A] {n : ℕ} {δ : ℝ} {a : A} : a ∈ approxOrderOf A n δ ↔ ∃ b : A, orderOf b = n ∧ a ∈ ball b δ := by simp only [approxOrderOf, thickening_eq_biUnion_ball, mem_iUnion₂, mem_setOf_eq, exists_prop]
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
mem_approxOrderOf_iff
null
@[to_additive addWellApproximable /-- In a seminormed additive group `A`, given a sequence of distances `δ₁, δ₂, ...`, `addWellApproximable A δ` is the limsup as `n → ∞` of the sets `approxAddOrderOf A n δₙ`. Thus, it is the set of points that lie in infinitely many of the sets `approxAddOrderOf A n δₙ`. -/] wellApprox...
def
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
wellApproximable
In a seminormed group `A`, given a sequence of distances `δ₁, δ₂, ...`, `wellApproximable A δ` is the limsup as `n → ∞` of the sets `approxOrderOf A n δₙ`. Thus, it is the set of points that lie in infinitely many of the sets `approxOrderOf A n δₙ`.
mem_wellApproximable_iff {A : Type*} [SeminormedGroup A] {δ : ℕ → ℝ} {a : A} : a ∈ wellApproximable A δ ↔ a ∈ blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n := Iff.rfl
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
mem_wellApproximable_iff
null
@[to_additive] image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) : (fun (y : A) => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) := by rintro - ⟨a, ha, rfl⟩ obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha replace hb : b ^ m ∈ {u : A | orderOf u = n} := by rw [← hb] at hmn ⊢; exac...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
image_pow_subset_of_coprime
null
image_pow_subset (n : ℕ) (hm : 0 < m) : (fun (y : A) => y ^ m) '' approxOrderOf A (n * m) δ ⊆ approxOrderOf A n (m * δ) := by rintro - ⟨a, ha, rfl⟩ obtain ⟨b, hb : orderOf b = n * m, hab : a ∈ ball b δ⟩ := mem_approxOrderOf_iff.mp ha replace hb : b ^ m ∈ {y : A | orderOf y = n} := by rw [mem_setOf_eq, ord...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
image_pow_subset
null
smul_subset_of_coprime (han : (orderOf a).Coprime n) : a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ := by simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul, smul_ball'', smul_eq_mul, mem_setOf_eq] refine iUnion₂_subset_iff.mpr fun b hb c hc => ?_ si...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
smul_subset_of_coprime
null
smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) : a • approxOrderOf A n δ = approxOrderOf A n δ := by simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul, smul_ball'', smul_eq_mul, mem_setOf_eq] replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n :=...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
smul_eq_of_mul_dvd
null
mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn : 0 < n) : x ∈ approxAddOrderOf UnitAddCircle n δ ↔ ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ := by simp only [mem_approx_add_orderOf_iff, mem_setOf_eq, ball, dist_eq_norm, AddCircle.addOrderOf_eq_pos_iff hn, mul_one] constructor · rin...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
mem_approxAddOrderOf_iff
null
mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) : x ∈ addWellApproximable UnitAddCircle δ ↔ {n : ℕ | ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ n}.Infinite := by simp only [mem_add_wellApproximable_iff, ← Nat.cofinite_eq_atTop, cofinite.blimsup_set_eq, mem_setOf_eq] refine iff_of_eq (...
theorem
NumberTheory
[ "Mathlib.Dynamics.Ergodic.AddCircle", "Mathlib.MeasureTheory.Covering.LiminfLimsup" ]
Mathlib/NumberTheory/WellApproximable.lean
mem_addWellApproximable_iff
null