import Mathlib /-! # Odd-Odd Integer Heffter Arrays: Core Theory, Block-Diagonal Assembly, and Single-Family Latin-Pair Gadgets This file establishes the foundational framework for our resolution of the **odd-odd coprime open frontier** (`k ∈ {3, 5}`, `s` odd, `gcd(s, k) = 1`) of Dan Archdeacon's 2015 Integer Heffter Array Conjecture — the very last open regime left by Morini–Pellegrini (`arXiv:2510.08302`, Oct 2025) after our Track 5 resolution of the even-`s` (`s ≡ 2 (mod 4)`) frontier. ## Main Results 1. **Core Definitions & Necessary Conditions**: - `IntegerHeffterArray m n s k`, `ms_eq_nk`, `magnitudes_eq_Icc`, `existsUnique_magnitude`, `three_le_s`, `three_le_k`, `nk_mod_four`, `necessary_conditions`, and `transpose`. 2. **Block-Diagonal Column-Permutation Assembly (`ofBlockAssembly`)**: - Generalizes the Independent-Row-Partition reduction to arbitrary per-column row permutations and signs across `t` disjoint `k × s` blocks pulled back from a base `k × N` magnitude-bijective zero-column-sum array. 3. **Universal Single-Family Latin-Pair Gadgets**: - `affine_four_block_sum`: universal `(+1, -1, -1, +1)` `4`-column zero-sum padding block. - `latinPair3x7_row_sum`, `latinPair3x9_row_sum`, `latinPair3xs_row_sum`: universal `3 × s` single-family zero-sum blocks for **every** odd `s ≥ 7` on any affine triple family with slopes `(2ε, -ε, -ε)`. - `latinPair5x9_row_sum`, `latinPair5x11_row_sum`, `latinPair5xs_row_sum`: universal `5 × s` single-family zero-sum blocks for **every** odd `s ≥ 9` on any affine quintuple family with slopes `(2, -1, 1, -1, -1)`. 4. **Smallest Odd-Odd Coprime Witness**: - `exists_heffter_3_5` and `exists_heffter_5_3`: explicit `H(3, 5; 5, 3)` and `H(5, 3; 3, 5)`. -/ namespace HeffterOddCore open Finset BigOperators /-- An integer Heffter array `H(m, n; s, k)`: an `m × n` partially filled integer matrix whose filled cells have `s` entries per row summing to `0`, `k` entries per column summing to `0`, and distinct nonzero absolute values in `{1, ..., n * k}`. -/ structure IntegerHeffterArray (m n s k : ℕ) where entry : Fin m → Fin n → Option ℤ row_card : ∀ i : Fin m, (Finset.univ.filter (fun j : Fin n => (entry i j).isSome)).card = s col_card : ∀ j : Fin n, (Finset.univ.filter (fun i : Fin m => (entry i j).isSome)).card = k row_sum : ∀ i : Fin m, ∑ j : Fin n, (entry i j).getD 0 = 0 col_sum : ∀ j : Fin n, ∑ i : Fin m, (entry i j).getD 0 = 0 entry_ne_zero : ∀ i j v, entry i j = some v → v ≠ 0 entry_natAbs_le : ∀ i j v, entry i j = some v → v.natAbs ≤ n * k natAbs_inj : ∀ i₁ j₁ v₁ i₂ j₂ v₂, entry i₁ j₁ = some v₁ → entry i₂ j₂ = some v₂ → v₁.natAbs = v₂.natAbs → i₁ = i₂ ∧ j₁ = j₂ namespace IntegerHeffterArray variable {m n s k : ℕ} (H : IntegerHeffterArray m n s k) /-- The finite set of filled cell coordinates `(i, j)`. -/ def filledCells : Finset (Fin m × Fin n) := Finset.univ.filter (fun p => (H.entry p.1 p.2).isSome) /-- The signed value at cell `(i, j)`, defaulting to `0` on empty cells. -/ def val (i : Fin m) (j : Fin n) : ℤ := (H.entry i j).getD 0 lemma mem_filledCells {i : Fin m} {j : Fin n} : (i, j) ∈ H.filledCells ↔ (H.entry i j).isSome := by simp [filledCells] lemma val_eq_of_entry {i : Fin m} {j : Fin n} {v : ℤ} (hv : H.entry i j = some v) : H.val i j = v := by simp [val, hv] lemma val_ne_zero_of_mem {p : Fin m × Fin n} (hp : p ∈ H.filledCells) : H.val p.1 p.2 ≠ 0 := by rw [mem_filledCells] at hp cases h : H.entry p.1 p.2 with | none => simp [h] at hp | some v => rw [H.val_eq_of_entry h] exact H.entry_ne_zero p.1 p.2 v h lemma natAbs_pos_of_mem {p : Fin m × Fin n} (hp : p ∈ H.filledCells) : 1 ≤ (H.val p.1 p.2).natAbs := Int.natAbs_pos.mpr (H.val_ne_zero_of_mem hp) lemma natAbs_le_of_mem {p : Fin m × Fin n} (hp : p ∈ H.filledCells) : (H.val p.1 p.2).natAbs ≤ n * k := by rw [mem_filledCells] at hp cases h : H.entry p.1 p.2 with | none => simp [h] at hp | some v => rw [H.val_eq_of_entry h] exact H.entry_natAbs_le p.1 p.2 v h lemma natAbs_injOn_filledCells : Set.InjOn (fun p : Fin m × Fin n => (H.val p.1 p.2).natAbs) H.filledCells := by intro p₁ hp₁ p₂ hp₂ heq rw [Finset.mem_coe, mem_filledCells] at hp₁ hp₂ cases h₁ : H.entry p₁.1 p₁.2 with | none => simp [h₁] at hp₁ | some v₁ => cases h₂ : H.entry p₂.1 p₂.2 with | none => simp [h₂] at hp₂ | some v₂ => simp only [val, h₁, h₂, Option.getD_some] at heq have hpair := H.natAbs_inj p₁.1 p₁.2 v₁ p₂.1 p₂.2 v₂ h₁ h₂ heq exact Prod.ext hpair.1 hpair.2 /-- Counting filled cells by rows gives `m * s`. -/ lemma filledCells_card_rows : H.filledCells.card = m * s := by have h1 : H.filledCells.card = ∑ i : Fin m, (Finset.univ.filter (fun j : Fin n => (H.entry i j).isSome)).card := by rw [filledCells, Finset.card_filter, Fintype.sum_prod_type] congr 1; ext i; rw [Finset.card_filter] rw [h1]; simp [H.row_card] /-- Counting filled cells by columns gives `n * k`. -/ lemma filledCells_card_cols : H.filledCells.card = n * k := by have h1 : H.filledCells.card = ∑ j : Fin n, (Finset.univ.filter (fun i : Fin m => (H.entry i j).isSome)).card := by rw [filledCells, Finset.card_filter, Fintype.sum_prod_type_right] congr 1; ext j; rw [Finset.card_filter] rw [h1]; simp [H.col_card] /-- Double counting: `m * s = n * k`. -/ theorem ms_eq_nk (H : IntegerHeffterArray m n s k) : m * s = n * k := by rw [← H.filledCells_card_rows, H.filledCells_card_cols] /-- The set of magnitudes of filled cells is exactly `{1, ..., n * k}`. -/ theorem magnitudes_eq_Icc (H : IntegerHeffterArray m n s k) : H.filledCells.image (fun p => (H.val p.1 p.2).natAbs) = Finset.Icc 1 (n * k) := by refine Finset.eq_of_subset_of_card_le ?_ ?_ · intro d hd rcases Finset.mem_image.mp hd with ⟨p, hp, rfl⟩ exact Finset.mem_Icc.mpr ⟨H.natAbs_pos_of_mem hp, H.natAbs_le_of_mem hp⟩ · rw [Finset.card_image_of_injOn H.natAbs_injOn_filledCells, H.filledCells_card_cols, Nat.card_Icc] omega /-- Every integer `d ∈ {1, ..., n * k}` occurs as `|v|` in a unique filled cell. -/ theorem existsUnique_magnitude (H : IntegerHeffterArray m n s k) {d : ℕ} (hd1 : 1 ≤ d) (hd2 : d ≤ n * k) : ∃! p : Fin m × Fin n, p ∈ H.filledCells ∧ (H.val p.1 p.2).natAbs = d := by have hmem : d ∈ H.filledCells.image (fun p => (H.val p.1 p.2).natAbs) := by rw [H.magnitudes_eq_Icc]; exact Finset.mem_Icc.mpr ⟨hd1, hd2⟩ rcases Finset.mem_image.mp hmem with ⟨p, hp, rfl⟩ exact ⟨p, ⟨hp, rfl⟩, fun q hq => H.natAbs_injOn_filledCells hq.1 hp hq.2⟩ /-- Any non-empty integer Heffter array has `s ≥ 3` whenever `m ≥ 1` and `s ≥ 1`. -/ theorem three_le_s (H : IntegerHeffterArray m n s k) (hm : 0 < m) (hs : 0 < s) : 3 ≤ s := by by_contra hlt have hle : s ≤ 2 := by omega let i₀ : Fin m := ⟨0, hm⟩ set S := Finset.univ.filter (fun j : Fin n => (H.entry i₀ j).isSome) have hScard : S.card = s := H.row_card i₀ have hSsum : ∑ j ∈ S, H.val i₀ j = 0 := by have h : ∑ j : Fin n, H.val i₀ j = 0 := H.row_sum i₀ rw [← h] refine Finset.sum_subset (Finset.subset_univ S) ?_ intro j _ hj simp only [S, Finset.mem_filter, Finset.mem_univ, true_and, Option.isSome_iff_exists, not_exists] at hj cases he : H.entry i₀ j with | none => simp [val, he] | some v => exact absurd he (hj v) have hne : ∀ j ∈ S, H.val i₀ j ≠ 0 := fun j hj => by exact H.val_ne_zero_of_mem (p := (i₀, j)) (by rw [mem_filledCells]; exact (Finset.mem_filter.mp hj).2) have hs12 : s = 1 ∨ s = 2 := by omega rcases hs12 with rfl | rfl · rw [Finset.card_eq_one] at hScard rcases hScard with ⟨j₁, hj₁⟩ rw [hj₁, Finset.sum_singleton] at hSsum exact hne j₁ (hj₁ ▸ Finset.mem_singleton_self j₁) hSsum · rw [Finset.card_eq_two] at hScard rcases hScard with ⟨j₁, j₂, hjne, hSeq⟩ rw [hSeq, Finset.sum_pair hjne] at hSsum have habs : (H.val i₀ j₁).natAbs = (H.val i₀ j₂).natAbs := by have hneg : H.val i₀ j₁ = -H.val i₀ j₂ := eq_neg_of_add_eq_zero_left hSsum rw [hneg, Int.natAbs_neg] have hj₁S : j₁ ∈ S := by rw [hSeq]; simp have hj₂S : j₂ ∈ S := by rw [hSeq]; simp have hp₁ : (i₀, j₁) ∈ H.filledCells := by rw [mem_filledCells]; exact (Finset.mem_filter.mp hj₁S).2 have hp₂ : (i₀, j₂) ∈ H.filledCells := by rw [mem_filledCells]; exact (Finset.mem_filter.mp hj₂S).2 have heq := H.natAbs_injOn_filledCells hp₁ hp₂ habs exact hjne (congrArg Prod.snd heq) /-- Transpose duality: `H(m, n; s, k) → H(n, m; k, s)`. -/ def transpose : IntegerHeffterArray n m k s where entry j i := H.entry i j row_card j := H.col_card j col_card i := H.row_card i row_sum j := H.col_sum j col_sum i := H.row_sum i entry_ne_zero j i v hv := H.entry_ne_zero i j v hv entry_natAbs_le j i v hv := by rw [H.ms_eq_nk]; exact H.entry_natAbs_le i j v hv natAbs_inj j₁ i₁ v₁ j₂ i₂ v₂ h₁ h₂ habs := by have hp := H.natAbs_inj i₁ j₁ v₁ i₂ j₂ v₂ h₁ h₂ habs exact ⟨hp.2, hp.1⟩ /-- Any non-empty integer Heffter array has `k ≥ 3` whenever `n ≥ 1` and `k ≥ 1`. -/ theorem three_le_k (H : IntegerHeffterArray m n s k) (hn : 0 < n) (hk : 0 < k) : 3 ≤ k := H.transpose.three_le_s hn hk /-- Archdeacon's parity obstruction: `n * k % 4 = 0 ∨ n * k % 4 = 3`. -/ theorem nk_mod_four (H : IntegerHeffterArray m n s k) : (n * k) % 4 = 0 ∨ (n * k) % 4 = 3 := by have hsum_zero : ∑ p ∈ H.filledCells, H.val p.1 p.2 = 0 := by have h1 : ∑ p ∈ H.filledCells, H.val p.1 p.2 = ∑ p : Fin m × Fin n, H.val p.1 p.2 := by refine Finset.sum_subset (Finset.subset_univ _) ?_ intro p _ hp rw [mem_filledCells] at hp cases he : H.entry p.1 p.2 with | none => simp [val, he] | some v => simp [he] at hp rw [h1, Fintype.sum_prod_type] simp only [val, H.row_sum, Finset.sum_const_zero] have heven_abs : Even (∑ p ∈ H.filledCells, (H.val p.1 p.2).natAbs) := by have hdiff : Even (∑ p ∈ H.filledCells, ((H.val p.1 p.2).natAbs : ℤ) - ∑ p ∈ H.filledCells, H.val p.1 p.2) := by rw [← Finset.sum_sub_distrib] refine Finset.even_sum _ fun p _ => ?_ rcases Int.natAbs_eq (H.val p.1 p.2) with h | h · exact ⟨0, by omega⟩ · exact ⟨(H.val p.1 p.2).natAbs, by omega⟩ rw [hsum_zero, sub_zero] at hdiff rcases hdiff with ⟨r, hr⟩ have hr_cast : ((∑ p ∈ H.filledCells, (H.val p.1 p.2).natAbs : ℕ) : ℤ) = r + r := by rw [Nat.cast_sum]; exact hr have h2 : 2 ∣ ∑ p ∈ H.filledCells, (H.val p.1 p.2).natAbs := by refine ⟨r.toNat, ?_⟩; omega exact even_iff_two_dvd.mpr h2 have hsum_Icc : ∑ p ∈ H.filledCells, (H.val p.1 p.2).natAbs = ∑ d ∈ Finset.Icc 1 (n * k), d := by rw [← H.magnitudes_eq_Icc, Finset.sum_image H.natAbs_injOn_filledCells] rw [hsum_Icc] at heven_abs have hgauss : 2 * (∑ d ∈ Finset.Icc 1 (n * k), d) = (n * k) * (n * k + 1) := by have hrange : ∑ d ∈ Finset.Icc 1 (n * k), d = ∑ d ∈ Finset.range (n * k + 1), d := by have hsub : Finset.range (n * k + 1) = insert 0 (Finset.Icc 1 (n * k)) := by ext x; simp [Finset.mem_range, Finset.mem_Icc]; omega rw [hsub, Finset.sum_insert (by simp)] omega rw [hrange] have h := Finset.sum_range_id_mul_two (n * k + 1) simp only [Nat.add_sub_cancel] at h linarith rcases heven_abs with ⟨t, ht⟩ have h4 : 4 * t = (n * k) * (n * k + 1) := by omega have hmod : ((n * k) * (n * k + 1)) % 4 = 0 := by omega have hcases : (n * k) % 4 = 0 ∨ (n * k) % 4 = 1 ∨ (n * k) % 4 = 2 ∨ (n * k) % 4 = 3 := by omega rcases hcases with h0 | h1 | h2 | h3 · exact Or.inl h0 · exfalso have hm1 : (n * k + 1) % 4 = 2 := by omega have hmul : ((n * k) * (n * k + 1)) % 4 = ((n * k) % 4 * ((n * k + 1) % 4)) % 4 := Nat.mul_mod _ _ _ rw [h1, hm1] at hmul; omega · exfalso have hm2 : (n * k + 1) % 4 = 3 := by omega have hmul : ((n * k) * (n * k + 1)) % 4 = ((n * k) % 4 * ((n * k + 1) % 4)) % 4 := Nat.mul_mod _ _ _ rw [h2, hm2] at hmul; omega · exact Or.inr h3 /-- Full bundle of Archdeacon's necessary conditions for `H(m, n; s, k)`. -/ theorem necessary_conditions (H : IntegerHeffterArray m n s k) (hm : 0 < m) (hn : 0 < n) (hs : 0 < s) (hk : 0 < k) : 3 ≤ s ∧ 3 ≤ k ∧ s ≤ n ∧ k ≤ m ∧ m * s = n * k ∧ ((n * k) % 4 = 0 ∨ (n * k) % 4 = 3) := by have hsn : s ≤ n := by have hcard := H.row_card ⟨0, hm⟩ have hle := Finset.card_le_univ (Finset.univ.filter (fun j : Fin n => (H.entry ⟨0, hm⟩ j).isSome)) simp only [Fintype.card_fin] at hle omega have hkm : k ≤ m := by have hcard := H.col_card ⟨0, hn⟩ have hle := Finset.card_le_univ (Finset.univ.filter (fun i : Fin m => (H.entry i ⟨0, hn⟩).isSome)) simp only [Fintype.card_fin] at hle omega exact ⟨H.three_le_s hm hs, H.three_le_k hn hk, hsn, hkm, H.ms_eq_nk, H.nk_mod_four⟩ end IntegerHeffterArray /-! ## Block-Diagonal Column-Permutation Assembly Theorem -/ /-- **Block-Diagonal Column-Permutation Assembly Theorem**: Given a base `k × ι` zero-column-sum array `A` whose magnitudes are nonzero, bounded by `(s * t) * k`, and globally injective on `Fin k × ι`, any injective column assignment `colOf : Fin t → Fin s → ι`, unit signs `sgnOf`, and per-column row permutations `permOf` satisfying zero row sums in each of the `t` disjoint `k × s` blocks assemble into an `IntegerHeffterArray (k * t) (s * t) s k`. -/ def ofBlockAssembly {ι : Type*} {k t s : ℕ} (A : Fin k → ι → ℤ) (colOf : Fin t → Fin s → ι) (sgnOf : Fin t → Fin s → ℤ) (permOf : Fin t → Fin s → Equiv.Perm (Fin k)) (hsgn : ∀ b c, (sgnOf b c).natAbs = 1) (hcol_sum : ∀ x : ι, ∑ r : Fin k, A r x = 0) (hrow_sum : ∀ (b : Fin t) (r : Fin k), ∑ c : Fin s, sgnOf b c * A (permOf b c r) (colOf b c) = 0) (hne : ∀ r x, A r x ≠ 0) (hle : ∀ r x, (A r x).natAbs ≤ (s * t) * k) (hinjA : ∀ r₁ x₁ r₂ x₂, (A r₁ x₁).natAbs = (A r₂ x₂).natAbs → r₁ = r₂ ∧ x₁ = x₂) (hinjCol : ∀ b₁ c₁ b₂ c₂, colOf b₁ c₁ = colOf b₂ c₂ → b₁ = b₂ ∧ c₁ = c₂) : IntegerHeffterArray (k * t) (s * t) s k where entry i j := let rb := finProdFinEquiv.symm i let cb := finProdFinEquiv.symm j if rb.2 = cb.2 then some (sgnOf rb.2 cb.1 * A (permOf rb.2 cb.1 rb.1) (colOf rb.2 cb.1)) else none row_card i := by set rb := finProdFinEquiv.symm i have hbij : (Finset.univ.filter (fun j : Fin (s * t) => (if rb.2 = (finProdFinEquiv.symm j).2 then some (sgnOf rb.2 (finProdFinEquiv.symm j).1 * A (permOf rb.2 (finProdFinEquiv.symm j).1 rb.1) (colOf rb.2 (finProdFinEquiv.symm j).1)) else none).isSome)).card = (Finset.univ : Finset (Fin s)).card := by refine Finset.card_bij (fun j _ => (finProdFinEquiv.symm j).1) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro j₁ hj₁ j₂ hj₂ h1 rw [Finset.mem_filter] at hj₁ hj₂ have hb₁ : rb.2 = (finProdFinEquiv.symm j₁).2 := by split_ifs at hj₁ with h'; exact h'; simp at hj₁ have hb₂ : rb.2 = (finProdFinEquiv.symm j₂).2 := by split_ifs at hj₂ with h'; exact h'; simp at hj₂ exact finProdFinEquiv.symm.injective (Prod.ext h1 (hb₁.symm.trans hb₂)) · intro c _ refine ⟨finProdFinEquiv (c, rb.2), ?_, by simp⟩ rw [Finset.mem_filter] refine ⟨Finset.mem_univ _, ?_⟩ simp rw [hbij, Finset.card_univ, Fintype.card_fin] col_card j := by set cb := finProdFinEquiv.symm j have hbij : (Finset.univ.filter (fun i : Fin (k * t) => (if (finProdFinEquiv.symm i).2 = cb.2 then some (sgnOf (finProdFinEquiv.symm i).2 cb.1 * A (permOf (finProdFinEquiv.symm i).2 cb.1 (finProdFinEquiv.symm i).1) (colOf (finProdFinEquiv.symm i).2 cb.1)) else none).isSome)).card = (Finset.univ : Finset (Fin k)).card := by refine Finset.card_bij (fun i _ => (finProdFinEquiv.symm i).1) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro i₁ hi₁ i₂ hi₂ h1 rw [Finset.mem_filter] at hi₁ hi₂ have hb₁ : (finProdFinEquiv.symm i₁).2 = cb.2 := by split_ifs at hi₁ with h'; exact h'; simp at hi₁ have hb₂ : (finProdFinEquiv.symm i₂).2 = cb.2 := by split_ifs at hi₂ with h'; exact h'; simp at hi₂ exact finProdFinEquiv.symm.injective (Prod.ext h1 (hb₁.trans hb₂.symm)) · intro r _ refine ⟨finProdFinEquiv (r, cb.2), ?_, by simp⟩ rw [Finset.mem_filter] refine ⟨Finset.mem_univ _, ?_⟩ simp rw [hbij, Finset.card_univ, Fintype.card_fin] row_sum i := by set rb := finProdFinEquiv.symm i have hre : ∑ j : Fin (s * t), (if rb.2 = (finProdFinEquiv.symm j).2 then some (sgnOf rb.2 (finProdFinEquiv.symm j).1 * A (permOf rb.2 (finProdFinEquiv.symm j).1 rb.1) (colOf rb.2 (finProdFinEquiv.symm j).1)) else none).getD 0 = ∑ p : Fin s × Fin t, (if rb.2 = p.2 then sgnOf rb.2 p.1 * A (permOf rb.2 p.1 rb.1) (colOf rb.2 p.1) else 0) := by refine Fintype.sum_equiv finProdFinEquiv.symm _ _ fun j => ?_ split_ifs <;> rfl rw [hre, Fintype.sum_prod_type] simp only [Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte] exact hrow_sum rb.2 rb.1 col_sum j := by set cb := finProdFinEquiv.symm j have hre : ∑ i : Fin (k * t), (if (finProdFinEquiv.symm i).2 = cb.2 then some (sgnOf (finProdFinEquiv.symm i).2 cb.1 * A (permOf (finProdFinEquiv.symm i).2 cb.1 (finProdFinEquiv.symm i).1) (colOf (finProdFinEquiv.symm i).2 cb.1)) else none).getD 0 = ∑ p : Fin k × Fin t, (if p.2 = cb.2 then sgnOf p.2 cb.1 * A (permOf p.2 cb.1 p.1) (colOf p.2 cb.1) else 0) := by refine Fintype.sum_equiv finProdFinEquiv.symm _ _ fun i => ?_ split_ifs <;> rfl rw [hre, Fintype.sum_prod_type] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [← Finset.mul_sum, Equiv.sum_comp (permOf cb.2 cb.1) (fun r => A r (colOf cb.2 cb.1)), hcol_sum, mul_zero] entry_ne_zero i j v hv := by dsimp only at hv split_ifs at hv with h cases hv have hsne : sgnOf (finProdFinEquiv.symm i).2 (finProdFinEquiv.symm j).1 ≠ 0 := by have := hsgn (finProdFinEquiv.symm i).2 (finProdFinEquiv.symm j).1 omega exact mul_ne_zero hsne (hne _ _) entry_natAbs_le i j v hv := by dsimp only at hv split_ifs at hv with h cases hv rw [Int.natAbs_mul, hsgn, one_mul] exact hle _ _ natAbs_inj i₁ j₁ v₁ i₂ j₂ v₂ h₁ h₂ habs := by dsimp only at h₁ h₂ split_ifs at h₁ with hb₁ split_ifs at h₂ with hb₂ cases h₁; cases h₂ rw [Int.natAbs_mul, hsgn, one_mul, Int.natAbs_mul, hsgn, one_mul] at habs have hA := hinjA _ _ _ _ habs have hC := hinjCol _ _ _ _ hA.2 have hperm : permOf (finProdFinEquiv.symm i₁).2 (finProdFinEquiv.symm j₁).1 (finProdFinEquiv.symm i₁).1 = permOf (finProdFinEquiv.symm i₁).2 (finProdFinEquiv.symm j₁).1 (finProdFinEquiv.symm i₂).1 := by have h1 := hA.1 rw [← hC.1, ← hC.2] at h1 exact h1 have hr := (permOf (finProdFinEquiv.symm i₁).2 (finProdFinEquiv.symm j₁).1).injective hperm have hi : i₁ = i₂ := finProdFinEquiv.symm.injective (Prod.ext hr hC.1) have hj : j₁ = j₂ := finProdFinEquiv.symm.injective (Prod.ext hC.2 (hb₁.symm.trans (hC.1.trans hb₂))) exact ⟨hi, hj⟩ /-! ## Sum-Splitting & Universal Affine Single-Family Gadgets -/ /-- Split a sum over `Fin (s₀ + 4 * q)` into a head block of size `s₀` and `q` tail blocks of size `4`. -/ lemma sum_fin_add_four_mul {s₀ q : ℕ} (f : Fin (s₀ + 4 * q) → ℤ) : ∑ c : Fin (s₀ + 4 * q), f c = (∑ c : Fin s₀, f ⟨c.val, by omega⟩) + ∑ u : Fin q, ∑ d : Fin 4, f ⟨s₀ + 4 * u.val + d.val, by omega⟩ := by rw [Fin.sum_univ_add] congr 1 let e : Fin q × Fin 4 ≃ Fin (4 * q) := finProdFinEquiv.trans (finCongr (Nat.mul_comm q 4)) have h1 : ∑ i : Fin (4 * q), f (Fin.natAdd s₀ i) = ∑ p : Fin q × Fin 4, f (Fin.natAdd s₀ (e p)) := (Fintype.sum_equiv e _ _ fun p => rfl).symm rw [h1, Fintype.sum_prod_type] refine Finset.sum_congr rfl fun u _ => Finset.sum_congr rfl fun d _ => ?_ congr 1; apply Fin.ext simp [e, Fin.natAdd, finProdFinEquiv] omega lemma sum_fin_four {α : Type*} [AddCommMonoid α] (g : Fin 4 → α) : ∑ c : Fin 4, g c = g ⟨0, by omega⟩ + g ⟨1, by omega⟩ + g ⟨2, by omega⟩ + g ⟨3, by omega⟩ := by simp [Fin.sum_univ_succ, add_assoc] lemma sum_fin_seven {α : Type*} [AddCommMonoid α] (g : Fin 7 → α) : ∑ c : Fin 7, g c = g ⟨0, by omega⟩ + g ⟨1, by omega⟩ + g ⟨2, by omega⟩ + g ⟨3, by omega⟩ + g ⟨4, by omega⟩ + g ⟨5, by omega⟩ + g ⟨6, by omega⟩ := by simp [Fin.sum_univ_succ, add_assoc] lemma sum_fin_nine {α : Type*} [AddCommMonoid α] (g : Fin 9 → α) : ∑ c : Fin 9, g c = g ⟨0, by omega⟩ + g ⟨1, by omega⟩ + g ⟨2, by omega⟩ + g ⟨3, by omega⟩ + g ⟨4, by omega⟩ + g ⟨5, by omega⟩ + g ⟨6, by omega⟩ + g ⟨7, by omega⟩ + g ⟨8, by omega⟩ := by simp [Fin.sum_univ_succ, add_assoc] lemma sum_fin_eleven {α : Type*} [AddCommMonoid α] (g : Fin 11 → α) : ∑ c : Fin 11, g c = g ⟨0, by omega⟩ + g ⟨1, by omega⟩ + g ⟨2, by omega⟩ + g ⟨3, by omega⟩ + g ⟨4, by omega⟩ + g ⟨5, by omega⟩ + g ⟨6, by omega⟩ + g ⟨7, by omega⟩ + g ⟨8, by omega⟩ + g ⟨9, by omega⟩ + g ⟨10, by omega⟩ := by simp [Fin.sum_univ_succ, add_assoc] /-- Universal sign pattern `(+1, -1, -1, +1)` for affine `4`-blocks. -/ def sign4 : Fin 4 → ℤ | ⟨0, _⟩ => 1 | ⟨1, _⟩ => -1 | ⟨2, _⟩ => -1 | ⟨3, _⟩ => 1 lemma sign4_natAbs (d : Fin 4) : (sign4 d).natAbs = 1 := by fin_cases d <;> decide /-- Any affine progression `j ↦ a + b * j` has zero `(+1, -1, -1, +1)` sum on any `4` consecutive indices. -/ lemma affine_four_block_sum (a b : ℤ) (j₀ : ℕ) : ∑ d : Fin 4, sign4 d * (a + b * ((j₀ + d.val : ℕ) : ℤ)) = 0 := by rw [sum_fin_four] simp only [sign4] push_cast ring /-! ### Universal `k = 3` Single-Family Latin-Pair Gadgets (`3 × 7` and `3 × 9`) -/ /-- Explicit permutation builder on `Fin 3` from its triple of images. -/ noncomputable def perm3 (a b c : Fin 3) (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) : Equiv.Perm (Fin 3) := Equiv.ofBijective (fun r : Fin 3 => match r with | ⟨0, _⟩ => a | ⟨1, _⟩ => b | ⟨2, _⟩ => c) ((Finite.injective_iff_bijective).mp fun x y hxy => by fin_cases x <;> fin_cases y <;> simp_all) /-- Signs for the universal `3 × 7` single-family Latin-pair block. -/ def lp3x7Sgn : Fin 7 → ℤ | ⟨0, _⟩ => 1 | ⟨1, _⟩ => 1 | ⟨2, _⟩ => 1 | ⟨3, _⟩ => 1 | ⟨4, _⟩ => -1 | ⟨5, _⟩ => -1 | ⟨6, _⟩ => 1 lemma lp3x7Sgn_natAbs (c : Fin 7) : (lp3x7Sgn c).natAbs = 1 := by fin_cases c <;> decide /-- Row permutations for the universal `3 × 7` single-family Latin-pair block. -/ noncomputable def lp3x7Perm : Fin 7 → Equiv.Perm (Fin 3) | ⟨0, _⟩ => perm3 1 2 0 (by decide) (by decide) (by decide) | ⟨1, _⟩ => perm3 2 0 1 (by decide) (by decide) (by decide) | ⟨2, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨3, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨4, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨5, _⟩ => perm3 1 2 0 (by decide) (by decide) (by decide) | ⟨6, _⟩ => perm3 1 2 0 (by decide) (by decide) (by decide) /-- Universal `3 × 7` Latin-pair zero-row-sum theorem: holds identically in `(a₀, a₁, a₂, ε, j₀)` for any zero-sum affine triple family with slopes `(2ε, -ε, -ε)`. -/ theorem latinPair3x7_row_sum (a₀ a₁ a₂ ε : ℤ) (hsum : a₀ + a₁ + a₂ = 0) (j₀ : ℕ) (r : Fin 3) : let F : Fin 3 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * ε * (j : ℤ) | ⟨1, _⟩ => a₁ - ε * (j : ℤ) | ⟨2, _⟩ => a₂ - ε * (j : ℤ) ∑ c : Fin 7, lp3x7Sgn c * F (lp3x7Perm c r) (j₀ + c.val) = 0 := by intro F rw [sum_fin_seven] fin_cases r <;> simp only [F, lp3x7Sgn, lp3x7Perm, perm3, Equiv.ofBijective_apply, Fin.isValue] <;> push_cast <;> linarith /-- Signs for the universal `3 × 9` single-family Latin-pair block. -/ def lp3x9Sgn : Fin 9 → ℤ | ⟨0, _⟩ => 1 | ⟨1, _⟩ => 1 | ⟨2, _⟩ => 1 | ⟨3, _⟩ => -1 | ⟨4, _⟩ => 1 | ⟨5, _⟩ => -1 | ⟨6, _⟩ => 1 | ⟨7, _⟩ => -1 | ⟨8, _⟩ => 1 lemma lp3x9Sgn_natAbs (c : Fin 9) : (lp3x9Sgn c).natAbs = 1 := by fin_cases c <;> decide /-- Row permutations for the universal `3 × 9` single-family Latin-pair block. -/ noncomputable def lp3x9Perm : Fin 9 → Equiv.Perm (Fin 3) | ⟨0, _⟩ => perm3 0 2 1 (by decide) (by decide) (by decide) | ⟨1, _⟩ => perm3 1 0 2 (by decide) (by decide) (by decide) | ⟨2, _⟩ => perm3 2 1 0 (by decide) (by decide) (by decide) | ⟨3, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨4, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨5, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨6, _⟩ => perm3 0 1 2 (by decide) (by decide) (by decide) | ⟨7, _⟩ => perm3 2 0 1 (by decide) (by decide) (by decide) | ⟨8, _⟩ => perm3 2 0 1 (by decide) (by decide) (by decide) /-- Universal `3 × 9` Latin-pair zero-row-sum theorem: holds identically in `(a₀, a₁, a₂, ε, j₀)`. -/ theorem latinPair3x9_row_sum (a₀ a₁ a₂ ε : ℤ) (hsum : a₀ + a₁ + a₂ = 0) (j₀ : ℕ) (r : Fin 3) : let F : Fin 3 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * ε * (j : ℤ) | ⟨1, _⟩ => a₁ - ε * (j : ℤ) | ⟨2, _⟩ => a₂ - ε * (j : ℤ) ∑ c : Fin 9, lp3x9Sgn c * F (lp3x9Perm c r) (j₀ + c.val) = 0 := by intro F rw [sum_fin_nine] fin_cases r <;> simp only [F, lp3x9Sgn, lp3x9Perm, perm3, Equiv.ofBijective_apply, Fin.isValue] <;> push_cast <;> linarith /-- Combined `3 × (7 + 4q)` single-family zero-row-sum theorem. -/ theorem latinPair3x7_add4_row_sum (a₀ a₁ a₂ ε : ℤ) (hsum : a₀ + a₁ + a₂ = 0) (j₀ q : ℕ) (r : Fin 3) : let F : Fin 3 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * ε * (j : ℤ) | ⟨1, _⟩ => a₁ - ε * (j : ℤ) | ⟨2, _⟩ => a₂ - ε * (j : ℤ) ∑ c : Fin (7 + 4 * q), (if h : c.val < 7 then lp3x7Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 7) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 7 then lp3x7Perm ⟨c.val, h⟩ r else r) (j₀ + c.val) = 0 := by intro F rw [sum_fin_add_four_mul] have hhead : (∑ c : Fin 7, (if h : c.val < 7 then lp3x7Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 7) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 7 then lp3x7Perm ⟨c.val, h⟩ r else r) (j₀ + c.val)) = 0 := by have heq : ∀ c : Fin 7, (if h : c.val < 7 then lp3x7Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 7) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 7 then lp3x7Perm ⟨c.val, h⟩ r else r) (j₀ + c.val) = lp3x7Sgn c * F (lp3x7Perm c r) (j₀ + c.val) := fun c => by simp [c.isLt] simp_rw [heq] exact latinPair3x7_row_sum a₀ a₁ a₂ ε hsum j₀ r have htail : ∀ u : Fin q, (∑ d : Fin 4, (if h : 7 + 4 * u.val + d.val < 7 then lp3x7Sgn ⟨7 + 4 * u.val + d.val, h⟩ else sign4 ⟨(7 + 4 * u.val + d.val - 7) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : 7 + 4 * u.val + d.val < 7 then lp3x7Perm ⟨7 + 4 * u.val + d.val, h⟩ r else r) (j₀ + (7 + 4 * u.val + d.val))) = 0 := fun u => by have hmod : ∀ d : Fin 4, (7 + 4 * u.val + d.val - 7) % 4 = d.val := fun d => by omega have hnot : ∀ d : Fin 4, ¬ (7 + 4 * u.val + d.val < 7) := fun d => by omega have hadd : ∀ d : Fin 4, j₀ + (7 + 4 * u.val + d.val) = (j₀ + 7 + 4 * u.val) + d.val := fun d => by omega simp_rw [dif_neg (hnot _), hmod, hadd] fin_cases r · simpa [F, mul_assoc] using affine_four_block_sum a₀ (2 * ε) (j₀ + 7 + 4 * u.val) · simpa [F, sub_eq_add_neg, neg_mul] using affine_four_block_sum a₁ (-ε) (j₀ + 7 + 4 * u.val) · simpa [F, sub_eq_add_neg, neg_mul] using affine_four_block_sum a₂ (-ε) (j₀ + 7 + 4 * u.val) rw [hhead, zero_add, Finset.sum_eq_zero fun u _ => htail u] /-- Combined `3 × (9 + 4q)` single-family zero-row-sum theorem. -/ theorem latinPair3x9_add4_row_sum (a₀ a₁ a₂ ε : ℤ) (hsum : a₀ + a₁ + a₂ = 0) (j₀ q : ℕ) (r : Fin 3) : let F : Fin 3 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * ε * (j : ℤ) | ⟨1, _⟩ => a₁ - ε * (j : ℤ) | ⟨2, _⟩ => a₂ - ε * (j : ℤ) ∑ c : Fin (9 + 4 * q), (if h : c.val < 9 then lp3x9Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 9) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 9 then lp3x9Perm ⟨c.val, h⟩ r else r) (j₀ + c.val) = 0 := by intro F rw [sum_fin_add_four_mul] have hhead : (∑ c : Fin 9, (if h : c.val < 9 then lp3x9Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 9) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 9 then lp3x9Perm ⟨c.val, h⟩ r else r) (j₀ + c.val)) = 0 := by have heq : ∀ c : Fin 9, (if h : c.val < 9 then lp3x9Sgn ⟨c.val, h⟩ else sign4 ⟨(c.val - 9) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : c.val < 9 then lp3x9Perm ⟨c.val, h⟩ r else r) (j₀ + c.val) = lp3x9Sgn c * F (lp3x9Perm c r) (j₀ + c.val) := fun c => by simp [c.isLt] simp_rw [heq] exact latinPair3x9_row_sum a₀ a₁ a₂ ε hsum j₀ r have htail : ∀ u : Fin q, (∑ d : Fin 4, (if h : 9 + 4 * u.val + d.val < 9 then lp3x9Sgn ⟨9 + 4 * u.val + d.val, h⟩ else sign4 ⟨(9 + 4 * u.val + d.val - 9) % 4, Nat.mod_lt _ (by omega)⟩) * F (if h : 9 + 4 * u.val + d.val < 9 then lp3x9Perm ⟨9 + 4 * u.val + d.val, h⟩ r else r) (j₀ + (9 + 4 * u.val + d.val))) = 0 := fun u => by have hmod : ∀ d : Fin 4, (9 + 4 * u.val + d.val - 9) % 4 = d.val := fun d => by omega have hnot : ∀ d : Fin 4, ¬ (9 + 4 * u.val + d.val < 9) := fun d => by omega have hadd : ∀ d : Fin 4, j₀ + (9 + 4 * u.val + d.val) = (j₀ + 9 + 4 * u.val) + d.val := fun d => by omega simp_rw [dif_neg (hnot _), hmod, hadd] fin_cases r · simpa [F, mul_assoc] using affine_four_block_sum a₀ (2 * ε) (j₀ + 9 + 4 * u.val) · simpa [F, sub_eq_add_neg, neg_mul] using affine_four_block_sum a₁ (-ε) (j₀ + 9 + 4 * u.val) · simpa [F, sub_eq_add_neg, neg_mul] using affine_four_block_sum a₂ (-ε) (j₀ + 9 + 4 * u.val) rw [hhead, zero_add, Finset.sum_eq_zero fun u _ => htail u] /-! ### Universal `k = 5` Single-Family Latin-Pair Gadgets (`5 × 9` and `5 × 11`) -/ /-- Explicit permutation builder on `Fin 5` from its 5-tuple of images. -/ noncomputable def perm5 (v : Fin 5 → Fin 5) (hinj : Function.Injective v) : Equiv.Perm (Fin 5) := Equiv.ofBijective v ((Finite.injective_iff_bijective).mp hinj) /-- Column-offset permutation on `Fin 9` for the `5 × 9` Latin-pair block: `D = [0, 2, 3, 4, 6]`, pairs `(1, 5)` and `(7, 8)`. -/ def lp5x9Off : Fin 9 → Fin 9 | ⟨0, _⟩ => 0 | ⟨1, _⟩ => 2 | ⟨2, _⟩ => 3 | ⟨3, _⟩ => 4 | ⟨4, _⟩ => 6 | ⟨5, _⟩ => 1 | ⟨6, _⟩ => 5 | ⟨7, _⟩ => 7 | ⟨8, _⟩ => 8 lemma lp5x9Off_inj : Function.Injective lp5x9Off := by decide /-- Signs for the universal `5 × 9` single-family Latin-pair block. -/ def lp5x9Sgn : Fin 9 → ℤ | ⟨0, _⟩ => 1 | ⟨1, _⟩ => 1 | ⟨2, _⟩ => 1 | ⟨3, _⟩ => 1 | ⟨4, _⟩ => 1 | ⟨5, _⟩ => 1 | ⟨6, _⟩ => -1 | ⟨7, _⟩ => -1 | ⟨8, _⟩ => 1 lemma lp5x9Sgn_natAbs (c : Fin 9) : (lp5x9Sgn c).natAbs = 1 := by fin_cases c <;> decide /-- Row permutation table for the universal `5 × 9` single-family Latin-pair block. -/ def lp5x9PermFn : Fin 9 → Fin 5 → Fin 5 | ⟨0, _⟩ => ![0, 1, 3, 4, 2] | ⟨1, _⟩ => ![3, 4, 2, 0, 1] | ⟨2, _⟩ => ![1, 0, 4, 2, 3] | ⟨3, _⟩ => ![4, 2, 1, 3, 0] | ⟨4, _⟩ => ![2, 3, 0, 1, 4] | ⟨5, _⟩ => ![1, 2, 0, 4, 3] | ⟨6, _⟩ => ![1, 2, 0, 4, 3] | ⟨7, _⟩ => ![3, 0, 2, 4, 1] | ⟨8, _⟩ => ![3, 0, 2, 4, 1] lemma lp5x9PermFn_inj (c : Fin 9) : Function.Injective (lp5x9PermFn c) := by revert c; decide noncomputable def lp5x9Perm (c : Fin 9) : Equiv.Perm (Fin 5) := perm5 (lp5x9PermFn c) (lp5x9PermFn_inj c) /-- Universal `5 × 9` Latin-pair zero-row-sum theorem: holds identically in `(a₀..a₄, j₀)` for any zero-sum affine quintuple family with slopes `(2, -1, 1, -1, -1)`. -/ theorem latinPair5x9_row_sum (a₀ a₁ a₂ a₃ a₄ : ℤ) (hsum : a₀ + a₁ + a₂ + a₃ + a₄ = 0) (j₀ : ℕ) (r : Fin 5) : let F : Fin 5 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * (j : ℤ) | ⟨1, _⟩ => a₁ - (j : ℤ) | ⟨2, _⟩ => a₂ + (j : ℤ) | ⟨3, _⟩ => a₃ - (j : ℤ) | ⟨4, _⟩ => a₄ - (j : ℤ) ∑ c : Fin 9, lp5x9Sgn c * F (lp5x9Perm c r) (j₀ + (lp5x9Off c).val) = 0 := by intro F rw [sum_fin_nine] fin_cases r <;> simp only [F, lp5x9Sgn, lp5x9Perm, lp5x9PermFn, lp5x9Off, perm5, Equiv.ofBijective_apply, Fin.isValue] <;> norm_num <;> linarith /-- Signs for the universal `5 × 11` single-family Latin-pair block. -/ def lp5x11Sgn : Fin 11 → ℤ | ⟨0, _⟩ => 1 | ⟨1, _⟩ => 1 | ⟨2, _⟩ => 1 | ⟨3, _⟩ => 1 | ⟨4, _⟩ => 1 | ⟨5, _⟩ => 1 | ⟨6, _⟩ => -1 | ⟨7, _⟩ => -1 | ⟨8, _⟩ => 1 | ⟨9, _⟩ => -1 | ⟨10, _⟩ => 1 lemma lp5x11Sgn_natAbs (c : Fin 11) : (lp5x11Sgn c).natAbs = 1 := by fin_cases c <;> decide /-- Row permutation table for the universal `5 × 11` single-family Latin-pair block. -/ def lp5x11PermFn : Fin 11 → Fin 5 → Fin 5 | ⟨0, _⟩ => ![4, 3, 0, 1, 2] | ⟨1, _⟩ => ![2, 0, 1, 3, 4] | ⟨2, _⟩ => ![3, 1, 4, 2, 0] | ⟨3, _⟩ => ![1, 4, 2, 0, 3] | ⟨4, _⟩ => ![0, 2, 3, 4, 1] | ⟨5, _⟩ => ![0, 3, 4, 2, 1] | ⟨6, _⟩ => ![0, 3, 4, 2, 1] | ⟨7, _⟩ => ![4, 1, 0, 3, 2] | ⟨8, _⟩ => ![4, 1, 0, 3, 2] | ⟨9, _⟩ => ![1, 3, 2, 4, 0] | ⟨10, _⟩ => ![1, 3, 2, 4, 0] lemma lp5x11PermFn_inj (c : Fin 11) : Function.Injective (lp5x11PermFn c) := by revert c; decide noncomputable def lp5x11Perm (c : Fin 11) : Equiv.Perm (Fin 5) := perm5 (lp5x11PermFn c) (lp5x11PermFn_inj c) /-- Universal `5 × 11` Latin-pair zero-row-sum theorem: holds identically in `(a₀..a₄, j₀)`. -/ theorem latinPair5x11_row_sum (a₀ a₁ a₂ a₃ a₄ : ℤ) (hsum : a₀ + a₁ + a₂ + a₃ + a₄ = 0) (j₀ : ℕ) (r : Fin 5) : let F : Fin 5 → ℕ → ℤ := fun e j => match e with | ⟨0, _⟩ => a₀ + 2 * (j : ℤ) | ⟨1, _⟩ => a₁ - (j : ℤ) | ⟨2, _⟩ => a₂ + (j : ℤ) | ⟨3, _⟩ => a₃ - (j : ℤ) | ⟨4, _⟩ => a₄ - (j : ℤ) ∑ c : Fin 11, lp5x11Sgn c * F (lp5x11Perm c r) (j₀ + c.val) = 0 := by intro F rw [sum_fin_eleven] fin_cases r <;> simp only [F, lp5x11Sgn, lp5x11Perm, lp5x11PermFn, perm5, Equiv.ofBijective_apply, Fin.isValue] <;> push_cast <;> linarith /-! ## Explicit Smallest Odd-Odd Coprime Witness `H(3, 5; 5, 3)` -/ /-- Explicit `3 × 5` integer Heffter array `H(3, 5; 5, 3)` on `{1, ..., 15}`. -/ def heffter3x5Mat : Fin 3 → Fin 5 → ℤ | ⟨0, _⟩ => ![ 10, 6, -12, -9, 5] | ⟨1, _⟩ => ![ 1, -14, 15, -4, 2] | ⟨2, _⟩ => ![-11, 8, -3, 13, -7] /-- Existence of `H(3, 5; 5, 3)`. -/ def heffter3x5 : IntegerHeffterArray 3 5 5 3 where entry i j := some (heffter3x5Mat i j) row_card i := by fin_cases i <;> decide col_card j := by fin_cases j <;> decide row_sum i := by fin_cases i <;> decide col_sum j := by fin_cases j <;> decide entry_ne_zero i j v hv := by cases hv; revert i j; decide entry_natAbs_le i j v hv := by cases hv; revert i j; decide natAbs_inj i₁ j₁ v₁ i₂ j₂ v₂ h₁ h₂ habs := by cases h₁; cases h₂ revert i₁ j₁ i₂ j₂ habs; decide theorem exists_heffter_3_5 : Nonempty (IntegerHeffterArray 3 5 5 3) := ⟨heffter3x5⟩ theorem exists_heffter_5_3 : Nonempty (IntegerHeffterArray 5 3 3 5) := ⟨heffter3x5.transpose⟩ #print axioms IntegerHeffterArray.necessary_conditions #print axioms ofBlockAssembly #print axioms latinPair3x7_add4_row_sum #print axioms latinPair3x9_add4_row_sum #print axioms latinPair5x9_row_sum #print axioms latinPair5x11_row_sum #print axioms exists_heffter_3_5 #print axioms exists_heffter_5_3 end HeffterOddCore