/-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, Claude (AI assistant)-/module public import Mathlib.Data.ZMod.Basicpublic import Mathlib.Algebra.BigOperators.Group.Finset.Basicpublic import Mathlib.Algebra.BigOperators.Intervalspublic import Mathlib.FieldTheory.Finite.Basicpublic import Mathlib.Tactic.Ringpublic import Mathlib.Tactic.FieldSimp /-!# Power-sum moments of the half-system T_k in F_p For a prime p > 7, m = (p-1)/2 and k <= m with 8k(k+1)+1 = 0 in F_p, the half-system T_k = {1,...,k}u {-(k+1),...,-m} of F_p has odd power-sum moments M_3 = -1/128, M_5 = 7/1536, M_7 = -245/49152 (allin F_p). The proof reduces M_j(T_k) = 2F_j(k) - F_j(m) for odd j, proves the Faulhaber closed formsfor j = 3, 5, 7 over the integers by induction, and substitutes k(k+1) = -1/8 and m(m+1) = -1/4. Theexistence and uniqueness of k (needs (2|p) = 1), the half-system and centring claims and thesemigroup S_{T_k} = <3,5,7> are NOT formalized here; k is taken as a hypothesis. ## Main results * `P3a.moments_Tk`: M_3, M_5, M_7 of T_k equal -1/128, 7/1536, -245/49152 in F_p for p > 7* `P3a.moment_Tk_odd`: M_j(T_k) = 2F_j(k) - F_j(m) for odd j ## References * C. MarΓn, *The order generated by a column of the SU(n)β S-matrix is locally a numerical semigroup ring (Part II)*, Zenodo (2026), doi:10.5281/zenodo.22864267, `prop:familia`.-/ @[expose] public section open Finset namespace P3a variable {p : β} /-- The half-system `T_k = {1,β¦,k} βͺ {-(k+1),β¦,-m}` in `π½_p`, `m = (p-1)/2`. -/def Tk (p k : β) : Finset (ZMod p) := (Icc 1 k).image (fun r : β => (r : ZMod p)) βͺ (Icc (k + 1) ((p - 1) / 2)).image (fun r : β => -(r : ZMod p)) /-- The `j`-th power-sum moment of a finite subset of `π½_p`. -/def moment (T : Finset (ZMod p)) (j : β) : ZMod p := β t β T, t ^ j /-- Partial power sum `F_j(t) = β_{r=1}^t r^j` in `β€`. -/def F (j t : β) : β€ := β r β Icc 1 t, (r : β€) ^ j lemma F_succ (j t : β) : F j (t + 1) = F j t + ((t : β€) + 1) ^ j := by unfold F rw [Finset.sum_Icc_succ_top (by omega : 1 β€ t + 1)] push_cast; ring lemma F3 (t : β) : 4 * F 3 t = ((t : β€) * (t + 1)) ^ 2 := by induction t with | zero => simp [F] | succ n ih => rw [F_succ]; push_cast; nlinarith [ih] lemma F5 (t : β) : 12 * F 5 t = ((t : β€) * (t + 1)) ^ 2 * (2 * ((t : β€) * (t + 1)) - 1) := by induction t with | zero => simp [F] | succ n ih => rw [F_succ]; push_cast; nlinarith [ih] lemma F7 (t : β) : 24 * F 7 t = ((t : β€) * (t + 1)) ^ 2 * (3 * ((t : β€) * (t + 1)) ^ 2 - 4 * ((t : β€) * (t + 1)) + 2) := by induction t with | zero => simp [F] | succ n ih => rw [F_succ]; push_cast; nlinarith [ih] lemma tk_disjoint (hp : 2 < p) (k : β) : Disjoint ((Icc 1 k).image (fun r : β => (r : ZMod p))) ((Icc (k + 1) ((p - 1) / 2)).image (fun r : β => -(r : ZMod p))) := by rw [Finset.disjoint_left] intro x hx hx' simp only [mem_image, mem_Icc] at hx hx' obtain β¨a, β¨ha1, ha2β©, rflβ© := hx obtain β¨b, β¨hb1, hb2β©, habβ© := hx' have h0 : ((a + b : β) : ZMod p) = 0 := by push_cast; rw [β hab]; ring rw [ZMod.natCast_eq_zero_iff] at h0 have := Nat.le_of_dvd (by omega) h0 omega lemma moment_Tk_odd (hp : 2 < p) (k : β) (hk : k β€ (p - 1) / 2) (j : β) (hj : Odd j) : moment (Tk p k) j = 2 * ((F j k : β€) : ZMod p) - ((F j ((p - 1) / 2) : β€) : ZMod p) := by unfold moment Tk rw [sum_union (tk_disjoint hp k)] rw [sum_image (fun a ha b hb h => by simp only [coe_Icc, Set.mem_Icc] at ha hb rw [ZMod.natCast_eq_natCast_iff'] at h rwa [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega)] at h)] rw [sum_image (fun a ha b hb h => by have h' := neg_injective h simp only [coe_Icc, Set.mem_Icc] at ha hb rw [ZMod.natCast_eq_natCast_iff'] at h' rwa [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega)] at h')] simp only [hj.neg_pow, sum_neg_distrib] have e : β n, ((F j n : β€) : ZMod p) = β r β Ioc 0 n, (r : ZMod p) ^ j := by intro n; unfold F; push_cast; rfl have e1 : Icc 1 k = Ioc 0 k := by ext; simp only [mem_Icc, mem_Ioc]; omega have e2 : Icc (k + 1) ((p - 1) / 2) = Ioc k ((p - 1) / 2) := by ext; simp only [mem_Icc, mem_Ioc]; omega have := Finset.sum_Ioc_consecutive (fun r : β => (r : ZMod p) ^ j) (Nat.zero_le k) hk rw [e1, e2, e, e, β this] ring /-- `k(k+1) = -1/8` and `m(m+1) = -1/4` in `π½_p`, from `8k(k+1)+1 = 0` and `2m+1 = p`. -/lemma uv [Fact p.Prime] (hp : 2 < p) (k : β) (hk8 : (8 * (k : ZMod p) * (k + 1) + 1 = 0)) : 8 * ((k : ZMod p) * (k + 1)) = -1 β§ 4 * (((((p - 1) / 2 : β)) : ZMod p) * ((((p - 1) / 2 : β) : ZMod p) + 1)) = -1 := by have hodd : p % 2 = 1 := by rcases (Fact.out : p.Prime).eq_two_or_odd with h | h <;> omega have hm : ((2 * ((p - 1) / 2) + 1 : β) : ZMod p) = 0 := by rw [show 2 * ((p - 1) / 2) + 1 = p by omega]; simp push_cast at hm refine β¨by linear_combination hk8, ?_β© linear_combination (2 * (((p - 1) / 2 : β) : ZMod p) + 1) * hm /-- Moments of `T_k` (paper `prop:familia`): `Mβ = -1/128`, `Mβ = 7/1536`, `Mβ = -245/49152`in `π½_p`, for a prime `p > 7` and `k β€ m = (p-1)/2` with `8k(k+1)+1 = 0`. -/theorem moments_Tk [Fact p.Prime] (hp : 7 < p) (k : β) (hk : k β€ (p - 1) / 2) (hk8 : (8 * (k : ZMod p) * (k + 1) + 1 = 0)) : moment (Tk p k) 3 = -1 / 128 β§ moment (Tk p k) 5 = 7 / 1536 β§ moment (Tk p k) 7 = -245 / 49152 := by have hp2 : 2 < p := by omega have h2 : (2 : ZMod p) β 0 := by have := (ZMod.natCast_eq_zero_iff 2 p).not.mpr (fun h => by have := Nat.le_of_dvd (by norm_num) h; omega) simpa using this have h3 : (3 : ZMod p) β 0 := by have := (ZMod.natCast_eq_zero_iff 3 p).not.mpr (fun h => by have := Nat.le_of_dvd (by norm_num) h; omega) simpa using this obtain β¨hu, hvβ© := uv hp2 k hk8 set m := (p - 1) / 2 with hmdef set U : ZMod p := (k : ZMod p) * (k + 1) with hU set V : ZMod p := (m : ZMod p) * ((m : ZMod p) + 1) with hV have n4 : (4 : ZMod p) β 0 := by have : (4 : ZMod p) = 2 ^ 2 := by norm_num rw [this]; exact pow_ne_zero 2 h2 have n8 : (8 : ZMod p) β 0 := by have : (8 : ZMod p) = 2 ^ 3 := by norm_num rw [this]; exact pow_ne_zero 3 h2 have hU' : U = -1 / 8 := by rw [eq_div_iff n8]; linear_combination hu have hV' : V = -1 / 4 := by rw [eq_div_iff n4]; linear_combination hv have c3 : β t : β, 4 * ((F 3 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 := by intro t; have := congrArg (Int.cast : β€ β ZMod p) (F3 t); push_cast at this; exact this have c5 : β t : β, 12 * ((F 5 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 * (2 * ((t : ZMod p) * (t + 1)) - 1) := by intro t; have := congrArg (Int.cast : β€ β ZMod p) (F5 t); push_cast at this; exact this have c7 : β t : β, 24 * ((F 7 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 * (3 * ((t : ZMod p) * (t + 1)) ^ 2 - 4 * ((t : ZMod p) * (t + 1)) + 2) := by intro t; have := congrArg (Int.cast : β€ β ZMod p) (F7 t); push_cast at this; exact this have n12 : (12 : ZMod p) β 0 := by have : (12 : ZMod p) = 4 * 3 := by norm_num rw [this]; exact mul_ne_zero n4 h3 have n24 : (24 : ZMod p) β 0 := by have : (24 : ZMod p) = 8 * 3 := by norm_num rw [this]; exact mul_ne_zero n8 h3 have f3 : β t : β, ((F 3 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 / 4 := fun t => eq_div_of_mul_eq n4 (by rw [mul_comm]; exact c3 t) have f5 : β t : β, ((F 5 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 * (2 * ((t : ZMod p) * (t + 1)) - 1) / 12 := fun t => eq_div_of_mul_eq n12 (by rw [mul_comm]; exact c5 t) have f7 : β t : β, ((F 7 t : β€) : ZMod p) = ((t : ZMod p) * (t + 1)) ^ 2 * (3 * ((t : ZMod p) * (t + 1)) ^ 2 - 4 * ((t : ZMod p) * (t + 1)) + 2) / 24 := fun t => eq_div_of_mul_eq n24 (by rw [mul_comm]; exact c7 t) have n2 : (2 : ZMod p) β 0 := h2 have n16 : (16 : ZMod p) β 0 := by have : (16 : ZMod p) = 2 ^ 4 := by norm_num rw [this]; exact pow_ne_zero 4 h2 have n64 : (64 : ZMod p) β 0 := by have : (64 : ZMod p) = 2 ^ 6 := by norm_num rw [this]; exact pow_ne_zero 6 h2 have n128 : (128 : ZMod p) β 0 := by have : (128 : ZMod p) = 2 ^ 7 := by norm_num rw [this]; exact pow_ne_zero 7 h2 have n1536 : (1536 : ZMod p) β 0 := by have : (1536 : ZMod p) = 2 ^ 9 * 3 := by norm_num rw [this]; exact mul_ne_zero (pow_ne_zero 9 h2) h3 have n49152 : (49152 : ZMod p) β 0 := by have : (49152 : ZMod p) = 2 ^ 14 * 3 := by norm_num rw [this]; exact mul_ne_zero (pow_ne_zero 14 h2) h3 refine β¨?_, ?_, ?_β© Β· rw [moment_Tk_odd hp2 k hk 3 (by decide), f3, f3, β hU, β hV, hU', hV'] field_simp; ring Β· rw [moment_Tk_odd hp2 k hk 5 (by decide), f5, f5, β hU, β hV, hU', hV'] field_simp; ring Β· rw [moment_Tk_odd hp2 k hk 7 (by decide), f7, f7, β hU, β hV, hU', hV'] field_simp; ring end P3a