import Mathlib.Analysis.Fourier.FiniteAbelian.PontryaginDuality import Mathlib.Analysis.Fourier.FiniteAbelian.Orthogonality import Mathlib.Data.ZMod.Basic import Mathlib.FieldTheory.Finite.Basic import Mathlib.Data.Finset.Card import Mathlib.Data.Fintype.Pi import Mathlib.LinearAlgebra.Dimension.Finrank import Mathlib.LinearAlgebra.Dual.Lemmas import Mathlib.LinearAlgebra.LinearIndependent.Lemmas import Mathlib.Tactic.Linarith import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.FinCases /-! # Theorem 3.3: Strict Upper Bound `< 2^r` and Sharp Symmetry-Free `2^(r-1)` Family For every odd prime `p ≥ 3` and rank `r ≥ 2`, working in the elementary abelian group `G = Fin r → ZMod p`: 1. **Strict Upper Bound (`fiber_card_lt_two_pow`)**: For every aperiodic `C : Finset (Fin r → ZMod p)` and `x₀ ∉ C`, `(Fiber C x₀).card < 2 ^ r` (no full `r`-cube, since an additive sum of 1D functions taking values in `{0, 1}` has at most 1 nonconstant summand). 2. **Explicit Sharp Family (`sharp_construction_theorem`)**: For every `r ≥ 2` and prime `p ≥ 2 * r + 3`, define `sharpCore r p` as the union of: - three full hyperplanes `u 0 ∈ {r, r + 1, r + 3}`, - `2(r - 1)` coordinate masks `{u 0 = ±i ∧ u i = 0}` for `1 ≤ i ≤ r - 1`. We prove: - `sharpCore r p` is aperiodic, - all `2^(r - 1)` sites `u` with `u 0 = 0` and `u i ∈ {1, -1}` (`i ≠ 0`) lie in the same fiber, - all `2^(r - 1)` completions `insert x (sharpCore r p)` are pairwise inequivalent under translations `u ↦ u + g`, inversions `u ↦ -u + g`, and complements (even composed with translations or inversions). -/ namespace AbelianHomometry.SharpConstruction open scoped BigOperators ComplexConjugate section Core variable {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] /-- Periodic autocorrelation of a support `S : Finset G` at lag `t : G`. -/ def autocorr (S : Finset G) (t : G) : ℕ := (S.filter fun u => u + t ∈ S).card /-- A support `C : Finset G` is aperiodic if its only translational period is `0`. -/ def IsAperiodic (C : Finset G) : Prop := ∀ g : G, C.image (· + g) = C → g = 0 /-- The single-point insertion fiber of `x₀` with fixed core `C`. -/ noncomputable def Fiber (C : Finset G) (x₀ : G) : Finset G := by classical exact (Finset.univ \ C).filter fun x => autocorr (insert x C) = autocorr (insert x₀ C) /-- Indicator function `1_C : G → ℕ`. -/ def indC (C : Finset G) (u : G) : ℕ := if u ∈ C then 1 else 0 /-- Complex Fourier coefficient `f_hat(χ) = ∑ u ∈ C, χ (-u)`. -/ def fourierCoeff (C : Finset G) (χ : AddChar G ℂ) : ℂ := ∑ u ∈ C, χ (-u) omit [Fintype G] in private lemma autocorr_insert_eq (C : Finset G) {x : G} (hx : x ∉ C) (t : G) : autocorr (insert x C) t = autocorr C t + (if t = 0 then 1 else 0) + indC C (x + t) + indC C (x - t) := by unfold autocorr indC rw [Finset.card_filter, Finset.card_filter, Finset.sum_insert hx] have h1 : (if x + t ∈ insert x C then (1 : ℕ) else 0) = (if t = 0 then 1 else 0) + (if x + t ∈ C then 1 else 0) := by by_cases ht : t = 0 · subst ht; simp [hx] · have hne : x + t ≠ x := fun h => ht (add_left_cancel (h.trans (add_zero x).symm)) simp [ht, hne] have h2 : ∑ u ∈ C, (if u + t ∈ insert x C then (1 : ℕ) else 0) = (∑ u ∈ C, if u + t ∈ C then 1 else 0) + (if x - t ∈ C then 1 else 0) := by have hsplit : ∀ u ∈ C, (if u + t ∈ insert x C then (1 : ℕ) else 0) = (if u + t ∈ C then 1 else 0) + (if u = x - t then 1 else 0) := by intro u _ by_cases hux : u + t = x · have hueq : u = x - t := eq_sub_of_add_eq hux simp [hx, hueq] · have huneq : u ≠ x - t := fun h => hux (by rw [h, sub_add_cancel]) simp [hux, huneq] rw [Finset.sum_congr rfl hsplit, Finset.sum_add_distrib] congr 1 simp [Finset.sum_ite_eq'] rw [h1, h2] omega omit [Fintype G] in private lemma autocorr_insert_eq_iff (C : Finset G) {x x₀ : G} (hx : x ∉ C) (hx₀ : x₀ ∉ C) : autocorr (insert x C) = autocorr (insert x₀ C) ↔ ∀ t : G, indC C (x + t) + indC C (x - t) = indC C (x₀ + t) + indC C (x₀ - t) := by constructor · intro h t have ht := congr_fun h t rw [autocorr_insert_eq C hx t, autocorr_insert_eq C hx₀ t] at ht omega · intro h funext t rw [autocorr_insert_eq C hx t, autocorr_insert_eq C hx₀ t] have ht := h t omega private lemma mem_fiber_iff (C : Finset G) {x₀ : G} (hx₀ : x₀ ∉ C) (x : G) : x ∈ Fiber C x₀ ↔ x ∉ C ∧ ∀ t : G, indC C (x + t) + indC C (x - t) = indC C (x₀ + t) + indC C (x₀ - t) := by classical simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and] constructor · rintro ⟨hx, h⟩; exact ⟨hx, (autocorr_insert_eq_iff C hx hx₀).1 h⟩ · rintro ⟨hx, h⟩; exact ⟨hx, (autocorr_insert_eq_iff C hx hx₀).2 h⟩ private lemma sum_addChar_apply (a : G) : ∑ χ : AddChar G ℂ, χ a = if a = 0 then (Fintype.card G : ℂ) else 0 := by have h1 : (∑ χ : AddChar G ℂ, χ a) = ∑ χ : AddChar G ℂ, (AddChar.doubleDualEmb a : AddChar (AddChar G ℂ) ℂ) χ := rfl rw [h1, AddChar.sum_eq_ite] simp [AddChar.doubleDualEmb_eq_zero, AddChar.card_eq] private lemma fourier_inversion (g : G → ℂ) (s : G) : ∑ χ : AddChar G ℂ, (∑ t : G, g t * χ (-t)) * χ s = (Fintype.card G : ℂ) * g s := by calc ∑ χ : AddChar G ℂ, (∑ t : G, g t * χ (-t)) * χ s = ∑ χ : AddChar G ℂ, ∑ t : G, g t * (χ (-t) * χ s) := by refine Finset.sum_congr rfl fun χ _ => ?_ rw [Finset.sum_mul] refine Finset.sum_congr rfl fun t _ => by ring _ = ∑ t : G, ∑ χ : AddChar G ℂ, g t * χ (s - t) := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun t _ => Finset.sum_congr rfl fun χ _ => ?_ rw [← AddChar.map_add_eq_mul, neg_add_eq_sub] _ = ∑ t : G, g t * ∑ χ : AddChar G ℂ, χ (s - t) := by refine Finset.sum_congr rfl fun t _ => (Finset.mul_sum ..).symm _ = ∑ t : G, g t * (if s - t = 0 then (Fintype.card G : ℂ) else 0) := by refine Finset.sum_congr rfl fun t _ => by rw [sum_addChar_apply] _ = (Fintype.card G : ℂ) * g s := by have hsub : ∀ t : G, (s - t = 0) ↔ t = s := fun t => ⟨fun h => (sub_eq_zero.1 h).symm, fun h => by rw [h, sub_self]⟩ simp_rw [hsub] simp [mul_comm] omit [DecidableEq G] in private lemma addChar_conj_eq_neg (χ : AddChar G ℂ) (a : G) : star (χ a) = χ (-a) := by rw [AddChar.map_neg_eq_inv, AddChar.inv_apply_eq_conj, Complex.star_def] omit [DecidableEq G] in private lemma addChar_apply_ne_zero (χ : AddChar G ℂ) (a : G) : χ a ≠ 0 := by intro h have hn := χ.norm_apply a rw [h, norm_zero] at hn exact zero_ne_one hn private lemma fourier_profile_eq (C : Finset G) (x : G) (χ : AddChar G ℂ) : ∑ t : G, ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ) * χ (-t) = 2 * ((fourierCoeff C χ * χ x).re : ℂ) := by have hcast : ∀ t : G, ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ) * χ (-t) = (indC C (x + t) : ℂ) * χ (-t) + (indC C (x - t) : ℂ) * χ (-t) := fun t => by push_cast; ring simp_rw [hcast, Finset.sum_add_distrib] have hplus : ∑ t : G, (indC C (x + t) : ℂ) * χ (-t) = fourierCoeff C χ * χ x := by let e : G ≃ G := Equiv.addLeft x rw [← Equiv.sum_comp e.symm] have hterm : ∀ u : G, (indC C (x + e.symm u) : ℂ) * χ (-(e.symm u)) = (indC C u : ℂ) * (χ (-u) * χ x) := by intro u have h1 : x + e.symm u = u := by simp [e] have h2 : -(e.symm u) = -u + x := by simp [e] rw [h1, h2, AddChar.map_add_eq_mul] simp_rw [hterm, ← mul_assoc] rw [← Finset.sum_mul] congr 1 unfold fourierCoeff indC simp have hminus : ∑ t : G, (indC C (x - t) : ℂ) * χ (-t) = star (fourierCoeff C χ * χ x) := by let e : G ≃ G := Equiv.subLeft x rw [← Equiv.sum_comp e.symm] have hterm : ∀ u : G, (indC C (x - e.symm u) : ℂ) * χ (-(e.symm u)) = (indC C u : ℂ) * (χ u * χ (-x)) := by intro u have h1 : x - e.symm u = u := by simp [e] have h2 : -(e.symm u) = u + -x := by simp [e]; abel rw [h1, h2, AddChar.map_add_eq_mul] simp_rw [hterm, ← mul_assoc] rw [← Finset.sum_mul] have hstar : star (fourierCoeff C χ * χ x) = (∑ u ∈ C, χ u) * χ (-x) := by rw [star_mul', addChar_conj_eq_neg] congr 1 unfold fourierCoeff rw [star_sum] refine Finset.sum_congr rfl fun u _ => ?_ rw [addChar_conj_eq_neg, neg_neg] rw [hstar] congr 1 unfold indC simp rw [hplus, hminus] have hadd : ∀ z : ℂ, z + star z = 2 * (z.re : ℂ) := fun z => by rw [Complex.star_def, Complex.add_conj] push_cast; ring exact hadd _ private lemma mem_fiber_fourier {C : Finset G} {x₀ x : G} (hx₀ : x₀ ∉ C) (hx : x ∈ Fiber C x₀) (χ : AddChar G ℂ) : (fourierCoeff C χ * χ x).re = (fourierCoeff C χ * χ x₀).re := by classical simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and] at hx have hprof := (autocorr_insert_eq_iff C hx.1 hx₀).1 hx.2 have hsum : ∑ t : G, ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ) * χ (-t) = ∑ t : G, ((indC C (x₀ + t) + indC C (x₀ - t) : ℕ) : ℂ) * χ (-t) := Finset.sum_congr rfl fun t _ => by rw [hprof t] rw [fourier_profile_eq, fourier_profile_eq] at hsum exact Complex.ofReal_injective (mul_left_cancel₀ (two_ne_zero : (2 : ℂ) ≠ 0) hsum) private lemma fourier_inversion_indC (C : Finset G) (s : G) : ∑ χ : AddChar G ℂ, fourierCoeff C χ * χ s = (Fintype.card G : ℂ) * (indC C s : ℂ) := by have h := fourier_inversion (fun t => (indC C t : ℂ)) s have hcoef : ∀ χ : AddChar G ℂ, ∑ t : G, (indC C t : ℂ) * χ (-t) = fourierCoeff C χ := by intro χ; unfold fourierCoeff indC; simp simp_rw [hcoef] at h exact h private lemma mem_fiber_self (C : Finset G) {x₀ : G} (hx₀ : x₀ ∉ C) : x₀ ∈ Fiber C x₀ := by classical simp [Fiber, hx₀] omit [Fintype G] in private lemma isAperiodic_image_addEquiv {C : Finset G} (hC : IsAperiodic C) (φ : G ≃+ G) : IsAperiodic (C.image φ) := by intro g hg have himg : C.image (· + φ.symm g) = C := by ext u have hmem : φ u ∈ (C.image φ).image (· + g) ↔ φ u ∈ C.image φ := by rw [hg] simp only [Finset.mem_image] at hmem ⊢ constructor · rintro ⟨v, hv, rfl⟩ have : φ (v + φ.symm g) ∈ C.image φ := by rw [← hg] refine Finset.mem_image.2 ⟨φ v, Finset.mem_image_of_mem φ hv, ?_⟩ simp [map_add] obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 this rwa [← φ.injective hweq] · intro hu obtain ⟨b, hb, hbeq⟩ := hmem.2 ⟨u, hu, rfl⟩ obtain ⟨a, ha, rfl⟩ := hb refine ⟨a, ha, φ.injective ?_⟩ simp [map_add, hbeq] have hzero := hC (φ.symm g) himg simpa using congr_arg φ hzero omit [Fintype G] in private lemma autocorr_image_addEquiv (S : Finset G) (φ : G ≃+ G) (t : G) : autocorr (S.image φ) (φ t) = autocorr S t := by unfold autocorr have h : (S.image φ).filter (fun u => u + φ t ∈ S.image φ) = (S.filter (fun u => u + t ∈ S)).image φ := by ext v simp only [Finset.mem_filter, Finset.mem_image] constructor · rintro ⟨⟨u, hu, rfl⟩, ⟨w, hw, hweq⟩⟩ refine ⟨u, ⟨hu, ?_⟩, rfl⟩ have : w = u + t := φ.injective (by rw [map_add, hweq]) rwa [← this] · rintro ⟨u, ⟨hu, hut⟩, rfl⟩ exact ⟨⟨u, hu, rfl⟩, ⟨u + t, hut, map_add φ u t⟩⟩ rw [h, Finset.card_image_of_injective _ φ.injective] private lemma fiber_image_addEquiv (C : Finset G) (x₀ : G) (φ : G ≃+ G) : Fiber (C.image φ) (φ x₀) = (Fiber C x₀).image φ := by classical ext y simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and, Finset.mem_image] constructor · rintro ⟨hyC, hauto⟩ refine ⟨φ.symm y, ⟨?_, ?_⟩, by simp⟩ · intro h; exact hyC ⟨φ.symm y, h, by simp⟩ · funext t have ht := congr_fun hauto (φ t) have h1 : insert y (C.image φ) = (insert (φ.symm y) C).image φ := by rw [Finset.image_insert, φ.apply_symm_apply] have h2 : insert (φ x₀) (C.image φ) = (insert x₀ C).image φ := by rw [Finset.image_insert] rw [h1, h2, autocorr_image_addEquiv, autocorr_image_addEquiv] at ht exact ht · rintro ⟨x, ⟨hxC, hauto⟩, rfl⟩ refine ⟨?_, ?_⟩ · intro h; obtain ⟨u, hu, hueq⟩ := h; exact hxC (φ.injective hueq ▸ hu) · funext t have h1 : insert (φ x) (C.image φ) = (insert x C).image φ := by rw [Finset.image_insert] have h2 : insert (φ x₀) (C.image φ) = (insert x₀ C).image φ := by rw [Finset.image_insert] rw [h1, h2, ← φ.apply_symm_apply t, autocorr_image_addEquiv, autocorr_image_addEquiv] exact congr_fun hauto (φ.symm t) omit [Fintype G] in private lemma isAperiodic_image_add {C : Finset G} (hC : IsAperiodic C) (a : G) : IsAperiodic (C.image (· + a)) := by intro g hg have himg : C.image (· + g) = C := by ext u have hmem : u + a ∈ (C.image (· + a)).image (· + g) ↔ u + a ∈ C.image (· + a) := by rw [hg] simp only [Finset.mem_image] at hmem ⊢ constructor · rintro ⟨v, hv, rfl⟩ have : (v + g) + a ∈ C.image (· + a) := by rw [← hg] refine Finset.mem_image.2 ⟨v + a, Finset.mem_image_of_mem _ hv, by abel⟩ obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 this have : w = v + g := add_right_cancel hweq rwa [← this] · intro hu obtain ⟨b, hb, hbeq⟩ := hmem.2 ⟨u, hu, rfl⟩ obtain ⟨v, hv, rfl⟩ := hb refine ⟨v, hv, add_right_cancel (b := a) ?_⟩ calc v + g + a = v + a + g := by abel _ = u + a := hbeq exact hC g himg omit [Fintype G] in private lemma autocorr_image_add (S : Finset G) (a t : G) : autocorr (S.image (· + a)) t = autocorr S t := by unfold autocorr have h : (S.image (· + a)).filter (fun u => u + t ∈ S.image (· + a)) = (S.filter (fun u => u + t ∈ S)).image (· + a) := by ext v simp only [Finset.mem_filter, Finset.mem_image] constructor · rintro ⟨⟨u, hu, rfl⟩, ⟨w, hw, hweq⟩⟩ refine ⟨u, ⟨hu, ?_⟩, rfl⟩ have hwa : w + a = u + t + a := by rw [hweq]; abel have : w = u + t := add_right_cancel hwa rwa [← this] · rintro ⟨u, ⟨hu, hut⟩, rfl⟩ exact ⟨⟨u, hu, rfl⟩, ⟨u + t, hut, by abel⟩⟩ rw [h, Finset.card_image_of_injective _ (add_left_injective a)] private lemma fiber_image_add (C : Finset G) (x₀ a : G) : Fiber (C.image (· + a)) (x₀ + a) = (Fiber C x₀).image (· + a) := by classical ext y simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and, Finset.mem_image] constructor · rintro ⟨hyC, hauto⟩ refine ⟨y - a, ⟨?_, ?_⟩, sub_add_cancel y a⟩ · intro h; exact hyC ⟨y - a, h, sub_add_cancel y a⟩ · funext t have ht := congr_fun hauto t have h1 : insert y (C.image (· + a)) = (insert (y - a) C).image (· + a) := by rw [Finset.image_insert, sub_add_cancel] have h2 : insert (x₀ + a) (C.image (· + a)) = (insert x₀ C).image (· + a) := by rw [Finset.image_insert] rw [h1, h2, autocorr_image_add, autocorr_image_add] at ht exact ht · rintro ⟨x, ⟨hxC, hauto⟩, rfl⟩ refine ⟨?_, ?_⟩ · intro h; obtain ⟨u, hu, hueq⟩ := h; exact hxC (add_right_cancel hueq ▸ hu) · funext t have h1 : insert (x + a) (C.image (· + a)) = (insert x C).image (· + a) := by rw [Finset.image_insert] have h2 : insert (x₀ + a) (C.image (· + a)) = (insert x₀ C).image (· + a) := by rw [Finset.image_insert] rw [h1, h2, autocorr_image_add, autocorr_image_add] exact congr_fun hauto t private lemma unit_circle_re_eq_at_most_two {z w₁ w₂ w₃ : ℂ} (hz : z ≠ 0) (hw₁ : ‖w₁‖ = 1) (hw₂ : ‖w₂‖ = 1) (hw₃ : ‖w₃‖ = 1) (h12 : (z * w₁).re = (z * w₂).re) (h13 : (z * w₁).re = (z * w₃).re) : w₁ = w₂ ∨ w₁ = w₃ ∨ w₂ = w₃ := by have hns : ∀ w : ℂ, ‖w‖ = 1 → Complex.normSq (z * w) = Complex.normSq z := fun w hw => by rw [map_mul, Complex.normSq_eq_norm_sq w, hw, one_pow, mul_one] have him : ∀ w : ℂ, ‖w‖ = 1 → (z * w₁).re = (z * w).re → (z * w).im = (z * w₁).im ∨ (z * w).im = -(z * w₁).im := fun w hw hre => by have hq1 := hns w₁ hw₁ have hq2 := hns w hw have hsq : (z * w).im ^ 2 = (z * w₁).im ^ 2 := by have h := hq2.trans hq1.symm rw [Complex.normSq_apply, Complex.normSq_apply, ← hre] at h nlinarith exact sq_eq_sq_iff_eq_or_eq_neg.1 hsq rcases him w₂ hw₂ h12 with h2 | h2 · left; exact mul_left_cancel₀ hz (Complex.ext h12 h2.symm) · rcases him w₃ hw₃ h13 with h3 | h3 · right; left; exact mul_left_cancel₀ hz (Complex.ext h13 h3.symm) · right; right; exact mul_left_cancel₀ hz (Complex.ext (h12.symm.trans h13) (h2.trans h3.symm)) end Core section UpperBound variable {p r : ℕ} [Fact p.Prime] private noncomputable def e1 (p : ℕ) [NeZero p] : AddChar (ZMod p) ℂ := AddChar.zmodAddEquiv (1 : ZMod p) private lemma e1_apply_comm (p : ℕ) [NeZero p] (a : ZMod p) : e1 p a = (AddChar.zmodAddEquiv a : AddChar (ZMod p) ℂ) 1 := by unfold e1 rw [AddChar.zmodAddEquiv_apply, AddChar.zmodAddEquiv_apply] obtain ⟨k, rfl⟩ := ZMod.intCast_surjective a have h1 : (1 : ZMod p) = ((1 : ℤ) : ZMod p) := by simp rw [h1] change ((AddChar.zmod p ((1 : ℤ) : ZMod p) ((k : ℤ) : ZMod p) : Circle) : ℂ) = ((AddChar.zmod p ((k : ℤ) : ZMod p) ((1 : ℤ) : ZMod p) : Circle) : ℂ) rw [AddChar.zmod_intCast, AddChar.zmod_intCast] congr 2 ring private lemma e1_injective (p : ℕ) [NeZero p] : Function.Injective (e1 p) := by intro a b hab have hsub : e1 p (a - b) = 1 := by rw [AddChar.map_sub_eq_div, hab, div_self (addChar_apply_ne_zero (e1 p) b)] have h1 : (AddChar.zmodAddEquiv (a - b) : AddChar (ZMod p) ℂ) 1 = 1 := by rw [← e1_apply_comm, hsub] have hall : (AddChar.zmodAddEquiv (a - b) : AddChar (ZMod p) ℂ) = 0 := by ext y have hy : y = y.val • (1 : ZMod p) := by simp rw [hy, AddChar.map_nsmul_eq_pow, h1, one_pow] rfl have hzero : a - b = 0 := AddChar.zmodAddEquiv.injective (hall.trans (map_zero _).symm) exact sub_eq_zero.1 hzero private def dotHomR (p r : ℕ) (ξ : Fin r → ZMod p) : (Fin r → ZMod p) →+ ZMod p where toFun u := ∑ i : Fin r, ξ i * u i map_zero' := by simp map_add' u v := by simp only [Pi.add_apply, mul_add, Finset.sum_add_distrib] private noncomputable def charR (p r : ℕ) [NeZero p] (ξ : Fin r → ZMod p) : AddChar (Fin r → ZMod p) ℂ := (e1 p).compAddMonoidHom (dotHomR p r ξ) private lemma charR_apply (p r : ℕ) [NeZero p] (ξ u : Fin r → ZMod p) : charR p r ξ u = e1 p (∑ i : Fin r, ξ i * u i) := rfl private lemma charR_injective (p r : ℕ) [NeZero p] : Function.Injective (charR p r) := by intro ξ η h funext i have hi := DFunLike.congr_fun h (Pi.single i (1 : ZMod p)) simp only [charR_apply, Pi.single_apply, mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] at hi exact e1_injective p hi private lemma charR_bijective (p r : ℕ) [NeZero p] : Function.Bijective (charR p r) := by rw [Fintype.bijective_iff_injective_and_card, AddChar.card_eq] exact ⟨charR_injective p r, rfl⟩ private noncomputable def FR (C : Finset (Fin r → ZMod p)) (ξ : Fin r → ZMod p) : ℂ := fourierCoeff C (charR p r ξ) private lemma fourier_inversion_zmodR (C : Finset (Fin r → ZMod p)) (u : Fin r → ZMod p) : ∑ ξ : Fin r → ZMod p, FR C ξ * charR p r ξ u = ((p ^ r : ℕ) : ℂ) * (indC C u : ℂ) := by have h := fourier_inversion_indC C u have hbij := Fintype.sum_bijective (charR p r) (charR_bijective p r) (fun ξ => FR C ξ * charR p r ξ u) (fun χ => fourierCoeff C χ * χ u) (fun _ => rfl) rw [hbij, h] simp [Fintype.card_pi, ZMod.card] private lemma isAperiodic_of_orthog_zeroR {C : Finset (Fin r → ZMod p)} (hC : IsAperiodic C) {g : Fin r → ZMod p} (hg : ∀ ξ : Fin r → ZMod p, FR C ξ ≠ 0 → ∑ i : Fin r, ξ i * g i = 0) : g = 0 := by have hind : ∀ u : Fin r → ZMod p, indC C (u + g) = indC C u := by intro u have h1 := fourier_inversion_zmodR C (u + g) have h2 := fourier_inversion_zmodR C u have hsum : ∑ ξ : Fin r → ZMod p, FR C ξ * charR p r ξ (u + g) = ∑ ξ : Fin r → ZMod p, FR C ξ * charR p r ξ u := by refine Finset.sum_congr rfl fun ξ _ => ?_ by_cases hF : FR C ξ = 0 · simp [hF] · have hdot := hg ξ hF have hch : charR p r ξ (u + g) = charR p r ξ u := by rw [AddChar.map_add_eq_mul, charR_apply p r ξ g, hdot, AddChar.map_zero_eq_one, mul_one] rw [hch] rw [h1, h2] at hsum have hpr : ((p ^ r : ℕ) : ℂ) ≠ 0 := by exact Nat.cast_ne_zero.2 (pow_ne_zero r (Fact.out : p.Prime).ne_zero) exact Nat.cast_injective (mul_left_cancel₀ hpr hsum) have himg : C.image (· + (-g)) = C := by ext u simp only [Finset.mem_image] constructor · rintro ⟨v, hv, rfl⟩ have h := hind (v + -g) have hsub : v + -g + g = v := by abel rw [hsub] at h unfold indC at h by_cases h1 : v ∈ C <;> by_cases h2 : v + -g ∈ C <;> simp_all · intro hu refine ⟨u + g, ?_, by abel⟩ have h := hind u unfold indC at h by_cases h1 : u + g ∈ C <;> by_cases h2 : u ∈ C <;> simp_all have hneg : -g = 0 := hC (-g) himg simpa using congr_arg Neg.neg hneg /-- Active characters of an aperiodic support in `(ZMod p)^r` span the full space. -/ private lemma active_span_top {C : Finset (Fin r → ZMod p)} (hC : IsAperiodic C) : Submodule.span (ZMod p) {ξ : Fin r → ZMod p | FR C ξ ≠ 0} = ⊤ := by set W : Submodule (ZMod p) (Fin r → ZMod p) := Submodule.span (ZMod p) {ξ : Fin r → ZMod p | FR C ξ ≠ 0} by_contra hne have hfin_lt : Module.finrank (ZMod p) W < Module.finrank (ZMod p) (Fin r → ZMod p) := Submodule.finrank_lt hne let Φ : (Fin r → ZMod p) →ₗ[ZMod p] Module.Dual (ZMod p) W := { toFun := fun g => { toFun := fun w => ∑ i : Fin r, w.1 i * g i map_add' := fun w₁ w₂ => by simp only [Submodule.coe_add, Pi.add_apply, add_mul, Finset.sum_add_distrib] map_smul' := fun c w => by simp only [Submodule.coe_smul, Pi.smul_apply, smul_eq_mul, RingHom.id_apply, mul_assoc, Finset.mul_sum] } map_add' := fun g₁ g₂ => by ext w; simp [mul_add, Finset.sum_add_distrib] map_smul' := fun c g => by ext w; simp only [LinearMap.coe_mk, AddHom.coe_mk, Pi.smul_apply, smul_eq_mul, LinearMap.smul_apply, RingHom.id_apply, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => by ring } have hdual_lt : Module.finrank (ZMod p) (Module.Dual (ZMod p) W) < Module.finrank (ZMod p) (Fin r → ZMod p) := by rw [Subspace.dual_finrank_eq]; exact hfin_lt have hker_pos : 0 < Module.finrank (ZMod p) (LinearMap.ker Φ) := by have hrn := LinearMap.finrank_range_add_finrank_ker Φ have hrange_le : Module.finrank (ZMod p) (LinearMap.range Φ) ≤ Module.finrank (ZMod p) (Module.Dual (ZMod p) W) := Submodule.finrank_le _ omega obtain ⟨⟨g, hg_ker⟩, hg_ne⟩ := Module.finrank_pos_iff_exists_ne_zero.1 hker_pos have hg0 : g ≠ 0 := fun h => hg_ne (Subtype.ext h) apply hg0 apply isAperiodic_of_orthog_zeroR hC intro ξ hF have hξW : ξ ∈ W := Submodule.subset_span hF have h0 : Φ g ⟨ξ, hξW⟩ = 0 := by rw [LinearMap.mem_ker.1 hg_ker] rfl exact h0 /-- **Theorem 3.3 (Part 1 — Strict Upper Bound)**: For every odd prime `p ≥ 3`, rank `r ≥ 2`, aperiodic `C : Finset (Fin r → ZMod p)`, and `x₀ ∉ C`, the single-point insertion fiber has cardinality strictly less than `2 ^ r`. -/ theorem fiber_card_lt_two_pow {p r : ℕ} [Fact p.Prime] (hp3 : 3 ≤ p) (hr : 2 ≤ r) (C : Finset (Fin r → ZMod p)) (hC : IsAperiodic C) {x₀ : Fin r → ZMod p} (hx₀ : x₀ ∉ C) : (Fiber C x₀).card < 2 ^ r := by have h2ne0 : (2 : ZMod p) ≠ 0 := by intro h have hdvd : p ∣ 2 := (ZMod.natCast_eq_zero_iff 2 p).1 (by simpa using h) have hle : p ≤ 2 := Nat.le_of_dvd (by omega) hdvd omega -- Step 1: Extract an active basis `b : Fin r → (Fin r → ZMod p)`. have hspan := active_span_top hC obtain ⟨t, ht_sub, ht_span, ht_li⟩ := exists_linearIndependent (ZMod p) {ξ : Fin r → ZMod p | FR C ξ ≠ 0} rw [hspan] at ht_span let : Fintype t := Fintype.ofFinite t let B : Module.Basis t (ZMod p) (Fin r → ZMod p) := Module.Basis.mk ht_li (by rw [Subtype.range_coe_subtype]; exact le_of_eq ht_span.symm) have hcard_t : Fintype.card t = r := by have h1 := Module.finrank_eq_card_basis B rw [Module.finrank_fin_fun] at h1 exact h1.symm let e : Fin r ≃ t := (Fintype.equivFinOfCardEq hcard_t).symm let b : Fin r → (Fin r → ZMod p) := fun i => (e i).1 have hb_active : ∀ i : Fin r, FR C (b i) ≠ 0 := fun i => ht_sub (e i).2 have hb_span : Submodule.span (ZMod p) (Set.range b) = ⊤ := by have hrng : Set.range b = t := by ext ξ simp only [Set.mem_range, b] constructor · rintro ⟨i, rfl⟩; exact (e i).2 · intro hξ; exact ⟨e.symm ⟨ξ, hξ⟩, by simp⟩ rw [hrng, ht_span] -- Step 2: Change coordinates via `Llin u i = ∑ j, b i j * u j`. let Llin : (Fin r → ZMod p) →ₗ[ZMod p] (Fin r → ZMod p) := { toFun := fun u i => ∑ j : Fin r, b i j * u j map_add' := fun u v => by funext i; simp [mul_add, Finset.sum_add_distrib] map_smul' := fun c u => by funext i simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => by ring } have hL_inj : Function.Injective Llin := by rw [injective_iff_map_eq_zero] intro u hu let ψ : (Fin r → ZMod p) →ₗ[ZMod p] ZMod p := { toFun := fun ξ => ∑ j : Fin r, ξ j * u j map_add' := fun ξ η => by simp [add_mul, Finset.sum_add_distrib] map_smul' := fun c ξ => by simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, mul_assoc, Finset.mul_sum] } have hker : Submodule.span (ZMod p) (Set.range b) ≤ LinearMap.ker ψ := by rw [Submodule.span_le] rintro ξ ⟨i, rfl⟩ exact congr_fun hu i rw [hb_span, top_le_iff] at hker funext j have hj : ψ (Pi.single j 1) = 0 := by have : Pi.single j (1 : ZMod p) ∈ LinearMap.ker ψ := by rw [hker]; trivial exact this simpa [ψ, Pi.single_apply] using hj have hL_bij : Function.Bijective Llin.toAddMonoidHom := (Finite.injective_iff_bijective).1 hL_inj let L : (Fin r → ZMod p) ≃+ (Fin r → ZMod p) := AddEquiv.ofBijective Llin.toAddMonoidHom hL_bij -- Step 3: Transport to `C₁ = (C.image L).image (· + (-L x₀))`, basepoint `0`. let a := -L x₀ let C₁ := (C.image L).image (· + a) have hC₁ : IsAperiodic C₁ := isAperiodic_image_add (isAperiodic_image_addEquiv hC L) a have h0C₁ : (0 : Fin r → ZMod p) ∉ C₁ := by intro h obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 h obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hw have : L u = L x₀ := sub_eq_zero.1 (by simpa [a, sub_eq_add_neg] using hweq) exact hx₀ (L.injective this ▸ hu) have hcard₁ : (Fiber C₁ 0).card = (Fiber C x₀).card := by have ha0 : L x₀ + a = 0 := add_neg_cancel (L x₀) rw [← ha0, fiber_image_add, Finset.card_image_of_injective _ (add_left_injective a), fiber_image_addEquiv, Finset.card_image_of_injective _ L.injective] have hactive_coord : ∀ i : Fin r, FR C₁ (Pi.single i 1) ≠ 0 := by intro i have hcalc : FR C₁ (Pi.single i 1) = FR C (b i) * e1 p ((L x₀) i) := by unfold FR fourierCoeff rw [Finset.sum_image (fun _ _ _ _ h => add_left_injective a h), Finset.sum_image (fun _ _ _ _ h => L.injective h), Finset.sum_mul] refine Finset.sum_congr rfl fun u _ => ?_ simp only [charR_apply, Pi.single_apply, ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, ← AddChar.map_add_eq_mul] congr 1 have hLu : (L u) i = ∑ j : Fin r, b i j * u j := rfl have hneg : (-(L u + a)) i = -(L u) i + (L x₀) i := by simp [a]; ring rw [hneg, hLu] simp only [Pi.neg_apply, mul_neg, Finset.sum_neg_distrib] rw [hcalc] exact mul_ne_zero (hb_active i) (addChar_apply_ne_zero (e1 p) _) -- Step 4: Each coordinate projection `S i` of `Fiber C₁ 0` has size `≤ 2`. let S : Fin r → Finset (ZMod p) := fun i => (Fiber C₁ 0).image (fun u => u i) have hS_le2 : ∀ i : Fin r, (S i).card ≤ 2 := by intro i by_contra hgt have hge3 : 3 ≤ (S i).card := by omega obtain ⟨t3, ht3_sub, ht3_card⟩ := Finset.exists_subset_card_eq hge3 obtain ⟨v₁, v₂, v₃, h12, h13, h23, ht3_eq⟩ := Finset.card_eq_three.1 ht3_card subst ht3_eq obtain ⟨u₁, hu₁, hu₁v⟩ := Finset.mem_image.1 (ht3_sub (by simp : v₁ ∈ ({v₁, v₂, v₃} : Finset (ZMod p)))) obtain ⟨u₂, hu₂, hu₂v⟩ := Finset.mem_image.1 (ht3_sub (by simp : v₂ ∈ ({v₁, v₂, v₃} : Finset (ZMod p)))) obtain ⟨u₃, hu₃, hu₃v⟩ := Finset.mem_image.1 (ht3_sub (by simp : v₃ ∈ ({v₁, v₂, v₃} : Finset (ZMod p)))) have hr1 := mem_fiber_fourier h0C₁ hu₁ (charR p r (Pi.single i 1)) have hr2 := mem_fiber_fourier h0C₁ hu₂ (charR p r (Pi.single i 1)) have hr3 := mem_fiber_fourier h0C₁ hu₃ (charR p r (Pi.single i 1)) have htri := unit_circle_re_eq_at_most_two (hactive_coord i) ((charR p r (Pi.single i 1)).norm_apply u₁) ((charR p r (Pi.single i 1)).norm_apply u₂) ((charR p r (Pi.single i 1)).norm_apply u₃) (hr1.trans hr2.symm) (hr1.trans hr3.symm) have hch : ∀ u : Fin r → ZMod p, charR p r (Pi.single i 1) u = e1 p (u i) := fun u => by simp [charR_apply, Pi.single_apply] simp only [hch] at htri rcases htri with h | h | h · exact h12 (hu₁v.symm.trans ((e1_injective p h).trans hu₂v)) · exact h13 (hu₁v.symm.trans ((e1_injective p h).trans hu₃v)) · exact h23 (hu₂v.symm.trans ((e1_injective p h).trans hu₃v)) have hsub_pi : Fiber C₁ 0 ⊆ Fintype.piFinset S := by intro u hu rw [Fintype.mem_piFinset] intro i exact Finset.mem_image_of_mem _ hu have hcard_le : (Fiber C₁ 0).card ≤ 2 ^ r := by calc (Fiber C₁ 0).card ≤ (Fintype.piFinset S).card := Finset.card_le_card hsub_pi _ = ∏ i : Fin r, (S i).card := Fintype.card_piFinset S _ ≤ ∏ _i : Fin r, 2 := Finset.prod_le_prod (fun _ _ => Nat.zero_le _) (fun i _ => hS_le2 i) _ = 2 ^ r := by simp -- Step 5: Assume for contradiction `(Fiber C x₀).card = 2 ^ r` (full `r`-cube). rw [← hcard₁] by_contra hnotlt have hcard_eq : (Fiber C₁ 0).card = 2 ^ r := by omega have hS_eq2 : ∀ i : Fin r, (S i).card = 2 := by intro i have hle := hS_le2 i by_contra hne2 have hle1 : (S i).card ≤ 1 := by omega have hprod_le : ∏ j : Fin r, (S j).card ≤ 1 * 2 ^ (r - 1) := by rw [← Finset.mul_prod_erase Finset.univ (fun j => (S j).card) (Finset.mem_univ i)] refine Nat.mul_le_mul hle1 ?_ calc ∏ j ∈ Finset.univ.erase i, (S j).card ≤ ∏ _j ∈ Finset.univ.erase i, 2 := Finset.prod_le_prod (fun _ _ => Nat.zero_le _) (fun j _ => hS_le2 j) _ = 2 ^ (Finset.univ.erase i).card := by simp _ = 2 ^ (r - 1) := by simp have hpow_lt : 1 * 2 ^ (r - 1) < 2 ^ r := by rw [one_mul] have hr1 : r = (r - 1) + 1 := by omega conv_rhs => rw [hr1, pow_succ] have hpos : 0 < 2 ^ (r - 1) := by positivity omega have h1 : (Fiber C₁ 0).card ≤ ∏ j : Fin r, (S j).card := by rw [← Fintype.card_piFinset]; exact Finset.card_le_card hsub_pi omega have hpi_eq : Fiber C₁ 0 = Fintype.piFinset S := by refine Finset.eq_of_subset_of_card_le hsub_pi ?_ rw [Fintype.card_piFinset, hcard_eq] simp [hS_eq2] -- Extract nonzero `sc i` so `S i = {0, sc i}` and rescale to `{0, 1}^r`. have h0_in_S : ∀ i : Fin r, (0 : ZMod p) ∈ S i := fun i => Finset.mem_image.2 ⟨0, mem_fiber_self C₁ h0C₁, rfl⟩ have hex_sc : ∀ i : Fin r, ∃ c : ZMod p, c ≠ 0 ∧ S i = {0, c} := by intro i obtain ⟨c, hcS, hcne⟩ := Finset.exists_mem_ne (by rw [hS_eq2 i]; omega : 1 < (S i).card) 0 refine ⟨c, hcne, ?_⟩ symm refine Finset.eq_of_subset_of_card_le ?_ ?_ · intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl · exact h0_in_S i · exact hcS · rw [hS_eq2 i, Finset.card_pair hcne.symm] choose sc hsc_ne hsc_eq using hex_sc let D : (Fin r → ZMod p) ≃+ (Fin r → ZMod p) := { toFun := fun u i => (sc i)⁻¹ * u i invFun := fun v i => sc i * v i left_inv := fun u => by funext i; exact mul_inv_cancel_left₀ (hsc_ne i) (u i) right_inv := fun v => by funext i; exact inv_mul_cancel_left₀ (hsc_ne i) (v i) map_add' := fun u v => by funext i; simp [mul_add] } let C₂ := C₁.image D have hC₂ : IsAperiodic C₂ := isAperiodic_image_addEquiv hC₁ D have h0C₂ : (0 : Fin r → ZMod p) ∉ C₂ := by intro h obtain ⟨u, hu, hueq⟩ := Finset.mem_image.1 h have hu0 : u = 0 := D.injective (hueq.trans (map_zero D).symm) exact h0C₁ (hu0 ▸ hu) have hcube : ∀ u : Fin r → ZMod p, (∀ i : Fin r, u i = 0 ∨ u i = 1) → u ∈ Fiber C₂ 0 := by intro u hu have hF2 : Fiber C₂ 0 = (Fiber C₁ 0).image D := by have hD0 : D 0 = 0 := map_zero D simpa only [hD0] using fiber_image_addEquiv C₁ 0 D rw [hF2] refine Finset.mem_image.2 ⟨D.symm u, ?_, by simp⟩ rw [hpi_eq, Fintype.mem_piFinset] intro i rw [hsc_eq i] rcases hu i with h0 | h1 · simp [D, h0] · simp [D, h1] -- Step 6: Every active character `ξ` of `C₂` has at most one nonzero coordinate. have hsupport_le1 : ∀ ξ : Fin r → ZMod p, FR C₂ ξ ≠ 0 → ∀ i j : Fin r, ξ i ≠ 0 → ξ j ≠ 0 → i = j := by intro ξ hF i j hi hj by_contra hij have h0_mem : (0 : Fin r → ZMod p) ∈ Fiber C₂ 0 := hcube 0 (fun _ => Or.inl rfl) have hei_mem : Pi.single i (1 : ZMod p) ∈ Fiber C₂ 0 := hcube _ fun k => by by_cases hk : k = i <;> simp [hk] have hej_mem : Pi.single j (1 : ZMod p) ∈ Fiber C₂ 0 := hcube _ fun k => by by_cases hk : k = j <;> simp [hk] have heij_mem : Pi.single i (1 : ZMod p) + Pi.single j (1 : ZMod p) ∈ Fiber C₂ 0 := hcube _ fun k => by by_cases hki : k = i · subst hki; right; simp [hij] · by_cases hkj : k = j · subst hkj; right; simp [hki] · left; simp [hki, hkj] have hdot_ei : charR p r ξ (Pi.single i 1) = e1 p (ξ i) := by simp [charR_apply, Pi.single_apply] have hdot_ej : charR p r ξ (Pi.single j 1) = e1 p (ξ j) := by simp [charR_apply, Pi.single_apply] have hdot_eij : charR p r ξ (Pi.single i 1 + Pi.single j 1) = e1 p (ξ i + ξ j) := by rw [AddChar.map_add_eq_mul, hdot_ei, hdot_ej, ← AddChar.map_add_eq_mul] have htri1 := unit_circle_re_eq_at_most_two hF ((charR p r ξ).norm_apply 0) ((charR p r ξ).norm_apply (Pi.single i 1)) ((charR p r ξ).norm_apply (Pi.single j 1)) (mem_fiber_fourier h0C₂ hei_mem (charR p r ξ)).symm (mem_fiber_fourier h0C₂ hej_mem (charR p r ξ)).symm rw [show charR p r ξ 0 = e1 p 0 from by simp, hdot_ei, hdot_ej] at htri1 have hξeq : ξ i = ξ j := by rcases htri1 with h | h | h · exact absurd (e1_injective p h).symm hi · exact absurd (e1_injective p h).symm hj · exact e1_injective p h have htri2 := unit_circle_re_eq_at_most_two hF ((charR p r ξ).norm_apply 0) ((charR p r ξ).norm_apply (Pi.single i 1)) ((charR p r ξ).norm_apply (Pi.single i 1 + Pi.single j 1)) (mem_fiber_fourier h0C₂ hei_mem (charR p r ξ)).symm (mem_fiber_fourier h0C₂ heij_mem (charR p r ξ)).symm rw [show charR p r ξ 0 = e1 p 0 from by simp, hdot_ei, hdot_eij] at htri2 rcases htri2 with h | h | h · exact hi (e1_injective p h).symm · have hsum0 : ξ i + ξ j = 0 := (e1_injective p h).symm rw [← hξeq] at hsum0 have h2ξ : 2 * ξ i = 0 := by linear_combination hsum0 exact (mul_eq_zero.1 h2ξ).elim h2ne0 hi · have heq : ξ i = ξ i + ξ j := e1_injective p h exact hj (by linear_combination -heq) -- Step 7: Decompose `1_{C₂}(u) = c₀ + ∑ i, g i (u i)` and show at most one `g i` is nonconstant. let N : ℝ := (p ^ r : ℕ) have hNpos : (0 : ℝ) < N := Nat.cast_pos.2 (pow_pos (Fact.out : p.Prime).pos r) let c₀ : ℝ := N⁻¹ * (FR C₂ 0).re let g : Fin r → ZMod p → ℝ := fun i x => N⁻¹ * (∑ c ∈ Finset.univ.erase (0 : ZMod p), FR C₂ (Pi.single i c) * e1 p (c * x)).re have hdecomp : ∀ u : Fin r → ZMod p, (indC C₂ u : ℝ) = c₀ + ∑ i : Fin r, g i (u i) := by intro u let T : Fin r → Finset (Fin r → ZMod p) := fun i => (Finset.univ.erase (0 : ZMod p)).image (Pi.single i) have hdisjT : Set.PairwiseDisjoint (↑(Finset.univ : Finset (Fin r)) : Set (Fin r)) T := by intro i _ j _ hij show Disjoint (T i) (T j) rw [Finset.disjoint_left] intro ξ h1 h2 obtain ⟨c₁, hc₁, rfl⟩ := Finset.mem_image.1 h1 obtain ⟨c₂, _, h2'⟩ := Finset.mem_image.1 h2 have := congr_fun h2' i simp [hij] at this exact (Finset.mem_erase.1 hc₁).1 this.symm have h0_notin_biUnion : (0 : Fin r → ZMod p) ∉ Finset.univ.biUnion T := by simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, T, Finset.mem_image, Finset.mem_erase, not_exists, not_and] intro i c hc0 heq have := congr_fun heq i simp at this exact hc0.1 this have hcover : ∀ ξ : Fin r → ZMod p, FR C₂ ξ ≠ 0 → ξ ∈ insert (0 : Fin r → ZMod p) (Finset.univ.biUnion T) := by intro ξ hF by_cases hξ0 : ξ = 0 · rw [hξ0]; exact Finset.mem_insert_self _ _ · refine Finset.mem_insert_of_mem ?_ have hex : ∃ i : Fin r, ξ i ≠ 0 := by by_contra hall; push Not at hall; exact hξ0 (funext hall) obtain ⟨i, hi⟩ := hex rw [Finset.mem_biUnion] refine ⟨i, Finset.mem_univ i, Finset.mem_image.2 ⟨ξ i, Finset.mem_erase.2 ⟨hi, Finset.mem_univ _⟩, ?_⟩⟩ funext j by_cases hji : j = i · subst hji; simp · simp only [Pi.single_apply, if_neg hji] by_contra hj exact hji (hsupport_le1 ξ hF j i (Ne.symm hj) hi) have hinv := fourier_inversion_zmodR C₂ u have hsub : ∑ ξ : Fin r → ZMod p, FR C₂ ξ * charR p r ξ u = ∑ ξ ∈ insert (0 : Fin r → ZMod p) (Finset.univ.biUnion T), FR C₂ ξ * charR p r ξ u := by symm refine Finset.sum_subset (Finset.subset_univ _) fun ξ _ hnot => ?_ have hF0 : FR C₂ ξ = 0 := by by_contra hne; exact hnot (hcover ξ hne) simp [hF0] rw [hsub, Finset.sum_insert h0_notin_biUnion, Finset.sum_biUnion hdisjT] at hinv have hsumT : ∀ i : Fin r, ∑ ξ ∈ T i, FR C₂ ξ * charR p r ξ u = ∑ c ∈ Finset.univ.erase (0 : ZMod p), FR C₂ (Pi.single i c) * e1 p (c * u i) := by intro i rw [Finset.sum_image (fun a _ b _ h => by simpa using congr_fun h i)] refine Finset.sum_congr rfl fun c _ => ?_ simp [charR_apply, Pi.single_apply] simp_rw [hsumT] at hinv have h0char : charR p r 0 u = 1 := by simp [charR_apply] rw [h0char, mul_one] at hinv have hre := congr_arg Complex.re hinv rw [Complex.add_re, Complex.re_sum, Complex.mul_re, Complex.natCast_re, Complex.natCast_im, zero_mul, sub_zero, Complex.natCast_re] at hre have hNmul : N * (indC C₂ u : ℝ) = (FR C₂ 0).re + ∑ i : Fin r, (∑ c ∈ Finset.univ.erase (0 : ZMod p), FR C₂ (Pi.single i c) * e1 p (c * u i)).re := hre.symm dsimp only [c₀, g] rw [← Finset.mul_sum, ← mul_add, ← hNmul] have hN0 : N ≠ 0 := ne_of_gt hNpos field_simp [hN0] -- Two distinct nonconstant summands `g i, g j` would produce 3 distinct values in `{0, 1}`. have hat_most_one : ∀ i j : Fin r, i ≠ j → (∀ a b : ZMod p, g i a = g i b) ∨ (∀ a b : ZMod p, g j a = g j b) := by intro i j hij by_contra hnc push Not at hnc obtain ⟨⟨a₁, a₂, ha⟩, ⟨b₁, b₂, hb⟩⟩ := hnc have hlt1 : ∃ x₁ x₂, g i x₁ < g i x₂ := by rcases lt_or_gt_of_ne ha with h | h · exact ⟨a₁, a₂, h⟩ · exact ⟨a₂, a₁, h⟩ have hlt2 : ∃ y₁ y₂, g j y₁ < g j y₂ := by rcases lt_or_gt_of_ne hb with h | h · exact ⟨b₁, b₂, h⟩ · exact ⟨b₂, b₁, h⟩ obtain ⟨x₁, x₂, hx⟩ := hlt1 obtain ⟨y₁, y₂, hy⟩ := hlt2 let u₁ : Fin r → ZMod p := Function.update (Function.update 0 i x₁) j y₁ let u₂ : Fin r → ZMod p := Function.update (Function.update 0 i x₂) j y₁ let u₃ : Fin r → ZMod p := Function.update (Function.update 0 i x₂) j y₂ have hdiff12 : (indC C₂ u₂ : ℝ) - (indC C₂ u₁ : ℝ) = g i x₂ - g i x₁ := by rw [hdecomp u₂, hdecomp u₁] have hterm : ∀ k : Fin r, g k (u₂ k) - g k (u₁ k) = if k = i then g i x₂ - g i x₁ else 0 := by intro k by_cases hki : k = i · subst hki; simp [u₁, u₂, hij] · by_cases hkj : k = j · subst hkj; simp [u₁, u₂, hki] · simp [u₁, u₂, hki, hkj] have hsum_val : (∑ k : Fin r, g k (u₂ k)) - (∑ k : Fin r, g k (u₁ k)) = g i x₂ - g i x₁ := by rw [← Finset.sum_sub_distrib] rw [Finset.sum_congr rfl (fun k _ => hterm k)] simp linarith have hdiff23 : (indC C₂ u₃ : ℝ) - (indC C₂ u₂ : ℝ) = g j y₂ - g j y₁ := by rw [hdecomp u₃, hdecomp u₂] have hterm : ∀ k : Fin r, g k (u₃ k) - g k (u₂ k) = if k = j then g j y₂ - g j y₁ else 0 := by intro k by_cases hkj : k = j · subst hkj; simp [u₂, u₃] · simp [u₂, u₃, hkj] have hsum_val : (∑ k : Fin r, g k (u₃ k)) - (∑ k : Fin r, g k (u₂ k)) = g j y₂ - g j y₁ := by rw [← Finset.sum_sub_distrib] rw [Finset.sum_congr rfl (fun k _ => hterm k)] simp linarith have hbin : ∀ u : Fin r → ZMod p, (indC C₂ u : ℝ) = 0 ∨ (indC C₂ u : ℝ) = 1 := fun u => by unfold indC; split_ifs <;> simp rcases hbin u₁ with h1 | h1 <;> rcases hbin u₂ with h2 | h2 <;> rcases hbin u₃ with h3 | h3 <;> linarith -- Since `r ≥ 2`, some coordinate `k` has constant `g k`, giving a nonzero period of `C₂`. have hex_const : ∃ k : Fin r, ∀ a b : ZMod p, g k a = g k b := by let i0 : Fin r := ⟨0, by omega⟩ let i1 : Fin r := ⟨1, by omega⟩ have hne : i0 ≠ i1 := fun h => by have hv : (0 : ℕ) = 1 := congr_arg Fin.val h exact Nat.zero_ne_one hv rcases hat_most_one i0 i1 hne with h0 | h1 · exact ⟨i0, h0⟩ · exact ⟨i1, h1⟩ obtain ⟨k, hk_const⟩ := hex_const let ek : Fin r → ZMod p := Pi.single k 1 have hek_ne : ek ≠ 0 := by intro h have := congr_fun h k simp [ek] at this have hind_per : ∀ u : Fin r → ZMod p, indC C₂ (u + ek) = indC C₂ u := by intro u have h1 := hdecomp (u + ek) have h2 := hdecomp u have hsum : ∑ i : Fin r, g i ((u + ek) i) = ∑ i : Fin r, g i (u i) := by refine Finset.sum_congr rfl fun i _ => ?_ by_cases hik : i = k · subst hik; exact hk_const _ _ · simp [ek, hik] rw [hsum] at h1 exact Nat.cast_injective (h1.trans h2.symm) have himg : C₂.image (· + (-ek)) = C₂ := by ext u simp only [Finset.mem_image] constructor · rintro ⟨v, hv, rfl⟩ have h := hind_per (v + -ek) have hsub : v + -ek + ek = v := by abel rw [hsub] at h unfold indC at h by_cases h1 : v ∈ C₂ <;> by_cases h2 : v + -ek ∈ C₂ <;> simp_all · intro hu refine ⟨u + ek, ?_, by abel⟩ have h := hind_per u unfold indC at h by_cases h1 : u + ek ∈ C₂ <;> by_cases h2 : u ∈ C₂ <;> simp_all have hneg0 := hC₂ (-ek) himg exact hek_ne (by simpa using congr_arg Neg.neg hneg0) end UpperBound section SharpFamily variable {r p : ℕ} [Fact p.Prime] /-- The explicit sharp core in `(ZMod p)^r` (for `r ≥ 2` and prime `p ≥ 2 * r + 3`): three full hyperplanes `u 0 ∈ {r, r + 1, r + 3}` plus `2(r - 1)` coordinate masks `{u 0 = ±i ∧ u i = 0}` for `1 ≤ i ≤ r - 1`. -/ def sharpCore (r p : ℕ) [NeZero r] [NeZero p] : Finset (Fin r → ZMod p) := Finset.univ.filter fun u => (u 0 = (r : ZMod p) ∨ u 0 = ((r + 1 : ℕ) : ZMod p) ∨ u 0 = ((r + 3 : ℕ) : ZMod p)) ∨ ∃ i : Fin r, i.val ≠ 0 ∧ (u 0 = (i.val : ZMod p) ∨ u 0 = -(i.val : ZMod p)) ∧ u i = 0 /-- The `2^(r - 1)` insertion sites `(0, ±1, ..., ±1)`. -/ def sharpSites (r p : ℕ) [NeZero r] [NeZero p] : Finset (Fin r → ZMod p) := Finset.univ.filter fun u => u 0 = 0 ∧ ∀ i : Fin r, i.val ≠ 0 → u i = 1 ∨ u i = -1 /-- Base insertion site `(0, 1, ..., 1)`. -/ def baseSite (r p : ℕ) : Fin r → ZMod p := fun i => if i.val = 0 then 0 else 1 private lemma natCast_ne_zero_of_pos_lt {p n : ℕ} [Fact p.Prime] (h0 : 0 < n) (hlt : n < p) : (n : ZMod p) ≠ 0 := by intro h have hdvd : p ∣ n := (ZMod.natCast_eq_zero_iff n p).1 h exact absurd (Nat.le_of_dvd h0 hdvd) (not_le_of_gt hlt) private lemma natCast_ne_natCast_of_lt {p a b : ℕ} [Fact p.Prime] (hab : a < b) (hbp : b < p) : (a : ZMod p) ≠ (b : ZMod p) := by intro h have hdiff : ((b - a : ℕ) : ZMod p) = 0 := by rw [Nat.cast_sub (le_of_lt hab), h, sub_self] exact natCast_ne_zero_of_pos_lt (by omega) (by omega) hdiff private lemma natCast_ne_neg_natCast {p a b : ℕ} [Fact p.Prime] (hpos : 0 < a + b) (hlt : a + b < p) : (a : ZMod p) ≠ -(b : ZMod p) := by intro h have hsum : ((a + b : ℕ) : ZMod p) = 0 := by rw [Nat.cast_add, h, neg_add_cancel] exact natCast_ne_zero_of_pos_lt hpos hlt hsum /-- Cardinality of `sharpSites r p` is `2 ^ (r - 1)`. -/ theorem sharpSites_card [NeZero r] (hr : 2 ≤ r) (hp : 2 * r + 3 ≤ p) : (sharpSites r p).card = 2 ^ (r - 1) := by have h1_neg1 : (1 : ZMod p) ≠ -1 := by have h2 : (2 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_pos_lt (p := p) (n := 2) (by omega) (by omega) intro h; exact h2 (by linear_combination h) let φ : (Fin (r - 1) → Bool) → (Fin r → ZMod p) := fun f i => if hi : i.val = 0 then 0 else if f ⟨i.val - 1, by omega⟩ then 1 else -1 have hφ_inj : Function.Injective φ := by intro f₁ f₂ hf funext j have hj := congr_fun hf ⟨j.val + 1, by omega⟩ have hne0 : (j.val + 1) ≠ 0 := by omega simp only [φ, hne0, ↓reduceDIte, Nat.add_sub_cancel] at hj cases hb1 : f₁ j <;> cases hb2 : f₂ j · rfl · rw [hb1, hb2] at hj; exact absurd hj.symm h1_neg1 · rw [hb1, hb2] at hj; exact absurd hj h1_neg1 · rfl have himg : sharpSites r p = Finset.univ.image φ := by ext u simp only [sharpSites, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image] constructor · rintro ⟨hu0, hui⟩ let f : Fin (r - 1) → Bool := fun j => decide (u ⟨j.val + 1, by omega⟩ = 1) refine ⟨f, ?_⟩ funext i by_cases hi : i.val = 0 · have hi0 : i = 0 := Fin.ext hi rw [hi0, hu0] simp [φ] · simp only [φ, hi, ↓reduceDIte, f] have heq : (⟨i.val - 1 + 1, by omega⟩ : Fin r) = i := Fin.ext (Nat.sub_add_cancel (Nat.pos_of_ne_zero hi)) simp only [heq] rcases hui i hi with h1 | hn1 · simp [h1] · simp [hn1, h1_neg1.symm] · rintro ⟨f, rfl⟩ refine ⟨by simp [φ], fun i hi => ?_⟩ simp only [φ, hi, ↓reduceDIte] cases f ⟨i.val - 1, by omega⟩ <;> simp rw [himg, Finset.card_image_of_injective _ hφ_inj, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] /-- Helper: full hyperplanes of `S` in coordinate `0`. -/ private def IsFullHyperplane {r p : ℕ} [NeZero r] (S : Finset (Fin r → ZMod p)) (a : ZMod p) : Prop := ∀ u : Fin r → ZMod p, u 0 = a → u ∈ S /-- **Theorem 3.3 (Part 2 — Explicit Sharp Construction)**: For every `r ≥ 2` and prime `p ≥ 2 * r + 3`: 1. `sharpCore r p` is aperiodic, 2. `baseSite r p ∉ sharpCore r p`, 3. all `2^(r - 1)` sites in `sharpSites r p` lie in `Fiber (sharpCore r p) (baseSite r p)`, 4. for any distinct `x, y ∈ sharpSites r p`, the completed supports `insert x (sharpCore r p)` and `insert y (sharpCore r p)` are inequivalent under translations `u ↦ u + g`, inversions `u ↦ -u + g`, and complements (even composed with translations or inversions). -/ theorem sharp_construction_theorem [NeZero r] (hr : 2 ≤ r) (hp : 2 * r + 3 ≤ p) : let C := sharpCore r p let S := sharpSites r p let x₀ := baseSite r p IsAperiodic C ∧ x₀ ∉ C ∧ S.card = 2 ^ (r - 1) ∧ S ⊆ Fiber C x₀ ∧ (∀ x ∈ S, ∀ y ∈ S, x ≠ y → ∀ g : Fin r → ZMod p, (insert x C).image (· + g) ≠ insert y C) ∧ (∀ x ∈ S, ∀ y ∈ S, ∀ g : Fin r → ZMod p, (insert x C).image (fun u => -u + g) ≠ insert y C) ∧ (∀ x ∈ S, ∀ y ∈ S, ∀ g : Fin r → ZMod p, ((insert x C).image (· + g))ᶜ ≠ insert y C ∧ ((insert x C).image (fun u => -u + g))ᶜ ≠ insert y C) := by -- Basic arithmetic distinctness in `ZMod p` (since `p ≥ 2*r + 3 ≥ 7`). have hp7 : 7 ≤ p := by omega have h1ne0 : (1 : ZMod p) ≠ 0 := one_ne_zero have h2ne0 : (2 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_pos_lt (p := p) (n := 2) (by omega) (by omega) have h3ne0 : (3 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_pos_lt (p := p) (n := 3) (by omega) (by omega) have h4ne0 : (4 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_pos_lt (p := p) (n := 4) (by omega) (by omega) have h5ne0 : (5 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_pos_lt (p := p) (n := 5) (by omega) (by omega) -- Disjointness between `0`, `{±i | 1 ≤ i < r}`, and `{r, r+1, r+3}`. have h0_ne_r : (0 : ZMod p) ≠ (r : ZMod p) := (natCast_ne_zero_of_pos_lt (p := p) (n := r) (by omega) (by omega)).symm have h0_ne_r1 : (0 : ZMod p) ≠ ((r + 1 : ℕ) : ZMod p) := (natCast_ne_zero_of_pos_lt (p := p) (n := r + 1) (by omega) (by omega)).symm have h0_ne_r3 : (0 : ZMod p) ≠ ((r + 3 : ℕ) : ZMod p) := (natCast_ne_zero_of_pos_lt (p := p) (n := r + 3) (by omega) (by omega)).symm have h0_ne_i : ∀ i : Fin r, i.val ≠ 0 → (0 : ZMod p) ≠ (i.val : ZMod p) := fun i hi => (natCast_ne_zero_of_pos_lt (p := p) (n := i.val) (by omega) (by omega)).symm have h0_ne_ni : ∀ i : Fin r, i.val ≠ 0 → (0 : ZMod p) ≠ -(i.val : ZMod p) := fun i hi h => h0_ne_i i hi (by linear_combination -h) have hmask_ne_full : ∀ (i : Fin r) (_hi : i.val ≠ 0) (k : ℕ) (_hk : k ≤ 3), (i.val : ZMod p) ≠ ((r + k : ℕ) : ZMod p) ∧ -(i.val : ZMod p) ≠ ((r + k : ℕ) : ZMod p) := by intro i hi k hk exact ⟨natCast_ne_natCast_of_lt (by omega) (by omega), (natCast_ne_neg_natCast (a := r + k) (b := i.val) (by omega) (by omega)).symm⟩ have hmask_disj : ∀ (i j : Fin r) (_hi : i.val ≠ 0) (_hj : j.val ≠ 0), i ≠ j → (i.val : ZMod p) ≠ (j.val : ZMod p) ∧ (i.val : ZMod p) ≠ -(j.val : ZMod p) ∧ -(i.val : ZMod p) ≠ (j.val : ZMod p) ∧ -(i.val : ZMod p) ≠ -(j.val : ZMod p) := by intro i j hi hj hij have hval : i.val ≠ j.val := fun h => hij (Fin.ext h) have h1 : (i.val : ZMod p) ≠ (j.val : ZMod p) := by rcases lt_or_gt_of_ne hval with h | h · exact natCast_ne_natCast_of_lt h (by omega) · exact (natCast_ne_natCast_of_lt h (by omega)).symm have h2 : (i.val : ZMod p) ≠ -(j.val : ZMod p) := natCast_ne_neg_natCast (a := i.val) (b := j.val) (by omega) (by omega) exact ⟨h1, h2, fun h => h2 (by linear_combination -h), fun h => h1 (by linear_combination -h)⟩ -- Membership characterization of `sharpCore r p`. have hmemC : ∀ u : Fin r → ZMod p, u ∈ sharpCore r p ↔ (u 0 = (r : ZMod p) ∨ u 0 = ((r + 1 : ℕ) : ZMod p) ∨ u 0 = ((r + 3 : ℕ) : ZMod p)) ∨ ∃ i : Fin r, i.val ≠ 0 ∧ (u 0 = (i.val : ZMod p) ∨ u 0 = -(i.val : ZMod p)) ∧ u i = 0 := by intro u; simp [sharpCore] -- Helper: any site `x ∈ sharpSites r p` is not in `sharpCore r p`. have hsite_notC : ∀ x ∈ sharpSites r p, x ∉ sharpCore r p := by intro x hx hC have hx0 : x 0 = 0 := (Finset.mem_filter.1 hx).2.1 rw [hmemC, hx0] at hC rcases hC with (h | h | h) | ⟨i, hi, h | h, _⟩ · exact h0_ne_r h · exact h0_ne_r1 h · exact h0_ne_r3 h · exact h0_ne_i i hi h · exact h0_ne_ni i hi h have hbase_inS : baseSite r p ∈ sharpSites r p := by simp only [sharpSites, Finset.mem_filter, Finset.mem_univ, true_and, baseSite] exact ⟨by simp, fun i hi => by simp [hi]⟩ have hbase_notC : baseSite r p ∉ sharpCore r p := hsite_notC _ hbase_inS -- 1. All `sharpSites` lie in `Fiber (sharpCore r p) (baseSite r p)`. have hS_sub : sharpSites r p ⊆ Fiber (sharpCore r p) (baseSite r p) := by intro x hx rw [mem_fiber_iff (sharpCore r p) hbase_notC] refine ⟨hsite_notC x hx, ?_⟩ have hx0 : x 0 = 0 := (Finset.mem_filter.1 hx).2.1 have hxi : ∀ i : Fin r, i.val ≠ 0 → x i = 1 ∨ x i = -1 := (Finset.mem_filter.1 hx).2.2 have hb0 : baseSite r p 0 = 0 := by simp [baseSite] intro t have hxp0 : (x + t) 0 = t 0 := by simp [hx0] have hxm0 : (x - t) 0 = -t 0 := by simp [hx0] have hbp0 : (baseSite r p + t) 0 = t 0 := by simp [hb0] have hbm0 : (baseSite r p - t) 0 = -t 0 := by simp [hb0] by_cases hmask : ∃ i : Fin r, i.val ≠ 0 ∧ (t 0 = (i.val : ZMod p) ∨ t 0 = -(i.val : ZMod p)) · obtain ⟨i, hi, hti⟩ := hmask have hnti : -t 0 = (i.val : ZMod p) ∨ -t 0 = -(i.val : ZMod p) := by rcases hti with h | h · right; rw [h] · left; rw [h, neg_neg] have huniq : ∀ u : Fin r → ZMod p, (u 0 = (i.val : ZMod p) ∨ u 0 = -(i.val : ZMod p)) → (u ∈ sharpCore r p ↔ u i = 0) := by intro u hu0 rw [hmemC] constructor · rintro ((hf | hf | hf) | ⟨j, hj, huj, huj0⟩) · rcases hu0 with h | h · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 0 (by omega)).1 · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 0 (by omega)).2 · rcases hu0 with h | h · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 1 (by omega)).1 · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 1 (by omega)).2 · rcases hu0 with h | h · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 3 (by omega)).1 · exact absurd (h.symm.trans hf) (hmask_ne_full i hi 3 (by omega)).2 · have hjeq : j = i := by by_contra hji have hd := hmask_disj j i hj hi hji rcases huj with h1 | h1 <;> rcases hu0 with h2 | h2 · exact hd.1 (h1.symm.trans h2) · exact hd.2.1 (h1.symm.trans h2) · exact hd.2.2.1 (h1.symm.trans h2) · exact hd.2.2.2 (h1.symm.trans h2) rwa [← hjeq] · intro hui0 exact Or.inr ⟨i, hi, hu0, hui0⟩ have h1 : x + t ∈ sharpCore r p ↔ x i + t i = 0 := huniq (x + t) (by rwa [hxp0]) have h2 : x - t ∈ sharpCore r p ↔ x i - t i = 0 := huniq (x - t) (by rwa [hxm0]) have h3 : baseSite r p + t ∈ sharpCore r p ↔ 1 + t i = 0 := by simpa [baseSite, hi] using huniq (baseSite r p + t) (by rwa [hbp0]) have h4 : baseSite r p - t ∈ sharpCore r p ↔ 1 - t i = 0 := by simpa [baseSite, hi] using huniq (baseSite r p - t) (by rwa [hbm0]) unfold indC simp only [h1, h2, h3, h4] rcases hxi i hi with hxi1 | hxin1 · rw [hxi1] · rw [hxin1] have e1 : (-1 + t i = 0) ↔ (1 - t i = 0) := ⟨fun h => by linear_combination -h, fun h => by linear_combination -h⟩ have e2 : (-1 - t i = 0) ↔ (1 + t i = 0) := ⟨fun h => by linear_combination -h, fun h => by linear_combination -h⟩ simp only [e1, e2]; omega · push Not at hmask have hnomask_neg : ∀ i : Fin r, i.val ≠ 0 → -t 0 ≠ (i.val : ZMod p) ∧ -t 0 ≠ -(i.val : ZMod p) := fun i hi => ⟨fun h => (hmask i hi).2 (by linear_combination -h), fun h => (hmask i hi).1 (by linear_combination -h)⟩ have hp_iff : x + t ∈ sharpCore r p ↔ baseSite r p + t ∈ sharpCore r p := by rw [hmemC, hmemC, hxp0, hbp0] constructor <;> rintro (h | ⟨i, hi, hti, _⟩) · exact Or.inl h · exact absurd hti (by rintro (h | h); exact (hmask i hi).1 h; exact (hmask i hi).2 h) · exact Or.inl h · exact absurd hti (by rintro (h | h); exact (hmask i hi).1 h; exact (hmask i hi).2 h) have hm_iff : x - t ∈ sharpCore r p ↔ baseSite r p - t ∈ sharpCore r p := by rw [hmemC, hmemC, hxm0, hbm0] constructor <;> rintro (h | ⟨i, hi, hti, _⟩) · exact Or.inl h · exact absurd hti (by rintro (h | h); exact (hnomask_neg i hi).1 h; exact (hnomask_neg i hi).2 h) · exact Or.inl h · exact absurd hti (by rintro (h | h); exact (hnomask_neg i hi).1 h; exact (hnomask_neg i hi).2 h) simp [indC, hp_iff, hm_iff] -- 2. Full-hyperplane characterization for `sharpCore r p` and every `insert x (sharpCore r p)`. let FullSet : Finset (ZMod p) := {(r : ZMod p), ((r + 1 : ℕ) : ZMod p), ((r + 3 : ℕ) : ZMod p)} have hfull_core : ∀ a : ZMod p, IsFullHyperplane (sharpCore r p) a ↔ a ∈ FullSet := by intro a simp only [FullSet, Finset.mem_insert, Finset.mem_singleton] constructor · intro hfull by_contra hnot push Not at hnot obtain ⟨hner, hner1, hner3⟩ := hnot let u : Fin r → ZMod p := fun j => if j.val = 0 then a else 1 have hu0 : u 0 = a := by simp [u] have hu : u ∈ sharpCore r p := hfull u hu0 rw [hmemC, hu0] at hu rcases hu with (h | h | h) | ⟨i, hi, _, hui0⟩ · exact hner h · exact hner1 h · exact hner3 h · have hui1 : u i = 1 := if_neg hi rw [hui1] at hui0 exact h1ne0 hui0 · rintro (rfl | rfl | rfl) u hu <;> rw [hmemC, hu] <;> simp have hfull_insert : ∀ x ∈ sharpSites r p, ∀ a : ZMod p, IsFullHyperplane (insert x (sharpCore r p)) a ↔ a ∈ FullSet := by intro x hx a have hx0 : x 0 = 0 := (Finset.mem_filter.1 hx).2.1 have hxi : ∀ i : Fin r, i.val ≠ 0 → x i = 1 ∨ x i = -1 := (Finset.mem_filter.1 hx).2.2 simp only [FullSet, Finset.mem_insert, Finset.mem_singleton] constructor · intro hfull by_contra hnot push Not at hnot obtain ⟨hner, hner1, hner3⟩ := hnot by_cases ha0 : a = 0 · -- At `a = 0`, `0 ∉ sharpCore` and `0 ≠ x` (since `x 1 ∈ {1, -1}`). have h0_mem : (0 : Fin r → ZMod p) ∈ insert x (sharpCore r p) := hfull 0 (by simp [ha0]) rcases Finset.mem_insert.1 h0_mem with h0x | h0C · have h1val : x ⟨1, by omega⟩ = 0 := congr_fun h0x.symm ⟨1, by omega⟩ rcases hxi ⟨1, by omega⟩ (by simp) with h | h · exact h1ne0 (h.symm.trans h1val) · exact h1ne0 (by linear_combination -(h.symm.trans h1val)) · rw [hmemC] at h0C rcases h0C with (h | h | h) | ⟨i, hi, h | h, _⟩ · exact h0_ne_r h · exact h0_ne_r1 h · exact h0_ne_r3 h · exact h0_ne_i i hi h · exact h0_ne_ni i hi h · -- At `a ≠ 0`, `u = (a, 1, ..., 1)` is distinct from `x` and avoids `sharpCore`. let u : Fin r → ZMod p := fun j => if j.val = 0 then a else 1 have hu0 : u 0 = a := by simp [u] have hu : u ∈ insert x (sharpCore r p) := hfull u hu0 rcases Finset.mem_insert.1 hu with hux | huC · exact ha0 (by simpa [hu0, hx0] using congr_fun hux 0) · rw [hmemC, hu0] at huC rcases huC with (h | h | h) | ⟨i, hi, _, hui0⟩ · exact hner h · exact hner1 h · exact hner3 h · have hui1 : u i = 1 := if_neg hi rw [hui1] at hui0 exact h1ne0 hui0 · rintro (rfl | rfl | rfl) u hu <;> exact Finset.mem_insert_of_mem ((hmemC u).2 (Or.inl (by rw [hu]; simp))) -- 3. `FullSet = {r, r+1, r+3}` has no nonzero translation and no reflection in `ZMod p`. have hfull_no_trans : ∀ d : ZMod p, (∀ a : ZMod p, a ∈ FullSet ↔ a + d ∈ FullSet) → d = 0 := by intro d hd have hcard_eq : FullSet.image (· + d) = FullSet := by ext b simp only [Finset.mem_image] constructor · rintro ⟨a, ha, rfl⟩; exact (hd a).1 ha · intro hb; refine ⟨b - d, (hd (b - d)).2 (by simpa using hb), sub_add_cancel b d⟩ have hsum : ∑ a ∈ FullSet, (a + d) = ∑ a ∈ FullSet, a := by rw [← Finset.sum_image (f := fun x => x) (g := (· + d)) (fun _ _ _ _ h => add_right_cancel h), hcard_eq] rw [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul] at hsum have h3 : FullSet.card = 3 := by have h01 : (r : ZMod p) ≠ ((r + 1 : ℕ) : ZMod p) := natCast_ne_natCast_of_lt (by omega) (by omega) have h03 : (r : ZMod p) ≠ ((r + 3 : ℕ) : ZMod p) := natCast_ne_natCast_of_lt (by omega) (by omega) have h13 : ((r + 1 : ℕ) : ZMod p) ≠ ((r + 3 : ℕ) : ZMod p) := natCast_ne_natCast_of_lt (by omega) (by omega) dsimp only [FullSet] rw [Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_singleton] · rw [Finset.mem_singleton]; exact h13 · rw [Finset.mem_insert, Finset.mem_singleton]; push Not; exact ⟨h01, h03⟩ rw [h3] at hsum have h3d : (3 : ZMod p) * d = 0 := by linear_combination hsum exact (mul_eq_zero.1 h3d).resolve_left h3ne0 have hfull_no_refl : ∀ c : ZMod p, ¬ (∀ a : ZMod p, a ∈ FullSet ↔ -a + c ∈ FullSet) := by intro c hc have hr_in : -(r : ZMod p) + c ∈ FullSet := (hc _).1 (by simp [FullSet]) have hr1_in : -((r + 1 : ℕ) : ZMod p) + c ∈ FullSet := (hc _).1 (by simp [FullSet]) have hr3_in : -((r + 3 : ℕ) : ZMod p) + c ∈ FullSet := (hc _).1 (by simp [FullSet]) simp only [FullSet, Finset.mem_insert, Finset.mem_singleton, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] at hr_in hr1_in hr3_in -- Check all 3×3×3 cases: in each case `c` is forced to satisfy a contradiction in `{1,2,3,4,5} ≠ 0`. rcases hr_in with h0 | h0 | h0 <;> rcases hr1_in with h1 | h1 | h1 <;> rcases hr3_in with h3 | h3 | h3 all_goals try exact h1ne0 (by linear_combination h0 - h1) try exact h2ne0 (by linear_combination h1 - h3) try exact h3ne0 (by linear_combination h0 - h3) try exact h4ne0 (by linear_combination h0 - h1 + h3 - h3) try exact h4ne0 (by linear_combination h3 - h0 - (h1 - h0)) try exact h5ne0 (by linear_combination h3 - h1) try exact h1ne0 (by linear_combination h1 - h0) try exact h2ne0 (by linear_combination h3 - h1) try exact h3ne0 (by linear_combination h3 - h0) try exact h4ne0 (by linear_combination h0 - h3) try exact h4ne0 (by linear_combination h3 - h0) try exact h5ne0 (by linear_combination h1 - h3) try exact h2ne0 (by linear_combination h0 - h1) try exact h2ne0 (by linear_combination h1 - h0) try exact h1ne0 (by linear_combination h3 - h1) -- Helper: if `S₁.image (· + g) = S₂` and both have full hyperplanes `FullSet` and match -- `sharpCore` on slices `u 0 = i` (`1 ≤ i < r`), then `g = 0`. have htrans_eq_zero : ∀ (S₁ S₂ : Finset (Fin r → ZMod p)) (g : Fin r → ZMod p), (∀ a, IsFullHyperplane S₁ a ↔ a ∈ FullSet) → (∀ a, IsFullHyperplane S₂ a ↔ a ∈ FullSet) → (∀ i : Fin r, i.val ≠ 0 → ∀ u : Fin r → ZMod p, u 0 = (i.val : ZMod p) → (u ∈ S₁ ↔ u i = 0) ∧ (u ∈ S₂ ↔ u i = 0)) → S₁.image (· + g) = S₂ → g = 0 := by intro S₁ S₂ g hF₁ hF₂ hmask_eq htr have hg0 : g 0 = 0 := by apply hfull_no_trans (g 0) intro a rw [← hF₁ a, ← hF₂ (a + g 0)] constructor · intro ha u hu rw [← htr] refine Finset.mem_image.2 ⟨u - g, ha (u - g) ?_, sub_add_cancel u g⟩ simp only [Pi.sub_apply, hu, add_sub_cancel_right] · intro hag u hu have huS2 : u + g ∈ S₂ := hag (u + g) (by simp [hu]) rw [← htr] at huS2 obtain ⟨v, hv, hveq⟩ := Finset.mem_image.1 huS2 rwa [← add_right_cancel hveq] funext i by_cases hi : i.val = 0 · have hi0 : i = 0 := Fin.ext hi simp [hi0, hg0] · let u : Fin r → ZMod p := Pi.single 0 (i.val : ZMod p) have hu0 : u 0 = (i.val : ZMod p) := by simp [u] have hui : u i = 0 := by have hne : i ≠ 0 := fun h => hi (by simp [h]) simp [u, hne] have huS1 : u ∈ S₁ := (hmask_eq i hi u hu0).1.2 hui have hugS2 : u + g ∈ S₂ := by rw [← htr]; exact Finset.mem_image_of_mem _ huS1 have hug0 : (u + g) 0 = (i.val : ZMod p) := by simp [hu0, hg0] have hugi : (u + g) i = 0 := (hmask_eq i hi (u + g) hug0).2.1 hugS2 simpa [hui] using hugi have hmask_core : ∀ i : Fin r, i.val ≠ 0 → ∀ u : Fin r → ZMod p, u 0 = (i.val : ZMod p) → (u ∈ sharpCore r p ↔ u i = 0) := by intro i hi u hu0 rw [hmemC] constructor · rintro ((hf | hf | hf) | ⟨j, hj, huj, huj0⟩) · exact absurd (hu0.symm.trans hf) (hmask_ne_full i hi 0 (by omega)).1 · exact absurd (hu0.symm.trans hf) (hmask_ne_full i hi 1 (by omega)).1 · exact absurd (hu0.symm.trans hf) (hmask_ne_full i hi 3 (by omega)).1 · have hjeq : j = i := by by_contra hji have hd := hmask_disj j i hj hi hji rcases huj with h1 | h1 · exact hd.1 (h1.symm.trans hu0) · exact hd.2.2.1 (h1.symm.trans hu0) rwa [← hjeq] · intro hui0; exact Or.inr ⟨i, hi, Or.inl hu0, hui0⟩ have hmask_insert : ∀ x ∈ sharpSites r p, ∀ i : Fin r, i.val ≠ 0 → ∀ u : Fin r → ZMod p, u 0 = (i.val : ZMod p) → (u ∈ insert x (sharpCore r p) ↔ u i = 0) := by intro x hx i hi u hu0 have hx0 : x 0 = 0 := (Finset.mem_filter.1 hx).2.1 have hux : u ≠ x := fun h => h0_ne_i i hi (hx0.symm.trans (congr_fun h.symm 0 |>.trans hu0)) simp [hux, hmask_core i hi u hu0] -- 4. Assemble all 7 conclusions! refine ⟨?_, hbase_notC, sharpSites_card hr hp, hS_sub, ?_, ?_, ?_⟩ · -- `IsAperiodic (sharpCore r p)` intro g hg exact htrans_eq_zero (sharpCore r p) (sharpCore r p) g hfull_core hfull_core (fun i hi u hu0 => ⟨hmask_core i hi u hu0, hmask_core i hi u hu0⟩) hg · -- Pairwise inequivalence under translations intro x hx y hy hxy g hg have hg0 : g = 0 := htrans_eq_zero (insert x (sharpCore r p)) (insert y (sharpCore r p)) g (hfull_insert x hx) (hfull_insert y hy) (fun i hi u hu0 => ⟨hmask_insert x hx i hi u hu0, hmask_insert y hy i hi u hu0⟩) hg rw [hg0] at hg have heq : insert x (sharpCore r p) = insert y (sharpCore r p) := by simpa using hg have hx_in : x ∈ insert y (sharpCore r p) := heq ▸ Finset.mem_insert_self x _ rcases Finset.mem_insert.1 hx_in with h | h · exact hxy h · exact hsite_notC x hx h · -- Pairwise inequivalence under inversions `u ↦ -u + g` intro x hx y hy g hg apply hfull_no_refl (g 0) intro a rw [← hfull_insert x hx a, ← hfull_insert y hy (-a + g 0)] constructor · intro ha u hu rw [← hg] refine Finset.mem_image.2 ⟨-u + g, ha (-u + g) ?_, by abel⟩ simp only [Pi.add_apply, Pi.neg_apply, hu]; ring · intro hag u hu have huS2 : -u + g ∈ insert y (sharpCore r p) := hag (-u + g) (by simp [hu]) rw [← hg] at huS2 obtain ⟨v, hv, hveq⟩ := Finset.mem_image.1 huS2 have hvu : v = u := by have h1 : -v = -u := add_right_cancel hveq exact neg_inj.1 h1 rwa [← hvu] · -- Pairwise inequivalence under complements (even with translations or inversions) intro x hx y hy g have hcard_eq_xy : (insert x (sharpCore r p)).card = (insert y (sharpCore r p)).card := by rw [Finset.card_insert_of_notMem (hsite_notC x hx), Finset.card_insert_of_notMem (hsite_notC y hy)] have hodd : Odd (p ^ r) := by have hp_odd : Odd p := (Fact.out : p.Prime).odd_of_ne_two (by omega) exact hp_odd.pow have hno_compl : ∀ S : Finset (Fin r → ZMod p), S.card = (insert y (sharpCore r p)).card → Sᶜ ≠ insert y (sharpCore r p) := by intro S hSc hcompl have htot := Finset.card_compl_add_card S rw [hcompl, hSc, Fintype.card_pi] at htot simp only [ZMod.card, Finset.prod_const, Finset.card_univ, Fintype.card_fin] at htot have heven : Even (p ^ r) := ⟨(insert y (sharpCore r p)).card, by omega⟩ exact (Nat.not_even_iff_odd.2 hodd) heven constructor · refine hno_compl _ ?_ rw [Finset.card_image_of_injective _ (add_left_injective g), hcard_eq_xy] · refine hno_compl _ ?_ have hinj : Function.Injective (fun u : Fin r → ZMod p => -u + g) := fun u v h => neg_inj.1 (add_right_cancel h) rw [Finset.card_image_of_injective _ hinj, hcard_eq_xy] end SharpFamily #print axioms fiber_card_lt_two_pow #print axioms sharpSites_card #print axioms sharp_construction_theorem end AbelianHomometry.SharpConstruction