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 ⌀ |
|---|---|---|---|---|---|---|
functionField_iff (Fqt : Type*) [Field Fqt] [Algebra Fq[X] Fqt]
[IsFractionRing Fq[X] Fqt] [Algebra (RatFunc Fq) F] [Algebra Fqt F] [Algebra Fq[X] F]
[IsScalarTower Fq[X] Fqt F] [IsScalarTower Fq[X] (RatFunc Fq) F] :
FunctionField Fq F ↔ FiniteDimensional Fqt F := by
let e := IsLocalization.algEquiv Fq[X]... | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | functionField_iff | `F` is a function field over `Fq` iff it is a finite extension of `Fq(t)`. |
algebraMap_injective [Algebra Fq[X] F] [Algebra (RatFunc Fq) F]
[IsScalarTower Fq[X] (RatFunc Fq) F] : Function.Injective (⇑(algebraMap Fq[X] F)) := by
rw [IsScalarTower.algebraMap_eq Fq[X] (RatFunc Fq) F]
exact (algebraMap (RatFunc Fq) F).injective.comp (IsFractionRing.injective Fq[X] (RatFunc Fq))
@[deprecate... | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | algebraMap_injective | null |
ringOfIntegers [Algebra Fq[X] F] :=
integralClosure Fq[X] F | def | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | ringOfIntegers | The function field analogue of `NumberField.ringOfIntegers`:
`FunctionField.ringOfIntegers Fq Fqt F` is the integral closure of `Fq[t]` in `F`.
We don't actually assume `F` is a function field over `Fq` in the definition,
only when proving its properties. |
algebraMap_injective : Function.Injective (⇑(algebraMap Fq[X] (ringOfIntegers Fq F))) := by
have hinj : Function.Injective (⇑(algebraMap Fq[X] F)) := by
rw [IsScalarTower.algebraMap_eq Fq[X] (RatFunc Fq) F]
exact (algebraMap (RatFunc Fq) F).injective.comp (IsFractionRing.injective Fq[X] (RatFunc Fq))
rw [in... | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | algebraMap_injective | null |
not_isField : ¬IsField (ringOfIntegers Fq F) := by
simpa [← (IsIntegralClosure.isIntegral_algebra Fq[X] F).isField_iff_isField
(algebraMap_injective Fq F)] using
Polynomial.not_isField Fq
variable [FunctionField Fq F] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | not_isField | null |
inftyValuationDef (r : RatFunc Fq) : ℤᵐ⁰ :=
if r = 0 then 0 else exp r.intDegree | def | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuationDef | The valuation at infinity is the nonarchimedean valuation on `Fq(t)` with uniformizer `1/t`.
Explicitly, if `f/g ∈ Fq(t)` is a nonzero quotient of polynomials, its valuation at infinity is
`exp (degree(f) - degree(g))`. |
InftyValuation.map_zero' : inftyValuationDef Fq 0 = 0 :=
if_pos rfl | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | InftyValuation.map_zero' | null |
InftyValuation.map_one' : inftyValuationDef Fq 1 = 1 :=
(if_neg one_ne_zero).trans <| by simp | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | InftyValuation.map_one' | null |
InftyValuation.map_mul' (x y : RatFunc Fq) :
inftyValuationDef Fq (x * y) = inftyValuationDef Fq x * inftyValuationDef Fq y := by
rw [inftyValuationDef, inftyValuationDef, inftyValuationDef]
by_cases hx : x = 0
· rw [hx, zero_mul, if_pos (Eq.refl _), zero_mul]
· by_cases hy : y = 0
· rw [hy, mul_zero, i... | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | InftyValuation.map_mul' | null |
InftyValuation.map_add_le_max' (x y : RatFunc Fq) :
inftyValuationDef Fq (x + y) ≤ max (inftyValuationDef Fq x) (inftyValuationDef Fq y) := by
by_cases hx : x = 0
· rw [hx, zero_add]
conv_rhs => rw [inftyValuationDef, if_pos (Eq.refl _)]
rw [max_eq_right (WithZero.zero_le (inftyValuationDef Fq y))]
· ... | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | InftyValuation.map_add_le_max' | null |
inftyValuation_of_nonzero {x : RatFunc Fq} (hx : x ≠ 0) :
inftyValuationDef Fq x = exp x.intDegree := by
rw [inftyValuationDef, if_neg hx] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation_of_nonzero | null |
inftyValuation : Valuation (RatFunc Fq) ℤᵐ⁰ where
toFun := inftyValuationDef Fq
map_zero' := InftyValuation.map_zero' Fq
map_one' := InftyValuation.map_one' Fq
map_mul' := InftyValuation.map_mul' Fq
map_add_le_max' := InftyValuation.map_add_le_max' Fq | def | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation | The valuation at infinity on `Fq(t)`. |
inftyValuation_apply {x : RatFunc Fq} : inftyValuation Fq x = inftyValuationDef Fq x :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation_apply | null |
inftyValuation.C {k : Fq} (hk : k ≠ 0) :
inftyValuation Fq (RatFunc.C k) = 1 := by
simp [inftyValuation_apply, hk]
@[simp] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation.C | null |
inftyValuation.X : inftyValuation Fq RatFunc.X = exp 1 := by
simp [inftyValuation_apply, inftyValuationDef, if_neg RatFunc.X_ne_zero, RatFunc.intDegree_X] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation.X | null |
inftyValuation.X_zpow (m : ℤ) : inftyValuation Fq (RatFunc.X ^ m) = exp m := by simp | lemma | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation.X_zpow | null |
inftyValuation.X_inv : inftyValuation Fq (1 / RatFunc.X) = exp (-1) := by
rw [one_div, ← zpow_neg_one, inftyValuation.X_zpow] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation.X_inv | null |
inftyValuation.polynomial {p : Fq[X]} (hp : p ≠ 0) :
inftyValuationDef Fq (algebraMap Fq[X] (RatFunc Fq) p) = exp (p.natDegree : ℤ) := by
have hp' : algebraMap Fq[X] (RatFunc Fq) p ≠ 0 := by simpa
rw [inftyValuationDef, if_neg hp', RatFunc.intDegree_polynomial] | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuation.polynomial | null |
inftyValuedFqt : Valued (RatFunc Fq) ℤᵐ⁰ :=
Valued.mk' <| inftyValuation Fq | def | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuedFqt | The valued field `Fq(t)` with the valuation at infinity. |
inftyValuedFqt.def {x : RatFunc Fq} :
(inftyValuedFqt Fq).v x = inftyValuationDef Fq x :=
rfl | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | inftyValuedFqt.def | null |
FqtInfty :=
@UniformSpace.Completion (RatFunc Fq) <| (inftyValuedFqt Fq).toUniformSpace | def | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | FqtInfty | The completion `Fq((t⁻¹))` of `Fq(t)` with respect to the valuation at infinity. |
valuedFqtInfty : Valued (FqtInfty Fq) ℤᵐ⁰ := (inftyValuedFqt Fq).valuedCompletion | instance | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | valuedFqtInfty | The valuation at infinity on `k(t)` extends to a valuation on `FqtInfty`. |
valuedFqtInfty.def {x : FqtInfty Fq} : Valued.v x = (inftyValuedFqt Fq).extension x := rfl | theorem | NumberTheory | [
"Mathlib.FieldTheory.RatFunc.Degree",
"Mathlib.RingTheory.DedekindDomain.IntegralClosure",
"Mathlib.RingTheory.IntegralClosure.IntegrallyClosed",
"Mathlib.Topology.Algebra.Valued.ValuedField"
] | Mathlib/NumberTheory/FunctionField.lean | valuedFqtInfty.def | null |
gaussSum (χ : MulChar R R') (ψ : AddChar R R') : R' :=
∑ a, χ a * ψ a | def | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum | Definition of the Gauss sum associated to a multiplicative and an additive character. |
gaussSum_mulShift (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) :
χ a * gaussSum χ (mulShift ψ a) = gaussSum χ ψ := by
simp only [gaussSum, mulShift_apply, Finset.mul_sum]
simp_rw [← mul_assoc, ← map_mul]
exact Fintype.sum_bijective _ a.mulLeft_bijective _ _ fun x ↦ rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_mulShift | Replacing `ψ` by `mulShift ψ a` and multiplying the Gauss sum by `χ a` does not change it. |
gaussSum_mul {R : Type u} [CommRing R] [Fintype R] {R' : Type v} [CommRing R']
(χ φ : MulChar R R') (ψ : AddChar R R') :
gaussSum χ ψ * gaussSum φ ψ = ∑ t : R, ∑ x : R, χ x * φ (t - x) * ψ t := by
rw [gaussSum, gaussSum, sum_mul_sum]
conv => enter [1, 2, x, 2, x_1]; rw [mul_mul_mul_comm]
simp only [← ψ.ma... | lemma | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_mul | A formula for the product of two Gauss sums with the same additive character. |
mul_gaussSum_inv_eq_gaussSum (χ : MulChar R R') (ψ : AddChar R R') :
χ (-1) * gaussSum χ ψ⁻¹ = gaussSum χ ψ := by
rw [ψ.inv_mulShift, ← Units.coe_neg_one]
exact gaussSum_mulShift χ ψ (-1)
variable [IsDomain R'] -- From now on, `R'` needs to be a domain. | lemma | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | mul_gaussSum_inv_eq_gaussSum | null |
private gaussSum_mul_aux {χ : MulChar R R'} (hχ : χ ≠ 1) (ψ : AddChar R R')
(b : R) :
∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
rcases eq_or_ne b 0 with hb | hb
· -- case `b = 0`
simp only [hb, inv_zero, mul_zero, MulChar.map_zero, zero_mul,
Finset.sum_const_zero, map_zero_eq... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_mul_aux | null |
gaussSum_mul_gaussSum_eq_card {χ : MulChar R R'} (hχ : χ ≠ 1) {ψ : AddChar R R'}
(hψ : IsPrimitive ψ) :
gaussSum χ ψ * gaussSum χ⁻¹ ψ⁻¹ = Fintype.card R := by
simp only [gaussSum, AddChar.inv_apply, Finset.sum_mul, Finset.mul_sum, MulChar.inv_apply']
conv =>
enter [1, 2, x, 2, y]
rw [mul_mul_mul_com... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_mul_gaussSum_eq_card | We have `gaussSum χ ψ * gaussSum χ⁻¹ ψ⁻¹ = Fintype.card R`
when `χ` is nontrivial and `ψ` is primitive (and `R` is a field). |
gaussSum_mul_gaussSum_pow_orderOf_sub_one {χ : MulChar R R'} {ψ : AddChar R R'}
(hχ : χ ≠ 1) (hψ : ψ.IsPrimitive) :
gaussSum χ ψ * gaussSum (χ ^ (orderOf χ - 1)) ψ = χ (-1) * Fintype.card R := by
have h : χ ^ (orderOf χ - 1) = χ⁻¹ := by
refine (inv_eq_of_mul_eq_one_right ?_).symm
rw [← pow_succ', Nat.... | lemma | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_mul_gaussSum_pow_orderOf_sub_one | If `χ` is a multiplicative character of order `n` on a finite field `F`,
then `g(χ) * g(χ^(n-1)) = χ(-1)*#F` |
gaussSum_ne_zero_of_nontrivial (h : (Fintype.card R : R') ≠ 0) {χ : MulChar R R'}
(hχ : χ ≠ 1) {ψ : AddChar R R'} (hψ : ψ.IsPrimitive) :
gaussSum χ ψ ≠ 0 :=
fun H ↦ h.symm <| zero_mul (gaussSum χ⁻¹ _) ▸ H ▸ gaussSum_mul_gaussSum_eq_card hχ hψ | lemma | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_ne_zero_of_nontrivial | The Gauss sum of a nontrivial character on a finite field does not vanish. |
gaussSum_sq {χ : MulChar R R'} (hχ₁ : χ ≠ 1) (hχ₂ : IsQuadratic χ)
{ψ : AddChar R R'} (hψ : IsPrimitive ψ) :
gaussSum χ ψ ^ 2 = χ (-1) * Fintype.card R := by
rw [pow_two, ← gaussSum_mul_gaussSum_eq_card hχ₁ hψ, hχ₂.inv, mul_rotate']
congr
rw [mul_comm, ← gaussSum_mulShift _ _ (-1 : Rˣ), inv_mulShift]
rf... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_sq | When `χ` is a nontrivial quadratic character, then the square of `gaussSum χ ψ`
is `χ(-1)` times the cardinality of `R`. |
gaussSum_frob (χ : MulChar R R') (ψ : AddChar R R') :
gaussSum χ ψ ^ p = gaussSum (χ ^ p) (ψ ^ p) := by
rw [← frobenius_def, gaussSum, gaussSum, map_sum]
simp_rw [pow_apply' χ fp.1.ne_zero, map_mul, frobenius_def]
rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | gaussSum_frob | When `R'` has prime characteristic `p`, then the `p`th power of the Gauss sum
of `χ` and `ψ` is the Gauss sum of `χ^p` and `ψ^p`. |
MulChar.IsQuadratic.gaussSum_frob (hp : IsUnit (p : R)) {χ : MulChar R R'}
(hχ : IsQuadratic χ) (ψ : AddChar R R') :
gaussSum χ ψ ^ p = χ p * gaussSum χ ψ := by
rw [_root_.gaussSum_frob, pow_mulShift, hχ.pow_char p, ← gaussSum_mulShift χ ψ hp.unit,
← mul_assoc, hp.unit_spec, ← pow_two, ← pow_apply' _ two_... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | MulChar.IsQuadratic.gaussSum_frob | For a quadratic character `χ` and when the characteristic `p` of the target ring
is a unit in the source ring, the `p`th power of the Gauss sum of`χ` and `ψ` is
`χ p` times the original Gauss sum. |
MulChar.IsQuadratic.gaussSum_frob_iter (n : ℕ) (hp : IsUnit (p : R)) {χ : MulChar R R'}
(hχ : IsQuadratic χ) (ψ : AddChar R R') :
gaussSum χ ψ ^ p ^ n = χ ((p : R) ^ n) * gaussSum χ ψ := by
induction n with
| zero => rw [pow_zero, pow_one, pow_zero, MulChar.map_one, one_mul]
| succ n ih =>
rw [pow_suc... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | MulChar.IsQuadratic.gaussSum_frob_iter | For a quadratic character `χ` and when the characteristic `p` of the target ring
is a unit in the source ring and `n` is a natural number, the `p^n`th power of the Gauss
sum of`χ` and `ψ` is `χ (p^n)` times the original Gauss sum. |
Char.card_pow_char_pow {χ : MulChar R R'} (hχ : IsQuadratic χ) (ψ : AddChar R R') (p n : ℕ)
[fp : Fact p.Prime] [hch : CharP R' p] (hp : IsUnit (p : R)) (hp' : p ≠ 2)
(hg : gaussSum χ ψ ^ 2 = χ (-1) * Fintype.card R) :
(χ (-1) * Fintype.card R) ^ (p ^ n / 2) = χ ((p : R) ^ n) := by
have : gaussSum χ ψ ≠ 0... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | Char.card_pow_char_pow | If the square of the Gauss sum of a quadratic character is `χ(-1) * #R`,
then we get, for all `n : ℕ`, the relation `(χ(-1) * #R) ^ (p^n/2) = χ(p^n)`,
where `p` is the (odd) characteristic of the target ring `R'`.
This version can be used when `R` is not a field, e.g., `ℤ/8ℤ`. |
Char.card_pow_card {F : Type*} [Field F] [Fintype F] {F' : Type*} [Field F'] [Fintype F']
{χ : MulChar F F'} (hχ₁ : χ ≠ 1) (hχ₂ : IsQuadratic χ)
(hch₁ : ringChar F' ≠ ringChar F) (hch₂ : ringChar F' ≠ 2) :
(χ (-1) * Fintype.card F) ^ (Fintype.card F' / 2) = χ (Fintype.card F') := by
obtain ⟨n, hp, hc⟩ := ... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | Char.card_pow_card | When `F` and `F'` are finite fields and `χ : F → F'` is a nontrivial quadratic character,
then `(χ(-1) * #F)^(#F'/2) = χ #F'`. |
FiniteField.two_pow_card {F : Type*} [Fintype F] [Field F] (hF : ringChar F ≠ 2) :
(2 : F) ^ (Fintype.card F / 2) = χ₈ (Fintype.card F) := by
have hp2 (n : ℕ) : (2 ^ n : F) ≠ 0 := pow_ne_zero n (Ring.two_ne_zero hF)
obtain ⟨n, hp, hc⟩ := FiniteField.card F (ringChar F)
let FF := CyclotomicField 8 F
have hch... | theorem | NumberTheory | [
"Mathlib.NumberTheory.LegendreSymbol.AddCharacter",
"Mathlib.NumberTheory.LegendreSymbol.ZModChar",
"Mathlib.Algebra.CharP.CharAndCard"
] | Mathlib/NumberTheory/GaussSum.lean | FiniteField.two_pow_card | For every finite field `F` of odd characteristic, we have `2^(#F/2) = χ₈ #F` in `F`. |
noncomputable quotMapEquivQuotQuotMap (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)
(hx' : IsIntegral R x) :
S ⧸ I.map (algebraMap R S) ≃+* (R ⧸ I)[X] ⧸ span {(minpoly R x).map (Ideal.Quotient.mk I)} :=
(quotAdjoinEquivQuotMap hx (FaithfulSMul.algebraMap_injective
(Algebra.adjoin R {x}) S)).symm.t... | def | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | quotMapEquivQuotQuotMap | The isomorphism of rings between `S / I` and `(R / I)[X] / minpoly x` when `I`
and `(conductor R x) ∩ R` are coprime. |
quotMapEquivQuotQuotMap_symm_apply (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)
(hx' : IsIntegral R x) (Q : R[X]) :
(quotMapEquivQuotQuotMap hx hx').symm (Q.map (Ideal.Quotient.mk I)) = Q.aeval x := by
apply (quotMapEquivQuotQuotMap hx hx').injective
rw [quotMapEquivQuotQuotMap, AlgEquiv.toRingEqui... | lemma | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | quotMapEquivQuotQuotMap_symm_apply | null |
noncomputable normalizedFactorsMapEquivNormalizedFactorsMinPolyMk (hI : IsMaximal I)
(hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :
{J : Ideal S | J ∈ normalizedFactors (I.map (algebraMap R S))} ≃
{d : (R ⧸ I)[X] |
d ∈ normalizedFactors (Polynomial.map... | def | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | normalizedFactorsMapEquivNormalizedFactorsMinPolyMk | The first half of the **Kummer-Dedekind Theorem**, stating that the prime
factors of `I*S` are in bijection with those of the minimal polynomial of the generator of `S`
over `R`, taken `mod I`. |
emultiplicity_factors_map_eq_emultiplicity
(hI : IsMaximal I) (hI' : I ≠ ⊥)
(hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) {J : Ideal S}
(hJ : J ∈ normalizedFactors (I.map (algebraMap R S))) :
emultiplicity J (I.map (algebraMap R S)) =
emultiplicity (↑(normalizedFacto... | theorem | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | emultiplicity_factors_map_eq_emultiplicity | The second half of the **Kummer-Dedekind Theorem**, stating that the
bijection `FactorsEquiv'` defined in the first half preserves multiplicities. |
normalizedFactors_ideal_map_eq_normalizedFactors_min_poly_mk_map (hI : IsMaximal I)
(hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :
normalizedFactors (I.map (algebraMap R S)) =
Multiset.map
(fun f =>
((normalizedFactorsMapEquivNormalizedFactor... | theorem | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | normalizedFactors_ideal_map_eq_normalizedFactors_min_poly_mk_map | The **Kummer-Dedekind Theorem**. |
Ideal.irreducible_map_of_irreducible_minpoly (hI : IsMaximal I) (hI' : I ≠ ⊥)
(hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x)
(hf : Irreducible (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))) :
Irreducible (I.map (algebraMap R S)) := by
classical
have mem_norm_factors ... | theorem | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | Ideal.irreducible_map_of_irreducible_minpoly | null |
normalizedFactorsMapEquivNormalizedFactorsMinPolyMk_symm_apply_eq_span
(hI : I.IsMaximal) {Q : R[X]}
(hQ : Q.map (Ideal.Quotient.mk I) ∈ normalizedFactors ((minpoly R x).map (Ideal.Quotient.mk I)))
(hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :
((normalizedF... | theorem | NumberTheory | [
"Mathlib.RingTheory.Conductor",
"Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas",
"Mathlib.RingTheory.IsAdjoinRoot"
] | Mathlib/NumberTheory/KummerDedekind.lean | normalizedFactorsMapEquivNormalizedFactorsMinPolyMk_symm_apply_eq_span | Let `Q` be a lift of factor of the minimal polynomial of `x`, a generator of `S` over `R`, taken
`mod I`. Then (the reduction of) `Q` corresponds via
`normalizedFactorsMapEquivNormalizedFactorsMinPolyMk` to
`span (I.map (algebraMap R S) ∪ {Q.aeval x})`. |
mersenne (p : ℕ) : ℕ :=
2 ^ p - 1 | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne | The Mersenne numbers, 2^p - 1. |
strictMono_mersenne : StrictMono mersenne := fun m n h ↦
(Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | strictMono_mersenne | null |
mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q :=
strictMono_mersenne.lt_iff_lt
@[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_lt_mersenne | null |
mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q :=
strictMono_mersenne.le_iff_le
@[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne
@[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl
@[simp] lemma mersenne_odd : ∀ {p : ℕ}, Odd (mersenne p) ↔ p ≠ 0
| 0 => by simp
... | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_le_mersenne | null |
mersenne_succ (n : ℕ) : mersenne (n + 1) = 2 * mersenne n + 1 := by
dsimp [mersenne]
have := Nat.one_le_pow n 2 two_pos
cutsat | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_succ | null |
Nat.Prime.of_mersenne {p : ℕ} (h : (mersenne p).Prime) : Nat.Prime p := by
apply Nat.prime_of_pow_sub_one_prime _ h |>.2
rintro rfl
apply Nat.not_prime_one h | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | Nat.Prime.of_mersenne | If `2 ^ p - 1` is prime, then `p` is prime. |
@[positivity mersenne _]
evalMersenne : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℕ), ~q(mersenne $a) =>
let ra ← core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa => pure (.positive q(mersenne_pos_of_pos $pa))
| _ => pur... | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | evalMersenne | Extension for the `positivity` tactic: `mersenne`. |
@[simp]
one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p :=
mersenne_lt_mersenne (p := 1)
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | one_lt_mersenne | null |
succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by
rw [mersenne, tsub_add_cancel_of_le]
exact one_le_pow₀ (by simp) | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | succ_mersenne | null |
mersenne_mod_four {n : ℕ} (h : 2 ≤ n) : mersenne n % 4 = 3 := by
induction n, h using Nat.le_induction with
| base => rfl
| succ _ _ _ => rw [mersenne_succ]; cutsat | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_mod_four | null |
mersenne_mod_three {n : ℕ} (odd : Odd n) (h : 3 ≤ n) : mersenne n % 3 = 1 := by
obtain ⟨k, rfl⟩ := odd
replace h : 1 ≤ k := by omega
induction k, h using Nat.le_induction with
| base => rfl
| succ j _ _ =>
rw [mersenne_succ, show 2 * (j + 1) = 2 * j + 1 + 1 by cutsat, mersenne_succ]
cutsat | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_mod_three | null |
mersenne_mod_eight {n : ℕ} (h : 3 ≤ n) : mersenne n % 8 = 7 := by
induction n, h using Nat.le_induction with
| base => rfl
| succ _ _ _ => rw [mersenne_succ]; cutsat | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_mod_eight | null |
legendreSym_mersenne_two {p : ℕ} [Fact (mersenne p).Prime] (hp : 3 ≤ p) :
legendreSym (mersenne p) 2 = 1 := by
have := mersenne_mod_eight hp
rw [legendreSym.at_two (by cutsat), ZMod.χ₈_nat_eq_if_mod_eight]
cutsat | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | legendreSym_mersenne_two | If `2^p - 1` is prime then 2 is a square mod `2^p - 1`. |
legendreSym_mersenne_three {p : ℕ} [Fact (mersenne p).Prime] (hp : 3 ≤ p) (odd : Odd p) :
legendreSym (mersenne p) 3 = -1 := by
rw [(by rfl : (3 : ℤ) = (3 : ℕ)), legendreSym.quadratic_reciprocity_three_mod_four (by norm_num)
(mersenne_mod_four (by cutsat)),
legendreSym.mod]
rw_mod_cast [mersenne_mod_thr... | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | legendreSym_mersenne_three | If `2^p - 1` is prime then 3 is not a square mod `2^p - 1`. |
s : ℕ → ℤ
| 0 => 4
| i + 1 => s i ^ 2 - 2 | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | s | The recurrence `s (i+1) = (s i)^2 - 2` in `ℤ`. |
sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1)
| 0 => 4
| i + 1 => sZMod p i ^ 2 - 2 | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sZMod | The recurrence `s (i+1) = (s i)^2 - 2` in `ZMod (2^p - 1)`. |
sMod (p : ℕ) : ℕ → ℤ
| 0 => 4 % (2 ^ p - 1)
| i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sMod | The recurrence `s (i+1) = ((s i)^2 - 2) % (2^p - 1)` in `ℤ`. |
mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 :=
sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_int_pos | null |
mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 :=
(mersenne_int_pos hp).ne' | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mersenne_int_ne_zero | null |
sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by
cases i <;> dsimp [sMod]
· exact sup_eq_right.mp rfl
· apply Int.emod_nonneg
exact mersenne_int_ne_zero p hp | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sMod_nonneg | null |
sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sMod_mod | null |
sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by
rw [← sMod_mod]
refine (Int.emod_lt_abs _ (mersenne_int_ne_zero p hp)).trans_eq ?_
exact abs_of_nonneg (mersenne_int_pos hp).le | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sMod_lt | null |
sZMod_eq_s (p' : ℕ) (i : ℕ) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by
induction i with
| zero => dsimp [s, sZMod]; simp
| succ i ih => push_cast [s, sZMod, ih]; rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sZMod_eq_s | null |
Int.natCast_pow_pred (b p : ℕ) (w : 0 < b) : ((b ^ p - 1 : ℕ) : ℤ) = (b : ℤ) ^ p - 1 := by
have : 1 ≤ b ^ p := Nat.one_le_pow p b w
norm_cast | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | Int.natCast_pow_pred | null |
Int.coe_nat_two_pow_pred (p : ℕ) : ((2 ^ p - 1 : ℕ) : ℤ) = (2 ^ p - 1 : ℤ) :=
Int.natCast_pow_pred 2 p (by decide) | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | Int.coe_nat_two_pow_pred | null |
sZMod_eq_sMod (p : ℕ) (i : ℕ) : sZMod p i = (sMod p i : ZMod (2 ^ p - 1)) := by
induction i <;> push_cast [← Int.coe_nat_two_pow_pred p, sMod, sZMod, *] <;> rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | sZMod_eq_sMod | null |
lucasLehmerResidue (p : ℕ) : ZMod (2 ^ p - 1) :=
sZMod p (p - 2) | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | lucasLehmerResidue | The Lucas-Lehmer residue is `s p (p-2)` in `ZMod (2^p - 1)`. |
residue_eq_zero_iff_sMod_eq_zero (p : ℕ) (w : 1 < p) :
lucasLehmerResidue p = 0 ↔ sMod p (p - 2) = 0 := by
dsimp [lucasLehmerResidue]
rw [sZMod_eq_sMod p]
constructor
· -- We want to use that fact that `0 ≤ s_mod p (p-2) < 2^p - 1`
intro h
apply Int.eq_zero_of_dvd_of_nonneg_of_lt _ _
(by simpa... | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | residue_eq_zero_iff_sMod_eq_zero | null |
LucasLehmerTest (p : ℕ) : Prop :=
lucasLehmerResidue p = 0 | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | LucasLehmerTest | **Lucas-Lehmer Test**: a Mersenne number `2^p-1` is prime if and only if
the Lucas-Lehmer residue `s p (p-2) % (2^p - 1)` is zero. |
q (p : ℕ) : ℕ+ :=
⟨Nat.minFac (mersenne p), Nat.minFac_pos (mersenne p)⟩ | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | q | `q` is defined as the minimum factor of `mersenne p`, bundled as an `ℕ+`. |
X (q : ℕ) : Type :=
ZMod q × ZMod q | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | X | We construct the ring `X q` as ℤ/qℤ + √3 ℤ/qℤ. |
@[ext]
ext {x y : X q} (h₁ : x.1 = y.1) (h₂ : x.2 = y.2) : x = y := by
cases x; cases y; congr
@[simp] theorem zero_fst : (0 : X q).1 = 0 := rfl
@[simp] theorem zero_snd : (0 : X q).2 = 0 := rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | ext | null |
add_fst (x y : X q) : (x + y).1 = x.1 + y.1 :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | add_fst | null |
add_snd (x y : X q) : (x + y).2 = x.2 + y.2 :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | add_snd | null |
neg_fst (x : X q) : (-x).1 = -x.1 :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | neg_fst | null |
neg_snd (x : X q) : (-x).2 = -x.2 :=
rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | neg_snd | null |
@[simp]
mul_fst (x y : X q) : (x * y).1 = x.1 * y.1 + 3 * x.2 * y.2 :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mul_fst | null |
mul_snd (x y : X q) : (x * y).2 = x.1 * y.2 + x.2 * y.1 :=
rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | mul_snd | null |
@[simp]
one_fst : (1 : X q).1 = 1 :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | one_fst | null |
one_snd : (1 : X q).2 = 0 :=
rfl | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | one_snd | null |
@[simp] fst_natCast (n : ℕ) : (n : X q).fst = (n : ZMod q) := rfl
@[simp] theorem snd_natCast (n : ℕ) : (n : X q).snd = (0 : ZMod q) := rfl
@[simp] theorem ofNat_fst (n : ℕ) [n.AtLeastTwo] :
(ofNat(n) : X q).fst = OfNat.ofNat n :=
rfl
@[simp] theorem ofNat_snd (n : ℕ) [n.AtLeastTwo] :
(ofNat(n) : X q).snd = 0... | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | fst_natCast | null |
left_distrib (x y z : X q) : x * (y + z) = x * y + x * z := by
ext <;> dsimp <;> ring | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | left_distrib | null |
right_distrib (x y z : X q) : (x + y) * z = x * z + y * z := by
ext <;> dsimp <;> ring | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | right_distrib | null |
@[simp]
fst_intCast (n : ℤ) : (n : X q).fst = (n : ZMod q) :=
rfl
@[simp] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | fst_intCast | null |
snd_intCast (n : ℤ) : (n : X q).snd = (0 : ZMod q) :=
rfl
@[norm_cast] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | snd_intCast | null |
coe_mul (n m : ℤ) : ((n * m : ℤ) : X q) = (n : X q) * (m : X q) := by ext <;> simp
@[norm_cast] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | coe_mul | null |
coe_natCast (n : ℕ) : ((n : ℤ) : X q) = (n : X q) := by ext <;> simp | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | coe_natCast | null |
ω : X q := (2, 1) | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | ω | We define `ω = 2 + √3`. |
ωb : X q := (2, -1) | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | ωb | We define `ωb = 2 - √3`, which is the inverse of `ω`. |
ω_mul_ωb : (ω : X q) * ωb = 1 := by
dsimp [ω, ωb]
ext <;> simp; ring | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | ω_mul_ωb | null |
ωb_mul_ω : (ωb : X q) * ω = 1 := by
rw [mul_comm, ω_mul_ωb] | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | ωb_mul_ω | null |
closed_form (i : ℕ) : (s i : X q) = (ω : X q) ^ 2 ^ i + (ωb : X q) ^ 2 ^ i := by
induction i with
| zero =>
dsimp [s, ω, ωb]
ext <;> norm_num
| succ i ih =>
calc
(s (i + 1) : X q) = (s i ^ 2 - 2 : ℤ) := rfl
_ = (s i : X q) ^ 2 - 2 := by push_cast; rfl
_ = (ω ^ 2 ^ i + ωb ^ 2 ^ i) ^ 2... | theorem | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | closed_form | A closed form for the recurrence relation. |
α : X q := (0, 1)
@[simp] lemma α_sq : (α ^ 2 : X q) = 3 := by
ext <;> simp [α, sq]
@[simp] lemma one_add_α_sq : ((1 + α) ^ 2 : X q) = 2 * ω := by
ext <;> simpa [α, ω, sq] using by norm_num | def | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | α | We define `α = √3`. |
α_pow (i : ℕ) : (α : X q) ^ (2 * i + 1) = 3 ^ i * α := by
rw [pow_succ, pow_mul, α_sq]
/-! We show that `X q` has characteristic `q`, so that we can apply the binomial theorem. -/ | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | α_pow | null |
one_add_α_pow_q [Fact q.Prime] (odd : Odd q) (leg3 : legendreSym q 3 = -1) :
(1 + α : X q) ^ q = 1 - α := by
obtain ⟨k, rfl⟩ := odd
let q := 2 * k + 1
have : (3 ^ k : ZMod q) = -1 := by
simpa [leg3, mul_add_div, eq_comm] using legendreSym.eq_pow (2 * k + 1) 3
rw [add_pow_expChar, α_pow, show (3 : X q) =... | lemma | NumberTheory | [
"Mathlib.NumberTheory.Fermat",
"Mathlib.RingTheory.Fintype"
] | Mathlib/NumberTheory/LucasLehmer.lean | one_add_α_pow_q | If `3` is not a square mod `q` then `(1 + α) ^ q = 1 - α` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.