/-Copyright (c) 2026 Carles MarΓn. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles MarΓn-/module public import Mathlib.Data.Nat.Factorization.Basicpublic import Mathlib.Data.ENat.Basicpublic import Mathlib.Data.Int.ModEqpublic import Mathlib.Algebra.Ring.GeomSumpublic import Mathlib.Algebra.BigOperators.Group.Finset.Basicpublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmaspublic import Mathlib.Algebra.BigOperators.Group.Finset.Sigmapublic import Mathlib.Algebra.BigOperators.Intervalspublic import Mathlib.Tactic.Ringpublic import Mathlib.Tactic.LinearCombinationpublic import Mathlib.Tactic.Zifypublic import Mathlib.Tactic.Linarith /-!# The rank profile of a Mahler matrix modulo `p`: the arithmetic For an odd prime `p`, row `J > 0` of the Mahler matrix of a measure depends on the rows above itexactly when `u < p r_b`, where `J + 1 = p^s u` with `p β€ u`, `b β‘ J (mod p β 1)`, and `r_b` isthe `Ξ»`-invariant of the `Ο^b`-branch. This file formalizes the arithmetic of that criterion andof its consequences. The criterion itself enters as the explicit hypothesis `ThmA p r Dep`, andthe comparison with the graded layers as the explicit hypothesis `hB`; neither is proved here. ## Main results * `FilasIII.crit_iff_seed`, `FilasIII.seed_injective`, `FilasIII.thmA_seeds`: the seed form of the criterion, rows `Ξ¦^s(d_b(i))` for `i < r_b`, pairwise distinct.* `FilasIII.cor_low`, `FilasIII.cor_phi`, `FilasIII.cor_phi_top`, `FilasIII.Jk_Phi`, `FilasIII.kstar_count`, `FilasIII.cor_rank`: the corollaries on low rows, the map `Ξ¦`, the indices `k*` and the rank.* `FilasIII.cor_C`, `FilasIII.cor_D`, `FilasIII.jD_zero_strictMono`, `FilasIII.jD_zero_range`, `FilasIII.cor_D_first`: the arithmetic of the two corollaries on graded layers, given both hypotheses. ## References * C. MarΓn, *Reading Iwasawa Ξ»-invariants from Mahler matrices modulo p: programs, data and Lean files*, Zenodo (2026), doi:10.5281/zenodo.23085315.-/ @[expose] public section open Finset namespace FilasIII /-! ## Objects -/ /-- `Ξ¦(J) = p(J+1) - 1`. -/def Phi (p J : β) : β := p * (J + 1) - 1 /-- `[b-i]_{p-1}`: least nonnegative residue of `b - i` modulo `p - 1`. -/def brk (p b i : β) : β := (((b : β€) - i) % ((p : β€) - 1)).toNat /-- `d_b(i) = p i + [b-i]_{p-1}`. -/def dseed (p b i : β) : β := p * i + brk p b i /-- `u(J)`: the prime-to-`p` part of `J + 1`. -/def uPart (p J : β) : β := ordCompl[p] (J + 1) /-- The criterion of Theorem A: `u < p r_b`, `b β‘ J (mod p-1)`, `b β [0,p-2]`. -/def Crit (p : β) (r : β β ββ) (J : β) : Prop := (uPart p J : ββ) < p * r (J % (p - 1)) /-- Theorem A (measure part), taken as a hypothesis: for `0 < J < p^a`, row `J` at resolution`p^a` is dependent iff `u < p r_b`. `Dep a J` = "row `J` of `B` at level `p^a` is dependent". -/def ThmA (p : β) (r : β β ββ) (Dep : β β β β Prop) : Prop := β a J, 0 < J β J < p ^ a β (Dep a J β Crit p r J) /-! ## Basic arithmetic -/ lemma Phi_add_one {p : β} (hp : 0 < p) (J : β) : Phi p J + 1 = p * (J + 1) := by unfold Phi have : 1 β€ p * (J + 1) := Nat.mul_pos hp (Nat.succ_pos J) omega lemma Phi_iter_add_one {p : β} (hp : 0 < p) (s d : β) : (Phi p)^[s] d + 1 = p ^ s * (d + 1) := by induction s with | zero => simp | succ s ih => rw [Function.iterate_succ_apply', Phi_add_one hp, ih] ring lemma Phi_iter {p : β} (hp : 0 < p) (s d : β) : (Phi p)^[s] d = p ^ s * (d + 1) - 1 := by have := Phi_iter_add_one hp s d omega /-- Uniqueness of the decomposition `n = p^s u`, `p β€ u`. -/lemma factor_unique {p : β} (hp : p.Prime) {s u : β} (hu : Β¬ p β£ u) : (p ^ s * u).factorization p = s β§ ordCompl[p] (p ^ s * u) = u := by have hu0 : u β 0 := by rintro rfl; exact hu (dvd_zero p) refine β¨?_, Nat.ordCompl_pow_mul_of_not_dvd s hp huβ© rw [Nat.factorization_mul (pow_ne_zero s hp.ne_zero) hu0, Finsupp.add_apply, hp.factorization_pow, Finsupp.single_eq_same, Nat.factorization_eq_zero_of_not_dvd hu] simp lemma not_dvd_mul_add {p i e : β} (he0 : 0 < e) (he : e < p) : Β¬ p β£ p * i + e := by intro h have : p β£ e := (Nat.dvd_add_right (dvd_mul_right p i)).mp h exact absurd (Nat.le_of_dvd he0 this) (by omega) lemma brk_cast {p : β} (hp : 2 β€ p) (b i : β) : (brk p b i : β€) = ((b : β€) - i) % ((p : β€) - 1) := by unfold brk exact Int.toNat_of_nonneg (Int.emod_nonneg _ (by omega)) lemma brk_lt {p : β} (hp : 2 β€ p) (b i : β) : brk p b i < p - 1 := by have h := brk_cast hp b i have : ((b : β€) - i) % ((p : β€) - 1) < (p : β€) - 1 := Int.emod_lt_of_pos _ (by omega) omega /-- `[b-i]_{p-1}` is the unique `Ξ΄ β [0,p-2]` with `Ξ΄ β‘ b - i (mod p-1)`. -/lemma brk_eq_of {p b i Ξ΄ : β} (hp : 2 β€ p) (hΞ΄ : Ξ΄ < p - 1) (h : ((p : β€) - 1) β£ (Ξ΄ : β€) - ((b : β€) - i)) : brk p b i = Ξ΄ := by have h1 : ((b : β€) - i) % ((p : β€) - 1) = (Ξ΄ : β€) % ((p : β€) - 1) := (Int.modEq_iff_dvd.mpr h) have h2 : (Ξ΄ : β€) % ((p : β€) - 1) = Ξ΄ := Int.emod_eq_of_lt (by omega) (by omega) have := brk_cast hp b i omega lemma brk_dvd {p : β} (hp : 2 β€ p) (b i : β) : ((p : β€) - 1) β£ (brk p b i : β€) - ((b : β€) - i) := by rw [brk_cast hp, Int.emod_def] exact β¨-(((b : β€) - i) / ((p : β€) - 1)), by ringβ© /-- `p i + e < p r β i < r` in `ββ` for `e < p`. -/lemma key_lt {p i e : β} (hp : 0 < p) (he : e < p) (r : ββ) : ((p * i + e : β) : ββ) < p * r β (i : ββ) < r := by induction r using ENat.recTopCoe with | top => simp only [ENat.natCast_lt_top, iff_true] rw [ENat.mul_top (by exact_mod_cast hp.ne')] exact ENat.natCast_lt_top _ | coe n => rw [β Nat.cast_mul, Nat.cast_lt, Nat.cast_lt] constructor Β· intro h by_contra hc have : p * n β€ p * i := Nat.mul_le_mul_left p (by omega) omega Β· intro h have : p * (i + 1) β€ p * n := Nat.mul_le_mul_left p h rw [mul_add] at this omega lemma dseed_succ_not_dvd {p : β} (hp : 2 β€ p) (b i : β) : Β¬ p β£ dseed p b i + 1 := by unfold dseed have := brk_lt hp b i rw [add_assoc] exact not_dvd_mul_add (by omega) (by omega) lemma dseed_div {p : β} (hp : 2 β€ p) (b i : β) : (dseed p b i + 1) / p = i := by unfold dseed have := brk_lt hp b i rw [add_assoc, Nat.mul_add_div (by omega), Nat.div_eq_of_lt (by omega), add_zero] /-- `Ξ¦^s(d_b(i)) + 1 = p^s (d_b(i)+1)`, so `v_p = s` and `u = d_b(i)+1`. -/lemma seed_decomp {p : β} (hp : p.Prime) (b s i : β) : ((Phi p)^[s] (dseed p b i) + 1).factorization p = s β§ uPart p ((Phi p)^[s] (dseed p b i)) = dseed p b i + 1 := by unfold uPart rw [Phi_iter_add_one hp.pos] exact factor_unique hp (dseed_succ_not_dvd hp.two_le b i) /-- `Ξ¦^s(d_b(i)) β‘ b (mod p-1)`. -/lemma seed_mod {p : β} (hp : 2 β€ p) {b : β} (hb : b < p - 1) (s i : β) : (Phi p)^[s] (dseed p b i) % (p - 1) = b := by have hcast : ((p - 1 : β) : β€) = (p : β€) - 1 := by push_cast [Nat.cast_sub (by omega : 1 β€ p)]; ring have hX := Phi_iter_add_one (by omega : 0 < p) s (dseed p b i) obtain β¨c, hcβ© := sub_dvd_pow_sub_pow (p : β€) 1 s obtain β¨e, heβ© := brk_dvd hp b i have hX' : (((Phi p)^[s] (dseed p b i) : β) : β€) + 1 = (p : β€) ^ s * ((dseed p b i : β€) + 1) := by exact_mod_cast hX have hd : (dseed p b i : β€) = p * i + brk p b i := by unfold dseed; push_cast; ring have hdvd : ((p - 1 : β) : β€) β£ (((Phi p)^[s] (dseed p b i) : β) : β€) - b := by rw [hcast] refine β¨c * ((dseed p b i : β€) + 1) + i + e, ?_β© simp only [one_pow] at hc linear_combination hX' + hc * ((dseed p b i : β€) + 1) + hd + he have := (Nat.modEq_iff_dvd.mpr hdvd) unfold Nat.ModEq at this rw [Nat.mod_eq_of_lt hb] at this exact this.symm /-- Every `J` is `Ξ¦^s(d_b(i))` with `s = v_p(J+1)`, `b = J mod (p-1)`, `i = βu/pβ`, and`u = d_b(i) + 1`. -/lemma decomp {p : β} (hp : p.Prime) (J : β) : uPart p J = dseed p (J % (p - 1)) (uPart p J / p) + 1 β§ J = (Phi p)^[(J + 1).factorization p] (dseed p (J % (p - 1)) (uPart p J / p)) := by have hp2 := hp.two_le set s := (J + 1).factorization p with hs set u := uPart p J with hu set b := J % (p - 1) with hb set i := u / p with hi have hJu : p ^ s * u = J + 1 := Nat.ordProj_mul_ordCompl_eq_self (J + 1) p have hu0 : 0 < u := Nat.ordCompl_pos p (by omega) have hnd : Β¬ p β£ u := Nat.not_dvd_ordCompl hp (by omega) set Ξ΄ := u % p - 1 with hΞ΄ have hmod : u % p β 0 := fun h => hnd (Nat.dvd_of_mod_eq_zero h) have hmodlt : u % p < p := Nat.mod_lt _ hp.pos have hudec : u = p * i + Ξ΄ + 1 := by have := Nat.div_add_mod u p rw [β hi] at this omega have hΞ΄lt : Ξ΄ < p - 1 := by omega -- Ξ΄ β‘ b - i have hbrk : brk p b i = Ξ΄ := by apply brk_eq_of hp2 hΞ΄lt obtain β¨c, hcβ© := sub_dvd_pow_sub_pow (p : β€) 1 s have hJb : ((p - 1 : β) : β€) β£ (J : β€) - b := by have : b β‘ J [MOD p - 1] := Nat.mod_modEq J (p - 1) exact Nat.modEq_iff_dvd.mp this have hcast : ((p - 1 : β) : β€) = (p : β€) - 1 := by push_cast [Nat.cast_sub (by omega : 1 β€ p)]; ring rw [hcast] at hJb obtain β¨q, hqβ© := hJb have hJu' : (p : β€) ^ s * u = J + 1 := by exact_mod_cast hJu have hud' : (u : β€) = p * i + Ξ΄ + 1 := by exact_mod_cast hudec simp only [one_pow] at hc exact β¨q - c * u - i, by linear_combination hq - hc * (u : β€) + hJu' - hud'β© have hdseed : dseed p b i + 1 = u := by unfold dseed; rw [hbrk]; omega refine β¨hdseed.symm, ?_β© have := Phi_iter_add_one hp.pos s (dseed p b i) rw [hdseed, hJu] at this omega /-! ## Theorem A: the seed form and distinctness -/ /-- Arithmetic core of Theorem A: for `J β‘ b (mod p-1)`, `b β [0,p-2]`,`u(J) < p r β J = Ξ¦^s(d_b(i))` for some `s β₯ 0` and `i < r`. (Valid for every `J`, including`J = 0`, which is `Ξ¦^0(d_0(0))`.) -/theorem crit_iff_seed {p : β} (hp : p.Prime) {b J : β} (hJb : J % (p - 1) = b) (r : ββ) : (uPart p J : ββ) < p * r β β s i : β, (i : ββ) < r β§ J = (Phi p)^[s] (dseed p b i) := by have hp2 := hp.two_le constructor Β· intro h obtain β¨hu, hJβ© := decomp hp J refine β¨(J + 1).factorization p, uPart p J / p, ?_, by rw [β hJb]; exact hJβ© rw [hu, hJb] at h unfold dseed at h have := brk_lt hp2 b (uPart p J / p) rw [add_assoc] at h exact (key_lt hp.pos (by omega) r).mp h Β· rintro β¨s, i, hi, rflβ© rw [(seed_decomp hp b s i).2] unfold dseed have := brk_lt hp2 b i rw [add_assoc] exact (key_lt hp.pos (by omega) r).mpr hi /-- Distinctness in Theorem A: `(s,i) β¦ Ξ¦^s(d_b(i))` is injective. -/theorem seed_injective {p : β} (hp : p.Prime) (b : β) : Function.Injective (fun x : β Γ β => (Phi p)^[x.1] (dseed p b x.2)) := by rintro β¨s, iβ© β¨s', i'β© h simp only at h have h1 := seed_decomp hp b s i have h2 := seed_decomp hp b s' i' rw [h] at h1 have hs : s = s' := h1.1.symm.trans h2.1 have hd : dseed p b i + 1 = dseed p b i' + 1 := h1.2.symm.trans h2.2 have hi : i = i' := by rw [β dseed_div hp.two_le b i, β dseed_div hp.two_le b i', hd] rw [hs, hi] /-- **Theorem A, seed form** (thm:A, "Equivalently"), with the criterion `u < p r_b` ashypothesis `hA`: the positive rows `J < p^a`, `J β‘ b (mod p-1)`, that are dependent are exactlythe `Ξ¦^s(d_b(i))` with `0 < Ξ¦^s(d_b(i)) < p^a`, `s β₯ 0`, `i < r_b`. -/theorem thmA_seeds {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) (a : β) {b : β} (hb : b < p - 1) (J : β) : (0 < J β§ J < p ^ a β§ J % (p - 1) = b β§ Dep a J) β (0 < J β§ J < p ^ a β§ β s i : β, (i : ββ) < r b β§ J = (Phi p)^[s] (dseed p b i)) := by constructor Β· rintro β¨h0, h1, h2, h3β© refine β¨h0, h1, ?_β© have := (hA a J h0 h1).mp h3 unfold Crit at this rw [h2] at this exact (crit_iff_seed hp h2 (r b)).mp this Β· rintro β¨h0, h1, s, i, hi, rflβ© have h2 := seed_mod hp.two_le hb s i refine β¨h0, h1, h2, ?_β© rw [hA a _ h0 h1] unfold Crit rw [h2] exact (crit_iff_seed hp h2 (r b)).mpr β¨s, i, hi, rflβ© /-! ## Corollary 3.2 (cor:phi) -/ lemma Phi_eq {p : β} (hp : 0 < p) (J : β) : Phi p J = J + (p - 1) * (J + 1) := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© unfold Phi simp only [Nat.add_sub_cancel] have : (q + 1) * (J + 1) = J + q * (J + 1) + 1 := by ring omega lemma Crit_Phi {p : β} (hp : p.Prime) (r : β β ββ) (J : β) : Crit p r (Phi p J) β Crit p r J := by unfold Crit uPart have h1 : Phi p J + 1 = p ^ 1 * (J + 1) := by rw [pow_one]; exact Phi_add_one hp.pos J have h2 : Phi p J % (p - 1) = J % (p - 1) := by rw [Phi_eq hp.pos, Nat.add_mul_mod_self_left] rw [h1, Nat.ordCompl_self_pow_mul _ _ hp, h2] /-- **Corollary 3.2** (cor:phi), first part: for `0 < J < p^a`, row `J` is dependent atresolution `p^a` iff row `Ξ¦(J)` is dependent at resolution `p^{a+1}`. -/theorem cor_phi {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a J : β} (h0 : 0 < J) (hJ : J < p ^ a) : Dep a J β Dep (a + 1) (Phi p J) := by have h1 := Phi_add_one hp.pos J have hlt : Phi p J < p ^ (a + 1) := by have : p * (J + 1) β€ p * p ^ a := Nat.mul_le_mul_left p hJ rw [pow_succ] have : p * p ^ a = p ^ a * p := mul_comm _ _ omega have hpos : 0 < Phi p J := by have : p * (J + 1) β₯ 2 * 2 := Nat.mul_le_mul hp.two_le (by omega) omega rw [hA a J h0 hJ, hA (a + 1) _ hpos hlt, Crit_Phi hp] /-- **Corollary 3.2** (cor:phi), second part: row `p^a - 1` is dependent iff `r_0 > 0`. -/theorem cor_phi_top {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a : β} (ha : 1 β€ a) : Dep a (p ^ a - 1) β 0 < r 0 := by have hpa : p β€ p ^ a := by calc p = p ^ 1 := (pow_one p).symm _ β€ p ^ a := Nat.pow_le_pow_right hp.pos ha have h2 := hp.two_le rw [hA a _ (by omega) (by omega)] unfold Crit uPart have hsub : p ^ a - 1 + 1 = p ^ a := by omega have hmod : (p ^ a - 1) % (p - 1) = 0 := by apply Nat.mod_eq_zero_of_dvd simpa using Nat.sub_dvd_pow_sub_pow p 1 a rw [hsub, Nat.ordCompl_self_pow hp, hmod] have := key_lt (i := 0) (e := 1) hp.pos (by omega) (r 0) simpa using this /-! ## Corollary 3.1 (cor:low) -/ lemma dseed_zero_zero {p : β} (hp : 2 β€ p) : dseed p 0 0 = 0 := by unfold dseed rw [brk_eq_of (Ξ΄ := 0) hp (by omega) (by simp)]; simp lemma dseed_zero {p : β} (hp : 2 β€ p) {i : β} (hi1 : 1 β€ i) (hi : i β€ p - 2) : dseed p 0 i = (i + 1) * (p - 1) := by unfold dseed rw [brk_eq_of (Ξ΄ := p - 1 - i) hp (by omega) β¨1, by push_cast [Nat.cast_sub (by omega : i β€ p - 1), Nat.cast_sub (by omega : 1 β€ p)]; ringβ©] obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] zify [(by omega : i β€ q)] ring /-- **Corollary 3.1** (cor:low), with Theorem A as hypothesis: if `1 β€ r_0 = n β€ p - 1`, thedependent rows `0 < J < p^a` with `J β‘ 0 (mod p-1)` are`{p^s - 1 : 1 β€ s β€ a} βͺ {p^s((i+1)(p-1)+1) - 1 : 0 β€ s β€ a-2, 1 β€ i β€ r_0 - 1}`(`s β€ a - 2` written `s + 2 β€ a`, which is empty for `a < 2`, as in the paper). -/theorem cor_low {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) (a : β) {n : β} (hr : r 0 = n) (hn1 : 1 β€ n) (hn : n β€ p - 1) (J : β) : (0 < J β§ J < p ^ a β§ J % (p - 1) = 0 β§ Dep a J) β ((β s, 1 β€ s β§ s β€ a β§ J = p ^ s - 1) β¨ (β s i, s + 2 β€ a β§ 1 β€ i β§ i β€ n - 1 β§ J = p ^ s * ((i + 1) * (p - 1) + 1) - 1)) := by have h2 := hp.two_le have h1 := hp.one_lt rw [thmA_seeds hp hA a (b := 0) (by omega) J, hr] constructor Β· rintro β¨h0, hlt, s, i, hi, rflβ© rw [Nat.cast_lt] at hi rcases Nat.eq_zero_or_pos i with rfl | hi1 Β· left rw [Phi_iter hp.pos, dseed_zero_zero h2] at h0 hlt β’ simp only [zero_add, mul_one] at h0 hlt β’ refine β¨s, ?_, ?_, rflβ© Β· rcases Nat.eq_zero_or_pos s with rfl | hs Β· simp at h0 Β· exact hs Β· have : p ^ s β€ p ^ a := by omega exact (Nat.pow_le_pow_iff_right h1).mp this Β· right rw [Phi_iter hp.pos, dseed_zero h2 hi1 (by omega)] at hlt β’ refine β¨s, i, ?_, hi1, by omega, rflβ© by_contra hc have hX : p < (i + 1) * (p - 1) + 1 := by have : 2 * (p - 1) β€ (i + 1) * (p - 1) := Nat.mul_le_mul_right _ (by omega) omega have hps : 0 < p ^ s := pow_pos hp.pos s have h3 : p ^ s * p < p ^ s * ((i + 1) * (p - 1) + 1) := Nat.mul_lt_mul_of_pos_left hX hps have h4 : p ^ a β€ p ^ s * p := by rw [β pow_succ]; exact Nat.pow_le_pow_right hp.pos (by omega) omega Β· rintro (β¨s, hs1, hsa, rflβ© | β¨s, i, hsa, hi1, hin, rflβ©) Β· have hps : 1 < p ^ s := Nat.one_lt_pow (by omega) h1 have hpa : p ^ s β€ p ^ a := Nat.pow_le_pow_right hp.pos hsa refine β¨by omega, by omega, s, 0, by exact_mod_cast hn1, ?_β© rw [Phi_iter hp.pos, dseed_zero_zero h2]; simp Β· have hps : 0 < p ^ s := pow_pos hp.pos s have hX : (i + 1) * (p - 1) + 1 < p ^ 2 := by have : (i + 1) * (p - 1) β€ (p - 1) * (p - 1) := Nat.mul_le_mul_right _ (by omega) obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] at this β’ nlinarith have hX2 : 2 β€ (i + 1) * (p - 1) + 1 := by have : 1 * 1 β€ (i + 1) * (p - 1) := Nat.mul_le_mul (by omega) (by omega) omega have h3 : p ^ s * ((i + 1) * (p - 1) + 1) < p ^ s * p ^ 2 := Nat.mul_lt_mul_of_pos_left hX hps have h4 : p ^ s * p ^ 2 β€ p ^ a := by rw [β pow_add]; exact Nat.pow_le_pow_right hp.pos hsa have h5 : p ^ s * 2 β€ p ^ s * ((i + 1) * (p - 1) + 1) := Nat.mul_le_mul_left _ hX2 refine β¨by omega, by omega, s, i, by exact_mod_cast (show i < n by omega), ?_β© rw [Phi_iter hp.pos, dseed_zero h2 hi1 (by omega)] /-! ## Corollary 3.3 (cor:kstar) -/ /-- `J^{(a_0)}_k = p^{a_0-2}(k(p-1)+1) - 1`. -/def Jk (p a0 k : β) : β := p ^ (a0 - 2) * (k * (p - 1) + 1) - 1 /-- `k* = βp n/(p-1)β`, written in `β` (see `kstar_spec`). -/def kstar (p n : β) : β := (p * n + (p - 2)) / (p - 1) /-- `kstar p n` is the ceiling of `p n/(p-1)`: `(k*-1)(p-1) < p n β€ k*(p-1)`. -/lemma kstar_spec {p : β} (hp : 2 β€ p) (n : β) : p * n β€ kstar p n * (p - 1) β§ kstar p n * (p - 1) < p * n + (p - 1) := by unfold kstar have h1 := Nat.div_add_mod (p * n + (p - 2)) (p - 1) have h2 := Nat.mod_lt (p * n + (p - 2)) (show 0 < p - 1 by omega) rw [mul_comm ((p * n + (p - 2)) / (p - 1))] omega lemma Jk_add_one {p : β} (hp : 0 < p) (a0 k : β) : Jk p a0 k + 1 = p ^ (a0 - 2) * (k * (p - 1) + 1) := by unfold Jk have : 0 < p ^ (a0 - 2) * (k * (p - 1) + 1) := Nat.mul_pos (pow_pos hp _) (Nat.succ_pos _) omega /-- First claim of cor:kstar: `J_{pj+1} = Ξ¦(J_j)`. (Holds for every `j`, also `j = 0`.) -/theorem Jk_Phi {p : β} (hp : 0 < p) (a0 j : β) : Jk p a0 (p * j + 1) = Phi p (Jk p a0 j) := by suffices h : Jk p a0 (p * j + 1) + 1 = Phi p (Jk p a0 j) + 1 by omega rw [Jk_add_one hp, Phi_add_one hp, Jk_add_one hp] obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] ring lemma Jk_pos {p : β} (hp : 2 β€ p) (a0 : β) {k : β} (hk : 1 β€ k) : 0 < Jk p a0 k := by have h := Jk_add_one (by omega : 0 < p) a0 k have h1 : 1 * 1 β€ k * (p - 1) := Nat.mul_le_mul hk (by omega) have h2 : 1 β€ p ^ (a0 - 2) := Nat.one_le_pow _ _ (by omega) have h3 : 1 * 2 β€ p ^ (a0 - 2) * (k * (p - 1) + 1) := Nat.mul_le_mul h2 (by omega) omega lemma Jk_mono {p : β} (hp : 0 < p) (a0 : β) {k k' : β} (h : k β€ k') : Jk p a0 k β€ Jk p a0 k' := by have h1 := Jk_add_one hp a0 k have h2 := Jk_add_one hp a0 k' have : p ^ (a0 - 2) * (k * (p - 1) + 1) β€ p ^ (a0 - 2) * (k' * (p - 1) + 1) := Nat.mul_le_mul_left _ (by have := Nat.mul_le_mul_right (p - 1) h; omega) omega lemma Jk_mod {p : β} (hp : 2 β€ p) (a0 k : β) : Jk p a0 k % (p - 1) = 0 := by have h := Jk_add_one (by omega : 0 < p) a0 k obtain β¨c, hcβ© := sub_dvd_pow_sub_pow (p : β€) 1 (a0 - 2) have h' : ((Jk p a0 k : β) : β€) + 1 = (p : β€) ^ (a0 - 2) * ((k : β€) * ((p : β€) - 1) + 1) := by have := congrArg (fun x : β => (x : β€)) h push_cast [Nat.cast_sub (by omega : 1 β€ p)] at this exact this have hdvd : ((p - 1 : β) : β€) β£ ((Jk p a0 k : β) : β€) - (0 : β) := by rw [show ((p - 1 : β) : β€) = (p : β€) - 1 by push_cast [Nat.cast_sub (by omega : 1 β€ p)]; ring] simp only [one_pow] at hc exact β¨c * ((k : β€) * ((p : β€) - 1) + 1) + k, by push_cast; linear_combination h' + hc * ((k : β€) * ((p : β€) - 1) + 1)β© have := (Nat.modEq_iff_dvd.mpr hdvd) unfold Nat.ModEq at this rw [Nat.zero_mod] at this exact this.symm lemma Crit_Jk {p : β} (hp : p.Prime) (r : β β ββ) (a0 k : β) : Crit p r (Jk p a0 k) β (ordCompl[p] (k * (p - 1) + 1) : ββ) < p * r 0 := by unfold Crit uPart rw [Jk_add_one hp.pos, Nat.ordCompl_self_pow_mul _ _ hp, Jk_mod hp.two_le] /-- **Corollary 3.3** (cor:kstar), case `r_0 = 0`: row `J_1` is new (so `k* = 1`). -/theorem cor_kstar_zero {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a0 a1 : β} (hr : r 0 = 0) (hlt : Jk p a0 1 < p ^ a1) : Β¬ Dep a1 (Jk p a0 1) := by rw [hA a1 _ (Jk_pos hp.two_le a0 le_rfl) hlt, Crit_Jk hp, hr] simp /-- **Corollary 3.3** (cor:kstar), case `r_0 = β`: every row of the progression is dependent. -/theorem cor_kstar_top {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a0 a1 : β} (hr : r 0 = β€) {k : β} (hk : 1 β€ k) (hlt : Jk p a0 k < p ^ a1) : Dep a1 (Jk p a0 k) := by rw [hA a1 _ (Jk_pos hp.two_le a0 hk) hlt, Crit_Jk hp, hr, ENat.mul_top (by exact_mod_cast hp.ne_zero)] exact ENat.natCast_lt_top _ /-- **Corollary 3.3** (cor:kstar), case `1 β€ r_0 = n < β`, rows before `k*`: every `J_k` with`1 β€ k < k* = βp n/(p-1)β` (read at a resolution containing it) is dependent. -/theorem cor_kstar_below {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a0 a1 n : β} (hr : r 0 = n) (hn : 1 β€ n) {k : β} (hk : 1 β€ k) (hks : k < kstar p n) (hlt : Jk p a0 k < p ^ a1) : Dep a1 (Jk p a0 k) := by have h2 := hp.two_le rw [hA a1 _ (Jk_pos h2 a0 hk) hlt, Crit_Jk hp, hr, β Nat.cast_mul, Nat.cast_lt] obtain β¨_, hs2β© := kstar_spec h2 n have h3 : k * (p - 1) + (p - 1) β€ kstar p n * (p - 1) := by have := Nat.mul_le_mul_right (p - 1) (show k + 1 β€ kstar p n by omega) rw [add_mul, one_mul] at this exact this -- `k(p-1) + 1 β€ p n` rcases Nat.lt_or_ge (k * (p - 1) + 1) (p * n) with hX | hX Β· exact lt_of_le_of_lt (Nat.ordCompl_le _ _) hX Β· have hX' : k * (p - 1) + 1 = p ^ 1 * n := by rw [pow_one]; omega rw [hX', Nat.ordCompl_self_pow_mul _ _ hp] have : n < p * n := by have := Nat.mul_le_mul_right n h2 omega exact lt_of_le_of_lt (Nat.ordCompl_le _ _) this /-- **Corollary 3.3** (cor:kstar), case `1 β€ r_0 = n < β`, the row `k*`: if `J_{k*}` lies belowthe resolution, it is new. With `cor_kstar_below`, `k* = βp r_0/(p-1)β` is the least `k β₯ 1`with `J_k` new; it depends neither on `a_0` nor on `a_1`. -/theorem cor_kstar_new {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a0 a1 n : β} (hr : r 0 = n) (hn : 1 β€ n) (hlt : Jk p a0 (kstar p n) < p ^ a1) : Β¬ Dep a1 (Jk p a0 (kstar p n)) := by have h2 := hp.two_le obtain β¨hs1, hs2β© := kstar_spec h2 n have hk1 : 1 β€ kstar p n := by rcases Nat.eq_zero_or_pos (kstar p n) with h | h Β· rw [h, zero_mul] at hs1 have := Nat.mul_le_mul_left p hn omega Β· exact h rw [hA a1 _ (Jk_pos h2 a0 hk1) hlt, Crit_Jk hp, hr, β Nat.cast_mul, Nat.cast_lt] set k := kstar p n with hk -- `p β€ k(p-1)+1` have hnd : Β¬ p β£ k * (p - 1) + 1 := by intro hd have hsum : k * (p - 1) + 1 + (k - 1) = k * p := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© obtain β¨m, hmβ© : β m, k = m + 1 := β¨k - 1, by omegaβ© rw [hm] simp only [Nat.add_sub_cancel] ring have hd' : p β£ k - 1 := (Nat.dvd_add_right hd).mp (by rw [hsum]; exact dvd_mul_left p k) obtain β¨j, hjβ© := hd' have e1 : k * (p - 1) = p * (j * (p - 1)) + (p - 1) := by have : k = p * j + 1 := by omega rw [this, add_mul, one_mul, mul_assoc] have i1 : j * (p - 1) < n := by have : p * (j * (p - 1)) < p * n := by omega exact Nat.lt_of_mul_lt_mul_left this have i2 : n < j * (p - 1) + 1 := by have : p * n < p * (j * (p - 1) + 1) := by rw [mul_add, mul_one]; omega exact Nat.lt_of_mul_lt_mul_left this omega rw [(Nat.ordCompl_eq_self_iff_zero_or_not_dvd _ hp).mpr (Or.inr hnd)] omega /-- **Corollary 3.3** (cor:kstar), last sentence: if `J_{k*} β₯ p^{a_1}`, every row of theprogression below `p^{a_1}` is dependent. -/theorem cor_kstar_beyond {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a0 a1 n : β} (hr : r 0 = n) (hn : 1 β€ n) (hge : p ^ a1 β€ Jk p a0 (kstar p n)) {k : β} (hk : 1 β€ k) (hlt : Jk p a0 k < p ^ a1) : Dep a1 (Jk p a0 k) := by have hks : k < kstar p n := by by_contra hc have := Jk_mono hp.pos a0 (show kstar p n β€ k by omega) omega exact cor_kstar_below hp hA hr hn hk hks hlt /-! ## Corollary 3.4 (cor:rank) -/ lemma sum_count (N : β) (r : ββ) : β i β range N, (if (i : ββ) < r then 0 else 1) = (((N : β) : ββ) - r).toNat := by induction r using ENat.recTopCoe with | top => simp | coe n => rw [β ENat.natCast_sub, ENat.toNat_natCast] simp only [Nat.cast_lt] induction N with | zero => simp | succ N ih => rw [sum_range_succ, ih] split_ifs <;> omega open Classical in/-- **Corollary 3.4** (cor:rank), with Theorem A as hypothesis: the number of new rows of `B`at level `p^a` is `[ΞΌ(β€_p) β 0] + Ξ£_{b=0}^{p-2} Ξ£_{t=0}^{a-1} max(p^t - r_b, 0)`(`max(p^t - β, 0) = 0` is the truncated subtraction of `ββ`). `M0` stands for `ΞΌ(β€_p) = 0`, and`h0` is the row-0 clause of thm:A. -/theorem cor_rank {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a : β} (ha : 1 β€ a) (M0 : Prop) (h0 : Dep a 0 β M0) : ((range (p ^ a)).filter (fun J => Β¬ Dep a J)).card = (if M0 then 0 else 1) + β b β range (p - 1), β t β range a, (((p ^ t : β) : ββ) - r b).toNat := by have h2 := hp.two_le have hpa : p β€ p ^ a := by calc p = p ^ 1 := (pow_one p).symm _ β€ p ^ a := Nat.pow_le_pow_right hp.pos ha set P := p ^ a with hP set g : β β β := fun J => if Crit p r J then 0 else 1 with hg -- Step 1: split off row 0 and use Theorem A on the positive rows. have step1 : ((range P).filter (fun J => Β¬ Dep a J)).card = β J β range (P - 1), g (J + 1) + (if M0 then 0 else 1) := by rw [card_filter, show P = (P - 1) + 1 by omega, sum_range_succ'] congr 1 Β· refine sum_congr rfl (fun J hJ => ?_) rw [mem_range] at hJ rw [hA a (J + 1) (Nat.succ_pos J) (by omega)] simp only [hg] by_cases h : Crit p r (J + 1) <;> simp [h] Β· by_cases h : M0 <;> simp [h0, h] -- Step 2: `g (P-1) = g 0`, so shifting the window does not change the sum. have hgP : g (P - 1) = g 0 := by have hsub : P - 1 + 1 = p ^ a := by omega have hmod : (P - 1) % (p - 1) = 0 := by apply Nat.mod_eq_zero_of_dvd simpa using Nat.sub_dvd_pow_sub_pow p 1 a have hc : Crit p r (P - 1) β Crit p r 0 := by unfold Crit uPart rw [hsub, Nat.ordCompl_self_pow hp, hmod] simp simp only [hg] by_cases h : Crit p r 0 Β· rw [ite_eq_left (hc.mpr h), ite_eq_left h] Β· rw [ite_eq_right (fun h' => h (hc.mp h')), ite_eq_right h] have step2 : β J β range (P - 1), g (J + 1) = β J β range (P - 1), g J := by have e1 := sum_range_succ' g (P - 1) have e2 := sum_range_succ g (P - 1) rw [hgP] at e2 omega -- Step 3: reindex the rows `J < P - 1` by `(b, s, i)`, `J = Ξ¦^s(d_b(i))`. set T : Finset (Ξ£ _ : β, Ξ£ _ : β, β) := (range (p - 1)).sigma (fun _ => (range a).sigma (fun s => range (p ^ (a - s - 1)))) with hT have step3 : β J β range (P - 1), g J = β x β T, (if (x.2.2 : ββ) < r x.1 then 0 else 1) := by refine sum_nbij' (fun J => β¨J % (p - 1), β¨(J + 1).factorization p, uPart p J / pβ©β©) (fun x => (Phi p)^[x.2.1] (dseed p x.1 x.2.2)) ?_ ?_ ?_ ?_ ?_ Β· intro J hJ rw [mem_range] at hJ simp only [hT, mem_sigma, mem_range] have hJu : p ^ (J + 1).factorization p * uPart p J = J + 1 := Nat.ordProj_mul_ordCompl_eq_self (J + 1) p have hu0 : 0 < uPart p J := Nat.ordCompl_pos p (by omega) set s := (J + 1).factorization p have hs : s < a := by by_contra hc have : p ^ a β€ p ^ s := Nat.pow_le_pow_right hp.pos (by omega) have : p ^ s β€ p ^ s * uPart p J := Nat.le_mul_of_pos_right _ hu0 omega refine β¨Nat.mod_lt _ (by omega), hs, ?_β© rw [Nat.div_lt_iff_lt_mul hp.pos, β pow_succ, show a - s - 1 + 1 = a - s by omega] have : p ^ s * uPart p J < p ^ s * p ^ (a - s) := by rw [β pow_add, show s + (a - s) = a by omega]; omega exact Nat.lt_of_mul_lt_mul_left this Β· rintro β¨b, s, iβ© hx simp only [hT, mem_sigma, mem_range] at hx obtain β¨hb, hs, hiβ© := hx rw [mem_range] have h1 := Phi_iter_add_one hp.pos s (dseed p b i) have hbl := brk_lt h2 b i have hd : dseed p b i + 1 < p * p ^ (a - s - 1) := by have : p * (i + 1) β€ p * p ^ (a - s - 1) := Nat.mul_le_mul_left p hi unfold dseed rw [mul_add, mul_one] at this omega have : p ^ s * (dseed p b i + 1) < p ^ s * (p * p ^ (a - s - 1)) := Nat.mul_lt_mul_of_pos_left hd (pow_pos hp.pos s) rw [β pow_succ', β pow_add, show s + (a - s - 1 + 1) = a by omega] at this simp only omega Β· intro J _ exact (decomp hp J).2.symm Β· rintro β¨b, s, iβ© hx simp only [hT, mem_sigma, mem_range] at hx obtain β¨hb, -β© := hx obtain β¨hfs, huβ© := seed_decomp hp b s i simp only rw [hfs, hu, dseed_div h2, seed_mod h2 hb] Β· intro J _ simp only [hg] have hu := (decomp hp J).1 have hc : Crit p r J β ((uPart p J / p : β) : ββ) < r (J % (p - 1)) := by unfold Crit have := brk_lt h2 (J % (p - 1)) (uPart p J / p) generalize uPart p J / p = i at hu this β’ rw [hu] unfold dseed rw [add_assoc] exact key_lt hp.pos (by omega) _ by_cases h : Crit p r J Β· rw [ite_eq_left h, ite_eq_left (hc.mp h)] Β· rw [ite_eq_right h, ite_eq_right (fun h' => h (hc.mpr h'))] -- Step 4: evaluate the sum over `T`. have step4 : β x β T, (if (x.2.2 : ββ) < r x.1 then 0 else 1) = β b β range (p - 1), β t β range a, (((p ^ t : β) : ββ) - r b).toNat := by rw [hT, sum_sigma] refine sum_congr rfl (fun b _ => ?_) rw [sum_sigma] refine Eq.trans ?_ (sum_range_reflect (fun t => (((p ^ t : β) : ββ) - r b).toNat) a) refine sum_congr rfl (fun s hs => ?_) rw [mem_range] at hs rw [show a - 1 - s = a - s - 1 by omega] show (β i β range (p ^ (a - s - 1)), if (i : ββ) < r b then 0 else 1) = _ exact sum_count _ _ rw [step1, step2, step3, step4, add_comm] /-! ## cor:kstar, "Equivalently": `r_0 = (k* - 1) - #{j β₯ 1 : pj + 1 < k*}` -/ theorem kstar_count {p : β} (hp : 2 β€ p) {n : β} (hn : 1 β€ n) : n = (kstar p n - 1) - ((range (kstar p n)).filter (fun j => 1 β€ j β§ p * j + 1 < kstar p n)).card := by obtain β¨hs1, hs2β© := kstar_spec hp n set K := kstar p n with hK have hK2 : 2 β€ K := by by_contra hc have : K * (p - 1) β€ 1 * (p - 1) := Nat.mul_le_mul_right _ (by omega) have : p * 1 β€ p * n := Nat.mul_le_mul_left p hn omega set c := (K - 2) / p with hc set Ο := (K - 2) % p with hΟ have hΟlt : Ο < p := Nat.mod_lt _ (by omega) have hKdec : K = p * c + Ο + 2 := by have := Nat.div_add_mod (K - 2) p rw [β hc, β hΟ] at this omega -- the filtered set is `Icc 1 c` have hset : (range K).filter (fun j => 1 β€ j β§ p * j + 1 < K) = Icc 1 c := by ext j simp only [mem_filter, mem_range, mem_Icc] have hdiv : j β€ c β j * p β€ K - 2 := Nat.le_div_iff_mul_le (by omega) have hjp : j β€ p * j := Nat.le_mul_of_pos_left j (by omega) rw [hdiv, mul_comm j p] omega rw [hset, Nat.card_Icc, Nat.add_sub_cancel] set m := (p - 1) * c + Ο + 1 with hm have hid : K * (p - 1) + Ο + 2 = p * m + p := by rw [hKdec, hm] obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] ring have h1 : m β€ n := by have e1 : p * (n + 1) = p * n + p := by ring have : p * m < p * (n + 1) := by omega have := Nat.lt_of_mul_lt_mul_left this omega have h2 : n β€ m := by have e1 : p * (m + 1) = p * m + p := by ring have : p * n < p * (m + 1) := by omega have := Nat.lt_of_mul_lt_mul_left this omega have hpc : (p - 1) * c + c = p * c := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] ring omega /-! ## Arithmetic of Corollaries C and D (thm:B as hypothesis) -/ lemma ordCompl_prime_self {p : β} (hp : p.Prime) : ordCompl[p] p = 1 := by simpa using Nat.ordCompl_self_pow (k := 1) hp /-- **Corollary C** (cor:C), with thm:A and thm:B as hypotheses. `Vanish j` = "the`Ο`-component of `G_{P+j}` vanishes"; `hB` is thm:B (= lem:M1 + lem:bridge, not formalized);`r 0 = r_{Ο,0}`, which lem:R (not formalized) identifies with `Ξ»Μ(Ο)`. For `1 β€ k β€ p - 1`,the component at `P + J_k` vanishes iff `k β€ r_{Ο,0}`. -/theorem cor_C {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a : β} (ha : 2 β€ a) {Vanish : β β Prop} (hB : β j, j < p ^ a - p ^ (a - 1) β (Vanish j β Dep a j)) {k : β} (hk1 : 1 β€ k) (hk : k β€ p - 1) : Vanish (Jk p a k) β (k : ββ) β€ r 0 := by have h2 := hp.two_le -- `J_k < P - p^{a-1}` have hJ1 := Jk_add_one hp.pos a k have hPa : p ^ a = p ^ (a - 2) * (p * p) := by rw [β pow_two, β pow_add, show a - 2 + 2 = a by omega] have hPa1 : p ^ (a - 1) = p ^ (a - 2) * p := by rw [β pow_succ, show a - 2 + 1 = a - 1 by omega] have hX : k * (p - 1) + 1 + p β€ p * p := by have : k * (p - 1) β€ (p - 1) * (p - 1) := Nat.mul_le_mul_right _ hk obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] at this β’ nlinarith have hlt : Jk p a k < p ^ a - p ^ (a - 1) := by have := Nat.mul_le_mul_left (p ^ (a - 2)) hX rw [mul_add, mul_add] at this rw [mul_add, mul_one] at hJ1 rw [hPa, hPa1, Nat.lt_sub_iff_add_lt] omega have hltP : Jk p a k < p ^ a := lt_of_lt_of_le hlt (Nat.sub_le _ _) rw [hB _ hlt, hA a _ (Jk_pos h2 a hk1) hltP, Crit_Jk hp] induction r 0 using ENat.recTopCoe with | top => simp only [le_top, iff_true] rw [ENat.mul_top (by exact_mod_cast hp.ne_zero)] exact ENat.natCast_lt_top _ | coe n => rw [β Nat.cast_mul, Nat.cast_lt, Nat.cast_le] rcases Nat.eq_or_lt_of_le hk1 with rfl | hk2 Β· rw [one_mul, Nat.sub_add_cancel (by omega : 1 β€ p), ordCompl_prime_self hp] constructor Β· intro h; by_contra hc; simp_all Β· intro h; have := Nat.mul_le_mul h2 h; omega Β· have hnd : Β¬ p β£ k * (p - 1) + 1 := by have e : k * (p - 1) + 1 = p * (k - 1) + (p - k + 1) := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© obtain β¨m, rflβ© : β m, k = m + 1 := β¨k - 1, by omegaβ© simp only [Nat.add_sub_cancel] rw [show q + 1 - (m + 1) + 1 = q - m + 1 by omega] zify [(by omega : m β€ q)] ring rw [e] exact not_dvd_mul_add (by omega) (by omega) rw [(Nat.ordCompl_eq_self_iff_zero_or_not_dvd _ hp).mpr (Or.inr hnd)] constructor Β· intro h by_contra hc have : p * n β€ p * (k - 1) := Nat.mul_le_mul_left p (by omega) have e : p * (k - 1) β€ k * (p - 1) + 1 := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© obtain β¨m, rflβ© : β m, k = m + 1 := β¨k - 1, by omegaβ© simp only [Nat.add_sub_cancel] at hk β’ nlinarith omega Β· intro h have h3 : k * (p - 1) β€ n * (p - 1) := Nat.mul_le_mul_right _ h have e : n * (p - 1) + n = p * n := by obtain β¨q, rflβ© : β q, p = q + 1 := β¨p - 1, by omegaβ© simp only [Nat.add_sub_cancel] ring omega /-- `j_{b,i} = p i + [b-i]_{p-1}`, except `j_{0,0} = p - 1` (cor:D). -/def jD (p b i : β) : β := if b = 0 β§ i = 0 then p - 1 else dseed p b i lemma brk_self {p b : β} (hp : 2 β€ p) (hb : b < p - 1) : brk p b 0 = b := brk_eq_of hp hb (by simp) /-- Arithmetic of cor:D: `j_{b,i} > 0`, `j_{b,i} β‘ b`, and `u(j_{b,i}) < p r β i < r`. -/lemma jD_crit {p : β} (hp : p.Prime) (r : β β ββ) {b : β} (hb : b < p - 1) (i : β) : 0 < jD p b i β§ jD p b i % (p - 1) = b β§ (Crit p r (jD p b i) β (i : ββ) < r b) := by have h2 := hp.two_le unfold jD split_ifs with h Β· obtain β¨rfl, rflβ© := h refine β¨by omega, Nat.mod_self _, ?_β© unfold Crit uPart rw [Nat.sub_add_cancel (by omega : 1 β€ p), ordCompl_prime_self hp, Nat.mod_self] have := key_lt (i := 0) (e := 1) hp.pos (by omega) (r 0) simpa using this Β· have hm := seed_mod h2 hb 0 i simp only [Function.iterate_zero, id] at hm refine β¨?_, hm, ?_β© Β· unfold dseed rcases Nat.eq_zero_or_pos i with rfl | hi Β· rw [brk_self h2 hb]; omega Β· have : p * 1 β€ p * i := Nat.mul_le_mul_left p hi omega Β· unfold Crit have hu := (seed_decomp hp b 0 i).2 simp only [Function.iterate_zero, id] at hu rw [hu, hm] unfold dseed have := brk_lt h2 b i rw [add_assoc] exact key_lt hp.pos (by omega) _ /-- **Corollary D** (cor:D), first statement, with thm:A and thm:B (`hB`) as hypotheses:if `j_{b,i} < P - p^{a-1}`, the `Ο`-component of `G_{P + j_{b,i}}` vanishes iff `i < r_{Ο,b}`.(Stated for every `b β [0,p-2]`; the paper restricts to even `b`.) -/theorem cor_D {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a : β} {Vanish : β β Prop} (hB : β j, j < p ^ a - p ^ (a - 1) β (Vanish j β Dep a j)) {b : β} (hb : b < p - 1) {i : β} (hj : jD p b i < p ^ a - p ^ (a - 1)) : Vanish (jD p b i) β (i : ββ) < r b := by obtain β¨h0, hm, hcβ© := jD_crit hp r hb i rw [hB _ hj, hA a _ h0 (lt_of_lt_of_le hj (Nat.sub_le _ _)), hc] lemma jD_zero_lt {p : β} (hp : 2 β€ p) (i : β) : jD p 0 i < p * (i + 1) := by unfold jD split_ifs with h Β· obtain β¨-, rflβ© := h; omega Β· unfold dseed have := brk_lt hp 0 i rw [mul_add, mul_one] omega /-- cor:D: the `j_{0,i}` increase with `i`. -/theorem jD_zero_strictMono {p : β} (hp : 2 β€ p) : StrictMono (jD p 0) := by apply strictMono_nat_of_lt_succ intro i have h1 := jD_zero_lt hp i have h2 : p * (i + 1) β€ jD p 0 (i + 1) := by unfold jD rw [ite_eq_right (by omega)] unfold dseed omega omega /-- cor:D: `j_{0,i} < P - p^{a-1}` for `i β€ p^{a-1} - p^{a-2} - 1`. -/theorem jD_zero_range {p : β} (hp : 2 β€ p) {a : β} (ha : 2 β€ a) {i : β} (hi : i < p ^ (a - 1) - p ^ (a - 2)) : jD p 0 i < p ^ a - p ^ (a - 1) := by have h1 := jD_zero_lt hp i have e : p ^ a - p ^ (a - 1) = p * (p ^ (a - 1) - p ^ (a - 2)) := by rw [Nat.mul_sub, β pow_succ', β pow_succ', show a - 1 + 1 = a by omega, show a - 2 + 1 = a - 1 by omega] have : p * (i + 1) β€ p * (p ^ (a - 1) - p ^ (a - 2)) := Nat.mul_le_mul_left p hi omega /-- **Corollary D** (cor:D), "in particular": if `r_{Ο,0} = n < p^{a-1} - p^{a-2}`, then amongthe indices `0 β€ i β€ p^{a-1} - p^{a-2} - 1` (all within the range of thm:B) the components at`P + j_{0,i}` vanish exactly for the first `n` of them: the vanishing set is `{0, β¦, n-1}`. -/theorem cor_D_first {p : β} (hp : p.Prime) {r : β β ββ} {Dep : β β β β Prop} (hA : ThmA p r Dep) {a : β} (ha : 2 β€ a) {Vanish : β β Prop} [DecidablePred Vanish] (hB : β j, j < p ^ a - p ^ (a - 1) β (Vanish j β Dep a j)) {n : β} (hr : r 0 = n) (hn : n < p ^ (a - 1) - p ^ (a - 2)) : (range (p ^ (a - 1) - p ^ (a - 2))).filter (fun i => Vanish (jD p 0 i)) = range n := by have h2 := hp.two_le ext i simp only [mem_filter, mem_range] constructor Β· rintro β¨hi, hvβ© have := (cor_D hp hA hB (by omega : 0 < p - 1) (jD_zero_range h2 ha hi)).mp hv rw [hr] at this exact_mod_cast this Β· intro hi refine β¨by omega, ?_β© rw [cor_D hp hA hB (by have := hp.two_le; omega) (jD_zero_range hp.two_le ha (by omega)), hr] exact_mod_cast hi /-! ## Checks against Remark rem:scope (`p = 5`, `r_0 = 6`) -/ /-- `k* = β5Β·6/4β = 8`. -/example : kstar 5 6 = 8 := by decide /-- The seeds `j_{0,i}`, `i = 0, β¦, 6`, for `p = 5`: `4, 8, 12, 16, 20, 28, 32`. -/example : (List.range 7).map (jD 5 0) = [4, 8, 12, 16, 20, 28, 32] := by decide end FilasIII