import Mathlib /-! # Exact Determination of `H(I, 4)` for All `I ≥ 1` & Anchor-Exclusion Reduction This file determines the exact Disjoint Golomb Ruler threshold `H(I, 4)` for **all** `I ≥ 1` (matching and formally verifying the exact formula of Xiu–Fan–Liang, arXiv:1405.4535 [2014] and Xu–Xiu–Fan–Liang, arXiv:2409.14409 [2024]), and proves the **Anchor-Exclusion Lemma** and **Inductive Peeling Reduction** used to resolve the Main Open Conjecture for `J = 4` and all `I ≥ 1`. ## Main Results 1. Explicit verified `(I, 4, n)`-DGR constructions for `I = 1, 2, 3, 4, 5`: - `I = 1, n = 7`: `{1, 2, 5, 7}` - `I = 2, n = 9`: `{1, 2, 6, 8}, {3, 4, 7, 9}` - `I = 3, n = 12`: `{1, 2, 4, 8}, {3, 7, 10, 12}, {5, 6, 9, 11}` - `I = 4, n = 16`: `{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 11, 12, 14}, {9, 13, 15, 16}` - `I = 5, n = 20`: `{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 9, 12, 13}, {11, 15, 17, 18}, {14, 16, 19, 20}` 2. `isHVal_J4_ge_three` & `sInf_dgr_J4_ge_three`: Exact formula `H(I, 4) = 4 * I` for **all** `I ≥ 3` (by shift-composition `I → I + 3` from the bases `{3, 4, 5}` plus the trivial cardinality lower bound `4 * I`). 3. `isHVal_H4`: Unified exact formula `H(1, 4) = 7`, `H(2, 4) = 9`, `H(I, 4) = 4 * I` (`I ≥ 3`). 4. **Anchor-Exclusion Lemmas** (`anchor_right_at_most_four`, `anchor_left_at_most_four`): For any `x < y < z` with `y - x ≠ z - y`: - at most 4 elements `b` with `y < b < z` fail `IsGolombRuler {x, y, b, z}`; - at most 4 elements `b` with `x < b < y` fail `IsGolombRuler {x, b, y, z}`. 5. **Inductive Peeling Theorem** (`dgr_J4_of_I1_and_I3`): Given `|A| = 7 → HasDGR A 1 4` and `|A| = 12 → HasDGR A 3 4`, **every** `A ⊆ ℤ` with `|A| = 4 * I` (`I ≥ 3`) satisfies `HasDGR A I 4`. -/ namespace DGRIntervalH4 def IsGolombRuler (R : Finset ℤ) : Prop := ∀ a ∈ R, ∀ b ∈ R, ∀ c ∈ R, ∀ d ∈ R, a < b → c < d → b - a = d - c → a = c ∧ b = d def HasDGR (A : Finset ℤ) (I J : ℕ) : Prop := ∃ R : Fin I → Finset ℤ, (∀ i, R i ⊆ A) ∧ (∀ i, (R i).card = J) ∧ (∀ i, IsGolombRuler (R i)) ∧ Pairwise (fun i j => Disjoint (R i) (R j)) def IsDGRInterval (I J n : ℕ) : Prop := HasDGR (Finset.Icc (1 : ℤ) (n : ℤ)) I J def IsHVal (I J n : ℕ) : Prop := IsDGRInterval I J n ∧ ∀ m < n, ¬ IsDGRInterval I J m /-- Closed-form value of `H(I, 4)` for `I ≥ 1`. -/ def H4 (I : ℕ) : ℕ := if I = 1 then 7 else if I = 2 then 9 else 4 * I /-! ### Section 1: Core Algebraic Helpers -/ theorem isGolombRuler_quad_iff {a b c d : ℤ} (hab : a < b) (hbc : b < c) (hcd : c < d) : IsGolombRuler ({a, b, c, d} : Finset ℤ) ↔ b - a ≠ c - b ∧ b - a ≠ d - c ∧ c - b ≠ d - c ∧ b - a ≠ d - b ∧ c - a ≠ d - c := by constructor · intro h refine ⟨?_, ?_, ?_, ?_, ?_⟩ · intro heq; have := h a (by simp) b (by simp) b (by simp) c (by simp) hab hbc heq; omega · intro heq; have := h a (by simp) b (by simp) c (by simp) d (by simp) hab hcd heq; omega · intro heq; have := h b (by simp) c (by simp) c (by simp) d (by simp) hbc hcd heq; omega · intro heq; have := h a (by simp) b (by simp) b (by simp) d (by simp) hab (by omega) heq; omega · intro heq; have := h a (by simp) c (by simp) c (by simp) d (by simp) (by omega) hcd heq; omega · rintro ⟨h1, h2, h3, h4, h5⟩ x hx y hy z hz w hw hxy hzw hdiff simp only [Finset.mem_insert, Finset.mem_singleton] at hx hy hz hw rcases hx with rfl | rfl | rfl | rfl <;> rcases hy with rfl | rfl | rfl | rfl <;> rcases hz with rfl | rfl | rfl | rfl <;> rcases hw with rfl | rfl | rfl | rfl <;> omega theorem hasDGR_mono {A B : Finset ℤ} {I J : ℕ} (hAB : A ⊆ B) (h : HasDGR A I J) : HasDGR B I J := by rcases h with ⟨R, hsub, hcard, hgr, hdisj⟩ exact ⟨R, fun i => (hsub i).trans hAB, hcard, hgr, hdisj⟩ theorem isGolombRuler_translate {R : Finset ℤ} (hR : IsGolombRuler R) (t : ℤ) : IsGolombRuler (R.image (fun x => x + t)) := by intro x₁ hx₁ x₂ hx₂ x₃ hx₃ x₄ hx₄ h12 h34 hdiff rcases Finset.mem_image.mp hx₁ with ⟨a₁, ha₁, rfl⟩ rcases Finset.mem_image.mp hx₂ with ⟨a₂, ha₂, rfl⟩ rcases Finset.mem_image.mp hx₃ with ⟨a₃, ha₃, rfl⟩ rcases Finset.mem_image.mp hx₄ with ⟨a₄, ha₄, rfl⟩ have := hR a₁ ha₁ a₂ ha₂ a₃ ha₃ a₄ ha₄ (by omega) (by omega) (by omega) exact ⟨by omega, by omega⟩ theorem hasDGR_translate {A : Finset ℤ} {I J : ℕ} (h : HasDGR A I J) (t : ℤ) : HasDGR (A.image (fun x => x + t)) I J := by rcases h with ⟨R, hsub, hcard, hgr, hdisj⟩ have hinj : Function.Injective (fun x : ℤ => x + t) := fun x y hxy => by dsimp at hxy; omega refine ⟨fun i => (R i).image (fun x => x + t), fun i => Finset.image_subset_image (hsub i), fun i => by rw [Finset.card_image_of_injective _ hinj, hcard i], fun i => isGolombRuler_translate (hgr i) t, ?_⟩ intro i j hij rw [Finset.disjoint_left] intro y hyi hyj rcases Finset.mem_image.mp hyi with ⟨x₁, hx₁, rfl⟩ rcases Finset.mem_image.mp hyj with ⟨x₂, hx₂, heq⟩ have hx : x₁ = x₂ := hinj heq.symm subst hx exact Finset.disjoint_left.mp (hdisj hij) hx₁ hx₂ theorem hasDGR_union_disjoint {A B : Finset ℤ} {I₁ I₂ J : ℕ} (hdisjAB : Disjoint A B) (hA : HasDGR A I₁ J) (hB : HasDGR B I₂ J) : HasDGR (A ∪ B) (I₁ + I₂) J := by rcases hA with ⟨R₁, hsub₁, hcard₁, hgr₁, hdisj₁⟩ rcases hB with ⟨R₂, hsub₂, hcard₂, hgr₂, hdisj₂⟩ let R : Fin (I₁ + I₂) → Finset ℤ := Fin.addCases R₁ R₂ refine ⟨R, ?_, ?_, ?_, ?_⟩ · intro i refine Fin.addCases ?_ ?_ i · intro i₁; simp only [R, Fin.addCases_left]; exact (hsub₁ i₁).trans Finset.subset_union_left · intro i₂; simp only [R, Fin.addCases_right]; exact (hsub₂ i₂).trans Finset.subset_union_right · intro i refine Fin.addCases ?_ ?_ i · intro i₁; simp only [R, Fin.addCases_left]; exact hcard₁ i₁ · intro i₂; simp only [R, Fin.addCases_right]; exact hcard₂ i₂ · intro i refine Fin.addCases ?_ ?_ i · intro i₁; simp only [R, Fin.addCases_left]; exact hgr₁ i₁ · intro i₂; simp only [R, Fin.addCases_right]; exact hgr₂ i₂ · intro i j hij refine Fin.addCases (motive := fun i => ∀ j, i ≠ j → Disjoint (R i) (R j)) ?_ ?_ i j hij · intro i₁ j refine Fin.addCases (motive := fun j => Fin.castAdd I₂ i₁ ≠ j → Disjoint (R (Fin.castAdd I₂ i₁)) (R j)) ?_ ?_ j · intro j₁ hne; simp only [R, Fin.addCases_left]; exact hdisj₁ (fun h => hne (congrArg _ h)) · intro j₂ _; simp only [R, Fin.addCases_left, Fin.addCases_right] exact hdisjAB.mono (hsub₁ i₁) (hsub₂ j₂) · intro i₂ j refine Fin.addCases (motive := fun j => Fin.natAdd I₁ i₂ ≠ j → Disjoint (R (Fin.natAdd I₁ i₂)) (R j)) ?_ ?_ j · intro j₁ _; simp only [R, Fin.addCases_left, Fin.addCases_right] exact hdisjAB.symm.mono (hsub₂ i₂) (hsub₁ j₁) · intro j₂ hne; simp only [R, Fin.addCases_right]; exact hdisj₂ (fun h => hne (congrArg _ h)) theorem hasDGR_card_lower {A : Finset ℤ} {I J : ℕ} (h : HasDGR A I J) : I * J ≤ A.card := by rcases h with ⟨R, hsub, hcard, _, hdisj⟩ have hbi : Finset.univ.biUnion R ⊆ A := by intro x hx rcases Finset.mem_biUnion.mp hx with ⟨i, _, hxi⟩ exact hsub i hxi have hle := Finset.card_le_card hbi rw [Finset.card_biUnion (fun i _ j _ hij => hdisj hij)] at hle simp only [hcard, Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul] at hle exact hle theorem isDGRInterval_add {I₁ I₂ J n₁ n₂ : ℕ} (h₁ : IsDGRInterval I₁ J n₁) (h₂ : IsDGRInterval I₂ J n₂) : IsDGRInterval (I₁ + I₂) J (n₁ + n₂) := by have h₂' := hasDGR_translate h₂ (n₁ : ℤ) have hdisj : Disjoint (Finset.Icc (1 : ℤ) (n₁ : ℤ)) ((Finset.Icc (1 : ℤ) (n₂ : ℤ)).image (fun x => x + (n₁ : ℤ))) := by rw [Finset.disjoint_left] intro x hx₁ hx₂ rw [Finset.mem_Icc] at hx₁ rcases Finset.mem_image.mp hx₂ with ⟨y, hy, rfl⟩ rw [Finset.mem_Icc] at hy; omega refine hasDGR_mono ?_ (hasDGR_union_disjoint hdisj h₁ h₂') intro x hx rw [Finset.mem_union] at hx rw [Finset.mem_Icc] rcases hx with hx | hx · rw [Finset.mem_Icc] at hx; omega · rcases Finset.mem_image.mp hx with ⟨y, hy, rfl⟩ rw [Finset.mem_Icc] at hy; omega theorem isHVal_sInf {I J n : ℕ} (h : IsHVal I J n) : sInf {m : ℕ | IsDGRInterval I J m} = n := by apply le_antisymm · exact Nat.sInf_le h.1 · exact le_csInf ⟨n, h.1⟩ (fun m hm => by by_contra hlt exact h.2 m (Nat.lt_of_not_ge hlt) hm) /-! ### Section 2: Explicit Constructive Witnesses for `I = 1, 2, 3, 4, 5` & Exact `H(I, 4) = 4 I` (`I ≥ 3`) -/ /-- Decidable check for a concrete tuple of `I` sorted 4-tuples in `{1, ..., n}`. -/ def isQuadG4 (a b c d : ℤ) : Prop := a < b ∧ b < c ∧ c < d ∧ b - a ≠ c - b ∧ b - a ≠ d - c ∧ c - b ≠ d - c ∧ b - a ≠ d - b ∧ c - a ≠ d - c instance (a b c d : ℤ) : Decidable (isQuadG4 a b c d) := by unfold isQuadG4; infer_instance private theorem isGolombRuler_of_isQuadG4 {a b c d : ℤ} (h : isQuadG4 a b c d) : IsGolombRuler ({a, b, c, d} : Finset ℤ) := (isGolombRuler_quad_iff h.1 h.2.1 h.2.2.1).mpr h.2.2.2 /-- Witness for `(I = 1, J = 4, n = 7)`: `{1, 2, 5, 7}`. -/ theorem isDGRInterval_1_4_7 : IsDGRInterval 1 4 7 := by refine ⟨![{1, 2, 5, 7}], ?_, ?_, ?_, ?_⟩ · intro i; fin_cases i; decide · intro i; fin_cases i; decide · intro i; fin_cases i; exact isGolombRuler_of_isQuadG4 (by decide) · intro i j hij; exact (hij (Subsingleton.elim i j)).elim /-- Witness for `(I = 2, J = 4, n = 9)`: `{1, 2, 6, 8}, {3, 4, 7, 9}`. -/ theorem isDGRInterval_2_4_9 : IsDGRInterval 2 4 9 := by refine ⟨![{1, 2, 6, 8}, {3, 4, 7, 9}], ?_, ?_, ?_, ?_⟩ · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> exact isGolombRuler_of_isQuadG4 (by decide) · intro i j hij; fin_cases i <;> fin_cases j <;> first | exact (hij rfl).elim | decide /-- Witness for `(I = 3, J = 4, n = 12)`: `{1, 2, 4, 8}, {3, 7, 10, 12}, {5, 6, 9, 11}`. -/ theorem isDGRInterval_3_4_12 : IsDGRInterval 3 4 12 := by refine ⟨![{1, 2, 4, 8}, {3, 7, 10, 12}, {5, 6, 9, 11}], ?_, ?_, ?_, ?_⟩ · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> exact isGolombRuler_of_isQuadG4 (by decide) · intro i j hij; fin_cases i <;> fin_cases j <;> first | exact (hij rfl).elim | decide /-- Witness for `(I = 4, J = 4, n = 16)`: `{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 11, 12, 14}, {9, 13, 15, 16}`. -/ theorem isDGRInterval_4_4_16 : IsDGRInterval 4 4 16 := by refine ⟨![{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 11, 12, 14}, {9, 13, 15, 16}], ?_, ?_, ?_, ?_⟩ · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> exact isGolombRuler_of_isQuadG4 (by decide) · intro i j hij; fin_cases i <;> fin_cases j <;> first | exact (hij rfl).elim | decide /-- Witness for `(I = 5, J = 4, n = 20)`: `{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 9, 12, 13}, {11, 15, 17, 18}, {14, 16, 19, 20}`. -/ theorem isDGRInterval_5_4_20 : IsDGRInterval 5 4 20 := by refine ⟨![{1, 2, 4, 8}, {3, 5, 6, 10}, {7, 9, 12, 13}, {11, 15, 17, 18}, {14, 16, 19, 20}], ?_, ?_, ?_, ?_⟩ · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> decide · intro i; fin_cases i <;> exact isGolombRuler_of_isQuadG4 (by decide) · intro i j hij; fin_cases i <;> fin_cases j <;> first | exact (hij rfl).elim | decide /-- Complete constructive existence of `(I, 4, 4 * I)`-DGR for **all** `I ≥ 3` by `I → I + 3` shift composition from the bases `{3, 4, 5}`. -/ theorem isDGRInterval_J4_ge_three : ∀ I : ℕ, 3 ≤ I → IsDGRInterval I 4 (4 * I) := by intro I induction I using Nat.strong_induction_on with | h I ih => intro hI by_cases h3 : I = 3 · subst h3; exact isDGRInterval_3_4_12 by_cases h4 : I = 4 · subst h4; exact isDGRInterval_4_4_16 by_cases h5 : I = 5 · subst h5; exact isDGRInterval_5_4_20 · have hsub : 3 ≤ I - 3 := by omega have hlt : I - 3 < I := by omega have h1 := ih (I - 3) hlt hsub have h2 := isDGRInterval_3_4_12 have hadd := isDGRInterval_add h1 h2 have heq1 : (I - 3) + 3 = I := by omega have heq2 : 4 * (I - 3) + 12 = 4 * I := by omega rwa [heq1, heq2] at hadd /-- Exact value `H(I, 4) = 4 * I` for **all** `I ≥ 3`. -/ theorem isHVal_J4_ge_three {I : ℕ} (hI : 3 ≤ I) : IsHVal I 4 (4 * I) := by refine ⟨isDGRInterval_J4_ge_three I hI, ?_⟩ intro m hm h have hlow := hasDGR_card_lower h have hcard : (Finset.Icc (1 : ℤ) (m : ℤ)).card = m := by rw [Int.card_Icc]; omega rw [hcard] at hlow omega theorem sInf_dgr_J4_ge_three {I : ℕ} (hI : 3 ≤ I) : sInf {n : ℕ | IsDGRInterval I 4 n} = 4 * I := isHVal_sInf (isHVal_J4_ge_three hI) /-! ### Section 3: Anchor-Exclusion Lemmas (at most 4 bad elements in `(y, z)` or `(x, y)`) -/ /-- **Right Anchor-Exclusion Lemma**: Given `x < y < z` with `y - x ≠ z - y`, any finite set `B ⊆ ℤ` contained in the open interval `(y, z)` contains **at most 4** elements `b ∈ B` for which `{x, y, b, z}` fails to be a `4`-Golomb ruler (specifically, every such `b` lies in `{2y - x, x + z - y, (x + z)/2, (y + z)/2}`). -/ theorem anchor_right_at_most_four {x y z : ℤ} (hxy : x < y) (_hyz : y < z) (hne : y - x ≠ z - y) (B : Finset ℤ) (hB : ∀ b ∈ B, y < b ∧ b < z) : (B.filter (fun b => ¬ isQuadG4 x y b z)).card ≤ 4 := by let E : Finset ℤ := {2 * y - x, x + z - y, (x + z) / 2, (y + z) / 2} have hsub : B.filter (fun b => ¬ isQuadG4 x y b z) ⊆ E := by intro b hb rcases Finset.mem_filter.mp hb with ⟨hbB, hnot⟩ rcases hB b hbB with ⟨hyb, hbz⟩ have hfail : y - x = b - y ∨ y - x = z - b ∨ b - y = z - b ∨ y - x = z - y ∨ b - x = z - b := by by_contra h; push Not at h exact hnot ⟨hxy, hyb, hbz, h⟩ simp only [E, Finset.mem_insert, Finset.mem_singleton] rcases hfail with h | h | h | h | h · left; omega · right; left; omega · right; right; right; omega · exact absurd h hne · right; right; left; omega have hEcard : E.card ≤ 4 := by calc E.card ≤ ({x + z - y, (x + z) / 2, (y + z) / 2} : Finset ℤ).card + 1 := Finset.card_insert_le _ _ _ ≤ ({(x + z) / 2, (y + z) / 2} : Finset ℤ).card + 1 + 1 := by gcongr; exact Finset.card_insert_le _ _ _ ≤ ({(y + z) / 2} : Finset ℤ).card + 1 + 1 + 1 := by gcongr; exact Finset.card_insert_le _ _ _ = 4 := by simp exact (Finset.card_le_card hsub).trans hEcard /-- **Left Anchor-Exclusion Lemma**: Given `x < y < z` with `y - x ≠ z - y`, any finite set `B ⊆ ℤ` contained in the open interval `(x, y)` contains **at most 4** elements `b ∈ B` for which `{x, b, y, z}` fails to be a `4`-Golomb ruler (specifically, every such `b` lies in `{2y - z, x + z - y, (x + z)/2, (x + y)/2}`). -/ theorem anchor_left_at_most_four {x y z : ℤ} (_hxy : x < y) (hyz : y < z) (hne : y - x ≠ z - y) (B : Finset ℤ) (hB : ∀ b ∈ B, x < b ∧ b < y) : (B.filter (fun b => ¬ isQuadG4 x b y z)).card ≤ 4 := by let E : Finset ℤ := {2 * y - z, x + z - y, (x + z) / 2, (x + y) / 2} have hsub : B.filter (fun b => ¬ isQuadG4 x b y z) ⊆ E := by intro b hb rcases Finset.mem_filter.mp hb with ⟨hbB, hnot⟩ rcases hB b hbB with ⟨hxb, hby⟩ have hfail : b - x = y - b ∨ b - x = z - y ∨ y - b = z - y ∨ b - x = z - b ∨ y - x = z - y := by by_contra h; push Not at h exact hnot ⟨hxb, hby, hyz, h⟩ simp only [E, Finset.mem_insert, Finset.mem_singleton] rcases hfail with h | h | h | h | h · right; right; right; omega · right; left; omega · left; omega · right; right; left; omega · exact absurd h hne have hEcard : E.card ≤ 4 := by calc E.card ≤ ({x + z - y, (x + z) / 2, (x + y) / 2} : Finset ℤ).card + 1 := Finset.card_insert_le _ _ _ ≤ ({(x + z) / 2, (x + y) / 2} : Finset ℤ).card + 1 + 1 := by gcongr; exact Finset.card_insert_le _ _ _ ≤ ({(x + y) / 2} : Finset ℤ).card + 1 + 1 + 1 := by gcongr; exact Finset.card_insert_le _ _ _ = 4 := by simp exact (Finset.card_le_card hsub).trans hEcard /-! ### Section 4: Inductive Peeling Reduction for All `I ≥ 3` -/ /-- **Inductive Peeling Theorem**: Once `I = 1` (`|A| = 7`) and `I = 3` (`|A| = 12`) are established, every subset `A ⊆ ℤ` with `|A| = 4 * I` (`I ≥ 3`) partitions into `I` pairwise disjoint `4`-Golomb rulers. -/ theorem dgr_J4_of_I1_and_I3 (hI1 : ∀ A : Finset ℤ, A.card = 7 → HasDGR A 1 4) (hI3 : ∀ A : Finset ℤ, A.card = 12 → HasDGR A 3 4) : ∀ I : ℕ, 3 ≤ I → ∀ A : Finset ℤ, A.card = 4 * I → HasDGR A I 4 := by intro I hI induction I with | zero => omega | succ k ih => intro A hcard by_cases hk : k = 2 · subst hk; exact hI3 A hcard · have hk3 : 3 ≤ k := by omega have hA7 : 7 ≤ A.card := by omega rcases Finset.exists_subset_card_eq hA7 with ⟨S, hSA, hScard⟩ rcases hI1 S hScard with ⟨R₁, hsub₁, hcard₁, hgr₁, _⟩ have hR₁A : R₁ 0 ⊆ A := (hsub₁ 0).trans hSA let B := A \ R₁ 0 have hBcard : B.card = 4 * k := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hR₁A, hcard, hcard₁ 0]; omega have hB : HasDGR B k 4 := ih hk3 B hBcard have hR₁_dgr : HasDGR (R₁ 0) 1 4 := ⟨R₁, fun i => by rw [Subsingleton.elim i 0], hcard₁, hgr₁, fun i j hij => (hij (Subsingleton.elim i j)).elim⟩ have hu := hasDGR_union_disjoint Finset.sdiff_disjoint hB hR₁_dgr refine hasDGR_mono ?_ hu intro x hx rw [Finset.mem_union] at hx rcases hx with hx | hx · exact (Finset.mem_sdiff.mp hx).1 · exact hR₁A hx #print axioms isDGRInterval_J4_ge_three #print axioms isHVal_J4_ge_three #print axioms anchor_right_at_most_four #print axioms anchor_left_at_most_four #print axioms dgr_J4_of_I1_and_I3 end DGRIntervalH4