import Mathlib.Analysis.Fourier.FiniteAbelian.PontryaginDuality import Mathlib.Analysis.Fourier.FiniteAbelian.Orthogonality import Mathlib.Data.Finset.Card import Mathlib.Data.Complex.Basic /-! # Fixed-Core Single-Point Autocorrelation Fibers: Core Theory For a finite abelian group `G` and support `C : Finset G`, we define: - the autocorrelation `autocorr S t = #{u ∈ S | u + t ∈ S}`, - aperiodicity `IsAperiodic C : ∀ g : G, C.image (· + g) = C → g = 0`, - the single-point insertion fiber `Fiber C x₀ = {x ∈ G \ C | autocorr (insert x C) = autocorr (insert x₀ C)}`, - the indicator `indC C u` and Fourier coefficient `fourierCoeff C χ = ∑ u ∈ C, χ (-u)`. We prove: 1. `autocorr_insert_eq_iff`: exact profile reduction for `x, x₀ ∉ C`: `autocorr (insert x C) = autocorr (insert x₀ C) ↔ ∀ t, indC C (x + t) + indC C (x - t) = indC C (x₀ + t) + indC C (x₀ - t)`. 2. `autocorr_insert_eq_iff_fourier`: exact Fourier-side criterion for `x, x₀ ∉ C`: `autocorr (insert x C) = autocorr (insert x₀ C) ↔ ∀ χ : AddChar G ℂ, (fourierCoeff C χ * χ x).re = (fourierCoeff C χ * χ x₀).re`. -/ namespace AbelianHomometry open scoped BigOperators ComplexConjugate 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 /-- Complex Fourier coefficient `f_hat(χ) = ∑ u ∈ C, χ (-u)`. -/ def fourierCoeff (C : Finset G) (χ : AddChar G ℂ) : ℂ := ∑ u ∈ C, χ (-u) end Definitions section ProfileReduction variable {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] omit [Fintype G] in /-- Exact expansion of `autocorr (insert x C) t` when `x ∉ C`. -/ 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 := by intro h exact 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 /-- Exact profile reduction for `x, x₀ ∉ C`. -/ theorem 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 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 ProfileReduction section FourierCriterion variable {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] /-- Dual orthogonality: `∑ χ : AddChar G ℂ, χ a = if a = 0 then |G| else 0`. -/ 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] /-- Fourier inversion on a finite abelian group `G`. -/ theorem 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 => by constructor · intro h; exact (sub_eq_zero.1 h).symm · intro h; rw [h, sub_self] simp_rw [hsub] simp [mul_comm] omit [DecidableEq G] in /-- Complex conjugate of a character evaluation equals evaluation at the negated argument. -/ 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] /-- Fourier transform of the symmetrized profile `t ↦ 1_C(x + t) + 1_C(x - t)`. -/ 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 _ /-- Exact Fourier-side criterion for equal autocorrelations of single-point insertions. -/ theorem autocorr_insert_eq_iff_fourier (C : Finset G) {x x₀ : G} (hx : x ∉ C) (hx₀ : x₀ ∉ C) : autocorr (insert x C) = autocorr (insert x₀ C) ↔ ∀ χ : AddChar G ℂ, (fourierCoeff C χ * χ x).re = (fourierCoeff C χ * χ x₀).re := by rw [autocorr_insert_eq_iff C hx hx₀] constructor · intro h χ have hsum : ∑ t : G, ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ) * χ (-t) = ∑ t : G, ((indC C (x₀ + t) + indC C (x₀ - t) : ℕ) : ℂ) * χ (-t) := by refine Finset.sum_congr rfl fun t _ => ?_ rw [h t] rw [fourier_profile_eq, fourier_profile_eq] at hsum have h2 : ((fourierCoeff C χ * χ x).re : ℂ) = ((fourierCoeff C χ * χ x₀).re : ℂ) := mul_left_cancel₀ (two_ne_zero : (2 : ℂ) ≠ 0) hsum exact Complex.ofReal_injective h2 · intro h s have hinv_x := fourier_inversion (fun t => ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ)) s have hinv_x₀ := fourier_inversion (fun t => ((indC C (x₀ + t) + indC C (x₀ - t) : ℕ) : ℂ)) s have heq : ∑ χ : AddChar G ℂ, (∑ t : G, ((indC C (x + t) + indC C (x - t) : ℕ) : ℂ) * χ (-t)) * χ s = ∑ χ : AddChar G ℂ, (∑ t : G, ((indC C (x₀ + t) + indC C (x₀ - t) : ℕ) : ℂ) * χ (-t)) * χ s := by refine Finset.sum_congr rfl fun χ _ => ?_ rw [fourier_profile_eq, fourier_profile_eq, h χ] rw [hinv_x, hinv_x₀] at heq have hcard : (Fintype.card G : ℂ) ≠ 0 := Nat.cast_ne_zero.2 Fintype.card_ne_zero have hc : ((indC C (x + s) + indC C (x - s) : ℕ) : ℂ) = ((indC C (x₀ + s) + indC C (x₀ - s) : ℕ) : ℂ) := mul_left_cancel₀ hcard heq exact Nat.cast_injective hc /-- Membership in `Fiber C x₀` characterized via Fourier coefficients. -/ theorem mem_fiber_iff_fourier (C : Finset G) {x₀ : G} (hx₀ : x₀ ∉ C) (x : G) : x ∈ Fiber C x₀ ↔ x ∉ C ∧ ∀ χ : 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] constructor · rintro ⟨hx, h⟩ exact ⟨hx, (autocorr_insert_eq_iff_fourier C hx hx₀).1 h⟩ · rintro ⟨hx, h⟩ exact ⟨hx, (autocorr_insert_eq_iff_fourier C hx hx₀).2 h⟩ end FourierCriterion #print axioms autocorr_insert_eq_iff #print axioms autocorr_insert_eq_iff_fourier #print axioms mem_fiber_iff_fourier end AbelianHomometry