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
complEDS'_odd (m : ℕ) : complEDS' b c d k (2 * (m + 1) + 1) = complEDS' b c d k (m + 1) ^ 2 * normEDS b c d ((m + 2) * k + 1) * normEDS b c d ((m + 2) * k - 1) - complEDS' b c d k (m + 2) ^ 2 * normEDS b c d ((m + 1) * k + 1) * normEDS b c d ((m + 1) * k - 1) := by rw [show 2 * (m + 1) + 1...
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS'_odd
null
complEDS (n : ℤ) : R := n.sign * complEDS' b c d k n.natAbs @[simp]
def
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS
The complement sequence `Wᶜ : ℤ × ℤ → R` for a normalised EDS `W : ℤ → R` that witnesses `W(k) ∣ W(n * k)`. In other words, `W(k) * Wᶜ(k, n) = W(n * k)` for any `k, n ∈ ℤ`. This extends `complEDS'` by defining its values at negative integers.
complEDS_ofNat (n : ℕ) : complEDS b c d k n = complEDS' b c d k n := by by_cases hn : n = 0 · simp [hn, complEDS] · simp [complEDS, Int.sign_natCast_of_ne_zero hn] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_ofNat
null
complEDS_zero : complEDS b c d k 0 = 0 := by simp [complEDS] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_zero
null
complEDS_one : complEDS b c d k 1 = 1 := by simp [complEDS] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_one
null
complEDS_neg (n : ℤ) : complEDS b c d k (-n) = -complEDS b c d k n := by simp [complEDS]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_neg
null
complEDS_even (m : ℤ) : complEDS b c d k (2 * m) = complEDS b c d k m * complEDS₂ b c d (m * k) := by induction m using Int.negInduction with | nat m => rcases m with _ | _ · simp norm_cast simpa only [complEDS_ofNat] using complEDS'_even .. | neg ih => simp_rw [mul_neg, complEDS_neg, ih, neg_...
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_even
null
complEDS_odd (m : ℤ) : complEDS b c d k (2 * m + 1) = complEDS b c d k m ^ 2 * normEDS b c d ((m + 1) * k + 1) * normEDS b c d ((m + 1) * k - 1) - complEDS b c d k (m + 1) ^ 2 * normEDS b c d (m * k + 1) * normEDS b c d (m * k - 1) := by induction m using Int.negInduction with | nat m => rcases m with...
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDS_odd
null
@[elab_as_elim] noncomputable complEDSRec' {P : ℕ → Sort u} (zero : P 0) (one : P 1) (even : ∀ m : ℕ, (∀ k < 2 * (m + 1), P k) → P (2 * (m + 1))) (odd : ∀ m : ℕ, (∀ k < 2 * (m + 1) + 1, P k) → P (2 * (m + 1) + 1)) (n : ℕ) : P n := n.evenOddStrongRec (by rintro (_ | _) h; exacts [zero, even _ h]) (by rintr...
def
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDSRec'
Strong recursion principle for the complement sequence for a normalised EDS: if we have * `P 0`, `P 1`, * for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P k` for all `k < 2 * (m + 3)`, and * for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P k` for all `k < 2 * (m + 2) + 1`, then we have `P n` for all `n ...
@[elab_as_elim] noncomputable complEDSRec {P : ℕ → Sort u} (zero : P 0) (one : P 1) (even : ∀ m : ℕ, P (m + 1) → P (2 * (m + 1))) (odd : ∀ m : ℕ, P (m + 1) → P (m + 2) → P (2 * (m + 1) + 1)) (n : ℕ) : P n := complEDSRec' zero one (fun _ ih => even _ <| ih _ <| by linarith only) (fun _ ih => odd _ (ih _ <|...
def
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
complEDSRec
Recursion principle for the complement sequence for a normalised EDS: if we have * `P 0`, `P 1`, * for all `m : ℕ` we can prove `P (2 * (m + 3))` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)`, `P (m + 4)`, and `P (m + 5)`, and * for all `m : ℕ` we can prove `P (2 * (m + 2) + 1)` from `P (m + 1)`, `P (m + 2)`, `P (m + 3)...
@[simp] map_preNormEDS' (n : ℕ) : f (preNormEDS' b c d n) = preNormEDS' (f b) (f c) (f d) n := by induction n using normEDSRec' with | zero => simp | one => simp | two => simp | three => simp | four => simp | _ _ ih => simp only [preNormEDS'_even, preNormEDS'_odd, apply_ite f, map_pow, map_mul, map_su...
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_preNormEDS'
null
map_preNormEDS (n : ℤ) : f (preNormEDS b c d n) = preNormEDS (f b) (f c) (f d) n := by simp [preNormEDS] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_preNormEDS
null
map_complEDS₂ (n : ℤ) : f (complEDS₂ b c d n) = complEDS₂ (f b) (f c) (f d) n := by simp [complEDS₂, apply_ite f] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_complEDS₂
null
map_normEDS (n : ℤ) : f (normEDS b c d n) = normEDS (f b) (f c) (f d) n := by simp [normEDS, apply_ite f] @[simp]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_normEDS
null
map_complEDS' (k : ℤ) (n : ℕ) : f (complEDS' b c d k n) = complEDS' (f b) (f c) (f d) k n := by induction n using complEDSRec' with | zero => simp | one => simp | _ _ ih => simp only [complEDS'_even, complEDS'_odd, map_normEDS, map_complEDS₂, map_pow, map_mul, map_sub] repeat rw [ih _ <| by linarith...
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_complEDS'
null
map_complEDS (k n : ℤ) : f (complEDS b c d k n) = complEDS (f b) (f c) (f d) k n := by simp [complEDS]
lemma
NumberTheory
[ "Mathlib.Data.Nat.EvenOddRec", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.LinearCombination" ]
Mathlib/NumberTheory/EllipticDivisibilitySequence.lean
map_complEDS
null
Abundant (n : ℕ) : Prop := n < ∑ i ∈ properDivisors n, i
def
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Abundant
`n : ℕ` is _abundant_ if the sum of the proper divisors of `n` is greater than `n`.
Deficient (n : ℕ) : Prop := ∑ i ∈ properDivisors n, i < n
def
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Deficient
`n : ℕ` is _deficient_ if the sum of the proper divisors of `n` is less than `n`.
Pseudoperfect (n : ℕ) : Prop := 0 < n ∧ ∃ s ⊆ properDivisors n, ∑ i ∈ s, i = n
def
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Pseudoperfect
A positive natural number `n` is _pseudoperfect_ if there exists a subset of the proper divisors of `n` such that the sum of that subset is equal to `n`.
Weird (n : ℕ) : Prop := Abundant n ∧ ¬ Pseudoperfect n
def
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Weird
`n : ℕ` is a _weird_ number if and only if it is abundant but not pseudoperfect.
not_pseudoperfect_iff_forall : ¬ Pseudoperfect n ↔ n = 0 ∨ ∀ s ⊆ properDivisors n, ∑ i ∈ s, i ≠ n := by rw [Pseudoperfect, not_and_or] simp only [not_lt, nonpos_iff_eq_zero, not_exists, not_and, ne_eq]
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
not_pseudoperfect_iff_forall
null
deficient_one : Deficient 1 := zero_lt_one
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
deficient_one
null
deficient_two : Deficient 2 := one_lt_two
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
deficient_two
null
deficient_three : Deficient 3 := by norm_num [Deficient]
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
deficient_three
null
abundant_twelve : Abundant 12 := by rw [Abundant, show properDivisors 12 = {1,2,3,4,6} by rfl] simp
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
abundant_twelve
null
weird_seventy : Weird 70 := by rw [Weird, Abundant, not_pseudoperfect_iff_forall] have h : properDivisors 70 = {1, 2, 5, 7, 10, 14, 35} := by rfl constructor · rw [h] repeat norm_num · rw [h] right intro s hs have hs' := mem_powerset.mpr hs fin_cases hs' <;> decide
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
weird_seventy
null
deficient_iff_not_abundant_and_not_perfect (hn : n ≠ 0) : Deficient n ↔ ¬ Abundant n ∧ ¬ Perfect n := by dsimp only [Perfect, Abundant, Deficient] cutsat
lemma
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
deficient_iff_not_abundant_and_not_perfect
null
perfect_iff_not_abundant_and_not_deficient (hn : 0 ≠ n) : Perfect n ↔ ¬ Abundant n ∧ ¬ Deficient n := by dsimp only [Perfect, Abundant, Deficient] cutsat
lemma
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
perfect_iff_not_abundant_and_not_deficient
null
abundant_iff_not_perfect_and_not_deficient (hn : 0 ≠ n) : Abundant n ↔ ¬ Perfect n ∧ ¬ Deficient n := by dsimp only [Perfect, Abundant, Deficient] cutsat
lemma
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
abundant_iff_not_perfect_and_not_deficient
null
deficient_or_perfect_or_abundant (hn : 0 ≠ n) : Deficient n ∨ Abundant n ∨ Perfect n := by dsimp only [Perfect, Abundant, Deficient] cutsat
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
deficient_or_perfect_or_abundant
A positive natural number is either deficient, perfect, or abundant
Perfect.pseudoperfect (h : Perfect n) : Pseudoperfect n := ⟨h.2, ⟨properDivisors n, ⟨fun ⦃_⦄ a ↦ a, h.1⟩⟩⟩
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Perfect.pseudoperfect
null
Prime.not_abundant (h : Prime n) : ¬ Abundant n := fun h1 ↦ (h.one_lt.trans h1).ne' (sum_properDivisors_eq_one_iff_prime.mpr h)
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.not_abundant
null
Prime.not_weird (h : Prime n) : ¬ Weird n := by simp only [Nat.Weird, not_and_or] left exact h.not_abundant
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.not_weird
null
Prime.not_pseudoperfect (h : Prime p) : ¬ Pseudoperfect p := by simp_rw [not_pseudoperfect_iff_forall, ← mem_powerset, show p.properDivisors.powerset = {∅, {1}} by rw [Prime.properDivisors h]; rfl] refine Or.inr (fun s hs ↦ ?_) fin_cases hs <;> simp only [sum_empty, sum_singleton] <;> linarith [Prime.one_...
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.not_pseudoperfect
null
Prime.not_perfect (h : Prime p) : ¬ Perfect p := by have h1 := Prime.not_pseudoperfect h revert h1 exact not_imp_not.mpr (Perfect.pseudoperfect)
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.not_perfect
null
Prime.deficient_pow (h : Prime n) : Deficient (n ^ m) := by rcases Nat.eq_zero_or_pos m with (rfl | _) · simpa using deficient_one · have h1 : (n ^ m).properDivisors = image (n ^ ·) (range m) := by apply subset_antisymm <;> intro a · simp only [mem_properDivisors, mem_image, mem_range, dvd_prime_pow h...
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.deficient_pow
Any natural number power of a prime is deficient
_root_.IsPrimePow.deficient (h : IsPrimePow n) : Deficient n := by obtain ⟨p, k, hp, -, rfl⟩ := h exact hp.nat_prime.deficient_pow
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
_root_.IsPrimePow.deficient
null
Prime.deficient (h : Prime n) : Deficient n := by rw [← pow_one n] exact h.deficient_pow
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
Prime.deficient
null
infinite_deficient : {n : ℕ | n.Deficient}.Infinite := by rw [Set.infinite_iff_exists_gt] intro a obtain ⟨b, h1, h2⟩ := exists_infinite_primes a.succ exact ⟨b, h2.deficient, h1⟩
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
infinite_deficient
There exists infinitely many deficient numbers
infinite_even_deficient : {n : ℕ | Even n ∧ n.Deficient}.Infinite := by rw [Set.infinite_iff_exists_gt] intro n use 2 ^ (n + 1) constructor · exact ⟨⟨2 ^ n, by rw [pow_succ, mul_two]⟩, prime_two.deficient_pow⟩ · calc n ≤ 2 ^ n := Nat.le_of_lt n.lt_two_pow_self _ < 2 ^ (n + 1) := (Nat.pow_lt_pow_...
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
infinite_even_deficient
null
infinite_odd_deficient : {n : ℕ | Odd n ∧ n.Deficient}.Infinite := by rw [Set.infinite_iff_exists_gt] intro n obtain ⟨p, ⟨_, h2⟩⟩ := exists_infinite_primes (max (n + 1) 3) exact ⟨p, Set.mem_setOf.mpr ⟨Prime.odd_of_ne_two h2 (Ne.symm (ne_of_lt (by omega))), Prime.deficient h2⟩, by omega⟩
theorem
NumberTheory
[ "Mathlib.Algebra.Ring.GeomSum", "Mathlib.NumberTheory.Divisors", "Mathlib.Tactic.FinCases", "Mathlib.Tactic.Linarith", "Mathlib.Tactic.NormNum.Prime" ]
Mathlib/NumberTheory/FactorisationProperties.lean
infinite_odd_deficient
null
fermatNumber (n : ℕ) : ℕ := 2 ^ (2 ^ n) + 1 @[simp] theorem fermatNumber_zero : fermatNumber 0 = 3 := rfl @[simp] theorem fermatNumber_one : fermatNumber 1 = 5 := rfl @[simp] theorem fermatNumber_two : fermatNumber 2 = 17 := rfl
def
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber
Fermat numbers: the `n`-th Fermat number is defined as `2^(2^n) + 1`.
fermatNumber_strictMono : StrictMono fermatNumber := by intro m n simp only [fermatNumber, add_lt_add_iff_right, Nat.pow_lt_pow_iff_right (one_lt_two : 1 < 2), imp_self]
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_strictMono
null
fermatNumber_mono : Monotone fermatNumber := fermatNumber_strictMono.monotone
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_mono
null
fermatNumber_injective : Injective fermatNumber := fermatNumber_strictMono.injective
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_injective
null
three_le_fermatNumber (n : ℕ) : 3 ≤ fermatNumber n := fermatNumber_mono n.zero_le
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
three_le_fermatNumber
null
two_lt_fermatNumber (n : ℕ) : 2 < fermatNumber n := three_le_fermatNumber _
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
two_lt_fermatNumber
null
fermatNumber_ne_one (n : ℕ) : fermatNumber n ≠ 1 := by have := three_le_fermatNumber n; cutsat
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_ne_one
null
odd_fermatNumber (n : ℕ) : Odd (fermatNumber n) := (even_pow.mpr ⟨even_two, (pow_pos two_pos n).ne'⟩).add_one
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
odd_fermatNumber
null
prod_fermatNumber (n : ℕ) : ∏ k ∈ range n, fermatNumber k = fermatNumber n - 2 := by induction n with | zero => rfl | succ n hn => rw [prod_range_succ, hn, fermatNumber, fermatNumber, mul_comm, (show 2 ^ 2 ^ n + 1 - 2 = 2 ^ 2 ^ n - 1 by cutsat), ← sq_sub_sq] ring_nf cutsat
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
prod_fermatNumber
null
fermatNumber_eq_prod_add_two (n : ℕ) : fermatNumber n = ∏ k ∈ range n, fermatNumber k + 2 := by rw [prod_fermatNumber, Nat.sub_add_cancel] exact le_of_lt <| two_lt_fermatNumber _
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_eq_prod_add_two
null
fermatNumber_succ (n : ℕ) : fermatNumber (n + 1) = (fermatNumber n - 1) ^ 2 + 1 := by rw [fermatNumber, pow_succ, mul_comm, pow_mul', fermatNumber, add_tsub_cancel_right]
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_succ
null
two_mul_fermatNumber_sub_one_sq_le_fermatNumber_sq (n : ℕ) : 2 * (fermatNumber n - 1) ^ 2 ≤ (fermatNumber (n + 1)) ^ 2 := by simp only [fermatNumber, add_tsub_cancel_right] have : 0 ≤ 1 + 2 ^ (2 ^ n * 4) := le_add_left _ _ ring_nf cutsat
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
two_mul_fermatNumber_sub_one_sq_le_fermatNumber_sq
null
fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq (n : ℕ) : fermatNumber (n + 2) = (fermatNumber (n + 1)) ^ 2 - 2 * (fermatNumber n - 1) ^ 2 := by simp only [fermatNumber, add_sub_self_right] rw [← add_sub_self_right (2 ^ 2 ^ (n + 2) + 1) <| 2 * 2 ^ 2 ^ (n + 1)] ring_nf
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq
null
Int.fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq (n : ℕ) : (fermatNumber (n + 2) : ℤ) = (fermatNumber (n + 1)) ^ 2 - 2 * (fermatNumber n - 1) ^ 2 := by rw [Nat.fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq, Nat.cast_sub <| two_mul_fermatNumber_sub_one_sq_le_fermatN...
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
Int.fermatNumber_eq_fermatNumber_sq_sub_two_mul_fermatNumber_sub_one_sq
null
coprime_fermatNumber_fermatNumber {m n : ℕ} (hmn : m ≠ n) : Coprime (fermatNumber m) (fermatNumber n) := by wlog hmn' : m < n · simpa only [coprime_comm] using this hmn.symm (by cutsat) let d := (fermatNumber m).gcd (fermatNumber n) have h_n : d ∣ fermatNumber n := gcd_dvd_right .. have h_m : d ∣ 2 := (Na...
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
coprime_fermatNumber_fermatNumber
**Goldbach's theorem** : no two distinct Fermat numbers share a common factor greater than one. From a letter to Euler, see page 37 in [juskevic2022].
pairwise_coprime_fermatNumber : Pairwise fun m n ↦ Coprime (fermatNumber m) (fermatNumber n) := fun _m _n ↦ coprime_fermatNumber_fermatNumber open ZMod
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
pairwise_coprime_fermatNumber
null
pow_of_pow_add_prime {a n : ℕ} (ha : 1 < a) (hn : n ≠ 0) (hP : (a ^ n + 1).Prime) : ∃ m : ℕ, n = 2 ^ m := by obtain ⟨k, m, hm, rfl⟩ := exists_eq_two_pow_mul_odd hn rw [pow_mul] at hP use k replace ha : 1 < a ^ 2 ^ k := one_lt_pow (pow_ne_zero k two_ne_zero) ha let h := hm.nat_add_dvd_pow_add_pow (a ^ 2 ^ ...
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
pow_of_pow_add_prime
Prime `a ^ n + 1` implies `n` is a power of two (**Fermat primes**).
pepin_primality (n : ℕ) (h : 3 ^ (2 ^ (2 ^ n - 1)) = (-1 : ZMod (fermatNumber n))) : (fermatNumber n).Prime := by have := Fact.mk (two_lt_fermatNumber n) have key : 2 ^ n = 2 ^ n - 1 + 1 := (Nat.sub_add_cancel Nat.one_le_two_pow).symm apply lucas_primality (p := 2 ^ (2 ^ n) + 1) (a := 3) · rw [Nat.add_sub_c...
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
pepin_primality
`Fₙ = 2^(2^n)+1` is prime if `3^(2^(2^n-1)) = -1 mod Fₙ` (**Pépin's test**).
pepin_primality' (n : ℕ) (h : 3 ^ ((fermatNumber n - 1) / 2) = (-1 : ZMod (fermatNumber n))) : (fermatNumber n).Prime := by apply pepin_primality rw [← h] congr rw [fermatNumber, add_tsub_cancel_right, Nat.pow_div Nat.one_le_two_pow Nat.zero_lt_two]
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
pepin_primality'
`Fₙ = 2^(2^n)+1` is prime if `3^((Fₙ - 1)/2) = -1 mod Fₙ` (**Pépin's test**).
pow_pow_add_primeFactors_one_lt {a n p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) (hpdvd : p ∣ a ^ (2 ^ n) + 1) : ∃ k, p = k * 2 ^ (n + 1) + 1 := by have : Fact (2 < p) := Fact.mk (lt_of_le_of_ne hp.two_le hp2.symm) have : Fact p.Prime := Fact.mk hp have ha1 : (a : ZMod p) ^ (2 ^ n) = -1 := by rw [eq_neg_iff_a...
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
pow_pow_add_primeFactors_one_lt
Prime factors of `a ^ (2 ^ n) + 1` are of form `k * 2 ^ (n + 1) + 1`.
fermat_primeFactors_one_lt (n p : ℕ) (hn : 1 < n) (hp : p.Prime) (hpdvd : p ∣ fermatNumber n) : ∃ k, p = k * 2 ^ (n + 2) + 1 := by have : Fact p.Prime := Fact.mk hp have hp2 : p ≠ 2 := by exact ((even_pow.mpr ⟨even_two, pow_ne_zero n two_ne_zero⟩).add_one).ne_two_of_dvd_nat hpdvd have hp8 : p % 8 = 1 ...
lemma
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
fermat_primeFactors_one_lt
null
prime_of_pow_sub_one_prime {a n : ℕ} (hn1 : n ≠ 1) (hP : (a ^ n - 1).Prime) : a = 2 ∧ n.Prime := by have han1 : 1 < a ^ n := tsub_pos_iff_lt.mp hP.pos have hn0 : n ≠ 0 := fun h ↦ (h ▸ han1).ne' rfl have ha1 : 1 < a := (Nat.one_lt_pow_iff hn0).mp han1 have ha0 : 0 < a := one_pos.trans ha1 have ha2 : a = 2 ...
theorem
NumberTheory
[ "Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity", "Mathlib.NumberTheory.LucasPrimality" ]
Mathlib/NumberTheory/Fermat.lean
prime_of_pow_sub_one_prime
Prime `a ^ n - 1` implies `a = 2` and prime `n`.
ProbablePrime (n b : ℕ) : Prop := n ∣ b ^ (n - 1) - 1
def
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
ProbablePrime
`n` is a probable prime to base `b` if `n` passes the Fermat primality test; that is, `n` divides `b ^ (n - 1) - 1`. This definition implies that all numbers are probable primes to base 0 or 1, and that 0 and 1 are probable primes to any base.
FermatPsp (n b : ℕ) : Prop := ProbablePrime n b ∧ ¬n.Prime ∧ 1 < n
def
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
FermatPsp
`n` is a Fermat pseudoprime to base `b` if `n` is a probable prime to base `b` and is composite. By this definition, all composite natural numbers are pseudoprimes to base 0 and 1. This definition also permits `n` to be less than `b`, so that 4 is a pseudoprime to base 5, for example.
decidableProbablePrime (n b : ℕ) : Decidable (ProbablePrime n b) := Nat.decidable_dvd _ _
instance
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
decidableProbablePrime
null
decidablePsp (n b : ℕ) : Decidable (FermatPsp n b) := inferInstanceAs (Decidable (_ ∧ _))
instance
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
decidablePsp
null
coprime_of_probablePrime {n b : ℕ} (h : ProbablePrime n b) (h₁ : 1 ≤ n) (h₂ : 1 ≤ b) : Nat.Coprime n b := by by_cases h₃ : 2 ≤ n · -- To prove that `n` is coprime with `b`, we need to show that for all prime factors of `n`, apply Nat.coprime_of_dvd rintro k hk ⟨m, rfl⟩ ⟨j, rfl⟩ apply Nat.Prime.not_d...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
coprime_of_probablePrime
If `n` passes the Fermat primality test to base `b`, then `n` is coprime with `b`, assuming that `n` and `b` are both positive.
probablePrime_iff_modEq (n : ℕ) {b : ℕ} (h : 1 ≤ b) : ProbablePrime n b ↔ b ^ (n - 1) ≡ 1 [MOD n] := by have : 1 ≤ b ^ (n - 1) := one_le_pow₀ h rw [Nat.ModEq.comm] constructor · intro h₁ apply Nat.modEq_of_dvd exact mod_cast h₁ · intro h₁ exact mod_cast Nat.ModEq.dvd h₁
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
probablePrime_iff_modEq
null
coprime_of_fermatPsp {n b : ℕ} (h : FermatPsp n b) (h₁ : 1 ≤ b) : Nat.Coprime n b := by rcases h with ⟨hp, _, hn₂⟩ exact coprime_of_probablePrime hp (by cutsat) h₁
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
coprime_of_fermatPsp
If `n` is a Fermat pseudoprime to base `b`, then `n` is coprime with `b`, assuming that `b` is positive. This lemma is a small wrapper based on `coprime_of_probablePrime`
fermatPsp_base_one {n : ℕ} (h₁ : 1 < n) (h₂ : ¬n.Prime) : FermatPsp n 1 := by refine ⟨show n ∣ 1 ^ (n - 1) - 1 from ?_, h₂, h₁⟩ exact show 0 = 1 ^ (n - 1) - 1 by simp ▸ dvd_zero n
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
fermatPsp_base_one
All composite numbers are Fermat pseudoprimes to base 1.
private a_id_helper {a b : ℕ} (ha : 2 ≤ a) (hb : 2 ≤ b) : 2 ≤ (a ^ b - 1) / (a - 1) := by change 1 < _ have h₁ : a - 1 ∣ a ^ b - 1 := by simpa only [one_pow] using Nat.sub_dvd_pow_sub_pow a 1 b rw [Nat.lt_div_iff_mul_lt' h₁, mul_one, tsub_lt_tsub_iff_right (Nat.le_of_succ_le ha)] exact lt_self_pow₀ (Nat.lt_of_s...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
a_id_helper
null
private b_id_helper {a b : ℕ} (ha : 2 ≤ a) (hb : 2 < b) : 2 ≤ (a ^ b + 1) / (a + 1) := by rw [Nat.le_div_iff_mul_le (Nat.zero_lt_succ _)] apply Nat.succ_le_succ calc 2 * a + 1 ≤ a ^ 2 * a := by nlinarith _ = a ^ 3 := by rw [Nat.pow_succ a 2] _ ≤ a ^ b := pow_right_mono₀ (Nat.le_of_succ_le ha) hb
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
b_id_helper
null
private AB_id_helper (b p : ℕ) (_ : 2 ≤ b) (hp : Odd p) : (b ^ p - 1) / (b - 1) * ((b ^ p + 1) / (b + 1)) = (b ^ (2 * p) - 1) / (b ^ 2 - 1) := by have q₁ : b - 1 ∣ b ^ p - 1 := by simpa only [one_pow] using Nat.sub_dvd_pow_sub_pow b 1 p have q₂ : b + 1 ∣ b ^ p + 1 := by simpa only [one_pow] using hp.nat_add_dvd...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
AB_id_helper
null
private bp_helper {b p : ℕ} (hb : 0 < b) (hp : 1 ≤ p) : b ^ (2 * p) - 1 - (b ^ 2 - 1) = b * (b ^ (p - 1) - 1) * (b ^ p + b) := have hi_bsquared : 1 ≤ b ^ 2 := Nat.one_le_pow _ _ hb calc b ^ (2 * p) - 1 - (b ^ 2 - 1) = b ^ (2 * p) - (1 + (b ^ 2 - 1)) := by rw [Nat.sub_sub] _ = b ^ (2 * p) - (1 + b ^ 2 - ...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
bp_helper
Used in the proof of `psp_from_prime_psp`
private psp_from_prime (b : ℕ) (p : ℕ) : ℕ := (b ^ p - 1) / (b - 1) * ((b ^ p + 1) / (b + 1))
def
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
psp_from_prime
Given a prime `p` which does not divide `b * (b ^ 2 - 1)`, we can produce a number `n` which is larger than `p` and pseudoprime to base `b`. We do this by defining `n = ((b ^ p - 1) / (b - 1)) * ((b ^ p + 1) / (b + 1))` The primary purpose of this definition is to help prove `exists_infinite_pseudoprimes`. For a proof...
private psp_from_prime_psp {b : ℕ} (b_ge_two : 2 ≤ b) {p : ℕ} (p_prime : p.Prime) (p_gt_two : 2 < p) (not_dvd : ¬p ∣ b * (b ^ 2 - 1)) : FermatPsp (psp_from_prime b p) b := by unfold psp_from_prime set A := (b ^ p - 1) / (b - 1) set B := (b ^ p + 1) / (b + 1) have hi_A : 1 < A := a_id_helper (Nat.succ_le_iff...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
psp_from_prime_psp
This is a proof that the number produced using `psp_from_prime` is actually pseudoprime to base `b`. The primary purpose of this lemma is to help prove `exists_infinite_pseudoprimes`. We use <https://primes.utm.edu/notes/proofs/a_pseudoprimes.html> as a rough outline of the proof.
private psp_from_prime_gt_p {b : ℕ} (b_ge_two : 2 ≤ b) {p : ℕ} (p_prime : p.Prime) (p_gt_two : 2 < p) : p < psp_from_prime b p := by unfold psp_from_prime set A := (b ^ p - 1) / (b - 1) set B := (b ^ p + 1) / (b + 1) rw [show A * B = (b ^ (2 * p) - 1) / (b ^ 2 - 1) from AB_id_helper _ _ b_ge_two (p_pr...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
psp_from_prime_gt_p
This is a proof that the number produced using `psp_from_prime` is greater than the prime `p` used to create it. The primary purpose of this lemma is to help prove `exists_infinite_pseudoprimes`.
exists_infinite_pseudoprimes {b : ℕ} (h : 1 ≤ b) (m : ℕ) : ∃ n : ℕ, FermatPsp n b ∧ m ≤ n := by by_cases b_ge_two : 2 ≤ b · have h := Nat.exists_infinite_primes (b * (b ^ 2 - 1) + 1 + m) obtain ⟨p, ⟨hp₁, hp₂⟩⟩ := h have h₁ : 0 < b := pos_of_gt (Nat.succ_le_iff.mp b_ge_two) have h₂ : 4 ≤ b ^ 2 := pow...
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
exists_infinite_pseudoprimes
For all positive bases, there exist infinite **Fermat pseudoprimes** to that base. Given in this form: for all numbers `b ≥ 1` and `m`, there exists a pseudoprime `n` to base `b` such that `m ≤ n`. This form is similar to `Nat.exists_infinite_primes`.
frequently_atTop_fermatPsp {b : ℕ} (h : 1 ≤ b) : ∃ᶠ n in Filter.atTop, FermatPsp n b := by refine Filter.frequently_atTop.2 fun n => ?_ obtain ⟨p, hp⟩ := exists_infinite_pseudoprimes h n exact ⟨p, hp.2, hp.1⟩
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
frequently_atTop_fermatPsp
null
infinite_setOf_pseudoprimes {b : ℕ} (h : 1 ≤ b) : Set.Infinite { n : ℕ | FermatPsp n b } := Nat.frequently_atTop_iff_infinite.mp (frequently_atTop_fermatPsp h)
theorem
NumberTheory
[ "Mathlib.Algebra.Order.Archimedean.Basic", "Mathlib.FieldTheory.Finite.Basic", "Mathlib.Order.Filter.Cofinite", "Mathlib.Tactic.GCongr" ]
Mathlib/NumberTheory/FermatPsp.lean
infinite_setOf_pseudoprimes
Infinite set variant of `Nat.exists_infinite_pseudoprimes`
FrobeniusNumber (n : ℕ) (s : Set ℕ) : Prop := IsGreatest { k | k ∉ AddSubmonoid.closure s } n
def
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
FrobeniusNumber
A natural number `n` is the **Frobenius number** of a set of natural numbers `s` if it is an upper bound on the complement of the additive submonoid generated by `s`. In other words, it is the largest number that cannot be expressed as a sum of numbers in `s`.
frobeniusNumber_iff {n : ℕ} {s : Set ℕ} : FrobeniusNumber n s ↔ n ∉ AddSubmonoid.closure s ∧ ∀ k > n, k ∈ AddSubmonoid.closure s := by simp_rw [FrobeniusNumber, IsGreatest, upperBounds, Set.mem_setOf, not_imp_comm, not_le] variable {m n : ℕ}
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
frobeniusNumber_iff
null
frobeniusNumber_pair (cop : Coprime m n) (hm : 1 < m) (hn : 1 < n) : FrobeniusNumber (m * n - m - n) {m, n} := by simp_rw [FrobeniusNumber, AddSubmonoid.mem_closure_pair] have hmn : m + n ≤ m * n := add_le_mul hm hn constructor · push_neg intro a b h apply cop.mul_add_mul_ne_mul (add_one_ne_zero a) ...
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
frobeniusNumber_pair
The **Chicken McNugget theorem** stating that the Frobenius number of positive numbers `m` and `n` is `m * n - m - n`.
noncomputable setGcd (s : Set ℕ) : ℕ := (generator <| Ideal.span <| ((↑) : ℕ → ℤ) '' s).natAbs variable {s t : Set ℕ} {n : ℕ}
def
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd
The gcd of a set of natural numbers is defined to be the nonnegative generator of the ideal of `ℤ` generated by them.
setGcd_dvd_of_mem (h : n ∈ s) : setGcd s ∣ n := by rw [setGcd, ← Int.dvd_natCast, ← mem_iff_generator_dvd] exact Ideal.subset_span ⟨n, h, rfl⟩
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd_dvd_of_mem
null
setGcd_dvd_of_mem_closure (h : n ∈ AddSubmonoid.closure s) : setGcd s ∣ n := AddSubmonoid.closure_induction (fun _ ↦ setGcd_dvd_of_mem) (dvd_zero _) (fun _ _ _ _ ↦ dvd_add) h
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd_dvd_of_mem_closure
null
dvd_setGcd_iff : n ∣ setGcd s ↔ ∀ m ∈ s, n ∣ m := by simp_rw [setGcd, ← Int.natCast_dvd, dvd_generator_span_iff, Set.forall_mem_image, Int.natCast_dvd_natCast]
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
dvd_setGcd_iff
The characterizing property of `Nat.setGcd`.
setGcd_mono (h : s ⊆ t) : setGcd t ∣ setGcd s := dvd_setGcd_iff.mpr fun _m hm ↦ setGcd_dvd_of_mem (h hm)
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd_mono
null
dvdNotUnit_setGcd_insert (h : ¬ setGcd s ∣ n) : DvdNotUnit (setGcd (insert n s)) (setGcd s) := dvdNotUnit_of_dvd_of_not_dvd (setGcd_mono <| Set.subset_insert ..) fun dvd ↦ h <| dvd_setGcd_iff.mp dvd _ (Set.mem_insert ..)
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
dvdNotUnit_setGcd_insert
null
setGcd_insert_of_dvd (h : setGcd s ∣ n) : setGcd (insert n s) = setGcd s := (setGcd_mono <| Set.subset_insert ..).antisymm <| dvd_setGcd_iff.mpr fun m ↦ by rintro (rfl | hm); exacts [h, setGcd_dvd_of_mem hm]
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd_insert_of_dvd
null
setGcd_eq_zero_iff : setGcd s = 0 ↔ s ⊆ {0} := by simp_rw [setGcd, Int.natAbs_eq_zero, ← eq_bot_iff_generator_eq_zero, Ideal.span_eq_bot, Set.forall_mem_image, Int.natCast_eq_zero, Set.subset_def, Set.mem_singleton_iff]
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
setGcd_eq_zero_iff
null
exists_ne_zero_of_setGcd_ne_zero (hs : setGcd s ≠ 0) : ∃ n ∈ s, n ≠ 0 := by contrapose! hs exact setGcd_eq_zero_iff.mpr hs variable (s)
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
exists_ne_zero_of_setGcd_ne_zero
null
span_singleton_setGcd : Ideal.span {(setGcd s : ℤ)} = Ideal.span (((↑) : ℕ → ℤ) '' s) := by rw [setGcd, ← Ideal.span_singleton_eq_span_singleton.mpr (Int.associated_natAbs _), Ideal.span, span_singleton_generator]
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
span_singleton_setGcd
null
subset_span_setGcd : s ⊆ Ideal.span {setGcd s} := fun _x hx ↦ Ideal.mem_span_singleton.mpr (setGcd_dvd_of_mem hx) open Ideal in
lemma
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
subset_span_setGcd
null
exists_mem_span_nat_finset_of_ge : ∃ (t : Finset ℕ) (n : ℕ), ↑t ⊆ s ∧ ∀ m ≥ n, setGcd s ∣ m → m ∈ Ideal.span t := by by_cases h0 : setGcd s = 0 · refine ⟨∅, 0, by simp, fun _ _ dvd ↦ by cases zero_dvd_iff.mp (h0 ▸ dvd); exact zero_mem _⟩ have ⟨t, hts, a, eq⟩ := (Submodule.mem_span_image_iff_exists_fun _).mp ...
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
exists_mem_span_nat_finset_of_ge
null
exists_mem_closure_of_ge : ∃ n, ∀ m ≥ n, setGcd s ∣ m → m ∈ AddSubmonoid.closure s := have ⟨_t, n, hts, hn⟩ := exists_mem_span_nat_finset_of_ge s ⟨n, fun m ge dvd ↦ (Submodule.span_nat_eq_addSubmonoidClosure s).le (Submodule.span_mono hts (hn m ge dvd))⟩
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
exists_mem_closure_of_ge
null
finite_setOf_setGcd_dvd_and_mem_span : {n | setGcd s ∣ n ∧ n ∉ Ideal.span s}.Finite := have ⟨n, hn⟩ := exists_mem_closure_of_ge s (Finset.range n).finite_toSet.subset fun m h ↦ Finset.mem_range.mpr <| lt_of_not_ge fun ge ↦ h.2 <| (Submodule.span_nat_eq_addSubmonoidClosure s).ge (hn m ge h.1)
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
finite_setOf_setGcd_dvd_and_mem_span
null
exists_frobeniusNumber_iff {s : Set ℕ} : (∃ n, FrobeniusNumber n s) ↔ setGcd s = 1 ∧ 1 ∉ s where mp := fun ⟨n, hn⟩ ↦ by rw [frobeniusNumber_iff] at hn exact ⟨dvd_one.mp <| Nat.dvd_add_iff_right (setGcd_dvd_of_mem_closure (hn.2 (n + 1) (by omega))) (n := 1) |>.mpr (setGcd_dvd_of_mem_closure (hn.2 (n ...
theorem
NumberTheory
[ "Mathlib.RingTheory.Ideal.NatInt" ]
Mathlib/NumberTheory/FrobeniusNumber.lean
exists_frobeniusNumber_iff
`ℕ` is a Noetherian `ℕ`-module, i.e., `ℕ` is a Noetherian semiring. -/ instance : IsNoetherian ℕ ℕ where noetherian s := by have ⟨t, n, hts, hn⟩ := exists_mem_span_nat_finset_of_ge s classical refine ⟨t ∪ {m ∈ Finset.range n | m ∈ s}, (Submodule.span_le.mpr ?_).antisymm fun m hm ↦ ?_⟩ · simpa using ⟨h...
FunctionField [Algebra (RatFunc Fq) F] : Prop := FiniteDimensional (RatFunc Fq) F
abbrev
NumberTheory
[ "Mathlib.FieldTheory.RatFunc.Degree", "Mathlib.RingTheory.DedekindDomain.IntegralClosure", "Mathlib.RingTheory.IntegralClosure.IntegrallyClosed", "Mathlib.Topology.Algebra.Valued.ValuedField" ]
Mathlib/NumberTheory/FunctionField.lean
FunctionField
`F` is a function field over the finite field `Fq` if it is a finite extension of the field of rational functions in one variable over `Fq`. Note that `F` can be a function field over multiple, non-isomorphic, `Fq`.