/-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.MahlerBasis.ParityAndKernelpublic import Mathlib.RingTheory.Binomialpublic import Mathlib.Algebra.BigOperators.Intervalspublic import Mathlib.Algebra.BigOperators.NatAntidiagonalpublic import Mathlib.Data.Nat.Choose.Vandermondepublic import Mathlib.Tactic.Ringpublic import Mathlib.Tactic.Linarithpublic import Mathlib.Tactic.LinearCombination /-!# Mahler coefficients of an even function If `G = β_{i β€ N} c_i C(x, i)` (`x : β€`, values in a commutative ring) is even, then for odd`k β€ N`, `2 c_k = β_{k < i β€ N} (β1)^i C(i β 1, i β k) c_i`: compare coefficients in`G(βx) = G(x)`, using `C(βx, i) = (β1)^i β_k C(i β 1, i β k) C(x, k)` (Vandermonde). ## Main results * `LemaP2.choose_neg_vandermonde`: the expansion of `C(βx, i)`.* `LemaP2.mahler_unique`: Mahler coefficients are determined by the values on `β`.* `LemaP2.lemP_two`: the statement above. ## 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 LemaP2 variable {R : Type*} [CommRing R] /-! `mahlerZ N c x = β_{i β€ N} c_i C(x, i)` for `x : β€` is `ConjeturaC.mahlerZ`. -/open ConjeturaC (mahlerZ) /-- **Vandermonde, as in the proof of `lem:P`(2).** For `x β β`:`C(-x, i) = (-1)^i β_{k β€ i} C(i-1, i-k) C(x, k)`. -/theorem choose_neg_vandermonde (x i : β) : Ring.choose (-(x : β€)) i = (-1) ^ i * β k β range (i + 1), ((Nat.choose (i - 1) (i - k) * Nat.choose x k : β) : β€) := by rcases i with _ | j Β· simp Β· rw [Ring.choose_neg, show (x : β€) + ((j + 1 : β) : β€) - 1 = ((x + j : β) : β€) by push_cast; ring, Ring.choose_natCast, Nat.add_choose_eq, Nat.sum_antidiagonal_eq_sum_range_succ_mk, Units.smul_def, Int.coe_negOnePow_natCast, smul_eq_mul] push_cast congr 1 apply sum_congr rfl; intro k _; ring /-- Mahler coefficients are unique: if `β_{k β€ N} e_k C(x, k) = 0` for every `x β β`, then`e_k = 0` for `k β€ N`. -/theorem mahler_unique (N : β) (e : β β R) (h : β x : β, β k β range (N + 1), e k * (Nat.choose x k : R) = 0) : β k β€ N, e k = 0 := by intro k induction k using Nat.strong_induction_on with | _ k ih => intro hk have hx := h k rw [sum_congr rfl (g := fun j => if j = k then e k else 0)] at hx Β· rwa [sum_ite_eq', ite_eq_left (mem_range.mpr (by omega))] at hx Β· intro j hj rcases lt_trichotomy j k with hlt | heq | hgt Β· rw [ih j hlt (by omega), zero_mul, ite_eq_right (by omega)] Β· subst heq; simp Β· rw [Nat.choose_eq_zero_of_lt hgt, Nat.cast_zero, mul_zero, ite_eq_right (by omega)] /-- `G(-x)` in Mahler form: its `k`-th coefficient is `β_{k β€ i β€ N} (-1)^i C(i-1, i-k) c_i`. -/theorem mahlerZ_neg (N : β) (c : β β R) (x : β) : mahlerZ N c (-(x : β€)) = β k β range (N + 1), (β i β Icc k N, (-1) ^ i * (Nat.choose (i - 1) (i - k) : R) * c i) * (Nat.choose x k : R) := by unfold mahlerZ simp_rw [choose_neg_vandermonde] push_cast simp_rw [mul_sum, sum_mul] rw [sum_comm' (t' := range (N + 1)) (s' := fun k => Icc k N)] Β· apply sum_congr rfl; intro k _; apply sum_congr rfl; intro i _ ring Β· intro i k; simp only [mem_range, mem_Icc]; omega /-- **`lem:P`(2).** If `G = β_{i β€ N} c_i C(x, i)` is even on `β€`, then for every odd`k β€ N`, `2 c_k = β_{k < i β€ N} (-1)^i C(i-1, i-k) c_i`. Valid over any commutative ring. -/theorem lemP_two (N : β) (c : β β R) (heven : β x : β€, mahlerZ N c (-x) = mahlerZ N c x) {k : β} (hk : Odd k) (hkN : k β€ N) : 2 * c k = β i β Ioc k N, (-1) ^ i * (Nat.choose (i - 1) (i - k) : R) * c i := by have hu := mahler_unique N (fun k => (β i β Icc k N, (-1) ^ i * (Nat.choose (i - 1) (i - k) : R) * c i) - c k) (fun x => by have h1 := heven x rw [mahlerZ_neg] at h1 simp only [sub_mul, sum_sub_distrib] rw [h1]; unfold mahlerZ rw [sub_eq_zero]; apply sum_congr rfl; intro i _ rw [Ring.choose_natCast]; push_cast; ring) k hkN rw [Icc_eq_cons_Ioc hkN, sum_cons, Odd.neg_one_pow hk, Nat.sub_self, Nat.choose_zero_right, Nat.cast_one] at hu linear_combination -hu /-! ## Controls -/ /-- `xΒ² = C(x,1) + 2 C(x,2)` is even, `c = (0, 1, 2)`; at `k = 1` the identity reads`2 Β· 1 = (-1)Β² C(1,1) Β· 2`. -/example : (2 : β€) * 1 = β i β Ioc 1 2, (-1) ^ i * (Nat.choose (i - 1) (i - 1) : β€) * (if i = 2 then 2 else 0) := by decide /-- `C(-2, 3) = -4`, computed both ways. -/example : Ring.choose (-((2 : β) : β€)) 3 = -4 := by rw [choose_neg_vandermonde]; decide end LemaP2