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.Tactic.Linarith import Mathlib.Tactic.FieldSimp /-! # Theorem 3.2: Rank-2 Rigidity over `(ZMod p) × (ZMod p)` For every odd prime `p ≥ 3`, every aperiodic support `C : Finset (ZMod p × ZMod p)`, and every `x₀ ∉ C`, we prove `(Fiber C x₀).card ≤ 2`. Proof outline: 1. Active characters span `(ZMod p)^2` over `ZMod p`; pick a linearly independent active basis `ξ₁, ξ₂`, change coordinates to align them with `(1, 0), (0, 1)`, and shift `x₀` to `(0, 0)`. 2. Each active character restricts the corresponding coordinate on `Fiber C (0, 0)` to at most two values, embedding `Fiber C (0, 0)` into a `2 × 2` grid. 3. Assuming `|Fiber| ≥ 3`, affine rescaling places `{(0, 0), (1, 0), (0, 1)} ⊆ Fiber C (0, 0)`. 4. Every active character then lies in the three lines `{c₁ = 0} ∪ {c₂ = 0} ∪ {c₁ = c₂}`, yielding the additive decomposition `1_C(x, y) = f₁(x) + f₂(y) + f₃(x + y)` with `f₁(1 - x) = f₁(x)` (in particular `f₁(1) = f₁(0)`). 5. Aperiodicity forces `f₁` and `f₂` to be nonconstant. Passing to unit differences `u(x) = f₁(x + 1) - f₁(x)` and `v(y) = f₂(y + 1) - f₂(y)` yields `u(x) - v(y) ∈ {-1, 0, 1}` for all `x, y : ZMod p`, which forces `u` to avoid `0`, contradicting `u(0) = f₁(1) - f₁(0) = 0`. -/ namespace AbelianHomometry.Rank2Rigidity 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 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 end Core section Transport variable {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] private lemma mem_fiber_self (C : Finset G) {x₀ : G} (hx₀ : x₀ ∉ C) : x₀ ∈ Fiber C x₀ := by classical simp [Fiber, hx₀] private lemma fiber_eq_of_mem {C : Finset G} {x₀ y : G} (hy : y ∈ Fiber C x₀) : Fiber C y = Fiber C x₀ := by classical simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and] at hy ext z simp only [Fiber, Finset.mem_filter, Finset.mem_sdiff, Finset.mem_univ, true_and] constructor · rintro ⟨hz, h⟩; exact ⟨hz, h.trans hy.2⟩ · rintro ⟨hz, h⟩; exact ⟨hz, h.trans hy.2.symm⟩ 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 end Transport section ComplexLemmas /-- On the unit circle, a line of fixed real part meets at most two points. -/ 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)) /-- If `‖w‖ = 1`, `w ≠ 1`, and `(z * w).re = z.re`, then `z * w = star z`. -/ private lemma mul_eq_star_of_re_eq {z w : ℂ} (hw : ‖w‖ = 1) (hw1 : w ≠ 1) (hre : (z * w).re = z.re) : z * w = star z := by have hns : Complex.normSq (z * w) = Complex.normSq z := by rw [map_mul, Complex.normSq_eq_norm_sq w, hw, one_pow, mul_one] have hsq : (z * w).im ^ 2 = z.im ^ 2 := by rw [Complex.normSq_apply, Complex.normSq_apply, hre] at hns nlinarith rcases sq_eq_sq_iff_eq_or_eq_neg.1 hsq with him | him · have hzw : z * w = z := Complex.ext hre him have hz : z = 0 := by have hsub : z * (w - 1) = 0 := by linear_combination hzw exact (mul_eq_zero.1 hsub).resolve_right (sub_ne_zero.2 hw1) simp [hz] · exact Complex.ext (by simpa using hre) (by simpa using him) end ComplexLemmas section CharactersOnZModP2 variable {p : ℕ} [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 dotHom (p : ℕ) (ξ : ZMod p × ZMod p) : (ZMod p × ZMod p) →+ ZMod p where toFun u := ξ.1 * u.1 + ξ.2 * u.2 map_zero' := by simp map_add' u v := by simp; ring private noncomputable def char2 (p : ℕ) [NeZero p] (ξ : ZMod p × ZMod p) : AddChar (ZMod p × ZMod p) ℂ := (e1 p).compAddMonoidHom (dotHom p ξ) private lemma char2_apply (p : ℕ) [NeZero p] (ξ u : ZMod p × ZMod p) : char2 p ξ u = e1 p (ξ.1 * u.1 + ξ.2 * u.2) := rfl private lemma char2_injective (p : ℕ) [NeZero p] : Function.Injective (char2 p) := by intro ξ η h have h1 : e1 p ξ.1 = e1 p η.1 := by have := DFunLike.congr_fun h (1, 0) simpa [char2_apply] using this have h2 : e1 p ξ.2 = e1 p η.2 := by have := DFunLike.congr_fun h (0, 1) simpa [char2_apply] using this exact Prod.ext (e1_injective p h1) (e1_injective p h2) private lemma char2_bijective (p : ℕ) [NeZero p] : Function.Bijective (char2 p) := by rw [Fintype.bijective_iff_injective_and_card, AddChar.card_eq] exact ⟨char2_injective p, rfl⟩ private noncomputable def F2 (C : Finset (ZMod p × ZMod p)) (ξ : ZMod p × ZMod p) : ℂ := fourierCoeff C (char2 p ξ) private lemma fourier_inversion_zmod2 (C : Finset (ZMod p × ZMod p)) (u : ZMod p × ZMod p) : ∑ ξ : ZMod p × ZMod p, F2 C ξ * char2 p ξ u = ((p * p : ℕ) : ℂ) * (indC C u : ℂ) := by have h := fourier_inversion_indC C u have hbij := Fintype.sum_bijective (char2 p) (char2_bijective p) (fun ξ => F2 C ξ * char2 p ξ u) (fun χ => fourierCoeff C χ * χ u) (fun _ => rfl) rw [hbij, h] simp [Fintype.card_prod, ZMod.card] private lemma F2_neg (C : Finset (ZMod p × ZMod p)) (ξ : ZMod p × ZMod p) : F2 C (-ξ) = star (F2 C ξ) := by unfold F2 fourierCoeff rw [star_sum] refine Finset.sum_congr rfl fun u _ => ?_ rw [addChar_conj_eq_neg, neg_neg, char2_apply, char2_apply] congr 1 simp only [Prod.fst_neg, Prod.snd_neg] ring private lemma isAperiodic_of_orthog_zero {C : Finset (ZMod p × ZMod p)} (hC : IsAperiodic C) {g : ZMod p × ZMod p} (hg : ∀ ξ : ZMod p × ZMod p, F2 C ξ ≠ 0 → ξ.1 * g.1 + ξ.2 * g.2 = 0) : g = 0 := by have hind : ∀ u : ZMod p × ZMod p, indC C (u + g) = indC C u := by intro u have h1 := fourier_inversion_zmod2 C (u + g) have h2 := fourier_inversion_zmod2 C u have hsum : ∑ ξ : ZMod p × ZMod p, F2 C ξ * char2 p ξ (u + g) = ∑ ξ : ZMod p × ZMod p, F2 C ξ * char2 p ξ u := by refine Finset.sum_congr rfl fun ξ _ => ?_ by_cases hF : F2 C ξ = 0 · simp [hF] · have hdot := hg ξ hF have hch : char2 p ξ (u + g) = char2 p ξ u := by rw [AddChar.map_add_eq_mul, char2_apply p ξ g, hdot, AddChar.map_zero_eq_one, mul_one] rw [hch] rw [h1, h2] at hsum have hp2 : ((p * p : ℕ) : ℂ) ≠ 0 := by have hp0 : p ≠ 0 := (Fact.out : p.Prime).ne_zero exact Nat.cast_ne_zero.2 (mul_ne_zero hp0 hp0) exact Nat.cast_injective (mul_left_cancel₀ hp2 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 /-- Aperiodicity yields two linearly independent active characters in `(ZMod p)^2`. -/ private lemma exists_active_basis {C : Finset (ZMod p × ZMod p)} (hC : IsAperiodic C) : ∃ ξ₁ ξ₂ : ZMod p × ZMod p, F2 C ξ₁ ≠ 0 ∧ F2 C ξ₂ ≠ 0 ∧ ξ₁.1 * ξ₂.2 - ξ₁.2 * ξ₂.1 ≠ 0 := by have hex1 : ∃ ξ₁ : ZMod p × ZMod p, ξ₁ ≠ 0 ∧ F2 C ξ₁ ≠ 0 := by by_contra hall push Not at hall have h0 : ((1 : ZMod p), (0 : ZMod p)) = 0 := by apply isAperiodic_of_orthog_zero hC intro ξ hF have hξ0 : ξ = 0 := by by_contra hne exact hF (hall ξ hne) simp [hξ0] exact one_ne_zero (congr_arg Prod.fst h0) obtain ⟨ξ₁, hξ₁_ne, hF₁⟩ := hex1 have hex2 : ∃ ξ₂ : ZMod p × ZMod p, F2 C ξ₂ ≠ 0 ∧ ξ₁.1 * ξ₂.2 - ξ₁.2 * ξ₂.1 ≠ 0 := by by_contra hall push Not at hall have hg : (-ξ₁.2, ξ₁.1) = (0 : ZMod p × ZMod p) := by apply isAperiodic_of_orthog_zero hC intro ξ hF have hdet := hall ξ hF calc ξ.1 * (-ξ₁.2) + ξ.2 * ξ₁.1 = ξ₁.1 * ξ.2 - ξ₁.2 * ξ.1 := by ring _ = 0 := hdet apply hξ₁_ne ext · exact congr_arg Prod.snd hg · have := congr_arg Prod.fst hg simpa using this obtain ⟨ξ₂, hF₂, hdet⟩ := hex2 exact ⟨ξ₁, ξ₂, hF₁, hF₂, hdet⟩ end CharactersOnZModP2 section DifferenceContradiction variable {p : ℕ} [Fact p.Prime] /-- If `f₁, f₂, f₃ : ZMod p → ℝ` sum to a `{0, 1}`-valued function of `(x, y)` with `f₁, f₂` nonconstant and `f₁ 1 = f₁ 0`, we obtain a contradiction. -/ private lemma no_symmetric_additive_decomposition {f₁ f₂ f₃ : ZMod p → ℝ} (hbin : ∀ x y : ZMod p, f₁ x + f₂ y + f₃ (x + y) = 0 ∨ f₁ x + f₂ y + f₃ (x + y) = 1) (hf₁_nc : ∃ x₁ x₂ : ZMod p, f₁ x₁ ≠ f₁ x₂) (hf₂_nc : ∃ y₁ y₂ : ZMod p, f₂ y₁ ≠ f₂ y₂) (hsym : f₁ 1 = f₁ 0) : False := by let u : ZMod p → ℝ := fun x => f₁ (x + 1) - f₁ x let v : ZMod p → ℝ := fun y => f₂ (y + 1) - f₂ y have hsum_zero : ∀ g : ZMod p → ℝ, ∑ x : ZMod p, (g (x + 1) - g x) = 0 := fun g => by rw [Finset.sum_sub_distrib] have hshift : ∑ x : ZMod p, g (x + 1) = ∑ x : ZMod p, g x := Equiv.sum_comp (Equiv.addRight (1 : ZMod p)) g rw [hshift, sub_self] have hne_zero_of_nc : ∀ g : ZMod p → ℝ, (∃ a b : ZMod p, g a ≠ g b) → ∃ x : ZMod p, g (x + 1) - g x ≠ 0 := by intro g ⟨a, b, hab⟩ by_contra h push Not at h have hstep : ∀ x : ZMod p, g (x + 1) = g x := fun x => sub_eq_zero.1 (h x) have hconst : ∀ n : ℕ, g (n : ZMod p) = g 0 := by intro n induction n with | zero => simp | succ n ih => rw [Nat.cast_succ, hstep, ih] have ha : g a = g 0 := by rw [← ZMod.natCast_zmod_val a]; exact hconst a.val have hb : g b = g 0 := by rw [← ZMod.natCast_zmod_val b]; exact hconst b.val exact hab (ha.trans hb.symm) have hex_pos_neg : ∀ w : ZMod p → ℝ, ∑ x : ZMod p, w x = 0 → (∃ x, w x ≠ 0) → (∃ x, 0 < w x) ∧ (∃ x, w x < 0) := by intro w hsum ⟨x₀, hx₀⟩ constructor · by_contra hle push Not at hle have hall0 : ∀ x ∈ (Finset.univ : Finset (ZMod p)), w x = 0 := by have hnegsum : ∑ x ∈ (Finset.univ : Finset (ZMod p)), (-w x) = 0 := by rw [Finset.sum_neg_distrib, hsum, neg_zero] have hnn : ∀ x ∈ (Finset.univ : Finset (ZMod p)), 0 ≤ -w x := fun x _ => neg_nonneg.2 (hle x) intro x hx have := (Finset.sum_eq_zero_iff_of_nonneg hnn).1 hnegsum x hx linarith exact hx₀ (hall0 x₀ (Finset.mem_univ _)) · by_contra hge push Not at hge have hall0 := (Finset.sum_eq_zero_iff_of_nonneg (fun x _ => hge x)).1 hsum exact hx₀ (hall0 x₀ (Finset.mem_univ _)) obtain ⟨⟨xp, hxp⟩, ⟨xm, hxm⟩⟩ := hex_pos_neg u (hsum_zero f₁) (hne_zero_of_nc f₁ hf₁_nc) obtain ⟨⟨yp, hyp⟩, ⟨ym, hym⟩⟩ := hex_pos_neg v (hsum_zero f₂) (hne_zero_of_nc f₂ hf₂_nc) have hdiff : ∀ x y : ZMod p, u x - v y = -1 ∨ u x - v y = 0 ∨ u x - v y = 1 := by intro x y have h1 := hbin (x + 1) y have h2 := hbin x (y + 1) have hsum_eq : (x + 1) + y = x + (y + 1) := by ring rw [hsum_eq] at h1 have hsub : u x - v y = (f₁ (x + 1) + f₂ y + f₃ (x + (y + 1))) - (f₁ x + f₂ (y + 1) + f₃ (x + (y + 1))) := by dsimp only [u, v]; ring rcases h1 with h1 | h1 <;> rcases h2 with h2 | h2 · right; left; linarith · left; linarith · right; right; linarith · right; left; linarith have h1 : u xp - v ym = 1 := by rcases hdiff xp ym with h | h | h <;> linarith have h2 : u xm - v yp = -1 := by rcases hdiff xm yp with h | h | h <;> linarith have h3 : u xp - v yp = 0 := by rcases hdiff xp yp with h | h | h <;> linarith have hu0 : u 0 = 0 := by dsimp only [u] rw [zero_add, hsym, sub_self] have h0y := hdiff 0 ym rw [hu0] at h0y rcases h0y with h | h | h <;> linarith end DifferenceContradiction section MainTheorem variable {p : ℕ} [Fact p.Prime] /-- Core rigidity step when `{(0, 0), (1, 0), (0, 1)} ⊆ Fiber C (0, 0)`. -/ private lemma absurd_of_three_standard_sites {C : Finset (ZMod p × ZMod p)} (hC : IsAperiodic C) (h00C : (0, 0) ∉ C) (h10 : (1, 0) ∈ Fiber C (0, 0)) (h01 : (0, 1) ∈ Fiber C (0, 0)) : False := by have hactive_lines : ∀ ξ : ZMod p × ZMod p, F2 C ξ ≠ 0 → ξ.1 = 0 ∨ ξ.2 = 0 ∨ ξ.1 = ξ.2 := by intro ξ hF have hre10 := mem_fiber_fourier h00C h10 (char2 p ξ) have hre01 := mem_fiber_fourier h00C h01 (char2 p ξ) have hw0 : ‖(char2 p ξ (0, 0) : ℂ)‖ = 1 := (char2 p ξ).norm_apply _ have hw1 : ‖(char2 p ξ (1, 0) : ℂ)‖ = 1 := (char2 p ξ).norm_apply _ have hw2 : ‖(char2 p ξ (0, 1) : ℂ)‖ = 1 := (char2 p ξ).norm_apply _ have htri := unit_circle_re_eq_at_most_two hF hw0 hw1 hw2 hre10.symm hre01.symm rcases htri with h | h | h · left have he : e1 p 0 = e1 p ξ.1 := by simpa [char2_apply] using h exact (e1_injective p he).symm · right; left have he : e1 p 0 = e1 p ξ.2 := by simpa [char2_apply] using h exact (e1_injective p he).symm · right; right have he : e1 p ξ.1 = e1 p ξ.2 := by simpa [char2_apply] using h exact e1_injective p he let S1 : Finset (ZMod p × ZMod p) := (Finset.univ.erase (0 : ZMod p)).image (fun c => (c, 0)) let S2 : Finset (ZMod p × ZMod p) := (Finset.univ.erase (0 : ZMod p)).image (fun c => (0, c)) let S3 : Finset (ZMod p × ZMod p) := (Finset.univ : Finset (ZMod p)).image (fun c => (c, c)) have hdisj12 : Disjoint S1 S2 := by rw [Finset.disjoint_left] intro ξ h1 h2 obtain ⟨c₁, hc₁, rfl⟩ := Finset.mem_image.1 h1 obtain ⟨c₂, _, h2'⟩ := Finset.mem_image.1 h2 exact (Finset.mem_erase.1 hc₁).1 (congr_arg Prod.fst h2').symm have hdisj13 : Disjoint S1 S3 := by rw [Finset.disjoint_left] intro ξ h1 h3 obtain ⟨c₁, hc₁, rfl⟩ := Finset.mem_image.1 h1 obtain ⟨c₃, _, h3'⟩ := Finset.mem_image.1 h3 have h1' : c₃ = c₁ := congr_arg Prod.fst h3' have h2' : c₃ = 0 := congr_arg Prod.snd h3' exact (Finset.mem_erase.1 hc₁).1 (h1'.symm.trans h2') have hdisj23 : Disjoint S2 S3 := by rw [Finset.disjoint_left] intro ξ h2 h3 obtain ⟨c₂, hc₂, rfl⟩ := Finset.mem_image.1 h2 obtain ⟨c₃, _, h3'⟩ := Finset.mem_image.1 h3 have h1' : c₃ = 0 := congr_arg Prod.fst h3' have h2' : c₃ = c₂ := congr_arg Prod.snd h3' exact (Finset.mem_erase.1 hc₂).1 (h2'.symm.trans h1') have hcover : ∀ ξ : ZMod p × ZMod p, F2 C ξ ≠ 0 → ξ ∈ S1 ∪ S2 ∪ S3 := by intro ξ hF rcases hactive_lines ξ hF with h1 | h2 | h3 · by_cases h2' : ξ.2 = 0 · exact Finset.mem_union_right _ (Finset.mem_image.2 ⟨0, Finset.mem_univ _, Prod.ext h1.symm h2'.symm⟩) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_image.2 ⟨ξ.2, Finset.mem_erase.2 ⟨h2', Finset.mem_univ _⟩, Prod.ext h1.symm rfl⟩)) · by_cases h1' : ξ.1 = 0 · exact Finset.mem_union_right _ (Finset.mem_image.2 ⟨0, Finset.mem_univ _, Prod.ext h1'.symm h2.symm⟩) · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_image.2 ⟨ξ.1, Finset.mem_erase.2 ⟨h1', Finset.mem_univ _⟩, Prod.ext rfl h2.symm⟩)) · exact Finset.mem_union_right _ (Finset.mem_image.2 ⟨ξ.1, Finset.mem_univ _, Prod.ext rfl h3⟩) let N : ℝ := (p * p : ℕ) have hNpos : (0 : ℝ) < N := by have hp0 : 0 < p := (Fact.out : p.Prime).pos exact Nat.cast_pos.2 (Nat.mul_pos hp0 hp0) let f₁ : ZMod p → ℝ := fun x => N⁻¹ * (∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (c, 0) * e1 p (c * x)).re let f₂ : ZMod p → ℝ := fun y => N⁻¹ * (∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (0, c) * e1 p (c * y)).re let f₃ : ZMod p → ℝ := fun s => N⁻¹ * (∑ c : ZMod p, F2 C (c, c) * e1 p (c * s)).re have hdecomp : ∀ x y : ZMod p, (indC C (x, y) : ℝ) = f₁ x + f₂ y + f₃ (x + y) := by intro x y have hinv := fourier_inversion_zmod2 C (x, y) have hsub : ∑ ξ : ZMod p × ZMod p, F2 C ξ * char2 p ξ (x, y) = ∑ ξ ∈ S1 ∪ S2 ∪ S3, F2 C ξ * char2 p ξ (x, y) := by symm refine Finset.sum_subset (Finset.subset_univ _) fun ξ _ hnot => ?_ have hF0 : F2 C ξ = 0 := by by_contra hne exact hnot (hcover ξ hne) simp [hF0] rw [hsub, Finset.sum_union (Finset.disjoint_union_left.2 ⟨hdisj13, hdisj23⟩), Finset.sum_union hdisj12] at hinv have hs1 : ∑ ξ ∈ S1, F2 C ξ * char2 p ξ (x, y) = ∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (c, 0) * e1 p (c * x) := by rw [Finset.sum_image (fun a _ b _ h => congr_arg Prod.fst h)] refine Finset.sum_congr rfl fun c _ => ?_ simp [char2_apply] have hs2 : ∑ ξ ∈ S2, F2 C ξ * char2 p ξ (x, y) = ∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (0, c) * e1 p (c * y) := by rw [Finset.sum_image (fun a _ b _ h => congr_arg Prod.snd h)] refine Finset.sum_congr rfl fun c _ => ?_ simp [char2_apply] have hs3 : ∑ ξ ∈ S3, F2 C ξ * char2 p ξ (x, y) = ∑ c : ZMod p, F2 C (c, c) * e1 p (c * (x + y)) := by rw [Finset.sum_image (fun a _ b _ h => congr_arg Prod.fst h)] refine Finset.sum_congr rfl fun c _ => ?_ simp [char2_apply, mul_add] rw [hs1, hs2, hs3] at hinv have hre := congr_arg Complex.re hinv simp only [Complex.add_re, Complex.mul_re, Complex.natCast_re, Complex.natCast_im, zero_mul, sub_zero] at hre have hNmul : N * (indC C (x, y) : ℝ) = (∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (c, 0) * e1 p (c * x)).re + (∑ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (0, c) * e1 p (c * y)).re + (∑ c : ZMod p, F2 C (c, c) * e1 p (c * (x + y))).re := by simpa [N] using hre.symm dsimp only [f₁, f₂, f₃] have hN0 : N ≠ 0 := ne_of_gt hNpos field_simp [hN0] linarith have hbin : ∀ x y : ZMod p, f₁ x + f₂ y + f₃ (x + y) = 0 ∨ f₁ x + f₂ y + f₃ (x + y) = 1 := by intro x y rw [← hdecomp x y] unfold indC split_ifs <;> simp -- Symmetry `f₁ 1 = f₁ 0` from `(1, 0) ∈ Fiber C (0, 0)`. have hsym : f₁ 1 = f₁ 0 := by dsimp only [f₁] congr 1 congr 1 have hterm : ∀ c ∈ Finset.univ.erase (0 : ZMod p), F2 C (c, 0) * e1 p (c * 1) = F2 C (-c, 0) * e1 p ((-c) * 0) := by intro c hc have hc0 : c ≠ 0 := (Finset.mem_erase.1 hc).1 have hre := mem_fiber_fourier h00C h10 (char2 p (c, 0)) have hre' : (F2 C (c, 0) * e1 p c).re = (F2 C (c, 0)).re := by simpa [F2, char2_apply] using hre have hw : ‖(e1 p c : ℂ)‖ = 1 := (e1 p).norm_apply c have hw1 : e1 p c ≠ 1 := by intro h exact hc0 (e1_injective p (h.trans (AddChar.map_zero_eq_one (e1 p)).symm)) have hmul := mul_eq_star_of_re_eq hw hw1 hre' have hneg : star (F2 C (c, 0)) = F2 C (-c, 0) := by simpa using (F2_neg C (c, 0)).symm simpa [mul_one, mul_zero, AddChar.map_zero_eq_one, hneg] using hmul rw [Finset.sum_congr rfl hterm] refine Finset.sum_bij (fun c _ => -c) ?_ ?_ ?_ ?_ · intro c hc exact Finset.mem_erase.2 ⟨neg_ne_zero.2 (Finset.mem_erase.1 hc).1, Finset.mem_univ _⟩ · intro a _ b _ h; exact neg_inj.1 h · intro b hb exact ⟨-b, Finset.mem_erase.2 ⟨neg_ne_zero.2 (Finset.mem_erase.1 hb).1, Finset.mem_univ _⟩, neg_neg b⟩ · intro c _; rfl -- Aperiodicity forces non-constancy of `f₁` and `f₂`. have hperiod_contra : ∀ g : ZMod p × ZMod p, g ≠ 0 → (∀ u : ZMod p × ZMod p, indC C (u + g) = indC C u) → False := by intro g hg hind 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 hneg0 := hC (-g) himg exact hg (by simpa using congr_arg Neg.neg hneg0) have hno_two_nc : ∀ g₁ g₂ : ZMod p → ℝ, (∀ a b : ZMod p, g₁ a + g₂ b = 0 ∨ g₁ a + g₂ b = 1) → (∀ a₁ a₂, g₁ a₁ = g₁ a₂) ∨ (∀ b₁ b₂, g₂ b₁ = g₂ b₂) := by intro g₁ g₂ h by_contra hnc push Not at hnc obtain ⟨⟨a₁, a₂, ha⟩, ⟨b₁, b₂, hb⟩⟩ := hnc have hlt1 : ∃ x₁ x₂, g₁ x₁ < g₁ x₂ := by rcases lt_or_gt_of_ne ha with h1 | h1 · exact ⟨a₁, a₂, h1⟩ · exact ⟨a₂, a₁, h1⟩ have hlt2 : ∃ y₁ y₂, g₂ y₁ < g₂ y₂ := by rcases lt_or_gt_of_ne hb with h2 | h2 · exact ⟨b₁, b₂, h2⟩ · exact ⟨b₂, b₁, h2⟩ obtain ⟨x₁, x₂, hx⟩ := hlt1 obtain ⟨y₁, y₂, hy⟩ := hlt2 rcases h x₁ y₁ with h11 | h11 <;> rcases h x₂ y₁ with h21 | h21 <;> rcases h x₂ y₂ with h22 | h22 <;> linarith have hf₁_nc : ∃ x₁ x₂ : ZMod p, f₁ x₁ ≠ f₁ x₂ := by by_contra hc push Not at hc have h2var : ∀ a b : ZMod p, f₂ a + (f₃ b + f₁ 0) = 0 ∨ f₂ a + (f₃ b + f₁ 0) = 1 := by intro a b have := hbin (b - a) a rw [hc (b - a) 0, sub_add_cancel] at this rcases this with h | h <;> [left; right] <;> linarith rcases hno_two_nc f₂ (fun b => f₃ b + f₁ 0) h2var with hf2c | hf3c · apply hperiod_contra (1, -1) (fun h => one_ne_zero (congr_arg Prod.fst h)) intro ⟨x, y⟩ have h1 := hdecomp (x + 1) (y + -1) have h2 := hdecomp x y have hxy : x + 1 + (y + -1) = x + y := by ring rw [hxy, hc (x + 1) x, hf2c (y + -1) y] at h1 exact Nat.cast_injective (h1.trans h2.symm) · apply hperiod_contra (1, 0) (fun h => one_ne_zero (congr_arg Prod.fst h)) intro ⟨x, y⟩ have h1 := hdecomp (x + 1) y have h2 := hdecomp x y have h3 : f₃ (x + 1 + y) = f₃ (x + y) := by have := hf3c (x + 1 + y) (x + y); linarith rw [hc (x + 1) x, h3] at h1 simpa using (Nat.cast_injective (h1.trans h2.symm) : indC C (x + 1, y) = indC C (x, y)) have hf₂_nc : ∃ y₁ y₂ : ZMod p, f₂ y₁ ≠ f₂ y₂ := by by_contra hc push Not at hc have h2var : ∀ a b : ZMod p, f₁ a + (f₃ b + f₂ 0) = 0 ∨ f₁ a + (f₃ b + f₂ 0) = 1 := by intro a b have := hbin a (b - a) rw [hc (b - a) 0, add_sub_cancel] at this rcases this with h | h <;> [left; right] <;> linarith rcases hno_two_nc f₁ (fun b => f₃ b + f₂ 0) h2var with hf1c | hf3c · obtain ⟨x₁, x₂, hx⟩ := hf₁_nc exact hx (hf1c x₁ x₂) · apply hperiod_contra (0, 1) (fun h => one_ne_zero (congr_arg Prod.snd h)) intro ⟨x, y⟩ have h1 := hdecomp x (y + 1) have h2 := hdecomp x y have h3 : f₃ (x + (y + 1)) = f₃ (x + y) := by have := hf3c (x + (y + 1)) (x + y); linarith rw [hc (y + 1) y, h3] at h1 simpa using (Nat.cast_injective (h1.trans h2.symm) : indC C (x, y + 1) = indC C (x, y)) exact no_symmetric_additive_decomposition hbin hf₁_nc hf₂_nc hsym /-- **Theorem 3.2 (Rank-2 Rigidity)**: For every odd prime `p ≥ 3`, every aperiodic support `C : Finset (ZMod p × ZMod p)`, and every `x₀ ∉ C`, the single-point insertion fiber has cardinality at most `2`. -/ theorem rank2_fiber_card_le_two {p : ℕ} [Fact p.Prime] (_hp3 : 3 ≤ p) (C : Finset (ZMod p × ZMod p)) (hC : IsAperiodic C) {x₀ : ZMod p × ZMod p} (hx₀ : x₀ ∉ C) : (Fiber C x₀).card ≤ 2 := by by_contra hgt have hge3 : 3 ≤ (Fiber C x₀).card := by omega -- Step 1: Pick a linearly independent basis of active characters. obtain ⟨ξ₁, ξ₂, hF₁, hF₂, hdet⟩ := exists_active_basis hC -- Step 2: Change coordinates via `L (x, y) = (ξ₁ · (x, y), ξ₂ · (x, y))`. let d : ZMod p := ξ₁.1 * ξ₂.2 - ξ₁.2 * ξ₂.1 have hd : d ≠ 0 := hdet let L : (ZMod p × ZMod p) ≃+ (ZMod p × ZMod p) := { toFun := fun u => (ξ₁.1 * u.1 + ξ₁.2 * u.2, ξ₂.1 * u.1 + ξ₂.2 * u.2) invFun := fun v => (d⁻¹ * (ξ₂.2 * v.1 - ξ₁.2 * v.2), d⁻¹ * (-ξ₂.1 * v.1 + ξ₁.1 * v.2)) left_inv := fun ⟨x, y⟩ => by ext · change d⁻¹ * (ξ₂.2 * (ξ₁.1 * x + ξ₁.2 * y) - ξ₁.2 * (ξ₂.1 * x + ξ₂.2 * y)) = x have h : ξ₂.2 * (ξ₁.1 * x + ξ₁.2 * y) - ξ₁.2 * (ξ₂.1 * x + ξ₂.2 * y) = d * x := by dsimp only [d]; ring rw [h, inv_mul_cancel_left₀ hd] · change d⁻¹ * (-ξ₂.1 * (ξ₁.1 * x + ξ₁.2 * y) + ξ₁.1 * (ξ₂.1 * x + ξ₂.2 * y)) = y have h : -ξ₂.1 * (ξ₁.1 * x + ξ₁.2 * y) + ξ₁.1 * (ξ₂.1 * x + ξ₂.2 * y) = d * y := by dsimp only [d]; ring rw [h, inv_mul_cancel_left₀ hd] right_inv := fun ⟨u, v⟩ => by ext · change ξ₁.1 * (d⁻¹ * (ξ₂.2 * u - ξ₁.2 * v)) + ξ₁.2 * (d⁻¹ * (-ξ₂.1 * u + ξ₁.1 * v)) = u have h : ξ₁.1 * (d⁻¹ * (ξ₂.2 * u - ξ₁.2 * v)) + ξ₁.2 * (d⁻¹ * (-ξ₂.1 * u + ξ₁.1 * v)) = d⁻¹ * (d * u) := by dsimp only [d]; ring rw [h, inv_mul_cancel_left₀ hd] · change ξ₂.1 * (d⁻¹ * (ξ₂.2 * u - ξ₁.2 * v)) + ξ₂.2 * (d⁻¹ * (-ξ₂.1 * u + ξ₁.1 * v)) = v have h : ξ₂.1 * (d⁻¹ * (ξ₂.2 * u - ξ₁.2 * v)) + ξ₂.2 * (d⁻¹ * (-ξ₂.1 * u + ξ₁.1 * v)) = d⁻¹ * (d * v) := by dsimp only [d]; ring rw [h, inv_mul_cancel_left₀ hd] map_add' := fun u v => by ext <;> simp <;> ring } -- Step 3: Transport to `C₁ = (C.image L).image (· + (-L x₀))`, with basepoint `(0, 0)`. let C₀ := C.image L let a := -L x₀ let C₁ := C₀.image (· + a) have hC₁ : IsAperiodic C₁ := isAperiodic_image_add (isAperiodic_image_addEquiv hC L) a have h00C₁ : (0, 0) ∉ C₁ := by intro h obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 h obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hw have hzero : L u + (-L x₀) = 0 := hweq have : L u = L x₀ := sub_eq_zero.1 (by simpa [sub_eq_add_neg] using hzero) exact hx₀ (L.injective this ▸ hu) have hcard₁ : (Fiber C₁ (0, 0)).card = (Fiber C x₀).card := by have ha0 : L x₀ + a = (0, 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 hge3₁ : 3 ≤ (Fiber C₁ (0, 0)).card := hcard₁ ▸ hge3 -- Active coordinate characters `(1, 0)` and `(0, 1)` on `C₁`. have hF₁_C₁ : F2 C₁ (1, 0) ≠ 0 := by have hcalc : F2 C₁ (1, 0) = F2 C ξ₁ * e1 p (L x₀).1 := by unfold F2 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 [char2_apply, a, L, AddEquiv.coe_mk, Equiv.coe_fn_mk, one_mul, zero_mul, add_zero, Prod.fst_neg, Prod.snd_neg, Prod.fst_add, ← AddChar.map_add_eq_mul] congr 1 ring rw [hcalc] exact mul_ne_zero hF₁ (addChar_apply_ne_zero (e1 p) _) have hF₂_C₁ : F2 C₁ (0, 1) ≠ 0 := by have hcalc : F2 C₁ (0, 1) = F2 C ξ₂ * e1 p (L x₀).2 := by unfold F2 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 [char2_apply, a, L, AddEquiv.coe_mk, Equiv.coe_fn_mk, one_mul, zero_mul, zero_add, Prod.fst_neg, Prod.snd_neg, Prod.snd_add, ← AddChar.map_add_eq_mul] congr 1 ring rw [hcalc] exact mul_ne_zero hF₂ (addChar_apply_ne_zero (e1 p) _) -- Step 4: Each coordinate takes at most 2 values on `Fiber C₁ (0, 0)`, so both take exactly 2. have hcoord1_le2 : ∀ u₁ u₂ u₃ : ZMod p × ZMod p, u₁ ∈ Fiber C₁ (0, 0) → u₂ ∈ Fiber C₁ (0, 0) → u₃ ∈ Fiber C₁ (0, 0) → u₁.1 = u₂.1 ∨ u₁.1 = u₃.1 ∨ u₂.1 = u₃.1 := by intro u₁ u₂ u₃ h₁ h₂ h₃ have hr1 := mem_fiber_fourier h00C₁ h₁ (char2 p (1, 0)) have hr2 := mem_fiber_fourier h00C₁ h₂ (char2 p (1, 0)) have hr3 := mem_fiber_fourier h00C₁ h₃ (char2 p (1, 0)) have htri := unit_circle_re_eq_at_most_two hF₁_C₁ ((char2 p (1, 0)).norm_apply u₁) ((char2 p (1, 0)).norm_apply u₂) ((char2 p (1, 0)).norm_apply u₃) (hr1.trans hr2.symm) (hr1.trans hr3.symm) rcases htri with h | h | h · left; exact e1_injective p (by simpa [char2_apply] using h) · right; left; exact e1_injective p (by simpa [char2_apply] using h) · right; right; exact e1_injective p (by simpa [char2_apply] using h) have hcoord2_le2 : ∀ u₁ u₂ u₃ : ZMod p × ZMod p, u₁ ∈ Fiber C₁ (0, 0) → u₂ ∈ Fiber C₁ (0, 0) → u₃ ∈ Fiber C₁ (0, 0) → u₁.2 = u₂.2 ∨ u₁.2 = u₃.2 ∨ u₂.2 = u₃.2 := by intro u₁ u₂ u₃ h₁ h₂ h₃ have hr1 := mem_fiber_fourier h00C₁ h₁ (char2 p (0, 1)) have hr2 := mem_fiber_fourier h00C₁ h₂ (char2 p (0, 1)) have hr3 := mem_fiber_fourier h00C₁ h₃ (char2 p (0, 1)) have htri := unit_circle_re_eq_at_most_two hF₂_C₁ ((char2 p (0, 1)).norm_apply u₁) ((char2 p (0, 1)).norm_apply u₂) ((char2 p (0, 1)).norm_apply u₃) (hr1.trans hr2.symm) (hr1.trans hr3.symm) rcases htri with h | h | h · left; exact e1_injective p (by simpa [char2_apply] using h) · right; left; exact e1_injective p (by simpa [char2_apply] using h) · right; right; exact e1_injective p (by simpa [char2_apply] using h) have h00_mem : (0, 0) ∈ Fiber C₁ (0, 0) := mem_fiber_self C₁ h00C₁ have hex_x : ∃ u ∈ Fiber C₁ (0, 0), u.1 ≠ 0 := by by_contra hall push Not at hall have hcard_le : (Fiber C₁ (0, 0)).card ≤ 2 := by by_contra hgt2 have hge : 2 < (Fiber C₁ (0, 0)).card := by omega obtain ⟨s, hs, hscard⟩ := Finset.exists_subset_card_eq (Nat.succ_le_of_lt hge) obtain ⟨u₁, u₂, u₃, h12, h13, h23, rfl⟩ := Finset.card_eq_three.1 hscard have hm1 : u₁ ∈ Fiber C₁ (0, 0) := hs (by simp) have hm2 : u₂ ∈ Fiber C₁ (0, 0) := hs (by simp) have hm3 : u₃ ∈ Fiber C₁ (0, 0) := hs (by simp) rcases hcoord2_le2 u₁ u₂ u₃ hm1 hm2 hm3 with h | h | h · exact h12 (Prod.ext ((hall u₁ hm1).trans (hall u₂ hm2).symm) h) · exact h13 (Prod.ext ((hall u₁ hm1).trans (hall u₃ hm3).symm) h) · exact h23 (Prod.ext ((hall u₂ hm2).trans (hall u₃ hm3).symm) h) omega have hex_y : ∃ u ∈ Fiber C₁ (0, 0), u.2 ≠ 0 := by by_contra hall push Not at hall have hcard_le : (Fiber C₁ (0, 0)).card ≤ 2 := by by_contra hgt2 have hge : 2 < (Fiber C₁ (0, 0)).card := by omega obtain ⟨s, hs, hscard⟩ := Finset.exists_subset_card_eq (Nat.succ_le_of_lt hge) obtain ⟨u₁, u₂, u₃, h12, h13, h23, rfl⟩ := Finset.card_eq_three.1 hscard have hm1 : u₁ ∈ Fiber C₁ (0, 0) := hs (by simp) have hm2 : u₂ ∈ Fiber C₁ (0, 0) := hs (by simp) have hm3 : u₃ ∈ Fiber C₁ (0, 0) := hs (by simp) rcases hcoord1_le2 u₁ u₂ u₃ hm1 hm2 hm3 with h | h | h · exact h12 (Prod.ext h ((hall u₁ hm1).trans (hall u₂ hm2).symm)) · exact h13 (Prod.ext h ((hall u₁ hm1).trans (hall u₃ hm3).symm)) · exact h23 (Prod.ext h ((hall u₂ hm2).trans (hall u₃ hm3).symm)) omega obtain ⟨ux, hux_mem, hux_ne⟩ := hex_x obtain ⟨uy, huy_mem, huy_ne⟩ := hex_y -- Step 5: Rescale coordinates so `Fiber C₂ (0, 0) ⊆ {0, 1} × {0, 1}`. let ax : ZMod p := ux.1 let by_ : ZMod p := uy.2 let D : (ZMod p × ZMod p) ≃+ (ZMod p × ZMod p) := { toFun := fun u => (ax⁻¹ * u.1, by_⁻¹ * u.2) invFun := fun v => (ax * v.1, by_ * v.2) left_inv := fun ⟨x, y⟩ => by ext · exact mul_inv_cancel_left₀ hux_ne x · exact mul_inv_cancel_left₀ huy_ne y right_inv := fun ⟨x, y⟩ => by ext · exact inv_mul_cancel_left₀ hux_ne x · exact inv_mul_cancel_left₀ huy_ne y map_add' := fun u v => by ext <;> simp [mul_add] } let C₂ := C₁.image D have hC₂ : IsAperiodic C₂ := isAperiodic_image_addEquiv hC₁ D have h00C₂ : (0, 0) ∉ C₂ := by intro h obtain ⟨u, hu, hueq⟩ := Finset.mem_image.1 h have hu0 : u = (0, 0) := D.injective (hueq.trans (map_zero D).symm) exact h00C₁ (hu0 ▸ hu) have hF2_eq : Fiber C₂ (0, 0) = (Fiber C₁ (0, 0)).image D := by have hD0 : D (0, 0) = (0, 0) := map_zero D simpa only [hD0] using fiber_image_addEquiv C₁ (0, 0) D have hge3₂ : 3 ≤ (Fiber C₂ (0, 0)).card := by rw [hF2_eq, Finset.card_image_of_injective _ D.injective] exact hge3₁ have hsub_grid : Fiber C₂ (0, 0) ⊆ ({(0, 0), (1, 0), (0, 1), (1, 1)} : Finset (ZMod p × ZMod p)) := by intro v hv rw [hF2_eq] at hv obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hv have hx_cases : u.1 = 0 ∨ u.1 = ax := by rcases hcoord1_le2 (0, 0) ux u h00_mem hux_mem hu with h | h | h · exact absurd h.symm hux_ne · left; exact h.symm · right; exact h.symm have hy_cases : u.2 = 0 ∨ u.2 = by_ := by rcases hcoord2_le2 (0, 0) uy u h00_mem huy_mem hu with h | h | h · exact absurd h.symm huy_ne · left; exact h.symm · right; exact h.symm have hax1 : ax⁻¹ * ax = 1 := inv_mul_cancel₀ hux_ne have hby1 : by_⁻¹ * by_ = 1 := inv_mul_cancel₀ huy_ne rcases hx_cases with hx | hx <;> rcases hy_cases with hy | hy · simp [D, hx, hy] · simp [D, hx, hy, hby1] · simp [D, hx, hy, hax1] · simp [D, hx, hy, hax1, hby1] have h00_mem₂ : (0, 0) ∈ Fiber C₂ (0, 0) := mem_fiber_self C₂ h00C₂ -- Step 6: Among `(1, 0), (0, 1), (1, 1)`, at least two belong to `Fiber C₂ (0, 0)`. by_cases h10 : (1, 0) ∈ Fiber C₂ (0, 0) · by_cases h01 : (0, 1) ∈ Fiber C₂ (0, 0) · exact absurd_of_three_standard_sites hC₂ h00C₂ h10 h01 · -- `(0, 1) ∉ Fiber`, so `(1, 1) ∈ Fiber`. Shift by `-(1, 0)` and negate first coordinate. have h11 : (1, 1) ∈ Fiber C₂ (0, 0) := by by_contra h11 have hsub2 : Fiber C₂ (0, 0) ⊆ {(0, 0), (1, 0)} := by intro v hv have hg := hsub_grid hv simp only [Finset.mem_insert, Finset.mem_singleton] at hg ⊢ rcases hg with rfl | rfl | rfl | rfl · left; rfl · right; rfl · exact absurd hv h01 · exact absurd hv h11 have hle2 : (Fiber C₂ (0, 0)).card ≤ 2 := (Finset.card_le_card hsub2).trans (Finset.card_insert_le _ _) omega let N₁ : (ZMod p × ZMod p) ≃+ (ZMod p × ZMod p) := { toFun := fun u => (-u.1, u.2) invFun := fun u => (-u.1, u.2) left_inv := fun ⟨x, y⟩ => by simp right_inv := fun ⟨x, y⟩ => by simp map_add' := fun u v => by ext <;> simp; ring } let C₃ := (C₂.image (· + (-(1, 0)))).image N₁ have hC₃ : IsAperiodic C₃ := isAperiodic_image_addEquiv (isAperiodic_image_add hC₂ _) N₁ have h10_not : (1, 0) ∉ C₂ := by classical exact (Finset.mem_sdiff.1 (Finset.mem_filter.1 h10).1).2 have h00C₃ : (0, 0) ∉ C₃ := by intro h obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 h obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hw have hw0 : u + (-(1, 0)) = 0 := N₁.injective (hweq.trans (map_zero N₁).symm) have hu10 : u = (1, 0) := sub_eq_zero.1 (by simpa [sub_eq_add_neg] using hw0) exact h10_not (hu10 ▸ hu) have hF3 : Fiber C₃ (0, 0) = ((Fiber C₂ (0, 0)).image (· + (-(1, 0)))).image N₁ := by have hbase : N₁ ((1, 0) + (-(1, 0))) = (0, 0) := by simp [N₁] have hf := fiber_image_addEquiv (C₂.image (· + (-(1, 0)))) ((1, 0) + (-(1, 0))) N₁ rw [hbase, fiber_image_add, fiber_eq_of_mem h10] at hf exact hf have h10' : (1, 0) ∈ Fiber C₃ (0, 0) := by rw [hF3] refine Finset.mem_image.2 ⟨(0, 0) + (-(1, 0)), Finset.mem_image.2 ⟨(0, 0), h00_mem₂, rfl⟩, ?_⟩ simp [N₁] have h01' : (0, 1) ∈ Fiber C₃ (0, 0) := by rw [hF3] refine Finset.mem_image.2 ⟨(1, 1) + (-(1, 0)), Finset.mem_image.2 ⟨(1, 1), h11, rfl⟩, ?_⟩ simp [N₁] exact absurd_of_three_standard_sites hC₃ h00C₃ h10' h01' · -- `(1, 0) ∉ Fiber`, so both `(0, 1)` and `(1, 1)` are in `Fiber`. have h01 : (0, 1) ∈ Fiber C₂ (0, 0) := by by_contra h01 have hsub2 : Fiber C₂ (0, 0) ⊆ {(0, 0), (1, 1)} := by intro v hv have hg := hsub_grid hv simp only [Finset.mem_insert, Finset.mem_singleton] at hg ⊢ rcases hg with rfl | rfl | rfl | rfl · left; rfl · exact absurd hv h10 · exact absurd hv h01 · right; rfl have hle2 : (Fiber C₂ (0, 0)).card ≤ 2 := (Finset.card_le_card hsub2).trans (Finset.card_insert_le _ _) omega have h11 : (1, 1) ∈ Fiber C₂ (0, 0) := by by_contra h11 have hsub2 : Fiber C₂ (0, 0) ⊆ {(0, 0), (0, 1)} := by intro v hv have hg := hsub_grid hv simp only [Finset.mem_insert, Finset.mem_singleton] at hg ⊢ rcases hg with rfl | rfl | rfl | rfl · left; rfl · exact absurd hv h10 · right; rfl · exact absurd hv h11 have hle2 : (Fiber C₂ (0, 0)).card ≤ 2 := (Finset.card_le_card hsub2).trans (Finset.card_insert_le _ _) omega let N₂ : (ZMod p × ZMod p) ≃+ (ZMod p × ZMod p) := { toFun := fun u => (u.1, -u.2) invFun := fun u => (u.1, -u.2) left_inv := fun ⟨x, y⟩ => by simp right_inv := fun ⟨x, y⟩ => by simp map_add' := fun u v => by ext <;> simp; ring } let C₃ := (C₂.image (· + (-(0, 1)))).image N₂ have hC₃ : IsAperiodic C₃ := isAperiodic_image_addEquiv (isAperiodic_image_add hC₂ _) N₂ have h01_not : (0, 1) ∉ C₂ := by classical exact (Finset.mem_sdiff.1 (Finset.mem_filter.1 h01).1).2 have h00C₃ : (0, 0) ∉ C₃ := by intro h obtain ⟨w, hw, hweq⟩ := Finset.mem_image.1 h obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hw have hw0 : u + (-(0, 1)) = 0 := N₂.injective (hweq.trans (map_zero N₂).symm) have hu01 : u = (0, 1) := sub_eq_zero.1 (by simpa [sub_eq_add_neg] using hw0) exact h01_not (hu01 ▸ hu) have hF3 : Fiber C₃ (0, 0) = ((Fiber C₂ (0, 0)).image (· + (-(0, 1)))).image N₂ := by have hbase : N₂ ((0, 1) + (-(0, 1))) = (0, 0) := by simp [N₂] have hf := fiber_image_addEquiv (C₂.image (· + (-(0, 1)))) ((0, 1) + (-(0, 1))) N₂ rw [hbase, fiber_image_add, fiber_eq_of_mem h01] at hf exact hf have h10' : (1, 0) ∈ Fiber C₃ (0, 0) := by rw [hF3] refine Finset.mem_image.2 ⟨(1, 1) + (-(0, 1)), Finset.mem_image.2 ⟨(1, 1), h11, rfl⟩, ?_⟩ simp [N₂] have h01' : (0, 1) ∈ Fiber C₃ (0, 0) := by rw [hF3] refine Finset.mem_image.2 ⟨(0, 0) + (-(0, 1)), Finset.mem_image.2 ⟨(0, 0), h00_mem₂, rfl⟩, ?_⟩ simp [N₂] exact absurd_of_three_standard_sites hC₃ h00C₃ h10' h01' end MainTheorem #print axioms rank2_fiber_card_le_two end AbelianHomometry.Rank2Rigidity