From 218d8ec2c51210879ba85fa9e051a249c2284266 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 11:18:20 +0000 Subject: [PATCH 1/7] Import nearly quadratic split-graph clique partition gaps --- LeanPool/SplitCliqueGap.lean | 20 + .../SplitCliqueGap/GapExtremal/Bridge.lean | 600 ++++++++++++++++++ LeanPool/SplitCliqueGap/GapExtremal/Cap.lean | 101 +++ .../GapExtremal/Completion.lean | 283 +++++++++ LeanPool/SplitCliqueGap/GapExtremal/Core.lean | 230 +++++++ LeanPool/SplitCliqueGap/GapExtremal/Defs.lean | 63 ++ .../GapExtremal/ExactOrder.lean | 402 ++++++++++++ .../SplitCliqueGap/GapExtremal/Exponent.lean | 139 ++++ .../GapExtremal/ExponentTwo.lean | 157 +++++ .../SplitCliqueGap/GapExtremal/Geometry.lean | 87 +++ .../SplitCliqueGap/GapExtremal/Global.lean | 289 +++++++++ .../SplitCliqueGap/GapExtremal/Global2.lean | 326 ++++++++++ .../GapExtremal/GlobalLemmas.lean | 112 ++++ .../SplitCliqueGap/GapExtremal/Hosts.lean | 283 +++++++++ .../SplitCliqueGap/GapExtremal/Layered.lean | 178 ++++++ .../GapExtremal/LayeredExponent.lean | 124 ++++ .../GapExtremal/LocalEmbed.lean | 167 +++++ .../SplitCliqueGap/GapExtremal/LocalH12.lean | 118 ++++ LeanPool/SplitCliqueGap/GapExtremal/Main.lean | 80 +++ .../SplitCliqueGap/GapExtremal/PCore.lean | 256 ++++++++ .../SplitCliqueGap/GapExtremal/PHosts.lean | 250 ++++++++ .../SplitCliqueGap/GapExtremal/PMain.lean | 61 ++ .../SplitCliqueGap/GapExtremal/PSource.lean | 232 +++++++ .../SplitCliqueGap/GapExtremal/Residual.lean | 228 +++++++ LeanPool/SplitCliqueGap/GapExtremal/SCap.lean | 388 +++++++++++ .../SplitCliqueGap/GapExtremal/Single.lean | 120 ++++ .../SplitCliqueGap/GapExtremal/Source.lean | 274 ++++++++ .../SplitCliqueGap/GapExtremal/Sphere.lean | 240 +++++++ .../SplitCliqueGap/GapExtremal/WeightCap.lean | 181 ++++++ .../GraphBase/Clique/CliqueSets.lean | 75 +++ .../GraphBase/Clique/Partition.lean | 277 ++++++++ LeanPool/SplitCliqueGap/Imports.lean | 77 +++ .../R417/LogErrorAbsorption.lean | 97 +++ .../R417/OptimalCoefficient.lean | 79 +++ LeanPool/SplitCliqueGap/R434/AffineH54.lean | 191 ++++++ LeanPool/SplitCliqueGap/R434/CoreDefect.lean | 311 +++++++++ .../SplitCliqueGap/R434/CoreDirections.lean | 115 ++++ .../SplitCliqueGap/R434/CoreFractional.lean | 202 ++++++ .../SplitCliqueGap/R434/DensityThreshold.lean | 82 +++ LeanPool/SplitCliqueGap/R434/EHPSClasses.lean | 183 ++++++ .../R434/EHPSCompactExterior.lean | 105 +++ LeanPool/SplitCliqueGap/R434/EHPSDensity.lean | 289 +++++++++ LeanPool/SplitCliqueGap/R434/EHPSGrid.lean | 127 ++++ .../SplitCliqueGap/R434/EHPSHostTransfer.lean | 76 +++ .../SplitCliqueGap/R434/EHPSPotential.lean | 166 +++++ LeanPool/SplitCliqueGap/R434/EHPSProduct.lean | 123 ++++ LeanPool/SplitCliqueGap/R434/EHPSRegion.lean | 117 ++++ .../R434/ExactGraphTransfer.lean | 38 ++ LeanPool/SplitCliqueGap/R434/FiniteR434.lean | 200 ++++++ LeanPool/SplitCliqueGap/R434/GroupedGap.lean | 55 ++ .../SplitCliqueGap/R434/GroupedHosts.lean | 269 ++++++++ LeanPool/SplitCliqueGap/R434/LocalH54.lean | 170 +++++ .../SplitCliqueGap/R434/LocalPacking.lean | 148 +++++ .../R434/LocalTriangleLift.lean | 113 ++++ .../SplitCliqueGap/R434/MidpointHosts.lean | 133 ++++ .../SplitCliqueGap/R434/OddMidpoints.lean | 64 ++ .../SplitCliqueGap/R434/PackingTriangles.lean | 178 ++++++ .../SplitCliqueGap/R434/PartitionEnergy.lean | 80 +++ LeanPool/SplitCliqueGap/R434/PolylogGap.lean | 219 +++++++ .../SplitCliqueGap/R434/PolylogOrder.lean | 113 ++++ .../R434/ResidualArithmetic.lean | 69 ++ .../SplitCliqueGap/R434/ResidualIsolates.lean | 163 +++++ LeanPool/SplitCliqueGap/R434/RobustHosts.lean | 162 +++++ .../SplitCliqueGap/R434/RoleMatchings.lean | 44 ++ LeanPool/SplitCliqueGap/R434/TightPieces.lean | 102 +++ .../SplitCliqueGap/R434/TightTriangles.lean | 156 +++++ .../SplitCliqueGap/R434/TripartiteSlack.lean | 158 +++++ .../SplitCliqueGap/R434/UniformOrder.lean | 255 ++++++++ .../SplitCliqueGap/R434/UniversalHosts.lean | 145 +++++ .../SplitCliqueGap/R434/UniversalR434.lean | 85 +++ .../projects/split-clique-partition-gap.yaml | 41 ++ 71 files changed, 11841 insertions(+) create mode 100644 LeanPool/SplitCliqueGap.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Cap.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Completion.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Core.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Defs.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Geometry.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Global.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Global2.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Hosts.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Layered.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/LocalEmbed.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/LocalH12.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Main.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/PCore.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/PHosts.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/PMain.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/PSource.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Residual.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/SCap.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Single.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Source.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/WeightCap.lean create mode 100644 LeanPool/SplitCliqueGap/GraphBase/Clique/CliqueSets.lean create mode 100644 LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean create mode 100644 LeanPool/SplitCliqueGap/Imports.lean create mode 100644 LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean create mode 100644 LeanPool/SplitCliqueGap/R417/OptimalCoefficient.lean create mode 100644 LeanPool/SplitCliqueGap/R434/AffineH54.lean create mode 100644 LeanPool/SplitCliqueGap/R434/CoreDefect.lean create mode 100644 LeanPool/SplitCliqueGap/R434/CoreDirections.lean create mode 100644 LeanPool/SplitCliqueGap/R434/CoreFractional.lean create mode 100644 LeanPool/SplitCliqueGap/R434/DensityThreshold.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSClasses.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSCompactExterior.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSDensity.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSGrid.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSHostTransfer.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSPotential.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSProduct.lean create mode 100644 LeanPool/SplitCliqueGap/R434/EHPSRegion.lean create mode 100644 LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean create mode 100644 LeanPool/SplitCliqueGap/R434/FiniteR434.lean create mode 100644 LeanPool/SplitCliqueGap/R434/GroupedGap.lean create mode 100644 LeanPool/SplitCliqueGap/R434/GroupedHosts.lean create mode 100644 LeanPool/SplitCliqueGap/R434/LocalH54.lean create mode 100644 LeanPool/SplitCliqueGap/R434/LocalPacking.lean create mode 100644 LeanPool/SplitCliqueGap/R434/LocalTriangleLift.lean create mode 100644 LeanPool/SplitCliqueGap/R434/MidpointHosts.lean create mode 100644 LeanPool/SplitCliqueGap/R434/OddMidpoints.lean create mode 100644 LeanPool/SplitCliqueGap/R434/PackingTriangles.lean create mode 100644 LeanPool/SplitCliqueGap/R434/PartitionEnergy.lean create mode 100644 LeanPool/SplitCliqueGap/R434/PolylogGap.lean create mode 100644 LeanPool/SplitCliqueGap/R434/PolylogOrder.lean create mode 100644 LeanPool/SplitCliqueGap/R434/ResidualArithmetic.lean create mode 100644 LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean create mode 100644 LeanPool/SplitCliqueGap/R434/RobustHosts.lean create mode 100644 LeanPool/SplitCliqueGap/R434/RoleMatchings.lean create mode 100644 LeanPool/SplitCliqueGap/R434/TightPieces.lean create mode 100644 LeanPool/SplitCliqueGap/R434/TightTriangles.lean create mode 100644 LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean create mode 100644 LeanPool/SplitCliqueGap/R434/UniformOrder.lean create mode 100644 LeanPool/SplitCliqueGap/R434/UniversalHosts.lean create mode 100644 LeanPool/SplitCliqueGap/R434/UniversalR434.lean create mode 100644 LeanPool/projects/split-clique-partition-gap.yaml diff --git a/LeanPool/SplitCliqueGap.lean b/LeanPool/SplitCliqueGap.lean new file mode 100644 index 0000000000..43cd1d8458 --- /dev/null +++ b/LeanPool/SplitCliqueGap.lean @@ -0,0 +1,20 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +module + +public import LeanPool.SplitCliqueGap.R434.PolylogGap + +/-! +# Nearly quadratic additive gaps for edge-clique partitions of split graphs + +Source: doi:10.5281/zenodo.24408988, url:https://github.com/jtraverso/split-clique-partition-gap/tree/e96952eb38aaac532e5714be66a80535ebfd547a/preprints/SPLITGAP +Authors: Juan Pablo Traverso Gianini +Status: verified +Main declarations: `GapExtremal.R434.universal_R434_linear`, + `GapExtremal.R434.universal_R434_linear_mixed`, `GapExtremal.R434.universal_R434_polylog` +Tags: graph-theory, split-graphs, clique-partitions, combinatorial-optimization +MSC: 05C70, 05C35, 90C27 +-/ diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean new file mode 100644 index 0000000000..6c9223f570 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean @@ -0,0 +1,600 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Completion +public import LeanPool.SplitCliqueGap.GapExtremal.Global +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs +import Mathlib.Tactic.Tauto + +/-! +# The bridge `gap ≥ F - I` (ledger §8–§9, L9.1) + +A split graph `hostGraph N` has core `V` (a clique) and hosts `H` (independent), host `h` seeing +its palette +`N h`. Let `B` be a graph on the core. Under `HostHyp` (palettes independent in `B`; every non-`B` +pair +`{x, y}` assigned to a host `φ x y` whose palette contains it; assignments with a fixed endpoint +injective): + +* `gain_le` (integer side): every clique partition has gain `≤ I + 2 |J|` if all core packings have + residual value `≤ I`; +* `cpStar_le_of_source` (fractional side): a fractional residual packing of value `Fv` gives + `cp* ≤ E2 - (Fv + 2 |J|)`; +* `gap_ge`: hence `gap ≥ Fv - I`. + +Pairs are encoded as two-element `Finset`s. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] (B : SimpleGraph V) [DecidableRel B.Adj] +variable {H : Type*} [Fintype H] [DecidableEq H] + +/-! ### Pairs -/ + +/-- `B`-adjacent two-element subsets of `S`. -/ +def adjPairs (S : Finset V) : Finset (Finset V) := + (S.powersetCard 2).filter fun p => ∃ x ∈ p, ∃ y ∈ p, B.Adj x y + +/-- Non-adjacent two-element subsets of `S` (the marked pairs `J` inside `S`). -/ +def jPairs (S : Finset V) : Finset (Finset V) := + (S.powersetCard 2).filter fun p => ¬ ∃ x ∈ p, ∃ y ∈ p, B.Adj x y + +omit [DecidableEq V] [Fintype V] in +theorem card_adj_add_j (S : Finset V) : + (adjPairs B S).card + (jPairs B S).card = S.card.choose 2 := by + unfold adjPairs jPairs + rw [Finset.card_filter_add_card_filter_not, Finset.card_powersetCard] + +theorem e_eq_card_adjPairs (S : Finset V) : e B S = (adjPairs B S).card := by + unfold e adjPairs + refine Finset.card_bij (fun s _ => Sym2.lift ⟨fun u v => ({u, v} : Finset V), + fun u v => Finset.pair_comm u v⟩ s) ?_ ?_ ?_ + · intro s hs + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs + simp only [Sym2.lift_mk, Finset.mem_filter, Finset.mem_powersetCard] + refine ⟨⟨?_, Finset.card_pair hs.1.ne⟩, u, by simp, v, by simp, hs.1⟩ + intro x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl + exacts [hs.2.1, hs.2.2] + · intro s hs t ht hst + induction s using Sym2.ind with + | h a b => + induction t using Sym2.ind with + | h c d => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs ht + simp only [Sym2.lift_mk] at hst + have hab := hs.1.ne + have hcd := ht.1.ne + have hc : c ∈ ({a, b} : Finset V) := hst ▸ (by simp) + have hd : d ∈ ({a, b} : Finset V) := hst ▸ (by simp) + simp only [mem_insert, mem_singleton] at hc hd + rw [Sym2.eq_iff] + rcases hc with rfl | rfl <;> rcases hd with rfl | rfl + · exact absurd rfl hcd + · exact Or.inl ⟨rfl, rfl⟩ + · exact Or.inr ⟨rfl, rfl⟩ + · exact absurd rfl hcd + · intro p hp + simp only [Finset.mem_filter, Finset.mem_powersetCard] at hp + obtain ⟨⟨hpS, h2⟩, x, hx, y, hy, hxy⟩ := hp + refine ⟨s(x, y), ?_, ?_⟩ + · rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] + exact ⟨hxy, hpS hx, hpS hy⟩ + · simp only [Sym2.lift_mk] + exact Finset.eq_of_subset_of_card_le (fun z hz => by + simp only [mem_insert, mem_singleton] at hz + rcases hz with rfl | rfl <;> assumption) (by rw [h2, card_pair hxy.ne]) + +theorem w_add_two_j (S : Finset V) : + w B S + 2 * (jPairs B S).card = ((S.card.choose 2 : ℕ) : ℤ) - 1 := by + have h1 := card_adj_add_j B S + have h2 := e_eq_card_adjPairs B S + unfold w + rw [h2] + have : ((S.card.choose 2 : ℕ) : ℤ) = (adjPairs B S).card + (jPairs B S).card := by + rw [← h1]; push_cast; ring + rw [this]; ring + +theorem jPairs_eq_filter (S : Finset V) : jPairs B S = (jPairs B univ).filter (· ⊆ S) := by + ext p + simp only [jPairs, Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and] + tauto + +/-! ### The split graph with hosts -/ + +variable (N : H → Finset V) + +/-- The split graph: core `V` (clique), hosts `H` (independent), host `h` adjacent to `N h`. -/ +def hostGraph : SimpleGraph (V ⊕ H) where + Adj a b := + match a, b with + | .inl x, .inl y => x ≠ y + | .inl x, .inr h => x ∈ N h + | .inr h, .inl x => x ∈ N h + | .inr _, .inr _ => False + symm := ⟨fun a b h => by + rcases a with x | h <;> rcases b with y | h' <;> simp_all [eq_comm]⟩ + loopless := ⟨fun a h => by rcases a with x | h <;> simp_all⟩ + +instance : DecidableRel (hostGraph N).Adj := fun a b => + match a, b with + | .inl x, .inl y => inferInstanceAs (Decidable (x ≠ y)) + | .inl x, .inr h => inferInstanceAs (Decidable (x ∈ N h)) + | .inr h, .inl x => inferInstanceAs (Decidable (x ∈ N h)) + | .inr _, .inr _ => inferInstanceAs (Decidable False) + +omit [DecidableEq H] [DecidableEq V] [Fintype H] [Fintype V] in +@[simp] theorem hostGraph_inl_inl (x y : V) : (hostGraph N).Adj (.inl x) (.inl y) ↔ x ≠ y := Iff.rfl +omit [DecidableEq H] [DecidableEq V] [Fintype H] [Fintype V] in +@[simp] theorem hostGraph_inl_inr (x : V) (h : H) : (hostGraph N).Adj (.inl x) (.inr h) ↔ x ∈ N h := + Iff.rfl +omit [DecidableEq H] [DecidableEq V] [Fintype H] [Fintype V] in +@[simp] theorem hostGraph_inr_inl (x : V) (h : H) : (hostGraph N).Adj (.inr h) (.inl x) ↔ x ∈ N h := + Iff.rfl +omit [DecidableEq H] [DecidableEq V] [Fintype H] [Fintype V] in +@[simp] theorem hostGraph_inr_inr (h h' : H) : ¬ (hostGraph N).Adj (.inr h) (.inr h') := id + +/-- Hypotheses on palettes and on the assignment `φ` of marked pairs to hosts. -/ +structure HostHyp (φ : V → V → H) : Prop where + indep : ∀ h, ∀ x ∈ N h, ∀ y ∈ N h, ¬ B.Adj x y + cover : ∀ x y, x ≠ y → ¬ B.Adj x y → x ∈ N (φ x y) ∧ y ∈ N (φ x y) + symm : ∀ x y, φ x y = φ y x + inj : ∀ x y y', x ≠ y → ¬ B.Adj x y → x ≠ y' → ¬ B.Adj x y' → φ x y = φ x y' → y = y' + +variable {B N} + +omit [DecidableEq H] [DecidableEq V] [Fintype H] [Fintype V] in +/-- In a clique of `hostGraph`, at most one host. -/ +theorem card_toRight_le {Q : Finset (V ⊕ H)} (hQ : IsClq (hostGraph N) Q) : Q.toRight.card ≤ 1 := by + rw [Finset.card_le_one] + intro h hh h' hh' + by_contra hne + exact hostGraph_inr_inr N h h' (hQ.2 _ (Finset.mem_toRight.mp hh) _ (Finset.mem_toRight.mp hh') + (by simpa using hne)) + +omit [DecidableEq H] in +/-- **Integer side.** -/ +theorem cp_ge {φ : V → V → H} (hH : HostHyp B N φ) (I : ℤ) + (hI : ∀ T : Finset (Finset V), IsPack T → ∑ S ∈ T, w B S ≤ I) : + (E2 (hostGraph N) : ℤ) - I - 2 * (jPairs B univ).card ≤ (hostGraph N).cliquePartitionNumber := + by + classical + obtain ⟨P, hP, hcard⟩ := SimpleGraph.exists_isCliquePartition_card_eq (hostGraph N) + rw [← hcard, card_eq_of_partition _ hP] + -- pointwise bound on gains + have hpt : ∀ Q ∈ P, ((Q.card.choose 2 : ℕ) : ℤ) - 1 ≤ + (if Q.toRight = ∅ then w B Q.toLeft else 0) + 2 * (jPairs B Q.toLeft).card := by + intro Q hQ + have hsplit := Finset.card_toLeft_add_card_toRight (u := Q) + have hR := card_toRight_le (hP.isClq hQ) + split_ifs with hRe + · rw [hRe, Finset.card_empty, add_zero] at hsplit + rw [← hsplit, ← w_add_two_j B] + · obtain ⟨h, hh⟩ : ∃ h, h ∈ Q.toRight := Finset.nonempty_iff_ne_empty.mpr hRe + have hR1 : Q.toRight.card = 1 := le_antisymm hR (Finset.card_pos.mpr ⟨h, hh⟩) + have hpal : ∀ x ∈ Q.toLeft, x ∈ N h := fun x hx => + (hostGraph_inl_inr N x h).mp ((hP.isClq hQ).2 _ (Finset.mem_toLeft.mp hx) _ + (Finset.mem_toRight.mp hh) (by simp)) + have hadj0 : (adjPairs B Q.toLeft).card = 0 := by + rw [Finset.card_eq_zero, adjPairs, Finset.filter_eq_empty_iff] + rintro p hp ⟨x, hx, y, hy, hxy⟩ + have hp' := (Finset.mem_powersetCard.mp hp).1 + exact hH.indep h x (hpal x (hp' hx)) y (hpal y (hp' hy)) hxy + have hj := card_adj_add_j B Q.toLeft + rw [hadj0, zero_add] at hj + rw [hR1] at hsplit + rw [← hsplit, hj] + set s := Q.toLeft.card + have c1 := two_mul_choose_two_int (s + 1) + have c2 := two_mul_choose_two_int s + push_cast at c1 ⊢ + nlinarith [sq_nonneg ((s : ℤ) - 1), sq_nonneg ((s : ℤ) - 2)] + -- core pieces form a packing + set Pc := P.filter (fun Q => Q.toRight = ∅) with hPc + have hinjL : Set.InjOn (fun Q : Finset (V ⊕ H) => Q.toLeft) (Pc : Set _) := by + intro Q hQ Q' hQ' heq + have h1 := (Finset.mem_filter.mp hQ).2 + have h2 := (Finset.mem_filter.mp hQ').2 + rw [← Finset.toLeft_disjSum_toRight (u := Q), ← Finset.toLeft_disjSum_toRight (u := Q'), h1, h2] + simp only at heq + rw [heq] + -- two pieces sharing two core points coincide + have hshare : ∀ Q ∈ P, ∀ Q' ∈ P, ∀ a b : V, a ≠ b → a ∈ Q.toLeft → b ∈ Q.toLeft → + a ∈ Q'.toLeft → b ∈ Q'.toLeft → Q = Q' := by + intro Q hQ Q' hQ' a b hab ha hb ha' hb' + obtain ⟨R, -, hR⟩ := hP.existsUnique (.inl a) (.inl b) (by simpa using hab) + rw [hR Q ⟨hQ, Finset.mem_toLeft.mp ha, Finset.mem_toLeft.mp hb⟩, + hR Q' ⟨hQ', Finset.mem_toLeft.mp ha', Finset.mem_toLeft.mp hb'⟩] + have hpack : IsPack (Pc.image fun Q => Q.toLeft) := by + intro S hS S' hS' hne + obtain ⟨Q, hQ, rfl⟩ := Finset.mem_image.mp hS + obtain ⟨Q', hQ', rfl⟩ := Finset.mem_image.mp hS' + rw [Finset.card_le_one] + intro a ha b hb + by_contra hab + have ha' := Finset.mem_inter.mp ha + have hb' := Finset.mem_inter.mp hb + exact hne (by rw [hshare Q (Finset.mem_filter.mp hQ).1 Q' (Finset.mem_filter.mp hQ').1 a b hab + ha'.1 hb'.1 ha'.2 hb'.2]) + have hcore : ∑ Q ∈ P, (if Q.toRight = ∅ then w B Q.toLeft else 0) ≤ I := by + rw [← Finset.sum_filter, ← hPc, ← Finset.sum_image hinjL] + exact hI _ hpack + -- marked pairs are used at most once + have hJ : ∑ Q ∈ P, ((jPairs B Q.toLeft).card : ℤ) ≤ (jPairs B univ).card := by + have : ∑ Q ∈ P, (jPairs B Q.toLeft).card ≤ (jPairs B univ).card := by + rw [← Finset.card_sigma] + refine Finset.card_le_card_of_injOn (fun x => x.2) ?_ ?_ + · rintro ⟨Q, p⟩ hx + simp only [Finset.coe_sigma, Set.mem_sigma_iff, Finset.mem_coe] at hx + rw [jPairs_eq_filter B Q.toLeft] at hx + exact (Finset.mem_filter.mp hx.2).1 + · rintro ⟨Q, p⟩ hx ⟨Q', p'⟩ hx' (heq : p = p') + subst heq + simp only [Finset.coe_sigma, Set.mem_sigma_iff, Finset.mem_coe] at hx hx' + have hp := Finset.mem_powersetCard.mp (Finset.mem_filter.mp hx.2).1 + have hp' := Finset.mem_powersetCard.mp (Finset.mem_filter.mp hx'.2).1 + obtain ⟨a, b, hab, rfl⟩ := Finset.card_eq_two.mp hp.2 + have := hshare Q hx.1 Q' hx'.1 a b hab (hp.1 (by simp)) (hp.1 (by simp)) + (hp'.1 (by simp)) (hp'.1 (by simp)) + subst this + rfl + exact_mod_cast this + have hsum := Finset.sum_le_sum hpt + rw [Finset.sum_add_distrib, ← Finset.mul_sum] at hsum + linarith + +/-! ### Fractional side -/ + +/-- A fractional residual packing on the core (capacity 1 on every pair). -/ +structure ResPack (y : Finset V → ℝ) : Prop where + nonneg : ∀ S, 0 ≤ y S + two : ∀ S, y S ≠ 0 → 2 ≤ S.card + load : ∀ a b, a ≠ b → ∑ S, (if a ∈ S ∧ b ∈ S then y S else 0) ≤ 1 + +/-- Residual load on a set of core points. -/ +noncomputable def resLoad (y : Finset V → ℝ) (p : Finset V) : ℝ := ∑ S, if p ⊆ S then y S else 0 + +theorem resLoad_pair (y : Finset V → ℝ) (a b : V) : + resLoad y {a, b} = ∑ S, (if a ∈ S ∧ b ∈ S then y S else 0) := by + unfold resLoad + refine Finset.sum_congr rfl fun S _ => if_congr ?_ rfl rfl + constructor + · intro h; exact ⟨h (by simp), h (by simp)⟩ + · rintro ⟨ha, hb⟩ x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> assumption + +omit [DecidableEq V] in +theorem two_of_mem_jPairs {p : Finset V} (hp : p ∈ jPairs B univ) : p.card = 2 := + (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 + +omit [DecidableEq V] in +theorem nonadj_of_mem_jPairs {p : Finset V} (hp : p ∈ jPairs B univ) : + ∀ x ∈ p, ∀ y ∈ p, ¬ B.Adj x y := by + intro x hx y hy h + exact (Finset.mem_filter.mp hp).2 ⟨x, hx, y, hy, h⟩ + +variable (B) in +/-- Index type: core pieces of size `≥ 2`, and marked pairs. -/ +abbrev KIdx := {S : Finset V // 2 ≤ S.card} ⊕ {p : Finset V // p ∈ jPairs B univ} + +variable (B) in +/-- The two endpoints of a marked pair. -/ +noncomputable def ends (k : {p : Finset V // p ∈ jPairs B univ}) : V × V := + let h := Finset.card_eq_two.mp (two_of_mem_jPairs k.2) + (h.choose, h.choose_spec.choose) + +theorem ends_spec (k : {p : Finset V // p ∈ jPairs B univ}) : + (ends B k).1 ≠ (ends B k).2 ∧ k.1 = {(ends B k).1, (ends B k).2} := + (Finset.card_eq_two.mp (two_of_mem_jPairs k.2)).choose_spec.choose_spec + +variable (B) in +/-- The cliques of the fractional packing. -/ +noncomputable def cliqueOf (φ : V → V → H) : KIdx B → Finset (V ⊕ H) + | .inl S => S.1.disjSum ∅ + | .inr k => k.1.disjSum {φ (ends B k).1 (ends B k).2} + +variable (B) in +/-- The weights of the fractional packing. -/ +noncomputable def weightOf (y : Finset V → ℝ) : KIdx B → ℝ + | .inl S => y S.1 + | .inr k => 1 - resLoad y k.1 + +omit [DecidableEq H] [Fintype H] in +theorem host_of_ends {φ : V → V → H} (hH : HostHyp B N φ) (k : {p : Finset V // p ∈ jPairs B univ}) + {a : V} (ha : a ∈ k.1) : ∃ b, a ≠ b ∧ k.1 = {a, b} ∧ φ (ends B k).1 (ends B k).2 = φ a b := by + obtain ⟨hne, hk⟩ := ends_spec k + rw [hk] at ha + simp only [mem_insert, mem_singleton] at ha + rcases ha with rfl | rfl + · exact ⟨_, hne, hk, rfl⟩ + · exact ⟨_, hne.symm, by rw [hk, Finset.pair_comm], hH.symm _ _⟩ + + +theorem resLoad_nonneg {y : Finset V → ℝ} (hy : ResPack y) (p : Finset V) : 0 ≤ resLoad y p := + Finset.sum_nonneg fun S _ => by split_ifs <;> simp [hy.nonneg S] + +omit [Fintype H] in +theorem load_host {φ : V → V → H} (hH : HostHyp B N φ) {y : Finset V → ℝ} (hy : ResPack y) + (a : V) (h : H) : + loadQ (weightOf B y) (cliqueOf B φ) {Sum.inl a, Sum.inr h} ≤ 1 := by + classical + unfold loadQ + rw [Fintype.sum_sum_type] + have h1 : ∑ S : {S : Finset V // 2 ≤ S.card}, + (if ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inl S) + then weightOf B y (Sum.inl S) else 0) = 0 := by + refine Finset.sum_eq_zero fun S _ => ite_eq_right ?_ + intro hsub + have := hsub (by simp : (Sum.inr h : V ⊕ H) ∈ ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H))) + simp [cliqueOf] at this + rw [h1, zero_add] + set f := fun k : {p : Finset V // p ∈ jPairs B univ} => + (if ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inr k) + then weightOf B y (Sum.inr k) else 0) with hf + have hcond : ∀ k, ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inr k) → + a ∈ k.1 ∧ h = φ (ends B k).1 (ends B k).2 := by + intro k hsub + have ha := hsub (by simp : (Sum.inl a : V ⊕ H) ∈ ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H))) + have hh := hsub (by simp : (Sum.inr h : V ⊕ H) ∈ ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H))) + simp only [cliqueOf, Finset.inl_mem_disjSum, Finset.inr_mem_disjSum, Finset.mem_singleton] + at ha hh + exact ⟨ha, hh⟩ + by_cases hex : ∃ k0, ({Sum.inl a, Sum.inr h} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inr k0) + · obtain ⟨k0, hk0⟩ := hex + rw [Finset.sum_eq_single k0] + · rw [ite_eq_left hk0] + simp only [weightOf] + linarith [resLoad_nonneg hy k0.1] + · intro k _ hne + refine ite_eq_right fun hsub => hne ?_ + obtain ⟨ha, hh⟩ := hcond k hsub + obtain ⟨ha0, hh0⟩ := hcond k0 hk0 + obtain ⟨b, hab, hk, hφ⟩ := host_of_ends hH k ha + obtain ⟨b0, hab0, hk0', hφ0⟩ := host_of_ends hH k0 ha0 + have hn : ¬ B.Adj a b := nonadj_of_mem_jPairs k.2 a (by rw [hk]; simp) b (by rw [hk]; simp) + have hn0 : ¬ B.Adj a b0 := + nonadj_of_mem_jPairs k0.2 a (by rw [hk0']; simp) b0 (by rw [hk0']; simp) + have hbb : b = b0 := hH.inj a b b0 hab hn hab0 hn0 (by rw [← hφ, ← hφ0, ← hh, ← hh0]) + exact Subtype.ext (by rw [hk, hk0', hbb]) + · simp + · push Not at hex + rw [Finset.sum_eq_zero fun k _ => ite_eq_right (hex k)] + norm_num + +omit [Fintype H] in +theorem load_core {φ : V → V → H} {y : Finset V → ℝ} (hy : ResPack y) (a b : V) (hab : a ≠ b) : + loadQ (weightOf B y) (cliqueOf B φ) {Sum.inl a, Sum.inl b} ≤ 1 := by + classical + unfold loadQ + rw [Fintype.sum_sum_type] + have hsubS : ∀ S : Finset V, ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H)) ⊆ S.disjSum ∅ ↔ + a ∈ S ∧ b ∈ S := by + intro S + constructor + · intro h + have ha := h (by simp : (Sum.inl a : V ⊕ H) ∈ ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H))) + have hb := h (by simp : (Sum.inl b : V ⊕ H) ∈ ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H))) + rw [Finset.inl_mem_disjSum] at ha hb + exact ⟨ha, hb⟩ + · rintro ⟨ha, hb⟩ x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> rw [Finset.inl_mem_disjSum] <;> assumption + have hsubT : ∀ k : {p : Finset V // p ∈ jPairs B univ}, + ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inr k) ↔ k.1 = {a, b} := by + intro k + simp only [cliqueOf] + constructor + · intro h + have ha := h (by simp : (Sum.inl a : V ⊕ H) ∈ ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H))) + have hb := h (by simp : (Sum.inl b : V ⊕ H) ∈ ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H))) + rw [Finset.inl_mem_disjSum] at ha hb + symm + refine Finset.eq_of_subset_of_card_le (fun x hx => ?_) ?_ + · simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> assumption + · rw [two_of_mem_jPairs k.2, card_pair hab] + · intro hk x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> rw [Finset.inl_mem_disjSum, hk] <;> simp + -- first part is at most the residual load + have hp1 : ∑ S : {S : Finset V // 2 ≤ S.card}, + (if ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inl S) + then weightOf B y (Sum.inl S) else 0) ≤ resLoad y {a, b} := by + rw [resLoad_pair] + calc _ = ∑ S ∈ (univ.filter fun S : Finset V => 2 ≤ S.card), + (if a ∈ S ∧ b ∈ S then y S else 0) := by + rw [Finset.sum_subtype (univ.filter fun S : Finset V => 2 ≤ S.card) + (p := fun S : Finset V => 2 ≤ S.card) (fun S => by simp) + (fun S => if a ∈ S ∧ b ∈ S then y S else 0)] + refine Finset.sum_congr rfl fun S _ => ?_ + simp only [cliqueOf, weightOf] + exact if_congr (hsubS S.1) rfl rfl + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) + (fun S _ _ => by split_ifs <;> simp [hy.nonneg S]) + have hp2 : ∑ k : {p : Finset V // p ∈ jPairs B univ}, + (if ({Sum.inl a, Sum.inl b} : Finset (V ⊕ H)) ⊆ cliqueOf B φ (Sum.inr k) + then weightOf B y (Sum.inr k) else 0) = + if ({a, b} : Finset V) ∈ jPairs B univ then 1 - resLoad y {a, b} else 0 := by + rw [← Finset.sum_coe_sort (jPairs B univ) (fun p => if p = {a, b} then 1 - resLoad y p else 0) + |>.trans (Finset.sum_ite_eq' _ _ _)] + refine Finset.sum_congr rfl fun k _ => ?_ + simp only [weightOf] + exact if_congr (hsubT k) rfl rfl + rw [hp2] + have hl := hy.load a b hab + rw [← resLoad_pair] at hl + split_ifs <;> linarith + +/-- The fractional bridge, retaining the completion and its piece-size bound. -/ +theorem host_fractional_partition {φ : V → V → H} (hH : HostHyp B N φ) {y : Finset V → ℝ} + (hy : ResPack y) : + ∃ x, (hostGraph N).IsFracCliquePartition x ∧ + ((∀ S, y S ≠ 0 → S.card ≤ 3) → ∀ Q, x Q ≠ 0 → Q.card ≤ 3) ∧ + ∑ Q ∈ (hostGraph N).cliqueSets, x Q = + (E2 (hostGraph N) : ℝ) - (∑ S, y S * w B S + 2 * (jPairs B univ).card) := by + classical + have hres : ∀ p ∈ jPairs B univ, resLoad y p ≤ 1 := by + intro p hp + obtain ⟨a, b, hab, rfl⟩ := Finset.card_eq_two.mp (two_of_mem_jPairs hp) + rw [resLoad_pair]; exact hy.load a b hab + have hcl : ∀ k, IsClq (hostGraph N) (cliqueOf B φ k) := by + rintro (⟨S, hS⟩ | k) + · refine ⟨by simpa [cliqueOf, Finset.card_disjSum] using hS, ?_⟩ + intro u hu v hv huv + simp only [cliqueOf, Finset.mem_disjSum, Finset.notMem_empty] at hu hv + rcases u with x | h <;> rcases v with x' | h' <;> simp_all + · obtain ⟨hne, hk⟩ := ends_spec k + have h1 : (ends B k).1 ∈ k.1 := by rw [hk]; simp + have h2 : (ends B k).2 ∈ k.1 := by rw [hk]; simp + have hnadj := nonadj_of_mem_jPairs k.2 _ h1 _ h2 + have hcov := hH.cover _ _ hne hnadj + refine ⟨?_, ?_⟩ + · simp [cliqueOf, Finset.card_disjSum, two_of_mem_jPairs k.2] + · intro u hu v hv huv + simp only [cliqueOf] at hu hv + rcases u with x | h <;> rcases v with x' | h' + · simpa using huv + · rw [Finset.inl_mem_disjSum, hk] at hu + rw [Finset.inr_mem_disjSum, Finset.mem_singleton] at hv + rw [hostGraph_inl_inr, hv] + simp only [mem_insert, mem_singleton] at hu + rcases hu with rfl | rfl + exacts [hcov.1, hcov.2] + · rw [Finset.inl_mem_disjSum, hk] at hv + rw [Finset.inr_mem_disjSum, Finset.mem_singleton] at hu + rw [hostGraph_inr_inl, hu] + simp only [mem_insert, mem_singleton] at hv + rcases hv with rfl | rfl + exacts [hcov.1, hcov.2] + · rw [Finset.inr_mem_disjSum, Finset.mem_singleton] at hu hv + exact absurd (by rw [hu, hv]) huv + have hz : ∀ k, 0 ≤ weightOf B y k := by + rintro (S | k) + · exact hy.nonneg _ + · simp only [weightOf]; linarith [hres k.1 k.2] + -- loads + have hload : ∀ u v, (hostGraph N).Adj u v → loadQ (weightOf B y) (cliqueOf B φ) {u, v} ≤ 1 := by + rintro (a | h) (b | h') huv + · exact load_core hy a b (by simpa using huv) + · exact load_host hH hy a h' + · rw [Finset.pair_comm]; exact load_host hH hy b h + · exact absurd huv (hostGraph_inr_inr N h h') + have hval : ∑ k, weightOf B y k * ((((cliqueOf B φ k).card.choose 2 : ℕ) : ℝ) - 1) = + ∑ S, y S * w B S + 2 * (jPairs B univ).card := by + rw [Fintype.sum_sum_type] + have hA : ∑ S : {S : Finset V // 2 ≤ S.card}, weightOf B y (Sum.inl S) * + ((((cliqueOf B φ (Sum.inl S)).card.choose 2 : ℕ) : ℝ) - 1) = + ∑ S, y S * ((((S.card.choose 2 : ℕ) : ℝ)) - 1) := by + simp only [weightOf, cliqueOf, Finset.card_disjSum, Finset.card_empty, add_zero] + rw [← Finset.sum_subtype (univ.filter fun S : Finset V => 2 ≤ S.card) + (p := fun S : Finset V => 2 ≤ S.card) (fun S => by simp) + (fun S => y S * ((((S.card.choose 2 : ℕ) : ℝ)) - 1)), Finset.sum_filter] + refine Finset.sum_congr rfl fun S _ => ?_ + split_ifs with h + · rfl + · have : y S = 0 := by + by_contra h' + exact h (hy.two S h') + simp [this] + have hB : ∑ k : {p : Finset V // p ∈ jPairs B univ}, weightOf B y (Sum.inr k) * + ((((cliqueOf B φ (Sum.inr k)).card.choose 2 : ℕ) : ℝ) - 1) = + ∑ p ∈ jPairs B univ, 2 * (1 - resLoad y p) := by + rw [← Finset.sum_coe_sort (jPairs B univ)] + refine Finset.sum_congr rfl fun k _ => ?_ + simp only [weightOf, cliqueOf, Finset.card_disjSum, Finset.card_singleton, + two_of_mem_jPairs k.2] + norm_num + ring + have hw : ∀ S, y S * ((((S.card.choose 2 : ℕ) : ℝ)) - 1) = + y S * w B S + 2 * (y S * (jPairs B S).card) := by + intro S + have h1 := w_add_two_j B S + have h' : ((((S.card.choose 2 : ℕ) : ℝ)) - 1) = (w B S : ℝ) + 2 * (jPairs B S).card := by + exact_mod_cast h1.symm + rw [h'] + ring + have hdouble : ∑ S, y S * ((jPairs B S).card : ℝ) = ∑ p ∈ jPairs B univ, resLoad y p := by + unfold resLoad + rw [Finset.sum_comm] + refine Finset.sum_congr rfl fun S _ => ?_ + rw [jPairs_eq_filter B S, Finset.card_filter] + push_cast + rw [Finset.mul_sum] + refine Finset.sum_congr rfl fun p _ => ?_ + split_ifs <;> simp + rw [hA, hB, Finset.sum_congr rfl fun S _ => hw S, Finset.sum_add_distrib, ← Finset.mul_sum, + hdouble] + have h2 : ∑ p ∈ jPairs B univ, 2 * (1 - resLoad y p) = + 2 * (jPairs B univ).card - 2 * ∑ p ∈ jPairs B univ, resLoad y p := by + rw [← Finset.mul_sum, Finset.sum_sub_distrib] + simp only [Finset.sum_const, nsmul_eq_mul, mul_one] + ring + rw [h2] + ring + refine ⟨_, completion_isFrac hz hcl hload, ?_, ?_⟩ + · intro hsmall + apply completion_card_le (by decide) + rintro (S | p) hn + · simpa [cliqueOf] using hsmall S.1 hn + · simp [cliqueOf, Finset.card_disjSum, two_of_mem_jPairs p.2] + · rw [completion_sum hcl, hval] + +/-- **Fractional side.** -/ +theorem cpStar_le {φ : V → V → H} (hH : HostHyp B N φ) {y : Finset V → ℝ} (hy : ResPack y) : + (hostGraph N).fracCliquePartitionNumber ≤ + (E2 (hostGraph N) : ℝ) - (∑ S, y S * w B S + 2 * (jPairs B univ).card) := by + obtain ⟨x,hx,_,hval⟩ := host_fractional_partition hH hy + rw [← hval] + exact SimpleGraph.fracCliquePartitionNumber_le_sum_cliqueSets hx + +/-- **The bridge.** `gap ≥ Fv - I`. -/ +theorem gap_ge {φ : V → V → H} (hH : HostHyp B N φ) (I : ℤ) + (hI : ∀ T : Finset (Finset V), IsPack T → ∑ S ∈ T, w B S ≤ I) + {y : Finset V → ℝ} (hy : ResPack y) : + ∑ S, y S * w B S - I ≤ gap (hostGraph N) := by + have h1 := cp_ge hH I hI + have h2 := cpStar_le hH hy + have h1' : ((E2 (hostGraph N) : ℤ) : ℝ) - I - 2 * (jPairs B univ).card ≤ (hostGraph + N).cliquePartitionNumber := by + exact_mod_cast h1 + unfold gap + push_cast at h1' + linarith + +theorem gapWithFracFour_ge {φ : V → V → H} (hH : HostHyp B N φ) (I : ℤ) + (hI : ∀ T : Finset (Finset V), IsPack T → ∑ S ∈ T, w B S ≤ I) + {y : Finset V → ℝ} (hy : ResPack y) (hsmall : ∀ S, y S ≠ 0 → S.card ≤ 3) : + ∑ S, y S * w B S - I ≤ gapWithFracFour (hostGraph N) := by + classical + obtain ⟨x,hx,hcard,hval⟩ := host_fractional_partition hH hy + have hf := fracPartitionFour_le hx (fun Q hQ => (hcard hsmall Q hQ).trans (by decide : 3 ≤ 4)) + have hs : ∑ Q ∈ (hostGraph N).cliqueSets, x Q = ∑ Q, x Q := + sum_subset (subset_univ _) fun Q _ hQ => by + by_contra hn + exact hQ (SimpleGraph.mem_cliqueSets.mpr (hx.support Q hn)) + rw [← hs, hval] at hf + have hi : ((E2 (hostGraph N) : ℤ) : ℝ) - I - 2 * (jPairs B univ).card ≤ + (hostGraph N).cliquePartitionNumber := by exact_mod_cast cp_ge hH I hI + unfold gapWithFracFour + push_cast at hi + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Cap.lean b/LeanPool/SplitCliqueGap/GapExtremal/Cap.lean new file mode 100644 index 0000000000..19b910dc7b --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Cap.lean @@ -0,0 +1,101 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.LinearAlgebra.Pi +public import Mathlib.Algebra.Module.Prod + +/-! +# Caps and separable caps (ledger §2) + +* `IsCap A`: no three distinct collinear points of `A` (an affine cap). +* `IsSep A`: every point outside `A` lies on an affine hyperplane `{λ = b}` disjoint from `A`. +* `IsCap.prod`, `IsSep.prod` (ledger L2.1 for two factors) and the `Pi` versions `IsCap.pi`, +`IsSep.pi` + (the power `A^j`). +-/ + +@[expose] public section + +namespace GapExtremal + +variable {K : Type*} [Field K] + +section Defs + +variable {V : Type*} [AddCommGroup V] [Module K V] + +variable (K) in +/-- `A` is a cap: for distinct `P, R ∈ A` and `t ∉ {0, 1}`, the point `P + t • (R - P)` is not in +`A`. -/ +def IsCap (A : Set V) : Prop := + ∀ ⦃P⦄, P ∈ A → ∀ ⦃R⦄, R ∈ A → P ≠ R → ∀ t : K, t ≠ 0 → t ≠ 1 → P + t • (R - P) ∉ A + +variable (K) in +/-- `A` is separable: every point outside `A` is on an affine hyperplane disjoint from `A`. -/ +def IsSep (A : Set V) : Prop := + ∀ z ∉ A, ∃ (l : V →ₗ[K] K) (b : K), l z = b ∧ ∀ a ∈ A, l a ≠ b + +end Defs + +section Prod + +variable {V W : Type*} [AddCommGroup V] [Module K V] [AddCommGroup W] [Module K W] + +theorem IsCap.prod {A : Set V} {B : Set W} (hA : IsCap K A) (hB : IsCap K B) : + IsCap K (A ×ˢ B) := by + rintro ⟨p₁, p₂⟩ ⟨hp₁, hp₂⟩ ⟨r₁, r₂⟩ ⟨hr₁, hr₂⟩ hne t ht0 ht1 ⟨h₁, h₂⟩ + by_cases e₁ : p₁ = r₁ + · have e₂ : p₂ ≠ r₂ := fun e₂ => hne (by rw [e₁, e₂]) + exact hB hp₂ hr₂ e₂ t ht0 ht1 (by simpa using h₂) + · exact hA hp₁ hr₁ e₁ t ht0 ht1 (by simpa using h₁) + +theorem IsSep.prod {A : Set V} {B : Set W} (hA : IsSep K A) (hB : IsSep K B) : + IsSep K (A ×ˢ B) := by + rintro ⟨z₁, z₂⟩ hz + simp only [Set.mem_prod, not_and_or] at hz + rcases hz with hz | hz + · obtain ⟨l, b, hl, hlA⟩ := hA z₁ hz + refine ⟨l.comp (LinearMap.fst K V W), b, by simpa using hl, ?_⟩ + rintro ⟨a₁, a₂⟩ ⟨ha₁, -⟩ + simpa using hlA a₁ ha₁ + · obtain ⟨l, b, hl, hlB⟩ := hB z₂ hz + refine ⟨l.comp (LinearMap.snd K V W), b, by simpa using hl, ?_⟩ + rintro ⟨a₁, a₂⟩ ⟨-, ha₂⟩ + simpa using hlB a₂ ha₂ + +end Prod + +section Pi + +variable {ι : Type*} {V : Type*} [AddCommGroup V] [Module K V] + +theorem IsCap.pi {A : Set V} (hA : IsCap K A) : + IsCap K (Set.pi Set.univ (fun _ : ι => A)) := by + intro P hP R hR hne t ht0 ht1 hS + obtain ⟨i, hi⟩ : ∃ i, P i ≠ R i := by + by_contra h + push Not at h + exact hne (funext h) + exact hA (hP i (Set.mem_univ i)) (hR i (Set.mem_univ i)) hi t ht0 ht1 + (by simpa using hS i (Set.mem_univ i)) + +theorem IsSep.pi {A : Set V} (hA : IsSep K A) : + IsSep K (Set.pi Set.univ (fun _ : ι => A)) := by + intro z hz + obtain ⟨i, hi⟩ : ∃ i, z i ∉ A := by + by_contra h + push Not at h + exact hz (fun i _ => h i) + obtain ⟨l, b, hl, hlA⟩ := hA (z i) hi + refine ⟨l.comp (LinearMap.proj i), b, by simpa using hl, ?_⟩ + intro a ha + simpa using hlA (a i) (ha i (Set.mem_univ i)) + +end Pi + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Completion.lean b/LeanPool/SplitCliqueGap/GapExtremal/Completion.lean new file mode 100644 index 0000000000..ba973ae26f --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Completion.lean @@ -0,0 +1,283 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Defs +public import Mathlib.Algebra.BigOperators.Field +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.SplitIfs + +/-! +# Packings and completion by loose edges (ledger L1.1) + +For any graph `G`, with `E2 G` the number of edges (as 2-cliques): + +* `card_eq_of_partition`: a clique partition `P` has `|P| = E2 - ∑_{Q ∈ P} (C(|Q|,2) - 1)`; +* `cpStar_le_completion`: a fractional clique packing `z` (loads `≤ 1`) gives + `cp* ≤ E2 - ∑ z_k (C(|C_k|,2) - 1)`. + +Adapted from the B16 tournament development (`Framework.lean`: `completion`, `completion_isFrac`, +`completion_sum`), generalised from `graph m` to an arbitrary `SimpleGraph`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) + +open Classical in +/-- Number of edges, counted as two-element cliques. -/ +noncomputable def E2 : ℕ := ((G.cliqueSets).filter (fun Q => Q.card = 2)).card + +omit [Fintype V] in +theorem isClq_pair {u v : V} (h : G.Adj u v) : IsClq G {u, v} := by + refine ⟨by rw [card_pair h.ne], ?_⟩ + intro a ha b hb hab + simp only [mem_insert, mem_singleton] at ha hb + rcases ha with rfl | rfl <;> rcases hb with rfl | rfl + · exact absurd rfl hab + · exact h + · exact h.symm + · exact absurd rfl hab + +omit [DecidableEq V] in +theorem mem_cliques {Q : Finset V} : Q ∈ G.cliqueSets ↔ IsClq G Q := + mem_cliqueSets_iff_isClq + +omit [Fintype V] [DecidableEq V] in +/-- A two-element subset of a clique is a 2-clique. -/ +theorem isClq_of_sub {Q e : Finset V} (hQ : IsClq G Q) (he : e ⊆ Q) (h2 : e.card = 2) : + IsClq G e := ⟨h2.ge, fun u hu v hv huv => hQ.2 u (he hu) v (he hv) huv⟩ + +omit [Fintype V] in +theorem pair_of_card_two {e : Finset V} (h2 : e.card = 2) : ∃ u v, u ≠ v ∧ e = {u, v} := by + obtain ⟨u, v, huv, rfl⟩ := Finset.card_eq_two.mp h2 + exact ⟨u, v, huv, rfl⟩ + +omit [DecidableEq V] in +/-- In a clique partition, `∑ C(|Q|,2) = E2`. -/ +theorem sum_choose_of_partition {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : + ∑ Q ∈ P, Q.card.choose 2 = E2 G := by + classical + have hcount : ∀ Q ∈ P, Q.card.choose 2 = (Q.powersetCard 2).card := fun Q _ => + (Finset.card_powersetCard 2 Q).symm + rw [Finset.sum_congr rfl hcount, ← Finset.card_sigma] + unfold E2 + refine Finset.card_bij (fun x _ => x.2) ?_ ?_ ?_ + · rintro ⟨Q, e⟩ hx + simp only [Finset.mem_sigma, Finset.mem_powersetCard] at hx + rw [Finset.mem_filter, mem_cliques] + exact ⟨isClq_of_sub G (isClq_iff.mpr ⟨hP.two_le Q hx.1, hP.isClique Q hx.1⟩) hx.2.1 hx.2.2, + hx.2.2⟩ + · rintro ⟨Q, e⟩ hx ⟨Q', e'⟩ hx' (h : e = e') + subst h + simp only [Finset.mem_sigma, Finset.mem_powersetCard] at hx hx' + obtain ⟨u, v, huv, rfl⟩ := pair_of_card_two hx.2.2 + have hadj : G.Adj u v := hP.isClique Q hx.1 (hx.2.1 (by simp)) (hx.2.1 (by simp)) huv + obtain ⟨R, -, hR⟩ := hP.existsUnique u v hadj + have h1 := hR Q ⟨hx.1, hx.2.1 (by simp), hx.2.1 (by simp)⟩ + have h2 := hR Q' ⟨hx'.1, hx'.2.1 (by simp), hx'.2.1 (by simp)⟩ + rw [h1, h2] + · intro e he + rw [Finset.mem_filter, mem_cliques] at he + obtain ⟨u, v, huv, rfl⟩ := pair_of_card_two he.2 + have hadj : G.Adj u v := he.1.2 u (by simp) v (by simp) huv + obtain ⟨Q, ⟨hQ, hu, hv⟩, -⟩ := hP.existsUnique u v hadj + refine ⟨⟨Q, {u, v}⟩, ?_, rfl⟩ + simp only [Finset.mem_sigma, Finset.mem_powersetCard] + refine ⟨hQ, ?_, he.2⟩ + intro x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> assumption + +omit [DecidableEq V] in +/-- **Integer side of L1.1.** -/ +theorem card_eq_of_partition {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : + (P.card : ℤ) = E2 G - ∑ Q ∈ P, (((Q.card.choose 2 : ℕ) : ℤ) - 1) := by + classical + rw [Finset.sum_sub_distrib, ← Nat.cast_sum, sum_choose_of_partition G hP] + simp + +/-! ### Completion -/ + +variable {K : Type*} [Fintype K] (z : K → ℝ) (C : K → Finset V) + +/-- Load of a weighted clique family on a vertex set. -/ +noncomputable def loadQ (Q : Finset V) : ℝ := ∑ k, if Q ⊆ C k then z k else 0 + +open Classical in +/-- The packing plus a loose edge of mass `1 - load` on each edge. -/ +noncomputable def completion (Q : Finset V) : ℝ := + (∑ k, if Q = C k then z k else 0) + if IsClq G Q ∧ Q.card = 2 then 1 - loadQ z C Q else 0 + +variable {G z C} + +theorem completion_isFrac (hz : ∀ k, 0 ≤ z k) (hC : ∀ k, IsClq G (C k)) + (hload : ∀ u v, G.Adj u v → loadQ z C {u, v} ≤ 1) : + G.IsFracCliquePartition (completion G z C) := by + classical + refine SimpleGraph.IsFracCliquePartition.of_cliqueSets ?_ ?_ ?_ + · intro Q + unfold completion + apply add_nonneg + · exact Finset.sum_nonneg fun k _ => by split_ifs <;> simp [hz k] + · split_ifs with h + · obtain ⟨u, v, huv, rfl⟩ := pair_of_card_two h.2 + have := hload u v (h.1.2 u (by simp) v (by simp) huv) + linarith + · exact le_rfl + · intro Q hQ + rw [← isClq_iff] + unfold completion at hQ + by_contra hnot + apply hQ + have h1 : ∀ k, (if Q = C k then z k else 0) = 0 := by + intro k; split_ifs with h + · exact absurd (h ▸ hC k) hnot + · rfl + rw [Finset.sum_eq_zero (fun k _ => h1 k), zero_add, ite_eq_right (fun h => hnot h.1)] + · intro u v huv + unfold completion + rw [Finset.sum_add_distrib] + have h1 : ∑ Q ∈ (G.cliqueSets).filter (fun Q => u ∈ Q ∧ v ∈ Q), ∑ k, (if Q = C k then z k else + 0) = + loadQ z C {u, v} := by + rw [Finset.sum_comm] + unfold loadQ + refine Finset.sum_congr rfl fun k _ => ?_ + rw [Finset.sum_ite_eq'] + refine if_congr ?_ rfl rfl + rw [Finset.mem_filter, mem_cliques] + constructor + · rintro ⟨-, hu, hv⟩ x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl <;> assumption + · intro h + exact ⟨hC k, h (by simp), h (by simp)⟩ + have h2 : ∑ Q ∈ (G.cliqueSets).filter (fun Q => u ∈ Q ∧ v ∈ Q), + (if IsClq G Q ∧ Q.card = 2 then 1 - loadQ z C Q else 0) = 1 - loadQ z C {u, v} := by + rw [Finset.sum_eq_single_of_mem ({u, v} : Finset V)] + · rw [ite_eq_left ⟨isClq_pair G huv, card_pair huv.ne⟩] + · rw [Finset.mem_filter, mem_cliques] + exact ⟨isClq_pair G huv, by simp, by simp⟩ + · intro Q hQ hne + rw [ite_eq_right] + rintro ⟨-, h2⟩ + apply hne + rw [Finset.mem_filter] at hQ + symm + apply Finset.eq_of_subset_of_card_le + · intro x hx + simp only [mem_insert, mem_singleton] at hx + rcases hx with rfl | rfl + exacts [hQ.2.1, hQ.2.2] + · rw [h2, card_pair huv.ne] + rw [h1, h2] + ring + +theorem completion_sum (hC : ∀ k, IsClq G (C k)) : + ∑ Q ∈ G.cliqueSets, completion G z C Q = + (E2 G : ℝ) - ∑ k, z k * ((((C k).card.choose 2 : ℕ) : ℝ) - 1) := by + classical + unfold completion + rw [Finset.sum_add_distrib] + have h1 : ∑ Q ∈ G.cliqueSets, ∑ k, (if Q = C k then z k else 0) = ∑ k, z k := by + rw [Finset.sum_comm] + refine Finset.sum_congr rfl fun k _ => ?_ + rw [Finset.sum_ite_eq'] + rw [ite_eq_left ((mem_cliques G).mpr (hC k))] + have h2 : ∑ Q ∈ G.cliqueSets, (if IsClq G Q ∧ Q.card = 2 then 1 - loadQ z C Q else 0) = + ∑ Q ∈ (G.cliqueSets).filter (fun Q => Q.card = 2), (1 - loadQ z C Q) := by + rw [Finset.sum_filter] + refine Finset.sum_congr rfl fun Q hQ => ?_ + rw [mem_cliques] at hQ + simp [hQ] + have h3 : ∀ k, ∑ Q ∈ (G.cliqueSets).filter (fun Q => Q.card = 2), (if Q ⊆ C k then z k else 0) = + z k * (((C k).card.choose 2 : ℕ) : ℝ) := by + intro k + rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_comm] + congr 2 + rw [← Finset.card_powersetCard] + congr 1 + ext Q + simp only [Finset.mem_filter, mem_cliques, Finset.mem_powersetCard] + constructor + · rintro ⟨⟨-, h2⟩, hsub⟩; exact ⟨hsub, h2⟩ + · rintro ⟨hsub, h2⟩; exact ⟨⟨isClq_of_sub G (hC k) hsub h2, h2⟩, hsub⟩ + rw [h1, h2, Finset.sum_sub_distrib] + unfold loadQ + rw [Finset.sum_comm, Finset.sum_congr rfl fun k _ => h3 k] + simp only [Finset.sum_const, nsmul_eq_mul, mul_one, mul_sub, Finset.sum_sub_distrib] + unfold E2 + ring + +omit [Fintype V] in +/-- Completing a packing with edges preserves an upper bound on piece sizes. -/ +theorem completion_card_le {k : ℕ} (hk : 2 ≤ k) + (hsize : ∀ i, z i ≠ 0 → (C i).card ≤ k) + (Q : Finset V) (hq : completion G z C Q ≠ 0) : Q.card ≤ k := by + classical + by_contra! h + have hsum : ∑ i, (if Q = C i then z i else 0) = 0 := by + apply sum_eq_zero + intro i _ + split_ifs with hi + · by_contra hn + exact (not_le_of_gt h) (hi ▸ hsize i hn) + · rfl + have htwo : Q.card ≠ 2 := by omega + exact hq (by simp [completion, hsum, htwo]) + +/-- **Fractional side of L1.1.** -/ +theorem cpStar_le_completion (hz : ∀ k, 0 ≤ z k) (hC : ∀ k, IsClq G (C k)) + (hload : ∀ u v, G.Adj u v → loadQ z C {u, v} ≤ 1) : + G.fracCliquePartitionNumber ≤ (E2 G : ℝ) - ∑ k, z k * ((((C k).card.choose 2 : ℕ) : ℝ) - 1) := + by + rw [← completion_sum hC] + exact SimpleGraph.fracCliquePartitionNumber_le_sum_cliqueSets (completion_isFrac hz hC hload) + +section BoundedFractional + +variable {U : Type*} [Fintype U] [DecidableEq U] + +/-- Fractional clique partition cost with pieces of order at most four. -/ +noncomputable def fracPartitionFour (G : SimpleGraph U) : ℝ := + sInf {r | ∃ x, G.IsFracCliquePartition x ∧ (∀ Q, x Q ≠ 0 → Q.card ≤ 4) ∧ ∑ Q, x Q = r} + +theorem fracPartitionFour_le {G : SimpleGraph U} {x : Finset U → ℝ} + (hx : G.IsFracCliquePartition x) (hsmall : ∀ Q, x Q ≠ 0 → Q.card ≤ 4) : + fracPartitionFour G ≤ ∑ Q, x Q := + csInf_le ⟨0, by rintro _ ⟨y, hy, _, rfl⟩; exact sum_nonneg fun Q _ => hy.nonneg Q⟩ + ⟨x, hx, hsmall, rfl⟩ + +/-- The gap comparing unrestricted integral pieces to fractional pieces of order at most four. +Bounding this quantity from below also bounds the gap with both sides restricted. -/ +noncomputable def gapWithFracFour (G : SimpleGraph U) : ℝ := + (G.cliquePartitionNumber : ℝ) - fracPartitionFour G + +theorem gapWithFracFour_le_gap (G : SimpleGraph U) : gapWithFracFour G ≤ gap G := by + classical + have nonempty : {r | ∃ x : Finset U → ℝ, G.IsFracCliquePartition x ∧ + (∀ Q, x Q ≠ 0 → Q.card ≤ 4) ∧ ∑ Q, x Q = r}.Nonempty := by + let z : Fin 0 → ℝ := Fin.elim0 + let C : Fin 0 → Finset U := Fin.elim0 + have hx := completion_isFrac (G := G) (z := z) (C := C) (fun i => i.elim0) + (fun i => i.elim0) (fun _ _ _ => by simp [loadQ]) + exact ⟨_, _, hx, completion_card_le (by decide) (fun i => i.elim0), rfl⟩ + have h : G.fracCliquePartitionNumber ≤ fracPartitionFour G := + le_csInf nonempty (by rintro _ ⟨x, hx, _, rfl⟩; exact G.fracCliquePartitionNumber_le hx) + exact sub_le_sub_left h _ + +end BoundedFractional + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Core.lean b/LeanPool/SplitCliqueGap/GapExtremal/Core.lean new file mode 100644 index 0000000000..26dfcc16e8 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Core.lean @@ -0,0 +1,230 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Geometry +public import LeanPool.SplitCliqueGap.GapExtremal.LocalEmbed +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Abel + +/-! +# The core `F × W`, its blocks and the graph `B` (ledger §4–§5, §7) + +* `line x c`: the affine line through `x` with direction `u c = (1, c)`; +* `blocks C`: all lines with direction in `C`; +* `Bgr C σ`: `x ~ y` iff `y - x` has a direction of `C` and the colours `x.1, y.1` are an edge of +`H12` + (transported by `σ : Fin 6 ↪ F`). + +Main results: `blockHyp` (the hypotheses of `global_bound`, from CAP) and `I_le` (`I(B) ≤ 8 · +#blocks`). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] + +/-- The line through `x` with direction `u c`. -/ +def line (x : F × W) (c : W) : Finset (F × W) := univ.image fun t : F => x + t • u c + +omit [Fintype W] in +theorem mem_line {x y : F × W} {c : W} : y ∈ line x c ↔ ∃ t : F, y = x + t • u c := by + simp [line, eq_comm] + +omit [Fintype W] in +theorem self_mem_line (x : F × W) (c : W) : x ∈ line x c := mem_line.mpr ⟨0, by simp⟩ + +omit [Fintype W] in +theorem line_eq_of_mem {x y : F × W} {c : W} (h : y ∈ line x c) : line y c = line x c := by + obtain ⟨t, rfl⟩ := mem_line.mp h + ext z + simp only [mem_line] + constructor + · rintro ⟨s, rfl⟩; exact ⟨t + s, by rw [add_smul]; abel⟩ + · rintro ⟨s, rfl⟩; exact ⟨s - t, by rw [sub_smul]; abel⟩ + +omit [Fintype W] in +/-- Two points of one line differ by a multiple of its direction. -/ +theorem sub_of_mem_line {x p q : F × W} {c : W} (hp : p ∈ line x c) (hq : q ∈ line x c) : + q - p = (q.1 - p.1) • u c := by + obtain ⟨t, rfl⟩ := mem_line.mp hp + obtain ⟨s, rfl⟩ := mem_line.mp hq + ext + · simp [u] + · simp [u, sub_smul] + +omit [Fintype W] in +theorem fst_injOn_line (x : F × W) (c : W) : Set.InjOn Prod.fst (line x c : Set (F × W)) := by + intro p hp q hq h + have := sub_of_mem_line hp hq + rw [h, sub_self, zero_smul, sub_eq_zero] at this + exact this.symm + +variable (C : Finset W) (σ : Fin 6 ↪ F) + +/-- The blocks: lines with direction in `C`. -/ +def blocks : Finset (Finset (F × W)) := (univ ×ˢ C).image fun p => line p.1 p.2 + +/-- The graph `B`. -/ +def Bgr : SimpleGraph (F × W) where + Adj x y := x ≠ y ∧ (∃ c ∈ C, y - x = (y.1 - x.1) • u c) ∧ + ∃ i j, σ i = x.1 ∧ σ j = y.1 ∧ H12.graph.Adj i j + symm := ⟨fun x y ⟨hne, ⟨c, hc, h⟩, i, j, hi, hj, hij⟩ => + ⟨hne.symm, ⟨c, hc, by + have : x - y = -(y - x) := (neg_sub y x).symm + rw [this, h, ← neg_smul, neg_sub]⟩, j, i, hj, hi, hij.symm⟩⟩ + loopless := ⟨fun x h => h.1 rfl⟩ + +open Classical in +noncomputable instance : DecidableRel (Bgr C σ).Adj := Classical.decRel _ + +variable {C σ} + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem Bgr_fst_ne {x y : F × W} (h : (Bgr C σ).Adj x y) : x.1 ≠ y.1 := by + obtain ⟨-, -, i, j, hi, hj, hij⟩ := h + rw [← hi, ← hj] + exact fun h' => hij.ne (σ.injective h') + +omit [Fintype W] in +/-- Two distinct lines with directions in `C` share at most one point. -/ +theorem card_inter_line_le {x x' : F × W} {c c' : W} + (hne : line x c ≠ line x' c') : (line x c ∩ line x' c').card ≤ 1 := by + rw [Finset.card_le_one] + intro p hp q hq + by_contra hpq + obtain ⟨hp1, hp2⟩ := Finset.mem_inter.mp hp + obtain ⟨hq1, hq2⟩ := Finset.mem_inter.mp hq + have h1 := sub_of_mem_line hp1 hq1 + have h2 := sub_of_mem_line hp2 hq2 + have hne1 : q.1 - p.1 ≠ 0 := by + intro h0 + rw [h0, zero_smul, sub_eq_zero] at h1 + exact hpq h1.symm + obtain ⟨-, hcc⟩ := par_eq (h1.symm.trans h2) + have hcc := hcc hne1 + subst hcc + apply hne + rw [← line_eq_of_mem hp1, ← line_eq_of_mem hp2] + +theorem mem_blocks_of {x : F × W} {c : W} (hc : c ∈ C) : line x c ∈ blocks C := + Finset.mem_image.mpr ⟨(x, c), by simp [hc], rfl⟩ + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem snd_eq_of_sub {x y : F × W} {c : W} (h : y - x = (y.1 - x.1) • u c) : + y.2 - x.2 = (y.1 - x.1) • c := by + simpa [u] using congrArg Prod.snd h + +omit [Fintype W] in +theorem mem_line_of_sub {x y : F × W} {c : W} (h : y - x = (y.1 - x.1) • u c) : y ∈ line x c := + mem_line.mpr ⟨y.1 - x.1, by rw [← h]; abel⟩ + +variable (hC : IsCap F (C : Set W)) +include hC + +/-- **L5.1.** Every triangle of `B` lies in a block. -/ +theorem blocks_tri (x y z : F × W) (hxy : (Bgr C σ).Adj x y) (hyz : (Bgr C σ).Adj y z) + (hxz : (Bgr C σ).Adj x z) : ∃ ℓ ∈ blocks C, x ∈ ℓ ∧ y ∈ ℓ ∧ z ∈ ℓ := by + obtain ⟨a, ha, h1⟩ := hxy.2.1 + obtain ⟨b, hb, h2⟩ := hyz.2.1 + obtain ⟨c, hc, h3⟩ := hxz.2.1 + have hα : y.1 - x.1 ≠ 0 := sub_ne_zero.mpr (Bgr_fst_ne hxy).symm + by_cases hab : a = b + · subst hab + refine ⟨line x a, mem_blocks_of ha, self_mem_line x a, mem_line_of_sub h1, ?_⟩ + refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ + rw [add_smul, ← h1, ← h2]; abel + by_cases hac : a = c + · subst hac + exact ⟨line x a, mem_blocks_of ha, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ + by_cases hbc : b = c + · subst hbc + refine ⟨line z b, mem_blocks_of hb, ?_, ?_, self_mem_line z b⟩ + · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ + rw [neg_smul, ← h3]; abel + · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ + rw [neg_smul, ← h2]; abel + exfalso + have e1 := snd_eq_of_sub h1 + have e2 := snd_eq_of_sub h2 + have e3 := snd_eq_of_sub h3 + have := dep_zero hC ha hb hc hab hac hbc (α := y.1 - x.1) (β := z.1 - y.1) (γ := -(z.1 - x.1)) + (by ring) (by rw [← e1, ← e2, neg_smul, ← e3]; abel) + exact hα this.1 + +/-- **L5.2.** A point outside a block has at most one `B`-neighbour in it. -/ +theorem blocks_one (ℓ : Finset (F × W)) (hℓ : ℓ ∈ blocks C) (z : F × W) (hz : z ∉ ℓ) + (y : F × W) (hy : y ∈ ℓ) (y' : F × W) (hy' : y' ∈ ℓ) (h : (Bgr C σ).Adj z y) + (h' : (Bgr C σ).Adj z y') : y = y' := by + obtain ⟨⟨x0, c0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).2 + simp only at hy hy' hz + by_contra hne + have hyy := sub_of_mem_line hy hy' + have hγ : y'.1 - y.1 ≠ 0 := fun h0 => + hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) + obtain ⟨d, hd, hzy⟩ := h.2.1 + obtain ⟨e', he, hzy'⟩ := h'.2.1 + by_cases hdc : d = c0 + · subst hdc + apply hz + rw [← line_eq_of_mem hy] + refine mem_line.mpr ⟨-(y.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy]; abel + by_cases hec : e' = c0 + · subst hec + apply hz + rw [← line_eq_of_mem hy'] + refine mem_line.mpr ⟨-(y'.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy']; abel + by_cases hde : d = e' + · subst hde + have : (y'.1 - y.1) • (u d : F × W) = (y'.1 - y.1) • u c0 := by + rw [← hyy] + have : y' - y = (y' - z) - (y - z) := by abel + rw [this, hzy, hzy', ← sub_smul] + congr 1; ring + exact hdc ((par_eq this).2 hγ) + have e1 := snd_eq_of_sub hzy + have e2 := snd_eq_of_sub hzy' + have e3 := snd_eq_of_sub hyy + have := dep_zero hC he hd hc0 (Ne.symm hde) hec hdc (α := y'.1 - z.1) (β := -(y.1 - z.1)) + (γ := -(y'.1 - y.1)) (by ring) (by rw [← e2, neg_smul, ← e1, neg_smul, ← e3]; abel) + exact Bgr_fst_ne h' (sub_eq_zero.mp this.1).symm + +/-- The block hypotheses hold for the selected lines of a cap. -/ +theorem blockHyp : BlockHyp (Bgr C σ) (blocks C) where + inter := by + intro ℓ hℓ ℓ' hℓ' hne + obtain ⟨⟨x, c⟩, -, rfl⟩ := Finset.mem_image.mp hℓ + obtain ⟨⟨x', c'⟩, -, rfl⟩ := Finset.mem_image.mp hℓ' + exact card_inter_line_le hne + edge := by + intro x y h + obtain ⟨c, hc, hxy⟩ := h.2.1 + exact ⟨line x c, mem_blocks_of hc, self_mem_line x c, mem_line_of_sub hxy⟩ + tri := blocks_tri hC + one := blocks_one hC + +/-- **`I(B) ≤ 8 τ`** on the concrete core. -/ +theorem I_le {T : Finset (Finset (F × W))} (hT : IsPack T) : + ∑ Q ∈ T, w (Bgr C σ) Q ≤ 8 * (blocks (F := F) C).card := by + refine global_bound (blockHyp hC) 8 ?_ hT + intro ℓ hℓ T' hT'sub hT' + obtain ⟨⟨x, c⟩, -, rfl⟩ := Finset.mem_image.mp hℓ + have := block_local (B := Bgr C σ) Prod.fst σ (fst_injOn_line x c) + (fun u _ v _ huv => by + obtain ⟨-, -, i, j, hi, hj, hij⟩ := huv + exact ⟨i, j, hi, hj, hij⟩) T' hT'sub hT' + simpa using this + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Defs.lean b/LeanPool/SplitCliqueGap/GapExtremal/Defs.lean new file mode 100644 index 0000000000..d4a0bd858c --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Defs.lean @@ -0,0 +1,63 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GraphBase.Clique.CliqueSets + +/-! +# The integrality gap (ledger §0.1) + +Clique partitions, `cp`, fractional clique partitions and `cp*` are GraphBase's +(`SimpleGraph.IsCliquePartition`, `cliquePartitionNumber`, `IsFracCliquePartition`, +`fracCliquePartitionNumber`, +`cliqueSets`). Migrated 2026-11-18; until then this file had its own copies (from the B16 "PAIR" +development). + +* `gap G = cp G − cp* G`, the object of the paper; +* `IsClq G Q`: a convenience form of `Q ∈ G.cliqueSets` (`mem_cliqueSets_iff_isClq`), whose second +component + takes its arguments explicitly. +-/ + +@[expose] public section + +open Finset + +namespace GapExtremal + +section General + +variable {V : Type*} [Fintype V] [DecidableEq V] + +/-- `Q` has at least two vertices, all pairwise adjacent. Equivalent to `Q ∈ G.cliqueSets`. -/ +def IsClq (G : SimpleGraph V) (Q : Finset V) : Prop := + 2 ≤ Q.card ∧ ∀ u ∈ Q, ∀ v ∈ Q, u ≠ v → G.Adj u v + +omit [Fintype V] [DecidableEq V] in +theorem isClq_iff {G : SimpleGraph V} {Q : Finset V} : IsClq G Q ↔ 2 ≤ Q.card ∧ G.IsClique (Q : + Set V) := + ⟨fun h => ⟨h.1, fun u hu v hv huv => h.2 u hu v hv huv⟩, + fun h => ⟨h.1, fun _ hu _ hv huv => h.2 hu hv huv⟩⟩ + +omit [DecidableEq V] in +theorem mem_cliqueSets_iff_isClq {G : SimpleGraph V} {Q : Finset V} : Q ∈ G.cliqueSets ↔ IsClq G Q + := + SimpleGraph.mem_cliqueSets.trans isClq_iff.symm + +omit [Fintype V] [DecidableEq V] in +/-- The members of a GraphBase clique partition satisfy `IsClq`. -/ +theorem _root_.SimpleGraph.IsCliquePartition.isClq {G : SimpleGraph V} {P : Finset (Finset V)} + (hP : G.IsCliquePartition P) {Q : Finset V} (hQ : Q ∈ P) : IsClq G Q := + isClq_iff.mpr ⟨hP.two_le Q hQ, hP.isClique Q hQ⟩ + +/-- The integrality gap `D G = cp G − cp* G`. -/ +noncomputable def gap (G : SimpleGraph V) : ℝ := + (G.cliquePartitionNumber : ℝ) - G.fracCliquePartitionNumber + +end General + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean new file mode 100644 index 0000000000..c7a41f3dd9 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean @@ -0,0 +1,402 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.ExponentTwo +public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected +import Mathlib.Tactic.Choose +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! +# Exact order and connectivity (ledger L1.2) + +Hosts whose palette is a single core vertex are pendant leaves. Padding a host family (`padN`): +* gives every empty palette the vertex `x₀`; +* adds `k` new hosts with palette `{x₀}`. + +The bridge hypotheses `HostHyp` survive (`HostHyp.pad`), so the lower bound of `gap_ge` is +unchanged. The graph +stays split, becomes connected (`connected_hostGraph`), and its order grows by exactly `k`. With +`exponent_of_family_exact` this gives the final statements for split **connected** graphs of order +**exactly** +`n`: +* `tp_single_s_exact`; +* **`exponent_two_exact`**. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-! ### Padding a host family -/ + +section Pad + +variable {V : Type*} [Fintype V] [DecidableEq V] {H : Type*} [Fintype H] [DecidableEq H] + +/-- Padded palettes: empty palettes become `{x₀}`, and `k` new hosts with palette `{x₀}`. -/ +def padN (N : H → Finset V) (x0 : V) (k : ℕ) : H ⊕ Fin k → Finset V + | .inl h => if N h = ∅ then {x0} else N h + | .inr _ => {x0} + +omit [DecidableEq H] [Fintype H] [Fintype V] in +theorem padN_nonempty (N : H → Finset V) (x0 : V) (k : ℕ) (h : H ⊕ Fin k) : (padN N x0 k + h).Nonempty := by + rcases h with h | i + · simp only [padN] + split_ifs with h0 + · exact Finset.singleton_nonempty _ + · exact Finset.nonempty_iff_ne_empty.mpr h0 + · exact Finset.singleton_nonempty _ + +omit [DecidableEq H] [Fintype H] [Fintype V] in +theorem HostHyp.pad {B : SimpleGraph V} {N : H → Finset V} {φ : V → V → H} + (hH : HostHyp B N φ) (x0 : V) (k : ℕ) : + HostHyp B (padN N x0 k) (fun x y => Sum.inl (φ x y)) where + indep := by + rintro (h | i) x hx y hy hxy + · simp only [padN] at hx hy + split_ifs at hx hy with h0 + · rw [Finset.mem_singleton] at hx hy + subst hx; subst hy + exact B.loopless.irrefl _ hxy + · exact hH.indep h x hx y hy hxy + · simp only [padN, Finset.mem_singleton] at hx hy + subst hx; subst hy + exact B.loopless.irrefl _ hxy + cover := by + intro x y hne hadj + obtain ⟨hx, hy⟩ := hH.cover x y hne hadj + have h0 : N (φ x y) ≠ ∅ := Finset.ne_empty_of_mem hx + simp only [padN, ite_eq_right h0] + exact ⟨hx, hy⟩ + symm := fun x y => by rw [hH.symm x y] + inj := fun x y y' h1 h2 h3 h4 h => hH.inj x y y' h1 h2 h3 h4 (Sum.inl_injective h) + +omit [DecidableEq H] [DecidableEq V] in +theorem card_pad (k : ℕ) : + Fintype.card (V ⊕ (H ⊕ Fin k)) = Fintype.card (V ⊕ H) + k := by + simp only [Fintype.card_sum, Fintype.card_fin] + ring + +omit [DecidableEq V] [Fintype V] in +/-- A host graph with a nonempty core and nonempty palettes is connected. -/ +theorem connected_hostGraph {H' : Type*} (N : H' → Finset V) (x0 : V) + (hN : ∀ h, (N h).Nonempty) : + (hostGraph N).Connected := by + rw [SimpleGraph.connected_iff_exists_forall_reachable] + have hcore : ∀ y : V, (hostGraph N).Reachable (.inl x0) (.inl y) := fun y => by + by_cases hy : x0 = y + · rw [hy] + · exact SimpleGraph.Adj.reachable ((hostGraph_inl_inl N _ _).mpr hy) + refine ⟨.inl x0, ?_⟩ + rintro (y | h) + · exact hcore y + · obtain ⟨y, hy⟩ := hN h + exact (hcore y).trans (SimpleGraph.Adj.reachable ((hostGraph_inl_inr N _ _).mpr hy)) + +end Pad + +/-! ### From a padded family to every order -/ + +/-- **From a padded family to all orders exactly.** -/ +theorem exponent_of_family_exact {M a K : ℕ} (hM : 2 ≤ M) (ha : 1 ≤ a) (hK : 0 < K) + (V : ℕ → ℕ → Type) [∀ j k, Fintype (V j k)] [∀ j k, DecidableEq (V j k)] + (G : ∀ j k, SimpleGraph (V j k)) (b : ℕ → ℕ) (hb : ∀ j, b j ≤ K * M ^ j) + (hcard : ∀ j k, Fintype.card (V j k) = b j + k) (hsplit : ∀ j k, IsSplit (G j k)) + (hconn : ∀ j k, (G j k).Connected) + (hgap : ∀ j k, (a : ℝ) ^ j * (M : ℝ) ^ j / 3 ≤ gap (G j k)) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, K * M ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' = n ∧ IsSplit G' ∧ G'.Connected ∧ + c * (n : ℝ) ^ (1 + Real.log a / Real.log M) ≤ gap G' := by + set α := 1 + Real.log a / Real.log M + have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) + have hα : 0 ≤ α := by + have h1 : 0 ≤ Real.log a := Real.log_nonneg (by exact_mod_cast ha) + have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) + positivity + refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ + set j := Nat.log M (n / K) with hj + have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by + have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by + have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) + omega) + have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ + have hbn : b j ≤ n := by + calc b j ≤ K * M ^ j := hb j + _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj + _ ≤ n := Nat.mul_div_le n K + refine ⟨V j (n - b j), inferInstance, inferInstance, G j (n - b j), ?_, hsplit _ _, hconn _ _, ?_⟩ + · rw [hcard]; omega + · have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by + have h1 : n < K * (n / K) + K := by + have := Nat.div_add_mod n K + have := Nat.mod_lt n hK + omega + have h2 : n < K * M ^ (j + 1) := by + calc n < K * (n / K) + K := h1 + _ = K * (n / K + 1) := by ring + _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt + rw [div_le_iff₀ (by positivity)] + have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 + rw [pow_succ] at this + nlinarith + have hpow := pow_rpow_alpha ha hM j + have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := + Real.rpow_le_rpow (by positivity) hn' hα + have hsplit' : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by + rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] + ring + refine le_trans ?_ (hgap j _) + calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by + rw [hsplit']; ring + _ ≤ ((M : ℝ) ^ j) ^ α / 3 := by linarith + _ = (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + +/-! ### The padded positioned construction -/ + +section PPad + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] +variable {V P : Type*} [Fintype V] [DecidableEq V] [Fintype P] [DecidableEq P] +variable {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +instance instDecEqPadIdx (k : ℕ) : DecidableEq (PHostIdx F W P U ⊕ Fin k) := + @instDecidableEqSum _ _ instDecEqPHostIdx inferInstance + +instance instDecEqSumPadIdx (k : ℕ) : DecidableEq (V ⊕ (PHostIdx F W P U ⊕ Fin k)) := + @instDecidableEqSum _ _ inferInstance (instDecEqPadIdx k) + +/-- **Cor. 16.4, padded.** -/ +theorem pgap_ge_third_pad (D : PData F W V P) {C : Finset W} (hC : IsSCap (actCol D) (C : Set W)) + (hC0 : C.Nonempty) (S : SepFam F C U) + (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → + ¬ H12.graph.Adj i j) (x0 : V) (k : ℕ) : + ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (padN (ppalette D C S) x0 k)) := by + have h := gap_ge ((phostHyp (S := S) hC0 hsame).pad x0 k) (8 * (pblocks D C).card) + (fun T hT => pI_le_s D hC hT) (presPack (D := D) (C := C)) + have hv := pvalue (D := D) (C := C) + have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by + exact_mod_cast card_pblocks_le D + push_cast at h ⊢ + linarith + +end PPad + +/-! ### Exact-order transfer for S-caps -/ + +section Single + +variable {F : Type} [Field F] [Fintype F] [DecidableEq F] +variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +/-- The padded one-layer graph of `A^j`. -/ +abbrev SVk (F U : Type) (j k : ℕ) := + (F × (Fin j → U)) ⊕ (PHostIdx F (Fin j → U) F U ⊕ Fin k) + +omit [DecidableEq F] [Field F] [AddCommGroup U] [Module F U] [DecidableEq U] in +theorem card_SV_le [Nonempty U] (j : ℕ) : + Fintype.card (SV F U j) ≤ 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ^ j + := by + set M := Fintype.card U + set q := Fintype.card F + have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) + rw [hc] + simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, + Fintype.card_fin, Sym2.card] + set X := M ^ j + set C2 := (q + 1).choose 2 with hC2 + have hsym : C2 ≤ (q + 1) ^ 2 := by + rw [hC2, Nat.choose_two_right, sq] + exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) + have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 + have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by + calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym + _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) + _ = (q + 1) ^ 4 := by ring + have f3 : q * C2 ≤ (q + 1) ^ 4 := by + calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym + _ ≤ (q + 1) ^ 4 := by + calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring + _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have hM1 : 1 ≤ M := Fintype.card_pos + have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) + have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX + have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring + have e3 : q * X * C2 = (q * C2) * X := by ring + have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX + have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 + calc q * X + q * X * (M * q * C2) + q * X * C2 + ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by + rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 + _ = 3 * (q + 1) ^ 4 * M * X := by ring + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond for S-caps, exact order, connected.** -/ +theorem tp_single_s_exact (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ) (A : Set U)) + (hA0 : A.Nonempty) {e : U} (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' = n ∧ IsSplit G' ∧ G'.Connected ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + classical + set M := Fintype.card U + have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by + obtain ⟨a0, ha0⟩ := hA0 + exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ + refine exponent_of_family_exact hM hA0.card_pos (by positivity) (SVk F U) + (fun j k => hostGraph (padN (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j)) + ((0 : F), (0 : Fin j → U)) k)) + (fun j => Fintype.card (SV F U j)) (fun j => card_SV_le j) + (fun j k => card_pad k) (fun j k => isSplit_hostGraph _) + (fun j k => connected_hostGraph _ ((0 : F), (0 : Fin j → U)) (padN_nonempty _ _ _)) (fun j k + => ?_) + have h := pgap_ge_third_pad (single (W := Fin j → U) σ) (isSCap_capPow hA j) (hcapne j) + (prodSep A he j) (single_same σ) ((0 : F), (0 : Fin j → U)) k + rw [card_capPow] at h + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [hW] at h + push_cast at h + exact h + +end Single + +/-- **Theorem 17.0, exact form.** For every large `n` there is a connected split graph of order +exactly `n` +with `cp − cp* ≥ c n^{2 − ε}`. -/ +theorem exponent_two_exact {ε : ℝ} (hε : 0 < ε) : + ∃ c : ℝ, 0 < c ∧ ∃ N₀ : ℕ, ∀ n : ℕ, N₀ ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' = n ∧ IsSplit G' ∧ G'.Connected ∧ c * (n : ℝ) ^ (2 - ε) ≤ gap G' := by + have hl10 : 0 < Real.log 10 := Real.log_pos (by norm_num) + -- a large prime + obtain ⟨p, hpM, hpp⟩ := Nat.exists_infinite_primes (⌈Real.exp (2 * Real.log 10 / ε)⌉₊ + 11) + have : Fact p.Prime := ⟨hpp⟩ + have hp11 : 11 ≤ p := by omega + have hp5 : 5 < p := by omega + set K := (p - 1) / 10 with hKdef + have hK : 10 * K < p := by + have := Nat.div_mul_le_self (p - 1) 10 + rw [hKdef]; omega + have hK1 : 1 ≤ K := by rw [hKdef]; exact (Nat.le_div_iff_mul_le (by norm_num)).mpr (by omega) + have hpK : p ≤ 10 * (K + 1) := by + have h1 := Nat.div_add_mod (p - 1) 10 + have h2 := Nat.mod_lt (p - 1) (show 0 < 10 by norm_num) + rw [hKdef]; omega + have hpr : (1 : ℝ) < p := by exact_mod_cast (show 1 < p by omega) + set L := Real.log p with hLdef + have hL : 0 < L := Real.log_pos hpr + have hLbig : 2 * Real.log 10 / ε ≤ L := by + have h1 : Real.exp (2 * Real.log 10 / ε) ≤ p := by + have := Nat.le_ceil (Real.exp (2 * Real.log 10 / ε)) + have h2 : ((⌈Real.exp (2 * Real.log 10 / ε)⌉₊ : ℕ) : ℝ) ≤ p := by exact_mod_cast (by omega : + _ ≤ p) + linarith + rw [hLdef, ← Real.log_exp (2 * Real.log 10 / ε)] + exact Real.log_le_log (Real.exp_pos _) h1 + have hlog10 : Real.log 10 / L ≤ ε / 2 := by + rw [div_le_iff₀ hL] + have := mul_le_mul_of_nonneg_left hLbig hε.le + rw [mul_div_cancel₀ _ hε.ne'] at this + linarith + have hKlog : L ≤ Real.log 10 + Real.log (K + 1) := by + rw [← Real.log_mul (by norm_num) (by positivity)] + exact Real.log_le_log (by positivity) (by exact_mod_cast hpK) + -- choose `N` with `log (N R' + 1) ≤ (ε/2) N L` + set R' := K ^ 2 + 1 with hR'def + have hR'pos : (0 : ℝ) < R' := by positivity + have hε2 : 0 < ε / 2 := by positivity + set a : ℝ := L / R' + have ha : a ≠ 0 := by positivity + have ht := Real.tendsto_pow_log_div_mul_add_atTop a (-a) 1 ha + obtain ⟨X, hX⟩ := Filter.eventually_atTop.mp ((tendsto_order.1 ht).2 (ε / 2) hε2) + set N : ℕ := ⌈X⌉₊ + 1 with hNdef + have hN : 0 < N := by omega + have hxN : X ≤ (N : ℝ) * R' + 1 := by + have h1 := Nat.le_ceil X + have h2 : (⌈X⌉₊ : ℝ) ≤ N := by exact_mod_cast (show ⌈X⌉₊ ≤ N by omega) + have h3 : (N : ℝ) ≤ N * R' := by + have : (1 : ℝ) ≤ R' := by exact_mod_cast (show 1 ≤ R' by omega) + nlinarith + linarith + have hlogN : Real.log ((N : ℝ) * R' + 1) ≤ ε / 2 * (N * L) := by + have := (hX _ hxN).le + simp only [pow_one] at this + have hden : a * ((N : ℝ) * R' + 1) + -a = N * L := by + simp only [a]; field_simp; ring + rw [hden, div_le_iff₀ (by positivity)] at this + linarith + -- the seed + obtain ⟨r, hr⟩ := exists_large_sphere K N (R := R') (by omega) + set A := seed p K N r with hAdef + have hAcard : A.card = (sphere K N r).card := card_sphereSeed (by omega) + have hApos : 0 < A.card := by + rw [hAcard] + by_contra h0 + push Not at h0 + have : (sphere K N r).card = 0 := by omega + rw [this, mul_zero] at hr + have : 0 < (K + 1) ^ N := by positivity + omega + have hcardU : Fintype.card (Fin N → ZMod p) = p ^ N := by simp + have hM : 2 ≤ Fintype.card (Fin N → ZMod p) := by + rw [hcardU] + calc 2 ≤ p ^ 1 := by simp; omega + _ ≤ p ^ N := Nat.pow_le_pow_right (by omega) hN + have he : (fun _ => (1 : ZMod p) : Fin N → ZMod p) ≠ 0 := by + intro h + have := congrFun h ⟨0, hN⟩ + simp at this + obtain ⟨c, hc, h⟩ := tp_single_s_exact (colσ hp5) (isSCap_seed (N := N) (r := r) hK hp5) + (Finset.card_pos.mp hApos) he hM + refine ⟨c, hc, 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * + Fintype.card (Fin N → ZMod p), fun n hn => ?_⟩ + obtain ⟨V', i1, i2, G', hcard, hsplit, hconn, hgap⟩ := h n hn + refine ⟨V', i1, i2, G', hcard, hsplit, hconn, le_trans ?_ hgap⟩ + have hn1 : (1 : ℝ) ≤ n := by + have h0 : 0 < 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * + Fintype.card (Fin N → ZMod p) := by positivity + have : 1 ≤ n := by omega + exact_mod_cast this + have hlogU : Real.log (Fintype.card (Fin N → ZMod p) : ℝ) = N * L := by + rw [hcardU]; push_cast + rw [Real.log_pow] + have hrate : 1 - ε ≤ Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ) := by + rw [hlogU] + have hA : ((K + 1 : ℕ) : ℝ) ^ N ≤ ((N : ℝ) * R' + 1) * A.card := by + rw [hAcard]; exact_mod_cast hr + have hlog : (N : ℝ) * Real.log (K + 1) ≤ Real.log ((N : ℝ) * R' + 1) + Real.log A.card := by + have hK0 : (0 : ℝ) < ((K + 1 : ℕ) : ℝ) := by positivity + rw [← Real.log_mul (by positivity) (by exact_mod_cast hApos.ne')] + have := Real.log_le_log (by positivity) hA + rw [Real.log_pow] at this + push_cast at this + exact this + have hNL : (0 : ℝ) < N * L := by positivity + rw [le_div_iff₀ hNL] + -- `log 10 ≤ (ε/2) L` + have h10 : Real.log 10 ≤ ε / 2 * L := by + rw [div_le_iff₀ hL] at hlog10; linarith + have hNr : (0 : ℝ) < N := by exact_mod_cast hN + nlinarith + have hexp := Real.rpow_le_rpow_of_exponent_le hn1 (by linarith : + 2 - ε ≤ 1 + Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ)) + exact mul_le_mul_of_nonneg_left hexp hc.le + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean new file mode 100644 index 0000000000..f493ff7945 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean @@ -0,0 +1,139 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Main +public import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# The exponent (ledger §10, TP-cond) + +For a separable cap `A` in a finite `F`-module `U` (`|U| = M ≥ 2`, `|A| = a ≥ 1`) and `σ : Fin 6 ↪ +F`, the +graphs `G(A^j)` give, for every `n ≥ 3 q³ M`, a split graph with at most `n` vertices and + + `gap ≥ c · n^α`, `α = 1 + log a / log M`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type} [Field F] [Fintype F] [DecidableEq F] +variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +/-- The power `A^j` as a `Finset` of `Fin j → U`. -/ +def capPow (A : Finset U) (j : ℕ) : Finset (Fin j → U) := Fintype.piFinset fun _ => A + +omit [AddCommGroup U] [DecidableEq U] [Fintype U] in +theorem coe_capPow (A : Finset U) (j : ℕ) : + (capPow A j : Set (Fin j → U)) = Set.pi Set.univ fun _ => (A : Set U) := by + simp [capPow, Fintype.coe_piFinset] + +omit [DecidableEq F] [DecidableEq U] [Fintype F] [Fintype U] in +theorem isCap_capPow {A : Finset U} (hA : IsCap F (A : Set U)) (j : ℕ) : + IsCap F (capPow A j : Set (Fin j → U)) := by + rw [coe_capPow]; exact hA.pi + +omit [DecidableEq F] [DecidableEq U] [Fintype F] [Fintype U] in +theorem isSep_capPow {A : Finset U} (hA : IsSep F (A : Set U)) (j : ℕ) : + IsSep F (capPow A j : Set (Fin j → U)) := by + rw [coe_capPow]; exact hA.pi + +omit [AddCommGroup U] [DecidableEq U] [Fintype U] in +theorem card_capPow (A : Finset U) (j : ℕ) : (capPow A j).card = A.card ^ j := by + simp [capPow] + +/-- `(M^j)^α = a^j · M^j` for `α = 1 + log a / log M`. -/ +theorem pow_rpow_alpha {a M : ℕ} (ha : 1 ≤ a) (hM : 2 ≤ M) (j : ℕ) : + ((M : ℝ) ^ j) ^ (1 + Real.log a / Real.log M) = (a : ℝ) ^ j * (M : ℝ) ^ j := by + have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) + have ha0 : (0 : ℝ) < a := by exact_mod_cast (show 0 < a by omega) + have hlogM : Real.log M ≠ 0 := by + have : (1 : ℝ) < M := by exact_mod_cast (show 1 < M by omega) + exact (Real.log_pos this).ne' + have key : (M : ℝ) ^ ((j : ℝ) * Real.log a / Real.log M) = (a : ℝ) ^ j := by + rw [Real.rpow_def_of_pos hM0, ← Real.exp_log (pow_pos ha0 j), Real.log_pow] + congr 1 + field_simp + rw [← Real.rpow_natCast, ← Real.rpow_mul hM0.le, + show (j : ℝ) * (1 + Real.log a / Real.log M) = j + j * Real.log a / Real.log M by ring, + Real.rpow_add hM0, Real.rpow_natCast, key, mul_comm] + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond.** -/ +theorem tp_cond (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hS : IsSep F (A : Set U)) + (ha : 1 ≤ A.card) (hM : 2 ≤ Fintype.card U) (hq : 2 ≤ Fintype.card F) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, 3 * Fintype.card F ^ 3 * Fintype.card U ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V ≤ n ∧ IsSplit G ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G := by + classical + set M := Fintype.card U + set K := 3 * Fintype.card F ^ 3 + set α := 1 + Real.log A.card / Real.log M + have hK : 0 < K := by positivity + have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) + have hα : 0 ≤ α := by + have h1 : 0 ≤ Real.log A.card := Real.log_nonneg (by exact_mod_cast ha) + have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) + positivity + refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ + set j := Nat.log M (n / K) with hj + have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by + have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by + have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) + omega) + have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ + -- the graph + refine ⟨(F × (Fin j → U)) ⊕ HostIdx F (Fin j → U), inferInstance, instDecidableEqSum, + hostGraph (palette (capPow A j) σ (isSep_capPow hS j)), ?_, isSplit_hostGraph _, ?_⟩ + · have := card_vertices_le (F := F) (W := Fin j → U) hq + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [hW] at this + calc _ ≤ K * M ^ j := this + _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj + _ ≤ n := Nat.mul_div_le n K + · have hgap := gap_ge_third (W := Fin j → U) σ (isCap_capPow hA j) (isSep_capPow hS j) + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [card_capPow, hW] at hgap + -- n < K M^{j+1}, so n/(K M) < M^j + have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by + have h1 : n < K * (n / K) + K := by + have := Nat.div_add_mod n K + have := Nat.mod_lt n hK + omega + have h2 : n < K * M ^ (j + 1) := by + calc n < K * (n / K) + K := h1 + _ = K * (n / K + 1) := by ring + _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt + rw [div_le_iff₀ (by positivity)] + have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 + rw [pow_succ] at this + nlinarith + have hpow := pow_rpow_alpha ha hM j + have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := + Real.rpow_le_rpow (by positivity) hn' hα + have hsplit : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by + rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] + ring + push_cast at hgap + refine le_trans ?_ hgap + calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by + rw [hsplit]; ring + _ ≤ ((M : ℝ) ^ j) ^ α / 3 := div_le_div_of_nonneg_right hmono (by norm_num) + _ = (A.card : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean new file mode 100644 index 0000000000..acf5fbb46e --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean @@ -0,0 +1,157 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Sphere +import Mathlib.Tactic.Choose +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# The exponent of the split gap is 2 (ledger §17, Theorem 17.0) + +For every `ε > 0` there are `c > 0` and `N₀` such that every `n ≥ N₀` admits a split graph with at +most `n` +vertices and `cp − cp* ≥ c · n^{2 − ε}`. + +Proof: a large prime `p` with `log 10 / log p ≤ ε/2`, `K = (p - 1)/10`, a large sphere in +`{0..K}^N` (an S-cap in +`F_p^N`, `isSCap_seed`), and the S-cap transfer `tp_single_s`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-- **Theorem 17.0.** The gap `cp − cp*` on split graphs with at most `n` vertices is `≥ c n^{2 − +ε}`. -/ +theorem exponent_two {ε : ℝ} (hε : 0 < ε) : + ∃ c : ℝ, 0 < c ∧ ∃ N₀ : ℕ, ∀ n : ℕ, N₀ ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ c * (n : ℝ) ^ (2 - ε) ≤ gap G' := by + have hl10 : 0 < Real.log 10 := Real.log_pos (by norm_num) + -- a large prime + obtain ⟨p, hpM, hpp⟩ := Nat.exists_infinite_primes (⌈Real.exp (2 * Real.log 10 / ε)⌉₊ + 11) + have : Fact p.Prime := ⟨hpp⟩ + have hp11 : 11 ≤ p := by omega + have hp5 : 5 < p := by omega + set K := (p - 1) / 10 with hKdef + have hK : 10 * K < p := by + have := Nat.div_mul_le_self (p - 1) 10 + rw [hKdef]; omega + have hK1 : 1 ≤ K := by rw [hKdef]; exact (Nat.le_div_iff_mul_le (by norm_num)).mpr (by omega) + have hpK : p ≤ 10 * (K + 1) := by + have h1 := Nat.div_add_mod (p - 1) 10 + have h2 := Nat.mod_lt (p - 1) (show 0 < 10 by norm_num) + rw [hKdef]; omega + have hpr : (1 : ℝ) < p := by exact_mod_cast (show 1 < p by omega) + set L := Real.log p with hLdef + have hL : 0 < L := Real.log_pos hpr + have hLbig : 2 * Real.log 10 / ε ≤ L := by + have h1 : Real.exp (2 * Real.log 10 / ε) ≤ p := by + have := Nat.le_ceil (Real.exp (2 * Real.log 10 / ε)) + have h2 : ((⌈Real.exp (2 * Real.log 10 / ε)⌉₊ : ℕ) : ℝ) ≤ p := by exact_mod_cast (by omega : + _ ≤ p) + linarith + rw [hLdef, ← Real.log_exp (2 * Real.log 10 / ε)] + exact Real.log_le_log (Real.exp_pos _) h1 + have hlog10 : Real.log 10 / L ≤ ε / 2 := by + rw [div_le_iff₀ hL] + have := mul_le_mul_of_nonneg_left hLbig hε.le + rw [mul_div_cancel₀ _ hε.ne'] at this + linarith + have hKlog : L ≤ Real.log 10 + Real.log (K + 1) := by + rw [← Real.log_mul (by norm_num) (by positivity)] + exact Real.log_le_log (by positivity) (by exact_mod_cast hpK) + -- choose `N` with `log (N R' + 1) ≤ (ε/2) N L` + set R' := K ^ 2 + 1 with hR'def + have hR'pos : (0 : ℝ) < R' := by positivity + have hε2 : 0 < ε / 2 := by positivity + set a : ℝ := L / R' + have ha : a ≠ 0 := by positivity + have ht := Real.tendsto_pow_log_div_mul_add_atTop a (-a) 1 ha + obtain ⟨X, hX⟩ := Filter.eventually_atTop.mp ((tendsto_order.1 ht).2 (ε / 2) hε2) + set N : ℕ := ⌈X⌉₊ + 1 with hNdef + have hN : 0 < N := by omega + have hxN : X ≤ (N : ℝ) * R' + 1 := by + have h1 := Nat.le_ceil X + have h2 : (⌈X⌉₊ : ℝ) ≤ N := by exact_mod_cast (show ⌈X⌉₊ ≤ N by omega) + have h3 : (N : ℝ) ≤ N * R' := by + have : (1 : ℝ) ≤ R' := by exact_mod_cast (show 1 ≤ R' by omega) + nlinarith + linarith + have hlogN : Real.log ((N : ℝ) * R' + 1) ≤ ε / 2 * (N * L) := by + have := (hX _ hxN).le + simp only [pow_one] at this + have hden : a * ((N : ℝ) * R' + 1) + -a = N * L := by + simp only [a]; field_simp; ring + rw [hden, div_le_iff₀ (by positivity)] at this + linarith + -- the seed + obtain ⟨r, hr⟩ := exists_large_sphere K N (R := R') (by omega) + set A := seed p K N r with hAdef + have hAcard : A.card = (sphere K N r).card := card_sphereSeed (by omega) + have hApos : 0 < A.card := by + rw [hAcard] + by_contra h0 + push Not at h0 + have : (sphere K N r).card = 0 := by omega + rw [this, mul_zero] at hr + have : 0 < (K + 1) ^ N := by positivity + omega + have hcardU : Fintype.card (Fin N → ZMod p) = p ^ N := by simp + have hM : 2 ≤ Fintype.card (Fin N → ZMod p) := by + rw [hcardU] + calc 2 ≤ p ^ 1 := by simp; omega + _ ≤ p ^ N := Nat.pow_le_pow_right (by omega) hN + have he : (fun _ => (1 : ZMod p) : Fin N → ZMod p) ≠ 0 := by + intro h + have := congrFun h ⟨0, hN⟩ + simp at this + obtain ⟨c, hc, h⟩ := tp_single_s (colσ hp5) (isSCap_seed (N := N) (r := r) hK hp5) + (Finset.card_pos.mp hApos) he hM + refine ⟨c, hc, 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * + Fintype.card (Fin N → ZMod p), fun n hn => ?_⟩ + obtain ⟨V', i1, i2, G', hcard, hsplit, hgap⟩ := h n hn + refine ⟨V', i1, i2, G', hcard, hsplit, le_trans ?_ hgap⟩ + have hn1 : (1 : ℝ) ≤ n := by + have h0 : 0 < 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * + Fintype.card (Fin N → ZMod p) := by positivity + have : 1 ≤ n := by omega + exact_mod_cast this + have hlogU : Real.log (Fintype.card (Fin N → ZMod p) : ℝ) = N * L := by + rw [hcardU]; push_cast + rw [Real.log_pow] + have hrate : 1 - ε ≤ Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ) := by + rw [hlogU] + have hA : ((K + 1 : ℕ) : ℝ) ^ N ≤ ((N : ℝ) * R' + 1) * A.card := by + rw [hAcard]; exact_mod_cast hr + have hlog : (N : ℝ) * Real.log (K + 1) ≤ Real.log ((N : ℝ) * R' + 1) + Real.log A.card := by + have hK0 : (0 : ℝ) < ((K + 1 : ℕ) : ℝ) := by positivity + rw [← Real.log_mul (by positivity) (by exact_mod_cast hApos.ne')] + have := Real.log_le_log (by positivity) hA + rw [Real.log_pow] at this + push_cast at this + exact this + have hNL : (0 : ℝ) < N * L := by positivity + rw [le_div_iff₀ hNL] + -- `log 10 ≤ (ε/2) L` + have h10 : Real.log 10 ≤ ε / 2 * L := by + rw [div_le_iff₀ hL] at hlog10; linarith + have hNr : (0 : ℝ) < N := by exact_mod_cast hN + nlinarith + have hexp := Real.rpow_le_rpow_of_exponent_le hn1 (by linarith : + 2 - ε ≤ 1 + Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ)) + exact mul_le_mul_of_nonneg_left hexp hc.le + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Geometry.lean b/LeanPool/SplitCliqueGap/GapExtremal/Geometry.lean new file mode 100644 index 0000000000..e6e308ea5b --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Geometry.lean @@ -0,0 +1,87 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Cap +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.LinearCombination +public import Mathlib.Tactic.Module + +/-! +# Geometry of the selected directions (ledger L2.3, L5.1–L5.4) + +Points are `F × W` (first coordinate = colour), directions are `u c = (1, c)` for `c` in a cap `C ⊆ +W`. + +* `dep_zero` (L2.3): three distinct directions of a cap are linearly independent, in the form + `α + β + γ = 0`, `α a + β b + γ c = 0` ⇒ `α = β = γ = 0`. +* `par_eq` : two parallel nonzero differences `t • u c = t' • u c'` force `t = t'` and `c = c'`. +-/ + +@[expose] public section + +namespace GapExtremal + +variable {F : Type*} [Field F] {W : Type*} [AddCommGroup W] [Module F W] + +/-- The direction `(1, c)`. -/ +def u (c : W) : F × W := (1, c) + +theorem smul_u (t : F) (c : W) : t • (u c : F × W) = (t, t • c) := by simp [u] + +/-- Equal multiples of directions have equal scalars and (if nonzero) equal directions. -/ +theorem par_eq {t t' : F} {c c' : W} (h : t • (u c : F × W) = t' • u c') : t = t' ∧ (t ≠ 0 → c + = c') := by + rw [smul_u, smul_u, Prod.mk.injEq] at h + obtain ⟨h1, h2⟩ := h + subst h1 + refine ⟨rfl, fun ht => ?_⟩ + have := congrArg (fun v : W => t⁻¹ • v) h2 + simpa [smul_smul, inv_mul_cancel₀ ht] using this + +/-- **L2.3.** Three distinct points of a cap give independent directions. -/ +theorem dep_zero {C : Set W} (hC : IsCap F C) {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) + (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) {α β γ : F} (hsum : α + β + γ = 0) + (hvec : α • a + β • b + γ • c = 0) : α = 0 ∧ β = 0 ∧ γ = 0 := by + by_cases hγ : γ = 0 + · subst hγ + have hβ : β = -α := by linear_combination hsum + subst hβ + have : α • (a - b) = 0 := by + rw [smul_sub]; simpa [sub_eq_add_neg, neg_smul] using hvec + by_cases hα : α = 0 + · exact ⟨hα, by simp [hα], rfl⟩ + · exfalso + have h2 := congrArg (fun v : W => α⁻¹ • v) this + simp only [smul_smul, inv_mul_cancel₀ hα, one_smul, smul_zero] at h2 + exact hab (sub_eq_zero.mp h2) + · exfalso + -- `c = a + t (b - a)` with `t = β / (α + β) = -β / γ` + set t : F := -β / γ with ht + have hc' : c = a + t • (b - a) := by + have hαβ : α + β = -γ := by linear_combination hsum + have : γ • c = -(α • a + β • b) := by + rw [eq_neg_iff_add_eq_zero]; rw [add_comm]; simpa [add_assoc] using hvec + have hα : α = -γ - β := by linear_combination hαβ + rw [hα] at this + have : c = γ⁻¹ • (-((-γ - β) • a + β • b)) := by + rw [← this, smul_smul, inv_mul_cancel₀ hγ, one_smul] + rw [this, ht] + simp only [smul_neg, smul_add, smul_smul, sub_smul, neg_smul, div_eq_mul_inv, smul_sub] + rw [inv_mul_cancel₀ hγ] + module + have ht0 : t ≠ 0 := by + intro h0 + rw [h0, zero_smul, add_zero] at hc' + exact hac hc'.symm + have ht1 : t ≠ 1 := by + intro h1 + rw [h1, one_smul, add_sub_cancel] at hc' + exact hbc hc'.symm + exact hC ha hb hab t ht0 ht1 (hc' ▸ hc) + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Global.lean b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean new file mode 100644 index 0000000000..4f360598e3 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean @@ -0,0 +1,289 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Choose +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.SplitIfs + +/-! +# The global bound `I(B) ≤ c · #blocks` (ledger §7, L7.3), abstract form + +`B` is a graph on a finite type, `blocks` a family of vertex sets such that + +* two blocks share at most one vertex; +* every triangle of `B` lies in a block; +* a vertex outside a block has at most one `B`-neighbour in it. + +If every block satisfies the reserved local bound `∑ (4 w - e) ≤ 4c - e(ℓ)` for packings inside it, +then every +packing of the whole vertex set has `∑ w ≤ c · #blocks`. + +The proof fragments every column (`exists_pieces`), charges local pieces to their block and +triangle-free +pieces to the unused `B`-edges of the blocks (Mantel with reserve). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] (B : SimpleGraph V) [DecidableRel B.Adj] + +/-- A packing of columns: two distinct members share at most one vertex. -/ +def IsPack (T : Finset (Finset V)) : Prop := ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → (Q ∩ Q').card ≤ 1 + +/-- The geometric hypotheses on the blocks (ledger §5). -/ +structure BlockHyp (blocks : Finset (Finset V)) : Prop where + inter : ∀ ℓ ∈ blocks, ∀ ℓ' ∈ blocks, ℓ ≠ ℓ' → (ℓ ∩ ℓ').card ≤ 1 + edge : ∀ u v, B.Adj u v → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ + tri : ∀ u v x, B.Adj u v → B.Adj v x → B.Adj u x → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ ∧ x ∈ ℓ + one : ∀ ℓ ∈ blocks, ∀ z ∉ ℓ, ∀ y ∈ ℓ, ∀ y' ∈ ℓ, B.Adj z y → B.Adj z y' → y = y' + +variable {B} + +omit [Fintype V] [DecidableEq V] in +theorem D_singleton_le_one {ℓ A : Finset V} {z : V} (hA : A ⊆ ℓ) + (hone : ∀ y ∈ ℓ, ∀ y' ∈ ℓ, B.Adj z y → B.Adj z y' → y = y') : D B {z} A ≤ 1 := by + have : D B {z} A = (A.filter (fun v => B.Adj z v)).card := by + rw [D, Finset.sum_singleton, Finset.card_filter] + rw [this, Finset.card_le_one] + intro a ha b hb + simp only [Finset.mem_filter] at ha hb + exact hone a (hA ha.1) b (hA hb.1) ha.2 hb.2 + +omit [Fintype V] [DecidableEq V] [DecidableRel B.Adj] in +theorem triFree_of_card_le_one {p : Finset V} (h : p.card ≤ 1) : TriFree B p := by + intro u hu v hv _ _ huv _ _ + exact huv.ne (Finset.card_le_one.mp h u hu v hv) + +/-- **Fragmentation of one column.** -/ +theorem exists_pieces {blocks : Finset (Finset V)} (hB : BlockHyp B blocks) (Q : Finset V) : + ∃ P : Finset (Finset V), (∀ p ∈ P, p ⊆ Q) ∧ (∀ p ∈ P, ∀ p' ∈ P, p ≠ p' → Disjoint p p') ∧ + (∀ p ∈ P, (∃ ℓ ∈ blocks, p ⊆ ℓ) ∨ TriFree B p) ∧ w B Q ≤ ∑ p ∈ P, w B p := by + induction Q using Finset.strongInduction with + | H Q ih => + by_cases ht : TriFree B Q + · exact ⟨{Q}, by simp, by simp, by simp [ht], by simp⟩ + · simp only [TriFree, not_forall] at ht + obtain ⟨u, hu, v, hv, x, hx, huv, hvx, hux, -⟩ := ht + obtain ⟨ℓ, hℓ, huℓ, hvℓ, hxℓ⟩ := hB.tri u v x huv hvx hux + set A := Q ∩ ℓ with hAdef + set Z := Q \ ℓ with hZdef + by_cases hZ : Z = ∅ + · have hsub : Q ⊆ ℓ := Finset.sdiff_eq_empty_iff_subset.mp hZ + refine ⟨{Q}, by simp, by simp, ?_, by simp⟩ + simp only [Finset.mem_singleton, forall_eq] + exact Or.inl ⟨ℓ, hℓ, hsub⟩ + · have hZne : Z.Nonempty := Finset.nonempty_iff_ne_empty.mpr hZ + have hZQ : Z ⊂ Q := by + refine ⟨Finset.sdiff_subset, fun h => ?_⟩ + have := h hu + simp [hZdef, huℓ] at this + obtain ⟨PZ, hPZsub, hPZdisj, hPZtype, hPZw⟩ := ih Z hZQ + have hAZ : Disjoint A Z := by + rw [hAdef, hZdef] + exact Finset.disjoint_left.mpr fun a ha haZ => + (Finset.mem_sdiff.mp haZ).2 (Finset.mem_inter.mp ha).2 + have huA : u ∈ A := Finset.mem_inter.mpr ⟨hu, huℓ⟩ + have hA3 : 3 ≤ A.card := by + have hs : ({u, v, x} : Finset V) ⊆ A := by + intro y hy + simp only [Finset.mem_insert, Finset.mem_singleton] at hy + rcases hy with rfl | rfl | rfl <;> simp_all + have hc : ({u, v, x} : Finset V).card = 3 := by + rw [Finset.card_insert_of_notMem (by simp [huv.ne, hux.ne]), + Finset.card_pair hvx.ne] + exact hc ▸ Finset.card_le_card hs + have hAnot : A ∉ PZ := fun hA => by + have := hPZsub A hA huA + simp [hZdef, huℓ] at this + have hQAZ : Q = A ∪ Z := by + ext y; by_cases hy : y ∈ ℓ <;> simp [hAdef, hZdef] + refine ⟨insert A PZ, ?_, ?_, ?_, ?_⟩ + · intro p hp + rcases Finset.mem_insert.mp hp with rfl | hp + · exact Finset.inter_subset_left + · exact (hPZsub p hp).trans Finset.sdiff_subset + · intro p hp p' hp' hne + rcases Finset.mem_insert.mp hp with rfl | hp <;> + rcases Finset.mem_insert.mp hp' with rfl | hp' + · exact absurd rfl hne + · exact hAZ.mono_right (hPZsub p' hp') + · exact (hAZ.mono_right (hPZsub p hp)).symm + · exact hPZdisj p hp p' hp' hne + · intro p hp + rcases Finset.mem_insert.mp hp with rfl | hp + · exact Or.inl ⟨ℓ, hℓ, Finset.inter_subset_right⟩ + · exact hPZtype p hp + · rw [Finset.sum_insert hAnot, hQAZ] + refine (frag_le B hAZ hA3 hZne fun z hz => ?_).trans (by linarith) + have hzℓ : z ∉ ℓ := (Finset.mem_sdiff.mp hz).2 + exact D_singleton_le_one Finset.inter_subset_right (hB.one ℓ hℓ z hzℓ) + +/-- The edges of a column are covered by its parts in the blocks. -/ +theorem e_le_sum_blocks {blocks : Finset (Finset V)} + (hedge : ∀ u v, B.Adj u v → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ) (p : Finset V) : + e B p ≤ ∑ ℓ ∈ blocks, e B (p ∩ ℓ) := by + unfold e + refine (Finset.card_le_card ?_).trans Finset.card_biUnion_le + intro s hs + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs + obtain ⟨huv, hu, hv⟩ := hs + obtain ⟨ℓ, hℓ, huℓ, hvℓ⟩ := hedge u v huv + refine Finset.mem_biUnion.mpr ⟨ℓ, hℓ, ?_⟩ + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] + exact ⟨huv, Finset.mem_inter.mpr ⟨hu, huℓ⟩, Finset.mem_inter.mpr ⟨hv, hvℓ⟩⟩ + +/-- Pieces sharing at most one vertex use disjoint edges of a block. -/ +theorem sum_e_inter_le {ι : Type*} (S : Finset ι) (f : ι → Finset V) + (hf : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (f x ∩ f y).card ≤ 1) (ℓ : Finset V) : + ∑ x ∈ S, e B (f x ∩ ℓ) ≤ e B ℓ := by + unfold e + rw [← Finset.card_biUnion] + · refine Finset.card_le_card fun s hs => ?_ + obtain ⟨x, -, hx⟩ := Finset.mem_biUnion.mp hs + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hx ⊢ + exact ⟨hx.1, (Finset.mem_inter.mp hx.2.1).2, (Finset.mem_inter.mp hx.2.2).2⟩ + · intro x hx y hy hxy + rw [Function.onFun, Finset.disjoint_left] + intro s hsx hsy + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hsx hsy + have hu : u ∈ f x ∩ f y := + Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.1).1, (Finset.mem_inter.mp hsy.2.1).1⟩ + have hv : v ∈ f x ∩ f y := + Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.2).1, (Finset.mem_inter.mp hsy.2.2).1⟩ + exact hsx.1.ne (Finset.card_le_one.mp (hf x hx y hy hxy) u hu v hv) + +/-- **L7.3 (abstract).** -/ +theorem global_bound {blocks : Finset (Finset V)} (hB : BlockHyp B blocks) (c : ℤ) + (hloc : ∀ ℓ ∈ blocks, ∀ T : Finset (Finset V), (∀ Q ∈ T, Q ⊆ ℓ) → IsPack T → + ∑ Q ∈ T, (4 * w B Q - e B Q) ≤ 4 * c - e B ℓ) + {T : Finset (Finset V)} (hT : IsPack T) : ∑ Q ∈ T, w B Q ≤ c * blocks.card := by + classical + choose P hPsub hPdisj hPtype hPw using fun Q => exists_pieces hB Q + set S := T.sigma P with hS + have h1 : ∑ Q ∈ T, w B Q ≤ ∑ x ∈ S, w B x.2 := by + rw [hS, Finset.sum_sigma] + exact Finset.sum_le_sum fun Q _ => hPw Q + have hpair : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (x.2 ∩ y.2).card ≤ 1 := by + rintro ⟨Q, p⟩ hx ⟨Q', p'⟩ hy hne + simp only [hS, Finset.mem_sigma] at hx hy + by_cases hQ : Q = Q' + · subst hQ + have hp : p ≠ p' := fun h => hne (by rw [h]) + rw [Finset.disjoint_iff_inter_eq_empty.mp (hPdisj Q p hx.2 p' hy.2 hp)] + simp + · exact (Finset.card_le_card + (Finset.inter_subset_inter (hPsub Q p hx.2) (hPsub Q' p' hy.2))).trans (hT Q hx.1 Q' hy.1 + hQ) + set L : Finset V → Finset (Σ _ : Finset V, Finset V) := + fun ℓ => S.filter (fun x => 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) with hL + set R := S.filter (fun x => ¬ ∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) with hR + have hcount : ∀ x ∈ S, (∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) → + (blocks.filter (fun ℓ => 2 ≤ x.2.card ∧ x.2 ⊆ ℓ)).card = 1 := by + rintro x - ⟨ℓ, hℓ, h2, hsub⟩ + rw [Finset.card_eq_one] + refine ⟨ℓ, Finset.eq_singleton_iff_unique_mem.mpr ⟨Finset.mem_filter.mpr ⟨hℓ, h2, hsub⟩, ?_⟩⟩ + intro ℓ' hℓ' + obtain ⟨hℓ'b, -, hsub'⟩ := Finset.mem_filter.mp hℓ' + by_contra hne + have h3 := hB.inter ℓ' hℓ'b ℓ hℓ hne + have h4 : x.2.card ≤ (ℓ' ∩ ℓ).card := Finset.card_le_card (Finset.subset_inter hsub' hsub) + omega + have hsplit : ∀ g : (Σ _ : Finset V, Finset V) → ℤ, + ∑ x ∈ S, g x = ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, g x + ∑ x ∈ R, g x := by + intro g + have hLsum : ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, g x = + ∑ x ∈ S, if (∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) then g x else 0 := by + simp only [hL, Finset.sum_filter] + rw [Finset.sum_comm] + refine Finset.sum_congr rfl fun x hx => ?_ + split_ifs with hloc' + · rw [← Finset.sum_filter, Finset.sum_const, hcount x hx hloc', one_smul] + · refine Finset.sum_eq_zero fun ℓ hℓ => ?_ + rw [ite_eq_right] + exact fun h => hloc' ⟨ℓ, hℓ, h⟩ + rw [hLsum, hR, Finset.sum_filter, ← Finset.sum_add_distrib] + refine Finset.sum_congr rfl fun x _ => ?_ + split_ifs <;> simp + have hRtf : ∀ x ∈ R, TriFree B x.2 := by + intro x hx + obtain ⟨hxS, hnot⟩ := Finset.mem_filter.mp hx + obtain ⟨Q, p⟩ := x + simp only [hS, Finset.mem_sigma] at hxS + rcases hPtype Q p hxS.2 with ⟨ℓ, hℓ, hsub⟩ | htf + · refine triFree_of_card_le_one ?_ + by_contra h2 + exact hnot ⟨ℓ, hℓ, by omega, hsub⟩ + · exact htf + have hblock : ∀ ℓ ∈ blocks, + ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) ≤ 4 * c := by + intro ℓ hℓ + have hLR : Disjoint (L ℓ) R := by + rw [Finset.disjoint_left] + intro x hxL hxR + exact (Finset.mem_filter.mp hxR).2 ⟨ℓ, hℓ, (Finset.mem_filter.mp hxL).2⟩ + have hedges : ∑ x ∈ L ℓ, (e B x.2 : ℤ) + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) ≤ e B ℓ := by + have hLe : ∑ x ∈ L ℓ, (e B x.2 : ℤ) = ∑ x ∈ L ℓ, (e B (x.2 ∩ ℓ) : ℤ) := by + refine Finset.sum_congr rfl fun x hx => ?_ + rw [Finset.inter_eq_left.mpr (Finset.mem_filter.mp hx).2.2] + rw [hLe, ← Finset.sum_union hLR] + have hsub : L ℓ ∪ R ⊆ S := + Finset.union_subset (Finset.filter_subset _ _) (Finset.filter_subset _ _) + have := sum_e_inter_le (B := B) (L ℓ ∪ R) (fun x => x.2) + (fun x hx y hy => hpair x (hsub hx) y (hsub hy)) ℓ + exact_mod_cast this + have hinj : Set.InjOn (fun x : (Σ _ : Finset V, Finset V) => x.2) (L ℓ : Set _) := by + intro x hx y hy hxy + by_contra hne + have h2 := (Finset.mem_filter.mp hx).2.1 + have h5 := hpair x (Finset.mem_filter.mp hx).1 y (Finset.mem_filter.mp hy).1 hne + simp only at hxy + rw [hxy, Finset.inter_self] at h5 + rw [hxy] at h2 + omega + have hloc' := hloc ℓ hℓ ((L ℓ).image (fun x => x.2)) + (fun Q hQ => by + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ + exact (Finset.mem_filter.mp hx).2.2) + (fun Q hQ Q' hQ' hne => by + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hQ' + exact hpair x (Finset.mem_filter.mp hx).1 y (Finset.mem_filter.mp hy).1 + (fun h => hne (by rw [h]))) + rw [Finset.sum_image hinj] at hloc' + have hsub' : ∑ x ∈ L ℓ, (4 * w B x.2 - e B x.2) = + ∑ x ∈ L ℓ, 4 * w B x.2 - ∑ x ∈ L ℓ, (e B x.2 : ℤ) := Finset.sum_sub_distrib _ _ + linarith + have hR4 : ∑ x ∈ R, 4 * w B x.2 ≤ ∑ ℓ ∈ blocks, ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) := by + rw [Finset.sum_comm] + refine Finset.sum_le_sum fun x hx => (four_w_le_e B (hRtf x hx)).trans ?_ + exact_mod_cast e_le_sum_blocks hB.edge x.2 + have h4 : 4 * ∑ x ∈ S, w B x.2 ≤ 4 * (c * blocks.card) := by + rw [Finset.mul_sum, hsplit (fun x => 4 * w B x.2)] + calc ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, 4 * w B x.2 + ≤ ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ ℓ ∈ blocks, ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) := by + linarith + _ = ∑ ℓ ∈ blocks, (∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ)) := + Finset.sum_add_distrib.symm + _ ≤ ∑ _ℓ ∈ blocks, 4 * c := Finset.sum_le_sum hblock + _ = 4 * (c * blocks.card) := by rw [Finset.sum_const, nsmul_eq_mul]; ring + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean b/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean new file mode 100644 index 0000000000..95d0b83411 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean @@ -0,0 +1,326 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Global +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Choose +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.SplitIfs + +/-! +# Global bound with twins (ledger §16.2, L16.2) + +Hypotheses on the blocks: every `B`-edge and every `B`-triangle lies in a block, and a vertex +outside a block +has at most two neighbours in it, which are then non-adjacent. Blocks may share more than one + vertex. +Potential `what = 4 w - e`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] (B : SimpleGraph V) [DecidableRel B.Adj] + +/-- Twin-tolerant block hypotheses. -/ +structure BlockHyp2 (blocks : Finset (Finset V)) : Prop where + edge : ∀ u v, B.Adj u v → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ + tri : ∀ u v x, B.Adj u v → B.Adj v x → B.Adj u x → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ ∧ x ∈ ℓ + two : ∀ ℓ ∈ blocks, ∀ z ∉ ℓ, ∀ y ∈ ℓ, ∀ y' ∈ ℓ, ∀ y'' ∈ ℓ, B.Adj z y → B.Adj z y' → B.Adj z y'' → + y = y' ∨ y = y'' ∨ y' = y'' + nonadj : ∀ ℓ ∈ blocks, ∀ z ∉ ℓ, ∀ y ∈ ℓ, ∀ y' ∈ ℓ, B.Adj z y → B.Adj z y' → ¬ B.Adj y y' + +variable {B} + +/-- The potential `what = 4 w - e`. -/ +def what (B : SimpleGraph V) [DecidableRel B.Adj] (Q : Finset V) : ℤ := 4 * w B Q - e B Q + +omit [DecidableEq V] [Fintype V] in +theorem D_singleton_le_two {ℓ A : Finset V} {z : V} (hA : A ⊆ ℓ) + (htwo : ∀ y ∈ ℓ, ∀ y' ∈ ℓ, ∀ y'' ∈ ℓ, B.Adj z y → B.Adj z y' → B.Adj z y'' → + y = y' ∨ y = y'' ∨ y' = y'') : D B {z} A ≤ 2 := by + have : D B {z} A = (A.filter (fun v => B.Adj z v)).card := by + rw [D, Finset.sum_singleton, Finset.card_filter] + rw [this] + by_contra h + push Not at h + obtain ⟨a, ha, b, hb, c, hc, hab, hac, hbc⟩ := Finset.two_lt_card.mp h + simp only [Finset.mem_filter] at ha hb hc + rcases htwo a (hA ha.1) b (hA hb.1) c (hA hc.1) ha.2 hb.2 hc.2 with h | h | h + exacts [hab h, hac h, hbc h] + +theorem e_union (A Z : Finset V) (h : Disjoint A Z) : + (e B (A ∪ Z) : ℤ) = e B A + e B Z + D B A Z := by + have h1 := two_mul_e_eq_D B (A ∪ Z) + have h2 := two_mul_e_eq_D B A + have h3 := two_mul_e_eq_D B Z + have hD : D B (A ∪ Z) (A ∪ Z) = D B A A + D B A Z + (D B Z A + D B Z Z) := by + rw [D_union_left B h, D_union_right B h, D_union_right B h] + have hc : D B Z A = D B A Z := D_comm B Z A + have : 2 * e B (A ∪ Z) = 2 * (e B A + e B Z + D B A Z) := by + rw [h1, hD, ← h2, ← h3, hc]; ring + have := Nat.eq_of_mul_eq_mul_left (by norm_num) this + exact_mod_cast this + +/-- Fragmentation identity for `what`. -/ +theorem what_union {A Z : Finset V} (h : Disjoint A Z) : + what B (A ∪ Z) = what B A + what B Z + 7 * D B A Z - 4 * A.card * Z.card + 4 := by + have hc := card_union_choose_two h + have he := e_union (B := B) A Z h + unfold what w + have hD : D B (A ∪ Z) (A ∪ Z) = D B A A + D B A Z + (D B Z A + D B Z Z) := by + rw [D_union_left B h, D_union_right B h, D_union_right B h] + rw [he, hc] + ring + +/-- **Fragmentation of one column (twin version).** -/ +theorem exists_parts {blocks : Finset (Finset V)} (hB : BlockHyp2 B blocks) (Q : Finset V) : + ∃ P : Finset (Finset V), (∀ p ∈ P, p ⊆ Q) ∧ (∀ p ∈ P, ∀ p' ∈ P, p ≠ p' → Disjoint p p') ∧ + (∀ p ∈ P, ∃ ℓ ∈ blocks, p ⊆ ℓ) ∧ what B Q ≤ ∑ p ∈ P, what B p := by + induction Q using Finset.strongInduction with + | H Q ih => + by_cases ht : TriFree B Q + · refine ⟨∅, by simp, by simp, by simp, ?_⟩ + simp only [Finset.sum_empty, what] + linarith [four_w_le_e B ht] + · simp only [TriFree, not_forall] at ht + obtain ⟨u, hu, v, hv, x, hx, huv, hvx, hux, -⟩ := ht + obtain ⟨ℓ, hℓ, huℓ, hvℓ, hxℓ⟩ := hB.tri u v x huv hvx hux + set A := Q ∩ ℓ with hAdef + set Z := Q \ ℓ with hZdef + have hAsub : A ⊆ ℓ := Finset.inter_subset_right + by_cases hZ : Z = ∅ + · have hsub : Q ⊆ ℓ := Finset.sdiff_eq_empty_iff_subset.mp hZ + exact ⟨{Q}, by simp, by simp, by simp only [Finset.mem_singleton, forall_eq]; exact ⟨ℓ, + hℓ, hsub⟩, + by simp⟩ + have hZne : Z.Nonempty := Finset.nonempty_iff_ne_empty.mpr hZ + have hZQ : Z ⊂ Q := by + refine ⟨Finset.sdiff_subset, fun h => ?_⟩ + have := h hu + simp [hZdef, huℓ] at this + obtain ⟨PZ, hPZsub, hPZdisj, hPZblk, hPZw⟩ := ih Z hZQ + have hAZ : Disjoint A Z := by + rw [hAdef, hZdef] + exact Finset.disjoint_left.mpr fun a ha haZ => + (Finset.mem_sdiff.mp haZ).2 (Finset.mem_inter.mp ha).2 + have huA : u ∈ A := Finset.mem_inter.mpr ⟨hu, huℓ⟩ + have hvA : v ∈ A := Finset.mem_inter.mpr ⟨hv, hvℓ⟩ + have hxA : x ∈ A := Finset.mem_inter.mpr ⟨hx, hxℓ⟩ + have htriA : ({u, v, x} : Finset V) ⊆ A := by + intro y hy + simp only [Finset.mem_insert, Finset.mem_singleton] at hy + rcases hy with rfl | rfl | rfl <;> assumption + have hc3 : ({u, v, x} : Finset V).card = 3 := by + rw [Finset.card_insert_of_notMem (by simp [huv.ne, hux.ne]), Finset.card_pair hvx.ne] + have hA3 : 3 ≤ A.card := hc3 ▸ Finset.card_le_card htriA + have hQAZ : Q = A ∪ Z := by + ext y; by_cases hy : y ∈ ℓ <;> simp [hAdef, hZdef] + have hAnot : A ∉ PZ := fun hA => by + have := hPZsub A hA huA + simp [hZdef, huℓ] at this + have hpartsA : ∀ PP : Finset (Finset V), (∀ p ∈ PP, p ⊆ Z) → + (∀ p ∈ PP, ∀ p' ∈ PP, p ≠ p' → Disjoint p p') → (∀ p ∈ PP, ∃ ℓ ∈ blocks, p ⊆ ℓ) → + A ∉ PP → + (∀ p ∈ insert A PP, p ⊆ Q) ∧ (∀ p ∈ insert A PP, ∀ p' ∈ insert A PP, p ≠ p' → Disjoint p + p') ∧ + (∀ p ∈ insert A PP, ∃ ℓ ∈ blocks, p ⊆ ℓ) := by + intro PP hsub hdisj hblk _ + refine ⟨?_, ?_, ?_⟩ + · intro p hp + rcases Finset.mem_insert.mp hp with rfl | hp + · exact Finset.inter_subset_left + · exact (hsub p hp).trans Finset.sdiff_subset + · intro p hp p' hp' hne + rcases Finset.mem_insert.mp hp with rfl | hp <;> + rcases Finset.mem_insert.mp hp' with rfl | hp' + · exact absurd rfl hne + · exact hAZ.mono_right (hsub p' hp') + · exact (hAZ.mono_right (hsub p hp)).symm + · exact hdisj p hp p' hp' hne + · intro p hp + rcases Finset.mem_insert.mp hp with rfl | hp + · exact ⟨ℓ, hℓ, hAsub⟩ + · exact hblk p hp + have hid := what_union (B := B) hAZ + -- neighbour counts + have hD2 : D B A Z ≤ 2 * Z.card := by + rw [D_comm, D_eq_sum_singleton_left] + calc ∑ z ∈ Z, D B {z} A ≤ ∑ _z ∈ Z, 2 := Finset.sum_le_sum fun z hz => + D_singleton_le_two hAsub (hB.two ℓ hℓ z (Finset.mem_sdiff.mp hz).2) + _ = 2 * Z.card := by rw [Finset.sum_const, smul_eq_mul, mul_comm] + by_cases hall : ∀ z ∈ Z, D B {z} A ≤ 1 + · -- every outside vertex has at most one neighbour in `A` + have hD1 : D B A Z ≤ Z.card := by + rw [D_comm, D_eq_sum_singleton_left] + calc ∑ z ∈ Z, D B {z} A ≤ ∑ _z ∈ Z, 1 := Finset.sum_le_sum hall + _ = Z.card := by simp + obtain ⟨h1, h2, h3⟩ := hpartsA PZ hPZsub hPZdisj hPZblk hAnot + refine ⟨insert A PZ, h1, h2, h3, ?_⟩ + rw [Finset.sum_insert hAnot, hQAZ, hid] + have hZ1 : (1 : ℤ) ≤ Z.card := by exact_mod_cast hZne.card_pos + have hA3' : (3 : ℤ) ≤ A.card := by exact_mod_cast hA3 + have hD1' : (D B A Z : ℤ) ≤ Z.card := by exact_mod_cast hD1 + nlinarith + · -- some vertex has two non-adjacent neighbours in `A`, so `|A| ≥ 4` + push Not at hall + obtain ⟨z0, hz0, hz02⟩ := hall + have hA4 : 4 ≤ A.card := by + have hset : 1 < (A.filter (fun y => B.Adj z0 y)).card := by + have : D B {z0} A = (A.filter (fun y => B.Adj z0 y)).card := by + rw [D, Finset.sum_singleton, Finset.card_filter] + omega + obtain ⟨a, ha, b, hb, hab⟩ := Finset.one_lt_card.mp hset + simp only [Finset.mem_filter] at ha hb + have hnab := hB.nonadj ℓ hℓ z0 (Finset.mem_sdiff.mp hz0).2 a (hAsub ha.1) b (hAsub hb.1) + ha.2 hb.2 + -- the triangle `u v x` contains at most one of `a, b` + by_contra h4 + push Not at h4 + have hA3eq : A.card = 3 := by omega + have hAeq : A = {u, v, x} := (Finset.eq_of_subset_of_card_le htriA (by rw [hc3, + hA3eq])).symm + have ha' := ha.1 + have hb' := hb.1 + rw [hAeq] at ha' hb' + simp only [Finset.mem_insert, Finset.mem_singleton] at ha' hb' + rcases ha' with rfl | rfl | rfl <;> rcases hb' with rfl | rfl | rfl <;> + first | exact hab rfl | exact hnab huv | exact hnab huv.symm | exact hnab hvx | + exact hnab hvx.symm | exact hnab hux | exact hnab hux.symm + have hA4' : (4 : ℤ) ≤ A.card := by exact_mod_cast hA4 + have hD2' : (D B A Z : ℤ) ≤ 2 * Z.card := by exact_mod_cast hD2 + by_cases hZ1 : Z.card = 1 + · obtain ⟨z, hzZ⟩ := Finset.card_eq_one.mp hZ1 + refine ⟨{A}, ?_, by simp, ?_, ?_⟩ + · simp only [Finset.mem_singleton, forall_eq]; exact Finset.inter_subset_left + · simp only [Finset.mem_singleton, forall_eq]; exact ⟨ℓ, hℓ, hAsub⟩ + · rw [Finset.sum_singleton, hQAZ, hid, hzZ] + rw [hzZ] at hD2' + have hwz : what B {z} = -4 := by + have hm := mantel B (triFree_of_card_le_one (B := B) (p := {z}) (by simp)) + simp only [Finset.card_singleton] at hm + have he0 : e B {z} = 0 := by omega + unfold what w + rw [he0] + simp + rw [hwz] + simp only [Finset.card_singleton, Nat.cast_one] at hD2' ⊢ + nlinarith + · have hZ2 : (2 : ℤ) ≤ Z.card := by + have := hZne.card_pos + have : 2 ≤ Z.card := by omega + exact_mod_cast this + obtain ⟨h1, h2, h3⟩ := hpartsA PZ hPZsub hPZdisj hPZblk hAnot + refine ⟨insert A PZ, h1, h2, h3, ?_⟩ + rw [Finset.sum_insert hAnot, hQAZ, hid] + nlinarith + +theorem what_le_of_card_le_one {p : Finset V} (h : p.card ≤ 1) : what B p ≤ 0 := by + have := four_w_le_e B (triFree_of_card_le_one (B := B) h) + unfold what; linarith + +/-- **L16.2 (global bound with twins).** -/ +theorem global_bound2 {blocks : Finset (Finset V)} (hB : BlockHyp2 B blocks) (c : ℤ) + (hloc : ∀ ℓ ∈ blocks, ∀ T : Finset (Finset V), (∀ Q ∈ T, Q ⊆ ℓ) → IsPack T → + ∑ Q ∈ T, (4 * w B Q - e B Q) ≤ 4 * c - e B ℓ) + {T : Finset (Finset V)} (hT : IsPack T) : ∑ Q ∈ T, w B Q ≤ c * blocks.card := by + classical + choose P hPsub hPdisj hPblk hPw using fun Q => exists_parts hB Q + set S := T.sigma P with hS + -- pieces of distinct parts share at most one vertex + have hpair : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (x.2 ∩ y.2).card ≤ 1 := by + rintro ⟨Q, p⟩ hx ⟨Q', p'⟩ hy hne + simp only [hS, Finset.mem_sigma] at hx hy + by_cases hQ : Q = Q' + · subst hQ + have hp : p ≠ p' := fun h => hne (by rw [h]) + rw [Finset.disjoint_iff_inter_eq_empty.mp (hPdisj Q p hx.2 p' hy.2 hp)] + simp + · exact (Finset.card_le_card + (Finset.inter_subset_inter (hPsub Q p hx.2) (hPsub Q' p' hy.2))).trans (hT Q hx.1 Q' hy.1 + hQ) + -- step 1: potentials + have h1 : ∑ Q ∈ T, what B Q ≤ ∑ x ∈ S, what B x.2 := by + rw [hS, Finset.sum_sigma] + exact Finset.sum_le_sum fun Q _ => hPw Q + -- step 2: edges of the columns + have h2 : ∑ Q ∈ T, (e B Q : ℤ) ≤ ∑ ℓ ∈ blocks, (e B ℓ : ℤ) := by + have a := sum_e_inter_le (B := B) T id (fun x hx y hy hxy => hT x hx y hy hxy) Finset.univ + have b := e_le_sum_blocks (B := B) hB.edge Finset.univ + simp only [id, Finset.inter_univ, Finset.univ_inter] at a b + exact_mod_cast a.trans b + -- step 3: keep parts with at least two vertices and charge them to blocks + set S' := S.filter (fun x => 2 ≤ x.2.card) with hS' + have h3 : ∑ x ∈ S, what B x.2 ≤ ∑ x ∈ S', what B x.2 := by + rw [hS', Finset.sum_filter] + refine Finset.sum_le_sum fun x _ => ?_ + split_ifs with h + · exact le_rfl + · exact what_le_of_card_le_one (by omega) + have hblkS : ∀ x ∈ S, ∃ ℓ ∈ blocks, x.2 ⊆ ℓ := by + rintro ⟨Q, p⟩ hx + simp only [hS, Finset.mem_sigma] at hx + exact hPblk Q p hx.2 + let blk : (Σ _ : Finset V, Finset V) → Finset V := fun x => + if h : ∃ ℓ ∈ blocks, x.2 ⊆ ℓ then h.choose else ∅ + have hblk : ∀ x ∈ S, blk x ∈ blocks ∧ x.2 ⊆ blk x := by + intro x hx + have h := hblkS x hx + simp only [blk, dite_eq_left h] + exact h.choose_spec + have hmaps : ∀ x ∈ S', blk x ∈ blocks := fun x hx => (hblk x (Finset.mem_filter.mp hx).1).1 + have h4 : ∑ x ∈ S', what B x.2 = ∑ ℓ ∈ blocks, ∑ x ∈ S'.filter (fun x => blk x = ℓ), what B x.2 := + (Finset.sum_fiberwise_of_maps_to hmaps _).symm + have h5 : ∀ ℓ ∈ blocks, ∑ x ∈ S'.filter (fun x => blk x = ℓ), what B x.2 ≤ 4 * c - e B ℓ := by + intro ℓ hℓ + set F := S'.filter (fun x => blk x = ℓ) with hF + have hFS : ∀ x ∈ F, x ∈ S ∧ 2 ≤ x.2.card ∧ blk x = ℓ := by + intro x hx + obtain ⟨hx', hb⟩ := Finset.mem_filter.mp hx + obtain ⟨hxS, h2⟩ := Finset.mem_filter.mp hx' + exact ⟨hxS, h2, hb⟩ + have hinj : Set.InjOn (fun x : (Σ _ : Finset V, Finset V) => x.2) (F : Set _) := by + intro x hx y hy hxy + by_contra hne + obtain ⟨hxS, hx2, -⟩ := hFS x hx + obtain ⟨hyS, -, -⟩ := hFS y hy + have h6 := hpair x hxS y hyS hne + simp only at hxy + rw [hxy, Finset.inter_self] at h6 + rw [hxy] at hx2 + omega + have := hloc ℓ hℓ (F.image fun x => x.2) + (fun Q hQ => by + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ + obtain ⟨hxS, -, hb⟩ := hFS x hx + exact hb ▸ (hblk x hxS).2) + (fun Q hQ Q' hQ' hne => by + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hQ' + exact hpair x (hFS x hx).1 y (hFS y hy).1 (fun h => hne (by rw [h]))) + rw [Finset.sum_image hinj] at this + simpa [what] using this + have h6 : ∑ ℓ ∈ blocks, ∑ x ∈ S'.filter (fun x => blk x = ℓ), what B x.2 ≤ + ∑ ℓ ∈ blocks, (4 * c - e B ℓ) := Finset.sum_le_sum h5 + have hwhat : ∑ Q ∈ T, 4 * w B Q = ∑ Q ∈ T, what B Q + ∑ Q ∈ T, (e B Q : ℤ) := by + rw [← Finset.sum_add_distrib] + exact Finset.sum_congr rfl fun Q _ => by unfold what; ring + have h7 : ∑ ℓ ∈ blocks, (4 * c - e B ℓ) + ∑ ℓ ∈ blocks, (e B ℓ : ℤ) = 4 * (c * blocks.card) := by + rw [← Finset.sum_add_distrib] + simp only [sub_add_cancel, Finset.sum_const, nsmul_eq_mul] + ring + have h8 : 4 * ∑ Q ∈ T, w B Q ≤ 4 * (c * blocks.card) := by + rw [Finset.mul_sum, hwhat] + linarith + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean b/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean new file mode 100644 index 0000000000..ddf782042b --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean @@ -0,0 +1,112 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Residual +public import Mathlib.Combinatorics.SimpleGraph.Extremal.Turan +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Convert +import Mathlib.Tactic.NormNum + +/-! +# Mantel with reserve and fragmentation (ledger §7, L7.1–L7.2) + +* `mantel`: a `B`-triangle-free column `Q` has `4 e(Q) ≤ |Q|²` (Mathlib's Turán bound for `r = 2`). +* `four_w_le_e`: then `4 w(Q) ≤ e(Q)` (identity `16(e/4 - w) = (v-4)² + 7(v² - 4e)`). +* `frag_le`: if `|A| ≥ 3`, `Z ≠ ∅` is disjoint from `A` and every `z ∈ Z` has at most one +`B`-neighbour in + `A`, then `w(A ∪ Z) ≤ w(A) + w(Z)`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] (B : SimpleGraph V) [DecidableRel B.Adj] + +/-- `Q` contains no triangle of `B`. -/ +def TriFree (Q : Finset V) : Prop := + ∀ u ∈ Q, ∀ v ∈ Q, ∀ x ∈ Q, B.Adj u v → B.Adj v x → B.Adj u x → False + +theorem two_mul_choose_two_int (n : ℕ) : 2 * ((n.choose 2 : ℕ) : ℤ) = (n : ℤ) * ((n : ℤ) - 1) := by + rcases n with _ | n + · simp + · have h : 2 * (n + 1).choose 2 = (n + 1) * n := by + have := Nat.mul_div_cancel' (Nat.even_mul_pred_self (n + 1)).two_dvd + rw [Nat.choose_two_right] + simpa using this + have h' : (2 : ℤ) * (((n + 1).choose 2 : ℕ) : ℤ) = ((n + 1 : ℕ) : ℤ) * (n : ℤ) := by + exact_mod_cast h + rw [h'] + push_cast + ring + +/-- **Mantel** for a column. -/ +theorem mantel {Q : Finset V} (hQ : TriFree B Q) : 4 * e B Q ≤ Q.card ^ 2 := by + set G := inducedOn B Q + have hsupp : G.support ⊆ (Q : Set V) := by + rintro u ⟨v, huv⟩ + exact huv.2.1 + have hcard : #(G.induce (Q : Set V)).edgeFinset = e B Q := by + have := SimpleGraph.card_edgeFinset_induce_of_support_subset hsupp + rw [show e B Q = #G.edgeFinset from rfl] + (convert this using 2; ext; simp) + have hcf : (G.induce (Q : Set V)).CliqueFree (2 + 1) := by + intro t ht + rw [SimpleGraph.is3Clique_iff] at ht + obtain ⟨a, b, c, hab, hac, hbc, -⟩ := ht + simp only [SimpleGraph.comap_adj, Function.Embedding.coe_subtype, G, inducedOn] at hab hac hbc + exact hQ a a.2 b b.2 c c.2 hab.1 hbc.1 hac.1 + have h := hcf.card_edgeFinset_le + have hQc : Fintype.card (Q : Set V) = Q.card := by simp + rw [SimpleGraph.turanNumber_two, hcard, hQc] at h + have := Nat.div_mul_le_self (#Q ^ 2) 4 + omega + +/-- **L7.2.** On a triangle-free column, `4 w ≤ e`. -/ +theorem four_w_le_e {Q : Finset V} (hQ : TriFree B Q) : 4 * w B Q ≤ (e B Q : ℤ) := by + have hm : (4 : ℤ) * e B Q ≤ (Q.card : ℤ) ^ 2 := by exact_mod_cast mantel B hQ + have hc := two_mul_choose_two_int Q.card + unfold w + nlinarith [sq_nonneg ((Q.card : ℤ) - 4)] + +omit [Fintype V] in +theorem card_union_choose_two {A Z : Finset V} (h : Disjoint A Z) : + (((A ∪ Z).card.choose 2 : ℕ) : ℤ) = + ((A.card.choose 2 : ℕ) : ℤ) + ((Z.card.choose 2 : ℕ) : ℤ) + (A.card : ℤ) * Z.card := by + have h1 := two_mul_choose_two_int (A ∪ Z).card + have h2 := two_mul_choose_two_int A.card + have h3 := two_mul_choose_two_int Z.card + rw [card_union_of_disjoint h] at h1 ⊢ + push_cast at h1 ⊢ + linarith + +/-- **L7.1 (fragmentation).** -/ +theorem frag_le {A Z : Finset V} (hAZ : Disjoint A Z) (hA : 3 ≤ A.card) (hZ : Z.Nonempty) + (hone : ∀ z ∈ Z, D B {z} A ≤ 1) : w B (A ∪ Z) ≤ w B A + w B Z := by + have hD : D B (A ∪ Z) (A ∪ Z) = D B A A + D B A Z + (D B Z A + D B Z Z) := by + rw [D_union_left B hAZ, D_union_right B hAZ, D_union_right B hAZ] + have hZA : D B Z A ≤ Z.card := by + rw [D_eq_sum_singleton_left] + calc ∑ z ∈ Z, D B {z} A ≤ ∑ _z ∈ Z, 1 := Finset.sum_le_sum hone + _ = Z.card := by simp + have hAZ' : D B A Z = D B Z A := D_comm B A Z + have hc := card_union_choose_two hAZ + have hZpos : 1 ≤ Z.card := hZ.card_pos + rw [w_eq_D, w_eq_D, w_eq_D, hD, hc] + push_cast + have : ((D B Z A : ℕ) : ℤ) ≤ Z.card := by exact_mod_cast hZA + have hA' : (3 : ℤ) ≤ A.card := by exact_mod_cast hA + have hZ' : (1 : ℤ) ≤ Z.card := by exact_mod_cast hZpos + rw [hAZ'] + nlinarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Hosts.lean b/LeanPool/SplitCliqueGap/GapExtremal/Hosts.lean new file mode 100644 index 0000000000..fd54ea98d1 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Hosts.lean @@ -0,0 +1,283 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Source +public import Mathlib.LinearAlgebra.Dual.Lemmas +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs +import Mathlib.Tactic.Abel + +/-! +# Concrete hosts (ledger §8, L2.2, L8.1–L8.2) + +Hosts are indexed by `(F × W) × F × F` (exterior directions: representative, fibre value, label) +and by +`(F × W) × Sym2 F` (selected directions: representative, colour pair). + +* `rep d`: a canonical generator of the line `F ∙ d`; `rep (-d) = rep d`. +* `sepFun r`: for an exterior direction `r`, a functional vanishing on `r` and on no `u c` (L2.2, +from SEP). +* `lab r`: a functional not vanishing on `r` (labels, so that no division by 2 is needed). +* `hostHyp`: the hypotheses of the bridge hold. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] + +/-! ### Canonical representatives of directions -/ + +open Classical in +/-- A chosen nonzero vector of a submodule (or `0`). -/ +noncomputable def repOf (S : Submodule F (F × W)) : F × W := + if h : ∃ v ∈ S, v ≠ 0 then h.choose else 0 + +/-- Canonical generator of the line spanned by `d`. -/ +noncomputable def rep (d : F × W) : F × W := repOf (F ∙ d) + +theorem rep_spec {d : F × W} (hd : d ≠ 0) : rep d ≠ 0 ∧ ∃ s : F, s ≠ 0 ∧ rep d = s • d := by + classical + have hex : ∃ v ∈ (F ∙ d), v ≠ 0 := ⟨d, Submodule.mem_span_singleton_self d, hd⟩ + have hr : rep d = hex.choose := by unfold rep repOf; rw [dite_eq_left hex] + obtain ⟨hmem, hne⟩ := hex.choose_spec + rw [← hr] at hmem hne + obtain ⟨s, hs⟩ := Submodule.mem_span_singleton.mp hmem + refine ⟨hne, s, fun h0 => hne (by rw [← hs, h0, zero_smul]), hs.symm⟩ + +theorem rep_smul {t : F} (ht : t ≠ 0) (d : F × W) : rep (t • d) = rep d := by + unfold rep + rw [Submodule.span_singleton_smul_eq (IsUnit.mk0 t ht)] + +theorem rep_neg (d : F × W) : rep (-d) = rep d := by + rw [← neg_one_smul F d, rep_smul (neg_ne_zero.mpr one_ne_zero)] + +/-- `d = (rep d) / s` for some nonzero `s`. -/ +theorem eq_smul_rep {d : F × W} (hd : d ≠ 0) : ∃ a : F, a ≠ 0 ∧ d = a • rep d := by + obtain ⟨-, s, hs, h⟩ := rep_spec hd + exact ⟨s⁻¹, inv_ne_zero hs, by rw [h, smul_smul, inv_mul_cancel₀ hs, one_smul]⟩ + +/-! ### Selected and exterior directions -/ + +variable (C : Finset W) (σ : Fin 6 ↪ F) + +/-- A direction parallel to some `u c`, `c ∈ C`. -/ +def Par (d : F × W) : Prop := ∃ c ∈ C, ∃ t : F, d = t • u c + +/-- An exterior direction. -/ +def Ext (d : F × W) : Prop := d ≠ 0 ∧ ¬ Par C d + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem exists_sepFun (hS : IsSep F (C : Set W)) {r : F × W} (hr : Ext C r) : + ∃ L : (F × W) →ₗ[F] F, L r = 0 ∧ ∀ c ∈ C, L (u c) ≠ 0 := by + by_cases h1 : r.1 = 0 + · refine ⟨LinearMap.fst F F W, by simpa using h1, fun c _ => by simp [u]⟩ + · set z := r.1⁻¹ • r.2 + have hz : z ∉ (C : Set W) := by + intro hz + apply hr.2 + refine ⟨z, hz, r.1, ?_⟩ + ext + · simp [u] + · simp [u, z, smul_smul, mul_inv_cancel₀ h1] + obtain ⟨l, b, hl, hlC⟩ := hS z hz + refine ⟨l.comp (LinearMap.snd F F W) - b • LinearMap.fst F F W, ?_, ?_⟩ + · simp only [LinearMap.sub_apply, LinearMap.comp_apply, LinearMap.snd_apply, + LinearMap.smul_apply, LinearMap.fst_apply, smul_eq_mul] + have : l r.2 = r.1 * l z := by simp [z, ← mul_assoc, mul_inv_cancel₀ h1] + rw [this, hl]; ring + · intro c hc + simp only [LinearMap.sub_apply, LinearMap.comp_apply, LinearMap.snd_apply, + LinearMap.smul_apply, LinearMap.fst_apply, smul_eq_mul, u, mul_one] + exact sub_ne_zero.mpr (hlC c (by exact_mod_cast hc)) + +open Classical in +/-- The separating functional of an exterior direction (L2.2). -/ +noncomputable def sepFun (hS : IsSep F (C : Set W)) (r : F × W) : (F × W) →ₗ[F] F := + if h : Ext C r then (exists_sepFun C hS h).choose else 0 + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem sepFun_spec (hS : IsSep F (C : Set W)) {r : F × W} (hr : Ext C r) : + sepFun C hS r r = 0 ∧ ∀ c ∈ C, sepFun C hS r (u c) ≠ 0 := by + classical + unfold sepFun + rw [dite_eq_left hr] + exact (exists_sepFun C hS hr).choose_spec + +open Classical in +/-- A label functional, nonzero on `r ≠ 0`. -/ +noncomputable def lab (r : F × W) : (F × W) →ₗ[F] F := + if h : r ≠ 0 then (Module.Projective.exists_dual_ne_zero F h).choose else 0 + +omit [Fintype F] [Fintype W] in +theorem lab_spec {r : F × W} (hr : r ≠ 0) : lab r r ≠ 0 := by + classical + unfold lab + rw [dite_eq_left hr] + exact (Module.Projective.exists_dual_ne_zero F hr).choose_spec + +/-! ### Hosts, palettes and the assignment -/ + +/-- Host indices. -/ +abbrev HostIdx (F W : Type*) := ((F × W) × F × F) ⊕ ((F × W) × Sym2 F) + +/-- Colour pairs that are not edges of `H12`. -/ +def GoodS (s : Sym2 F) : Prop := ∀ i j : Fin 6, s = s(σ i, σ j) → ¬ H12.graph.Adj i j + +open Classical in +/-- The palettes. -/ +noncomputable def palette (hS : IsSep F (C : Set W)) : HostIdx F W → Finset (F × W) + | .inl ⟨r, b, _⟩ => if Ext C r then univ.filter (fun z => sepFun C hS r z = b) else ∅ + | .inr ⟨_, s⟩ => if GoodS σ s then univ.filter (fun z => z.1 ∈ s) else ∅ + +/-- A pair with a selected direction. -/ +def Sel (x y : F × W) : Prop := ∃ c ∈ C, y - x = (y.1 - x.1) • u c + +open Classical in +/-- The assignment of marked pairs to hosts. -/ +noncomputable def assign (hS : IsSep F (C : Set W)) (x y : F × W) : HostIdx F W := + if Sel C x y then .inr (rep (y - x), s(x.1, y.1)) + else .inl (rep (y - x), sepFun C hS (rep (y - x)) x, lab (rep (y - x)) (x + y)) + +variable {C σ} + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem sel_symm {x y : F × W} : Sel C x y ↔ Sel C y x := by + constructor <;> rintro ⟨c, hc, h⟩ <;> refine ⟨c, hc, ?_⟩ <;> + · rw [← neg_sub, h, ← neg_smul, neg_sub] + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem sel_fst_ne {x y : F × W} (hxy : x ≠ y) (h : Sel C x y) : x.1 ≠ y.1 := by + obtain ⟨c, -, h⟩ := h + intro h1 + rw [h1, sub_self, zero_smul, sub_eq_zero] at h + exact hxy h.symm + +theorem ext_of_not_sel {x y : F × W} (hxy : x ≠ y) (h : ¬ Sel C x y) : Ext C (rep (y - x)) := by + have hd : y - x ≠ 0 := sub_ne_zero.mpr hxy.symm + refine ⟨(rep_spec hd).1, ?_⟩ + rintro ⟨c, hc, t, ht⟩ + obtain ⟨a, -, ha⟩ := eq_smul_rep hd + apply h + refine ⟨c, hc, ?_⟩ + have e : y - x = (a * t) • u c := by rw [ha, ht, smul_smul] + have e1 : y.1 - x.1 = a * t := by simpa [u] using congrArg Prod.fst e + rw [e1, ← e] + +theorem rep_fst_ne_of_sel {x y : F × W} (hxy : x ≠ y) (h : Sel C x y) : (rep (y - x)).1 ≠ 0 := by + have hd : y - x ≠ 0 := sub_ne_zero.mpr hxy.symm + obtain ⟨-, s, hs, hr⟩ := rep_spec hd + rw [hr] + simp only [Prod.smul_fst, Prod.fst_sub, smul_eq_mul] + exact mul_ne_zero hs (sub_ne_zero.mpr (sel_fst_ne hxy h).symm) + +theorem sepFun_eq_of_ext (hS : IsSep F (C : Set W)) {x y : F × W} (hxy : x ≠ y) + (hext : Ext C (rep (y - x))) : sepFun C hS (rep (y - x)) y = sepFun C hS (rep (y - x)) x := by + obtain ⟨a, -, ha⟩ := eq_smul_rep (sub_ne_zero.mpr hxy.symm) + generalize rep (y - x) = r at ha hext ⊢ + have hy : y = x + a • r := by rw [← ha]; abel + rw [hy, map_add, map_smul, (sepFun_spec C hS hext).1, smul_zero, add_zero] + +variable (hS : IsSep F (C : Set W)) + +theorem hostHyp : HostHyp (Bgr C σ) (palette C σ hS) (assign C hS) where + indep := by + rintro (⟨r, b, l⟩ | ⟨r, s⟩) z hz z' hz' hadj + · simp only [palette] at hz hz' + split_ifs at hz hz' with hr + · simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hz hz' + obtain ⟨c, hc, hdir⟩ := hadj.2.1 + have h0 : sepFun C hS r (z' - z) = 0 := by rw [map_sub, hz, hz', sub_self] + rw [hdir, map_smul, smul_eq_mul] at h0 + rcases mul_eq_zero.mp h0 with h | h + · rw [h, zero_smul, sub_eq_zero] at hdir + exact hadj.1 hdir.symm + · exact (sepFun_spec C hS hr).2 c hc h + · simp at hz + · simp only [palette] at hz hz' + split_ifs at hz hz' with hs + · simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hz hz' + obtain ⟨i, j, hi, hj, hij⟩ := hadj.2.2 + have hne := Bgr_fst_ne hadj + have : s = s(z.1, z'.1) := (Sym2.mem_and_mem_iff hne).mp ⟨hz, hz'⟩ + exact hs i j (by rw [this, hi, hj]) hij + · simp at hz + cover := by + intro x y hxy hnadj + by_cases hsel : Sel C x y + · simp only [assign, ite_eq_left hsel, palette] + have hgood : GoodS σ s(x.1, y.1) := by + intro i j hs hij + apply hnadj + obtain ⟨c, hc, hdir⟩ := hsel + refine ⟨hxy, ⟨c, hc, hdir⟩, ?_⟩ + rcases Sym2.eq_iff.mp hs with ⟨h1, h2⟩ | ⟨h1, h2⟩ + · exact ⟨i, j, h1.symm, h2.symm, hij⟩ + · exact ⟨j, i, h1.symm, h2.symm, hij.symm⟩ + rw [ite_eq_left hgood] + simp + · have hext := ext_of_not_sel hxy hsel + simp only [assign, ite_eq_right hsel, palette, ite_eq_left hext, Finset.mem_filter, + Finset.mem_univ, + true_and] + exact sepFun_eq_of_ext hS hxy hext + symm := by + intro x y + by_cases hxy : x = y + · rw [hxy] + by_cases hsel : Sel C x y + · have hsel' : Sel C y x := sel_symm.mp hsel + simp only [assign, ite_eq_left hsel, ite_eq_left hsel'] + rw [← neg_sub x y, rep_neg, Sym2.eq_swap] + · have hsel' : ¬ Sel C y x := fun h => hsel (sel_symm.mpr h) + simp only [assign, ite_eq_right hsel, ite_eq_right hsel'] + have hext := ext_of_not_sel hxy hsel + have hxyv := sepFun_eq_of_ext hS hxy hext + rw [show x - y = -(y - x) by abel, rep_neg, add_comm x y, hxyv] + inj := by + intro x y y' hxy hn hxy' hn' heq + by_cases hs : Sel C x y <;> by_cases hs' : Sel C x y' + · simp only [assign, ite_eq_left hs, ite_eq_left hs', Sum.inr.injEq, Prod.mk.injEq] at heq + obtain ⟨hr, hsym⟩ := heq + have h1 : y.1 = y'.1 := by + rcases Sym2.eq_iff.mp hsym with ⟨-, h⟩ | ⟨h, h'⟩ + · exact h + · exact absurd h'.symm (sel_fst_ne hxy hs) + obtain ⟨a, -, ha⟩ := eq_smul_rep (sub_ne_zero.mpr hxy.symm) + obtain ⟨a', -, ha'⟩ := eq_smul_rep (sub_ne_zero.mpr hxy'.symm) + have hfst := rep_fst_ne_of_sel hxy' hs' + rw [hr] at ha + generalize rep (y' - x) = r at ha ha' hfst + have e1 : y.1 - x.1 = a * r.1 := by simpa using congrArg Prod.fst ha + have e2 : y'.1 - x.1 = a' * r.1 := by simpa using congrArg Prod.fst ha' + have haa : a = a' := mul_right_cancel₀ hfst (by rw [← e1, ← e2, h1]) + have : y - x = y' - x := by rw [ha, ha', haa] + exact sub_left_inj.mp this + · simp [assign, ite_eq_left hs, ite_eq_right hs'] at heq + · simp [assign, ite_eq_right hs, ite_eq_left hs'] at heq + · simp only [assign, ite_eq_right hs, ite_eq_right hs', Sum.inl.injEq, Prod.mk.injEq] at heq + obtain ⟨hr, -, hl⟩ := heq + obtain ⟨a, -, ha⟩ := eq_smul_rep (sub_ne_zero.mpr hxy.symm) + obtain ⟨a', -, ha'⟩ := eq_smul_rep (sub_ne_zero.mpr hxy'.symm) + have hr0 : rep (y' - x) ≠ 0 := (rep_spec (sub_ne_zero.mpr hxy'.symm)).1 + rw [hr] at ha hl + generalize rep (y' - x) = r at ha ha' hl hr0 + have hy : y = x + a • r := by rw [← ha]; abel + have hy' : y' = x + a' • r := by rw [← ha']; abel + rw [hy, hy'] at hl + simp only [map_add, map_smul, smul_eq_mul] at hl + have haa : a = a' := mul_right_cancel₀ (lab_spec hr0) (by linear_combination hl) + rw [hy, hy', haa] + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean new file mode 100644 index 0000000000..f9cf362a5e --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean @@ -0,0 +1,178 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.PMain +public import LeanPool.SplitCliqueGap.GapExtremal.Exponent +public import Mathlib.Algebra.Field.ZMod +import Mathlib.Tactic.NormNum.Prime +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! +# Product caps need no SEP, and the two-layer core over `F₅` (ledger §16.1, §16.3) + +* `prodSep`: for `C = A^j` (any cap `A ⊆ U`, no separability) a separating family with values in `U` + (fix the coordinates of one block where `z ∉ A`). +* `layered`: the positioned core `V = (F₅ × W) ⊕ W`; the twin `inr w` doubles the colour-0 point +`(0, w)`; + labels `0, 1, 2, 3, 4, 5` sit at `0, 1, twin, 2, 3, 4`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-! ### Separating maps for product caps -/ + +section ProdSep + +variable {F : Type} [Field F] [Fintype F] [DecidableEq F] +variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +omit [DecidableEq F] [DecidableEq U] [Fintype F] [Fintype U] in +theorem ext_bad {A : Finset U} {j : ℕ} {r : F × (Fin j → U)} (hr : Ext (capPow A j) r) + (h1 : r.1 ≠ 0) : ∃ i, (r.1⁻¹ • r.2) i ∉ A := by + by_contra h + push Not at h + apply hr.2 + refine ⟨r.1⁻¹ • r.2, ?_, r.1, ?_⟩ + · simp only [capPow, Fintype.mem_piFinset]; exact h + · ext + · simp [u] + · simp [u, smul_smul, mul_inv_cancel₀ h1] + +open Classical in +/-- The separating map of a direction for a product cap. -/ +noncomputable def prodSepMap (A : Finset U) (e : U) (j : ℕ) (r : F × (Fin j → U)) : + (F × (Fin j → U)) →ₗ[F] U := + if h : r.1 ≠ 0 ∧ ∃ i, (r.1⁻¹ • r.2) i ∉ A then + (LinearMap.proj h.2.choose).comp (LinearMap.snd F F (Fin j → U)) - + (LinearMap.fst F F (Fin j → U)).smulRight ((r.1⁻¹ • r.2) h.2.choose) + else (LinearMap.fst F F (Fin j → U)).smulRight e + +/-- **L16.1.** Product caps have a separating family (no SEP needed). -/ +noncomputable def prodSep (A : Finset U) {e : U} (he : e ≠ 0) (j : ℕ) : SepFam F (capPow A j) U + where + sep := prodSepMap A e j + sep_self := by + intro r hr + unfold prodSepMap + split_ifs with h + · simp only [LinearMap.sub_apply, LinearMap.comp_apply, LinearMap.snd_apply, + LinearMap.proj_apply, + LinearMap.smulRight_apply, LinearMap.fst_apply, Pi.smul_apply, smul_smul, + mul_inv_cancel₀ h.1, one_smul, sub_self] + · have h1 : r.1 = 0 := by + by_contra h1 + exact h ⟨h1, ext_bad hr h1⟩ + simp [h1] + sep_u := by + intro r hr c hc + unfold prodSepMap + split_ifs with h + · have hci : c h.2.choose ∈ A := by + simp only [capPow, Fintype.mem_piFinset] at hc; exact hc _ + simp only [LinearMap.sub_apply, LinearMap.comp_apply, LinearMap.snd_apply, + LinearMap.proj_apply, + LinearMap.smulRight_apply, LinearMap.fst_apply, u, one_smul] + intro h0 + rw [sub_eq_zero] at h0 + exact h.2.choose_spec (h0 ▸ hci) + · simpa [u] using he + +end ProdSep + +/-! ### The two-layer core over `F₅` -/ + +section Layered + +/-- The five-element field used in the layered construction. -/ +abbrev F5 := ZMod 5 + +instance : Fact (Nat.Prime 5) := ⟨by norm_num⟩ + +/-- Pin the additive group of `ZMod 5` to the ring structure (otherwise instance search may pick the +`IsSimpleAddGroup` route, which is not reducibly compatible with the module instances). -/ +instance (priority := 10000) addCommGroupF5 : AddCommGroup (ZMod 5) := Ring.toAddCommGroup + +/-- Label positions: `0 ↦ 0, 1 ↦ 1, 2 ↦ twin, 3 ↦ 2, 4 ↦ 3, 5 ↦ 4`. -/ +def σL : Fin 6 ↪ Option F5 := + ⟨![some 0, some 1, none, some 2, some 3, some 4], by decide⟩ + +/-- The colour of a layer, with colour zero assigned to the outer layer. -/ +def colL (o : Option F5) : F5 := o.getD 0 + +variable {W : Type} [AddCommGroup W] [Module F5 W] [Fintype W] [DecidableEq W] + +/-- The two-layer positioned core. -/ +def layered : PData F5 W ((F5 × W) ⊕ W) (Option F5) where + base := Sum.elim id fun w => ((0 : F5), w) + pos := Sum.elim (fun y => some y.1) fun _ => none + col := colL + σ := σL + base_fst := by rintro (y | w) <;> rfl + inj := by + rintro (y | w) (y' | w') hb hp + · simpa using hb + · simp at hp + · simp at hp + · simp only [Sum.elim_inr, Prod.mk.injEq, true_and] at hb; rw [hb] + fib := by + rintro (y | w) (y' | w') (y'' | w'') h₁ h₂ <;> + first + | exact Or.inl (congrArg Sum.inl h₁) + | exact Or.inl (congrArg Sum.inr (congrArg Prod.snd h₁)) + | exact Or.inr (Or.inl (congrArg Sum.inl h₂)) + | exact Or.inr (Or.inl (congrArg Sum.inr (congrArg Prod.snd h₂))) + | exact Or.inr (Or.inr (congrArg Sum.inl (h₁.symm.trans h₂))) + | exact Or.inr (Or.inr (congrArg Sum.inr (congrArg Prod.snd (h₁.symm.trans h₂)))) + rl y i := if σL i = none then Sum.inr y.2 else Sum.inl y + rl_base := by + intro y i hy + split_ifs with h + · simp only [Sum.elim_inr] + rw [h] at hy + ext + · exact hy.symm + · rfl + · rfl + rl_pos := by + intro y i hy + split_ifs with h + · simp [h] + · simp only [Sum.elim_inl] + obtain ⟨a, ha⟩ := Option.ne_none_iff_exists'.mp h + rw [ha] at hy ⊢ + simp only [colL, Option.getD_some] at hy + rw [hy] + colσ := by decide + +omit [DecidableEq W] [Fintype W] in +theorem layered_same : + ∀ v v' : (F5 × W) ⊕ W, (layered (W := W)).base v = (layered (W := W)).base v' → + ∀ i j, σL i = (layered (W := W)).pos v → σL j = (layered (W := W)).pos v' → + ¬ H12.graph.Adj i j := by + have key : ∀ i j : Fin 6, σL i = σL j → ¬ H12.graph.Adj i j := by decide + have key2 : ∀ i j : Fin 6, σL i = some 0 → σL j = none → ¬ H12.graph.Adj i j := by decide + have key3 : ∀ i j : Fin 6, σL i = none → σL j = some 0 → ¬ H12.graph.Adj i j := by decide + rintro (y | w) (y' | w') hb i j hi hj + · simp only [layered, Sum.elim_inl, id] at hb hi hj + exact key i j (by rw [hi, hj, hb]) + · simp only [layered, Sum.elim_inl, Sum.elim_inr, id] at hb hi hj + exact key2 i j (by rw [hi, hb]) hj + · simp only [layered, Sum.elim_inl, Sum.elim_inr, id] at hb hi hj + exact key3 i j hi (by rw [hj, ← hb]) + · simp only [layered, Sum.elim_inr] at hi hj + exact key i j (by rw [hi, hj]) + +end Layered + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean new file mode 100644 index 0000000000..6a17b1c732 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean @@ -0,0 +1,124 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.WeightCap +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# Beyond 5/3 (ledger §16) + +* `exponent_of_family`: a family of split graphs with `|V_j| ≤ K M^j` and `gap ≥ a^j M^j / 3` gives + `gap ≥ c n^{1 + log a / log M}` for every `n ≥ K M` (graphs with at most `n` vertices). +* `tp_layered`: for every cap `A` (no separability) in a finite `F₅`-module `U`, the two-layer +construction over + `A^j` gives exponent `1 + log |A| / log |U|`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-- **From a family to all orders.** -/ +theorem exponent_of_family {M a K : ℕ} (hM : 2 ≤ M) (ha : 1 ≤ a) (hK : 0 < K) + (V : ℕ → Type) [∀ j, Fintype (V j)] [∀ j, DecidableEq (V j)] (G : ∀ j, SimpleGraph (V j)) + (hcard : ∀ j, Fintype.card (V j) ≤ K * M ^ j) (hsplit : ∀ j, IsSplit (G j)) + (hgap : ∀ j, (a : ℝ) ^ j * (M : ℝ) ^ j / 3 ≤ gap (G j)) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, K * M ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log a / Real.log M) ≤ gap G' := by + set α := 1 + Real.log a / Real.log M + have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) + have hα : 0 ≤ α := by + have h1 : 0 ≤ Real.log a := Real.log_nonneg (by exact_mod_cast ha) + have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) + positivity + refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ + set j := Nat.log M (n / K) with hj + have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by + have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by + have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) + omega) + have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ + refine ⟨V j, inferInstance, inferInstance, G j, ?_, hsplit j, ?_⟩ + · calc Fintype.card (V j) ≤ K * M ^ j := hcard j + _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj + _ ≤ n := Nat.mul_div_le n K + · have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by + have h1 : n < K * (n / K) + K := by + have := Nat.div_add_mod n K + have := Nat.mod_lt n hK + omega + have h2 : n < K * M ^ (j + 1) := by + calc n < K * (n / K) + K := h1 + _ = K * (n / K + 1) := by ring + _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt + rw [div_le_iff₀ (by positivity)] + have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 + rw [pow_succ] at this + nlinarith + have hpow := pow_rpow_alpha ha hM j + have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := + Real.rpow_le_rpow (by positivity) hn' hα + have hsplit' : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by + rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] + ring + refine le_trans ?_ (hgap j) + calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by + rw [hsplit']; ring + _ ≤ ((M : ℝ) ^ j) ^ α / 3 := by linarith + _ = (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + +variable {U : Type} [AddCommGroup U] [Module F5 U] [Fintype U] [DecidableEq U] + +/-- The layered graph of `A^j`. -/ +abbrev LV (U : Type) (j : ℕ) := + ((F5 × (Fin j → U)) ⊕ (Fin j → U)) ⊕ PHostIdx F5 (Fin j → U) (Option F5) U + +omit [DecidableEq U] in +/-- **Theorem 16.0, conditional form.** Any cap `A` in a finite `F₅`-module gives exponent +`1 + log |A| / log |U|` (no separability). -/ +theorem tp_layered {A : Finset U} (hA : IsCap F5 (A : Set U)) (hA0 : A.Nonempty) {e : U} (he : e ≠ + 0) + (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, 636 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + classical + set M := Fintype.card U + have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by + obtain ⟨a0, ha0⟩ := hA0 + exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ + refine exponent_of_family hM hA0.card_pos (by positivity) (LV U) + (fun j => hostGraph (ppalette (layered (W := Fin j → U)) (capPow A j) (prodSep A he j))) + (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) + · simp only [LV, PHostIdx, Fintype.card_sum, Fintype.card_prod, Fintype.card_pi, + Finset.prod_const, Finset.card_univ, + Fintype.card_fin, Sym2.card, Fintype.card_option, ZMod.card] + have hM1 : 1 ≤ Fintype.card U := by omega + have h72 : Nat.choose 7 2 = 21 := by decide + rw [h72] + have hp : Fintype.card U ^ j ≤ Fintype.card U * Fintype.card U ^ j := + Nat.le_mul_of_pos_left _ (by omega) + nlinarith + · have h := pgap_ge_third (layered (W := Fin j → U)) (isCap_capPow hA j) (hcapne j) + (prodSep A he j) layered_same + rw [card_capPow] at h + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [hW] at h + push_cast at h + exact h + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/LocalEmbed.lean b/LeanPool/SplitCliqueGap/GapExtremal/LocalEmbed.lean new file mode 100644 index 0000000000..a6e38b94e6 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/LocalEmbed.lean @@ -0,0 +1,167 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Global +public import LeanPool.SplitCliqueGap.GapExtremal.LocalH12 +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.SplitIfs + +/-! +# The local lemma on a block (ledger §6 → §7) + +A block `ℓ` whose points carry injective colours `f : V → F`, with `B`-edges inside `ℓ` only +between colours +`σ i, σ j` with `ij ∈ H12` (`σ : Fin 6 ↪ F`; the other colours are isolated), satisfies the +hypothesis of +`global_bound` with `c = 8`: + + `∑_{Q ∈ T} (4 w(Q) - e(Q)) ≤ 32 - e(ℓ)` for packings `T` inside `ℓ`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +namespace H12 + +/-- `H12` as a simple graph on `Fin 6`. -/ +def graph : SimpleGraph (Fin 6) where + Adj i j := adj i j = true ∨ adj j i = true + symm := ⟨fun _ _ h => h.symm⟩ + loopless := ⟨by decide⟩ + +instance : DecidableRel graph.Adj := fun i j => + inferInstanceAs (Decidable (adj i j = true ∨ adj j i = true)) + +theorem e_graph_eq : ∀ Q : Finset (Fin 6), e graph Q = eH Q := by decide +kernel + +end H12 + +variable {V : Type*} [Fintype V] [DecidableEq V] {B : SimpleGraph V} [DecidableRel B.Adj] + +/-- Transport of edge counts along a map injective on the column. -/ +theorem e_le_e_image {W : Type*} [Fintype W] [DecidableEq W] (H : SimpleGraph W) [DecidableRel + H.Adj] + (g : V → W) {Q : Finset V} (hg : Set.InjOn g Q) + (hadj : ∀ u ∈ Q, ∀ v ∈ Q, B.Adj u v → H.Adj (g u) (g v)) : e B Q ≤ e H (Q.image g) := by + unfold e + refine Finset.card_le_card_of_injOn (Sym2.map g) ?_ ?_ + · intro s hs + induction s using Sym2.ind with + | h u v => + rw [Finset.mem_coe, SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs + rw [Sym2.map_mk, Finset.mem_coe, SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] + exact ⟨hadj u hs.2.1 v hs.2.2 hs.1, Finset.mem_image_of_mem g hs.2.1, + Finset.mem_image_of_mem g hs.2.2⟩ + · intro s hs t ht hst + induction s using Sym2.ind with + | h a b => + induction t using Sym2.ind with + | h c d => + rw [Finset.mem_coe, SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs ht + simp only [Sym2.map_mk, Sym2.eq_iff] at hst + rw [Sym2.eq_iff] + rcases hst with ⟨h1, h2⟩ | ⟨h1, h2⟩ + · exact Or.inl ⟨hg hs.2.1 ht.2.1 h1, hg hs.2.2 ht.2.2 h2⟩ + · exact Or.inr ⟨hg hs.2.1 ht.2.2 h1, hg hs.2.2 ht.2.1 h2⟩ + +/-- **Local lemma on a coloured block.** -/ +theorem block_local {F : Type*} (f : V → F) (σ : Fin 6 ↪ F) {ℓ : Finset V} + (hf : Set.InjOn f ℓ) + (hadj : ∀ u ∈ ℓ, ∀ v ∈ ℓ, B.Adj u v → ∃ i j, σ i = f u ∧ σ j = f v ∧ H12.graph.Adj i j) + (T : Finset (Finset V)) (hTsub : ∀ Q ∈ T, Q ⊆ ℓ) (hT : IsPack T) : + ∑ Q ∈ T, (4 * w B Q - e B Q) ≤ 32 - e B ℓ := by + classical + -- the colour index map, defined on active points + let g : V → Fin 6 := fun u => Function.invFun σ (f u) + let act : Finset V → Finset V := fun Q => Q.filter (fun u => ∃ i, σ i = f u) + have hg_spec : ∀ u, (∃ i, σ i = f u) → σ (g u) = f u := fun u h => Function.invFun_eq h + have hinj : ∀ Q ⊆ ℓ, Set.InjOn g (act Q) := by + intro Q hQ u hu v hv huv + have hu' := (Finset.mem_filter.mp hu) + have hv' := (Finset.mem_filter.mp hv) + apply hf (hQ hu'.1) (hQ hv'.1) + rw [← hg_spec u hu'.2, ← hg_spec v hv'.2] + exact congrArg σ huv + -- edges of `Q` live on active points and inject into `H12` + have he : ∀ Q ⊆ ℓ, e B Q ≤ H12.eH ((act Q).image g) := by + intro Q hQ + have h1 : e B Q ≤ e B (act Q) := by + unfold e + refine Finset.card_le_card fun s hs => ?_ + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs ⊢ + obtain ⟨i, j, hi, hj, -⟩ := hadj u (hQ hs.2.1) v (hQ hs.2.2) hs.1 + exact ⟨hs.1, Finset.mem_filter.mpr ⟨hs.2.1, i, hi⟩, Finset.mem_filter.mpr ⟨hs.2.2, j, hj⟩⟩ + have h2 : e B (act Q) ≤ e H12.graph ((act Q).image g) := by + refine e_le_e_image H12.graph g (hinj Q hQ) fun u hu v hv huv => ?_ + have hu' := Finset.mem_filter.mp hu + have hv' := Finset.mem_filter.mp hv + obtain ⟨i, j, hi, hj, hij⟩ := hadj u (hQ hu'.1) v (hQ hv'.1) huv + have : g u = i := σ.injective (by rw [hg_spec u hu'.2, hi]) + have : g v = j := σ.injective (by rw [hg_spec v hv'.2, hj]) + simp [*] + rw [← H12.e_graph_eq] + exact h1.trans h2 + have hcardQ : ∀ Q, ((act Q).image g).card ≤ Q.card := + fun Q => Finset.card_image_le.trans (Finset.card_filter_le _ _) + -- pointwise comparison with the `Fin 6` objective + have hpt : ∀ Q ⊆ ℓ, 4 * w B Q - e B Q ≤ H12.f ((act Q).image g) := by + intro Q hQ + have h1 := he Q hQ + have h2 := hcardQ Q + have hc : (((act Q).image g).card.choose 2 : ℤ) ≤ (Q.card.choose 2 : ℤ) := by + exact_mod_cast Nat.choose_le_choose 2 h2 + unfold w H12.f + have h1' : (e B Q : ℤ) ≤ H12.eH ((act Q).image g) := by exact_mod_cast h1 + linarith + -- images of distinct pieces share at most one colour + have hcompat : ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → + (((act Q).image g) ∩ ((act Q').image g)).card ≤ 1 := by + intro Q hQ Q' hQ' hne + have hsub : act Q ∪ act Q' ⊆ act ℓ := Finset.union_subset + (Finset.filter_subset_filter _ (hTsub Q hQ)) (Finset.filter_subset_filter _ (hTsub Q' hQ')) + rw [← Finset.image_inter_of_injOn] + · refine Finset.card_image_le.trans ((Finset.card_le_card ?_).trans (hT Q hQ Q' hQ' hne)) + exact Finset.inter_subset_inter (Finset.filter_subset _ _) (Finset.filter_subset _ _) + · exact (hinj ℓ subset_rfl).mono (by exact_mod_cast hsub) + -- reduce to the positive pieces, which have distinct images + set T' := T.filter (fun Q => 0 < H12.f ((act Q).image g)) with hT' + have hstep1 : ∑ Q ∈ T, (4 * w B Q - e B Q) ≤ ∑ Q ∈ T', H12.f ((act Q).image g) := by + refine (Finset.sum_le_sum fun Q hQ => hpt Q (hTsub Q hQ)).trans ?_ + rw [hT', Finset.sum_filter] + exact Finset.sum_le_sum fun Q _ => by split_ifs with h <;> [exact le_rfl; exact not_lt.mp h] + have himg : Set.InjOn (fun Q => (act Q).image g) (T' : Set (Finset V)) := by + intro Q hQ Q' hQ' heq + by_contra hne + have hQT := (Finset.mem_filter.mp hQ) + have hQT' := (Finset.mem_filter.mp hQ') + have h3 := H12.three_le_card_of_pos _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hQT.2⟩) + have h1 := hcompat Q hQT.1 Q' hQT'.1 hne + simp only at heq + rw [heq, Finset.inter_self] at h1 + rw [heq] at h3 + omega + rw [← Finset.sum_image himg] at hstep1 + have hfin := H12.local_bound (T'.image fun Q => (act Q).image g) (by + intro P hP P' hP' hne + obtain ⟨Q, hQ, rfl⟩ := Finset.mem_image.mp hP + obtain ⟨Q', hQ', rfl⟩ := Finset.mem_image.mp hP' + exact hcompat Q (Finset.mem_filter.mp hQ).1 Q' (Finset.mem_filter.mp hQ').1 + (fun h => hne (by rw [h]))) + have heℓ : (e B ℓ : ℤ) ≤ 12 := by + have := he ℓ subset_rfl + have h12 : ∀ P : Finset (Fin 6), H12.eH P ≤ 12 := by decide +kernel + exact_mod_cast this.trans (h12 _) + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/LocalH12.lean b/LeanPool/SplitCliqueGap/GapExtremal/LocalH12.lean new file mode 100644 index 0000000000..cce64113cf --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/LocalH12.lean @@ -0,0 +1,118 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Data.Fintype.Powerset +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Data.Finset.Card +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.IntervalCases +import Mathlib.Tactic.SplitIfs + +/-! +# The local lemma for the gadget `H12` (ledger §6, L6.1) + +`H12` has the twelve edges `01,12,23,45,04,05,14,15,24,25,34,35` on `Fin 6`. For a set `Q` of +colours put +`w(Q) = 2 e_H(Q) - C(|Q|,2) - 1`. The reserved integer bound (1) of the ledger, multiplied by 4, +reads + + `∑_{Q ∈ P} (4 w(Q) - e_H(Q)) ≤ 20` for every packing `P` (pairwise intersections of size `≤ 1`). + +`local_bound` proves it on `Fin 6`; `local_bound_emb` transports it to any colour type `C` along an +embedding `σ : Fin 6 ↪ C`, the remaining colours being isolated (the isolation lemma of L6.1). +-/ + +@[expose] public section + +namespace GapExtremal.H12 + +open Finset + +/-- Adjacency of `H12`. -/ +def adj (i j : Fin 6) : Bool := + match i.val, j.val with + | 0, 1 | 1, 2 | 2, 3 | 4, 5 | 0, 4 | 0, 5 | 1, 4 | 1, 5 | 2, 4 | 2, 5 | 3, 4 | 3, 5 => true + | _, _ => false + +/-- Number of `H12` edges inside `Q` (pairs `i < j`). -/ +def eH (Q : Finset (Fin 6)) : ℕ := ((Q ×ˢ Q).filter (fun p => p.1 < p.2 ∧ adj p.1 p.2 = true)).card + +/-- The reserved local objective `4 w(Q) - e_H(Q)` with `w(Q) = 2 e_H(Q) - C(|Q|,2) - 1`. -/ +def f (Q : Finset (Fin 6)) : ℤ := 4 * (2 * (eH Q : ℤ) - (Q.card.choose 2 : ℤ) - 1) - eH Q + +/-- The pieces with positive objective. -/ +def pos : Finset (Finset (Fin 6)) := univ.filter (fun Q => 0 < f Q) + +theorem three_le_card_of_pos : ∀ Q ∈ pos, 3 ≤ Q.card := by decide +kernel + +/-- Compatibility of two pieces in a packing. -/ +def Compat (Q Q' : Finset (Fin 6)) : Prop := (Q ∩ Q').card ≤ 1 + +instance : DecidableRel Compat := fun _ _ => inferInstanceAs (Decidable (_ ≤ _)) + +theorem no_four : ∀ a ∈ pos, ∀ b ∈ pos, a ≠ b → Compat a b → ∀ c ∈ pos, a ≠ c → b ≠ c → + Compat a c → Compat b c → ∀ d ∈ pos, a ≠ d → b ≠ d → c ≠ d → Compat a d → Compat b d → + ¬ Compat c d := by + decide +kernel + +theorem triple_bound : ∀ a ∈ pos, ∀ b ∈ pos, a ≠ b → Compat a b → ∀ c ∈ pos, a ≠ c → b ≠ c → + Compat a c → Compat b c → f a + f b + f c ≤ 20 := by + decide +kernel + +theorem pair_bound : ∀ a ∈ pos, ∀ b ∈ pos, a ≠ b → Compat a b → f a + f b ≤ 20 := by + decide +kernel + +theorem single_bound : ∀ a ∈ pos, f a ≤ 20 := by decide +kernel + +/-- Packings of positive pieces have at most three members. -/ +theorem card_le_three {T : Finset (Finset (Fin 6))} (hTp : T ⊆ pos) + (hT : ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → Compat Q Q') : T.card ≤ 3 := by + by_contra h + push Not at h + obtain ⟨U, hUT, hU⟩ := Finset.exists_subset_card_eq (show 4 ≤ T.card by omega) + obtain ⟨a, b, c, d, hab, hac, had, hbc, hbd, hcd, rfl⟩ := Finset.card_eq_four.mp hU + have m : ∀ x ∈ ({a, b, c, d} : Finset (Finset (Fin 6))), x ∈ T := fun x hx => hUT hx + have ha := m a (by simp); have hb := m b (by simp); have hc := m c (by simp); have hd := + m d (by simp) + exact no_four a (hTp ha) b (hTp hb) hab (hT a ha b hb hab) c (hTp hc) hac hbc (hT a ha c hc hac) + (hT b hb c hc hbc) d (hTp hd) had hbd hcd (hT a ha d hd had) (hT b hb d hd hbd) (hT c hc d hd + hcd) + +/-- **L6.1 on `Fin 6`.** -/ +theorem local_bound (T : Finset (Finset (Fin 6))) + (hT : ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → Compat Q Q') : ∑ Q ∈ T, f Q ≤ 20 := by + set T' := T.filter (fun Q => 0 < f Q) with hT' + have hle : ∑ Q ∈ T, f Q ≤ ∑ Q ∈ T', f Q := by + rw [hT', Finset.sum_filter] + exact Finset.sum_le_sum fun Q _ => by split_ifs with h <;> [exact le_rfl; exact not_lt.mp h] + have hTp : T' ⊆ pos := fun Q hQ => by + simp only [hT', Finset.mem_filter] at hQ + simpa [pos] using hQ.2 + have hT'c : ∀ Q ∈ T', ∀ Q' ∈ T', Q ≠ Q' → Compat Q Q' := fun Q hQ Q' hQ' hne => + hT Q (Finset.mem_of_mem_filter Q hQ) Q' (Finset.mem_of_mem_filter Q' hQ') hne + have hcard := card_le_three hTp hT'c + refine hle.trans ?_ + interval_cases h : T'.card + · rw [Finset.card_eq_zero.mp h]; simp + · obtain ⟨a, ha⟩ := Finset.card_eq_one.mp h + rw [ha, Finset.sum_singleton] + exact single_bound a (hTp (by simp [ha])) + · obtain ⟨a, b, hab, he⟩ := Finset.card_eq_two.mp h + rw [he, Finset.sum_pair hab] + have ha : a ∈ T' := by simp [he] + have hb : b ∈ T' := by simp [he] + exact pair_bound a (hTp ha) b (hTp hb) hab (hT'c a ha b hb hab) + · obtain ⟨a, b, c, hab, hac, hbc, he⟩ := Finset.card_eq_three.mp h + have ha : a ∈ T' := by simp [he] + have hb : b ∈ T' := by simp [he] + have hc : c ∈ T' := by simp [he] + rw [he, Finset.sum_insert (by simp [hab, hac]), Finset.sum_pair hbc, ← add_assoc] + exact triple_bound a (hTp ha) b (hTp hb) hab (hT'c a ha b hb hab) c (hTp hc) hac hbc + (hT'c a ha c hc hac) (hT'c b hb c hc hbc) + +end GapExtremal.H12 diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Main.lean b/LeanPool/SplitCliqueGap/GapExtremal/Main.lean new file mode 100644 index 0000000000..3520755561 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Main.lean @@ -0,0 +1,80 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Hosts +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# T406-q: the gap of the construction (ledger Cor. 9.2) + +For a finite field `F`, a finite `F`-module `W`, an embedding `σ : Fin 6 ↪ F` and a separable cap +`C ⊆ W`, +the split graph `G(C) = hostGraph (palette C σ hS)` on `(F × W) ⊕ HostIdx F W` satisfies + + `gap G(C) ≥ |C| · |W| / 3`, `|V(G(C))| ≤ 3 q³ |W|` (`q = |F| ≥ 2`). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-- Split graphs: a clique and an independent set covering all vertices. -/ +def IsSplit {V : Type*} (G : SimpleGraph V) : Prop := + ∃ K : Set V, (∀ x ∈ K, ∀ y ∈ K, x ≠ y → G.Adj x y) ∧ (∀ x ∉ K, ∀ y ∉ K, ¬ G.Adj x y) + +theorem isSplit_hostGraph {V H : Type*} + (N : H → Finset V) : IsSplit (hostGraph N) := by + refine ⟨Set.range Sum.inl, ?_, ?_⟩ + · rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ h + exact fun e => h (by rw [e]) + · rintro (x | h) hx (y | h') hy + · exact absurd ⟨x, rfl⟩ hx + · exact absurd ⟨x, rfl⟩ hx + · exact absurd ⟨y, rfl⟩ hy + · exact hostGraph_inr_inr N h h' + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] + +/-- **T406-q.** -/ +theorem gap_ge_third (σ : Fin 6 ↪ F) {C : Finset W} (hC : IsCap F (C : Set W)) + (hS : IsSep F (C : Set W)) : + ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (palette C σ hS)) := by + have h := gap_ge (hostHyp (σ := σ) hS) (8 * (blocks (F := F) C).card) + (fun T hT => I_le (σ := σ) hC hT) + (resPack_ysrc (C := C) (σ := σ)) + have hv := value_ysrc (C := C) (σ := σ) + rw [card_blocks] at h + push_cast at h ⊢ + linarith + +omit [AddCommGroup W] [DecidableEq F] [DecidableEq W] [Module F W] in +/-- Order of the construction. -/ +theorem card_vertices_le (hq : 2 ≤ Fintype.card F) : + Fintype.card ((F × W) ⊕ HostIdx F W) ≤ 3 * Fintype.card F ^ 3 * Fintype.card W := by + simp only [HostIdx, Fintype.card_sum, Fintype.card_prod, Sym2.card] + set q := Fintype.card F + set m := Fintype.card W + have h1 : (q + 1).choose 2 ≤ q * q := by + rw [Nat.choose_two_right] + apply Nat.div_le_of_le_mul + simp only [Nat.add_sub_cancel] + nlinarith + have e1 : q * m * (q + 1).choose 2 ≤ q * m * (q * q) := Nat.mul_le_mul_left _ h1 + have e2 : q * m ≤ q * m * (q * q) := Nat.le_mul_of_pos_right _ (by positivity) + have e3 : q * m * (q * q) = q ^ 3 * m := by ring + calc q * m + (q * m * (q * q) + q * m * (q + 1).choose 2) + ≤ q * m * (q * q) + (q * m * (q * q) + q * m * (q * q)) := by omega + _ = 3 * q ^ 3 * m := by rw [e3]; ring + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean new file mode 100644 index 0000000000..9d11b2ab69 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean @@ -0,0 +1,256 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Global2 +public import LeanPool.SplitCliqueGap.GapExtremal.Source +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Abel + +/-! +# Positioned cores (ledger §16.3) + +A core `V` with a base map `base : V → F × W` and a position map `pos : V → P`; the gadget labels +are placed by +`σ : Fin 6 ↪ P`, and each position has a colour `col : P → F` with `(base v).1 = col (pos v)`. +Several vertices may share a base (twins), at most two, with distinct positions. + +`PB`: `v ~ v'` iff the bases differ by a selected direction and the positions carry adjacent `H12` +labels. +Blocks: for each selected line, the vertices on it whose position is a label. + +Results: `pblockHyp` (hypotheses of `global_bound2`) and `pI_le` (`I(B) ≤ 8 · #blocks`). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] + +/-! ### Geometry of selected directions on bases -/ + +section Geom + +variable {C : Finset W} (hC : IsCap F (C : Set W)) +include hC + +omit [Fintype W] in +/-- Three points with pairwise selected differences lie on one selected line. -/ +theorem tri_geom {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) + (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) + (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d + ∧ z ∈ line p d := by + have hα : y.1 - x.1 ≠ 0 := by + intro h0; rw [h0, zero_smul, sub_eq_zero] at h1; exact hxy h1.symm + by_cases hab : a = b + · subst hab + refine ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, ?_⟩ + refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ + rw [add_smul, ← h1, ← h2]; abel + by_cases hac : a = c + · subst hac + exact ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ + by_cases hbc : b = c + · subst hbc + refine ⟨b, hb, z, ?_, ?_, self_mem_line z b⟩ + · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ + rw [neg_smul, ← h3]; abel + · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ + rw [neg_smul, ← h2]; abel + exfalso + have e1 := snd_eq_of_sub h1 + have e2 := snd_eq_of_sub h2 + have e3 := snd_eq_of_sub h3 + have := dep_zero hC ha hb hc hab hac hbc (α := y.1 - x.1) (β := z.1 - y.1) (γ := -(z.1 - x.1)) + (by ring) (by rw [← e1, ← e2, neg_smul, ← e3]; abel) + exact hα this.1 + +omit [Fintype W] in +/-- A point off a selected line has selected differences to at most one point of the line. -/ +theorem one_geom {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) + (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) {d e' : W} (hd : d ∈ C) (he : e' ∈ C) + (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := by + by_contra hne + have hyy := sub_of_mem_line hy hy' + have hγ : y'.1 - y.1 ≠ 0 := fun h0 => + hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) + by_cases hdc : d = c0 + · subst hdc + apply hz + rw [← line_eq_of_mem hy] + refine mem_line.mpr ⟨-(y.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy]; abel + by_cases hec : e' = c0 + · subst hec + apply hz + rw [← line_eq_of_mem hy'] + refine mem_line.mpr ⟨-(y'.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy']; abel + by_cases hde : d = e' + · subst hde + have : (y'.1 - y.1) • (u d : F × W) = (y'.1 - y.1) • u c0 := by + rw [← hyy] + have : y' - y = (y' - z) - (y - z) := by abel + rw [this, hzy, hzy', ← sub_smul] + congr 1; ring + exact hdc ((par_eq this).2 hγ) + have e1 := snd_eq_of_sub hzy + have e2 := snd_eq_of_sub hzy' + have e3 := snd_eq_of_sub hyy + have := dep_zero hC he hd hc0 (Ne.symm hde) hec hdc (α := y'.1 - z.1) (β := -(y.1 - z.1)) + (γ := -(y'.1 - y.1)) (by ring) (by rw [← e2, neg_smul, ← e1, neg_smul, ← e3]; abel) + have hz' : y' = z := by + have h0 : y'.1 - z.1 = 0 := this.1 + rw [h0, zero_smul, sub_eq_zero] at hzy' + exact hzy' + exact hz (hz' ▸ hy') + +end Geom + +/-! ### Positioned cores -/ + +/-- Data of a positioned core. -/ +structure PData (F W V P : Type*) [Field F] [AddCommGroup W] [Module F W] where + /-- The field and vector coordinates of each core vertex. -/ + base : V → F × W + /-- The position of each vertex within its base fibre. -/ + pos : V → P + /-- The field coordinate assigned to each position. -/ + col : P → F + /-- The six distinguished positions used for the core roles. -/ + σ : Fin 6 ↪ P + base_fst : ∀ v, (base v).1 = col (pos v) + inj : ∀ v v', base v = base v' → pos v = pos v' → v = v' + fib : ∀ v v' v'', base v = base v' → base v = base v'' → v = v' ∨ v = v'' ∨ v' = v'' + /-- A distinguished vertex at the given base coordinate and role. -/ + rl : F × W → Fin 6 → V + rl_base : ∀ y i, y.1 = col (σ i) → base (rl y i) = y + rl_pos : ∀ y i, y.1 = col (σ i) → pos (rl y i) = σ i + colσ : ∀ i j, col (σ i) = col (σ j) → i = j ∨ (i = 0 ∧ j = 2) ∨ (i = 2 ∧ j = 0) + +variable {V P : Type*} [Fintype V] [DecidableEq V] [DecidableEq P] + +/-- The graph `B` of a positioned core. -/ +def PB (D : PData F W V P) (C : Finset W) : SimpleGraph V where + Adj v v' := D.base v ≠ D.base v' ∧ + (∃ c ∈ C, D.base v' - D.base v = ((D.base v').1 - (D.base v).1) • u c) ∧ + ∃ i j, D.σ i = D.pos v ∧ D.σ j = D.pos v' ∧ H12.graph.Adj i j + symm := ⟨fun v v' ⟨hne, ⟨c, hc, h⟩, i, j, hi, hj, hij⟩ => + ⟨hne.symm, ⟨c, hc, by + have : D.base v - D.base v' = -(D.base v' - D.base v) := (neg_sub _ _).symm + rw [this, h, ← neg_smul, neg_sub]⟩, j, i, hj, hi, hij.symm⟩⟩ + loopless := ⟨fun v h => h.1 rfl⟩ + +open Classical in +noncomputable instance (D : PData F W V P) (C : Finset W) : DecidableRel (PB D C).Adj := + Classical.decRel _ + +open Classical in +/-- The block of a selected line. -/ +noncomputable def pblock (D : PData F W V P) (x : F × W) (c : W) : Finset V := + univ.filter fun v => D.base v ∈ line x c ∧ ∃ i, D.σ i = D.pos v + +/-- The blocks. -/ +noncomputable def pblocks (D : PData F W V P) (C : Finset W) : Finset (Finset V) := + (C ×ˢ univ).image fun p : W × W => pblock D ((0 : F), p.2) p.1 + +variable (D : PData F W V P) {C : Finset W} + +omit [DecidableEq V] [Fintype W] in +theorem mem_pblock {x : F × W} {c : W} {v : V} : + v ∈ pblock D x c ↔ D.base v ∈ line x c ∧ ∃ i, D.σ i = D.pos v := by + classical + unfold pblock + simp + +theorem pblock_mem (hc : c ∈ C) (x : F × W) : pblock D x c ∈ pblocks D C := by + rw [show pblock D x c = pblock D ((0 : F), x.2 - x.1 • c) c by + unfold pblock; rw [line_eq_line_zero x c]] + exact Finset.mem_image.mpr ⟨(c, x.2 - x.1 • c), by simp [hc], rfl⟩ + +theorem card_pblocks_le : (pblocks D C).card ≤ C.card * Fintype.card W := by + unfold pblocks + refine Finset.card_image_le.trans ?_ + simp + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem PB_adj_pos {v v' : V} (h : (PB D C).Adj v v') : (∃ i, D.σ i = D.pos v) ∧ ∃ j, + D.σ j = D.pos v' := + by obtain ⟨-, -, i, j, hi, hj, -⟩ := h; exact ⟨⟨i, hi⟩, ⟨j, hj⟩⟩ + +variable (hC : IsCap F (C : Set W)) +include hC + +theorem pblockHyp : BlockHyp2 (PB D C) (pblocks D C) where + edge := by + intro v v' h + obtain ⟨hv, hv'⟩ := PB_adj_pos D h + obtain ⟨-, ⟨c, hc, hdir⟩, -⟩ := h + refine ⟨pblock D (D.base v) c, pblock_mem D hc _, ?_, ?_⟩ + · exact (mem_pblock D).mpr ⟨self_mem_line _ _, hv⟩ + · exact (mem_pblock D).mpr ⟨mem_line_of_sub hdir, hv'⟩ + tri := by + intro a b x hab hbx hax + have pa := (PB_adj_pos D hab).1 + have pb := (PB_adj_pos D hab).2 + have px := (PB_adj_pos D hbx).2 + obtain ⟨hne, ⟨c1, hc1, h1⟩, -⟩ := hab + obtain ⟨-, ⟨c2, hc2, h2⟩, -⟩ := hbx + obtain ⟨-, ⟨c3, hc3, h3⟩, -⟩ := hax + obtain ⟨d, hd, p, ha, hb, hx⟩ := tri_geom hC hc1 hc2 hc3 hne h1 h2 h3 + refine ⟨pblock D p d, pblock_mem D hd p, ?_, ?_, ?_⟩ + · exact (mem_pblock D).mpr ⟨ha, pa⟩ + · exact (mem_pblock D).mpr ⟨hb, pb⟩ + · exact (mem_pblock D).mpr ⟨hx, px⟩ + two := by + intro ℓ hℓ z hz y hy y' hy' y'' hy'' h1 h2 h3 + obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 + rw [mem_pblock] at hy hy' hy'' + have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => + hz ((mem_pblock D).mpr ⟨hzl, (PB_adj_pos D h1).1⟩) + obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 + obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 + obtain ⟨-, ⟨d3, hd3, e3⟩, -⟩ := h3 + have b12 := one_geom hC hc0 hzl hy.1 hy'.1 hd1 hd2 e1 e2 + have b13 := one_geom hC hc0 hzl hy.1 hy''.1 hd1 hd3 e1 e3 + exact D.fib y y' y'' b12 b13 + nonadj := by + intro ℓ hℓ z hz y hy y' hy' h1 h2 hyy + obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 + rw [mem_pblock] at hy hy' + have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => + hz ((mem_pblock D).mpr ⟨hzl, (PB_adj_pos D h1).1⟩) + obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 + obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 + exact hyy.1 (one_geom hC hc0 hzl hy.1 hy'.1 hd1 hd2 e1 e2) + +/-- **`I(B) ≤ 8 · #blocks`** on a positioned core. -/ +theorem pI_le {T : Finset (Finset V)} (hT : IsPack T) : + ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card := by + refine global_bound2 (pblockHyp D hC) 8 ?_ hT + intro ℓ hℓ T' hT'sub hT' + obtain ⟨⟨c0, w0⟩, -, rfl⟩ := Finset.mem_image.mp hℓ + have hinj : Set.InjOn D.pos (pblock D ((0 : F), w0) c0 : Set V) := by + intro v hv v' hv' h + rw [Finset.mem_coe, mem_pblock] at hv hv' + apply D.inj v v' _ h + apply fst_injOn_line _ _ hv.1 hv'.1 + rw [D.base_fst, D.base_fst, h] + have := block_local (B := PB D C) D.pos D.σ hinj + (fun v _ v' _ h => by + obtain ⟨-, -, i, j, hi, hj, hij⟩ := h + exact ⟨i, j, hi, hj, hij⟩) T' hT'sub hT' + simpa using this + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PHosts.lean b/LeanPool/SplitCliqueGap/GapExtremal/PHosts.lean new file mode 100644 index 0000000000..27af2d182b --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/PHosts.lean @@ -0,0 +1,250 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.PSource +public import LeanPool.SplitCliqueGap.GapExtremal.Hosts +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.SplitIfs +import Mathlib.Tactic.Abel + +/-! +# Hosts on a positioned core (ledger §16.1, §16.3) + +Exterior directions are separated by linear maps `sep r : F × W →ₗ U` (`sep r r = 0`, `sep r (u c) +≠ 0`), not +necessarily hyperplanes (no SEP). Hosts: + +* `inl (r, β, λ, s)`: base fibre `sep r = β`, positions in `s`; marked pairs with exterior +difference; +* `inr (r, s)`: positions in `s` (a non-adjacent label pair); marked pairs with selected or zero +difference + (twins). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] +variable {V P : Type*} [Fintype V] [DecidableEq V] [Fintype P] [DecidableEq P] +variable {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +variable (F) in +/-- A separating family for the exterior directions of `C`. -/ +structure SepFam (C : Finset W) (U : Type*) [AddCommGroup U] [Module F U] where + /-- The linear functional separating the specified exterior direction from core directions. -/ + sep : F × W → (F × W) →ₗ[F] U + sep_self : ∀ r, Ext C r → sep r r = 0 + sep_u : ∀ r, Ext C r → ∀ c ∈ C, sep r (u c) ≠ 0 + +/-- Host indices. -/ +abbrev PHostIdx (F W P U : Type*) := ((F × W) × U × F × Sym2 P) ⊕ ((F × W) × Sym2 P) + +instance instDecEqPHostIdx : DecidableEq (PHostIdx F W P U) := + @instDecidableEqSum _ _ (fun a b => instDecidableEqProd a b) (fun a b => instDecidableEqProd a b) + +instance instDecEqSumPHostIdx : DecidableEq (V ⊕ PHostIdx F W P U) := + @instDecidableEqSum _ _ inferInstance instDecEqPHostIdx + +variable (D : PData F W V P) (C : Finset W) (S : SepFam F C U) + +/-- Position pairs carrying no `H12` edge. -/ +def GoodP (s : Sym2 P) : Prop := ∀ i j : Fin 6, s = s(D.σ i, D.σ j) → ¬ H12.graph.Adj i j + +open Classical in +/-- The palettes. -/ +noncomputable def ppalette : PHostIdx F W P U → Finset V + | .inl ⟨r, β, _, s⟩ => + if Ext C r then univ.filter (fun v => S.sep r (D.base v) = β ∧ D.pos v ∈ s) else ∅ + | .inr ⟨_, s⟩ => if GoodP D s then univ.filter (fun v => D.pos v ∈ s) else ∅ + +/-- Selected (or zero) base difference. -/ +def PSel (v v' : V) : Prop := + ∃ c ∈ C, D.base v' - D.base v = ((D.base v').1 - (D.base v).1) • u c + +open Classical in +/-- The assignment. -/ +noncomputable def passign (v v' : V) : PHostIdx F W P U := + if PSel D C v v' then .inr (rep (D.base v' - D.base v), s(D.pos v, D.pos v')) + else .inl (rep (D.base v' - D.base v), S.sep (rep (D.base v' - D.base v)) (D.base v), + lab (rep (D.base v' - D.base v)) (D.base v + D.base v'), s(D.pos v, D.pos v')) + +variable {D C S} + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype P] + [Fintype V] [Fintype W] in +theorem psel_symm {v v' : V} : PSel D C v v' ↔ PSel D C v' v := by + constructor <;> rintro ⟨c, hc, h⟩ <;> refine ⟨c, hc, ?_⟩ <;> + · rw [← neg_sub, h, ← neg_smul, neg_sub] + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype P] + [Fintype V] [Fintype W] in +theorem psel_of_base_eq (hC0 : C.Nonempty) {v v' : V} (h : D.base v = D.base v') : PSel D C v v' + := by + obtain ⟨c, hc⟩ := hC0 + exact ⟨c, hc, by rw [h, sub_self, sub_self, zero_smul]⟩ + +omit [DecidableEq P] [DecidableEq V] [Fintype P] [Fintype V] in +theorem ext_of_not_psel {v v' : V} (hb : D.base v ≠ D.base v') (h : ¬ PSel D C v v') : + Ext C (rep (D.base v' - D.base v)) := by + have hd : D.base v' - D.base v ≠ 0 := sub_ne_zero.mpr (Ne.symm hb) + refine ⟨(rep_spec hd).1, ?_⟩ + rintro ⟨c, hc, t, ht⟩ + obtain ⟨a, -, ha⟩ := eq_smul_rep hd + apply h + refine ⟨c, hc, ?_⟩ + have e : D.base v' - D.base v = (a * t) • u c := by rw [ha, ht, smul_smul] + have e1 : (D.base v').1 - (D.base v).1 = a * t := by simpa [u] using congrArg Prod.fst e + rw [e1, ← e] + +omit [DecidableEq P] [DecidableEq U] [DecidableEq V] [Fintype P] [Fintype U] [Fintype V] in +theorem sep_eq_of_ext {v v' : V} (hb : D.base v ≠ D.base v') + (hext : Ext C (rep (D.base v' - D.base v))) : + S.sep (rep (D.base v' - D.base v)) (D.base v') = S.sep (rep (D.base v' - D.base v)) (D.base v) + := by + obtain ⟨a, -, ha⟩ := eq_smul_rep (sub_ne_zero.mpr (Ne.symm hb)) + generalize rep (D.base v' - D.base v) = r at ha hext ⊢ + have hy : D.base v' = D.base v + a • r := by rw [← ha]; abel + rw [hy, map_add, map_smul, S.sep_self r hext, smul_zero, add_zero] + +omit [DecidableEq F] [DecidableEq U] [Fintype F] [Fintype U] in +theorem smul_ne_zero_of {t : F} {x : U} (ht : t ≠ 0) (hx : x ≠ 0) : t • x ≠ 0 := by + intro h + apply hx + have := congrArg (fun y => t⁻¹ • y) h + simpa [smul_smul, inv_mul_cancel₀ ht] using this + +omit [DecidableEq V] [Fintype P] [Fintype U] in +/-- **Host hypotheses** on a positioned core. -/ +theorem phostHyp (hC0 : C.Nonempty) + (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → + ¬ H12.graph.Adj i j) : + HostHyp (PB D C) (ppalette D C S) (passign D C S) where + indep := by + rintro (⟨r, b, l, s⟩ | ⟨r, s⟩) z hz z' hz' hadj + · simp only [ppalette] at hz hz' + split_ifs at hz hz' with hr + · simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hz hz' + obtain ⟨hne, ⟨c, hc, hdir⟩, -⟩ := hadj + have h0 : S.sep r (D.base z' - D.base z) = 0 := by rw [map_sub, hz.1, hz'.1, sub_self] + rw [hdir, map_smul] at h0 + by_cases ht : (D.base z').1 - (D.base z).1 = 0 + · rw [ht, zero_smul, sub_eq_zero] at hdir + exact hne hdir.symm + · exact smul_ne_zero_of ht (S.sep_u r hr c hc) h0 + · simp at hz + · simp only [ppalette] at hz hz' + split_ifs at hz hz' with hs + · simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hz hz' + obtain ⟨-, -, i, j, hi, hj, hij⟩ := hadj + have hne : D.pos z ≠ D.pos z' := by + intro h + exact hij.ne (D.σ.injective (by rw [hi, hj, h])) + have : s = s(D.pos z, D.pos z') := (Sym2.mem_and_mem_iff hne).mp ⟨hz, hz'⟩ + exact hs i j (by rw [this, hi, hj]) hij + · simp at hz + cover := by + intro v v' hvv hnadj + by_cases hsel : PSel D C v v' + · simp only [passign, ite_eq_left hsel, ppalette] + have hgood : GoodP D s(D.pos v, D.pos v') := by + intro i j hs hij + rcases Sym2.eq_iff.mp hs with ⟨h1, h2⟩ | ⟨h1, h2⟩ + · by_cases hb : D.base v = D.base v' + · exact hsame v v' hb i j h1.symm h2.symm hij + · exact hnadj ⟨hb, hsel, i, j, h1.symm, h2.symm, hij⟩ + · by_cases hb : D.base v = D.base v' + · exact hsame v v' hb j i h1.symm h2.symm hij.symm + · exact hnadj ⟨hb, hsel, j, i, h1.symm, h2.symm, hij.symm⟩ + rw [ite_eq_left hgood] + simp + · have hb : D.base v ≠ D.base v' := fun h => hsel (psel_of_base_eq hC0 h) + have hext := ext_of_not_psel hb hsel + simp only [passign, ite_eq_right hsel, ppalette, ite_eq_left hext, Finset.mem_filter, + Finset.mem_univ, + true_and] + constructor <;> simp [sep_eq_of_ext (S := S) hb hext] + symm := by + intro v v' + by_cases hvv : v = v' + · rw [hvv] + by_cases hsel : PSel D C v v' + · have hsel' : PSel D C v' v := psel_symm.mp hsel + simp only [passign, ite_eq_left hsel, ite_eq_left hsel'] + rw [← neg_sub (D.base v) (D.base v'), rep_neg, Sym2.eq_swap] + · have hsel' : ¬ PSel D C v' v := fun h => hsel (psel_symm.mpr h) + simp only [passign, ite_eq_right hsel, ite_eq_right hsel'] + have hb : D.base v ≠ D.base v' := fun h => hsel (psel_of_base_eq hC0 h) + have hext := ext_of_not_psel hb hsel + have hsv := sep_eq_of_ext (S := S) hb hext + rw [show D.base v - D.base v' = -(D.base v' - D.base v) by abel, rep_neg, + add_comm (D.base v) (D.base v'), hsv, Sym2.eq_swap] + inj := by + intro v v' v'' hvv hn hvv' hn' heq + by_cases hs : PSel D C v v' <;> by_cases hs' : PSel D C v v'' + · simp only [passign, ite_eq_left hs, ite_eq_left hs', Sum.inr.injEq, Prod.mk.injEq] at heq + obtain ⟨hr, hsym⟩ := heq + have hpos : D.pos v' = D.pos v'' := Sym2.congr_right.mp hsym + apply D.inj v' v'' _ hpos + -- equal bases + by_cases h0 : D.base v' - D.base v = 0 + · have h0' : D.base v'' - D.base v = 0 := by + by_contra hne + have := (rep_spec hne).1 + rw [← hr, h0] at this + apply this + simp [rep, repOf] + rw [sub_eq_zero] at h0 h0' + rw [h0, h0'] + · have h0' : D.base v'' - D.base v ≠ 0 := by + intro hz + have := (rep_spec h0).1 + rw [hr, hz] at this + apply this + simp [rep, repOf] + obtain ⟨a, -, ha⟩ := eq_smul_rep h0 + obtain ⟨a', -, ha'⟩ := eq_smul_rep h0' + rw [hr] at ha + have hcol : (D.base v').1 = (D.base v'').1 := by rw [D.base_fst, D.base_fst, hpos] + have hfst : (rep (D.base v'' - D.base v)).1 ≠ 0 := by + obtain ⟨c, -, hdir⟩ := hs' + obtain ⟨-, s, hs0, hrs⟩ := rep_spec h0' + rw [hrs] + simp only [Prod.smul_fst, Prod.fst_sub, smul_eq_mul] + refine mul_ne_zero hs0 fun h1 => h0' ?_ + rw [hdir, h1, zero_smul] + generalize rep (D.base v'' - D.base v) = r at ha ha' hfst + have e1 : (D.base v').1 - (D.base v).1 = a * r.1 := by simpa using congrArg Prod.fst ha + have e2 : (D.base v'').1 - (D.base v).1 = a' * r.1 := by simpa using congrArg Prod.fst ha' + have haa : a = a' := mul_right_cancel₀ hfst (by rw [← e1, ← e2, hcol]) + have : D.base v' - D.base v = D.base v'' - D.base v := by rw [ha, ha', haa] + exact sub_left_inj.mp this + · simp [passign, ite_eq_left hs, ite_eq_right hs'] at heq + · simp [passign, ite_eq_right hs, ite_eq_left hs'] at heq + · simp only [passign, ite_eq_right hs, ite_eq_right hs', Sum.inl.injEq, Prod.mk.injEq] at heq + obtain ⟨hr, -, hl, hsym⟩ := heq + have hpos : D.pos v' = D.pos v'' := Sym2.congr_right.mp hsym + apply D.inj v' v'' _ hpos + have hb : D.base v ≠ D.base v' := fun h => hs (psel_of_base_eq hC0 h) + have hb' : D.base v ≠ D.base v'' := fun h => hs' (psel_of_base_eq hC0 h) + obtain ⟨a, -, ha⟩ := eq_smul_rep (sub_ne_zero.mpr (Ne.symm hb)) + obtain ⟨a', -, ha'⟩ := eq_smul_rep (sub_ne_zero.mpr (Ne.symm hb')) + have hr0 : rep (D.base v'' - D.base v) ≠ 0 := (rep_spec (sub_ne_zero.mpr (Ne.symm hb'))).1 + rw [hr] at ha hl + generalize rep (D.base v'' - D.base v) = r at ha ha' hl hr0 + have hy : D.base v' = D.base v + a • r := by rw [← ha]; abel + have hy' : D.base v'' = D.base v + a' • r := by rw [← ha']; abel + rw [hy, hy'] at hl + simp only [map_add, map_smul, smul_eq_mul] at hl + have haa : a = a' := mul_right_cancel₀ (lab_spec hr0) (by linear_combination hl) + rw [hy, hy', haa] + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean b/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean new file mode 100644 index 0000000000..8cd66fbc85 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean @@ -0,0 +1,61 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.PHosts +public import LeanPool.SplitCliqueGap.GapExtremal.Main +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# The gap of a positioned construction (ledger Cor. 16.4) + +`gap (hostGraph (ppalette D C S)) ≥ |C| · |W| / 3` for every cap `C` with a separating family `S`, +on any +positioned core satisfying the twin condition `hsame`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] +variable {V P : Type*} [Fintype V] [DecidableEq V] [Fintype P] [DecidableEq P] +variable {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +/-- **Cor. 16.4.** -/ +theorem pgap_ge_third (D : PData F W V P) {C : Finset W} (hC : IsCap F (C : Set W)) (hC0 : + C.Nonempty) + (S : SepFam F C U) + (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → + ¬ H12.graph.Adj i j) : + ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (ppalette D C S)) := by + have h := gap_ge (phostHyp (S := S) hC0 hsame) (8 * (pblocks D C).card) + (fun T hT => pI_le D hC hT) (presPack (D := D) (C := C)) + have hv := pvalue (D := D) (C := C) + have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by + exact_mod_cast card_pblocks_le D + push_cast at h ⊢ + linarith + +omit [AddCommGroup U] [AddCommGroup W] [DecidableEq F] [DecidableEq P] [DecidableEq U] + [DecidableEq V] [DecidableEq W] [Field F] [Module F U] [Module F W] in +/-- Order of a positioned construction. -/ +theorem pcard_vertices : + Fintype.card (V ⊕ PHostIdx F W P U) = + Fintype.card V + Fintype.card (F × W) * (Fintype.card U * Fintype.card F * Fintype.card + (Sym2 P)) + + Fintype.card (F × W) * Fintype.card (Sym2 P) := by + simp only [PHostIdx, Fintype.card_sum, Fintype.card_prod] + ring + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean new file mode 100644 index 0000000000..0f5a21d9b0 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean @@ -0,0 +1,232 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.PCore +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! +# The fractional source on a positioned core (ledger §16.3, L7.4) + +The nine source pieces of every selected line, realised through `D.rl`; none contains both labels +`0` and `2` +(which may share a base). `presPack` (capacity 1) and `pvalue` (`∑ y w ≥ 25/3 · |C| · |W|`). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] +variable {V P : Type*} [Fintype V] [DecidableEq V] [DecidableEq P] +variable (D : PData F W V P) {C : Finset W} + +theorem src_no02 : ∀ K ∈ src, ¬ ((0 : Fin 6) ∈ K ∧ (2 : Fin 6) ∈ K) := by decide +kernel + +theorem not_adj02 : ¬ H12.graph.Adj 0 2 ∧ ¬ H12.graph.Adj 2 0 := by decide + +/-- The base point of label `i` on `line (0, w) c`. -/ +def ppt (w c : W) (i : Fin 6) : F × W := (D.col (D.σ i), w + D.col (D.σ i) • c) + +/-- The vertex of label `i` on `line (0, w) c`. -/ +def pvx (w c : W) (i : Fin 6) : V := D.rl (ppt D w c i) i + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem pvx_base (w c : W) (i : Fin 6) : D.base (pvx D w c i) = ppt D w c i := + D.rl_base _ _ rfl + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem pvx_pos (w c : W) (i : Fin 6) : D.pos (pvx D w c i) = D.σ i := + D.rl_pos _ _ rfl + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem pvx_injective (w c : W) : Function.Injective (pvx D w c) := fun i j h => + D.σ.injective (by rw [← pvx_pos D w c i, ← pvx_pos D w c j, h]) + +/-- A piece. -/ +def ppiece (x : (W × W) × Finset (Fin 6)) : Finset V := x.2.image (pvx D x.1.2 x.1.1) + +omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] [Fintype V] [Fintype W] in +theorem card_ppiece (x : (W × W) × Finset (Fin 6)) : (ppiece D x).card = x.2.card := + Finset.card_image_of_injective _ (pvx_injective _ _ _) + +omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] [Fintype V] [Fintype W] in +theorem mem_ppiece {x : (W × W) × Finset (Fin 6)} {v : V} : + v ∈ ppiece D x ↔ ∃ i ∈ x.2, pvx D x.1.2 x.1.1 i = v := Finset.mem_image + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +/-- Colours of two labels of a source piece are distinct. -/ +theorem col_ne_of_src {K : Finset (Fin 6)} (hK : K ∈ src) {i j : Fin 6} (hi : i ∈ K) (hj : j ∈ K) + (hij : i ≠ j) : D.col (D.σ i) ≠ D.col (D.σ j) := by + intro h + rcases D.colσ i j h with h | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · exact hij h + · exact src_no02 K hK ⟨hi, hj⟩ + · exact src_no02 K hK ⟨hj, hi⟩ + +omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] [Fintype V] in +theorem ppiece_injOn : Set.InjOn (ppiece D) (↑(pidx C)) := by + rintro ⟨⟨c, w⟩, K⟩ hx ⟨⟨c', w'⟩, K'⟩ hx' h + rw [Finset.mem_coe, pidx, Finset.mem_product] at hx hx' + have h3 := src_card K hx.2 + obtain ⟨i1, hi1, i2, hi2, hne⟩ := Finset.one_lt_card.mp (by omega : 1 < K.card) + have m1 : pvx D w c i1 ∈ ppiece D ((c', w'), K') := h ▸ Finset.mem_image_of_mem _ hi1 + have m2 : pvx D w c i2 ∈ ppiece D ((c', w'), K') := h ▸ Finset.mem_image_of_mem _ hi2 + obtain ⟨j1, -, e1⟩ := Finset.mem_image.mp m1 + obtain ⟨j2, -, e2⟩ := Finset.mem_image.mp m2 + have hj1 : j1 = i1 := D.σ.injective (by rw [← pvx_pos D w' c' j1, e1, pvx_pos]) + have hj2 : j2 = i2 := D.σ.injective (by rw [← pvx_pos D w' c' j2, e2, pvx_pos]) + subst hj1 hj2 + have b1 := congrArg D.base e1 + have b2 := congrArg D.base e2 + rw [pvx_base, pvx_base] at b1 b2 + simp only [ppt, Prod.mk.injEq] at b1 b2 + obtain ⟨hw, hc⟩ := wc_eq_of_two (col_ne_of_src D hx.2 hi1 hi2 hne) b1.2.symm b2.2.symm + subst hw hc + have : K = K' := Finset.image_injective (pvx_injective D w c) h + rw [this] + +/-- All pieces. -/ +noncomputable def ppieces (C : Finset W) : Finset (Finset V) := (pidx C).image (ppiece D) + +open Classical in +/-- The fractional source. -/ +noncomputable def pysrc (C : Finset W) (S : Finset V) : ℝ := if S ∈ ppieces D C then 1 / 3 else 0 + +omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] in +theorem presPack : ResPack (pysrc D C) where + nonneg S := by unfold pysrc; split_ifs <;> norm_num + two S h := by + unfold pysrc at h + split_ifs at h with hS + · obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hS + rw [card_ppiece] + have := src_card x.2 (Finset.mem_product.mp hx).2 + omega + · exact absurd rfl h + load a b hab := by + classical + set T := (ppieces D C).filter (fun S => a ∈ S ∧ b ∈ S) with hT + have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then pysrc D C S else 0) = T.card * (1 / 3 : ℝ) := by + rw [hT, Finset.card_filter, Nat.cast_sum, Finset.sum_mul] + rw [← Finset.sum_subset (Finset.subset_univ (ppieces D C))] + · refine Finset.sum_congr rfl fun S hS => ?_ + unfold pysrc + rw [ite_eq_left hS] + split_ifs <;> simp + · intro S _ hS + unfold pysrc + rw [ite_eq_right hS] + simp + rw [hsum] + have hT3 : T.card ≤ 3 := by + rcases T.eq_empty_or_nonempty with h0 | ⟨S0, hS0⟩ + · rw [h0]; simp + obtain ⟨hS0p, ha0, hb0⟩ := Finset.mem_filter.mp hS0 + obtain ⟨⟨⟨c, w⟩, K⟩, hx0, rfl⟩ := Finset.mem_image.mp hS0p + have hK : K ∈ src := (Finset.mem_product.mp hx0).2 + obtain ⟨i, hi, rfl⟩ := (mem_ppiece D).mp ha0 + obtain ⟨j, hj, rfl⟩ := (mem_ppiece D).mp hb0 + have hij : i ≠ j := fun h => hab (by rw [h]) + have hcij := col_ne_of_src D hK hi hj hij + refine (Finset.card_le_card ?_).trans + ((Finset.card_image_le (s := src.filter fun K => i ∈ K ∧ j ∈ K) + (f := fun K => ppiece D ((c, w), K))).trans (src_pair i j hij)) + intro S hS + obtain ⟨hSp, haS, hbS⟩ := Finset.mem_filter.mp hS + obtain ⟨⟨⟨c', w'⟩, K'⟩, hx', rfl⟩ := Finset.mem_image.mp hSp + obtain ⟨i', hi', e1⟩ := (mem_ppiece D).mp haS + obtain ⟨j', hj', e2⟩ := (mem_ppiece D).mp hbS + have hii : i' = i := D.σ.injective (by rw [← pvx_pos D w' c' i', e1, pvx_pos]) + have hjj : j' = j := D.σ.injective (by rw [← pvx_pos D w' c' j', e2, pvx_pos]) + subst hii hjj + have b1 := congrArg D.base e1 + have b2 := congrArg D.base e2 + rw [pvx_base, pvx_base] at b1 b2 + simp only [ppt, Prod.mk.injEq] at b1 b2 + obtain ⟨hw, hc⟩ := wc_eq_of_two hcij b1.2 b2.2 + subst hw hc + exact Finset.mem_image.mpr ⟨K', Finset.mem_filter.mpr ⟨(Finset.mem_product.mp hx').2, hi', + hj'⟩, rfl⟩ + have : (T.card : ℝ) ≤ 3 := by exact_mod_cast hT3 + linarith + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem pvx_adj {c : W} (hc : c ∈ C) (w0 : W) {i j : Fin 6} (h : H12.graph.Adj i j) : + (PB D C).Adj (pvx D w0 c i) (pvx D w0 c j) := by + have hcol : D.col (D.σ i) ≠ D.col (D.σ j) := by + intro hh + rcases D.colσ i j hh with h' | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · exact h.ne h' + · exact not_adj02.1 h + · exact not_adj02.2 h + refine ⟨?_, ⟨c, hc, ?_⟩, i, j, (pvx_pos D w0 c i).symm, (pvx_pos D w0 c j).symm, h⟩ + · rw [pvx_base, pvx_base] + intro hh + exact hcol (congrArg Prod.fst hh) + · rw [pvx_base, pvx_base] + simp only [ppt, u, Prod.ext_iff, Prod.fst_sub, Prod.snd_sub, Prod.smul_fst, Prod.smul_snd, + smul_eq_mul, mul_one] + exact ⟨trivial, by module⟩ + +omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] in +/-- **L7.4** on a positioned core. -/ +theorem pvalue : + (25 / 3 : ℝ) * (C.card * Fintype.card W) ≤ ∑ S, pysrc D C S * (w (PB D C) S : ℝ) := by + classical + have h1 : ∑ S, pysrc D C S * (w (PB D C) S : ℝ) = + ∑ x ∈ pidx C, (1 / 3 : ℝ) * (w (PB D C) (ppiece D x) : ℝ) := by + rw [← Finset.sum_image (f := fun S => (1 / 3 : ℝ) * (w (PB D C) S : ℝ)) (ppiece_injOn D)] + rw [← Finset.sum_subset (Finset.subset_univ (ppieces D C))] + · refine Finset.sum_congr rfl fun S hS => ?_ + unfold pysrc + rw [ite_eq_left (show S ∈ ppieces D C from hS)] + · intro S _ hS + unfold pysrc + rw [ite_eq_right (show S ∉ ppieces D C from hS), zero_mul] + have h2 : ∀ x ∈ pidx C, ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) ≤ + (w (PB D C) (ppiece D x) : ℝ) := by + rintro ⟨⟨c, w0⟩, K⟩ hx + have hc : c ∈ C := (Finset.mem_product.mp (Finset.mem_product.mp hx).1).1 + have he : e H12.graph K ≤ e (PB D C) (ppiece D ((c, w0), K)) := + e_le_e_image (B := H12.graph) (PB D C) (pvx D w0 c) (pvx_injective D w0 c).injOn + fun i _ j _ h => pvx_adj D hc w0 h + rw [H12.e_graph_eq] at he + unfold w + rw [card_ppiece] + have : (H12.eH K : ℝ) ≤ (e (PB D C) (ppiece D ((c, w0), K)) : ℝ) := by exact_mod_cast he + push_cast + linarith + rw [h1] + calc (25 / 3 : ℝ) * (C.card * Fintype.card W) + = ∑ x ∈ pidx C, (1 / 3 : ℝ) * + ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) := by + rw [← Finset.mul_sum, pidx, Finset.sum_product] + simp only + have hv : ∑ K ∈ src, ((2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) = 25 := by + exact_mod_cast src_value + rw [Finset.sum_congr rfl fun _ _ => hv, Finset.sum_const, Finset.card_product, + Finset.card_univ, nsmul_eq_mul] + push_cast + ring + _ ≤ _ := Finset.sum_le_sum fun x hx => by + have := h2 x hx + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Residual.lean b/LeanPool/SplitCliqueGap/GapExtremal/Residual.lean new file mode 100644 index 0000000000..def59973e9 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Residual.lean @@ -0,0 +1,228 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Combinatorics.SimpleGraph.DegreeSum +public import Mathlib.Combinatorics.SimpleGraph.Operations +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Data.Int.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Push + +/-! +Ported (Lean 4.28 → 4.35, module system) from the B16 isolation development +(`C:/gap-cordal/verificacion/b16_aislamiento_20261004/source/RequestProject/Basic.lean`, +2026-10-04). +-/ + +@[expose] public section + +/-! +# Pesos de columnas (`w`, `φ`, `w⁺`) + +Definiciones básicas del modelo: para un grafo simple concreto `B : SimpleGraph V` +sobre un tipo finito `V` y una "columna" `S : Finset V`, + +* `D B X Y` es el número de pares **ordenados** `(u,v) ∈ X × Y` adyacentes en `B`; +* `e B S` es el número de aristas de `B` con ambos extremos en `S`; +* `w B S = 2 * e B S - (S.card).choose 2 - 1` y `phi B S = 2 * e B S - (S.card).choose 2`; +* `wpos B S = max (w B S) 0`. + +Todo está *definido* mediante fórmulas explícitas (nada postulado). +-/ + +namespace GapExtremal + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] + +/-- Subgrafo de `B` inducido en `S`, visto como grafo sobre el mismo tipo de vértices. -/ +def inducedOn (B : SimpleGraph V) (S : Finset V) : SimpleGraph V where + Adj u v := B.Adj u v ∧ u ∈ S ∧ v ∈ S + symm := ⟨fun _ _ h => ⟨h.1.symm, h.2.2, h.2.1⟩⟩ + loopless := ⟨fun _ h => h.1.ne rfl⟩ + +instance inducedOn.instDecidableRel (B : SimpleGraph V) [DecidableRel B.Adj] (S : Finset V) : + DecidableRel (inducedOn B S).Adj := fun u v => + inferInstanceAs (Decidable (B.Adj u v ∧ u ∈ S ∧ v ∈ S)) + +/-- Número de pares **ordenados** `(u,v) ∈ X × Y` con `u` adyacente a `v` en `B`. -/ +def D (B : SimpleGraph V) [DecidableRel B.Adj] (X Y : Finset V) : ℕ := + ∑ u ∈ X, ∑ v ∈ Y, if B.Adj u v then 1 else 0 + +/-- Número de aristas de `B` con ambos extremos en `S`. -/ +def e (B : SimpleGraph V) [DecidableRel B.Adj] (S : Finset V) : ℕ := + (inducedOn B S).edgeFinset.card + +/-- Peso de una columna: `w B S = 2 * e B S - C(|S|,2) - 1`. -/ +def w (B : SimpleGraph V) [DecidableRel B.Adj] (S : Finset V) : ℤ := + 2 * (e B S : ℤ) - ((S.card).choose 2 : ℤ) - 1 + +/-- `phi B S = 2 * e B S - C(|S|,2) = w B S + 1`. -/ +def phi (B : SimpleGraph V) [DecidableRel B.Adj] (S : Finset V) : ℤ := + 2 * (e B S : ℤ) - ((S.card).choose 2 : ℤ) + +/-- Parte positiva del peso, `w⁺`. -/ +def wpos (B : SimpleGraph V) [DecidableRel B.Adj] (S : Finset V) : ℤ := max (w B S) 0 + +variable (B : SimpleGraph V) [DecidableRel B.Adj] + +lemma phi_eq_w_add_one (S : Finset V) : phi B S = w B S + 1 := by + simp [phi, w] + +lemma w_le_wpos (S : Finset V) : w B S ≤ wpos B S := le_max_left _ _ + +lemma wpos_nonneg (S : Finset V) : 0 ≤ wpos B S := le_max_right _ _ + +/-! ### `D` -/ + +omit [Fintype V] [DecidableEq V] in +lemma D_comm (X Y : Finset V) : D B X Y = D B Y X := by + unfold D + rw [Finset.sum_comm] + exact Finset.sum_congr rfl fun u _ => Finset.sum_congr rfl fun v _ => by + simp [SimpleGraph.adj_comm] + +omit [Fintype V] in +lemma D_union_left {X X' Y : Finset V} (h : Disjoint X X') : + D B (X ∪ X') Y = D B X Y + D B X' Y := by + unfold D + rw [Finset.sum_union h] + +omit [Fintype V] in +lemma D_union_right {X Y Y' : Finset V} (h : Disjoint Y Y') : + D B X (Y ∪ Y') = D B X Y + D B X Y' := by + rw [D_comm, D_union_left B h, D_comm B Y X, D_comm B Y' X] + +omit [Fintype V] [DecidableEq V] in +lemma D_empty_left (Y : Finset V) : D B ∅ Y = 0 := by simp [D] + +omit [Fintype V] [DecidableEq V] in +lemma D_empty_right (X : Finset V) : D B X ∅ = 0 := by simp [D] + +omit [Fintype V] [DecidableEq V] in +/-- Si no hay aristas entre `X` e `Y`, `D B X Y = 0`. -/ +lemma D_eq_zero_of_no_edges {X Y : Finset V} (h : ∀ u ∈ X, ∀ v ∈ Y, ¬ B.Adj u v) : + D B X Y = 0 := by + unfold D + refine Finset.sum_eq_zero fun u hu => Finset.sum_eq_zero fun v hv => ?_ + simp [h u hu v hv] + +omit [Fintype V] [DecidableEq V] in +lemma D_eq_sum_singleton_left (X Y : Finset V) : D B X Y = ∑ u ∈ X, D B {u} Y := by + unfold D + exact Finset.sum_congr rfl fun u _ => by rw [Finset.sum_singleton] + +omit [Fintype V] [DecidableEq V] in +lemma D_self_singleton (a : V) : D B {a} {a} = 0 := by + simp [D, SimpleGraph.irrefl] + +omit [Fintype V] in +lemma D_biUnion_left {ι : Type*} (A : Finset ι) (f : ι → Finset V) (Y : Finset V) + (hdisj : (A : Set ι).PairwiseDisjoint f) : + D B (A.biUnion f) Y = ∑ a ∈ A, D B (f a) Y := by + unfold D + rw [Finset.sum_biUnion hdisj] + +omit [Fintype V] in +lemma D_biUnion_right {ι : Type*} (A : Finset ι) (f : ι → Finset V) (X : Finset V) + (hdisj : (A : Set ι).PairwiseDisjoint f) : + D B X (A.biUnion f) = ∑ a ∈ A, D B X (f a) := by + rw [D_comm, D_biUnion_left B A f X hdisj] + exact Finset.sum_congr rfl fun a _ => D_comm B (f a) X + +/-- `2 * e B S = D B S S`: cada arista interior se cuenta dos veces como par ordenado. -/ +lemma two_mul_e_eq_D (S : Finset V) : 2 * e B S = D B S S := by + classical + rw [e, (inducedOn B S).two_mul_card_edgeFinset, D, Finset.card_filter, + ← Finset.univ_product_univ, Finset.sum_product] + rw [← Finset.sum_subset (Finset.subset_univ S) (by + intro u _ hu + refine Finset.sum_eq_zero ?_ + intro v _ + simp only [inducedOn] + simp [hu])] + refine Finset.sum_congr rfl fun u hu => ?_ + rw [← Finset.sum_subset (Finset.subset_univ S) (by + intro v _ hv + simp only [inducedOn] + simp [hv])] + refine Finset.sum_congr rfl fun v hv => ?_ + simp only [inducedOn] + simp [hu, hv] + +/-- El peso escrito con pares ordenados. -/ +lemma w_eq_D (S : Finset V) : w B S = (D B S S : ℤ) - ((S.card).choose 2 : ℤ) - 1 := by + rw [w, ← two_mul_e_eq_D] + push_cast + ring + +lemma phi_eq_D (S : Finset V) : phi B S = (D B S S : ℤ) - ((S.card).choose 2 : ℤ) := by + rw [phi, ← two_mul_e_eq_D] + push_cast + ring + +omit [Fintype V] [DecidableEq V] in +lemma D_self_eq_zero_of_card_le_one {S : Finset V} (h : S.card ≤ 1) : D B S S = 0 := by + rcases Nat.lt_or_ge S.card 1 with h0 | h1 + · have hS : S = ∅ := Finset.card_eq_zero.mp (show S.card = 0 by omega) + subst hS + simp [D] + · obtain ⟨a, rfl⟩ := Finset.card_eq_one.mp (show S.card = 1 by omega) + simp [D, SimpleGraph.irrefl] + +/-- `phi` se anula en conjuntos de a lo sumo un elemento. -/ +lemma phi_eq_zero_of_card_le_one {S : Finset V} (h : S.card ≤ 1) : phi B S = 0 := by + rw [phi_eq_D, D_self_eq_zero_of_card_le_one B h] + rcases Nat.lt_or_ge S.card 1 with h0 | h1 + · rw [show S.card = 0 by omega] + simp + · rw [show S.card = 1 by omega] + simp + +/-- Un conjunto con menos de tres elementos tiene peso `≤ 0`. -/ +lemma w_nonpos_of_card_lt_three {S : Finset V} (h : S.card < 3) : w B S ≤ 0 := by + rw [w_eq_D] + have h012 : S.card = 0 ∨ S.card = 1 ∨ S.card = 2 := by omega + rcases h012 with hc | hc | hc + · rw [Finset.card_eq_zero] at hc + subst hc + simp [D] + · have hD : D B S S = 0 := by + obtain ⟨a, rfl⟩ := Finset.card_eq_one.mp hc + simp [D, SimpleGraph.irrefl] + rw [hD, hc] + norm_num + · have hD : D B S S ≤ 2 := by + obtain ⟨a, b, hab, rfl⟩ := Finset.card_eq_two.mp hc + unfold D + rw [Finset.sum_pair hab, Finset.sum_pair hab, Finset.sum_pair hab] + simp only [SimpleGraph.irrefl, ite_false] + split <;> split <;> simp + rw [hc] + have : (D B S S : ℤ) ≤ 2 := by exact_mod_cast hD + norm_num + linarith + +/-- `w⁺` se anula en conjuntos de menos de tres elementos. -/ +lemma wpos_eq_zero_of_card_lt_three {S : Finset V} (h : S.card < 3) : wpos B S = 0 := + max_eq_right (w_nonpos_of_card_lt_three B h) + +/-- Si `w⁺ B S ≠ 0` entonces `S` es una columna (tiene al menos tres elementos). -/ +lemma three_le_card_of_wpos_ne_zero {S : Finset V} (h : wpos B S ≠ 0) : 3 ≤ S.card := by + by_contra hc + exact h (wpos_eq_zero_of_card_lt_three B (by omega)) + +/-- Si `w B S > 0` entonces `S` es una columna. -/ +lemma three_le_card_of_w_pos {S : Finset V} (h : 0 < w B S) : 3 ≤ S.card := by + by_contra hc + exact absurd h (not_lt.mpr (w_nonpos_of_card_lt_three B (by omega))) + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean new file mode 100644 index 0000000000..ac1da4cc65 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean @@ -0,0 +1,388 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Single +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Abel + +/-! +# S-caps suffice (ledger §17, L17.1) + +The cap hypothesis enters the positioned construction only through `tri_geom` and `one_geom`, and +there the +coefficients of the linear dependence are differences of *active* colours. So it suffices that the +seed `A` be an +**S-cap** for the set `S` of active colours: no three distinct `a, b, c ∈ A` and `s₁, s₂, s₃ ∈ S` +with `s₁ ≠ s₂` and +`(s₂ - s₁) a + (s₃ - s₂) b + (s₁ - s₃) c = 0`. + +This file re-runs the chain `pblockHyp → pI_le → pgap_ge_third → tp_single` under that weaker +hypothesis +(`tp_single_s`). The original cap chain is left untouched. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-! ### S-caps -/ + +section SCapDef + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +/-- `A` is an `S`-cap: no colour relation `(s₂ - s₁) a + (s₃ - s₂) b + (s₁ - s₃) c = 0` with `s₁ ≠ +s₂` among three +distinct points of `A`. -/ +def IsSCap (S : Set K) (A : Set V) : Prop := + ∀ ⦃a⦄, a ∈ A → ∀ ⦃b⦄, b ∈ A → ∀ ⦃c⦄, c ∈ A → a ≠ b → a ≠ c → b ≠ c → + ∀ ⦃s₁⦄, s₁ ∈ S → ∀ ⦃s₂⦄, s₂ ∈ S → ∀ ⦃s₃⦄, s₃ ∈ S → s₁ ≠ s₂ → + (s₂ - s₁) • a + (s₃ - s₂) • b + (s₁ - s₃) • c ≠ 0 + +/-- A colour relation with `s₂ = s₃` forces `a = c`. -/ +theorem rel_eq23 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} + (h : (s₂ - s₁) • a + (s₂ - s₂) • b + (s₁ - s₂) • c = 0) : a = c := by + have : (s₂ - s₁) • (a - c) = 0 := by + rw [smul_sub] + have e : (s₁ - s₂) • c = -((s₂ - s₁) • c) := by rw [← neg_smul, neg_sub] + rw [sub_self, zero_smul, add_zero, e] at h + simpa [sub_eq_add_neg] using h + rcases smul_eq_zero.mp this with h0 | h0 + · exact absurd (sub_eq_zero.mp h0).symm h12 + · exact sub_eq_zero.mp h0 + +/-- A colour relation with `s₁ = s₃` forces `a = b`. -/ +theorem rel_eq13 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} + (h : (s₂ - s₁) • a + (s₁ - s₂) • b + (s₁ - s₁) • c = 0) : a = b := by + have : (s₂ - s₁) • (a - b) = 0 := by + rw [smul_sub] + have e : (s₁ - s₂) • b = -((s₂ - s₁) • b) := by rw [← neg_smul, neg_sub] + rw [sub_self, zero_smul, add_zero, e] at h + simpa [sub_eq_add_neg] using h + rcases smul_eq_zero.mp this with h0 | h0 + · exact absurd (sub_eq_zero.mp h0).symm h12 + · exact sub_eq_zero.mp h0 + +/-- S-caps are closed under powers. -/ +theorem IsSCap.pi {ι : Type*} {S : Set K} {A : Set V} (hA : IsSCap S A) : + IsSCap S (Set.pi Set.univ (fun _ : ι => A)) := by + intro a ha b hb c hc hab hac hbc s₁ h1 s₂ h2 s₃ h3 h12 hrel + have hcoord : ∀ i, (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • c i = 0 := fun i => by + simpa using congrFun hrel i + by_cases h23 : s₂ = s₃ + · subst h23 + exact hac (funext fun i => rel_eq23 h12 (hcoord i)) + by_cases h13 : s₁ = s₃ + · subst h13 + exact hab (funext fun i => rel_eq13 h12 (hcoord i)) + obtain ⟨i, hi⟩ : ∃ i, a i ≠ b i := by + by_contra h; push Not at h; exact hab (funext h) + have hai := ha i (Set.mem_univ i) + have hbi := hb i (Set.mem_univ i) + have hci := hc i (Set.mem_univ i) + by_cases hac' : a i = c i + · -- then `(s₂ - s₃) (a i - b i) = 0` + have e := hcoord i + rw [← hac'] at e + have : (s₂ - s₃) • (a i - b i) = 0 := by + have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • a i = (s₂ - s₃) • (a i - b i) := by + simp only [smul_sub, sub_smul]; abel + rw [← this]; exact e + rcases smul_eq_zero.mp this with h0 | h0 + · exact h23 (sub_eq_zero.mp h0) + · exact hi (sub_eq_zero.mp h0) + by_cases hbc' : b i = c i + · have e := hcoord i + rw [← hbc'] at e + have : (s₂ - s₁) • (a i - b i) = 0 := by + have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • b i = (s₂ - s₁) • (a i - b i) := by + simp only [smul_sub, sub_smul]; abel + rw [← this]; exact e + rcases smul_eq_zero.mp this with h0 | h0 + · exact h12 (sub_eq_zero.mp h0).symm + · exact hi (sub_eq_zero.mp h0) + exact hA hai hbi hci hi hac' hbc' h1 h2 h3 h12 (hcoord i) + +end SCapDef + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] + +/-! ### Geometry under an S-cap -/ + +section Geom + +variable {S : Set F} {C : Finset W} (hC : IsSCap S (C : Set W)) +include hC + +omit [Fintype W] in +/-- `tri_geom` under an S-cap, for points of active colours. -/ +theorem tri_geom_s {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) + (hxS : x.1 ∈ S) (hyS : y.1 ∈ S) (hzS : z.1 ∈ S) + (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) + (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d + ∧ z ∈ line p d := by + have hα : y.1 - x.1 ≠ 0 := by + intro h0; rw [h0, zero_smul, sub_eq_zero] at h1; exact hxy h1.symm + by_cases hab : a = b + · subst hab + refine ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, ?_⟩ + refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ + rw [add_smul, ← h1, ← h2]; abel + by_cases hac : a = c + · subst hac + exact ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ + by_cases hbc : b = c + · subst hbc + refine ⟨b, hb, z, ?_, ?_, self_mem_line z b⟩ + · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ + rw [neg_smul, ← h3]; abel + · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ + rw [neg_smul, ← h2]; abel + exfalso + have e1 := snd_eq_of_sub h1 + have e2 := snd_eq_of_sub h2 + have e3 := snd_eq_of_sub h3 + refine hC ha hb hc hab hac hbc hxS hyS hzS (fun h0 => hα (sub_eq_zero.mpr h0.symm)) ?_ + rw [show x.1 - z.1 = -(z.1 - x.1) by ring, ← e1, ← e2, neg_smul, ← e3]; abel + +omit [Fintype W] in +/-- `one_geom` under an S-cap, for points of active colours. -/ +theorem one_geom_s {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) + (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) (hzS : z.1 ∈ S) (hyS : y.1 ∈ S) (hy'S : y'.1 ∈ S) + {d e' : W} (hd : d ∈ C) (he : e' ∈ C) + (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := by + by_contra hne + have hyy := sub_of_mem_line hy hy' + have hγ : y'.1 - y.1 ≠ 0 := fun h0 => + hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) + by_cases hdc : d = c0 + · subst hdc + apply hz + rw [← line_eq_of_mem hy] + refine mem_line.mpr ⟨-(y.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy]; abel + by_cases hec : e' = c0 + · subst hec + apply hz + rw [← line_eq_of_mem hy'] + refine mem_line.mpr ⟨-(y'.1 - z.1), ?_⟩ + rw [neg_smul, ← hzy']; abel + by_cases hde : d = e' + · subst hde + have : (y'.1 - y.1) • (u d : F × W) = (y'.1 - y.1) • u c0 := by + rw [← hyy] + have : y' - y = (y' - z) - (y - z) := by abel + rw [this, hzy, hzy', ← sub_smul] + congr 1; ring + exact hdc ((par_eq this).2 hγ) + by_cases hzy1 : y'.1 = z.1 + · have : y' = z := by + rw [hzy1, sub_self, zero_smul, sub_eq_zero] at hzy' + exact hzy' + exact hz (this ▸ hy') + have e1 := snd_eq_of_sub hzy + have e2 := snd_eq_of_sub hzy' + have e3 := snd_eq_of_sub hyy + -- colours `s₁ = z.1`, `s₂ = y'.1`, `s₃ = y.1`; points `e'`, `c0`, `d` + refine hC he hc0 hd hec (Ne.symm hde) (Ne.symm hdc) hzS hy'S hyS (Ne.symm hzy1) ?_ + have : (y.1 - y'.1) • c0 = -((y'.1 - y.1) • c0) := by rw [← neg_smul, neg_sub] + have hd' : (z.1 - y.1) • d = -((y.1 - z.1) • d) := by rw [← neg_smul, neg_sub] + rw [hd', this, ← e2, ← e1, ← e3]; abel + +end Geom + +section PChain + +/-! ### The positioned chain under an S-cap -/ + +variable {V P : Type*} [Fintype V] [DecidableEq V] [DecidableEq P] +variable (D : PData F W V P) {C : Finset W} + +/-- Active colours of a positioned core. -/ +def actCol : Set F := Set.range fun i => D.col (D.σ i) + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem fst_mem_actCol {v : V} (h : ∃ i, D.σ i = D.pos v) : (D.base v).1 ∈ actCol D := by + obtain ⟨i, hi⟩ := h + exact ⟨i, by rw [D.base_fst]; exact congrArg D.col hi⟩ + +variable (hC : IsSCap (actCol D) (C : Set W)) +include hC + +theorem pblockHyp_s : BlockHyp2 (PB D C) (pblocks D C) where + edge := by + intro v v' h + obtain ⟨hv, hv'⟩ := PB_adj_pos D h + obtain ⟨-, ⟨c, hc, hdir⟩, -⟩ := h + refine ⟨pblock D (D.base v) c, pblock_mem D hc _, ?_, ?_⟩ + · exact (mem_pblock D).mpr ⟨self_mem_line _ _, hv⟩ + · exact (mem_pblock D).mpr ⟨mem_line_of_sub hdir, hv'⟩ + tri := by + intro a b x hab hbx hax + have pa := (PB_adj_pos D hab).1 + have pb := (PB_adj_pos D hab).2 + have px := (PB_adj_pos D hbx).2 + obtain ⟨hne, ⟨c1, hc1, h1⟩, -⟩ := hab + obtain ⟨-, ⟨c2, hc2, h2⟩, -⟩ := hbx + obtain ⟨-, ⟨c3, hc3, h3⟩, -⟩ := hax + obtain ⟨d, hd, p, ha, hb, hx⟩ := tri_geom_s hC hc1 hc2 hc3 hne (fst_mem_actCol D pa) + (fst_mem_actCol D pb) (fst_mem_actCol D px) h1 h2 h3 + refine ⟨pblock D p d, pblock_mem D hd p, ?_, ?_, ?_⟩ + · exact (mem_pblock D).mpr ⟨ha, pa⟩ + · exact (mem_pblock D).mpr ⟨hb, pb⟩ + · exact (mem_pblock D).mpr ⟨hx, px⟩ + two := by + intro ℓ hℓ z hz y hy y' hy' y'' hy'' h1 h2 h3 + obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 + rw [mem_pblock] at hy hy' hy'' + have pz := (PB_adj_pos D h1).1 + have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => + hz ((mem_pblock D).mpr ⟨hzl, pz⟩) + obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 + obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 + obtain ⟨-, ⟨d3, hd3, e3⟩, -⟩ := h3 + have b12 := one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2 + have b13 := one_geom_s hC hc0 hzl hy.1 hy''.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy''.2) hd1 hd3 e1 e3 + exact D.fib y y' y'' b12 b13 + nonadj := by + intro ℓ hℓ z hz y hy y' hy' h1 h2 hyy + obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 + rw [mem_pblock] at hy hy' + have pz := (PB_adj_pos D h1).1 + have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => + hz ((mem_pblock D).mpr ⟨hzl, pz⟩) + obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 + obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 + exact hyy.1 (one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2) + +/-- **`I(B) ≤ 8 · #blocks`** under an S-cap. -/ +theorem pI_le_s {T : Finset (Finset V)} (hT : IsPack T) : + ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card := by + refine global_bound2 (pblockHyp_s D hC) 8 ?_ hT + intro ℓ hℓ T' hT'sub hT' + obtain ⟨⟨c0, w0⟩, -, rfl⟩ := Finset.mem_image.mp hℓ + have hinj : Set.InjOn D.pos (pblock D ((0 : F), w0) c0 : Set V) := by + intro v hv v' hv' h + rw [Finset.mem_coe, mem_pblock] at hv hv' + apply D.inj v v' _ h + apply fst_injOn_line _ _ hv.1 hv'.1 + rw [D.base_fst, D.base_fst, h] + have := block_local (B := PB D C) D.pos D.σ hinj + (fun v _ v' _ h => by + obtain ⟨-, -, i, j, hi, hj, hij⟩ := h + exact ⟨i, j, hi, hj, hij⟩) T' hT'sub hT' + simpa using this + +omit hC in +theorem pgap_ge_third_s [Fintype P] {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] + [DecidableEq U] + (hC : IsSCap (actCol D) (C : Set W)) (hC0 : C.Nonempty) (S : SepFam F C U) + (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → + ¬ H12.graph.Adj i j) : + ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (ppalette D C S)) := by + have h := gap_ge (phostHyp (S := S) hC0 hsame) (8 * (pblocks D C).card) + (fun T hT => pI_le_s D hC hT) (presPack (D := D) (C := C)) + have hv := pvalue (D := D) (C := C) + have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by + exact_mod_cast card_pblocks_le D + push_cast at h ⊢ + linarith + + +end PChain + +section Single + +variable {F : Type} [Field F] [Fintype F] [DecidableEq F] +variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +omit [DecidableEq F] [DecidableEq U] [Fintype F] [Fintype U] in +theorem isSCap_capPow {S : Set F} {A : Finset U} (hA : IsSCap S (A : Set U)) (j : ℕ) : + IsSCap S (capPow A j : Set (Fin j → U)) := by + rw [coe_capPow]; exact hA.pi + +omit [DecidableEq F] [Fintype F] in +theorem actCol_single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : + actCol (single (W := W) σ) = Set.range σ := rfl + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond for S-caps** (ledger §17): the exponent `1 + log |A| / log |U|` for every S-cap `A`, +`S` the +active colours `range σ`. -/ +theorem tp_single_s (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ) (A : Set U)) (hA0 : + A.Nonempty) {e : U} + (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + classical + set M := Fintype.card U + set q := Fintype.card F + have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by + obtain ⟨a0, ha0⟩ := hA0 + exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ + refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) + (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) + (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) + · have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) + rw [hc] + simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, + Fintype.card_fin, Sym2.card] + set X := M ^ j + set C2 := (q + 1).choose 2 with hC2 + have hsym : C2 ≤ (q + 1) ^ 2 := by + rw [hC2, Nat.choose_two_right, sq] + exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) + have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 + have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by + calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym + _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) + _ = (q + 1) ^ 4 := by ring + have f3 : q * C2 ≤ (q + 1) ^ 4 := by + calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym + _ ≤ (q + 1) ^ 4 := by + calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring + _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) + have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX + have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring + have e3 : q * X * C2 = (q * C2) * X := by ring + have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX + have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 + calc q * X + q * X * (M * q * C2) + q * X * C2 + ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by + rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 + _ = 3 * (q + 1) ^ 4 * M * X := by ring + · have h := pgap_ge_third_s (single (W := Fin j → U) σ) (isSCap_capPow hA j) (hcapne j) + (prodSep A he j) (single_same σ) + rw [card_capPow] at h + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [hW] at h + push_cast at h + exact h + + +end Single + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean new file mode 100644 index 0000000000..3a343a22b6 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean @@ -0,0 +1,120 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.LayeredExponent +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# One-layer cores: any cap, any field with at least six elements (ledger §16.1) + +`single σ` is the positioned core `V = F × W` with positions = colours. Together with `prodSep` it +gives, for +every cap `A` in a finite `F`-module `U` (no separability), the exponent `1 + log |A| / log |U|` +(`tp_single`). This removes SEP from TP-cond. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type} [Field F] [Fintype F] [DecidableEq F] + +/-- The one-layer positioned core. -/ +def single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : PData F W (F × W) F where + base := id + pos := Prod.fst + col := id + σ := σ + base_fst := fun _ => rfl + inj := fun _ _ h _ => h + fib := fun _ _ _ h _ => Or.inl h + rl := fun y _ => y + rl_base := fun _ _ _ => rfl + rl_pos := fun _ _ h => h + colσ := fun _ _ h => Or.inl (σ.injective h) + +omit [DecidableEq F] [Fintype F] in +theorem single_same {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : + ∀ v v' : F × W, (single (W := W) σ).base v = (single (W := W) σ).base v' → + ∀ i j, σ i = (single (W := W) σ).pos v → σ j = (single (W := W) σ).pos v' → + ¬ H12.graph.Adj i j := by + intro v v' hb i j hi hj hij + simp only [single, id] at hb hi hj + subst hb + exact hij.ne (σ.injective (hi.trans hj.symm)) + +variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] + +/-- The one-layer graph of `A^j`. -/ +abbrev SV (F U : Type) (j : ℕ) := + (F × (Fin j → U)) ⊕ PHostIdx F (Fin j → U) F U + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond without SEP.** -/ +theorem tp_single (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hA0 : A.Nonempty) {e + : U} + (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + classical + set M := Fintype.card U + set q := Fintype.card F + have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by + obtain ⟨a0, ha0⟩ := hA0 + exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ + refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) + (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) + (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) + · have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) + rw [hc] + simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, + Fintype.card_fin, Sym2.card] + set X := M ^ j + set C2 := (q + 1).choose 2 with hC2 + have hsym : C2 ≤ (q + 1) ^ 2 := by + rw [hC2, Nat.choose_two_right, sq] + exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) + have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 + have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by + calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym + _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) + _ = (q + 1) ^ 4 := by ring + have f3 : q * C2 ≤ (q + 1) ^ 4 := by + calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym + _ ≤ (q + 1) ^ 4 := by + calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring + _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) + have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX + have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring + have e3 : q * X * C2 = (q * C2) * X := by ring + have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX + have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 + calc q * X + q * X * (M * q * C2) + q * X * C2 + ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by + rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 + _ = 3 * (q + 1) ^ 4 * M * X := by ring + · have h := pgap_ge_third (single (W := Fin j → U) σ) (isCap_capPow hA j) (hcapne j) + (prodSep A he j) (single_same σ) + rw [card_capPow] at h + have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] + rw [hW] at h + push_cast at h + exact h + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Source.lean b/LeanPool/SplitCliqueGap/GapExtremal/Source.lean new file mode 100644 index 0000000000..8f0428f54f --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Source.lean @@ -0,0 +1,274 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Core +public import LeanPool.SplitCliqueGap.GapExtremal.Bridge +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! +# Counting blocks and the fractional source (ledger L7.4) + +* `blocks_eq`, `card_blocks`: the blocks are the lines `line (0, w) c`, `c ∈ C`, `w ∈ W`, all +distinct, so + `#blocks = |C| · |W|`. +* `ysrc`: mass `1/3` on the nine source pieces of every block; `resPack_ysrc` (capacity 1 on every +pair) and + `value_ysrc` (`∑ y w ≥ 25/3 · |C| · |W|`). +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] +variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] +variable {C : Finset W} {σ : Fin 6 ↪ F} + +/-! ### Blocks indexed by direction and colour-0 point -/ + +omit [Fintype W] in +theorem line_zero (w c : W) : line ((0 : F), w) c = univ.image fun a : F => (a, w + a • c) := by + unfold line + congr 1 + funext a + simp [u] + +omit [Fintype W] in +theorem mem_line_zero {w c : W} {p : F × W} : p ∈ line ((0 : F), w) c ↔ p.2 = w + p.1 • c := by + rw [line_zero] + simp only [Finset.mem_image, Finset.mem_univ, true_and] + constructor + · rintro ⟨a, rfl⟩; rfl + · intro h; exact ⟨p.1, by rw [← h]⟩ + +omit [Fintype W] in +theorem line_eq_line_zero (x : F × W) (c : W) : line x c = line ((0 : F), x.2 - x.1 • c) c := by + symm + apply line_eq_of_mem + exact mem_line.mpr ⟨-x.1, by simp [u, Prod.ext_iff, sub_eq_add_neg]⟩ + +omit [Fintype W] in +theorem line_zero_inj {w w' c c' : W} (h : line ((0 : F), w) c = line ((0 : F), w') c') : + w = w' ∧ c = c' := by + have h0 : ((0 : F), w) ∈ line ((0 : F), w') c' := h ▸ self_mem_line _ _ + rw [mem_line_zero] at h0 + simp only [zero_smul, add_zero] at h0 + subst h0 + have h1 : ((1 : F), w + (1 : F) • c) ∈ line ((0 : F), w) c' := by + rw [← h, mem_line_zero] + rw [mem_line_zero] at h1 + simp only [one_smul, add_right_inj] at h1 + exact ⟨rfl, h1⟩ + +theorem blocks_eq : blocks (F := F) C = (C ×ˢ univ).image fun p : W × W => line ((0 : F), p.2) p.1 + := by + ext ℓ + constructor + · intro hℓ + obtain ⟨⟨x, c⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc : c ∈ C := (Finset.mem_product.mp hp).2 + exact Finset.mem_image.mpr ⟨(c, x.2 - x.1 • c), + Finset.mem_product.mpr ⟨hc, Finset.mem_univ _⟩, (line_eq_line_zero x c).symm⟩ + · intro hℓ + obtain ⟨⟨c, w⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + exact mem_blocks_of (Finset.mem_product.mp hp).1 + +theorem card_blocks : (blocks (F := F) C).card = C.card * Fintype.card W := by + rw [blocks_eq, Finset.card_image_of_injOn, Finset.card_product, Finset.card_univ] + rintro ⟨c, w⟩ - ⟨c', w'⟩ - h + obtain ⟨hw, hc⟩ := line_zero_inj h + exact Prod.ext hc hw + +/-! ### The source -/ + +/-- The nine pieces of the local fractional source (mass `1/3` each). -/ +def src : Finset (Finset (Fin 6)) := + {{0, 1, 4}, {0, 1, 5}, {1, 2, 4}, {1, 2, 5}, {2, 3, 4}, {2, 3, 5}, {0, 1, 4, 5}, {0, 3, 4, 5}, + {2, 3, 4, 5}} + +theorem src_value : ∑ K ∈ src, (2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1) = 25 := by + decide +kernel + +theorem src_card : ∀ K ∈ src, 3 ≤ K.card := by decide +kernel + +theorem src_pair : ∀ i j : Fin 6, i ≠ j → (src.filter fun K => i ∈ K ∧ j ∈ K).card ≤ 3 := by + decide +kernel + +/-- The point of colour `σ i` on the line `line (0, w) c`. -/ +def ptc (σ : Fin 6 ↪ F) (w c : W) (i : Fin 6) : F × W := (σ i, w + σ i • c) + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem ptc_injective (w c : W) : Function.Injective (ptc σ w c) := fun _ _ h => + σ.injective (congrArg Prod.fst h) + +/-- A source piece, indexed by direction, colour-0 point and colour set. -/ +def piece (σ : Fin 6 ↪ F) (x : (W × W) × Finset (Fin 6)) : Finset (F × W) := + x.2.image (ptc σ x.1.2 x.1.1) + +/-- Index set of the pieces. -/ +def pidx (C : Finset W) : Finset ((W × W) × Finset (Fin 6)) := (C ×ˢ univ) ×ˢ src + +omit [Fintype F] [Fintype W] in +theorem card_piece (x : (W × W) × Finset (Fin 6)) : (piece σ x).card = x.2.card := + Finset.card_image_of_injective _ (ptc_injective _ _) + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +/-- Two points of distinct colours on a line `line (0, w) c` determine `w` and `c`. -/ +theorem wc_eq_of_two {w c w' c' : W} {a b : F} (hab : a ≠ b) (ha : w + a • c = w' + a • c') + (hb : w + b • c = w' + b • c') : w = w' ∧ c = c' := by + have h1 : (a - b) • (c - c') = 0 := by + calc (a - b) • (c - c') = (w + a • c - (w' + a • c')) - (w + b • c - (w' + b • c')) := by module + _ = 0 := by rw [ha, hb, sub_self, sub_self, sub_zero] + have hc : c = c' := by + have := congrArg (fun v => (a - b)⁻¹ • v) h1 + simp only [smul_smul, inv_mul_cancel₀ (sub_ne_zero.mpr hab), one_smul, smul_zero] at this + exact sub_eq_zero.mp this + subst hc + exact ⟨add_right_cancel ha, rfl⟩ + +omit [Fintype F] in +theorem piece_injOn : Set.InjOn (piece (W := W) σ) (↑(pidx C)) := by + rintro ⟨⟨c, w⟩, K⟩ hx ⟨⟨c', w'⟩, K'⟩ hx' h + rw [Finset.mem_coe, pidx, Finset.mem_product] at hx hx' + have h3 := src_card K hx.2 + obtain ⟨i1, hi1, i2, hi2, hne⟩ := Finset.one_lt_card.mp (by omega : 1 < K.card) + have m1 : ptc σ w c i1 ∈ piece σ ((c', w'), K') := h ▸ Finset.mem_image_of_mem _ hi1 + have m2 : ptc σ w c i2 ∈ piece σ ((c', w'), K') := h ▸ Finset.mem_image_of_mem _ hi2 + obtain ⟨j1, -, e1⟩ := Finset.mem_image.mp m1 + obtain ⟨j2, -, e2⟩ := Finset.mem_image.mp m2 + simp only [ptc, Prod.mk.injEq] at e1 e2 + have hj1 : j1 = i1 := σ.injective e1.1 + have hj2 : j2 = i2 := σ.injective e2.1 + subst hj1 hj2 + obtain ⟨hw, hc⟩ := wc_eq_of_two (fun h' => hne (σ.injective h')) e1.2.symm e2.2.symm + subst hw hc + have : K = K' := Finset.image_injective (ptc_injective w c) h + rw [this] + +/-- All the source pieces. -/ +def pieces (C : Finset W) (σ : Fin 6 ↪ F) : Finset (Finset (F × W)) := (pidx C).image (piece σ) + +open Classical in +/-- The fractional source: `1/3` on every piece. -/ +noncomputable def ysrc (C : Finset W) (σ : Fin 6 ↪ F) (S : Finset (F × W)) : ℝ := + if S ∈ pieces C σ then 1 / 3 else 0 + +omit [DecidableEq F] [DecidableEq W] [Fintype F] [Fintype W] in +theorem ptc_adj {c : W} (hc : c ∈ C) (w : W) {i j : Fin 6} (h : H12.graph.Adj i j) : + (Bgr C σ).Adj (ptc σ w c i) (ptc σ w c j) := by + refine ⟨fun h' => h.ne (ptc_injective w c h'), ⟨c, hc, ?_⟩, i, j, rfl, rfl, h⟩ + simp only [ptc, u, Prod.ext_iff, Prod.fst_sub, Prod.snd_sub, Prod.smul_fst, Prod.smul_snd, + smul_eq_mul, mul_one] + exact ⟨trivial, by module⟩ + +omit [Fintype F] [Fintype W] in +theorem mem_piece_iff {x : (W × W) × Finset (Fin 6)} {p : F × W} : + p ∈ piece σ x ↔ ∃ i ∈ x.2, ptc σ x.1.2 x.1.1 i = p := Finset.mem_image + +theorem resPack_ysrc : ResPack (ysrc C σ) where + nonneg S := by unfold ysrc; split_ifs <;> norm_num + two S h := by + unfold ysrc at h + split_ifs at h with hS + · obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hS + rw [card_piece] + have := src_card x.2 (Finset.mem_product.mp hx).2 + omega + · exact absurd rfl h + load a b hab := by + classical + set T := (pieces C σ).filter (fun S => a ∈ S ∧ b ∈ S) with hT + have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then ysrc C σ S else 0) = T.card * (1 / 3 : ℝ) := by + rw [hT, Finset.card_filter, Nat.cast_sum, Finset.sum_mul] + rw [← Finset.sum_subset (Finset.subset_univ (pieces C σ))] + · refine Finset.sum_congr rfl fun S hS => ?_ + unfold ysrc + rw [ite_eq_left hS] + split_ifs <;> simp + · intro S _ hS + unfold ysrc + rw [ite_eq_right hS] + simp + rw [hsum] + have hT3 : T.card ≤ 3 := by + rcases T.eq_empty_or_nonempty with h0 | ⟨S0, hS0⟩ + · rw [h0]; simp + obtain ⟨hS0p, ha0, hb0⟩ := Finset.mem_filter.mp hS0 + obtain ⟨⟨⟨c, w⟩, K⟩, hx0, rfl⟩ := Finset.mem_image.mp hS0p + obtain ⟨i, -, rfl⟩ := mem_piece_iff.mp ha0 + obtain ⟨j, -, rfl⟩ := mem_piece_iff.mp hb0 + have hij : i ≠ j := fun h => hab (by rw [h]) + refine (Finset.card_le_card ?_).trans + ((Finset.card_image_le (s := src.filter fun K => i ∈ K ∧ j ∈ K) + (f := fun K => piece σ ((c, w), K))).trans (src_pair i j hij)) + intro S hS + obtain ⟨hSp, haS, hbS⟩ := Finset.mem_filter.mp hS + obtain ⟨⟨⟨c', w'⟩, K'⟩, hx', rfl⟩ := Finset.mem_image.mp hSp + obtain ⟨i', hi', e1⟩ := mem_piece_iff.mp haS + obtain ⟨j', hj', e2⟩ := mem_piece_iff.mp hbS + simp only [ptc, Prod.mk.injEq] at e1 e2 + have hii : i' = i := σ.injective e1.1 + have hjj : j' = j := σ.injective e2.1 + subst hii hjj + obtain ⟨hw, hc⟩ := wc_eq_of_two (fun h => hij (σ.injective h)) e1.2 e2.2 + subst hw hc + refine Finset.mem_image.mpr ⟨K', Finset.mem_filter.mpr ⟨(Finset.mem_product.mp hx').2, hi', + hj'⟩, rfl⟩ + have : (T.card : ℝ) ≤ 3 := by exact_mod_cast hT3 + linarith + +/-- **L7.4.** The source has value at least `25/3` per block. -/ +theorem value_ysrc : + (25 / 3 : ℝ) * (C.card * Fintype.card W) ≤ ∑ S, ysrc C σ S * (w (Bgr C σ) S : ℝ) := by + classical + have h1 : ∑ S, ysrc C σ S * (w (Bgr C σ) S : ℝ) = + ∑ x ∈ pidx C, (1 / 3 : ℝ) * (w (Bgr C σ) (piece σ x) : ℝ) := by + rw [← Finset.sum_image (f := fun S => (1 / 3 : ℝ) * (w (Bgr C σ) S : ℝ)) piece_injOn] + rw [← Finset.sum_subset (Finset.subset_univ (pieces C σ))] + · refine Finset.sum_congr rfl fun S hS => ?_ + unfold ysrc + rw [ite_eq_left (show S ∈ pieces C σ from hS)] + · intro S _ hS + unfold ysrc + rw [ite_eq_right (show S ∉ pieces C σ from hS), zero_mul] + have h2 : ∀ x ∈ pidx C, ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) ≤ + (w (Bgr C σ) (piece σ x) : ℝ) := by + rintro ⟨⟨c, w0⟩, K⟩ hx + have hc : c ∈ C := (Finset.mem_product.mp (Finset.mem_product.mp hx).1).1 + have he : e H12.graph K ≤ e (Bgr C σ) (piece σ ((c, w0), K)) := + e_le_e_image (B := H12.graph) (Bgr C σ) (ptc σ w0 c) (ptc_injective w0 c).injOn + fun i _ j _ h => ptc_adj hc w0 h + rw [H12.e_graph_eq] at he + unfold w + rw [card_piece] + have : (H12.eH K : ℝ) ≤ (e (Bgr C σ) (piece σ ((c, w0), K)) : ℝ) := by exact_mod_cast he + push_cast + linarith + rw [h1] + calc (25 / 3 : ℝ) * (C.card * Fintype.card W) + = ∑ x ∈ pidx C, (1 / 3 : ℝ) * + ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) := by + rw [← Finset.mul_sum, pidx, Finset.sum_product] + simp only + have hv : ∑ K ∈ src, ((2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) = 25 := by + exact_mod_cast src_value + rw [Finset.sum_congr rfl fun _ _ => hv, Finset.sum_const, Finset.card_product, + Finset.card_univ, nsmul_eq_mul] + push_cast + ring + _ ≤ _ := Finset.sum_le_sum fun x hx => by + have := h2 x hx + linarith + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean b/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean new file mode 100644 index 0000000000..a41269dd47 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean @@ -0,0 +1,240 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.SCap +import Mathlib.Tactic.GCongr +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! +# Integer spheres are S-caps; the exponent of the gap is 2 (ledger §17, L17.2–L17.3, Theorem 17.0) + +* `sphere_rel`: three distinct integer points with the same squared norm satisfy no relation + `α (X - Z) + β (Y - Z) = 0` with `α ≠ 0` (strict convexity of the squared norm). +* `isSCap_seed`: a sphere `{x ∈ {0..K}^N : Σ x_i² = r}`, embedded in `F_p^N` with `10 K < p`, is an +S-cap for the + colours `0, …, 5` (an `F_p` colour relation lifts to `ℤ`). +* `exists_large_sphere`: some sphere has `≥ (K+1)^N / (N R + 1)` points (`K² ≤ R`). +* **`exponent_two`**: `gap ≥ c · n^{2 - ε}` on split graphs with at most `n` vertices. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-! ### Strict convexity over `ℤ` -/ + +/-- Three distinct integer points on a sphere satisfy no relation `α (X - Z) + β (Y - Z) = 0`, `α ≠ +0`. -/ +theorem sphere_rel {N : ℕ} (X Y Z : Fin N → ℤ) {α β : ℤ} (hα : α ≠ 0) (hXZ : X ≠ Z) (hXY : X ≠ Y) + (hrel : ∀ i, α * (X i - Z i) + β * (Y i - Z i) = 0) + (hX : ∑ i, X i ^ 2 = ∑ i, Z i ^ 2) (hY : ∑ i, Y i ^ 2 = ∑ i, Z i ^ 2) : False := by + set A := ∑ i, (X i - Z i) ^ 2 + set B := ∑ i, (Y i - Z i) ^ 2 + set Pp := ∑ i, (X i - Z i) * Z i + set Q := ∑ i, (Y i - Z i) * Z i + have hb : ∀ i, β * (Y i - Z i) = -(α * (X i - Z i)) := fun i => by linear_combination hrel i + have e1 : β * Q = -(α * Pp) := by + simp only [Q, Pp, Finset.mul_sum, ← Finset.sum_neg_distrib] + refine Finset.sum_congr rfl fun i _ => ?_ + rw [← mul_assoc, hb i]; ring + have e2 : A + 2 * Pp = 0 := by + have : A + 2 * Pp = ∑ i, X i ^ 2 - ∑ i, Z i ^ 2 := by + simp only [A, Pp, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] + refine Finset.sum_congr rfl fun i _ => ?_ + ring + rw [this, hX, sub_self] + have e3 : B + 2 * Q = 0 := by + have : B + 2 * Q = ∑ i, Y i ^ 2 - ∑ i, Z i ^ 2 := by + simp only [B, Q, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] + refine Finset.sum_congr rfl fun i _ => ?_ + ring + rw [this, hY, sub_self] + have e4 : β ^ 2 * B = α ^ 2 * A := by + change β ^ 2 * ∑ i, (Y i - Z i) ^ 2 = α ^ 2 * ∑ i, (X i - Z i) ^ 2 + rw [Finset.mul_sum, Finset.mul_sum] + refine Finset.sum_congr rfl fun i _ => ?_ + have : (β * (Y i - Z i)) ^ 2 = (-(α * (X i - Z i))) ^ 2 := by rw [hb i] + linear_combination this + have hA : 0 < A := by + obtain ⟨i, hi⟩ : ∃ i, X i ≠ Z i := by + by_contra h; push Not at h; exact hXZ (funext h) + refine lt_of_lt_of_le ?_ (Finset.single_le_sum (fun j _ => sq_nonneg (X j - Z j)) + (Finset.mem_univ i)) + exact lt_of_le_of_ne (sq_nonneg _) (Ne.symm (pow_ne_zero 2 (sub_ne_zero.mpr hi))) + have key : α * (α + β) * A = 0 := by + linear_combination (-1 : ℤ) * e4 + β ^ 2 * e3 - 2 * β * e1 + α * β * e2 + have hab : α + β = 0 := by + rcases mul_eq_zero.mp key with h | h + · rcases mul_eq_zero.mp h with h' | h' + · exact absurd h' hα + · exact h' + · exact absurd h hA.ne' + apply hXY + funext i + have := hrel i + have hb' : β = -α := by linear_combination hab + rw [hb'] at this + have : α * (X i - Y i) = 0 := by linear_combination this + rcases mul_eq_zero.mp this with h | h + · exact absurd h hα + · exact sub_eq_zero.mp h + +/-! ### Spheres in a box, embedded in `F_p^N` -/ + +variable {p : ℕ} [hp : Fact p.Prime] + +/-- Pin the additive group of `ZMod p` to the ring structure (avoids an exotic instance path). -/ +instance (priority := 10000) addCommGroupZModP : AddCommGroup (ZMod p) := Ring.toAddCommGroup + +/-- The colours `0, …, 5` in `ZMod p` (`p > 5`). -/ +def colσ (hp5 : 5 < p) : Fin 6 ↪ ZMod p where + toFun i := ((i : ℕ) : ZMod p) + inj' := by + intro i j h + have := congrArg ZMod.val h + simp only [ZMod.val_natCast] at this + rw [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega)] at this + exact Fin.ext this + +/-- Box points. -/ +def emb (K N : ℕ) (x : Fin N → Fin (K + 1)) : Fin N → ZMod p := fun i => ((x i : ℕ) : ZMod p) + +theorem emb_injective {K N : ℕ} (hK : K < p) : Function.Injective (emb (p := p) K N) := by + intro x y h + funext i + have := congrArg ZMod.val (congrFun h i) + simp only [emb, ZMod.val_natCast] at this + rw [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega)] at this + exact Fin.ext this + +/-- The sphere of squared radius `r` in the box `{0..K}^N`. -/ +def sphere (K N r : ℕ) : Finset (Fin N → Fin (K + 1)) := + univ.filter fun x => ∑ i, ((x i : ℕ)) ^ 2 = r + +/-- The seed: the sphere, embedded in `F_p^N`. -/ +def seed (p K N r : ℕ) [Fact p.Prime] : Finset (Fin N → ZMod p) := (sphere K N r).image (emb K N) + +theorem card_sphereSeed {K N r : ℕ} (hK : K < p) : (seed p K N r).card = (sphere K N r).card := + Finset.card_image_of_injective _ (emb_injective hK) + +/-- An integer of absolute value `< p` divisible by `p` is `0`. -/ +theorem int_eq_zero_of_cast {E : ℤ} (hE : (E : ZMod p) = 0) (hb : |E| < p) : E = 0 := by + rw [ZMod.intCast_zmod_eq_zero_iff_dvd] at hE + obtain ⟨k, hk⟩ := hE + have hp0 : (0 : ℤ) < p := by exact_mod_cast hp.out.pos + rcases lt_trichotomy k 0 with h | h | h + · exfalso + have : (p : ℤ) ≤ |E| := by + rw [hk, abs_mul, abs_of_pos hp0] + have : 1 ≤ |k| := Int.one_le_abs h.ne + nlinarith + linarith + · simp [hk, h] + · exfalso + have : (p : ℤ) ≤ |E| := by + rw [hk, abs_mul, abs_of_pos hp0] + have : 1 ≤ |k| := Int.one_le_abs h.ne' + nlinarith + linarith + +/-- `|(m₂ - m₁)(x - z) + (m₃ - m₂)(y - z)| ≤ 10 K` for colours `≤ 5` and coordinates `≤ K`. -/ +theorem lift_bound {K : ℕ} {m₁ m₂ m₃ x y z : ℕ} (h1 : m₁ < 6) (h2 : m₂ < 6) (h3 : m₃ < 6) + (hx : x ≤ K) (hy : y ≤ K) (hz : z ≤ K) : + |((m₂ : ℤ) - m₁) * ((x : ℤ) - z) + ((m₃ : ℤ) - m₂) * ((y : ℤ) - z)| ≤ 10 * K := by + have a1 : |((m₂ : ℤ) - m₁)| ≤ 5 := by rw [abs_le]; constructor <;> omega + have a2 : |((m₃ : ℤ) - m₂)| ≤ 5 := by rw [abs_le]; constructor <;> omega + have b1 : |((x : ℤ) - z)| ≤ K := by rw [abs_le]; constructor <;> omega + have b2 : |((y : ℤ) - z)| ≤ K := by rw [abs_le]; constructor <;> omega + calc _ ≤ |((m₂ : ℤ) - m₁) * ((x : ℤ) - z)| + |((m₃ : ℤ) - m₂) * ((y : ℤ) - z)| := abs_add_le _ _ + _ = |((m₂ : ℤ) - m₁)| * |((x : ℤ) - z)| + |((m₃ : ℤ) - m₂)| * |((y : ℤ) - z)| := by + rw [abs_mul, abs_mul] + _ ≤ 5 * K + 5 * K := by + gcongr + _ = 10 * K := by ring + +/-- **L17.2 + L17.3.** The embedded sphere is an S-cap for the colours `0, …, 5` when `10 K < p`. -/ +theorem isSCap_seed {K N r : ℕ} (hK : 10 * K < p) (hp5 : 5 < p) : + IsSCap (Set.range (colσ (p := p) hp5)) (seed p K N r : Set (Fin N → ZMod p)) := by + intro a ha b hb c hc hab hac hbc s₁ h1 s₂ h2 s₃ h3 h12 hrel + simp only [seed, Finset.coe_image, Set.mem_image, Finset.mem_coe] at ha hb hc + obtain ⟨x, hx, rfl⟩ := ha + obtain ⟨y, hy, rfl⟩ := hb + obtain ⟨z, hz, rfl⟩ := hc + obtain ⟨i₁, rfl⟩ := h1 + obtain ⟨i₂, rfl⟩ := h2 + obtain ⟨i₃, rfl⟩ := h3 + simp only [sphere, Finset.mem_filter, Finset.mem_univ, true_and] at hx hy hz + set m₁ := (i₁ : ℕ) + set m₂ := (i₂ : ℕ) + set m₃ := (i₃ : ℕ) + have hm12 : (m₁ : ℤ) ≠ m₂ := by + intro h + apply h12 + have h' : m₁ = m₂ := by exact_mod_cast h + change ((m₁ : ℕ) : ZMod p) = ((m₂ : ℕ) : ZMod p) + rw [h'] + set X : Fin N → ℤ := fun i => ((x i : ℕ) : ℤ) + set Y : Fin N → ℤ := fun i => ((y i : ℕ) : ℤ) + set Z : Fin N → ℤ := fun i => ((z i : ℕ) : ℤ) + have hcoord : ∀ i, ((m₂ : ℤ) - m₁) * (X i - Z i) + ((m₃ : ℤ) - m₂) * (Y i - Z i) = 0 := by + intro i + apply int_eq_zero_of_cast (p := p) + · have := congrFun hrel i + simp only [colσ, Function.Embedding.coeFn_mk, emb, Pi.add_apply, Pi.smul_apply, smul_eq_mul, + Pi.zero_apply] at this + push_cast [X, Y, Z] + linear_combination this + · have := lift_bound (K := K) (m₁ := m₁) (m₂ := m₂) (m₃ := m₃) i₁.isLt i₂.isLt i₃.isLt + (Nat.lt_succ_iff.mp (x i).isLt) (Nat.lt_succ_iff.mp (y i).isLt) (Nat.lt_succ_iff.mp (z + i).isLt) + have hK' : (10 * K : ℤ) < p := by exact_mod_cast hK + exact lt_of_le_of_lt this hK' + have hXr : ∑ i, X i ^ 2 = r := by simp only [X]; exact_mod_cast hx + have hYr : ∑ i, Y i ^ 2 = r := by simp only [Y]; exact_mod_cast hy + have hZr : ∑ i, Z i ^ 2 = r := by simp only [Z]; exact_mod_cast hz + have hinj : ∀ u v : Fin N → Fin (K + 1), (fun i => ((u i : ℕ) : ℤ)) = (fun i => ((v i : ℕ) : ℤ)) + → u = v := by + intro u v h; funext i + have := congrFun h i + simp only [Nat.cast_inj] at this + exact Fin.ext this + refine sphere_rel X Y Z (sub_ne_zero.mpr (Ne.symm hm12)) (fun h => hac ?_) (fun h => + hab ?_) hcoord + (hXr.trans hZr.symm) (hYr.trans hZr.symm) + · rw [hinj x z h] + · rw [hinj x y h] + +/-- **Pigeonhole.** Some sphere is large. -/ +theorem exists_large_sphere (K N : ℕ) {R : ℕ} (hR : K ^ 2 ≤ R) : + ∃ r, (K + 1) ^ N ≤ (N * R + 1) * (sphere K N r).card := by + classical + have hmaps : ∀ x ∈ (univ : Finset (Fin N → Fin (K + 1))), (∑ i, ((x i : ℕ)) ^ 2) ∈ range (N * R + + 1) := by + intro x _ + rw [Finset.mem_range, Nat.lt_succ_iff] + calc ∑ i, ((x i : ℕ)) ^ 2 ≤ ∑ _i : Fin N, R := Finset.sum_le_sum fun i _ => + le_trans (Nat.pow_le_pow_left (Nat.lt_succ_iff.mp (x i).isLt) 2) hR + _ = N * R := by simp + have hcard : (univ : Finset (Fin N → Fin (K + 1))).card = + ∑ r ∈ range (N * R + 1), (sphere K N r).card := by + rw [Finset.card_eq_sum_card_fiberwise hmaps] + rfl + obtain ⟨r, -, h⟩ := Finset.exists_le_of_sum_le (s := range (N * R + 1)) (by simp) + (f := fun _ => (K + 1) ^ N) (g := fun r => (N * R + 1) * (sphere K N r).card) (by + rw [← Finset.mul_sum, ← hcard, Finset.sum_const, Finset.card_range, smul_eq_mul, + Finset.card_univ, + Fintype.card_pi, Finset.prod_const, Finset.card_univ, Fintype.card_fin, Fintype.card_fin]) + exact ⟨r, h⟩ + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/WeightCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/WeightCap.lean new file mode 100644 index 0000000000..fa0193b498 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/WeightCap.lean @@ -0,0 +1,181 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Layered +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.SplitIfs +import Mathlib.Tactic.Tauto + +/-! +# Weight caps in `F₅^k` (ledger L16.5) + +`wcap k s = {c ∈ {0,1,2}^k : #{i : c i = 1} = s}` is a cap in `F₅^k`, of size `C(k,s) · 2^(k-s)`, +and for every +`k` some `s ≤ k` gives size at least `3^k / (k+1)`. +-/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-- The ternary digits `{0, 1, 2} ⊆ F₅`. -/ +def tern : Finset F5 := {0, 1, 2} + +/-- Number of coordinates equal to `1`. -/ +def ones {k : ℕ} (c : Fin k → F5) : ℕ := (univ.filter fun i => c i = 1).card + +/-- The weight cap. -/ +def wcap (k s : ℕ) : Finset (Fin k → F5) := (Fintype.piFinset fun _ => tern).filter fun c => + ones c = s + +theorem coord2 : ∀ x y : F5, x ∈ tern → y ∈ tern → x + 2 * (y - x) ∈ tern → + (if y = 1 then 1 else 0 : ℕ) = (if x = 1 then 1 else 0) + (if x ≠ y then 1 else 0) := by + decide + +theorem coord3 : ∀ x y : F5, x ∈ tern → y ∈ tern → x + 3 * (y - x) ∈ tern → + (if x + 3 * (y - x) = 1 then 1 else 0 : ℕ) = (if x = 1 then 1 else 0) + (if x ≠ y then 1 else + 0) := by + decide + +theorem coord4 : ∀ x y : F5, x ∈ tern → y ∈ tern → x + 4 * (y - x) ∈ tern → + (if x = 1 then 1 else 0 : ℕ) = (if y = 1 then 1 else 0) + (if x ≠ y then 1 else 0) := by + decide + +theorem t_cases : ∀ t : F5, t ≠ 0 → t ≠ 1 → t = 2 ∨ t = 3 ∨ t = 4 := by decide + +theorem ones_eq_sum {k : ℕ} (c : Fin k → F5) : ones c = ∑ i, (if c i = 1 then 1 else 0 : ℕ) := by + rw [ones, Finset.card_filter] + +/-- **L16.5.** Weight caps are caps. -/ +theorem isCap_wcap (k s : ℕ) : IsCap F5 (wcap k s : Set (Fin k → F5)) := by + intro P hP R hR hne t ht0 ht1 hS + simp only [wcap, Finset.coe_filter, Fintype.mem_piFinset, Set.mem_ofPred_eq] at hP hR hS + obtain ⟨hPt, hPw⟩ := hP + obtain ⟨hRt, hRw⟩ := hR + obtain ⟨hSt, hSw⟩ := hS + have hD : 0 < ∑ i, (if P i ≠ R i then 1 else 0 : ℕ) := by + obtain ⟨i, hi⟩ : ∃ i, P i ≠ R i := by + by_contra h; push Not at h; exact hne (funext h) + exact Finset.sum_pos' (fun _ _ => by positivity) ⟨i, Finset.mem_univ _, by simp [hi]⟩ + have hc : ∀ i, (P + t • (R - P)) i = P i + t * (R i - P i) := fun i => by simp + rcases t_cases t ht0 ht1 with rfl | rfl | rfl + · have : ones R = ones P + ∑ i, (if P i ≠ R i then 1 else 0 : ℕ) := by + rw [ones_eq_sum, ones_eq_sum, ← Finset.sum_add_distrib] + exact Finset.sum_congr rfl fun i _ => coord2 _ _ (hPt i) (hRt i) (hc i ▸ hSt i) + omega + · have : ones (P + (3 : F5) • (R - P)) = ones P + ∑ i, (if P i ≠ R i then 1 else 0 : ℕ) := by + rw [ones_eq_sum, ones_eq_sum, ← Finset.sum_add_distrib] + refine Finset.sum_congr rfl fun i _ => ?_ + rw [hc i] + exact coord3 _ _ (hPt i) (hRt i) (hc i ▸ hSt i) + omega + · have : ones P = ones R + ∑ i, (if P i ≠ R i then 1 else 0 : ℕ) := by + rw [ones_eq_sum, ones_eq_sum, ← Finset.sum_add_distrib] + exact Finset.sum_congr rfl fun i _ => coord4 _ _ (hPt i) (hRt i) (hc i ▸ hSt i) + omega + +/-- The weight cap as a disjoint union over the set of `1`-coordinates. -/ +theorem wcap_eq_biUnion (k s : ℕ) : + wcap k s = (powersetCard s (univ : Finset (Fin k))).biUnion fun S => + Fintype.piFinset fun i => if i ∈ S then ({1} : Finset F5) else {0, 2} := by + ext c + simp only [wcap, Finset.mem_filter, Fintype.mem_piFinset, Finset.mem_biUnion, + Finset.mem_powersetCard, + Finset.subset_univ, true_and] + constructor + · rintro ⟨ht, hw⟩ + refine ⟨univ.filter fun i => c i = 1, hw, fun i => ?_⟩ + by_cases h : c i = 1 + · simp [h] + · have := ht i + simp only [tern, Finset.mem_insert, Finset.mem_singleton] at this + simp only [Finset.mem_filter, Finset.mem_univ, true_and, h, ite_false, Finset.mem_insert, + Finset.mem_singleton] + tauto + · rintro ⟨S, hS, hc⟩ + have hones : (univ.filter fun i => c i = 1) = S := by + ext i + have := hc i + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · intro h1 + by_contra hi + rw [ite_eq_right hi] at this + simp only [Finset.mem_insert, Finset.mem_singleton] at this + rcases this with h | h <;> rw [h] at h1 <;> revert h1 <;> decide + · intro hi + rw [ite_eq_left hi] at this + simpa using this + refine ⟨fun i => ?_, by rw [ones, hones, hS]⟩ + have := hc i + split_ifs at this + · simp only [Finset.mem_singleton] at this; simp [tern, this] + · simp only [Finset.mem_insert, Finset.mem_singleton] at this + rcases this with h | h <;> simp [tern, h] + +theorem card_wcap (k s : ℕ) : (wcap k s).card = k.choose s * 2 ^ (k - s) := by + rw [wcap_eq_biUnion, Finset.card_biUnion] + · have : ∀ S ∈ powersetCard s (univ : Finset (Fin k)), + (Fintype.piFinset fun i => if i ∈ S then ({1} : Finset F5) else {0, 2}).card = 2 ^ (k - s) + := by + intro S hS + rw [Fintype.card_piFinset] + have hSc := (Finset.mem_powersetCard.mp hS).2 + calc ∏ i, (if i ∈ S then ({1} : Finset F5) else {0, 2}).card + = ∏ i, (if i ∈ S then 1 else 2) := by + refine Finset.prod_congr rfl fun i _ => ?_ + split_ifs <;> decide + _ = 2 ^ (k - s) := by + rw [Finset.prod_ite, Finset.prod_const_one, one_mul, Finset.prod_const] + congr 1 + rw [Finset.filter_not, Finset.card_sdiff_of_subset (Finset.filter_subset _ _)] + simp [hSc] + rw [Finset.sum_congr rfl this, Finset.sum_const, Finset.card_powersetCard, Finset.card_univ, + Fintype.card_fin, smul_eq_mul] + · intro S hS S' hS' hne + rw [Function.onFun, Finset.disjoint_left] + intro c hc hc' + simp only [Fintype.mem_piFinset] at hc hc' + apply hne + ext i + have h1 := hc i + have h2 := hc' i + constructor + · intro hi + rw [ite_eq_left hi] at h1 + by_contra hi' + rw [ite_eq_right hi'] at h2 + simp only [Finset.mem_singleton] at h1 + simp only [Finset.mem_insert, Finset.mem_singleton, h1] at h2 + revert h2; decide + · intro hi + rw [ite_eq_left hi] at h2 + by_contra hi' + rw [ite_eq_right hi'] at h1 + simp only [Finset.mem_singleton] at h2 + simp only [Finset.mem_insert, Finset.mem_singleton, h2] at h1 + revert h1; decide + +theorem sum_card_wcap (k : ℕ) : ∑ s ∈ range (k + 1), k.choose s * 2 ^ (k - s) = 3 ^ k := by + have := (add_pow (1 : ℕ) 2 k) + rw [show (1 : ℕ) + 2 = 3 by norm_num] at this + rw [this] + refine Finset.sum_congr rfl fun s _ => ?_ + rw [one_pow, one_mul, mul_comm, Nat.cast_id] + +/-- Some weight gives at least the average `3^k / (k+1)`. -/ +theorem exists_large_wcap (k : ℕ) : ∃ s ≤ k, 3 ^ k ≤ (k + 1) * (wcap k s).card := by + obtain ⟨s, hs, h⟩ := Finset.exists_le_of_sum_le (s := range (k + 1)) (by simp) + (f := fun _ => 3 ^ k) (g := fun s => (k + 1) * (k.choose s * 2 ^ (k - s))) (by + rw [← Finset.mul_sum, sum_card_wcap, Finset.sum_const, Finset.card_range, smul_eq_mul]) + exact ⟨s, Nat.lt_succ_iff.mp (Finset.mem_range.mp hs), by rw [card_wcap]; exact h⟩ + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GraphBase/Clique/CliqueSets.lean b/LeanPool/SplitCliqueGap/GraphBase/Clique/CliqueSets.lean new file mode 100644 index 0000000000..1d40d14530 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GraphBase/Clique/CliqueSets.lean @@ -0,0 +1,75 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GraphBase.Clique.Partition + +/-! +# Fractional clique partitions, summed over `cliqueSets` + +A fractional clique partition vanishes outside `G.cliqueSets`, so its edge constraints and its +total weight may be +computed over `G.cliqueSets` instead of over all vertex sets. This file gives that form of the API. +-/ + +@[expose] public section + +open Finset + +namespace SimpleGraph + +variable {V : Type*} [Fintype V] [DecidableEq V] {G : SimpleGraph V} + +theorem IsFracCliquePartition.eq_zero_of_notMem {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) + {Q : Finset V} (hQ : Q ∉ G.cliqueSets) : x Q = 0 := by + by_contra h + exact hQ (mem_cliqueSets.mpr (hx.support Q h)) + +/-- Sums of `x` over a filter of all vertex sets may be taken over `cliqueSets`. -/ +theorem IsFracCliquePartition.sum_filter_cliqueSets {x : Finset V → ℝ} (hx : + G.IsFracCliquePartition x) + (p : Finset V → Prop) [DecidablePred p] : + ∑ Q ∈ G.cliqueSets with p Q, x Q = ∑ Q ∈ univ.filter p, x Q := by + rw [sum_filter, sum_filter] + exact sum_subset (subset_univ _) fun Q _ hQ => by simp [hx.eq_zero_of_notMem hQ] + +theorem IsFracCliquePartition.edge_cliqueSets {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) + {u v : V} (huv : G.Adj u v) : ∑ Q ∈ G.cliqueSets with (u ∈ Q ∧ v ∈ Q), x Q = 1 := by + rw [hx.sum_filter_cliqueSets] + exact hx.edge u v huv + +/-- Constructing a fractional clique partition from edge constraints over `cliqueSets`. -/ +theorem IsFracCliquePartition.of_cliqueSets {x : Finset V → ℝ} (h0 : ∀ Q, 0 ≤ x Q) + (hs : ∀ Q, x Q ≠ 0 → 2 ≤ Q.card ∧ G.IsClique (Q : Set V)) + (he : ∀ u v, G.Adj u v → ∑ Q ∈ G.cliqueSets with (u ∈ Q ∧ v ∈ Q), x Q = 1) : + G.IsFracCliquePartition x := by + have hzero : ∀ Q, Q ∉ G.cliqueSets → x Q = 0 := fun Q hQ => by + by_contra h + exact hQ (mem_cliqueSets.mpr (hs Q h)) + refine ⟨h0, hs, fun u v huv => ?_⟩ + rw [← he u v huv, sum_filter, sum_filter] + exact (sum_subset (subset_univ _) fun Q _ hQ => by simp [hzero Q hQ]).symm + +theorem fracCliquePartitionNumber_le_sum_cliqueSets {x : Finset V → ℝ} (hx : + G.IsFracCliquePartition x) : + G.fracCliquePartitionNumber ≤ ∑ Q ∈ G.cliqueSets, x Q := by + rw [hx.sum_cliqueSets] + exact fracCliquePartitionNumber_le hx + +theorem fracCliquePartitionNumber_eq_of_cliqueSets {r : ℝ} + (hlow : ∀ x, G.IsFracCliquePartition x → r ≤ ∑ Q ∈ G.cliqueSets, x Q) + {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) (hxr : ∑ Q ∈ G.cliqueSets, x Q = r) : + G.fracCliquePartitionNumber = r := + fracCliquePartitionNumber_eq_of (fun y hy => (hlow y hy).trans_eq hy.sum_cliqueSets) + hx (hx.sum_cliqueSets ▸ hxr) + +theorem le_fracCliquePartitionNumber_of_cliqueSets {r : ℝ} + (h : ∀ x, G.IsFracCliquePartition x → r ≤ ∑ Q ∈ G.cliqueSets, x Q) : r + ≤ G.fracCliquePartitionNumber := + le_fracCliquePartitionNumber fun x hx => (h x hx).trans_eq hx.sum_cliqueSets + +end SimpleGraph diff --git a/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean b/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean new file mode 100644 index 0000000000..ef360651df --- /dev/null +++ b/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean @@ -0,0 +1,277 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Combinatorics.SimpleGraph.Clique +public import Mathlib.Combinatorics.SimpleGraph.Finite +public import Mathlib.Algebra.BigOperators.Group.Finset.Basic +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.Order.Archimedean.Real.Basic +public import Mathlib.Order.ConditionallyCompleteLattice.Basic +public import Mathlib.Data.Fintype.Powerset +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.SplitIfs + +/-! +# Clique partitions and fractional clique partitions + +For a finite simple graph `G`: + +* `G.IsCliquePartition P`: `P` is a family of cliques of order at least two such that every edge of +`G` lies in + exactly one member of `P`; +* `G.cliquePartitionNumber`: the least size of a clique partition (`cp(G)`); +* `G.cliqueSets`: the finite set of cliques of order at least two; +* `G.IsFracCliquePartition x`: a nonnegative weighting of the vertex sets, supported on cliques of +order at least + two, giving every edge total weight exactly one; +* `G.fracCliquePartitionNumber`: the infimum of the total weight of a fractional clique partition +(`cp*(G)`). + +## Provenance + +The definitions `IsCliquePartition` and `IsFracCliquePartition` are those of `IsCliquePartition` and +`IsFracPartition` in `PaperVIChallenge.lean` of PALOMAR-2026-11-01-000006 (repository +`jtraverso/erdos81-optimal-clique-partitions` @ `719e39b`), where `cp_{≤ r}` and the fractional +value are also +defined. The infimum `fracCliquePartitionNumber` and the API below are new here; the proofs follow +`GapExtremal/Defs.lean` and `GapExtremal/SplitUpper.lean` of the gap-extremal project, except +`exists_isCliquePartition_card_eq_edgeFinset`, whose proof is that of +`exists_isCliqueEdgePartition_card_eq` in +Formal Conjectures (`FormalConjecturesForMathlib/Combinatorics/SimpleGraph/Chordal.lean` @ +`7bdc4a4`, Apache-2.0). +-/ + +@[expose] public section + +open Finset + +namespace SimpleGraph + +variable {V : Type*} + +/-- A clique partition of `G`: cliques of order at least two such that every edge of `G` lies in +exactly one of +them. -/ +structure IsCliquePartition (G : SimpleGraph V) (P : Finset (Finset V)) : Prop where + two_le : ∀ B ∈ P, 2 ≤ B.card + isClique : ∀ B ∈ P, G.IsClique (B : Set V) + existsUnique : ∀ u v, G.Adj u v → ∃! B, B ∈ P ∧ u ∈ B ∧ v ∈ B + +/-- The clique partition number `cp(G)`: the least size of a clique partition. -/ +noncomputable def cliquePartitionNumber (G : SimpleGraph V) : ℕ := + sInf {k | ∃ P, G.IsCliquePartition P ∧ P.card = k} + +variable [Fintype V] + +open Classical in +/-- The cliques of `G` of order at least two, as a `Finset`. -/ +noncomputable def cliqueSets (G : SimpleGraph V) : Finset (Finset V) := + univ.filter fun Q => 2 ≤ Q.card ∧ G.IsClique (Q : Set V) + +/-- A fractional clique partition: nonnegative weights on vertex sets, supported on cliques of + order at least +two, with total weight exactly one on every edge. -/ +structure IsFracCliquePartition [DecidableEq V] (G : SimpleGraph V) (x : Finset V → ℝ) : Prop where + nonneg : ∀ Q, 0 ≤ x Q + support : ∀ Q, x Q ≠ 0 → 2 ≤ Q.card ∧ G.IsClique (Q : Set V) + edge : ∀ u v, G.Adj u v → ∑ Q ∈ univ.filter (fun Q : Finset V => u ∈ Q ∧ v ∈ Q), x Q = 1 + +/-- The fractional clique partition number `cp*(G)`. -/ +noncomputable def fracCliquePartitionNumber [DecidableEq V] (G : SimpleGraph V) : ℝ := + sInf {r | ∃ x, G.IsFracCliquePartition x ∧ ∑ Q, x Q = r} + +variable {G : SimpleGraph V} + +theorem mem_cliqueSets {Q : Finset V} : Q ∈ G.cliqueSets ↔ 2 ≤ Q.card ∧ G.IsClique (Q : Set V) := by + classical + simp [cliqueSets] + +section Integral + +variable [DecidableEq V] + +omit [Fintype V] [DecidableEq V] in +/-- The edges, as pairs, form a clique partition. -/ +theorem exists_isCliquePartition [Finite V] (G : SimpleGraph V) : ∃ P, G.IsCliquePartition P := by + classical + let _ := Fintype.ofFinite V + refine ⟨(univ.filter (fun p : V × V => G.Adj p.1 p.2)).image (fun p => {p.1, p.2}), ?_, ?_, ?_⟩ + · intro Q hQ + simp only [mem_image, mem_filter, mem_univ, true_and] at hQ + obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ + rw [card_pair hab.ne] + · intro Q hQ + simp only [mem_image, mem_filter, mem_univ, true_and] at hQ + obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ + intro u hu v hv huv + simp only [coe_insert, coe_singleton, Set.mem_insert_iff, Set.mem_singleton_iff] at hu hv + rcases hu with rfl | rfl <;> rcases hv with rfl | rfl + · exact absurd rfl huv + · exact hab + · exact hab.symm + · exact absurd rfl huv + · intro u v huv + refine ⟨{u, v}, ⟨?_, by simp, by simp⟩, ?_⟩ + · simp only [mem_image, mem_filter, mem_univ, true_and] + exact ⟨(u, v), huv, rfl⟩ + · rintro Q ⟨hQ, huQ, hvQ⟩ + simp only [mem_image, mem_filter, mem_univ, true_and] at hQ + obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ + simp only [mem_insert, mem_singleton] at huQ hvQ + have hne := huv.ne + rcases huQ with rfl | rfl <;> rcases hvQ with rfl | rfl + · exact absurd rfl hne + · rfl + · exact pair_comm _ _ + · exact absurd rfl hne + +omit [Fintype V] [DecidableEq V] in +theorem cliquePartitionNumber_le {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : + G.cliquePartitionNumber ≤ P.card := + Nat.sInf_le ⟨P, hP, rfl⟩ + +omit [Fintype V] [DecidableEq V] in +theorem exists_isCliquePartition_card_eq [Finite V] (G : SimpleGraph V) : + ∃ P, G.IsCliquePartition P ∧ P.card = G.cliquePartitionNumber := by + obtain ⟨P, hP⟩ := exists_isCliquePartition G + exact Nat.sInf_mem (s := {k | ∃ P, G.IsCliquePartition P ∧ P.card = k}) ⟨P.card, P, hP, rfl⟩ + +omit [Fintype V] [DecidableEq V] in +theorem le_cliquePartitionNumber [Finite V] {k : ℕ} (h : ∀ P, G.IsCliquePartition P → k ≤ P.card) : + k ≤ G.cliquePartitionNumber := by + obtain ⟨P, hP, hc⟩ := exists_isCliquePartition_card_eq G + exact hc ▸ h P hP + +omit [Fintype V] [DecidableEq V] in +theorem cliquePartitionNumber_eq_of [Finite V] {k : ℕ} (hlow : ∀ P, G.IsCliquePartition P → k + ≤ P.card) + (hup : ∃ P, G.IsCliquePartition P ∧ P.card ≤ k) : G.cliquePartitionNumber = k := by + obtain ⟨P, hP, hPk⟩ := hup + exact le_antisymm ((cliquePartitionNumber_le hP).trans hPk) (le_cliquePartitionNumber hlow) + +omit [Fintype V] [DecidableEq V] in +theorem exists_isCliquePartition_card_le [Finite V] (G : SimpleGraph V) : + ∃ P, G.IsCliquePartition P ∧ P.card ≤ G.cliquePartitionNumber := by + obtain ⟨P, hP, hc⟩ := exists_isCliquePartition_card_eq G + exact ⟨P, hP, hc.le⟩ + +omit [Fintype V] [DecidableEq V] in +theorem cliquePartitionNumber_le_iff [Finite V] (G : SimpleGraph V) {m : ℕ} : + G.cliquePartitionNumber ≤ m ↔ ∃ P, G.IsCliquePartition P ∧ P.card ≤ m := by + constructor + · intro h + obtain ⟨P, hP, hc⟩ := exists_isCliquePartition_card_eq G + exact ⟨P, hP, hc.le.trans h⟩ + · rintro ⟨P, hP, hc⟩ + exact (cliquePartitionNumber_le hP).trans hc + +omit [DecidableEq V] in +/-- The edges, as two-element sets, form a clique partition with `|E(G)|` members. -/ +theorem exists_isCliquePartition_card_eq_edgeFinset (G : SimpleGraph V) [DecidableRel G.Adj] : + ∃ P, G.IsCliquePartition P ∧ P.card = G.edgeFinset.card := by + classical + refine ⟨G.edgeFinset.image Sym2.toFinset, ⟨?_, ?_, ?_⟩, ?_⟩ + · simp only [Finset.mem_image, mem_edgeFinset] + rintro s ⟨e, he, rfl⟩ + induction e using Sym2.ind with + | h a b => + rw [mem_edgeSet] at he + rw [Sym2.toFinset_mk_eq, Finset.card_pair he.ne] + · simp only [Finset.mem_image, mem_edgeFinset] + rintro s ⟨e, he, rfl⟩ + induction e using Sym2.ind with + | h a b => + rw [mem_edgeSet] at he + rw [Sym2.toFinset_mk_eq, Finset.coe_pair] + exact isClique_pair.mpr (fun _ => he) + · intro u v huv + refine ⟨s(u, v).toFinset, + ⟨Finset.mem_image.mpr ⟨s(u, v), by simpa using huv, rfl⟩, by simp, by simp⟩, ?_⟩ + rintro s ⟨hs, hu, hv⟩ + obtain ⟨e, -, rfl⟩ := Finset.mem_image.mp hs + rw [Sym2.mem_toFinset] at hu hv + rw [(Sym2.mem_and_mem_iff huv.ne).mp ⟨hu, hv⟩] + · apply Finset.card_image_of_injOn + intro e he e' _ h + simp only [mem_edgeFinset, Finset.mem_coe] at he + induction e using Sym2.ind with + | h a b => + have hab := (mem_edgeSet G).mp he + have ha : a ∈ e'.toFinset := by rw [← h]; simp + have hb : b ∈ e'.toFinset := by rw [← h]; simp + rw [Sym2.mem_toFinset] at ha hb + exact ((Sym2.mem_and_mem_iff hab.ne).mp ⟨ha, hb⟩).symm + +omit [DecidableEq V] in +/-- The members of a clique partition are cliques of order at least two. -/ +theorem IsCliquePartition.subset_cliqueSets {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : + P ⊆ G.cliqueSets := fun Q hQ => mem_cliqueSets.mpr ⟨hP.two_le Q hQ, hP.isClique Q hQ⟩ + +end Integral + +section Fractional + +variable [DecidableEq V] + +theorem fracCliquePartitionNumber_le {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) : + G.fracCliquePartitionNumber ≤ ∑ Q, x Q := + csInf_le ⟨0, by rintro _ ⟨y, hy, rfl⟩; exact sum_nonneg fun Q _ => hy.nonneg Q⟩ ⟨x, hx, rfl⟩ + +/-- The total weight of a fractional clique partition is carried by `cliqueSets`. -/ +theorem IsFracCliquePartition.sum_cliqueSets {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) : + ∑ Q ∈ G.cliqueSets, x Q = ∑ Q, x Q := by + refine sum_subset (subset_univ _) fun Q _ hQ => ?_ + by_contra h + exact hQ (mem_cliqueSets.mpr (hx.support Q h)) + +/-- The indicator of a clique partition is a fractional clique partition. -/ +theorem IsCliquePartition.isFracCliquePartition {P : Finset (Finset V)} + (hP : G.IsCliquePartition P) : + G.IsFracCliquePartition (fun Q => if Q ∈ P then 1 else 0) := by + refine ⟨fun Q => by split_ifs <;> norm_num, fun Q hQ => ?_, fun u v huv => ?_⟩ + · have : Q ∈ P := by by_contra h; simp [h] at hQ + exact ⟨hP.two_le Q this, hP.isClique Q this⟩ + · obtain ⟨B, ⟨hB, huB, hvB⟩, huniq⟩ := hP.existsUnique u v huv + rw [sum_eq_single_of_mem B (by simp [huB, hvB]) fun Q hQ hne => ?_] + · simp [hB] + · simp only [mem_filter, mem_univ, true_and] at hQ + rw [ite_eq_right_iff] + intro hQP + exact absurd (huniq Q ⟨hQP, hQ.1, hQ.2⟩) hne + +/-- `cp*(G) ≤ cp(G)`. -/ +theorem fracCliquePartitionNumber_le_cliquePartitionNumber (G : SimpleGraph V) : + G.fracCliquePartitionNumber ≤ G.cliquePartitionNumber := by + obtain ⟨P, hP, hc⟩ := exists_isCliquePartition_card_eq G + refine (fracCliquePartitionNumber_le hP.isFracCliquePartition).trans_eq ?_ + rw [← hc, ← sum_filter] + simp + +theorem nonempty_fracCliquePartition (G : SimpleGraph V) : + ∃ x, G.IsFracCliquePartition x := by + obtain ⟨P, hP⟩ := exists_isCliquePartition G + exact ⟨_, hP.isFracCliquePartition⟩ + +theorem le_fracCliquePartitionNumber {r : ℝ} + (h : ∀ x, G.IsFracCliquePartition x → r ≤ ∑ Q, x Q) : r ≤ G.fracCliquePartitionNumber := by + obtain ⟨x, hx⟩ := nonempty_fracCliquePartition G + exact le_csInf ⟨_, x, hx, rfl⟩ (by rintro _ ⟨y, hy, rfl⟩; exact h y hy) + +theorem fracCliquePartitionNumber_nonneg (G : SimpleGraph V) : + 0 ≤ G.fracCliquePartitionNumber := + le_fracCliquePartitionNumber fun _ hx => sum_nonneg fun Q _ => hx.nonneg Q + +theorem fracCliquePartitionNumber_eq_of {r : ℝ} + (hlow : ∀ x, G.IsFracCliquePartition x → r ≤ ∑ Q, x Q) + {x : Finset V → ℝ} (hx : G.IsFracCliquePartition x) (hxr : ∑ Q, x Q = r) : + G.fracCliquePartitionNumber = r := + IsLeast.csInf_eq ⟨⟨x, hx, hxr⟩, by rintro _ ⟨y, hy, rfl⟩; exact hlow y hy⟩ + +end Fractional + +end SimpleGraph diff --git a/LeanPool/SplitCliqueGap/Imports.lean b/LeanPool/SplitCliqueGap/Imports.lean new file mode 100644 index 0000000000..20a42b3eb8 --- /dev/null +++ b/LeanPool/SplitCliqueGap/Imports.lean @@ -0,0 +1,77 @@ +/- +Copyright (c) 2026 Lean Pool contributors. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Lean Pool contributors +-/ +module -- shake: keep-all --deprecated_module: ignore + +-- Generated project imports; run `lake exe mk_all`. +public import LeanPool.SplitCliqueGap +public import LeanPool.SplitCliqueGap.GapExtremal.Bridge +public import LeanPool.SplitCliqueGap.GapExtremal.Cap +public import LeanPool.SplitCliqueGap.GapExtremal.Completion +public import LeanPool.SplitCliqueGap.GapExtremal.Core +public import LeanPool.SplitCliqueGap.GapExtremal.Defs +public import LeanPool.SplitCliqueGap.GapExtremal.ExactOrder +public import LeanPool.SplitCliqueGap.GapExtremal.Exponent +public import LeanPool.SplitCliqueGap.GapExtremal.ExponentTwo +public import LeanPool.SplitCliqueGap.GapExtremal.Geometry +public import LeanPool.SplitCliqueGap.GapExtremal.Global +public import LeanPool.SplitCliqueGap.GapExtremal.Global2 +public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas +public import LeanPool.SplitCliqueGap.GapExtremal.Hosts +public import LeanPool.SplitCliqueGap.GapExtremal.Layered +public import LeanPool.SplitCliqueGap.GapExtremal.LayeredExponent +public import LeanPool.SplitCliqueGap.GapExtremal.LocalEmbed +public import LeanPool.SplitCliqueGap.GapExtremal.LocalH12 +public import LeanPool.SplitCliqueGap.GapExtremal.Main +public import LeanPool.SplitCliqueGap.GapExtremal.PCore +public import LeanPool.SplitCliqueGap.GapExtremal.PHosts +public import LeanPool.SplitCliqueGap.GapExtremal.PMain +public import LeanPool.SplitCliqueGap.GapExtremal.PSource +public import LeanPool.SplitCliqueGap.GapExtremal.Residual +public import LeanPool.SplitCliqueGap.GapExtremal.SCap +public import LeanPool.SplitCliqueGap.GapExtremal.Single +public import LeanPool.SplitCliqueGap.GapExtremal.Source +public import LeanPool.SplitCliqueGap.GapExtremal.Sphere +public import LeanPool.SplitCliqueGap.GapExtremal.WeightCap +public import LeanPool.SplitCliqueGap.GraphBase.Clique.CliqueSets +public import LeanPool.SplitCliqueGap.GraphBase.Clique.Partition +public import LeanPool.SplitCliqueGap.R417.LogErrorAbsorption +public import LeanPool.SplitCliqueGap.R417.OptimalCoefficient +public import LeanPool.SplitCliqueGap.R434.AffineH54 +public import LeanPool.SplitCliqueGap.R434.CoreDefect +public import LeanPool.SplitCliqueGap.R434.CoreDirections +public import LeanPool.SplitCliqueGap.R434.CoreFractional +public import LeanPool.SplitCliqueGap.R434.DensityThreshold +public import LeanPool.SplitCliqueGap.R434.EHPSClasses +public import LeanPool.SplitCliqueGap.R434.EHPSCompactExterior +public import LeanPool.SplitCliqueGap.R434.EHPSDensity +public import LeanPool.SplitCliqueGap.R434.EHPSGrid +public import LeanPool.SplitCliqueGap.R434.EHPSHostTransfer +public import LeanPool.SplitCliqueGap.R434.EHPSPotential +public import LeanPool.SplitCliqueGap.R434.EHPSProduct +public import LeanPool.SplitCliqueGap.R434.EHPSRegion +public import LeanPool.SplitCliqueGap.R434.ExactGraphTransfer +public import LeanPool.SplitCliqueGap.R434.FiniteR434 +public import LeanPool.SplitCliqueGap.R434.GroupedGap +public import LeanPool.SplitCliqueGap.R434.GroupedHosts +public import LeanPool.SplitCliqueGap.R434.LocalH54 +public import LeanPool.SplitCliqueGap.R434.LocalPacking +public import LeanPool.SplitCliqueGap.R434.LocalTriangleLift +public import LeanPool.SplitCliqueGap.R434.MidpointHosts +public import LeanPool.SplitCliqueGap.R434.OddMidpoints +public import LeanPool.SplitCliqueGap.R434.PackingTriangles +public import LeanPool.SplitCliqueGap.R434.PartitionEnergy +public import LeanPool.SplitCliqueGap.R434.PolylogGap +public import LeanPool.SplitCliqueGap.R434.PolylogOrder +public import LeanPool.SplitCliqueGap.R434.ResidualArithmetic +public import LeanPool.SplitCliqueGap.R434.ResidualIsolates +public import LeanPool.SplitCliqueGap.R434.RobustHosts +public import LeanPool.SplitCliqueGap.R434.RoleMatchings +public import LeanPool.SplitCliqueGap.R434.TightPieces +public import LeanPool.SplitCliqueGap.R434.TightTriangles +public import LeanPool.SplitCliqueGap.R434.TripartiteSlack +public import LeanPool.SplitCliqueGap.R434.UniformOrder +public import LeanPool.SplitCliqueGap.R434.UniversalHosts +public import LeanPool.SplitCliqueGap.R434.UniversalR434 diff --git a/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean b/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean new file mode 100644 index 0000000000..2db9127071 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean @@ -0,0 +1,97 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R417.OptimalCoefficient +public import Mathlib.Analysis.Real.Sqrt +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! C3: an explicit, uniform threshold absorbs t log t and t errors into eta t². -/ + +@[expose] public section + +namespace GapExtremal.R417 + +/-- The coefficient bounding the logarithmic remainder after parameter selection. -/ +noncomputable def remainderCoefficient (c a b C A₀ : ℝ) : ℝ := + (a / c) * A₀ + 2 * a * C + 12 * a + C + C * A₀ + 12 * b + Real.log 48 + +theorem scalar_loss_envelope (c a b C A₀ t E : ℝ) (hb : 0 ≤ b) + (hC : 0 ≤ C) (hA₀ : 0 ≤ A₀) (ht : 1 ≤ t) + (hE : E ≤ (c / a) * t ^ 2 + (a / c * t + C) * + (2 * a * t + Real.log t + A₀) + 12 * a * t + 12 * b + Real.log 48) : + E ≤ (c / a + 2 * a ^ 2 / c) * t ^ 2 + + (a / c) * t * Real.log t + remainderCoefficient c a b C A₀ * t := by + have hlog : Real.log t ≤ t := by + have hh := Real.log_le_sub_one_of_pos (show (0 : ℝ) < t by linarith) + linarith + let R := C * A₀ + 12 * b + Real.log 48 + have hR : 0 ≤ R := by + dsimp [R] + exact add_nonneg (add_nonneg (mul_nonneg hC hA₀) (by positivity)) + (Real.log_nonneg (by norm_num)) + have hnon : 0 ≤ C * (t - Real.log t) + R * (t - 1) := + add_nonneg (mul_nonneg hC (sub_nonneg.mpr hlog)) + (mul_nonneg hR (by linarith)) + have hid : ((c / a + 2 * a ^ 2 / c) * t ^ 2 + + (a / c) * t * Real.log t + remainderCoefficient c a b C A₀ * t) - + ((c / a) * t ^ 2 + (a / c * t + C) * + (2 * a * t + Real.log t + A₀) + 12 * a * t + 12 * b + Real.log 48) = + C * (t - Real.log t) + R * (t - 1) := by + dsimp [remainderCoefficient, R] + ring + linarith + +theorem log_le_two_sqrt {t : ℝ} (ht : 1 ≤ t) : Real.log t ≤ 2 * Real.sqrt t := by + have ht0 : 0 ≤ t := by linarith + have hs : 0 < Real.sqrt t := Real.sqrt_pos.mpr (by linarith) + have hh := Real.log_le_sub_one_of_pos hs + calc + Real.log t = Real.log (Real.sqrt t ^ 2) := congrArg Real.log (Real.sq_sqrt ht0).symm + _ = 2 * Real.log (Real.sqrt t) := by rw [Real.log_pow]; norm_num + _ ≤ 2 * Real.sqrt t := by linarith + +theorem log_error_absorption (A B η : ℝ) (hA : 0 ≤ A) (_hB : 0 ≤ B) (hη : 0 < η) : + ∃ T : ℝ, 1 ≤ T ∧ ∀ t : ℝ, T ≤ t → + A * t * Real.log t + B * t ≤ η * t ^ 2 := by + let T := max 1 (max ((4 * A / η) ^ 2) (2 * B / η)) + refine ⟨T, le_max_left _ _, fun t ht => ?_⟩ + have ht1 : 1 ≤ t := (le_max_left _ _).trans ht + have ht0 : 0 ≤ t := by linarith + have hAt : (4 * A / η) ^ 2 ≤ t := + (le_max_left _ _).trans ((le_max_right _ _).trans ht) + have hBt : 2 * B / η ≤ t := + (le_max_right _ _).trans ((le_max_right _ _).trans ht) + have hroot : 4 * A / η ≤ Real.sqrt t := Real.le_sqrt_of_sq_le hAt + have hroot' : 4 * A ≤ Real.sqrt t * η := (div_le_iff₀ hη).mp hroot + have hB' : 2 * B ≤ t * η := (div_le_iff₀ hη).mp hBt + have hprod := mul_le_mul_of_nonneg_right hroot' (Real.sqrt_nonneg t) + have hprod' : 4 * A * Real.sqrt t ≤ η * t := by + calc + 4 * A * Real.sqrt t ≤ (Real.sqrt t * η) * Real.sqrt t := hprod + _ = η * t := by + rw [show (Real.sqrt t * η) * Real.sqrt t = η * Real.sqrt t ^ 2 by ring, + Real.sq_sqrt ht0] + have hlog := mul_le_mul_of_nonneg_left (log_le_two_sqrt ht1) hA + have hcoef : A * Real.log t + B ≤ η * t := by nlinarith + calc + A * t * Real.log t + B * t = t * (A * Real.log t + B) := by ring + _ ≤ t * (η * t) := mul_le_mul_of_nonneg_left hcoef ht0 + _ = η * t ^ 2 := by ring + +theorem coefficient_absorption (C A B η : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) (hη : 0 < η) : + ∃ T : ℝ, 1 ≤ T ∧ ∀ (t E : ℝ), T ≤ t → + E ≤ C * t ^ 2 + A * t * Real.log t + B * t → E ≤ (C + η) * t ^ 2 := by + obtain ⟨T, hT, hbound⟩ := log_error_absorption A B η hA hB hη + refine ⟨T, hT, fun t E ht hE => ?_⟩ + have hh := hbound t ht + nlinarith + +end GapExtremal.R417 diff --git a/LeanPool/SplitCliqueGap/R417/OptimalCoefficient.lean b/LeanPool/SplitCliqueGap/R417/OptimalCoefficient.lean new file mode 100644 index 0000000000..64b63afbd8 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R417/OptimalCoefficient.lean @@ -0,0 +1,79 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Analysis.SpecialFunctions.Pow.Real +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Ring +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity + +/-! C3: exact minimisation of the leading loss coefficient, with no numerics. -/ + +@[expose] public section + +namespace GapExtremal.R417 + +/-- The scale minimizing the competing real error terms for coefficient `c`. -/ +noncomputable def optimalScale (c : ℝ) : ℝ := (c ^ 2 / 4) ^ ((1 : ℝ) / 3) + +/-- The minimized coefficient of the error term at the optimal scale. -/ +noncomputable def criticalCoefficient (c : ℝ) : ℝ := + (3 / 2 : ℝ) * (4 : ℝ) ^ ((1 : ℝ) / 3) * c ^ ((1 : ℝ) / 3) + +theorem optimalScale_pos {c : ℝ} (hc : 0 < c) : 0 < optimalScale c := by + exact Real.rpow_pos_of_pos (by positivity) _ + +theorem optimalScale_cube {c : ℝ} (hc : 0 < c) : + optimalScale c ^ 3 = c ^ 2 / 4 := by + rw [optimalScale, ← Real.rpow_natCast, ← Real.rpow_mul (by positivity)] + norm_num + +theorem optimized_energy_eq {c : ℝ} (hc : 0 < c) : + c / optimalScale c + 2 * optimalScale c ^ 2 / c = criticalCoefficient c := by + let a := optimalScale c + have ha : 0 < a := optimalScale_pos hc + have ha3 : a ^ 3 = c ^ 2 / 4 := optimalScale_cube hc + have heq : c / a + 2 * a ^ 2 / c = 6 * a ^ 2 / c := by + field_simp [ha.ne', hc.ne'] + nlinarith + have hcube : (6 * a ^ 2 / c) ^ 3 = (27 / 2 : ℝ) * c := by + have hh := congrArg (fun x : ℝ => x ^ 2) ha3 + field_simp [hc.ne'] + nlinarith + have h4 : ((4 : ℝ) ^ ((1 : ℝ) / 3)) ^ 3 = 4 := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 4)] + norm_num + have hc3 : (c ^ ((1 : ℝ) / 3)) ^ 3 = c := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hc.le] + norm_num + have hcc : criticalCoefficient c ^ 3 = (27 / 2 : ℝ) * c := by + dsimp [criticalCoefficient] + rw [mul_pow, mul_pow, h4, hc3] + ring + have hpos : 0 < criticalCoefficient c := by dsimp [criticalCoefficient]; positivity + rw [show c / optimalScale c + 2 * optimalScale c ^ 2 / c = 6 * a ^ 2 / c from heq] + exact (pow_left_inj₀ (by positivity) hpos.le (by norm_num : (3 : ℕ) ≠ 0)).mp + (hcube.trans hcc.symm) + +theorem leading_energy_minimum {c x : ℝ} (hc : 0 < c) (hx : 0 < x) : + criticalCoefficient c ≤ c / x + 2 * x ^ 2 / c := by + let a := optimalScale c + have ha : 0 < a := optimalScale_pos hc + have ha3 : c ^ 2 = 4 * a ^ 3 := by have hh := optimalScale_cube hc; dsimp [a]; nlinarith + have hid : c / x + 2 * x ^ 2 / c - (c / a + 2 * a ^ 2 / c) = + 2 * (x - a) ^ 2 * (x + 2 * a) / (c * x) := by + field_simp [hc.ne', hx.ne', ha.ne'] + have hh := congrArg (fun y : ℝ => y * (a - x)) ha3 + nlinarith + have hnon : 0 ≤ 2 * (x - a) ^ 2 * (x + 2 * a) / (c * x) := by positivity + have heq := optimized_energy_eq hc + change c / a + 2 * a ^ 2 / c = criticalCoefficient c at heq + linarith + +end GapExtremal.R417 diff --git a/LeanPool/SplitCliqueGap/R434/AffineH54.lean b/LeanPool/SplitCliqueGap/R434/AffineH54.lean new file mode 100644 index 0000000000..ea7a76f366 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/AffineH54.lean @@ -0,0 +1,191 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.MidpointHosts +public import LeanPool.SplitCliqueGap.R434.LocalH54 +public import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Ring + +/-! The affine realization of H54 and recovery of the owner of a core edge. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434.H54 + +/-- A vertex role in one of the three parts of the 15-vertex template. -/ +abbrev Role := Fin 3 × Fin 5 + +/-- The lower part of an edge of the given kind. -/ +def lowerPart (k : Fin 3) : Fin 3 := if k = 1 then 1 else 0 +/-- The upper part of an edge of the given kind. -/ +def upperPart (k : Fin 3) : Fin 3 := if k = 0 then 1 else 2 + +/-- The edge kind for the ordered pair of parts `i < j`. -/ +def edgeKind (i j : Fin 3) : Fin 3 := + if i = 0 then (if j = 1 then 0 else 2) else 1 + +/-- Adjacency in the finite role template, oriented from lower to higher part. -/ +def orderedAdj (a b : Role) : Prop := + a.1 < b.1 ∧ (edgeKind a.1 b.1, a.2, b.2) ∈ edges + +instance (a b : Role) : Decidable (orderedAdj a b) := + inferInstanceAs (Decidable (_ ∧ _)) + +/-- The undirected graph on the three sets of five roles. -/ +def roleGraph : SimpleGraph Role where + Adj a b := orderedAdj a b ∨ orderedAdj b a + symm := ⟨fun _ _ h => h.symm⟩ + loopless := ⟨fun a h => h.elim (fun h' => (lt_irrefl a.1) h'.1) + (fun h' => (lt_irrefl a.1) h'.1)⟩ + +instance : DecidableRel roleGraph.Adj := fun a b => + inferInstanceAs (Decidable (orderedAdj a b ∨ orderedAdj b a)) + +theorem roleGraph_ordered {a b : Role} (h : a.1 < b.1) : + roleGraph.Adj a b ↔ (edgeKind a.1 b.1, a.2, b.2) ∈ edges := by + change orderedAdj a b ∨ orderedAdj b a ↔ _ + simp [orderedAdj, h, not_lt_of_ge h.le] + +section + +variable {R : Type} [CommRing R] (h : R) + +/-- The signed inverse step between parts, with `h` for the outer pair. -/ +def directedStep (i j : Fin 3) : R := + if i < j then (if i = 0 ∧ j = 2 then h else 1) + else if j < i then -(if j = 0 ∧ i = 2 then h else 1) + else 0 + +theorem directedStep_swap (i j : Fin 3) : directedStep h j i = -directedStep h i j := by + rcases lt_trichotomy i j with hlt | rfl | hgt + · simp [directedStep, hlt, not_lt_of_ge hlt.le] + · simp [directedStep] + · simp [directedStep, hgt, not_lt_of_ge hgt.le] + +/-- The directed step for a pair of roles, determined by their parts. -/ +def roleStep (a b : Role) : R := directedStep h a.1 b.1 + +theorem roleStep_swap (a b : Role) : roleStep h b a = -roleStep h a b := + directedStep_swap h a.1 b.1 + +/-- The vertex at role `r` in the affine block of slope `a` and intercept `x`. -/ +def affineVertex (a x : R) (r : Role) : Role × R := (r, x + (r.1.val : R) * a) + +theorem directedStep_inverse (hh : 2 * h = 1) {i j : Fin 3} (hij : i < j) : + directedStep h i j * ((j.val : R) - (i.val : R)) = 1 := by + fin_cases i <;> fin_cases j <;> simp_all [directedStep, mul_comm h (2 : R)] ; ring + +theorem edge_direction (hh : 2 * h = 1) {r s : Role} (hrs : r.1 < s.1) (a x : R) : + pairDirection (roleStep h) (affineVertex a x r) (affineVertex a x s) = a := by + change directedStep h r.1 s.1 * ((x + (s.1.val : R) * a) - (x + (r.1.val : R) * a)) = a + calc + _ = (directedStep h r.1 s.1 * ((s.1.val : R) - (r.1.val : R))) * a := by ring + _ = a := by rw [directedStep_inverse h hh hrs, one_mul] + +theorem position_eq_of_direction (hh : 2 * h = 1) {r s : Role} (hrs : r.1 < s.1) + (p q : R) : + let a := pairDirection (roleStep h) (r,p) (s,q) + affineVertex a (p - (r.1.val : R) * a) s = (s,q) := by + dsimp only + refine Prod.ext (show (affineVertex _ _ s).1 = s from rfl) ?_ + change p - (r.1.val : R) * (directedStep h r.1 s.1 * (q - p)) + + (s.1.val : R) * (directedStep h r.1 s.1 * (q - p)) = q + calc + _ = p + (directedStep h r.1 s.1 * ((s.1.val : R) - (r.1.val : R))) * (q - p) := by ring + _ = q := by rw [directedStep_inverse h hh hrs, one_mul]; ring + +/-- The edge of an affine block corresponding to a template edge. -/ +def blockEdge (a x : R) (e : Edge) : Sym2 (Role × R) := + s(affineVertex a x (lowerPart e.1, e.2.1), affineVertex a x (upperPart e.1, e.2.2)) + +theorem part_lt (k : Fin 3) : lowerPart k < upperPart k := by decide +revert +kernel + +theorem parts_of_order {i j : Fin 3} (hij : i < j) : + lowerPart (edgeKind i j) = i ∧ upperPart (edgeKind i j) = j := by + revert i j + decide +kernel + +theorem kind_of_parts (k : Fin 3) : edgeKind (lowerPart k) (upperPart k) = k := by + decide +revert +kernel + +theorem blockEdge_injective (hh : 2 * h = 1) : + Function.Injective (fun t : R × R × Edge => blockEdge t.1 t.2.1 t.2.2) := by + intro ⟨a,x,k,u,v⟩ ⟨b,y,l,p,q⟩ he + change blockEdge a x (k,u,v) = blockEdge b y (l,p,q) at he + rcases Sym2.eq_iff.mp he with hdir | hswap + · have h₁ : (lowerPart k, u) = (lowerPart l, p) := congrArg Prod.fst hdir.1 + have h₂ : (upperPart k, v) = (upperPart l, q) := congrArg Prod.fst hdir.2 + have hlo : lowerPart k = lowerPart l := congrArg Prod.fst h₁ + have hup : upperPart k = upperPart l := congrArg Prod.fst h₂ + have hk : k = l := by + calc + k = edgeKind (lowerPart k) (upperPart k) := (kind_of_parts k).symm + _ = edgeKind (lowerPart l) (upperPart l) := congrArg₂ edgeKind hlo hup + _ = l := kind_of_parts l + have hu : u = p := congrArg Prod.snd h₁ + have hv : v = q := congrArg Prod.snd h₂ + subst l + subst p + subst q + have ha : a = b := calc + a = pairDirection (roleStep h) + (affineVertex a x (lowerPart k, u)) (affineVertex a x (upperPart k, v)) := + (edge_direction h hh (part_lt k) a x).symm + _ = _ := congrArg₂ (pairDirection (roleStep h)) hdir.1 hdir.2 + _ = b := edge_direction h hh (part_lt k) b y + subst b + have hx : x = y := add_right_cancel (congrArg Prod.snd hdir.1) + subst y + rfl + · have h₁ : lowerPart k = upperPart l := congrArg (fun z => z.1.1) hswap.1 + have h₂ : upperPart k = lowerPart l := congrArg (fun z => z.1.1) hswap.2 + have hlt := part_lt k + rw [h₁, h₂] at hlt + exact ((not_lt_of_ge (part_lt l).le) hlt).elim + +variable [Fintype R] [DecidableEq R] + +omit [DecidableEq R] [Fintype R] in +theorem blockEdge_adj (hh : 2 * h = 1) {A : Finset R} {a x : R} {e : Edge} + (ha : a ∈ A) (he : e ∈ edges) : + (directionCore roleGraph (roleStep h) A (roleStep_swap h)).Adj + (affineVertex a x (lowerPart e.1, e.2.1)) (affineVertex a x (upperPart e.1, e.2.2)) := by + refine ⟨(roleGraph_ordered (part_lt e.1)).mpr ?_, ?_⟩ + · change (edgeKind (lowerPart e.1) (upperPart e.1), e.2.1, e.2.2) ∈ edges + simpa only [kind_of_parts] using he + · simpa only [edge_direction h hh (r := (lowerPart e.1, e.2.1)) + (s := (upperPart e.1, e.2.2)) (part_lt e.1)] using ha + +omit [DecidableEq R] [Fintype R] in +theorem blockEdge_of_adj (hh : 2 * h = 1) {A : Finset R} {u v : Role × R} + (huv : (directionCore roleGraph (roleStep h) A (roleStep_swap h)).Adj u v) : + ∃ a ∈ A, ∃ x, ∃ e ∈ edges, blockEdge a x e = s(u,v) := by + have ordered (r s : Role) (p q : R) (hrs : r.1 < s.1) + (hr : roleGraph.Adj r s) (ha : pairDirection (roleStep h) (r,p) (s,q) ∈ A) : + ∃ a ∈ A, ∃ x, ∃ e ∈ edges, blockEdge a x e = s((r,p),(s,q)) := by + let a := pairDirection (roleStep h) (r,p) (s,q) + let x := p - (r.1.val : R) * a + refine ⟨a, ha, x, (edgeKind r.1 s.1, r.2, s.2), (roleGraph_ordered hrs).mp hr, ?_⟩ + unfold blockEdge + rw [(parts_of_order hrs).1, (parts_of_order hrs).2] + have h₁ : affineVertex a x r = (r,p) := Prod.ext rfl (sub_add_cancel _ _) + have h₂ : affineVertex a x s = (s,q) := position_eq_of_direction h hh hrs p q + rw [h₁, h₂] + change roleGraph.Adj u.1 v.1 ∧ pairDirection (roleStep h) u v ∈ A at huv + rcases huv.1 with hlt | hgt + · exact ordered u.1 v.1 u.2 v.2 hlt.1 (.inl hlt) huv.2 + · obtain ⟨a, ha, x, e, he, heq⟩ := + ordered v.1 u.1 v.2 u.2 hgt.1 (.inl hgt) + ((pairDirection_swap (roleStep h) (roleStep_swap h) u v).symm ▸ huv.2) + exact ⟨a, ha, x, e, he, heq.trans Sym2.eq_swap⟩ + +end + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/CoreDefect.lean b/LeanPool/SplitCliqueGap/R434/CoreDefect.lean new file mode 100644 index 0000000000..1f99a6299a --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/CoreDefect.lean @@ -0,0 +1,311 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.LocalPacking +public import LeanPool.SplitCliqueGap.R434.PackingTriangles +public import LeanPool.SplitCliqueGap.R434.PartitionEnergy +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +/-! The signed energy forces an integer score defect on the physical core. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.H54 + +variable {R : Type} [Fintype R] [DecidableEq R] [CommRing R] + +/-- Recovers the slope, intercept, and template index of an edge in an affine block. -/ +noncomputable def decodeEdge (e : Sym2 (Role × R)) : R × R × Edge := + Function.invFun (fun z : R × R × Edge => blockEdge z.1 z.2.1 z.2.2) e + +omit [DecidableEq R] [Fintype R] in +theorem decode_blockEdge (h : R) (hh : 2 * h = 1) (a x : R) (e : Edge) : + decodeEdge (blockEdge a x e) = (a,x,e) := + Function.leftInverse_invFun (blockEdge_injective h hh) (a,x,e) + +theorem blockEdge_mem_core (h : R) (hh : 2 * h = 1) (A : Finset R) (a x : R) (e : Edge) : + blockEdge a x e ∈ (coreGraph h A).edgeFinset ↔ a ∈ A ∧ e ∈ edges := by + rw [core_edges_image h hh, mem_image] + constructor + · rintro ⟨⟨b,y,d⟩, hbd, hbe⟩ + have he : ((b,y,d) : R × R × Edge) = (a,x,e) := blockEdge_injective h hh hbe + simpa only [he, mem_product, mem_univ, true_and] using hbd + · intro he + exact ⟨(a,x,e), by simpa using he, rfl⟩ + +omit [DecidableEq R] [Fintype R] in +theorem decode_ordered (h : R) (hh : 2 * h = 1) {u v : Role × R} (huv : u.1.1 < v.1.1) : + let a := pairDirection (roleStep h) u v + decodeEdge s(u,v) = (a, u.2 - (u.1.1.val : R) * a, edgeKind u.1.1 v.1.1, u.1.2, v.1.2) := by + let a := pairDirection (roleStep h) u v + let x := u.2 - (u.1.1.val : R) * a + have he : blockEdge a x (edgeKind u.1.1 v.1.1,u.1.2,v.1.2) = s(u,v) := by + unfold blockEdge + rw [(parts_of_order huv).1, (parts_of_order huv).2] + have hu : affineVertex a x u.1 = u := Prod.ext rfl (sub_add_cancel _ _) + have hv : affineVertex a x v.1 = v := position_eq_of_direction h hh huv u.2 v.2 + rw [show (u.1.1,u.1.2) = u.1 from rfl, show (v.1.1,v.1.2) = v.1 from rfl, hu,hv] + dsimp only + rw [← he, decode_blockEdge h hh] + +/-- The signed price assigned using the block slope and edge kind. -/ +noncomputable def edgePrice (R₀ : ℝ) (f : R → ℝ) (e : Sym2 (Role × R)) : ℝ := + signedPrice R₀ f (decodeEdge e).1 (decodeEdge e).2.2.1 + +theorem core_edgePrice_sum (h : R) (hh : 2 * h = 1) (A : Finset R) (R₀ : ℝ) (f : R → ℝ) : + ∑ e ∈ (coreGraph h A).edgeFinset, edgePrice R₀ f e = 0 := by + classical + rw [core_edges_image h hh, sum_image (fun _ _ _ _ he => blockEdge_injective h hh he)] + simp only [edgePrice, decode_blockEdge h hh, Finset.sum_product, signedPrice_block, + sum_const_zero] + +omit [Fintype R] in +theorem core_edgePrice_triangle (h : R) (hh : 2 * h = 1) (R₀ : ℝ) (f : R → ℝ) + (u v z : Role × R) (hu : u.1.1 = 0) (hv : v.1.1 = 1) (hz : z.1.1 = 2) : + ∑ e ∈ triangleEdges (u,v,z), edgePrice R₀ f e = + f (pairDirection (roleStep h) u v) + f (pairDirection (roleStep h) v z) - + 2 * f (pairDirection (roleStep h) u z) := by + classical + have huv : u.1.1 < v.1.1 := by rw [hu,hv]; decide + have hvz : v.1.1 < z.1.1 := by rw [hv,hz]; decide + have he₁ : s(u,v) ≠ s(v,z) := by + intro he + rcases Sym2.eq_iff.mp he with hp | hp + · exact (ne_of_lt huv) (congrArg (fun x : Role × R => x.1.1) hp.1) + · exact (ne_of_lt (huv.trans hvz)) (congrArg (fun x : Role × R => x.1.1) hp.1) + have he₂ : s(u,v) ≠ s(u,z) := by + intro he + rcases Sym2.eq_iff.mp he with hp | hp + · exact (ne_of_lt hvz) (congrArg (fun x : Role × R => x.1.1) hp.2) + · exact (ne_of_lt (huv.trans hvz)) (congrArg (fun x : Role × R => x.1.1) hp.1) + have he₃ : s(v,z) ≠ s(u,z) := by + intro he + rcases Sym2.eq_iff.mp he with hp | hp + · exact (ne_of_gt huv) (congrArg (fun x : Role × R => x.1.1) hp.1) + · exact (ne_of_lt hvz) (congrArg (fun x : Role × R => x.1.1) hp.1) + unfold triangleEdges + change ∑ e ∈ ({s(u,v),s(v,z),s(u,z)} : Finset (Sym2 (Role × R))), edgePrice R₀ f e = _ + rw [sum_insert (by simp [he₁,he₂]), sum_insert (by simp [he₃]), sum_singleton, ← add_assoc] + simp only [edgePrice, decode_ordered h hh huv, decode_ordered h hh hvz, + decode_ordered h hh (huv.trans hvz), hu,hv,hz, edgeKind] + norm_num + exact signedPrice_triangle _ _ _ _ _ + +/-- The triangles in the packing whose vertices lie outside any single affine block. -/ +noncomputable def mixedTriangles (h : R) (T : Finset (OrderedTriangle (Role × R))) : + Finset (OrderedTriangle (Role × R)) := + T.filter fun t => pairDirection (roleStep h) t.1 t.2.1 ≠ pairDirection (roleStep h) t.2.1 t.2.2 + +theorem owner_covered (h : R) (hh : 2 * h = 1) (A : Finset R) + (T : Finset (OrderedTriangle (Role × R))) (X : Finset (Sym2 (Role × R))) + (hc : ∀ t ∈ T, t.1.1.1 = 0 ∧ t.2.1.1.1 = 1 ∧ t.2.2.1.1 = 2) + (hpack : (T : Set (OrderedTriangle (Role × R))).PairwiseDisjoint triangleEdges) + (hpart : X ∪ T.biUnion triangleEdges = (coreGraph h A).edgeFinset) : + A ×ˢ (univ : Finset R) ⊆ + (X ∪ (mixedTriangles h T).biUnion triangleEdges).image + (fun e => ((decodeEdge e).1, (decodeEdge e).2.1)) := by + classical + rintro ⟨a,x⟩ hax + have ha := (mem_product.mp hax).1 + by_contra hn + let g (t : Triangle) : ℤ := if blockTriangle a x t ∈ T then 1 else 0 + apply no_integral_cover g (by intro t _; unfold g; split <;> decide) + intro e he + have hB := (blockEdge_mem_core h hh A a x e).mpr ⟨ha,he⟩ + have hnot : blockEdge a x e ∉ X ∪ (mixedTriangles h T).biUnion triangleEdges := by + intro hmem + exact hn (mem_image.mpr ⟨_,hmem,by rw [decode_blockEdge h hh]⟩) + have ht' : blockEdge a x e ∈ T.biUnion triangleEdges := by + rcases mem_union.mp (hpart.symm ▸ hB) with hx | ht + · exact (hnot (mem_union_left _ hx)).elim + · exact ht + obtain ⟨t,ht,het⟩ := mem_biUnion.mp ht' + have hm : t ∉ mixedTriangles h T := fun hx => hnot (mem_union_right _ + (mem_biUnion.mpr ⟨t,hx,het⟩)) + have hloc : pairDirection (roleStep h) t.1 t.2.1 = pairDirection (roleStep h) t.2.1 t.2.2 := by + by_contra hf + exact hm (mem_filter.mpr ⟨ht,hf⟩) + obtain ⟨b,y,k,hk⟩ := is_blockTriangle_of_local h (hc t ht) hloc + rw [← hk] at het ht + obtain ⟨rfl,rfl,he_on⟩ := (blockEdge_mem_blockTriangle h hh).mp het + have hkin (i : Fin 3) : onTriangleIndex k i ∈ edges := by + have h₁ : blockEdge a x (onTriangleIndex k i) ∈ triangleEdges (blockTriangle a x k) := by + rw [triangleEdges_block] + exact mem_image.mpr ⟨i,mem_univ _,rfl⟩ + have h₂ : blockEdge a x (onTriangleIndex k i) ∈ (coreGraph h A).edgeFinset := + hpart ▸ mem_union_right _ (mem_biUnion.mpr ⟨_,ht,h₁⟩) + exact ((blockEdge_mem_core h hh A _ _ _).mp h₂).2 + have hktri : k ∈ triangles := by + exact mem_filter.mpr ⟨mem_univ _, hkin 0, hkin 1, hkin 2⟩ + have hfilt : + ((triangles.filter (onEdge · e)).filter (fun j => blockTriangle a x j ∈ T)) = {k} := by + ext j + simp only [mem_filter, mem_singleton] + constructor + · rintro ⟨⟨_,hon⟩,hj⟩ + have h₁ : blockEdge a x e ∈ triangleEdges (blockTriangle a x j) := + (blockEdge_mem_blockTriangle h hh).mpr ⟨rfl,rfl,hon⟩ + have heq : blockTriangle a x j = blockTriangle a x k := by + by_contra hne + exact disjoint_left.mp (hpack hj ht hne) h₁ het + have h : ((a,x,j) : R × R × Triangle) = (a,x,k) := + blockTriangle_injective h hh heq + exact congrArg (fun z : R × R × Triangle => z.2.2) h + · rintro rfl + exact ⟨⟨hktri,he_on⟩,ht⟩ + unfold load g + rw [sum_eq_single k] + · simp [ht] + · intro j hj hne + have hn : blockTriangle a x j ∉ T := by + intro hjT + have hmem : j ∈ (triangles.filter (onEdge · e)).filter + (fun j => blockTriangle a x j ∈ T) := by + have hhj := mem_filter.mp hj + exact mem_filter.mpr ⟨mem_filter.mpr hhj, hjT⟩ + rw [hfilt, mem_singleton] at hmem + exact hne hmem + simp [hn] + · intro hn + exact (hn (mem_filter.mpr ⟨hktri, he_on⟩)).elim + +theorem six_edges_per_block (h : R) (hh : 2 * h = 1) (A : Finset R) + (T : Finset (OrderedTriangle (Role × R))) (X : Finset (Sym2 (Role × R))) + (hc : ∀ t ∈ T, t.1.1.1 = 0 ∧ t.2.1.1.1 = 1 ∧ t.2.2.1.1 = 2) + (hpack : (T : Set (OrderedTriangle (Role × R))).PairwiseDisjoint triangleEdges) + (hpart : X ∪ T.biUnion triangleEdges = (coreGraph h A).edgeFinset) : + 6 * (A.card * Fintype.card R) ≤ X.card + 3 * (mixedTriangles h T).card := by + classical + let owners := A ×ˢ (univ : Finset R) + let L (o : R × R) := triangles.filter fun k => blockTriangle o.1 o.2 k ∈ T + let family (o : R × R) := (L o).image (blockTriangle o.1 o.2) + have hcap (o) : (family o).card ≤ 16 := by + apply card_image_le.trans + apply local_packing_le_sixteen _ (filter_subset _ _) + intro i u hu v hv eq + change onTriangleIndex u i = onTriangleIndex v i at eq + have eu : blockEdge o.1 o.2 (onTriangleIndex u i) ∈ triangleEdges (blockTriangle o.1 o.2 u) := + by + rw [triangleEdges_block]; exact mem_image.mpr ⟨i,mem_univ _,rfl⟩ + have ev : blockEdge o.1 o.2 (onTriangleIndex u i) ∈ triangleEdges (blockTriangle o.1 o.2 v) := + by + rw [eq,triangleEdges_block]; exact mem_image.mpr ⟨i,mem_univ _,rfl⟩ + by_contra ne + have hne : blockTriangle o.1 o.2 u ≠ blockTriangle o.1 o.2 v := + fun he => ne (congrArg (fun z : R × R × Triangle => z.2.2) + (show ((o.1,o.2,u) : R × R × Triangle) = (o.1,o.2,v) from blockTriangle_injective h hh he)) + exact disjoint_left.mp (hpack (mem_filter.mp hu).2 (mem_filter.mp hv).2 hne) eu ev + let Z := mixedTriangles h T + have hloc : T \ Z ⊆ owners.biUnion family := by + intro t ht + obtain ⟨ht,hn⟩ := mem_sdiff.mp ht + have heq : pairDirection (roleStep h) t.1 t.2.1 = pairDirection (roleStep h) t.2.1 t.2.2 := + by by_contra he; exact hn (mem_filter.mpr ⟨ht,he⟩) + obtain ⟨a,x,k,rfl⟩ := is_blockTriangle_of_local h (hc t ht) heq + have hparts (i : Fin 3) : a ∈ A ∧ onTriangleIndex k i ∈ edges := by + apply (blockEdge_mem_core h hh A a x _).mp + rw [← hpart] + apply mem_union_right + apply mem_biUnion.mpr + refine ⟨_,ht,?_⟩ + rw [triangleEdges_block]; exact mem_image.mpr ⟨i,mem_univ _,rfl⟩ + have hk : k ∈ triangles := mem_filter.mpr + ⟨mem_univ _, (hparts 0).2, (hparts 1).2, (hparts 2).2⟩ + exact mem_biUnion.mpr ⟨(a,x), mem_product.mpr ⟨(hparts 0).1,mem_univ _⟩, + mem_image.mpr ⟨k,mem_filter.mpr ⟨hk,ht⟩,rfl⟩⟩ + have hlocal := (card_le_card hloc).trans + (card_biUnion_le_card_mul owners family 16 (fun o _ => hcap o)) + have hz : Z ⊆ T := filter_subset _ _ + rw [card_sdiff_of_subset hz] at hlocal + have hzc := card_le_card hz + have htot := (card_union_le X (T.biUnion triangleEdges)).trans + (Nat.add_le_add_left (card_biUnion_le_card_mul T triangleEdges 3 + (fun t _ => triangleEdges_card_le t)) X.card) + rw [hpart,core_edge_count h hh A] at htot + simp only [owners,card_product,card_univ] at hlocal + change 6 * (A.card * Fintype.card R) ≤ X.card + 3 * Z.card + omega + +theorem core_integer_defect_six (h : R) (hh : 2 * h = 1) (A : Finset R) (R₀ δ : ℝ) + (hR : 0 ≤ R₀) (hδ : 0 < δ) (f : R → ℝ) (hf : ∀ a ∈ A, 0 ≤ f a ∧ f a ≤ R₀) + (hmid : ∀ a b c, a ∈ A → b ∈ A → c ∈ A → a ≠ b → a + b = 2 * c → + δ ≤ f a + f b - 2 * f c) + {P : Finset (Finset (Role × R))} (hP : IsPack P) : + 6 * ((A.card * Fintype.card R : ℕ) : ℝ) / (27 * (1 + 2 * R₀ / δ)) ≤ + 36 * ((A.card * Fintype.card R : ℕ) : ℝ) - ∑ Q ∈ P, (w (coreGraph h A) Q : ℝ) := by + classical + let B := coreGraph h A + obtain ⟨T,X,hc,hpack,hpart,hdisj,hslack⟩ := + packing_to_triangles B (fun u : Role × R => u.1.1) (fun _ _ he => core_is_tripartite h A he) hP + let Z := mixedTriangles h T + have hBcard : (B.edgeFinset.card : ℝ) = 54 * ((A.card * Fintype.card R : ℕ) : ℝ) := by + exact_mod_cast core_edge_count h hh A + rw [hBcard] at hslack + have hb : ∀ t ∈ T, triangleEdges t ⊆ B.edgeFinset := + fun t ht e he => hpart ▸ mem_union_right _ (mem_biUnion.mpr ⟨t,ht,he⟩) + have hdir_in (u v : Role × R) (hs : s(u,v) ∈ B.edgeFinset) : pairDirection (roleStep h) u v ∈ A := + (show B.Adj u v from SimpleGraph.mem_edgeFinset.mp hs).2 + have hgap := edge_partition_gap_of_count B.edgeFinset X T Z triangleEdges + (6 * (A.card * Fintype.card R)) (edgePrice R₀ f) R₀ δ + (36 * ((A.card * Fintype.card R : ℕ) : ℝ) - ∑ Q ∈ P, (w B Q : ℝ)) + hR hδ hpart hdisj hpack (filter_subset _ _) + (six_edges_per_block h hh A T X hc hpack hpart) (core_edgePrice_sum h hh A R₀ f) + have hprice (e : Sym2 (Role × R)) (he : e ∈ X) : -(2 * R₀ / 3) ≤ edgePrice R₀ f e := by + have heB : e ∈ B.edgeFinset := hpart ▸ mem_union_left _ he + rw [core_edges_image h hh A] at heB + obtain ⟨⟨a,x,k⟩,hm,rfl⟩ := mem_image.mp heB + have hfa := hf a (mem_product.mp hm).1 + simpa only [edgePrice, decode_blockEdge h hh] using signedPrice_lower R₀ f hfa.1 hfa.2 k.1 + have hzero (t : OrderedTriangle (Role × R)) (ht : t ∈ T) (hn : t ∉ Z) : + ∑ e ∈ triangleEdges t, edgePrice R₀ f e = 0 := by + obtain ⟨u,v,z⟩ := t + obtain ⟨hu,hv,hz⟩ := hc _ ht + have hloc : pairDirection (roleStep h) u v = pairDirection (roleStep h) v z := by + by_contra he + exact hn (mem_filter.mpr ⟨ht,he⟩) + have hpr := triangle_directions_of_parts h hh hu hv hz + rw [← hloc, ← two_mul] at hpr + have hlast : pairDirection (roleStep h) u v = pairDirection (roleStep h) u z := by + have he := congrArg (fun a : R => h * a) hpr + simpa only [← mul_assoc, mul_comm h (2 : R), hh, one_mul] using he + rw [core_edgePrice_triangle h hh R₀ f u v z hu hv hz, ← hloc, ← hlast] + ring + have hmix (t : OrderedTriangle (Role × R)) (ht : t ∈ Z) : + δ ≤ ∑ e ∈ triangleEdges t, edgePrice R₀ f e := by + obtain ⟨u,v,z⟩ := t + obtain ⟨htT, hne⟩ := mem_filter.mp ht + obtain ⟨hu,hv,hz⟩ := hc _ htT + rw [core_edgePrice_triangle h hh R₀ f u v z hu hv hz] + apply hmid + · exact hdir_in u v (hb _ htT (by simp [triangleEdges])) + · exact hdir_in v z (hb _ htT (by simp [triangleEdges])) + · exact hdir_in u z (hb _ htT (by simp [triangleEdges])) + · exact hne + · exact triangle_directions_of_parts h hh hu hv hz + simpa only [Nat.cast_mul, Nat.cast_ofNat] using hgap hprice hzero hmix (by linarith only [hslack]) + +theorem core_integer_defect (h : R) (hh : 2 * h = 1) (A : Finset R) (R₀ δ : ℝ) + (hR : 0 ≤ R₀) (hδ : 0 < δ) (f : R → ℝ) (hf : ∀ a ∈ A, 0 ≤ f a ∧ f a ≤ R₀) + (hmid : ∀ a b c, a ∈ A → b ∈ A → c ∈ A → a ≠ b → a + b = 2 * c → + δ ≤ f a + f b - 2 * f c) + {P : Finset (Finset (Role × R))} (hP : IsPack P) : + ((A.card * Fintype.card R : ℕ) : ℝ) / (27 * (1 + 2 * R₀ / δ)) ≤ + 36 * ((A.card * Fintype.card R : ℕ) : ℝ) - ∑ Q ∈ P, (w (coreGraph h A) Q : ℝ) := by + have hstrong := core_integer_defect_six h hh A R₀ δ hR hδ f hf hmid hP + apply le_trans _ hstrong + apply div_le_div_of_nonneg_right _ (by positivity) + nlinarith only [Nat.cast_nonneg (α := ℝ) (A.card * Fintype.card R)] + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/CoreDirections.lean b/LeanPool/SplitCliqueGap/R434/CoreDirections.lean new file mode 100644 index 0000000000..69df668001 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/CoreDirections.lean @@ -0,0 +1,115 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.AffineH54 +public import LeanPool.SplitCliqueGap.R434.ResidualArithmetic +public import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! Edge locations and signed triangle prices on the affine core. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.H54 + +variable {R : Type} [Fintype R] [DecidableEq R] [CommRing R] + +/-- The affine role graph with edge directions restricted to `A`. -/ +abbrev coreGraph (h : R) (A : Finset R) := + directionCore roleGraph (roleStep h) A (roleStep_swap h) + +omit [DecidableEq R] [Fintype R] in +theorem core_is_tripartite (h : R) (A : Finset R) {u v : Role × R} + (hadj : (coreGraph h A).Adj u v) : u.1.1 ≠ v.1.1 := by + change (orderedAdj u.1 v.1 ∨ orderedAdj v.1 u.1) ∧ _ at hadj + exact hadj.1.elim (fun hu => ne_of_lt hu.1) (fun hv => ne_of_gt hv.1) + +theorem core_edges_image (h : R) (hh : 2 * h = 1) (A : Finset R) : + (coreGraph h A).edgeFinset = (A ×ˢ (univ ×ˢ edges)).image + (fun t : R × R × Edge => blockEdge t.1 t.2.1 t.2.2) := by + ext f + constructor + · intro hf + induction f using Sym2.inductionOn with + | _ u v => + obtain ⟨a, ha, x, e, he, heq⟩ := blockEdge_of_adj h hh (SimpleGraph.mem_edgeFinset.mp hf) + exact mem_image.mpr ⟨(a,x,e), by simpa using And.intro ha he, heq⟩ + · intro hf + obtain ⟨⟨a,x,e⟩, hax, rfl⟩ := mem_image.mp hf + simp only [mem_product, mem_univ, true_and] at hax + exact SimpleGraph.mem_edgeFinset.mpr (blockEdge_adj h hh hax.1 hax.2) + +theorem core_edge_count (h : R) (hh : 2 * h = 1) (A : Finset R) : + (coreGraph h A).edgeFinset.card = 54 * (A.card * Fintype.card R) := by + rw [core_edges_image h hh, card_image_of_injective _ (blockEdge_injective h hh)] + simp only [card_product, card_univ, edge_count] + ring + +omit [DecidableEq R] [Fintype R] in +theorem triangle_directions_of_parts (h : R) (hh : 2 * h = 1) {u v w : Role × R} + (hu : u.1.1 = 0) (hv : v.1.1 = 1) (hw : w.1.1 = 2) : + pairDirection (roleStep h) u v + pairDirection (roleStep h) v w = + 2 * pairDirection (roleStep h) u w := by + simp only [pairDirection, roleStep, directedStep, hu, hv, hw] + norm_num + rw [← mul_assoc, hh, one_mul] + +omit [DecidableEq R] [Fintype R] in +theorem local_vertices_of_short_directions (h : R) {u v w : Role × R} + (hu : u.1.1 = 0) (hv : v.1.1 = 1) (hw : w.1.1 = 2) + (hloc : pairDirection (roleStep h) u v = pairDirection (roleStep h) v w) : + ∃ a x : R, a = pairDirection (roleStep h) u v ∧ + affineVertex a x u.1 = u ∧ affineVertex a x v.1 = v ∧ affineVertex a x w.1 = w := by + have hduv : pairDirection (roleStep h) u v = v.2 - u.2 := by + simp [pairDirection, roleStep, directedStep, hu, hv] + have hdvw : pairDirection (roleStep h) v w = w.2 - v.2 := by + simp [pairDirection, roleStep, directedStep, hv, hw] + rw [hduv, hdvw] at hloc + refine ⟨v.2 - u.2, u.2, hduv.symm, Prod.ext rfl ?_, Prod.ext rfl ?_, Prod.ext rfl ?_⟩ + · simp [affineVertex, hu] + · simp only [affineVertex, hv] + norm_num + · simp only [affineVertex, hw] + norm_num + linear_combination hloc + +/-- The price for slope `a`, with the outer pair carrying the negative doubled price. -/ +noncomputable def signedPrice (R₀ : ℝ) (f : R → ℝ) (a : R) (k : Fin 3) : ℝ := + if k = 2 then -2 * (f a - 2 * R₀ / 3) else f a - 2 * R₀ / 3 + +omit [CommRing R] [DecidableEq R] [Fintype R] in +theorem signedPrice_lower (R₀ : ℝ) (f : R → ℝ) {a : R} (ha₀ : 0 ≤ f a) (ha₁ : f a ≤ R₀) + (k : Fin 3) : -(2 * R₀ / 3) ≤ signedPrice R₀ f a k := by + unfold signedPrice + split <;> linarith + +omit [CommRing R] [DecidableEq R] [Fintype R] in +theorem signedPrice_triangle (R₀ : ℝ) (f : R → ℝ) (a b c : R) : + signedPrice R₀ f a 0 + signedPrice R₀ f b 1 + signedPrice R₀ f c 2 = + f a + f b - 2 * f c := by + norm_num [signedPrice] + ring + +omit [CommRing R] [DecidableEq R] [Fintype R] in +theorem signedPrice_block (R₀ : ℝ) (f : R → ℝ) (a : R) : + ∑ e ∈ edges, signedPrice R₀ f a e.1 = 0 := by + have htwo := balanced_edge_counts 2 + have hcompl : (edges.filter (fun e => e.1 ≠ 2)).card = 36 := by + decide +kernel + simp only [signedPrice, sum_ite, sum_const, nsmul_eq_mul, htwo, hcompl] + push_cast + ring + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/CoreFractional.lean b/LeanPool/SplitCliqueGap/R434/CoreFractional.lean new file mode 100644 index 0000000000..43fa7d517c --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/CoreFractional.lean @@ -0,0 +1,202 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.CoreDefect +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Tauto + +/-! Lifting the half-integral H54 witness to a residual packing. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434 + +/-- The unordered vertex set underlying an ordered triangle. -/ +def triangleVertices {V : Type} [DecidableEq V] (t : OrderedTriangle V) : Finset V := + {t.1, t.2.1, t.2.2} + +theorem pair_mem_triangleVertices {V : Type} [DecidableEq V] + {t : OrderedTriangle V} {u v : V} (hne : u ≠ v) : + u ∈ triangleVertices t ∧ v ∈ triangleVertices t ↔ s(u,v) ∈ triangleEdges t := by + simp only [triangleVertices, triangleEdges, mem_insert, mem_singleton, Sym2.eq_iff] + constructor + · rintro ⟨hu,hv⟩ + rcases hu with h | h | h <;> rcases hv with h' | h' | h' <;> + first | exact (hne (h.trans h'.symm)).elim | tauto + · tauto + +namespace H54 + +variable {R : Type} [Fintype R] [DecidableEq R] [CommRing R] + +omit [Fintype R] in +theorem blockTriangle_vertices_card (a x : R) (t : Triangle) : + (triangleVertices (blockTriangle a x t)).card = 3 := by + let u := affineVertex a x (0,t.1) + let v := affineVertex a x (1,t.2.1) + let z := affineVertex a x (2,t.2.2) + have huv : u ≠ v := fun h => (by decide : (0 : Fin 3) ≠ 1) + (congrArg (fun q : Role × R => q.1.1) h) + have huz : u ≠ z := fun h => (by decide : (0 : Fin 3) ≠ 2) + (congrArg (fun q : Role × R => q.1.1) h) + have hvz : v ≠ z := fun h => (by decide : (1 : Fin 3) ≠ 2) + (congrArg (fun q : Role × R => q.1.1) h) + change ({u,v,z} : Finset (Role × R)).card = 3 + rw [card_insert_of_notMem (by simp [huv,huz]), card_pair hvz] + +theorem blockTriangle_edges_core (h : R) (hh : 2 * h = 1) {A : Finset R} + {a x : R} {t : Triangle} (ha : a ∈ A) (ht : t ∈ triangles) : + triangleEdges (blockTriangle a x t) ⊆ (coreGraph h A).edgeFinset := by + intro f hf + rw [triangleEdges_block] at hf + obtain ⟨i, _, rfl⟩ := mem_image.mp hf + have he := (mem_filter.mp ht).2 + apply (blockEdge_mem_core h hh A _ _ _).mpr + refine ⟨ha, ?_⟩ + fin_cases i + · exact he.1 + · exact he.2.1 + · exact he.2.2 + +theorem blockTriangle_score (h : R) (hh : 2 * h = 1) {A : Finset R} + {a x : R} {t : Triangle} (ha : a ∈ A) (ht : t ∈ triangles) : + w (coreGraph h A) (triangleVertices (blockTriangle a x t)) = 2 := by + let T := blockTriangle a x t + let Q := triangleVertices T + let B := coreGraph h A + have hE : (inducedOn B Q).edgeFinset = triangleEdges T := by + ext f + induction f using Sym2.inductionOn with + | _ u v => + constructor + · intro hf + have hp : B.Adj u v ∧ u ∈ Q ∧ v ∈ Q := SimpleGraph.mem_edgeFinset.mp hf + exact (pair_mem_triangleVertices hp.1.ne).mp hp.2 + · intro hf + have hAdj : B.Adj u v := SimpleGraph.mem_edgeFinset.mp (blockTriangle_edges_core h hh ha + ht hf) + obtain ⟨hu,hv⟩ := (pair_mem_triangleVertices hAdj.ne).mpr hf + exact SimpleGraph.mem_edgeFinset.mpr ⟨hAdj,hu,hv⟩ + have hinj : Function.Injective (fun k => blockEdge a x (onTriangleIndex t k)) := by + intro i j he + have heq : ((a,x,onTriangleIndex t i) : R × R × Edge) = (a,x,onTriangleIndex t j) := + blockEdge_injective h hh he + simpa only [onTriangleIndex_kind] using congrArg (fun q : R × R × Edge => q.2.2.1) heq + have he : e B Q = 3 := by + unfold e + rw [hE, triangleEdges_block, card_image_of_injective _ hinj] + simp + change w B Q = 2 + rw [w, he, blockTriangle_vertices_card] + decide + +theorem core_fractional_score_small (h : R) (hh : 2 * h = 1) (A : Finset R) : + ∃ y : Finset (Role × R) → ℝ, ResPack y ∧ (∀ S, y S ≠ 0 → S.card ≤ 3) ∧ + (∑ Q, y Q * (w (coreGraph h A) Q : ℝ)) = + 36 * ((A.card * Fintype.card R : ℕ) : ℝ) := by + classical + let B := coreGraph h A + let D := A ×ˢ ((univ : Finset R) ×ˢ support) + let Q (k : R × R × Triangle) := triangleVertices (blockTriangle k.1 k.2.1 k.2.2) + let y (S : Finset (Role × R)) : ℝ := ∑ k ∈ D, if Q k = S then (1 : ℝ) / 2 else 0 + have hp (k : R × R × Triangle) (hk : k ∈ D) : + k.1 ∈ A ∧ k.2.2 ∈ triangles := by + exact ⟨(mem_product.mp hk).1, support_valid (mem_product.mp (mem_product.mp hk).2).2⟩ + refine ⟨y,⟨?_,?_,?_⟩,?_,?_⟩ + · intro S + exact sum_nonneg fun k _ => by split <;> norm_num + · intro S hs + by_contra! hsmall + apply hs + apply sum_eq_zero + intro k _ + have hcard : (Q k).card = 3 := blockTriangle_vertices_card _ _ _ + have hne : Q k ≠ S := fun he => by rw [he] at hcard; omega + simp [hne] + · intro u v huv + have hsum : ∑ S, (if u ∈ S ∧ v ∈ S then y S else 0) = + ∑ k ∈ D, (if s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2) then (1 : ℝ) / 2 else + 0) := by + simp only [y, ite_sum_zero] + rw [sum_comm] + apply sum_congr rfl + intro k _ + change ∑ S, (if u ∈ S ∧ v ∈ S then if Q k = S then (1 : ℝ) / 2 else 0 else 0) = + if s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2) then (1 : ℝ) / 2 else 0 + rw [sum_eq_single (Q k)] + · simp only + exact if_congr (pair_mem_triangleVertices huv) rfl rfl + · intro S _ hne + simp [hne.symm] + · simp + rw [hsum] + by_cases hB : s(u,v) ∈ B.edgeFinset + · obtain ⟨a,ha,x,e,he,heq⟩ := blockEdge_of_adj h hh (SimpleGraph.mem_edgeFinset.mp hB) + have hfilter : + (D.filter fun k => s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2)) = + {a} ×ˢ ({x} ×ˢ support.filter (onEdge · e)) := by + ext k + simp only [← heq, mem_filter, mem_product, mem_singleton, D, mem_univ, true_and, + blockEdge_mem_blockTriangle h hh] + constructor + · rintro ⟨⟨_,hs⟩,ha',hx',hon⟩ + exact ⟨ha'.symm,hx'.symm,hs,hon⟩ + · rintro ⟨ha',hx',hs,hon⟩ + exact ⟨⟨ha'.symm ▸ ha,hs⟩,ha'.symm,hx'.symm,hon⟩ + rw [← sum_filter (s := D) + (fun k => s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2)) (fun _ => (1 : ℝ) / 2), + hfilter] + simp only [sum_const, nsmul_eq_mul, card_product, card_singleton, twice_on_each_edge e he] + norm_num + · have hzero : ∑ k ∈ D, (if s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2) + then (1 : ℝ) / 2 else 0) = 0 := by + apply sum_eq_zero + intro k hk + have hne : s(u,v) ∉ triangleEdges (blockTriangle k.1 k.2.1 k.2.2) := + fun hm => hB (blockTriangle_edges_core h hh (hp k hk).1 (hp k hk).2 hm) + simp [hne] + rw [hzero] + norm_num + · intro S hs + by_contra! hlarge + apply hs + apply sum_eq_zero + intro k _ + have hc : (Q k).card = 3 := blockTriangle_vertices_card _ _ _ + have hne : Q k ≠ S := fun he => by rw [he] at hc; omega + simp [hne] + · simp only [y, sum_mul, ite_mul, zero_mul] + rw [sum_comm] + have hval : ∑ k ∈ D, ∑ S, (if Q k = S then (1 : ℝ) / 2 * (w B S : ℝ) else 0) = + ∑ _k ∈ D, (1 : ℝ) := by + apply sum_congr rfl + intro k hk + have hscore : w B (Q k) = 2 := blockTriangle_score h hh (hp k hk).1 (hp k hk).2 + simp [hscore] + change ∑ k ∈ D, ∑ S, (if Q k = S then (1 : ℝ) / 2 * (w B S : ℝ) else 0) = _ + rw [hval] + simp only [D, sum_const, nsmul_eq_mul, mul_one, card_product, card_univ, support_count, + Nat.cast_mul] + ring + +theorem core_fractional_score (h : R) (hh : 2 * h = 1) (A : Finset R) : + ∃ y : Finset (Role × R) → ℝ, ResPack y ∧ + (∑ Q, y Q * (w (coreGraph h A) Q : ℝ)) = + 36 * ((A.card * Fintype.card R : ℕ) : ℝ) := by + obtain ⟨y, hy, _, hscore⟩ := core_fractional_score_small h hh A + exact ⟨y, hy, hscore⟩ + +end H54 + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/DensityThreshold.lean b/LeanPool/SplitCliqueGap/R434/DensityThreshold.lean new file mode 100644 index 0000000000..55d7ce82d9 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/DensityThreshold.lean @@ -0,0 +1,82 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSDensity +public import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Tactic.Convert +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! A fixed EHPS region attains any density strictly below 7/24. -/ + +@[expose] public section + +namespace GapExtremal.R434.EHPS + +theorem density_grid_uniform {ε : ℝ} {m : ℕ} [NeZero m] + (he : 0 < ε) (he_small : 0 ≤ 1 / 12 - 3 * ε) (hεm : 43 ≤ ε * (m : ℝ)) : + (7/24 - 30*ε) * (m : ℝ)^2 ≤ ((gridSupport ε m).card : ℝ) := by + have hm₀ : 0 ≤ (m : ℝ) := by positivity + let q := m / 12 + let d := ⌈ε * (m : ℝ)⌉₊ + 20 + let p := q - 2*d + have hqL : 12*q ≤ m := by dsimp [q]; omega + have hqU : m ≤ 12*q+11 := by dsimp [q]; omega + have hql : 12 * (q : ℝ) ≤ (m : ℝ) := by exact_mod_cast hqL + have hqu : (m : ℝ) ≤ 12 * (q : ℝ)+11 := by exact_mod_cast hqU + have hd20 : 20 ≤ d := by dsimp [d]; omega + have hdL : ε * (m : ℝ) + 20 ≤ (d : ℝ) := by + dsimp [d] + push_cast + linarith only [Nat.le_ceil (ε * (m : ℝ))] + have hdU : (d : ℝ) ≤ ε * (m : ℝ) + 21 := by + dsimp [d] + push_cast + linarith only [Nat.ceil_lt_add_one (show 0 ≤ ε * (m : ℝ) by positivity)] + have hgap : (1/12 - 3*ε) * (m : ℝ) ≤ (q : ℝ) - 2*(d : ℝ) := by + nlinarith only [hεm,hqu,hdU] + have hqd : 2*d ≤ q := by + have h : 2 * (d : ℝ) ≤ (q : ℝ) := by + linarith only [hgap,mul_nonneg he_small hm₀] + exact_mod_cast h + have hpL : (1/12 - 3*ε) * (m : ℝ) ≤ (p : ℝ) := by + simpa only [p, Nat.cast_sub hqd, Nat.cast_mul, Nat.cast_ofNat] using hgap + have hpU : (p : ℝ) ≤ (m : ℝ)/12 := by + have h : p ≤ q := Nat.sub_le _ _ + have h' : (p : ℝ) ≤ q := by exact_mod_cast h + linarith only [h',hql] + have hdU' : (d : ℝ) ≤ 2*ε*(m : ℝ) := by linarith only [hdU,hεm] + have hcount := density_grid_lower (q := q) (d := d) (p := p) (m := m) + (by dsimp [p]; omega) hqL hqU hd20 hdL + have hcountR : 42*(p : ℝ)^2 - (p : ℝ) - 26*(d : ℝ)*(p : ℝ) ≤ + ((gridSupport ε m).card : ℝ) := by exact_mod_cast hcount + have hsq := pow_le_pow_left₀ (mul_nonneg he_small hm₀) hpL 2 + have hm_sq : (m : ℝ) ≤ ε * (m : ℝ)^2 := by + have h := mul_le_mul_of_nonneg_right (show 1 ≤ ε * (m : ℝ) by linarith) hm₀ + nlinarith only [h] + have hploss : (p : ℝ) ≤ ε * (m : ℝ)^2 := by linarith only [hpU,hm_sq,hm₀] + have hdloss := mul_le_mul hdU' hpU (show 0 ≤ (p : ℝ) by positivity) + (show 0 ≤ 2*ε*(m : ℝ) by positivity) + nlinarith only [hcountR,hsq,hploss,hdloss,mul_nonneg (sq_nonneg ε) (sq_nonneg (m : ℝ)), + mul_nonneg he.le (sq_nonneg (m : ℝ))] + +theorem density_below_seven_twentyfour {ρ : ℝ} (hρ : 0 < ρ) (hρ' : ρ < 7 / 24) : + ∃ (ε : ℝ) (m₀ : ℕ), 0 < ε ∧ ε ≤ 1 ∧ + ∀ (m : ℕ) [NeZero m], m₀ ≤ m → ρ * (m : ℝ)^2 ≤ ((gridSupport ε m).card : ℝ) := by + let ε := (7/24 - ρ) / 30 + have he : 0 < ε := by dsimp [ε]; linarith + refine ⟨ε, ⌈43/ε⌉₊, he, by dsimp [ε]; linarith, fun m _ hm => ?_⟩ + have hm' : 43/ε ≤ (m : ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast hm) + have h := density_grid_uniform he (by dsimp [ε]; linarith) + (m := m) (by linarith only [(div_le_iff₀ he).mp hm']) + convert h using 1; dsimp [ε]; ring + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSClasses.lean b/LeanPool/SplitCliqueGap/R434/EHPSClasses.lean new file mode 100644 index 0000000000..e4d35af89b --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSClasses.lean @@ -0,0 +1,183 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSGrid +public import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! Midpoint-safe complement classes of the EHPS grid. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434.EHPS + +/-- A three-valued code distinguishing negative, zero, and positive real numbers. -/ +noncomputable def signCode (x : ℝ) : Fin 3 := by + classical + exact if x < 0 then 0 else if x = 0 then 1 else 2 + +theorem signCode_lt (x : ℝ) : signCode x = 0 ↔ x < 0 := by + unfold signCode + split_ifs with h h' <;> norm_num <;> linarith + +theorem signCode_gt (x : ℝ) : signCode x = 2 ↔ 0 < x := by + unfold signCode + split_ifs with h h' <;> norm_num + · linarith + · linarith + · exact lt_of_le_of_ne (le_of_not_gt h) (Ne.symm h') + +theorem signCode_mid {a b : ℝ} (h : signCode a = signCode b) : + signCode ((a + b) / 2) = signCode a := by + rcases lt_trichotomy a 0 with ha | ha | ha + · have hb : b < 0 := (signCode_lt b).mp (h.symm.trans ((signCode_lt a).mpr ha)) + exact ((signCode_lt _).mpr (by linarith)).trans ((signCode_lt _).mpr ha).symm + · subst a + have h0 : signCode 0 = 1 := by simp [signCode] + rw [h0] at h + have hb : b = 0 := by + rcases lt_trichotomy b 0 with hb | hb | hb + · have hz := (signCode_lt b).mpr hb + rw [← h] at hz + norm_num at hz + · exact hb + · have hz := (signCode_gt b).mpr hb + rw [← h] at hz + norm_num at hz + simp [hb] + · have hb : 0 < b := (signCode_gt b).mp (h.symm.trans ((signCode_gt a).mpr ha)) + exact ((signCode_gt _).mpr (by linarith)).trans ((signCode_gt _).mpr ha).symm + +/-- The signed value of the indexed affine form at a point. -/ +noncomputable def lineValue (ε : ℝ) (u : Point) (i : Fin 7) : ℝ := + match i.val with + | 0 => u.1 - 1 / 2 + | 1 => u.2 - 1 / 2 + | 2 => total u - 2 / 3 + | 3 => total u - 7 / 6 + | 4 => total u - (7 / 6 + ε) + | 5 => total u - 17 / 12 + | _ => 2 * u.1 + u.2 - (3 / 2 + ε) + +/-- The coordinatewise midpoint of two points in the plane. -/ +noncomputable def midpoint (u v : Point) : Point := ((u.1 + v.1) / 2, (u.2 + v.2) / 2) + +theorem lineValue_mid (ε : ℝ) (u v : Point) (i : Fin 7) : + lineValue ε (midpoint u v) i = (lineValue ε u i + lineValue ε v i) / 2 := by + fin_cases i <;> simp [lineValue, midpoint, total] <;> ring + +/-- The seven affine sign codes of a point. -/ +noncomputable def profile (ε : ℝ) (u : Point) : Fin 7 → Fin 3 := + fun i => signCode (lineValue ε u i) + +theorem profile_mid {ε : ℝ} {u v : Point} (h : profile ε u = profile ε v) : + profile ε (midpoint u v) = profile ε u := by + funext i + unfold profile + rw [lineValue_mid] + exact signCode_mid (congrFun h i) + +/-- Membership in the half-open unit square. -/ +def InSquare (x : Point) : Prop := 0 ≤ x.1 ∧ x.1 < 1 ∧ 0 ≤ x.2 ∧ x.2 < 1 + +theorem region_iff_of_profile {ε : ℝ} {u v : Point} + (hu : InSquare u) (hv : InSquare v) (h : profile ε u = profile ε v) : + Region ε u ↔ Region ε v := by + have hlt (i : Fin 7) : lineValue ε u i < 0 ↔ lineValue ε v i < 0 := by + rw [← signCode_lt, ← signCode_lt] + exact Iff.of_eq (congrArg (fun k : Fin 3 => k = 0) (congrFun h i)) + have hgt (i : Fin 7) : 0 < lineValue ε u i ↔ 0 < lineValue ε v i := by + rw [← signCode_gt, ← signCode_gt] + exact Iff.of_eq (congrArg (fun k : Fin 3 => k = 2) (congrFun h i)) + have h₀ := not_congr (hlt 0) + have h₁ := hlt 1 + have h₁' := not_congr h₁ + have h₂ := hgt 2 + have h₃ := not_congr (hgt 3) + have h₄ := not_congr (hlt 4) + have h₅ := not_congr (hgt 5) + have h₆ := not_congr (hlt 6) + change ¬ u.1 - 1 / 2 < 0 ↔ ¬ v.1 - 1 / 2 < 0 at h₀ + change u.2 - 1 / 2 < 0 ↔ v.2 - 1 / 2 < 0 at h₁ + change ¬ u.2 - 1 / 2 < 0 ↔ ¬ v.2 - 1 / 2 < 0 at h₁' + change 0 < total u - 2 / 3 ↔ 0 < total v - 2 / 3 at h₂ + change ¬ 0 < total u - 7 / 6 ↔ ¬ 0 < total v - 7 / 6 at h₃ + change ¬ total u - (7 / 6 + ε) < 0 ↔ ¬ total v - (7 / 6 + ε) < 0 at h₄ + change ¬ 0 < total u - 17 / 12 ↔ ¬ 0 < total v - 17 / 12 at h₅ + change ¬ 2 * u.1 + u.2 - (3 / 2 + ε) < 0 ↔ + ¬ 2 * v.1 + v.2 - (3 / 2 + ε) < 0 at h₆ + have h₀' := not_congr h₀ + simp only [sub_lt_zero, sub_pos, not_lt, not_le] at h₀ h₀' h₁ h₁' h₂ h₃ h₄ h₅ h₆ + unfold InSquare at hu hv + simp only [Region, hu.1, hu.2.1, hu.2.2.1, hu.2.2.2, + hv.1, hv.2.1, hv.2.2.1, hv.2.2.2, true_and, h₀, h₀', h₁, h₁', h₂, h₃, h₄, h₅, h₆] + +/-- The two-dimensional cyclic grid of side length `m`. -/ +abbrev Grid (m : ℕ) := ZMod m × ZMod m +/-- A class records the affine sign profile and the two coordinate parities. -/ +abbrev Class := (Fin 7 → Fin 3) × Fin 2 × Fin 2 + +/-- Assigns each grid point its affine sign and parity class. -/ +noncomputable def colour (ε : ℝ) (m : ℕ) (u : Grid m) : Class := + (profile ε (gridPoint m u), ⟨u.1.val % 2, Nat.mod_lt _ (by decide)⟩, + ⟨u.2.val % 2, Nat.mod_lt _ (by decide)⟩) + +theorem class_count : Fintype.card Class = 8748 := by + simp + +theorem grid_in_square {m : ℕ} [NeZero m] (x : Grid m) : + InSquare (gridPoint m x) := by + have hm : (0 : ℝ) < m := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne m) + constructor + · exact div_nonneg (by positivity) hm.le + constructor + · exact (div_lt_one₀ hm).mpr (by exact_mod_cast ZMod.val_lt x.1) + constructor + · exact div_nonneg (by positivity) hm.le + · exact (div_lt_one₀ hm).mpr (by exact_mod_cast ZMod.val_lt x.2) + +theorem grid_coord_mid {m : ℕ} [NeZero m] (hm : Odd m) (u v : ZMod m) + (hp : u.val % 2 = v.val % 2) : + (((oddHalf m * (u + v)).val : ℝ) / m) = + ((u.val : ℝ) / m + (v.val : ℝ) / m) / 2 := by + have hh : oddHalf m * (u + v) = (((u.val + v.val) / 2 : ℕ) : ZMod m) := by + simpa only [ZMod.natCast_zmod_val] using natCast_midpoint hm hp + have hlt : (u.val + v.val) / 2 < m := by + have h₁ := ZMod.val_lt u + have h₂ := ZMod.val_lt v + omega + rw [hh, ZMod.val_natCast_of_lt hlt] + have hN : 2 * ((u.val + v.val) / 2) = u.val + v.val := by omega + have hR : (2 : ℝ) * (((u.val + v.val) / 2 : ℕ) : ℝ) = (u.val : ℝ) + v.val := by + exact_mod_cast hN + linarith only [congrArg (fun a : ℝ => a / (m : ℝ)) hR, + show ((2 : ℝ) * (((u.val + v.val) / 2 : ℕ) : ℝ)) / m = + 2 * ((((u.val + v.val) / 2 : ℕ) : ℝ) / m) by ring, + add_div (u.val : ℝ) v.val m] + +theorem region_mid_of_colour {m : ℕ} [NeZero m] (hm : Odd m) {ε : ℝ} {u v : Grid m} + (hc : colour ε m u = colour ε m v) : + Region ε (gridPoint m (oddHalf m * (u.1 + v.1), oddHalf m * (u.2 + v.2))) ↔ + Region ε (gridPoint m u) := by + let t : Grid m := (oddHalf m * (u.1 + v.1), oddHalf m * (u.2 + v.2)) + have h₁ : u.1.val % 2 = v.1.val % 2 := congrArg (fun c : Class => c.2.1.val) hc + have h₂ : u.2.val % 2 = v.2.val % 2 := congrArg (fun c : Class => c.2.2.val) hc + have ht : gridPoint m t = midpoint (gridPoint m u) (gridPoint m v) := + Prod.ext (grid_coord_mid hm _ _ h₁) (grid_coord_mid hm _ _ h₂) + change Region ε (gridPoint m t) ↔ Region ε (gridPoint m u) + apply region_iff_of_profile (grid_in_square t) (grid_in_square u) + rw [ht] + exact profile_mid (congrArg Prod.fst hc) + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSCompactExterior.lean b/LeanPool/SplitCliqueGap/R434/EHPSCompactExterior.lean new file mode 100644 index 0000000000..7502dc7b16 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSCompactExterior.lean @@ -0,0 +1,105 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSProduct +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.Convert +import Mathlib.Tactic.FinCases + +/-! Six convex certificates for points outside the EHPS region. -/ + +@[expose] public section + +namespace GapExtremal.R434.EHPS.CompactExterior + +private def cell (ε : ℝ) (x : Point) (i : Fin 6) : Prop := + match i.val with + | 0 => total x ≤ 2/3 + | 1 => x.1 < 1/2 ∧ total x < 7/6 + ε + | 2 => 7/6 < total x ∧ total x < 7/6 + ε + | 3 => 7/6 < total x ∧ 1/2 ≤ x.1 ∧ 1/2 ≤ x.2 + | 4 => x.1 < 1/2 ∧ 2*x.1 + x.2 < 3/2 + ε + | _ => 17/12 < total x + +private theorem covered {ε : ℝ} (he : 0 < ε) {x : Point} (hs : InSquare x) (hx : ¬Region ε x) : + ∃ i, cell ε x i := by + by_contra! h + have h0 := h 0 + have h1 := h 1 + have h2 := h 2 + have h3 := h 3 + have h4 := h 4 + have h5 := h 5 + simp [cell,total] at h0 h1 h2 h3 h4 h5 + apply hx + obtain ⟨ha,ha',hb,hb'⟩ := hs + refine ⟨ha,ha',hb,hb',?_⟩ + unfold total + grind + +private theorem outside {ε : ℝ} (he : 0 < ε) {x : Point} {i : Fin 6} + (hx : cell ε x i) : ¬Region ε x := by + intro hr + obtain ⟨_,_,_,_,hr⟩ := hr + fin_cases i <;> simp [cell,total] at hx <;> unfold total at hr <;> grind + +private theorem closed_mid {ε : ℝ} {x y : Point} {i : Fin 6} + (hx : cell ε x i) (hy : cell ε y i) : cell ε (midpoint x y) i := by + fin_cases i <;> simp [cell,total,midpoint] at * <;> grind + +/-- A coordinate, an exterior class, and two parity bits. -/ +abbrev Label (j : ℕ) := Fin j × Fin 6 × Fin 2 × Fin 2 + +theorem label_count (j : ℕ) : Fintype.card (Label j) = 24*j := by + simp [Label]; omega + +theorem product_colouring {m j : ℕ} [NeZero m] (hm : Odd m) {ε : ℝ} (he : 0 < ε) : + ∃ χ : {a : ProductGrid m j // a ∉ productSupport ε m j} → Label j, + ∀ u v, χ u = χ v → productHalf m j * (u.val + v.val) ∉ productSupport ε m j := by + classical + let E := {a : ProductGrid m j // a ∉ productSupport ε m j} + have bad (a : E) : ∃ i, ¬Region ε (gridPoint m (a.val i)) := + not_forall.mp fun h => a.prop (mem_productSupport.mpr h) + let idx (a : E) := (bad a).choose + have witness (a : E) := covered he (grid_in_square (a.val (idx a))) (bad a).choose_spec + let χ (a : E) : Label j := (idx a,(witness a).choose, + ⟨(a.val (idx a)).1.val % 2, Nat.mod_lt _ (by decide)⟩, + ⟨(a.val (idx a)).2.val % 2, Nat.mod_lt _ (by decide)⟩) + refine ⟨χ, fun u v eq hs => ?_⟩ + have hi : idx u = idx v := congrArg Prod.fst eq + have hc : (witness u).choose = (witness v).choose := congrArg (fun c : Label j => c.2.1) eq + have hp := congrArg (fun c : Label j => c.2.2.1.val) eq + have hq := congrArg (fun c : Label j => c.2.2.2.val) eq + change (u.val (idx u)).1.val % 2 = (v.val (idx v)).1.val % 2 at hp + change (u.val (idx u)).2.val % 2 = (v.val (idx v)).2.val % 2 at hq + have hu := (witness u).choose_spec + have hv := (witness v).choose_spec + have hvSame := Eq.mp (congrArg₂ (fun i k => cell ε (gridPoint m (v.val i)) k) hi hc).symm hv + rw [← hi] at hp hq + have ht := (mem_productSupport.mp hs) (idx u) + apply outside he (closed_mid hu hvSame) + convert ht using 1 + exact (Prod.ext (grid_coord_mid hm _ _ hp) (grid_coord_mid hm _ _ hq)).symm + +/-- Extend the exterior coloring to a total map. The extra label is used only +on the support. -/ +noncomputable def colour {m j : ℕ} [NeZero m] {ε : ℝ} (hm : Odd m) (he : 0 < ε) + (a : ProductGrid m j) : Option (Label j) := by + classical + exact if ha : a ∉ productSupport ε m j then + some ((product_colouring hm he).choose ⟨a, ha⟩) else none + +theorem mid_outside {m j : ℕ} [NeZero m] {ε : ℝ} (hm : Odd m) (he : 0 < ε) + {a b : ProductGrid m j} (ha : a ∉ productSupport ε m j) + (hb : b ∉ productSupport ε m j) (hc : colour hm he a = colour hm he b) : + productHalf m j * (a + b) ∉ productSupport ε m j := by + classical + simp only [colour, dite_eq_left ha, dite_eq_left hb, Option.some.injEq] at hc + exact (product_colouring hm he).choose_spec _ _ hc + +end GapExtremal.R434.EHPS.CompactExterior diff --git a/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean b/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean new file mode 100644 index 0000000000..e95c1eeabe --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean @@ -0,0 +1,289 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSHostTransfer +public import Mathlib.Data.Int.Interval +public import Mathlib.Algebra.BigOperators.Intervals +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Mathlib.Tactic.WLOG + +/-! A lattice count of the seven vertical strips of the EHPS region. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.EHPS + +/-- The width multiplier of a strip in the explicit density construction. -/ +def stripWidth (i : Fin 7) : ℕ := + match i.val with | 0 => 2 | 1 => 4 | 2 => 3 | _ => 1 + +/-- The horizontal start of a strip, in units of the scaling parameter. -/ +def stripStart (i : Fin 7) : ℤ := + match i.val with | 0 => 6 | 1 => 8 | 2 => 8 | 3 => 11 | 4 => 3 | 5 => 4 | _ => 5 + +/-- The inclusive lower vertical boundary at horizontal index `k`. -/ +def stripBottom (q k : ℤ) (i : Fin 7) : ℤ := + match i.val with + | 0 => 2 * q-k | 1 => 0 | 2 => 6 * q-k | 3 => 3 * q-k + | 4 => 12 * q-2 * k | 5 => 10 * q-k | _ => 9 * q-k + +/-- The exclusive upper vertical boundary at horizontal index `k`. -/ +def stripTop (q k : ℤ) (i : Fin 7) : ℤ := + match i.val with + | 0 => 8 * q-k | 1 => 6 * q-k | 2 => 6 * q | 3 => 6 * q-k + | 4 => 12 * q | 5 => 12 * q | _ => 12 * q-k + +/-- Integer grid points at one horizontal coordinate of a strip. -/ +def stripRow (q d : ℕ) (i : Fin 7) (j : ℕ) : Finset (ℤ × ℤ) := + {stripStart i * (q : ℤ) + (j : ℤ) + d} ×ˢ + Ico (stripBottom q ((j : ℤ) + d) i + d) (stripTop q ((j : ℤ) + d) i - d) + +/-- Integer grid points in one strip of the density construction. -/ +def stripSet (q d p : ℕ) (i : Fin 7) : Finset (ℤ × ℤ) := + (range (stripWidth i * p)).biUnion (stripRow q d i) + +/-- The union of the seven strips used to bound the grid density from below. -/ +def densitySet (q d p : ℕ) : Finset (ℤ × ℤ) := + univ.biUnion (stripSet q d p) + +theorem strip_row_bounds {q d p j : ℕ} {i : Fin 7} {z : ℤ × ℤ} + (hq : p + 2 * d ≤ q) (hj : j ∈ range (stripWidth i * p)) (hz : z ∈ stripRow q d i j) : + let k := (j : ℤ) + d + (d : ℤ) ≤ k ∧ k + d < (stripWidth i : ℤ) * (q : ℤ) ∧ + z.1 = stripStart i * (q : ℤ) + k ∧ + stripBottom q k i + d ≤ z.2 ∧ z.2 < stripTop q k i - d := by + have hq' : (p : ℤ) + 2 * (d : ℤ) ≤ q := by exact_mod_cast hq + have hj' : (j : ℤ) < (stripWidth i : ℤ) * (p : ℤ) := by exact_mod_cast (mem_range.mp hj) + simp only [stripRow, mem_product, mem_singleton, mem_Ico] at hz + have hd : 0 ≤ (d : ℤ) := by positivity + have hj₀ : 0 ≤ (j : ℤ) := by positivity + have hhi : (j : ℤ) + d + d < (stripWidth i : ℤ) * (q : ℤ) := by + fin_cases i <;> norm_num [stripWidth] at hj' ⊢ <;> omega + exact ⟨by omega, hhi, by linarith only [hz.1], hz.2.1, hz.2.2⟩ + +theorem strip_coordinates {q d p m : ℕ} (hq : p + 2 * d ≤ q) + (hm₁ : 12 * q ≤ m) (hm₂ : m ≤ 12 * q + 11) (hd : 20 ≤ d) + {i : Fin 7} {z : ℤ × ℤ} (hz : z ∈ stripSet q d p i) : + 0 ≤ z.1 ∧ z.1 < m ∧ 0 ≤ z.2 ∧ z.2 < m ∧ + ((i.val ≤ 1 ∧ (m : ℤ) ≤ 2 * z.1 ∧ 2 * (m : ℤ) < 3 * (z.1 + z.2) ∧ + 6 * (z.1 + z.2) ≤ 7 * (m : ℤ)) ∨ + (2 ≤ i.val ∧ i.val ≤ 3 ∧ (m : ℤ) ≤ 2 * z.1 ∧ 2 * z.2 < m ∧ + 7 * (12 * (q : ℤ))/6 + d ≤ z.1 + z.2 ∧ 12 * (z.1 + z.2) ≤ 17 * (m : ℤ)) ∨ + (4 ≤ i.val ∧ 2 * z.1 < m ∧ (m : ℤ) ≤ 2 * z.2 ∧ + 14 * (q : ℤ) + d ≤ z.1 + z.2 ∧ 12 * (z.1 + z.2) ≤ 17 * (m : ℤ) ∧ + 18 * (q : ℤ) + d ≤ 2 * z.1 + z.2)) := by + obtain ⟨j,hj,hz⟩ := mem_biUnion.mp hz + obtain ⟨hk₀,hk₁,hx,hy₀,hy₁⟩ := strip_row_bounds hq hj hz + have hmL : 12 * (q : ℤ) ≤ m := by exact_mod_cast hm₁ + have hmU : (m : ℤ) ≤ 12 * (q : ℤ) + 11 := by exact_mod_cast hm₂ + have hd' : (20 : ℤ) ≤ d := by exact_mod_cast hd + have hq' : 0 ≤ (q : ℤ) := by positivity + fin_cases i <;> + norm_num [stripWidth, stripStart, stripBottom, stripTop] at hk₁ hx hy₀ hy₁ + · refine ⟨by omega,by omega,by omega,by omega, .inl ⟨by decide,by omega,by omega,by omega⟩⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inl ⟨by decide,by omega,by omega,by omega⟩⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inr (.inl + ⟨by decide,by decide,by omega,by omega,by omega,by omega⟩)⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inr (.inl + ⟨by decide,by decide,by omega,by omega,by omega,by omega⟩)⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inr (.inr + ⟨by decide,by omega,by omega,by omega,by omega,by omega⟩)⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inr (.inr + ⟨by decide,by omega,by omega,by omega,by omega,by omega⟩)⟩ + · refine ⟨by omega,by omega,by omega,by omega, .inr (.inr + ⟨by decide,by omega,by omega,by omega,by omega,by omega⟩)⟩ + +theorem densitySet_in_region {q d p m : ℕ} [NeZero m] {ε : ℝ} + (hq : p + 2 * d ≤ q) (hm₁ : 12 * q ≤ m) (hm₂ : m ≤ 12 * q + 11) (hd : 20 ≤ d) + (hε : ε * (m : ℝ) + 20 ≤ d) {z : ℤ × ℤ} (hz : z ∈ densitySet q d p) : + ((z.1 : ZMod m), (z.2 : ZMod m)) ∈ gridSupport ε m := by + obtain ⟨i,_,hi⟩ := mem_biUnion.mp hz + obtain ⟨hx₀,hxU,hy₀,hyU,hcases⟩ := strip_coordinates hq hm₁ hm₂ hd hi + have hmpos : (0 : ℝ) < m := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne m) + have hval (a : ℤ) (ha : 0 ≤ a) (hU : a < (m : ℤ)) : + (((a : ZMod m).val : ℕ) : ℝ) = (a : ℝ) := by + have hn : ((a.toNat : ℕ) : ℤ) = a := Int.toNat_of_nonneg ha + have hlt : a.toNat < m := by exact_mod_cast (show (a.toNat : ℤ) < m by rw [hn]; exact hU) + have he : (a : ZMod m) = (a.toNat : ZMod m) := by + simpa only [Int.cast_natCast] using (congrArg (fun t : ℤ => (t : ZMod m)) hn).symm + rw [he, ZMod.val_natCast_of_lt hlt] + exact_mod_cast hn + apply mem_gridSupport.mpr + simp only [gridPoint, hval _ hx₀ hxU, hval _ hy₀ hyU] + have hx₀' : (0 : ℝ) ≤ (z.1 : ℝ) := by exact_mod_cast hx₀ + have hxU' : (z.1 : ℝ) < (m : ℝ) := by exact_mod_cast hxU + have hy₀' : (0 : ℝ) ≤ (z.2 : ℝ) := by exact_mod_cast hy₀ + have hyU' : (z.2 : ℝ) < (m : ℝ) := by exact_mod_cast hyU + refine ⟨div_nonneg hx₀' hmpos.le, (div_lt_one₀ hmpos).mpr hxU', + div_nonneg hy₀' hmpos.le, (div_lt_one₀ hmpos).mpr hyU', ?_⟩ + have hmU : (m : ℝ) ≤ 12 * (q : ℝ) + 11 := by exact_mod_cast hm₂ + simp only [total, ← add_div] + rcases hcases with ⟨_,hx,hl,hu⟩ | ⟨_,_,hx,hy,hl,hu⟩ | ⟨_,hx,hy,hl,hu,hdbl⟩ + · have hx' : (m : ℝ) ≤ 2 * (z.1 : ℝ) := by exact_mod_cast hx + have hl' : 2 * (m : ℝ) < 3 * ((z.1 : ℝ) + (z.2 : ℝ)) := by exact_mod_cast hl + have hu' : 6 * ((z.1 : ℝ) + (z.2 : ℝ)) ≤ 7 * (m : ℝ) := by exact_mod_cast hu + exact .inl ⟨(le_div_iff₀ hmpos).mpr (by linarith), (lt_div_iff₀ hmpos).mpr (by linarith), + (div_le_iff₀ hmpos).mpr (by linarith)⟩ + · have hx' : (m : ℝ) ≤ 2 * (z.1 : ℝ) := by exact_mod_cast hx + have hy' : 2 * (z.2 : ℝ) < (m : ℝ) := by exact_mod_cast hy + have hlN : 14 * (q : ℤ) + d ≤ z.1 + z.2 := by omega + have hl' : 14 * (q : ℝ) + d ≤ (z.1 : ℝ) + (z.2 : ℝ) := by exact_mod_cast hlN + have hu' : 12 * ((z.1 : ℝ) + (z.2 : ℝ)) ≤ 17 * (m : ℝ) := by exact_mod_cast hu + refine .inr (.inl ⟨(le_div_iff₀ hmpos).mpr (by linarith), (div_lt_iff₀ hmpos).mpr (by linarith), + (le_div_iff₀ hmpos).mpr ?_, (div_le_iff₀ hmpos).mpr (by linarith)⟩) + linarith only [hl',hε,hmU] + · have hx' : 2 * (z.1 : ℝ) < (m : ℝ) := by exact_mod_cast hx + have hy' : (m : ℝ) ≤ 2 * (z.2 : ℝ) := by exact_mod_cast hy + have hl' : 14 * (q : ℝ) + d ≤ (z.1 : ℝ) + (z.2 : ℝ) := by exact_mod_cast hl + have hu' : 12 * ((z.1 : ℝ) + (z.2 : ℝ)) ≤ 17 * (m : ℝ) := by exact_mod_cast hu + have hd' : 18 * (q : ℝ) + d ≤ 2 * (z.1 : ℝ) + (z.2 : ℝ) := by exact_mod_cast hdbl + refine .inr (.inr ⟨(div_lt_iff₀ hmpos).mpr (by linarith), (le_div_iff₀ hmpos).mpr (by linarith), + (le_div_iff₀ hmpos).mpr (by linarith only [hl',hε,hmU]), (div_le_iff₀ hmpos).mpr (by + linarith), ?_⟩) + rw [← mul_div_assoc, ← add_div] + apply (le_div_iff₀ hmpos).mpr + linarith only [hd',hε,hmU] + +theorem stripSets_disjoint {q d p : ℕ} (hq : p + 2 * d ≤ q) : + ((univ : Finset (Fin 7)) : Set (Fin 7)).PairwiseDisjoint (stripSet q d p) := by + intro i hi i' hi' hne + wlog horder : i < i' generalizing i i' + · exact (this hi' hi hne.symm (lt_of_le_of_ne (le_of_not_gt horder) hne.symm)).symm + change Disjoint (stripSet q d p i) (stripSet q d p i') + rw [disjoint_left] + intro z hz hz' + obtain ⟨j,hj,hr⟩ := mem_biUnion.mp hz + obtain ⟨j',hj',hr'⟩ := mem_biUnion.mp hz' + obtain ⟨h₀,h₁,hx,hy₀,hy₁⟩ := strip_row_bounds hq hj hr + obtain ⟨h₀',h₁',hx',hy₀',hy₁'⟩ := strip_row_bounds hq hj' hr' + have hd : 0 ≤ (d : ℤ) := by positivity + have hq₀ : 0 ≤ (q : ℤ) := by positivity + fin_cases i <;> fin_cases i' <;> norm_num [Fin.lt_def] at horder + all_goals + norm_num [stripWidth, stripStart] at h₁ h₁' hx hx' + first + | omega + | norm_num [stripBottom, stripTop] at hy₀ hy₁ hy₀' hy₁' + omega + +/-- The initial height multiplier of each strip. -/ +def baseHeight (i : Fin 7) : ℤ := + match i.val with | 0 => 6 | 1 => 6 | 2 => 0 | 3 => 3 | 4 => 0 | 5 => 2 | _ => 3 + +/-- The change in ideal strip height per unit horizontal displacement. -/ +def heightSlope (i : Fin 7) : ℤ := + match i.val with | 1 => -1 | 2 => 1 | 4 => 2 | 5 => 1 | _ => 0 + +/-- The affine height of a strip before rounding the boundary. -/ +def idealHeight (p j : ℕ) (i : Fin 7) : ℤ := + baseHeight i * (p : ℤ) + heightSlope i * (j : ℤ) + +theorem stripRow_card_lower {q d p j : ℕ} (hq : p + 2 * d ≤ q) (i : Fin 7) : + idealHeight p j i - 2 * (d : ℤ) ≤ ((stripRow q d i j).card : ℤ) := by + have hq' : (p : ℤ) + 2 * (d : ℤ) ≤ q := by exact_mod_cast hq + have hd' : 0 ≤ (d : ℤ) := by positivity + simp only [stripRow, card_product, card_singleton, one_mul, Int.card_Ico] + fin_cases i <;> norm_num [idealHeight, stripBottom, stripTop, baseHeight, heightSlope] <;> omega + +theorem stripRows_disjoint (q d p : ℕ) (i : Fin 7) : + ((range (stripWidth i * p) : Finset ℕ) : Set ℕ).PairwiseDisjoint (stripRow q d i) := by + intro j _ j' _ hne + change Disjoint (stripRow q d i j) (stripRow q d i j') + rw [disjoint_left] + intro z h h' + simp only [stripRow, mem_product, mem_singleton] at h h' + apply hne + omega + +theorem sum_range_int_twice (n : ℕ) : + 2 * ∑ j ∈ range n, (j : ℤ) = (n : ℤ) * ((n : ℤ) - 1) := by + cases n with + | zero => simp + | succ n => + have h := sum_range_id_mul_two (n + 1) + simp only [Nat.add_sub_cancel] at h + have h' := congrArg (fun t : ℕ => (t : ℤ)) h + push_cast at h' + calc + _ = (∑ j ∈ range (n + 1), (j : ℤ)) * 2 := by rw [mul_comm] + _ = _ := by simpa using h' + +theorem sum_idealHeight (p : ℕ) : + ∑ i : Fin 7, ∑ j ∈ range (stripWidth i * p), idealHeight p j i = + 42 * (p : ℤ)^2 - (p : ℤ) := by + simp only [idealHeight, sum_add_distrib, ← Finset.mul_sum, sum_const, card_range, nsmul_eq_mul] + simp only [Fin.sum_univ_succ, Fin.sum_univ_zero, Nat.cast_mul] + have h₁ := sum_range_int_twice p + have h₃ := sum_range_int_twice (3 * p) + have h₄ := sum_range_int_twice (4 * p) + push_cast at h₃ h₄ + norm_num [stripWidth, baseHeight, heightSlope, Fin.succ] at ⊢ + nlinarith only [h₁,h₃,h₄] + +theorem densitySet_card_lower {q d p : ℕ} (hq : p + 2 * d ≤ q) : + 42 * (p : ℤ)^2 - (p : ℤ) - 26 * (d : ℤ) * (p : ℤ) ≤ ((densitySet q d p).card : ℤ) := by + have hsum (i : Fin 7) : (∑ j ∈ range (stripWidth i * p), (idealHeight p j i - 2 * (d : ℤ))) ≤ + ((stripSet q d p i).card : ℤ) := by + rw [stripSet, card_biUnion (stripRows_disjoint q d p i)] + push_cast + exact sum_le_sum fun j _ => stripRow_card_lower hq i + have hl := sum_le_sum (s := (univ : Finset (Fin 7))) (fun i _ => hsum i) + rw [densitySet, card_biUnion (stripSets_disjoint hq)] + push_cast + simp only [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul, Nat.cast_mul] at hl + rw [sum_idealHeight] at hl + have hconst : (∑ i : Fin 7, (stripWidth i : ℤ) * (p : ℤ) * (2 * (d : ℤ))) = + 26 * (d : ℤ) * (p : ℤ) := by + simp only [Fin.sum_univ_succ, Fin.sum_univ_zero] + (norm_num [stripWidth, Fin.succ]; ring) + rw [hconst] at hl + exact hl + +theorem density_grid_lower {q d p m : ℕ} [NeZero m] {ε : ℝ} + (hq : p + 2 * d ≤ q) (hm₁ : 12 * q ≤ m) (hm₂ : m ≤ 12 * q + 11) (hd : 20 ≤ d) + (hε : ε * (m : ℝ) + 20 ≤ d) : + 42 * (p : ℤ)^2 - (p : ℤ) - 26 * (d : ℤ) * (p : ℤ) ≤ ((gridSupport ε m).card : ℤ) := by + classical + let f (z : ℤ × ℤ) : Grid m := ((z.1 : ZMod m), (z.2 : ZMod m)) + let S := densitySet q d p + have hcoord {z : ℤ × ℤ} (hz : z ∈ S) : 0 ≤ z.1 ∧ z.1 < m ∧ 0 ≤ z.2 ∧ z.2 < m := by + obtain ⟨i,_,hi⟩ := mem_biUnion.mp hz + obtain ⟨hx,hx',hy,hy',_⟩ := strip_coordinates hq hm₁ hm₂ hd hi + exact ⟨hx,hx',hy,hy'⟩ + have hinj : Set.InjOn f S := by + intro a ha b hb hab + obtain ⟨h₁,h₁',h₂,h₂'⟩ := hcoord ha + obtain ⟨h₃,h₃',h₄,h₄'⟩ := hcoord hb + have recInt (x : ℤ) (hx : 0 ≤ x) (hx' : x < (m : ℤ)) : ((x : ZMod m).val : ℤ) = x := by + have h := Int.toNat_of_nonneg hx + have hN : x.toNat < m := by exact_mod_cast (show (x.toNat : ℤ) < m by rw [h]; exact hx') + have he : (x : ZMod m) = (x.toNat : ZMod m) := by + simpa only [Int.cast_natCast] using (congrArg (fun t : ℤ => (t : ZMod m)) h).symm + rw [he, ZMod.val_natCast_of_lt hN, h] + apply Prod.ext + · have he : (a.1 : ZMod m) = (b.1 : ZMod m) := congrArg Prod.fst hab + rw [← recInt a.1 h₁ h₁', ← recInt b.1 h₃ h₃', he] + · have he : (a.2 : ZMod m) = (b.2 : ZMod m) := congrArg Prod.snd hab + rw [← recInt a.2 h₂ h₂', ← recInt b.2 h₄ h₄', he] + have hsub : S.image f ⊆ gridSupport ε m := by + intro z hz + obtain ⟨a,ha,rfl⟩ := mem_image.mp hz + exact densitySet_in_region hq hm₁ hm₂ hd hε ha + have hcard := card_le_card hsub + rw [card_image_of_injOn hinj] at hcard + exact (densitySet_card_lower hq).trans (by exact_mod_cast hcard) + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSGrid.lean b/LeanPool/SplitCliqueGap/R434/EHPSGrid.lean new file mode 100644 index 0000000000..5b285ce0b2 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSGrid.lean @@ -0,0 +1,127 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSPotential +public import LeanPool.SplitCliqueGap.R434.OddMidpoints +public import Mathlib.Tactic.IntervalCases +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! Modular midpoint relations on grid representatives and discrete curvature. -/ + +@[expose] public section + +namespace GapExtremal.R434.EHPS + +theorem wrap_of_cast_eq {m a b c : ℕ} (ha : a < m) (hb : b < m) (hc : c < m) + (h : (a : ZMod m) + c = 2 * (b : ZMod m)) : + Wrap ((a : ℝ) / m) ((b : ℝ) / m) ((c : ℝ) / m) := by + have hz : (((a : ℤ) + c - 2 * (b : ℤ) : ℤ) : ZMod m) = 0 := by + push_cast + exact sub_eq_zero.mpr h + obtain ⟨k, hk⟩ := (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp hz + have hmN : 0 < m := by omega + have hmI : (0 : ℤ) < m := by exact_mod_cast hmN + have hmR : (0 : ℝ) < m := by exact_mod_cast hmN + have haI : (a : ℤ) < m := by exact_mod_cast ha + have hbI : (b : ℤ) < m := by exact_mod_cast hb + have hcI : (c : ℤ) < m := by exact_mod_cast hc + have klo : -1 ≤ k := by + by_contra! hn + have hmul := mul_le_mul_of_nonneg_left (show k ≤ -2 by omega) hmI.le + nlinarith only [hk, hmul, hbI, Int.natCast_nonneg a, Int.natCast_nonneg c] + have khi : k ≤ 1 := by + by_contra! hn + have hmul := mul_le_mul_of_nonneg_left (show 2 ≤ k by omega) hmI.le + nlinarith only [hk, hmul, haI, hcI, Int.natCast_nonneg b] + have hkR : (a : ℝ) + c - 2 * (b : ℝ) = (m : ℝ) * (k : ℝ) := by + exact_mod_cast hk + interval_cases k + · right + right + field_simp [hmR.ne'] + norm_num at hkR + linarith only [hkR] + · right + left + field_simp [hmR.ne'] + norm_num at hkR + linarith only [hkR] + · left + field_simp [hmR.ne'] + norm_num at hkR + linarith only [hkR] + +/-- Maps a cyclic grid element to its normalized real coordinates. -/ +noncomputable def gridPoint (m : ℕ) (u : ZMod m × ZMod m) : Point := + ((u.1.val : ℝ) / m, (u.2.val : ℝ) / m) + +/-- The real potential on a grid point, scaled by the square of the grid side. -/ +noncomputable def gridPotential (ε : ℝ) (m : ℕ) (u : ZMod m × ZMod m) : ℝ := + (m : ℝ) ^ 2 * potential ε (gridPoint m u) + +theorem grid_potential_bounds {ε : ℝ} {m : ℕ} {u : ZMod m × ZMod m} + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hu : Region ε (gridPoint m u)) : + 0 ≤ gridPotential ε m u ∧ gridPotential ε m u ≤ 100 * (m : ℝ) ^ 2 / ε ^ 2 := by + have hb := potential_bounds hε hε₁ hu + refine ⟨mul_nonneg (sq_nonneg _) hb.1, ?_⟩ + calc + gridPotential ε m u ≤ (m : ℝ) ^ 2 * (100 / ε ^ 2) := + mul_le_mul_of_nonneg_left hb.2 (sq_nonneg _) + _ = _ := by ring + +theorem square_nat_difference {a b : ℕ} (h : a ≠ b) : + (1 : ℝ) ≤ ((a : ℝ) - b) ^ 2 := by + have hh : (1 : ℝ) ≤ |(a : ℝ) - b| := by + rcases lt_or_gt_of_ne h with hlt | hgt + · have hR : (a : ℝ) + 1 ≤ b := by exact_mod_cast hlt + rw [abs_of_nonpos (by linarith : (a : ℝ) - b ≤ 0)] + linarith + · have hR : (b : ℝ) + 1 ≤ a := by exact_mod_cast hgt + rw [abs_of_nonneg (by linarith : 0 ≤ (a : ℝ) - b)] + linarith + simpa only [sq_abs, one_pow] using pow_le_pow_left₀ (by norm_num : 0 ≤ (1 : ℝ)) hh 2 + +theorem grid_potential_midpoint {ε : ℝ} {m : ℕ} [NeZero m] + {x y z : ZMod m × ZMod m} (hε : 0 < ε) (hε₁ : ε ≤ 1) + (hx : Region ε (gridPoint m x)) (hy : Region ε (gridPoint m y)) + (hz : Region ε (gridPoint m z)) (hne : x ≠ z) + (h₁ : x.1 + z.1 = 2 * y.1) (h₂ : x.2 + z.2 = 2 * y.2) : + 1 ≤ gridPotential ε m x + gridPotential ε m z - 2 * gridPotential ε m y := by + have hwrap₁ : Wrap (gridPoint m x).1 (gridPoint m y).1 (gridPoint m z).1 := + wrap_of_cast_eq (ZMod.val_lt _) (ZMod.val_lt _) (ZMod.val_lt _) + (by simpa only [ZMod.natCast_zmod_val] using h₁) + have hwrap₂ : Wrap (gridPoint m x).2 (gridPoint m y).2 (gridPoint m z).2 := + wrap_of_cast_eq (ZMod.val_lt _) (ZMod.val_lt _) (ZMod.val_lt _) + (by simpa only [ZMod.natCast_zmod_val] using h₂) + have h := potential_midpoint hε hε₁ hx hy hz hwrap₁ hwrap₂ + have hmR : (m : ℝ) ≠ 0 := by exact_mod_cast (NeZero.ne m) + have hid : (m : ℝ) ^ 2 * + (((gridPoint m x).1 - (gridPoint m z).1) ^ 2 + + ((gridPoint m x).2 - (gridPoint m z).2) ^ 2) = + ((x.1.val : ℝ) - z.1.val) ^ 2 + ((x.2.val : ℝ) - z.2.val) ^ 2 := by + simp only [gridPoint] + field_simp [hmR] + have hscaled := mul_le_mul_of_nonneg_left h (sq_nonneg (m : ℝ)) + rw [hid] at hscaled + have hunit : (1 : ℝ) ≤ + ((x.1.val : ℝ) - z.1.val) ^ 2 + ((x.2.val : ℝ) - z.2.val) ^ 2 := by + by_cases hf : x.1.val = z.1.val + · have hs : x.2.val ≠ z.2.val := by + intro hs + exact hne (Prod.ext (ZMod.val_injective m hf) (ZMod.val_injective m hs)) + linarith only [square_nat_difference hs, sq_nonneg ((x.1.val : ℝ) - z.1.val)] + · linarith only [square_nat_difference hf, sq_nonneg ((x.2.val : ℝ) - z.2.val)] + unfold gridPotential + nlinarith only [hscaled, hunit] + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSHostTransfer.lean b/LeanPool/SplitCliqueGap/R434/EHPSHostTransfer.lean new file mode 100644 index 0000000000..47a6e0dc10 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSHostTransfer.lean @@ -0,0 +1,76 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSProduct +public import LeanPool.SplitCliqueGap.R434.CoreDirections +public import Mathlib.Data.Sym.Card +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +/-! Physical host budget and exact-order transfer for the EHPS powers. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.EHPS + +/-- The grid elements whose normalized coordinates lie in the admissible region. -/ +noncomputable def gridSupport (ε : ℝ) (m : ℕ) [NeZero m] : Finset (Grid m) := by + classical + exact univ.filter fun a => Region ε (gridPoint m a) + +theorem mem_gridSupport {ε : ℝ} {m : ℕ} [NeZero m] {a : Grid m} : + a ∈ gridSupport ε m ↔ Region ε (gridPoint m a) := by + classical + simp [gridSupport] + +theorem productSupport_card (ε : ℝ) (m j : ℕ) [NeZero m] : + (productSupport ε m j).card = (gridSupport ε m).card ^ j := by + classical + let eqv : productSupport ε m j ≃ (Fin j → gridSupport ε m) := { + toFun := fun a i => ⟨a.val i, mem_gridSupport.mpr (mem_productSupport.mp a.prop i)⟩ + invFun := fun f => ⟨fun i => (f i).val, + mem_productSupport.mpr (fun i => mem_gridSupport.mp (f i).prop)⟩ + left_inv := fun _ => Subtype.ext rfl + right_inv := fun _ => funext fun _ => Subtype.ext rfl + } + simpa [Fintype.card_fun] using Fintype.card_congr eqv + +/-- The linear bound on the number of host labels in the basic product construction. -/ +def hostFactor (j : ℕ) := 255 + 1049760 * j + +theorem host_order (m j : ℕ) [NeZero m] : + Fintype.card ((H54.Role × ProductGrid m j) ⊕ + MidHost H54.Role (ProductGrid m j) (ProductClass j)) = + hostFactor j * (m ^ 2) ^ j := by + have hc : Fintype.card (ProductGrid m j) = (m ^ 2) ^ j := by + simp [ZMod.card, pow_two] + simp only [MidHost, Fintype.card_sum, Fintype.card_prod, hc, Sym2.card, + Fintype.card_fin, Fintype.card_option, hostFactor] + norm_num [Nat.choose_two_right] + ring + +theorem exact_graph_from_EHPS_scores {ε : ℝ} {m j n : ℕ} [NeZero m] (hm : Odd m) + (hn : hostFactor j * (m ^ 2) ^ j ≤ n) + (I : ℤ) {y : Finset (H54.Role × ProductGrid m j) → ℝ} + (hi : ∀ P : Finset (Finset (H54.Role × ProductGrid m j)), IsPack P → + ∑ Q ∈ P, w (H54.coreGraph (productHalf m j) (productSupport ε m j)) Q ≤ I) + (hy : ResPack y) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + (∑ Q, y Q * (w (H54.coreGraph (productHalf m j) + (productSupport ε m j)) Q : ℝ)) - (I : ℝ) ≤ gap G := by + classical + have hH := midpoint_host_hyp H54.roleGraph (H54.roleStep (productHalf m j)) + (productSupport ε m j) (productHalf m j) (H54.roleStep_swap _) (productHalf_spec hm) + (productColour ε m j) (fun _ _ ha hb hc => product_mid_outside hm ha hb hc) + exact exact_graph_of_host_scores hH ((0,0),0) n (by simpa only [host_order] using hn) I hi hy + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSPotential.lean b/LeanPool/SplitCliqueGap/R434/EHPSPotential.lean new file mode 100644 index 0000000000..9b6d119d75 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSPotential.lean @@ -0,0 +1,166 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSRegion +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +/-! The EHPS potential and its uniform pointwise curvature. -/ + +@[expose] public section + +namespace GapExtremal.R434.EHPS + +/-- A quadratic potential that restarts at the half-unit boundary. -/ +noncomputable def bend (u : ℝ) : ℝ := if u < 1 / 2 then u ^ 2 else (u - 1 / 2) ^ 2 + +/-- The weighted quadratic potential used to control midpoint defects. -/ +noncomputable def potential (ε : ℝ) (x : Point) : ℝ := + (24 / ε ^ 2) * total x ^ 2 + 6 * bend x.1 + +theorem bend_bounds {u : ℝ} (h₀ : 0 ≤ u) (h₁ : u < 1) : 0 ≤ bend u ∧ bend u ≤ 1 / 4 := by + unfold bend + split + · rename_i h + exact ⟨sq_nonneg _, by + have hh : u ^ 2 ≤ (1 / 2 : ℝ) ^ 2 := pow_le_pow_left₀ h₀ h.le 2 + linarith⟩ + · rename_i h + have hw : 0 ≤ u - 1 / 2 := sub_nonneg.mpr (le_of_not_gt h) + have hh : (u - 1 / 2) ^ 2 ≤ (1 / 2 : ℝ) ^ 2 := + pow_le_pow_left₀ hw (by linarith) 2 + exact ⟨sq_nonneg _, by linarith⟩ + +theorem bend_lower {ε : ℝ} {x : Point} (hε : 0 < ε) (hx : Region ε x) : + (x.1 - 1 / 2) ^ 2 ≤ bend x.1 := by + unfold bend + split + · rename_i h + have hh := (left_total hx h).2 + nlinarith only [hh, hε, hx.2.2.2.1] + · exact le_rfl + +theorem bend_midpoint {a b c : ℝ} (ha : 0 ≤ a) (ha' : a < 1) + (hb : 0 ≤ b) (hb' : b < 1) (hc : 0 ≤ c) (hc' : c < 1) + (h : Wrap a b c) : bend b = bend ((a + c) / 2) := by + rcases h with h | h | h + · have hb₁ : b < 1 / 2 := by linarith + have hm : ¬ (a + c) / 2 < 1 / 2 := by linarith + simp only [bend, ite_eq_left hb₁, ite_eq_right hm] + rw [show b = (a + c) / 2 - 1 / 2 by linarith] + · rw [show b = (a + c) / 2 by linarith] + · have hb₁ : ¬ b < 1 / 2 := by linarith + have hm : (a + c) / 2 < 1 / 2 := by linarith + simp only [bend, ite_eq_right hb₁, ite_eq_left hm] + rw [show b - 1 / 2 = (a + c) / 2 by linarith] + +theorem bend_convex_if_close {ε : ℝ} {x y z : Point} (hε : 0 < ε) + (hx : Region ε x) (hy : Region ε y) (hz : Region ε z) + (hw : Wrap x.1 y.1 z.1) + (hd₁ : total x - total z < ε) (hd₂ : total z - total x < ε) : + 2 * bend y.1 + (x.1 - z.1) ^ 2 / 2 ≤ bend x.1 + bend z.1 := by + rw [bend_midpoint hx.1 hx.2.1 hy.1 hy.2.1 hz.1 hz.2.1 hw] + by_cases h : 1 / 2 ≤ x.1 ∨ 1 / 2 ≤ z.1 + · have hm : ¬ (x.1 + z.1) / 2 < 1 / 2 := by + linarith only [close_first_sum hx hz hd₁ hd₂ h] + have hid : 2 * bend ((x.1 + z.1) / 2) + (x.1 - z.1) ^ 2 / 2 = + (x.1 - 1 / 2) ^ 2 + (z.1 - 1 / 2) ^ 2 := by + simp only [bend, ite_eq_right hm] + ring + rw [hid] + exact add_le_add (bend_lower hε hx) (bend_lower hε hz) + · have hx' : x.1 < 1 / 2 := lt_of_not_ge (fun hn => h (Or.inl hn)) + have hz' : z.1 < 1 / 2 := lt_of_not_ge (fun hn => h (Or.inr hn)) + have hm : (x.1 + z.1) / 2 < 1 / 2 := by linarith + simp only [bend, ite_eq_left hx', ite_eq_left hz', ite_eq_left hm] + nlinarith + +theorem potential_bounds {ε : ℝ} {x : Point} (hε : 0 < ε) (hε₁ : ε ≤ 1) + (hx : Region ε x) : 0 ≤ potential ε x ∧ potential ε x ≤ 100 / ε ^ 2 := by + have hb := bend_bounds hx.1 hx.2.1 + have hxs := total_bounds hε hx + have hsq : total x ^ 2 ≤ 4 := by + have hh : total x ^ 2 ≤ (2 : ℝ) ^ 2 := + pow_le_pow_left₀ (by linarith only [hxs.1]) (by linarith only [hxs.2]) 2 + linarith + have hep : 0 < ε ^ 2 := by positivity + have he : ε ^ 2 ≤ 1 := by simpa using pow_le_pow_left₀ hε.le hε₁ 2 + have h₄ : (4 : ℝ) ≤ 4 / ε ^ 2 := (le_div_iff₀ hep).mpr (by linarith) + unfold potential + constructor + · have hn := hb.1 + positivity + · have hmul := mul_le_mul_of_nonneg_left hsq (show 0 ≤ 24 / ε ^ 2 by positivity) + have hid : (100 : ℝ) / ε ^ 2 = (24 / ε ^ 2) * 4 + 4 / ε ^ 2 := by ring + linarith only [hmul, h₄, hb.2, hid] + +theorem potential_midpoint {ε : ℝ} {x y z : Point} (hε : 0 < ε) (hε₁ : ε ≤ 1) + (hx : Region ε x) (hy : Region ε y) (hz : Region ε z) + (hw₁ : Wrap x.1 y.1 z.1) (hw₂ : Wrap x.2 y.2 z.2) : + (x.1 - z.1) ^ 2 + (x.2 - z.2) ^ 2 ≤ + potential ε x + potential ε z - 2 * potential ε y := by + have hep : 0 < ε ^ 2 := by positivity + have hcoef : 0 ≤ 24 / ε ^ 2 := by positivity + have he : ε ^ 2 ≤ 1 := by simpa using pow_le_pow_left₀ hε.le hε₁ 2 + have hbₓ := bend_bounds hx.1 hx.2.1 + have hbᵧ := bend_bounds hy.1 hy.2.1 + have hb_z := bend_bounds hz.1 hz.2.1 + have hdist₁ : (x.1 - z.1) ^ 2 ≤ 1 := by + have h : |x.1 - z.1| ≤ 1 := abs_le.mpr + ⟨by linarith only [hx.1, hz.2.1], by linarith only [hx.2.1, hz.1]⟩ + simpa only [sq_abs, one_pow] using pow_le_pow_left₀ (abs_nonneg _) h 2 + have hdist₂ : (x.2 - z.2) ^ 2 ≤ 1 := by + have h : |x.2 - z.2| ≤ 1 := abs_le.mpr + ⟨by linarith only [hx.2.2.1, hz.2.2.2.1], + by linarith only [hx.2.2.2.1, hz.2.2.1]⟩ + simpa only [sq_abs, one_pow] using pow_le_pow_left₀ (abs_nonneg _) h 2 + have large : ε ^ 2 / 2 ≤ total x ^ 2 + total z ^ 2 - 2 * total y ^ 2 → + (x.1 - z.1) ^ 2 + (x.2 - z.2) ^ 2 ≤ + potential ε x + potential ε z - 2 * potential ε y := by + intro h + have hmul := mul_le_mul_of_nonneg_left h hcoef + have hid : (24 / ε ^ 2) * (ε ^ 2 / 2) = 12 := by + (field_simp [hε.ne']; norm_num) + rw [hid] at hmul + unfold potential + nlinarith only [hmul, hdist₁, hdist₂, hbₓ.1, hbᵧ.2, hb_z.1] + rcases midpoint_total hε hx hy hz hw₁ hw₂ with hsum | hsum + · by_cases hlarge : ε ≤ |total x - total z| + · apply large + have hh := pow_le_pow_left₀ hε.le hlarge 2 + rw [sq_abs] at hh + have hid : total x ^ 2 + total z ^ 2 - 2 * total y ^ 2 = + (total x - total z) ^ 2 / 2 := by + rw [show total y = (total x + total z) / 2 by linarith only [hsum]] + ring + linarith only [hh, hid] + · have hc := abs_lt.mp (lt_of_not_ge hlarge) + have hb := bend_convex_if_close hε hx hy hz hw₁ hc.2 (by linarith only [hc.1]) + have ht : (2 : ℝ) ≤ 12 / ε ^ 2 := (le_div_iff₀ hep).mpr (by linarith) + have hm := mul_le_mul_of_nonneg_right ht (sq_nonneg (total x - total z)) + have hid : (24 / ε ^ 2) * (total x ^ 2 + total z ^ 2 - 2 * total y ^ 2) = + 12 / ε ^ 2 * (total x - total z) ^ 2 := by + rw [show total y = (total x + total z) / 2 by linarith only [hsum]] + ring + have hsq : (x.2 - z.2) ^ 2 ≤ + 2 * (total x - total z) ^ 2 + 2 * (x.1 - z.1) ^ 2 := by + unfold total + nlinarith only [sq_nonneg ((x.1 - z.1) + (x.1 + x.2 - (z.1 + z.2)))] + unfold potential + nlinarith only [hb, hm, hid, hsq] + · apply large + have hid : total x ^ 2 + total z ^ 2 - 2 * total y ^ 2 = + (total x - total z) ^ 2 / 2 + 2 * total y + 1 / 2 := by + rw [show total y = (total x + total z - 1) / 2 by linarith only [hsum]] + ring + linarith only [he, hid, (total_bounds hε hy).1, sq_nonneg (total x - total z)] + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSProduct.lean b/LeanPool/SplitCliqueGap/R434/EHPSProduct.lean new file mode 100644 index 0000000000..260022bf24 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSProduct.lean @@ -0,0 +1,123 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSClasses +public import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Tactic.Ring + +/-! Cartesian powers of the EHPS support, with colour and energy estimates. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.EHPS + +/-- The grid obtained by taking `j` independent two-dimensional coordinates. -/ +abbrev ProductGrid (m j : ℕ) := Fin j → Grid m +/-- An optional exterior coordinate and its class. -/ +abbrev ProductClass (j : ℕ) := Option (Fin j × Class) + +/-- The product of the admissible grid supports in all coordinates. -/ +noncomputable def productSupport (ε : ℝ) (m j : ℕ) [NeZero m] : + Finset (ProductGrid m j) := by + classical + exact univ.filter fun a => ∀ i, Region ε (gridPoint m (a i)) + +theorem mem_productSupport {ε : ℝ} {m j : ℕ} [NeZero m] {a : ProductGrid m j} : + a ∈ productSupport ε m j ↔ ∀ i, Region ε (gridPoint m (a i)) := by + classical + simp [productSupport] + +/-- The class from the first coordinate outside the support, when one exists. -/ +noncomputable def productColour (ε : ℝ) (m j : ℕ) (a : ProductGrid m j) : + ProductClass j := by + classical + exact if h : ∃ i, ¬ Region ε (gridPoint m (a i)) then + some (h.choose, colour ε m (a h.choose)) + else none + +/-- The coordinatewise inverse of two on the product grid of odd side length. -/ +def productHalf (m j : ℕ) : ProductGrid m j := + fun _ => (oddHalf m, oddHalf m) + +theorem productHalf_spec {m j : ℕ} (hm : Odd m) : + 2 * productHalf m j = 1 := by + funext i + exact Prod.ext (two_mul_oddHalf hm) (two_mul_oddHalf hm) + +theorem productClass_count (j : ℕ) : Fintype.card (ProductClass j) = 8748 * j + 1 := by + simp [Nat.mul_comm] + +theorem product_mid_outside {ε : ℝ} {m j : ℕ} [NeZero m] (hm : Odd m) + {a b : ProductGrid m j} (ha : a ∉ productSupport ε m j) + (hb : b ∉ productSupport ε m j) (hc : productColour ε m j a = productColour ε m j b) : + productHalf m j * (a + b) ∉ productSupport ε m j := by + classical + have ha' : ∃ i, ¬ Region ε (gridPoint m (a i)) := + not_forall.mp (fun h => ha (mem_productSupport.mpr h)) + have hb' : ∃ i, ¬ Region ε (gridPoint m (b i)) := + not_forall.mp (fun h => hb (mem_productSupport.mpr h)) + simp only [productColour, dite_eq_left ha', dite_eq_left hb', Option.some.injEq] at hc + have hi : ha'.choose = hb'.choose := congrArg Prod.fst hc + have hci := congrArg Prod.snd hc + rw [← hi] at hci + intro ht + apply ha'.choose_spec + exact (region_mid_of_colour hm hci).mp ((mem_productSupport.mp ht) ha'.choose) + +/-- The sum of the coordinate grid potentials. -/ +noncomputable def productPotential (ε : ℝ) (m j : ℕ) (a : ProductGrid m j) : ℝ := + ∑ i, gridPotential ε m (a i) + +theorem product_potential_bounds {ε : ℝ} {m j : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) {a : ProductGrid m j} (ha : a ∈ productSupport ε m j) : + 0 ≤ productPotential ε m j a ∧ productPotential ε m j a ≤ + (j : ℝ) * (100 * (m : ℝ) ^ 2 / ε ^ 2) := by + constructor + · exact sum_nonneg fun i _ => (grid_potential_bounds hε hε₁ (mem_productSupport.mp ha i)).1 + · calc + productPotential ε m j a ≤ ∑ _i : Fin j, 100 * (m : ℝ) ^ 2 / ε ^ 2 := + sum_le_sum fun i _ => (grid_potential_bounds hε hε₁ (mem_productSupport.mp ha i)).2 + _ = _ := by simp + +theorem product_potential_midpoint {ε : ℝ} {m j : ℕ} [NeZero m] + (hm : Odd m) (hε : 0 < ε) (hε₁ : ε ≤ 1) {a b c : ProductGrid m j} + (ha : a ∈ productSupport ε m j) (hb : b ∈ productSupport ε m j) + (hc : c ∈ productSupport ε m j) (hne : a ≠ c) (heq : a + c = 2 * b) : + 1 ≤ productPotential ε m j a + productPotential ε m j c - 2 * productPotential ε m j b := by + classical + let d (i : Fin j) := gridPotential ε m (a i) + gridPotential ε m (c i) - + 2 * gridPotential ε m (b i) + have hcoord (i : Fin j) : a i + c i = 2 * b i := congrFun heq i + have hsome (i : Fin j) (hi : a i ≠ c i) : 1 ≤ d i := + grid_potential_midpoint hε hε₁ (mem_productSupport.mp ha i) (mem_productSupport.mp hb i) + (mem_productSupport.mp hc i) hi (congrArg Prod.fst (hcoord i)) + (congrArg Prod.snd (hcoord i)) + have hall (i : Fin j) : 0 ≤ d i := by + by_cases hi : a i = c i + · have hh : (2 : Grid m) * (oddHalf m, oddHalf m) = 1 := + Prod.ext (two_mul_oddHalf hm) (two_mul_oddHalf hm) + have hx : a i = b i := by + have h2 := hcoord i + rw [← hi, ← two_mul] at h2 + have hs := congrArg (fun x : Grid m => (oddHalf m, oddHalf m) * x) h2 + simpa only [← mul_assoc, mul_comm (oddHalf m, oddHalf m) (2 : Grid m), hh, one_mul] using hs + have hz : d i = 0 := by + simp only [d, ← hi, ← hx] + ring + rw [hz] + · exact zero_le_one.trans (hsome i hi) + have hn : ∃ i, a i ≠ c i := not_forall.mp (fun h => hne (funext h)) + obtain ⟨i, hi⟩ := hn + have hs : 1 ≤ ∑ x, d x := + (hsome i hi).trans (single_le_sum (fun x _ => hall x) (mem_univ i)) + simpa only [d, sum_sub_distrib, sum_add_distrib, ← Finset.mul_sum, productPotential] using hs + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean b/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean new file mode 100644 index 0000000000..a7c9337a86 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean @@ -0,0 +1,117 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Basic.Real.Basic +public import Mathlib.Tactic.Linarith + +/-! The polygonal inequalities in EHPS, Definition 4.1 and Lemmas 4.4, 4.6. -/ + +@[expose] public section + +namespace GapExtremal.R434.EHPS + +/-- A point in the real plane. -/ +abbrev Point := ℝ × ℝ +/-- The sum of the two coordinates of a point. -/ +def total (x : Point) : ℝ := x.1 + x.2 + +/-- The admissible half-open region for the midpoint-defect construction. -/ +def Region (ε : ℝ) (x : Point) : Prop := + 0 ≤ x.1 ∧ x.1 < 1 ∧ 0 ≤ x.2 ∧ x.2 < 1 ∧ + ((1 / 2 ≤ x.1 ∧ 2 / 3 < total x ∧ total x ≤ 7 / 6) ∨ + (1 / 2 ≤ x.1 ∧ x.2 < 1 / 2 ∧ 7 / 6 + ε ≤ total x ∧ total x ≤ 17 / 12) ∨ + (x.1 < 1 / 2 ∧ 1 / 2 ≤ x.2 ∧ 7 / 6 + ε ≤ total x ∧ + total x ≤ 17 / 12 ∧ 3 / 2 + ε ≤ 2 * x.1 + x.2)) + +/-- Each doubled coordinate of the midpoint differs by one of these integers. -/ +def Wrap (a b c : ℝ) : Prop := + 2 * b = a + c - 1 ∨ 2 * b = a + c ∨ 2 * b = a + c + 1 + +theorem total_bounds {ε : ℝ} {x : Point} (hε : 0 < ε) (hx : Region ε x) : + 2 / 3 < total x ∧ total x ≤ 17 / 12 := by + rcases hx.2.2.2.2 with ⟨_, h1, h2⟩ | ⟨_, _, h1, h2⟩ | ⟨_, _, h1, h2, _⟩ + all_goals constructor <;> linarith only [hε, h1, h2] + +theorem left_total {ε : ℝ} {x : Point} (hx : Region ε x) (hl : x.1 < 1 / 2) : + 7 / 6 + ε ≤ total x ∧ 3 / 2 + ε ≤ 2 * x.1 + x.2 := by + rcases hx.2.2.2.2 with ⟨hf, _, _⟩ | ⟨hf, _, _, _⟩ | ⟨_, _, h1, _, h2⟩ + · exact False.elim ((not_le_of_gt hl) hf) + · exact False.elim ((not_le_of_gt hl) hf) + · exact ⟨h1, h2⟩ + +theorem upper_right_total {ε : ℝ} {x : Point} (hx : Region ε x) + (h₁ : 1 / 2 ≤ x.1) (h₂ : 1 / 2 ≤ x.2) : total x ≤ 7 / 6 := by + rcases hx.2.2.2.2 with ⟨_, _, hu⟩ | ⟨_, hl, _, _⟩ | ⟨hl, _, _, _, _⟩ + · exact hu + · exact False.elim ((not_le_of_gt hl) h₂) + · exact False.elim ((not_le_of_gt hl) h₁) + +theorem one_coordinate_high {ε : ℝ} {x : Point} (hx : Region ε x) : + 1 / 2 ≤ x.1 ∨ 1 / 2 ≤ x.2 := by + rcases hx.2.2.2.2 with ⟨h, _, _⟩ | ⟨h, _, _, _⟩ | ⟨_, h, _, _, _⟩ + · exact Or.inl h + · exact Or.inl h + · exact Or.inr h + +theorem midpoint_total {ε : ℝ} {x y z : Point} (hε : 0 < ε) + (hx : Region ε x) (hy : Region ε y) (hz : Region ε z) + (h₁ : Wrap x.1 y.1 z.1) (h₂ : Wrap x.2 y.2 z.2) : + 2 * total y = total x + total z ∨ 2 * total y = total x + total z - 1 := by + have hxs := total_bounds hε hx + have hys := total_bounds hε hy + have hzs := total_bounds hε hz + have hmax₁ : 2 * y.1 ≤ x.1 + z.1 + 1 := by + rcases h₁ with h | h | h <;> linarith only [h] + have hmax₂ : 2 * y.2 ≤ x.2 + z.2 + 1 := by + rcases h₂ with h | h | h <;> linarith only [h] + have hnotup : ¬ (total x + total z + 1 ≤ 2 * total y) := by + intro hup + have hraw := hup + unfold total at hraw + by_cases hs : x.1 + z.1 < 1 + · have hlarge : 11 / 6 < total x + total z := by + by_cases ht : x.1 < 1 / 2 + · linarith only [hε, (left_total hx ht).1, hzs.1] + · have ht' : z.1 < 1 / 2 := by linarith only [hs, le_of_not_gt ht] + linarith only [hε, (left_total hz ht').1, hxs.1] + linarith only [hup, hlarge, hys.2] + · have hs' := le_of_not_gt hs + have hfirst : 1 / 2 ≤ y.1 := by linarith only [hraw, hmax₂, hs'] + have hsecond : 1 / 2 ≤ y.2 := by + rcases h₁ with h | h | h + · linarith only [h, hraw, hmax₂] + · linarith only [h, hraw, hx.2.2.1, hz.2.2.1] + · linarith only [h, hs', hy.2.1] + linarith only [hup, hxs.1, hzs.1, upper_right_total hy hfirst hsecond] + have hnotdown : ¬ (2 * y.1 = x.1 + z.1 - 1 ∧ 2 * y.2 = x.2 + z.2 - 1) := by + intro ⟨ha, hb⟩ + rcases one_coordinate_high hy with hh | hh + · linarith only [ha, hh, hx.2.1, hz.2.1] + · linarith only [hb, hh, hx.2.2.2.1, hz.2.2.2.1] + rcases h₁ with ha | ha | ha <;> rcases h₂ with hb | hb | hb <;> + first + | exact False.elim (hnotdown ⟨ha, hb⟩) + | left; unfold total; linarith only [ha, hb] + | right; unfold total; linarith only [ha, hb] + | exfalso; apply hnotup; unfold total; linarith only [ha, hb] + +theorem close_first_sum {ε : ℝ} {x z : Point} + (hx : Region ε x) (hz : Region ε z) + (hd₁ : total x - total z < ε) (hd₂ : total z - total x < ε) + (hside : 1 / 2 ≤ x.1 ∨ 1 / 2 ≤ z.1) : + 1 ≤ x.1 + z.1 := by + have hxbox := hx.2.2.2.2 + have hzbox := hz.2.2.2.2 + unfold total at hd₁ hd₂ hxbox hzbox + rcases hside with hs | hs <;> + rcases hxbox with ⟨hx₁,hx₂,hx₃⟩ | ⟨hx₁,hx₂,hx₃,hx₄⟩ | + ⟨hx₁,hx₂,hx₃,hx₄,hx₅⟩ <;> + rcases hzbox with ⟨hz₁,hz₂,hz₃⟩ | ⟨hz₁,hz₂,hz₃,hz₄⟩ | + ⟨hz₁,hz₂,hz₃,hz₄,hz₅⟩ <;> linarith + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean new file mode 100644 index 0000000000..4d21f86714 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean @@ -0,0 +1,38 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.ExactOrder + +/-! The GraphBase bridge and leaf padding at an arbitrary order. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +theorem exact_graph_of_host_scores + {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] + {B : SimpleGraph V} [DecidableRel B.Adj] {N : H → Finset V} + {φ : V → V → H} (hH : HostHyp B N φ) (v₀ : V) + (n : ℕ) (hn : Fintype.card (V ⊕ H) ≤ n) + (I : ℤ) (hI : ∀ P : Finset (Finset V), IsPack P → ∑ Q ∈ P, w B Q ≤ I) + {y : Finset V → ℝ} (hy : ResPack y) : + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' = n ∧ IsSplit G' ∧ G'.Connected ∧ + (∑ Q, y Q * (w B Q : ℝ)) - (I : ℝ) ≤ gap G' := by + classical + let k := n - Fintype.card (V ⊕ H) + let N' := padN N v₀ k + refine ⟨V ⊕ (H ⊕ Fin k), inferInstance, inferInstance, hostGraph N', + ?_, isSplit_hostGraph N', connected_hostGraph N' v₀ (padN_nonempty N v₀ k), ?_⟩ + · rw [card_pad] + exact Nat.add_sub_of_le hn + · exact gap_ge (hH.pad v₀ k) I hI hy + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/FiniteR434.lean b/LeanPool/SplitCliqueGap/R434/FiniteR434.lean new file mode 100644 index 0000000000..b2ab4a513b --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/FiniteR434.lean @@ -0,0 +1,200 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.CoreFractional +public import LeanPool.SplitCliqueGap.R434.RobustHosts +public import LeanPool.SplitCliqueGap.R434.EHPSCompactExterior +public import LeanPool.SplitCliqueGap.R434.UniversalHosts +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! The finite gap at an exact order, with the concrete EHPS support. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434.EHPS + +theorem finite_gap_of_product_for {ε : ℝ} {m j n d : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (loss : ∀ {U : Type} [Fintype U] [DecidableEq U], SimpleGraph U → ℝ) + (realize : ∀ (I : ℤ) {y : Finset (H54.Role × ProductGrid m j) → ℝ}, + (∀ P : Finset (Finset (H54.Role × ProductGrid m j)), IsPack P → + ∑ S ∈ P, w (H54.coreGraph (productHalf m j) (productSupport ε m j)) S ≤ I) → + ResPack y → (∀ S, y S ≠ 0 → S.card ≤ 3) → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G d ∧ + (∑ Q, y Q * (w (H54.coreGraph (productHalf m j) (productSupport ε m j)) Q : ℝ)) - + (I : ℝ) ≤ loss G) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G d ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ loss G := by + classical + let A := productSupport ε m j + let h := productHalf m j + let B := H54.coreGraph h A + let τ : ℝ := ((A.card * Fintype.card (ProductGrid m j) : ℕ) : ℝ) + let R : ℝ := (j : ℝ) * (100 * (m : ℝ) ^ 2 / ε ^ 2) + let D : ℝ := 6 * τ / (27 * (1 + 2 * R / 1)) + let I := ⌊36 * τ - D⌋ + have hh : 2 * h = 1 := productHalf_spec hm + have hi (P : Finset (Finset (H54.Role × ProductGrid m j))) (hP : IsPack P) : + ∑ S ∈ P, w B S ≤ I := by + apply Int.le_floor.mpr + have hdef := H54.core_integer_defect_six h hh A R 1 (by dsimp [R]; positivity) (by norm_num) + (productPotential ε m j) (fun _ ha => product_potential_bounds hε hε₁ ha) + (fun a b c ha hb hc hab he => product_potential_midpoint hm hε hε₁ ha hc hb hab he) hP + change D ≤ 36 * τ - ∑ S ∈ P, (w B S : ℝ) at hdef + push_cast + linarith only [hdef] + obtain ⟨y, hy, hsmall, hscore⟩ := H54.core_fractional_score_small h hh A + obtain ⟨V, fV, dV, G, hcard, hs, hconn, hcuts, hgap⟩ := realize I hi hy hsmall + rw [hscore] at hgap + have hfloor : (I : ℝ) ≤ 36 * τ - D := Int.floor_le _ + have hD : D ≤ loss G := by linarith only [hgap,hfloor] + refine ⟨V, fV, dV, G, hcard, hs, hconn, hcuts, ?_⟩ + have hgrid : Fintype.card (ProductGrid m j) = (m ^ 2) ^ j := by simp [ZMod.card,pow_two] + have hnume : τ = ((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j := by + dsimp [τ,A] + rw [productSupport_card, hgrid] + push_cast + rfl + have hden : 27 * (1 + 2 * R / 1) = 27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2) := by + dsimp [R] + ring + simpa only [D, hnume, hden] using hD + +theorem finite_gap_of_product_with {ε : ℝ} {m j n d : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (realize : ∀ (I : ℤ) {y : Finset (H54.Role × ProductGrid m j) → ℝ}, + (∀ P : Finset (Finset (H54.Role × ProductGrid m j)), IsPack P → + ∑ S ∈ P, w (H54.coreGraph (productHalf m j) (productSupport ε m j)) S ≤ I) → + ResPack y → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G d ∧ + (∑ Q, y Q * (w (H54.coreGraph (productHalf m j) (productSupport ε m j)) Q : ℝ)) - + (I : ℝ) ≤ gap G) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G d ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + exact finite_gap_of_product_for hε hε₁ hm gap (fun I _ hi hy _ => realize I hi hy) + +theorem finite_gap_of_product_robust {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (hn : hostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((m^2)^j) ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + exact finite_gap_of_product_with hε hε₁ hm (fun I _ hi hy => robust_graph_from_EHPS_scores hm hn + I hi hy) + +/-- The host-count multiplier for the compact 6-class construction. -/ +def compactHostFactor (j : ℕ) := 255 + 2880 * j + +theorem compact_host_order (m j : ℕ) [NeZero m] : + Fintype.card ((H54.Role × ProductGrid m j) ⊕ + MidHost H54.Role (ProductGrid m j) (Option (CompactExterior.Label j))) = + compactHostFactor j * (m ^ 2) ^ j := by + have hc : Fintype.card (ProductGrid m j) = (m ^ 2) ^ j := by simp [ZMod.card, pow_two] + simp only [MidHost, Fintype.card_sum, Fintype.card_prod, hc, Sym2.card, + Fintype.card_fin, Fintype.card_option, compactHostFactor] + norm_num [Nat.choose_two_right] + ring + +theorem finite_gap_of_product_compact {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (hn : compactHostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((m^2)^j) ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + classical + exact finite_gap_of_product_with hε hε₁ hm fun I _ hi hy => + robust_graph_from_EHPS_scores_with hm (CompactExterior.colour hm hε) + (fun _ _ ha hb hc => CompactExterior.mid_outside hm hε ha hb hc) + ((compact_host_order m j).trans_le hn) I hi hy + +/-- The host-count multiplier including the extra labels for linear cut survival. -/ +def linearHostFactor (j : ℕ) := 25 * compactHostFactor j + +theorem finite_gap_of_product_linear_mixed {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) (hn₀ : 100 ≤ n) + (hn : linearHostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((n+4)/5) ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gapWithFracFour G := by + classical + let R := ProductGrid m j + let T := H54.Role × R + let H := MidHost H54.Role R (Option (CompactExterior.Label j)) + let χ := CompactExterior.colour hm hε (j := j) + let h := productHalf m j + let A := productSupport ε m j + let x := (n+4)/5 + have hx : 0 < x := by dsimp [x]; omega + have base := midpoint_host_hyp H54.roleGraph (H54.roleStep h) A h (H54.roleStep_swap h) + (productHalf_spec hm) χ (fun _ _ ha hb hc => CompactExterior.mid_outside hm hε ha hb hc) + have hbase : 25 * Fintype.card (T ⊕ H) ≤ n := by + simpa only [T, R, H, compact_host_order, linearHostFactor, Nat.mul_assoc] using hn + have hcore : Fintype.card T ≤ Fintype.card (T ⊕ H) := by simp + have hbudget : Fintype.card (T ⊕ H) + x + Fintype.card (Fin 3) * (Fintype.card T + x) ≤ n := by + simp only [Fintype.card_fin] + dsimp [x] + omega + have proper (u v : T) (he : (H54.coreGraph h A).Adj u v) : u.1.1 ≠ v.1.1 := by + exact H54.core_is_tripartite h A he + apply finite_gap_of_product_for hε hε₁ hm gapWithFracFour + intro I y hi hy hsmall + obtain ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,_,hmixed⟩ := + universal_graph_of_host_scores_with_support base (fun u : T => u.1.1) 0 proper hx hbudget I hi + hy + exact ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,hmixed hsmall⟩ + +theorem finite_gap_of_product_linear {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) (hn₀ : 100 ≤ n) + (hn : linearHostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((n+4)/5) ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + obtain ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,hgap⟩ := + finite_gap_of_product_linear_mixed hε hε₁ hm hn₀ hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,hgap.trans (gapWithFracFour_le_gap G)⟩ + +theorem finite_gap_of_product_six {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (hn : hostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + obtain ⟨V,fV,dV,G,hcard,hs,hconn,_,hg⟩ := finite_gap_of_product_robust hε hε₁ hm hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hg⟩ + +theorem finite_gap_of_product {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) + (hn : hostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + ((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + obtain ⟨V,fV,dV,G,hcard,hs,hconn,hgap⟩ := finite_gap_of_product_six hε hε₁ hm hn + refine ⟨V,fV,dV,G,hcard,hs,hconn,le_trans ?_ hgap⟩ + apply div_le_div_of_nonneg_right _ (by positivity) + linarith only [show 0 ≤ ((gridSupport ε m).card : ℝ)^j * ((m : ℝ)^2)^j by positivity] + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/GroupedGap.lean b/LeanPool/SplitCliqueGap/R434/GroupedGap.lean new file mode 100644 index 0000000000..e5df44d727 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/GroupedGap.lean @@ -0,0 +1,55 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.GroupedHosts +public import LeanPool.SplitCliqueGap.R434.FiniteR434 +import Mathlib.Tactic.Ring + +/-! Transfer with compressed role matchings and the compact exterior coloring. -/ + +@[expose] public section +namespace GapExtremal.R434.EHPS +open Finset + +/-- The host-count multiplier for the grouped assignment construction. -/ +def groupedHostFactor (j : ℕ) := 81 + 288 * j + +theorem grouped_host_order (m j : ℕ) [NeZero m] : + Fintype.card ((H54.Role × ProductGrid m j) ⊕ + H54.GroupedHost (ProductGrid m j) (CompactExterior.Label j)) = + groupedHostFactor j * (m ^ 2) ^ j := by + have hc : Fintype.card (ProductGrid m j) = (m ^ 2) ^ j := by simp [ZMod.card, pow_two] + simp only [H54.GroupedHost, Fintype.card_sum, Fintype.card_prod, hc, Fintype.card_fin, + H54.missing_role_count, groupedHostFactor] + ring + +theorem finite_gap_of_product_grouped {ε : ℝ} {m j n : ℕ} [NeZero m] + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hm : Odd m) (hj : 1 ≤ j) (hn₀ : 0 < n) + (hn : groupedHostFactor j * (m ^ 2) ^ j ≤ n) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G 0 ∧ + 6 * (((gridSupport ε m).card : ℝ) ^ j * ((m : ℝ) ^ 2) ^ j) / + (27 * (1 + 200 / ε ^ 2 * (j : ℝ) * (m : ℝ) ^ 2)) ≤ gap G := by + classical + let fallback : CompactExterior.Label j := (⟨0,by omega⟩,0,0,0) + let χ (a : ProductGrid m j) := (CompactExterior.colour hm hε a).getD fallback + have hχ (a b : ProductGrid m j) (ha : a ∉ productSupport ε m j) + (hb : b ∉ productSupport ε m j) (hc : χ a = χ b) : + productHalf m j * (a+b) ∉ productSupport ε m j := by + apply CompactExterior.mid_outside hm hε ha hb + simp only [CompactExterior.colour, dite_eq_left ha, dite_eq_left hb, Option.some.injEq] + simpa only [χ, CompactExterior.colour, dite_eq_left ha, dite_eq_left hb, Option.getD_some] + using hc + have base := H54.grouped_host_hyp (productHalf m j) (productSupport ε m j) + (productHalf_spec hm) χ hχ + exact finite_gap_of_product_with hε hε₁ hm fun I _ hi hy => by + obtain ⟨V,fV,dV,G,hcard,hs,hconn,hgap⟩ := + exact_graph_of_host_scores base ((0,0),0) n ((grouped_host_order m j).trans_le hn) I hi hy + exact ⟨V,fV,dV,G,hcard,hs,hconn,⟨hcard ▸ hn₀,fun _ hd => (Nat.not_lt_zero _ hd).elim⟩,hgap⟩ + +end GapExtremal.R434.EHPS diff --git a/LeanPool/SplitCliqueGap/R434/GroupedHosts.lean b/LeanPool/SplitCliqueGap/R434/GroupedHosts.lean new file mode 100644 index 0000000000..f4c1c75678 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/GroupedHosts.lean @@ -0,0 +1,269 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.RoleMatchings +public import Mathlib.Data.Sym.Card +import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.NormNum + +/-! Shared midpoint hosts for a matching of role pairs in one bipartite layer. -/ + +@[expose] public section +namespace GapExtremal.R434.H54 +open Finset + +/-- An edge is indexed with its lower color first. -/ +def orderedIndex (a b : Role) : Edge := + if a.1 < b.1 then (edgeKind a.1 b.1, a.2, b.2) + else (edgeKind b.1 a.1, b.2, a.2) + +/-- The edge kind and matching colour for a pair of roles. -/ +def matchingClass (a b : Role) : Fin 3 × Fin 4 := + let e := orderedIndex a b + (e.1, edgeColour e.1 e.2.1 e.2.2) + +private theorem matchingClass_of_order {a b : Role} (h : a.1 < b.1) : + matchingClass a b = (edgeKind a.1 b.1, edgeColour (edgeKind a.1 b.1) a.2 b.2) := by + simp only [matchingClass, orderedIndex, ite_eq_left h] + +theorem matchingClass_symm : ∀ a b : Role, + roleGraph.Adj a b → matchingClass a b = matchingClass b a := by + intro a b hab + change orderedAdj a b ∨ orderedAdj b a at hab + rcases hab with h | h + · simp only [matchingClass, orderedIndex, ite_eq_left h.1, ite_eq_right (not_lt_of_gt h.1)] + · simp only [matchingClass, orderedIndex, ite_eq_left h.1, ite_eq_right (not_lt_of_gt h.1)] + +theorem matchingClass_parts : ∀ a b : Role, roleGraph.Adj a b → + let k := (matchingClass a b).1 + (a.1 = lowerPart k ∧ b.1 = upperPart k) ∨ (a.1 = upperPart k ∧ b.1 = lowerPart k) := by + intro a b hab + dsimp only + change orderedAdj a b ∨ orderedAdj b a at hab + rcases hab with h | h + · rw [matchingClass_of_order h.1] + exact Or.inl ⟨(parts_of_order h.1).1.symm, (parts_of_order h.1).2.symm⟩ + · rw [matchingClass_symm a b (Or.inr h), matchingClass_of_order h.1] + exact Or.inr ⟨(parts_of_order h.1).2.symm, (parts_of_order h.1).1.symm⟩ + +theorem matchingClass_partner : ∀ a b c : Role, roleGraph.Adj a b → roleGraph.Adj a c → + matchingClass a b = matchingClass a c → b = c := by + intro a b c hab hac heq + have forward : ∀ {x y z : Role}, orderedAdj x y → orderedAdj x z → + matchingClass x y = matchingClass x z → y = z := by + intro x y z hxy hxz he + rw [matchingClass_of_order hxy.1, matchingClass_of_order hxz.1] at he + have hk := congrArg Prod.fst he + have hcolor := congrArg Prod.snd he + dsimp only at hk hcolor + rw [← hk] at hcolor + have hmem := hxz.2 + rw [← hk] at hmem + exact Prod.ext ((parts_of_order hxy.1).2.symm.trans + (hk.symm ▸ (parts_of_order hxz.1).2)) + (edgeColour_left _ _ _ _ hxy.2 hmem hcolor) + have reverse : ∀ {x y z : Role}, orderedAdj y x → orderedAdj z x → + matchingClass y x = matchingClass z x → y = z := by + intro x y z hyx hzx he + rw [matchingClass_of_order hyx.1, matchingClass_of_order hzx.1] at he + have hk := congrArg Prod.fst he + have hcolor := congrArg Prod.snd he + dsimp only at hk hcolor + rw [← hk] at hcolor + have hmem := hzx.2 + rw [← hk] at hmem + exact Prod.ext ((parts_of_order hyx.1).1.symm.trans + (hk.symm ▸ (parts_of_order hzx.1).1)) + (edgeColour_right _ _ _ _ hyx.2 hmem hcolor) + have incompatible : ∀ {x y z : Role}, orderedAdj x y → orderedAdj z x → + matchingClass x y ≠ matchingClass z x := by + intro x y z hxy hzx he + rw [matchingClass_of_order hxy.1, matchingClass_of_order hzx.1] at he + have hk := congrArg Prod.fst he + dsimp only at hk + exact (part_lt (edgeKind x.1 y.1)).ne + ((parts_of_order hxy.1).1.trans (hk.symm ▸ (parts_of_order hzx.1).2.symm)) + change orderedAdj a b ∨ orderedAdj b a at hab + change orderedAdj a c ∨ orderedAdj c a at hac + rcases hab with hab | hab <;> rcases hac with hac | hac + · exact forward hab hac heq + · rw [matchingClass_symm a c (Or.inr hac)] at heq + exact (incompatible hab hac heq).elim + · rw [matchingClass_symm a b (Or.inr hab)] at heq + exact (incompatible hac hab heq.symm).elim + · rw [matchingClass_symm a b (Or.inr hab), matchingClass_symm a c (Or.inr hac)] at heq + exact reverse hab hac heq + +/-- An unordered pair of roles that is absent from the template edge set. -/ +abbrev MissingRolePair := {p : Sym2 Role // p ∉ roleGraph.edgeSet} + +noncomputable instance : Fintype MissingRolePair := Fintype.ofFinite _ + +private def rolePair (e : Edge) : Sym2 Role := + s((lowerPart e.1, e.2.1), (upperPart e.1, e.2.2)) + +private theorem rolePair_injective : Function.Injective rolePair := by + intro ⟨k,a,b⟩ ⟨l,c,d⟩ he + rcases Sym2.eq_iff.mp he with ⟨ha,hb⟩ | ⟨ha,hb⟩ + · have hlo : lowerPart k = lowerPart l := congrArg Prod.fst ha + have hup : upperPart k = upperPart l := congrArg Prod.fst hb + have hk : k = l := by + rw [← kind_of_parts k, ← kind_of_parts l, hlo, hup] + have ha' : a = c := congrArg Prod.snd ha + have hb' : b = d := congrArg Prod.snd hb + subst l + subst c + subst d + rfl + · have hlo : lowerPart k = upperPart l := congrArg Prod.fst ha + have hup : upperPart k = lowerPart l := congrArg Prod.fst hb + have hlt := part_lt k + rw [hlo, hup] at hlt + exact ((part_lt l).asymm hlt).elim + +private theorem role_edgeFinset : roleGraph.edgeFinset = edges.image rolePair := by + classical + ext p + refine p.inductionOn (fun a b => ?_) + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] + constructor + · intro hab + have ordered (u v : Role) (hlt : u.1 < v.1) (hmem : (edgeKind u.1 v.1,u.2,v.2) ∈ edges) : + s(u,v) ∈ edges.image rolePair := by + have hparts := parts_of_order hlt + exact mem_image.mpr ⟨_,hmem, by + simp [rolePair, hparts.1, hparts.2]⟩ + change orderedAdj a b ∨ orderedAdj b a at hab + rcases hab with hab | hab + · exact ordered a b hab.1 hab.2 + · rw [Sym2.eq_swap] + exact ordered b a hab.1 hab.2 + · intro hp + obtain ⟨e,he,heq⟩ := mem_image.mp hp + have hadj : roleGraph.Adj (lowerPart e.1,e.2.1) (upperPart e.1,e.2.2) := by + rw [roleGraph_ordered (part_lt e.1)] + simpa [kind_of_parts] using he + have hm : rolePair e ∈ roleGraph.edgeSet := hadj + exact (SimpleGraph.mem_edgeSet (G := roleGraph)).mp (heq ▸ hm) + +theorem missing_role_count : Fintype.card MissingRolePair = 66 := by + have h : Fintype.card roleGraph.edgeSet = 54 := by + rw [← SimpleGraph.edgeFinset_card, role_edgeFinset, card_image_of_injective _ + rolePair_injective, + edge_count] + rw [Fintype.card_subtype_compl (fun p => p ∈ roleGraph.edgeSet), h, Sym2.card] + norm_num [Role, Nat.choose_two_right] + +section +variable {R C : Type} [Fintype R] [DecidableEq R] [CommRing R] +variable (h : R) + +/-- A grouped host index consisting of a role-pair label and an affine coordinate. -/ +abbrev GroupedHost (R C : Type) := (MissingRolePair ⊕ ((Fin 3 × Fin 4) × C)) × R + +/-- For a geometric role edge use a matching label. For any other pair keep its role type. -/ +def groupedAssign (χ : R → C) (x y : Role × R) : GroupedHost R C := + (if ha : roleGraph.Adj x.1 y.1 then .inr (matchingClass x.1 y.1, χ (pairDirection (roleStep h) x + y)) + else .inl ⟨s(x.1,y.1),fun hp => ha hp⟩, h * (x.2 + y.2)) + +omit [DecidableEq R] [Fintype R] in +theorem groupedAssign_symm (χ : R → C) (x y : Role × R) : + groupedAssign h χ x y = groupedAssign h χ y x := by + have ha : roleGraph.Adj y.1 x.1 ↔ roleGraph.Adj x.1 y.1 := ⟨fun h => h.symm, fun h => h.symm⟩ + by_cases hp : roleGraph.Adj x.1 y.1 + · simp [groupedAssign, ha, hp, matchingClass_symm _ _ hp, + pairDirection_swap _ (roleStep_swap h), add_comm y.2 x.2] + · simp [groupedAssign, ha, hp, Sym2.eq_swap (a := y.1), add_comm y.2 x.2] + +/-- The vertices assigned to the given grouped host. -/ +noncomputable def groupedPalette (A : Finset R) (χ : R → C) (k : GroupedHost R C) : + Finset (Role × R) := by + classical + exact univ.filter fun x => ∃ y, x ≠ y ∧ ¬ (directionCore roleGraph (roleStep h) A (roleStep_swap + h)).Adj x y ∧ + groupedAssign h χ x y = k + +private theorem cross_colours {a a' b b' : Role} + (ha : roleGraph.Adj a a') (hb : roleGraph.Adj b b') (hab : roleGraph.Adj a b) + (eq : matchingClass a a' = matchingClass b b') : a.1 = b'.1 ∧ a'.1 = b.1 := by + have hne : a.1 ≠ b.1 := by + change orderedAdj a b ∨ orderedAdj b a at hab + exact hab.elim (fun hu => ne_of_lt hu.1) (fun hv => ne_of_gt hv.1) + have h₁ := matchingClass_parts _ _ ha + have h₂ := matchingClass_parts _ _ hb + rw [← eq] at h₂ + rcases h₁ with ⟨h₁,h₁'⟩ | ⟨h₁,h₁'⟩ <;> + rcases h₂ with ⟨h₂,h₂'⟩ | ⟨h₂,h₂'⟩ + · exact False.elim (hne (h₁.trans h₂.symm)) + · exact ⟨h₁.trans h₂'.symm,h₁'.trans h₂.symm⟩ + · exact ⟨h₁.trans h₂'.symm,h₁'.trans h₂.symm⟩ + · exact False.elim (hne (h₁.trans h₂.symm)) + +omit [DecidableEq R] in +theorem grouped_host_hyp (A : Finset R) (hh : 2 * h = 1) (χ : R → C) + (hχ : ∀ a b, a ∉ A → b ∉ A → χ a = χ b → h * (a + b) ∉ A) : + HostHyp (directionCore roleGraph (roleStep h) A (roleStep_swap h)) + (groupedPalette h A χ) (groupedAssign h χ) := by + classical + constructor + · intro k x hx y hy hxy + obtain ⟨x', _, ha, hk⟩ := (mem_filter.mp hx).2 + obtain ⟨y', _, hb, hk'⟩ := (mem_filter.mp hy).2 + have eq := hk.trans hk'.symm + have sameMid := congrArg Prod.snd eq + change h * (x.2 + x'.2) = h * (y.2 + y'.2) at sameMid + have groups := congrArg Prod.fst eq + change roleGraph.Adj x.1 y.1 ∧ pairDirection (roleStep h) x y ∈ A at hxy + by_cases hp : roleGraph.Adj x.1 x'.1 <;> by_cases hq : roleGraph.Adj y.1 y'.1 + · simp only [groupedAssign, dite_eq_left hp, dite_eq_left hq, Sum.inr.injEq, Prod.mk.injEq] + at groups + obtain ⟨hclass,hcolour⟩ := groups + obtain ⟨hfirst,hsecond⟩ := cross_colours hp hq hxy.1 hclass + have s₁ : roleStep h x.1 x'.1 = roleStep h x.1 y.1 := by unfold roleStep; rw [hsecond] + have s₂ : roleStep h y.1 y'.1 = -roleStep h x.1 y.1 := by + rw [← roleStep_swap]; unfold roleStep; rw [hfirst] + have hm := congrArg (fun t : R => 2 * t) sameMid + simp only [← mul_assoc, hh, one_mul] at hm + have cross : pairDirection (roleStep h) x y = + h * (pairDirection (roleStep h) x x' + pairDirection (roleStep h) y y') := by + unfold pairDirection + rw [s₁,s₂] + calc + _ = (2 * h) * (roleStep h x.1 y.1 * (y.2-x.2)) := by rw [hh,one_mul] + _ = _ := by linear_combination -(h * roleStep h x.1 y.1) * hm + exact hχ _ _ (fun ht => ha ⟨hp,ht⟩) (fun ht => hb ⟨hq,ht⟩) hcolour (cross ▸ hxy.2) + · simp [groupedAssign, hp, hq] at groups + · simp [groupedAssign, hp, hq] at groups + · simp only [groupedAssign, dite_eq_right hp, dite_eq_right hq, Sum.inl.injEq, + Subtype.mk.injEq] at groups + rcases Sym2.eq_iff.mp groups with ⟨hr,_⟩ | ⟨_,hr⟩ + · exact roleGraph.loopless.irrefl _ (hr ▸ hxy.1) + · exact hp (hr.symm ▸ hxy.1) + · intro x y hne hno + exact ⟨mem_filter.mpr ⟨mem_univ _, y, hne, hno, rfl⟩, + mem_filter.mpr ⟨mem_univ _, x, hne.symm, fun hh => hno hh.symm, groupedAssign_symm h χ y x⟩⟩ + · exact groupedAssign_symm h χ + · intro x y y' _ _ _ _ eq + have groups := congrArg Prod.fst eq + have hr : y.1 = y'.1 := by + by_cases hp : roleGraph.Adj x.1 y.1 <;> by_cases hq : roleGraph.Adj x.1 y'.1 + · simp only [groupedAssign, dite_eq_left hp, dite_eq_left hq, Sum.inr.injEq, Prod.mk.injEq] + at groups + exact matchingClass_partner _ _ _ hp hq groups.1 + · simp [groupedAssign, hp, hq] at groups + · simp [groupedAssign, hp, hq] at groups + · simp only [groupedAssign, dite_eq_right hp, dite_eq_right hq, Sum.inl.injEq, + Subtype.mk.injEq] at groups + rcases Sym2.eq_iff.mp groups with ⟨_,he⟩ | ⟨he₁,he₂⟩ + · exact he + · exact he₂.trans he₁ + exact Prod.ext hr (midpoint_partner_unique h x.2 y.2 y'.2 hh (congrArg Prod.snd eq)) + +end +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/LocalH54.lean b/LeanPool/SplitCliqueGap/R434/LocalH54.lean new file mode 100644 index 0000000000..22515e67c0 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/LocalH54.lean @@ -0,0 +1,170 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Algebra.BigOperators.Group.Finset.Basic +public import Mathlib.Data.Fintype.Prod +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.Order.Ring.Int + +/-! The R419 fractional witness and the R433 exposing dual for H54. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434.H54 + +/-- The three local indices of a candidate triangle, in part order. -/ +abbrev Triangle := Fin 5 × Fin 5 × Fin 5 +/-- The edge kind and two local endpoint indices. -/ +abbrev Edge := Fin 3 × Fin 5 × Fin 5 + +/-- The seven triangles removed from the tripartite template. -/ +def deleted : List Triangle := + [(2, 2, 2), (1, 2, 1), (3, 1, 4), (0, 3, 1), (0, 4, 0), (2, 3, 0), (4, 0, 3)] + +/-- Edge indices 0, 1 and 2 refer to the pairs of parts 01, 12 and 02. -/ +def onEdge (t : Triangle) (e : Edge) : Bool := + if e.1 = 0 then decide (e.2 = (t.1, t.2.1)) + else if e.1 = 1 then decide (e.2 = (t.2.1, t.2.2)) + else decide (e.2 = (t.1, t.2.2)) + +/-- Template edges left after removing the edges of the deleted triangles. -/ +def edges : Finset Edge := + univ.filter fun e => !deleted.any (onEdge · e) + +/-- The triangles supported by the remaining template edges. -/ +def triangles : Finset Triangle := + univ.filter fun t => + (0, t.1, t.2.1) ∈ edges ∧ (1, t.2.1, t.2.2) ∈ edges ∧ (2, t.1, t.2.2) ∈ edges + +/-- The support of the explicit fractional triangle packing. -/ +def support : Finset Triangle := + {(0,0,2),(0,0,4),(0,1,2),(0,1,3),(0,2,3),(0,2,4), + (1,0,0),(1,0,2),(1,1,0),(1,1,2),(1,3,3),(1,3,4),(1,4,3),(1,4,4), + (2,0,1),(2,0,4),(2,1,1),(2,1,3),(2,4,3),(2,4,4), + (3,0,0),(3,0,1),(3,2,0),(3,2,3),(3,3,2),(3,3,3),(3,4,1),(3,4,2), + (4,1,0),(4,1,1),(4,2,0),(4,2,4),(4,3,2),(4,3,4),(4,4,1),(4,4,2)} + +/-- The integer edge price in the finite dual certificate. -/ +def price (e : Edge) : ℤ := + match e.1.val, e.2.1.val, e.2.2.val with + | 0,0,2 => 3 + | 0,2,4 => 1 + | 0,3,0 => 1 + | 0,3,3 => -2 + | 0,3,4 => -1 + | 0,4,1 => 1 + | 0,4,3 => -2 + | 0,4,4 => -1 + | 1,0,0 => -1 + | 1,0,4 => 1 + | 1,1,0 => -1 + | 1,1,3 => 1 + | 1,2,3 => -2 + | 1,2,4 => -2 + | 1,3,2 => 2 + | 1,4,1 => 2 + | 1,4,2 => 1 + | 2,0,3 => -1 + | 2,0,4 => -1 + | 2,1,0 => 1 + | 2,2,3 => -1 + | 2,2,4 => -1 + | 2,3,1 => -1 + | 2,3,3 => 2 + | 2,4,1 => -1 + | 2,4,4 => 2 + | _,_,_ => 0 + +/-- The total assigned weight of triangles meeting a given edge. -/ +def load (S : Finset Triangle) (x : Triangle → ℤ) (e : Edge) : ℤ := + ∑ t ∈ S.filter (onEdge · e), x t + +/-- The total certificate price of the edges of a triangle. -/ +def triPrice (t : Triangle) : ℤ := + ∑ e ∈ edges.filter (fun e => onEdge t e), price e + +theorem edge_count : edges.card = 54 := by decide +kernel +theorem triangle_count : triangles.card = 45 := by decide +kernel +theorem support_count : support.card = 36 := by decide +kernel +theorem support_valid : support ⊆ triangles := by decide +kernel +theorem balanced_edge_counts : ∀ i : Fin 3, (edges.filter (fun e => e.1 = i)).card = 18 := by + decide +kernel + +theorem twice_on_each_edge : ∀ e : Edge, e ∈ edges → + (support.filter (onEdge · e)).card = 2 := by decide +kernel + +theorem price_sum : ∑ e ∈ edges, price e = 0 := by decide +kernel + +theorem price_support : ∀ t : Triangle, t ∈ triangles → + 0 ≤ triPrice t ∧ (t ∉ support → 0 < triPrice t) := by decide +kernel + +theorem support_price_zero : ∀ t : Triangle, t ∈ support → triPrice t = 0 := by + decide +kernel + +theorem no_integral_cover (x : Triangle → ℤ) + (hn : ∀ t ∈ triangles, 0 ≤ x t) + (hc : ∀ e ∈ edges, load triangles x e = 1) : False := by + classical + have exchange : + ∑ t ∈ triangles, x t * triPrice t = ∑ e ∈ edges, price e * load triangles x e := by + simp only [triPrice, load, sum_filter, Finset.mul_sum, mul_ite, mul_zero] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e he + apply Finset.sum_congr rfl + intro t ht + split <;> simp [*, mul_comm] + have hzero : ∑ t ∈ triangles, x t * triPrice t = 0 := by + rw [exchange, ← price_sum] + apply Finset.sum_congr rfl + intro e he + rw [hc e he, mul_one] + have hx : ∀ t ∈ triangles, t ∉ support → x t = 0 := by + intro t ht hs + have hnon : ∀ u ∈ triangles, 0 ≤ x u * triPrice u := + fun u hu => mul_nonneg (hn u hu) (price_support u hu).1 + have hle : x t * triPrice t ≤ 0 := + hzero ▸ Finset.single_le_sum (f := fun u => x u * triPrice u) hnon ht + exact le_antisymm (nonpos_of_mul_nonpos_left hle ((price_support t ht).2 hs)) (hn t ht) + have hs : ∀ e ∈ edges, load support x e = 1 := by + intro e he + rw [← hc e he] + unfold load + apply Finset.sum_subset (Finset.filter_subset_filter _ support_valid) + intro t ht hnot + rw [Finset.mem_filter] at ht + exact hx t ht.1 fun h => hnot (Finset.mem_filter.mpr ⟨h, ht.2⟩) + have h1 := hs (1,2,3) (by decide +kernel) + have h2 := hs (0,0,2) (by decide +kernel) + have h3 := hs (2,0,4) (by decide +kernel) + have h4 := hs (0,0,0) (by decide +kernel) + have h5 := hs (1,0,2) (by decide +kernel) + have h6 := hs (0,1,0) (by decide +kernel) + have h7 := hs (1,0,0) (by decide +kernel) + have h8 := hs (2,3,0) (by decide +kernel) + have h9 := hs (0,3,2) (by decide +kernel) + have pair_sum (e : Edge) (a b : Triangle) (hab : a ≠ b) + (hpair : support.filter (onEdge · e) = {a, b}) (h : load support x e = 1) : + x a + x b = 1 := by + unfold load at h + rwa [hpair, Finset.sum_pair hab] at h + have p1 := pair_sum (1,2,3) (3,2,3) (0,2,3) (by decide) (by decide +kernel) h1 + have p2 := pair_sum (0,0,2) (0,2,3) (0,2,4) (by decide) (by decide +kernel) h2 + have p3 := pair_sum (2,0,4) (0,2,4) (0,0,4) (by decide) (by decide +kernel) h3 + have p4 := pair_sum (0,0,0) (0,0,4) (0,0,2) (by decide) (by decide +kernel) h4 + have p5 := pair_sum (1,0,2) (0,0,2) (1,0,2) (by decide) (by decide +kernel) h5 + have p6 := pair_sum (0,1,0) (1,0,2) (1,0,0) (by decide) (by decide +kernel) h6 + have p7 := pair_sum (1,0,0) (1,0,0) (3,0,0) (by decide) (by decide +kernel) h7 + have p8 := pair_sum (2,3,0) (3,0,0) (3,2,0) (by decide) (by decide +kernel) h8 + have p9 := pair_sum (0,3,2) (3,2,0) (3,2,3) (by decide) (by decide +kernel) h9 + omega + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/LocalPacking.lean b/LeanPool/SplitCliqueGap/R434/LocalPacking.lean new file mode 100644 index 0000000000..7caeba956a --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/LocalPacking.lean @@ -0,0 +1,148 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.LocalTriangleLift +import Mathlib.Tactic.ByContra +import Mathlib.Tactic.Choose +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Linarith + +/-! One uncovered pair of each color type would itself be a triangle. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434.H54 + +private def layer (i : Fin 3) := edges.filter fun e => e.1 = i + +private theorem in_layer {t : Triangle} (ht : t ∈ triangles) (i : Fin 3) : + onTriangleIndex t i ∈ layer i := by + obtain ⟨_,h0,h1,h2⟩ := mem_filter.mp ht + apply mem_filter.mpr + refine ⟨?_, onTriangleIndex_kind t i⟩ + fin_cases i <;> assumption + +/-- The three coordinates telescope around a triangle. The base five records +each role separately when a single edge is missing from each layer. -/ +private def boundary (e : Edge) : ℤ := + let a : ℤ := e.2.1.val + let b : ℤ := e.2.2.val + if e.1 = 0 then 25*a + 5*b else if e.1 = 1 then b-5*a else -25*a-b + +private theorem layer_balance : + (∑ e ∈ layer 0, boundary e) + (∑ e ∈ layer 1, boundary e) + + (∑ e ∈ layer 2, boundary e) = 0 := by decide +kernel + +private theorem triangle_balance (t : Triangle) : + boundary (onTriangleIndex t 0) + boundary (onTriangleIndex t 1) + + boundary (onTriangleIndex t 2) = 0 := by + simp [boundary,onTriangleIndex] + +private theorem impossible_full (S : Finset Triangle) (hs : S ⊆ triangles) + (hi : ∀ i : Fin 3, Set.InjOn (fun t => onTriangleIndex t i) S) + (hfull : ∀ i, S.image (fun t => onTriangleIndex t i) = layer i) : False := by + classical + apply no_integral_cover (fun t => if t ∈ S then 1 else 0) (by intro t _; split <;> decide) + intro e he + have hm : e ∈ S.image (fun t => onTriangleIndex t e.1) := by + rw [hfull]; exact mem_filter.mpr ⟨he,rfl⟩ + obtain ⟨t,ht,hidx⟩ := mem_image.mp hm + have ht' : t ∈ triangles.filter (onEdge · e) := mem_filter.mpr + ⟨hs ht, (onEdge_iff_index t e).mpr hidx.symm⟩ + unfold load + rw [sum_eq_single t] + · simp [ht] + · intro u hu hne + have hu' : u ∉ S := fun huS => hne (hi e.1 huS ht + (((onEdge_iff_index u e).mp (mem_filter.mp hu).2).symm.trans hidx.symm)) + simp [hu'] + · exact fun hn => (hn ht').elim + +theorem local_packing_le_sixteen (S : Finset Triangle) (hs : S ⊆ triangles) + (hi : ∀ i : Fin 3, Set.InjOn (fun t => onTriangleIndex t i) S) : S.card ≤ 16 := by + classical + let P (i : Fin 3) := S.image fun t => onTriangleIndex t i + have hsub (i) : P i ⊆ layer i := by + rintro _ he + obtain ⟨t,ht,rfl⟩ := mem_image.mp he + exact in_layer (hs ht) i + have hcard (i) : (P i).card = S.card := card_image_of_injOn (hi i) + have hsize (i) : (layer i).card = 18 := balanced_edge_counts i + have hle := card_le_card (hsub 0) + rw [hcard, hsize] at hle + by_contra! hn + by_cases h18 : S.card = 18 + · exact impossible_full S hs hi (fun i => eq_of_subset_of_card_le (hsub i) + (by rw [hsize,hcard,h18])) + have hmiss (i) : ∃ e, layer i \ P i = {e} := by + apply card_eq_one.mp + rw [card_sdiff_of_subset (hsub i), hsize, hcard] + omega + choose e he using hmiss + have hem (i) : e i ∈ layer i ∧ e i ∉ P i := mem_sdiff.mp (he i ▸ mem_singleton_self _) + have hsum (i) : (∑ k ∈ layer i, boundary k) = + (∑ t ∈ S, boundary (onTriangleIndex t i)) + boundary (e i) := by + have h := sum_sdiff (f := boundary) (hsub i) + rw [he, sum_singleton] at h + dsimp [P] at h + rw [sum_image (hi i)] at h + linarith + have hbal := layer_balance + rw [hsum 0, hsum 1, hsum 2] at hbal + have hs0 : (∑ t ∈ S, boundary (onTriangleIndex t 0)) + + (∑ t ∈ S, boundary (onTriangleIndex t 1)) + + (∑ t ∈ S, boundary (onTriangleIndex t 2)) = 0 := by + rw [← sum_add_distrib, ← sum_add_distrib] + simp only [triangle_balance, sum_const_zero] + have he0 : boundary (e 0) + boundary (e 1) + boundary (e 2) = 0 := by linarith + have hk (i) : (e i).1 = i := (mem_filter.mp (hem i).1).2 + let t : Triangle := ((e 0).2.1, (e 0).2.2, (e 1).2.2) + have hroles : (e 0).2.1 = (e 2).2.1 ∧ (e 0).2.2 = (e 1).2.1 ∧ (e 1).2.2 = (e 2).2.2 := by + simp [boundary,hk] at he0 + have hv (i : Fin 3) : (e i).2.1.val < 5 ∧ (e i).2.2.val < 5 := + ⟨(e i).2.1.isLt, (e i).2.2.isLt⟩ + obtain ⟨_,_⟩ := hv 0 + obtain ⟨_,_⟩ := hv 1 + obtain ⟨_,_⟩ := hv 2 + constructor + · apply Fin.ext; omega + constructor <;> apply Fin.ext <;> omega + have hidx (i : Fin 3) : onTriangleIndex t i = e i := by + apply Prod.ext + · exact (onTriangleIndex_kind ..).trans (hk i).symm + · fin_cases i <;> apply Prod.ext <;> first | rfl | exact hroles.1 | exact hroles.2.1 | + exact hroles.2.2 + have hin (i) : onTriangleIndex t i ∈ edges := by rw [hidx]; exact (mem_filter.mp (hem i).1).1 + have ht : t ∈ triangles := mem_filter.mpr ⟨mem_univ _, hin 0, hin 1, hin 2⟩ + have hnew (i) (v) (hv : v ∈ S) : onTriangleIndex v i ≠ onTriangleIndex t i := by + rw [hidx]; exact fun h => (hem i).2 (mem_image.mpr ⟨v,hv,h⟩) + apply impossible_full (insert t S) (insert_subset ht hs) + · intro i u hu v hv heq + rcases mem_insert.mp hu with rfl | hu <;> rcases mem_insert.mp hv with rfl | hv + · rfl + · exact False.elim (hnew i v hv heq.symm) + · exact False.elim (hnew i u hu heq) + · exact hi i hu hv heq + · intro i + rw [image_insert, hidx] + change insert (e i) (P i) = layer i + rw [← singleton_union, ← he, sdiff_union_of_subset (hsub i)] + +theorem packing_of_sixteen : ∃ S : Finset Triangle, S ⊆ triangles ∧ S.card = 16 ∧ + ∀ i : Fin 3, Set.InjOn (fun t => onTriangleIndex t i) S := by + let S : Finset Triangle := + {(0,0,4),(0,1,2),(0,2,3),(1,0,0),(1,1,3),(1,3,4),(1,4,2),(2,0,1), + (2,4,3),(3,0,2),(3,2,0),(3,3,3),(3,4,1),(4,1,0),(4,3,2),(4,4,4)} + refine ⟨S, by decide +kernel, by decide +kernel, ?_⟩ + have h : ∀ i : Fin 3, ∀ t ∈ S, ∀ u ∈ S, + onTriangleIndex t i = onTriangleIndex u i → t = u := by decide +kernel + exact fun i t ht u hu => h i t ht u hu + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/LocalTriangleLift.lean b/LeanPool/SplitCliqueGap/R434/LocalTriangleLift.lean new file mode 100644 index 0000000000..b6fa23a4c0 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/LocalTriangleLift.lean @@ -0,0 +1,113 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.CoreDirections +public import LeanPool.SplitCliqueGap.R434.TightTriangles +import Mathlib.Tactic.FinCases + +/-! Lifting the H54 triangle incidence table to the affine core. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434.H54 + +variable {R : Type} [Fintype R] [DecidableEq R] [CommRing R] + +/-- The ordered vertices of a template triangle lifted into an affine block. -/ +def blockTriangle (a x : R) (t : Triangle) : OrderedTriangle (Role × R) := + (affineVertex a x (0,t.1), affineVertex a x (1,t.2.1), affineVertex a x (2,t.2.2)) + +/-- The template edge of the specified kind in a triangle. -/ +def onTriangleIndex (t : Triangle) (k : Fin 3) : Edge := + if k = 0 then (0,t.1,t.2.1) else if k = 1 then (1,t.2.1,t.2.2) else (2,t.1,t.2.2) + +theorem onTriangleIndex_kind (t : Triangle) (k : Fin 3) : (onTriangleIndex t k).1 = k := by + fin_cases k <;> rfl + +theorem onEdge_iff_index (t : Triangle) (e : Edge) : + onEdge t e ↔ e = onTriangleIndex t e.1 := by + obtain ⟨k, i, j⟩ := e + fin_cases k <;> simp [onEdge, onTriangleIndex] + +omit [Fintype R] in +theorem triangleEdges_block (a x : R) (t : Triangle) : + triangleEdges (blockTriangle a x t) = + univ.image (fun k => blockEdge a x (onTriangleIndex t k)) := by + ext y + simp only [triangleEdges, mem_insert, mem_singleton, mem_image, mem_univ, true_and] + constructor + · rintro (hy | hy | hy) + · exact ⟨0, hy.symm⟩ + · exact ⟨1, hy.symm⟩ + · exact ⟨2, hy.symm⟩ + · rintro ⟨k,hk⟩ + fin_cases k + · exact Or.inl hk.symm + · exact Or.inr (Or.inl hk.symm) + · exact Or.inr (Or.inr hk.symm) + +omit [Fintype R] in +theorem blockEdge_mem_blockTriangle (h : R) (hh : 2 * h = 1) + {a x b y : R} {t : Triangle} {e : Edge} : + blockEdge b y e ∈ triangleEdges (blockTriangle a x t) ↔ + b = a ∧ y = x ∧ onEdge t e := by + rw [triangleEdges_block] + constructor + · intro hmem + obtain ⟨k, _, hk⟩ := mem_image.mp hmem + have hei : (a,x,onTriangleIndex t k) = (b,y,e) := blockEdge_injective h hh hk + have hdir : a = b := congrArg Prod.fst hei + have hx : x = y := congrArg (fun z : R × R × Edge => z.2.1) hei + have he : onTriangleIndex t k = e := congrArg (fun z : R × R × Edge => z.2.2) hei + have hkind : k = e.1 := (onTriangleIndex_kind t k).symm.trans (congrArg Prod.fst he) + exact ⟨hdir.symm, hx.symm, (onEdge_iff_index t e).mpr (hkind ▸ he.symm)⟩ + · rintro ⟨rfl,rfl,he⟩ + exact mem_image.mpr ⟨e.1, mem_univ _, congrArg (blockEdge b y) ((onEdge_iff_index t e).mp + he).symm⟩ + +omit [DecidableEq R] [Fintype R] in +theorem blockTriangle_injective (h : R) (hh : 2 * h = 1) : + Function.Injective (fun z : R × R × Triangle => blockTriangle z.1 z.2.1 z.2.2) := by + intro ⟨a,x,t⟩ ⟨b,y,s⟩ he + have h₂ : blockEdge a x (0,t.1,t.2.1) = blockEdge b y (0,s.1,s.2.1) := + congrArg (fun z : OrderedTriangle (Role × R) => s(z.1,z.2.1)) he + have ei : ((a,x,(0,t.1,t.2.1)) : R × R × Edge) = (b,y,(0,s.1,s.2.1)) := + blockEdge_injective h hh h₂ + have ha : a = b := congrArg Prod.fst ei + have hx : x = y := congrArg (fun z : R × R × Edge => z.2.1) ei + have hfst : t.1 = s.1 := congrArg (fun z : R × R × Edge => z.2.2.2.1) ei + have hmid : t.2.1 = s.2.1 := congrArg (fun z : R × R × Edge => z.2.2.2.2) ei + have hlast : t.2.2 = s.2.2 := congrArg (fun z : OrderedTriangle (Role × R) => z.2.2.1.2) he + exact Prod.ext ha (Prod.ext hx (Prod.ext hfst (Prod.ext hmid hlast))) + +omit [DecidableEq R] [Fintype R] in +theorem short_directions_eq_of_blockTriangle (h : R) (hh : 2 * h = 1) + (a x : R) (t : Triangle) : + let u := blockTriangle a x t + pairDirection (roleStep h) u.1 u.2.1 = pairDirection (roleStep h) u.2.1 u.2.2 := by + dsimp only [blockTriangle] + rw [edge_direction h hh (show (0 : Fin 3) < 1 by decide), + edge_direction h hh (show (1 : Fin 3) < 2 by decide)] + +omit [DecidableEq R] [Fintype R] in +theorem is_blockTriangle_of_local (h : R) {T : OrderedTriangle (Role × R)} + (hc : T.1.1.1 = 0 ∧ T.2.1.1.1 = 1 ∧ T.2.2.1.1 = 2) + (hloc : pairDirection (roleStep h) T.1 T.2.1 = pairDirection (roleStep h) T.2.1 T.2.2) : + ∃ a x, ∃ t : Triangle, blockTriangle a x t = T := by + obtain ⟨a,x,_,hu,hv,hw⟩ := local_vertices_of_short_directions h hc.1 hc.2.1 hc.2.2 hloc + let t : Triangle := (T.1.1.2,T.2.1.1.2,T.2.2.1.2) + have h₁ : ((0,t.1) : Role) = T.1.1 := Prod.ext hc.1.symm rfl + have h₂ : ((1,t.2.1) : Role) = T.2.1.1 := Prod.ext hc.2.1.symm rfl + have h₃ : ((2,t.2.2) : Role) = T.2.2.1 := Prod.ext hc.2.2.symm rfl + refine ⟨a,x,t,?_⟩ + unfold blockTriangle + rw [h₁,h₂,h₃,hu,hv,hw] + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/MidpointHosts.lean b/LeanPool/SplitCliqueGap/R434/MidpointHosts.lean new file mode 100644 index 0000000000..1c5897ca1b --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/MidpointHosts.lean @@ -0,0 +1,133 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.ExactGraphTransfer +public import LeanPool.SplitCliqueGap.R434.OddMidpoints +public import Mathlib.Data.Sym.Sym2 +public import Mathlib.Tactic.LinearCombination +import Mathlib.Tactic.Ring + +/-! Midpoint palettes on a core with translation-invariant role directions. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +section + +variable {L R C : Type} [Fintype L] [DecidableEq L] [Fintype R] [DecidableEq R] +variable [CommRing R] [DecidableEq C] + +variable (H : SimpleGraph L) [DecidableRel H.Adj] (step : L → L → R) +variable (A : Finset R) (h : R) + +/-- The direction of an ordered vertex pair after applying the role-dependent step. -/ +def pairDirection (x y : L × R) : R := step x.1 y.1 * (y.2 - x.2) + +omit [DecidableEq L] [DecidableEq R] [Fintype L] [Fintype R] in +theorem pairDirection_swap (hs : ∀ i j, step j i = -step i j) + (x y : L × R) : pairDirection step y x = pairDirection step x y := by + unfold pairDirection + rw [hs] + ring + +/-- The graph whose edges have adjacent roles and an allowed direction. -/ +def directionCore (hs : ∀ i j, step j i = -step i j) : SimpleGraph (L × R) where + Adj x y := H.Adj x.1 y.1 ∧ pairDirection step x y ∈ A + symm := ⟨by + intro x y hp + exact ⟨hp.1.symm, (pairDirection_swap step hs x y).symm ▸ hp.2⟩⟩ + loopless := ⟨fun _ hp => H.loopless.irrefl _ hp.1⟩ + +instance directionCoreDecidable (hs : ∀ i j, step j i = -step i j) : + DecidableRel (directionCore H step A hs).Adj := + fun x y => inferInstanceAs (Decidable (H.Adj x.1 y.1 ∧ pairDirection step x y ∈ A)) + +/-- A host label consisting of a role pair, a midpoint, and an optional colour. -/ +abbrev MidHost (L R C : Type) := Sym2 L × R × Option C + +/-- The host index for a pair of vertices, determined by its roles and midpoint. -/ +def midAssign (χ : R → C) (x y : L × R) : MidHost L R C := + (s(x.1,y.1), h * (x.2 + y.2), + if H.Adj x.1 y.1 then some (χ (pairDirection step x y)) else none) + +omit [DecidableEq C] [DecidableEq L] [DecidableEq R] [Fintype L] [Fintype R] in +theorem midAssign_swap (hs : ∀ i j, step j i = -step i j) (χ : R → C) + (x y : L × R) : midAssign H step h χ x y = midAssign H step h χ y x := by + have hAdj : H.Adj y.1 x.1 ↔ H.Adj x.1 y.1 := ⟨fun ha => ha.symm, fun ha => ha.symm⟩ + simp only [midAssign, ← Sym2.eq_swap (a := x.1) (b := y.1), hAdj, + pairDirection_swap step hs x y, add_comm y.2 x.2] + +/-- The finite palette of vertices admitted by the given midpoint host. -/ +noncomputable def midPalette (hs : ∀ i j, step j i = -step i j) (χ : R → C) + (k : MidHost L R C) : Finset (L × R) := by + classical + exact univ.filter fun x => ∃ y, x ≠ y ∧ ¬ (directionCore H step A hs).Adj x y ∧ + midAssign H step h χ x y = k + +omit [DecidableEq L] [DecidableEq R] [Fintype L] [Fintype R] in +theorem direction_of_cross_fibre (hs : ∀ i j, step j i = -step i j) (hh : 2 * h = 1) + (x x' y y' : L × R) (hr : x.1 = y'.1) (hs' : x'.1 = y.1) + (hm : h * (x.2 + x'.2) = h * (y.2 + y'.2)) : + pairDirection step x y = h * (pairDirection step x x' + pairDirection step y y') := by + have hsum := congrArg (fun u : R => 2 * u) hm + simp only [← mul_assoc, hh, one_mul] at hsum + unfold pairDirection + rw [hs', ← hr, hs x.1 y.1] + calc + _ = (2 * h) * (step x.1 y.1 * (y.2 - x.2)) := by rw [hh, one_mul] + _ = _ := by linear_combination -(h * step x.1 y.1) * hsum + +theorem midpoint_host_hyp (hs : ∀ i j, step j i = -step i j) (hh : 2 * h = 1) + (χ : R → C) + (hχ : ∀ a b, a ∉ A → b ∉ A → χ a = χ b → h * (a + b) ∉ A) : + HostHyp (directionCore H step A hs) (midPalette H step A h hs χ) + (midAssign H step h χ) := by + classical + constructor + · intro k x hx y hy hxy + change H.Adj x.1 y.1 ∧ pairDirection step x y ∈ A at hxy + change x ∈ univ.filter _ at hx + change y ∈ univ.filter _ at hy + obtain ⟨x', _, hxx, hxk⟩ := (Finset.mem_filter.mp hx).2 + obtain ⟨y', _, hyy, hyk⟩ := (Finset.mem_filter.mp hy).2 + have heq := hxk.trans hyk.symm + have hroles : s(x.1,x'.1) = s(y.1,y'.1) := congrArg Prod.fst heq + rcases Sym2.eq_iff.mp hroles with ⟨he, _⟩ | ⟨hr, hs'⟩ + · exact H.loopless.irrefl _ (he ▸ hxy.1) + · have h₁ : H.Adj x.1 x'.1 := hs'.symm ▸ hxy.1 + have h₂ : H.Adj y.1 y'.1 := hr ▸ hxy.1.symm + have hcolor : χ (pairDirection step x x') = χ (pairDirection step y y') := by + have hc := congrArg (fun u : MidHost L R C => u.2.2) heq + simpa only [midAssign, ite_eq_left h₁, ite_eq_left h₂, Option.some.injEq] using hc + have hbad₁ : pairDirection step x x' ∉ A := fun ha => hxx ⟨h₁, ha⟩ + have hbad₂ : pairDirection step y y' ∉ A := fun ha => hyy ⟨h₂, ha⟩ + apply hχ _ _ hbad₁ hbad₂ hcolor + rw [← direction_of_cross_fibre step h hs hh x x' y y' hr hs'] + · exact hxy.2 + · exact congrArg (fun u : MidHost L R C => u.2.1) heq + · intro x y hne hxy + constructor + · exact Finset.mem_filter.mpr ⟨mem_univ _, y, hne, hxy, rfl⟩ + · exact Finset.mem_filter.mpr ⟨mem_univ _, x, hne.symm, fun h' => hxy h'.symm, + midAssign_swap H step h hs χ y x⟩ + · exact midAssign_swap H step h hs χ + · intro x y y' _ _ _ _ heq + have hroles : s(x.1,y.1) = s(x.1,y'.1) := congrArg Prod.fst heq + have hr : y.1 = y'.1 := by + rcases Sym2.eq_iff.mp hroles with ⟨_, hh'⟩ | ⟨h₁,h₂⟩ + · exact hh' + · exact h₂.trans h₁ + exact Prod.ext hr (midpoint_partner_unique h x.2 y.2 y'.2 hh + (congrArg (fun u : MidHost L R C => u.2.1) heq)) + +end + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/OddMidpoints.lean b/LeanPool/SplitCliqueGap/R434/OddMidpoints.lean new file mode 100644 index 0000000000..a1c99b6e8d --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/OddMidpoints.lean @@ -0,0 +1,64 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Data.ZMod.Basic +public import Mathlib.Tactic.Ring +import Mathlib.Tactic.Push + +/-! # Midpoints on odd residue spaces -/ + +@[expose] public section + +namespace GapExtremal.R434 + +/-- The inverse of two in the cyclic ring when its modulus is odd. -/ +def oddHalf (m : ℕ) : ZMod m := (((m + 1) / 2 : ℕ) : ZMod m) + +theorem two_mul_oddHalf {m : ℕ} (hm : Odd m) : (2 : ZMod m) * oddHalf m = 1 := by + obtain ⟨k, hk⟩ := hm + have hN : 2 * ((m + 1) / 2) = m + 1 := by omega + have hM := congrArg (fun n : ℕ => (n : ZMod m)) hN + push_cast at hM + simpa [oddHalf] using hM + +/-- With equal parities, integer and modular midpoints coincide. -/ +theorem natCast_midpoint {m a b : ℕ} (hm : Odd m) (hab : a % 2 = b % 2) : + oddHalf m * ((a : ZMod m) + (b : ZMod m)) = (((a + b) / 2 : ℕ) : ZMod m) := by + have hN : 2 * ((a + b) / 2) = a + b := by omega + have hM := congrArg (fun n : ℕ => (n : ZMod m)) hN + push_cast at hM + rw [← hM] + calc + oddHalf m * (2 * (((a + b) / 2 : ℕ) : ZMod m)) = + (2 * oddHalf m) * (((a + b) / 2 : ℕ) : ZMod m) := by ring + _ = _ := by rw [two_mul_oddHalf hm, one_mul] + +section Positions + +variable {R : Type*} [CommRing R] + +theorem triangle_directions (h x y z : R) (hh : 2 * h = 1) : + (y - x) + (z - y) = 2 * (h * (z - x)) := by + rw [← mul_assoc, hh, one_mul] + ring + +theorem palette_direction (h d invD c u v : R) (hd : invD * d = 1) : + invD * ((c + d * h * v) - (c - d * h * u)) = h * (u + v) := by + calc + _ = (invD * d) * (h * (u + v)) := by ring + _ = _ := by rw [hd, one_mul] + +theorem midpoint_partner_unique (h x y y' : R) (hh : 2 * h = 1) + (hc : h * (x + y) = h * (x + y')) : y = y' := by + have htwo := congrArg (fun b : R => 2 * b) hc + simp only [← mul_assoc, hh, one_mul] at htwo + exact add_left_cancel htwo + +end Positions + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/PackingTriangles.lean b/LeanPool/SplitCliqueGap/R434/PackingTriangles.lean new file mode 100644 index 0000000000..297fe11ba6 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/PackingTriangles.lean @@ -0,0 +1,178 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.TightTriangles +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! A residual packing leaves a triangle partition and a charged remainder. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434 + +variable {V : Type} [Fintype V] [DecidableEq V] +variable (B : SimpleGraph V) [DecidableRel B.Adj] + +/-- The difference between two thirds of the edge count and the score of a piece. -/ +noncomputable def pieceSlack (Q : Finset V) : ℝ := + 2 * (e B Q : ℝ) / 3 - (w B Q : ℝ) + +theorem pieceSlack_formula (Q : Finset V) : + pieceSlack B Q = (Q.card.choose 2 : ℝ) + 1 - 4 * (e B Q : ℝ) / 3 := by + unfold pieceSlack w + push_cast + ring + +theorem packing_to_triangles (c : V → Fin 3) (hc : ∀ ⦃x y⦄, B.Adj x y → c x ≠ c y) + {P : Finset (Finset V)} (hP : IsPack P) : + ∃ (T : Finset (OrderedTriangle V)) (X : Finset (Sym2 V)), + (∀ t ∈ T, c t.1 = 0 ∧ c t.2.1 = 1 ∧ c t.2.2 = 2) ∧ + (T : Set (OrderedTriangle V)).PairwiseDisjoint triangleEdges ∧ + X ∪ T.biUnion triangleEdges = B.edgeFinset ∧ + Disjoint X (T.biUnion triangleEdges) ∧ + (X.card : ℝ) ≤ 27 * (2 * (B.edgeFinset.card : ℝ) / 3 - ∑ Q ∈ P, (w B Q : ℝ)) := by + classical + let E (Q : Finset V) := (inducedOn B Q).edgeFinset + let P' := P.filter fun Q => 2 ≤ Q.card + let Z := P'.filter fun Q => pieceSlack B Q = 0 + let W := P'.filter fun Q => pieceSlack B Q ≠ 0 + have hP' : P' ⊆ P := filter_subset _ _ + have hZ : Z ⊆ P' := filter_subset _ _ + have hW : W ⊆ P' := filter_subset _ _ + have hE : (P : Set (Finset V)).PairwiseDisjoint E := induced_edges_disjoint_of_pack B hP + have hEB (Q : Finset V) : E Q ⊆ B.edgeFinset := by + intro f hf + induction f using Sym2.inductionOn with + | _ x y => + have h : B.Adj x y ∧ x ∈ Q ∧ y ∈ Q := SimpleGraph.mem_edgeFinset.mp hf + exact SimpleGraph.mem_edgeFinset.mpr h.1 + have hs (Q : Finset V) (hQ : Q ∈ P') : + 0 ≤ pieceSlack B Q ∧ + (pieceSlack B Q = 0 → (Q.card = 3 ∧ e B Q = 3) ∨ (Q.card = 6 ∧ e B Q = 12)) ∧ + (pieceSlack B Q ≠ 0 → (e B Q : ℝ) ≤ 27 * pieceSlack B Q) := by + rw [pieceSlack_formula] + exact slack_of_tripartite_counts _ _ (mem_filter.mp hQ).2 (tripartite_edge_bound B c hc Q) + have hdecomp (Q : Finset V) (hQ : Q ∈ Z) : + ∃ T : Finset (OrderedTriangle V), + (∀ t ∈ T, c t.1 = 0 ∧ c t.2.1 = 1 ∧ c t.2.2 = 2) ∧ + (T : Set (OrderedTriangle V)).PairwiseDisjoint triangleEdges ∧ T.biUnion triangleEdges + = E Q := by + obtain ⟨hQP, hz⟩ := mem_filter.mp hQ + have hs' := (hs Q hQP).2.1 hz + have ht : 3 * e B Q = Q.card ^ 2 := by rcases hs' with ⟨hv,he⟩ | ⟨hv,he⟩ <;> simp [hv,he] + have hcard : Q.card / 3 ≠ 0 := by rcases hs' with ⟨hv,_⟩ | ⟨hv,_⟩ <;> simp [hv] + let _ : NeZero (Q.card / 3) := ⟨hcard⟩ + obtain ⟨hparts, hcomplete⟩ := tight_tripartite B c hc Q ht + refine triangulate_uniform_piece B c hc Q (Q.card / 3) (fun i => ?_) hcomplete + have := hparts i + omega + let F (Q : Finset V) : Finset (OrderedTriangle V) := + if h : Q ∈ Z then (hdecomp Q h).choose else ∅ + have hF (Q : Finset V) (hQ : Q ∈ Z) : + (∀ t ∈ F Q, c t.1 = 0 ∧ c t.2.1 = 1 ∧ c t.2.2 = 2) ∧ + (F Q : Set (OrderedTriangle V)).PairwiseDisjoint triangleEdges ∧ + (F Q).biUnion triangleEdges = E Q := by + simpa only [F, dite_eq_left hQ] using (hdecomp Q hQ).choose_spec + let T := Z.biUnion F + let U := Z.biUnion E + let D := P'.biUnion E + let X := B.edgeFinset \ U + have hUD : U ⊆ D := by + intro f hf + obtain ⟨Q, hQ, he⟩ := mem_biUnion.mp hf + exact mem_biUnion.mpr ⟨Q, hZ hQ, he⟩ + have hDB : D ⊆ B.edgeFinset := by + intro f hf + obtain ⟨Q, _, he⟩ := mem_biUnion.mp hf + exact hEB Q he + have hTU : T.biUnion triangleEdges = U := by + ext f + simp only [T, U, mem_biUnion] + constructor + · rintro ⟨t, ⟨Q,hQ,ht⟩, hf⟩ + exact ⟨Q, hQ, (hF Q hQ).2.2 ▸ mem_biUnion.mpr ⟨t, ht, hf⟩⟩ + · rintro ⟨Q, hQ, hf⟩ + rw [← (hF Q hQ).2.2] at hf + obtain ⟨t, ht, hf⟩ := mem_biUnion.mp hf + exact ⟨t, ⟨Q,hQ,ht⟩, hf⟩ + have hdisj : (T : Set (OrderedTriangle V)).PairwiseDisjoint triangleEdges := by + intro t ht u hu htu + obtain ⟨Q, hQ, ht⟩ := mem_biUnion.mp ht + obtain ⟨Q', hQ', hu⟩ := mem_biUnion.mp hu + by_cases h : Q = Q' + · subst Q' + exact (hF Q hQ).2.1 ht hu htu + · have hsub (t : OrderedTriangle V) (Q : Finset V) (hQ : Q ∈ Z) (ht : t ∈ F Q) : + triangleEdges t ⊆ E Q := + fun _ he => (hF Q hQ).2.2 ▸ mem_biUnion.mpr ⟨t, ht, he⟩ + exact Disjoint.mono (hsub _ _ hQ ht) (hsub _ _ hQ' hu) + (hE (hP' (hZ hQ)) (hP' (hZ hQ')) h) + refine ⟨T,X,?_,hdisj,?_,?_,?_⟩ + · intro t ht + obtain ⟨Q,hQ,ht⟩ := mem_biUnion.mp ht + exact (hF Q hQ).1 t ht + · rw [hTU] + exact sdiff_union_of_subset (hUD.trans hDB) + · rw [hTU] + exact disjoint_sdiff_self_left + have hD : D.card = ∑ Q ∈ P', e B Q := + card_biUnion (fun _ hq _ hr hn => hE (hP' hq) (hP' hr) hn) + have hU : U.card = ∑ Q ∈ Z, e B Q := + card_biUnion (fun _ hq _ hr hn => hE (hP' (hZ hq)) (hP' (hZ hr)) hn) + have hparts : (∑ Q ∈ Z, e B Q) + ∑ Q ∈ W, e B Q = ∑ Q ∈ P', e B Q := + sum_filter_add_sum_filter_not P' (fun Q => pieceSlack B Q = 0) (e B) + have hX : X.card + U.card = B.edgeFinset.card := by + have hr := card_union_of_disjoint (s := X) (t := U) disjoint_sdiff_self_left + rw [sdiff_union_of_subset (hUD.trans hDB)] at hr + exact hr.symm + have hXC : (X.card : ℝ) = (B.edgeFinset.card : ℝ) - D.card + ∑ Q ∈ W, (e B Q : ℝ) := by + have hsum : (D.card : ℝ) = U.card + ∑ Q ∈ W, (e B Q : ℝ) := by + rw [hD,hU] + exact_mod_cast hparts.symm + have hcast : (X.card : ℝ) + U.card = B.edgeFinset.card := by exact_mod_cast hX + linarith only [hsum, hcast] + have hWsum : ∑ Q ∈ W, (e B Q : ℝ) ≤ 27 * ∑ Q ∈ P', pieceSlack B Q := by + rw [Finset.mul_sum] + calc + _ ≤ ∑ Q ∈ W, 27 * pieceSlack B Q := + sum_le_sum fun Q hQ => (hs Q (hW hQ)).2.2 (mem_filter.mp hQ).2 + _ ≤ _ := sum_le_sum_of_subset_of_nonneg hW + fun Q hQ _ => mul_nonneg (by norm_num) (hs Q hQ).1 + have hnon : (D.card : ℝ) ≤ B.edgeFinset.card := by exact_mod_cast card_le_card hDB + have hscore : ∑ Q ∈ P, (w B Q : ℝ) ≤ ∑ Q ∈ P', (w B Q : ℝ) := by + let P'' := P.filter fun Q => ¬2 ≤ Q.card + have hsplit : (∑ Q ∈ P', (w B Q : ℝ)) + ∑ Q ∈ P'', (w B Q : ℝ) = + ∑ Q ∈ P, (w B Q : ℝ) := sum_filter_add_sum_filter_not P _ _ + have hnonpos : ∑ Q ∈ P'', (w B Q : ℝ) ≤ 0 := by + apply sum_nonpos + intro Q hQ + have hv : Q.card ≤ 1 := by + have hh := (mem_filter.mp hQ).2 + omega + have he0 : e B Q = 0 := by + have hh := tripartite_edge_bound B c hc Q + have hsq : Q.card ^ 2 ≤ 1 := by simpa using Nat.pow_le_pow_left hv 2 + omega + have hchoose : Q.card.choose 2 = 0 := Nat.choose_eq_zero_of_lt (by omega) + simp [w, he0, hchoose] + linarith only [hsplit, hnonpos] + have hloss : ∑ Q ∈ P', pieceSlack B Q = + 2 * (D.card : ℝ) / 3 - ∑ Q ∈ P', (w B Q : ℝ) := by + simp only [pieceSlack, sum_sub_distrib, div_eq_mul_inv, ← sum_mul, ← mul_sum] + congr 1 + have hd : (D.card : ℝ) = ∑ Q ∈ P', (e B Q : ℝ) := by exact_mod_cast hD + rw [hd] + linarith only [hXC,hWsum,hnon,hscore,hloss] + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/PartitionEnergy.lean b/LeanPool/SplitCliqueGap/R434/PartitionEnergy.lean new file mode 100644 index 0000000000..6e0baf0e1d --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/PartitionEnergy.lean @@ -0,0 +1,80 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.ResidualArithmetic +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum + +/-! Energy and owner counts for a set of edge-disjoint triangles. -/ + +@[expose] public section + +open Finset +open scoped BigOperators + +namespace GapExtremal.R434 + +variable {E T K : Type} [DecidableEq E] [DecidableEq K] + +theorem edge_partition_gap_of_count (B X : Finset E) (P Z : Finset T) + (edges : T → Finset E) (mass : ℕ) + (price : E → ℝ) (R δ loss : ℝ) (hR : 0 ≤ R) (hδ : 0 < δ) + (hpart : X ∪ P.biUnion edges = B) (hdisj : Disjoint X (P.biUnion edges)) + (hpack : (P : Set T).PairwiseDisjoint edges) (hZ : Z ⊆ P) + (hcard : mass ≤ X.card + 3 * Z.card) + (htotal : ∑ e ∈ B, price e = 0) + (hprice : ∀ e ∈ X, -(2 * R / 3) ≤ price e) + (hzero : ∀ t ∈ P, t ∉ Z → ∑ e ∈ edges t, price e = 0) + (hmixed : ∀ t ∈ Z, δ ≤ ∑ e ∈ edges t, price e) + (hslack : (X.card : ℝ) ≤ 27 * loss) : + (mass : ℝ) / (27 * (1 + 2 * R / δ)) ≤ loss := by + have hZsum : ∑ t ∈ Z, ∑ e ∈ edges t, price e = + ∑ t ∈ P, ∑ e ∈ edges t, price e := + sum_subset hZ hzero + have hbalance : + 0 = (∑ e ∈ X, price e) + ∑ t ∈ Z, ∑ e ∈ edges t, price e := by + rw [hZsum, ← sum_biUnion hpack, ← sum_union hdisj, hpart, htotal] + have hx : -(2 * R / 3) * (X.card : ℝ) ≤ ∑ e ∈ X, price e := by + calc + _ = ∑ _e ∈ X, -(2 * R / 3) := by simp [mul_comm] + _ ≤ _ := sum_le_sum hprice + have hz : δ * (Z.card : ℝ) ≤ ∑ t ∈ Z, ∑ e ∈ edges t, price e := by + calc + _ = ∑ _t ∈ Z, δ := by simp [mul_comm] + _ ≤ _ := sum_le_sum hmixed + apply signed_gap_of_budgets (mass : ℝ) (X.card : ℝ) (Z.card : ℝ) R δ loss hR hδ + · exact_mod_cast hcard + · linarith only [hbalance, hx, hz] + · exact hslack + +theorem edge_partition_gap (B X : Finset E) (P Z : Finset T) + (edges : T → Finset E) (owners : Finset K) (owner : E → K) + (price : E → ℝ) (R δ loss : ℝ) (hR : 0 ≤ R) (hδ : 0 < δ) + (hpart : X ∪ P.biUnion edges = B) (hdisj : Disjoint X (P.biUnion edges)) + (hpack : (P : Set T).PairwiseDisjoint edges) (hZ : Z ⊆ P) + (hsize : ∀ t ∈ Z, (edges t).card ≤ 3) + (hcover : owners ⊆ (X ∪ Z.biUnion edges).image owner) + (htotal : ∑ e ∈ B, price e = 0) + (hprice : ∀ e ∈ X, -(2 * R / 3) ≤ price e) + (hzero : ∀ t ∈ P, t ∉ Z → ∑ e ∈ edges t, price e = 0) + (hmixed : ∀ t ∈ Z, δ ≤ ∑ e ∈ edges t, price e) + (hslack : (X.card : ℝ) ≤ 27 * loss) : + (owners.card : ℝ) / (27 * (1 + 2 * R / δ)) ≤ loss := by + have hcard : owners.card ≤ X.card + 3 * Z.card := calc + owners.card ≤ ((X ∪ Z.biUnion edges).image owner).card := card_le_card hcover + _ ≤ (X ∪ Z.biUnion edges).card := card_image_le + _ ≤ X.card + (Z.biUnion edges).card := card_union_le _ _ + _ ≤ X.card + 3 * Z.card := by + have hz := card_biUnion_le_card_mul Z edges 3 hsize + omega + exact edge_partition_gap_of_count B X P Z edges owners.card price R δ loss hR hδ hpart + hdisj hpack hZ hcard htotal hprice hzero hmixed hslack + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/PolylogGap.lean b/LeanPool/SplitCliqueGap/R434/PolylogGap.lean new file mode 100644 index 0000000000..d226e472f9 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/PolylogGap.lean @@ -0,0 +1,219 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.UniversalR434 +public import LeanPool.SplitCliqueGap.R434.PolylogOrder +public import LeanPool.SplitCliqueGap.R434.GroupedGap +import Mathlib.Tactic.Convert +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! The endpoint coefficient with a logarithmic prefactor at every large order. -/ + +@[expose] public section + +namespace GapExtremal.R434 + +open Real EHPS + +/-- The coefficient in the polylogarithmic cut-survival estimate. -/ +noncomputable def connectivityConstant : ℝ := sqrt (log (24/7)) / (1050015 * exp 1) + +/-- The leading coefficient of the basic nearly quadratic gap bound. -/ +noncomputable def gapConstant : ℝ := 2 * orderAmplitude 1050015 (200*(1080/7)^2) (log (24/7)) + +private theorem universal_R434_with (H : ℕ → ℕ) (A : ℝ) (hA : 1 ≤ A) + (hH : ∀ j : ℕ, 1 ≤ j → 1 ≤ H j ∧ (H j : ℝ) ≤ A * (j : ℝ)) + (loss : ∀ {U : Type} [Fintype U] [DecidableEq U], SimpleGraph U → ℝ) + (cut : ℕ → ℕ → ℕ → ℕ) + (realize : ∀ {ε : ℝ} {m j n : ℕ} [NeZero m], 0 < ε → ε ≤ 1 → Odd m → + 1 ≤ j → 100 ≤ n → H j * (m^2)^j ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G (cut n m j) ∧ + 6 * (((gridSupport ε m).card : ℝ)^j * ((m : ℝ)^2)^j) / + (27 * (1 + 200 / ε^2 * (j : ℝ) * (m : ℝ)^2)) ≤ loss G) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + (∃ m j : ℕ, SurvivesCuts G (cut n m j) ∧ + sqrt (log (24/7)) / (A * exp 1) * n / sqrt (log n) ≤ (m : ℝ)^(2*j)) ∧ + 2 * orderAmplitude A (200*(1080/7)^2) (log (24/7)) * n^2 / + (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ loss G := by + let c := log (24/7) + have hc : 0 < c := log_pos (by norm_num) + obtain ⟨N,hN⟩ := joint_order_parameters H A (200*(1080/7)^2) c 24000 + hA (by norm_num) hc (by norm_num) hH + refine ⟨max N 100, fun n hn => ?_⟩ + have hn₀ : 100 ≤ n := (le_max_right _ _).trans hn + obtain ⟨m,j,hm,hod,hj,horder,hw,hconnect,hsize⟩ := hN n ((le_max_left _ _).trans hn) + have horder' : H j * (m^2)^j ≤ n := by simpa only [pow_mul] using horder + let : NeZero m := ⟨by omega⟩ + have hj1 : (1 : ℝ) ≤ j := by exact_mod_cast hj + have hjp : 0 < (j : ℝ) := by linarith + let ε := 7 / (1080*(j : ℝ)) + have he : 0 < ε := by dsimp [ε]; positivity + have hem : ε ≤ 7 / 1080 := by + dsimp [ε] + apply (div_le_div_iff₀ (by positivity) (by norm_num)).mpr + linarith + have hgrid := density_grid_uniform he (by linarith : 0 ≤ 1/12 - 3*ε) (m := m) + (by dsimp [ε]; field_simp; linarith only [hw]) + obtain ⟨V,fV,dV,G,hcard,hsplit,hconn,hcuts,hgap⟩ := + realize he (by linarith) hod hj hn₀ horder' + refine ⟨V,fV,dV,G,hcard,hsplit,hconn,⟨m,j,hcuts,hconnect⟩,?_⟩ + let ρ : ℝ := 7/24 + let u : ℝ := -(2/(3*(j : ℝ))) + have hu : -(2/3 : ℝ) ≤ u := by + apply neg_le_neg + apply (div_le_div_iff₀ (by positivity) (by norm_num)).mpr + linarith + have hb := one_add_mul_le_pow (show -2 ≤ u by linarith) j + have hju : (j : ℝ)*u = -(2/3 : ℝ) := by dsimp [u]; field_simp + have hb' : 1/3 ≤ (1+u)^j := by linarith only [hb,hju] + have hd : ρ*(1+u) ≤ 7/24-30*ε := by dsimp [ρ,u,ε]; field_simp; linarith + have hbase : 0 ≤ ρ*(1+u)*(m : ℝ)^2 := by + apply mul_nonneg _ (sq_nonneg _) + exact mul_nonneg (by norm_num [ρ]) (by linarith) + have hp := pow_le_pow_left₀ hbase ((mul_le_mul_of_nonneg_right hd (sq_nonneg _)).trans hgrid) j + have hρ : ρ^j = exp (-c*(j : ℝ)) := by + have hr : ρ = exp (-c) := by rw [exp_neg, exp_log (by norm_num : (0 : ℝ) < 24/7)]; norm_num [ρ] + rw [hr, ← exp_nat_mul, mul_comm] + rw [mul_pow, mul_pow, hρ] at hp + have hnum : exp (-c*(j : ℝ)) / 3 * (m : ℝ)^(4*j) ≤ + ((gridSupport ε m).card : ℝ)^j * ((m : ℝ)^2)^j := by + have hb'' := mul_le_mul_of_nonneg_left hb' (exp_pos (-c*(j : ℝ))).le + have hjj : (m : ℝ)^(4*j) = ((m : ℝ)^2)^j * ((m : ℝ)^2)^j := by + rw [← pow_add, ← pow_mul]; congr 1; omega + rw [hjj] + have h := mul_le_mul_of_nonneg_right hb'' (show 0 ≤ ((m : ℝ)^2)^j by positivity) + have h' := mul_le_mul_of_nonneg_right (h.trans hp) (show 0 ≤ ((m : ℝ)^2)^j by positivity) + linarith only [h'] + have hd' : 200/ε^2*(j : ℝ) = (200*(1080/7)^2)*(j : ℝ)^3 := by dsimp [ε]; field_simp + rw [hd'] at hgap + have hfin := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hnum (by norm_num : (0 : ℝ) + ≤ 6)) + (show 0 ≤ 27*(1+200*(1080/7)^2*(j : ℝ)^3*(m : ℝ)^2) by positivity) + change _ ≤ loss G + have hs := (mul_le_mul_of_nonneg_right hsize (by norm_num : (0 : ℝ) ≤ 2)) + change 2 * orderAmplitude A (200*(1080/7)^2) (log (24/7)) * _ / _ * _ ≤ _ + dsimp only [c] at hs hfin hgap ⊢ + convert hs.trans (le_trans (le_of_eq ?_) (hfin.trans hgap)) using 1 <;> ring + + +theorem universal_R434_robust : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + (∃ d : ℕ, SurvivesCuts G d ∧ connectivityConstant * n / sqrt (log n) ≤ d) ∧ + gapConstant * n^2 / (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gap G := by + have hH (j : ℕ) (hj : 1 ≤ j) : 1 ≤ hostFactor j ∧ (hostFactor j : ℝ) ≤ 1050015*(j : ℝ) := by + have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj + unfold hostFactor + constructor + · omega + · push_cast + linarith + obtain ⟨N,hN⟩ := universal_R434_with hostFactor 1050015 (by norm_num) hH gap + (fun _ m j => (m^2)^j) + (fun he he₁ hm _ _ h => finite_gap_of_product_robust he he₁ hm h) + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,⟨m,j,hc,hb⟩,hg⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,⟨_,hc,by simpa only [connectivityConstant, Nat.cast_pow, + ← pow_mul, Nat.cast_ofNat] using hb⟩,hg⟩ + +theorem universal_R434_compact : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + (∃ d : ℕ, SurvivesCuts G d ∧ sqrt (log (24/7)) / (3135 * exp 1) * n / sqrt (log n) ≤ d) ∧ + 2 * orderAmplitude 3135 (200*(1080/7)^2) (log (24/7)) * n^2 / + (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gap G := by + have hH (j : ℕ) (hj : 1 ≤ j) : 1 ≤ compactHostFactor j ∧ (compactHostFactor j : ℝ) ≤ 3135*(j : + ℝ) := by + have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj + unfold compactHostFactor + constructor + · omega + · push_cast + linarith + obtain ⟨N,hN⟩ := universal_R434_with compactHostFactor 3135 (by norm_num) hH gap + (fun _ m j => (m^2)^j) (fun he he₁ hm _ _ h => finite_gap_of_product_compact he he₁ hm h) + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,⟨m,j,hc,hb⟩,hg⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,⟨_,hc,by simpa only [Nat.cast_pow, ← pow_mul, Nat.cast_ofNat] + using hb⟩,hg⟩ + +theorem universal_R434_linear_mixed : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + SurvivesCuts G ((n+4)/5) ∧ + 2 * orderAmplitude 78375 (200*(1080/7)^2) (log (24/7)) * n^2 / + (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gapWithFracFour G := by + have hH (j : ℕ) (hj : 1 ≤ j) : 1 ≤ linearHostFactor j ∧ (linearHostFactor j : ℝ) ≤ 78375*(j : ℝ) + := by + have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj + unfold linearHostFactor compactHostFactor + constructor + · omega + · push_cast + linarith + obtain ⟨N,hN⟩ := universal_R434_with linearHostFactor 78375 (by norm_num) hH gapWithFracFour + (fun n _ _ => (n+4)/5) + (fun he he₁ hm _ hn h => finite_gap_of_product_linear_mixed he he₁ hm hn h) + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,⟨m,j,hc,hb⟩,hg⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hc,hg⟩ + +theorem universal_R434_linear : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + SurvivesCuts G ((n+4)/5) ∧ + 2 * orderAmplitude 78375 (200*(1080/7)^2) (log (24/7)) * n^2 / + (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gap G := by + obtain ⟨N,hN⟩ := universal_R434_linear_mixed + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,hgap⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hcuts,hgap.trans (gapWithFracFour_le_gap G)⟩ + +theorem universal_R434_grouped : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + 2 * orderAmplitude 369 (200*(1080/7)^2) (log (24/7)) * n^2 / + (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gap G := by + have hH (j : ℕ) (hj : 1 ≤ j) : 1 ≤ groupedHostFactor j ∧ (groupedHostFactor j : ℝ) ≤ 369 * j := by + have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj + unfold groupedHostFactor + constructor + · omega + · push_cast + linarith + obtain ⟨N,hN⟩ := universal_R434_with groupedHostFactor 369 (by norm_num) hH gap + (fun _ _ _ => 0) (fun he he₁ hm hj hn h => finite_gap_of_product_grouped he he₁ hm hj (by + omega) h) + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,_,hg⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hg⟩ + +theorem universal_R434_polylog : + ∃ k : ℝ, 0 < k ∧ ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + k * n^2 / (log n)^(5/2 : ℝ) * exp (-2 * sqrt (log (24/7) * log n)) ≤ gap G := by + obtain ⟨N,hN⟩ := universal_R434_robust + refine ⟨gapConstant, by unfold gapConstant orderAmplitude; positivity, N, fun n hn => ?_⟩ + obtain ⟨V,fV,dV,G,hcard,hs,hconn,_,hg⟩ := hN n hn + exact ⟨V,fV,dV,G,hcard,hs,hconn,hg⟩ + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/PolylogOrder.lean b/LeanPool/SplitCliqueGap/R434/PolylogOrder.lean new file mode 100644 index 0000000000..a6451d4fa3 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/PolylogOrder.lean @@ -0,0 +1,113 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.UniformOrder +public import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! Quantitative rounding at the endpoint density. -/ + +@[expose] public section + +namespace GapExtremal.R434 + +open Real + +/-- The explicit amplitude from fitting the product order to the target order. -/ +noncomputable def orderAmplitude (A K c : ℝ) := + exp (-(2 * log A + 2 + 2*c + log (27*(1+K)) - (5/2)*log c)) + +theorem joint_order_parameters (H : ℕ → ℕ) (A K c W : ℝ) + (hA : 1 ≤ A) (hK : 0 ≤ K) (hc : 0 < c) (hW : 10 ≤ W) + (hH : ∀ j : ℕ, 1 ≤ j → 1 ≤ H j ∧ (H j : ℝ) ≤ A * (j : ℝ)) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∃ m j : ℕ, + 1 ≤ m ∧ Odd m ∧ 1 ≤ j ∧ H j * m ^ (2*j) ≤ n ∧ W/2*(j : ℝ) ≤ m ∧ + sqrt c / (A * exp 1) * n / sqrt (log n) ≤ (m : ℝ)^(2*j) ∧ + orderAmplitude A K c * n^2 / (log n)^(5/2 : ℝ) * exp (-2 * sqrt (c * log n)) ≤ + exp (-c * (j : ℝ)) * (m : ℝ)^(4*j) / + (27 * (1 + K * (j : ℝ)^3 * (m : ℝ)^2)) := by + let C := 27 * (1 + K) + have hC : 0 < C := by dsimp [C]; positivity + let b := 2 * log A + 2 + 2*c + log C - (5/2)*log c + obtain ⟨N,hN⟩ := rounded_order_witness H A c hA hc W hW 0 hH + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨m,j,hm,_,hod,hj,horder,hw,hnpos,ht,hjt,hL,hround,hshort⟩ := hN n hn + let t := sqrt (log n / c) + simp only [Nat.cast_zero, zero_add] at ht + change 2 ≤ t at ht + change (j : ℝ) ≤ t at hjt + change log n = c*t^2 at hL + change _ ≤ 2*(log A + log t + 1) at hround + change _ ≤ c*(t+2) at hshort + have htpos : 0 < t := by linarith + have hLpos : 0 < log n := hL ▸ by positivity + have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hj1 : (1 : ℝ) ≤ j := by exact_mod_cast hj + have hp : 0 < (m : ℝ) := by linarith + have hjp : 0 < (j : ℝ) := by linarith + refine ⟨m,j,hm,hod,hj,horder,hw,?_,?_⟩ + · have hAl : 0 < A := by linarith + have hs : sqrt (log n) = sqrt c*t := by rw [hL,sqrt_mul hc.le,sqrt_sq htpos.le] + have hlogbd : log n ≤ log (A * exp 1 * t * (m : ℝ)^(2*j)) := by + rw [log_mul (by positivity) (pow_ne_zero _ hp.ne'), + log_mul (by positivity) htpos.ne', log_mul hAl.ne' (exp_pos 1).ne',log_exp,log_pow] + push_cast + linarith only [hround] + have hnle := (log_le_log_iff hnpos (by positivity)).mp hlogbd + rw [hs] + apply (div_le_iff₀ (by positivity)).mpr + rw [div_mul_eq_mul_div, div_le_iff₀ (by positivity)] + have hp' := mul_le_mul_of_nonneg_left hnle (sqrt_nonneg c) + linarith only [hp'] + have hLj : log (j : ℝ) ≤ log t := log_le_log hjp hjt + have hct : c*(j : ℝ) ≤ c*t := mul_le_mul_of_nonneg_left hjt hc.le + have hroot : sqrt (c*log n) = c*t := by + rw [hL, show c*(c*t^2)=(c*t)^2 by ring, sqrt_sq (by positivity)] + have hlog : log (log n) = log c + 2 * log t := by + conv_lhs => rw [hL, log_mul hc.ne' (pow_ne_zero _ htpos.ne'), log_pow] + norm_num + let D := 27*(1+K*(j : ℝ)^3*(m : ℝ)^2) + have hD : 0 < D := by dsimp [D]; positivity + have hprod : 1 ≤ (j : ℝ)^3*(m : ℝ)^2 := + one_le_mul_of_one_le_of_one_le (one_le_pow₀ hj1) (one_le_pow₀ hm1) + have hDlog : log D ≤ log C + 3*log (j : ℝ) + 2*log (m : ℝ) := by + have hle : D ≤ C*(j : ℝ)^3*(m : ℝ)^2 := by dsimp [D,C]; nlinarith only [hprod] + have h := log_le_log hD hle + rw [log_mul (by positivity : C*(j : ℝ)^3 ≠ 0) (pow_ne_zero _ hp.ne'), + log_mul hC.ne' (pow_ne_zero _ hjp.ne'), log_pow, log_pow] at h + exact_mod_cast h + change exp (-b) * (n : ℝ)^2 / (log n)^(5/2 : ℝ) * exp (-2 * sqrt (c*log n)) ≤ + exp (-c*(j : ℝ)) * (m : ℝ)^(4*j) / D + apply (log_le_log_iff (by positivity) (by positivity)).mp + rw [log_mul (by positivity) (by positivity), log_div (by positivity) (by positivity), + log_mul (by positivity) (by positivity), log_exp, log_pow, log_rpow hLpos, + log_exp, hroot, hlog, log_div (by positivity) hD.ne', + log_mul (by positivity) (by positivity), log_exp, log_pow] + push_cast + dsimp [b] + linarith only [hround,hshort,hDlog,hLj,hct] + +theorem polylog_order_parameters (H : ℕ → ℕ) (A K c W : ℝ) + (hA : 1 ≤ A) (hK : 0 ≤ K) (hc : 0 < c) (hW : 10 ≤ W) + (hH : ∀ j : ℕ, 1 ≤ j → 1 ≤ H j ∧ (H j : ℝ) ≤ A * (j : ℝ)) : + ∃ k : ℝ, 0 < k ∧ ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∃ m j : ℕ, + 1 ≤ m ∧ Odd m ∧ 1 ≤ j ∧ H j * m ^ (2*j) ≤ n ∧ W/2*(j : ℝ) ≤ m ∧ + k * n^2 / (log n)^(5/2 : ℝ) * exp (-2 * sqrt (c * log n)) ≤ + exp (-c * (j : ℝ)) * (m : ℝ)^(4*j) / + (27 * (1 + K * (j : ℝ)^3 * (m : ℝ)^2)) := by + exact ⟨orderAmplitude A K c, exp_pos _, by + obtain ⟨N,hN⟩ := joint_order_parameters H A K c W hA hK hc hW hH + refine ⟨N,fun n hn => ?_⟩ + obtain ⟨m,j,hm,hod,hj,hsize,hw,_,hg⟩ := hN n hn + exact ⟨m,j,hm,hod,hj,hsize,hw,hg⟩⟩ + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/ResidualArithmetic.lean b/LeanPool/SplitCliqueGap/R434/ResidualArithmetic.lean new file mode 100644 index 0000000000..92dc1fd303 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/ResidualArithmetic.lean @@ -0,0 +1,69 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import Mathlib.Basic.Real.Basic +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.Positivity + +/-! # Arithmetic estimates for residual clique partitions -/ + +@[expose] public section + +namespace GapExtremal.R434 + +/-- Three times the slack of a piece with v vertices and e tripartite edges. -/ +def slack3 (v e : ℕ) : ℤ := 3 * (v * (v - 1) / 2 + 1 : ℕ) - 4 * (e : ℤ) + +theorem small_slack_check : + ∀ v : Fin 9, ∀ e : Fin 22, 2 ≤ v.val → 3 * e.val ≤ v.val ^ 2 → + 0 ≤ slack3 v.val e.val ∧ + (slack3 v.val e.val = 0 → (v.val = 3 ∧ e.val = 3) ∨ (v.val = 6 ∧ e.val = 12)) ∧ + (slack3 v.val e.val ≠ 0 → (e.val : ℤ) ≤ 9 * slack3 v.val e.val) := by + decide +kernel + +theorem large_tripartite_slack (v e : ℝ) (hv : 9 ≤ v) (he : 0 ≤ e) + (h : 3 * e ≤ v ^ 2) : + 0 < v * (v - 1) / 2 + 1 - 4 * e / 3 ∧ + e / 27 ≤ v * (v - 1) / 2 + 1 - 4 * e / 3 := by + have hpos : 0 ≤ (v - 9) * (7 * v - 18) := mul_nonneg (by linarith) (by linarith) + have hb : e / 27 ≤ v * (v - 1) / 2 + 1 - 4 * e / 3 := by nlinarith + refine ⟨?_, hb⟩ + rcases he.eq_or_lt with h0 | h0 + · have hv' : 0 ≤ v * (v - 1) := mul_nonneg (by linarith) (by linarith) + linarith + · linarith + +/-- The energy and incidence budgets imply the signed defect bound. -/ +theorem signed_gap_of_budgets (τ x z R δ loss : ℝ) (hR : 0 ≤ R) (hδ : 0 < δ) + (hcover : τ ≤ x + 3 * z) (hcharge : δ * z ≤ (2 * R / 3) * x) + (hslack : x ≤ 27 * loss) : + τ / (27 * (1 + 2 * R / δ)) ≤ loss := by + have hcoef : 0 ≤ 2 * R / δ := by positivity + have hd : 0 < 27 * (1 + 2 * R / δ) := by positivity + have hz : 3 * z ≤ (2 * R / δ) * x := by + apply (mul_le_mul_iff_left₀ hδ).mp + have hcancel : (2 * R / δ * x) * δ = 2 * R * x := by + rw [mul_right_comm, div_mul_cancel₀ _ hδ.ne'] + rw [hcancel] + nlinarith only [hcharge] + apply (div_le_iff₀ hd).mpr + calc + τ ≤ x + 3 * z := hcover + _ ≤ (1 + 2 * R / δ) * x := by linarith only [hz, show + (1 + 2 * R / δ) * x = x + (2 * R / δ) * x by ring] + _ ≤ (1 + 2 * R / δ) * (27 * loss) := + mul_le_mul_of_nonneg_left hslack (by linarith) + _ = loss * (27 * (1 + 2 * R / δ)) := by ring + +theorem signed_price_bounds (m M f : ℝ) (hlo : m ≤ f) (hhi : f ≤ M) : + -(2 * (M - m) / 3) ≤ f - (m + 2 * M) / 3 ∧ + -(2 * (M - m) / 3) ≤ -2 * (f - (m + 2 * M) / 3) := by + constructor <;> linarith + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean b/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean new file mode 100644 index 0000000000..ce3eee7b02 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean @@ -0,0 +1,163 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.RobustHosts + +/-! Score certificates extend across isolated residual vertices. -/ + +@[expose] public section +namespace GapExtremal.R434 +open Finset + +variable {V X : Type} + +/-- Adds a disjoint set of isolated vertices to `B`. -/ +def withIsolates (B : SimpleGraph V) : SimpleGraph (V ⊕ X) := B.map Function.Embedding.inl + +@[simp] theorem isolates_adj_inl (B : SimpleGraph V) (a b : V) : + (withIsolates B : SimpleGraph (V ⊕ X)).Adj (.inl a) (.inl b) ↔ B.Adj a b := + SimpleGraph.map_adj_apply + +@[simp] theorem isolates_not_adj_inr (B : SimpleGraph V) (a : V ⊕ X) (x : X) : + ¬ (withIsolates B).Adj a (.inr x) := by + simp [withIsolates, SimpleGraph.map_adj, Function.Embedding.inl] + +instance (B : SimpleGraph V) [DecidableRel B.Adj] : + DecidableRel (withIsolates (X := X) B).Adj := fun a b => + match a, b with + | .inl u, .inl v => decidable_of_iff _ (isolates_adj_inl B u v).symm + | .inl _, .inr _ => isFalse (isolates_not_adj_inr B _ _) + | .inr _, .inr _ => isFalse (isolates_not_adj_inr B _ _) + | .inr _, .inl _ => isFalse fun h => isolates_not_adj_inr B _ _ h.symm + +@[simp] theorem isolates_not_adj_inr_left (B : SimpleGraph V) (x : X) (a : V ⊕ X) : + ¬ (withIsolates B).Adj (.inr x) a := fun h => isolates_not_adj_inr B a x h.symm + +variable [Fintype V] [DecidableEq V] [Fintype X] [DecidableEq X] +variable (B : SimpleGraph V) [DecidableRel B.Adj] + +theorem isolate_edges (Q : Finset (V ⊕ X)) : + e (withIsolates B) Q = e B Q.toLeft := by + rw [← Nat.mul_right_inj (a := 2) (by decide), two_mul_e_eq_D, two_mul_e_eq_D] + have h : ∀ (L : Finset V) (R : Finset X), D (withIsolates B) (L.disjSum R) (L.disjSum R) + = D B L L := by + intro L R + simp only [D, sum_disjSum, isolates_adj_inl, isolates_not_adj_inr, + isolates_not_adj_inr_left, ite_false, sum_const_zero, add_zero] + simpa only [toLeft_disjSum_toRight] using h Q.toLeft Q.toRight + +theorem isolate_score_le (Q : Finset (V ⊕ X)) : + w (withIsolates B) Q ≤ w B Q.toLeft := by + unfold w + rw [isolate_edges] + have hc := Nat.choose_le_choose 2 (card_toLeft_le (u := Q)) + omega + +theorem isolate_integral_bound (I : ℤ) + (hi : ∀ P : Finset (Finset V), IsPack P → ∑ S ∈ P, w B S ≤ I) + (P : Finset (Finset (V ⊕ X))) (hp : IsPack P) : + ∑ Q ∈ P, w (withIsolates B) Q ≤ I := by + classical + let P' := P.filter fun Q => 2 ≤ Q.toLeft.card + have share {Q S : Finset (V ⊕ X)} (hq : Q ∈ P) (hs : S ∈ P) + {a b : V} (hne : a ≠ b) (ha : a ∈ Q.toLeft ∩ S.toLeft) + (hb : b ∈ Q.toLeft ∩ S.toLeft) : Q = S := by + by_contra hqs + have small := card_le_one.mp (hp Q hq S hs hqs) + have lift {u : V} (hu : u ∈ Q.toLeft ∩ S.toLeft) : + (Sum.inl u : V ⊕ X) ∈ Q ∩ S := by simpa [mem_toLeft] using hu + exact hne (Sum.inl_injective (small _ (lift ha) _ (lift hb))) + have noCollisions : Set.InjOn (fun Q : Finset (V ⊕ X) => Q.toLeft) (↑P' : Set _) := by + intro Q hq S hs eq + obtain ⟨hq, htwo⟩ := mem_filter.mp hq + obtain ⟨hs, _⟩ := mem_filter.mp hs + change Q.toLeft = S.toLeft at eq + obtain ⟨a, ha, b, hb, hne⟩ := one_lt_card.mp htwo + exact share hq hs hne (mem_inter.mpr ⟨ha, eq ▸ ha⟩) (mem_inter.mpr ⟨hb, eq ▸ hb⟩) + have hpack : IsPack (P'.image fun Q => Q.toLeft) := by + intro Q hQ S hS hne + obtain ⟨U, hu, rfl⟩ := mem_image.mp hQ + obtain ⟨W, hw, rfl⟩ := mem_image.mp hS + rw [card_le_one] + intro a ha b hb + by_contra hab + exact hne (congrArg Finset.toLeft (share (mem_filter.mp hu).1 (mem_filter.mp hw).1 hab ha hb)) + calc + ∑ Q ∈ P, w (withIsolates B) Q ≤ ∑ Q ∈ P', w (withIsolates B) Q := by + apply sum_le_sum_of_subset_of_nonpos (filter_subset _ _) + intro Q hq hnot + have hs : Q.toLeft.card < 2 := by + exact Nat.lt_of_not_ge fun hh => hnot (mem_filter.mpr ⟨hq, hh⟩) + exact (isolate_score_le B Q).trans (by + rw [w_eq_D, D_self_eq_zero_of_card_le_one B (by omega : Q.toLeft.card ≤ 1)] + omega) + _ ≤ ∑ Q ∈ P', w B Q.toLeft := sum_le_sum fun Q _ => isolate_score_le B Q + _ = ∑ S ∈ P'.image (fun Q => Q.toLeft), w B S := (sum_image noCollisions).symm + _ ≤ I := hi _ hpack + +private noncomputable def liftWeights (y : Finset V → ℝ) (Q : Finset (V ⊕ X)) : ℝ := + if Q.toRight = ∅ then y Q.toLeft else 0 + +omit [DecidableEq V] [DecidableEq X] in +private theorem sum_old_columns {A : Type} [AddCommMonoid A] (g : Finset (V ⊕ X) → A) + (hz : ∀ Q, Q.toRight ≠ ∅ → g Q = 0) : + ∑ Q, g Q = ∑ S : Finset V, g (S.disjSum ∅) := by + classical + let incl : Finset V ↪ Finset (V ⊕ X) := + ⟨fun S => S.disjSum ∅, fun _ _ h => (disjSum_inj.mp h).1⟩ + rw [← show ∑ Q ∈ (univ.map incl), g Q = ∑ S : Finset V, g (S.disjSum ∅) from sum_map _ _ _] + symm + apply sum_subset (subset_univ _) + intro Q _ hq + apply hz Q + intro hr + apply hq + exact mem_map.mpr ⟨Q.toLeft, mem_univ _, by simpa [incl, hr] using + (toLeft_disjSum_toRight (u := Q))⟩ + +theorem isolate_fractional_lift_with_support {y : Finset V → ℝ} (hy : ResPack y) : + ∃ z : Finset (V ⊕ X) → ℝ, ResPack z ∧ + ((∀ S, y S ≠ 0 → S.card ≤ 3) → ∀ Q, z Q ≠ 0 → Q.card ≤ 3) ∧ + ∑ Q, z Q * (w (withIsolates B) Q : ℝ) = ∑ S, y S * (w B S : ℝ) := by + classical + let z : Finset (V ⊕ X) → ℝ := liftWeights y + refine ⟨z, ⟨fun Q => ?_, fun Q hq => ?_, fun a b hab => ?_⟩, ?_, ?_⟩ + · unfold z liftWeights + split + · exact hy.nonneg _ + · exact le_rfl + · have hr : Q.toRight = ∅ := by + by_contra hr + exact hq (by simp [z, liftWeights, hr]) + exact (hy.two _ (by simpa [z, liftWeights, hr] using hq)).trans card_toLeft_le + · rw [sum_old_columns _ (fun Q hr => by simp [z, liftWeights, hr])] + rcases a with a | a <;> rcases b with b | b + · simpa [z, liftWeights, ← disjSum_empty] using hy.load a b (by simpa using hab) + · simp + · simp + · simp + · intro hsmall Q hQ + have hr : Q.toRight = ∅ := by + by_contra hr + exact hQ (by simp [z, liftWeights, hr]) + have hcard := card_toLeft_add_card_toRight (u := Q) + rw [hr, card_empty, add_zero] at hcard + exact hcard ▸ hsmall _ (by simpa [z, liftWeights, hr] using hQ) + · rw [sum_old_columns _ (fun Q hr => by simp [z, liftWeights, hr])] + refine sum_congr rfl fun S _ => ?_ + have hw : w (withIsolates B : SimpleGraph (V ⊕ X)) (S.disjSum (∅ : Finset X)) = w B S := by + simp only [w, isolate_edges, toLeft_disjSum, card_disjSum, card_empty, add_zero] + simp only [z, liftWeights, toLeft_disjSum, toRight_disjSum, ite_true, hw] + +theorem isolate_fractional_lift {y : Finset V → ℝ} (hy : ResPack y) : + ∃ z : Finset (V ⊕ X) → ℝ, ResPack z ∧ + ∑ Q, z Q * (w (withIsolates B) Q : ℝ) = ∑ S, y S * (w B S : ℝ) := by + obtain ⟨z, hz, _, hscore⟩ := isolate_fractional_lift_with_support (X := X) B hy + exact ⟨z, hz, hscore⟩ + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/RobustHosts.lean b/LeanPool/SplitCliqueGap/R434/RobustHosts.lean new file mode 100644 index 0000000000..786564f592 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/RobustHosts.lean @@ -0,0 +1,162 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.EHPSHostTransfer + +/-! Enlarged host neighborhoods and connectivity after vertex deletion. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +/-- Deleting fewer than k vertices leaves a connected graph, and the order exceeds k. -/ +def SurvivesCuts {V : Type*} [Fintype V] (G : SimpleGraph V) (k : ℕ) : Prop := + k < Fintype.card V ∧ ∀ D : Finset V, D.card < k → + (G.induce {v | v ∉ D}).Connected + +theorem connected_after_cut {V H : Type*} [Fintype V] + (N : H → Finset V) {k : ℕ} + (hcore : k ≤ Fintype.card V) (hN : ∀ h, k ≤ (N h).card) + (D : Finset (V ⊕ H)) (hD : D.card < k) : + ((hostGraph N).induce {v | v ∉ D}).Connected := by + classical + have survivor (S : Finset V) (hs : k ≤ S.card) : ∃ v ∈ S, (Sum.inl v : V ⊕ H) ∉ D := by + have hi : (S.image (Sum.inl : V → V ⊕ H)).card = S.card := + card_image_of_injective _ Sum.inl_injective + obtain ⟨_,he,hd⟩ := exists_mem_notMem_of_card_lt_card (hD.trans_le (hs.trans hi.ge)) + obtain ⟨v,hv,rfl⟩ := mem_image.mp he + exact ⟨v,hv,hd⟩ + obtain ⟨v,_,hv⟩ := survivor univ (by simpa using hcore) + let G := (hostGraph N).induce {u | u ∉ D} + let root : {u : V ⊕ H // u ∉ D} := ⟨.inl v,hv⟩ + have reach (w : V) (hw : (Sum.inl w : V ⊕ H) ∉ D) : G.Reachable root ⟨.inl w,hw⟩ := by + by_cases eq : v = w + · subst w; exact SimpleGraph.Reachable.refl _ + · exact SimpleGraph.Adj.reachable (G := G) ((hostGraph_inl_inl N _ _).mpr eq) + rw [SimpleGraph.connected_iff_exists_forall_reachable] + refine ⟨root,?_⟩ + rintro ⟨w | h, hw⟩ + · exact reach w hw + · obtain ⟨w,hm,hd⟩ := survivor (N h) (hN h) + exact (reach w hd).trans (SimpleGraph.Adj.reachable (G := G) ((hostGraph_inl_inr N _ _).mpr hm)) + +namespace H54 + +private theorem role_exists (p : Sym2 Role) : ∃ r : Role, ∀ z ∈ p, ¬roleGraph.Adj r z := by + refine p.inductionOn (fun a b => ?_) + have table : ∀ a b : Role, ∃ r : Role, ¬roleGraph.Adj r a ∧ ¬roleGraph.Adj r b := by + decide +kernel + obtain ⟨r,ha,hb⟩ := table a b + refine ⟨r, fun z hz => ?_⟩ + rcases Sym2.mem_iff.mp hz with rfl | rfl <;> assumption + +private noncomputable def safeRole (p : Sym2 Role) := (role_exists p).choose + +end H54 + +namespace EHPS + +theorem robust_graph_from_EHPS_scores_with {ε : ℝ} {m j n : ℕ} [NeZero m] (hm : Odd m) + {C : Type} [Fintype C] + (χ : ProductGrid m j → C) + (hχ : ∀ a b, a ∉ productSupport ε m j → b ∉ productSupport ε m j → χ a = χ b → + productHalf m j * (a + b) ∉ productSupport ε m j) + (hn : Fintype.card ((H54.Role × ProductGrid m j) ⊕ MidHost H54.Role (ProductGrid m j) C) ≤ n) + (I : ℤ) {y : Finset (H54.Role × ProductGrid m j) → ℝ} + (hi : ∀ P : Finset (Finset (H54.Role × ProductGrid m j)), IsPack P → + ∑ Q ∈ P, w (H54.coreGraph (productHalf m j) (productSupport ε m j)) Q ≤ I) + (hy : ResPack y) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((m^2)^j) ∧ + (∑ Q, y Q * (w (H54.coreGraph (productHalf m j) + (productSupport ε m j)) Q : ℝ)) - (I : ℝ) ≤ gap G := by + classical + let R := ProductGrid m j + let H := MidHost H54.Role R C + let : DecidableEq H := Classical.decEq H + let T := H54.Role × R + let h := productHalf m j + let A := productSupport ε m j + let B := H54.coreGraph h A + let step := H54.roleStep h + let φ := midAssign H54.roleGraph step h χ + let N := midPalette H54.roleGraph step A h (H54.roleStep_swap h) χ + have base : HostHyp B N φ := midpoint_host_hyp _ _ _ _ _ (productHalf_spec hm) χ + hχ + let fibre (r : H54.Role) : Finset T := {r} ×ˢ univ + have hrole {v : T} {i : H} (hv : v ∈ N i) : v.1 ∈ i.1 := by + simp only [N, midPalette, mem_filter, mem_univ, true_and] at hv + obtain ⟨u,_,_,he⟩ := hv + rw [← he]; exact Sym2.mem_mk_left _ _ + let q := n - Fintype.card (T ⊕ H) + let M : H ⊕ Fin q → Finset T + | .inl i => N i ∪ fibre (H54.safeRole i.1) + | .inr _ => fibre (0,0) + have big : HostHyp B M (fun x y => Sum.inl (φ x y)) := by + constructor + · rintro (i | i) x hx y hy adj + · change x ∈ N i ∪ fibre _ at hx + change y ∈ N i ∪ fibre _ at hy + have safe := (H54.role_exists i.1).choose_spec + have bad : H54.roleGraph.Adj x.1 y.1 := adj.1 + rcases mem_union.mp hx with hx | hx <;> rcases mem_union.mp hy with hy | hy + · exact base.indep i x hx y hy adj + · have eq := mem_singleton.mp (mem_product.mp hy).1 + rw [eq] at bad + exact safe x.1 (hrole hx) bad.symm + · have eq := mem_singleton.mp (mem_product.mp hx).1 + rw [eq] at bad + exact safe y.1 (hrole hy) bad + · have ex := mem_singleton.mp (mem_product.mp hx).1 + have ey := mem_singleton.mp (mem_product.mp hy).1 + exact H54.roleGraph.loopless.irrefl _ (ex.trans ey.symm ▸ bad) + · have ex := mem_singleton.mp (mem_product.mp hx).1 + have ey := mem_singleton.mp (mem_product.mp hy).1 + exact H54.roleGraph.loopless.irrefl _ (ex.trans ey.symm ▸ adj.1) + · intro x y hne hn + obtain ⟨hx,hy⟩ := base.cover x y hne hn + exact ⟨mem_union_left _ hx,mem_union_left _ hy⟩ + · intro x y; rw [base.symm x y] + · intro x y z h1 h2 h3 h4 eq + exact base.inj x y z h1 h2 h3 h4 (Sum.inl_injective eq) + have hR : Fintype.card R = (m^2)^j := by simp [R,ProductGrid,ZMod.card,pow_two] + have hsize (i) : Fintype.card R ≤ (M i).card := by + have hf (r) : (fibre r).card = Fintype.card R := by simp [fibre] + cases i with + | inl i => exact (hf _).ge.trans (card_le_card (subset_union_right (s₁ := N i))) + | inr i => exact (hf _).ge + have hT : Fintype.card T = 15 * Fintype.card R := by simp [T,H54.Role] + have ht : 0 < Fintype.card R := Fintype.card_pos + have hn' : Fintype.card (T ⊕ H) ≤ n := hn + have hcard : Fintype.card (T ⊕ (H ⊕ Fin q)) = n := (card_pad q).trans (Nat.add_sub_of_le hn') + have hcore : Fintype.card R ≤ Fintype.card T := by omega + have hconn := connected_hostGraph M ((0,0),0) (fun i => card_pos.mp (ht.trans_le (hsize i))) + refine ⟨_, inferInstance, inferInstance, hostGraph M,hcard,isSplit_hostGraph M,hconn,?_,gap_ge + big I hi hy⟩ + rw [← hR] + constructor + · rw [Fintype.card_sum]; omega + · exact connected_after_cut M hcore hsize + +theorem robust_graph_from_EHPS_scores {ε : ℝ} {m j n : ℕ} [NeZero m] (hm : Odd m) + (hn : hostFactor j * (m ^ 2) ^ j ≤ n) + (I : ℤ) {y : Finset (H54.Role × ProductGrid m j) → ℝ} + (hi : ∀ P : Finset (Finset (H54.Role × ProductGrid m j)), IsPack P → + ∑ Q ∈ P, w (H54.coreGraph (productHalf m j) (productSupport ε m j)) Q ≤ I) + (hy : ResPack y) : + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G ((m^2)^j) ∧ + (∑ Q, y Q * (w (H54.coreGraph (productHalf m j) + (productSupport ε m j)) Q : ℝ)) - (I : ℝ) ≤ gap G := by + exact robust_graph_from_EHPS_scores_with hm (productColour ε m j) + (fun _ _ ha hb hc => product_mid_outside hm ha hb hc) ((host_order m j).trans_le hn) I hi hy + +end EHPS +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/RoleMatchings.lean b/LeanPool/SplitCliqueGap/R434/RoleMatchings.lean new file mode 100644 index 0000000000..adc17fdb51 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/RoleMatchings.lean @@ -0,0 +1,44 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.AffineH54 + +/-! Four matching classes in each of the three bipartite layers of the local graph. -/ + +@[expose] public section +namespace GapExtremal.R434.H54 + +/-- Values on missing pairs are immaterial. The layers are ordered 01, 12, 02. -/ +def edgeColour (k : Fin 3) (a b : Fin 5) : Fin 4 := + ![![![0, 1, 2, 0, 0], + ![1, 0, 0, 2, 3], + ![2, 3, 0, 0, 0], + ![3, 0, 0, 1, 2], + ![0, 2, 3, 0, 1]], + ![![0, 1, 2, 0, 3], + ![1, 0, 3, 2, 0], + ![2, 0, 0, 0, 1], + ![0, 0, 0, 1, 2], + ![0, 2, 1, 3, 0]], + ![![0, 0, 0, 1, 2], + ![0, 0, 1, 2, 3], + ![0, 0, 0, 3, 1], + ![1, 2, 3, 0, 0], + ![3, 1, 2, 0, 0]]] k a b + +theorem edgeColour_left : + ∀ (k : Fin 3) (a b b' : Fin 5), (k,a,b) ∈ edges → (k,a,b') ∈ edges → + edgeColour k a b = edgeColour k a b' → b = b' := by + decide +kernel + +theorem edgeColour_right : + ∀ (k : Fin 3) (a a' b : Fin 5), (k,a,b) ∈ edges → (k,a',b) ∈ edges → + edgeColour k a b = edgeColour k a' b → a = a' := by + decide +kernel + +end GapExtremal.R434.H54 diff --git a/LeanPool/SplitCliqueGap/R434/TightPieces.lean b/LeanPool/SplitCliqueGap/R434/TightPieces.lean new file mode 100644 index 0000000000..671748b31d --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/TightPieces.lean @@ -0,0 +1,102 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.TripartiteSlack +public import Mathlib.Data.ZMod.Basic +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +/-! Saturated tripartite pieces and their edge-disjoint triangles. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +variable {V : Type} [Fintype V] [DecidableEq V] +variable (B : SimpleGraph V) [DecidableRel B.Adj] + +theorem tight_tripartite (c : V → Fin 3) (hc : ∀ ⦃u v⦄, B.Adj u v → c u ≠ c v) + (Q : Finset V) (ht : 3 * e B Q = Q.card ^ 2) : + (∀ i : Fin 3, 3 * (partOf c Q i).card = Q.card) ∧ + (∀ ⦃u v⦄, u ∈ Q → v ∈ Q → c u ≠ c v → B.Adj u v) := by + let a := (partOf c Q 0).card + let b := (partOf c Q 1).card + let d := (partOf c Q 2).card + have hsub := induced_edges_subset_crossPairs B c hc Q + have hcard : ((crossPairs c Q).image (fun p => s(p.1,p.2))).card = a * b + a * d + b * d := by + rw [card_image_of_injOn (crossPairs_injOn c Q), crossPairs_card] + have hle := card_le_card hsub + rw [hcard] at hle + change e B Q ≤ a * b + a * d + b * d at hle + have hn : Q.card = a + b + d := partOf_card_sum c Q + have ht' := ht + rw [hn] at ht' + have hR : (3 : ℝ) * e B Q = ((a : ℝ) + b + d) ^ 2 := by exact_mod_cast ht' + have hleR : (e B Q : ℝ) ≤ (a : ℝ) * b + a * d + b * d := by exact_mod_cast hle + have hab0 := sq_nonneg ((a : ℝ) - b) + have had0 := sq_nonneg ((a : ℝ) - d) + have hbd0 := sq_nonneg ((b : ℝ) - d) + have hab : a = b := by + have hz : ((a : ℝ) - b) ^ 2 = 0 := by nlinarith only [hR, hleR, hab0, had0, hbd0] + have hdiff : (a : ℝ) - b = 0 := (pow_eq_zero_iff (by decide)).mp hz + exact_mod_cast (sub_eq_zero.mp hdiff) + have had : a = d := by + have hz : ((a : ℝ) - d) ^ 2 = 0 := by nlinarith only [hR, hleR, hab0, had0, hbd0] + have hdiff : (a : ℝ) - d = 0 := (pow_eq_zero_iff (by decide)).mp hz + exact_mod_cast (sub_eq_zero.mp hdiff) + have he : e B Q = a * b + a * d + b * d := by + have hR' : (e B Q : ℝ) = (a : ℝ) * b + a * d + b * d := by + have habR : (a : ℝ) = b := by exact_mod_cast hab + have hadR : (a : ℝ) = d := by exact_mod_cast had + rw [← habR, ← hadR] at hR ⊢ + linarith [show ((a : ℝ) + a + a) ^ 2 = 9 * (a : ℝ) ^ 2 by ring] + exact_mod_cast hR' + have heq := eq_of_subset_of_card_le hsub (by rw [hcard]; exact he.ge) + constructor + · intro i + fin_cases i + · change 3 * a = Q.card + omega + · change 3 * b = Q.card + omega + · change 3 * d = Q.card + omega + · intro u v hu hv hne + suffices h : s(u,v) ∈ (inducedOn B Q).edgeFinset from + (show B.Adj u v ∧ u ∈ Q ∧ v ∈ Q from SimpleGraph.mem_edgeFinset.mp h).1 + rw [heq] + rcases lt_or_gt_of_ne hne with hlt | hgt + · exact mem_image.mpr ⟨(u,v), crossPairs_iff.mpr ⟨hu, hv, hlt⟩, rfl⟩ + · exact mem_image.mpr ⟨(v,u), crossPairs_iff.mpr ⟨hv, hu, hgt⟩, Sym2.eq_swap⟩ + +theorem induced_edges_disjoint_of_pack {P : Finset (Finset V)} (hP : IsPack P) : + (P : Set (Finset V)).PairwiseDisjoint (fun Q => (inducedOn B Q).edgeFinset) := by + intro Q hQ Q' hQ' hne + change Disjoint (inducedOn B Q).edgeFinset (inducedOn B Q').edgeFinset + rw [Finset.disjoint_left] + intro f h₁ h₂ + induction f using Sym2.inductionOn with + | _ u v => + have hu : B.Adj u v ∧ u ∈ Q ∧ v ∈ Q := SimpleGraph.mem_edgeFinset.mp h₁ + have hv : B.Adj u v ∧ u ∈ Q' ∧ v ∈ Q' := SimpleGraph.mem_edgeFinset.mp h₂ + have hsub : ({u,v} : Finset V) ⊆ Q ∩ Q' := by + intro a ha + simp only [mem_insert, mem_singleton] at ha + rcases ha with rfl | rfl + · exact mem_inter.mpr ⟨hu.2.1, hv.2.1⟩ + · exact mem_inter.mpr ⟨hu.2.2, hv.2.2⟩ + have hcard := card_le_card hsub + rw [Finset.card_pair hu.1.ne] at hcard + have hle := hP Q hQ Q' hQ' hne + omega + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/TightTriangles.lean b/LeanPool/SplitCliqueGap/R434/TightTriangles.lean new file mode 100644 index 0000000000..69cad04ae8 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/TightTriangles.lean @@ -0,0 +1,156 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.TightPieces +public import Mathlib.Data.Fintype.EquivFin +import Mathlib.Tactic.Abel + +/-! Triangle decompositions of saturated tripartite pieces. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +section + +variable {V : Type} [DecidableEq V] + +/-- A candidate triangle represented by an ordered triple of vertices. -/ +abbrev OrderedTriangle (V : Type) := V × V × V + +/-- The unordered pairs of vertices belonging to an ordered triangle. -/ +def triangleEdges (t : OrderedTriangle V) : Finset (Sym2 V) := + {s(t.1,t.2.1), s(t.2.1,t.2.2), s(t.1,t.2.2)} + +theorem triangleEdges_card_le (t : OrderedTriangle V) : (triangleEdges t).card ≤ 3 := by + unfold triangleEdges + have h₁ := card_insert_le (s := ({s(t.2.1,t.2.2), s(t.1,t.2.2)} : Finset (Sym2 V))) + (a := s(t.1,t.2.1)) + have h₂ := card_insert_le (s := ({s(t.1,t.2.2)} : Finset (Sym2 V))) (a := s(t.2.1,t.2.2)) + simp only [card_singleton] at h₂ + omega + +variable [Fintype V] (B : SimpleGraph V) [DecidableRel B.Adj] + +theorem triangulate_uniform_piece (c : V → Fin 3) + (hc : ∀ ⦃u v⦄, B.Adj u v → c u ≠ c v) (Q : Finset V) (k : ℕ) [NeZero k] + (hparts : ∀ i, (partOf c Q i).card = k) + (hcomplete : ∀ ⦃x y⦄, x ∈ Q → y ∈ Q → c x ≠ c y → B.Adj x y) : + ∃ T : Finset (OrderedTriangle V), + (∀ t ∈ T, c t.1 = 0 ∧ c t.2.1 = 1 ∧ c t.2.2 = 2) ∧ + (T : Set (OrderedTriangle V)).PairwiseDisjoint triangleEdges ∧ + T.biUnion triangleEdges = (inducedOn B Q).edgeFinset := by + classical + let p (i : Fin 3) : ZMod k ≃ partOf c Q i := + (ZMod.finEquiv k).toEquiv.symm.trans (Finset.equivFinOfCardEq (hparts i)).symm + let u (i : Fin 3) (x : ZMod k) : V := (p i x).val + have hQ (i : Fin 3) (x : ZMod k) : u i x ∈ Q := + (mem_filter.mp (p i x).prop).1 + have hC (i : Fin 3) (x : ZMod k) : c (u i x) = i := + (mem_filter.mp (p i x).prop).2 + have hinj (i : Fin 3) : Function.Injective (u i) := + fun _ _ h => (p i).injective (Subtype.ext h) + have hex (i : Fin 3) {v : V} (hv : v ∈ Q) (hc : c v = i) : ∃ x, u i x = v := by + obtain ⟨x, hx⟩ := (p i).surjective ⟨v, mem_filter.mpr ⟨hv, hc⟩⟩ + exact ⟨x, congrArg Subtype.val hx⟩ + let tri (a : ZMod k × ZMod k) : OrderedTriangle V := + (u 0 a.1, u 1 a.2, u 2 (a.1 + a.2)) + let tp (a : ZMod k × ZMod k) : Finset (V × V) := + {(u 0 a.1, u 1 a.2), (u 1 a.2, u 2 (a.1 + a.2)), (u 0 a.1, u 2 (a.1 + a.2))} + have htp {a : ZMod k × ZMod k} {x : V × V} (hx : x ∈ tp a) : x ∈ crossPairs c Q := by + simp only [tp, mem_insert, mem_singleton] at hx + apply crossPairs_iff.mpr + rcases hx with rfl | rfl | rfl <;> exact ⟨hQ _ _, hQ _ _, by + simp only [hC] + decide⟩ + let f (x : V × V) : Sym2 V := s(x.1,x.2) + have he (a : ZMod k × ZMod k) : triangleEdges (tri a) = (tp a).image f := by + simp [triangleEdges, tri, tp, f] + have huniq {a b : ZMod k × ZMod k} {x : V × V} (hx : x ∈ tp a) (hy : x ∈ tp b) : + a = b := by + simp only [tp, mem_insert, mem_singleton] at hx hy + have himp (i j : Fin 3) (t s : ZMod k) (h : u i t = u j s) : i = j := by + simpa only [hC] using congrArg c h + rcases hx with rfl | rfl | rfl <;> rcases hy with hy | hy | hy + · exact Prod.ext (hinj 0 (congrArg Prod.fst hy)) (hinj 1 (congrArg Prod.snd hy)) + · exact ((by decide : (0 : Fin 3) ≠ 1) (himp 0 1 _ _ (congrArg Prod.fst hy))).elim + · exact ((by decide : (1 : Fin 3) ≠ 2) (himp 1 2 _ _ (congrArg Prod.snd hy))).elim + · exact ((by decide : (1 : Fin 3) ≠ 0) (himp 1 0 _ _ (congrArg Prod.fst hy))).elim + · have hb := hinj 1 (congrArg Prod.fst hy) + have hab := hinj 2 (congrArg Prod.snd hy) + rw [hb] at hab + exact Prod.ext (add_right_cancel hab) hb + · exact ((by decide : (1 : Fin 3) ≠ 0) (himp 1 0 _ _ (congrArg Prod.fst hy))).elim + · exact ((by decide : (2 : Fin 3) ≠ 1) (himp 2 1 _ _ (congrArg Prod.snd hy))).elim + · exact ((by decide : (0 : Fin 3) ≠ 1) (himp 0 1 _ _ (congrArg Prod.fst hy))).elim + · have ha := hinj 0 (congrArg Prod.fst hy) + have hab := hinj 2 (congrArg Prod.snd hy) + rw [ha] at hab + exact Prod.ext ha (add_left_cancel hab) + have hdisj : (((univ : Finset (ZMod k × ZMod k)).image tri : Set (OrderedTriangle V)) + ).PairwiseDisjoint triangleEdges := by + intro t ht t' ht' hn + obtain ⟨a, _, rfl⟩ := mem_image.mp ht + obtain ⟨b, _, rfl⟩ := mem_image.mp ht' + change Disjoint (triangleEdges (tri a)) (triangleEdges (tri b)) + rw [he, he, Finset.disjoint_left] + intro e ha hb + obtain ⟨x, hx, hx'⟩ := mem_image.mp ha + obtain ⟨y, hy, hy'⟩ := mem_image.mp hb + have hxy : x = y := crossPairs_injOn c Q (htp hx) (htp hy) (hx'.trans hy'.symm) + subst y + exact hn (congrArg tri (huniq hx hy)) + have htri : ((univ : Finset (ZMod k × ZMod k)).image tri).biUnion triangleEdges = + (crossPairs c Q).image f := by + ext e + constructor + · intro he' + obtain ⟨t, ht, het⟩ := mem_biUnion.mp he' + obtain ⟨a, _, rfl⟩ := mem_image.mp ht + rw [he] at het + obtain ⟨x, hx, rfl⟩ := mem_image.mp het + exact mem_image.mpr ⟨x, htp hx, rfl⟩ + · intro he' + obtain ⟨⟨x,y⟩, hx, rfl⟩ := mem_image.mp he' + obtain ⟨hxQ, hyQ, hlt⟩ := crossPairs_iff.mp hx + have hc' : (c x = 0 ∧ c y = 1) ∨ (c x = 0 ∧ c y = 2) ∨ (c x = 1 ∧ c y = 2) := by + have split_lt (i j : Fin 3) : i < j → + (i = 0 ∧ j = 1) ∨ (i = 0 ∧ j = 2) ∨ (i = 1 ∧ j = 2) := by + decide +revert +kernel + exact split_lt _ _ hlt + have inc (a : ZMod k × ZMod k) (ha : (x,y) ∈ tp a) : + f (x,y) ∈ ((univ : Finset (ZMod k × ZMod k)).image tri).biUnion triangleEdges := + mem_biUnion.mpr ⟨tri a, mem_image.mpr ⟨a, mem_univ _, rfl⟩, + (he a).symm ▸ mem_image.mpr ⟨(x,y), ha, rfl⟩⟩ + rcases hc' with ⟨h₁,h₂⟩ | ⟨h₁,h₂⟩ | ⟨h₁,h₂⟩ + · obtain ⟨a, ha⟩ := hex 0 hxQ h₁ + obtain ⟨b, hb⟩ := hex 1 hyQ h₂ + exact inc (a,b) (by simp [tp, ha, hb]) + · obtain ⟨a, ha⟩ := hex 0 hxQ h₁ + obtain ⟨b, hb⟩ := hex 2 hyQ h₂ + exact inc (a,b-a) (by simp [tp, ha, show a + (b-a) = b by abel, hb]) + · obtain ⟨a, ha⟩ := hex 1 hxQ h₁ + obtain ⟨b, hb⟩ := hex 2 hyQ h₂ + exact inc (b-a,a) (by simp [tp, ha, show (b-a) + a = b by abel, hb]) + have hsat : (crossPairs c Q).image f ⊆ (inducedOn B Q).edgeFinset := by + intro e he' + obtain ⟨⟨x,y⟩, hx, rfl⟩ := mem_image.mp he' + obtain ⟨hxQ, hyQ, hlt⟩ := crossPairs_iff.mp hx + exact SimpleGraph.mem_edgeFinset.mpr ⟨hcomplete hxQ hyQ (ne_of_lt hlt), hxQ, hyQ⟩ + refine ⟨univ.image tri, ?_, hdisj, ?_⟩ + · intro t ht + obtain ⟨a, _, rfl⟩ := mem_image.mp ht + exact ⟨hC _ _, hC _ _, hC _ _⟩ + · rw [htri] + exact Subset.antisymm hsat (induced_edges_subset_crossPairs B c hc Q) + +end + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean b/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean new file mode 100644 index 0000000000..fddf19ac6a --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean @@ -0,0 +1,158 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.ResidualArithmetic +public import LeanPool.SplitCliqueGap.R434.ExactGraphTransfer +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Tauto + +/-! Edge counts and the zero-slack cases for tripartite pieces. -/ + +@[expose] public section + +open Finset + +namespace GapExtremal.R434 + +theorem slack_of_tripartite_counts (v e : ℕ) (hv : 2 ≤ v) (he : 3 * e ≤ v ^ 2) : + let s := ((v.choose 2 : ℕ) : ℝ) + 1 - 4 * (e : ℝ) / 3 + 0 ≤ s ∧ (s = 0 → (v = 3 ∧ e = 3) ∨ (v = 6 ∧ e = 12)) ∧ + (s ≠ 0 → (e : ℝ) ≤ 27 * s) := by + dsimp only + by_cases hv9 : 9 ≤ v + · have hchooseN : v.choose 2 * 2 = v * (v - 1) := by + simpa using (Nat.choose_mul (n := v) (k := 2) (s := 1) (by decide)) + have hchooseR : (v.choose 2 : ℝ) * 2 = (v : ℝ) * ((v : ℝ) - 1) := by + have hcast : (v.choose 2 : ℝ) * 2 = (v : ℝ) * ((v - 1 : ℕ) : ℝ) := by + exact_mod_cast hchooseN + rwa [Nat.cast_sub (by omega : 1 ≤ v), Nat.cast_one] at hcast + have hvR : (9 : ℝ) ≤ v := by exact_mod_cast hv9 + have heR : (3 : ℝ) * e ≤ (v : ℝ) ^ 2 := by exact_mod_cast he + obtain ⟨hs, hse⟩ := large_tripartite_slack (v : ℝ) (e : ℝ) hvR (by positivity) heR + refine ⟨by linarith, fun hz => False.elim (by linarith), fun _ => ?_⟩ + linarith + · have hv8 : v ≤ 8 := by omega + have he21 : e < 22 := by + have hs : v ^ 2 ≤ 8 ^ 2 := Nat.pow_le_pow_left hv8 2 + omega + obtain ⟨hs, hzero, hpos⟩ := small_slack_check ⟨v, by omega⟩ ⟨e, he21⟩ hv he + have hid : (slack3 v e : ℝ) = + 3 * ((v.choose 2 : ℝ) + 1 - 4 * (e : ℝ) / 3) := by + simp only [slack3, Int.cast_add, Int.cast_sub, Int.cast_mul, Int.cast_ofNat, Int.cast_natCast, + Nat.cast_add, Nat.cast_one, ← Nat.choose_two_right] + ring + have hsR : (0 : ℝ) ≤ (slack3 v e : ℝ) := by exact_mod_cast hs + refine ⟨by linarith, ?_, ?_⟩ + · intro hz + apply hzero + exact_mod_cast (show (slack3 v e : ℝ) = 0 by linarith) + · intro hz + have hn : slack3 v e ≠ 0 := by + intro hz' + have hzR : (slack3 v e : ℝ) = 0 := by exact_mod_cast hz' + exact hz (by linarith) + have hr : (e : ℝ) ≤ 9 * (slack3 v e : ℝ) := by exact_mod_cast hpos hn + linarith + +section + +variable {V : Type} [Fintype V] [DecidableEq V] + +/-- The vertices of `Q` in the specified part of the colouring. -/ +def partOf (c : V → Fin 3) (Q : Finset V) (i : Fin 3) := + Q.filter fun u => c u = i + +/-- The ordered vertex pairs in distinct parts, oriented by increasing colour. -/ +def crossPairs (c : V → Fin 3) (Q : Finset V) : Finset (V × V) := + (partOf c Q 0 ×ˢ partOf c Q 1) ∪ (partOf c Q 0 ×ˢ partOf c Q 2) ∪ + (partOf c Q 1 ×ˢ partOf c Q 2) + +omit [Fintype V] in +theorem crossPairs_iff {c : V → Fin 3} {Q : Finset V} {p : V × V} : + p ∈ crossPairs c Q ↔ p.1 ∈ Q ∧ p.2 ∈ Q ∧ c p.1 < c p.2 := by + simp only [crossPairs, mem_union, mem_product, partOf, mem_filter] + have h (i j : Fin 3) : i < j ↔ + (i = 0 ∧ j = 1) ∨ (i = 0 ∧ j = 2) ∨ (i = 1 ∧ j = 2) := by + decide +revert +kernel + rw [h] + tauto + +omit [DecidableEq V] [Fintype V] in +theorem partOf_card_sum (c : V → Fin 3) (Q : Finset V) : + Q.card = (partOf c Q 0).card + (partOf c Q 1).card + (partOf c Q 2).card := by + calc + Q.card = ∑ i : Fin 3, (partOf c Q i).card := + card_eq_sum_card_fiberwise (fun _ _ => mem_univ _) + _ = _ := by rw [Fin.sum_univ_three] + +omit [Fintype V] in +theorem crossPairs_card (c : V → Fin 3) (Q : Finset V) : + (crossPairs c Q).card = + (partOf c Q 0).card * (partOf c Q 1).card + + (partOf c Q 0).card * (partOf c Q 2).card + + (partOf c Q 1).card * (partOf c Q 2).card := by + have h₁ : Disjoint (partOf c Q 0 ×ˢ partOf c Q 1) (partOf c Q 0 ×ˢ partOf c Q 2) := by + rw [Finset.disjoint_left] + intro p hp hq + simp only [mem_product, partOf, mem_filter] at hp hq + have hc := hp.2.2.symm.trans hq.2.2 + exact (by decide : (1 : Fin 3) ≠ 2) hc + have h₂ : Disjoint ((partOf c Q 0 ×ˢ partOf c Q 1) ∪ (partOf c Q 0 ×ˢ partOf c Q 2)) + (partOf c Q 1 ×ˢ partOf c Q 2) := by + rw [Finset.disjoint_left] + intro p hp hq + simp only [mem_union, mem_product, partOf, mem_filter] at hp hq + have hp' : c p.1 = 0 := hp.elim (fun h => h.1.2) (fun h => h.1.2) + have hc := hp'.symm.trans hq.1.2 + exact (by decide : (0 : Fin 3) ≠ 1) hc + rw [crossPairs, card_union_of_disjoint h₂, card_union_of_disjoint h₁] + simp only [card_product] + +omit [Fintype V] in +theorem crossPairs_injOn (c : V → Fin 3) (Q : Finset V) : + Set.InjOn (fun p : V × V => s(p.1,p.2)) (crossPairs c Q) := by + intro p hp q hq he + rcases Sym2.eq_iff.mp he with h | h + · exact Prod.ext h.1 h.2 + · have hlt := (crossPairs_iff.mp hp).2.2 + rw [h.1, h.2] at hlt + exact ((not_lt_of_ge (crossPairs_iff.mp hq).2.2.le) hlt).elim + +variable (B : SimpleGraph V) [DecidableRel B.Adj] + +theorem induced_edges_subset_crossPairs (c : V → Fin 3) + (hc : ∀ ⦃u v⦄, B.Adj u v → c u ≠ c v) (Q : Finset V) : + (inducedOn B Q).edgeFinset ⊆ (crossPairs c Q).image (fun p => s(p.1,p.2)) := by + intro f hf + induction f using Sym2.inductionOn with + | _ u v => + have h : B.Adj u v ∧ u ∈ Q ∧ v ∈ Q := + SimpleGraph.mem_edgeFinset.mp hf + rcases lt_or_gt_of_ne (hc h.1) with hlt | hgt + · exact mem_image.mpr ⟨(u,v), crossPairs_iff.mpr ⟨h.2.1, h.2.2, hlt⟩, rfl⟩ + · exact mem_image.mpr ⟨(v,u), crossPairs_iff.mpr ⟨h.2.2, h.2.1, hgt⟩, Sym2.eq_swap⟩ + +theorem tripartite_edge_bound (c : V → Fin 3) + (hc : ∀ ⦃u v⦄, B.Adj u v → c u ≠ c v) (Q : Finset V) : + 3 * e B Q ≤ Q.card ^ 2 := by + have hle := card_le_card (induced_edges_subset_crossPairs B c hc Q) + rw [card_image_of_injOn (crossPairs_injOn c Q), crossPairs_card] at hle + change e B Q ≤ _ at hle + rw [partOf_card_sum c Q] + zify at hle ⊢ + nlinarith only [hle, + sq_nonneg ((partOf c Q 0).card - (partOf c Q 1).card : ℤ), + sq_nonneg ((partOf c Q 0).card - (partOf c Q 2).card : ℤ), + sq_nonneg ((partOf c Q 1).card - (partOf c Q 2).card : ℤ)] + +end + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/UniformOrder.lean b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean new file mode 100644 index 0000000000..742b25caa5 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean @@ -0,0 +1,255 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R417.LogErrorAbsorption +public import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Tactic.Convert +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! Choosing the dimension and an odd modulus at every sufficiently large order. -/ + +@[expose] public section + +namespace GapExtremal.R434 + +open Real + +theorem odd_floor_close {x : ℝ} (hx : 1 ≤ x) : + ∃ m : ℕ, Odd m ∧ (m : ℝ) ≤ x ∧ x < (m : ℝ) + 2 := by + let y := (x - 1) / 2 + let k := ⌊y⌋₊ + refine ⟨2 * k + 1, ⟨k, by omega⟩, ?_, ?_⟩ + · push_cast + have hk : (k : ℝ) ≤ y := Nat.floor_le (by dsimp [y]; linarith) + dsimp only [y] at hk + linarith + · push_cast + have hk : y < (k : ℝ) + 1 := Nat.lt_floor_add_one _ + dsimp only [y] at hk + linarith + +theorem log_linear_error (A B d : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) (hd : 0 < d) : + ∃ T : ℝ, 1 ≤ T ∧ ∀ t : ℝ, T ≤ t → A * log t + B ≤ d * t := by + obtain ⟨T,hT,h⟩ := R417.log_error_absorption A B d hA hB hd + refine ⟨T,hT,fun t ht => ?_⟩ + have ht₀ : 0 < t := by linarith + apply (mul_le_mul_iff_left₀ ht₀).mp + convert h t ht using 1 <;> ring + +theorem rounded_order_witness (H : ℕ → ℕ) (A c : ℝ) (hA : 1 ≤ A) + (hc : 0 < c) (W : ℝ) (hW : 10 ≤ W) (m₀ : ℕ) + (hH : ∀ j : ℕ, 1 ≤ j → 1 ≤ H j ∧ (H j : ℝ) ≤ A * (j : ℝ)) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∃ m j : ℕ, + 1 ≤ m ∧ m₀ ≤ m ∧ Odd m ∧ 1 ≤ j ∧ H j * m ^ (2*j) ≤ n ∧ + W / 2 * (j : ℝ) ≤ m ∧ 0 < (n : ℝ) ∧ + let t := sqrt (log n / c) + (m₀ : ℝ) + 2 ≤ t ∧ (j : ℝ) ≤ t ∧ log n = c * t^2 ∧ + 2 * (log n - 2 * (j : ℝ) * log (m : ℝ)) ≤ 2 * (log A + log t + 1) ∧ + 2 * log (m : ℝ) ≤ c * (t + 2) := by + have hAl : 0 ≤ log A := log_nonneg hA + obtain ⟨T₁,hT₁,h₁⟩ := log_linear_error 1 (log A) (c/2) (by norm_num) hAl (by positivity) + have hWpos : 0 < W := by linarith + let T := 2 + T₁ + 32 * W / c ^ 2 + (m₀ : ℝ) + 2 + refine ⟨⌈exp (c * T ^ 2)⌉₊, fun n hn => ?_⟩ + have hT : 2 ≤ T := by + dsimp [T] + have : 0 ≤ 32 * W / c ^ 2 := by positivity + have : 0 ≤ (m₀ : ℝ) := by positivity + linarith + have hT₁' : T₁ ≤ T := by + dsimp [T] + have : 0 ≤ 32 * W / c ^ 2 := by positivity + have : 0 ≤ (m₀ : ℝ) := by positivity + linarith + have hTlarge : 32 * W / c ^ 2 ≤ T := by + dsimp [T] + have : 0 ≤ (m₀ : ℝ) := by positivity + linarith + have hTm : (m₀ : ℝ) + 2 ≤ T := by + dsimp [T] + have : 0 ≤ 32 * W / c ^ 2 := by positivity + linarith + have hnR : exp (c * T ^ 2) ≤ (n : ℝ) := + (Nat.le_ceil _).trans (by exact_mod_cast hn) + have hn₀ : 0 < (n : ℝ) := (exp_pos _).trans_le hnR + let L := log (n : ℝ) + have hL : c * T ^ 2 ≤ L := by + simpa only [log_exp] using (log_le_log_iff (exp_pos _) hn₀).mpr hnR + have hL₀ : 0 ≤ L := (by positivity : 0 ≤ c * T ^ 2).trans hL + let t := sqrt (L / c) + have ht : T ≤ t := by + apply le_sqrt_of_sq_le + exact (le_div_iff₀ hc).mpr (by nlinarith only [hL]) + have ht2 : 2 ≤ t := hT.trans ht + have ht₀ : 0 < t := by linarith + have hLt : L = c * t ^ 2 := by + dsimp [t] + rw [sq_sqrt (by positivity), mul_div_cancel₀ _ hc.ne'] + have hsqrt : sqrt L = sqrt c * t := by + have he : L = c * (L / c) := by field_simp + conv_lhs => rw [he, sqrt_mul hc.le] + let j := ⌊t⌋₊ + have hj₁ : 1 ≤ j := Nat.le_floor (by norm_cast; linarith) + have hjU : (j : ℝ) ≤ t := Nat.floor_le ht₀.le + have hjL : t < (j : ℝ) + 1 := Nat.lt_floor_add_one t + have hjpos : 0 < (j : ℝ) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hj₁) + obtain ⟨hH₁,hHU⟩ := hH j hj₁ + have hHpos : 0 < (H j : ℝ) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hH₁) + have hlogH₀ : 0 ≤ log (H j : ℝ) := log_natCast_nonneg _ + have hlogH : log (H j : ℝ) ≤ log A + log t := by + rw [← log_mul (by linarith : A ≠ 0) ht₀.ne'] + apply (log_le_log_iff hHpos (by positivity)).mpr + exact hHU.trans (mul_le_mul_of_nonneg_left hjU (by linarith)) + have hlogH' : log (H j : ℝ) ≤ L / 2 := by + have hh := h₁ t (hT₁'.trans ht) + have ht' : t ≤ t ^ 2 := by nlinarith only [mul_nonneg ht₀.le (show 0 ≤ t - 1 by linarith)] + have hh' := mul_le_mul_of_nonneg_left ht' (show 0 ≤ c/2 by positivity) + rw [hLt] + nlinarith only [hlogH, hh, hh'] + let x := exp ((L - log (H j : ℝ)) / (2 * (j : ℝ))) + have hxpos : 0 < x := exp_pos _ + have hxLog : 2 * (j : ℝ) * log x = L - log (H j : ℝ) := by + simp only [x, log_exp] + field_simp + have hxLower : c * t / 4 ≤ log x := by + have hp := mul_le_mul_of_nonneg_left hjU (show 0 ≤ c*t/2 by positivity) + apply (mul_le_mul_iff_left₀ (show 0 < 2 * (j : ℝ) by positivity)).mp + nlinarith only [hp,hlogH',hLt,hxLog] + have hxWide : W * t ≤ x := by + have hlarge : 32 * W ≤ c ^ 2 * t := + (div_le_iff₀ (sq_pos_of_pos hc)).mp (hTlarge.trans ht) |>.trans_eq (mul_comm _ _) + have hmul := mul_le_mul_of_nonneg_right hlarge ht₀.le + have hq := quadratic_le_exp_of_nonneg (show 0 ≤ c * t / 4 by positivity) + have hx := (exp_le_exp.mpr hxLower) + rw [exp_log hxpos] at hx + nlinarith only [hmul,hq,hx,show 0 ≤ c*t/4 by positivity] + have h8 : 8*t ≤ x := (mul_le_mul_of_nonneg_right (by linarith : 8 ≤ W) ht₀.le).trans hxWide + obtain ⟨m,hmOdd,hmx,hxm⟩ := odd_floor_close (x := x) (by linarith) + have hm₁ : 1 ≤ m := by exact_mod_cast (show (1 : ℝ) ≤ m by linarith) + have hm₀ : m₀ ≤ m := by + have h := hTm.trans ht + exact_mod_cast (show (m₀ : ℝ) ≤ m by linarith) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm₁ + have hmpos : 0 < (m : ℝ) := by linarith + have hmLog₀ : 0 ≤ log (m : ℝ) := log_nonneg hmR + have hmLog : log (m : ℝ) ≤ log x := (log_le_log_iff hmpos hxpos).mpr hmx + have hmLogLoss : 2 * (j : ℝ) * (log x - log (m : ℝ)) ≤ 1 := by + have h := log_le_sub_one_of_pos (div_pos hxpos hmpos) + rw [log_div hxpos.ne' hmpos.ne', div_sub_one hmpos.ne'] at h + have h' := (le_div_iff₀ hmpos).mp h + have hm4 : 4 * (j : ℝ) ≤ m := by linarith + have hmLoss₀ : 0 ≤ log x - log (m : ℝ) := sub_nonneg.mpr hmLog + have hmul := mul_le_mul_of_nonneg_right hm4 hmLoss₀ + nlinarith only [h',hxm,hmul] + have horder : H j * m ^ (2 * j) ≤ n := by + have hcast : (H j : ℝ) * (m : ℝ) ^ (2*j) ≤ (n : ℝ) := by + apply (log_le_log_iff (by positivity) hn₀).mp + rw [log_mul hHpos.ne' (pow_ne_zero _ hmpos.ne'), log_pow] + push_cast + have hp := mul_le_mul_of_nonneg_left hmLog (show 0 ≤ 2 * (j : ℝ) by positivity) + linarith only [hp,hxLog] + exact_mod_cast hcast + have hshort : 2 * log (m : ℝ) ≤ c * (t + 2) := by + have hcj : c * (t - 1) ≤ c * (j : ℝ) := + mul_le_mul_of_nonneg_left (by linarith) hc.le + have hprod := mul_le_mul_of_nonneg_right hcj (show 0 ≤ t + 2 by linarith) + have hct := mul_nonneg hc.le (show 0 ≤ t - 2 by linarith) + have hupper := mul_le_mul_of_nonneg_left hmLog (show 0 ≤ 2 * (j : ℝ) by positivity) + apply (mul_le_mul_iff_left₀ hjpos).mp + nlinarith only [hupper,hxLog,hlogH₀,hprod,hct,hLt] + refine ⟨m,j,hm₁,hm₀,hmOdd,hj₁,horder,?_,hn₀,hTm.trans ht,hjU,hLt,?_,hshort⟩ + · have hp := mul_le_mul_of_nonneg_left hjU hWpos.le + have hwt := mul_le_mul_of_nonneg_right hW ht₀.le + linarith only [hp,hwt,hxWide,hxm,ht2] + · linarith only [hmLogLoss,hlogH,hxLog, + show 2 * (j : ℝ) * (log x - log (m : ℝ)) = + 2 * (j : ℝ) * log x - 2 * (j : ℝ) * log (m : ℝ) by ring] + +theorem uniform_order_parameters (H : ℕ → ℕ) (A K c η : ℝ) (hA : 1 ≤ A) (hK : 0 ≤ K) + (hc : 0 < c) (hη : 0 < η) (m₀ : ℕ) + (hH : ∀ j : ℕ, 1 ≤ j → 1 ≤ H j ∧ (H j : ℝ) ≤ A * (j : ℝ)) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∃ m j : ℕ, + 1 ≤ m ∧ m₀ ≤ m ∧ Odd m ∧ 1 ≤ j ∧ H j * m ^ (2 * j) ≤ n ∧ + (n : ℝ) ^ 2 * exp (-(2 * sqrt c + η) * sqrt (log n)) ≤ + exp (-c * (j : ℝ)) * (m : ℝ) ^ (4 * j) / + (27 * (1 + K * (j : ℝ) * (m : ℝ) ^ 2)) := by + let C := 27 * (1 + K) + have hC : 1 ≤ C := by dsimp [C]; linarith + have hC₀ : 0 < C := by linarith + have hAl : 0 ≤ log A := log_nonneg hA + have hCl : 0 ≤ log C := log_nonneg hC + let b := 2 * log A + 2 + 2 * c + log C + obtain ⟨T₂,hT₂,h₂⟩ := log_linear_error 3 b (η * sqrt c) (by norm_num) + (by dsimp [b]; linarith) (mul_pos hη (sqrt_pos.mpr hc)) + let M := max m₀ ⌈T₂⌉₊ + obtain ⟨N,hN⟩ := rounded_order_witness H A c hA hc 10 (by norm_num) M hH + refine ⟨N, fun n hn => ?_⟩ + obtain ⟨m,j,hm₁,hmM,hmOdd,hj₁,horder,_,hn₀,htM,hjU,hLt,hround,hshort⟩ := hN n hn + let L := log (n : ℝ) + let t := sqrt (L / c) + change (M : ℝ) + 2 ≤ t at htM + change (j : ℝ) ≤ t at hjU + change L = c * t^2 at hLt + change 2 * (L - 2 * (j : ℝ) * log (m : ℝ)) ≤ 2*(log A + log t + 1) at hround + change _ ≤ c*(t+2) at hshort + have hM : T₂ ≤ (M : ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast (le_max_right m₀ ⌈T₂⌉₊)) + have ht₀ : 0 < t := by linarith + have hjpos : 0 < (j : ℝ) := by exact_mod_cast (show 0 < j by omega) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm₁ + have hmpos : 0 < (m : ℝ) := by linarith + have hm₀ := (le_max_left m₀ ⌈T₂⌉₊).trans hmM + have hsqrt : sqrt L = sqrt c * t := by rw [hLt, sqrt_mul hc.le, sqrt_sq ht₀.le] + have hjLog : log (j : ℝ) ≤ log t := (log_le_log_iff hjpos ht₀).mpr hjU + let D := 27 * (1 + K * (j : ℝ) * (m : ℝ) ^ 2) + have hDpos : 0 < D := by dsimp [D]; positivity + have hDLog : log D ≤ log C + log (j : ℝ) + 2 * log (m : ℝ) := by + have hm2 : 1 ≤ (m : ℝ)^2 := by + nlinarith only [mul_nonneg (show 0 ≤ (m:ℝ)-1 by linarith) (show 0 ≤ (m:ℝ)+1 by positivity)] + have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj₁ + have hmul : 1 ≤ (j : ℝ) * (m : ℝ)^2 := + one_le_mul_of_one_le_of_one_le hjR hm2 + have hD : D ≤ C * (j : ℝ) * (m : ℝ)^2 := by + dsimp [D,C] + linarith only [hmul, show 27 * (1 + K) * (j : ℝ) * (m : ℝ) ^ 2 - + 27 * (1 + K * (j : ℝ) * (m : ℝ) ^ 2) = + 27 * ((j : ℝ) * (m : ℝ)^2 - 1) by ring] + have h := (log_le_log_iff hDpos (show 0 < C * (j : ℝ) * (m : ℝ)^2 by positivity)).mpr hD + rw [log_mul (by positivity : C * (j : ℝ) ≠ 0) (pow_ne_zero _ hmpos.ne'), + log_mul hC₀.ne' hjpos.ne', log_pow] at h + norm_num at h + exact h + have herror := h₂ t (by linarith only [htM,hM]) + have hcoef := mul_le_mul_of_nonneg_left hjU hc.le + have hloss : 2 * (L - 2 * (j : ℝ) * log (m : ℝ)) + + c * (j : ℝ) + log D ≤ (2 * sqrt c + η) * sqrt L := by + rw [hsqrt] + have heq := sq_sqrt hc.le + have hright : (2 * sqrt c + η) * (sqrt c * t) = 2*c*t + (η * sqrt c) * t := by + calc + _ = 2 * (sqrt c)^2 * t + (η * sqrt c) * t := by ring + _ = _ := by rw [heq] + rw [hright] + dsimp [b] at herror + linarith only [herror,hcoef,hDLog,hjLog,hround,hshort] + refine ⟨m,j,hm₁,hm₀,hmOdd,hj₁,horder,?_⟩ + change (n : ℝ)^2 * exp (-(2 * sqrt c + η) * sqrt L) ≤ exp (-c * (j : ℝ)) * (m : ℝ)^(4*j) / D + apply (log_le_log_iff (by positivity) (by positivity)).mp + rw [log_mul (pow_ne_zero _ hn₀.ne') (exp_pos _).ne', log_pow, log_exp, + log_div (by positivity : exp (-c * (j : ℝ)) * (m : ℝ) ^ (4*j) ≠ 0) hDpos.ne', + log_mul (exp_pos _).ne' (pow_ne_zero _ hmpos.ne'), log_exp, log_pow] + push_cast + change 2 * L + -(2 * sqrt c + η) * sqrt L ≤ + -c * (j : ℝ) + (4 * (j : ℝ)) * log (m : ℝ) - log D + linarith only [hloss] + +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean b/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean new file mode 100644 index 0000000000..f93a00ff2a --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean @@ -0,0 +1,145 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.ResidualIsolates + +/-! Split realizations whose new core vertices are universal. -/ + +@[expose] public section +namespace GapExtremal.R434 +open Finset + +section +variable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + [Fintype C] [DecidableEq C] + +/-- The new host labels indexed by a colour and a cyclic base coordinate. -/ +abbrev AddedHosts (V C : Type) [Fintype V] (x : ℕ) := C × ZMod (Fintype.card V + x) + +private def universalPalettes (N : H → Finset V) (colour : V → C) {x q : ℕ} : + H ⊕ (AddedHosts V C x ⊕ Fin q) → Finset (V ⊕ Fin x) + | .inl h => (N h).disjSum univ + | .inr (.inl (c, _)) => (univ.filter fun v => colour v = c).disjSum univ + | .inr (.inr _) => (∅ : Finset V).disjSum univ + +private noncomputable def coreLabel (x : ℕ) [NeZero (Fintype.card V + x)] : (V ⊕ Fin x) ≃ ZMod + (Fintype.card V + x) := + Fintype.equivOfCardEq (by simp [ZMod.card]) + +private noncomputable def universalAssign (φ : V → V → H) (colour : V → C) (c₀ : C) + {x q : ℕ} [NeZero (Fintype.card V + x)] (u v : V ⊕ Fin x) : H ⊕ (AddedHosts V C x ⊕ Fin q) := + match u, v with + | .inl a, .inl b => .inl (φ a b) + | .inl a, .inr _ => .inr (.inl (colour a, coreLabel x u + coreLabel x v)) + | .inr _, .inl b => .inr (.inl (colour b, coreLabel x u + coreLabel x v)) + | .inr _, .inr _ => .inr (.inl (c₀, coreLabel x u + coreLabel x v)) + +omit [DecidableEq H] [DecidableEq V] [Fintype C] [Fintype H] in +private theorem universal_hyp {B : SimpleGraph V} + {N : H → Finset V} {φ : V → V → H} (original : HostHyp B N φ) + (colour : V → C) (c₀ : C) (hcolour : ∀ a b, B.Adj a b → colour a ≠ colour b) + (x q : ℕ) [NeZero (Fintype.card V + x)] : HostHyp (withIsolates B) + (universalPalettes N colour : H ⊕ (AddedHosts V C x ⊕ Fin q) → _) + (universalAssign φ colour c₀) where + indep := by + intro h a ha b hb hab + rcases a with a | a + · rcases b with b | b + · have hab := (isolates_adj_inl B a b).mp hab + rcases h with h | (⟨c,k⟩ | r) + · exact original.indep h a (by simpa [universalPalettes] using ha) + b (by simpa [universalPalettes] using hb) hab + · have ha : colour a = c := by simpa [universalPalettes] using ha + have hb : colour b = c := by simpa [universalPalettes] using hb + exact hcolour a b hab (ha.trans hb.symm) + · simp [universalPalettes] at ha + · exact isolates_not_adj_inr B _ _ hab + · exact isolates_not_adj_inr B _ _ hab.symm + cover := by + intro u v hne hnadj + rcases u with a | a <;> rcases v with b | b + · simpa [universalAssign, universalPalettes] using original.cover a b + (fun e => hne (congrArg Sum.inl e)) (fun h => hnadj ((isolates_adj_inl B a b).mpr h)) + all_goals simp [universalAssign, universalPalettes] + symm := by + intro u v + rcases u with a | a <;> rcases v with b | b <;> + simp [universalAssign, original.symm, add_comm] + inj := by + intro u v v' huv ha huv' ha' heq + have joined {u v v' : V ⊕ Fin x} + (h : coreLabel x u + coreLabel x v = coreLabel x u + coreLabel x v') : v = v' := + (coreLabel x).injective (add_left_cancel h) + rcases u with a | a <;> rcases v with b | b <;> rcases v' with c | c + · simp only [universalAssign, Sum.inl.injEq] at heq + exact congrArg Sum.inl (original.inj a b c (by simpa using huv) (by simpa using ha) + (by simpa using huv') (by simpa using ha') heq) + all_goals + simp only [universalAssign, Sum.inl.injEq, Sum.inr.injEq, Sum.inl_ne_inr, + Sum.inr_ne_inl, Prod.mk.injEq] at heq + all_goals exact joined heq.2 + +omit [DecidableEq C] [DecidableEq H] in +theorem universal_graph_of_host_scores_with_support {B : SimpleGraph V} [DecidableRel B.Adj] + {N : H → Finset V} {φ : V → V → H} (original : HostHyp B N φ) + (colour : V → C) (c₀ : C) (hcolour : ∀ a b, B.Adj a b → colour a ≠ colour b) + {x n : ℕ} (hx : 0 < x) + (hn : Fintype.card (V ⊕ H) + x + Fintype.card C * (Fintype.card V + x) ≤ n) + (I : ℤ) (hi : ∀ P : Finset (Finset V), IsPack P → ∑ Q ∈ P, w B Q ≤ I) + {y : Finset V → ℝ} (hy : ResPack y) : + ∃ (T : Type) (_ : Fintype T) (_ : DecidableEq T) (G : SimpleGraph T), + Fintype.card T = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G x ∧ + (∑ Q, y Q * (w B Q : ℝ)) - (I : ℝ) ≤ gap G ∧ + ((∀ S, y S ≠ 0 → S.card ≤ 3) → + (∑ Q, y Q * (w B Q : ℝ)) - (I : ℝ) ≤ gapWithFracFour G) := by + classical + let : NeZero (Fintype.card V + x) := ⟨by omega⟩ + let q := n - (Fintype.card (V ⊕ H) + x + Fintype.card C * (Fintype.card V + x)) + let M := universalPalettes N colour (x := x) (q := q) + let T := (V ⊕ Fin x) ⊕ (H ⊕ (AddedHosts V C x ⊕ Fin q)) + have hm (i) : x ≤ (M i).card := by + rcases i with h | (⟨c,k⟩ | r) <;> simp [M, universalPalettes, card_disjSum] + have hcore : x ≤ Fintype.card (V ⊕ Fin x) := by simp + have hc : Fintype.card T = n := by + dsimp [T,q] + simp only [Fintype.card_sum,Fintype.card_fin,Fintype.card_prod,ZMod.card] at hn ⊢ + omega + have cuts : SurvivesCuts (hostGraph M) x := by + refine ⟨?_, connected_after_cut M hcore hm⟩ + simp only [Fintype.card_sum, Fintype.card_fin] + have hp : 0 < Fintype.card (AddedHosts V C x) := Fintype.card_pos_iff.mpr ⟨(c₀, 0)⟩ + omega + obtain ⟨z, hz, hs, hscore⟩ := isolate_fractional_lift_with_support (X := Fin x) B hy + have hg := gap_ge (universal_hyp original colour c₀ hcolour x q) I + (isolate_integral_bound B I hi) hz + rw [hscore] at hg + refine ⟨T, inferInstance, inferInstance, hostGraph M, hc, isSplit_hostGraph M, + connected_hostGraph M (.inr ⟨0,hx⟩) (fun i => card_pos.mp (hx.trans_le (hm i))), cuts, hg, ?_⟩ + intro hsmall + have h := gapWithFracFour_ge (universal_hyp original colour c₀ hcolour x q) I + (isolate_integral_bound B I hi) hz (hs hsmall) + rw [hscore] at h + exact h + +omit [DecidableEq C] [DecidableEq H] in +theorem universal_graph_of_host_scores {B : SimpleGraph V} [DecidableRel B.Adj] + {N : H → Finset V} {φ : V → V → H} (original : HostHyp B N φ) + (colour : V → C) (c₀ : C) (hcolour : ∀ a b, B.Adj a b → colour a ≠ colour b) + {x n : ℕ} (hx : 0 < x) + (hn : Fintype.card (V ⊕ H) + x + Fintype.card C * (Fintype.card V + x) ≤ n) + (I : ℤ) (hi : ∀ P : Finset (Finset V), IsPack P → ∑ Q ∈ P, w B Q ≤ I) + {y : Finset V → ℝ} (hy : ResPack y) : + ∃ (T : Type) (_ : Fintype T) (_ : DecidableEq T) (G : SimpleGraph T), + Fintype.card T = n ∧ IsSplit G ∧ G.Connected ∧ SurvivesCuts G x ∧ + (∑ Q, y Q * (w B Q : ℝ)) - (I : ℝ) ≤ gap G := by + obtain ⟨T, fT, dT, G, hc, hsplit, hconn, hcuts, hgap, _⟩ := + universal_graph_of_host_scores_with_support original colour c₀ hcolour hx hn I hi hy + exact ⟨T, fT, dT, G, hc, hsplit, hconn, hcuts, hgap⟩ + +end +end GapExtremal.R434 diff --git a/LeanPool/SplitCliqueGap/R434/UniversalR434.lean b/LeanPool/SplitCliqueGap/R434/UniversalR434.lean new file mode 100644 index 0000000000..d6cfb26169 --- /dev/null +++ b/LeanPool/SplitCliqueGap/R434/UniversalR434.lean @@ -0,0 +1,85 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.R434.DensityThreshold +public import LeanPool.SplitCliqueGap.R434.UniformOrder +public import LeanPool.SplitCliqueGap.R434.FiniteR434 +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring + +/-! R434 for every sufficiently large graph order, with no external hypotheses. -/ + +@[expose] public section + +namespace GapExtremal.R434 + +open Real EHPS + +theorem universal_R434 (η : ℝ) (hη : 0 < η) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∃ (V : Type) (_ : Fintype V) (_ : DecidableEq V) (G : SimpleGraph V), + Fintype.card V = n ∧ IsSplit G ∧ G.Connected ∧ + (n : ℝ)^2 * exp (-(2 * sqrt (log (24/7)) + η) * sqrt (log n)) ≤ gap G := by + let a := sqrt (log (24/7)) + have ha : 0 ≤ a := sqrt_nonneg _ + have ha2 : a^2 = log (24/7) := sq_sqrt (log_nonneg (by norm_num)) + let c := (a + η/4)^2 + have hc : 0 < c := sq_pos_of_pos (by linarith) + have hc' : log (24/7) < c := by + dsimp [c] + nlinarith only [ha,ha2,hη,mul_nonneg ha hη.le,sq_pos_of_pos hη] + have hcoeff : 2 * sqrt c + η/2 = 2 * a + η := by + simp only [c, sqrt_sq (show 0 ≤ a + η/4 by linarith)] + ring + let ρ := exp (-c) + have hρ₀ : 0 < ρ := exp_pos _ + have hρ₁ : ρ < 7/24 := by + have h : ρ < exp (-log (24/7)) := exp_lt_exp.mpr (by linarith only [hc']) + rw [exp_neg, exp_log (by norm_num : (0 : ℝ) < 24/7)] at h + norm_num at h ⊢ + exact h + obtain ⟨ε,m₀,hε,hε₁,hdensity⟩ := density_below_seven_twentyfour hρ₀ hρ₁ + have hH (j : ℕ) (hj : 1 ≤ j) : 1 ≤ hostFactor j ∧ (hostFactor j : ℝ) ≤ 1050015*(j : ℝ) := by + constructor + · unfold hostFactor + omega + · have hjR : (1 : ℝ) ≤ j := by exact_mod_cast hj + unfold hostFactor + push_cast + linarith + obtain ⟨N,hN⟩ := uniform_order_parameters hostFactor 1050015 (200/ε^2) c (η/2) + (by norm_num) (by positivity) hc (by positivity) m₀ hH + refine ⟨N,fun n hn => ?_⟩ + obtain ⟨m,j,hmpos,hm₀,hmOdd,_,horder,hsize⟩ := hN n hn + let : NeZero m := ⟨by omega⟩ + have horder' : hostFactor j * (m^2)^j ≤ n := by simpa only [pow_mul] using horder + obtain ⟨V,fV,dV,G,hcard,hsplit,hconn,hgap⟩ := + finite_gap_of_product hε hε₁ hmOdd horder' + refine ⟨V,fV,dV,G,hcard,hsplit,hconn,?_⟩ + rw [hcoeff] at hsize + refine hsize.trans (le_trans ?_ hgap) + apply div_le_div_of_nonneg_right _ (by positivity) + have hden := hdensity m hm₀ + have hpw := pow_le_pow_left₀ (mul_nonneg hρ₀.le (sq_nonneg (m : ℝ))) hden j + have hprod := mul_le_mul_of_nonneg_right hpw + (show 0 ≤ ((m : ℝ)^2)^j by positivity) + have hre : (ρ * (m : ℝ)^2)^j * ((m : ℝ)^2)^j = + exp (-c * (j : ℝ)) * (m : ℝ)^(4*j) := by + rw [mul_pow, show ρ^j = exp (-c * (j : ℝ)) by + change exp (-c) ^ j = _ + rw [← exp_nat_mul, mul_comm (j : ℝ) (-c)]] + rw [mul_assoc, ← pow_add, ← pow_mul] + congr 2 + omega + rw [hre] at hprod + exact hprod + +end GapExtremal.R434 diff --git a/LeanPool/projects/split-clique-partition-gap.yaml b/LeanPool/projects/split-clique-partition-gap.yaml new file mode 100644 index 0000000000..75f2258ac5 --- /dev/null +++ b/LeanPool/projects/split-clique-partition-gap.yaml @@ -0,0 +1,41 @@ +slug: split-clique-partition-gap +title: Nearly quadratic additive gaps for edge-clique partitions of split graphs +summary: Constructs connected split graphs of every sufficiently large order with a nearly + quadratic difference between the integral and fractional edge-clique partition numbers. + The strongest construction also withstands deletion of any set of fewer than one fifth + of the vertices. The development includes host assignments that transfer residual + triangle-packings to clique partitions, and quantitative product constructions. +branch: graph theory +entry_module: LeanPool.SplitCliqueGap +authors: +- Juan Pablo Traverso Gianini +source: + doi: 10.5281/zenodo.24408988 + url: https://github.com/jtraverso/split-clique-partition-gap/tree/e96952eb38aaac532e5714be66a80535ebfd547a/preprints/SPLITGAP + github_repo: jtraverso/split-clique-partition-gap + commit: e96952eb38aaac532e5714be66a80535ebfd547a + announcement_url: https://github.com/jtraverso/split-clique-partition-gap/commit/e96952eb38aaac532e5714be66a80535ebfd547a + announcement_date: '2026-11-22' +license: Apache-2.0 +status: verified +provenance: AI +main_declarations: +- GapExtremal.R434.universal_R434_linear +- GapExtremal.R434.universal_R434_linear_mixed +- GapExtremal.R434.universal_R434_polylog +main_results: +- declaration: GapExtremal.R434.universal_R434_linear + informal: Constructs a connected split graph of each sufficiently large order with a nearly quadratic gap and a linear cut guarantee. +- declaration: GapExtremal.R434.universal_R434_linear_mixed + informal: Obtains the same gap and cut guarantee with fractional clique sizes restricted to at most four. +- declaration: GapExtremal.R434.universal_R434_polylog + informal: Proves the uniform nearly quadratic lower bound on the split-graph gap. +tags: +- graph-theory +- split-graphs +- clique-partitions +- combinatorial-optimization +msc: +- 05C70 +- 05C35 +- 90C27 From b5aa7246c10ad5b44ebace275055184ad7ae4499 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 11:23:22 +0000 Subject: [PATCH 2/7] Complete upstream modification notice and clarify cut survival --- LeanPool/SplitCliqueGap.lean | 1 + LeanPool/projects/split-clique-partition-gap.yaml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/LeanPool/SplitCliqueGap.lean b/LeanPool/SplitCliqueGap.lean index 43cd1d8458..b5ee5beb6a 100644 --- a/LeanPool/SplitCliqueGap.lean +++ b/LeanPool/SplitCliqueGap.lean @@ -3,6 +3,7 @@ Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Juan Pablo Traverso Gianini -/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module public import LeanPool.SplitCliqueGap.R434.PolylogGap diff --git a/LeanPool/projects/split-clique-partition-gap.yaml b/LeanPool/projects/split-clique-partition-gap.yaml index 75f2258ac5..d6d7f7e8ed 100644 --- a/LeanPool/projects/split-clique-partition-gap.yaml +++ b/LeanPool/projects/split-clique-partition-gap.yaml @@ -2,8 +2,8 @@ slug: split-clique-partition-gap title: Nearly quadratic additive gaps for edge-clique partitions of split graphs summary: Constructs connected split graphs of every sufficiently large order with a nearly quadratic difference between the integral and fractional edge-clique partition numbers. - The strongest construction also withstands deletion of any set of fewer than one fifth - of the vertices. The development includes host assignments that transfer residual + The strongest construction remains connected after deletion of any set of fewer + than one fifth of the vertices. The development includes host assignments that transfer residual triangle-packings to clique partitions, and quantitative product constructions. branch: graph theory entry_module: LeanPool.SplitCliqueGap From f618d5d9f48ad6aac13ea5bf9b018a873760db6a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 11:32:14 +0000 Subject: [PATCH 3/7] Reuse split partitions and share repeated gap estimates --- .../GapExtremal/ExactOrder.lean | 40 +---- .../GapExtremal/ExponentTwo.lean | 143 ++---------------- LeanPool/SplitCliqueGap/GapExtremal/SCap.lean | 32 +--- .../SplitCliqueGap/GapExtremal/Single.lean | 71 +++++---- LeanPool/SplitCliqueGap/Imports.lean | 1 + .../R434/ExactGraphTransfer.lean | 2 +- LeanPool/SplitCliqueGap/SplitPartition.lean | 37 +++++ 7 files changed, 90 insertions(+), 236 deletions(-) create mode 100644 LeanPool/SplitCliqueGap/SplitPartition.lean diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean index c7a41f3dd9..45298f0f1d 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.ExponentTwo +public import LeanPool.SplitCliqueGap.GapExtremal.Sphere public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected import Mathlib.Tactic.Choose import Mathlib.Tactic.FieldSimp @@ -208,44 +208,6 @@ variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] abbrev SVk (F U : Type) (j k : ℕ) := (F × (Fin j → U)) ⊕ (PHostIdx F (Fin j → U) F U ⊕ Fin k) -omit [DecidableEq F] [Field F] [AddCommGroup U] [Module F U] [DecidableEq U] in -theorem card_SV_le [Nonempty U] (j : ℕ) : - Fintype.card (SV F U j) ≤ 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ^ j - := by - set M := Fintype.card U - set q := Fintype.card F - have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) - rw [hc] - simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, - Fintype.card_fin, Sym2.card] - set X := M ^ j - set C2 := (q + 1).choose 2 with hC2 - have hsym : C2 ≤ (q + 1) ^ 2 := by - rw [hC2, Nat.choose_two_right, sq] - exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) - have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 - have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by - calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym - _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) - _ = (q + 1) ^ 4 := by ring - have f3 : q * C2 ≤ (q + 1) ^ 4 := by - calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym - _ ≤ (q + 1) ^ 4 := by - calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring - _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have hM1 : 1 ≤ M := Fintype.card_pos - have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) - have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX - have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring - have e3 : q * X * C2 = (q * C2) * X := by ring - have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX - have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 - calc q * X + q * X * (M * q * C2) + q * X * C2 - ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by - rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 - _ = 3 * (q + 1) ^ 4 * M * X := by ring - omit [DecidableEq F] [DecidableEq U] in /-- **TP-cond for S-caps, exact order, connected.** -/ theorem tp_single_s_exact (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ) (A : Set U)) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean index acf5fbb46e..a491edad19 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExponentTwo.lean @@ -6,152 +6,27 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.Sphere -import Mathlib.Tactic.Choose -import Mathlib.Tactic.FieldSimp -import Mathlib.Tactic.Linarith -import Mathlib.Tactic.NormNum -import Mathlib.Tactic.Positivity -import Mathlib.Tactic.Push -import Mathlib.Tactic.Ring +public import LeanPool.SplitCliqueGap.GapExtremal.ExactOrder /-! -# The exponent of the split gap is 2 (ledger §17, Theorem 17.0) +# The split-graph gap at bounded order -For every `ε > 0` there are `c > 0` and `N₀` such that every `n ≥ N₀` admits a split graph with at -most `n` -vertices and `cp − cp* ≥ c · n^{2 − ε}`. - -Proof: a large prime `p` with `log 10 / log p ≤ ε/2`, `K = (p - 1)/10`, a large sphere in -`{0..K}^N` (an S-cap in -`F_p^N`, `isSCap_seed`), and the S-cap transfer `tp_single_s`. +The exact-order construction also gives the `n ^ (2 - ε)` bound under a vertex budget of `n`. -/ @[expose] public section namespace GapExtremal -open Finset - -/-- **Theorem 17.0.** The gap `cp − cp*` on split graphs with at most `n` vertices is `≥ c n^{2 − -ε}`. -/ +/-- For every `ε > 0`, split graphs with at most `n` vertices have gap at least +`c * n ^ (2 - ε)` for some positive `c` and every sufficiently large `n`. -/ theorem exponent_two {ε : ℝ} (hε : 0 < ε) : ∃ c : ℝ, 0 < c ∧ ∃ N₀ : ℕ, ∀ n : ℕ, N₀ ≤ n → ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), Fintype.card V' ≤ n ∧ IsSplit G' ∧ c * (n : ℝ) ^ (2 - ε) ≤ gap G' := by - have hl10 : 0 < Real.log 10 := Real.log_pos (by norm_num) - -- a large prime - obtain ⟨p, hpM, hpp⟩ := Nat.exists_infinite_primes (⌈Real.exp (2 * Real.log 10 / ε)⌉₊ + 11) - have : Fact p.Prime := ⟨hpp⟩ - have hp11 : 11 ≤ p := by omega - have hp5 : 5 < p := by omega - set K := (p - 1) / 10 with hKdef - have hK : 10 * K < p := by - have := Nat.div_mul_le_self (p - 1) 10 - rw [hKdef]; omega - have hK1 : 1 ≤ K := by rw [hKdef]; exact (Nat.le_div_iff_mul_le (by norm_num)).mpr (by omega) - have hpK : p ≤ 10 * (K + 1) := by - have h1 := Nat.div_add_mod (p - 1) 10 - have h2 := Nat.mod_lt (p - 1) (show 0 < 10 by norm_num) - rw [hKdef]; omega - have hpr : (1 : ℝ) < p := by exact_mod_cast (show 1 < p by omega) - set L := Real.log p with hLdef - have hL : 0 < L := Real.log_pos hpr - have hLbig : 2 * Real.log 10 / ε ≤ L := by - have h1 : Real.exp (2 * Real.log 10 / ε) ≤ p := by - have := Nat.le_ceil (Real.exp (2 * Real.log 10 / ε)) - have h2 : ((⌈Real.exp (2 * Real.log 10 / ε)⌉₊ : ℕ) : ℝ) ≤ p := by exact_mod_cast (by omega : - _ ≤ p) - linarith - rw [hLdef, ← Real.log_exp (2 * Real.log 10 / ε)] - exact Real.log_le_log (Real.exp_pos _) h1 - have hlog10 : Real.log 10 / L ≤ ε / 2 := by - rw [div_le_iff₀ hL] - have := mul_le_mul_of_nonneg_left hLbig hε.le - rw [mul_div_cancel₀ _ hε.ne'] at this - linarith - have hKlog : L ≤ Real.log 10 + Real.log (K + 1) := by - rw [← Real.log_mul (by norm_num) (by positivity)] - exact Real.log_le_log (by positivity) (by exact_mod_cast hpK) - -- choose `N` with `log (N R' + 1) ≤ (ε/2) N L` - set R' := K ^ 2 + 1 with hR'def - have hR'pos : (0 : ℝ) < R' := by positivity - have hε2 : 0 < ε / 2 := by positivity - set a : ℝ := L / R' - have ha : a ≠ 0 := by positivity - have ht := Real.tendsto_pow_log_div_mul_add_atTop a (-a) 1 ha - obtain ⟨X, hX⟩ := Filter.eventually_atTop.mp ((tendsto_order.1 ht).2 (ε / 2) hε2) - set N : ℕ := ⌈X⌉₊ + 1 with hNdef - have hN : 0 < N := by omega - have hxN : X ≤ (N : ℝ) * R' + 1 := by - have h1 := Nat.le_ceil X - have h2 : (⌈X⌉₊ : ℝ) ≤ N := by exact_mod_cast (show ⌈X⌉₊ ≤ N by omega) - have h3 : (N : ℝ) ≤ N * R' := by - have : (1 : ℝ) ≤ R' := by exact_mod_cast (show 1 ≤ R' by omega) - nlinarith - linarith - have hlogN : Real.log ((N : ℝ) * R' + 1) ≤ ε / 2 * (N * L) := by - have := (hX _ hxN).le - simp only [pow_one] at this - have hden : a * ((N : ℝ) * R' + 1) + -a = N * L := by - simp only [a]; field_simp; ring - rw [hden, div_le_iff₀ (by positivity)] at this - linarith - -- the seed - obtain ⟨r, hr⟩ := exists_large_sphere K N (R := R') (by omega) - set A := seed p K N r with hAdef - have hAcard : A.card = (sphere K N r).card := card_sphereSeed (by omega) - have hApos : 0 < A.card := by - rw [hAcard] - by_contra h0 - push Not at h0 - have : (sphere K N r).card = 0 := by omega - rw [this, mul_zero] at hr - have : 0 < (K + 1) ^ N := by positivity - omega - have hcardU : Fintype.card (Fin N → ZMod p) = p ^ N := by simp - have hM : 2 ≤ Fintype.card (Fin N → ZMod p) := by - rw [hcardU] - calc 2 ≤ p ^ 1 := by simp; omega - _ ≤ p ^ N := Nat.pow_le_pow_right (by omega) hN - have he : (fun _ => (1 : ZMod p) : Fin N → ZMod p) ≠ 0 := by - intro h - have := congrFun h ⟨0, hN⟩ - simp at this - obtain ⟨c, hc, h⟩ := tp_single_s (colσ hp5) (isSCap_seed (N := N) (r := r) hK hp5) - (Finset.card_pos.mp hApos) he hM - refine ⟨c, hc, 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * - Fintype.card (Fin N → ZMod p), fun n hn => ?_⟩ - obtain ⟨V', i1, i2, G', hcard, hsplit, hgap⟩ := h n hn - refine ⟨V', i1, i2, G', hcard, hsplit, le_trans ?_ hgap⟩ - have hn1 : (1 : ℝ) ≤ n := by - have h0 : 0 < 3 * (Fintype.card (ZMod p) + 1) ^ 4 * Fintype.card (Fin N → ZMod p) * - Fintype.card (Fin N → ZMod p) := by positivity - have : 1 ≤ n := by omega - exact_mod_cast this - have hlogU : Real.log (Fintype.card (Fin N → ZMod p) : ℝ) = N * L := by - rw [hcardU]; push_cast - rw [Real.log_pow] - have hrate : 1 - ε ≤ Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ) := by - rw [hlogU] - have hA : ((K + 1 : ℕ) : ℝ) ^ N ≤ ((N : ℝ) * R' + 1) * A.card := by - rw [hAcard]; exact_mod_cast hr - have hlog : (N : ℝ) * Real.log (K + 1) ≤ Real.log ((N : ℝ) * R' + 1) + Real.log A.card := by - have hK0 : (0 : ℝ) < ((K + 1 : ℕ) : ℝ) := by positivity - rw [← Real.log_mul (by positivity) (by exact_mod_cast hApos.ne')] - have := Real.log_le_log (by positivity) hA - rw [Real.log_pow] at this - push_cast at this - exact this - have hNL : (0 : ℝ) < N * L := by positivity - rw [le_div_iff₀ hNL] - -- `log 10 ≤ (ε/2) L` - have h10 : Real.log 10 ≤ ε / 2 * L := by - rw [div_le_iff₀ hL] at hlog10; linarith - have hNr : (0 : ℝ) < N := by exact_mod_cast hN - nlinarith - have hexp := Real.rpow_le_rpow_of_exponent_le hn1 (by linarith : - 2 - ε ≤ 1 + Real.log A.card / Real.log (Fintype.card (Fin N → ZMod p) : ℝ)) - exact mul_le_mul_of_nonneg_left hexp hc.le + obtain ⟨c, hc, N, hN⟩ := exponent_two_exact hε + refine ⟨c, hc, N, fun n hn => ?_⟩ + obtain ⟨V, fV, dV, G, hcard, hsplit, _, hgap⟩ := hN n hn + exact ⟨V, fV, dV, G, hcard.le, hsplit, hgap⟩ end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean index ac1da4cc65..b2b9ee8ef1 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean @@ -337,43 +337,13 @@ theorem tp_single_s (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by classical set M := Fintype.card U - set q := Fintype.card F have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by obtain ⟨a0, ha0⟩ := hA0 exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) - · have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) - rw [hc] - simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, - Fintype.card_fin, Sym2.card] - set X := M ^ j - set C2 := (q + 1).choose 2 with hC2 - have hsym : C2 ≤ (q + 1) ^ 2 := by - rw [hC2, Nat.choose_two_right, sq] - exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) - have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 - have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by - calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym - _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) - _ = (q + 1) ^ 4 := by ring - have f3 : q * C2 ≤ (q + 1) ^ 4 := by - calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym - _ ≤ (q + 1) ^ 4 := by - calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring - _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) - have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX - have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring - have e3 : q * X * C2 = (q * C2) * X := by ring - have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX - have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 - calc q * X + q * X * (M * q * C2) + q * X * C2 - ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by - rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 - _ = 3 * (q + 1) ^ 4 * M * X := by ring + · exact card_SV_le j · have h := pgap_ge_third_s (single (W := Fin j → U) σ) (isSCap_capPow hA j) (hcapne j) (prodSep A he j) (single_same σ) rw [card_capPow] at h diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean index 3a343a22b6..e72e3b076c 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean @@ -60,6 +60,45 @@ variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] abbrev SV (F U : Type) (j : ℕ) := (F × (Fin j → U)) ⊕ PHostIdx F (Fin j → U) F U +omit [DecidableEq F] [Field F] [AddCommGroup U] [Module F U] [DecidableEq U] in +/-- Bound the order of the one-layer construction by its field and module sizes. -/ +theorem card_SV_le [Nonempty U] (j : ℕ) : + Fintype.card (SV F U j) ≤ 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ^ j + := by + set M := Fintype.card U + set q := Fintype.card F + have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) + rw [hc] + simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, + Fintype.card_fin, Sym2.card] + set X := M ^ j + set C2 := (q + 1).choose 2 with hC2 + have hsym : C2 ≤ (q + 1) ^ 2 := by + rw [hC2, Nat.choose_two_right, sq] + exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) + have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 + have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by + calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym + _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) + _ = (q + 1) ^ 4 := by ring + have f3 : q * C2 ≤ (q + 1) ^ 4 := by + calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym + _ ≤ (q + 1) ^ 4 := by + calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring + _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) + have hM1 : 1 ≤ M := Fintype.card_pos + have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) + have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX + have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring + have e3 : q * X * C2 = (q * C2) * X := by ring + have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX + have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 + calc q * X + q * X * (M * q * C2) + q * X * C2 + ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by + rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 + _ = 3 * (q + 1) ^ 4 * M * X := by ring + omit [DecidableEq F] [DecidableEq U] in /-- **TP-cond without SEP.** -/ theorem tp_single (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hA0 : A.Nonempty) {e @@ -72,43 +111,13 @@ theorem tp_single (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) ( c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by classical set M := Fintype.card U - set q := Fintype.card F have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by obtain ⟨a0, ha0⟩ := hA0 exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) - · have hc := pcard_vertices (F := F) (W := Fin j → U) (V := F × (Fin j → U)) (P := F) (U := U) - rw [hc] - simp only [Fintype.card_prod, Fintype.card_pi, Finset.prod_const, Finset.card_univ, - Fintype.card_fin, Sym2.card] - set X := M ^ j - set C2 := (q + 1).choose 2 with hC2 - have hsym : C2 ≤ (q + 1) ^ 2 := by - rw [hC2, Nat.choose_two_right, sq] - exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le _ _)) - have hq4 : (q + 1) ^ 2 ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have f1 : q ≤ (q + 1) ^ 4 := le_trans (by nlinarith) hq4 - have f2 : q * q * C2 ≤ (q + 1) ^ 4 := by - calc q * q * C2 ≤ q * q * (q + 1) ^ 2 := Nat.mul_le_mul_left _ hsym - _ ≤ (q + 1) ^ 2 * (q + 1) ^ 2 := Nat.mul_le_mul_right _ (by nlinarith) - _ = (q + 1) ^ 4 := by ring - have f3 : q * C2 ≤ (q + 1) ^ 4 := by - calc q * C2 ≤ (q + 1) * (q + 1) ^ 2 := Nat.mul_le_mul (by omega) hsym - _ ≤ (q + 1) ^ 4 := by - calc (q + 1) * (q + 1) ^ 2 = (q + 1) ^ 3 := by ring - _ ≤ (q + 1) ^ 4 := Nat.pow_le_pow_right (by omega) (by norm_num) - have hX : X ≤ M * X := Nat.le_mul_of_pos_left _ (by omega) - have e1 : q * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f1 hX - have e2 : q * X * (M * q * C2) = (q * q * C2) * (M * X) := by ring - have e3 : q * X * C2 = (q * C2) * X := by ring - have e4 : (q * C2) * X ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul f3 hX - have e5 : (q * q * C2) * (M * X) ≤ (q + 1) ^ 4 * (M * X) := Nat.mul_le_mul_right _ f2 - calc q * X + q * X * (M * q * C2) + q * X * C2 - ≤ (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) + (q + 1) ^ 4 * (M * X) := by - rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 - _ = 3 * (q + 1) ^ 4 * M * X := by ring + · exact card_SV_le j · have h := pgap_ge_third (single (W := Fin j → U) σ) (isCap_capPow hA j) (hcapne j) (prodSep A he j) (single_same σ) rw [card_capPow] at h diff --git a/LeanPool/SplitCliqueGap/Imports.lean b/LeanPool/SplitCliqueGap/Imports.lean index 20a42b3eb8..a9ade8c66f 100644 --- a/LeanPool/SplitCliqueGap/Imports.lean +++ b/LeanPool/SplitCliqueGap/Imports.lean @@ -75,3 +75,4 @@ public import LeanPool.SplitCliqueGap.R434.TripartiteSlack public import LeanPool.SplitCliqueGap.R434.UniformOrder public import LeanPool.SplitCliqueGap.R434.UniversalHosts public import LeanPool.SplitCliqueGap.R434.UniversalR434 +public import LeanPool.SplitCliqueGap.SplitPartition diff --git a/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean index 4d21f86714..564b6f3977 100644 --- a/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean +++ b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.ExactOrder +public import LeanPool.SplitCliqueGap.GapExtremal.ExponentTwo /-! The GraphBase bridge and leaf padding at an arbitrary order. -/ diff --git a/LeanPool/SplitCliqueGap/SplitPartition.lean b/LeanPool/SplitCliqueGap/SplitPartition.lean new file mode 100644 index 0000000000..c061aea4a8 --- /dev/null +++ b/LeanPool/SplitCliqueGap/SplitPartition.lean @@ -0,0 +1,37 @@ +/- +Copyright (c) 2026 Lean Pool contributors. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Lean Pool contributors +-/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Main +public import LeanPool.StructuralGraphClasses.Split + +/-! The split witnesses in this development give split partitions in the shared graph API. -/ + +public section + +namespace GapExtremal + +/-- The clique-and-complement condition is equivalent to admitting a split partition. -/ +theorem isSplit_iff_simpleGraph_isSplit {V : Type*} (G : SimpleGraph V) : + IsSplit G ↔ G.IsSplit := by + constructor + · rintro ⟨K, hK, hOutside⟩ + exact ⟨{ + clique := K + independent := Kᶜ + isClique := fun u hu v hv hne => hK u hu v hv hne + isIndepSet := fun u hu v hv _ => hOutside u hu v hv + disjoint := disjoint_compl_right + cover := Set.union_compl_self K + }⟩ + · rintro ⟨P⟩ + refine ⟨P.clique, fun _ hu _ hv hne => P.isClique hu hv hne, ?_⟩ + intro u hu v hv hAdj + have hu' := (P.mem_clique_or_mem_independent u).resolve_left hu + have hv' := (P.mem_clique_or_mem_independent v).resolve_left hv + exact P.isIndepSet hu' hv' hAdj.ne hAdj + +end GapExtremal From 4f443125c1cd69c04d17a31facf326b2095a57f0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 12:44:48 +0000 Subject: [PATCH 4/7] Share graph construction proofs and narrow split-gap imports --- .../SplitCliqueGap/GapExtremal/Bridge.lean | 30 +- LeanPool/SplitCliqueGap/GapExtremal/Core.lean | 196 +++++++++++-- .../GapExtremal/ExactOrder.lean | 135 +-------- .../SplitCliqueGap/GapExtremal/Exponent.lean | 88 +++--- .../SplitCliqueGap/GapExtremal/Global.lean | 169 +----------- .../SplitCliqueGap/GapExtremal/Global2.lean | 4 +- .../GapExtremal/GlobalLemmas.lean | 50 ++++ .../GapExtremal/GraphPadding.lean | 106 +++++++ .../SplitCliqueGap/GapExtremal/Layered.lean | 6 +- .../GapExtremal/LayeredExponent.lean | 47 +--- LeanPool/SplitCliqueGap/GapExtremal/Main.lean | 16 +- .../SplitCliqueGap/GapExtremal/PCore.lean | 132 +++------ .../SplitCliqueGap/GapExtremal/PSource.lean | 46 +--- LeanPool/SplitCliqueGap/GapExtremal/SCap.lean | 258 +----------------- .../SplitCliqueGap/GapExtremal/Source.lean | 92 ++++--- .../SplitCliqueGap/GapExtremal/Sphere.lean | 2 - .../GraphBase/Clique/Partition.lean | 105 +++---- LeanPool/SplitCliqueGap/Imports.lean | 1 + .../R417/LogErrorAbsorption.lean | 8 +- .../SplitCliqueGap/R434/CoreFractional.lean | 24 +- LeanPool/SplitCliqueGap/R434/EHPSDensity.lean | 1 + LeanPool/SplitCliqueGap/R434/EHPSRegion.lean | 2 - .../R434/ExactGraphTransfer.lean | 2 +- .../SplitCliqueGap/R434/TripartiteSlack.lean | 1 + .../SplitCliqueGap/R434/UniformOrder.lean | 11 +- 25 files changed, 582 insertions(+), 950 deletions(-) create mode 100644 LeanPool/SplitCliqueGap/GapExtremal/GraphPadding.lean diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean index 6c9223f570..437611f008 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean @@ -61,43 +61,33 @@ theorem card_adj_add_j (S : Finset V) : theorem e_eq_card_adjPairs (S : Finset V) : e B S = (adjPairs B S).card := by unfold e adjPairs - refine Finset.card_bij (fun s _ => Sym2.lift ⟨fun u v => ({u, v} : Finset V), - fun u v => Finset.pair_comm u v⟩ s) ?_ ?_ ?_ + refine Finset.card_bij (fun s _ => s.toFinset) ?_ ?_ ?_ · intro s hs induction s using Sym2.ind with | h u v => rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs - simp only [Sym2.lift_mk, Finset.mem_filter, Finset.mem_powersetCard] + simp only [Sym2.toFinset_mk_eq, Finset.mem_filter, Finset.mem_powersetCard] refine ⟨⟨?_, Finset.card_pair hs.1.ne⟩, u, by simp, v, by simp, hs.1⟩ intro x hx simp only [mem_insert, mem_singleton] at hx rcases hx with rfl | rfl exacts [hs.2.1, hs.2.2] - · intro s hs t ht hst + · intro s hs t _ hst induction s using Sym2.ind with | h a b => - induction t using Sym2.ind with - | h c d => - rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs ht - simp only [Sym2.lift_mk] at hst - have hab := hs.1.ne - have hcd := ht.1.ne - have hc : c ∈ ({a, b} : Finset V) := hst ▸ (by simp) - have hd : d ∈ ({a, b} : Finset V) := hst ▸ (by simp) - simp only [mem_insert, mem_singleton] at hc hd - rw [Sym2.eq_iff] - rcases hc with rfl | rfl <;> rcases hd with rfl | rfl - · exact absurd rfl hcd - · exact Or.inl ⟨rfl, rfl⟩ - · exact Or.inr ⟨rfl, rfl⟩ - · exact absurd rfl hcd + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs + have hab := hs.1 + have ha : a ∈ t.toFinset := hst ▸ (by simp) + have hb : b ∈ t.toFinset := hst ▸ (by simp) + rw [Sym2.mem_toFinset] at ha hb + exact ((Sym2.mem_and_mem_iff hab.ne).mp ⟨ha, hb⟩).symm · intro p hp simp only [Finset.mem_filter, Finset.mem_powersetCard] at hp obtain ⟨⟨hpS, h2⟩, x, hx, y, hy, hxy⟩ := hp refine ⟨s(x, y), ?_, ?_⟩ · rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] exact ⟨hxy, hpS hx, hpS hy⟩ - · simp only [Sym2.lift_mk] + · simp only [Sym2.toFinset_mk_eq] exact Finset.eq_of_subset_of_card_le (fun z hz => by simp only [mem_insert, mem_singleton] at hz rcases hz with rfl | rfl <;> assumption) (by rw [h2, card_pair hxy.ne]) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Core.lean b/LeanPool/SplitCliqueGap/GapExtremal/Core.lean index 26dfcc16e8..dfd07bec35 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Core.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Core.lean @@ -9,7 +9,9 @@ module public import LeanPool.SplitCliqueGap.GapExtremal.Geometry public import LeanPool.SplitCliqueGap.GapExtremal.LocalEmbed import Mathlib.Tactic.Ring +import Mathlib.Algebra.Module.Torsion.Field import Mathlib.Tactic.Abel +import Mathlib.Tactic.Push /-! # The core `F × W`, its blocks and the graph `B` (ledger §4–§5, §7) @@ -30,6 +32,91 @@ namespace GapExtremal open Finset +section SCapDef + +variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] + +/-- `A` is an `S`-cap: no colour relation `(s₂ - s₁) a + (s₃ - s₂) b + (s₁ - s₃) c = 0` with `s₁ ≠ +s₂` among three +distinct points of `A`. -/ +def IsSCap (S : Set K) (A : Set V) : Prop := + ∀ ⦃a⦄, a ∈ A → ∀ ⦃b⦄, b ∈ A → ∀ ⦃c⦄, c ∈ A → a ≠ b → a ≠ c → b ≠ c → + ∀ ⦃s₁⦄, s₁ ∈ S → ∀ ⦃s₂⦄, s₂ ∈ S → ∀ ⦃s₃⦄, s₃ ∈ S → s₁ ≠ s₂ → + (s₂ - s₁) • a + (s₃ - s₂) • b + (s₁ - s₃) • c ≠ 0 + +/-- A colour relation with `s₂ = s₃` forces `a = c`. -/ +theorem rel_eq23 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} + (h : (s₂ - s₁) • a + (s₂ - s₂) • b + (s₁ - s₂) • c = 0) : a = c := by + have : (s₂ - s₁) • (a - c) = 0 := by + rw [smul_sub] + have e : (s₁ - s₂) • c = -((s₂ - s₁) • c) := by rw [← neg_smul, neg_sub] + rw [sub_self, zero_smul, add_zero, e] at h + simpa [sub_eq_add_neg] using h + rcases smul_eq_zero.mp this with h0 | h0 + · exact absurd (sub_eq_zero.mp h0).symm h12 + · exact sub_eq_zero.mp h0 + +/-- A colour relation with `s₁ = s₃` forces `a = b`. -/ +theorem rel_eq13 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} + (h : (s₂ - s₁) • a + (s₁ - s₂) • b + (s₁ - s₁) • c = 0) : a = b := by + have : (s₂ - s₁) • (a - b) = 0 := by + rw [smul_sub] + have e : (s₁ - s₂) • b = -((s₂ - s₁) • b) := by rw [← neg_smul, neg_sub] + rw [sub_self, zero_smul, add_zero, e] at h + simpa [sub_eq_add_neg] using h + rcases smul_eq_zero.mp this with h0 | h0 + · exact absurd (sub_eq_zero.mp h0).symm h12 + · exact sub_eq_zero.mp h0 + +/-- S-caps are closed under powers. -/ +theorem IsSCap.pi {ι : Type*} {S : Set K} {A : Set V} (hA : IsSCap S A) : + IsSCap S (Set.pi Set.univ (fun _ : ι => A)) := by + intro a ha b hb c hc hab hac hbc s₁ h1 s₂ h2 s₃ h3 h12 hrel + have hcoord : ∀ i, (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • c i = 0 := fun i => by + simpa using congrFun hrel i + by_cases h23 : s₂ = s₃ + · subst h23 + exact hac (funext fun i => rel_eq23 h12 (hcoord i)) + by_cases h13 : s₁ = s₃ + · subst h13 + exact hab (funext fun i => rel_eq13 h12 (hcoord i)) + obtain ⟨i, hi⟩ : ∃ i, a i ≠ b i := by + by_contra h; push Not at h; exact hab (funext h) + have hai := ha i (Set.mem_univ i) + have hbi := hb i (Set.mem_univ i) + have hci := hc i (Set.mem_univ i) + by_cases hac' : a i = c i + · -- then `(s₂ - s₃) (a i - b i) = 0` + have e := hcoord i + rw [← hac'] at e + have : (s₂ - s₃) • (a i - b i) = 0 := by + have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • a i = (s₂ - s₃) • (a i - b i) := by + simp only [smul_sub, sub_smul]; abel + rw [← this]; exact e + rcases smul_eq_zero.mp this with h0 | h0 + · exact h23 (sub_eq_zero.mp h0) + · exact hi (sub_eq_zero.mp h0) + by_cases hbc' : b i = c i + · have e := hcoord i + rw [← hbc'] at e + have : (s₂ - s₁) • (a i - b i) = 0 := by + have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • b i = (s₂ - s₁) • (a i - b i) := by + simp only [smul_sub, sub_smul]; abel + rw [← this]; exact e + rcases smul_eq_zero.mp this with h0 | h0 + · exact h12 (sub_eq_zero.mp h0).symm + · exact hi (sub_eq_zero.mp h0) + exact hA hai hbi hci hi hac' hbc' h1 h2 h3 h12 (hcoord i) + +/-- Every cap satisfies the colour-restricted dependence condition. -/ +theorem IsCap.isSCap {S : Set K} {A : Set V} (hA : IsCap K A) : IsSCap S A := by + intro a ha b hb c hc hab hac hbc s₁ _ s₂ _ s₃ _ h12 hrel + have h := dep_zero hA ha hb hc hab hac hbc (α := s₂ - s₁) (β := s₃ - s₂) + (γ := s₁ - s₃) (by ring) hrel + exact h12 (sub_eq_zero.mp h.1).symm + +end SCapDef + variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] @@ -128,27 +215,31 @@ omit [Fintype W] in theorem mem_line_of_sub {x y : F × W} {c : W} (h : y - x = (y.1 - x.1) • u c) : y ∈ line x c := mem_line.mpr ⟨y.1 - x.1, by rw [← h]; abel⟩ -variable (hC : IsCap F (C : Set W)) +section Geom + +variable {S : Set F} {C : Finset W} (hC : IsSCap S (C : Set W)) include hC -/-- **L5.1.** Every triangle of `B` lies in a block. -/ -theorem blocks_tri (x y z : F × W) (hxy : (Bgr C σ).Adj x y) (hyz : (Bgr C σ).Adj y z) - (hxz : (Bgr C σ).Adj x z) : ∃ ℓ ∈ blocks C, x ∈ ℓ ∧ y ∈ ℓ ∧ z ∈ ℓ := by - obtain ⟨a, ha, h1⟩ := hxy.2.1 - obtain ⟨b, hb, h2⟩ := hyz.2.1 - obtain ⟨c, hc, h3⟩ := hxz.2.1 - have hα : y.1 - x.1 ≠ 0 := sub_ne_zero.mpr (Bgr_fst_ne hxy).symm +omit [Fintype W] in +/-- `tri_geom` under an S-cap, for points of active colours. -/ +theorem tri_geom_s {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) + (hxS : x.1 ∈ S) (hyS : y.1 ∈ S) (hzS : z.1 ∈ S) + (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) + (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d + ∧ z ∈ line p d := by + have hα : y.1 - x.1 ≠ 0 := by + intro h0; rw [h0, zero_smul, sub_eq_zero] at h1; exact hxy h1.symm by_cases hab : a = b · subst hab - refine ⟨line x a, mem_blocks_of ha, self_mem_line x a, mem_line_of_sub h1, ?_⟩ + refine ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, ?_⟩ refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ rw [add_smul, ← h1, ← h2]; abel by_cases hac : a = c · subst hac - exact ⟨line x a, mem_blocks_of ha, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ + exact ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ by_cases hbc : b = c · subst hbc - refine ⟨line z b, mem_blocks_of hb, ?_, ?_, self_mem_line z b⟩ + refine ⟨b, hb, z, ?_, ?_, self_mem_line z b⟩ · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ rw [neg_smul, ← h3]; abel · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ @@ -157,23 +248,19 @@ theorem blocks_tri (x y z : F × W) (hxy : (Bgr C σ).Adj x y) (hyz : (Bgr C σ) have e1 := snd_eq_of_sub h1 have e2 := snd_eq_of_sub h2 have e3 := snd_eq_of_sub h3 - have := dep_zero hC ha hb hc hab hac hbc (α := y.1 - x.1) (β := z.1 - y.1) (γ := -(z.1 - x.1)) - (by ring) (by rw [← e1, ← e2, neg_smul, ← e3]; abel) - exact hα this.1 + refine hC ha hb hc hab hac hbc hxS hyS hzS (fun h0 => hα (sub_eq_zero.mpr h0.symm)) ?_ + rw [show x.1 - z.1 = -(z.1 - x.1) by ring, ← e1, ← e2, neg_smul, ← e3]; abel -/-- **L5.2.** A point outside a block has at most one `B`-neighbour in it. -/ -theorem blocks_one (ℓ : Finset (F × W)) (hℓ : ℓ ∈ blocks C) (z : F × W) (hz : z ∉ ℓ) - (y : F × W) (hy : y ∈ ℓ) (y' : F × W) (hy' : y' ∈ ℓ) (h : (Bgr C σ).Adj z y) - (h' : (Bgr C σ).Adj z y') : y = y' := by - obtain ⟨⟨x0, c0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ - have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).2 - simp only at hy hy' hz +omit [Fintype W] in +/-- `one_geom` under an S-cap, for points of active colours. -/ +theorem one_geom_s {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) + (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) (hzS : z.1 ∈ S) (hyS : y.1 ∈ S) (hy'S : y'.1 ∈ S) + {d e' : W} (hd : d ∈ C) (he : e' ∈ C) + (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := by by_contra hne have hyy := sub_of_mem_line hy hy' have hγ : y'.1 - y.1 ≠ 0 := fun h0 => hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) - obtain ⟨d, hd, hzy⟩ := h.2.1 - obtain ⟨e', he, hzy'⟩ := h'.2.1 by_cases hdc : d = c0 · subst hdc apply hz @@ -194,12 +281,69 @@ theorem blocks_one (ℓ : Finset (F × W)) (hℓ : ℓ ∈ blocks C) (z : F × W rw [this, hzy, hzy', ← sub_smul] congr 1; ring exact hdc ((par_eq this).2 hγ) + by_cases hzy1 : y'.1 = z.1 + · have : y' = z := by + rw [hzy1, sub_self, zero_smul, sub_eq_zero] at hzy' + exact hzy' + exact hz (this ▸ hy') have e1 := snd_eq_of_sub hzy have e2 := snd_eq_of_sub hzy' have e3 := snd_eq_of_sub hyy - have := dep_zero hC he hd hc0 (Ne.symm hde) hec hdc (α := y'.1 - z.1) (β := -(y.1 - z.1)) - (γ := -(y'.1 - y.1)) (by ring) (by rw [← e2, neg_smul, ← e1, neg_smul, ← e3]; abel) - exact Bgr_fst_ne h' (sub_eq_zero.mp this.1).symm + -- colours `s₁ = z.1`, `s₂ = y'.1`, `s₃ = y.1`; points `e'`, `c0`, `d` + refine hC he hc0 hd hec (Ne.symm hde) (Ne.symm hdc) hzS hy'S hyS (Ne.symm hzy1) ?_ + have : (y.1 - y'.1) • c0 = -((y'.1 - y.1) • c0) := by rw [← neg_smul, neg_sub] + have hd' : (z.1 - y.1) • d = -((y.1 - z.1) • d) := by rw [← neg_smul, neg_sub] + rw [hd', this, ← e2, ← e1, ← e3]; abel + +end Geom + +/-! ### Geometry of selected directions on bases -/ + +section Geom + +variable {C : Finset W} (hC : IsCap F (C : Set W)) +include hC + +omit [Fintype W] in +/-- Three points with pairwise selected differences lie on one selected line. -/ +theorem tri_geom {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) + (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) + (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d + ∧ z ∈ line p d := + tri_geom_s (S := Set.univ) hC.isSCap ha hb hc hxy (Set.mem_univ _) (Set.mem_univ _) + (Set.mem_univ _) h1 h2 h3 + +omit [Fintype W] in +/-- A point off a selected line has selected differences to at most one point of the line. -/ +theorem one_geom {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) + (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) {d e' : W} (hd : d ∈ C) (he : e' ∈ C) + (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := + one_geom_s (S := Set.univ) hC.isSCap hc0 hz hy hy' (Set.mem_univ _) (Set.mem_univ _) + (Set.mem_univ _) hd he hzy hzy' + +end Geom + +variable (hC : IsCap F (C : Set W)) +include hC + +/-- **L5.1.** Every triangle of `B` lies in a block. -/ +theorem blocks_tri (x y z : F × W) (hxy : (Bgr C σ).Adj x y) (hyz : (Bgr C σ).Adj y z) + (hxz : (Bgr C σ).Adj x z) : ∃ ℓ ∈ blocks C, x ∈ ℓ ∧ y ∈ ℓ ∧ z ∈ ℓ := by + obtain ⟨a, ha, h1⟩ := hxy.2.1 + obtain ⟨b, hb, h2⟩ := hyz.2.1 + obtain ⟨c, hc, h3⟩ := hxz.2.1 + obtain ⟨d, hd, p, hx, hy, hz⟩ := tri_geom hC ha hb hc hxy.1 h1 h2 h3 + exact ⟨line p d, mem_blocks_of hd, hx, hy, hz⟩ + +/-- **L5.2.** A point outside a block has at most one `B`-neighbour in it. -/ +theorem blocks_one (ℓ : Finset (F × W)) (hℓ : ℓ ∈ blocks C) (z : F × W) (hz : z ∉ ℓ) + (y : F × W) (hy : y ∈ ℓ) (y' : F × W) (hy' : y' ∈ ℓ) (h : (Bgr C σ).Adj z y) + (h' : (Bgr C σ).Adj z y') : y = y' := by + obtain ⟨⟨x0, c0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ + have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).2 + obtain ⟨d, hd, hzy⟩ := h.2.1 + obtain ⟨e', he, hzy'⟩ := h'.2.1 + exact one_geom hC hc0 hz hy hy' hd he hzy hzy' /-- The block hypotheses hold for the selected lines of a cap. -/ theorem blockHyp : BlockHyp (Bgr C σ) (blocks C) where diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean index 45298f0f1d..f95f0c6b1c 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean @@ -7,7 +7,7 @@ Authors: Juan Pablo Traverso Gianini module public import LeanPool.SplitCliqueGap.GapExtremal.Sphere -public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected +public import LeanPool.SplitCliqueGap.GapExtremal.GraphPadding import Mathlib.Tactic.Choose import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.Linarith @@ -18,20 +18,10 @@ import Mathlib.Tactic.Ring import Mathlib.Tactic.SplitIfs /-! -# Exact order and connectivity (ledger L1.2) +# Exact-order exponent estimates for split graphs -Hosts whose palette is a single core vertex are pendant leaves. Padding a host family (`padN`): -* gives every empty palette the vertex `x₀`; -* adds `k` new hosts with palette `{x₀}`. +The cap construction combines the host padding theorem with a quantitative choice of seed. -The bridge hypotheses `HostHyp` survive (`HostHyp.pad`), so the lower bound of `gap_ge` is -unchanged. The graph -stays split, becomes connected (`connected_hostGraph`), and its order grows by exactly `k`. With -`exponent_of_family_exact` this gives the final statements for split **connected** graphs of order -**exactly** -`n`: -* `tp_single_s_exact`; -* **`exponent_two_exact`**. -/ @[expose] public section @@ -40,75 +30,6 @@ namespace GapExtremal open Finset -/-! ### Padding a host family -/ - -section Pad - -variable {V : Type*} [Fintype V] [DecidableEq V] {H : Type*} [Fintype H] [DecidableEq H] - -/-- Padded palettes: empty palettes become `{x₀}`, and `k` new hosts with palette `{x₀}`. -/ -def padN (N : H → Finset V) (x0 : V) (k : ℕ) : H ⊕ Fin k → Finset V - | .inl h => if N h = ∅ then {x0} else N h - | .inr _ => {x0} - -omit [DecidableEq H] [Fintype H] [Fintype V] in -theorem padN_nonempty (N : H → Finset V) (x0 : V) (k : ℕ) (h : H ⊕ Fin k) : (padN N x0 k - h).Nonempty := by - rcases h with h | i - · simp only [padN] - split_ifs with h0 - · exact Finset.singleton_nonempty _ - · exact Finset.nonempty_iff_ne_empty.mpr h0 - · exact Finset.singleton_nonempty _ - -omit [DecidableEq H] [Fintype H] [Fintype V] in -theorem HostHyp.pad {B : SimpleGraph V} {N : H → Finset V} {φ : V → V → H} - (hH : HostHyp B N φ) (x0 : V) (k : ℕ) : - HostHyp B (padN N x0 k) (fun x y => Sum.inl (φ x y)) where - indep := by - rintro (h | i) x hx y hy hxy - · simp only [padN] at hx hy - split_ifs at hx hy with h0 - · rw [Finset.mem_singleton] at hx hy - subst hx; subst hy - exact B.loopless.irrefl _ hxy - · exact hH.indep h x hx y hy hxy - · simp only [padN, Finset.mem_singleton] at hx hy - subst hx; subst hy - exact B.loopless.irrefl _ hxy - cover := by - intro x y hne hadj - obtain ⟨hx, hy⟩ := hH.cover x y hne hadj - have h0 : N (φ x y) ≠ ∅ := Finset.ne_empty_of_mem hx - simp only [padN, ite_eq_right h0] - exact ⟨hx, hy⟩ - symm := fun x y => by rw [hH.symm x y] - inj := fun x y y' h1 h2 h3 h4 h => hH.inj x y y' h1 h2 h3 h4 (Sum.inl_injective h) - -omit [DecidableEq H] [DecidableEq V] in -theorem card_pad (k : ℕ) : - Fintype.card (V ⊕ (H ⊕ Fin k)) = Fintype.card (V ⊕ H) + k := by - simp only [Fintype.card_sum, Fintype.card_fin] - ring - -omit [DecidableEq V] [Fintype V] in -/-- A host graph with a nonempty core and nonempty palettes is connected. -/ -theorem connected_hostGraph {H' : Type*} (N : H' → Finset V) (x0 : V) - (hN : ∀ h, (N h).Nonempty) : - (hostGraph N).Connected := by - rw [SimpleGraph.connected_iff_exists_forall_reachable] - have hcore : ∀ y : V, (hostGraph N).Reachable (.inl x0) (.inl y) := fun y => by - by_cases hy : x0 = y - · rw [hy] - · exact SimpleGraph.Adj.reachable ((hostGraph_inl_inl N _ _).mpr hy) - refine ⟨.inl x0, ?_⟩ - rintro (y | h) - · exact hcore y - · obtain ⟨y, hy⟩ := hN h - exact (hcore y).trans (SimpleGraph.Adj.reachable ((hostGraph_inl_inr N _ _).mpr hy)) - -end Pad - /-! ### From a padded family to every order -/ /-- **From a padded family to all orders exactly.** -/ @@ -122,49 +43,13 @@ theorem exponent_of_family_exact {M a K : ℕ} (hM : 2 ≤ M) (ha : 1 ≤ a) (hK ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), Fintype.card V' = n ∧ IsSplit G' ∧ G'.Connected ∧ c * (n : ℝ) ^ (1 + Real.log a / Real.log M) ≤ gap G' := by - set α := 1 + Real.log a / Real.log M - have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) - have hα : 0 ≤ α := by - have h1 : 0 ≤ Real.log a := Real.log_nonneg (by exact_mod_cast ha) - have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) - positivity - refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ - set j := Nat.log M (n / K) with hj - have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by - have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by - have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) - omega) - have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ - have hbn : b j ≤ n := by - calc b j ≤ K * M ^ j := hb j - _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj - _ ≤ n := Nat.mul_div_le n K - refine ⟨V j (n - b j), inferInstance, inferInstance, G j (n - b j), ?_, hsplit _ _, hconn _ _, ?_⟩ - · rw [hcard]; omega - · have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by - have h1 : n < K * (n / K) + K := by - have := Nat.div_add_mod n K - have := Nat.mod_lt n hK - omega - have h2 : n < K * M ^ (j + 1) := by - calc n < K * (n / K) + K := h1 - _ = K * (n / K + 1) := by ring - _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt - rw [div_le_iff₀ (by positivity)] - have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 - rw [pow_succ] at this - nlinarith - have hpow := pow_rpow_alpha ha hM j - have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := - Real.rpow_le_rpow (by positivity) hn' hα - have hsplit' : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by - rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] - ring - refine le_trans ?_ (hgap j _) - calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by - rw [hsplit']; ring - _ ≤ ((M : ℝ) ^ j) ^ α / 3 := by linarith - _ = (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + refine ⟨((K : ℝ) * M) ^ (-(1 + Real.log a / Real.log M)) / 3, by positivity, fun n hn => ?_⟩ + obtain ⟨j, hsize, hscale⟩ := exponent_budget hM ha hK hn + have hbn : b j ≤ n := (hb j).trans hsize + refine ⟨V j (n - b j), inferInstance, inferInstance, G j (n - b j), ?_, hsplit _ _, hconn _ _, + hscale.trans (hgap j _)⟩ + rw [hcard] + omega /-! ### The padded positioned construction -/ diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean index f493ff7945..d561f9d15e 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean @@ -72,6 +72,49 @@ theorem pow_rpow_alpha {a M : ℕ} (ha : 1 ≤ a) (hM : 2 ≤ M) (j : ℕ) : show (j : ℝ) * (1 + Real.log a / Real.log M) = j + j * Real.log a / Real.log M by ring, Real.rpow_add hM0, Real.rpow_natCast, key, mul_comm] +/-- Select the largest admissible power of the base and bound its associated gap scale. -/ +theorem exponent_budget {M a K n : ℕ} (hM : 2 ≤ M) (ha : 1 ≤ a) (hK : 0 < K) + (hn : K * M ≤ n) : + ∃ j : ℕ, K * M ^ j ≤ n ∧ + ((K : ℝ) * M) ^ (-(1 + Real.log a / Real.log M)) / 3 * + (n : ℝ) ^ (1 + Real.log a / Real.log M) ≤ (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by + set α := 1 + Real.log a / Real.log M + have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) + have hα : 0 ≤ α := by + have h1 : 0 ≤ Real.log a := Real.log_nonneg (by exact_mod_cast ha) + have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) + positivity + set j := Nat.log M (n / K) with hj + have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by + have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by + have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) + omega) + have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ + refine ⟨j, (Nat.mul_le_mul_left K hMj).trans (Nat.mul_div_le n K), ?_⟩ + have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by + have h1 : n < K * (n / K) + K := by + have := Nat.div_add_mod n K + have := Nat.mod_lt n hK + omega + have h2 : n < K * M ^ (j + 1) := by + calc n < K * (n / K) + K := h1 + _ = K * (n / K + 1) := by ring + _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt + rw [div_le_iff₀ (by positivity)] + have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 + rw [pow_succ] at this + nlinarith + have hpow := pow_rpow_alpha ha hM j + have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := + Real.rpow_le_rpow (by positivity) hn' hα + have hsplit' : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by + rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] + ring + calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by + rw [hsplit']; ring + _ ≤ ((M : ℝ) ^ j) ^ α / 3 := by linarith + _ = (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + omit [DecidableEq F] [DecidableEq U] in /-- **TP-cond.** -/ theorem tp_cond (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hS : IsSep F (A : Set U)) @@ -83,20 +126,10 @@ theorem tp_cond (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hS classical set M := Fintype.card U set K := 3 * Fintype.card F ^ 3 - set α := 1 + Real.log A.card / Real.log M have hK : 0 < K := by positivity - have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) - have hα : 0 ≤ α := by - have h1 : 0 ≤ Real.log A.card := Real.log_nonneg (by exact_mod_cast ha) - have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) - positivity - refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ - set j := Nat.log M (n / K) with hj - have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by - have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by - have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) - omega) - have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ + refine ⟨((K : ℝ) * M) ^ (-(1 + Real.log A.card / Real.log M)) / 3, by positivity, + fun n hn => ?_⟩ + obtain ⟨j, hsize, hscale⟩ := exponent_budget hM ha hK hn -- the graph refine ⟨(F × (Fin j → U)) ⊕ HostIdx F (Fin j → U), inferInstance, instDecidableEqSum, hostGraph (palette (capPow A j) σ (isSep_capPow hS j)), ?_, isSplit_hostGraph _, ?_⟩ @@ -104,36 +137,11 @@ theorem tp_cond (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hS have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] rw [hW] at this calc _ ≤ K * M ^ j := this - _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj - _ ≤ n := Nat.mul_div_le n K + _ ≤ n := hsize · have hgap := gap_ge_third (W := Fin j → U) σ (isCap_capPow hA j) (isSep_capPow hS j) have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] rw [card_capPow, hW] at hgap - -- n < K M^{j+1}, so n/(K M) < M^j - have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by - have h1 : n < K * (n / K) + K := by - have := Nat.div_add_mod n K - have := Nat.mod_lt n hK - omega - have h2 : n < K * M ^ (j + 1) := by - calc n < K * (n / K) + K := h1 - _ = K * (n / K + 1) := by ring - _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt - rw [div_le_iff₀ (by positivity)] - have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 - rw [pow_succ] at this - nlinarith - have hpow := pow_rpow_alpha ha hM j - have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := - Real.rpow_le_rpow (by positivity) hn' hα - have hsplit : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by - rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] - ring push_cast at hgap - refine le_trans ?_ hgap - calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by - rw [hsplit]; ring - _ ≤ ((M : ℝ) ^ j) ^ α / 3 := div_le_div_of_nonneg_right hmono (by norm_num) - _ = (A.card : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + exact hscale.trans hgap end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Global.lean b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean index 4f360598e3..93ac45ab3b 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Global.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas +public import LeanPool.SplitCliqueGap.GapExtremal.Global2 import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring import Mathlib.Tactic.Choose @@ -39,9 +39,6 @@ open Finset variable {V : Type*} [Fintype V] [DecidableEq V] (B : SimpleGraph V) [DecidableRel B.Adj] -/-- A packing of columns: two distinct members share at most one vertex. -/ -def IsPack (T : Finset (Finset V)) : Prop := ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → (Q ∩ Q').card ≤ 1 - /-- The geometric hypotheses on the blocks (ledger §5). -/ structure BlockHyp (blocks : Finset (Finset V)) : Prop where inter : ∀ ℓ ∈ blocks, ∀ ℓ' ∈ blocks, ℓ ≠ ℓ' → (ℓ ∩ ℓ').card ≤ 1 @@ -61,11 +58,6 @@ theorem D_singleton_le_one {ℓ A : Finset V} {z : V} (hA : A ⊆ ℓ) simp only [Finset.mem_filter] at ha hb exact hone a (hA ha.1) b (hA hb.1) ha.2 hb.2 -omit [Fintype V] [DecidableEq V] [DecidableRel B.Adj] in -theorem triFree_of_card_le_one {p : Finset V} (h : p.card ≤ 1) : TriFree B p := by - intro u hu v hv _ _ huv _ _ - exact huv.ne (Finset.card_le_one.mp h u hu v hv) - /-- **Fragmentation of one column.** -/ theorem exists_pieces {blocks : Finset (Finset V)} (hB : BlockHyp B blocks) (Q : Finset V) : ∃ P : Finset (Finset V), (∀ p ∈ P, p ⊆ Q) ∧ (∀ p ∈ P, ∀ p' ∈ P, p ≠ p' → Disjoint p p') ∧ @@ -130,160 +122,19 @@ theorem exists_pieces {blocks : Finset (Finset V)} (hB : BlockHyp B blocks) (Q : have hzℓ : z ∉ ℓ := (Finset.mem_sdiff.mp hz).2 exact D_singleton_le_one Finset.inter_subset_right (hB.one ℓ hℓ z hzℓ) -/-- The edges of a column are covered by its parts in the blocks. -/ -theorem e_le_sum_blocks {blocks : Finset (Finset V)} - (hedge : ∀ u v, B.Adj u v → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ) (p : Finset V) : - e B p ≤ ∑ ℓ ∈ blocks, e B (p ∩ ℓ) := by - unfold e - refine (Finset.card_le_card ?_).trans Finset.card_biUnion_le - intro s hs - induction s using Sym2.ind with - | h u v => - rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs - obtain ⟨huv, hu, hv⟩ := hs - obtain ⟨ℓ, hℓ, huℓ, hvℓ⟩ := hedge u v huv - refine Finset.mem_biUnion.mpr ⟨ℓ, hℓ, ?_⟩ - rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] - exact ⟨huv, Finset.mem_inter.mpr ⟨hu, huℓ⟩, Finset.mem_inter.mpr ⟨hv, hvℓ⟩⟩ - -/-- Pieces sharing at most one vertex use disjoint edges of a block. -/ -theorem sum_e_inter_le {ι : Type*} (S : Finset ι) (f : ι → Finset V) - (hf : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (f x ∩ f y).card ≤ 1) (ℓ : Finset V) : - ∑ x ∈ S, e B (f x ∩ ℓ) ≤ e B ℓ := by - unfold e - rw [← Finset.card_biUnion] - · refine Finset.card_le_card fun s hs => ?_ - obtain ⟨x, -, hx⟩ := Finset.mem_biUnion.mp hs - induction s using Sym2.ind with - | h u v => - rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hx ⊢ - exact ⟨hx.1, (Finset.mem_inter.mp hx.2.1).2, (Finset.mem_inter.mp hx.2.2).2⟩ - · intro x hx y hy hxy - rw [Function.onFun, Finset.disjoint_left] - intro s hsx hsy - induction s using Sym2.ind with - | h u v => - rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hsx hsy - have hu : u ∈ f x ∩ f y := - Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.1).1, (Finset.mem_inter.mp hsy.2.1).1⟩ - have hv : v ∈ f x ∩ f y := - Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.2).1, (Finset.mem_inter.mp hsy.2.2).1⟩ - exact hsx.1.ne (Finset.card_le_one.mp (hf x hx y hy hxy) u hu v hv) - /-- **L7.3 (abstract).** -/ theorem global_bound {blocks : Finset (Finset V)} (hB : BlockHyp B blocks) (c : ℤ) (hloc : ∀ ℓ ∈ blocks, ∀ T : Finset (Finset V), (∀ Q ∈ T, Q ⊆ ℓ) → IsPack T → ∑ Q ∈ T, (4 * w B Q - e B Q) ≤ 4 * c - e B ℓ) {T : Finset (Finset V)} (hT : IsPack T) : ∑ Q ∈ T, w B Q ≤ c * blocks.card := by - classical - choose P hPsub hPdisj hPtype hPw using fun Q => exists_pieces hB Q - set S := T.sigma P with hS - have h1 : ∑ Q ∈ T, w B Q ≤ ∑ x ∈ S, w B x.2 := by - rw [hS, Finset.sum_sigma] - exact Finset.sum_le_sum fun Q _ => hPw Q - have hpair : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (x.2 ∩ y.2).card ≤ 1 := by - rintro ⟨Q, p⟩ hx ⟨Q', p'⟩ hy hne - simp only [hS, Finset.mem_sigma] at hx hy - by_cases hQ : Q = Q' - · subst hQ - have hp : p ≠ p' := fun h => hne (by rw [h]) - rw [Finset.disjoint_iff_inter_eq_empty.mp (hPdisj Q p hx.2 p' hy.2 hp)] - simp - · exact (Finset.card_le_card - (Finset.inter_subset_inter (hPsub Q p hx.2) (hPsub Q' p' hy.2))).trans (hT Q hx.1 Q' hy.1 - hQ) - set L : Finset V → Finset (Σ _ : Finset V, Finset V) := - fun ℓ => S.filter (fun x => 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) with hL - set R := S.filter (fun x => ¬ ∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) with hR - have hcount : ∀ x ∈ S, (∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) → - (blocks.filter (fun ℓ => 2 ≤ x.2.card ∧ x.2 ⊆ ℓ)).card = 1 := by - rintro x - ⟨ℓ, hℓ, h2, hsub⟩ - rw [Finset.card_eq_one] - refine ⟨ℓ, Finset.eq_singleton_iff_unique_mem.mpr ⟨Finset.mem_filter.mpr ⟨hℓ, h2, hsub⟩, ?_⟩⟩ - intro ℓ' hℓ' - obtain ⟨hℓ'b, -, hsub'⟩ := Finset.mem_filter.mp hℓ' - by_contra hne - have h3 := hB.inter ℓ' hℓ'b ℓ hℓ hne - have h4 : x.2.card ≤ (ℓ' ∩ ℓ).card := Finset.card_le_card (Finset.subset_inter hsub' hsub) - omega - have hsplit : ∀ g : (Σ _ : Finset V, Finset V) → ℤ, - ∑ x ∈ S, g x = ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, g x + ∑ x ∈ R, g x := by - intro g - have hLsum : ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, g x = - ∑ x ∈ S, if (∃ ℓ ∈ blocks, 2 ≤ x.2.card ∧ x.2 ⊆ ℓ) then g x else 0 := by - simp only [hL, Finset.sum_filter] - rw [Finset.sum_comm] - refine Finset.sum_congr rfl fun x hx => ?_ - split_ifs with hloc' - · rw [← Finset.sum_filter, Finset.sum_const, hcount x hx hloc', one_smul] - · refine Finset.sum_eq_zero fun ℓ hℓ => ?_ - rw [ite_eq_right] - exact fun h => hloc' ⟨ℓ, hℓ, h⟩ - rw [hLsum, hR, Finset.sum_filter, ← Finset.sum_add_distrib] - refine Finset.sum_congr rfl fun x _ => ?_ - split_ifs <;> simp - have hRtf : ∀ x ∈ R, TriFree B x.2 := by - intro x hx - obtain ⟨hxS, hnot⟩ := Finset.mem_filter.mp hx - obtain ⟨Q, p⟩ := x - simp only [hS, Finset.mem_sigma] at hxS - rcases hPtype Q p hxS.2 with ⟨ℓ, hℓ, hsub⟩ | htf - · refine triFree_of_card_le_one ?_ - by_contra h2 - exact hnot ⟨ℓ, hℓ, by omega, hsub⟩ - · exact htf - have hblock : ∀ ℓ ∈ blocks, - ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) ≤ 4 * c := by - intro ℓ hℓ - have hLR : Disjoint (L ℓ) R := by - rw [Finset.disjoint_left] - intro x hxL hxR - exact (Finset.mem_filter.mp hxR).2 ⟨ℓ, hℓ, (Finset.mem_filter.mp hxL).2⟩ - have hedges : ∑ x ∈ L ℓ, (e B x.2 : ℤ) + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) ≤ e B ℓ := by - have hLe : ∑ x ∈ L ℓ, (e B x.2 : ℤ) = ∑ x ∈ L ℓ, (e B (x.2 ∩ ℓ) : ℤ) := by - refine Finset.sum_congr rfl fun x hx => ?_ - rw [Finset.inter_eq_left.mpr (Finset.mem_filter.mp hx).2.2] - rw [hLe, ← Finset.sum_union hLR] - have hsub : L ℓ ∪ R ⊆ S := - Finset.union_subset (Finset.filter_subset _ _) (Finset.filter_subset _ _) - have := sum_e_inter_le (B := B) (L ℓ ∪ R) (fun x => x.2) - (fun x hx y hy => hpair x (hsub hx) y (hsub hy)) ℓ - exact_mod_cast this - have hinj : Set.InjOn (fun x : (Σ _ : Finset V, Finset V) => x.2) (L ℓ : Set _) := by - intro x hx y hy hxy - by_contra hne - have h2 := (Finset.mem_filter.mp hx).2.1 - have h5 := hpair x (Finset.mem_filter.mp hx).1 y (Finset.mem_filter.mp hy).1 hne - simp only at hxy - rw [hxy, Finset.inter_self] at h5 - rw [hxy] at h2 - omega - have hloc' := hloc ℓ hℓ ((L ℓ).image (fun x => x.2)) - (fun Q hQ => by - obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ - exact (Finset.mem_filter.mp hx).2.2) - (fun Q hQ Q' hQ' hne => by - obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hQ - obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hQ' - exact hpair x (Finset.mem_filter.mp hx).1 y (Finset.mem_filter.mp hy).1 - (fun h => hne (by rw [h]))) - rw [Finset.sum_image hinj] at hloc' - have hsub' : ∑ x ∈ L ℓ, (4 * w B x.2 - e B x.2) = - ∑ x ∈ L ℓ, 4 * w B x.2 - ∑ x ∈ L ℓ, (e B x.2 : ℤ) := Finset.sum_sub_distrib _ _ - linarith - have hR4 : ∑ x ∈ R, 4 * w B x.2 ≤ ∑ ℓ ∈ blocks, ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) := by - rw [Finset.sum_comm] - refine Finset.sum_le_sum fun x hx => (four_w_le_e B (hRtf x hx)).trans ?_ - exact_mod_cast e_le_sum_blocks hB.edge x.2 - have h4 : 4 * ∑ x ∈ S, w B x.2 ≤ 4 * (c * blocks.card) := by - rw [Finset.mul_sum, hsplit (fun x => 4 * w B x.2)] - calc ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, 4 * w B x.2 - ≤ ∑ ℓ ∈ blocks, ∑ x ∈ L ℓ, 4 * w B x.2 + ∑ ℓ ∈ blocks, ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ) := by - linarith - _ = ∑ ℓ ∈ blocks, (∑ x ∈ L ℓ, 4 * w B x.2 + ∑ x ∈ R, (e B (x.2 ∩ ℓ) : ℤ)) := - Finset.sum_add_distrib.symm - _ ≤ ∑ _ℓ ∈ blocks, 4 * c := Finset.sum_le_sum hblock - _ = 4 * (c * blocks.card) := by rw [Finset.sum_const, nsmul_eq_mul]; ring - linarith + have weaker : BlockHyp2 B blocks := by + refine ⟨hB.edge, hB.tri, ?_, ?_⟩ + · intro ℓ hℓ z hz y hy y' hy' _ _ hadj hadj' _ + exact Or.inl (hB.one ℓ hℓ z hz y hy y' hy' hadj hadj') + · intro ℓ hℓ z hz y hy y' hy' hadj hadj' hedge + have eq := hB.one ℓ hℓ z hz y hy y' hy' hadj hadj' + subst y' + exact hedge.ne rfl + exact global_bound2 weaker c hloc hT end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean b/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean index 95d0b83411..320ed1d8c4 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Global2.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.Global +public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith import Mathlib.Tactic.Choose @@ -77,8 +77,6 @@ theorem what_union {A Z : Finset V} (h : Disjoint A Z) : have hc := card_union_choose_two h have he := e_union (B := B) A Z h unfold what w - have hD : D B (A ∪ Z) (A ∪ Z) = D B A A + D B A Z + (D B Z A + D B Z Z) := by - rw [D_union_left B h, D_union_right B h, D_union_right B h] rw [he, hc] ring diff --git a/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean b/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean index ddf782042b..dee89d13d1 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/GlobalLemmas.lean @@ -109,4 +109,54 @@ theorem frag_le {A Z : Finset V} (hAZ : Disjoint A Z) (hA : 3 ≤ A.card) (hZ : rw [hAZ'] nlinarith +/-- A packing of columns: two distinct members share at most one vertex. -/ +def IsPack (T : Finset (Finset V)) : Prop := ∀ Q ∈ T, ∀ Q' ∈ T, Q ≠ Q' → (Q ∩ Q').card ≤ 1 + +variable {B} + +omit [Fintype V] [DecidableEq V] [DecidableRel B.Adj] in +theorem triFree_of_card_le_one {p : Finset V} (h : p.card ≤ 1) : TriFree B p := by + intro u hu v hv _ _ huv _ _ + exact huv.ne (Finset.card_le_one.mp h u hu v hv) + +/-- The edges of a column are covered by its parts in the blocks. -/ +theorem e_le_sum_blocks {blocks : Finset (Finset V)} + (hedge : ∀ u v, B.Adj u v → ∃ ℓ ∈ blocks, u ∈ ℓ ∧ v ∈ ℓ) (p : Finset V) : + e B p ≤ ∑ ℓ ∈ blocks, e B (p ∩ ℓ) := by + unfold e + refine (Finset.card_le_card ?_).trans Finset.card_biUnion_le + intro s hs + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hs + obtain ⟨huv, hu, hv⟩ := hs + obtain ⟨ℓ, hℓ, huℓ, hvℓ⟩ := hedge u v huv + refine Finset.mem_biUnion.mpr ⟨ℓ, hℓ, ?_⟩ + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] + exact ⟨huv, Finset.mem_inter.mpr ⟨hu, huℓ⟩, Finset.mem_inter.mpr ⟨hv, hvℓ⟩⟩ + +/-- Pieces sharing at most one vertex use disjoint edges of a block. -/ +theorem sum_e_inter_le {ι : Type*} (S : Finset ι) (f : ι → Finset V) + (hf : ∀ x ∈ S, ∀ y ∈ S, x ≠ y → (f x ∩ f y).card ≤ 1) (ℓ : Finset V) : + ∑ x ∈ S, e B (f x ∩ ℓ) ≤ e B ℓ := by + unfold e + rw [← Finset.card_biUnion] + · refine Finset.card_le_card fun s hs => ?_ + obtain ⟨x, -, hx⟩ := Finset.mem_biUnion.mp hs + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hx ⊢ + exact ⟨hx.1, (Finset.mem_inter.mp hx.2.1).2, (Finset.mem_inter.mp hx.2.2).2⟩ + · intro x hx y hy hxy + rw [Function.onFun, Finset.disjoint_left] + intro s hsx hsy + induction s using Sym2.ind with + | h u v => + rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet] at hsx hsy + have hu : u ∈ f x ∩ f y := + Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.1).1, (Finset.mem_inter.mp hsy.2.1).1⟩ + have hv : v ∈ f x ∩ f y := + Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hsx.2.2).1, (Finset.mem_inter.mp hsy.2.2).1⟩ + exact hsx.1.ne (Finset.card_le_one.mp (hf x hx y hy hxy) u hu v hv) + end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/GraphPadding.lean b/LeanPool/SplitCliqueGap/GapExtremal/GraphPadding.lean new file mode 100644 index 0000000000..0d6d181662 --- /dev/null +++ b/LeanPool/SplitCliqueGap/GapExtremal/GraphPadding.lean @@ -0,0 +1,106 @@ +/- +Copyright (c) 2026 Juan Pablo Traverso Gianini. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Juan Pablo Traverso Gianini +-/ +/- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ +module + +public import LeanPool.SplitCliqueGap.GapExtremal.Bridge +public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +/-! Padding and connectivity for the host-graph construction. -/ + +@[expose] public section + +namespace GapExtremal + +open Finset + +/-- Split graphs: a clique and an independent set covering all vertices. -/ +def IsSplit {V : Type*} (G : SimpleGraph V) : Prop := + ∃ K : Set V, (∀ x ∈ K, ∀ y ∈ K, x ≠ y → G.Adj x y) ∧ (∀ x ∉ K, ∀ y ∉ K, ¬ G.Adj x y) + +theorem isSplit_hostGraph {V H : Type*} + (N : H → Finset V) : IsSplit (hostGraph N) := by + refine ⟨Set.range Sum.inl, ?_, ?_⟩ + · rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ h + exact fun e => h (by rw [e]) + · rintro (x | h) hx (y | h') hy + · exact absurd ⟨x, rfl⟩ hx + · exact absurd ⟨x, rfl⟩ hx + · exact absurd ⟨y, rfl⟩ hy + · exact hostGraph_inr_inr N h h' + +/-! ### Padding a host family -/ + +section Pad + +variable {V : Type*} [Fintype V] [DecidableEq V] {H : Type*} [Fintype H] [DecidableEq H] + +/-- Padded palettes: empty palettes become `{x₀}`, and `k` new hosts with palette `{x₀}`. -/ +def padN (N : H → Finset V) (x0 : V) (k : ℕ) : H ⊕ Fin k → Finset V + | .inl h => if N h = ∅ then {x0} else N h + | .inr _ => {x0} + +omit [DecidableEq H] [Fintype H] [Fintype V] in +theorem padN_nonempty (N : H → Finset V) (x0 : V) (k : ℕ) (h : H ⊕ Fin k) : (padN N x0 k + h).Nonempty := by + rcases h with h | i + · simp only [padN] + split_ifs with h0 + · exact Finset.singleton_nonempty _ + · exact Finset.nonempty_iff_ne_empty.mpr h0 + · exact Finset.singleton_nonempty _ + +omit [DecidableEq H] [Fintype H] [Fintype V] in +theorem HostHyp.pad {B : SimpleGraph V} {N : H → Finset V} {φ : V → V → H} + (hH : HostHyp B N φ) (x0 : V) (k : ℕ) : + HostHyp B (padN N x0 k) (fun x y => Sum.inl (φ x y)) where + indep := by + rintro (h | i) x hx y hy hxy + · simp only [padN] at hx hy + split_ifs at hx hy with h0 + · rw [Finset.mem_singleton] at hx hy + subst hx; subst hy + exact B.loopless.irrefl _ hxy + · exact hH.indep h x hx y hy hxy + · simp only [padN, Finset.mem_singleton] at hx hy + subst hx; subst hy + exact B.loopless.irrefl _ hxy + cover := by + intro x y hne hadj + obtain ⟨hx, hy⟩ := hH.cover x y hne hadj + have h0 : N (φ x y) ≠ ∅ := Finset.ne_empty_of_mem hx + simp only [padN, ite_eq_right h0] + exact ⟨hx, hy⟩ + symm := fun x y => by rw [hH.symm x y] + inj := fun x y y' h1 h2 h3 h4 h => hH.inj x y y' h1 h2 h3 h4 (Sum.inl_injective h) + +omit [DecidableEq H] [DecidableEq V] in +theorem card_pad (k : ℕ) : + Fintype.card (V ⊕ (H ⊕ Fin k)) = Fintype.card (V ⊕ H) + k := by + simp only [Fintype.card_sum, Fintype.card_fin] + ring + +omit [DecidableEq V] [Fintype V] in +/-- A host graph with a nonempty core and nonempty palettes is connected. -/ +theorem connected_hostGraph {H' : Type*} (N : H' → Finset V) (x0 : V) + (hN : ∀ h, (N h).Nonempty) : + (hostGraph N).Connected := by + rw [SimpleGraph.connected_iff_exists_forall_reachable] + have hcore : ∀ y : V, (hostGraph N).Reachable (.inl x0) (.inl y) := fun y => by + by_cases hy : x0 = y + · rw [hy] + · exact SimpleGraph.Adj.reachable ((hostGraph_inl_inl N _ _).mpr hy) + refine ⟨.inl x0, ?_⟩ + rintro (y | h) + · exact hcore y + · obtain ⟨y, hy⟩ := hN h + exact (hcore y).trans (SimpleGraph.Adj.reachable ((hostGraph_inl_inr N _ _).mpr hy)) + +end Pad + +end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean index f9cf362a5e..d2055a5ecb 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean @@ -99,9 +99,9 @@ abbrev F5 := ZMod 5 instance : Fact (Nat.Prime 5) := ⟨by norm_num⟩ -/-- Pin the additive group of `ZMod 5` to the ring structure (otherwise instance search may pick the -`IsSimpleAddGroup` route, which is not reducibly compatible with the module instances). -/ -instance (priority := 10000) addCommGroupF5 : AddCommGroup (ZMod 5) := Ring.toAddCommGroup +/-- The ring parent keeps the additive-group and module instances definitionally compatible. -/ +scoped instance (priority := 10000) addCommGroupZModRing (p : ℕ) : + AddCommGroup (ZMod p) := Ring.toAddCommGroup /-- Label positions: `0 ↦ 0, 1 ↦ 1, 2 ↦ twin, 3 ↦ 2, 4 ↦ 3, 5 ↦ 4`. -/ def σL : Fin 6 ↪ Option F5 := diff --git a/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean index 6a17b1c732..fa053e9f8f 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.WeightCap +public import LeanPool.SplitCliqueGap.GapExtremal.Layered import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity @@ -38,47 +38,10 @@ theorem exponent_of_family {M a K : ℕ} (hM : 2 ≤ M) (ha : 1 ≤ a) (hK : 0 < ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), Fintype.card V' ≤ n ∧ IsSplit G' ∧ c * (n : ℝ) ^ (1 + Real.log a / Real.log M) ≤ gap G' := by - set α := 1 + Real.log a / Real.log M - have hM0 : (0 : ℝ) < M := by exact_mod_cast (show 0 < M by omega) - have hα : 0 ≤ α := by - have h1 : 0 ≤ Real.log a := Real.log_nonneg (by exact_mod_cast ha) - have h2 : 0 ≤ Real.log M := Real.log_nonneg (by exact_mod_cast (show 1 ≤ M by omega)) - positivity - refine ⟨((K : ℝ) * M) ^ (-α) / 3, by positivity, fun n hn => ?_⟩ - set j := Nat.log M (n / K) with hj - have hMj : M ^ j ≤ n / K := Nat.pow_log_le_self M (by - have : 1 ≤ n / K := (Nat.le_div_iff_mul_le hK).mpr (by - have := Nat.mul_le_mul_left K (show 1 ≤ M by omega); nlinarith) - omega) - have hlt : n / K < M ^ (j + 1) := Nat.lt_pow_succ_log_self (by omega) _ - refine ⟨V j, inferInstance, inferInstance, G j, ?_, hsplit j, ?_⟩ - · calc Fintype.card (V j) ≤ K * M ^ j := hcard j - _ ≤ K * (n / K) := Nat.mul_le_mul_left K hMj - _ ≤ n := Nat.mul_div_le n K - · have hn' : (n : ℝ) / (K * M) ≤ (M : ℝ) ^ j := by - have h1 : n < K * (n / K) + K := by - have := Nat.div_add_mod n K - have := Nat.mod_lt n hK - omega - have h2 : n < K * M ^ (j + 1) := by - calc n < K * (n / K) + K := h1 - _ = K * (n / K + 1) := by ring - _ ≤ K * M ^ (j + 1) := Nat.mul_le_mul_left K hlt - rw [div_le_iff₀ (by positivity)] - have : (n : ℝ) < K * M ^ (j + 1) := by exact_mod_cast h2 - rw [pow_succ] at this - nlinarith - have hpow := pow_rpow_alpha ha hM j - have hmono : ((n : ℝ) / (K * M)) ^ α ≤ ((M : ℝ) ^ j) ^ α := - Real.rpow_le_rpow (by positivity) hn' hα - have hsplit' : ((n : ℝ) / (K * M)) ^ α = ((K : ℝ) * M) ^ (-α) * (n : ℝ) ^ α := by - rw [Real.div_rpow (by positivity) (by positivity), Real.rpow_neg (by positivity)] - ring - refine le_trans ?_ (hgap j) - calc ((K : ℝ) * M) ^ (-α) / 3 * (n : ℝ) ^ α = ((n : ℝ) / (K * M)) ^ α / 3 := by - rw [hsplit']; ring - _ ≤ ((M : ℝ) ^ j) ^ α / 3 := by linarith - _ = (a : ℝ) ^ j * (M : ℝ) ^ j / 3 := by rw [hpow] + refine ⟨((K : ℝ) * M) ^ (-(1 + Real.log a / Real.log M)) / 3, by positivity, fun n hn => ?_⟩ + obtain ⟨j, hsize, hscale⟩ := exponent_budget hM ha hK hn + exact ⟨V j, inferInstance, inferInstance, G j, (hcard j).trans hsize, hsplit j, + hscale.trans (hgap j)⟩ variable {U : Type} [AddCommGroup U] [Module F5 U] [Fintype U] [DecidableEq U] diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Main.lean b/LeanPool/SplitCliqueGap/GapExtremal/Main.lean index 3520755561..1902d858d1 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Main.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Main.lean @@ -7,6 +7,7 @@ Authors: Juan Pablo Traverso Gianini module public import LeanPool.SplitCliqueGap.GapExtremal.Hosts +public import LeanPool.SplitCliqueGap.GapExtremal.GraphPadding import Mathlib.Tactic.Linarith import Mathlib.Tactic.Positivity import Mathlib.Tactic.Push @@ -28,21 +29,6 @@ namespace GapExtremal open Finset -/-- Split graphs: a clique and an independent set covering all vertices. -/ -def IsSplit {V : Type*} (G : SimpleGraph V) : Prop := - ∃ K : Set V, (∀ x ∈ K, ∀ y ∈ K, x ≠ y → G.Adj x y) ∧ (∀ x ∉ K, ∀ y ∉ K, ¬ G.Adj x y) - -theorem isSplit_hostGraph {V H : Type*} - (N : H → Finset V) : IsSplit (hostGraph N) := by - refine ⟨Set.range Sum.inl, ?_, ?_⟩ - · rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ h - exact fun e => h (by rw [e]) - · rintro (x | h) hx (y | h') hy - · exact absurd ⟨x, rfl⟩ hx - · exact absurd ⟨x, rfl⟩ hx - · exact absurd ⟨y, rfl⟩ hy - · exact hostGraph_inr_inr N h h' - variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean index 9d11b2ab69..24af11fc47 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean @@ -35,86 +35,6 @@ open Finset variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] -/-! ### Geometry of selected directions on bases -/ - -section Geom - -variable {C : Finset W} (hC : IsCap F (C : Set W)) -include hC - -omit [Fintype W] in -/-- Three points with pairwise selected differences lie on one selected line. -/ -theorem tri_geom {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) - (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) - (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d - ∧ z ∈ line p d := by - have hα : y.1 - x.1 ≠ 0 := by - intro h0; rw [h0, zero_smul, sub_eq_zero] at h1; exact hxy h1.symm - by_cases hab : a = b - · subst hab - refine ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, ?_⟩ - refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ - rw [add_smul, ← h1, ← h2]; abel - by_cases hac : a = c - · subst hac - exact ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ - by_cases hbc : b = c - · subst hbc - refine ⟨b, hb, z, ?_, ?_, self_mem_line z b⟩ - · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ - rw [neg_smul, ← h3]; abel - · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ - rw [neg_smul, ← h2]; abel - exfalso - have e1 := snd_eq_of_sub h1 - have e2 := snd_eq_of_sub h2 - have e3 := snd_eq_of_sub h3 - have := dep_zero hC ha hb hc hab hac hbc (α := y.1 - x.1) (β := z.1 - y.1) (γ := -(z.1 - x.1)) - (by ring) (by rw [← e1, ← e2, neg_smul, ← e3]; abel) - exact hα this.1 - -omit [Fintype W] in -/-- A point off a selected line has selected differences to at most one point of the line. -/ -theorem one_geom {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) - (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) {d e' : W} (hd : d ∈ C) (he : e' ∈ C) - (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := by - by_contra hne - have hyy := sub_of_mem_line hy hy' - have hγ : y'.1 - y.1 ≠ 0 := fun h0 => - hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) - by_cases hdc : d = c0 - · subst hdc - apply hz - rw [← line_eq_of_mem hy] - refine mem_line.mpr ⟨-(y.1 - z.1), ?_⟩ - rw [neg_smul, ← hzy]; abel - by_cases hec : e' = c0 - · subst hec - apply hz - rw [← line_eq_of_mem hy'] - refine mem_line.mpr ⟨-(y'.1 - z.1), ?_⟩ - rw [neg_smul, ← hzy']; abel - by_cases hde : d = e' - · subst hde - have : (y'.1 - y.1) • (u d : F × W) = (y'.1 - y.1) • u c0 := by - rw [← hyy] - have : y' - y = (y' - z) - (y - z) := by abel - rw [this, hzy, hzy', ← sub_smul] - congr 1; ring - exact hdc ((par_eq this).2 hγ) - have e1 := snd_eq_of_sub hzy - have e2 := snd_eq_of_sub hzy' - have e3 := snd_eq_of_sub hyy - have := dep_zero hC he hd hc0 (Ne.symm hde) hec hdc (α := y'.1 - z.1) (β := -(y.1 - z.1)) - (γ := -(y'.1 - y.1)) (by ring) (by rw [← e2, neg_smul, ← e1, neg_smul, ← e3]; abel) - have hz' : y' = z := by - have h0 : y'.1 - z.1 = 0 := this.1 - rw [h0, zero_smul, sub_eq_zero] at hzy' - exact hzy' - exact hz (hz' ▸ hy') - -end Geom - /-! ### Positioned cores -/ /-- Data of a positioned core. -/ @@ -187,10 +107,21 @@ theorem PB_adj_pos {v v' : V} (h : (PB D C).Adj v v') : (∃ i, D.σ i = D.pos v D.σ j = D.pos v' := by obtain ⟨-, -, i, j, hi, hj, -⟩ := h; exact ⟨⟨i, hi⟩, ⟨j, hj⟩⟩ -variable (hC : IsCap F (C : Set W)) +section ActiveCap + +/-- Active colours of a positioned core. -/ +def actCol : Set F := Set.range fun i => D.col (D.σ i) + +omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] + [Fintype W] in +theorem fst_mem_actCol {v : V} (h : ∃ i, D.σ i = D.pos v) : (D.base v).1 ∈ actCol D := by + obtain ⟨i, hi⟩ := h + exact ⟨i, by rw [D.base_fst]; exact congrArg D.col hi⟩ + +variable (hC : IsSCap (actCol D) (C : Set W)) include hC -theorem pblockHyp : BlockHyp2 (PB D C) (pblocks D C) where +theorem pblockHyp_s : BlockHyp2 (PB D C) (pblocks D C) where edge := by intro v v' h obtain ⟨hv, hv'⟩ := PB_adj_pos D h @@ -206,7 +137,8 @@ theorem pblockHyp : BlockHyp2 (PB D C) (pblocks D C) where obtain ⟨hne, ⟨c1, hc1, h1⟩, -⟩ := hab obtain ⟨-, ⟨c2, hc2, h2⟩, -⟩ := hbx obtain ⟨-, ⟨c3, hc3, h3⟩, -⟩ := hax - obtain ⟨d, hd, p, ha, hb, hx⟩ := tri_geom hC hc1 hc2 hc3 hne h1 h2 h3 + obtain ⟨d, hd, p, ha, hb, hx⟩ := tri_geom_s hC hc1 hc2 hc3 hne (fst_mem_actCol D pa) + (fst_mem_actCol D pb) (fst_mem_actCol D px) h1 h2 h3 refine ⟨pblock D p d, pblock_mem D hd p, ?_, ?_, ?_⟩ · exact (mem_pblock D).mpr ⟨ha, pa⟩ · exact (mem_pblock D).mpr ⟨hb, pb⟩ @@ -216,29 +148,34 @@ theorem pblockHyp : BlockHyp2 (PB D C) (pblocks D C) where obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 rw [mem_pblock] at hy hy' hy'' + have pz := (PB_adj_pos D h1).1 have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => - hz ((mem_pblock D).mpr ⟨hzl, (PB_adj_pos D h1).1⟩) + hz ((mem_pblock D).mpr ⟨hzl, pz⟩) obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 obtain ⟨-, ⟨d3, hd3, e3⟩, -⟩ := h3 - have b12 := one_geom hC hc0 hzl hy.1 hy'.1 hd1 hd2 e1 e2 - have b13 := one_geom hC hc0 hzl hy.1 hy''.1 hd1 hd3 e1 e3 + have b12 := one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2 + have b13 := one_geom_s hC hc0 hzl hy.1 hy''.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy''.2) hd1 hd3 e1 e3 exact D.fib y y' y'' b12 b13 nonadj := by intro ℓ hℓ z hz y hy y' hy' h1 h2 hyy obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 rw [mem_pblock] at hy hy' + have pz := (PB_adj_pos D h1).1 have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => - hz ((mem_pblock D).mpr ⟨hzl, (PB_adj_pos D h1).1⟩) + hz ((mem_pblock D).mpr ⟨hzl, pz⟩) obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 - exact hyy.1 (one_geom hC hc0 hzl hy.1 hy'.1 hd1 hd2 e1 e2) + exact hyy.1 (one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) + (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2) -/-- **`I(B) ≤ 8 · #blocks`** on a positioned core. -/ -theorem pI_le {T : Finset (Finset V)} (hT : IsPack T) : +/-- **`I(B) ≤ 8 · #blocks`** under an S-cap. -/ +theorem pI_le_s {T : Finset (Finset V)} (hT : IsPack T) : ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card := by - refine global_bound2 (pblockHyp D hC) 8 ?_ hT + refine global_bound2 (pblockHyp_s D hC) 8 ?_ hT intro ℓ hℓ T' hT'sub hT' obtain ⟨⟨c0, w0⟩, -, rfl⟩ := Finset.mem_image.mp hℓ have hinj : Set.InjOn D.pos (pblock D ((0 : F), w0) c0 : Set V) := by @@ -253,4 +190,17 @@ theorem pI_le {T : Finset (Finset V)} (hT : IsPack T) : exact ⟨i, j, hi, hj, hij⟩) T' hT'sub hT' simpa using this +end ActiveCap + +variable (hC : IsCap F (C : Set W)) +include hC + +theorem pblockHyp : BlockHyp2 (PB D C) (pblocks D C) := + pblockHyp_s D hC.isSCap + +/-- Bound the integral packing score of a positioned core from an ordinary cap. -/ +theorem pI_le {T : Finset (Finset V)} (hT : IsPack T) : + ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card := + pI_le_s D hC.isSCap hT + end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean index 0f5a21d9b0..48301b646d 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean @@ -121,18 +121,9 @@ theorem presPack : ResPack (pysrc D C) where · exact absurd rfl h load a b hab := by classical - set T := (ppieces D C).filter (fun S => a ∈ S ∧ b ∈ S) with hT - have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then pysrc D C S else 0) = T.card * (1 / 3 : ℝ) := by - rw [hT, Finset.card_filter, Nat.cast_sum, Finset.sum_mul] - rw [← Finset.sum_subset (Finset.subset_univ (ppieces D C))] - · refine Finset.sum_congr rfl fun S hS => ?_ - unfold pysrc - rw [ite_eq_left hS] - split_ifs <;> simp - · intro S _ hS - unfold pysrc - rw [ite_eq_right hS] - simp + set T := (ppieces D C).filter (fun S => a ∈ S ∧ b ∈ S) + have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then pysrc D C S else 0) = T.card * (1 / 3 : ℝ) := + by simpa only [pysrc, T] using source_pair_weight (ppieces D C) a b rw [hsum] have hT3 : T.card ≤ 3 := by rcases T.eq_empty_or_nonempty with h0 | ⟨S0, hS0⟩ @@ -190,16 +181,6 @@ omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] in theorem pvalue : (25 / 3 : ℝ) * (C.card * Fintype.card W) ≤ ∑ S, pysrc D C S * (w (PB D C) S : ℝ) := by classical - have h1 : ∑ S, pysrc D C S * (w (PB D C) S : ℝ) = - ∑ x ∈ pidx C, (1 / 3 : ℝ) * (w (PB D C) (ppiece D x) : ℝ) := by - rw [← Finset.sum_image (f := fun S => (1 / 3 : ℝ) * (w (PB D C) S : ℝ)) (ppiece_injOn D)] - rw [← Finset.sum_subset (Finset.subset_univ (ppieces D C))] - · refine Finset.sum_congr rfl fun S hS => ?_ - unfold pysrc - rw [ite_eq_left (show S ∈ ppieces D C from hS)] - · intro S _ hS - unfold pysrc - rw [ite_eq_right (show S ∉ ppieces D C from hS), zero_mul] have h2 : ∀ x ∈ pidx C, ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) ≤ (w (PB D C) (ppiece D x) : ℝ) := by rintro ⟨⟨c, w0⟩, K⟩ hx @@ -213,20 +194,11 @@ theorem pvalue : have : (H12.eH K : ℝ) ≤ (e (PB D C) (ppiece D ((c, w0), K)) : ℝ) := by exact_mod_cast he push_cast linarith - rw [h1] - calc (25 / 3 : ℝ) * (C.card * Fintype.card W) - = ∑ x ∈ pidx C, (1 / 3 : ℝ) * - ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) := by - rw [← Finset.mul_sum, pidx, Finset.sum_product] - simp only - have hv : ∑ K ∈ src, ((2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) = 25 := by - exact_mod_cast src_value - rw [Finset.sum_congr rfl fun _ _ => hv, Finset.sum_const, Finset.card_product, - Finset.card_univ, nsmul_eq_mul] - push_cast - ring - _ ≤ _ := Finset.sum_le_sum fun x hx => by - have := h2 x hx - linarith + have bound := source_score_bound C (ppiece D) (fun S => (w (PB D C) S : ℝ)) (ppiece_injOn D) h2 + refine bound.trans (le_of_eq ?_) + apply Finset.sum_congr rfl + intro S _ + unfold pysrc ppieces + by_cases hS : S ∈ (pidx C).image (ppiece D) <;> simp [hS] end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean index b2b9ee8ef1..48b8f97768 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean @@ -15,19 +15,11 @@ import Mathlib.Tactic.Ring import Mathlib.Tactic.Abel /-! -# S-caps suffice (ledger §17, L17.1) +# The split-graph gap under a cap supported on active colours -The cap hypothesis enters the positioned construction only through `tri_geom` and `one_geom`, and -there the -coefficients of the linear dependence are differences of *active* colours. So it suffices that the -seed `A` be an -**S-cap** for the set `S` of active colours: no three distinct `a, b, c ∈ A` and `s₁, s₂, s₃ ∈ S` -with `s₁ ≠ s₂` and -`(s₂ - s₁) a + (s₃ - s₂) b + (s₁ - s₃) c = 0`. +The positioned construction uses only relations among its active colours. +The resulting exponent bound applies to every cap for that colour set. -This file re-runs the chain `pblockHyp → pI_le → pgap_ge_third → tp_single` under that weaker -hypothesis -(`tp_single_s`). The original cap chain is left untouched. -/ @[expose] public section @@ -36,173 +28,11 @@ namespace GapExtremal open Finset -/-! ### S-caps -/ -section SCapDef - -variable {K : Type*} [Field K] {V : Type*} [AddCommGroup V] [Module K V] - -/-- `A` is an `S`-cap: no colour relation `(s₂ - s₁) a + (s₃ - s₂) b + (s₁ - s₃) c = 0` with `s₁ ≠ -s₂` among three -distinct points of `A`. -/ -def IsSCap (S : Set K) (A : Set V) : Prop := - ∀ ⦃a⦄, a ∈ A → ∀ ⦃b⦄, b ∈ A → ∀ ⦃c⦄, c ∈ A → a ≠ b → a ≠ c → b ≠ c → - ∀ ⦃s₁⦄, s₁ ∈ S → ∀ ⦃s₂⦄, s₂ ∈ S → ∀ ⦃s₃⦄, s₃ ∈ S → s₁ ≠ s₂ → - (s₂ - s₁) • a + (s₃ - s₂) • b + (s₁ - s₃) • c ≠ 0 - -/-- A colour relation with `s₂ = s₃` forces `a = c`. -/ -theorem rel_eq23 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} - (h : (s₂ - s₁) • a + (s₂ - s₂) • b + (s₁ - s₂) • c = 0) : a = c := by - have : (s₂ - s₁) • (a - c) = 0 := by - rw [smul_sub] - have e : (s₁ - s₂) • c = -((s₂ - s₁) • c) := by rw [← neg_smul, neg_sub] - rw [sub_self, zero_smul, add_zero, e] at h - simpa [sub_eq_add_neg] using h - rcases smul_eq_zero.mp this with h0 | h0 - · exact absurd (sub_eq_zero.mp h0).symm h12 - · exact sub_eq_zero.mp h0 - -/-- A colour relation with `s₁ = s₃` forces `a = b`. -/ -theorem rel_eq13 {s₁ s₂ : K} (h12 : s₁ ≠ s₂) {a b c : V} - (h : (s₂ - s₁) • a + (s₁ - s₂) • b + (s₁ - s₁) • c = 0) : a = b := by - have : (s₂ - s₁) • (a - b) = 0 := by - rw [smul_sub] - have e : (s₁ - s₂) • b = -((s₂ - s₁) • b) := by rw [← neg_smul, neg_sub] - rw [sub_self, zero_smul, add_zero, e] at h - simpa [sub_eq_add_neg] using h - rcases smul_eq_zero.mp this with h0 | h0 - · exact absurd (sub_eq_zero.mp h0).symm h12 - · exact sub_eq_zero.mp h0 - -/-- S-caps are closed under powers. -/ -theorem IsSCap.pi {ι : Type*} {S : Set K} {A : Set V} (hA : IsSCap S A) : - IsSCap S (Set.pi Set.univ (fun _ : ι => A)) := by - intro a ha b hb c hc hab hac hbc s₁ h1 s₂ h2 s₃ h3 h12 hrel - have hcoord : ∀ i, (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • c i = 0 := fun i => by - simpa using congrFun hrel i - by_cases h23 : s₂ = s₃ - · subst h23 - exact hac (funext fun i => rel_eq23 h12 (hcoord i)) - by_cases h13 : s₁ = s₃ - · subst h13 - exact hab (funext fun i => rel_eq13 h12 (hcoord i)) - obtain ⟨i, hi⟩ : ∃ i, a i ≠ b i := by - by_contra h; push Not at h; exact hab (funext h) - have hai := ha i (Set.mem_univ i) - have hbi := hb i (Set.mem_univ i) - have hci := hc i (Set.mem_univ i) - by_cases hac' : a i = c i - · -- then `(s₂ - s₃) (a i - b i) = 0` - have e := hcoord i - rw [← hac'] at e - have : (s₂ - s₃) • (a i - b i) = 0 := by - have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • a i = (s₂ - s₃) • (a i - b i) := by - simp only [smul_sub, sub_smul]; abel - rw [← this]; exact e - rcases smul_eq_zero.mp this with h0 | h0 - · exact h23 (sub_eq_zero.mp h0) - · exact hi (sub_eq_zero.mp h0) - by_cases hbc' : b i = c i - · have e := hcoord i - rw [← hbc'] at e - have : (s₂ - s₁) • (a i - b i) = 0 := by - have : (s₂ - s₁) • a i + (s₃ - s₂) • b i + (s₁ - s₃) • b i = (s₂ - s₁) • (a i - b i) := by - simp only [smul_sub, sub_smul]; abel - rw [← this]; exact e - rcases smul_eq_zero.mp this with h0 | h0 - · exact h12 (sub_eq_zero.mp h0).symm - · exact hi (sub_eq_zero.mp h0) - exact hA hai hbi hci hi hac' hbc' h1 h2 h3 h12 (hcoord i) - -end SCapDef variable {F : Type*} [Field F] [Fintype F] [DecidableEq F] variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] -/-! ### Geometry under an S-cap -/ - -section Geom - -variable {S : Set F} {C : Finset W} (hC : IsSCap S (C : Set W)) -include hC - -omit [Fintype W] in -/-- `tri_geom` under an S-cap, for points of active colours. -/ -theorem tri_geom_s {x y z : F × W} {a b c : W} (ha : a ∈ C) (hb : b ∈ C) (hc : c ∈ C) (hxy : x ≠ y) - (hxS : x.1 ∈ S) (hyS : y.1 ∈ S) (hzS : z.1 ∈ S) - (h1 : y - x = (y.1 - x.1) • u a) (h2 : z - y = (z.1 - y.1) • u b) - (h3 : z - x = (z.1 - x.1) • u c) : ∃ d ∈ C, ∃ p : F × W, x ∈ line p d ∧ y ∈ line p d - ∧ z ∈ line p d := by - have hα : y.1 - x.1 ≠ 0 := by - intro h0; rw [h0, zero_smul, sub_eq_zero] at h1; exact hxy h1.symm - by_cases hab : a = b - · subst hab - refine ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, ?_⟩ - refine mem_line.mpr ⟨(y.1 - x.1) + (z.1 - y.1), ?_⟩ - rw [add_smul, ← h1, ← h2]; abel - by_cases hac : a = c - · subst hac - exact ⟨a, ha, x, self_mem_line x a, mem_line_of_sub h1, mem_line_of_sub h3⟩ - by_cases hbc : b = c - · subst hbc - refine ⟨b, hb, z, ?_, ?_, self_mem_line z b⟩ - · refine mem_line.mpr ⟨-(z.1 - x.1), ?_⟩ - rw [neg_smul, ← h3]; abel - · refine mem_line.mpr ⟨-(z.1 - y.1), ?_⟩ - rw [neg_smul, ← h2]; abel - exfalso - have e1 := snd_eq_of_sub h1 - have e2 := snd_eq_of_sub h2 - have e3 := snd_eq_of_sub h3 - refine hC ha hb hc hab hac hbc hxS hyS hzS (fun h0 => hα (sub_eq_zero.mpr h0.symm)) ?_ - rw [show x.1 - z.1 = -(z.1 - x.1) by ring, ← e1, ← e2, neg_smul, ← e3]; abel - -omit [Fintype W] in -/-- `one_geom` under an S-cap, for points of active colours. -/ -theorem one_geom_s {x0 : F × W} {c0 : W} (hc0 : c0 ∈ C) {z y y' : F × W} (hz : z ∉ line x0 c0) - (hy : y ∈ line x0 c0) (hy' : y' ∈ line x0 c0) (hzS : z.1 ∈ S) (hyS : y.1 ∈ S) (hy'S : y'.1 ∈ S) - {d e' : W} (hd : d ∈ C) (he : e' ∈ C) - (hzy : y - z = (y.1 - z.1) • u d) (hzy' : y' - z = (y'.1 - z.1) • u e') : y = y' := by - by_contra hne - have hyy := sub_of_mem_line hy hy' - have hγ : y'.1 - y.1 ≠ 0 := fun h0 => - hne (fst_injOn_line x0 c0 hy hy' (sub_eq_zero.mp h0).symm) - by_cases hdc : d = c0 - · subst hdc - apply hz - rw [← line_eq_of_mem hy] - refine mem_line.mpr ⟨-(y.1 - z.1), ?_⟩ - rw [neg_smul, ← hzy]; abel - by_cases hec : e' = c0 - · subst hec - apply hz - rw [← line_eq_of_mem hy'] - refine mem_line.mpr ⟨-(y'.1 - z.1), ?_⟩ - rw [neg_smul, ← hzy']; abel - by_cases hde : d = e' - · subst hde - have : (y'.1 - y.1) • (u d : F × W) = (y'.1 - y.1) • u c0 := by - rw [← hyy] - have : y' - y = (y' - z) - (y - z) := by abel - rw [this, hzy, hzy', ← sub_smul] - congr 1; ring - exact hdc ((par_eq this).2 hγ) - by_cases hzy1 : y'.1 = z.1 - · have : y' = z := by - rw [hzy1, sub_self, zero_smul, sub_eq_zero] at hzy' - exact hzy' - exact hz (this ▸ hy') - have e1 := snd_eq_of_sub hzy - have e2 := snd_eq_of_sub hzy' - have e3 := snd_eq_of_sub hyy - -- colours `s₁ = z.1`, `s₂ = y'.1`, `s₃ = y.1`; points `e'`, `c0`, `d` - refine hC he hc0 hd hec (Ne.symm hde) (Ne.symm hdc) hzS hy'S hyS (Ne.symm hzy1) ?_ - have : (y.1 - y'.1) • c0 = -((y'.1 - y.1) • c0) := by rw [← neg_smul, neg_sub] - have hd' : (z.1 - y.1) • d = -((y.1 - z.1) • d) := by rw [← neg_smul, neg_sub] - rw [hd', this, ← e2, ← e1, ← e3]; abel - -end Geom - section PChain /-! ### The positioned chain under an S-cap -/ @@ -210,88 +40,6 @@ section PChain variable {V P : Type*} [Fintype V] [DecidableEq V] [DecidableEq P] variable (D : PData F W V P) {C : Finset W} -/-- Active colours of a positioned core. -/ -def actCol : Set F := Set.range fun i => D.col (D.σ i) - -omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] - [Fintype W] in -theorem fst_mem_actCol {v : V} (h : ∃ i, D.σ i = D.pos v) : (D.base v).1 ∈ actCol D := by - obtain ⟨i, hi⟩ := h - exact ⟨i, by rw [D.base_fst]; exact congrArg D.col hi⟩ - -variable (hC : IsSCap (actCol D) (C : Set W)) -include hC - -theorem pblockHyp_s : BlockHyp2 (PB D C) (pblocks D C) where - edge := by - intro v v' h - obtain ⟨hv, hv'⟩ := PB_adj_pos D h - obtain ⟨-, ⟨c, hc, hdir⟩, -⟩ := h - refine ⟨pblock D (D.base v) c, pblock_mem D hc _, ?_, ?_⟩ - · exact (mem_pblock D).mpr ⟨self_mem_line _ _, hv⟩ - · exact (mem_pblock D).mpr ⟨mem_line_of_sub hdir, hv'⟩ - tri := by - intro a b x hab hbx hax - have pa := (PB_adj_pos D hab).1 - have pb := (PB_adj_pos D hab).2 - have px := (PB_adj_pos D hbx).2 - obtain ⟨hne, ⟨c1, hc1, h1⟩, -⟩ := hab - obtain ⟨-, ⟨c2, hc2, h2⟩, -⟩ := hbx - obtain ⟨-, ⟨c3, hc3, h3⟩, -⟩ := hax - obtain ⟨d, hd, p, ha, hb, hx⟩ := tri_geom_s hC hc1 hc2 hc3 hne (fst_mem_actCol D pa) - (fst_mem_actCol D pb) (fst_mem_actCol D px) h1 h2 h3 - refine ⟨pblock D p d, pblock_mem D hd p, ?_, ?_, ?_⟩ - · exact (mem_pblock D).mpr ⟨ha, pa⟩ - · exact (mem_pblock D).mpr ⟨hb, pb⟩ - · exact (mem_pblock D).mpr ⟨hx, px⟩ - two := by - intro ℓ hℓ z hz y hy y' hy' y'' hy'' h1 h2 h3 - obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ - have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 - rw [mem_pblock] at hy hy' hy'' - have pz := (PB_adj_pos D h1).1 - have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => - hz ((mem_pblock D).mpr ⟨hzl, pz⟩) - obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 - obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 - obtain ⟨-, ⟨d3, hd3, e3⟩, -⟩ := h3 - have b12 := one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) - (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2 - have b13 := one_geom_s hC hc0 hzl hy.1 hy''.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) - (fst_mem_actCol D hy''.2) hd1 hd3 e1 e3 - exact D.fib y y' y'' b12 b13 - nonadj := by - intro ℓ hℓ z hz y hy y' hy' h1 h2 hyy - obtain ⟨⟨c0, w0⟩, hp, rfl⟩ := Finset.mem_image.mp hℓ - have hc0 : c0 ∈ C := (Finset.mem_product.mp hp).1 - rw [mem_pblock] at hy hy' - have pz := (PB_adj_pos D h1).1 - have hzl : D.base z ∉ line ((0 : F), w0) c0 := fun hzl => - hz ((mem_pblock D).mpr ⟨hzl, pz⟩) - obtain ⟨-, ⟨d1, hd1, e1⟩, -⟩ := h1 - obtain ⟨-, ⟨d2, hd2, e2⟩, -⟩ := h2 - exact hyy.1 (one_geom_s hC hc0 hzl hy.1 hy'.1 (fst_mem_actCol D pz) (fst_mem_actCol D hy.2) - (fst_mem_actCol D hy'.2) hd1 hd2 e1 e2) - -/-- **`I(B) ≤ 8 · #blocks`** under an S-cap. -/ -theorem pI_le_s {T : Finset (Finset V)} (hT : IsPack T) : - ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card := by - refine global_bound2 (pblockHyp_s D hC) 8 ?_ hT - intro ℓ hℓ T' hT'sub hT' - obtain ⟨⟨c0, w0⟩, -, rfl⟩ := Finset.mem_image.mp hℓ - have hinj : Set.InjOn D.pos (pblock D ((0 : F), w0) c0 : Set V) := by - intro v hv v' hv' h - rw [Finset.mem_coe, mem_pblock] at hv hv' - apply D.inj v v' _ h - apply fst_injOn_line _ _ hv.1 hv'.1 - rw [D.base_fst, D.base_fst, h] - have := block_local (B := PB D C) D.pos D.σ hinj - (fun v _ v' _ h => by - obtain ⟨-, -, i, j, hi, hj, hij⟩ := h - exact ⟨i, j, hi, hj, hij⟩) T' hT'sub hT' - simpa using this - -omit hC in theorem pgap_ge_third_s [Fintype P] {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] (hC : IsSCap (actCol D) (C : Set W)) (hC0 : C.Nonempty) (S : SepFam F C U) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Source.lean b/LeanPool/SplitCliqueGap/GapExtremal/Source.lean index 8f0428f54f..d26dbe0ab9 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Source.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Source.lean @@ -176,6 +176,21 @@ omit [Fintype F] [Fintype W] in theorem mem_piece_iff {x : (W × W) × Finset (Fin 6)} {p : F × W} : p ∈ piece σ x ↔ ∃ i ∈ x.2, ptc σ x.1.2 x.1.1 i = p := Finset.mem_image +open Classical in +/-- The pair load of a uniform one-third source counts the pieces containing the pair. -/ +theorem source_pair_weight {α : Type*} [Fintype α] [DecidableEq α] + (P : Finset (Finset α)) (a b : α) : + (∑ S, if a ∈ S ∧ b ∈ S then (if S ∈ P then (1 : ℝ) / 3 else 0) else 0) = + ((P.filter (fun S => a ∈ S ∧ b ∈ S)).card : ℝ) * (1 / 3) := by + rw [Finset.card_filter, Nat.cast_sum, Finset.sum_mul] + rw [← Finset.sum_subset (Finset.subset_univ P)] + · refine Finset.sum_congr rfl fun S hS => ?_ + rw [ite_eq_left hS] + split_ifs <;> simp + · intro S _ hS + rw [ite_eq_right hS] + simp + theorem resPack_ysrc : ResPack (ysrc C σ) where nonneg S := by unfold ysrc; split_ifs <;> norm_num two S h := by @@ -188,18 +203,9 @@ theorem resPack_ysrc : ResPack (ysrc C σ) where · exact absurd rfl h load a b hab := by classical - set T := (pieces C σ).filter (fun S => a ∈ S ∧ b ∈ S) with hT - have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then ysrc C σ S else 0) = T.card * (1 / 3 : ℝ) := by - rw [hT, Finset.card_filter, Nat.cast_sum, Finset.sum_mul] - rw [← Finset.sum_subset (Finset.subset_univ (pieces C σ))] - · refine Finset.sum_congr rfl fun S hS => ?_ - unfold ysrc - rw [ite_eq_left hS] - split_ifs <;> simp - · intro S _ hS - unfold ysrc - rw [ite_eq_right hS] - simp + set T := (pieces C σ).filter (fun S => a ∈ S ∧ b ∈ S) + have hsum : ∑ S, (if a ∈ S ∧ b ∈ S then ysrc C σ S else 0) = T.card * (1 / 3 : ℝ) := + by simpa only [ysrc, T] using source_pair_weight (pieces C σ) a b rw [hsum] have hT3 : T.card ≤ 3 := by rcases T.eq_empty_or_nonempty with h0 | ⟨S0, hS0⟩ @@ -228,20 +234,41 @@ theorem resPack_ysrc : ResPack (ysrc C σ) where have : (T.card : ℝ) ≤ 3 := by exact_mod_cast hT3 linarith +open Classical in +/-- Sum the template score over an injectively indexed family of source pieces. -/ +theorem source_score_bound {α U : Type*} [Fintype α] [DecidableEq α] [Fintype U] (C : Finset U) + (piece : (U × U) × Finset (Fin 6) → Finset α) (score : Finset α → ℝ) + (hinj : Set.InjOn piece (pidx C : Set _)) + (hscore : ∀ x ∈ pidx C, + ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) ≤ score (piece x)) : + (25 / 3 : ℝ) * (C.card * Fintype.card U) ≤ + ∑ S, (if S ∈ (pidx C).image piece then (1 : ℝ) / 3 else 0) * score S := by + have h1 : (∑ S, (if S ∈ (pidx C).image piece then (1 : ℝ) / 3 else 0) * score S) = + ∑ x ∈ pidx C, (1 / 3 : ℝ) * score (piece x) := by + rw [← Finset.sum_image (f := fun S => (1 / 3 : ℝ) * score S) hinj] + rw [← Finset.sum_subset (Finset.subset_univ ((pidx C).image piece))] + · exact Finset.sum_congr rfl fun S hS => by rw [ite_eq_left hS] + · intro S _ hS + rw [ite_eq_right hS, zero_mul] + rw [h1] + calc (25 / 3 : ℝ) * (C.card * Fintype.card U) + = ∑ x ∈ pidx C, (1 / 3 : ℝ) * + ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) := by + rw [← Finset.mul_sum, pidx, Finset.sum_product] + simp only + have hv : ∑ K ∈ src, ((2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) = 25 := by + exact_mod_cast src_value + rw [Finset.sum_congr rfl fun _ _ => hv, Finset.sum_const, Finset.card_product, + Finset.card_univ, nsmul_eq_mul] + push_cast + ring + _ ≤ _ := Finset.sum_le_sum fun x hx => + mul_le_mul_of_nonneg_left (hscore x hx) (by norm_num) + /-- **L7.4.** The source has value at least `25/3` per block. -/ theorem value_ysrc : (25 / 3 : ℝ) * (C.card * Fintype.card W) ≤ ∑ S, ysrc C σ S * (w (Bgr C σ) S : ℝ) := by classical - have h1 : ∑ S, ysrc C σ S * (w (Bgr C σ) S : ℝ) = - ∑ x ∈ pidx C, (1 / 3 : ℝ) * (w (Bgr C σ) (piece σ x) : ℝ) := by - rw [← Finset.sum_image (f := fun S => (1 / 3 : ℝ) * (w (Bgr C σ) S : ℝ)) piece_injOn] - rw [← Finset.sum_subset (Finset.subset_univ (pieces C σ))] - · refine Finset.sum_congr rfl fun S hS => ?_ - unfold ysrc - rw [ite_eq_left (show S ∈ pieces C σ from hS)] - · intro S _ hS - unfold ysrc - rw [ite_eq_right (show S ∉ pieces C σ from hS), zero_mul] have h2 : ∀ x ∈ pidx C, ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) ≤ (w (Bgr C σ) (piece σ x) : ℝ) := by rintro ⟨⟨c, w0⟩, K⟩ hx @@ -255,20 +282,11 @@ theorem value_ysrc : have : (H12.eH K : ℝ) ≤ (e (Bgr C σ) (piece σ ((c, w0), K)) : ℝ) := by exact_mod_cast he push_cast linarith - rw [h1] - calc (25 / 3 : ℝ) * (C.card * Fintype.card W) - = ∑ x ∈ pidx C, (1 / 3 : ℝ) * - ((2 * (H12.eH x.2 : ℤ) - (x.2.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) := by - rw [← Finset.mul_sum, pidx, Finset.sum_product] - simp only - have hv : ∑ K ∈ src, ((2 * (H12.eH K : ℤ) - (K.card.choose 2 : ℕ) - 1 : ℤ) : ℝ) = 25 := by - exact_mod_cast src_value - rw [Finset.sum_congr rfl fun _ _ => hv, Finset.sum_const, Finset.card_product, - Finset.card_univ, nsmul_eq_mul] - push_cast - ring - _ ≤ _ := Finset.sum_le_sum fun x hx => by - have := h2 x hx - linarith + have bound := source_score_bound C (piece σ) (fun S => (w (Bgr C σ) S : ℝ)) piece_injOn h2 + refine bound.trans (le_of_eq ?_) + apply Finset.sum_congr rfl + intro S _ + unfold ysrc pieces + by_cases hS : S ∈ (pidx C).image (piece σ) <;> simp [hS] end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean b/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean index a41269dd47..0c84e8a007 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Sphere.lean @@ -94,8 +94,6 @@ theorem sphere_rel {N : ℕ} (X Y Z : Fin N → ℤ) {α β : ℤ} (hα : α ≠ variable {p : ℕ} [hp : Fact p.Prime] -/-- Pin the additive group of `ZMod p` to the ring structure (avoids an exotic instance path). -/ -instance (priority := 10000) addCommGroupZModP : AddCommGroup (ZMod p) := Ring.toAddCommGroup /-- The colours `0, …, 5` in `ZMod p` (`p > 5`). -/ def colσ (hp5 : 5 < p) : Fin 6 ↪ ZMod p where diff --git a/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean b/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean index ef360651df..7cc973fe8e 100644 --- a/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean +++ b/LeanPool/SplitCliqueGap/GraphBase/Clique/Partition.lean @@ -95,40 +95,50 @@ section Integral variable [DecidableEq V] +omit [DecidableEq V] in +/-- The edges, as two-element sets, form a clique partition with `|E(G)|` members. -/ +theorem exists_isCliquePartition_card_eq_edgeFinset (G : SimpleGraph V) [DecidableRel G.Adj] : + ∃ P, G.IsCliquePartition P ∧ P.card = G.edgeFinset.card := by + classical + refine ⟨G.edgeFinset.image Sym2.toFinset, ⟨?_, ?_, ?_⟩, ?_⟩ + · simp only [Finset.mem_image, mem_edgeFinset] + rintro s ⟨e, he, rfl⟩ + induction e using Sym2.ind with + | h a b => + rw [mem_edgeSet] at he + rw [Sym2.toFinset_mk_eq, Finset.card_pair he.ne] + · simp only [Finset.mem_image, mem_edgeFinset] + rintro s ⟨e, he, rfl⟩ + induction e using Sym2.ind with + | h a b => + rw [mem_edgeSet] at he + rw [Sym2.toFinset_mk_eq, Finset.coe_pair] + exact isClique_pair.mpr (fun _ => he) + · intro u v huv + refine ⟨s(u, v).toFinset, + ⟨Finset.mem_image.mpr ⟨s(u, v), by simpa using huv, rfl⟩, by simp, by simp⟩, ?_⟩ + rintro s ⟨hs, hu, hv⟩ + obtain ⟨e, -, rfl⟩ := Finset.mem_image.mp hs + rw [Sym2.mem_toFinset] at hu hv + rw [(Sym2.mem_and_mem_iff huv.ne).mp ⟨hu, hv⟩] + · apply Finset.card_image_of_injOn + intro e he e' _ h + simp only [mem_edgeFinset, Finset.mem_coe] at he + induction e using Sym2.ind with + | h a b => + have hab := (mem_edgeSet G).mp he + have ha : a ∈ e'.toFinset := by rw [← h]; simp + have hb : b ∈ e'.toFinset := by rw [← h]; simp + rw [Sym2.mem_toFinset] at ha hb + exact ((Sym2.mem_and_mem_iff hab.ne).mp ⟨ha, hb⟩).symm + omit [Fintype V] [DecidableEq V] in /-- The edges, as pairs, form a clique partition. -/ theorem exists_isCliquePartition [Finite V] (G : SimpleGraph V) : ∃ P, G.IsCliquePartition P := by classical let _ := Fintype.ofFinite V - refine ⟨(univ.filter (fun p : V × V => G.Adj p.1 p.2)).image (fun p => {p.1, p.2}), ?_, ?_, ?_⟩ - · intro Q hQ - simp only [mem_image, mem_filter, mem_univ, true_and] at hQ - obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ - rw [card_pair hab.ne] - · intro Q hQ - simp only [mem_image, mem_filter, mem_univ, true_and] at hQ - obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ - intro u hu v hv huv - simp only [coe_insert, coe_singleton, Set.mem_insert_iff, Set.mem_singleton_iff] at hu hv - rcases hu with rfl | rfl <;> rcases hv with rfl | rfl - · exact absurd rfl huv - · exact hab - · exact hab.symm - · exact absurd rfl huv - · intro u v huv - refine ⟨{u, v}, ⟨?_, by simp, by simp⟩, ?_⟩ - · simp only [mem_image, mem_filter, mem_univ, true_and] - exact ⟨(u, v), huv, rfl⟩ - · rintro Q ⟨hQ, huQ, hvQ⟩ - simp only [mem_image, mem_filter, mem_univ, true_and] at hQ - obtain ⟨⟨a, b⟩, hab, rfl⟩ := hQ - simp only [mem_insert, mem_singleton] at huQ hvQ - have hne := huv.ne - rcases huQ with rfl | rfl <;> rcases hvQ with rfl | rfl - · exact absurd rfl hne - · rfl - · exact pair_comm _ _ - · exact absurd rfl hne + obtain ⟨P, hP, _⟩ := exists_isCliquePartition_card_eq_edgeFinset G + exact ⟨P, hP⟩ omit [Fintype V] [DecidableEq V] in theorem cliquePartitionNumber_le {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : @@ -170,43 +180,6 @@ theorem cliquePartitionNumber_le_iff [Finite V] (G : SimpleGraph V) {m : ℕ} : · rintro ⟨P, hP, hc⟩ exact (cliquePartitionNumber_le hP).trans hc -omit [DecidableEq V] in -/-- The edges, as two-element sets, form a clique partition with `|E(G)|` members. -/ -theorem exists_isCliquePartition_card_eq_edgeFinset (G : SimpleGraph V) [DecidableRel G.Adj] : - ∃ P, G.IsCliquePartition P ∧ P.card = G.edgeFinset.card := by - classical - refine ⟨G.edgeFinset.image Sym2.toFinset, ⟨?_, ?_, ?_⟩, ?_⟩ - · simp only [Finset.mem_image, mem_edgeFinset] - rintro s ⟨e, he, rfl⟩ - induction e using Sym2.ind with - | h a b => - rw [mem_edgeSet] at he - rw [Sym2.toFinset_mk_eq, Finset.card_pair he.ne] - · simp only [Finset.mem_image, mem_edgeFinset] - rintro s ⟨e, he, rfl⟩ - induction e using Sym2.ind with - | h a b => - rw [mem_edgeSet] at he - rw [Sym2.toFinset_mk_eq, Finset.coe_pair] - exact isClique_pair.mpr (fun _ => he) - · intro u v huv - refine ⟨s(u, v).toFinset, - ⟨Finset.mem_image.mpr ⟨s(u, v), by simpa using huv, rfl⟩, by simp, by simp⟩, ?_⟩ - rintro s ⟨hs, hu, hv⟩ - obtain ⟨e, -, rfl⟩ := Finset.mem_image.mp hs - rw [Sym2.mem_toFinset] at hu hv - rw [(Sym2.mem_and_mem_iff huv.ne).mp ⟨hu, hv⟩] - · apply Finset.card_image_of_injOn - intro e he e' _ h - simp only [mem_edgeFinset, Finset.mem_coe] at he - induction e using Sym2.ind with - | h a b => - have hab := (mem_edgeSet G).mp he - have ha : a ∈ e'.toFinset := by rw [← h]; simp - have hb : b ∈ e'.toFinset := by rw [← h]; simp - rw [Sym2.mem_toFinset] at ha hb - exact ((Sym2.mem_and_mem_iff hab.ne).mp ⟨ha, hb⟩).symm - omit [DecidableEq V] in /-- The members of a clique partition are cliques of order at least two. -/ theorem IsCliquePartition.subset_cliqueSets {P : Finset (Finset V)} (hP : G.IsCliquePartition P) : diff --git a/LeanPool/SplitCliqueGap/Imports.lean b/LeanPool/SplitCliqueGap/Imports.lean index a9ade8c66f..45595f0550 100644 --- a/LeanPool/SplitCliqueGap/Imports.lean +++ b/LeanPool/SplitCliqueGap/Imports.lean @@ -19,6 +19,7 @@ public import LeanPool.SplitCliqueGap.GapExtremal.Geometry public import LeanPool.SplitCliqueGap.GapExtremal.Global public import LeanPool.SplitCliqueGap.GapExtremal.Global2 public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas +public import LeanPool.SplitCliqueGap.GapExtremal.GraphPadding public import LeanPool.SplitCliqueGap.GapExtremal.Hosts public import LeanPool.SplitCliqueGap.GapExtremal.Layered public import LeanPool.SplitCliqueGap.GapExtremal.LayeredExponent diff --git a/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean b/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean index 2db9127071..fbe8b5c3d4 100644 --- a/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean +++ b/LeanPool/SplitCliqueGap/R417/LogErrorAbsorption.lean @@ -6,12 +6,12 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.R417.OptimalCoefficient public import Mathlib.Analysis.Real.Sqrt import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity import Mathlib.Tactic.Ring +public import Mathlib.Analysis.SpecialFunctions.Log.Basic /-! C3: an explicit, uniform threshold absorbs t log t and t errors into eta t². -/ @@ -58,7 +58,7 @@ theorem log_le_two_sqrt {t : ℝ} (ht : 1 ≤ t) : Real.log t ≤ 2 * Real.sqrt _ = 2 * Real.log (Real.sqrt t) := by rw [Real.log_pow]; norm_num _ ≤ 2 * Real.sqrt t := by linarith -theorem log_error_absorption (A B η : ℝ) (hA : 0 ≤ A) (_hB : 0 ≤ B) (hη : 0 < η) : +theorem log_error_absorption (A B η : ℝ) (hA : 0 ≤ A) (hη : 0 < η) : ∃ T : ℝ, 1 ≤ T ∧ ∀ t : ℝ, T ≤ t → A * t * Real.log t + B * t ≤ η * t ^ 2 := by let T := max 1 (max ((4 * A / η) ^ 2) (2 * B / η)) @@ -86,10 +86,10 @@ theorem log_error_absorption (A B η : ℝ) (hA : 0 ≤ A) (_hB : 0 ≤ B) (hη _ ≤ t * (η * t) := mul_le_mul_of_nonneg_left hcoef ht0 _ = η * t ^ 2 := by ring -theorem coefficient_absorption (C A B η : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) (hη : 0 < η) : +theorem coefficient_absorption (C A B η : ℝ) (hA : 0 ≤ A) (hη : 0 < η) : ∃ T : ℝ, 1 ≤ T ∧ ∀ (t E : ℝ), T ≤ t → E ≤ C * t ^ 2 + A * t * Real.log t + B * t → E ≤ (C + η) * t ^ 2 := by - obtain ⟨T, hT, hbound⟩ := log_error_absorption A B η hA hB hη + obtain ⟨T, hT, hbound⟩ := log_error_absorption A B η hA hη refine ⟨T, hT, fun t E ht hE => ?_⟩ have hh := hbound t ht nlinarith diff --git a/LeanPool/SplitCliqueGap/R434/CoreFractional.lean b/LeanPool/SplitCliqueGap/R434/CoreFractional.lean index 43fa7d517c..164f5dd841 100644 --- a/LeanPool/SplitCliqueGap/R434/CoreFractional.lean +++ b/LeanPool/SplitCliqueGap/R434/CoreFractional.lean @@ -113,17 +113,19 @@ theorem core_fractional_score_small (h : R) (hh : 2 * h = 1) (A : Finset R) : have hp (k : R × R × Triangle) (hk : k ∈ D) : k.1 ∈ A ∧ k.2.2 ∈ triangles := by exact ⟨(mem_product.mp hk).1, support_valid (mem_product.mp (mem_product.mp hk).2).2⟩ - refine ⟨y,⟨?_,?_,?_⟩,?_,?_⟩ - · intro S - exact sum_nonneg fun k _ => by split <;> norm_num - · intro S hs - by_contra! hsmall + have supportCard (S : Finset (Role × R)) (hs : y S ≠ 0) : S.card = 3 := by + by_contra hcard apply hs apply sum_eq_zero intro k _ - have hcard : (Q k).card = 3 := blockTriangle_vertices_card _ _ _ - have hne : Q k ≠ S := fun he => by rw [he] at hcard; omega + have hne : Q k ≠ S := fun he => hcard (he ▸ blockTriangle_vertices_card _ _ _) simp [hne] + refine ⟨y, ⟨?_, ?_, ?_⟩, fun S hs => (supportCard S hs).le, ?_⟩ + · intro S + exact sum_nonneg fun k _ => by split <;> norm_num + · intro S hs + rw [supportCard S hs] + norm_num · intro u v huv have hsum : ∑ S, (if u ∈ S ∧ v ∈ S then y S else 0) = ∑ k ∈ D, (if s(u,v) ∈ triangleEdges (blockTriangle k.1 k.2.1 k.2.2) then (1 : ℝ) / 2 else @@ -168,14 +170,6 @@ theorem core_fractional_score_small (h : R) (hh : 2 * h = 1) (A : Finset R) : simp [hne] rw [hzero] norm_num - · intro S hs - by_contra! hlarge - apply hs - apply sum_eq_zero - intro k _ - have hc : (Q k).card = 3 := blockTriangle_vertices_card _ _ _ - have hne : Q k ≠ S := fun he => by rw [he] at hc; omega - simp [hne] · simp only [y, sum_mul, ite_mul, zero_mul] rw [sum_comm] have hval : ∑ k ∈ D, ∑ S, (if Q k = S then (1 : ℝ) / 2 * (w B S : ℝ) else 0) = diff --git a/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean b/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean index e95c1eeabe..b9bc2b75df 100644 --- a/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean +++ b/LeanPool/SplitCliqueGap/R434/EHPSDensity.lean @@ -16,6 +16,7 @@ import Mathlib.Tactic.Positivity import Mathlib.Tactic.Push import Mathlib.Tactic.Ring import Mathlib.Tactic.WLOG +import Mathlib.Algebra.BigOperators.Fin /-! A lattice count of the seven vertical strips of the EHPS region. -/ diff --git a/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean b/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean index a7c9337a86..71938724ef 100644 --- a/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean +++ b/LeanPool/SplitCliqueGap/R434/EHPSRegion.lean @@ -65,8 +65,6 @@ theorem midpoint_total {ε : ℝ} {x y z : Point} (hε : 0 < ε) have hxs := total_bounds hε hx have hys := total_bounds hε hy have hzs := total_bounds hε hz - have hmax₁ : 2 * y.1 ≤ x.1 + z.1 + 1 := by - rcases h₁ with h | h | h <;> linarith only [h] have hmax₂ : 2 * y.2 ≤ x.2 + z.2 + 1 := by rcases h₂ with h | h | h <;> linarith only [h] have hnotup : ¬ (total x + total z + 1 ≤ 2 * total y) := by diff --git a/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean index 564b6f3977..e9bd69b9c3 100644 --- a/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean +++ b/LeanPool/SplitCliqueGap/R434/ExactGraphTransfer.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.ExponentTwo +public import LeanPool.SplitCliqueGap.GapExtremal.GraphPadding /-! The GraphBase bridge and leaf padding at an arbitrary order. -/ diff --git a/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean b/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean index fddf19ac6a..3e042c9459 100644 --- a/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean +++ b/LeanPool/SplitCliqueGap/R434/TripartiteSlack.lean @@ -13,6 +13,7 @@ import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity import Mathlib.Tactic.Ring import Mathlib.Tactic.Tauto +import Mathlib.Algebra.BigOperators.Fin /-! Edge counts and the zero-slack cases for tripartite pieces. -/ diff --git a/LeanPool/SplitCliqueGap/R434/UniformOrder.lean b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean index 742b25caa5..45f9fa0e50 100644 --- a/LeanPool/SplitCliqueGap/R434/UniformOrder.lean +++ b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean @@ -38,9 +38,9 @@ theorem odd_floor_close {x : ℝ} (hx : 1 ≤ x) : dsimp only [y] at hk linarith -theorem log_linear_error (A B d : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) (hd : 0 < d) : +theorem log_linear_error (A B d : ℝ) (hA : 0 ≤ A) (hd : 0 < d) : ∃ T : ℝ, 1 ≤ T ∧ ∀ t : ℝ, T ≤ t → A * log t + B ≤ d * t := by - obtain ⟨T,hT,h⟩ := R417.log_error_absorption A B d hA hB hd + obtain ⟨T,hT,h⟩ := R417.log_error_absorption A B d hA hd refine ⟨T,hT,fun t ht => ?_⟩ have ht₀ : 0 < t := by linarith apply (mul_le_mul_iff_left₀ ht₀).mp @@ -56,8 +56,7 @@ theorem rounded_order_witness (H : ℕ → ℕ) (A c : ℝ) (hA : 1 ≤ A) (m₀ : ℝ) + 2 ≤ t ∧ (j : ℝ) ≤ t ∧ log n = c * t^2 ∧ 2 * (log n - 2 * (j : ℝ) * log (m : ℝ)) ≤ 2 * (log A + log t + 1) ∧ 2 * log (m : ℝ) ≤ c * (t + 2) := by - have hAl : 0 ≤ log A := log_nonneg hA - obtain ⟨T₁,hT₁,h₁⟩ := log_linear_error 1 (log A) (c/2) (by norm_num) hAl (by positivity) + obtain ⟨T₁,hT₁,h₁⟩ := log_linear_error 1 (log A) (c/2) (by norm_num) (by positivity) have hWpos : 0 < W := by linarith let T := 2 + T₁ + 32 * W / c ^ 2 + (m₀ : ℝ) + 2 refine ⟨⌈exp (c * T ^ 2)⌉₊, fun n hn => ?_⟩ @@ -186,11 +185,9 @@ theorem uniform_order_parameters (H : ℕ → ℕ) (A K c η : ℝ) (hA : 1 ≤ let C := 27 * (1 + K) have hC : 1 ≤ C := by dsimp [C]; linarith have hC₀ : 0 < C := by linarith - have hAl : 0 ≤ log A := log_nonneg hA - have hCl : 0 ≤ log C := log_nonneg hC let b := 2 * log A + 2 + 2 * c + log C obtain ⟨T₂,hT₂,h₂⟩ := log_linear_error 3 b (η * sqrt c) (by norm_num) - (by dsimp [b]; linarith) (mul_pos hη (sqrt_pos.mpr hc)) + (mul_pos hη (sqrt_pos.mpr hc)) let M := max m₀ ⌈T₂⌉₊ obtain ⟨N,hN⟩ := rounded_order_witness H A c hA hc 10 (by norm_num) M hH refine ⟨N, fun n hn => ?_⟩ From 96c4938555ed43d0ba4ef44006cc8fcfb7711f06 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 13:51:09 +0000 Subject: [PATCH 5/7] Simplify split-graph exact-order proof reuse --- .../SplitCliqueGap/GapExtremal/Bridge.lean | 2 +- .../GapExtremal/ExactOrder.lean | 57 +++++++++++-------- .../SplitCliqueGap/GapExtremal/Exponent.lean | 21 +++++-- .../SplitCliqueGap/GapExtremal/Global.lean | 5 +- .../SplitCliqueGap/GapExtremal/Layered.lean | 2 +- .../GapExtremal/LayeredExponent.lean | 11 +--- .../SplitCliqueGap/GapExtremal/PCore.lean | 5 +- .../SplitCliqueGap/GapExtremal/PMain.lean | 24 +++++--- .../SplitCliqueGap/GapExtremal/PSource.lean | 3 +- LeanPool/SplitCliqueGap/GapExtremal/SCap.lean | 39 +------------ .../SplitCliqueGap/GapExtremal/Single.lean | 29 +--------- .../SplitCliqueGap/R434/UniformOrder.lean | 6 +- LeanPool/SplitCliqueGap/SplitPartition.lean | 2 +- 13 files changed, 82 insertions(+), 124 deletions(-) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean index 437611f008..d994df19a3 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Bridge.lean @@ -7,7 +7,7 @@ Authors: Juan Pablo Traverso Gianini module public import LeanPool.SplitCliqueGap.GapExtremal.Completion -public import LeanPool.SplitCliqueGap.GapExtremal.Global +public import LeanPool.SplitCliqueGap.GapExtremal.GlobalLemmas import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum import Mathlib.Tactic.Push diff --git a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean index f95f0c6b1c..63042c4ae2 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/ExactOrder.lean @@ -60,25 +60,13 @@ variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] variable {V P : Type*} [Fintype V] [DecidableEq V] [Fintype P] [DecidableEq P] variable {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] -instance instDecEqPadIdx (k : ℕ) : DecidableEq (PHostIdx F W P U ⊕ Fin k) := - @instDecidableEqSum _ _ instDecEqPHostIdx inferInstance - -instance instDecEqSumPadIdx (k : ℕ) : DecidableEq (V ⊕ (PHostIdx F W P U ⊕ Fin k)) := - @instDecidableEqSum _ _ inferInstance (instDecEqPadIdx k) - /-- **Cor. 16.4, padded.** -/ theorem pgap_ge_third_pad (D : PData F W V P) {C : Finset W} (hC : IsSCap (actCol D) (C : Set W)) (hC0 : C.Nonempty) (S : SepFam F C U) (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → ¬ H12.graph.Adj i j) (x0 : V) (k : ℕ) : ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (padN (ppalette D C S) x0 k)) := by - have h := gap_ge ((phostHyp (S := S) hC0 hsame).pad x0 k) (8 * (pblocks D C).card) - (fun T hT => pI_le_s D hC hT) (presPack (D := D) (C := C)) - have hv := pvalue (D := D) (C := C) - have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by - exact_mod_cast card_pblocks_le D - push_cast at h ⊢ - linarith + exact positioned_gap_ge_third D ((phostHyp (S := S) hC0 hsame).pad x0 k) (fun _ => pI_le_s D hC) end PPad @@ -104,9 +92,6 @@ theorem tp_single_s_exact (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.ra c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by classical set M := Fintype.card U - have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by - obtain ⟨a0, ha0⟩ := hA0 - exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ refine exponent_of_family_exact hM hA0.card_pos (by positivity) (SVk F U) (fun j k => hostGraph (padN (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j)) ((0 : F), (0 : Fin j → U)) k)) @@ -114,13 +99,38 @@ theorem tp_single_s_exact (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.ra (fun j k => card_pad k) (fun j k => isSplit_hostGraph _) (fun j k => connected_hostGraph _ ((0 : F), (0 : Fin j → U)) (padN_nonempty _ _ _)) (fun j k => ?_) - have h := pgap_ge_third_pad (single (W := Fin j → U) σ) (isSCap_capPow hA j) (hcapne j) - (prodSep A he j) (single_same σ) ((0 : F), (0 : Fin j → U)) k - rw [card_capPow] at h - have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] - rw [hW] at h - push_cast at h - exact h + have h := pgap_ge_third_pad (single (W := Fin j → U) σ) (isSCap_capPow hA j) + (capPow_nonempty hA0 j) (prodSep A he j) (single_same σ) ((0 : F), (0 : Fin j → U)) k + exact capPow_gap_le h + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond for S-caps** (ledger §17): the exponent `1 + log |A| / log |U|` for every S-cap `A`, +`S` the +active colours `range σ`. -/ +theorem tp_single_s (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ) (A : Set U)) (hA0 : + A.Nonempty) {e : U} + (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + obtain ⟨c, hc, h⟩ := tp_single_s_exact σ hA hA0 he hM + refine ⟨c, hc, fun n hn => ?_⟩ + obtain ⟨V, fV, dV, G, hcard, hsplit, _, hgap⟩ := h n hn + exact ⟨V, fV, dV, G, hcard.le, hsplit, hgap⟩ + +omit [DecidableEq F] [DecidableEq U] in +/-- **TP-cond without SEP.** -/ +theorem tp_single (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hA0 : A.Nonempty) {e + : U} + (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → + ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), + Fintype.card V' ≤ n ∧ IsSplit G' ∧ + c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by + exact tp_single_s σ hA.isSCap hA0 he hM end Single @@ -229,7 +239,6 @@ theorem exponent_two_exact {ε : ℝ} (hε : 0 < ε) : have hA : ((K + 1 : ℕ) : ℝ) ^ N ≤ ((N : ℝ) * R' + 1) * A.card := by rw [hAcard]; exact_mod_cast hr have hlog : (N : ℝ) * Real.log (K + 1) ≤ Real.log ((N : ℝ) * R' + 1) + Real.log A.card := by - have hK0 : (0 : ℝ) < ((K + 1 : ℕ) : ℝ) := by positivity rw [← Real.log_mul (by positivity) (by exact_mod_cast hApos.ne')] have := Real.log_le_log (by positivity) hA rw [Real.log_pow] at this diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean index d561f9d15e..f3dfad3fc7 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Exponent.lean @@ -56,6 +56,22 @@ omit [AddCommGroup U] [DecidableEq U] [Fintype U] in theorem card_capPow (A : Finset U) (j : ℕ) : (capPow A j).card = A.card ^ j := by simp [capPow] +omit [AddCommGroup U] [DecidableEq U] [Fintype U] in +/-- A nonempty cap has a nonempty finite power. -/ +theorem capPow_nonempty {A : Finset U} (hA : A.Nonempty) (j : ℕ) : + (capPow A j).Nonempty := by + obtain ⟨a, ha⟩ := hA + exact ⟨fun _ => a, by simp [capPow, ha]⟩ + +/-- Express the score of a powered cap in terms of the original cap and ambient type. -/ +theorem capPow_gap_le {U V : Type} [Fintype U] [Fintype V] [vertexDecidable : DecidableEq V] + {G : SimpleGraph V} {A : Finset U} {j : ℕ} + (h : (((capPow A j).card * Fintype.card (Fin j → U) : ℕ) : ℝ) / 3 ≤ gap G) : + (A.card : ℝ) ^ j * (Fintype.card U : ℝ) ^ j / 3 ≤ gap G := by + rw [card_capPow, Fintype.card_pi, Finset.prod_const, Finset.card_univ, Fintype.card_fin] at h + push_cast at h + exact h + /-- `(M^j)^α = a^j · M^j` for `α = 1 + log a / log M`. -/ theorem pow_rpow_alpha {a M : ℕ} (ha : 1 ≤ a) (hM : 2 ≤ M) (j : ℕ) : ((M : ℝ) ^ j) ^ (1 + Real.log a / Real.log M) = (a : ℝ) ^ j * (M : ℝ) ^ j := by @@ -139,9 +155,6 @@ theorem tp_cond (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hS calc _ ≤ K * M ^ j := this _ ≤ n := hsize · have hgap := gap_ge_third (W := Fin j → U) σ (isCap_capPow hA j) (isSep_capPow hS j) - have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] - rw [card_capPow, hW] at hgap - push_cast at hgap - exact hscale.trans hgap + exact hscale.trans (capPow_gap_le (vertexDecidable := instDecidableEqSum) hgap) end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Global.lean b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean index 93ac45ab3b..9c73397fef 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Global.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Global.lean @@ -26,9 +26,8 @@ If every block satisfies the reserved local bound `∑ (4 w - e) ≤ 4c - e(ℓ) then every packing of the whole vertex set has `∑ w ≤ c · #blocks`. -The proof fragments every column (`exists_pieces`), charges local pieces to their block and -triangle-free -pieces to the unused `B`-edges of the blocks (Mantel with reserve). +The global bound follows from the twin-tolerant bound. The separate theorem `exists_pieces` bounds +one column's unadjusted score using pieces in blocks and triangle-free pieces. -/ @[expose] public section diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean index d2055a5ecb..a896596f9a 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean @@ -155,7 +155,7 @@ def layered : PData F5 W ((F5 × W) ⊕ W) (Option F5) where rw [hy] colσ := by decide -omit [DecidableEq W] [Fintype W] in +omit [AddCommGroup W] [Module F5 W] [DecidableEq W] [Fintype W] in theorem layered_same : ∀ v v' : (F5 × W) ⊕ W, (layered (W := W)).base v = (layered (W := W)).base v' → ∀ i j, σL i = (layered (W := W)).pos v → σL j = (layered (W := W)).pos v' → diff --git a/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean index fa053e9f8f..9e91965193 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/LayeredExponent.lean @@ -61,9 +61,6 @@ theorem tp_layered {A : Finset U} (hA : IsCap F5 (A : Set U)) (hA0 : A.Nonempty) c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by classical set M := Fintype.card U - have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by - obtain ⟨a0, ha0⟩ := hA0 - exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ refine exponent_of_family hM hA0.card_pos (by positivity) (LV U) (fun j => hostGraph (ppalette (layered (W := Fin j → U)) (capPow A j) (prodSep A he j))) (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) @@ -76,12 +73,8 @@ theorem tp_layered {A : Finset U} (hA : IsCap F5 (A : Set U)) (hA0 : A.Nonempty) have hp : Fintype.card U ^ j ≤ Fintype.card U * Fintype.card U ^ j := Nat.le_mul_of_pos_left _ (by omega) nlinarith - · have h := pgap_ge_third (layered (W := Fin j → U)) (isCap_capPow hA j) (hcapne j) + · have h := pgap_ge_third (layered (W := Fin j → U)) (isCap_capPow hA j) (capPow_nonempty hA0 j) (prodSep A he j) layered_same - rw [card_capPow] at h - have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] - rw [hW] at h - push_cast at h - exact h + exact capPow_gap_le h end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean index 24af11fc47..d2b49409b1 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/PCore.lean @@ -38,7 +38,7 @@ variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] /-! ### Positioned cores -/ /-- Data of a positioned core. -/ -structure PData (F W V P : Type*) [Field F] [AddCommGroup W] [Module F W] where +structure PData (F W V P : Type*) where /-- The field and vector coordinates of each core vertex. -/ base : V → F × W /-- The position of each vertex within its base fibre. -/ @@ -112,7 +112,8 @@ section ActiveCap /-- Active colours of a positioned core. -/ def actCol : Set F := Set.range fun i => D.col (D.σ i) -omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] +omit [Field F] [AddCommGroup W] [Module F W] + [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] [Fintype W] in theorem fst_mem_actCol {v : V} (h : ∃ i, D.σ i = D.pos v) : (D.base v).1 ∈ actCol D := by obtain ⟨i, hi⟩ := h diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean b/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean index 8cd66fbc85..2824a4405d 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/PMain.lean @@ -32,6 +32,21 @@ variable {W : Type*} [AddCommGroup W] [Module F W] [Fintype W] [DecidableEq W] variable {V P : Type*} [Fintype V] [DecidableEq V] [Fintype P] [DecidableEq P] variable {U : Type*} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] +omit [Fintype P] in +/-- Transfer a positioned packing score through any suitable host certificate. -/ +theorem positioned_gap_ge_third (D : PData F W V P) {C : Finset W} + {H : Type*} [Fintype H] [DecidableEq H] {N : H → Finset V} {φ : V → V → H} + (host : HostHyp (PB D C) N φ) + (integral : ∀ T : Finset (Finset V), IsPack T → + ∑ Q ∈ T, w (PB D C) Q ≤ 8 * (pblocks D C).card) : + ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph N) := by + have h := gap_ge host (8 * (pblocks D C).card) integral (presPack (D := D) (C := C)) + have hv := pvalue (D := D) (C := C) + have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by + exact_mod_cast card_pblocks_le D + push_cast at h ⊢ + linarith + /-- **Cor. 16.4.** -/ theorem pgap_ge_third (D : PData F W V P) {C : Finset W} (hC : IsCap F (C : Set W)) (hC0 : C.Nonempty) @@ -39,13 +54,8 @@ theorem pgap_ge_third (D : PData F W V P) {C : Finset W} (hC : IsCap F (C : Set (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → ¬ H12.graph.Adj i j) : ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (ppalette D C S)) := by - have h := gap_ge (phostHyp (S := S) hC0 hsame) (8 * (pblocks D C).card) - (fun T hT => pI_le D hC hT) (presPack (D := D) (C := C)) - have hv := pvalue (D := D) (C := C) - have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by - exact_mod_cast card_pblocks_le D - push_cast at h ⊢ - linarith + exact positioned_gap_ge_third D (phostHyp (S := S) hC0 hsame) (fun _ => pI_le D hC) + omit [AddCommGroup U] [AddCommGroup W] [DecidableEq F] [DecidableEq P] [DecidableEq U] [DecidableEq V] [DecidableEq W] [Field F] [Module F U] [Module F W] in diff --git a/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean index 48301b646d..b872ee526f 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/PSource.lean @@ -68,7 +68,8 @@ omit [DecidableEq F] [DecidableEq P] [DecidableEq W] [Fintype F] [Fintype V] [Fi theorem mem_ppiece {x : (W × W) × Finset (Fin 6)} {v : V} : v ∈ ppiece D x ↔ ∃ i ∈ x.2, pvx D x.1.2 x.1.1 i = v := Finset.mem_image -omit [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] +omit [Field F] [AddCommGroup W] [Module F W] + [DecidableEq F] [DecidableEq P] [DecidableEq V] [DecidableEq W] [Fintype F] [Fintype V] [Fintype W] in /-- Colours of two labels of a source piece are distinct. -/ theorem col_ne_of_src {K : Finset (Fin 6)} (hK : K ∈ src) {i j : Fin 6} (hi : i ∈ K) (hj : j ∈ K) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean index 48b8f97768..7d4168246b 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean @@ -46,14 +46,7 @@ theorem pgap_ge_third_s [Fintype P] {U : Type*} [AddCommGroup U] [Module F U] [F (hsame : ∀ v v', D.base v = D.base v' → ∀ i j, D.σ i = D.pos v → D.σ j = D.pos v' → ¬ H12.graph.Adj i j) : ((C.card * Fintype.card W : ℕ) : ℝ) / 3 ≤ gap (hostGraph (ppalette D C S)) := by - have h := gap_ge (phostHyp (S := S) hC0 hsame) (8 * (pblocks D C).card) - (fun T hT => pI_le_s D hC hT) (presPack (D := D) (C := C)) - have hv := pvalue (D := D) (C := C) - have hb : ((pblocks D C).card : ℝ) ≤ C.card * Fintype.card W := by - exact_mod_cast card_pblocks_le D - push_cast at h ⊢ - linarith - + exact positioned_gap_ge_third D (phostHyp (S := S) hC0 hsame) (fun _ => pI_le_s D hC) end PChain @@ -71,36 +64,6 @@ omit [DecidableEq F] [Fintype F] in theorem actCol_single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : actCol (single (W := W) σ) = Set.range σ := rfl -omit [DecidableEq F] [DecidableEq U] in -/-- **TP-cond for S-caps** (ledger §17): the exponent `1 + log |A| / log |U|` for every S-cap `A`, -`S` the -active colours `range σ`. -/ -theorem tp_single_s (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsSCap (Set.range σ) (A : Set U)) (hA0 : - A.Nonempty) {e : U} - (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : - ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, - 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → - ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), - Fintype.card V' ≤ n ∧ IsSplit G' ∧ - c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by - classical - set M := Fintype.card U - have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by - obtain ⟨a0, ha0⟩ := hA0 - exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ - refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) - (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) - (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) - · exact card_SV_le j - · have h := pgap_ge_third_s (single (W := Fin j → U) σ) (isSCap_capPow hA j) (hcapne j) - (prodSep A he j) (single_same σ) - rw [card_capPow] at h - have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] - rw [hW] at h - push_cast at h - exact h - - end Single end GapExtremal diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean index e72e3b076c..27f402b5e9 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean @@ -19,7 +19,7 @@ import Mathlib.Tactic.Ring `single σ` is the positioned core `V = F × W` with positions = colours. Together with `prodSep` it gives, for every cap `A` in a finite `F`-module `U` (no separability), the exponent `1 + log |A| / log |U|` -(`tp_single`). This removes SEP from TP-cond. +for the one-layer cap construction. -/ @[expose] public section @@ -99,31 +99,4 @@ theorem card_SV_le [Nonempty U] (j : ℕ) : rw [e2, e3]; exact Nat.add_le_add (Nat.add_le_add e1 e5) e4 _ = 3 * (q + 1) ^ 4 * M * X := by ring -omit [DecidableEq F] [DecidableEq U] in -/-- **TP-cond without SEP.** -/ -theorem tp_single (σ : Fin 6 ↪ F) {A : Finset U} (hA : IsCap F (A : Set U)) (hA0 : A.Nonempty) {e - : U} - (he : e ≠ 0) (hM : 2 ≤ Fintype.card U) : - ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, - 3 * (Fintype.card F + 1) ^ 4 * Fintype.card U * Fintype.card U ≤ n → - ∃ (V' : Type) (_ : Fintype V') (_ : DecidableEq V') (G' : SimpleGraph V'), - Fintype.card V' ≤ n ∧ IsSplit G' ∧ - c * (n : ℝ) ^ (1 + Real.log A.card / Real.log (Fintype.card U)) ≤ gap G' := by - classical - set M := Fintype.card U - have hcapne : ∀ j, (capPow A j).Nonempty := fun j => by - obtain ⟨a0, ha0⟩ := hA0 - exact ⟨fun _ => a0, by simp [capPow, ha0]⟩ - refine exponent_of_family hM hA0.card_pos (by positivity) (SV F U) - (fun j => hostGraph (ppalette (single (W := Fin j → U) σ) (capPow A j) (prodSep A he j))) - (fun j => ?_) (fun j => isSplit_hostGraph _) (fun j => ?_) - · exact card_SV_le j - · have h := pgap_ge_third (single (W := Fin j → U) σ) (isCap_capPow hA j) (hcapne j) - (prodSep A he j) (single_same σ) - rw [card_capPow] at h - have hW : Fintype.card (Fin j → U) = M ^ j := by simp [M] - rw [hW] at h - push_cast at h - exact h - end GapExtremal diff --git a/LeanPool/SplitCliqueGap/R434/UniformOrder.lean b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean index 45f9fa0e50..f937cb78c6 100644 --- a/LeanPool/SplitCliqueGap/R434/UniformOrder.lean +++ b/LeanPool/SplitCliqueGap/R434/UniformOrder.lean @@ -94,9 +94,6 @@ theorem rounded_order_witness (H : ℕ → ℕ) (A c : ℝ) (hA : 1 ≤ A) have hLt : L = c * t ^ 2 := by dsimp [t] rw [sq_sqrt (by positivity), mul_div_cancel₀ _ hc.ne'] - have hsqrt : sqrt L = sqrt c * t := by - have he : L = c * (L / c) := by field_simp - conv_lhs => rw [he, sqrt_mul hc.le] let j := ⌊t⌋₊ have hj₁ : 1 ≤ j := Nat.le_floor (by norm_cast; linarith) have hjU : (j : ℝ) ≤ t := Nat.floor_le ht₀.le @@ -183,8 +180,7 @@ theorem uniform_order_parameters (H : ℕ → ℕ) (A K c η : ℝ) (hA : 1 ≤ exp (-c * (j : ℝ)) * (m : ℝ) ^ (4 * j) / (27 * (1 + K * (j : ℝ) * (m : ℝ) ^ 2)) := by let C := 27 * (1 + K) - have hC : 1 ≤ C := by dsimp [C]; linarith - have hC₀ : 0 < C := by linarith + have hC₀ : 0 < C := by dsimp [C]; positivity let b := 2 * log A + 2 + 2 * c + log C obtain ⟨T₂,hT₂,h₂⟩ := log_linear_error 3 b (η * sqrt c) (by norm_num) (mul_pos hη (sqrt_pos.mpr hc)) diff --git a/LeanPool/SplitCliqueGap/SplitPartition.lean b/LeanPool/SplitCliqueGap/SplitPartition.lean index c061aea4a8..82da8c14bb 100644 --- a/LeanPool/SplitCliqueGap/SplitPartition.lean +++ b/LeanPool/SplitCliqueGap/SplitPartition.lean @@ -5,7 +5,7 @@ Authors: Lean Pool contributors -/ module -public import LeanPool.SplitCliqueGap.GapExtremal.Main +public import LeanPool.SplitCliqueGap.GapExtremal.GraphPadding public import LeanPool.StructuralGraphClasses.Split /-! The split witnesses in this development give split partitions in the shared graph API. -/ From 73aa50173bbbc15f3fc414507449af7fa149cdf6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 13:56:28 +0000 Subject: [PATCH 6/7] Drop unused typeclass premises from the one-layer core --- LeanPool/SplitCliqueGap/GapExtremal/SCap.lean | 4 ++-- LeanPool/SplitCliqueGap/GapExtremal/Single.lean | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean index 7d4168246b..51298e63d3 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/SCap.lean @@ -60,8 +60,8 @@ theorem isSCap_capPow {S : Set F} {A : Finset U} (hA : IsSCap S (A : Set U)) (j IsSCap S (capPow A j : Set (Fin j → U)) := by rw [coe_capPow]; exact hA.pi -omit [DecidableEq F] [Fintype F] in -theorem actCol_single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : +omit [DecidableEq F] [Fintype F] [Field F] in +theorem actCol_single {W : Type} (σ : Fin 6 ↪ F) : actCol (single (W := W) σ) = Set.range σ := rfl end Single diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean index 27f402b5e9..10f2fa3097 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Single.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Single.lean @@ -28,10 +28,10 @@ namespace GapExtremal open Finset -variable {F : Type} [Field F] [Fintype F] [DecidableEq F] +variable {F : Type} /-- The one-layer positioned core. -/ -def single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : PData F W (F × W) F where +def single {W : Type} (σ : Fin 6 ↪ F) : PData F W (F × W) F where base := id pos := Prod.fst col := id @@ -44,8 +44,7 @@ def single {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : PData F rl_pos := fun _ _ h => h colσ := fun _ _ h => Or.inl (σ.injective h) -omit [DecidableEq F] [Fintype F] in -theorem single_same {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) : +theorem single_same {W : Type} (σ : Fin 6 ↪ F) : ∀ v v' : F × W, (single (W := W) σ).base v = (single (W := W) σ).base v' → ∀ i j, σ i = (single (W := W) σ).pos v → σ j = (single (W := W) σ).pos v' → ¬ H12.graph.Adj i j := by @@ -54,6 +53,7 @@ theorem single_same {W : Type} [AddCommGroup W] [Module F W] (σ : Fin 6 ↪ F) subst hb exact hij.ne (σ.injective (hi.trans hj.symm)) +variable [Field F] [Fintype F] [DecidableEq F] variable {U : Type} [AddCommGroup U] [Module F U] [Fintype U] [DecidableEq U] /-- The one-layer graph of `A^j`. -/ From fbf48867f6503eae364ac9eb9258a293b854eb24 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 26 Nov 2026 14:33:45 +0000 Subject: [PATCH 7/7] Narrow isolate-score dependencies and reuse the ZMod instance --- LeanPool/SplitCliqueGap/GapExtremal/Layered.lean | 4 ---- LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean | 2 +- LeanPool/SplitCliqueGap/R434/UniversalHosts.lean | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean index a896596f9a..d4125e9890 100644 --- a/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean +++ b/LeanPool/SplitCliqueGap/GapExtremal/Layered.lean @@ -99,10 +99,6 @@ abbrev F5 := ZMod 5 instance : Fact (Nat.Prime 5) := ⟨by norm_num⟩ -/-- The ring parent keeps the additive-group and module instances definitionally compatible. -/ -scoped instance (priority := 10000) addCommGroupZModRing (p : ℕ) : - AddCommGroup (ZMod p) := Ring.toAddCommGroup - /-- Label positions: `0 ↦ 0, 1 ↦ 1, 2 ↦ twin, 3 ↦ 2, 4 ↦ 3, 5 ↦ 4`. -/ def σL : Fin 6 ↪ Option F5 := ⟨![some 0, some 1, none, some 2, some 3, some 4], by decide⟩ diff --git a/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean b/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean index ce3eee7b02..211654b61d 100644 --- a/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean +++ b/LeanPool/SplitCliqueGap/R434/ResidualIsolates.lean @@ -6,7 +6,7 @@ Authors: Juan Pablo Traverso Gianini /- Modified by Lean Pool contributors for the current Lean and Mathlib toolchain. -/ module -public import LeanPool.SplitCliqueGap.R434.RobustHosts +public import LeanPool.SplitCliqueGap.GapExtremal.Bridge /-! Score certificates extend across isolated residual vertices. -/ diff --git a/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean b/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean index f93a00ff2a..3045e1ab8d 100644 --- a/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean +++ b/LeanPool/SplitCliqueGap/R434/UniversalHosts.lean @@ -7,6 +7,7 @@ Authors: Juan Pablo Traverso Gianini module public import LeanPool.SplitCliqueGap.R434.ResidualIsolates +public import LeanPool.SplitCliqueGap.R434.RobustHosts /-! Split realizations whose new core vertices are universal. -/