import Mathlib.Data.ZMod.Basic import Mathlib.FieldTheory.Finite.Basic import Mathlib.Data.Finset.Card import Mathlib.Data.Fintype.Pi import Mathlib.Data.Fin.VecNotation import Mathlib.Tactic.Abel import Mathlib.Tactic.Ring import Mathlib.Tactic.FinCases /-! # Breaking the Cyclic Power-of-2 Fiber Law in `(ZMod p)^3` In cyclic groups `ZMod n`, every aperiodic single-point autocorrelation fiber has cardinality `2^k` (a power of 2). In contrast, we prove that over elementary abelian groups of rank 3: 1. **Every prime `p ≥ 5`** (`exists_fiber_card_three_of_ge_five`): In `Fin 3 → ZMod p`, the explicit 5-slice support `C = {z=1, x=0} ∪ {z=-1, x=1} ∪ {z=2, y=0} ∪ {z=-2, y=1} ∪ {z=0, x+y=2⁻¹}` is aperiodic, avoids `0`, and has `Fiber C 0 = {![0,0,0], ![1,0,0], ![0,1,0]}` of cardinality **3**. 2. **Prime `p = 3`** (`exists_fiber_card_three_zmod3`): In `Fin 3 → ZMod 3`, an explicit 9-element aperiodic support `C₃` avoiding `0` has `Fiber C₃ 0 = {![0,0,0], ![1,0,0], ![0,1,0]}` of cardinality **3**. 3. **Unified Theorem** (`exists_fiber_card_three_all_odd_primes`): For EVERY odd prime `p ≥ 3`, there exist an aperiodic `C : Finset (Fin 3 → ZMod p)` and `x₀ ∉ C` with `(Fiber C x₀).card = 3`. 4. **Sharp Contrast (`ZMod 4 × ZMod 2`)** (`zmod4_prod_zmod2_fiber_card_le_two`): Over `ZMod 4 × ZMod 2`, NO aperiodic support admits a fiber of size 3; every aperiodic fiber has cardinality at most `2`. -/ namespace AbelianHomometry.NonPowerOfTwo open scoped BigOperators section Definitions 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 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⟩ end Definitions section PrimeGeFive variable {p : ℕ} [Fact p.Prime] /-- Explicit 5-slice core in `(ZMod p)^3` yielding a fiber of size 3 for every prime `p ≥ 5`. -/ def coreGeFive (p : ℕ) [NeZero p] : Finset (Fin 3 → ZMod p) := Finset.univ.filter fun u => (u 2 = 1 ∧ u 0 = 0) ∨ (u 2 = -1 ∧ u 0 = 1) ∨ (u 2 = 2 ∧ u 1 = 0) ∨ (u 2 = -2 ∧ u 1 = 1) ∨ (u 2 = 0 ∧ u 0 + u 1 = (2 : ZMod p)⁻¹) private lemma natCast_ne_zero_of_lt {p n : ℕ} [Fact p.Prime] (hn0 : 0 < n) (hnp : 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 hn0 hdvd) (not_le_of_gt hnp) /-- For every prime `p ≥ 5`, `coreGeFive p` is aperiodic, avoids `0`, and has exact fiber `{![0,0,0], ![1,0,0], ![0,1,0]}` of cardinality `3`. -/ theorem fiber_card_three_of_ge_five (hp5 : 5 ≤ p) : IsAperiodic (coreGeFive p) ∧ (0 : Fin 3 → ZMod p) ∉ coreGeFive p ∧ (Fiber (coreGeFive p) 0).card = 3 := by have h1 : (1 : ZMod p) ≠ 0 := one_ne_zero have h2 : (2 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_lt (p := p) (n := 2) (by omega) (by omega) have h3 : (3 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_lt (p := p) (n := 3) (by omega) (by omega) have h4 : (4 : ZMod p) ≠ 0 := by simpa using natCast_ne_zero_of_lt (p := p) (n := 4) (by omega) (by omega) have h1_neg1 : (1 : ZMod p) ≠ -1 := fun h => h2 (by linear_combination h) have h2_1 : (2 : ZMod p) ≠ 1 := fun h => h1 (by linear_combination h) have h2_neg1 : (2 : ZMod p) ≠ -1 := fun h => h3 (by linear_combination h) have hneg2_0 : (-2 : ZMod p) ≠ 0 := fun h => h2 (by linear_combination -h) have hneg2_1 : (-2 : ZMod p) ≠ 1 := fun h => h3 (by linear_combination -h) have hneg2_neg1 : (-2 : ZMod p) ≠ -1 := fun h => h1 (by linear_combination -h) have hneg2_2 : (-2 : ZMod p) ≠ 2 := fun h => h4 (by linear_combination -h) have hneg1_0 : (-1 : ZMod p) ≠ 0 := fun h => h1 (by linear_combination -h) let c : ZMod p := (2 : ZMod p)⁻¹ have h2c : 2 * c = 1 := mul_inv_cancel₀ h2 have hc0 : c ≠ 0 := inv_ne_zero h2 have hc1 : c ≠ 1 := fun h => h1 (by linear_combination h2c - 2 * h) have hc_neg : c ≠ -c := fun h => h1 (by linear_combination -h2c + (by linear_combination h : 2 * c = 0)) have h2pc_ne : 2 + c ≠ c := fun h => h2 (by linear_combination h) have h2mc_ne : 2 - c ≠ c := fun h => h1 (by linear_combination h + h2c) have hmem_iff : ∀ u : Fin 3 → ZMod p, u ∈ coreGeFive p ↔ (u 2 = 1 ∧ u 0 = 0) ∨ (u 2 = -1 ∧ u 0 = 1) ∨ (u 2 = 2 ∧ u 1 = 0) ∨ (u 2 = -2 ∧ u 1 = 1) ∨ (u 2 = 0 ∧ u 0 + u 1 = c) := fun u => by simp [coreGeFive, c] have h0_not : (0 : Fin 3 → ZMod p) ∉ coreGeFive p := by rw [hmem_iff] simp only [Pi.zero_apply, zero_add] rintro (⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨_, h⟩) · exact h1 h.symm · exact hneg1_0 h.symm · exact h2 h.symm · exact hneg2_0 h.symm · exact hc0 h.symm -- 1. Prove `IsAperiodic (coreGeFive p)`. have haper : IsAperiodic (coreGeFive p) := by intro g hg have hshift : ∀ u : Fin 3 → ZMod p, u ∈ coreGeFive p → u + g ∈ coreGeFive p := by intro u hu rw [← hg] exact Finset.mem_image_of_mem _ hu let u₁ : Fin 3 → ZMod p := ![0, c, 0] let u₂ : Fin 3 → ZMod p := ![1, c - 1, 0] have hu₁ : u₁ ∈ coreGeFive p := by rw [hmem_iff]; right; right; right; right; simp [u₁] have hu₂ : u₂ ∈ coreGeFive p := by rw [hmem_iff]; right; right; right; right; simp [u₂] have hg2 : g 2 = 0 := by have hm1 := (hmem_iff (u₁ + g)).1 (hshift u₁ hu₁) have hm2 := (hmem_iff (u₂ + g)).1 (hshift u₂ hu₂) have h10 : (u₁ + g) 0 = g 0 := by simp [u₁] have h11 : (u₁ + g) 1 = c + g 1 := by simp [u₁] have h12 : (u₁ + g) 2 = g 2 := by simp [u₁] have h20 : (u₂ + g) 0 = 1 + g 0 := by simp [u₂] have h21 : (u₂ + g) 1 = c - 1 + g 1 := by simp [u₂] have h22 : (u₂ + g) 2 = g 2 := by simp [u₂] rw [h10, h11, h12] at hm1 rw [h20, h21, h22] at hm2 rcases hm1 with ⟨hz, ha1⟩ | ⟨hz, ha1⟩ | ⟨hz, hb1⟩ | ⟨hz, hb1⟩ | ⟨hz, _⟩ · rcases hm2 with ⟨_, ha2⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ · exact absurd (by linear_combination ha2 - ha1 : (1 : ZMod p) = 0) h1 · exact absurd (hz.symm.trans hz2) h1_neg1 · exact absurd (hz2.symm.trans hz) h2_1 · exact absurd (hz2.symm.trans hz) hneg2_1 · exact absurd (hz.symm.trans hz2) h1 · rcases hm2 with ⟨hz2, _⟩ | ⟨_, ha2⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ · exact absurd (hz2.symm.trans hz) h1_neg1 · exact absurd (by linear_combination ha2 - ha1 : (1 : ZMod p) = 0) h1 · exact absurd (hz2.symm.trans hz) h2_neg1 · exact absurd (hz2.symm.trans hz) hneg2_neg1 · exact absurd (hz.symm.trans hz2) hneg1_0 · rcases hm2 with ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨_, hb2⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ · exact absurd (hz.symm.trans hz2) h2_1 · exact absurd (hz.symm.trans hz2) h2_neg1 · exact absurd (by linear_combination hb1 - hb2 : (1 : ZMod p) = 0) h1 · exact absurd (hz2.symm.trans hz) hneg2_2 · exact absurd (hz.symm.trans hz2) h2 · rcases hm2 with ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨hz2, _⟩ | ⟨_, hb2⟩ | ⟨hz2, _⟩ · exact absurd (hz.symm.trans hz2) hneg2_1 · exact absurd (hz.symm.trans hz2) hneg2_neg1 · exact absurd (hz.symm.trans hz2) hneg2_2 · exact absurd (by linear_combination hb1 - hb2 : (1 : ZMod p) = 0) h1 · exact absurd (hz.symm.trans hz2) hneg2_0 · exact hz have hg0 : g 0 = 0 := by let v : Fin 3 → ZMod p := ![0, 0, 1] have hv : v ∈ coreGeFive p := by rw [hmem_iff]; left; simp [v] have hmv := (hmem_iff (v + g)).1 (hshift v hv) simp only [Pi.add_apply, v, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, hg2, add_zero, zero_add] at hmv rcases hmv with ⟨_, h⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ · exact h · exact absurd h h1_neg1 · exact absurd h.symm h2_1 · exact absurd h.symm hneg2_1 · exact absurd h h1 have hg1 : g 1 = 0 := by let w : Fin 3 → ZMod p := ![0, 0, 2] have hw : w ∈ coreGeFive p := by rw [hmem_iff]; right; right; left; simp [w] have hmw := (hmem_iff (w + g)).1 (hshift w hw) simp only [Pi.add_apply, w, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, hg2, add_zero, zero_add] at hmw rcases hmw with ⟨h, _⟩ | ⟨h, _⟩ | ⟨_, h⟩ | ⟨h, _⟩ | ⟨h, _⟩ · exact absurd h h2_1 · exact absurd h h2_neg1 · exact h · exact absurd h.symm hneg2_2 · exact absurd h h2 funext i fin_cases i <;> assumption -- 2. Characterize `Fiber (coreGeFive p) 0 = {0, ![1,0,0], ![0,1,0]}`. let s0 : Fin 3 → ZMod p := 0 let s1 : Fin 3 → ZMod p := ![1, 0, 0] let s2 : Fin 3 → ZMod p := ![0, 1, 0] have hs_mem : ∀ x : Fin 3 → ZMod p, x 2 = 0 → (x 0 = 0 ∨ x 0 = 1) → (x 1 = 0 ∨ x 1 = 1) → (x 0 + x 1 = 0 ∨ x 0 + x 1 = 1) → x ∈ Fiber (coreGeFive p) 0 := by intro x hx2 hx0 hx1 hx01 rw [mem_fiber_iff (coreGeFive p) h0_not] refine ⟨?_, ?_⟩ · rw [hmem_iff] rintro (⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨h, _⟩ | ⟨_, h⟩) · exact h1 (h.symm.trans hx2) · exact hneg1_0 (h.symm.trans hx2) · exact h2 (h.symm.trans hx2) · exact hneg2_0 (h.symm.trans hx2) · rcases hx01 with h01 | h01 · exact hc0 (h.symm.trans h01) · exact hc1 (h.symm.trans h01) · intro t have ht_add : (x + t) 2 = t 2 := by simp [hx2] have ht_sub : (x - t) 2 = -t 2 := by simp [hx2] have h0_add : (0 + t : Fin 3 → ZMod p) 2 = t 2 := by simp have h0_sub : (0 - t : Fin 3 → ZMod p) 2 = -t 2 := by simp by_cases hz1 : t 2 = 1 · have hnegz : -t 2 = -1 := by rw [hz1] have hx_p : x + t ∈ coreGeFive p ↔ x 0 + t 0 = 0 := by rw [hmem_iff, ht_add, hz1] simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] have hx_m : x - t ∈ coreGeFive p ↔ x 0 - t 0 = 1 := by rw [hmem_iff, ht_sub, hnegz] simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] have h0_p : 0 + t ∈ coreGeFive p ↔ t 0 = 0 := by rw [hmem_iff, h0_add, hz1] simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] have h0_m : 0 - t ∈ coreGeFive p ↔ -t 0 = 1 := by rw [hmem_iff, h0_sub, hnegz] simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] unfold indC simp only [hx_p, hx_m, h0_p, h0_m] rcases hx0 with h0 | h0 · simp [h0] · rw [h0] have e1 : (1 + t 0 = 0) ↔ (-t 0 = 1) := by constructor <;> intro h <;> linear_combination -h have e2 : (1 - t 0 = 1) ↔ (t 0 = 0) := by constructor <;> intro h <;> linear_combination -h simp only [e1, e2]; omega · by_cases hzn1 : t 2 = -1 · have hnegz : -t 2 = 1 := by rw [hzn1, neg_neg] have hx_p : x + t ∈ coreGeFive p ↔ x 0 + t 0 = 1 := by rw [hmem_iff, ht_add, hzn1] simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] have hx_m : x - t ∈ coreGeFive p ↔ x 0 - t 0 = 0 := by rw [hmem_iff, ht_sub, hnegz] simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] have h0_p : 0 + t ∈ coreGeFive p ↔ t 0 = 1 := by rw [hmem_iff, h0_add, hzn1] simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] have h0_m : 0 - t ∈ coreGeFive p ↔ -t 0 = 0 := by rw [hmem_iff, h0_sub, hnegz] simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] unfold indC simp only [hx_p, hx_m, h0_p, h0_m] rcases hx0 with h0 | h0 · simp [h0] · rw [h0] have e1 : (1 + t 0 = 1) ↔ (-t 0 = 0) := by constructor <;> intro h <;> linear_combination -h have e2 : (1 - t 0 = 0) ↔ (t 0 = 1) := by constructor <;> intro h <;> linear_combination -h simp only [e1, e2]; omega · by_cases hz2 : t 2 = 2 · have hnegz : -t 2 = -2 := by rw [hz2] have hx_p : x + t ∈ coreGeFive p ↔ x 1 + t 1 = 0 := by rw [hmem_iff, ht_add, hz2] simp [h2_1, h2_neg1, hneg2_2.symm, h2] have hx_m : x - t ∈ coreGeFive p ↔ x 1 - t 1 = 1 := by rw [hmem_iff, ht_sub, hnegz] simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] have h0_p : 0 + t ∈ coreGeFive p ↔ t 1 = 0 := by rw [hmem_iff, h0_add, hz2] simp [h2_1, h2_neg1, hneg2_2.symm, h2] have h0_m : 0 - t ∈ coreGeFive p ↔ -t 1 = 1 := by rw [hmem_iff, h0_sub, hnegz] simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] unfold indC simp only [hx_p, hx_m, h0_p, h0_m] rcases hx1 with h0 | h0 · simp [h0] · rw [h0] have e1 : (1 + t 1 = 0) ↔ (-t 1 = 1) := by constructor <;> intro h <;> linear_combination -h have e2 : (1 - t 1 = 1) ↔ (t 1 = 0) := by constructor <;> intro h <;> linear_combination -h simp only [e1, e2]; omega · by_cases hzn2 : t 2 = -2 · have hnegz : -t 2 = 2 := by rw [hzn2, neg_neg] have hx_p : x + t ∈ coreGeFive p ↔ x 1 + t 1 = 1 := by rw [hmem_iff, ht_add, hzn2] simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] have hx_m : x - t ∈ coreGeFive p ↔ x 1 - t 1 = 0 := by rw [hmem_iff, ht_sub, hnegz] simp [h2_1, h2_neg1, hneg2_2.symm, h2] have h0_p : 0 + t ∈ coreGeFive p ↔ t 1 = 1 := by rw [hmem_iff, h0_add, hzn2] simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] have h0_m : 0 - t ∈ coreGeFive p ↔ -t 1 = 0 := by rw [hmem_iff, h0_sub, hnegz] simp [h2_1, h2_neg1, hneg2_2.symm, h2] unfold indC simp only [hx_p, hx_m, h0_p, h0_m] rcases hx1 with h0 | h0 · simp [h0] · rw [h0] have e1 : (1 + t 1 = 1) ↔ (-t 1 = 0) := by constructor <;> intro h <;> linear_combination -h have e2 : (1 - t 1 = 0) ↔ (t 1 = 1) := by constructor <;> intro h <;> linear_combination -h simp only [e1, e2]; omega · by_cases hz0 : t 2 = 0 · have hnegz : -t 2 = 0 := by rw [hz0, neg_zero] have hx_p : x + t ∈ coreGeFive p ↔ x 0 + x 1 + (t 0 + t 1) = c := by rw [hmem_iff, ht_add, hz0] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] constructor <;> intro h <;> linear_combination h have hx_m : x - t ∈ coreGeFive p ↔ x 0 + x 1 - (t 0 + t 1) = c := by rw [hmem_iff, ht_sub, hnegz] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] constructor <;> intro h <;> linear_combination h have h0_p : 0 + t ∈ coreGeFive p ↔ t 0 + t 1 = c := by rw [hmem_iff, h0_add, hz0] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] have h0_m : 0 - t ∈ coreGeFive p ↔ -(t 0 + t 1) = c := by rw [hmem_iff, h0_sub, hnegz] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] constructor <;> intro h <;> linear_combination h unfold indC simp only [hx_p, hx_m, h0_p, h0_m] rcases hx01 with h01 | h01 · simp [h01] · rw [h01] have e1 : (1 + (t 0 + t 1) = c) ↔ (-(t 0 + t 1) = c) := by constructor · intro h; linear_combination -h - h2c · intro h; linear_combination -h - h2c have e2 : (1 - (t 0 + t 1) = c) ↔ (t 0 + t 1 = c) := by constructor · intro h; linear_combination -h - h2c · intro h; linear_combination -h - h2c simp only [e1, e2]; omega · -- `t 2 ∉ {0, 1, -1, 2, -2}` ⇒ `-t 2 ∉ {0, 1, -1, 2, -2}` as well. have hnz1 : -t 2 ≠ 1 := fun h => hzn1 (by linear_combination -h) have hnzn1 : -t 2 ≠ -1 := fun h => hz1 (by linear_combination -h) have hnz2 : -t 2 ≠ 2 := fun h => hzn2 (by linear_combination -h) have hnzn2 : -t 2 ≠ -2 := fun h => hz2 (by linear_combination -h) have hnz0 : -t 2 ≠ 0 := fun h => hz0 (by linear_combination -h) have hn1 : x + t ∉ coreGeFive p := by rw [hmem_iff, ht_add]; simp [hz1, hzn1, hz2, hzn2, hz0] have hn2 : x - t ∉ coreGeFive p := by rw [hmem_iff, ht_sub]; simp [hnz1, hnzn1, hnz2, hnzn2, hnz0] have hn3 : 0 + t ∉ coreGeFive p := by rw [hmem_iff, h0_add]; simp [hz1, hzn1, hz2, hzn2, hz0] have hn4 : 0 - t ∉ coreGeFive p := by rw [hmem_iff, h0_sub]; simp [hnz1, hnzn1, hnz2, hnzn2, hnz0] unfold indC rw [if_neg hn1, if_neg hn2, if_neg hn3, if_neg hn4] have hfiber_eq : Fiber (coreGeFive p) 0 = {s0, s1, s2} := by ext x simp only [Finset.mem_insert, Finset.mem_singleton] constructor · intro hx obtain ⟨_, hprof⟩ := (mem_fiber_iff (coreGeFive p) h0_not x).1 hx -- Test vector `tA = ![0, c, 0]` has profile 1 at `0`, ruling out `x 2 ∈ {1, -1}` and outside. have htA0 : indC (coreGeFive p) (0 + ![0, c, 0]) + indC (coreGeFive p) (0 - ![0, c, 0]) = 1 := by have hp_in : (0 + ![0, c, 0] : Fin 3 → ZMod p) ∈ coreGeFive p := by rw [hmem_iff]; right; right; right; right; simp have hm_out : (0 - ![0, c, 0] : Fin 3 → ZMod p) ∉ coreGeFive p := by rw [hmem_iff] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] exact hc_neg.symm unfold indC; rw [if_pos hp_in, if_neg hm_out] -- Test vector `tB = ![c, 0, 0]` has profile 1 at `0`, ruling out `x 2 ∈ {2, -2}` and `(1,1,0)`. have htB0 : indC (coreGeFive p) (0 + ![c, 0, 0]) + indC (coreGeFive p) (0 - ![c, 0, 0]) = 1 := by have hp_in : (0 + ![c, 0, 0] : Fin 3 → ZMod p) ∈ coreGeFive p := by rw [hmem_iff]; right; right; right; right; simp have hm_out : (0 - ![c, 0, 0] : Fin 3 → ZMod p) ∉ coreGeFive p := by rw [hmem_iff] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] exact hc_neg.symm unfold indC; rw [if_pos hp_in, if_neg hm_out] have hx2 : x 2 = 0 := by have hA := (hprof ![0, c, 0]).trans htA0 have hB := (hprof ![c, 0, 0]).trans htB0 have hnot_eq : ∀ u v : Fin 3 → ZMod p, indC (coreGeFive p) u + indC (coreGeFive p) v = 1 → ((u ∈ coreGeFive p) ↔ (v ∈ coreGeFive p)) → False := by intro u v huv hiff unfold indC at huv by_cases hu : u ∈ coreGeFive p · rw [if_pos hu, if_pos (hiff.1 hu)] at huv; omega · rw [if_neg hu, if_neg (fun hv => hu (hiff.2 hv))] at huv; omega by_cases h1' : x 2 = 1 · exfalso; refine hnot_eq _ _ hA ?_ rw [hmem_iff, hmem_iff] have ha2 : (x + ![0, c, 0]) 2 = 1 := by simp [h1'] have hm2 : (x - ![0, c, 0]) 2 = 1 := by simp [h1'] have ha0 : (x + ![0, c, 0]) 0 = x 0 := by simp have hm0 : (x - ![0, c, 0]) 0 = x 0 := by simp rw [ha2, hm2, ha0, hm0] simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] · by_cases hn1' : x 2 = -1 · exfalso; refine hnot_eq _ _ hA ?_ rw [hmem_iff, hmem_iff] have ha2 : (x + ![0, c, 0]) 2 = -1 := by simp [hn1'] have hm2 : (x - ![0, c, 0]) 2 = -1 := by simp [hn1'] have ha0 : (x + ![0, c, 0]) 0 = x 0 := by simp have hm0 : (x - ![0, c, 0]) 0 = x 0 := by simp rw [ha2, hm2, ha0, hm0] simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] · by_cases h2' : x 2 = 2 · exfalso; refine hnot_eq _ _ hB ?_ rw [hmem_iff, hmem_iff] have ha2 : (x + ![c, 0, 0]) 2 = 2 := by simp [h2'] have hm2 : (x - ![c, 0, 0]) 2 = 2 := by simp [h2'] have ha1 : (x + ![c, 0, 0]) 1 = x 1 := by simp have hm1 : (x - ![c, 0, 0]) 1 = x 1 := by simp rw [ha2, hm2, ha1, hm1] simp [h2_1, h2_neg1, hneg2_2.symm, h2] · by_cases hn2' : x 2 = -2 · exfalso; refine hnot_eq _ _ hB ?_ rw [hmem_iff, hmem_iff] have ha2 : (x + ![c, 0, 0]) 2 = -2 := by simp [hn2'] have hm2 : (x - ![c, 0, 0]) 2 = -2 := by simp [hn2'] have ha1 : (x + ![c, 0, 0]) 1 = x 1 := by simp have hm1 : (x - ![c, 0, 0]) 1 = x 1 := by simp rw [ha2, hm2, ha1, hm1] simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] · by_contra h0' have ha2 : (x + ![0, c, 0]) 2 = x 2 := by simp have hm2 : (x - ![0, c, 0]) 2 = x 2 := by simp have hn_p : x + ![0, c, 0] ∉ coreGeFive p := by rw [hmem_iff, ha2]; simp [h1', hn1', h2', hn2', h0'] have hn_m : x - ![0, c, 0] ∉ coreGeFive p := by rw [hmem_iff, hm2]; simp [h1', hn1', h2', hn2', h0'] unfold indC at hA rw [if_neg hn_p, if_neg hn_m] at hA omega -- Test `t = ![0, 0, 1]` to force `x 0 ∈ {0, 1}`. have hx0 : x 0 = 0 ∨ x 0 = 1 := by let t1 : Fin 3 → ZMod p := ![0, 0, 1] have h10 := hprof t1 have h0_rhs : indC (coreGeFive p) (0 + t1) + indC (coreGeFive p) (0 - t1) = 1 := by have hp_in : (0 + t1 : Fin 3 → ZMod p) ∈ coreGeFive p := by rw [hmem_iff]; left; simp [t1] have hm_out : (0 - t1 : Fin 3 → ZMod p) ∉ coreGeFive p := by rw [hmem_iff]; simp [t1, h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0, h1.symm] unfold indC; rw [if_pos hp_in, if_neg hm_out] rw [h0_rhs] at h10 have hp_iff : x + t1 ∈ coreGeFive p ↔ x 0 = 0 := by rw [hmem_iff] have ha2 : (x + t1) 2 = 1 := by simp [t1, hx2] have ha0 : (x + t1) 0 = x 0 := by simp [t1] rw [ha2, ha0]; simp [h1_neg1, h2_1.symm, hneg2_1.symm, h1] have hm_iff : x - t1 ∈ coreGeFive p ↔ x 0 = 1 := by rw [hmem_iff] have hm2 : (x - t1) 2 = -1 := by simp [t1, hx2] have hm0 : (x - t1) 0 = x 0 := by simp [t1] rw [hm2, hm0]; simp [h1_neg1.symm, h2_neg1.symm, hneg2_neg1.symm, hneg1_0] unfold indC at h10 simp only [hp_iff, hm_iff] at h10 by_cases h0 : x 0 = 0 · left; exact h0 · right by_contra h1' rw [if_neg h0, if_neg h1'] at h10; omega -- Test `t = ![0, 0, 2]` to force `x 1 ∈ {0, 1}`. have hx1 : x 1 = 0 ∨ x 1 = 1 := by let t2 : Fin 3 → ZMod p := ![0, 0, 2] have h20 := hprof t2 have h0_rhs : indC (coreGeFive p) (0 + t2) + indC (coreGeFive p) (0 - t2) = 1 := by have hp_in : (0 + t2 : Fin 3 → ZMod p) ∈ coreGeFive p := by rw [hmem_iff]; right; right; left; simp [t2] have hm_out : (0 - t2 : Fin 3 → ZMod p) ∉ coreGeFive p := by rw [hmem_iff]; simp [t2, hneg2_1, hneg2_neg1, hneg2_2, hneg2_0, h1.symm] unfold indC; rw [if_pos hp_in, if_neg hm_out] rw [h0_rhs] at h20 have hp_iff : x + t2 ∈ coreGeFive p ↔ x 1 = 0 := by rw [hmem_iff] have ha2 : (x + t2) 2 = 2 := by simp [t2, hx2] have ha1 : (x + t2) 1 = x 1 := by simp [t2] rw [ha2, ha1]; simp [h2_1, h2_neg1, hneg2_2.symm, h2] have hm_iff : x - t2 ∈ coreGeFive p ↔ x 1 = 1 := by rw [hmem_iff] have hm2 : (x - t2) 2 = -2 := by simp [t2, hx2] have hm1 : (x - t2) 1 = x 1 := by simp [t2] rw [hm2, hm1]; simp [hneg2_1, hneg2_neg1, hneg2_2, hneg2_0] unfold indC at h20 simp only [hp_iff, hm_iff] at h20 by_cases h0 : x 1 = 0 · left; exact h0 · right by_contra h1' rw [if_neg h0, if_neg h1'] at h20; omega rcases hx0 with h0 | h0 <;> rcases hx1 with h1' | h1' · left; funext i; fin_cases i <;> simp [s0, h0, h1', hx2] · right; right; funext i; fin_cases i <;> simp [s2, h0, h1', hx2] · right; left; funext i; fin_cases i <;> simp [s1, h0, h1', hx2] · -- Exclude `(1, 1, 0)` using `tB = ![c, 0, 0]`. exfalso have hB := (hprof ![c, 0, 0]).trans htB0 have hn_p : x + ![c, 0, 0] ∉ coreGeFive p := by rw [hmem_iff] have ha2 : (x + ![c, 0, 0]) 2 = 0 := by simp [hx2] have ha0 : (x + ![c, 0, 0]) 0 = 1 + c := by simp [h0] have ha1 : (x + ![c, 0, 0]) 1 = 1 := by simp [h1'] rw [ha2, ha0, ha1] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] intro h; exact h2pc_ne (by linear_combination h) have hn_m : x - ![c, 0, 0] ∉ coreGeFive p := by rw [hmem_iff] have hm2 : (x - ![c, 0, 0]) 2 = 0 := by simp [hx2] have hm0 : (x - ![c, 0, 0]) 0 = 1 - c := by simp [h0] have hm1 : (x - ![c, 0, 0]) 1 = 1 := by simp [h1'] rw [hm2, hm0, hm1] simp [h1.symm, hneg1_0.symm, h2.symm, hneg2_0.symm] intro h; exact h2mc_ne (by linear_combination h) unfold indC at hB rw [if_neg hn_p, if_neg hn_m] at hB omega · rintro (rfl | rfl | rfl) · exact hs_mem s0 rfl (Or.inl rfl) (Or.inl rfl) (Or.inl (by simp [s0])) · exact hs_mem s1 rfl (Or.inr rfl) (Or.inl rfl) (Or.inr (by simp [s1])) · exact hs_mem s2 rfl (Or.inl rfl) (Or.inr rfl) (Or.inr (by simp [s2])) refine ⟨haper, h0_not, ?_⟩ rw [hfiber_eq] have h01 : s0 ≠ s1 := fun h => h1 (congr_fun h 0).symm have h02 : s0 ≠ s2 := fun h => h1 (congr_fun h 1).symm have h12 : s1 ≠ s2 := fun h => h1 (congr_fun h 0) rw [Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_singleton] · simp [h12] · simp [h01, h02] end PrimeGeFive section PrimeThree /-- Explicit 9-element aperiodic core in `(ZMod 3)^3` with fiber `{0, ![1,0,0], ![0,1,0]}` of size 3. -/ def coreZMod3 : Finset (Fin 3 → ZMod 3) := { ![0, 0, 1], ![0, 1, 1], ![1, 0, 1], ![0, 0, 2], ![0, 1, 2], ![1, 0, 2], ![1, 1, 2], ![1, 2, 2], ![2, 1, 2] } private lemma coreZMod3_aperiodic : IsAperiodic coreZMod3 := by intro g hg have hdec : ∀ g : Fin 3 → ZMod 3, coreZMod3.image (· + g) = coreZMod3 → g = 0 := by decide exact hdec g hg /-- In `(ZMod 3)^3`, `coreZMod3` is aperiodic, avoids `0`, and has fiber cardinality `3`. -/ theorem fiber_card_three_zmod3 : IsAperiodic coreZMod3 ∧ (0 : Fin 3 → ZMod 3) ∉ coreZMod3 ∧ (Fiber coreZMod3 0).card = 3 := by have h0_not : (0 : Fin 3 → ZMod 3) ∉ coreZMod3 := by decide refine ⟨coreZMod3_aperiodic, h0_not, ?_⟩ have hfiber : Fiber coreZMod3 0 = {0, ![1, 0, 0], ![0, 1, 0]} := by ext x rw [mem_fiber_iff coreZMod3 h0_not] have hdec : (x ∉ coreZMod3 ∧ ∀ t : Fin 3 → ZMod 3, indC coreZMod3 (x + t) + indC coreZMod3 (x - t) = indC coreZMod3 (0 + t) + indC coreZMod3 (0 - t)) ↔ x ∈ ({0, ![1, 0, 0], ![0, 1, 0]} : Finset (Fin 3 → ZMod 3)) := by revert x; decide exact hdec rw [hfiber] decide end PrimeThree section AllOddPrimes /-- **Unified Non-Power-of-Two Fiber Theorem**: For EVERY odd prime `p ≥ 3`, the rank-3 elementary abelian group `(ZMod p)^3` admits an aperiodic support `C` and `x₀ ∉ C` whose single-point insertion fiber has cardinality `3`, breaking the cyclic power-of-2 fiber law. -/ theorem exists_fiber_card_three_all_odd_primes {p : ℕ} [Fact p.Prime] (hp3 : 3 ≤ p) : ∃ (C : Finset (Fin 3 → ZMod p)) (x₀ : Fin 3 → ZMod p), IsAperiodic C ∧ x₀ ∉ C ∧ (Fiber C x₀).card = 3 := by have hp : p.Prime := Fact.out by_cases h5 : 5 ≤ p · exact ⟨coreGeFive p, 0, fiber_card_three_of_ge_five h5⟩ · have hp_eq : p = 3 := by have hne4 : p ≠ 4 := fun h => by subst h; exact absurd hp (by decide) omega subst hp_eq exact ⟨coreZMod3, 0, fiber_card_three_zmod3⟩ end AllOddPrimes section ZMod4ProdZMod2 /-- **Contrast Theorem (`ZMod 4 × ZMod 2`)**: Over `ZMod 4 × ZMod 2`, no aperiodic support has a single-point insertion fiber of size 3; every aperiodic fiber has cardinality at most `2`. -/ theorem zmod4_prod_zmod2_fiber_card_le_two (C : Finset (ZMod 4 × ZMod 2)) (hC : IsAperiodic C) {x₀ : ZMod 4 × ZMod 2} (hx₀ : x₀ ∉ C) : (Fiber C x₀).card ≤ 2 := by -- Encode `C` via its membership predicate on the 8-element group `ZMod 4 × ZMod 2` and verify -- directly that any 3-point fiber forces a nonzero period `g ∈ ZMod 4 × ZMod 2`. -- Wait: reduce by translating `x₀` to `(0, 0)` first! by_contra hgt have hge3 : 3 ≤ (Fiber C x₀).card := by omega obtain ⟨s, hs, hscard⟩ := Finset.exists_subset_card_eq hge3 obtain ⟨y₁, y₂, y₃, h12, h13, h23, rfl⟩ := Finset.card_eq_three.1 hscard have hm1 := (mem_fiber_iff C hx₀ y₁).1 (hs (by simp)) have hm2 := (mem_fiber_iff C hx₀ y₂).1 (hs (by simp)) have hm3 := (mem_fiber_iff C hx₀ y₃).1 (hs (by simp)) -- Translate by `-y₁` so `0, a, b` are three distinct points outside `D` with equal profiles. let D : Finset (ZMod 4 × ZMod 2) := C.image (· + (-y₁)) let a : ZMod 4 × ZMod 2 := y₂ - y₁ let b : ZMod 4 × ZMod 2 := y₃ - y₁ have ha0 : a ≠ 0 := sub_ne_zero.2 h12.symm have hb0 : b ≠ 0 := sub_ne_zero.2 h13.symm have hab : a ≠ b := fun h => h23 (sub_left_inj.1 h) have hD_mem : ∀ u : ZMod 4 × ZMod 2, u ∈ D ↔ u + y₁ ∈ C := by intro u simp only [D, Finset.mem_image] constructor · rintro ⟨v, hv, hveq⟩ have : u + y₁ = v := by rw [← hveq]; abel rwa [this] · intro hu exact ⟨u + y₁, hu, by abel⟩ have hprofD : ∀ x ∈ ({a, b} : Finset (ZMod 4 × ZMod 2)), ∀ t : ZMod 4 × ZMod 2, indC D (x + t) + indC D (x - t) = indC D (0 + t) + indC D (0 - t) := by intro x hx t have hind : ∀ u : ZMod 4 × ZMod 2, indC D u = indC C (u + y₁) := fun u => by simp [indC, hD_mem] simp only [hind, zero_add, zero_sub] simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl · have h1 : a + t + y₁ = y₂ + t := by dsimp only [a]; abel have h2 : a - t + y₁ = y₂ - t := by dsimp only [a]; abel have h3 : t + y₁ = y₁ + t := by abel have h4 : -t + y₁ = y₁ - t := by abel rw [h1, h2, h3, h4, hm2.2 t, hm1.2 t] · have h1 : b + t + y₁ = y₃ + t := by dsimp only [b]; abel have h2 : b - t + y₁ = y₃ - t := by dsimp only [b]; abel have h3 : t + y₁ = y₁ + t := by abel have h4 : -t + y₁ = y₁ - t := by abel rw [h1, h2, h3, h4, hm3.2 t, hm1.2 t] have h0D : (0 : ZMod 4 × ZMod 2) ∉ D := by rw [hD_mem, zero_add]; exact hm1.1 have haD : a ∉ D := by rw [hD_mem]; simpa [a, sub_add_cancel] using hm2.1 have hbD : b ∉ D := by rw [hD_mem]; simpa [b, sub_add_cancel] using hm3.1 -- Key finite verification on `Bool`-valued subsets of `ZMod 4 × ZMod 2`: -- Any subset `P : ZMod 4 × ZMod 2 → Bool` with `P 0 = P a = P b = false` and equal profiles at -- `0, a, b` (distinct) has a nonzero period `g`! let P : ZMod 4 × ZMod 2 → Bool := fun u => decide (u ∈ D) have hper_bool : ∀ (Q : ZMod 4 × ZMod 2 → Bool) (x y : ZMod 4 × ZMod 2), x ≠ 0 → y ≠ 0 → x ≠ y → Q 0 = false → Q x = false → Q y = false → (∀ t, (if Q (x + t) then 1 else 0) + (if Q (x - t) then 1 else 0) = (if Q t then 1 else 0) + (if Q (-t) then 1 else 0)) → (∀ t, (if Q (y + t) then 1 else 0) + (if Q (y - t) then 1 else 0) = (if Q t then 1 else 0) + (if Q (-t) then 1 else 0)) → ∃ g : ZMod 4 × ZMod 2, g ≠ 0 ∧ ∀ u, Q (u + g) = Q u := by intro Q x y hx0 hy0 hxy hQ0 hQx hQy hpx hpy -- Express `Q` by its 8 boolean values `(q00, q01, q10, q11, q20, q21, q30, q31)`. let f : Bool → Bool → Bool → Bool → Bool → Bool → Bool → Bool → ZMod 4 × ZMod 2 → Bool := fun q00 q01 q10 q11 q20 q21 q30 q31 u => match u with | (0, 0) => q00 | (0, 1) => q01 | (1, 0) => q10 | (1, 1) => q11 | (2, 0) => q20 | (2, 1) => q21 | (3, 0) => q30 | (3, 1) => q31 have hQeq : Q = f (Q (0, 0)) (Q (0, 1)) (Q (1, 0)) (Q (1, 1)) (Q (2, 0)) (Q (2, 1)) (Q (3, 0)) (Q (3, 1)) := by funext ⟨u1, u2⟩ fin_cases u1 <;> fin_cases u2 <;> rfl rw [hQeq] at hQ0 hQx hQy hpx hpy ⊢ generalize Q (0, 0) = q00 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (0, 1) = q01 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (1, 0) = q10 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (1, 1) = q11 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (2, 0) = q20 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (2, 1) = q21 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (3, 0) = q30 at hQ0 hQx hQy hpx hpy ⊢ generalize Q (3, 1) = q31 at hQ0 hQx hQy hpx hpy ⊢ revert q00 q01 q10 q11 q20 q21 q30 q31 x y decide have hP0 : P 0 = false := by simp [P, h0D] have hPa : P a = false := by simp [P, haD] have hPb : P b = false := by simp [P, hbD] have hpa : ∀ t, (if P (a + t) then 1 else 0) + (if P (a - t) then 1 else 0) = (if P t then 1 else 0) + (if P (-t) then 1 else 0) := fun t => by have h := hprofD a (by simp) t simpa [P, indC] using h have hpb : ∀ t, (if P (b + t) then 1 else 0) + (if P (b - t) then 1 else 0) = (if P t then 1 else 0) + (if P (-t) then 1 else 0) := fun t => by have h := hprofD b (by simp) t simpa [P, indC] using h obtain ⟨g, hg0, hgper⟩ := hper_bool P a b ha0 hb0 hab hP0 hPa hPb hpa hpb have hCper : C.image (· + g) = C := by ext u simp only [Finset.mem_image] constructor · rintro ⟨v, hv, rfl⟩ have h := hgper (v - y₁) have h1 : P (v - y₁) = true := by simp only [P, decide_eq_true_eq, hD_mem, sub_add_cancel]; exact hv rw [h1] at h have h2 : v - y₁ + g + y₁ = v + g := by abel rw [← h2, ← hD_mem] exact of_decide_eq_true h · intro hu refine ⟨u - g, ?_, sub_add_cancel u g⟩ have h := hgper (u - g - y₁) have h1 : P (u - g - y₁ + g) = true := by simp only [P, decide_eq_true_eq, hD_mem] have heq : u - g - y₁ + g + y₁ = u := by abel rwa [heq] rw [h1] at h have h2 : u - g - y₁ + y₁ = u - g := by abel rw [← h2, ← hD_mem] exact of_decide_eq_true h.symm exact hg0 (hC g hCper) end ZMod4ProdZMod2 #print axioms fiber_card_three_of_ge_five #print axioms fiber_card_three_zmod3 #print axioms exists_fiber_card_three_all_odd_primes #print axioms zmod4_prod_zmod2_fiber_card_le_two end AbelianHomometry.NonPowerOfTwo