πŸ›οΈ Atlasβœ’οΈFormalizations.NumberTheory.NumberField.InvariantOrders.TriangularBasis view on GitHub β†—45 theorems
/-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 Formalizations.NumberTheory.NumberField.InvariantOrders.Saturationpublic import Mathlib.SetTheory.Cardinal.Finitepublic import Mathlib.GroupTheory.QuotientGroup.Basicpublic import Mathlib.Tactic.TFAE /-!# The quotient `A/β„€[Ξ±]` of a quartic order with a triangular basis In the model of `Saturation` (`K = β„š(Ξ±)` as `β„šβ΄`, `β„€[Ξ±] = ℀⁴`), an order `M` is given with atriangular `β„€`-basis `1, ω₁, Ο‰β‚‚, ω₃`, `Ο‰_k = (αᡏ + P_k(Ξ±))/d_k`, `P_k ∈ β„€[X]` of degree `< k`,`0 < d₁ ∣ dβ‚‚ ∣ d₃` (the structure `Louboutin.Triang`; the existence of such a basis is cited fromLouboutin 2020, Prop. 10, and Cohen 1993, Cor. 4.7.6, and enters as data). That it is a basis,that `β„€[Ξ±] βŠ† M`, and the flags `M ∩ V_k = β„€ + ℀ω₁ + … + β„€Ο‰_k` are proved. For `M = A` thehypothesis `d₁ = 1` is Louboutin's Theorem 13. `Triang.ofData` realizes every datum, so thehypotheses are not contradictory. ## Main results * `Louboutin.Triang.quotient_equiv`: `M/β„€[Ξ±] ≃+ β„€/d₁ Γ— β„€/dβ‚‚ Γ— β„€/d₃`.* `Louboutin.Triang.quotient_equiv_T1`, `Louboutin.Triang.index_V2`: with `d₁ = 1`,  `A/β„€[Ξ±] ≃+ β„€/dβ‚‚ Γ— β„€/d₃` and `[A ∩ Vβ‚‚ : Lβ‚‚] = dβ‚‚`.* `Louboutin.Triang.T1_i_iff_ii`, `T1_ii_iff_iii`, `T1_iii_iff_iv`, `T1_iii_iff_v`,  `Louboutin.Triang.prop_T1`: the five equivalent conditions.* `Louboutin.Triang.T1_mod_p`: `p ∣ dβ‚‚` iff `1, Ξ±, Ξ±Β²` are dependent over `𝔽_p` in `A/pA`. ## References * S. R. Louboutin, *On the order generated by the conjugates of an algebraic integer*, in:  Algebra, Logic and Number Theory, Banach Center Publ. 121 (2020), 107–124, doi:10.4064/bc121-10.* S. R. Louboutin, *When is the order generated by a cubic, quartic or quintic algebraic unit Galois  invariant: three conjectures*, Czechoslovak Math. J. 70 (2020), 905–919,  doi:10.21136/CMJ.2020.0019-19.* C. MarΓ­n, *Orders generated by conjugates of Galois quartic integers*, preprint (2026).-/ @[expose] public section namespace Louboutin /-- `apow i = αⁱ` in the power basis. -/abbrev apow (i : Fin 4) : Fin 4 β†’ β„š := Pi.single i 1 /-- Vβ‚‚ = β„š + β„šΞ± + β„šΞ±Β². -/def V2 : AddSubgroup (Fin 4 β†’ β„š) where  carrier := {x | x 3 = 0}  zero_mem' := rfl  add_mem' := by    intro a b ha hb    simp only [Set.mem_ofPred_eq, Pi.add_apply] at *    rw [ha, hb, add_zero]  neg_mem' := by    intro a ha    simp only [Set.mem_ofPred_eq, Pi.neg_apply] at *    rw [ha, neg_zero] /-- Lβ‚‚ = β„€ + β„€Ξ± + β„€Ξ±Β² = β„€[Ξ±] ∩ Vβ‚‚. -/def L2 : AddSubgroup (Fin 4 β†’ β„š) := Z4 βŠ“ V2 /-- ω₁ = (Ξ± + a)/d. -/def omega1 (d : β„•) (a : β„€) : Fin 4 β†’ β„š := ![a / d, 1 / d, 0, 0]/-- Ο‰β‚‚ = (Ξ±Β² + bΞ± + a)/d. -/def omega2 (d : β„•) (a b : β„€) : Fin 4 β†’ β„š := ![a / d, b / d, 1 / d, 0]/-- ω₃ = (Ξ±Β³ + cΞ±Β² + bΞ± + a)/d. -/def omega3 (d : β„•) (a b c : β„€) : Fin 4 β†’ β„š := ![a / d, b / d, c / d, 1 / d] /-- nβ‚€ + n₁ω₁ + nβ‚‚Ο‰β‚‚ + n₃ω₃. -/def combOf (ω₁ Ο‰β‚‚ ω₃ : Fin 4 β†’ β„š) (n : Fin 4 β†’ β„€) : Fin 4 β†’ β„š :=  n 0 β€’ apow 0 + n 1 β€’ ω₁ + n 2 β€’ Ο‰β‚‚ + n 3 β€’ ω₃ /-- The triangular basis of the order `M` (cited, taken as data): `1, ω₁, Ο‰β‚‚, ω₃` with    `Ο‰_k = (αᡏ + P_k(Ξ±))/d_k`, `P_k ∈ β„€[X]`, `deg P_k < k`, and `d₁ ∣ dβ‚‚ ∣ d₃`. -/structure Triang (M : AddSubgroup (Fin 4 β†’ β„š)) where  d₁ : β„•  dβ‚‚ : β„•  d₃ : β„•  d₁_pos : 0 < d₁  dβ‚‚_pos : 0 < dβ‚‚  d₃_pos : 0 < d₃  d₁_dvd : d₁ ∣ dβ‚‚  dβ‚‚_dvd : dβ‚‚ ∣ d₃  p₁₀ : β„€  pβ‚‚β‚€ : β„€  p₂₁ : β„€  p₃₀ : β„€  p₃₁ : β„€  p₃₂ : β„€  one_mem : apow 0 ∈ M  ω₁_mem : omega1 d₁ p₁₀ ∈ M  Ο‰β‚‚_mem : omega2 dβ‚‚ pβ‚‚β‚€ p₂₁ ∈ M  ω₃_mem : omega3 d₃ p₃₀ p₃₁ p₃₂ ∈ M  span : βˆ€ x ∈ M, βˆƒ n : Fin 4 β†’ β„€,    x = combOf (omega1 d₁ p₁₀) (omega2 dβ‚‚ pβ‚‚β‚€ p₂₁) (omega3 d₃ p₃₀ p₃₁ p₃₂) n namespace Triang variable {M : AddSubgroup (Fin 4 β†’ β„š)} (B : Triang M) /-- `ω₁` of the triangular basis. -/def ω₁ : Fin 4 β†’ β„š := omega1 B.d₁ B.p₁₀/-- `Ο‰β‚‚` of the triangular basis. -/def Ο‰β‚‚ : Fin 4 β†’ β„š := omega2 B.dβ‚‚ B.pβ‚‚β‚€ B.p₂₁/-- `ω₃` of the triangular basis. -/def ω₃ : Fin 4 β†’ β„š := omega3 B.d₃ B.p₃₀ B.p₃₁ B.p₃₂/-- Coordinates in the basis `1, ω₁, Ο‰β‚‚, ω₃`. -/def comb (n : Fin 4 β†’ β„€) : Fin 4 β†’ β„š := combOf B.ω₁ B.Ο‰β‚‚ B.ω₃ n theorem d₁_q : (B.d₁ : β„š) β‰  0 := by exact_mod_cast B.d₁_pos.ne'theorem dβ‚‚_q : (B.dβ‚‚ : β„š) β‰  0 := by exact_mod_cast B.dβ‚‚_pos.ne'theorem d₃_q : (B.d₃ : β„š) β‰  0 := by exact_mod_cast B.d₃_pos.ne' theorem comb_apply_zero (n : Fin 4 β†’ β„€) :    B.comb n 0 = n 0 + n 1 * B.p₁₀ / B.d₁ + n 2 * B.pβ‚‚β‚€ / B.dβ‚‚ + n 3 * B.p₃₀ / B.d₃ := by  simp [comb, combOf, ω₁, Ο‰β‚‚, ω₃, omega1, omega2, omega3]  ring theorem comb_apply_one (n : Fin 4 β†’ β„€) :    B.comb n 1 = n 1 / B.d₁ + n 2 * B.p₂₁ / B.dβ‚‚ + n 3 * B.p₃₁ / B.d₃ := by  simp [comb, combOf, ω₁, Ο‰β‚‚, ω₃, omega1, omega2, omega3]  ring theorem comb_apply_two (n : Fin 4 β†’ β„€) :    B.comb n 2 = n 2 / B.dβ‚‚ + n 3 * B.p₃₂ / B.d₃ := by  simp [comb, combOf, ω₁, Ο‰β‚‚, ω₃, omega1, omega2, omega3]  ring theorem comb_apply_three (n : Fin 4 β†’ β„€) : B.comb n 3 = n 3 / B.d₃ := by  simp [comb, combOf, ω₁, Ο‰β‚‚, ω₃, omega1, omega2, omega3]  ring /-- Auxiliary: if `k = n/d + q` with `k`, `q` integers, then `d ∣ n`. -/theorem dvd_of_cast_eq {d : β„•} (hd : 0 < d) {n k q : β„€} (h : (k : β„š) = n / d + q) :    (d : β„€) ∣ n := by  have hd0 : (d : β„š) β‰  0 := by exact_mod_cast hd.ne'  refine ⟨k - q, ?_⟩  have : (n : β„š) = d * (k - q) := by    rw [h]; field_simp; ring  exact_mod_cast this /-- Key lemma: `nβ‚€ + n₁ω₁ + nβ‚‚Ο‰β‚‚ + n₃ω₃ ∈ β„€[Ξ±] ↔ d₁ ∣ n₁, dβ‚‚ ∣ nβ‚‚, d₃ ∣ n₃`. -/theorem comb_mem_Z4_iff (n : Fin 4 β†’ β„€) :    B.comb n ∈ Z4 ↔ (B.d₁ : β„€) ∣ n 1 ∧ (B.dβ‚‚ : β„€) ∣ n 2 ∧ (B.d₃ : β„€) ∣ n 3 := by  have h1q := B.d₁_q  have h2q := B.dβ‚‚_q  have h3q := B.d₃_q  constructor  Β· intro h    obtain ⟨k3, h3⟩ := h 3    obtain ⟨k2, h2⟩ := h 2    obtain ⟨k1, h1⟩ := h 1    rw [B.comb_apply_three] at h3    rw [B.comb_apply_two] at h2    rw [B.comb_apply_one] at h1    have e3 : (B.d₃ : β„€) ∣ n 3 := dvd_of_cast_eq B.d₃_pos (k := k3) (q := 0) (by rw [h3]; simp)    obtain ⟨m3, hm3⟩ := e3    have e2 : (B.dβ‚‚ : β„€) ∣ n 2 := dvd_of_cast_eq B.dβ‚‚_pos (k := k2) (q := m3 * B.p₃₂) (by      rw [h2, hm3]; push_cast; field_simp)    obtain ⟨m2, hm2⟩ := e2    have e1 : (B.d₁ : β„€) ∣ n 1 := dvd_of_cast_eq B.d₁_pos (k := k1)        (q := m2 * B.p₂₁ + m3 * B.p₃₁) (by      rw [h1, hm2, hm3]; push_cast; field_simp; ring)    exact ⟨e1, ⟨m2, hm2⟩, ⟨m3, hm3⟩⟩  Β· rintro ⟨⟨a1, ha1⟩, ⟨a2, ha2⟩, ⟨a3, ha3⟩⟩ i    fin_cases i    Β· refine ⟨n 0 + a1 * B.p₁₀ + a2 * B.pβ‚‚β‚€ + a3 * B.p₃₀, ?_⟩      show _ = B.comb n 0      rw [B.comb_apply_zero, ha1, ha2, ha3]; push_cast; field_simp    Β· refine ⟨a1 + a2 * B.p₂₁ + a3 * B.p₃₁, ?_⟩      show _ = B.comb n 1      rw [B.comb_apply_one, ha1, ha2, ha3]; push_cast; field_simp    Β· refine ⟨a2 + a3 * B.p₃₂, ?_⟩      show _ = B.comb n 2      rw [B.comb_apply_two, ha2, ha3]; push_cast; field_simp    Β· refine ⟨a3, ?_⟩      show _ = B.comb n 3      rw [B.comb_apply_three, ha3]; push_cast; field_simp theorem comb_add (n m : Fin 4 β†’ β„€) : B.comb (n + m) = B.comb n + B.comb m := by  simp only [comb, combOf, Pi.add_apply, add_smul]; abel theorem comb_zero : B.comb 0 = 0 := by simp [comb, combOf] theorem comb_mem (n : Fin 4 β†’ β„€) : B.comb n ∈ M :=  M.add_mem (M.add_mem (M.add_mem (M.zsmul_mem B.one_mem _) (M.zsmul_mem B.ω₁_mem _))    (M.zsmul_mem B.Ο‰β‚‚_mem _)) (M.zsmul_mem B.ω₃_mem _) /-- `comb` as a homomorphism `℀⁴ β†’ M`. -/def combHom : (Fin 4 β†’ β„€) β†’+ M where  toFun n := ⟨B.comb n, B.comb_mem n⟩  map_zero' := Subtype.ext B.comb_zero  map_add' n m := Subtype.ext (B.comb_add n m) theorem combHom_surjective : Function.Surjective B.combHom := by  rintro ⟨x, hx⟩  obtain ⟨n, hn⟩ := B.span x hx  exact ⟨n, Subtype.ext hn.symm⟩ /-- `1, ω₁, Ο‰β‚‚, ω₃` are linearly independent: a `β„€`-basis of `M`. -/theorem comb_injective : Function.Injective B.comb := by  intro n m h  have h1q := B.d₁_q  have h2q := B.dβ‚‚_q  have h3q := B.d₃_q  have c3 := congrFun h 3  have c2 := congrFun h 2  have c1 := congrFun h 1  have c0 := congrFun h 0  rw [B.comb_apply_three, B.comb_apply_three] at c3  rw [B.comb_apply_two, B.comb_apply_two] at c2  rw [B.comb_apply_one, B.comb_apply_one] at c1  rw [B.comb_apply_zero, B.comb_apply_zero] at c0  have e3 : (n 3 : β„š) = m 3 := (div_left_inj' h3q).mp c3  rw [e3] at c2 c1 c0  have e2 : (n 2 : β„š) = m 2 := (div_left_inj' h2q).mp (add_right_cancel c2)  rw [e2] at c1 c0  have e1 : (n 1 : β„š) = m 1 := (div_left_inj' h1q).mp (add_right_cancel (add_right_cancel c1))  rw [e1] at c0  have e0 : (n 0 : β„š) = m 0 := add_right_cancel (add_right_cancel (add_right_cancel c0))  funext i  fin_cases i  Β· exact_mod_cast e0  Β· exact_mod_cast e1  Β· exact_mod_cast e2  Β· exact_mod_cast e3 /-- Flags, `k = 2`: `M ∩ Vβ‚‚ = β„€ + ℀ω₁ + β„€Ο‰β‚‚`. -/theorem inter_V2 {x : Fin 4 β†’ β„š} (hx : x ∈ M) (h3 : x 3 = 0) :    βˆƒ n : Fin 4 β†’ β„€, n 3 = 0 ∧ x = B.comb n := by  obtain ⟨n, rfl⟩ := B.span x hx  refine ⟨n, ?_, rfl⟩  have h := h3  change B.comb n 3 = 0 at h  rw [B.comb_apply_three, div_eq_zero_iff] at h  rcases h with h | h  Β· exact_mod_cast h  Β· exact absurd h B.d₃_q /-- Flags, `k = 1`: `M ∩ V₁ = β„€ + ℀ω₁`. -/theorem inter_V1 {x : Fin 4 β†’ β„š} (hx : x ∈ M) (h3 : x 3 = 0) (h2 : x 2 = 0) :    βˆƒ n : Fin 4 β†’ β„€, n 3 = 0 ∧ n 2 = 0 ∧ x = B.comb n := by  obtain ⟨n, hn3, rfl⟩ := B.inter_V2 hx h3  refine ⟨n, hn3, ?_, rfl⟩  have h := h2  change B.comb n 2 = 0 at h  rw [B.comb_apply_two, hn3] at h  simp only [Int.cast_zero, zero_mul, zero_div, add_zero, div_eq_zero_iff] at h  rcases h with h | h  Β· exact_mod_cast h  Β· exact absurd h B.dβ‚‚_q include B in/-- β„€[Ξ±] βŠ† M. -/theorem Z4_le : Z4 ≀ M := by  intro x hx  choose k hk using hx  -- `x` is the image of an explicit coefficient vector (triangular inversion)  have h1q := B.d₁_q  have h2q := B.dβ‚‚_q  have h3q := B.d₃_q  set m3 : β„€ := B.d₃ * k 3  set m2 : β„€ := B.dβ‚‚ * (k 2 - k 3 * B.p₃₂)  set m1 : β„€ := B.d₁ * (k 1 - (k 2 - k 3 * B.p₃₂) * B.p₂₁ - k 3 * B.p₃₁)  set m0 : β„€ := k 0 - (k 1 - (k 2 - k 3 * B.p₃₂) * B.p₂₁ - k 3 * B.p₃₁) * B.p₁₀    - (k 2 - k 3 * B.p₃₂) * B.pβ‚‚β‚€ - k 3 * B.p₃₀  have : x = B.comb ![m0, m1, m2, m3] := by    funext i    fin_cases i    Β· show x 0 = B.comb _ 0      rw [B.comb_apply_zero, ← hk 0]; simp [m0, m1, m2, m3]; field_simp; ring    Β· show x 1 = B.comb _ 1      rw [B.comb_apply_one, ← hk 1]; simp [m1, m2, m3]; field_simp; ring    Β· show x 2 = B.comb _ 2      rw [B.comb_apply_two, ← hk 2]; simp [m2, m3]; field_simp; ring    Β· show x 3 = B.comb _ 3      rw [B.comb_apply_three, ← hk 3]; simp [m3]; field_simp  rw [this]; exact B.comb_mem _ theorem comb_zsmul (k : β„€) (n : Fin 4 β†’ β„€) : B.comb (k β€’ n) = k β€’ B.comb n := by  exact congrArg Subtype.val (map_zsmul B.combHom k n) theorem comb_nsmul (k : β„•) (n : Fin 4 β†’ β„€) : B.comb (k β€’ n) = k β€’ B.comb n := by  exact congrArg Subtype.val (map_nsmul B.combHom k n) /-- `(M ∩ Vβ‚‚)/Lβ‚‚` is killed by `dβ‚‚`: `x ∈ M`, `x ∈ Vβ‚‚` β‡’ `dβ‚‚ x ∈ β„€[Ξ±]`. -/theorem dβ‚‚_smul_mem {x : Fin 4 β†’ β„š} (hx : x ∈ M) (h3 : x 3 = 0) : (B.dβ‚‚ : β„€) β€’ x ∈ Z4 := by  obtain ⟨n, hn3, rfl⟩ := B.inter_V2 hx h3  rw [← B.comb_zsmul, B.comb_mem_Z4_iff]  simp only [Pi.smul_apply, smul_eq_mul, hn3, mul_zero, dvd_zero, and_true]  exact ⟨Dvd.dvd.mul_right (Int.natCast_dvd_natCast.mpr B.d₁_dvd) _, dvd_mul_right _ _⟩ end Triang /-! ### The quotient `A/β„€[Ξ±]` -/ /-- Auxiliary: `G β§Έ H ≃+ Q` if `f : P β†  G`, `g : P β†  Q` and `f n ∈ H ↔ g n = 0`. -/noncomputable def quotEquivOf {P G Q : Type*} [AddCommGroup P] [AddCommGroup G] [AddCommGroup Q]    (H : AddSubgroup G) (f : P β†’+ G) (hf : Function.Surjective f) (g : P β†’+ Q)    (hg : Function.Surjective g) (hker : βˆ€ n, f n ∈ H ↔ g n = 0) : G β§Έ H ≃+ Q :=  let ψ : P β†’+ G β§Έ H := (QuotientAddGroup.mk' H).comp f  have hψ : Function.Surjective ψ := (QuotientAddGroup.mk'_surjective H).comp hf  have hk : ψ.ker = g.ker := by    ext n    rw [AddMonoidHom.mem_ker, AddMonoidHom.mem_ker, ← hker]    exact QuotientAddGroup.eq_zero_iff (f n)  (QuotientAddGroup.quotientKerEquivOfSurjective ψ hψ).symm.trans    ((QuotientAddGroup.quotientAddEquivOfEq hk).trans      (QuotientAddGroup.quotientKerEquivOfSurjective g hg)) /-- n ↦ (n₁ mod a, nβ‚‚ mod b, n₃ mod c). -/def red3 (a b c : β„•) : (Fin 4 β†’ β„€) β†’+ ZMod a Γ— ZMod b Γ— ZMod c where  toFun n := ((n 1 : ZMod a), (n 2 : ZMod b), (n 3 : ZMod c))  map_zero' := by simp  map_add' n m := by simp theorem red3_surjective {a b c : β„•} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) :    Function.Surjective (red3 a b c) := by  have : NeZero a := ⟨ha.ne'⟩  have : NeZero b := ⟨hb.ne'⟩  have : NeZero c := ⟨hc.ne'⟩  rintro ⟨x, y, z⟩  refine ⟨![0, (x.val : β„€), (y.val : β„€), (z.val : β„€)], ?_⟩  simp [red3] theorem red3_eq_zero_iff (a b c : β„•) (n : Fin 4 β†’ β„€) :    red3 a b c n = 0 ↔ (a : β„€) ∣ n 1 ∧ (b : β„€) ∣ n 2 ∧ (c : β„€) ∣ n 3 := by  simp only [red3, AddMonoidHom.coe_mk, ZeroHom.coe_mk, Prod.ext_iff, Prod.fst_zero,    Prod.snd_zero, ZMod.intCast_zmod_eq_zero_iff_dvd] /-- n ↦ (n₁ mod a, nβ‚‚ mod b). -/def red2 (a b : β„•) : (Fin 4 β†’ β„€) β†’+ ZMod a Γ— ZMod b where  toFun n := ((n 1 : ZMod a), (n 2 : ZMod b))  map_zero' := by simp  map_add' n m := by simp theorem red2_surjective {a b : β„•} (ha : 0 < a) (hb : 0 < b) :    Function.Surjective (red2 a b) := by  have : NeZero a := ⟨ha.ne'⟩  have : NeZero b := ⟨hb.ne'⟩  rintro ⟨x, y⟩  refine ⟨![0, (x.val : β„€), (y.val : β„€), 0], ?_⟩  simp [red2] theorem red2_eq_zero_iff (a b : β„•) (n : Fin 4 β†’ β„€) :    red2 a b n = 0 ↔ (a : β„€) ∣ n 1 ∧ (b : β„€) ∣ n 2 := by  simp only [red2, AddMonoidHom.coe_mk, ZeroHom.coe_mk, Prod.ext_iff, Prod.fst_zero,    Prod.snd_zero, ZMod.intCast_zmod_eq_zero_iff_dvd] namespace Triang variable {M : AddSubgroup (Fin 4 β†’ β„š)} (B : Triang M) /-- `M/β„€[Ξ±] β‰… β„€/d₁ Γ— β„€/dβ‚‚ Γ— β„€/d₃`. -/noncomputable def quotient_equiv :    (M β§Έ Z4.addSubgroupOf M) ≃+ ZMod B.d₁ Γ— ZMod B.dβ‚‚ Γ— ZMod B.d₃ :=  quotEquivOf _ B.combHom B.combHom_surjective (red3 B.d₁ B.dβ‚‚ B.d₃)    (red3_surjective B.d₁_pos B.dβ‚‚_pos B.d₃_pos) (fun n => by      rw [AddSubgroup.mem_addSubgroupOf, red3_eq_zero_iff]      exact B.comb_mem_Z4_iff n) /-- With `d₁ = 1`, `A/β„€[Ξ±] β‰… β„€/dβ‚‚ Γ— β„€/d₃`. -/theorem quotient_equiv_T1 (h1 : B.d₁ = 1) :    Nonempty ((M β§Έ Z4.addSubgroupOf M) ≃+ ZMod B.dβ‚‚ Γ— ZMod B.d₃) := by  have e := B.quotient_equiv  rw [h1] at e  exact ⟨e.trans AddEquiv.uniqueProd⟩ /-- [A : β„€[Ξ±]] = d₁ dβ‚‚ d₃. -/theorem index_eq : (Z4.addSubgroupOf M).index = B.d₁ * B.dβ‚‚ * B.d₃ := by  rw [AddSubgroup.index, Nat.card_congr B.quotient_equiv.toEquiv, Nat.card_prod, Nat.card_prod,    Nat.card_zmod, Nat.card_zmod, Nat.card_zmod, mul_assoc] /-! ### [A ∩ Vβ‚‚ : Lβ‚‚] = dβ‚‚ -/ /-- `n ↦ nβ‚€ + n₁ω₁ + nβ‚‚Ο‰β‚‚ ∈ M ∩ Vβ‚‚` (`n₃` is ignored). -/def combHom2 : (Fin 4 β†’ β„€) β†’+ (M βŠ“ V2 : AddSubgroup (Fin 4 β†’ β„š)) where  toFun n := ⟨B.comb ![n 0, n 1, n 2, 0], AddSubgroup.mem_inf.mpr ⟨B.comb_mem _, by    show B.comb _ 3 = 0    rw [B.comb_apply_three]; simp⟩⟩  map_zero' := by    apply Subtype.ext    show B.comb _ = 0    rw [← B.comb_zero]; congr 1; funext i; fin_cases i <;> rfl  map_add' n m := by    apply Subtype.ext    show B.comb _ = B.comb _ + B.comb _    rw [← B.comb_add]; congr 1; funext i; fin_cases i <;> simp theorem combHom2_surjective : Function.Surjective B.combHom2 := by  rintro ⟨x, hx⟩  obtain ⟨hxM, hx3⟩ := AddSubgroup.mem_inf.mp hx  obtain ⟨n, hn3, rfl⟩ := B.inter_V2 hxM hx3  refine ⟨n, Subtype.ext ?_⟩  show B.comb _ = B.comb _  congr 1; funext i; fin_cases i <;> simp [hn3] /-- (M ∩ Vβ‚‚)/Lβ‚‚ β‰… β„€/d₁ Γ— β„€/dβ‚‚. -/noncomputable def quotient_equiv_V2 :    ((M βŠ“ V2 : AddSubgroup (Fin 4 β†’ β„š)) β§Έ L2.addSubgroupOf (M βŠ“ V2)) ≃+ ZMod B.d₁ Γ— ZMod B.dβ‚‚ :=  quotEquivOf _ B.combHom2 B.combHom2_surjective (red2 B.d₁ B.dβ‚‚)    (red2_surjective B.d₁_pos B.dβ‚‚_pos) (fun n => by      rw [AddSubgroup.mem_addSubgroupOf, red2_eq_zero_iff]      show B.comb _ ∈ Z4 βŠ“ V2 ↔ _      rw [AddSubgroup.mem_inf, B.comb_mem_Z4_iff]      have h3 : B.comb ![n 0, n 1, n 2, 0] ∈ V2 := by        show B.comb _ 3 = 0        rw [B.comb_apply_three]; simp      simp [h3]) /-- [A ∩ Vβ‚‚ : Lβ‚‚] = d₁ dβ‚‚. -/theorem index_V2_eq : (L2.addSubgroupOf (M βŠ“ V2)).index = B.d₁ * B.dβ‚‚ := by  rw [AddSubgroup.index, Nat.card_congr B.quotient_equiv_V2.toEquiv, Nat.card_prod,    Nat.card_zmod, Nat.card_zmod] /-- With `d₁ = 1`, `dβ‚‚ = [A ∩ Vβ‚‚ : Lβ‚‚]`. -/theorem index_V2 (h1 : B.d₁ = 1) : (L2.addSubgroupOf (M βŠ“ V2)).index = B.dβ‚‚ := by  rw [B.index_V2_eq, h1, one_mul] end Triang /-! ### The five conditions -/ /-- 1Β·cβ‚€ + Ξ±Β·c₁ + Ξ±Β²Β·cβ‚‚ + ω·c₃. -/def lin (Ο‰ : Fin 4 β†’ β„š) (c : Fin 4 β†’ β„€) : Fin 4 β†’ β„š :=  c 0 β€’ apow 0 + c 1 β€’ apow 1 + c 2 β€’ apow 2 + c 3 β€’ Ο‰ /-- (i): `{1, Ξ±, Ξ±Β², Ο‰}` is a `β„€`-basis of `M` (`Ο‰ ∈ M` and unique integer coordinates). -/def BasisWith (M : AddSubgroup (Fin 4 β†’ β„š)) (Ο‰ : Fin 4 β†’ β„š) : Prop :=  Ο‰ ∈ M ∧ βˆ€ x ∈ M, βˆƒ! c : Fin 4 β†’ β„€, x = lin Ο‰ c /-- (v): the set `{e β‰₯ 1 | eM βŠ† β„€[Ξ±]}`. -/def expSet (M : AddSubgroup (Fin 4 β†’ β„š)) : Set β„• := {e | 1 ≀ e ∧ βˆ€ x ∈ M, e β€’ x ∈ Z4} theorem lin_apply_three (Ο‰ : Fin 4 β†’ β„š) (c : Fin 4 β†’ β„€) : lin Ο‰ c 3 = c 3 * Ο‰ 3 := by  simp [lin] theorem lin_apply_two (Ο‰ : Fin 4 β†’ β„š) (c : Fin 4 β†’ β„€) : lin Ο‰ c 2 = c 2 + c 3 * Ο‰ 2 := by  simp [lin] theorem lin_apply_one (Ο‰ : Fin 4 β†’ β„š) (c : Fin 4 β†’ β„€) : lin Ο‰ c 1 = c 1 + c 3 * Ο‰ 1 := by  simp [lin] theorem lin_apply_zero (Ο‰ : Fin 4 β†’ β„š) (c : Fin 4 β†’ β„€) : lin Ο‰ c 0 = c 0 + c 3 * Ο‰ 0 := by  simp [lin] theorem lin_injective {Ο‰ : Fin 4 β†’ β„š} (hΟ‰ : Ο‰ 3 β‰  0) : Function.Injective (lin Ο‰) := by  intro c c' h  have c3 := congrFun h 3  have c2 := congrFun h 2  have c1 := congrFun h 1  have c0 := congrFun h 0  rw [lin_apply_three, lin_apply_three] at c3  rw [lin_apply_two, lin_apply_two] at c2  rw [lin_apply_one, lin_apply_one] at c1  rw [lin_apply_zero, lin_apply_zero] at c0  have e3 : (c 3 : β„š) = c' 3 := mul_right_cancelβ‚€ hΟ‰ c3  rw [e3] at c2 c1 c0  have e2 : (c 2 : β„š) = c' 2 := add_right_cancel c2  have e1 : (c 1 : β„š) = c' 1 := add_right_cancel c1  have e0 : (c 0 : β„š) = c' 0 := add_right_cancel c0  funext i  fin_cases i  Β· exact_mod_cast e0  Β· exact_mod_cast e1  Β· exact_mod_cast e2  Β· exact_mod_cast e3 namespace Triang variable {M : AddSubgroup (Fin 4 β†’ β„š)} (B : Triang M) include B in/-- (i) β‡’ (ii). -/theorem saturated_of_basis {Ο‰ : Fin 4 β†’ β„š} (hΟ‰ : BasisWith M Ο‰) : Saturated M := by  have hne : Ο‰ 3 β‰  0 := by    intro h0    obtain ⟨c, hc, -⟩ := hΟ‰.2 _ B.ω₃_mem    have := congrFun hc 3    rw [lin_apply_three, h0, mul_zero] at this    simp [omega3] at this    exact B.d₃_pos.ne' this  intro x hx hx3  obtain ⟨c, rfl, -⟩ := hΟ‰.2 x hx  rw [lin_apply_three] at hx3  have hc3 : (c 3 : β„š) = 0 := (mul_eq_zero.mp hx3).resolve_right hne  intro i  fin_cases i  Β· exact ⟨c 0, by simp [lin, hc3]⟩  Β· exact ⟨c 1, by simp [lin, hc3]⟩  Β· exact ⟨c 2, by simp [lin, hc3]⟩  Β· exact ⟨0, by simp [lin, hc3]⟩ /-- (ii) β‡’ (iii). -/theorem dβ‚‚_eq_one_of_saturated (hsat : Saturated M) : B.dβ‚‚ = 1 := by  have h := hsat _ B.Ο‰β‚‚_mem (by simp [omega2])  obtain ⟨k, hk⟩ := h 2  have hk' : (k : β„š) = ((1 : β„€) : β„š) / B.dβ‚‚ + ((0 : β„€) : β„š) := by    rw [hk]; simp [omega2]  have := dvd_of_cast_eq B.dβ‚‚_pos hk'  exact Nat.dvd_one.mp (by exact_mod_cast this) theorem d₁_eq_one_of_dβ‚‚ (h2 : B.dβ‚‚ = 1) : B.d₁ = 1 :=  Nat.dvd_one.mp (h2 β–Έ B.d₁_dvd) /-- (iii) β‡’ (i), with `Ο‰ = ω₃`. -/theorem basis_of_dβ‚‚_eq_one (h2 : B.dβ‚‚ = 1) : BasisWith M B.ω₃ := by  have h1 := B.d₁_eq_one_of_dβ‚‚ h2  have hne : B.ω₃ 3 β‰  0 := by simp [ω₃, omega3, B.d₃_q]  refine ⟨B.ω₃_mem, fun x hx => ?_⟩  obtain ⟨n, rfl⟩ := B.span x hx  refine ⟨![n 0 + n 1 * B.p₁₀ + n 2 * B.pβ‚‚β‚€, n 1 + n 2 * B.p₂₁, n 2, n 3], ?_,    fun c hc => lin_injective hne (hc.symm.trans ?_)⟩ <;>  Β· funext i    fin_cases i <;> simp [lin, combOf, ω₃, omega1, omega2, omega3, h1, h2] include B in/-- (i) ⇔ (ii). -/theorem T1_i_iff_ii : (βˆƒ Ο‰, BasisWith M Ο‰) ↔ Saturated M :=  ⟨fun ⟨_, h⟩ => B.saturated_of_basis h,    fun h => ⟨B.ω₃, B.basis_of_dβ‚‚_eq_one (B.dβ‚‚_eq_one_of_saturated h)⟩⟩ /-- (ii) ⇔ (iii). -/theorem T1_ii_iff_iii : Saturated M ↔ B.dβ‚‚ = 1 :=  ⟨B.dβ‚‚_eq_one_of_saturated, fun h => B.saturated_of_basis (B.basis_of_dβ‚‚_eq_one h)⟩ /-- (iii) ⇔ (iv). -/theorem T1_iii_iff_iv : B.dβ‚‚ = 1 ↔ IsAddCyclic (M β§Έ Z4.addSubgroupOf M) := by  rw [B.quotient_equiv.isAddCyclic, AddGroup.isAddCyclic_prod_iff,    AddGroup.isAddCyclic_prod_iff]  simp only [Nat.card_prod, Nat.card_zmod, ZMod.instIsAddCyclic, true_and]  constructor  Β· intro h2    rw [B.d₁_eq_one_of_dβ‚‚ h2, h2]    exact ⟨Nat.coprime_one_left _, Nat.coprime_one_left _⟩  Β· rintro ⟨h23, -⟩    exact Nat.Coprime.eq_one_of_dvd h23 B.dβ‚‚_dvd /-- min{e β‰₯ 1 : eM βŠ† β„€[Ξ±]} = d₃. -/theorem isLeast_expSet : IsLeast (expSet M) B.d₃ := by  refine ⟨⟨B.d₃_pos, fun x hx => ?_⟩, fun e ⟨_, he⟩ => ?_⟩  Β· obtain ⟨n, rfl⟩ := B.span x hx    show B.d₃ β€’ B.comb n ∈ Z4    rw [← B.comb_nsmul, B.comb_mem_Z4_iff]    simp only [Pi.smul_apply, nsmul_eq_mul]    exact ⟨Dvd.dvd.mul_right (Int.natCast_dvd_natCast.mpr (B.d₁_dvd.trans B.dβ‚‚_dvd)) _,      Dvd.dvd.mul_right (Int.natCast_dvd_natCast.mpr B.dβ‚‚_dvd) _, dvd_mul_right _ _⟩  Β· obtain ⟨k, hk⟩ := he _ B.ω₃_mem 3    have hk' : (k : β„š) = ((e : β„€) : β„š) / B.d₃ + ((0 : β„€) : β„š) := by      rw [hk]; simp [omega3]; ring    have := dvd_of_cast_eq B.d₃_pos hk'    exact Nat.le_of_dvd (by omega) (by exact_mod_cast this) /-- (iii) ⇔ (v). -/theorem T1_iii_iff_v : B.dβ‚‚ = 1 ↔ IsLeast (expSet M) (Z4.addSubgroupOf M).index := by  rw [B.index_eq]  constructor  Β· intro h2    rw [B.d₁_eq_one_of_dβ‚‚ h2, h2, one_mul, one_mul]    exact B.isLeast_expSet  Β· intro h    have h' := h.unique B.isLeast_expSet    have : B.d₁ * B.dβ‚‚ = 1 := by      have := B.d₃_pos      have h'' : B.d₁ * B.dβ‚‚ * B.d₃ = 1 * B.d₃ := by rw [h', one_mul]      exact Nat.eq_of_mul_eq_mul_right this h''    exact Nat.dvd_one.mp ⟨B.d₁, by rw [← this, mul_comm]⟩ /-- `p ∣ dβ‚‚` iff `1, Ξ±, Ξ±Β²` are linearly dependent over `𝔽_p` in `A/pA`, that is, there are    `cβ‚€, c₁, cβ‚‚ ∈ β„€`, not all divisible by `p`, with `cβ‚€ + c₁α + cβ‚‚Ξ±Β² ∈ pA`. -/theorem T1_mod_p {p : β„•} (hp : p.Prime) :    p ∣ B.dβ‚‚ ↔ βˆƒ c : Fin 3 β†’ β„€, Β¬ (βˆ€ i, (p : β„€) ∣ c i) ∧      βˆƒ y ∈ M, c 0 β€’ apow 0 + c 1 β€’ apow 1 + c 2 β€’ apow 2 = p β€’ y := by  have hp0 : (p : β„š) β‰  0 := by exact_mod_cast hp.ne_zero  constructor  Β· rintro ⟨m, hm⟩    have hm0 : (m : β„š) β‰  0 := by      have := B.dβ‚‚_pos; rw [hm] at this; exact_mod_cast (Nat.pos_of_mul_pos_left this).ne'    refine ⟨![B.pβ‚‚β‚€, B.p₂₁, 1], fun h => ?_, (m : β„€) β€’ B.Ο‰β‚‚, M.zsmul_mem B.Ο‰β‚‚_mem _, ?_⟩    Β· have h2 := h 2      simp only [Matrix.cons_val_two, Matrix.tail_cons, Matrix.head_cons] at h2      exact hp.one_lt.ne' (Nat.dvd_one.mp (by exact_mod_cast h2))    Β· funext i      fin_cases i <;> simp [Ο‰β‚‚, omega2, hm] <;> field_simp  Β· rintro ⟨c, hc, y, hy, heq⟩    by_contra hnd    have hy3 : y 3 = 0 := by      have := congrFun heq 3      simp at this      exact this.resolve_left hp.ne_zero    have hd2y := B.dβ‚‚_smul_mem hy hy3    have hpy : (p : β„€) β€’ y ∈ Z4 := by      rw [natCast_zsmul, ← heq]      intro i      fin_cases i      Β· exact ⟨c 0, by simp⟩      Β· exact ⟨c 1, by simp⟩      Β· exact ⟨c 2, by simp⟩      Β· exact ⟨0, by simp⟩    have hcop : Nat.gcd p B.dβ‚‚ = 1 := (Nat.Prime.coprime_iff_not_dvd hp).mpr hnd    have huv := Nat.gcd_eq_gcd_ab p B.dβ‚‚    rw [hcop, Nat.cast_one] at huv    set u := Nat.gcdA p B.dβ‚‚    set v := Nat.gcdB p B.dβ‚‚    have hyZ : y ∈ Z4 := by      have : y = u β€’ ((p : β„€) β€’ y) + v β€’ ((B.dβ‚‚ : β„€) β€’ y) := by        rw [smul_smul, smul_smul, ← add_smul, mul_comm u, mul_comm v, ← huv, one_smul]      rw [this]      exact Z4.add_mem (Z4.zsmul_mem hpy u) (Z4.zsmul_mem hd2y v)    apply hc    intro i    fin_cases i    Β· obtain ⟨k, hk⟩ := hyZ 0      have := congrFun heq 0      simp only [Pi.add_apply, Pi.smul_apply, Pi.single_apply] at this      simp at this      rw [← hk] at this      exact ⟨k, by exact_mod_cast this⟩    Β· obtain ⟨k, hk⟩ := hyZ 1      have := congrFun heq 1      simp at this      rw [← hk] at this      exact ⟨k, by exact_mod_cast this⟩    Β· obtain ⟨k, hk⟩ := hyZ 2      have := congrFun heq 2      simp at this      rw [← hk] at this      exact ⟨k, by exact_mod_cast this⟩ /-- **The proposition**, for `M = A` with `d₁ = 1` (Louboutin 2020, Thm. 13):    `A/β„€[Ξ±] β‰… β„€/dβ‚‚ Γ— β„€/d₃`, `dβ‚‚ = [A ∩ Vβ‚‚ : Lβ‚‚]`, (i)–(v) equivalent, and the clause modulo `p`. -/theorem prop_T1 (h1 : B.d₁ = 1) :    Nonempty ((M β§Έ Z4.addSubgroupOf M) ≃+ ZMod B.dβ‚‚ Γ— ZMod B.d₃) ∧    (L2.addSubgroupOf (M βŠ“ V2)).index = B.dβ‚‚ ∧    [βˆƒ Ο‰, BasisWith M Ο‰, Saturated M, B.dβ‚‚ = 1, IsAddCyclic (M β§Έ Z4.addSubgroupOf M),      IsLeast (expSet M) (Z4.addSubgroupOf M).index].TFAE ∧    βˆ€ p : β„•, p.Prime β†’ (p ∣ B.dβ‚‚ ↔ βˆƒ c : Fin 3 β†’ β„€, Β¬ (βˆ€ i, (p : β„€) ∣ c i) ∧      βˆƒ y ∈ M, c 0 β€’ apow 0 + c 1 β€’ apow 1 + c 2 β€’ apow 2 = p β€’ y) := by  refine ⟨B.quotient_equiv_T1 h1, B.index_V2 h1, ?_, fun p hp => B.T1_mod_p hp⟩  tfae_have 1 ↔ 2 := B.T1_i_iff_ii  tfae_have 2 ↔ 3 := B.T1_ii_iff_iii  tfae_have 3 ↔ 4 := B.T1_iii_iff_iv  tfae_have 3 ↔ 5 := B.T1_iii_iff_v  tfae_finish end Triang /-! ### Non-vacuity: every datum (`d₁ ∣ dβ‚‚ ∣ d₃`, `P_k`) is realized -/ /-- `combOf` as a homomorphism. -/def combOfHom (ω₁ Ο‰β‚‚ ω₃ : Fin 4 β†’ β„š) : (Fin 4 β†’ β„€) β†’+ (Fin 4 β†’ β„š) where  toFun := combOf ω₁ Ο‰β‚‚ ω₃  map_zero' := by simp [combOf]  map_add' n m := by simp only [combOf, Pi.add_apply, add_smul]; abel /-- For every `0 < d₁ ∣ dβ‚‚ ∣ d₃` and `P_k`, the `β„€`-module generated by `1, ω₁, Ο‰β‚‚, ω₃` carries    a `Triang` structure: the hypotheses of `Triang` are not contradictory, for any `dβ‚‚`. -/def Triang.ofData (d₁ dβ‚‚ d₃ : β„•) (h₁ : 0 < d₁) (hβ‚‚ : 0 < dβ‚‚) (h₃ : 0 < d₃) (h₁₂ : d₁ ∣ dβ‚‚)    (h₂₃ : dβ‚‚ ∣ d₃) (p₁₀ pβ‚‚β‚€ p₂₁ p₃₀ p₃₁ p₃₂ : β„€) :    Triang (combOfHom (omega1 d₁ p₁₀) (omega2 dβ‚‚ pβ‚‚β‚€ p₂₁) (omega3 d₃ p₃₀ p₃₁ p₃₂)).range where  d₁ := d₁  dβ‚‚ := dβ‚‚  d₃ := d₃  d₁_pos := h₁  dβ‚‚_pos := hβ‚‚  d₃_pos := h₃  d₁_dvd := h₁₂  dβ‚‚_dvd := h₂₃  p₁₀ := p₁₀  pβ‚‚β‚€ := pβ‚‚β‚€  p₂₁ := p₂₁  p₃₀ := p₃₀  p₃₁ := p₃₁  p₃₂ := p₃₂  one_mem := ⟨![1, 0, 0, 0], by simp [combOfHom, combOf]⟩  ω₁_mem := ⟨![0, 1, 0, 0], by simp [combOfHom, combOf]⟩  Ο‰β‚‚_mem := ⟨![0, 0, 1, 0], by simp [combOfHom, combOf]⟩  ω₃_mem := ⟨![0, 0, 0, 1], by simp [combOfHom, combOf]⟩  span := fun _ ⟨n, hn⟩ => ⟨n, hn.symm⟩ end Louboutin