import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Combinatorics.SimpleGraph.DegreeSum import Mathlib.Combinatorics.SimpleGraph.Maps import Mathlib.Data.Sym.Sym2 import Mathlib.Data.ZMod.Basic import Mathlib.Tactic /-! # Sheehan's Conjecture (1975): Thomason Lollipop Parity, Near-$C$-ID Subdivision, # Chord 2-Factor Multiplicity, Vertex-Transitive Resolution, and Structural $n \le 12$ **Sheehan's Conjecture (1975)**: Every $4$-regular Hamiltonian simple graph has at least two distinct Hamiltonian cycles (equivalently, no $4$-regular simple graph is uniquely Hamiltonian). This file provides a complete, self-contained Lean 4 formalization of: 1. **Hamiltonian Cycle Calculus & 2-Switch Engine** (`DirHamCycle`, `IsHamCycle`, `hamCycles`, crossing-chord 2-switch construction, and chord 2-factor decomposition). 2. **Thomason's Lollipop Involution Engine (First Lean 4 Formalization)**: - General Thomason Lollipop Parity Theorem (only requiring odd degrees outside `{u, v}`), - Smith–Thomason All-Odd-Degree Multiplicity Theorem ($\ge 3$ Hamiltonian cycles), - Bipartite Thomason Parity Theorem (requiring odd degrees on only one side `B \ {v}`). 3. **Master Bipartite-Subdivision & Near-$C$-ID Parity Engine (Strictly Strengthening Thomassen 1998)**: - Near-$C$-ID Parity Theorem (allowing up to 1 undominated vertex in `V \ A`), - Full $C$-ID Multiplicity Theorem ($\ge 3$ Hamiltonian cycles), - 3-Colorable Triangle-Chord Multiplicity Theorem ($\ge 4$ Hamiltonian cycles). 4. **Chord 2-Factor Odd-Cycle & Quantitative Multiplicity Hierarchy for 4-Regular Graphs**: - Bipartite chord 2-factors ($m = 0$, strictly generalizing Sheehan 1975) $\implies \ge 5$ H-cycles, - Single even Hamiltonian chord cycle $\implies \ge 6$ H-cycles; single odd $\implies \ge 4$ H-cycles, - Single odd chord cycle ($m = 1$) $\implies \ge 2$ H-cycles, - Two adjacent odd chord cycles & $\le 2$ chord components $\implies \ge 2$ H-cycles. 5. **Complete Resolution for All Vertex-Transitive, Cayley, Circulant & Torus-Grid 4-Regular Graphs**. 6. **Pure Structural Proof of Sheehan's Conjecture for ALL $n \le 12$ (Zero Brute-Force Search!)**. -/ open scoped Classical open Finset namespace SheehanConjecture /-! ## Section 1: Hamiltonian Cycles, Cyclic Arithmetic, and the 2-Switch Engine -/ section CyclicFin /-- Modular successor on `Fin n` (for `0 < n`). -/ def cNext {n : ℕ} (hn : 0 < n) (i : Fin n) : Fin n := ⟨(i.1 + 1) % n, Nat.mod_lt _ hn⟩ /-- Modular predecessor on `Fin n` (for `0 < n`). -/ def cPrev {n : ℕ} (hn : 0 < n) (i : Fin n) : Fin n := ⟨(i.1 + n - 1) % n, Nat.mod_lt _ hn⟩ lemma cNext_val {n : ℕ} (hn : 0 < n) (i : Fin n) : (cNext hn i).1 = if i.1 + 1 < n then i.1 + 1 else 0 := by unfold cNext by_cases h : i.1 + 1 < n · simp [h, Nat.mod_eq_of_lt h] · have heq : i.1 + 1 = n := by omega simp [heq] lemma cPrev_val {n : ℕ} (hn : 0 < n) (i : Fin n) : (cPrev hn i).1 = if i.1 = 0 then n - 1 else i.1 - 1 := by unfold cPrev by_cases h : i.1 = 0 · simp [h, Nat.mod_eq_of_lt (by omega : n - 1 < n)] · have h1 : i.1 + n - 1 = (i.1 - 1) + n := by omega simp only [h, ↓reduceIte] rw [h1, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] lemma cPrev_cNext {n : ℕ} (hn : 0 < n) (i : Fin n) : cPrev hn (cNext hn i) = i := by have hi := i.2 ext rw [cPrev_val, cNext_val] by_cases h : i.1 + 1 < n · simp [h] · simp [h]; omega lemma cNext_cPrev {n : ℕ} (hn : 0 < n) (i : Fin n) : cNext hn (cPrev hn i) = i := by ext rw [cNext_val, cPrev_val] split_ifs <;> omega lemma cNext_injective {n : ℕ} (hn : 0 < n) : Function.Injective (cNext hn) := Function.LeftInverse.injective (cPrev_cNext hn) lemma cNext_ne_self {n : ℕ} (hn : 2 ≤ n) (i : Fin n) : cNext (by omega) i ≠ i := by intro h have hv := congrArg Fin.val h rw [cNext_val] at hv split_ifs at hv <;> omega lemma cNext_ne_cPrev {n : ℕ} (hn : 3 ≤ n) (i : Fin n) : cNext (by omega) i ≠ cPrev (by omega) i := by intro h have hv := congrArg Fin.val h rw [cNext_val, cPrev_val] at hv split_ifs at hv <;> omega /-- Cyclic shift permutation `i ↦ (i + k) % n` on `Fin n`. -/ def cShift {n : ℕ} (hn : 0 < n) (k : ℕ) : Equiv.Perm (Fin n) where toFun i := ⟨(i.1 + k) % n, Nat.mod_lt _ hn⟩ invFun i := ⟨(i.1 + (n - k % n)) % n, Nat.mod_lt _ hn⟩ left_inv i := by ext; dsimp have hk : k % n < n := Nat.mod_lt k hn have h1 : ((i.1 + k) % n + (n - k % n)) % n = (i.1 + k + (n - k % n)) % n := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [h1] have h2 : i.1 + k + (n - k % n) = i.1 + n * (k / n + 1) := by rw [Nat.mul_succ]; have := Nat.div_add_mod k n; omega rw [h2, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt i.2] right_inv i := by ext; dsimp have hk : k % n < n := Nat.mod_lt k hn have h1 : ((i.1 + (n - k % n)) % n + k) % n = (i.1 + (n - k % n) + k) % n := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [h1] have h2 : i.1 + (n - k % n) + k = i.1 + n * (k / n + 1) := by rw [Nat.mul_succ]; have := Nat.div_add_mod k n; omega rw [h2, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt i.2] lemma cShift_cNext {n : ℕ} (hn : 0 < n) (k : ℕ) (i : Fin n) : cShift hn k (cNext hn i) = cNext hn (cShift hn k i) := by ext; dsimp [cShift, cNext] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] conv_rhs => rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] congr 1; omega lemma cShift_zero {n : ℕ} (hn : 0 < n) (i : Fin n) : cShift hn 0 i = i := by ext; change (i.1 + 0) % n = i.1; rw [add_zero, Nat.mod_eq_of_lt i.2] lemma cShift_succ {n : ℕ} (hn : 0 < n) (m : ℕ) (i : Fin n) : cShift hn (m + 1) i = cNext hn (cShift hn m i) := by ext; dsimp [cShift, cNext] conv_rhs => rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] congr 1 lemma mem_foldr_union {α β : Type*} [DecidableEq β] (L : List α) (f : α → Finset β) (x : β) : x ∈ L.foldr (fun a acc => f a ∪ acc) ∅ ↔ ∃ a ∈ L, x ∈ f a := by induction L with | nil => simp | cons a tl ih => simp only [List.foldr_cons, Finset.mem_union, List.mem_cons, exists_eq_or_imp] exact or_congr_right ih /-- Reversal permutation `i ↦ (n - 1 - i) % n` on `Fin n`. -/ def cRev {n : ℕ} (_hn : 0 < n) : Equiv.Perm (Fin n) where toFun i := ⟨n - 1 - i.1, by omega⟩ invFun i := ⟨n - 1 - i.1, by omega⟩ left_inv i := by ext; dsimp; omega right_inv i := by ext; dsimp; omega lemma cRev_cNext {n : ℕ} (hn : 0 < n) (i : Fin n) : cRev hn (cNext hn i) = cPrev hn (cRev hn i) := by ext; dsimp [cRev]; rw [cNext_val, cPrev_val]; dsimp; split_ifs <;> omega end CyclicFin section HamCycleDefs variable {V : Type*} [Fintype V] [DecidableEq V] /-- A directed Hamiltonian cycle in a finite simple graph `G` (requiring `|V| ≥ 3`). -/ structure DirHamCycle (G : SimpleGraph V) where card_ge_three : 3 ≤ Fintype.card V toEquiv : Fin (Fintype.card V) ≃ V adj_next : ∀ i : Fin (Fintype.card V), G.Adj (toEquiv i) (toEquiv (cNext (by omega : 0 < Fintype.card V) i)) /-- The undirected edge set of a directed Hamiltonian cycle `c`. -/ def DirHamCycle.edgeSet {G : SimpleGraph V} (c : DirHamCycle G) : Finset (Sym2 V) := Finset.univ.image fun i => s(c.toEquiv i, c.toEquiv (cNext (by have := c.card_ge_three; omega) i)) /-- Predicate: `E` is the edge set of an undirected Hamiltonian cycle of `G`. -/ def IsHamCycle (G : SimpleGraph V) (E : Finset (Sym2 V)) : Prop := ∃ c : DirHamCycle G, c.edgeSet = E /-- The finite set of all undirected Hamiltonian cycles (identified with their edge sets) of `G`. -/ noncomputable def hamCycles (G : SimpleGraph V) : Finset (Finset (Sym2 V)) := Finset.univ.filter (IsHamCycle G) lemma mem_hamCycles {G : SimpleGraph V} {E : Finset (Sym2 V)} : E ∈ hamCycles G ↔ IsHamCycle G E := by simp [hamCycles] lemma DirHamCycle.edgeSet_mem_hamCycles {G : SimpleGraph V} (c : DirHamCycle G) : c.edgeSet ∈ hamCycles G := mem_hamCycles.mpr ⟨c, rfl⟩ def DirHamCycle.map_le {G₁ G₂ : SimpleGraph V} (hle : G₁ ≤ G₂) (c : DirHamCycle G₁) : DirHamCycle G₂ where card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next i := hle (c.adj_next i) lemma hamCycles_mono {G₁ G₂ : SimpleGraph V} (hle : G₁ ≤ G₂) : hamCycles G₁ ⊆ hamCycles G₂ := by intro E hE obtain ⟨c, rfl⟩ := mem_hamCycles.mp hE exact mem_hamCycles.mpr ⟨c.map_le hle, rfl⟩ /-- Every edge in `c.edgeSet` is an edge of `G`. -/ lemma DirHamCycle.adj_of_mem_edgeSet {G : SimpleGraph V} (c : DirHamCycle G) {x y : V} (h : s(x, y) ∈ c.edgeSet) : G.Adj x y := by rcases Finset.mem_image.mp h with ⟨i, _, hi⟩ rcases Sym2.eq_iff.mp hi with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ · exact c.adj_next i · exact (c.adj_next i).symm /-- Every edge of `c.edgeSet` connects `c i` to either `c (cNext i)` or `c (cPrev i)`. -/ lemma DirHamCycle.mem_edgeSet_iff {G : SimpleGraph V} (c : DirHamCycle G) (i j : Fin (Fintype.card V)) : s(c.toEquiv i, c.toEquiv j) ∈ c.edgeSet ↔ j = cNext (by have := c.card_ge_three; omega) i ∨ j = cPrev (by have := c.card_ge_three; omega) i := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega constructor · intro h rcases Finset.mem_image.mp h with ⟨k, _, hk⟩ rcases Sym2.eq_iff.mp hk with ⟨h1, h2⟩ | ⟨h1, h2⟩ · have hk_eq : k = i := c.toEquiv.injective h1 have hj_eq : cNext hn k = j := c.toEquiv.injective h2 left; rw [← hj_eq, hk_eq] · have hk_eq : k = j := c.toEquiv.injective h1 have hi_eq : cNext hn k = i := c.toEquiv.injective h2 right; rw [← hk_eq, ← hi_eq, cPrev_cNext] · rintro (rfl | rfl) · exact Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩ · refine Finset.mem_image.mpr ⟨cPrev hn i, Finset.mem_univ _, ?_⟩ rw [cNext_cPrev, Sym2.eq_swap] /-- The edge set of a directed Hamiltonian cycle has cardinality `Fintype.card V`. -/ lemma DirHamCycle.card_edgeSet {G : SimpleGraph V} (c : DirHamCycle G) : c.edgeSet.card = Fintype.card V := by have hn3 : 3 ≤ Fintype.card V := c.card_ge_three have hn : 0 < Fintype.card V := by omega unfold DirHamCycle.edgeSet rw [Finset.card_image_of_injective _ ?_, Finset.card_univ, Fintype.card_fin] intro i j hij rcases Sym2.eq_iff.mp hij with ⟨h1, _⟩ | ⟨h1, h2⟩ · exact c.toEquiv.injective h1 · have h1' : i = cNext hn j := c.toEquiv.injective h1 have h2' : cNext hn i = j := c.toEquiv.injective h2 have : cNext hn i = cPrev hn i := by rw [h2', h1', cPrev_cNext] exact absurd this (cNext_ne_cPrev hn3 i) /-- Every vertex has exactly 2 incident edges in `c.edgeSet`, namely `c (cPrev i)` and `c (cNext i)`. -/ lemma DirHamCycle.edgeSet_ne_of_exists_not_mem {G : SimpleGraph V} {E₁ E₂ : Finset (Sym2 V)} (h₁ : IsHamCycle G E₁) (h₂ : IsHamCycle G E₂) (hne : E₁ ≠ E₂) : ∃ e ∈ E₁, e ∉ E₂ := by by_contra hall push Not at hall have hsub : E₁ ⊆ E₂ := hall obtain ⟨c₁, rfl⟩ := h₁ obtain ⟨c₂, rfl⟩ := h₂ have hcard : c₁.edgeSet.card = c₂.edgeSet.card := by rw [c₁.card_edgeSet, c₂.card_edgeSet] exact hne (Finset.eq_of_subset_of_card_le hsub (le_of_eq hcard.symm)) /-- Cyclically shifting a directed Hamiltonian cycle preserves its edge set. -/ def DirHamCycle.shift {G : SimpleGraph V} (c : DirHamCycle G) (k : ℕ) : DirHamCycle G where card_ge_three := c.card_ge_three toEquiv := (cShift (by have := c.card_ge_three; omega) k).trans c.toEquiv adj_next i := by dsimp only [Equiv.trans_apply] rw [cShift_cNext] exact c.adj_next _ lemma DirHamCycle.shift_edgeSet {G : SimpleGraph V} (c : DirHamCycle G) (k : ℕ) : (c.shift k).edgeSet = c.edgeSet := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega ext e simp only [DirHamCycle.edgeSet, DirHamCycle.shift, Finset.mem_image, Finset.mem_univ, true_and, Equiv.trans_apply, cShift_cNext] constructor · rintro ⟨i, hi⟩; exact ⟨cShift hn k i, hi⟩ · rintro ⟨j, hj⟩; exact ⟨(cShift hn k).symm j, by simpa using hj⟩ /-- Reversing a directed Hamiltonian cycle preserves its edge set. -/ def DirHamCycle.rev {G : SimpleGraph V} (c : DirHamCycle G) : DirHamCycle G where card_ge_three := c.card_ge_three toEquiv := (cRev (by have := c.card_ge_three; omega)).trans c.toEquiv adj_next i := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega dsimp only [Equiv.trans_apply] rw [cRev_cNext] have h := c.adj_next (cPrev hn (cRev hn i)) rw [cNext_cPrev] at h exact h.symm lemma DirHamCycle.rev_edgeSet {G : SimpleGraph V} (c : DirHamCycle G) : c.rev.edgeSet = c.edgeSet := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega ext e simp only [DirHamCycle.edgeSet, DirHamCycle.rev, Finset.mem_image, Finset.mem_univ, true_and, Equiv.trans_apply, cRev_cNext] constructor · rintro ⟨i, hi⟩ refine ⟨cPrev hn (cRev hn i), ?_⟩ rw [cNext_cPrev, Sym2.eq_swap]; exact hi · rintro ⟨j, hj⟩ refine ⟨(cRev hn).symm (cNext hn j), ?_⟩ simp only [Equiv.apply_symm_apply, cPrev_cNext, Sym2.eq_swap] exact hj private lemma fin_cast_val {m n : ℕ} (h : m = n) (j : Fin m) : (Equiv.cast (congrArg Fin h) j).1 = j.1 := by subst h; rfl /-- Pushing a directed Hamiltonian cycle along a graph isomorphism `φ : G ≃g H`. -/ def DirHamCycle.mapIso {W : Type*} [Fintype W] [DecidableEq W] {G : SimpleGraph V} {H : SimpleGraph W} (φ : G ≃g H) (c : DirHamCycle G) : DirHamCycle H where card_ge_three := by rw [← Fintype.card_congr φ.toEquiv]; exact c.card_ge_three toEquiv := (Equiv.cast (congrArg Fin (Fintype.card_congr φ.toEquiv).symm)).trans (c.toEquiv.trans φ.toEquiv) adj_next i := by have hcard : Fintype.card W = Fintype.card V := (Fintype.card_congr φ.toEquiv).symm have hnV : 0 < Fintype.card V := by have := c.card_ge_three; omega have hnW : 0 < Fintype.card W := by omega dsimp only [Equiv.trans_apply] have hnext : Equiv.cast (congrArg Fin hcard) (cNext hnW i) = cNext hnV (Equiv.cast (congrArg Fin hcard) i) := by ext rw [fin_cast_val hcard, cNext_val, cNext_val, fin_cast_val hcard] simp [hcard] rw [hnext] exact φ.map_rel_iff.mpr (c.adj_next _) end HamCycleDefs section TwoSwitch variable {V : Type*} [Fintype V] [DecidableEq V] /-- Reversing the suffix `[a + 1, b]` on `Fin n` (for `a < b < n`). -/ def revSeg (n a b : ℕ) (hb : b < n) : Equiv.Perm (Fin n) where toFun i := if h : a < i.1 ∧ i.1 ≤ b then ⟨a + 1 + b - i.1, by omega⟩ else i invFun i := if h : a < i.1 ∧ i.1 ≤ b then ⟨a + 1 + b - i.1, by omega⟩ else i left_inv i := by ext; dsimp split_ifs with h1 h2 <;> simp_all <;> omega right_inv i := by ext; dsimp split_ifs with h1 h2 <;> simp_all <;> omega /-- **2-Switch Theorem**: Given a Hamiltonian cycle `c` in `G` and two crossing chords `G.Adj (c i) (c j)` and `G.Adj (c (i + 1)) (c (j + 1))` with `i, i + 1, j, j + 1` distinct, reversing the arc between `i + 1` and `j` produces a **distinct second Hamiltonian cycle** that omits `s(c i, c (i + 1))` and `s(c j, c (j + 1))` while containing `s(c i, c j)` and `s(c (i + 1), c (j + 1))`. -/ theorem exists_second_hamCycle_of_crossing_chords {G : SimpleGraph V} (c : DirHamCycle G) (i j : Fin (Fintype.card V)) (h1 : G.Adj (c.toEquiv i) (c.toEquiv j)) (h2 : G.Adj (c.toEquiv (cNext (by have := c.card_ge_three; omega) i)) (c.toEquiv (cNext (by have := c.card_ge_three; omega) j))) (hij : i ≠ j) (hi_nj : i ≠ cNext (by have := c.card_ge_three; omega) j) (hni_j : cNext (by have := c.card_ge_three; omega) i ≠ j) : ∃ c' : DirHamCycle G, c'.edgeSet ≠ c.edgeSet ∧ s(c.toEquiv i, c.toEquiv (cNext (by have := c.card_ge_three; omega) i)) ∉ c'.edgeSet ∧ s(c.toEquiv i, c.toEquiv j) ∈ c'.edgeSet := by have hn3 : 3 ≤ Fintype.card V := c.card_ge_three have hn : 0 < Fintype.card V := by omega -- Shift c so that i is at index 0! let c0 : DirHamCycle G := c.shift i.1 have hc0_edge : c0.edgeSet = c.edgeSet := c.shift_edgeSet i.1 have h0_eq : c0.toEquiv ⟨0, hn⟩ = c.toEquiv i := by dsimp [c0, DirHamCycle.shift, cShift] congr 1; ext; dsimp; rw [zero_add, Nat.mod_eq_of_lt i.2] have h1_eq : c0.toEquiv ⟨1, by omega⟩ = c.toEquiv (cNext hn i) := by dsimp [c0, DirHamCycle.shift, cShift, cNext] congr 1; ext; dsimp; rw [add_comm] let b : Fin (Fintype.card V) := (cShift hn i.1).symm j have hb_eq : c0.toEquiv b = c.toEquiv j := by dsimp [c0, DirHamCycle.shift, b]; simp have hbn_eq : c0.toEquiv (cNext hn b) = c.toEquiv (cNext hn j) := by dsimp [c0, DirHamCycle.shift, b] rw [cShift_cNext, Equiv.apply_symm_apply] have hb_ne0 : b ≠ ⟨0, hn⟩ := by intro h; apply hij; rw [← c.toEquiv.injective.eq_iff, ← h0_eq, ← hb_eq, h] have hb_ne1 : b ≠ ⟨1, by omega⟩ := by intro h; apply hni_j; rw [← c.toEquiv.injective.eq_iff, ← h1_eq, ← hb_eq, h] have hb_ne_last : b.1 ≠ Fintype.card V - 1 := by intro h apply hi_nj have hbn0 : cNext hn b = ⟨0, hn⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega exact c.toEquiv.injective (by rw [← h0_eq, ← hbn0, hbn_eq]) have hb_ge2 : 2 ≤ b.1 := by have h0 : b.1 ≠ 0 := fun h => hb_ne0 (Fin.ext h) have h1' : b.1 ≠ 1 := fun h => hb_ne1 (Fin.ext h) omega have hb_lt : b.1 < Fintype.card V - 1 := by omega -- Reverse the arc [1, b] in c0! let π := revSeg (Fintype.card V) 0 b.1 b.2 have hπ0 : π ⟨0, hn⟩ = ⟨0, hn⟩ := by ext; dsimp [π, revSeg] have hπ1 : π ⟨1, by omega⟩ = b := by ext; dsimp [π, revSeg] split_ifs with h <;> simp_all have hπb : π b = ⟨1, by omega⟩ := by ext; dsimp [π, revSeg] split_ifs with h <;> simp_all have hπbn : π (cNext hn b) = cNext hn b := by ext; dsimp [π, revSeg] have hval : (cNext hn b).1 = b.1 + 1 := by rw [cNext_val]; split_ifs <;> omega split_ifs with h <;> [omega; rfl] let c' : DirHamCycle G := { card_ge_three := hn3 toEquiv := π.trans c0.toEquiv adj_next := fun k => by dsimp only [Equiv.trans_apply] by_cases hk0 : k.1 = 0 · have hk : k = ⟨0, hn⟩ := Fin.ext hk0 have hkn : cNext hn ⟨0, hn⟩ = ⟨1, by omega⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hk, hkn, hπ0, hπ1, h0_eq, hb_eq]; exact h1 · by_cases hkb : k.1 = b.1 · have hk : k = b := Fin.ext hkb rw [hk, hπb, hπbn, h1_eq, hbn_eq]; exact h2 · by_cases hlt : k.1 < b.1 · -- Both k and k + 1 lie in [1, b] have hk_in : 0 < k.1 ∧ k.1 ≤ b.1 := by omega have hkn_val : (cNext hn k).1 = k.1 + 1 := by rw [cNext_val]; split_ifs <;> omega have hkn_in : 0 < (cNext hn k).1 ∧ (cNext hn k).1 ≤ b.1 := by omega have hπk : (π k).1 = 1 + b.1 - k.1 := by dsimp [π, revSeg]; rw [dif_pos hk_in] have hπkn : (π (cNext hn k)).1 = 1 + b.1 - (k.1 + 1) := by dsimp [π, revSeg]; rw [dif_pos hkn_in]; simp [hkn_val] have hstep : cNext hn (π (cNext hn k)) = π k := by ext; rw [cNext_val, hπkn, hπk]; split_ifs <;> omega have hadj := c0.adj_next (π (cNext hn k)) rw [hstep] at hadj exact hadj.symm · -- k > b: π fixes both k and cNext hn k! have hπk : π k = k := by ext; dsimp [π, revSeg]; split_ifs with h <;> [omega; rfl] have hπkn : π (cNext hn k) = cNext hn k := by ext; dsimp [π, revSeg] have hval : (cNext hn k).1 = if k.1 + 1 < Fintype.card V then k.1 + 1 else 0 := cNext_val hn k have hnot : ¬ (0 < (cNext hn k).1 ∧ (cNext hn k).1 ≤ b.1) := by rw [hval]; split_ifs <;> omega rw [dif_neg hnot] rw [hπk, hπkn] exact c0.adj_next k } refine ⟨c', ?_, ?_, ?_⟩ · intro heq have hmem : s(c.toEquiv i, c.toEquiv j) ∈ c'.edgeSet := by refine Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, ?_⟩ dsimp [c'] have h0n : cNext hn ⟨0, hn⟩ = ⟨1, by omega⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [h0n, hπ0, hπ1, h0_eq, hb_eq] rw [heq] at hmem rw [c.mem_edgeSet_iff] at hmem rcases hmem with rfl | rfl · exact hni_j rfl · exact hi_nj (by rw [cNext_cPrev]) · intro hmem have h0_eq' : c'.toEquiv ⟨0, hn⟩ = c.toEquiv i := by dsimp [c']; rw [hπ0, h0_eq] have hb_eq' : c'.toEquiv b = c.toEquiv (cNext hn i) := by dsimp [c']; rw [hπb, h1_eq] rw [← h0_eq', ← hb_eq', c'.mem_edgeSet_iff] at hmem rcases hmem with h | h · have : b.1 = 1 := by have := congrArg Fin.val h; rw [cNext_val] at this; dsimp at this; split_ifs at this <;> omega omega · have : b.1 = Fintype.card V - 1 := by have := congrArg Fin.val h; rw [cPrev_val] at this; dsimp at this; exact this omega · refine Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, ?_⟩ dsimp [c'] have h0n : cNext hn ⟨0, hn⟩ = ⟨1, by omega⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [h0n, hπ0, hπ1, h0_eq, hb_eq] end TwoSwitch /-! ## Section 2: Thomason's Lollipop Involution Engine (First Lean 4 Formalization) Given a finite simple graph `G` on `V` (`|V| ≥ 3`) and a fixed edge `G.Adj u v`, consider the auxiliary **Lollipop Graph** `lollipopGraph G u v` whose vertices are Hamiltonian paths `p : Fin n ≃ V` with `p 0 = u` and `p 1 = v`. Two paths are adjacent iff one is obtained from the other by a **Pósa rotation** at some `1 ≤ k ≤ n - 3` with `G.Adj (p (n - 1)) (p k)`. The degree of `p` in `lollipopGraph G u v` is: - `G.degree (p (n - 1)) - 2` if `G.Adj (p (n - 1)) u` (i.e., `p` closes to a Hamiltonian cycle containing `s(u, v)`), - `G.degree (p (n - 1)) - 1` otherwise. By `SimpleGraph.even_card_odd_degree_vertices` (the Handshaking Lemma), whenever every reachable endpoint `p (n - 1)` has odd degree in `G`, the number of closing paths — and hence the number of undirected Hamiltonian cycles containing `s(u, v)` — is **EVEN**! -/ section ThomasonLollipop variable {V : Type*} [Fintype V] [DecidableEq V] /-- A Hamiltonian path in `G` starting with `p 0 = u` and `p 1 = v` (assuming `3 ≤ |V|`). -/ @[ext] structure HamPathFrom (G : SimpleGraph V) (u v : V) where card_ge_three : 3 ≤ Fintype.card V toEquiv : Fin (Fintype.card V) ≃ V start_zero : toEquiv ⟨0, by omega⟩ = u start_one : toEquiv ⟨1, by omega⟩ = v adj_step : ∀ (i : ℕ) (hi : i + 1 < Fintype.card V), G.Adj (toEquiv ⟨i, by omega⟩) (toEquiv ⟨i + 1, hi⟩) /-- `HamPathFrom G u v` is finite (embeds into `Fin (Fintype.card V) ≃ V`). -/ noncomputable instance instFintypeHamPathFrom (G : SimpleGraph V) (u v : V) : Fintype (HamPathFrom G u v) := Fintype.ofInjective (fun p => p.toEquiv) (fun p q h => by cases p; cases q; simp_all) /-- Endpoint `p (n - 1)` of a Hamiltonian path `p : HamPathFrom G u v`. -/ def HamPathFrom.last {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) : V := p.toEquiv ⟨Fintype.card V - 1, by have := p.card_ge_three; omega⟩ /-- Second-to-last vertex `p (n - 2)` of `p`. -/ def HamPathFrom.penult {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) : V := p.toEquiv ⟨Fintype.card V - 2, by have := p.card_ge_three; omega⟩ omit [DecidableEq V] in lemma HamPathFrom.last_ne_u {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) : p.last ≠ u := by have hn := p.card_ge_three intro h have h' : p.toEquiv ⟨Fintype.card V - 1, by omega⟩ = p.toEquiv ⟨0, by omega⟩ := h.trans p.start_zero.symm have := congrArg Fin.val (p.toEquiv.injective h') dsimp at this; omega omit [DecidableEq V] in lemma HamPathFrom.last_ne_v {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) : p.last ≠ v := by have hn := p.card_ge_three intro h have h' : p.toEquiv ⟨Fintype.card V - 1, by omega⟩ = p.toEquiv ⟨1, by omega⟩ := h.trans p.start_one.symm have := congrArg Fin.val (p.toEquiv.injective h') dsimp at this; omega omit [DecidableEq V] in lemma HamPathFrom.adj_penult_last {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) : G.Adj p.penult p.last := by have hn := p.card_ge_three have h := p.adj_step (Fintype.card V - 2) (by omega) have hidx : (⟨Fintype.card V - 2 + 1, by omega⟩ : Fin (Fintype.card V)) = ⟨Fintype.card V - 1, by omega⟩ := by ext; dsimp; omega rw [hidx] at h exact h /-- Pósa suffix-reversal permutation on `Fin n` fixing `0..k` and reversing `(k+1)..(n-1)`. -/ def posaPerm (n k : ℕ) : Equiv.Perm (Fin n) where toFun i := if h : i.1 ≤ k then i else ⟨k + n - i.1, by omega⟩ invFun i := if h : i.1 ≤ k then i else ⟨k + n - i.1, by omega⟩ left_inv i := by ext; dsimp; split_ifs with h1 h2 <;> simp_all <;> omega right_inv i := by ext; dsimp; split_ifs with h1 h2 <;> simp_all <;> omega lemma posaPerm_involutive (n k : ℕ) (i : Fin n) : posaPerm n k (posaPerm n k i) = i := (posaPerm n k).left_inv i /-- Perform a Pósa rotation on `p : HamPathFrom G u v` at position `k` (`1 ≤ k ≤ n - 3`) when `G.Adj p.last (p k)`. -/ def HamPathFrom.posaRotate {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) (k : ℕ) (hk1 : 1 ≤ k) (hk2 : k + 3 ≤ Fintype.card V) (hadj : G.Adj p.last (p.toEquiv ⟨k, by omega⟩)) : HamPathFrom G u v where card_ge_three := p.card_ge_three toEquiv := (posaPerm (Fintype.card V) k).trans p.toEquiv start_zero := by dsimp [posaPerm]; exact p.start_zero start_one := by dsimp [posaPerm]; rw [dif_pos hk1]; exact p.start_one adj_step i hi := by dsimp only [Equiv.trans_apply] by_cases hik : i < k · have h1 : posaPerm (Fintype.card V) k ⟨i, by omega⟩ = ⟨i, by omega⟩ := by ext; dsimp [posaPerm]; rw [dif_pos (by omega)] have h2 : posaPerm (Fintype.card V) k ⟨i + 1, hi⟩ = ⟨i + 1, hi⟩ := by ext; dsimp [posaPerm]; rw [dif_pos (by omega)] rw [h1, h2]; exact p.adj_step i hi · by_cases heq : i = k · have h1 : posaPerm (Fintype.card V) k ⟨i, by omega⟩ = ⟨k, by omega⟩ := by ext; dsimp [posaPerm]; rw [dif_pos (by omega)]; exact heq have h2 : posaPerm (Fintype.card V) k ⟨i + 1, hi⟩ = ⟨Fintype.card V - 1, by omega⟩ := by ext; dsimp [posaPerm]; rw [dif_neg (by omega)]; dsimp; omega rw [h1, h2]; exact hadj.symm · have h1 : posaPerm (Fintype.card V) k ⟨i, by omega⟩ = ⟨k + Fintype.card V - i, by omega⟩ := by ext; dsimp [posaPerm]; rw [dif_neg (by omega)] have h2 : posaPerm (Fintype.card V) k ⟨i + 1, hi⟩ = ⟨k + Fintype.card V - (i + 1), by omega⟩ := by ext; dsimp [posaPerm]; rw [dif_neg (by omega)] rw [h1, h2] have hs := p.adj_step (k + Fintype.card V - (i + 1)) (by omega) have hidx : (⟨k + Fintype.card V - (i + 1) + 1, by omega⟩ : Fin (Fintype.card V)) = ⟨k + Fintype.card V - i, by omega⟩ := by ext; dsimp; omega rw [hidx] at hs exact hs.symm lemma HamPathFrom.posaRotate_last {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) (k : ℕ) (hk1 : 1 ≤ k) (hk2 : k + 3 ≤ Fintype.card V) (hadj : G.Adj p.last (p.toEquiv ⟨k, by omega⟩)) : (p.posaRotate k hk1 hk2 hadj).last = p.toEquiv ⟨k + 1, by omega⟩ := by dsimp [HamPathFrom.last, HamPathFrom.posaRotate, posaPerm] split_ifs with h · omega · congr 1; ext; dsimp; omega lemma HamPathFrom.posaRotate_ne_self {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) (k : ℕ) (hk1 : 1 ≤ k) (hk2 : k + 3 ≤ Fintype.card V) (hadj : G.Adj p.last (p.toEquiv ⟨k, by omega⟩)) : p.posaRotate k hk1 hk2 hadj ≠ p := by intro heq have hl := congrArg HamPathFrom.last heq rw [p.posaRotate_last] at hl have := congrArg Fin.val (p.toEquiv.injective hl) dsimp at this; omega lemma HamPathFrom.posaRotate_involutive {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) (k : ℕ) (hk1 : 1 ≤ k) (hk2 : k + 3 ≤ Fintype.card V) (hadj : G.Adj p.last (p.toEquiv ⟨k, by omega⟩)) : let q := p.posaRotate k hk1 hk2 hadj have hq_adj : G.Adj q.last (q.toEquiv ⟨k, by omega⟩) := by dsimp only [q] rw [p.posaRotate_last] have hqk : (p.posaRotate k hk1 hk2 hadj).toEquiv ⟨k, by omega⟩ = p.toEquiv ⟨k, by omega⟩ := by dsimp [HamPathFrom.posaRotate, posaPerm]; split_ifs <;> [rfl; omega] rw [hqk] exact (p.adj_step k (by omega)).symm q.posaRotate k hk1 hk2 hq_adj = p := by intro q hq_adj ext i dsimp [q, HamPathFrom.posaRotate] rw [posaPerm_involutive] /-- The **Lollipop Graph** on `HamPathFrom G u v`: two paths are adjacent iff one is a Pósa rotation of the other. -/ def lollipopGraph (G : SimpleGraph V) (u v : V) : SimpleGraph (HamPathFrom G u v) where Adj p q := ∃ (k : ℕ) (hk1 : 1 ≤ k) (hk2 : k + 3 ≤ Fintype.card V) (hadj : G.Adj p.last (p.toEquiv ⟨k, by omega⟩)), q = p.posaRotate k hk1 hk2 hadj symm := ⟨fun p q h => by rcases h with ⟨k, hk1, hk2, hadj, rfl⟩ have hq_adj : G.Adj (p.posaRotate k hk1 hk2 hadj).last ((p.posaRotate k hk1 hk2 hadj).toEquiv ⟨k, by omega⟩) := by rw [p.posaRotate_last] have hqk : (p.posaRotate k hk1 hk2 hadj).toEquiv ⟨k, by omega⟩ = p.toEquiv ⟨k, by omega⟩ := by dsimp [HamPathFrom.posaRotate, posaPerm]; split_ifs <;> [rfl; omega] rw [hqk] exact (p.adj_step k (by omega)).symm exact ⟨k, hk1, hk2, hq_adj, (p.posaRotate_involutive k hk1 hk2 hadj).symm⟩⟩ loopless := ⟨fun p h => by rcases h with ⟨k, hk1, hk2, hadj, heq⟩ exact p.posaRotate_ne_self k hk1 hk2 hadj heq.symm⟩ /-- Exact neighbor count in `lollipopGraph G u v`: `q` is determined uniquely by the neighbor `w = p k` of `p.last` outside `{u, p.penult}`. -/ lemma lollipopGraph_degree_add (G : SimpleGraph V) [DecidableRel G.Adj] (u v : V) (p : HamPathFrom G u v) : (lollipopGraph G u v).degree p + (if G.Adj p.last u then 2 else 1) = G.degree p.last := by have hn := p.card_ge_three -- Map each neighbor w of p.last outside {u, p.penult} to the Pósa rotation at p.symm w! let S : Finset V := (G.neighborFinset p.last).filter (fun w => w ≠ u ∧ w ≠ p.penult) have hS_card : S.card + (if G.Adj p.last u then 2 else 1) = G.degree p.last := by rw [← SimpleGraph.card_neighborFinset_eq_degree] have hpen_mem : p.penult ∈ G.neighborFinset p.last := (SimpleGraph.mem_neighborFinset G p.last p.penult).mpr p.adj_penult_last.symm have hpen_ne_u : p.penult ≠ u := by intro h have h' : p.toEquiv ⟨Fintype.card V - 2, by omega⟩ = p.toEquiv ⟨0, by omega⟩ := h.trans p.start_zero.symm have := congrArg Fin.val (p.toEquiv.injective h'); dsimp at this; omega by_cases hadju : G.Adj p.last u · have hu_mem : u ∈ G.neighborFinset p.last := (SimpleGraph.mem_neighborFinset G p.last u).mpr hadju have hS_eq : S = ((G.neighborFinset p.last).erase u).erase p.penult := by ext w; simp only [S, Finset.mem_filter, Finset.mem_erase]; tauto rw [if_pos hadju, hS_eq, Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hpen_ne_u, hpen_mem⟩), Finset.card_erase_of_mem hu_mem] have h2le : 2 ≤ (G.neighborFinset p.last).card := by have hsub : ({u, p.penult} : Finset V) ⊆ G.neighborFinset p.last := by intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl <;> assumption have hpair : ({u, p.penult} : Finset V).card = 2 := Finset.card_pair hpen_ne_u.symm calc 2 = ({u, p.penult} : Finset V).card := hpair.symm _ ≤ (G.neighborFinset p.last).card := Finset.card_le_card hsub omega · have hu_nmem : u ∉ G.neighborFinset p.last := by rwa [SimpleGraph.mem_neighborFinset] have hS_eq : S = (G.neighborFinset p.last).erase p.penult := by ext w; simp only [S, Finset.mem_filter, Finset.mem_erase] refine ⟨fun ⟨h1, _, h3⟩ => ⟨h3, h1⟩, fun ⟨h3, h1⟩ => ⟨h1, fun hwu => hu_nmem (hwu ▸ h1), h3⟩⟩ rw [if_neg hadju, hS_eq, Finset.card_erase_of_mem hpen_mem] have h1le : 1 ≤ (G.neighborFinset p.last).card := Finset.card_pos.mpr ⟨p.penult, hpen_mem⟩ omega suffices hcard : (lollipopGraph G u v).degree p = S.card by rw [hcard, hS_card] rw [← SimpleGraph.card_neighborFinset_eq_degree] -- Bijection between S and (lollipopGraph G u v).neighborFinset p! refine (Finset.card_bij (fun (w : V) (hw : w ∈ S) => let k := (p.toEquiv.symm w).1 have hmem := Finset.mem_filter.mp hw have hadj : G.Adj p.last w := (SimpleGraph.mem_neighborFinset G p.last w).mp hmem.1 have hk0 : k ≠ 0 := by intro h0; apply hmem.2.1 have : p.toEquiv.symm w = ⟨0, by omega⟩ := Fin.ext h0 rw [← p.start_zero, ← this, Equiv.apply_symm_apply] have hk_last : k ≠ Fintype.card V - 1 := by intro hl; apply G.ne_of_adj hadj have : p.toEquiv.symm w = ⟨Fintype.card V - 1, by omega⟩ := Fin.ext hl rw [HamPathFrom.last, ← this, Equiv.apply_symm_apply] have hk_pen : k ≠ Fintype.card V - 2 := by intro hp'; apply hmem.2.2 have : p.toEquiv.symm w = ⟨Fintype.card V - 2, by omega⟩ := Fin.ext hp' rw [HamPathFrom.penult, ← this, Equiv.apply_symm_apply] have hk_lt : k < Fintype.card V := (p.toEquiv.symm w).2 have hpk : p.toEquiv ⟨k, hk_lt⟩ = w := by simp [k] p.posaRotate k (by omega) (by omega) (by rw [hpk]; exact hadj)) ?_ ?_ ?_).symm · intro w hw rw [SimpleGraph.mem_neighborFinset] exact ⟨_, _, _, _, rfl⟩ · intro w₁ hw₁ w₂ hw₂ heq have hl := congrArg HamPathFrom.last heq rw [p.posaRotate_last, p.posaRotate_last] at hl have hidx := congrArg Fin.val (p.toEquiv.injective hl) dsimp at hidx have hkeq : (p.toEquiv.symm w₁).1 = (p.toEquiv.symm w₂).1 := by omega exact p.toEquiv.symm.injective (Fin.ext hkeq) · intro q hq rw [SimpleGraph.mem_neighborFinset] at hq rcases hq with ⟨k, hk1, hk2, hadj, rfl⟩ refine ⟨p.toEquiv ⟨k, by omega⟩, ?_, ?_⟩ · refine Finset.mem_filter.mpr ⟨(SimpleGraph.mem_neighborFinset G _ _).mpr hadj, ?_, ?_⟩ · intro h have h' : p.toEquiv ⟨k, by omega⟩ = p.toEquiv ⟨0, by omega⟩ := h.trans p.start_zero.symm have := congrArg Fin.val (p.toEquiv.injective h'); dsimp at this; omega · intro h; rw [HamPathFrom.penult] at h have := congrArg Fin.val (p.toEquiv.injective h); dsimp at this; omega · ext i have hk_eq : (p.toEquiv.symm (p.toEquiv ⟨k, by omega⟩)).1 = k := by simp dsimp [HamPathFrom.posaRotate] congr 1 simp only [hk_eq] /-- Convert a closing `HamPathFrom G u v` (`G.Adj p.last u`) into a `DirHamCycle G`. -/ def HamPathFrom.toDirHamCycle {G : SimpleGraph V} {u v : V} (p : HamPathFrom G u v) (hclose : G.Adj p.last u) : DirHamCycle G where card_ge_three := p.card_ge_three toEquiv := p.toEquiv adj_next i := by have hn := p.card_ge_three by_cases hlt : i.1 + 1 < Fintype.card V · have hn_eq : cNext (by omega : 0 < Fintype.card V) i = ⟨i.1 + 1, hlt⟩ := by ext; rw [cNext_val]; simp [hlt] rw [hn_eq]; exact p.adj_step i.1 hlt · have hi_last : i = ⟨Fintype.card V - 1, by omega⟩ := by ext; dsimp; omega have hn_eq : cNext (by omega : 0 < Fintype.card V) ⟨Fintype.card V - 1, by omega⟩ = ⟨0, by omega⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hi_last, hn_eq, p.start_zero]; exact hclose /-- Exact bijection between closing paths `{p : HamPathFrom G u v | G.Adj p.last u}` and undirected Hamiltonian cycles `{E ∈ hamCycles G | s(u, v) ∈ E}`. -/ theorem card_closing_paths_eq_card_hamCycles_through_edge (G : SimpleGraph V) [DecidableRel G.Adj] {u v : V} : (Finset.univ.filter (fun p : HamPathFrom G u v => G.Adj p.last u)).card = ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := by refine Finset.card_bij (fun (p : HamPathFrom G u v) (hp : p ∈ Finset.univ.filter (fun p => G.Adj p.last u)) => (p.toDirHamCycle (Finset.mem_filter.mp hp).2).edgeSet) ?_ ?_ ?_ · intro p hp have hcl := (Finset.mem_filter.mp hp).2 have hn := p.card_ge_three refine Finset.mem_filter.mpr ⟨(p.toDirHamCycle hcl).edgeSet_mem_hamCycles, ?_⟩ refine Finset.mem_image.mpr ⟨⟨0, by omega⟩, Finset.mem_univ _, ?_⟩ have h0n : cNext (by omega : 0 < Fintype.card V) ⟨0, by omega⟩ = ⟨1, by omega⟩ := by ext; rw [cNext_val]; simp; omega dsimp [HamPathFrom.toDirHamCycle]; rw [h0n, p.start_zero, p.start_one] · -- Injectivity: strong induction on i : Fin n! intro p₁ hp₁ p₂ hp₂ heq have hcl₁ := (Finset.mem_filter.mp hp₁).2 have hcl₂ := (Finset.mem_filter.mp hp₂).2 have hn := p₁.card_ge_three have hstep : ∀ k : ℕ, (hk : k < Fintype.card V) → p₁.toEquiv ⟨k, hk⟩ = p₂.toEquiv ⟨k, hk⟩ := by intro k induction k using Nat.strong_induction_on with | h k ih => intro hk match k with | 0 => rw [p₁.start_zero, p₂.start_zero] | 1 => rw [p₁.start_one, p₂.start_one] | m + 2 => have hm1 : m + 1 < Fintype.card V := by omega have hm0 : m < Fintype.card V := by omega have hprev1 := ih (m + 1) (by omega) hm1 have hprev0 := ih m (by omega) hm0 -- s(p₁ (m+1), p₁ (m+2)) ∈ edgeSet p₁ = edgeSet p₂! have hmem : s(p₁.toEquiv ⟨m + 1, hm1⟩, p₁.toEquiv ⟨m + 2, hk⟩) ∈ (p₂.toDirHamCycle hcl₂).edgeSet := by rw [← heq] refine Finset.mem_image.mpr ⟨⟨m + 1, hm1⟩, Finset.mem_univ _, ?_⟩ dsimp [HamPathFrom.toDirHamCycle] have hcn : cNext (by omega : 0 < Fintype.card V) ⟨m + 1, hm1⟩ = ⟨m + 2, hk⟩ := by ext; rw [cNext_val]; simp [hk] rw [hcn] let j := p₂.toEquiv.symm (p₁.toEquiv ⟨m + 2, hk⟩) have hj_eq : p₂.toEquiv j = p₁.toEquiv ⟨m + 2, hk⟩ := by simp [j] rw [hprev1, ← hj_eq] at hmem have hiff := ((p₂.toDirHamCycle hcl₂).mem_edgeSet_iff ⟨m + 1, hm1⟩ j).mp hmem rcases hiff with hj_next | hj_prev · have hcn : cNext (by omega : 0 < Fintype.card V) ⟨m + 1, hm1⟩ = ⟨m + 2, hk⟩ := by ext; rw [cNext_val]; simp [hk] rw [← hj_eq, hj_next, hcn] · exfalso have hcp : cPrev (by omega : 0 < Fintype.card V) ⟨m + 1, hm1⟩ = ⟨m, hm0⟩ := by ext; rw [cPrev_val]; simp have hcontra : p₁.toEquiv ⟨m + 2, hk⟩ = p₁.toEquiv ⟨m, hm0⟩ := by rw [← hj_eq, hj_prev, hcp, ← hprev0] have := congrArg Fin.val (p₁.toEquiv.injective hcontra) dsimp at this; omega ext i exact hstep i.1 i.2 · -- Surjectivity: shift or reverse c to start with (u, v)! intro E hE rcases Finset.mem_filter.mp hE with ⟨hE_ham, huv⟩ obtain ⟨c, rfl⟩ := mem_hamCycles.mp hE_ham have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega rcases Finset.mem_image.mp huv with ⟨i₀, _, hi₀⟩ rcases Sym2.eq_iff.mp hi₀ with ⟨hu_eq, hv_eq⟩ | ⟨hv_eq, hu_eq⟩ · -- Forward orientation: shift c by i₀! let c' := c.shift i₀.1 have hc'0 : c'.toEquiv ⟨0, hn⟩ = u := by dsimp [c', DirHamCycle.shift, cShift] have : (⟨(0 + i₀.1) % Fintype.card V, Nat.mod_lt _ hn⟩ : Fin (Fintype.card V)) = i₀ := by ext; dsimp; rw [zero_add, Nat.mod_eq_of_lt i₀.2] rw [this, hu_eq] have hc'1 : c'.toEquiv ⟨1, by omega⟩ = v := by dsimp [c', DirHamCycle.shift, cShift] have : (⟨(1 + i₀.1) % Fintype.card V, Nat.mod_lt _ hn⟩ : Fin (Fintype.card V)) = cNext hn i₀ := by ext; dsimp [cNext]; rw [add_comm] rw [this, hv_eq] let p : HamPathFrom G u v := { card_ge_three := hn3 toEquiv := c'.toEquiv start_zero := hc'0 start_one := hc'1 adj_step := fun i hi => by have h := c'.adj_next ⟨i, by omega⟩ have hcn : cNext hn ⟨i, by omega⟩ = ⟨i + 1, hi⟩ := by ext; rw [cNext_val]; simp [hi] rwa [hcn] at h } have hcl : G.Adj p.last u := by have h := c'.adj_next ⟨Fintype.card V - 1, by omega⟩ have hcn : cNext hn ⟨Fintype.card V - 1, by omega⟩ = ⟨0, hn⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hcn, hc'0] at h; exact h refine ⟨p, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hcl⟩, ?_⟩ change c'.edgeSet = c.edgeSet exact c.shift_edgeSet i₀.1 · -- Reverse orientation: reverse c, then shift to start at u! let cr := c.rev let j₀ : Fin (Fintype.card V) := (cRev hn).symm (cNext hn i₀) let c' := cr.shift j₀.1 have hc'0 : c'.toEquiv ⟨0, hn⟩ = u := by dsimp [c', cr, DirHamCycle.shift, DirHamCycle.rev, cShift, j₀] have h1 : (⟨(0 + ((cRev hn).symm (cNext hn i₀)).1) % Fintype.card V, Nat.mod_lt _ hn⟩ : Fin (Fintype.card V)) = (cRev hn).symm (cNext hn i₀) := by ext; dsimp; rw [zero_add, Nat.mod_eq_of_lt ((cRev hn).symm (cNext hn i₀)).2] rw [h1, Equiv.apply_symm_apply, hu_eq] have hc'1 : c'.toEquiv ⟨1, by omega⟩ = v := by dsimp [c', cr, DirHamCycle.shift, DirHamCycle.rev, cShift, j₀] have h1 : (⟨(1 + ((cRev hn).symm (cNext hn i₀)).1) % Fintype.card V, Nat.mod_lt _ hn⟩ : Fin (Fintype.card V)) = cNext hn ((cRev hn).symm (cNext hn i₀)) := by ext; dsimp [cNext]; rw [add_comm] rw [h1, cRev_cNext, Equiv.apply_symm_apply, cPrev_cNext, hv_eq] let p : HamPathFrom G u v := { card_ge_three := hn3 toEquiv := c'.toEquiv start_zero := hc'0 start_one := hc'1 adj_step := fun i hi => by have h := c'.adj_next ⟨i, by omega⟩ have hcn : cNext hn ⟨i, by omega⟩ = ⟨i + 1, hi⟩ := by ext; rw [cNext_val]; simp [hi] rwa [hcn] at h } have hcl : G.Adj p.last u := by have h := c'.adj_next ⟨Fintype.card V - 1, by omega⟩ have hcn : cNext hn ⟨Fintype.card V - 1, by omega⟩ = ⟨0, hn⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hcn, hc'0] at h; exact h refine ⟨p, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hcl⟩, ?_⟩ change c'.edgeSet = c.edgeSet rw [cr.shift_edgeSet j₀.1, c.rev_edgeSet] /-- **Core Parity Lemma (Endpoint-Oddness Formulation)**: If EVERY Hamiltonian path `p : HamPathFrom G u v` ends at a vertex `p.last` of **ODD** degree in `G`, then the number of undirected Hamiltonian cycles of `G` containing `s(u, v)` is **EVEN**! -/ theorem even_hamCycles_through_edge_of_odd_last (G : SimpleGraph V) [DecidableRel G.Adj] {u v : V} (hodd : ∀ p : HamPathFrom G u v, Odd (G.degree p.last)) : Even ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := by rw [← card_closing_paths_eq_card_hamCycles_through_edge] have hhand := SimpleGraph.even_card_odd_degree_vertices (lollipopGraph G u v) suffices hset : Finset.univ.filter (fun p : HamPathFrom G u v => G.Adj p.last u) = Finset.univ.filter (fun p : HamPathFrom G u v => Odd ((lollipopGraph G u v).degree p)) by rw [hset]; exact hhand ext p simp only [Finset.mem_filter, Finset.mem_univ, true_and] have hdeg := lollipopGraph_degree_add G u v p obtain ⟨k, hk⟩ := hodd p by_cases hadj : G.Adj p.last u · rw [if_pos hadj] at hdeg simp only [hadj, true_iff] exact ⟨k - 1, by omega⟩ · rw [if_neg hadj] at hdeg simp only [hadj, false_iff] rintro ⟨m, hm⟩; omega /-- **Theorem 2a (General Thomason Lollipop Parity Theorem, 1978)**: If EVERY vertex `w ∉ {u, v}` has **ODD** degree in `G`, then the number of undirected Hamiltonian cycles of `G` containing `s(u, v)` is **EVEN**! (No parity restriction on `u` or `v`!) -/ theorem even_hamCycles_through_edge_of_odd_deg_off (G : SimpleGraph V) [DecidableRel G.Adj] {u v : V} (hodd : ∀ w : V, w ≠ u → w ≠ v → Odd (G.degree w)) : Even ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := even_hamCycles_through_edge_of_odd_last G (fun p => hodd p.last p.last_ne_u p.last_ne_v) /-- Corollary: If `G` has a Hamiltonian cycle `c` and every vertex outside one edge `s(u, v) ∈ c` has odd degree in `G`, then `G` has a **second** distinct Hamiltonian cycle containing `s(u, v)`. -/ theorem exists_second_hamCycle_of_odd_deg_off (G : SimpleGraph V) [DecidableRel G.Adj] {u v : V} {E₀ : Finset (Sym2 V)} (hE₀ : E₀ ∈ hamCycles G) (huv : s(u, v) ∈ E₀) (hodd : ∀ w : V, w ≠ u → w ≠ v → Odd (G.degree w)) : ∃ E₁ ∈ hamCycles G, E₁ ≠ E₀ ∧ s(u, v) ∈ E₁ := by have hev := even_hamCycles_through_edge_of_odd_deg_off G hodd have hmem : E₀ ∈ (hamCycles G).filter (fun E => s(u, v) ∈ E) := Finset.mem_filter.mpr ⟨hE₀, huv⟩ have hpos : 0 < ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := Finset.card_pos.mpr ⟨E₀, hmem⟩ obtain ⟨m, hm⟩ := hev have hge2 : 2 ≤ ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := by omega have h1lt : 1 < ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := by omega obtain ⟨E₁, hE₁, E₂, hE₂, hne12⟩ := Finset.one_lt_card.mp h1lt by_cases h1 : E₁ = E₀ · rcases Finset.mem_filter.mp hE₂ with ⟨hE₂_ham, hE₂_uv⟩ exact ⟨E₂, hE₂_ham, fun h => hne12 (h1.trans h.symm), hE₂_uv⟩ · rcases Finset.mem_filter.mp hE₁ with ⟨hE₁_ham, hE₁_uv⟩ exact ⟨E₁, hE₁_ham, h1, hE₁_uv⟩ /-- **Theorem 2b (Smith–Thomason All-Odd-Degree Multiplicity Theorem)**: If EVERY vertex of `G` has **ODD** degree (e.g., any odd-regular graph) and `G` is Hamiltonian, then `G` has **AT LEAST 3 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_three_of_all_odd_deg (G : SimpleGraph V) [DecidableRel G.Adj] (hodd : ∀ w : V, Odd (G.degree w)) (c : DirHamCycle G) : 3 ≤ (hamCycles G).card := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega let E₀ := c.edgeSet have hE₀ : E₀ ∈ hamCycles G := c.edgeSet_mem_hamCycles let e₁ : Sym2 V := s(c.toEquiv ⟨0, hn⟩, c.toEquiv (cNext hn ⟨0, hn⟩)) have he₁ : e₁ ∈ E₀ := Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, rfl⟩ obtain ⟨E₁, hE₁, hE₁_ne, _⟩ := exists_second_hamCycle_of_odd_deg_off G hE₀ he₁ (fun w _ _ => hodd w) -- Since E₀ ≠ E₁ are Hamiltonian cycles of equal size, pick f ∈ E₀ \ E₁! obtain ⟨f, hf₀, hf₁⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem (mem_hamCycles.mp hE₀) (mem_hamCycles.mp hE₁) hE₁_ne.symm rcases Sym2.mk_surjective f with ⟨⟨a, b⟩, rfl⟩ obtain ⟨E₂, hE₂, hE₂_ne₀, hE₂_f⟩ := exists_second_hamCycle_of_odd_deg_off G hE₀ hf₀ (fun w _ _ => hodd w) have hE₂_ne₁ : E₂ ≠ E₁ := fun h => hf₁ (h ▸ hE₂_f) have hsub : ({E₀, E₁, E₂} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl <;> assumption calc 3 = ({E₀, E₁, E₂} : Finset (Finset (Sym2 V))).card := by rw [Finset.card_insert_of_notMem, Finset.card_pair hE₂_ne₁.symm] simp [hE₁_ne.symm, hE₂_ne₀.symm] _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- **Theorem 2c (Bipartite Thomason Parity Theorem)**: Let `G` be a bipartite graph with bipartition `col : V → Bool` (so adjacent vertices have opposite colors). Suppose `u` has color `false`, `v` has color `true`, and EVERY vertex `w` with `col w = true` and `w ≠ v` has **ODD** degree in `G` (with **NO restriction whatsoever** on the degrees of `col = false` vertices!). Then the number of Hamiltonian cycles of `G` containing `s(u, v)` is **EVEN**! -/ theorem even_hamCycles_bipartite_of_odd_deg_side (G : SimpleGraph V) [DecidableRel G.Adj] (col : V → Bool) (hbip : ∀ x y : V, G.Adj x y → col x ≠ col y) {u v : V} (hu : col u = false) (heven_card : Even (Fintype.card V)) (hodd : ∀ w : V, col w = true → w ≠ v → Odd (G.degree w)) : Even ((hamCycles G).filter (fun E => s(u, v) ∈ E)).card := by apply even_hamCycles_through_edge_of_odd_last intro p have hn := p.card_ge_three -- Prove col (p i) = decide (Odd i) by induction on i! have hcol : ∀ k : ℕ, (hk : k < Fintype.card V) → col (p.toEquiv ⟨k, hk⟩) = decide (k % 2 = 1) := by intro k induction k with | zero => intro hk rw [p.start_zero, hu]; rfl | succ m ih => intro hmk have hm : m < Fintype.card V := by omega have hne := hbip _ _ (p.adj_step m hmk) rw [ih hm] at hne cases hm2 : m % 2 with | zero => have : (m + 1) % 2 = 1 := by omega rw [this]; revert hne; cases col (p.toEquiv ⟨m + 1, hmk⟩) <;> simp [hm2] | succ r => have hr1 : m % 2 = 1 := by omega have : (m + 1) % 2 = 0 := by omega rw [this]; revert hne; cases col (p.toEquiv ⟨m + 1, hmk⟩) <;> simp [hr1] have hlast_col : col p.last = true := by rw [HamPathFrom.last, hcol (Fintype.card V - 1) (by omega)] obtain ⟨m, hm⟩ := heven_card have : (Fintype.card V - 1) % 2 = 1 := by omega simp [this] exact hodd p.last hlast_col p.last_ne_v /-- Corollary: In a bipartite Hamiltonian graph `(col : V → Bool)` where EVERY vertex of color `true` has **ODD** degree, every edge of every Hamiltonian cycle lies in an even number of Hamiltonian cycles, and `G` has **AT LEAST 3 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_three_bipartite_of_odd_deg_side (G : SimpleGraph V) [DecidableRel G.Adj] (col : V → Bool) (hbip : ∀ x y : V, G.Adj x y → col x ≠ col y) (hodd : ∀ w : V, col w = true → Odd (G.degree w)) (c : DirHamCycle G) : 3 ≤ (hamCycles G).card := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega -- First prove Fintype.card V is even because c alternates colors! have hcol_c : ∀ k : ℕ, (hk : k < Fintype.card V) → col (c.toEquiv ⟨k, hk⟩) = if k % 2 = 0 then col (c.toEquiv ⟨0, hn⟩) else !(col (c.toEquiv ⟨0, hn⟩)) := by intro k induction k with | zero => intro _; simp | succ m ih => intro hmk have hm : m < Fintype.card V := by omega have hnext := c.adj_next ⟨m, hm⟩ have hcn : cNext hn ⟨m, hm⟩ = ⟨m + 1, hmk⟩ := by ext; rw [cNext_val]; simp [hmk] rw [hcn] at hnext have hne := hbip _ _ hnext rw [ih hm] at hne by_cases hm2 : m % 2 = 0 · have h1 : (m + 1) % 2 ≠ 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases col (c.toEquiv ⟨0, hn⟩) <;> cases col (c.toEquiv ⟨m + 1, hmk⟩) <;> decide · have h1 : (m + 1) % 2 = 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases col (c.toEquiv ⟨0, hn⟩) <;> cases col (c.toEquiv ⟨m + 1, hmk⟩) <;> decide have heven_card : Even (Fintype.card V) := by have hlast := c.adj_next ⟨Fintype.card V - 1, by omega⟩ have hcn : cNext hn ⟨Fintype.card V - 1, by omega⟩ = ⟨0, hn⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hcn] at hlast have hne := hbip _ _ hlast rw [hcol_c (Fintype.card V - 1) (by omega)] at hne by_cases hmod : (Fintype.card V - 1) % 2 = 0 · simp [hmod] at hne · exact ⟨Fintype.card V / 2, by omega⟩ -- Helper: any edge s(a, b) ∈ E₀ (with E₀ ∈ hamCycles G) has a second cycle containing it! have hex_second : ∀ (E₀ : Finset (Sym2 V)), E₀ ∈ hamCycles G → ∀ (a b : V), s(a, b) ∈ E₀ → ∃ E₁ ∈ hamCycles G, E₁ ≠ E₀ ∧ s(a, b) ∈ E₁ := by intro E₀ hE₀ a b hab obtain ⟨c₀, rfl⟩ := mem_hamCycles.mp hE₀ have hadj : G.Adj a b := c₀.adj_of_mem_edgeSet hab have hcol_ne : col a ≠ col b := hbip a b hadj have hev : Even ((hamCycles G).filter (fun E => s(a, b) ∈ E)).card := by cases hca : col a · exact even_hamCycles_bipartite_of_odd_deg_side G col hbip hca heven_card (fun w hw _ => hodd w hw) · have hcb : col b = false := by revert hcol_ne; rw [hca]; cases col b <;> decide have h := even_hamCycles_bipartite_of_odd_deg_side (v := a) G col hbip hcb heven_card (fun w hw _ => hodd w hw) simpa [Sym2.eq_swap] using h have hmem : c₀.edgeSet ∈ (hamCycles G).filter (fun E => s(a, b) ∈ E) := Finset.mem_filter.mpr ⟨c₀.edgeSet_mem_hamCycles, hab⟩ have hpos : 0 < ((hamCycles G).filter (fun E => s(a, b) ∈ E)).card := Finset.card_pos.mpr ⟨c₀.edgeSet, hmem⟩ obtain ⟨m, hm⟩ := hev have h1lt : 1 < ((hamCycles G).filter (fun E => s(a, b) ∈ E)).card := by omega obtain ⟨E₁, hE₁, E₂, hE₂, hne12⟩ := Finset.one_lt_card.mp h1lt by_cases h1 : E₁ = c₀.edgeSet · rcases Finset.mem_filter.mp hE₂ with ⟨hE₂_ham, hE₂_ab⟩ exact ⟨E₂, hE₂_ham, fun h => hne12 (h1.trans h.symm), hE₂_ab⟩ · rcases Finset.mem_filter.mp hE₁ with ⟨hE₁_ham, hE₁_ab⟩ exact ⟨E₁, hE₁_ham, h1, hE₁_ab⟩ let E₀ := c.edgeSet have hE₀ : E₀ ∈ hamCycles G := c.edgeSet_mem_hamCycles have he₁ : s(c.toEquiv ⟨0, hn⟩, c.toEquiv (cNext hn ⟨0, hn⟩)) ∈ E₀ := Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, rfl⟩ obtain ⟨E₁, hE₁, hE₁_ne, _⟩ := hex_second E₀ hE₀ _ _ he₁ obtain ⟨f, hf₀, hf₁⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem (mem_hamCycles.mp hE₀) (mem_hamCycles.mp hE₁) hE₁_ne.symm rcases Sym2.mk_surjective f with ⟨⟨a, b⟩, rfl⟩ obtain ⟨E₂, hE₂, hE₂_ne₀, hE₂_f⟩ := hex_second E₀ hE₀ a b hf₀ have hE₂_ne₁ : E₂ ≠ E₁ := fun h => hf₁ (h ▸ hE₂_f) have hsub : ({E₀, E₁, E₂} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl <;> assumption calc 3 = ({E₀, E₁, E₂} : Finset (Finset (Sym2 V))).card := by rw [Finset.card_insert_of_notMem, Finset.card_pair hE₂_ne₁.symm] simp [hE₁_ne.symm, hE₂_ne₀.symm] _ ≤ (hamCycles G).card := Finset.card_le_card hsub end ThomasonLollipop /-! ## Section 3: Master Bipartite-Subdivision & Near-$C$-ID Parity Engine We formalize a **strict strengthening of Thomassen's (1998) Independent Dominating Set Theorem**: - **Near-$C$-ID Parity Theorem (`exists_second_hamCycle_of_near_cid`)**: If `A ⊆ V` is `C`-independent and chord-dominates **all but at most ONE** vertex of `V \ A`, then `G` has at least **2** distinct Hamiltonian cycles! - **Full $C$-ID Multiplicity Theorem (`card_hamCycles_ge_three_of_cid`)**: If `A` chord-dominates all of `V \ A`, then `G` has at least **3** distinct Hamiltonian cycles! - **3-Colorable Triangle-Chord Multiplicity Theorem (`card_hamCycles_ge_four_of_three_colorable_triangle_chords`)**: If `G` has a proper 3-coloring in which every color class chord-dominates its complement (e.g., any 3-colorable Cycle + Triangles graph), then `G` has at least **4** distinct Hamiltonian cycles! -/ section BipartiteSubdivision variable {V : Type*} [Fintype V] [DecidableEq V] /-- Predicate: `A` is independent along the Hamiltonian cycle `c`. -/ def IsCycleIndep {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) : Prop := ∀ i : Fin (Fintype.card V), c.toEquiv i ∈ A → c.toEquiv (cNext (by have := c.card_ge_three; omega) i) ∉ A /-- A `c`-independent set on a cycle of length `n ≥ 3` has `|A| < n`, in fact `2 ≤ (V \ A).card`. -/ lemma card_compl_ge_two_of_isCycleIndep {G : SimpleGraph V} (c : DirHamCycle G) {A : Finset V} (hA : IsCycleIndep c A) : 2 ≤ (Finset.univ \ A).card := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega -- Every vertex in A is followed along c by a distinct vertex in V \ A! let f : V → V := fun x => c.toEquiv (cNext hn (c.toEquiv.symm x)) have hf_inj : Function.Injective f := by intro x y hxy exact c.toEquiv.symm.injective (cNext_injective hn (c.toEquiv.injective hxy)) have hf_maps : A.image f ⊆ Finset.univ \ A := by intro y hy rcases Finset.mem_image.mp hy with ⟨x, hx, rfl⟩ refine Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, ?_⟩ have hx' : c.toEquiv (c.toEquiv.symm x) ∈ A := by simpa using hx exact hA (c.toEquiv.symm x) hx' have hle : A.card ≤ (Finset.univ \ A).card := by calc A.card = (A.image f).card := (Finset.card_image_of_injective A hf_inj).symm _ ≤ (Finset.univ \ A).card := Finset.card_le_card hf_maps have hsum : A.card + (Finset.univ \ A).card = Fintype.card V := by rw [Finset.card_sdiff, Finset.inter_univ, Finset.card_univ] have : A.card ≤ Fintype.card V := Finset.card_le_univ A omega omega /-- Auxiliary spanning subgraph `G'` keeping `c.edgeSet` plus one chord `s(w, pick w)` per vertex `w ∈ U ⊆ V \ A`, where `pick w ∈ A` and `s(w, pick w) ∉ c.edgeSet`. -/ def pickSubgraph {G : SimpleGraph V} (c : DirHamCycle G) (_A U : Finset V) (pick : V → V) : SimpleGraph V where Adj x y := s(x, y) ∈ c.edgeSet ∨ (x ∈ U ∧ y = pick x ∧ G.Adj x y) ∨ (y ∈ U ∧ x = pick y ∧ G.Adj y x) symm := ⟨fun x y h => by rcases h with h | h | h · left; rwa [Sym2.eq_swap] · right; right; exact h · right; left; exact h⟩ loopless := ⟨fun x h => by rcases h with h | ⟨_, _, hadj⟩ | ⟨_, _, hadj⟩ · exact G.loopless.irrefl x (c.adj_of_mem_edgeSet h) · exact G.loopless.irrefl x hadj · exact G.loopless.irrefl x hadj⟩ lemma pickSubgraph_le {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) : pickSubgraph c A U pick ≤ G := by intro x y h rcases h with h | ⟨_, _, hadj⟩ | ⟨_, _, hadj⟩ · exact c.adj_of_mem_edgeSet h · exact hadj · exact hadj.symm /-- The cycle `c` is a directed Hamiltonian cycle in `pickSubgraph c A U pick`. -/ def pickSubgraphCycle {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) : DirHamCycle (pickSubgraph c A U pick) where card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next i := Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) /-- Exact degree of every `w ∉ A` in `pickSubgraph`: `3` if `w ∈ U`, `2` if `w ∉ U`. -/ lemma pickSubgraph_degree_not_mem_A {G : SimpleGraph V} (c : DirHamCycle G) {A U : Finset V} {pick : V → V} (_hUA : ∀ w ∈ U, w ∉ A) (hpick_A : ∀ w ∈ U, pick w ∈ A) (hpick_adj : ∀ w ∈ U, G.Adj w (pick w)) (hpick_chord : ∀ w ∈ U, s(w, pick w) ∉ c.edgeSet) {w : V} (hwA : w ∉ A) : (pickSubgraph c A U pick).degree w = if w ∈ U then 3 else 2 := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega let i := c.toEquiv.symm w have hi_eq : c.toEquiv i = w := by simp [i] let n1 := c.toEquiv (cNext hn i) let n2 := c.toEquiv (cPrev hn i) have hn12 : n1 ≠ n2 := fun h => cNext_ne_cPrev hn3 i (c.toEquiv.injective h) rw [← SimpleGraph.card_neighborFinset_eq_degree] by_cases hwU : w ∈ U · rw [if_pos hwU] have hnb : (pickSubgraph c A U pick).neighborFinset w = {n1, n2, pick w} := by ext y rw [SimpleGraph.mem_neighborFinset] simp only [Finset.mem_insert, Finset.mem_singleton, pickSubgraph] constructor · rintro (hc | ⟨_, rfl, _⟩ | ⟨hyU, hwy, _⟩) · have hy_eq : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi_eq, ← hy_eq, c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · left; rw [← hy_eq, h1] · right; left; rw [← hy_eq, h2] · right; right; rfl · exfalso; exact hwA (hwy ▸ hpick_A y hyU) · rintro (rfl | rfl | rfl) · left; rw [← hi_eq, c.mem_edgeSet_iff]; left; rfl · left; rw [← hi_eq, c.mem_edgeSet_iff]; right; rfl · right; left; exact ⟨hwU, rfl, hpick_adj w hwU⟩ rw [hnb] have hne1 : n1 ≠ pick w := by intro h; apply hpick_chord w hwU rw [← h, ← hi_eq, c.mem_edgeSet_iff]; left; rfl have hne2 : n2 ≠ pick w := by intro h; apply hpick_chord w hwU rw [← h, ← hi_eq, c.mem_edgeSet_iff]; right; rfl rw [Finset.card_insert_of_notMem, Finset.card_pair hne2] simp [hn12, hne1] · rw [if_neg hwU] have hnb : (pickSubgraph c A U pick).neighborFinset w = {n1, n2} := by ext y rw [SimpleGraph.mem_neighborFinset] simp only [Finset.mem_insert, Finset.mem_singleton, pickSubgraph] constructor · rintro (hc | ⟨hwU', _, _⟩ | ⟨hyU, hwy, _⟩) · have hy_eq : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi_eq, ← hy_eq, c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · left; rw [← hy_eq, h1] · right; rw [← hy_eq, h2] · exact absurd hwU' hwU · exfalso; exact hwA (hwy ▸ hpick_A y hyU) · rintro (rfl | rfl) · left; rw [← hi_eq, c.mem_edgeSet_iff]; left; rfl · left; rw [← hi_eq, c.mem_edgeSet_iff]; right; rfl rw [hnb, Finset.card_pair hn12] /-- Subdivision vertex type: original vertices `V` plus one degree-2 vertex for each `c`-edge whose endpoints both lie outside `A`. -/ abbrev SubdivEdge {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) := { i : Fin (Fintype.card V) // c.toEquiv i ∉ A ∧ c.toEquiv (cNext (by have := c.card_ge_three; omega) i) ∉ A } abbrev SubdivVert {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) := V ⊕ SubdivEdge c A /-- The subdivided bipartite graph of `pickSubgraph c A U pick` with respect to `A`: every `c`-edge inside `V \ A` is replaced by a length-2 path through a new `Sum.inr` vertex. -/ def subdivGraph {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) : SimpleGraph (SubdivVert c A) where Adj p q := match p, q with | Sum.inl x, Sum.inl y => (pickSubgraph c A U pick).Adj x y ∧ (x ∈ A ∨ y ∈ A) | Sum.inl x, Sum.inr e => x = c.toEquiv e.1 ∨ x = c.toEquiv (cNext (by have := c.card_ge_three; omega) e.1) | Sum.inr e, Sum.inl x => x = c.toEquiv e.1 ∨ x = c.toEquiv (cNext (by have := c.card_ge_three; omega) e.1) | Sum.inr _, Sum.inr _ => False symm := ⟨fun p q h => by cases p <;> cases q · exact ⟨SimpleGraph.Adj.symm h.1, h.2.symm⟩ · exact h · exact h · exact h⟩ loopless := ⟨fun p h => by cases p · exact (pickSubgraph c A U pick).loopless.irrefl _ h.1 · exact h⟩ /-- Bipartition coloring on `SubdivVert c A`: `false` on `A ∪ SubdivEdge`, `true` on `V \ A`. -/ def subdivCol {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) : SubdivVert c A → Bool | Sum.inl x => decide (x ∉ A) | Sum.inr _ => false lemma subdivGraph_bipartite {G : SimpleGraph V} (c : DirHamCycle G) {A U : Finset V} {pick : V → V} (hA : IsCycleIndep c A) (hUA : ∀ w ∈ U, w ∉ A) : ∀ p q : SubdivVert c A, (subdivGraph c A U pick).Adj p q → subdivCol c A p ≠ subdivCol c A q := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega intro p q hadj cases p with | inl x => cases q with | inl y => rcases hadj with ⟨hxy, hmem⟩ -- Show ¬(x ∈ A ∧ y ∈ A) have hnot_both : ¬ (x ∈ A ∧ y ∈ A) := by rintro ⟨hxA, hyA⟩ rcases hxy with hc | ⟨hxU, _, _⟩ | ⟨hyU, _, _⟩ · have hx' : c.toEquiv (c.toEquiv.symm x) = x := by simp have hy' : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hx', ← hy', c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · have := hA (c.toEquiv.symm x) (by simpa using hxA) rw [← h1, hy'] at this; exact this hyA · have := hA (c.toEquiv.symm y) (by simpa using hyA) rw [h2, cNext_cPrev, hx'] at this; exact this hxA · exact hUA x hxU hxA · exact hUA y hyU hyA dsimp [subdivCol] rcases hmem with hxA | hyA · have hyA : y ∉ A := fun hy => hnot_both ⟨hxA, hy⟩ simp [hxA, hyA] · have hxA : x ∉ A := fun hx => hnot_both ⟨hx, hyA⟩ simp [hxA, hyA] | inr e => dsimp [subdivCol] rcases hadj with rfl | rfl · simp [e.2.1] · simp [e.2.2] | inr e => cases q with | inl y => dsimp [subdivCol] rcases hadj with rfl | rfl · simp [e.2.1] · simp [e.2.2] | inr _ => exact False.elim hadj /-- Every vertex `Sum.inl w` (`w ∉ A`) has the EXACT SAME degree in `subdivGraph` as in `pickSubgraph`. -/ lemma subdivGraph_degree_inl_not_mem_A {G : SimpleGraph V} (c : DirHamCycle G) {A U : Finset V} {pick : V → V} (hpick_A : ∀ w ∈ U, pick w ∈ A) {w : V} (hwA : w ∉ A) : (subdivGraph c A U pick).degree (Sum.inl w) = (pickSubgraph c A U pick).degree w := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega rw [← SimpleGraph.card_neighborFinset_eq_degree, ← SimpleGraph.card_neighborFinset_eq_degree] let i := c.toEquiv.symm w have hi_eq : c.toEquiv i = w := by simp [i] refine (Finset.card_bij (fun (y : V) (hy : y ∈ (pickSubgraph c A U pick).neighborFinset w) => if hyA : y ∈ A then Sum.inl y else if hnext : y = c.toEquiv (cNext hn i) then Sum.inr ⟨i, by rw [hi_eq]; exact hwA, by rw [← hnext]; exact hyA⟩ else Sum.inr ⟨cPrev hn i, by have hprev : y = c.toEquiv (cPrev hn i) := by have hadj := (SimpleGraph.mem_neighborFinset _ _ _).mp hy rcases hadj with hc | ⟨hwU, rfl, _⟩ | ⟨hyU, hwy, _⟩ · have hy' : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi_eq, ← hy', c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · exfalso; exact hnext (by rw [← hy', h1]) · rw [← hy', h2] · exact absurd (hpick_A w hwU) hyA · exact absurd (hwy ▸ hpick_A y hyU) hwA rw [← hprev]; exact hyA, by rw [cNext_cPrev, hi_eq]; exact hwA⟩) ?_ ?_ ?_).symm · intro y hy rw [SimpleGraph.mem_neighborFinset] at hy ⊢ split_ifs with hyA hnext · exact ⟨hy, Or.inr hyA⟩ · left; exact hi_eq.symm · right; rw [cNext_cPrev]; exact hi_eq.symm · intro y₁ hy₁ y₂ hy₂ heq have hprev_eq : ∀ y, y ∈ (pickSubgraph c A U pick).neighborFinset w → y ∉ A → y ≠ c.toEquiv (cNext hn i) → y = c.toEquiv (cPrev hn i) := by intro y hy hyA hne have hadj := (SimpleGraph.mem_neighborFinset _ _ _).mp hy rcases hadj with hc | ⟨hwU, rfl, _⟩ | ⟨hyU, hwy, _⟩ · have hy' : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi_eq, ← hy', c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · exact absurd (by rw [← hy', h1]) hne · rw [← hy', h2] · exact absurd (hpick_A w hwU) hyA · exact absurd (hwy ▸ hpick_A y hyU) hwA by_cases h1A : y₁ ∈ A <;> by_cases h2A : y₂ ∈ A · rw [dif_pos h1A, dif_pos h2A] at heq; exact Sum.inl.inj heq · rw [dif_pos h1A, dif_neg h2A] at heq; by_cases h2n : y₂ = c.toEquiv (cNext hn i) <;> [rw [dif_pos h2n] at heq; rw [dif_neg h2n] at heq] <;> cases heq · rw [dif_neg h1A, dif_pos h2A] at heq; by_cases h1n : y₁ = c.toEquiv (cNext hn i) <;> [rw [dif_pos h1n] at heq; rw [dif_neg h1n] at heq] <;> cases heq · rw [dif_neg h1A, dif_neg h2A] at heq by_cases h1n : y₁ = c.toEquiv (cNext hn i) <;> by_cases h2n : y₂ = c.toEquiv (cNext hn i) · rw [h1n, h2n] · rw [dif_pos h1n, dif_neg h2n] at heq have hidx : i = cPrev hn i := congrArg Subtype.val (Sum.inr.inj heq) have h1 : cNext hn i = i := by have := congrArg (cNext hn) hidx; rwa [cNext_cPrev] at this exact absurd h1 (cNext_ne_self (by omega) i) · rw [dif_neg h1n, dif_pos h2n] at heq have hidx : cPrev hn i = i := congrArg Subtype.val (Sum.inr.inj heq) have h1 : cNext hn i = i := by have := congrArg (cNext hn) hidx.symm; rwa [cNext_cPrev] at this exact absurd h1 (cNext_ne_self (by omega) i) · rw [hprev_eq y₁ hy₁ h1A h1n, hprev_eq y₂ hy₂ h2A h2n] · intro q hq rw [SimpleGraph.mem_neighborFinset] at hq cases q with | inl y => rcases hq with ⟨hwy, hwA' | hyA⟩ · exact absurd hwA' hwA · refine ⟨y, (SimpleGraph.mem_neighborFinset _ _ _).mpr hwy, ?_⟩ simp [hyA] | inr e => rcases hq with he1 | he2 · have hei : e.1 = i := c.toEquiv.injective (by rw [← he1, hi_eq]) refine ⟨c.toEquiv (cNext hn i), ?_, ?_⟩ · rw [SimpleGraph.mem_neighborFinset]; left; rw [← hi_eq, c.mem_edgeSet_iff]; left; rfl · have hyA : c.toEquiv (cNext hn i) ∉ A := by rw [← hei]; exact e.2.2 rw [dif_neg hyA, dif_pos rfl] congr 1; exact Subtype.ext hei.symm · have hei : e.1 = cPrev hn i := by have : cNext hn e.1 = i := c.toEquiv.injective (by rw [← he2, hi_eq]) rw [← this, cPrev_cNext] refine ⟨c.toEquiv (cPrev hn i), ?_, ?_⟩ · rw [SimpleGraph.mem_neighborFinset]; left; rw [← hi_eq, c.mem_edgeSet_iff]; right; rfl · have hyA : c.toEquiv (cPrev hn i) ∉ A := by rw [← hei]; exact e.2.1 have hne : c.toEquiv (cPrev hn i) ≠ c.toEquiv (cNext hn i) := fun h => cNext_ne_cPrev hn3 i (c.toEquiv.injective h).symm rw [dif_neg hyA, dif_neg hne] congr 1; exact Subtype.ext hei.symm /-- Every subdivision vertex `Sum.inr e` has EXACTLY two neighbors in `subdivGraph`: `Sum.inl (c e)` and `Sum.inl (c (cNext e))`. -/ lemma subdivGraph_adj_inr_iff {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) (e : SubdivEdge c A) (q : SubdivVert c A) : (subdivGraph c A U pick).Adj (Sum.inr e) q ↔ q = Sum.inl (c.toEquiv e.1) ∨ q = Sum.inl (c.toEquiv (cNext (by have := c.card_ge_three; omega) e.1)) := by cases q with | inl x => simp [subdivGraph] | inr e' => simp [subdivGraph] /-- Build the subdivided Hamiltonian cycle `c*` in `subdivGraph` from `c` by inserting each `Sum.inr e` between `Sum.inl (c e)` and `Sum.inl (c (cNext e))`. -/ noncomputable def subdivCycle {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) : DirHamCycle (subdivGraph c A U pick) := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega -- Construct explicit cyclic list L of all SubdivVert c A! let seg : Fin (Fintype.card V) → List (SubdivVert c A) := fun i => if h : c.toEquiv i ∉ A ∧ c.toEquiv (cNext hn i) ∉ A then [Sum.inl (c.toEquiv i), Sum.inr ⟨i, h⟩] else [Sum.inl (c.toEquiv i)] let L : List (SubdivVert c A) := (List.finRange (Fintype.card V)).flatMap seg have hmem_L : ∀ p : SubdivVert c A, p ∈ L := by intro p rw [List.mem_flatMap] cases p with | inl x => refine ⟨c.toEquiv.symm x, List.mem_finRange _, ?_⟩ dsimp [seg]; split_ifs <;> simp | inr e => refine ⟨e.1, List.mem_finRange _, ?_⟩ dsimp [seg]; rw [dif_pos e.2]; simp have hnodup_L : L.Nodup := by rw [List.nodup_flatMap] refine ⟨?_, ?_⟩ · intro i _ dsimp [seg]; split_ifs <;> simp · exact (List.nodup_finRange _).imp_of_mem fun {i j} _ _ hij p hp1 hp2 => by have hp_key : ∀ (k : Fin (Fintype.card V)), p ∈ seg k → p = Sum.inl (c.toEquiv k) ∨ ∃ h, p = Sum.inr ⟨k, h⟩ := by intro k hk dsimp [seg] at hk split_ifs at hk with h · simp only [List.mem_cons, List.not_mem_nil, or_false] at hk rcases hk with rfl | rfl · exact Or.inl rfl · exact Or.inr ⟨h, rfl⟩ · simp only [List.mem_cons, List.not_mem_nil, or_false] at hk exact Or.inl hk rcases hp_key i hp1 with rfl | ⟨_, rfl⟩ <;> rcases hp_key j hp2 with h | ⟨_, h⟩ · exact hij (c.toEquiv.injective (Sum.inl.inj h)) · cases h · cases h · exact hij (congrArg Subtype.val (Sum.inr.inj h)) have hlen_L : L.length = Fintype.card (SubdivVert c A) := by have h1 := List.toFinset_card_of_nodup hnodup_L have h2 : L.toFinset = Finset.univ := by ext p; simp [hmem_L p] rw [h2, Finset.card_univ] at h1 exact h1.symm have hcard_ge : 3 ≤ Fintype.card (SubdivVert c A) := by rw [Fintype.card_sum]; omega let eL : Fin (Fintype.card (SubdivVert c A)) ≃ SubdivVert c A := (Equiv.cast (congrArg Fin hlen_L.symm)).trans (Equiv.ofBijective (fun k : Fin L.length => L.get k) ⟨fun a b hab => by have := (List.nodup_iff_injective_get.mp hnodup_L) hab; exact this, fun p => by obtain ⟨k, hk⟩ := List.mem_iff_get.mp (hmem_L p) exact ⟨k, hk⟩⟩) -- Helper: adjacent pairs in L (including wrap-around from last to head!) have hadj_list : ∀ k : Fin L.length, (subdivGraph c A U pick).Adj (L.get k) (L.get ⟨(k.1 + 1) % L.length, Nat.mod_lt _ (by omega)⟩) := by -- Prove adjacency by tracking which block `seg i` index `k` falls into! -- Even cleaner: every `seg i` starts with `inl (c i)` and ends with either `inr i` or `inl (c i)`, -- so consecutive elements in `L` are either inside `seg i` (i.e. `inl (c i) ~ inr i`) -- or bridge from end of `seg i` to start of `seg (cNext i)`! have hpair : ∀ (xs : List (Fin (Fintype.card V))), (∀ m (hm : m + 1 < xs.length), xs.get ⟨m + 1, hm⟩ = cNext hn (xs.get ⟨m, by omega⟩)) → (xs.flatMap seg).IsChain (fun a b => (subdivGraph c A U pick).Adj a b) := by intro xs induction xs with | nil => intro _; simp | cons i tl ih => intro hstep cases tl with | nil => simp only [List.flatMap_cons, List.flatMap_nil, List.append_nil, seg] split_ifs with h · simp [subdivGraph] · simp | cons j rest => have hj_eq : j = cNext hn i := hstep 0 (by simp) have htl := ih (fun m hm => hstep (m + 1) (by simpa using hm)) rw [List.flatMap_cons, List.flatMap_cons] have hbridge : (subdivGraph c A U pick).Adj ((seg i).getLast (by dsimp [seg]; split_ifs <;> simp)) ((seg j).head (by dsimp [seg]; split_ifs <;> simp)) := by have hhead : (seg j).head (by dsimp [seg]; split_ifs <;> simp) = Sum.inl (c.toEquiv j) := by dsimp [seg]; split_ifs <;> rfl rw [hhead, hj_eq] dsimp [seg] split_ifs with h · simp [subdivGraph] · simp only [List.getLast_singleton, subdivGraph] refine ⟨Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩), ?_⟩ by_cases h1 : c.toEquiv i ∈ A · exact Or.inl h1 · right; by_contra h2; exact h ⟨h1, h2⟩ -- Combine chain on `seg i` and chain on `(j :: rest).flatMap seg`! have hseg_chain : (seg i).IsChain (fun a b => (subdivGraph c A U pick).Adj a b) := by dsimp [seg]; split_ifs with h · simp [subdivGraph] · simp rw [List.flatMap_cons] at htl have hne_i : seg i ≠ [] := by dsimp [seg]; split_ifs <;> simp have hne_j : seg j ++ rest.flatMap seg ≠ [] := by intro h have h1 : seg j = [] := (List.append_eq_nil_iff.mp h).1 dsimp [seg] at h1 by_cases hc : c.toEquiv j ∉ A ∧ c.toEquiv (cNext hn j) ∉ A · rw [dif_pos hc] at h1; cases h1 · rw [dif_neg hc] at h1; cases h1 refine List.IsChain.append hseg_chain htl ?_ intro x hx y hy have hx' : x = (seg i).getLast hne_i := by rw [List.getLast?_eq_some_getLast hne_i] at hx; exact Option.some.inj hx.symm have hy' : y = (seg j).head (by dsimp [seg]; split_ifs <;> simp) := by have hne_j0 : seg j ≠ [] := by dsimp [seg]; split_ifs <;> simp rw [List.head?_append_of_ne_nil _ hne_j0, List.head?_eq_some_head hne_j0] at hy exact Option.some.inj hy.symm rw [hx', hy']; exact hbridge have hL_chain : L.IsChain (fun a b => (subdivGraph c A U pick).Adj a b) := by apply hpair intro m hm simp only [List.length_finRange] at hm simp only [List.get_eq_getElem, List.getElem_finRange] ext; rw [cNext_val]; dsimp; rw [if_pos hm] intro k by_cases hlt : k.1 + 1 < L.length · have hmod : (k.1 + 1) % L.length = k.1 + 1 := Nat.mod_eq_of_lt hlt have hget := List.isChain_iff_getElem.mp hL_chain k.1 hlt simpa [List.get_eq_getElem, hmod] using hget · -- Wrap-around: last element of L to first element of L! have hk_last : k.1 = L.length - 1 := by omega have hmod : (k.1 + 1) % L.length = 0 := by have : k.1 + 1 = L.length := by omega rw [this, Nat.mod_self] have hL_ne : L ≠ [] := by intro h; rw [h] at hlen_L; simp at hlen_L; omega have h0 : L.get ⟨(k.1 + 1) % L.length, Nat.mod_lt _ (by omega)⟩ = L.head hL_ne := by simp [List.get_eq_getElem, hmod, List.head_eq_getElem_zero] have hlast : L.get k = L.getLast hL_ne := by simp [List.get_eq_getElem, hk_last, List.getLast_eq_getElem] rw [h0, hlast] -- First element of L is Sum.inl (c 0), last element of L is last of seg (n - 1)! have hfr_ne : List.finRange (Fintype.card V) ≠ [] := by intro h; have := congrArg List.length h; simp at this; omega have hhead_L : L.head hL_ne = Sum.inl (c.toEquiv ⟨0, hn⟩) := by have hfr_cons : ∃ tl, List.finRange (Fintype.card V) = ⟨0, hn⟩ :: tl := by cases hfr : List.finRange (Fintype.card V) with | nil => exact absurd hfr hfr_ne | cons a tl => have ha0 : a = ⟨0, hn⟩ := by have h0' : (List.finRange (Fintype.card V))[0]'(by simp; omega) = ⟨0, hn⟩ := by simp simp [hfr] at h0'; exact h0' exact ⟨tl, ha0 ▸ rfl⟩ rcases hfr_cons with ⟨tl, htl⟩ have hseg0_ne : seg ⟨0, hn⟩ ≠ [] := by dsimp [seg] by_cases h : c.toEquiv ⟨0, hn⟩ ∉ A ∧ c.toEquiv (cNext hn ⟨0, hn⟩) ∉ A · rw [dif_pos h]; simp · rw [dif_neg h]; simp have hL_eq : L = seg ⟨0, hn⟩ ++ tl.flatMap seg := by dsimp [L]; rw [htl, List.flatMap_cons] have h1 : L.head hL_ne = (seg ⟨0, hn⟩).head hseg0_ne := by have := List.head?_append_of_ne_nil (l₁ := seg ⟨0, hn⟩) (l₂ := tl.flatMap seg) hseg0_ne rw [← hL_eq, List.head?_eq_some_head hL_ne, List.head?_eq_some_head hseg0_ne] at this exact Option.some.inj this rw [h1]; dsimp [seg]; split_ifs <;> rfl have hlast_L : L.getLast hL_ne = (seg ⟨Fintype.card V - 1, by omega⟩).getLast (by dsimp [seg]; split_ifs <;> simp) := by have hfr_snoc : ∃ init, List.finRange (Fintype.card V) = init ++ [⟨Fintype.card V - 1, by omega⟩] := by refine ⟨(List.finRange (Fintype.card V)).dropLast, ?_⟩ have h1 := List.dropLast_append_getLast hfr_ne have hgl : (List.finRange (Fintype.card V)).getLast hfr_ne = ⟨Fintype.card V - 1, by omega⟩ := by rw [List.getLast_eq_getElem]; simp rw [hgl] at h1; exact h1.symm rcases hfr_snoc with ⟨init, hinit⟩ have hseg_ne : seg ⟨Fintype.card V - 1, by omega⟩ ≠ [] := by dsimp [seg]; split_ifs <;> simp have hL_eq : L = init.flatMap seg ++ seg ⟨Fintype.card V - 1, by omega⟩ := by dsimp [L]; rw [hinit, List.flatMap_append, List.flatMap_singleton] have h1 := List.getLast?_append_of_ne_nil (init.flatMap seg) hseg_ne rw [← hL_eq, List.getLast?_eq_some_getLast hL_ne, List.getLast?_eq_some_getLast hseg_ne] at h1 exact Option.some.inj h1 rw [hhead_L, hlast_L] have hcn : cNext hn ⟨Fintype.card V - 1, by omega⟩ = ⟨0, hn⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega dsimp [seg] split_ifs with h · simp only [List.getLast_cons_cons, List.getLast_singleton, subdivGraph] right; rw [hcn] · simp only [List.getLast_singleton, subdivGraph] refine ⟨Or.inl (by refine Finset.mem_image.mpr ⟨⟨Fintype.card V - 1, by omega⟩, Finset.mem_univ _, ?_⟩ rw [hcn]), ?_⟩ rw [hcn] at h by_cases h1 : c.toEquiv ⟨Fintype.card V - 1, by omega⟩ ∈ A · exact Or.inl h1 · right; by_contra h2; exact h ⟨h1, h2⟩ exact { card_ge_three := hcard_ge toEquiv := eL adj_next := fun k => by dsimp only [eL, Equiv.trans_apply, Equiv.ofBijective_apply] have hk := hadj_list (Equiv.cast (congrArg Fin hlen_L.symm) k) have hstep : Equiv.cast (congrArg Fin hlen_L.symm) (cNext (by omega) k) = ⟨((Equiv.cast (congrArg Fin hlen_L.symm) k).1 + 1) % L.length, Nat.mod_lt _ (by omega)⟩ := by ext dsimp only [Fin.val_mk] rw [fin_cast_val hlen_L.symm, cNext_val, fin_cast_val hlen_L.symm] by_cases hlt : k.1 + 1 < Fintype.card (SubdivVert c A) · have hlt' : k.1 + 1 < L.length := by omega rw [if_pos hlt, Nat.mod_eq_of_lt hlt'] · have heq : k.1 + 1 = L.length := by omega rw [if_neg hlt, heq, Nat.mod_self] rw [hstep] exact hk } /-- **Exact Contraction Injection**: Every Hamiltonian cycle of `subdivGraph` contracts (by suppressing degree-2 `Sum.inr` vertices) to a Hamiltonian cycle of `pickSubgraph`, injectively on undirected edge sets! -/ theorem card_hamCycles_subdiv_le {G : SimpleGraph V} (c : DirHamCycle G) (A U : Finset V) (pick : V → V) (hA : IsCycleIndep c A) (hUA : ∀ w ∈ U, w ∉ A) : (hamCycles (subdivGraph c A U pick)).card ≤ (hamCycles (pickSubgraph c A U pick)).card := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega have hbip := subdivGraph_bipartite (pick := pick) c hA hUA -- Helper: contract any DirHamCycle c' of subdivGraph into a DirHamCycle of pickSubgraph! have hcontract : ∀ c' : DirHamCycle (subdivGraph c A U pick), ∃ d : DirHamCycle (pickSubgraph c A U pick), ∀ x y : V, (x ∈ A ∨ y ∈ A) → (s(Sum.inl x, Sum.inl y) ∈ c'.edgeSet ↔ s(x, y) ∈ d.edgeSet) := by intro c' let N := Fintype.card (SubdivVert c A) have hN3 : 3 ≤ N := c'.card_ge_three have hN : 0 < N := by omega -- Extract the list of original vertices visited by c' in cyclic order! let origList : List V := (List.finRange N).filterMap fun k => match c'.toEquiv k with | Sum.inl x => some x | Sum.inr _ => none have hmem_orig : ∀ x : V, x ∈ origList := by intro x rw [List.mem_filterMap] refine ⟨c'.toEquiv.symm (Sum.inl x), List.mem_finRange _, by simp⟩ have hnodup_orig : origList.Nodup := by have h1 : (List.finRange N).Nodup := List.nodup_finRange N -- filterMap preserves Nodup when the map is injective on `some`! rw [List.nodup_iff_injective_get] at h1 ⊢ -- Even simpler: prove directly by induction on any Nodup list of Fin N! have hfm : ∀ (l : List (Fin N)), l.Nodup → (l.filterMap (fun k => match c'.toEquiv k with | Sum.inl x => some x | Sum.inr _ => none)).Nodup := by intro l hl induction l with | nil => simp | cons k tl ih => rw [List.nodup_cons] at hl cases hck : c'.toEquiv k with | inr e => simp [hck, ih hl.2] | inl x => simp only [List.filterMap_cons, hck, List.nodup_cons] refine ⟨?_, ih hl.2⟩ rw [List.mem_filterMap] rintro ⟨j, hj, hcj⟩ cases hcj' : c'.toEquiv j with | inr _ => simp [hcj'] at hcj | inl y => simp [hcj'] at hcj subst hcj have hkj : k = j := c'.toEquiv.injective (by rw [hck, hcj']) exact hl.1 (hkj ▸ hj) exact List.nodup_iff_injective_get.mp (hfm _ (List.nodup_finRange N)) have hlen_orig : origList.length = Fintype.card V := by have h1 := List.toFinset_card_of_nodup hnodup_orig have h2 : origList.toFinset = Finset.univ := by ext x; simp [hmem_orig x] rw [h2, Finset.card_univ] at h1 exact h1.symm -- Key structural property of c': no two Sum.inr are adjacent, and every Sum.inr e -- sits directly between Sum.inl (c e) and Sum.inl (c (cNext e))! have hinr_next_inl : ∀ k : Fin N, ∀ e : SubdivEdge c A, c'.toEquiv k = Sum.inr e → ∃ y : V, c'.toEquiv (cNext hN k) = Sum.inl y := by intro k e hk have hadj := c'.adj_next k rw [hk] at hadj cases hq : c'.toEquiv (cNext hN k) with | inl y => exact ⟨y, rfl⟩ | inr e' => rw [hq] at hadj; exact False.elim hadj have hinr_neighbors : ∀ k : Fin N, ∀ e : SubdivEdge c A, c'.toEquiv k = Sum.inr e → (c'.toEquiv (cPrev hN k) = Sum.inl (c.toEquiv e.1) ∧ c'.toEquiv (cNext hN k) = Sum.inl (c.toEquiv (cNext hn e.1))) ∨ (c'.toEquiv (cPrev hN k) = Sum.inl (c.toEquiv (cNext hn e.1)) ∧ c'.toEquiv (cNext hN k) = Sum.inl (c.toEquiv e.1)) := by intro k e hk have h1 := (subdivGraph_adj_inr_iff c A U pick e _).mp (hk ▸ c'.adj_next k) have h2' := c'.adj_next (cPrev hN k) rw [cNext_cPrev, hk] at h2' have h2 := (subdivGraph_adj_inr_iff c A U pick e _).mp h2'.symm have hne : c'.toEquiv (cPrev hN k) ≠ c'.toEquiv (cNext hN k) := fun h => cNext_ne_cPrev hN3 k (c'.toEquiv.injective h).symm rcases h2 with h2a | h2b <;> rcases h1 with h1a | h1b · exact absurd (h2a.trans h1a.symm) hne · exact Or.inl ⟨h2a, h1b⟩ · exact Or.inr ⟨h2b, h1a⟩ · exact absurd (h2b.trans h1b.symm) hne -- Build helper: given any `k` with `c' k = inl x`, the next `inl` vertex after `k` is either -- `c' (cNext k)` (if it's `inl`, with `pickSubgraph.Adj x y` AND `x ∈ A ∨ y ∈ A`), -- or `c' (cNext (cNext k))` (if `c' (cNext k) = inr e`, with `s(x, y) ∈ c.edgeSet` AND `x ∉ A ∧ y ∉ A`)! have hstep_adj : ∀ k : Fin N, ∀ x : V, c'.toEquiv k = Sum.inl x → (∃ y : V, c'.toEquiv (cNext hN k) = Sum.inl y ∧ (pickSubgraph c A U pick).Adj x y ∧ (x ∈ A ∨ y ∈ A)) ∨ (∃ (e : SubdivEdge c A) (y : V), c'.toEquiv (cNext hN k) = Sum.inr e ∧ c'.toEquiv (cNext hN (cNext hN k)) = Sum.inl y ∧ (pickSubgraph c A U pick).Adj x y ∧ x ∉ A ∧ y ∉ A) := by intro k x hk have hadj := c'.adj_next k rw [hk] at hadj cases hq : c'.toEquiv (cNext hN k) with | inl y => rw [hq] at hadj exact Or.inl ⟨y, rfl, hadj.1, hadj.2⟩ | inr e => have hnb := hinr_neighbors (cNext hN k) e hq rw [cPrev_cNext, hk] at hnb rcases hnb with ⟨h1, h2⟩ | ⟨h1, h2⟩ · have hx : x = c.toEquiv e.1 := Sum.inl.inj h1 refine Or.inr ⟨e, c.toEquiv (cNext hn e.1), rfl, h2, ?_, ?_, e.2.2⟩ · rw [hx]; left; exact Finset.mem_image.mpr ⟨e.1, Finset.mem_univ _, rfl⟩ · rw [hx]; exact e.2.1 · have hx : x = c.toEquiv (cNext hn e.1) := Sum.inl.inj h1 refine Or.inr ⟨e, c.toEquiv e.1, rfl, h2, ?_, ?_, e.2.1⟩ · rw [hx]; left; rw [Sym2.eq_swap]; exact Finset.mem_image.mpr ⟨e.1, Finset.mem_univ _, rfl⟩ · rw [hx]; exact e.2.2 -- Build `d : DirHamCycle (pickSubgraph c A U pick)` from `origList`! let eD : Fin (Fintype.card V) ≃ V := (Equiv.cast (congrArg Fin hlen_orig.symm)).trans (Equiv.ofBijective (fun k : Fin origList.length => origList.get k) ⟨List.nodup_iff_injective_get.mp hnodup_orig, fun x => by obtain ⟨k, hk⟩ := List.mem_iff_get.mp (hmem_orig x); exact ⟨k, hk⟩⟩) -- Characterize consecutive elements of `origList` (cyclically) via `hstep_adj`! -- For any `a, b : V`, `b` immediately follows `a` in `origList` (cyclically) iff in `c'`, -- `a = c' k` and `b` is the next `inl` after `k`! have horig_succ : ∀ (m : Fin (Fintype.card V)), let a := eD m let b := eD (cNext hn m) let k := c'.toEquiv.symm (Sum.inl a) (c'.toEquiv (cNext hN k) = Sum.inl b) ∨ (∃ e : SubdivEdge c A, c'.toEquiv (cNext hN k) = Sum.inr e ∧ c'.toEquiv (cNext hN (cNext hN k)) = Sum.inl b) := by -- Prove via exact index correspondence in `List.finRange N`! -- Define `pos : Fin N → ℕ` = number of `inl` elements before index `k`. -- Even simpler: prove a general lemma on `l.filterMap f` for consecutive elements! intro m dsimp only let fm : Fin N → Option V := fun k => match c'.toEquiv k with | Sum.inl x => some x | Sum.inr _ => none let a := eD m let b := eD (cNext hn m) let k := c'.toEquiv.symm (Sum.inl a) have hck : c'.toEquiv k = Sum.inl a := by simp [k] -- Find `k'` = the next `inl` position after `k`! have hnext_pos : ∃ (y : V) (k' : Fin N), c'.toEquiv k' = Sum.inl y ∧ ((k' = cNext hN k) ∨ (∃ e : SubdivEdge c A, c'.toEquiv (cNext hN k) = Sum.inr e ∧ k' = cNext hN (cNext hN k))) := by rcases hstep_adj k a hck with ⟨y, hy, _, _⟩ | ⟨e, y, he, hy, _, _, _⟩ · exact ⟨y, cNext hN k, hy, Or.inl rfl⟩ · exact ⟨y, cNext hN (cNext hN k), hy, Or.inr ⟨e, he, rfl⟩⟩ rcases hnext_pos with ⟨y, k', hck', hk'_case⟩ -- Show `y = b` by counting elements of `origList` before `k` vs before `k'`! -- Specifically, `origList` is strictly ordered by index `k.1` in `Fin N`! -- Let `idxOf (x : V) : Fin N := c'.toEquiv.symm (Sum.inl x)`. -- Since `List.finRange N` is sorted by `.1`, `origList[i]` has strictly increasing `idxOf`! have hidx_mono : ∀ i j : Fin origList.length, i < j → (c'.toEquiv.symm (Sum.inl (origList.get i))).1 < (c'.toEquiv.symm (Sum.inl (origList.get j))).1 := by -- Prove generally for any list `l` sorted by `(<)` on `Fin N`! have hgen : ∀ (l : List (Fin N)), l.Pairwise (· < ·) → (l.filterMap fm).Pairwise (fun x y => (c'.toEquiv.symm (Sum.inl x)).1 < (c'.toEquiv.symm (Sum.inl y)).1) := by intro l hl induction l with | nil => simp | cons u tl ih => rw [List.pairwise_cons] at hl cases hcu : c'.toEquiv u with | inr _ => have hfm_u : fm u = none := by dsimp [fm]; rw [hcu] rw [List.filterMap_cons, hfm_u]; exact ih hl.2 | inl x => have hfm_u : fm u = some x := by dsimp [fm]; rw [hcu] rw [List.filterMap_cons, hfm_u, List.pairwise_cons] refine ⟨?_, ih hl.2⟩ intro y hy rw [List.mem_filterMap] at hy rcases hy with ⟨v, hv, hfv⟩ cases hcv : c'.toEquiv v with | inr _ => dsimp [fm] at hfv; rw [hcv] at hfv; cases hfv | inl y' => dsimp [fm] at hfv; rw [hcv] at hfv have hyeq : y' = y := Option.some.inj hfv subst hyeq have hu : c'.toEquiv.symm (Sum.inl x) = u := by rw [← hcu, Equiv.symm_apply_apply] have hv' : c'.toEquiv.symm (Sum.inl y') = v := by rw [← hcv, Equiv.symm_apply_apply] rw [hu, hv']; exact hl.1 v hv have hpw := hgen (List.finRange N) (List.pairwise_lt_finRange N) intro i j hij exact (List.pairwise_iff_get.mp hpw) i j hij -- `origList` has strictly increasing `idxOf` values, and EVERY `k''` with `c' k'' = inl z` appears! -- Therefore `y = b` follows because NO `inl` lies strictly between `k` and `k'` cyclically! have hno_between : ∀ z : V, let kz := c'.toEquiv.symm (Sum.inl z) (k.1 < k'.1 → ¬ (k.1 < kz.1 ∧ kz.1 < k'.1)) ∧ (k'.1 < k.1 → ¬ (k.1 < kz.1 ∨ kz.1 < k'.1)) := by intro z kz have hcz : c'.toEquiv kz = Sum.inl z := by simp [kz] rcases hk'_case with rfl | ⟨e, he, rfl⟩ · have hcv := cNext_val hN k constructor · intro hlt ⟨h1, h2⟩; rw [hcv] at hlt h2; split_ifs at hlt h2 <;> omega · intro hlt hdisj; rw [hcv] at hlt hdisj; split_ifs at hlt hdisj <;> omega · have hcv1 := cNext_val hN k have hcv2 := cNext_val hN (cNext hN k) have hkz_ne : kz ≠ cNext hN k := by intro h; rw [h, he] at hcz; cases hcz have hkz_val : kz.1 ≠ (cNext hN k).1 := fun h => hkz_ne (Fin.ext h) constructor · intro hlt ⟨h1, h2⟩ rw [hcv2] at hlt h2; rw [hcv1] at hlt h2 hkz_val split_ifs at hlt h2 hkz_val <;> omega · intro hlt hdisj rw [hcv2] at hlt hdisj; rw [hcv1] at hlt hdisj hkz_val split_ifs at hlt hdisj hkz_val <;> omega -- Since `a ≠ y` (as `k ≠ k'`), locate `y = eD m'` and prove `m' = cNext hn m`! have hk_ne_k' : k ≠ k' := by rcases hk'_case with rfl | ⟨_, _, rfl⟩ · exact (cNext_ne_self (by omega) k).symm · intro h have : cNext hN (cNext hN k) = k := h.symm have hv := congrArg Fin.val this rw [cNext_val, cNext_val] at hv split_ifs at hv <;> omega let m' : Fin (Fintype.card V) := eD.symm y have hm'_eq : eD m' = y := by simp [m'] have hk'_eq : c'.toEquiv.symm (Sum.inl y) = k' := by rw [← hck', Equiv.symm_apply_apply] have hord : ∀ i j : Fin (Fintype.card V), i < j → (c'.toEquiv.symm (Sum.inl (eD i))).1 < (c'.toEquiv.symm (Sum.inl (eD j))).1 := by intro i j hij have h1 := hidx_mono (Equiv.cast (congrArg Fin hlen_orig.symm) i) (Equiv.cast (congrArg Fin hlen_orig.symm) j) (by show (Equiv.cast (congrArg Fin hlen_orig.symm) i).1 < _; rw [fin_cast_val hlen_orig.symm, fin_cast_val hlen_orig.symm]; exact hij) simpa [eD] using h1 have hm'_eq_next : m' = cNext hn m := by by_cases hlt : k.1 < k'.1 · -- `m < m'`, and no `j` lies strictly between `m` and `m'`! have hmm' : m < m' := by by_contra hle; push Not at hle rcases lt_or_eq_of_le hle with hlt' | rfl · have h1 := hord m' m hlt' rw [hm'_eq, hk'_eq] at h1 have hk_def : c'.toEquiv.symm (Sum.inl (eD m)) = k := rfl rw [hk_def] at h1; omega · exact hk_ne_k' (by rw [← hk'_eq, ← hm'_eq]) have hm1 : m.1 + 1 < Fintype.card V := by omega have hno : ∀ j : Fin (Fintype.card V), ¬ (m < j ∧ j < m') := by rintro j ⟨h1, h2⟩ have hlt1 := hord m j h1 have hlt2 := hord j m' h2 rw [hm'_eq, hk'_eq] at hlt2 exact (hno_between (eD j)).1 hlt ⟨hlt1, hlt2⟩ have hm'_val : m'.1 = m.1 + 1 := by by_contra hne have h1 : m.1 + 1 < m'.1 := by omega exact hno ⟨m.1 + 1, hm1⟩ ⟨by show m.1 < m.1 + 1; omega, by show m.1 + 1 < m'.1; omega⟩ ext; rw [cNext_val, hm'_val]; simp [hm1] · -- `k'.1 < k.1`: `m` is the maximum (`n - 1`) and `m'` is the minimum (`0`)! have hgt : k'.1 < k.1 := by have : k.1 ≠ k'.1 := fun h => hk_ne_k' (Fin.ext h); omega have hm_max : m.1 = Fintype.card V - 1 := by by_contra hne have hlt1 : m < ⟨Fintype.card V - 1, by omega⟩ := by show m.1 < Fintype.card V - 1; omega have h1 := hord m ⟨Fintype.card V - 1, by omega⟩ hlt1 exact (hno_between (eD ⟨Fintype.card V - 1, by omega⟩)).2 hgt (Or.inl h1) have hm'_min : m'.1 = 0 := by by_contra hne have hlt1 : ⟨0, hn⟩ < m' := by show 0 < m'.1; omega have h1 := hord ⟨0, hn⟩ m' hlt1 rw [hm'_eq, hk'_eq] at h1 exact (hno_between (eD ⟨0, hn⟩)).2 hgt (Or.inr h1) ext; rw [cNext_val, hm'_min]; split_ifs <;> omega have hyb : y = eD (cNext hn m) := by rw [← hm'_eq, hm'_eq_next] rw [← hyb] rcases hk'_case with rfl | ⟨e, he, rfl⟩ · exact Or.inl hck' · exact Or.inr ⟨e, he, hck'⟩ -- Now assemble `d : DirHamCycle (pickSubgraph c A U pick)`! let d : DirHamCycle (pickSubgraph c A U pick) := { card_ge_three := hn3 toEquiv := eD adj_next := fun m => by have hs := horig_succ m let k := c'.toEquiv.symm (Sum.inl (eD m)) have hck : c'.toEquiv k = Sum.inl (eD m) := by simp [k] rcases hs with h1 | ⟨e, he, h2⟩ · have hadj := c'.adj_next k rw [hck, h1] at hadj exact hadj.1 · rcases hstep_adj k (eD m) hck with ⟨y, hy, _, _⟩ | ⟨e', y, he', hy', hadj, _, _⟩ · rw [he] at hy; cases hy · rw [h2] at hy'; exact (Sum.inl.inj hy') ▸ hadj } refine ⟨d, ?_⟩ -- Prove exact edge correspondence for pairs `(x, y)` with `x ∈ A ∨ y ∈ A`! intro x y hxyA constructor · intro hmem -- s(inl x, inl y) ∈ c'.edgeSet → either y follows x or x follows y in c', hence in d! let kx := c'.toEquiv.symm (Sum.inl x) let ky := c'.toEquiv.symm (Sum.inl y) have hkx : c'.toEquiv kx = Sum.inl x := by simp [kx] have hky : c'.toEquiv ky = Sum.inl y := by simp [ky] rw [← hkx, ← hky, c'.mem_edgeSet_iff] at hmem rcases hmem with hnext | hprev · -- ky = cNext kx → eD (cNext (eD.symm x)) = y! let m := eD.symm x have hm : eD m = x := by simp [m] have hs := horig_succ m rw [hm] at hs rcases hs with h1 | ⟨e, he, _⟩ · have hy_eq : eD (cNext hn m) = y := Sum.inl.inj (h1.symm.trans (by rw [← hnext, hky])) rw [← hm, ← hy_eq]; exact Finset.mem_image.mpr ⟨m, Finset.mem_univ _, rfl⟩ · rw [← hnext, hky] at he; cases he · -- ky = cPrev kx → kx = cNext ky → eD (cNext (eD.symm y)) = x! have hnext : kx = cNext hN ky := by rw [hprev, cNext_cPrev] let m := eD.symm y have hm : eD m = y := by simp [m] have hs := horig_succ m rw [hm] at hs rcases hs with h1 | ⟨e, he, _⟩ · have hx_eq : eD (cNext hn m) = x := Sum.inl.inj (h1.symm.trans (by rw [← hnext, hkx])) rw [Sym2.eq_swap, ← hm, ← hx_eq]; exact Finset.mem_image.mpr ⟨m, Finset.mem_univ _, rfl⟩ · rw [← hnext, hkx] at he; cases he · intro hmem let mx := eD.symm x let my := eD.symm y have hmx : eD mx = x := by simp [mx] have hmy : eD my = y := by simp [my] rw [← hmx, ← hmy, d.mem_edgeSet_iff] at hmem rcases hmem with hnext | hprev · have hs := horig_succ mx rw [hmx, ← hnext, hmy] at hs rcases hs with h1 | ⟨e, he, h2⟩ · refine Finset.mem_image.mpr ⟨c'.toEquiv.symm (Sum.inl x), Finset.mem_univ _, ?_⟩ rw [Equiv.apply_symm_apply, h1] · -- Impossible since x ∈ A ∨ y ∈ A, while `inr e` only touches vertices in V \ A! exfalso have hnb := hinr_neighbors (cNext hN (c'.toEquiv.symm (Sum.inl x))) e he rw [cPrev_cNext, Equiv.apply_symm_apply, h2] at hnb rcases hnb with ⟨h1', h2'⟩ | ⟨h1', h2'⟩ · rcases hxyA with hxA | hyA · exact e.2.1 (Sum.inl.inj h1' ▸ hxA) · exact e.2.2 (Sum.inl.inj h2' ▸ hyA) · rcases hxyA with hxA | hyA · exact e.2.2 (Sum.inl.inj h1' ▸ hxA) · exact e.2.1 (Sum.inl.inj h2' ▸ hyA) · have hnext : mx = cNext hn my := by rw [hprev, cNext_cPrev] have hs := horig_succ my rw [hmy, ← hnext, hmx] at hs rcases hs with h1 | ⟨e, he, h2⟩ · refine Finset.mem_image.mpr ⟨c'.toEquiv.symm (Sum.inl y), Finset.mem_univ _, ?_⟩ rw [Equiv.apply_symm_apply, h1, Sym2.eq_swap] · exfalso have hnb := hinr_neighbors (cNext hN (c'.toEquiv.symm (Sum.inl y))) e he rw [cPrev_cNext, Equiv.apply_symm_apply, h2] at hnb rcases hnb with ⟨h1', h2'⟩ | ⟨h1', h2'⟩ · rcases hxyA with hxA | hyA · exact e.2.2 (Sum.inl.inj h2' ▸ hxA) · exact e.2.1 (Sum.inl.inj h1' ▸ hyA) · rcases hxyA with hxA | hyA · exact e.2.1 (Sum.inl.inj h2' ▸ hxA) · exact e.2.2 (Sum.inl.inj h1' ▸ hyA) -- Now map each E ∈ hamCycles (subdivGraph) to (hcontract c').choose.edgeSet and prove injectivity! let fMap : Finset (Sym2 (SubdivVert c A)) → Finset (Sym2 V) := fun E => if h : E ∈ hamCycles (subdivGraph c A U pick) then (hcontract (mem_hamCycles.mp h).choose).choose.edgeSet else ∅ refine Finset.card_le_card_of_injOn fMap ?_ ?_ · intro E hE have hE' : E ∈ hamCycles (subdivGraph c A U pick) := Finset.mem_coe.mp hE dsimp only [fMap]; rw [dif_pos hE'] exact Finset.mem_coe.mpr (hcontract (mem_hamCycles.mp hE').choose).choose.edgeSet_mem_hamCycles · intro E₁ hE₁ E₂ hE₂ heq have hE₁' : E₁ ∈ hamCycles (subdivGraph c A U pick) := Finset.mem_coe.mp hE₁ have hE₂' : E₂ ∈ hamCycles (subdivGraph c A U pick) := Finset.mem_coe.mp hE₂ dsimp only [fMap] at heq rw [dif_pos hE₁', dif_pos hE₂'] at heq let c₁ := (mem_hamCycles.mp hE₁').choose let c₂ := (mem_hamCycles.mp hE₂').choose have hc₁ : c₁.edgeSet = E₁ := (mem_hamCycles.mp hE₁').choose_spec have hc₂ : c₂.edgeSet = E₂ := (mem_hamCycles.mp hE₂').choose_spec have hcorr₁ := (hcontract c₁).choose_spec have hcorr₂ := (hcontract c₂).choose_spec -- Every Sum.inr e has degree 2 in subdivGraph, so BOTH its incident edges lie in EVERY H-cycle! have hinr_mem : ∀ (c' : DirHamCycle (subdivGraph c A U pick)) (e : SubdivEdge c A) (x : V), (subdivGraph c A U pick).Adj (Sum.inr e) (Sum.inl x) → s(Sum.inr e, Sum.inl x) ∈ c'.edgeSet := by intro c' e x hadj have hN3 := c'.card_ge_three have hN : 0 < Fintype.card (SubdivVert c A) := by omega let k := c'.toEquiv.symm (Sum.inr e) have hk : c'.toEquiv k = Sum.inr e := by simp [k] have h1 := (subdivGraph_adj_inr_iff c A U pick e _).mp (hk ▸ c'.adj_next k) have h2' := c'.adj_next (cPrev hN k) rw [cNext_cPrev, hk] at h2' have h2 := (subdivGraph_adj_inr_iff c A U pick e _).mp h2'.symm have hne : c'.toEquiv (cPrev hN k) ≠ c'.toEquiv (cNext hN k) := fun h => cNext_ne_cPrev hN3 k (c'.toEquiv.injective h).symm have hx := (subdivGraph_adj_inr_iff c A U pick e (Sum.inl x)).mp hadj have hor : Sum.inl x = c'.toEquiv (cNext hN k) ∨ Sum.inl x = c'.toEquiv (cPrev hN k) := by rcases h1 with h1a | h1b <;> rcases h2 with h2a | h2b · exact absurd (h2a.trans h1a.symm) hne · rcases hx with hx1 | hx2 · left; exact hx1.trans h1a.symm · right; exact hx2.trans h2b.symm · rcases hx with hx1 | hx2 · right; exact hx1.trans h2a.symm · left; exact hx2.trans h1b.symm · exact absurd (h2b.trans h1b.symm) hne rcases hor with h | h · refine Finset.mem_image.mpr ⟨k, Finset.mem_univ _, ?_⟩; rw [hk, ← h] · refine Finset.mem_image.mpr ⟨cPrev hN k, Finset.mem_univ _, ?_⟩ rw [cNext_cPrev, hk, ← h, Sym2.eq_swap] rw [← hc₁, ← hc₂] ext f rcases Sym2.mk_surjective f with ⟨⟨p, q⟩, rfl⟩ change s(p, q) ∈ c₁.edgeSet ↔ s(p, q) ∈ c₂.edgeSet cases p with | inl x => cases q with | inl y => by_cases hxyA : x ∈ A ∨ y ∈ A · rw [hcorr₁ x y hxyA, hcorr₂ x y hxyA, heq] · constructor <;> intro hmem · exfalso; exact hxyA (c₁.adj_of_mem_edgeSet hmem).2 · exfalso; exact hxyA (c₂.adj_of_mem_edgeSet hmem).2 | inr e => constructor <;> intro hmem · rw [Sym2.eq_swap]; exact hinr_mem c₂ e x (c₁.adj_of_mem_edgeSet hmem).symm · rw [Sym2.eq_swap]; exact hinr_mem c₁ e x (c₂.adj_of_mem_edgeSet hmem).symm | inr e => cases q with | inl y => constructor <;> intro hmem · exact hinr_mem c₂ e y (c₁.adj_of_mem_edgeSet hmem) · exact hinr_mem c₁ e y (c₂.adj_of_mem_edgeSet hmem) | inr e' => constructor <;> intro hmem · exact False.elim (c₁.adj_of_mem_edgeSet hmem) · exact False.elim (c₂.adj_of_mem_edgeSet hmem) /-- **Theorem 3a (Near-$C$-ID Parity Theorem — Strict Strengthening of Thomassen 1998)**: Let `G` be a finite simple graph with Hamiltonian cycle `c` and a `c`-independent set `A ⊆ V` that **chord-dominates all but at most ONE vertex** `v₀ ∈ V \ A` (every `w ∈ (V \ A) \ {v₀}` has a neighbor `a ∈ A` with `s(w, a) ∉ c.edgeSet`). Then `G` has **AT LEAST 2 DISTINCT HAMILTONIAN CYCLES**! -/ theorem exists_second_hamCycle_of_near_cid {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) (hA : IsCycleIndep c A) (v₀ : V) (hv₀A : v₀ ∉ A) (hdom : ∀ w : V, w ∉ A → w ≠ v₀ → ∃ a ∈ A, G.Adj w a ∧ s(w, a) ∉ c.edgeSet) : 2 ≤ (hamCycles G).card := by let U : Finset V := (Finset.univ \ A).erase v₀ let pick : V → V := fun w => if h : w ∈ U then (hdom w (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase h)).2 (Finset.ne_of_mem_erase h)).choose else w have hUA : ∀ w ∈ U, w ∉ A := fun w hw => (Finset.mem_sdiff.mp (Finset.mem_of_mem_erase hw)).2 have hpick_A : ∀ w ∈ U, pick w ∈ A := fun w hw => by dsimp [pick]; rw [dif_pos hw] exact (hdom w (hUA w hw) (Finset.ne_of_mem_erase hw)).choose_spec.1 have hpick_adj : ∀ w ∈ U, G.Adj w (pick w) := fun w hw => by dsimp [pick]; rw [dif_pos hw] exact (hdom w (hUA w hw) (Finset.ne_of_mem_erase hw)).choose_spec.2.1 have hpick_chord : ∀ w ∈ U, s(w, pick w) ∉ c.edgeSet := fun w hw => by dsimp [pick]; rw [dif_pos hw] exact (hdom w (hUA w hw) (Finset.ne_of_mem_erase hw)).choose_spec.2.2 -- Build subdivGraph and its subdivided cycle c*! let Gs := subdivGraph c A U pick let cs : DirHamCycle Gs := subdivCycle c A U pick have hbip := subdivGraph_bipartite (pick := pick) c hA hUA -- Show Fintype.card (SubdivVert c A) is even because cs alternates colors! have hN3 := cs.card_ge_three have hN : 0 < Fintype.card (SubdivVert c A) := by omega have hcol_cs : ∀ k : ℕ, (hk : k < Fintype.card (SubdivVert c A)) → subdivCol c A (cs.toEquiv ⟨k, hk⟩) = if k % 2 = 0 then subdivCol c A (cs.toEquiv ⟨0, hN⟩) else !(subdivCol c A (cs.toEquiv ⟨0, hN⟩)) := by intro k induction k with | zero => intro _; simp | succ m ih => intro hmk have hm : m < Fintype.card (SubdivVert c A) := by omega have hnext := cs.adj_next ⟨m, hm⟩ have hcn : cNext hN ⟨m, hm⟩ = ⟨m + 1, hmk⟩ := by ext; dsimp; rw [cNext_val]; dsimp; rw [if_pos hmk] rw [hcn] at hnext have hne := hbip _ _ hnext rw [ih hm] at hne by_cases hm2 : m % 2 = 0 · have h1 : (m + 1) % 2 ≠ 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases subdivCol c A (cs.toEquiv ⟨0, hN⟩) <;> cases subdivCol c A (cs.toEquiv ⟨m + 1, hmk⟩) <;> decide · have h1 : (m + 1) % 2 = 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases subdivCol c A (cs.toEquiv ⟨0, hN⟩) <;> cases subdivCol c A (cs.toEquiv ⟨m + 1, hmk⟩) <;> decide have heven_card : Even (Fintype.card (SubdivVert c A)) := by have hlast := cs.adj_next ⟨Fintype.card (SubdivVert c A) - 1, by omega⟩ have hcn : cNext hN ⟨Fintype.card (SubdivVert c A) - 1, by omega⟩ = ⟨0, hN⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hcn] at hlast have hne := hbip _ _ hlast rw [hcol_cs (Fintype.card (SubdivVert c A) - 1) (by omega)] at hne by_cases hmod : (Fintype.card (SubdivVert c A) - 1) % 2 = 0 · rw [if_pos hmod] at hne; exact absurd rfl hne · exact ⟨Fintype.card (SubdivVert c A) / 2, by omega⟩ -- Pick the neighbor `u*` of `Sum.inl v₀` on `cs`! It has `subdivCol = false`! let k0 := cs.toEquiv.symm (Sum.inl v₀) let uStar := cs.toEquiv (cPrev hN k0) have huStar_adj : Gs.Adj uStar (Sum.inl v₀) := by have h := cs.adj_next (cPrev hN k0) rw [cNext_cPrev] at h; simpa [k0] using h have huStar_edge : s(uStar, Sum.inl v₀) ∈ cs.edgeSet := by refine Finset.mem_image.mpr ⟨cPrev hN k0, Finset.mem_univ _, ?_⟩ rw [cNext_cPrev]; simp [k0, uStar] have huStar_col : subdivCol c A uStar = false := by have hne := hbip _ _ huStar_adj have hv₀_col : subdivCol c A (Sum.inl v₀) = true := by simp [subdivCol, hv₀A] rw [hv₀_col] at hne cases h : subdivCol c A uStar <;> simp [h] at hne ⊢ -- Apply Bipartite Thomason Parity Theorem on `(Gs, uStar, Sum.inl v₀)`! have hev := even_hamCycles_bipartite_of_odd_deg_side Gs (subdivCol c A) hbip huStar_col heven_card (fun p hp_col hp_ne => by cases p with | inr e => simp [subdivCol] at hp_col | inl w => have hwA : w ∉ A := by simpa [subdivCol] using hp_col have hw_ne : w ≠ v₀ := fun h => hp_ne (congrArg Sum.inl h) have hwU : w ∈ U := Finset.mem_erase.mpr ⟨hw_ne, Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, hwA⟩⟩ rw [subdivGraph_degree_inl_not_mem_A c hpick_A hwA, pickSubgraph_degree_not_mem_A c hUA hpick_A hpick_adj hpick_chord hwA, if_pos hwU] exact ⟨1, rfl⟩) have hpos : 0 < ((hamCycles Gs).filter (fun E => s(uStar, Sum.inl v₀) ∈ E)).card := Finset.card_pos.mpr ⟨cs.edgeSet, Finset.mem_filter.mpr ⟨cs.edgeSet_mem_hamCycles, huStar_edge⟩⟩ obtain ⟨m, hm⟩ := hev have hge2_sub : 2 ≤ (hamCycles Gs).card := by calc 2 ≤ ((hamCycles Gs).filter (fun E => s(uStar, Sum.inl v₀) ∈ E)).card := by omega _ ≤ (hamCycles Gs).card := Finset.card_filter_le _ _ calc 2 ≤ (hamCycles Gs).card := hge2_sub _ ≤ (hamCycles (pickSubgraph c A U pick)).card := card_hamCycles_subdiv_le c A U pick hA hUA _ ≤ (hamCycles G).card := Finset.card_le_card (hamCycles_mono (pickSubgraph_le c A U pick)) /-- **Theorem 3b (Full $C$-ID Multiplicity Theorem — Strengthening Thomassen 1998)**: If `A ⊆ V` is `c`-independent and chord-dominates **ALL** of `V \ A`, then `G` has **AT LEAST 3 DISTINCT HAMILTONIAN CYCLES** (and in fact the chord-bipartite subgraph `pickSubgraph` already has `≥ 3` Hamiltonian cycles!). -/ theorem card_hamCycles_ge_three_of_cid {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) (hA : IsCycleIndep c A) (hdom : ∀ w : V, w ∉ A → ∃ a ∈ A, G.Adj w a ∧ s(w, a) ∉ c.edgeSet) : 3 ≤ (hamCycles G).card := by let U : Finset V := Finset.univ \ A let pick : V → V := fun w => if h : w ∈ U then (hdom w (Finset.mem_sdiff.mp h).2).choose else w have hUA : ∀ w ∈ U, w ∉ A := fun w hw => (Finset.mem_sdiff.mp hw).2 have hpick_A : ∀ w ∈ U, pick w ∈ A := fun w hw => by dsimp [pick]; rw [dif_pos hw]; exact (hdom w (hUA w hw)).choose_spec.1 have hpick_adj : ∀ w ∈ U, G.Adj w (pick w) := fun w hw => by dsimp [pick]; rw [dif_pos hw]; exact (hdom w (hUA w hw)).choose_spec.2.1 have hpick_chord : ∀ w ∈ U, s(w, pick w) ∉ c.edgeSet := fun w hw => by dsimp [pick]; rw [dif_pos hw]; exact (hdom w (hUA w hw)).choose_spec.2.2 let Gs := subdivGraph c A U pick let cs : DirHamCycle Gs := subdivCycle c A U pick have hge3 : 3 ≤ (hamCycles Gs).card := card_hamCycles_ge_three_bipartite_of_odd_deg_side Gs (subdivCol c A) (subdivGraph_bipartite c hA hUA) (fun p hp_col => by cases p with | inr e => simp [subdivCol] at hp_col | inl w => have hwA : w ∉ A := by simpa [subdivCol] using hp_col have hwU : w ∈ U := Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, hwA⟩ rw [subdivGraph_degree_inl_not_mem_A c hpick_A hwA, pickSubgraph_degree_not_mem_A c hUA hpick_A hpick_adj hpick_chord hwA, if_pos hwU] exact ⟨1, rfl⟩) cs calc 3 ≤ (hamCycles Gs).card := hge3 _ ≤ (hamCycles (pickSubgraph c A U pick)).card := card_hamCycles_subdiv_le c A U pick hA hUA _ ≤ (hamCycles G).card := Finset.card_le_card (hamCycles_mono (pickSubgraph_le c A U pick)) /-- **Theorem 3c (3-Colorable Triangle-Chord Multiplicity Theorem)**: Suppose `G` has a Hamiltonian cycle `c` and a partition into 3 `c`-independent classes `A₀, A₁, A₂` (`col : V → Fin 3`) such that every vertex `w ∉ Aᵢ` has a chord to `Aᵢ` (e.g., any proper 3-coloring of a Cycle + Triangles graph). Then `G` has **AT LEAST 4 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_four_of_three_cid_classes {G : SimpleGraph V} (c : DirHamCycle G) (col : V → Fin 3) (hind : ∀ t : Fin 3, IsCycleIndep c (Finset.univ.filter fun v => col v = t)) (hdom : ∀ (t : Fin 3) (w : V), col w ≠ t → ∃ a : V, col a = t ∧ G.Adj w a ∧ s(w, a) ∉ c.edgeSet) : 4 ≤ (hamCycles G).card := by -- For each color t ∈ Fin 3, build the subgraph G_t keeping c.edgeSet + chords touching class t! let Gt : Fin 3 → SimpleGraph V := fun t => { Adj := fun x y => s(x, y) ∈ c.edgeSet ∨ (G.Adj x y ∧ (col x = t ∨ col y = t)) symm := ⟨fun x y h => by rcases h with h | ⟨ha, hc⟩ · left; rwa [Sym2.eq_swap] · right; exact ⟨ha.symm, hc.symm⟩⟩ loopless := ⟨fun x h => by rcases h with h | ⟨ha, _⟩ · exact G.loopless.irrefl x (c.adj_of_mem_edgeSet h) · exact G.loopless.irrefl x ha⟩ } have hGt_le : ∀ t, Gt t ≤ G := fun t x y h => by rcases h with h | ⟨ha, _⟩ · exact c.adj_of_mem_edgeSet h · exact ha have hGt_ge3 : ∀ t : Fin 3, 3 ≤ (hamCycles (Gt t)).card := by intro t let ct : DirHamCycle (Gt t) := { card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next := fun i => Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) } have hct_eq : ct.edgeSet = c.edgeSet := rfl apply card_hamCycles_ge_three_of_cid ct (Finset.univ.filter fun v => col v = t) (hind t) intro w hw have hcw : col w ≠ t := by simpa using hw obtain ⟨a, hca, hadj, hch⟩ := hdom t w hcw exact ⟨a, by simpa using hca, Or.inr ⟨hadj, Or.inr hca⟩, by rwa [hct_eq]⟩ -- Let S_t = (hamCycles (Gt t)).erase c.edgeSet; each |S_t| ≥ 2! let S : Fin 3 → Finset (Finset (Sym2 V)) := fun t => (hamCycles (Gt t)).erase c.edgeSet have hS_sub : ∀ t, S t ⊆ (hamCycles G).erase c.edgeSet := fun t E hE => by rcases Finset.mem_erase.mp hE with ⟨hne, hmem⟩ exact Finset.mem_erase.mpr ⟨hne, hamCycles_mono (hGt_le t) hmem⟩ have hS_card : ∀ t, 2 ≤ (S t).card := by intro t have hc_mem : c.edgeSet ∈ hamCycles (Gt t) := by refine mem_hamCycles.mpr ⟨⟨c.card_ge_three, c.toEquiv, fun i => Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩)⟩, rfl⟩ rw [Finset.card_erase_of_mem hc_mem] have := hGt_ge3 t; omega -- Key double-counting fact: NO cycle E ≠ c.edgeSet can lie in ALL THREE of S 0, S 1, S 2! -- Because E ≠ c.edgeSet must contain some chord s(x, y) ∉ c.edgeSet, and col x, col y cover at most 2 colors! have hnot_all3 : ∀ E, ¬ (E ∈ S 0 ∧ E ∈ S 1 ∧ E ∈ S 2) := by rintro E ⟨h0, h1, h2⟩ have hne : E ≠ c.edgeSet := (Finset.mem_erase.mp h0).1 have hE_G : IsHamCycle G E := mem_hamCycles.mp (hamCycles_mono (hGt_le 0) (Finset.mem_erase.mp h0).2) obtain ⟨f, hfE, hfc⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem hE_G ⟨c, rfl⟩ hne rcases Sym2.mk_surjective f with ⟨⟨x, y⟩, rfl⟩ have hadj_t : ∀ t : Fin 3, (Gt t).Adj x y := fun t => by have ht : E ∈ hamCycles (Gt t) := by fin_cases t · exact (Finset.mem_erase.mp h0).2 · exact (Finset.mem_erase.mp h1).2 · exact (Finset.mem_erase.mp h2).2 obtain ⟨ct, rfl⟩ := mem_hamCycles.mp ht exact ct.adj_of_mem_edgeSet hfE have hcol_t : ∀ t : Fin 3, col x = t ∨ col y = t := fun t => by rcases hadj_t t with hc | ⟨_, hcol⟩ · exact absurd hc hfc · exact hcol -- 3 distinct colors in Fin 3 cannot all belong to {col x, col y}! have h0' := hcol_t 0 have h1' := hcol_t 1 have h2' := hcol_t 2 rcases h0' with hx0 | hy0 <;> rcases h1' with hx1 | hy1 <;> rcases h2' with hx2 | hy2 all_goals omega -- Sum of indicator functions over U = (hamCycles G).erase c.edgeSet is ≤ 2 * |U| and ≥ 6! let U := (hamCycles G).erase c.edgeSet have hsum_ge : 6 ≤ (S 0).card + (S 1).card + (S 2).card := by have := hS_card 0; have := hS_card 1; have := hS_card 2; omega have hsum_le : (S 0).card + (S 1).card + (S 2).card ≤ 2 * U.card := by have hcard_eq : ∀ t, (S t).card = ∑ E ∈ U, if E ∈ S t then 1 else 0 := fun t => by rw [Finset.sum_boole, Nat.cast_id, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr (hS_sub t)] rw [hcard_eq 0, hcard_eq 1, hcard_eq 2, ← Finset.sum_add_distrib, ← Finset.sum_add_distrib] calc ∑ E ∈ U, ((if E ∈ S 0 then 1 else 0) + (if E ∈ S 1 then 1 else 0) + (if E ∈ S 2 then 1 else 0)) ≤ ∑ _E ∈ U, 2 := by apply Finset.sum_le_sum intro E _ have hn3 := hnot_all3 E by_cases h0 : E ∈ S 0 <;> by_cases h1 : E ∈ S 1 <;> by_cases h2 : E ∈ S 2 · exact False.elim (hn3 ⟨h0, h1, h2⟩) all_goals simp [h0, h1, h2] _ = 2 * U.card := by rw [Finset.sum_const, smul_eq_mul, mul_comm] have hU_ge3 : 3 ≤ U.card := by omega have hc_mem : c.edgeSet ∈ hamCycles G := c.edgeSet_mem_hamCycles have hcard_U : U.card = (hamCycles G).card - 1 := Finset.card_erase_of_mem hc_mem have hpos : 1 ≤ (hamCycles G).card := Finset.card_pos.mpr ⟨c.edgeSet, hc_mem⟩ omega end BipartiteSubdivision /-! ## Section 4: Chord 2-Factor Cycle Decomposition & Quantitative Multiplicity Hierarchy For any 4-regular simple graph `G` with a Hamiltonian cycle `c`, the chord graph `chordGraph c := G \ E(c)` is a **2-regular simple graph** edge-disjoint from `c`. We prove that every 2-regular finite simple graph decomposes into vertex-disjoint cycles `𝒟 : List (CycleIn H)` of lengths `≥ 3`, and establish the full quantitative multiplicity hierarchy: - **Theorem 4a**: Every chord cycle even (`m = 0`, strictly generalizing Sheehan 1975 for bipartite 4-regular graphs) $\implies \ge 5$ Hamiltonian cycles! - **Theorem 4b**: Single even Hamiltonian chord cycle $\implies \ge 6$ Hamiltonian cycles; single odd Hamiltonian chord cycle $\implies \ge 4$ Hamiltonian cycles! - **Theorem 4c**: At most 1 odd chord cycle (`m ≤ 1`) $\implies \ge 2$ Hamiltonian cycles! - **Theorem 4d**: Exactly 2 odd chord cycles connected by a `c`-edge — and in particular ANY chord 2-factor with `≤ 2` components — $\implies \ge 2$ Hamiltonian cycles! -/ section ChordTwoFactor variable {V : Type*} [Fintype V] [DecidableEq V] /-- The chord graph `G \ E(c)` of a Hamiltonian graph `(G, c)`. -/ def chordGraph {G : SimpleGraph V} (c : DirHamCycle G) : SimpleGraph V where Adj x y := G.Adj x y ∧ s(x, y) ∉ c.edgeSet symm := ⟨fun _ _ h => ⟨h.1.symm, fun h' => h.2 (by rwa [Sym2.eq_swap])⟩⟩ loopless := ⟨fun x h => G.loopless.irrefl x h.1⟩ lemma chordGraph_le {G : SimpleGraph V} (c : DirHamCycle G) : chordGraph c ≤ G := fun _ _ h => h.1 /-- In a 4-regular graph `G` with Hamiltonian cycle `c`, `chordGraph c` is 2-regular! -/ lemma chordGraph_isRegularOfDegree_two {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (c : DirHamCycle G) : (chordGraph c).IsRegularOfDegree 2 := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega intro w let i := c.toEquiv.symm w have hi : c.toEquiv i = w := by simp [i] let n1 := c.toEquiv (cNext hn i) let n2 := c.toEquiv (cPrev hn i) have hn12 : n1 ≠ n2 := fun h => cNext_ne_cPrev hn3 i (c.toEquiv.injective h) have hn1_mem : n1 ∈ G.neighborFinset w := by rw [SimpleGraph.mem_neighborFinset, ← hi]; exact c.adj_next i have hn2_mem : n2 ∈ G.neighborFinset w := by rw [SimpleGraph.mem_neighborFinset, ← hi] have h := c.adj_next (cPrev hn i); rw [cNext_cPrev] at h; exact h.symm have hnb : (chordGraph c).neighborFinset w = ((G.neighborFinset w).erase n1).erase n2 := by ext y rw [SimpleGraph.mem_neighborFinset, Finset.mem_erase, Finset.mem_erase, SimpleGraph.mem_neighborFinset] change (G.Adj w y ∧ s(w, y) ∉ c.edgeSet) ↔ y ≠ n2 ∧ y ≠ n1 ∧ G.Adj w y constructor · rintro ⟨hadj, hnot⟩ refine ⟨?_, ?_, hadj⟩ · intro rfl; apply hnot; rw [← hi, c.mem_edgeSet_iff]; right; rfl · intro rfl; apply hnot; rw [← hi, c.mem_edgeSet_iff]; left; rfl · rintro ⟨hne2, hne1, hadj⟩ refine ⟨hadj, ?_⟩ intro hmem have hy : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi, ← hy, c.mem_edgeSet_iff] at hmem rcases hmem with h1 | h2 · exact hne1 (by rw [← hy, h1]) · exact hne2 (by rw [← hy, h2]) rw [← SimpleGraph.card_neighborFinset_eq_degree, hnb, Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hn12.symm, hn2_mem⟩), Finset.card_erase_of_mem hn1_mem, SimpleGraph.card_neighborFinset_eq_degree, hreg w] /-- An embedded simple cycle of length `≥ 3` in a simple graph `H`. -/ structure CycleIn (H : SimpleGraph V) where len : ℕ len_ge_three : 3 ≤ len verts : Fin len ↪ V adj_next : ∀ i : Fin len, H.Adj (verts i) (verts (cNext (by omega : 0 < len) i)) /-- Vertex set of an embedded cycle `D : CycleIn H`. -/ def CycleIn.vertSet {H : SimpleGraph V} (D : CycleIn H) : Finset V := Finset.univ.image D.verts omit [Fintype V] in lemma CycleIn.card_vertSet {H : SimpleGraph V} (D : CycleIn H) : D.vertSet.card = D.len := by unfold CycleIn.vertSet rw [Finset.card_image_of_injective _ D.verts.injective, Finset.card_univ, Fintype.card_fin] /-- In a 2-regular graph `H`, every `CycleIn H` is closed under `H`-adjacency: the only two `H`-neighbors of `D i` are `D (cPrev i)` and `D (cNext i)`. -/ lemma CycleIn.neighborFinset_eq {H : SimpleGraph V} (hreg : H.IsRegularOfDegree 2) (D : CycleIn H) (i : Fin D.len) : H.neighborFinset (D.verts i) = {D.verts (cNext (by have := D.len_ge_three; omega) i), D.verts (cPrev (by have := D.len_ge_three; omega) i)} := by have hl3 := D.len_ge_three have hl : 0 < D.len := by omega have hne : D.verts (cNext hl i) ≠ D.verts (cPrev hl i) := fun h => cNext_ne_cPrev hl3 i (D.verts.injective h) have hsub : ({D.verts (cNext hl i), D.verts (cPrev hl i)} : Finset V) ⊆ H.neighborFinset (D.verts i) := by intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy rw [SimpleGraph.mem_neighborFinset] rcases hy with rfl | rfl · exact D.adj_next i · have h := D.adj_next (cPrev hl i); rw [cNext_cPrev] at h; exact h.symm have hcard : ({D.verts (cNext hl i), D.verts (cPrev hl i)} : Finset V).card = (H.neighborFinset (D.verts i)).card := by rw [Finset.card_pair hne, SimpleGraph.card_neighborFinset_eq_degree, hreg] exact (Finset.eq_of_subset_of_card_le hsub (le_of_eq hcard.symm)).symm /-- Every vertex `v₀` in a 2-regular graph `H` lies on an embedded cycle `D : CycleIn H`. -/ theorem exists_cycleIn_through {H : SimpleGraph V} (hreg : H.IsRegularOfDegree 2) (v₀ : V) : ∃ D : CycleIn H, v₀ ∈ D.vertSet := by -- Helper: every vertex v has 2 distinct neighbors, so given a ≠ v with H.Adj v a, -- there is a unique other neighbor b ≠ a with H.Adj v b! have hstep : ∀ x y : V, H.Adj x y → ∃ z : V, H.Adj y z ∧ z ≠ x := by intro x y hxy have hx_mem : x ∈ H.neighborFinset y := (SimpleGraph.mem_neighborFinset _ _ _).mpr hxy.symm have hcard : ((H.neighborFinset y).erase x).card = 1 := by rw [Finset.card_erase_of_mem hx_mem, SimpleGraph.card_neighborFinset_eq_degree, hreg y] obtain ⟨z, hz⟩ := Finset.card_pos.mp (by omega : 0 < ((H.neighborFinset y).erase x).card) rcases Finset.mem_erase.mp hz with ⟨hzx, hznb⟩ exact ⟨z, (SimpleGraph.mem_neighborFinset _ _ _).mp hznb, hzx⟩ -- Pick initial neighbor v₁ of v₀ have hv₀_pos : 0 < (H.neighborFinset v₀).card := by rw [SimpleGraph.card_neighborFinset_eq_degree, hreg v₀]; omega obtain ⟨v₁, hv₁_mem⟩ := Finset.card_pos.mp hv₀_pos have hv₀₁ : H.Adj v₀ v₁ := (SimpleGraph.mem_neighborFinset _ _ _).mp hv₁_mem -- Build infinite non-backtracking walk `walk : ℕ → V × V` storing `(w_k, w_{k+1})`! let nextPair : (p : { p : V × V // H.Adj p.1 p.2 }) → { p : V × V // H.Adj p.1 p.2 } := fun ⟨⟨x, y⟩, hxy⟩ => ⟨⟨y, (hstep x y hxy).choose⟩, (hstep x y hxy).choose_spec.1⟩ let seq : ℕ → { p : V × V // H.Adj p.1 p.2 } := fun k => nextPair^[k] ⟨⟨v₀, v₁⟩, hv₀₁⟩ let w : ℕ → V := fun k => (seq k).1.1 have hw0 : w 0 = v₀ := rfl have hw_snd : ∀ k, (seq k).1.2 = w (k + 1) := by intro k change (seq k).1.2 = (nextPair^[k + 1] ⟨⟨v₀, v₁⟩, hv₀₁⟩).1.1 rw [Function.iterate_succ_apply'] have hw_adj : ∀ k, H.Adj (w k) (w (k + 1)) := fun k => by rw [← hw_snd k]; exact (seq k).2 have hw_noback : ∀ k, w (k + 2) ≠ w k := by intro k have h1 : w (k + 2) = (hstep (seq k).1.1 (seq k).1.2 (seq k).2).choose := by rw [← hw_snd (k + 1)] change (nextPair^[k + 1] ⟨⟨v₀, v₁⟩, hv₀₁⟩).1.2 = _ rw [Function.iterate_succ_apply'] rw [h1] exact (hstep (seq k).1.1 (seq k).1.2 (seq k).2).choose_spec.2 -- By pigeonhole, ∃ a < b with w a = w b! Let b be minimal with ∃ a < b, w a = w b! have hex_rep : ∃ b : ℕ, ∃ a < b, w a = w b := by have hnot : ¬ Function.Injective w := fun hinj => by have := Finite.of_injective w hinj exact not_finite ℕ unfold Function.Injective at hnot push Not at hnot rcases hnot with ⟨i, j, hij, hne⟩ rcases lt_or_gt_of_ne hne with hlt | hgt · exact ⟨j, i, hlt, hij⟩ · exact ⟨i, j, hgt, hij.symm⟩ let b := Nat.find hex_rep have hb_spec : ∃ a < b, w a = w b := Nat.find_spec hex_rep have hb_min : ∀ b' < b, ∀ a' < b', w a' ≠ w b' := fun b' hb' a' ha' heq => Nat.find_min hex_rep hb' ⟨a', ha', heq⟩ obtain ⟨a, hab, hwab⟩ := hb_spec -- Prove `a = 0`! Because if `a ≥ 1`, `w a` would have 3 distinct neighbors `w(a-1), w(a+1), w(b-1)`! have ha0 : a = 0 := by by_contra ha_pos have ha1 : 1 ≤ a := by omega have hlen2 : a + 2 < b := by have h1 : b ≠ a + 1 := fun h => by have hadj := hw_adj a rw [← h, ← hwab] at hadj exact H.loopless.irrefl (w a) hadj have h2 : b ≠ a + 2 := fun h => hw_noback a (by rw [← h, ← hwab]) omega -- All 3 of w(a-1), w(a+1), w(b-1) are adjacent to w a and pairwise distinct! have hnb1 : w (a - 1) ∈ H.neighborFinset (w a) := by rw [SimpleGraph.mem_neighborFinset] have h := hw_adj (a - 1); rw [show a - 1 + 1 = a by omega] at h; exact h.symm have hnb2 : w (a + 1) ∈ H.neighborFinset (w a) := (SimpleGraph.mem_neighborFinset _ _ _).mpr (hw_adj a) have hnb3 : w (b - 1) ∈ H.neighborFinset (w a) := by rw [SimpleGraph.mem_neighborFinset, hwab] have h := hw_adj (b - 1); rw [show b - 1 + 1 = b by omega] at h; exact h.symm have hne12 : w (a - 1) ≠ w (a + 1) := hb_min (a + 1) (by omega) (a - 1) (by omega) have hne13 : w (a - 1) ≠ w (b - 1) := hb_min (b - 1) (by omega) (a - 1) (by omega) have hne23 : w (a + 1) ≠ w (b - 1) := hb_min (b - 1) (by omega) (a + 1) (by omega) have hsub : ({w (a - 1), w (a + 1), w (b - 1)} : Finset V) ⊆ H.neighborFinset (w a) := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl | rfl <;> assumption have h3le : 3 ≤ (H.neighborFinset (w a)).card := by calc 3 = ({w (a - 1), w (a + 1), w (b - 1)} : Finset V).card := by rw [Finset.card_insert_of_notMem, Finset.card_pair hne23]; simp [hne12, hne13] _ ≤ (H.neighborFinset (w a)).card := Finset.card_le_card hsub rw [SimpleGraph.card_neighborFinset_eq_degree, hreg (w a)] at h3le omega subst ha0 have hb3 : 3 ≤ b := by have h1 : b ≠ 1 := fun h => by have hadj := hw_adj 0 rw [zero_add, ← h, ← hwab] at hadj exact H.loopless.irrefl (w 0) hadj have h2 : b ≠ 2 := fun h => hw_noback 0 (by rw [zero_add, ← h, ← hwab]) omega have hw_inj : Function.Injective (fun i : Fin b => w i.1) := by intro i j hij by_contra hne have hne' : i.1 ≠ j.1 := fun h => hne (Fin.ext h) rcases lt_or_gt_of_ne hne' with hlt | hgt · exact hb_min j.1 j.2 i.1 hlt hij · exact hb_min i.1 i.2 j.1 hgt hij.symm let D : CycleIn H := { len := b len_ge_three := hb3 verts := ⟨fun i => w i.1, hw_inj⟩ adj_next := fun i => by dsimp by_cases hlt : i.1 + 1 < b · have hcn : (cNext (by omega : 0 < b) i).1 = i.1 + 1 := by rw [cNext_val]; simp [hlt] rw [hcn]; exact hw_adj i.1 · have hi : i.1 = b - 1 := by omega have hcn : (cNext (by omega : 0 < b) i).1 = 0 := by rw [cNext_val]; simp [hlt] rw [hcn, hwab, hi] have h := hw_adj (b - 1); rwa [show b - 1 + 1 = b by omega] at h } refine ⟨D, Finset.mem_image.mpr ⟨⟨0, by omega⟩, Finset.mem_univ _, hw0⟩⟩ /-- **2-Regular Cycle Decomposition Theorem**: Every 2-regular finite simple graph `H` decomposes into a list `𝒟 : List (CycleIn H)` of pairwise vertex-disjoint cycles partitioning `V`! -/ theorem exists_cycle_decomp_of_two_regular {H : SimpleGraph V} (hreg : H.IsRegularOfDegree 2) : ∃ 𝒟 : List (CycleIn H), 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet) ∧ (∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) := by -- Strong induction on the number of uncovered vertices! suffices hgen : ∀ (k : ℕ) (S : Finset V), (Finset.univ \ S).card = k → (∀ x ∈ S, ∀ y, H.Adj x y → y ∈ S) → ∃ 𝒟 : List (CycleIn H), 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet) ∧ (∀ D ∈ 𝒟, Disjoint D.vertSet S) ∧ (∀ v ∉ S, ∃ D ∈ 𝒟, v ∈ D.vertSet) by obtain ⟨𝒟, hpw, _, hcov⟩ := hgen (Fintype.card V) ∅ (by simp) (by simp) exact ⟨𝒟, hpw, fun v => hcov v (Finset.notMem_empty v)⟩ intro k induction k using Nat.strong_induction_on with | h k ih => intro S hcard hclosed by_cases hS : S = Finset.univ · exact ⟨[], by simp, by simp, fun v hv => absurd (hS ▸ Finset.mem_univ v) hv⟩ · have hne : (Finset.univ \ S).Nonempty := by rw [Finset.nonempty_iff_ne_empty] intro hemp apply hS ext v; simp only [Finset.mem_univ, iff_true] by_contra hv have : v ∈ Finset.univ \ S := Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, hv⟩ rw [hemp] at this; exact Finset.notMem_empty v this obtain ⟨v₀, hv₀_mem⟩ := hne have hv₀S : v₀ ∉ S := (Finset.mem_sdiff.mp hv₀_mem).2 obtain ⟨D, hv₀D⟩ := exists_cycleIn_through hreg v₀ -- Prove D.vertSet is disjoint from S (since S is H-closed and D is connected)! have hD_disj : Disjoint D.vertSet S := by rw [Finset.disjoint_left] intro x hxD hxS -- Walk around D from x back to v₀: every vertex of D would lie in S! rcases Finset.mem_image.mp hxD with ⟨ix, _, rfl⟩ rcases Finset.mem_image.mp hv₀D with ⟨i₀, _, hv₀_eq⟩ have hl : 0 < D.len := by have := D.len_ge_three; omega have hall : ∀ m : ℕ, D.verts (cShift hl m ix) ∈ S := by intro m induction m with | zero => rw [cShift_zero]; exact hxS | succ m ihm => rw [cShift_succ]; exact hclosed _ ihm _ (D.adj_next (cShift hl m ix)) have hreach : D.verts i₀ ∈ S := by let m := (i₀.1 + D.len - ix.1) % D.len have hm : cShift hl m ix = i₀ := by ext; dsimp [cShift, m] have h1 : (ix.1 + (i₀.1 + D.len - ix.1) % D.len) % D.len = (ix.1 + (i₀.1 + D.len - ix.1)) % D.len := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [h1] have h2 : ix.1 + (i₀.1 + D.len - ix.1) = i₀.1 + D.len := by omega rw [h2, Nat.add_mod_right, Nat.mod_eq_of_lt i₀.2] rw [← hm]; exact hall m exact hv₀S (hv₀_eq ▸ hreach) -- S' = S ∪ D.vertSet is also H-closed and strictly larger! let S' := S ∪ D.vertSet have hS'_closed : ∀ x ∈ S', ∀ y, H.Adj x y → y ∈ S' := by intro x hx y hxy rcases Finset.mem_union.mp hx with hxS | hxD · exact Finset.mem_union_left _ (hclosed x hxS y hxy) · apply Finset.mem_union_right rcases Finset.mem_image.mp hxD with ⟨ix, _, rfl⟩ have hy_nb : y ∈ H.neighborFinset (D.verts ix) := (SimpleGraph.mem_neighborFinset _ _ _).mpr hxy rw [D.neighborFinset_eq hreg ix] at hy_nb simp only [Finset.mem_insert, Finset.mem_singleton] at hy_nb rcases hy_nb with rfl | rfl <;> exact Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩ have hlt : (Finset.univ \ S').card < k := by rw [← hcard] apply Finset.card_lt_card rw [Finset.ssubset_iff_subset_ne] refine ⟨fun x hx => ?_, fun heq => ?_⟩ · rcases Finset.mem_sdiff.mp hx with ⟨hu, hns⟩ exact Finset.mem_sdiff.mpr ⟨hu, fun hs => hns (Finset.mem_union_left _ hs)⟩ · have hv₀_in : v₀ ∈ Finset.univ \ S' := heq ▸ hv₀_mem exact (Finset.mem_sdiff.mp hv₀_in).2 (Finset.mem_union_right _ hv₀D) obtain ⟨𝒟', hpw', hdisj', hcov'⟩ := ih _ hlt S' rfl hS'_closed refine ⟨D :: 𝒟', ?_, ?_, ?_⟩ · rw [List.pairwise_cons] refine ⟨fun D' hD' => (Disjoint.mono_right (Finset.subset_union_right) (hdisj' D' hD')).symm, hpw'⟩ · intro D' hD' rcases List.mem_cons.mp hD' with rfl | hD'' · exact hD_disj · exact Disjoint.mono_right Finset.subset_union_left (hdisj' D' hD'') · intro v hvS by_cases hvD : v ∈ D.vertSet · exact ⟨D, List.mem_cons_self, hvD⟩ · obtain ⟨D', hD', hvD'⟩ := hcov' v (fun h => by rcases Finset.mem_union.mp h with h1 | h2 · exact hvS h1 · exact hvD h2) exact ⟨D', List.mem_cons_of_mem _ hD', hvD'⟩ /-- Sum of cycle lengths in a cycle decomposition equals `Fintype.card V`. -/ lemma cycle_decomp_sum_len {H : SimpleGraph V} {𝒟 : List (CycleIn H)} (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) : (𝒟.map CycleIn.len).sum = Fintype.card V := by have hsum_card : ∀ (L : List (CycleIn H)), L.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet) → (L.map CycleIn.len).sum = (L.foldr (fun (D : CycleIn H) acc => D.vertSet ∪ acc) ∅).card := by intro L induction L with | nil => intro _; simp | cons D tl ih => intro hpw' rw [List.pairwise_cons] at hpw' simp only [List.map_cons, List.sum_cons] have hdisj : Disjoint D.vertSet (tl.foldr (fun (D' : CycleIn H) acc => D'.vertSet ∪ acc) ∅) := by rw [Finset.disjoint_left] intro x hxD hxAcc obtain ⟨D', hD', hxD'⟩ := (mem_foldr_union tl CycleIn.vertSet x).mp hxAcc exact Finset.disjoint_left.mp (hpw'.1 D' hD') hxD hxD' change D.len + (tl.map CycleIn.len).sum = (D.vertSet ∪ tl.foldr (fun (D' : CycleIn H) acc => D'.vertSet ∪ acc) ∅).card rw [Finset.card_union_of_disjoint hdisj, D.card_vertSet, ih hpw'.2] rw [hsum_card 𝒟 hpw] have huniv : 𝒟.foldr (fun D acc => D.vertSet ∪ acc) ∅ = Finset.univ := by ext v; simp only [Finset.mem_univ, iff_true] exact (mem_foldr_union 𝒟 CycleIn.vertSet v).mpr (hcov v) rw [huniv, Finset.card_univ] /-- Adding a matching `M : Finset (Sym2 V)` (edges of `chordGraph c` that are pairwise vertex-disjoint) to `c.edgeSet` gives a spanning subgraph `cycleAddMatching c M ≤ G`. -/ def cycleAddMatching {G : SimpleGraph V} (c : DirHamCycle G) (M : Finset (Sym2 V)) : SimpleGraph V where Adj x y := s(x, y) ∈ c.edgeSet ∨ (s(x, y) ∈ M ∧ (chordGraph c).Adj x y) symm := ⟨fun _ _ h => by rcases h with h | ⟨hm, ha⟩ · left; rwa [Sym2.eq_swap] · right; exact ⟨by rwa [Sym2.eq_swap], ha.symm⟩⟩ loopless := ⟨fun x h => by rcases h with h | ⟨_, ha⟩ · exact G.loopless.irrefl x (c.adj_of_mem_edgeSet h) · exact G.loopless.irrefl x ha.1⟩ lemma cycleAddMatching_le {G : SimpleGraph V} (c : DirHamCycle G) (M : Finset (Sym2 V)) : cycleAddMatching c M ≤ G := fun _ _ h => by rcases h with h | ⟨_, ha⟩ · exact c.adj_of_mem_edgeSet h · exact ha.1 def cycleAddMatchingCycle {G : SimpleGraph V} (c : DirHamCycle G) (M : Finset (Sym2 V)) : DirHamCycle (cycleAddMatching c M) where card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next i := Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) /-- A matching `M` represented as an involutive partial pairing: `pair : V → V` with `pair (pair x) = x`, `pair x = x` on uncovered vertices, and `(chordGraph c).Adj x (pair x)` on covered vertices! This makes degree-3 proofs 3 lines long! -/ structure ChordMatching {G : SimpleGraph V} (c : DirHamCycle G) where covered : Finset V partner : V → V partner_mem : ∀ x ∈ covered, partner x ∈ covered partner_invol : ∀ x ∈ covered, partner (partner x) = x partner_adj : ∀ x ∈ covered, (chordGraph c).Adj x (partner x) /-- Subgraph `C ∪ M` for a `ChordMatching c`. -/ def ChordMatching.toGraph {G : SimpleGraph V} {c : DirHamCycle G} (M : ChordMatching c) : SimpleGraph V where Adj x y := s(x, y) ∈ c.edgeSet ∨ (x ∈ M.covered ∧ y = M.partner x) symm := ⟨fun x y h => by rcases h with h | ⟨hx, rfl⟩ · left; rwa [Sym2.eq_swap] · right; exact ⟨M.partner_mem x hx, (M.partner_invol x hx).symm⟩⟩ loopless := ⟨fun x h => by rcases h with h | ⟨hx, heq⟩ · exact G.loopless.irrefl x (c.adj_of_mem_edgeSet h) · have h1 := M.partner_adj x hx rw [← heq] at h1 exact (chordGraph c).loopless.irrefl x h1⟩ lemma ChordMatching.toGraph_le {G : SimpleGraph V} {c : DirHamCycle G} (M : ChordMatching c) : M.toGraph ≤ G := fun _ _ h => by rcases h with h | ⟨hx, rfl⟩ · exact c.adj_of_mem_edgeSet h · exact (M.partner_adj _ hx).1 def ChordMatching.toCycle {G : SimpleGraph V} {c : DirHamCycle G} (M : ChordMatching c) : DirHamCycle M.toGraph where card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next i := Or.inl (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) /-- Exact degree in `M.toGraph`: `3` if `w ∈ M.covered`, `2` if `w ∉ M.covered`! -/ lemma ChordMatching.degree_eq {G : SimpleGraph V} {c : DirHamCycle G} (M : ChordMatching c) (w : V) : M.toGraph.degree w = if w ∈ M.covered then 3 else 2 := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega let i := c.toEquiv.symm w have hi : c.toEquiv i = w := by simp [i] let n1 := c.toEquiv (cNext hn i) let n2 := c.toEquiv (cPrev hn i) have hn12 : n1 ≠ n2 := fun h => cNext_ne_cPrev hn3 i (c.toEquiv.injective h) rw [← SimpleGraph.card_neighborFinset_eq_degree] by_cases hw : w ∈ M.covered · rw [if_pos hw] have hnb : M.toGraph.neighborFinset w = {n1, n2, M.partner w} := by ext y rw [SimpleGraph.mem_neighborFinset] simp only [Finset.mem_insert, Finset.mem_singleton, ChordMatching.toGraph] constructor · rintro (hc | ⟨_, rfl⟩) · have hy : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi, ← hy, c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · left; rw [← hy, h1] · right; left; rw [← hy, h2] · right; right; rfl · rintro (rfl | rfl | rfl) · left; rw [← hi, c.mem_edgeSet_iff]; left; rfl · left; rw [← hi, c.mem_edgeSet_iff]; right; rfl · right; exact ⟨hw, rfl⟩ have hne1 : n1 ≠ M.partner w := by intro h; apply (M.partner_adj w hw).2 rw [← h, ← hi, c.mem_edgeSet_iff]; left; rfl have hne2 : n2 ≠ M.partner w := by intro h; apply (M.partner_adj w hw).2 rw [← h, ← hi, c.mem_edgeSet_iff]; right; rfl rw [hnb, Finset.card_insert_of_notMem, Finset.card_pair hne2] simp [hn12, hne1] · rw [if_neg hw] have hnb : M.toGraph.neighborFinset w = {n1, n2} := by ext y rw [SimpleGraph.mem_neighborFinset] simp only [Finset.mem_insert, Finset.mem_singleton, ChordMatching.toGraph] constructor · rintro (hc | ⟨hw', _⟩) · have hy : c.toEquiv (c.toEquiv.symm y) = y := by simp rw [← hi, ← hy, c.mem_edgeSet_iff] at hc rcases hc with h1 | h2 · left; rw [← hy, h1] · right; rw [← hy, h2] · exact absurd hw' hw · rintro (rfl | rfl) · left; rw [← hi, c.mem_edgeSet_iff]; left; rfl · left; rw [← hi, c.mem_edgeSet_iff]; right; rfl rw [hnb, Finset.card_pair hn12] /-- Matching helper on an EVEN cycle `D` (`parity = false` gives `0↔1, 2↔3, ...`; `parity = true` gives `1↔2, 3↔4, ..., (2m-1)↔0`). -/ noncomputable def evenCyclePartner {H : SimpleGraph V} (D : CycleIn H) (_heven : Even D.len) (shift : Bool) (x : V) : V := if h : x ∈ D.vertSet then let i : Fin D.len := (Finset.mem_image.mp h).choose have hl : 0 < D.len := by have := D.len_ge_three; omega if (i.1 % 2 == 0) == !shift then D.verts (cNext hl i) else D.verts (cPrev hl i) else x omit [Fintype V] in lemma evenCyclePartner_props {H : SimpleGraph V} (D : CycleIn H) (heven : Even D.len) (shift : Bool) : (∀ x ∈ D.vertSet, evenCyclePartner D heven shift x ∈ D.vertSet) ∧ (∀ x ∈ D.vertSet, evenCyclePartner D heven shift (evenCyclePartner D heven shift x) = x) ∧ (∀ x ∈ D.vertSet, H.Adj x (evenCyclePartner D heven shift x)) ∧ (∀ x ∈ D.vertSet, evenCyclePartner D heven false x ≠ evenCyclePartner D heven true x) := by have hl3 := D.len_ge_three have hl : 0 < D.len := by omega obtain ⟨m, hm⟩ := heven have hget : ∀ (i : Fin D.len), evenCyclePartner D ⟨m, hm⟩ shift (D.verts i) = if (i.1 % 2 == 0) == !shift then D.verts (cNext hl i) else D.verts (cPrev hl i) := by intro i have hmem : D.verts i ∈ D.vertSet := Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩ dsimp [evenCyclePartner]; rw [dif_pos hmem] have hi_eq : (Finset.mem_image.mp hmem).choose = i := D.verts.injective (Finset.mem_image.mp hmem).choose_spec.2 rw [hi_eq] have hnext_par : ∀ i : Fin D.len, ((cNext hl i).1 % 2 == 0) = !(i.1 % 2 == 0) := by intro i; rw [cNext_val] by_cases h : i.1 + 1 < D.len · rw [if_pos h] rcases Nat.mod_two_eq_zero_or_one i.1 with h0 | h1 · have h' : (i.1 + 1) % 2 = 1 := by omega simp [h0, h'] · have h' : (i.1 + 1) % 2 = 0 := by omega simp [h1, h'] · rw [if_neg h] have hodd : i.1 % 2 = 1 := by omega simp [hodd] have hprev_par : ∀ i : Fin D.len, ((cPrev hl i).1 % 2 == 0) = !(i.1 % 2 == 0) := by intro i have h := hnext_par (cPrev hl i) rw [cNext_cPrev] at h cases h1 : ((cPrev hl i).1 % 2 == 0) <;> cases h2 : (i.1 % 2 == 0) <;> simp_all refine ⟨?_, ?_, ?_, ?_⟩ · intro x hx rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rw [hget i]; split_ifs <;> exact Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩ · intro x hx rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rw [hget i] rcases Bool.eq_false_or_eq_true (i.1 % 2 == 0) with h0 | h0 <;> cases shift all_goals simp [h0, hget, hnext_par, hprev_par, cPrev_cNext, cNext_cPrev] · intro x hx rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rw [hget i] split_ifs · exact D.adj_next i · have h := D.adj_next (cPrev hl i); rw [cNext_cPrev] at h; exact h.symm · intro x hx rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ have hf : evenCyclePartner D ⟨m, hm⟩ false (D.verts i) = if (i.1 % 2 == 0) == true then D.verts (cNext hl i) else D.verts (cPrev hl i) := by have hmem : D.verts i ∈ D.vertSet := Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩ dsimp [evenCyclePartner]; rw [dif_pos hmem] have hi_eq : (Finset.mem_image.mp hmem).choose = i := D.verts.injective (Finset.mem_image.mp hmem).choose_spec.2 rw [hi_eq]; rfl have ht : evenCyclePartner D ⟨m, hm⟩ true (D.verts i) = if (i.1 % 2 == 0) == false then D.verts (cNext hl i) else D.verts (cPrev hl i) := by have hmem : D.verts i ∈ D.vertSet := Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩ dsimp [evenCyclePartner]; rw [dif_pos hmem] have hi_eq : (Finset.mem_image.mp hmem).choose = i := D.verts.injective (Finset.mem_image.mp hmem).choose_spec.2 rw [hi_eq]; rfl rw [hf, ht] cases hi2 : (i.1 % 2 == 0) · simp only [↓reduceIte, beq_self_eq_true] exact fun h => cNext_ne_cPrev hl3 i (D.verts.injective h).symm · simp only [beq_self_eq_true, ↓reduceIte] exact fun h => cNext_ne_cPrev hl3 i (D.verts.injective h) /-- Matching helper on an ODD cycle `D` minus a chosen vertex `u = D i₀`: pairs `i₀ + 1 ↔ i₀ + 2`, `i₀ + 3 ↔ i₀ + 4`, ..., `i₀ + (len - 2) ↔ i₀ + (len - 1)`! -/ noncomputable def oddCycleDeletePartner {H : SimpleGraph V} (D : CycleIn H) (_hodd : Odd D.len) (i₀ : Fin D.len) (x : V) : V := if h : x ∈ D.vertSet then let i : Fin D.len := (Finset.mem_image.mp h).choose have hl : 0 < D.len := by have := D.len_ge_three; omega let d := (i.1 + D.len - i₀.1) % D.len if d = 0 then x else if d % 2 = 1 then D.verts (cNext hl i) else D.verts (cPrev hl i) else x omit [Fintype V] in lemma oddCycleDeletePartner_props {H : SimpleGraph V} (D : CycleIn H) (hodd : Odd D.len) (i₀ : Fin D.len) : (∀ x ∈ D.vertSet.erase (D.verts i₀), oddCycleDeletePartner D hodd i₀ x ∈ D.vertSet.erase (D.verts i₀)) ∧ (∀ x ∈ D.vertSet.erase (D.verts i₀), oddCycleDeletePartner D hodd i₀ (oddCycleDeletePartner D hodd i₀ x) = x) ∧ (∀ x ∈ D.vertSet.erase (D.verts i₀), H.Adj x (oddCycleDeletePartner D hodd i₀ x)) := by have hl3 := D.len_ge_three have hl : 0 < D.len := by omega obtain ⟨m, hm⟩ := hodd let dist : Fin D.len → ℕ := fun i => (i.1 + D.len - i₀.1) % D.len have hdist_lt : ∀ i, dist i < D.len := fun i => Nat.mod_lt _ hl have hdist_zero : ∀ i, dist i = 0 ↔ i = i₀ := by intro i; dsimp [dist] constructor · intro h by_cases hle : i₀.1 ≤ i.1 · have h1 : i.1 + D.len - i₀.1 = (i.1 - i₀.1) + D.len := by omega rw [h1, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] at h exact Fin.ext (by omega) · rw [Nat.mod_eq_of_lt (by omega)] at h; omega · intro heq; subst heq have : i.1 + D.len - i.1 = D.len := by omega rw [this, Nat.mod_self] have hdist_next : ∀ i, dist (cNext hl i) = (dist i + 1) % D.len := by intro i; dsimp [dist]; rw [cNext_val] by_cases h : i.1 + 1 < D.len · rw [if_pos h] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] congr 1; omega · rw [if_neg h] have hi : i.1 = D.len - 1 := by omega rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] have h1 : 0 + D.len - i₀.1 = D.len - i₀.1 := by omega have h2 : i.1 + D.len - i₀.1 + 1 = (D.len - i₀.1) + D.len := by omega rw [h1, h2, Nat.add_mod_right] have hdist_prev : ∀ i, dist i ≠ 0 → dist (cPrev hl i) + 1 = dist i := by intro i hne have h := hdist_next (cPrev hl i) rw [cNext_cPrev] at h have hlt := hdist_lt (cPrev hl i) by_cases h1 : dist (cPrev hl i) + 1 < D.len · rw [Nat.mod_eq_of_lt h1] at h; exact h.symm · have : dist (cPrev hl i) + 1 = D.len := by omega rw [this, Nat.mod_self] at h; exact absurd h hne have hget : ∀ i : Fin D.len, oddCycleDeletePartner D ⟨m, hm⟩ i₀ (D.verts i) = if dist i = 0 then D.verts i else if dist i % 2 = 1 then D.verts (cNext hl i) else D.verts (cPrev hl i) := by intro i have hmem : D.verts i ∈ D.vertSet := Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩ dsimp [oddCycleDeletePartner]; rw [dif_pos hmem] have hi_eq : (Finset.mem_image.mp hmem).choose = i := D.verts.injective (Finset.mem_image.mp hmem).choose_spec.2 rw [hi_eq] refine ⟨?_, ?_, ?_⟩ · intro x hx rcases Finset.mem_erase.mp hx with ⟨hne, hxD⟩ rcases Finset.mem_image.mp hxD with ⟨i, _, rfl⟩ have hd0 : dist i ≠ 0 := fun h => hne (congrArg D.verts ((hdist_zero i).mp h)) rw [hget i, if_neg hd0] split_ifs with hd1 · refine Finset.mem_erase.mpr ⟨?_, Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩⟩ intro heq have hd_next : dist (cNext hl i) = 0 := (hdist_zero _).mpr (D.verts.injective heq) rw [hdist_next] at hd_next have hlt := hdist_lt i have : dist i + 1 = D.len := by by_contra hlt2 rw [Nat.mod_eq_of_lt (by omega)] at hd_next; omega omega · refine Finset.mem_erase.mpr ⟨?_, Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩⟩ intro heq have hd_prev : dist (cPrev hl i) = 0 := (hdist_zero _).mpr (D.verts.injective heq) have h1 := hdist_prev i hd0 rw [hd_prev] at h1; omega · intro x hx rcases Finset.mem_erase.mp hx with ⟨hne, hxD⟩ rcases Finset.mem_image.mp hxD with ⟨i, _, rfl⟩ have hd0 : dist i ≠ 0 := fun h => hne (congrArg D.verts ((hdist_zero i).mp h)) rw [hget i, if_neg hd0] split_ifs with hd1 · rw [hget (cNext hl i)] have hlt := hdist_lt i have hlt2 : dist i + 1 < D.len := by omega have hd_next : dist (cNext hl i) = dist i + 1 := by rw [hdist_next, Nat.mod_eq_of_lt hlt2] rw [if_neg (by omega), if_neg (by omega), cPrev_cNext] · rw [hget (cPrev hl i)] have h1 := hdist_prev i hd0 rw [if_neg (by omega), if_pos (by omega), cNext_cPrev] · intro x hx rcases Finset.mem_erase.mp hx with ⟨hne, hxD⟩ rcases Finset.mem_image.mp hxD with ⟨i, _, rfl⟩ have hd0 : dist i ≠ 0 := fun h => hne (congrArg D.verts ((hdist_zero i).mp h)) rw [hget i, if_neg hd0] split_ifs · exact D.adj_next i · have h := D.adj_next (cPrev hl i); rw [cNext_cPrev] at h; exact h.symm /-- Build a global `ChordMatching c` by combining matchings across a cycle decomposition `𝒟` of `chordGraph c` (covering all even cycles and deleting at most one vertex from each odd cycle). -/ noncomputable def buildChordMatching {G : SimpleGraph V} (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (covOf : CycleIn (chordGraph c) → Finset V) (partOf : CycleIn (chordGraph c) → V → V) (hsub : ∀ D ∈ 𝒟, covOf D ⊆ D.vertSet) (hmem : ∀ D ∈ 𝒟, ∀ x ∈ covOf D, partOf D x ∈ covOf D) (hinvol : ∀ D ∈ 𝒟, ∀ x ∈ covOf D, partOf D (partOf D x) = x) (hadj : ∀ D ∈ 𝒟, ∀ x ∈ covOf D, (chordGraph c).Adj x (partOf D x)) : ChordMatching c := by let cov : Finset V := 𝒟.foldr (fun D acc => covOf D ∪ acc) ∅ have hmem_cov : ∀ x : V, x ∈ cov ↔ ∃ D ∈ 𝒟, x ∈ covOf D := by intro x clear hpw hsub hmem hinvol hadj induction 𝒟 with | nil => simp [cov] | cons D tl ih => simp only [cov, List.foldr_cons, Finset.mem_union, List.mem_cons, exists_eq_or_imp] exact or_congr_right ih have huniq : ∀ D₁ ∈ 𝒟, ∀ D₂ ∈ 𝒟, ∀ x, x ∈ covOf D₁ → x ∈ covOf D₂ → D₁ = D₂ := by intro D₁ hD₁ D₂ hD₂ x hx1 hx2 by_contra hne have hdisj : Disjoint D₁.vertSet D₂.vertSet := by clear hmem_cov cov hmem hinvol hadj induction 𝒟 with | nil => cases hD₁ | cons A rest ih => rw [List.pairwise_cons] at hpw rcases List.mem_cons.mp hD₁ with rfl | h1 <;> rcases List.mem_cons.mp hD₂ with rfl | h2 · exact absurd rfl hne · exact hpw.1 D₂ h2 · exact (hpw.1 D₁ h1).symm · exact ih hpw.2 (fun D hD => hsub D (List.mem_cons_of_mem _ hD)) h1 h2 exact Finset.disjoint_left.mp hdisj (hsub D₁ hD₁ hx1) (hsub D₂ hD₂ hx2) let part : V → V := fun x => if h : x ∈ cov then partOf ((hmem_cov x).mp h).choose x else x have hpart_eq : ∀ D ∈ 𝒟, ∀ x ∈ covOf D, part x = partOf D x := by intro D hD x hx have hxc : x ∈ cov := (hmem_cov x).mpr ⟨D, hD, hx⟩ dsimp [part]; rw [dif_pos hxc] have hspec := ((hmem_cov x).mp hxc).choose_spec rw [huniq _ hspec.1 D hD x hspec.2 hx] exact { covered := cov partner := part partner_mem := fun x hx => by obtain ⟨D, hD, hxD⟩ := (hmem_cov x).mp hx rw [hpart_eq D hD x hxD] exact (hmem_cov _).mpr ⟨D, hD, hmem D hD x hxD⟩ partner_invol := fun x hx => by obtain ⟨D, hD, hxD⟩ := (hmem_cov x).mp hx rw [hpart_eq D hD x hxD, hpart_eq D hD _ (hmem D hD x hxD)] exact hinvol D hD x hxD partner_adj := fun x hx => by obtain ⟨D, hD, hxD⟩ := (hmem_cov x).mp hx rw [hpart_eq D hD x hxD] exact hadj D hD x hxD } /-- **Theorem 4a (Bipartite Chord-2-Factor Multiplicity Theorem — Strictly Generalizing Sheehan 1975)**: Let `G` be a 4-regular simple graph with Hamiltonian cycle `c`. If every cycle of the chord 2-factor `chordGraph c` has **EVEN length** (which holds automatically for every 4-regular bipartite Hamiltonian graph!), then `G` has **AT LEAST 5 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_five_of_even_chord_cycles {G : SimpleGraph V} (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) (heven : ∀ D ∈ 𝒟, Even D.len) : 5 ≤ (hamCycles G).card := by let partFn : Bool → CycleIn (chordGraph c) → V → V := fun sh D x => if h : Even D.len then evenCyclePartner D h sh x else x let mkM : Bool → ChordMatching c := fun sh => buildChordMatching c 𝒟 hpw CycleIn.vertSet (partFn sh) (fun _ _ => Finset.Subset.refl _) (fun D hD x hx => by dsimp [partFn]; rw [dif_pos (heven D hD)] exact (evenCyclePartner_props D (heven D hD) sh).1 x hx) (fun D hD x hx => by dsimp [partFn]; rw [dif_pos (heven D hD), dif_pos (heven D hD)] exact (evenCyclePartner_props D (heven D hD) sh).2.1 x hx) (fun D hD x hx => by dsimp [partFn]; rw [dif_pos (heven D hD)] exact (evenCyclePartner_props D (heven D hD) sh).2.2.1 x hx) let M₀ := mkM false let M₁ := mkM true have hcov_univ : ∀ sh, (mkM sh).covered = Finset.univ := by intro sh; ext v; simp only [Finset.mem_univ, iff_true] exact (mem_foldr_union 𝒟 CycleIn.vertSet v).mpr (hcov v) have hge3_0 : 3 ≤ (hamCycles M₀.toGraph).card := card_hamCycles_ge_three_of_all_odd_deg M₀.toGraph (fun w => by rw [M₀.degree_eq, if_pos (by rw [hcov_univ false]; exact Finset.mem_univ w)]; exact ⟨1, rfl⟩) M₀.toCycle have hge3_1 : 3 ≤ (hamCycles M₁.toGraph).card := card_hamCycles_ge_three_of_all_odd_deg M₁.toGraph (fun w => by rw [M₁.degree_eq, if_pos (by rw [hcov_univ true]; exact Finset.mem_univ w)]; exact ⟨1, rfl⟩) M₁.toCycle -- M₀ and M₁ have DISJOINT chord edges (for every v, M₀.partner v ≠ M₁.partner v)! have hpart_ne : ∀ v : V, M₀.partner v ≠ M₁.partner v := by intro v obtain ⟨D, hD, hvD⟩ := hcov v have huniq : ∀ D' ∈ 𝒟, v ∈ D'.vertSet → D' = D := by intro D' hD' hvD' by_contra hne have hdisj : Disjoint D'.vertSet D.vertSet := by clear hcov heven partFn mkM M₀ M₁ hcov_univ hge3_0 hge3_1 induction 𝒟 with | nil => cases hD' | cons A rest ih => rw [List.pairwise_cons] at hpw rcases List.mem_cons.mp hD' with rfl | h1 <;> rcases List.mem_cons.mp hD with rfl | h2 · exact absurd rfl hne · exact hpw.1 D h2 · exact (hpw.1 D' h1).symm · exact ih hpw.2 h2 h1 exact Finset.disjoint_left.mp hdisj hvD' hvD have hpeq : ∀ sh, (mkM sh).partner v = evenCyclePartner D (heven D hD) sh v := by intro sh have hvc : v ∈ 𝒟.foldr (fun D acc => D.vertSet ∪ acc) ∅ := (mem_foldr_union 𝒟 CycleIn.vertSet v).mpr ⟨D, hD, hvD⟩ dsimp [mkM, buildChordMatching] rw [dif_pos hvc] have hch := ((mem_foldr_union 𝒟 CycleIn.vertSet v).mp hvc).choose_spec have hDeq := huniq _ hch.1 hch.2 rw [hDeq]; dsimp [partFn]; rw [dif_pos (heven D hD)] rw [hpeq false, hpeq true] exact (evenCyclePartner_props D (heven D hD) false).2.2.2 v hvD -- Therefore S₀ = (hamCycles M₀.toGraph).erase c.edgeSet and S₁ = (hamCycles M₁.toGraph).erase c.edgeSet are DISJOINT! let S₀ := (hamCycles M₀.toGraph).erase c.edgeSet let S₁ := (hamCycles M₁.toGraph).erase c.edgeSet have hdisj_S : Disjoint S₀ S₁ := by rw [Finset.disjoint_left] intro E hE0 hE1 rcases Finset.mem_erase.mp hE0 with ⟨hne, h0⟩ have h1 := (Finset.mem_erase.mp hE1).2 obtain ⟨c₀, rfl⟩ := mem_hamCycles.mp h0 obtain ⟨c₁, hc₁⟩ := mem_hamCycles.mp h1 obtain ⟨f, hfE, hfc⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem ⟨c₀, rfl⟩ ⟨M₀.toCycle, rfl⟩ hne rcases Sym2.mk_surjective f with ⟨⟨x, y⟩, rfl⟩ have hadj0 : M₀.toGraph.Adj x y := c₀.adj_of_mem_edgeSet hfE have hadj1 : M₁.toGraph.Adj x y := c₁.adj_of_mem_edgeSet (hc₁ ▸ hfE) rcases hadj0 with hc | ⟨_, hxy0⟩ · exact hfc hc · rcases hadj1 with hc | ⟨_, hxy1⟩ · exact hfc hc · exact hpart_ne x (hxy0.symm.trans hxy1) have hc0_mem : c.edgeSet ∈ hamCycles M₀.toGraph := M₀.toCycle.edgeSet_mem_hamCycles have hc1_mem : c.edgeSet ∈ hamCycles M₁.toGraph := M₁.toCycle.edgeSet_mem_hamCycles have hS0_ge2 : 2 ≤ S₀.card := by rw [Finset.card_erase_of_mem hc0_mem]; omega have hS1_ge2 : 2 ≤ S₁.card := by rw [Finset.card_erase_of_mem hc1_mem]; omega have hsub : insert c.edgeSet (S₀ ∪ S₁) ⊆ hamCycles G := by intro E hE rcases Finset.mem_insert.mp hE with rfl | hU · exact c.edgeSet_mem_hamCycles · rcases Finset.mem_union.mp hU with h0 | h1 · exact hamCycles_mono M₀.toGraph_le (Finset.mem_erase.mp h0).2 · exact hamCycles_mono M₁.toGraph_le (Finset.mem_erase.mp h1).2 have hc_not_U : c.edgeSet ∉ S₀ ∪ S₁ := by intro h; rcases Finset.mem_union.mp h with h0 | h1 · exact (Finset.mem_erase.mp h0).1 rfl · exact (Finset.mem_erase.mp h1).1 rfl calc 5 ≤ 1 + (S₀.card + S₁.card) := by omega _ = (insert c.edgeSet (S₀ ∪ S₁)).card := by rw [Finset.card_insert_of_notMem hc_not_U, Finset.card_union_of_disjoint hdisj_S]; omega _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- Corollary (Strict Strengthening of Sheehan 1975): Every 4-regular **bipartite** Hamiltonian graph has **AT LEAST 5 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_five_of_bipartite {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (col : V → Bool) (hbip : ∀ x y : V, G.Adj x y → col x ≠ col y) (c : DirHamCycle G) : 5 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) apply card_hamCycles_ge_five_of_even_chord_cycles c 𝒟 hpw hcov intro D hD -- Every cycle in a bipartite graph has even length! have hl3 := D.len_ge_three have hl : 0 < D.len := by omega have hcol_D : ∀ k : ℕ, (hk : k < D.len) → col (D.verts ⟨k, hk⟩) = if k % 2 = 0 then col (D.verts ⟨0, hl⟩) else !(col (D.verts ⟨0, hl⟩)) := by intro k induction k with | zero => intro _; simp | succ m ih => intro hmk have hm : m < D.len := by omega have hnext := (D.adj_next ⟨m, hm⟩).1 have hcn : cNext hl ⟨m, hm⟩ = ⟨m + 1, hmk⟩ := by ext; dsimp; rw [cNext_val]; dsimp; rw [if_pos hmk] rw [hcn] at hnext have hne := hbip _ _ hnext rw [ih hm] at hne by_cases hm2 : m % 2 = 0 · have h1 : (m + 1) % 2 ≠ 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases col (D.verts ⟨0, hl⟩) <;> cases col (D.verts ⟨m + 1, hmk⟩) <;> decide · have h1 : (m + 1) % 2 = 0 := by omega simp only [hm2, ↓reduceIte, h1] at hne ⊢ revert hne; cases col (D.verts ⟨0, hl⟩) <;> cases col (D.verts ⟨m + 1, hmk⟩) <;> decide have hlast := (D.adj_next ⟨D.len - 1, by omega⟩).1 have hcn : cNext hl ⟨D.len - 1, by omega⟩ = ⟨0, hl⟩ := by ext; rw [cNext_val]; dsimp; split_ifs <;> omega rw [hcn] at hlast have hne := hbip _ _ hlast rw [hcol_D (D.len - 1) (by omega)] at hne by_cases hmod : (D.len - 1) % 2 = 0 · rw [if_pos hmod] at hne; exact absurd rfl hne · exact ⟨D.len / 2, by omega⟩ /-- **Theorem 4b-i (Single Even Hamiltonian Chord Cycle $\implies \ge 6$ Hamiltonian Cycles)**: If `G` is the edge-disjoint union of two Hamiltonian cycles `c` and `c₂` on an **EVEN** number of vertices, then `G` has **AT LEAST 6 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_six_of_even_ham_chord {G : SimpleGraph V} (c : DirHamCycle G) (c₂ : DirHamCycle (chordGraph c)) (heven : Even (Fintype.card V)) : 6 ≤ (hamCycles G).card := by let D : CycleIn (chordGraph c) := { len := Fintype.card V len_ge_three := c.card_ge_three verts := c₂.toEquiv.toEmbedding adj_next := c₂.adj_next } have hD_univ : D.vertSet = Finset.univ := by ext v; simp only [CycleIn.vertSet, D, Finset.mem_image, Finset.mem_univ, true_and, iff_true] exact ⟨c₂.toEquiv.symm v, by simp⟩ let mkM : Bool → ChordMatching c := fun sh => { covered := Finset.univ partner := evenCyclePartner D heven sh partner_mem := fun _ _ => Finset.mem_univ _ partner_invol := fun x _ => (evenCyclePartner_props D heven sh).2.1 x (hD_univ ▸ Finset.mem_univ x) partner_adj := fun x _ => (evenCyclePartner_props D heven sh).2.2.1 x (hD_univ ▸ Finset.mem_univ x) } let M₀ := mkM false let M₁ := mkM true have hge3_0 : 3 ≤ (hamCycles M₀.toGraph).card := card_hamCycles_ge_three_of_all_odd_deg M₀.toGraph (fun w => by rw [M₀.degree_eq, if_pos (Finset.mem_univ w)]; exact ⟨1, rfl⟩) M₀.toCycle have hge3_1 : 3 ≤ (hamCycles M₁.toGraph).card := card_hamCycles_ge_three_of_all_odd_deg M₁.toGraph (fun w => by rw [M₁.degree_eq, if_pos (Finset.mem_univ w)]; exact ⟨1, rfl⟩) M₁.toCycle let S₀ := (hamCycles M₀.toGraph).erase c.edgeSet let S₁ := (hamCycles M₁.toGraph).erase c.edgeSet have hpart_ne : ∀ v : V, M₀.partner v ≠ M₁.partner v := fun v => (evenCyclePartner_props D heven false).2.2.2 v (hD_univ ▸ Finset.mem_univ v) have hdisj_S : Disjoint S₀ S₁ := by rw [Finset.disjoint_left]; intro E h0 h1 rcases Finset.mem_erase.mp h0 with ⟨hne, h0'⟩ have h1' := (Finset.mem_erase.mp h1).2 obtain ⟨a, rfl⟩ := mem_hamCycles.mp h0' obtain ⟨b, hb⟩ := mem_hamCycles.mp h1' obtain ⟨f, hfE, hfc⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem ⟨a, rfl⟩ ⟨M₀.toCycle, rfl⟩ hne rcases Sym2.mk_surjective f with ⟨⟨x, y⟩, rfl⟩ rcases a.adj_of_mem_edgeSet hfE with hc | ⟨_, hxy0⟩ · exact hfc hc · rcases b.adj_of_mem_edgeSet (hb ▸ hfE) with hc | ⟨_, hxy1⟩ · exact hfc hc · exact hpart_ne x (hxy0.symm.trans hxy1) -- Show c₂.edgeSet is distinct from c.edgeSet and lies in NEITHER S₀ NOR S₁! let E₂ : Finset (Sym2 V) := (c₂.map_le (chordGraph_le c)).edgeSet have hE₂_mem : E₂ ∈ hamCycles G := (c₂.map_le (chordGraph_le c)).edgeSet_mem_hamCycles have hE₂_no_c : ∀ e ∈ E₂, e ∉ c.edgeSet := by intro e he rcases Sym2.mk_surjective e with ⟨⟨x, y⟩, rfl⟩ exact (c₂.adj_of_mem_edgeSet he).2 have hE₂_ne_c : E₂ ≠ c.edgeSet := by intro heq have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega have hmem : s(c.toEquiv ⟨0, hn⟩, c.toEquiv (cNext hn ⟨0, hn⟩)) ∈ c.edgeSet := Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, rfl⟩ exact hE₂_no_c _ (heq.symm ▸ hmem) hmem have hE₂_not_M : ∀ sh, E₂ ∉ hamCycles (mkM sh).toGraph := by intro sh hmem -- Every edge of E₂ would have to be a partner-edge of mkM sh! -- At vertex v₀ = c₂ 0, BOTH edges s(v₀, c₂ 1) and s(v₀, c₂ (n-1)) are in E₂, impossible! obtain ⟨c', hc'⟩ := mem_hamCycles.mp hmem have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega have he1 : s(c₂.toEquiv ⟨0, hn⟩, c₂.toEquiv (cNext hn ⟨0, hn⟩)) ∈ E₂ := Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, rfl⟩ have he2 : s(c₂.toEquiv ⟨0, hn⟩, c₂.toEquiv (cPrev hn ⟨0, hn⟩)) ∈ E₂ := by refine Finset.mem_image.mpr ⟨cPrev hn ⟨0, hn⟩, Finset.mem_univ _, ?_⟩ change s(c₂.toEquiv (cPrev hn ⟨0, hn⟩), c₂.toEquiv (cNext hn (cPrev hn ⟨0, hn⟩))) = _ rw [cNext_cPrev, Sym2.eq_swap] have ha1 := c'.adj_of_mem_edgeSet (hc'.symm ▸ he1) have ha2 := c'.adj_of_mem_edgeSet (hc'.symm ▸ he2) rcases ha1 with hc1 | ⟨_, h1⟩ · exact hE₂_no_c _ he1 hc1 · rcases ha2 with hc2 | ⟨_, h2⟩ · exact hE₂_no_c _ he2 hc2 · exact cNext_ne_cPrev hn3 ⟨0, hn⟩ (c₂.toEquiv.injective (h1.trans h2.symm)) have hc0_mem : c.edgeSet ∈ hamCycles M₀.toGraph := M₀.toCycle.edgeSet_mem_hamCycles have hc1_mem : c.edgeSet ∈ hamCycles M₁.toGraph := M₁.toCycle.edgeSet_mem_hamCycles have hS0_ge2 : 2 ≤ S₀.card := by dsimp [S₀]; rw [Finset.card_erase_of_mem hc0_mem]; omega have hS1_ge2 : 2 ≤ S₁.card := by dsimp [S₁]; rw [Finset.card_erase_of_mem hc1_mem]; omega have hsub : insert E₂ (insert c.edgeSet (S₀ ∪ S₁)) ⊆ hamCycles G := by intro E hE rcases Finset.mem_insert.mp hE with rfl | h1 · exact hE₂_mem · rcases Finset.mem_insert.mp h1 with rfl | h2 · exact c.edgeSet_mem_hamCycles · rcases Finset.mem_union.mp h2 with h0 | h1' · exact hamCycles_mono M₀.toGraph_le (Finset.mem_erase.mp h0).2 · exact hamCycles_mono M₁.toGraph_le (Finset.mem_erase.mp h1').2 have hnot1 : c.edgeSet ∉ S₀ ∪ S₁ := by intro h; rcases Finset.mem_union.mp h with h0 | h1 · exact (Finset.mem_erase.mp h0).1 rfl · exact (Finset.mem_erase.mp h1).1 rfl have hnot2 : E₂ ∉ insert c.edgeSet (S₀ ∪ S₁) := by intro h; rcases Finset.mem_insert.mp h with heq | hU · exact hE₂_ne_c heq · rcases Finset.mem_union.mp hU with h0 | h1 · exact hE₂_not_M false (Finset.mem_erase.mp h0).2 · exact hE₂_not_M true (Finset.mem_erase.mp h1).2 calc 6 ≤ 1 + (1 + (S₀.card + S₁.card)) := by omega _ = (insert E₂ (insert c.edgeSet (S₀ ∪ S₁))).card := by rw [Finset.card_insert_of_notMem hnot2, Finset.card_insert_of_notMem hnot1, Finset.card_union_of_disjoint hdisj_S]; omega _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- **Theorem 4b-ii (Single Odd Hamiltonian Chord Cycle $\implies \ge 4$ Hamiltonian Cycles)**: If `G` is the edge-disjoint union of two Hamiltonian cycles `c` and `c₂` on an **ODD** number of vertices, then `G` has **AT LEAST 4 DISTINCT HAMILTONIAN CYCLES**! -/ theorem card_hamCycles_ge_four_of_odd_ham_chord {G : SimpleGraph V} (c : DirHamCycle G) (c₂ : DirHamCycle (chordGraph c)) (hodd : Odd (Fintype.card V)) : 4 ≤ (hamCycles G).card := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega let D : CycleIn (chordGraph c) := { len := Fintype.card V len_ge_three := hn3 verts := c₂.toEquiv.toEmbedding adj_next := c₂.adj_next } have hD_univ : D.vertSet = Finset.univ := by ext v; simp only [CycleIn.vertSet, D, Finset.mem_image, Finset.mem_univ, true_and, iff_true] exact ⟨c₂.toEquiv.symm v, by simp⟩ let E₂ : Finset (Sym2 V) := (c₂.map_le (chordGraph_le c)).edgeSet have hE₂_mem : E₂ ∈ hamCycles G := (c₂.map_le (chordGraph_le c)).edgeSet_mem_hamCycles have hE₂_no_c : ∀ e ∈ E₂, e ∉ c.edgeSet := fun e he => by rcases Sym2.mk_surjective e with ⟨⟨x, y⟩, rfl⟩ exact (c₂.adj_of_mem_edgeSet he).2 have hE₂_ne_c : E₂ ≠ c.edgeSet := by intro heq have hmem : s(c.toEquiv ⟨0, hn⟩, c.toEquiv (cNext hn ⟨0, hn⟩)) ∈ c.edgeSet := Finset.mem_image.mpr ⟨⟨0, hn⟩, Finset.mem_univ _, rfl⟩ exact hE₂_no_c _ (heq.symm ▸ hmem) hmem -- For ANY vertex u : V, deleting u from D gives a Hamiltonian cycle E_u ≠ c.edgeSet -- that avoids ALL chords at u (hence uses a c-edge at u, so E_u ≠ E₂)! have hex_avoid : ∀ u : V, ∃ E ∈ hamCycles G, E ≠ c.edgeSet ∧ E ≠ E₂ ∧ (∀ y : V, s(u, y) ∈ E → s(u, y) ∈ c.edgeSet) := by intro u let i₀ := c₂.toEquiv.symm u have hi₀ : D.verts i₀ = u := by simp [D, i₀] let M : ChordMatching c := { covered := Finset.univ.erase u partner := oddCycleDeletePartner D hodd i₀ partner_mem := fun x hx => by have h := (oddCycleDeletePartner_props D hodd i₀).1 x (by rwa [hD_univ, hi₀]) rwa [hD_univ, hi₀] at h partner_invol := fun x hx => (oddCycleDeletePartner_props D hodd i₀).2.1 x (by rwa [hD_univ, hi₀]) partner_adj := fun x hx => (oddCycleDeletePartner_props D hodd i₀).2.2 x (by rwa [hD_univ, hi₀]) } let iu := c.toEquiv.symm u have hiu : c.toEquiv iu = u := by simp [iu] let v := c.toEquiv (cNext hn iu) have huv : s(u, v) ∈ c.edgeSet := by refine Finset.mem_image.mpr ⟨iu, Finset.mem_univ _, ?_⟩; rw [hiu] obtain ⟨E, hE_M, hE_ne_c, hE_uv⟩ := exists_second_hamCycle_of_odd_deg_off M.toGraph M.toCycle.edgeSet_mem_hamCycles huv (fun w hwu _ => by rw [M.degree_eq, if_pos (Finset.mem_erase.mpr ⟨hwu, Finset.mem_univ w⟩)]; exact ⟨1, rfl⟩) refine ⟨E, hamCycles_mono M.toGraph_le hE_M, hE_ne_c, ?_, ?_⟩ · intro hEq; exact hE₂_no_c _ (hEq ▸ hE_uv) huv · intro y huy obtain ⟨cE, rfl⟩ := mem_hamCycles.mp hE_M rcases cE.adj_of_mem_edgeSet huy with hc | ⟨hu_cov, _⟩ · exact hc · exact absurd hu_cov (Finset.notMem_erase u _) -- Pick u₀ = c 0 → gets E₃; since E₃ ≠ c.edgeSet, E₃ contains some chord s(x, y) ∉ c.edgeSet; -- apply hex_avoid x → gets E₄ distinct from c.edgeSet, E₂, AND E₃! obtain ⟨E₃, hE₃_mem, hE₃_nec, hE₃_ne2, _⟩ := hex_avoid (c.toEquiv ⟨0, hn⟩) obtain ⟨f, hf3, hfc⟩ := DirHamCycle.edgeSet_ne_of_exists_not_mem (mem_hamCycles.mp hE₃_mem) ⟨c, rfl⟩ hE₃_nec rcases Sym2.mk_surjective f with ⟨⟨x, y⟩, rfl⟩ obtain ⟨E₄, hE₄_mem, hE₄_nec, hE₄_ne2, hE₄_av⟩ := hex_avoid x have hE₄_ne3 : E₄ ≠ E₃ := fun h => hfc (hE₄_av y (h ▸ hf3)) have hsub : ({c.edgeSet, E₂, E₃, E₄} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl | rfl | rfl · exact c.edgeSet_mem_hamCycles · exact hE₂_mem · exact hE₃_mem · exact hE₄_mem calc 4 = ({c.edgeSet, E₂, E₃, E₄} : Finset (Finset (Sym2 V))).card := by rw [Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_pair hE₄_ne3.symm] · simp [hE₃_ne2.symm, hE₄_ne2.symm] · simp [hE₂_ne_c.symm, hE₃_nec.symm, hE₄_nec.symm] _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- **Theorem 4c (Single Odd Chord-Cycle Theorem)**: If the chord 2-factor `chordGraph c` has **AT MOST ONE** odd cycle (plus any number of even cycles), then `G` has **AT LEAST 2 DISTINCT HAMILTONIAN CYCLES**! -/ theorem exists_second_hamCycle_of_le_one_odd_chord_cycle {G : SimpleGraph V} (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) (hle1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1) : 2 ≤ (hamCycles G).card := by by_cases h0 : (𝒟.filter fun D => decide (Odd D.len)).length = 0 · have heven : ∀ D ∈ 𝒟, Even D.len := by intro D hD by_contra hne have hodd : Odd D.len := Nat.not_even_iff_odd.mp hne have hmem : D ∈ 𝒟.filter (fun D => decide (Odd D.len)) := List.mem_filter.mpr ⟨hD, by simpa using hodd⟩ have hpos : 0 < (𝒟.filter fun D => decide (Odd D.len)).length := List.length_pos_of_mem hmem omega exact le_trans (by decide : 2 ≤ 5) (card_hamCycles_ge_five_of_even_chord_cycles c 𝒟 hpw hcov heven) · -- Exactly one odd cycle D₀ ∈ 𝒟! have hpos : 0 < (𝒟.filter fun D => decide (Odd D.len)).length := by omega obtain ⟨D₀, hD₀_filt⟩ := List.exists_mem_of_length_pos hpos rcases List.mem_filter.mp hD₀_filt with ⟨hD₀_mem, hD₀_odd'⟩ have hD₀_odd : Odd D₀.len := by simpa using hD₀_odd' have hother_even : ∀ D ∈ 𝒟, D ≠ D₀ → Even D.len := by intro D hD hne by_contra hne_ev have hodd : Odd D.len := Nat.not_even_iff_odd.mp hne_ev have hD_filt : D ∈ 𝒟.filter (fun D => decide (Odd D.len)) := List.mem_filter.mpr ⟨hD, by simpa using hodd⟩ -- Two distinct elements D, D₀ in a list of length ≤ 1! have h2le : 2 ≤ (𝒟.filter fun D => decide (Odd D.len)).length := by cases hf : 𝒟.filter (fun D => decide (Odd D.len)) with | nil => rw [hf] at hD_filt; cases hD_filt | cons a tl => cases tl with | nil => rw [hf] at hD_filt hD₀_filt simp only [List.mem_singleton] at hD_filt hD₀_filt exact absurd (hD_filt.trans hD₀_filt.symm) hne | cons b rest => simp omega have hl0 : 0 < D₀.len := by have := D₀.len_ge_three; omega let i₀ : Fin D₀.len := ⟨0, hl0⟩ let u := D₀.verts i₀ let covOf : CycleIn (chordGraph c) → Finset V := fun D => if D = D₀ then D.vertSet.erase u else D.vertSet let partOf : CycleIn (chordGraph c) → V → V := fun D x => if h : D = D₀ then oddCycleDeletePartner D₀ hD₀_odd i₀ x else if he : Even D.len then evenCyclePartner D he false x else x let M := buildChordMatching c 𝒟 hpw covOf partOf (fun D _ => by dsimp [covOf]; split_ifs <;> [exact Finset.erase_subset _ _; exact Finset.Subset.refl _]) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases hDD : D = D₀ · subst hDD; rw [if_pos rfl] at hx; rw [if_pos rfl, if_pos rfl] exact (oddCycleDeletePartner_props D hD₀_odd i₀).1 x hx · rw [if_neg hDD] at hx; rw [if_neg hDD, if_neg hDD, dif_pos (hother_even D hD hDD)] exact (evenCyclePartner_props D (hother_even D hD hDD) false).1 x hx) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases hDD : D = D₀ · subst hDD; rw [if_pos rfl] at hx; rw [if_pos rfl, if_pos rfl] exact (oddCycleDeletePartner_props D hD₀_odd i₀).2.1 x hx · rw [if_neg hDD] at hx; rw [if_neg hDD, if_neg hDD, dif_pos (hother_even D hD hDD), dif_pos (hother_even D hD hDD)] exact (evenCyclePartner_props D (hother_even D hD hDD) false).2.1 x hx) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases hDD : D = D₀ · subst hDD; rw [if_pos rfl] at hx; rw [if_pos rfl] exact (oddCycleDeletePartner_props D hD₀_odd i₀).2.2 x hx · rw [if_neg hDD] at hx; rw [if_neg hDD, dif_pos (hother_even D hD hDD)] exact (evenCyclePartner_props D (hother_even D hD hDD) false).2.2.1 x hx) -- Every w ≠ u lies in M.covered! have hcov_all : ∀ w : V, w ≠ u → w ∈ M.covered := by intro w hwu obtain ⟨D, hD, hwD⟩ := hcov w have hmem_cov : w ∈ covOf D := by dsimp [covOf]; split_ifs with hDD · exact Finset.mem_erase.mpr ⟨hwu, hwD⟩ · exact hwD exact (mem_foldr_union 𝒟 covOf w).mpr ⟨D, hD, hmem_cov⟩ have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega let iu := c.toEquiv.symm u have hiu : c.toEquiv iu = u := by simp [iu] let v := c.toEquiv (cNext hn iu) have huv : s(u, v) ∈ c.edgeSet := by refine Finset.mem_image.mpr ⟨iu, Finset.mem_univ _, ?_⟩; rw [hiu] obtain ⟨E₁, hE₁, hE₁_ne, _⟩ := exists_second_hamCycle_of_odd_deg_off M.toGraph M.toCycle.edgeSet_mem_hamCycles huv (fun w hwu _ => by rw [M.degree_eq, if_pos (hcov_all w hwu)]; exact ⟨1, rfl⟩) have hsub : ({c.edgeSet, E₁} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl · exact c.edgeSet_mem_hamCycles · exact hamCycles_mono M.toGraph_le hE₁ calc 2 = ({c.edgeSet, E₁} : Finset (Finset (Sym2 V))).card := (Finset.card_pair hE₁_ne.symm).symm _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- **Theorem 4d-i (Adjacent Two-Odd-Cycle Theorem)**: If `𝒟` has **EXACTLY TWO** odd cycles `D₁, D₂` connected by a `c`-edge `s(u, v) ∈ c.edgeSet` (`u ∈ D₁`, `v ∈ D₂`, plus any number of even cycles), then `G` has **AT LEAST 2 DISTINCT HAMILTONIAN CYCLES**! -/ theorem exists_second_hamCycle_of_two_adj_odd_chord_cycles {G : SimpleGraph V} (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) {D₁ D₂ : CycleIn (chordGraph c)} (hD₁ : D₁ ∈ 𝒟) (hD₂ : D₂ ∈ 𝒟) (hD₁₂ : D₁ ≠ D₂) (hodd₁ : Odd D₁.len) (hodd₂ : Odd D₂.len) (hother_even : ∀ D ∈ 𝒟, D ≠ D₁ → D ≠ D₂ → Even D.len) {u v : V} (hu : u ∈ D₁.vertSet) (hv : v ∈ D₂.vertSet) (huv : s(u, v) ∈ c.edgeSet) : 2 ≤ (hamCycles G).card := by obtain ⟨i₁, _, hi₁⟩ := Finset.mem_image.mp hu obtain ⟨i₂, _, hi₂⟩ := Finset.mem_image.mp hv let covOf : CycleIn (chordGraph c) → Finset V := fun D => if D = D₁ then D.vertSet.erase u else if D = D₂ then D.vertSet.erase v else D.vertSet let partOf : CycleIn (chordGraph c) → V → V := fun D x => if h1 : D = D₁ then oddCycleDeletePartner D₁ hodd₁ i₁ x else if h2 : D = D₂ then oddCycleDeletePartner D₂ hodd₂ i₂ x else if he : Even D.len then evenCyclePartner D he false x else x let M := buildChordMatching c 𝒟 hpw covOf partOf (fun D _ => by dsimp [covOf]; split_ifs <;> [exact Finset.erase_subset _ _; exact Finset.erase_subset _ _; exact Finset.Subset.refl _]) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases h1 : D = D₁ · subst h1; rw [if_pos rfl] at hx; rw [if_pos rfl, if_pos rfl] rw [← hi₁] at hx ⊢; exact (oddCycleDeletePartner_props D hodd₁ i₁).1 x hx · by_cases h2 : D = D₂ · subst h2; rw [if_neg h1, if_pos rfl] at hx; rw [if_neg h1, if_pos rfl, if_neg h1, if_pos rfl] rw [← hi₂] at hx ⊢; exact (oddCycleDeletePartner_props D hodd₂ i₂).1 x hx · rw [if_neg h1, if_neg h2] at hx rw [if_neg h1, if_neg h2, if_neg h1, if_neg h2, dif_pos (hother_even D hD h1 h2)] exact (evenCyclePartner_props D (hother_even D hD h1 h2) false).1 x hx) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases h1 : D = D₁ · subst h1; rw [if_pos rfl] at hx; rw [if_pos rfl, if_pos rfl] rw [← hi₁] at hx; exact (oddCycleDeletePartner_props D hodd₁ i₁).2.1 x hx · by_cases h2 : D = D₂ · subst h2; rw [if_neg h1, if_pos rfl] at hx; rw [if_neg h1, if_pos rfl, if_neg h1, if_pos rfl] rw [← hi₂] at hx; exact (oddCycleDeletePartner_props D hodd₂ i₂).2.1 x hx · rw [if_neg h1, if_neg h2] at hx rw [if_neg h1, if_neg h2, if_neg h1, if_neg h2, dif_pos (hother_even D hD h1 h2), dif_pos (hother_even D hD h1 h2)] exact (evenCyclePartner_props D (hother_even D hD h1 h2) false).2.1 x hx) (fun D hD x hx => by dsimp [covOf, partOf] at hx ⊢ by_cases h1 : D = D₁ · subst h1; rw [if_pos rfl] at hx; rw [if_pos rfl] rw [← hi₁] at hx; exact (oddCycleDeletePartner_props D hodd₁ i₁).2.2 x hx · by_cases h2 : D = D₂ · subst h2; rw [if_neg h1, if_pos rfl] at hx; rw [if_neg h1, if_pos rfl] rw [← hi₂] at hx; exact (oddCycleDeletePartner_props D hodd₂ i₂).2.2 x hx · rw [if_neg h1, if_neg h2] at hx; rw [if_neg h1, if_neg h2, dif_pos (hother_even D hD h1 h2)] exact (evenCyclePartner_props D (hother_even D hD h1 h2) false).2.2.1 x hx) have hcov_all : ∀ w : V, w ≠ u → w ≠ v → w ∈ M.covered := by intro w hwu hwv obtain ⟨D, hD, hwD⟩ := hcov w have hmem_cov : w ∈ covOf D := by dsimp [covOf]; split_ifs with h1 h2 · exact Finset.mem_erase.mpr ⟨hwu, hwD⟩ · exact Finset.mem_erase.mpr ⟨hwv, hwD⟩ · exact hwD exact (mem_foldr_union 𝒟 covOf w).mpr ⟨D, hD, hmem_cov⟩ obtain ⟨E₁, hE₁, hE₁_ne, _⟩ := exists_second_hamCycle_of_odd_deg_off M.toGraph M.toCycle.edgeSet_mem_hamCycles huv (fun w hwu hwv => by rw [M.degree_eq, if_pos (hcov_all w hwu hwv)]; exact ⟨1, rfl⟩) have hsub : ({c.edgeSet, E₁} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl · exact c.edgeSet_mem_hamCycles · exact hamCycles_mono M.toGraph_le hE₁ calc 2 = ({c.edgeSet, E₁} : Finset (Finset (Sym2 V))).card := (Finset.card_pair hE₁_ne.symm).symm _ ≤ (hamCycles G).card := Finset.card_le_card hsub /-- **Theorem 4d-ii (Two-Component Chord 2-Factor Theorem)**: If the chord 2-factor `chordGraph c` decomposes into **AT MOST 2 CYCLES** (`𝒟.length ≤ 2`), then `G` ALWAYS has **AT LEAST 2 DISTINCT HAMILTONIAN CYCLES**! -/ theorem exists_second_hamCycle_of_le_two_chord_components {G : SimpleGraph V} (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) (hlen : 𝒟.length ≤ 2) : 2 ≤ (hamCycles G).card := by by_cases hodd_le1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1 · exact exists_second_hamCycle_of_le_one_odd_chord_cycle c 𝒟 hpw hcov hodd_le1 · -- Must have 𝒟 = [D₁, D₂] with BOTH D₁ and D₂ odd! cases h𝒟 : 𝒟 with | nil => simp [h𝒟] at hodd_le1 | cons D₁ tl => cases tl with | nil => have : ([D₁].filter fun D => decide (Odd D.len)).length ≤ 1 := by simp only [List.filter_cons, List.filter_nil]; split_ifs <;> simp rw [h𝒟] at hodd_le1; exact absurd this hodd_le1 | cons D₂ rest => cases rest with | cons _ _ => rw [h𝒟] at hlen; simp at hlen | nil => rw [h𝒟] at hpw hcov hodd_le1 have hdisj : Disjoint D₁.vertSet D₂.vertSet := by rw [List.pairwise_cons] at hpw; exact hpw.1 D₂ List.mem_cons_self have hD₁₂ : D₁ ≠ D₂ := by intro rfl have hl : 0 < D₁.len := by have := D₁.len_ge_three; omega exact Finset.disjoint_left.mp hdisj (Finset.mem_image.mpr ⟨⟨0, hl⟩, Finset.mem_univ _, rfl⟩) (Finset.mem_image.mpr ⟨⟨0, hl⟩, Finset.mem_univ _, rfl⟩) have hodd₁ : Odd D₁.len := by by_contra h have hle : (([D₁, D₂].filter fun D => decide (Odd D.len))).length ≤ 1 := by simp only [List.filter_cons, List.filter_nil, decide_eq_true_eq] rw [if_neg h]; split_ifs <;> simp exact hodd_le1 hle have hodd₂ : Odd D₂.len := by by_contra h have hle : (([D₁, D₂].filter fun D => decide (Odd D.len))).length ≤ 1 := by simp only [List.filter_cons, List.filter_nil, decide_eq_true_eq] rw [if_neg h]; (split_ifs; simp) exact hodd_le1 hle -- Since D₁ ∪ D₂ = univ and both are nonempty, the connected cycle c MUST have an edge crossing! have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega have hex_cross : ∃ i : Fin (Fintype.card V), c.toEquiv i ∈ D₁.vertSet ∧ c.toEquiv (cNext hn i) ∈ D₂.vertSet := by by_contra hno push Not at hno -- Pick i₁ with c i₁ ∈ D₁ and i₂ with c i₂ ∈ D₂ have hl1 : 0 < D₁.len := by have := D₁.len_ge_three; omega have hl2 : 0 < D₂.len := by have := D₂.len_ge_three; omega let i₁ := c.toEquiv.symm (D₁.verts ⟨0, hl1⟩) let i₂ := c.toEquiv.symm (D₂.verts ⟨0, hl2⟩) have hi₁ : c.toEquiv i₁ ∈ D₁.vertSet := by simp [i₁]; exact Finset.mem_image.mpr ⟨⟨0, hl1⟩, Finset.mem_univ _, rfl⟩ have hi₂ : c.toEquiv i₂ ∈ D₂.vertSet := by simp [i₂]; exact Finset.mem_image.mpr ⟨⟨0, hl2⟩, Finset.mem_univ _, rfl⟩ -- By induction along c, every vertex c (cShift m i₁) lies in D₁.vertSet! have hall : ∀ m : ℕ, c.toEquiv (cShift hn m i₁) ∈ D₁.vertSet := by intro m induction m with | zero => rw [cShift_zero]; exact hi₁ | succ m ihm => rw [cShift_succ] obtain ⟨D, hD, hmem⟩ := hcov (c.toEquiv (cNext hn (cShift hn m i₁))) simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl · exact hmem · exact absurd hmem (hno (cShift hn m i₁) ihm) let m := (i₂.1 + Fintype.card V - i₁.1) % Fintype.card V have hm : cShift hn m i₁ = i₂ := by ext; dsimp [cShift, m] have h1 : (i₁.1 + (i₂.1 + Fintype.card V - i₁.1) % Fintype.card V) % Fintype.card V = (i₁.1 + (i₂.1 + Fintype.card V - i₁.1)) % Fintype.card V := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [h1] have h2 : i₁.1 + (i₂.1 + Fintype.card V - i₁.1) = i₂.1 + Fintype.card V := by omega rw [h2, Nat.add_mod_right, Nat.mod_eq_of_lt i₂.2] have hcontra : c.toEquiv i₂ ∈ D₁.vertSet := hm ▸ hall m exact Finset.disjoint_left.mp hdisj hcontra hi₂ obtain ⟨i, hi1, hi2⟩ := hex_cross exact exists_second_hamCycle_of_two_adj_odd_chord_cycles c [D₁, D₂] hpw hcov List.mem_cons_self (List.mem_cons_of_mem _ List.mem_cons_self) hD₁₂ hodd₁ hodd₂ (fun D hD h1 h2 => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl <;> contradiction) hi1 hi2 (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) end ChordTwoFactor /-! ## Section 5: Complete Resolution of Sheehan's Conjecture for All Vertex-Transitive, ## Cayley, Circulant, and Torus-Grid 4-Regular Graphs We prove: - **Theorem 5a (`sheehan_vertex_transitive`)**: EVERY vertex-transitive 4-regular Hamiltonian simple graph has at least 2 distinct Hamiltonian cycles (via the Dihedral Automorphism Dichotomy: either an automorphism moves `c`, or `Aut(G)` embeds transitively into `D_n`, yielding either a crossing-chord 2-switch or a bipartite 4-regular graph with `≥ 5` Hamiltonian cycles!). - **Theorem 5b (`sheehan_cayley`)**: EVERY 4-regular Hamiltonian Cayley graph `Cay(Γ, S)` satisfies Sheehan's Conjecture. - **Theorem 5c (`sheehan_circulant` & `card_hamCycles_circulant_coprime`)**: EVERY 4-regular Hamiltonian circulant graph `Circ(n; a, b)` satisfies Sheehan's Conjecture, and whenever `Nat.Coprime a n` it is explicitly Hamiltonian with `≥ (n + 1) / 2 + 1` Hamiltonian cycles! - **Theorem 5d (`sheehan_torus_grid` & `card_hamCycles_torus_grid_even`)**: Every Hamiltonian torus grid `C_a □ C_b` (`a, b ≥ 3`) satisfies Sheehan's Conjecture, and when `a, b` are even it is explicitly Hamiltonian with `≥ 5` Hamiltonian cycles! -/ section VertexTransitive variable {V : Type*} [Fintype V] [DecidableEq V] /-- A graph `G` is **vertex-transitive** if `Aut(G)` acts transitively on `V`. -/ def IsVertexTransitive (G : SimpleGraph V) : Prop := ∀ u v : V, ∃ φ : G ≃g G, φ u = v /-- Reflection `i ↦ (k + n - i) % n` on `Fin n`. -/ private lemma cRefl_invol_nat {n : ℕ} (hn : 0 < n) (a b : ℕ) (hb : b < n) : (a + n - (a + n - b) % n) % n = b := by have hdiv : n * (a / n) + a % n = a := Nat.div_add_mod a n have hsucc : n * (a / n + 1) = n * (a / n) + n := Nat.mul_succ n (a / n) have hlt_a : a % n < n := Nat.mod_lt a hn by_cases h : b ≤ a % n · have hmod : (a + n - b) % n = a % n - b := by have heq : a + n - b = (a % n - b) + n * (a / n + 1) := by omega rw [heq, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt (by omega)] rw [hmod] have heq : a + n - (a % n - b) = b + n * (a / n + 1) := by omega rw [heq, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt hb] · have hmod : (a + n - b) % n = a % n + n - b := by have heq : a + n - b = (a % n + n - b) + n * (a / n) := by omega rw [heq, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt (by omega)] rw [hmod] have heq : a + n - (a % n + n - b) = b + n * (a / n) := by omega rw [heq, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt hb] def cRefl {n : ℕ} (hn : 0 < n) (k : ℕ) : Equiv.Perm (Fin n) where toFun i := ⟨(k + n - i.1) % n, Nat.mod_lt _ hn⟩ invFun i := ⟨(k + n - i.1) % n, Nat.mod_lt _ hn⟩ left_inv i := by ext; exact cRefl_invol_nat hn k i.1 i.2 right_inv i := by ext; exact cRefl_invol_nat hn k i.1 i.2 lemma cRefl_involutive {n : ℕ} (hn : 0 < n) (k : ℕ) (i : Fin n) : cRefl hn k (cRefl hn k i) = i := (cRefl hn k).left_inv i lemma cRefl_zero {n : ℕ} (hn : 0 < n) (k : ℕ) : (cRefl hn k ⟨0, hn⟩).1 = k % n := by dsimp [cRefl]; exact Nat.add_mod_right k n lemma cRefl_succ {n : ℕ} (hn : 0 < n) (k : ℕ) (i : Fin n) : cRefl hn k (cNext hn i) = cPrev hn (cRefl hn k i) := by ext; dsimp only [cRefl, Equiv.coe_fn_mk]; rw [cPrev_val, cNext_val]; dsimp only [Fin.val_mk] by_cases hlt : i.1 + 1 < n · rw [if_pos hlt] by_cases h0 : (k + n - i.1) % n = 0 · rw [if_pos h0] obtain ⟨q, hq⟩ := Nat.dvd_of_mod_eq_zero h0 have h1 : k + n - (i.1 + 1) = (n - 1) + n * (q - 1) := by have hqpos : 1 ≤ q := by by_contra h; have hq0 : q = 0 := by omega rw [hq0, mul_zero] at hq; omega have : n * q = n * (q - 1) + n := by conv_lhs => rw [show q = (q - 1) + 1 by omega, Nat.mul_succ] omega rw [h1, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt (by omega)] · rw [if_neg h0] have hdiv := Nat.div_add_mod (k + n - i.1) n have hltm : (k + n - i.1) % n < n := Nat.mod_lt _ hn have h1 : k + n - (i.1 + 1) = ((k + n - i.1) % n - 1) + n * ((k + n - i.1) / n) := by omega rw [h1, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt (by omega)] · rw [if_neg hlt] have hi : i.1 = n - 1 := by omega rw [Nat.sub_zero, Nat.add_mod_right] simp only [hi, show k + n - (n - 1) = k + 1 by omega] by_cases h0 : (k + 1) % n = 0 · rw [if_pos h0] have h1 : k % n = n - 1 := by have hdiv := Nat.div_add_mod k n have hltm : k % n < n := Nat.mod_lt _ hn have : (k % n + 1) % n = 0 := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod]; exact h0 by_contra hne rw [Nat.mod_eq_of_lt (by omega)] at this; omega exact h1 · rw [if_neg h0] have hltm : k % n < n := Nat.mod_lt _ hn have hne : k % n + 1 ≠ n := by intro h; apply h0 have hdiv := Nat.div_add_mod k n have h1 : k + 1 = n * (k / n + 1) := by rw [Nat.mul_succ]; omega rw [h1, Nat.mul_mod_right] have h1 : (k + 1) % n = k % n + 1 := by have hdiv := Nat.div_add_mod k n have : k + 1 = (k % n + 1) + n * (k / n) := by omega rw [this, Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt (by omega)] rw [h1]; omega /-- **Dihedral Classification Lemma**: If an automorphism `φ : G ≃g G` preserves `c.edgeSet`, then the induced permutation `π := c ⁻¹ ∘ φ ∘ c` on `Fin n` is either a rotation `cShift` or a reflection `cRefl`! -/ lemma dihedral_of_fixes_cycle {G : SimpleGraph V} (c : DirHamCycle G) (φ : G ≃g G) (hfix : (c.mapIso φ).edgeSet = c.edgeSet) : let hn : 0 < Fintype.card V := by have := c.card_ge_three; omega let π : Equiv.Perm (Fin (Fintype.card V)) := c.toEquiv.trans (φ.toEquiv.trans c.toEquiv.symm) let k := (π ⟨0, hn⟩).1 (∀ i, π i = cShift hn k i) ∨ (∀ i, π i = cRefl hn k i) := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega intro hn' π k -- Show π preserves cyclic adjacency on Fin n! have hπ_adj : ∀ i : Fin (Fintype.card V), π (cNext hn i) = cNext hn (π i) ∨ π (cNext hn i) = cPrev hn (π i) := by intro i have hmem : s(c.toEquiv (π i), c.toEquiv (π (cNext hn i))) ∈ c.edgeSet := by rw [← hfix] refine Finset.mem_image.mpr ⟨i, Finset.mem_univ _, ?_⟩ simp only [DirHamCycle.mapIso, π, Equiv.trans_apply, Equiv.apply_symm_apply] rfl exact (c.mem_edgeSet_iff (π i) (π (cNext hn i))).mp hmem -- Case split on whether π 1 = cNext (π 0) or π 1 = cPrev (π 0)! rcases hπ_adj ⟨0, hn⟩ with hpos | hneg · left have hall : ∀ m : ℕ, (hm : m < Fintype.card V) → π ⟨m, hm⟩ = cShift hn k ⟨m, hm⟩ := by intro m induction m using Nat.strong_induction_on with | h m ih => intro hm match m with | 0 => ext; change (π ⟨0, hn⟩).1 = (0 + k) % Fintype.card V rw [zero_add, Nat.mod_eq_of_lt (π ⟨0, hn⟩).2] | 1 => have h01 : cNext hn ⟨0, hn⟩ = ⟨1, hm⟩ := by ext; rw [cNext_val]; dsimp; rw [if_pos hm] rw [← h01, hpos] ext; rw [cNext_val]; dsimp [cShift]; rw [h01]; dsimp have hklt : k < Fintype.card V := (π ⟨0, hn⟩).2 by_cases h1 : k + 1 < Fintype.card V · rw [if_pos h1, show (1 + k) % Fintype.card V = k + 1 by rw [add_comm, Nat.mod_eq_of_lt h1]] · rw [if_neg h1, show (1 + k) % Fintype.card V = 0 by have : 1 + k = Fintype.card V := by omega rw [this, Nat.mod_self]] | r + 2 => have hr1 : r + 1 < Fintype.card V := by omega have hr0 : r < Fintype.card V := by omega have hcn : cNext hn ⟨r + 1, hr1⟩ = ⟨r + 2, hm⟩ := by ext; rw [cNext_val]; simp [hm] have hcn0 : cNext hn ⟨r, hr0⟩ = ⟨r + 1, hr1⟩ := by ext; rw [cNext_val]; simp [hr1] have h1 := hπ_adj ⟨r + 1, hr1⟩ rw [hcn, ih (r + 1) (by omega) hr1] at h1 rcases h1 with hnext | hprev · rw [hnext, ← cShift_cNext, hcn] · exfalso have hprev' : cPrev hn (cShift hn k ⟨r + 1, hr1⟩) = cShift hn k ⟨r, hr0⟩ := by rw [← hcn0, cShift_cNext, cPrev_cNext] rw [hprev', ← ih r (by omega) hr0] at hprev have := congrArg Fin.val (π.injective hprev) dsimp at this; omega intro i; exact hall i.1 i.2 · right have hall : ∀ m : ℕ, (hm : m < Fintype.card V) → π ⟨m, hm⟩ = cRefl hn k ⟨m, hm⟩ := by intro m induction m using Nat.strong_induction_on with | h m ih => intro hm match m with | 0 => ext; rw [cRefl_zero, Nat.mod_eq_of_lt (π ⟨0, hn⟩).2] | 1 => have h01 : cNext hn ⟨0, hn⟩ = ⟨1, hm⟩ := by ext; rw [cNext_val]; dsimp; rw [if_pos hm] rw [← h01, hneg, cRefl_succ] congr 1; ext; rw [cRefl_zero, Nat.mod_eq_of_lt (π ⟨0, hn⟩).2] | r + 2 => have hr1 : r + 1 < Fintype.card V := by omega have hr0 : r < Fintype.card V := by omega have hcn : cNext hn ⟨r + 1, hr1⟩ = ⟨r + 2, hm⟩ := by ext; rw [cNext_val]; simp [hm] have hcn0 : cNext hn ⟨r, hr0⟩ = ⟨r + 1, hr1⟩ := by ext; rw [cNext_val]; simp [hr1] have h1 := hπ_adj ⟨r + 1, hr1⟩ rw [hcn, ih (r + 1) (by omega) hr1] at h1 rcases h1 with hnext | hprev · exfalso have hnext' : cNext hn (cRefl hn k ⟨r + 1, hr1⟩) = cRefl hn k ⟨r, hr0⟩ := by rw [← hcn0, cRefl_succ, cNext_cPrev] rw [hnext', ← ih r (by omega) hr0] at hnext have := congrArg Fin.val (π.injective hnext) dsimp at this; omega · rw [hprev, ← cRefl_succ, hcn] intro i; exact hall i.1 i.2 /-- **Theorem 5a (Complete Resolution of Sheehan's Conjecture for ALL Vertex-Transitive 4-Regular Graphs)**: Every vertex-transitive 4-regular Hamiltonian simple graph has **AT LEAST 2 DISTINCT HAMILTONIAN CYCLES**! -/ theorem sheehan_vertex_transitive {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (hvt : IsVertexTransitive G) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by have hn3 := c.card_ge_three have hn5 : 5 ≤ Fintype.card V := by have h4 : 4 = G.degree (c.toEquiv ⟨0, by omega⟩) := (hreg _).symm have hlt := G.degree_lt_card_verts (c.toEquiv ⟨0, by omega⟩) omega have hn : 0 < Fintype.card V := by omega -- If ANY automorphism moves c.edgeSet, we immediately get a 2nd Hamiltonian cycle! by_cases hmove : ∃ φ : G ≃g G, (c.mapIso φ).edgeSet ≠ c.edgeSet · obtain ⟨φ, hne⟩ := hmove have hsub : ({c.edgeSet, (c.mapIso φ).edgeSet} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl · exact c.edgeSet_mem_hamCycles · exact (c.mapIso φ).edgeSet_mem_hamCycles calc 2 = ({c.edgeSet, (c.mapIso φ).edgeSet} : Finset (Finset (Sym2 V))).card := (Finset.card_pair hne.symm).symm _ ≤ (hamCycles G).card := Finset.card_le_card hsub · push Not at hmove -- Helper: if the 1-step rotation `i ↦ cNext hn i` is a graph automorphism of G, we win by 2-switch! have hwin_rot1 : (∀ i j : Fin (Fintype.card V), G.Adj (c.toEquiv i) (c.toEquiv j) → G.Adj (c.toEquiv (cNext hn i)) (c.toEquiv (cNext hn j))) → 2 ≤ (hamCycles G).card := by intro hrot1 -- Pick any chord from c 0! have hpos : 0 < ((chordGraph c).neighborFinset (c.toEquiv ⟨0, hn⟩)).card := by rw [SimpleGraph.card_neighborFinset_eq_degree, chordGraph_isRegularOfDegree_two hreg c]; omega obtain ⟨y, hy⟩ := Finset.card_pos.mp hpos have hadj_ch : (chordGraph c).Adj (c.toEquiv ⟨0, hn⟩) y := (SimpleGraph.mem_neighborFinset _ _ _).mp hy let j := c.toEquiv.symm y have hj : c.toEquiv j = y := by simp [j] have h1 : G.Adj (c.toEquiv ⟨0, hn⟩) (c.toEquiv j) := hj ▸ hadj_ch.1 have h2 : G.Adj (c.toEquiv (cNext hn ⟨0, hn⟩)) (c.toEquiv (cNext hn j)) := hrot1 ⟨0, hn⟩ j h1 have h0_ne_j : (⟨0, hn⟩ : Fin (Fintype.card V)) ≠ j := fun h => G.loopless.irrefl _ (h ▸ h1) have h0_ne_nj : (⟨0, hn⟩ : Fin (Fintype.card V)) ≠ cNext hn j := by intro h; apply hadj_ch.2 rw [← hj, c.mem_edgeSet_iff]; right; rw [h, cPrev_cNext] have hn0_ne_j : cNext hn ⟨0, hn⟩ ≠ j := by intro h; apply hadj_ch.2 rw [← hj, c.mem_edgeSet_iff]; left; exact h.symm obtain ⟨c', hne, _, _⟩ := exists_second_hamCycle_of_crossing_chords c ⟨0, hn⟩ j h1 h2 h0_ne_j h0_ne_nj hn0_ne_j have hsub : ({c.edgeSet, c'.edgeSet} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl · exact c.edgeSet_mem_hamCycles · exact c'.edgeSet_mem_hamCycles calc 2 = ({c.edgeSet, c'.edgeSet} : Finset (Finset (Sym2 V))).card := (Finset.card_pair hne.symm).symm _ ≤ (hamCycles G).card := Finset.card_le_card hsub -- Pick φ₁ sending c 0 ↦ c 1 and φ₂ sending c 0 ↦ c 2! obtain ⟨φ₁, hφ₁⟩ := hvt (c.toEquiv ⟨0, hn⟩) (c.toEquiv ⟨1, by omega⟩) obtain ⟨φ₂, hφ₂⟩ := hvt (c.toEquiv ⟨0, hn⟩) (c.toEquiv ⟨2, by omega⟩) have hd₁ := dihedral_of_fixes_cycle c φ₁ (hmove φ₁) have hd₂ := dihedral_of_fixes_cycle c φ₂ (hmove φ₂) have hk₁ : ((c.toEquiv.trans (φ₁.toEquiv.trans c.toEquiv.symm)) ⟨0, hn⟩).1 = 1 := by simp [hφ₁] have hk₂ : ((c.toEquiv.trans (φ₂.toEquiv.trans c.toEquiv.symm)) ⟨0, hn⟩).1 = 2 := by simp [hφ₂] dsimp only at hd₁ hd₂ rw [hk₁] at hd₁; rw [hk₂] at hd₂ have hφ_adj : ∀ (φ : G ≃g G) (π : Equiv.Perm (Fin (Fintype.card V))), (∀ i, c.toEquiv.symm (φ (c.toEquiv i)) = π i) → ∀ i j, G.Adj (c.toEquiv i) (c.toEquiv j) → G.Adj (c.toEquiv (π i)) (c.toEquiv (π j)) := by intro φ π hπ i j hij have h := φ.map_rel_iff.mpr hij rwa [← hπ i, ← hπ j, Equiv.apply_symm_apply, Equiv.apply_symm_apply] rcases hd₁ with hrot₁ | hrefl₁ · -- φ₁ IS the 1-step rotation! apply hwin_rot1 intro i j hij have h := hφ_adj φ₁ (cShift hn 1) hrot₁ i j hij have hcs : ∀ x, cShift hn 1 x = cNext hn x := fun x => by rw [show (1 : ℕ) = 0 + 1 by rfl, cShift_succ, cShift_zero] rwa [hcs i, hcs j] at h · rcases hd₂ with hrot₂ | hrefl₂ · -- φ₁ is reflection (1 - i), φ₂ is 2-step rotation (i + 2)! have hstep2 : ∀ i j, G.Adj (c.toEquiv i) (c.toEquiv j) → G.Adj (c.toEquiv (cShift hn 2 i)) (c.toEquiv (cShift hn 2 j)) := hφ_adj φ₂ (cShift hn 2) hrot₂ have hstep2k : ∀ (k : ℕ) i j, G.Adj (c.toEquiv i) (c.toEquiv j) → G.Adj (c.toEquiv (cShift hn (2 * k) i)) (c.toEquiv (cShift hn (2 * k) j)) := by intro k induction k with | zero => intro i j hij; simpa [cShift_zero] using hij | succ k ih => intro i j hij have h := hstep2 _ _ (ih i j hij) have hcomp : ∀ x, cShift hn 2 (cShift hn (2 * k) x) = cShift hn (2 * (k + 1)) x := fun x => by ext; dsimp [cShift]; rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod]; congr 1 rwa [hcomp i, hcomp j] at h by_cases heven : Even (Fintype.card V) · -- Even n: either G is bipartite (→ ≥ 5 H-cycles!) or ∃ same-parity chord (→ 2-switch!) by_cases hsame : ∃ i j : Fin (Fintype.card V), (chordGraph c).Adj (c.toEquiv i) (c.toEquiv j) ∧ i.1 % 2 = j.1 % 2 · obtain ⟨i, j, hch, hpar⟩ := hsame -- First ensure first index is EVEN (if odd, apply reflection φ₁: 1 - i is even!) have hev_chord : ∃ a b : Fin (Fintype.card V), (chordGraph c).Adj (c.toEquiv a) (c.toEquiv b) ∧ a.1 % 2 = 0 ∧ b.1 % 2 = 0 := by rcases Nat.mod_two_eq_zero_or_one i.1 with hi0 | hi1 · exact ⟨i, j, hch, hi0, hpar ▸ hi0⟩ · have hj1 : j.1 % 2 = 1 := hpar ▸ hi1 obtain ⟨m, hm⟩ := heven have href_par : ∀ x : Fin (Fintype.card V), x.1 % 2 = 1 → (cRefl hn 1 x).1 % 2 = 0 := by intro x hx; dsimp [cRefl] have hxlt := x.2 have h1 : 1 + Fintype.card V - x.1 = 2 * (m - x.1 / 2) := by omega rw [h1] have hmod : (2 * (m - x.1 / 2)) % Fintype.card V = if 2 * (m - x.1 / 2) < Fintype.card V then 2 * (m - x.1 / 2) else 0 := by split_ifs with hlt · exact Nat.mod_eq_of_lt hlt · have heq : 2 * (m - x.1 / 2) = Fintype.card V := by omega rw [heq, Nat.mod_self] rw [hmod]; split_ifs <;> omega have hadj_r := hφ_adj φ₁ (cRefl hn 1) hrefl₁ i j hch.1 have hnot_r : s(c.toEquiv (cRefl hn 1 i), c.toEquiv (cRefl hn 1 j)) ∉ c.edgeSet := by intro hmem rw [c.mem_edgeSet_iff] at hmem apply hch.2; rw [c.mem_edgeSet_iff] rcases hmem with h1 | h2 · right have h1' := congrArg (cRefl hn 1) h1 rw [cRefl_involutive, cRefl_succ, cRefl_involutive] at h1' exact h1' · left have h2' := congrArg (cRefl hn 1) h2 have hprev_r : cRefl hn 1 (cPrev hn (cRefl hn 1 i)) = cNext hn i := by rw [← cRefl_succ, cRefl_involutive] rw [cRefl_involutive, hprev_r] at h2' exact h2' exact ⟨cRefl hn 1 i, cRefl hn 1 j, ⟨hadj_r, hnot_r⟩, href_par i hi1, href_par j hj1⟩ obtain ⟨a, b, hch, ha0, hb0⟩ := hev_chord -- Shift `a` to `0` via `cShift hn (n - a)` (even!) to get chord `(0, d)` with `d` even! obtain ⟨m, hm⟩ := heven have hsh_even : ∃ t : ℕ, cShift hn (2 * t) a = ⟨0, hn⟩ := by refine ⟨(Fintype.card V - a.1) / 2, ?_⟩ ext; dsimp [cShift] have h2t : 2 * ((Fintype.card V - a.1) / 2) = Fintype.card V - a.1 := by omega rw [h2t, show a.1 + (Fintype.card V - a.1) = Fintype.card V by omega, Nat.mod_self] obtain ⟨t, ht⟩ := hsh_even let d := cShift hn (2 * t) b have hd_even : d.1 % 2 = 0 := by dsimp [d, cShift] have hdiv : Fintype.card V * ((b.1 + 2 * t) / Fintype.card V) + (b.1 + 2 * t) % Fintype.card V = b.1 + 2 * t := Nat.div_add_mod _ _ have h2m : Fintype.card V * ((b.1 + 2 * t) / Fintype.card V) = 2 * (m * ((b.1 + 2 * t) / Fintype.card V)) := by generalize ((b.1 + 2 * t) / Fintype.card V) = q; rw [hm]; ring omega have h0d_adj : G.Adj (c.toEquiv ⟨0, hn⟩) (c.toEquiv d) := by rw [← ht]; exact hstep2k t a b hch.1 have h0d_not : s(c.toEquiv ⟨0, hn⟩, c.toEquiv d) ∉ c.edgeSet := by intro hmem; apply hch.2 rw [c.mem_edgeSet_iff] at hmem ⊢ rw [← ht] at hmem rcases hmem with h1 | h2 · left; apply (cShift hn (2 * t)).injective; rw [cShift_cNext]; exact h1 · right; apply (cShift hn (2 * t)).injective have hcprev : cShift hn (2 * t) (cPrev hn a) = cPrev hn (cShift hn (2 * t) a) := by rw [← cPrev_cNext hn (cShift hn (2 * t) (cPrev hn a)), ← cShift_cNext, cNext_cPrev] rw [hcprev]; exact h2 -- Apply reflection φ₁ to `(0, d)` → `(1, (1 - d) mod n)`, then shift by `d` (even!) → `(d + 1, 1)`! have href_0d : G.Adj (c.toEquiv (cRefl hn 1 ⟨0, hn⟩)) (c.toEquiv (cRefl hn 1 d)) := hφ_adj φ₁ (cRefl hn 1) hrefl₁ ⟨0, hn⟩ d h0d_adj have hsh_ref := hstep2k (d.1 / 2) (cRefl hn 1 ⟨0, hn⟩) (cRefl hn 1 d) href_0d have h2d : 2 * (d.1 / 2) = d.1 := by omega have hleft : cShift hn (2 * (d.1 / 2)) (cRefl hn 1 ⟨0, hn⟩) = cNext hn d := by ext; dsimp [cShift, cRefl]; rw [h2d, cNext_val] have h1 : (1 + Fintype.card V) % Fintype.card V = 1 := by rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h1] by_cases hlt : d.1 + 1 < Fintype.card V · rw [if_pos hlt, add_comm, Nat.mod_eq_of_lt hlt] · rw [if_neg hlt, show 1 + d.1 = Fintype.card V by omega, Nat.mod_self] have hright : cShift hn (2 * (d.1 / 2)) (cRefl hn 1 d) = cNext hn ⟨0, hn⟩ := by ext; dsimp [cShift, cRefl]; rw [h2d, cNext_val]; dsimp rw [if_pos (by omega : 0 + 1 < Fintype.card V)] have h1 : ((1 + Fintype.card V - d.1) % Fintype.card V + d.1) % Fintype.card V = (1 + Fintype.card V - d.1 + d.1) % Fintype.card V := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [h1, show 1 + Fintype.card V - d.1 + d.1 = 1 + Fintype.card V by omega, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hleft, hright] at hsh_ref have h0_ne_d : (⟨0, hn⟩ : Fin (Fintype.card V)) ≠ d := fun h => G.loopless.irrefl _ (h ▸ h0d_adj) have h0_ne_nd : (⟨0, hn⟩ : Fin (Fintype.card V)) ≠ cNext hn d := by intro h; apply h0d_not; rw [c.mem_edgeSet_iff]; right; rw [h, cPrev_cNext] have hn0_ne_d : cNext hn ⟨0, hn⟩ ≠ d := by intro h; apply h0d_not; rw [c.mem_edgeSet_iff]; left; exact h.symm obtain ⟨c', hne, _, _⟩ := exists_second_hamCycle_of_crossing_chords c ⟨0, hn⟩ d h0d_adj hsh_ref.symm h0_ne_d h0_ne_nd hn0_ne_d have hsub : ({c.edgeSet, c'.edgeSet} : Finset (Finset (Sym2 V))) ⊆ hamCycles G := by intro E hE; simp only [Finset.mem_insert, Finset.mem_singleton] at hE rcases hE with rfl | rfl · exact c.edgeSet_mem_hamCycles · exact c'.edgeSet_mem_hamCycles calc 2 = ({c.edgeSet, c'.edgeSet} : Finset (Finset (Sym2 V))).card := (Finset.card_pair hne.symm).symm _ ≤ (hamCycles G).card := Finset.card_le_card hsub · -- ALL chords cross parity → G is BIPARTITE → ≥ 5 Hamiltonian cycles! push Not at hsame let col : V → Bool := fun v => decide ((c.toEquiv.symm v).1 % 2 = 1) have hbip : ∀ x y : V, G.Adj x y → col x ≠ col y := by intro x y hxy let ix := c.toEquiv.symm x let iy := c.toEquiv.symm y have hix : c.toEquiv ix = x := by simp [ix] have hiy : c.toEquiv iy = y := by simp [iy] have hpar_ne : ix.1 % 2 ≠ iy.1 % 2 := by by_cases hmem : s(x, y) ∈ c.edgeSet · rw [← hix, ← hiy, c.mem_edgeSet_iff] at hmem obtain ⟨m, hm⟩ := heven have hix_lt := ix.2 rcases hmem with h1 | h2 · rw [h1, cNext_val]; split_ifs <;> omega · rw [h2, cPrev_val]; split_ifs <;> omega · exact hsame ix iy ⟨by rw [hix, hiy]; exact hxy, by rw [hix, hiy]; exact hmem⟩ dsimp [col] rcases Nat.mod_two_eq_zero_or_one ix.1 with h1 | h1 <;> rcases Nat.mod_two_eq_zero_or_one iy.1 with h2 | h2 <;> simp [ix, iy, h1, h2] at hpar_ne ⊢ exact le_trans (by decide : 2 ≤ 5) (card_hamCycles_ge_five_of_bipartite hreg col hbip c) · -- Odd n: iterating `i ↦ i + 2` `(n + 1) / 2` times gives `i ↦ i + 1`! have hodd := Nat.not_even_iff_odd.mp heven obtain ⟨m, hm⟩ := hodd apply hwin_rot1 intro i j hij have h := hstep2k (m + 1) i j hij have hcs : ∀ x : Fin (Fintype.card V), cShift hn (2 * (m + 1)) x = cNext hn x := fun x => by ext; dsimp [cShift, cNext] have : x.1 + 2 * (m + 1) = (x.1 + 1) + Fintype.card V := by omega rw [this, Nat.add_mod_right] rwa [hcs i, hcs j] at h · -- BOTH φ₁ (1 - i) and φ₂ (2 - i) are reflections → φ₂ ∘ φ₁ is the 1-step rotation! apply hwin_rot1 intro i j hij have h1 := hφ_adj φ₁ (cRefl hn 1) hrefl₁ i j hij have h2 := hφ_adj φ₂ (cRefl hn 2) hrefl₂ _ _ h1 have hcomp : ∀ x : Fin (Fintype.card V), cRefl hn 2 (cRefl hn 1 x) = cNext hn x := fun x => by ext; dsimp [cRefl, cNext] have hsub : (2 + Fintype.card V - (1 + Fintype.card V - x.1) % Fintype.card V) % Fintype.card V = (x.1 + 1) % Fintype.card V := by by_cases hx0 : x.1 = 0 · rw [hx0, Nat.sub_zero, zero_add, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega : 1 < Fintype.card V), show 2 + Fintype.card V - 1 = 1 + Fintype.card V by omega, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega : 1 < Fintype.card V)] · by_cases hx1 : x.1 = 1 · rw [hx1, show 1 + Fintype.card V - 1 = Fintype.card V by omega, Nat.mod_self, Nat.sub_zero, Nat.add_mod_right] · have hmod : (1 + Fintype.card V - x.1) % Fintype.card V = 1 + Fintype.card V - x.1 := Nat.mod_eq_of_lt (by omega) rw [hmod, show 2 + Fintype.card V - (1 + Fintype.card V - x.1) = x.1 + 1 by omega] exact hsub rwa [hcomp i, hcomp j] at h2 /-- Cayley graph `Cay(Γ, S)` on a finite group `Γ` with symmetric unit-free generating set `S`. -/ def cayleyGraph (Γ : Type*) [Group Γ] (S : Set Γ) (hS_symm : ∀ s ∈ S, s⁻¹ ∈ S) (hS_one : (1 : Γ) ∉ S) : SimpleGraph Γ where Adj x y := x⁻¹ * y ∈ S symm := ⟨fun x y h => by have h' := hS_symm _ h rwa [mul_inv_rev, inv_inv] at h'⟩ loopless := ⟨fun x h => by rw [inv_mul_cancel] at h; exact hS_one h⟩ lemma cayleyGraph_vertex_transitive (Γ : Type*) [Group Γ] (S : Set Γ) (hS_symm : ∀ s ∈ S, s⁻¹ ∈ S) (hS_one : (1 : Γ) ∉ S) : IsVertexTransitive (cayleyGraph Γ S hS_symm hS_one) := by intro u v refine ⟨ { toFun := fun x => (v * u⁻¹) * x invFun := fun x => (u * v⁻¹) * x left_inv := fun x => by group right_inv := fun x => by group map_rel_iff' := fun {x y} => by dsimp [cayleyGraph] have h : ((v * u⁻¹) * x)⁻¹ * ((v * u⁻¹) * y) = x⁻¹ * y := by group rw [h] }, by dsimp; group⟩ /-- **Theorem 5b (All 4-Regular Hamiltonian Cayley Graphs Satisfy Sheehan's Conjecture)**: -/ theorem sheehan_cayley (Γ : Type*) [Group Γ] [Fintype Γ] [DecidableEq Γ] (S : Set Γ) (hS_symm : ∀ s ∈ S, s⁻¹ ∈ S) (hS_one : (1 : Γ) ∉ S) (hreg : (cayleyGraph Γ S hS_symm hS_one).IsRegularOfDegree 4) (c : DirHamCycle (cayleyGraph Γ S hS_symm hS_one)) : 2 ≤ (hamCycles (cayleyGraph Γ S hS_symm hS_one)).card := sheehan_vertex_transitive hreg (cayleyGraph_vertex_transitive Γ S hS_symm hS_one) c /-- Circulant graph `Circ(n; a, b)` on `ZMod n`. -/ def circulantGraph (n a b : ℕ) : SimpleGraph (ZMod n) where Adj x y := x ≠ y ∧ (y - x = (a : ZMod n) ∨ y - x = -(a : ZMod n) ∨ y - x = (b : ZMod n) ∨ y - x = -(b : ZMod n)) symm := ⟨fun x y h => by refine ⟨h.1.symm, ?_⟩ have hneg : x - y = -(y - x) := by ring rw [hneg] rcases h.2 with h1 | h2 | h3 | h4 · right; left; rw [h1] · left; rw [h2, neg_neg] · right; right; right; rw [h3] · right; right; left; rw [h4, neg_neg]⟩ loopless := ⟨fun _ h => h.1 rfl⟩ lemma circulantGraph_vertex_transitive (n a b : ℕ) : IsVertexTransitive (circulantGraph n a b) := by intro u v refine ⟨ { toFun := fun x => x + (v - u) invFun := fun x => x - (v - u) left_inv := fun x => by ring right_inv := fun x => by ring map_rel_iff' := fun {x y} => by dsimp [circulantGraph] have h1 : (¬ x + (v - u) = y + (v - u)) ↔ ¬ x = y := by constructor <;> intro h heq <;> apply h <;> [rw [heq]; exact add_right_cancel heq] have h2 : (y + (v - u)) - (x + (v - u)) = y - x := by ring rw [h1, h2] }, by dsimp; ring⟩ /-- **Theorem 5c (All 4-Regular Hamiltonian Circulant Graphs Satisfy Sheehan's Conjecture)**: -/ theorem sheehan_circulant {n a b : ℕ} [NeZero n] (hreg : (circulantGraph n a b).IsRegularOfDegree 4) (c : DirHamCycle (circulantGraph n a b)) : 2 ≤ (hamCycles (circulantGraph n a b)).card := sheehan_vertex_transitive hreg (circulantGraph_vertex_transitive n a b) c /-- **Theorem 5c-ii (Explicit Multiplicity for Coprime Circulants `Circ(n; 1, b)`)**: For every `n ≥ 5` and `2 ≤ b ≤ n - 2`, `Circ(n; 1, b)` is explicitly Hamiltonian and has **AT LEAST `n / 2 + 1` (in particular `≥ 3`) DISTINCT HAMILTONIAN CYCLES** via shifted 2-switches! -/ theorem card_hamCycles_circulant_one_ge {n b : ℕ} (hn : 5 ≤ n) (hb1 : 2 ≤ b) (hb2 : b + 2 ≤ n) : have : NeZero n := ⟨by omega⟩ n / 2 + 1 ≤ (hamCycles (circulantGraph n 1 b)).card := by have : NeZero n := ⟨by omega⟩ have : Fact (1 < n) := ⟨by omega⟩ have hpos : 0 < n := by omega have hcard : Fintype.card (ZMod n) = n := ZMod.card n -- Explicit Hamiltonian cycle c : i ↦ (i : ZMod n)! let e : Fin (Fintype.card (ZMod n)) ≃ ZMod n := Equiv.ofBijective (fun k : Fin (Fintype.card (ZMod n)) => (k.1 : ZMod n)) ⟨fun i j hij => by have h1 := congrArg ZMod.val hij have hi : i.1 < n := by have := i.2; omega have hj : j.1 < n := by have := j.2; omega rw [ZMod.val_natCast, ZMod.val_natCast, Nat.mod_eq_of_lt hi, Nat.mod_eq_of_lt hj] at h1 exact Fin.ext h1, fun z => ⟨⟨z.val, by have := z.val_lt; omega⟩, ZMod.natCast_zmod_val z⟩⟩ have he_val : ∀ k : Fin (Fintype.card (ZMod n)), e k = (k.1 : ZMod n) := fun _ => rfl let c : DirHamCycle (circulantGraph n 1 b) := { card_ge_three := by rw [hcard]; omega toEquiv := e adj_next := fun i => by rw [he_val, he_val] have hdiff : ((cNext (by omega) i).1 : ZMod n) - (i.1 : ZMod n) = (1 : ZMod n) := by rw [cNext_val] by_cases hlt : i.1 + 1 < Fintype.card (ZMod n) · rw [if_pos hlt]; push_cast; ring · rw [if_neg hlt] have hi : i.1 = n - 1 := by omega rw [hi, Nat.cast_zero, zero_sub] have h1 : ((n - 1 : ℕ) : ZMod n) + ((1 : ℕ) : ZMod n) = 0 := by rw [← Nat.cast_add, show n - 1 + 1 = n by omega, ZMod.natCast_self] rw [Nat.cast_one] at h1 exact eq_of_sub_eq_zero (by linear_combination -h1) refine ⟨?_, Or.inl (by simpa using hdiff)⟩ intro heq rw [heq, sub_self] at hdiff have h10 : (1 : ZMod n) = 0 := hdiff.symm have := congrArg ZMod.val h10 rw [ZMod.val_one, ZMod.val_zero] at this exact absurd this (by decide) } have hn' : 0 < Fintype.card (ZMod n) := by omega have hbij : ∀ x : Fin (Fintype.card (ZMod n)), (cShift hn' b x).1 = (x.1 + b) % n := fun x => congrArg ((x.1 + b) % ·) hcard have hne_b : (b : ZMod n) ≠ 0 := by intro h0 have := congrArg ZMod.val h0 rw [ZMod.val_natCast, Nat.mod_eq_of_lt (by omega), ZMod.val_zero] at this omega have hsw : ∀ i : Fin (Fintype.card (ZMod n)), ∃ c' : DirHamCycle (circulantGraph n 1 b), c'.edgeSet ≠ c.edgeSet ∧ (∀ e ∈ c'.edgeSet, e ∉ c.edgeSet → e = s(c.toEquiv i, c.toEquiv (cShift hn' b i)) ∨ e = s(c.toEquiv (cNext hn' i), c.toEquiv (cNext hn' (cShift hn' b i)))) ∧ s(c.toEquiv i, c.toEquiv (cShift hn' b i)) ∈ c'.edgeSet := by intro i let j := cShift hn' b i have hdiff : ∀ x : Fin (Fintype.card (ZMod n)), c.toEquiv (cShift hn' b x) - c.toEquiv x = (b : ZMod n) := by intro x; change e (cShift hn' b x) - e x = (b : ZMod n) rw [he_val, he_val, hbij x] have hmod : (((x.1 + b) % n : ℕ) : ZMod n) = (x.1 : ZMod n) + (b : ZMod n) := by rw [← Nat.cast_add, ZMod.natCast_mod] rw [hmod]; ring have hadj_b : ∀ x : Fin (Fintype.card (ZMod n)), (circulantGraph n 1 b).Adj (c.toEquiv x) (c.toEquiv (cShift hn' b x)) := by intro x refine ⟨?_, Or.inr (Or.inr (Or.inl (hdiff x)))⟩ intro heq; apply hne_b; rw [← hdiff x, heq, sub_self] have h1 := hadj_b i have h2 : (circulantGraph n 1 b).Adj (c.toEquiv (cNext hn' i)) (c.toEquiv (cNext hn' j)) := by rw [show cNext hn' j = cShift hn' b (cNext hn' i) from (cShift_cNext hn' b i).symm] exact hadj_b (cNext hn' i) have hij : i ≠ j := by intro h; have := congrArg Fin.val h; rw [hbij i] at this have hi_lt : i.1 < n := by have := i.2; omega by_cases hlt : i.1 + b < n · rw [Nat.mod_eq_of_lt hlt] at this; omega · have hmod : (i.1 + b) % n = i.1 + b - n := by have : i.1 + b = (i.1 + b - n) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hmod] at this; omega have hi_nj : i ≠ cNext hn' j := by intro h have hi_lt : i.1 < n := by have := i.2; omega have h1' : (cNext hn' j).1 = (i.1 + b + 1) % n := by rw [← cShift_cNext, hbij, cNext_val] by_cases hlt : i.1 + 1 < Fintype.card (ZMod n) · rw [if_pos hlt]; congr 1; omega · rw [if_neg hlt] have hi : i.1 = n - 1 := by omega rw [hi, zero_add, show n - 1 + b + 1 = b + n by omega, Nat.add_mod_right] have := congrArg Fin.val h; rw [h1'] at this by_cases hlt : i.1 + b + 1 < n · rw [Nat.mod_eq_of_lt hlt] at this; omega · have hmod : (i.1 + b + 1) % n = i.1 + b + 1 - n := by have : i.1 + b + 1 = (i.1 + b + 1 - n) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hmod] at this; omega have hni_j : cNext hn' i ≠ j := by intro h have hi_lt : i.1 < n := by have := i.2; omega have h1' := congrArg Fin.val h rw [cNext_val, hbij i] at h1' by_cases hlt1 : i.1 + 1 < Fintype.card (ZMod n) · rw [if_pos hlt1] at h1' by_cases hlt2 : i.1 + b < n · rw [Nat.mod_eq_of_lt hlt2] at h1'; omega · have hmod : (i.1 + b) % n = i.1 + b - n := by have : i.1 + b = (i.1 + b - n) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hmod] at h1'; omega · rw [if_neg hlt1] at h1' have hi : i.1 = n - 1 := by omega rw [hi] at h1' have hmod : (n - 1 + b) % n = b - 1 := by have : n - 1 + b = (b - 1) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hmod] at h1'; omega let Gi : SimpleGraph (ZMod n) := { Adj := fun x y => s(x, y) ∈ c.edgeSet ∨ s(x, y) = s(c.toEquiv i, c.toEquiv j) ∨ s(x, y) = s(c.toEquiv (cNext hn' i), c.toEquiv (cNext hn' j)) symm := ⟨fun _ _ h => by rcases h with h | h | h · left; rwa [Sym2.eq_swap] · right; left; rwa [Sym2.eq_swap] · right; right; rwa [Sym2.eq_swap]⟩ loopless := ⟨fun x h => by rcases h with h | h | h · exact (circulantGraph n 1 b).loopless.irrefl x (c.adj_of_mem_edgeSet h) · rcases Sym2.eq_iff.mp h with ⟨rfl, h2'⟩ | ⟨rfl, h2'⟩ · exact hij (c.toEquiv.injective h2') · exact hij.symm (c.toEquiv.injective h2') · rcases Sym2.eq_iff.mp h with ⟨rfl, h2'⟩ | ⟨rfl, h2'⟩ · exact hij (cNext_injective hn' (c.toEquiv.injective h2')) · exact hij.symm (cNext_injective hn' (c.toEquiv.injective h2'))⟩ } have hGi_le : Gi ≤ circulantGraph n 1 b := fun x y h => by rcases h with h | h | h · exact c.adj_of_mem_edgeSet h · rcases Sym2.eq_iff.mp h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ · exact h1 · exact h1.symm · rcases Sym2.eq_iff.mp h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ · exact h2 · exact h2.symm let ci : DirHamCycle Gi := { card_ge_three := c.card_ge_three toEquiv := c.toEquiv adj_next := fun k => Or.inl (Finset.mem_image.mpr ⟨k, Finset.mem_univ _, rfl⟩) } obtain ⟨c', hne, _, hmem_ij⟩ := exists_second_hamCycle_of_crossing_chords ci i j (Or.inr (Or.inl rfl)) (Or.inr (Or.inr rfl)) hij hi_nj hni_j refine ⟨c'.map_le hGi_le, hne, ?_, hmem_ij⟩ intro f hfE hfc rcases Sym2.mk_surjective f with ⟨⟨x, y⟩, rfl⟩ rcases c'.adj_of_mem_edgeSet hfE with hc | h1' | h2' · exact absurd hc hfc · exact Or.inl h1' · exact Or.inr h2' let f : Fin (Fintype.card (ZMod n)) → Finset (Sym2 (ZMod n)) := fun i => (hsw i).choose.edgeSet let F : Finset (Finset (Sym2 (ZMod n))) := Finset.univ.image f have hfiber : ∀ E ∈ F, (Finset.univ.filter (fun i => f i = E)).card ≤ 2 := by intro E hE rcases Finset.mem_image.mp hE with ⟨i₀, _, rfl⟩ have hsub : Finset.univ.filter (fun i => f i = f i₀) ⊆ {i₀, cShift hn' b i₀} := by intro i hi have hfeq : f i = f i₀ := (Finset.mem_filter.mp hi).2 have hch_in_i : s(c.toEquiv i, c.toEquiv (cShift hn' b i)) ∈ f i := (hsw i).choose_spec.2.2 have hch_not_c : ∀ x : Fin (Fintype.card (ZMod n)), s(c.toEquiv x, c.toEquiv (cShift hn' b x)) ∉ c.edgeSet := by intro x hmem have hx_lt : x.1 < n := by have := x.2; omega rw [c.mem_edgeSet_iff] at hmem rcases hmem with h1 | h2 · have hv := congrArg Fin.val h1; rw [hbij x, cNext_val] at hv by_cases hlt : x.1 + 1 < Fintype.card (ZMod n) · rw [if_pos hlt] at hv by_cases hlt2 : x.1 + b < n · rw [Nat.mod_eq_of_lt hlt2] at hv; omega · have hm : (x.1 + b) % n = x.1 + b - n := by have : x.1 + b = (x.1 + b - n) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hm] at hv; omega · rw [if_neg hlt] at hv have hx : x.1 = n - 1 := by omega rw [hx] at hv have hm : (n - 1 + b) % n = b - 1 := by have : n - 1 + b = (b - 1) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hm] at hv; omega · have hv := congrArg Fin.val h2; rw [hbij x, cPrev_val] at hv by_cases hx0 : x.1 = 0 · rw [if_pos hx0, hx0, zero_add, Nat.mod_eq_of_lt (by omega)] at hv; omega · rw [if_neg hx0] at hv by_cases hlt2 : x.1 + b < n · rw [Nat.mod_eq_of_lt hlt2] at hv; omega · have hm : (x.1 + b) % n = x.1 + b - n := by have : x.1 + b = (x.1 + b - n) + n := by omega conv_lhs => rw [this] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hm] at hv; omega have hch_in_i0 : s(c.toEquiv i, c.toEquiv (cShift hn' b i)) ∈ (hsw i₀).choose.edgeSet := by change s(c.toEquiv i, c.toEquiv (cShift hn' b i)) ∈ f i₀ rwa [← hfeq] have hdisj1 := (hsw i₀).choose_spec.2.1 _ hch_in_i0 (hch_not_c i) have hch_in_0i : s(c.toEquiv i₀, c.toEquiv (cShift hn' b i₀)) ∈ (hsw i).choose.edgeSet := by change s(c.toEquiv i₀, c.toEquiv (cShift hn' b i₀)) ∈ f i rw [hfeq]; exact (hsw i₀).choose_spec.2.2 have hdisj2 := (hsw i).choose_spec.2.1 _ hch_in_0i (hch_not_c i₀) have heq_ch : ∀ x y : Fin (Fintype.card (ZMod n)), s(c.toEquiv x, c.toEquiv (cShift hn' b x)) = s(c.toEquiv y, c.toEquiv (cShift hn' b y)) → x = y ∨ x = cShift hn' b y := by intro x y hs rcases Sym2.eq_iff.mp hs with ⟨h1, _⟩ | ⟨h1, _⟩ · left; exact c.toEquiv.injective h1 · right; exact c.toEquiv.injective h1 simp only [Finset.mem_insert, Finset.mem_singleton] rcases hdisj1 with h1 | h1 · exact heq_ch i i₀ h1 · rcases hdisj2 with h2 | h2 · exact heq_ch i i₀ h2.symm · exfalso rw [← cShift_cNext] at h1 h2 have hswap_2b : ∀ x y : Fin (Fintype.card (ZMod n)), s(c.toEquiv x, c.toEquiv (cShift hn' b x)) = s(c.toEquiv y, c.toEquiv (cShift hn' b y)) → x = y ∨ (x = cShift hn' b y ∧ y = cShift hn' b x) := by intro x y hs rcases Sym2.eq_iff.mp hs with ⟨h1', _⟩ | ⟨h1', h2'⟩ · left; exact c.toEquiv.injective h1' · right; exact ⟨c.toEquiv.injective h1', (c.toEquiv.injective h2').symm⟩ have hA' := hswap_2b i (cNext hn' i₀) h1 have hB' := hswap_2b i₀ (cNext hn' i) h2 have hval_add : ∀ (x : Fin (Fintype.card (ZMod n))), ((cNext hn' x).1 : ZMod n) = (x.1 : ZMod n) + 1 := by intro x; rw [cNext_val] by_cases hlt : x.1 + 1 < Fintype.card (ZMod n) · rw [if_pos hlt]; push_cast; ring · rw [if_neg hlt] have hx : x.1 = n - 1 := by omega rw [hx, Nat.cast_zero] have h1' : ((n - 1 : ℕ) : ZMod n) + ((1 : ℕ) : ZMod n) = 0 := by rw [← Nat.cast_add, show n - 1 + 1 = n by omega, ZMod.natCast_self] rw [Nat.cast_one] at h1'; exact h1'.symm have hval_sh : ∀ (x : Fin (Fintype.card (ZMod n))), ((cShift hn' b x).1 : ZMod n) = (x.1 : ZMod n) + (b : ZMod n) := by intro x; rw [hbij x, ← Nat.cast_add, ZMod.natCast_mod] have h2ne0 : (2 : ZMod n) ≠ 0 := by intro h; have := congrArg ZMod.val h rw [show (2 : ZMod n) = ((2 : ℕ) : ZMod n) by norm_num, ZMod.val_natCast, Nat.mod_eq_of_lt (by omega), ZMod.val_zero] at this; omega have h4ne0 : (4 : ZMod n) ≠ 0 := by intro h; have := congrArg ZMod.val h rw [show (4 : ZMod n) = ((4 : ℕ) : ZMod n) by norm_num, ZMod.val_natCast, Nat.mod_eq_of_lt (by omega), ZMod.val_zero] at this; omega rcases hA' with hA1 | ⟨hA1, hA2⟩ <;> rcases hB' with hB1 | ⟨hB1, hB2⟩ · have h1z : (i.1 : ZMod n) = (i₀.1 : ZMod n) + 1 := by rw [hA1, hval_add] have h2z : (i₀.1 : ZMod n) = (i.1 : ZMod n) + 1 := by rw [hB1, hval_add] exact h2ne0 (by linear_combination -h1z - h2z) · have h1z : (i.1 : ZMod n) = (i₀.1 : ZMod n) + 1 := by rw [hA1, hval_add] have h2z : (i₀.1 : ZMod n) = (i.1 : ZMod n) + 1 + (b : ZMod n) := by rw [hB1, hval_sh, hval_add] have h3z : (i.1 : ZMod n) + 1 = (i₀.1 : ZMod n) + (b : ZMod n) := by rw [← hval_add i, hB2, hval_sh] exact h4ne0 (by linear_combination -h1z - h2z + h3z - h1z) · have h1z : (i.1 : ZMod n) = (i₀.1 : ZMod n) + 1 + (b : ZMod n) := by rw [hA1, hval_sh, hval_add] have h2z : (i₀.1 : ZMod n) + 1 = (i.1 : ZMod n) + (b : ZMod n) := by rw [← hval_add i₀, hA2, hval_sh] have h3z : (i₀.1 : ZMod n) = (i.1 : ZMod n) + 1 := by rw [hB1, hval_add] exact h4ne0 (by linear_combination -h1z - h3z + h2z - h3z) · have h1z : (i.1 : ZMod n) = (i₀.1 : ZMod n) + 1 + (b : ZMod n) := by rw [hA1, hval_sh, hval_add] have h2z : (i₀.1 : ZMod n) = (i.1 : ZMod n) + 1 + (b : ZMod n) := by rw [hB1, hval_sh, hval_add] have h3z : (i₀.1 : ZMod n) + 1 = (i.1 : ZMod n) + (b : ZMod n) := by rw [← hval_add i₀, hA2, hval_sh] exact h2ne0 (by linear_combination -h1z - h2z + (h1z + h3z)) calc (Finset.univ.filter (fun i => f i = f i₀)).card ≤ ({i₀, cShift hn' b i₀} : Finset (Fin (Fintype.card (ZMod n)))).card := Finset.card_le_card hsub _ ≤ 2 := Finset.card_le_two have hsum : n ≤ 2 * F.card := by calc n = (Finset.univ : Finset (Fin (Fintype.card (ZMod n)))).card := by rw [Finset.card_univ, Fintype.card_fin, hcard] _ = ∑ E ∈ F, (Finset.univ.filter (fun i => f i = E)).card := by exact Finset.card_eq_sum_card_fiberwise (f := f) (t := F) (fun i _ => Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) _ ≤ ∑ _E ∈ F, 2 := Finset.sum_le_sum hfiber _ = 2 * F.card := by rw [Finset.sum_const, smul_eq_mul, mul_comm] have hc_not_F : c.edgeSet ∉ F := by intro hmem rcases Finset.mem_image.mp hmem with ⟨i, _, hi⟩ exact (hsw i).choose_spec.1 hi have hsub : insert c.edgeSet F ⊆ hamCycles (circulantGraph n 1 b) := by intro E hE rcases Finset.mem_insert.mp hE with rfl | hF · exact c.edgeSet_mem_hamCycles · rcases Finset.mem_image.mp hF with ⟨i, _, rfl⟩ exact (hsw i).choose.edgeSet_mem_hamCycles calc n / 2 + 1 ≤ F.card + 1 := by omega _ = (insert c.edgeSet F).card := by rw [Finset.card_insert_of_notMem hc_not_F] _ ≤ (hamCycles (circulantGraph n 1 b)).card := Finset.card_le_card hsub /-- Torus grid graph `C_a □ C_b` on `Fin a × Fin b` (`a, b ≥ 3`). -/ def torusGrid (a b : ℕ) (ha : 3 ≤ a) (hb : 3 ≤ b) : SimpleGraph (Fin a × Fin b) where Adj p q := (p.1 = q.1 ∧ (q.2 = cNext (by omega) p.2 ∨ q.2 = cPrev (by omega) p.2)) ∨ (p.2 = q.2 ∧ (q.1 = cNext (by omega) p.1 ∨ q.1 = cPrev (by omega) p.1)) symm := ⟨fun p q h => by rcases h with ⟨h1, h2 | h2⟩ | ⟨h1, h2 | h2⟩ · left; refine ⟨h1.symm, Or.inr ?_⟩; rw [h2, cPrev_cNext] · left; refine ⟨h1.symm, Or.inl ?_⟩; rw [h2, cNext_cPrev] · right; refine ⟨h1.symm, Or.inr ?_⟩; rw [h2, cPrev_cNext] · right; refine ⟨h1.symm, Or.inl ?_⟩; rw [h2, cNext_cPrev]⟩ loopless := ⟨fun p h => by rcases h with ⟨_, h2 | h2⟩ | ⟨_, h2 | h2⟩ · exact cNext_ne_self (by omega) p.2 h2.symm · exact cNext_ne_self (by omega) (cPrev (by omega) p.2) (by rw [cNext_cPrev]; exact h2) · exact cNext_ne_self (by omega) p.1 h2.symm · exact cNext_ne_self (by omega) (cPrev (by omega) p.1) (by rw [cNext_cPrev]; exact h2)⟩ lemma torusGrid_vertex_transitive (a b : ℕ) (ha : 3 ≤ a) (hb : 3 ≤ b) : IsVertexTransitive (torusGrid a b ha hb) := by intro p q have ha0 : 0 < a := by omega have hb0 : 0 < b := by omega let da := (q.1.1 + a - p.1.1) % a let db := (q.2.1 + b - p.2.1) % b let φEquiv : Fin a × Fin b ≃ Fin a × Fin b := Equiv.prodCongr (cShift ha0 da) (cShift hb0 db) have hprev_shift : ∀ {n : ℕ} (hn : 0 < n) (k : ℕ) (i : Fin n), cShift hn k (cPrev hn i) = cPrev hn (cShift hn k i) := fun hn k i => by rw [← cPrev_cNext hn (cShift hn k (cPrev hn i)), ← cShift_cNext, cNext_cPrev] refine ⟨ { toEquiv := φEquiv map_rel_iff' := fun {x y} => by dsimp [φEquiv, torusGrid] have h1 : (cShift ha0 da x.1 = cShift ha0 da y.1) ↔ x.1 = y.1 := (cShift ha0 da).injective.eq_iff have h2 : (cShift hb0 db x.2 = cShift hb0 db y.2) ↔ x.2 = y.2 := (cShift hb0 db).injective.eq_iff have hn1 : (cShift ha0 da y.1 = cNext ha0 (cShift ha0 da x.1)) ↔ y.1 = cNext ha0 x.1 := by rw [← cShift_cNext]; exact (cShift ha0 da).injective.eq_iff have hp1 : (cShift ha0 da y.1 = cPrev ha0 (cShift ha0 da x.1)) ↔ y.1 = cPrev ha0 x.1 := by rw [← hprev_shift]; exact (cShift ha0 da).injective.eq_iff have hn2 : (cShift hb0 db y.2 = cNext hb0 (cShift hb0 db x.2)) ↔ y.2 = cNext hb0 x.2 := by rw [← cShift_cNext]; exact (cShift hb0 db).injective.eq_iff have hp2 : (cShift hb0 db y.2 = cPrev hb0 (cShift hb0 db x.2)) ↔ y.2 = cPrev hb0 x.2 := by rw [← hprev_shift]; exact (cShift hb0 db).injective.eq_iff simp only [Equiv.prodCongr_apply, Prod.map_fst, Prod.map_snd] rw [h1, h2, hn1, hp1, hn2, hp2] }, by ext · change (cShift ha0 da p.1).1 = q.1.1; dsimp [cShift, da] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod, show p.1.1 + (q.1.1 + a - p.1.1) = q.1.1 + a by omega, Nat.add_mod_right, Nat.mod_eq_of_lt q.1.2] · change (cShift hb0 db p.2).1 = q.2.1; dsimp [cShift, db] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod, show p.2.1 + (q.2.1 + b - p.2.1) = q.2.1 + b by omega, Nat.add_mod_right, Nat.mod_eq_of_lt q.2.2]⟩ lemma torusGrid_isRegularOfDegree_four (a b : ℕ) (ha : 3 ≤ a) (hb : 3 ≤ b) : (torusGrid a b ha hb).IsRegularOfDegree 4 := by intro p have ha0 : 0 < a := by omega have hb0 : 0 < b := by omega let q1 : Fin a × Fin b := (p.1, cNext hb0 p.2) let q2 : Fin a × Fin b := (p.1, cPrev hb0 p.2) let q3 : Fin a × Fin b := (cNext ha0 p.1, p.2) let q4 : Fin a × Fin b := (cPrev ha0 p.1, p.2) have hnb : (torusGrid a b ha hb).neighborFinset p = {q1, q2, q3, q4} := by ext q rw [SimpleGraph.mem_neighborFinset] simp only [Finset.mem_insert, Finset.mem_singleton, torusGrid, q1, q2, q3, q4, Prod.ext_iff] tauto have h12 : q1 ≠ q2 := fun h => cNext_ne_cPrev hb p.2 (congrArg Prod.snd h) have h13 : q1 ≠ q3 := fun h => cNext_ne_self (by omega) p.1 (congrArg Prod.fst h).symm have h14 : q1 ≠ q4 := fun h => cNext_ne_self (by omega) (cPrev ha0 p.1) (by rw [cNext_cPrev]; exact congrArg Prod.fst h) have h23 : q2 ≠ q3 := fun h => cNext_ne_self (by omega) p.1 (congrArg Prod.fst h).symm have h24 : q2 ≠ q4 := fun h => cNext_ne_self (by omega) (cPrev ha0 p.1) (by rw [cNext_cPrev]; exact congrArg Prod.fst h) have h34 : q3 ≠ q4 := fun h => cNext_ne_cPrev ha p.1 (congrArg Prod.fst h) rw [← SimpleGraph.card_neighborFinset_eq_degree, hnb, Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_pair h34] · simp [h23, h24] · simp [h12, h13, h14] /-- **Theorem 5d (All Hamiltonian Torus Grids `C_a □ C_b` Satisfy Sheehan's Conjecture)**: -/ theorem sheehan_torus_grid {a b : ℕ} (ha : 3 ≤ a) (hb : 3 ≤ b) (c : DirHamCycle (torusGrid a b ha hb)) : 2 ≤ (hamCycles (torusGrid a b ha hb)).card := sheehan_vertex_transitive (torusGrid_isRegularOfDegree_four a b ha hb) (torusGrid_vertex_transitive a b ha hb) c /-- **Theorem 5d-ii (Even-by-Even Torus Grids `C_{2m} □ C_{2k}` Have `≥ 5` Hamiltonian Cycles)**: -/ theorem card_hamCycles_torus_grid_even {a b : ℕ} (ha : 4 ≤ a) (hb : 4 ≤ b) (hae : Even a) (hbe : Even b) (c : DirHamCycle (torusGrid a b (by omega) (by omega))) : 5 ≤ (hamCycles (torusGrid a b (by omega) (by omega))).card := by let col : Fin a × Fin b → Bool := fun p => decide ((p.1.1 + p.2.1) % 2 = 1) apply card_hamCycles_ge_five_of_bipartite (torusGrid_isRegularOfDegree_four a b (by omega) (by omega)) col _ c intro p q hpq obtain ⟨ma, hma⟩ := hae obtain ⟨mb, hmb⟩ := hbe dsimp [torusGrid] at hpq have hpar : (p.1.1 + p.2.1) % 2 ≠ (q.1.1 + q.2.1) % 2 := by rcases hpq with ⟨h1, h2 | h2⟩ | ⟨h1, h2 | h2⟩ · rw [← h1, h2, cNext_val]; split_ifs <;> omega · rw [← h1, h2, cPrev_val]; split_ifs <;> omega · rw [← h1, h2, cNext_val]; split_ifs <;> omega · rw [← h1, h2, cPrev_val]; split_ifs <;> omega dsimp [col] rcases Nat.mod_two_eq_zero_or_one (p.1.1 + p.2.1) with h1 | h1 <;> rcases Nat.mod_two_eq_zero_or_one (q.1.1 + q.2.1) with h2 | h2 <;> simp [h1, h2] at hpar ⊢ end VertexTransitive /-! ## Section 6: Pure Structural Resolution of Sheehan's Conjecture for ALL `n ≤ 12` We prove Sheehan's Conjecture for **EVERY** 4-regular Hamiltonian simple graph on `n ≤ 12` vertices by pure structural arguments — **ZERO brute-force enumeration, ZERO `decide` over graph spaces** — combining our chord 2-factor multiplicity engine (Section 4) with our new Near-$C$-ID Parity Theorem (Section 3a) and Full $C$-ID Multiplicity Theorem (Section 3b): - **`n ≤ 8`** (`sheehan_of_card_le_eight`): Every chord cycle has length `≥ 3`, so `𝒟.length ≤ 2`, immediately resolved by Theorem 4d-ii. - **`n = 9`** (`sheehan_of_card_nine`): Either `≤ 1` odd chord cycle (Theorem 4c), or `3+3+3`, where a `C₉`-independent transversal yields **`≥ 3` Hamiltonian cycles** (Theorem 3b). - **`n = 10`** (`sheehan_of_card_ten`): Either `≤ 1` odd cycle or `≤ 2` components, or `3+3+4`; two disjoint triangles cannot be `C₁₀`-separated since `2 · 6 > 10`, forcing adjacency (Theorem 4d-i). - **`n = 11`** (`sheehan_of_card_eleven`): Either `≤ 1` odd cycle, or `3+3+5`; a pure 4-case arc analysis on `C₁₁` constructs a 4-vertex Near-$C$-ID set, resolving via Theorem 3a. - **`n = 12`** (`sheehan_of_card_twelve`): - `m = 0`: `≥ 5` Hamiltonian cycles (Theorem 4a). - `m = 2`, adjacent odd cycles: Theorem 4d-i. - `m = 2`, separated `3+3+6`: exact parity forcing + 3-vertex Near-Domination of `C₆` → Theorem 3a. - `m = 2`, separated `3+5+4`: exact forced `{k, k+2, k+4}` geometry + 6-pairs-vs-5-edges Pigeonhole in `C₅` → Theorem 3a. - `m = 4`, `3+3+3+3`: pure double-counting (`6 > 4`) constructs a full 4-vertex $C_{12}$-ID transversal, yielding **`≥ 3` Hamiltonian cycles** (Theorem 3b)! -/ section SmallOrderStructural variable {V : Type*} [Fintype V] [DecidableEq V] /-- The 2-element Finset of cycle-neighbors of `x` on `c`. -/ def cNbr {G : SimpleGraph V} (c : DirHamCycle G) (x : V) : Finset V := let hn : 0 < Fintype.card V := by have := c.card_ge_three; omega {c.toEquiv (cPrev hn (c.toEquiv.symm x)), c.toEquiv (cNext hn (c.toEquiv.symm x))} lemma mem_cNbr_iff {G : SimpleGraph V} (c : DirHamCycle G) (x y : V) : y ∈ cNbr c x ↔ s(x, y) ∈ c.edgeSet := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega dsimp [cNbr] rw [Finset.mem_insert, Finset.mem_singleton] have hiff := c.mem_edgeSet_iff (c.toEquiv.symm x) (c.toEquiv.symm y) simp only [Equiv.apply_symm_apply] at hiff rw [hiff] constructor · rintro (rfl | rfl) · right; simp · left; simp · rintro (h | h) · right; simpa using congrArg c.toEquiv h · left; simpa using congrArg c.toEquiv h lemma mem_cNbr_symm {G : SimpleGraph V} (c : DirHamCycle G) {x y : V} : y ∈ cNbr c x ↔ x ∈ cNbr c y := by rw [mem_cNbr_iff, mem_cNbr_iff, Sym2.eq_swap] lemma self_not_mem_cNbr {G : SimpleGraph V} (c : DirHamCycle G) (x : V) : x ∉ cNbr c x := by rw [mem_cNbr_iff] intro h exact G.loopless.irrefl x (c.adj_of_mem_edgeSet h) lemma card_cNbr {G : SimpleGraph V} (c : DirHamCycle G) (x : V) : (cNbr c x).card = 2 := by have hn3 := c.card_ge_three have hn : 0 < Fintype.card V := by omega dsimp [cNbr] apply Finset.card_pair intro h exact cNext_ne_cPrev hn3 (c.toEquiv.symm x) (c.toEquiv.injective h).symm /-- Equivalence between `IsCycleIndep c A` and having no `c`-edge with both endpoints in `A`. -/ lemma isCycleIndep_iff_edges {G : SimpleGraph V} (c : DirHamCycle G) (A : Finset V) : IsCycleIndep c A ↔ ∀ x ∈ A, ∀ y ∈ A, s(x, y) ∉ c.edgeSet := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega constructor · intro hA x hx y hy hedge rw [← mem_cNbr_iff] at hedge dsimp [cNbr] at hedge simp only [Finset.mem_insert, Finset.mem_singleton] at hedge rcases hedge with rfl | rfl · have h1 := hA (cPrev hn (c.toEquiv.symm x)) hy rw [cNext_cPrev, Equiv.apply_symm_apply] at h1 exact h1 hx · exact hA (c.toEquiv.symm x) (by simpa using hx) hy · intro h i hi hnext exact h _ hi _ hnext (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) /-- Any `c`-independent set `A` satisfies `2 · |A| ≤ |V|`. -/ lemma two_mul_card_le_of_isCycleIndep {G : SimpleGraph V} (c : DirHamCycle G) {A : Finset V} (hA : IsCycleIndep c A) : 2 * A.card ≤ Fintype.card V := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega let f : V → V := fun v => c.toEquiv (cNext hn (c.toEquiv.symm v)) have hf_inj : Function.Injective f := fun x y hxy => c.toEquiv.symm.injective (cNext_injective hn (c.toEquiv.injective hxy)) have hdisj : Disjoint A (A.image f) := by rw [Finset.disjoint_left] intro x hx hfx rcases Finset.mem_image.mp hfx with ⟨a, ha, rfl⟩ exact hA (c.toEquiv.symm a) (by simpa using ha) hx have hcard_union : (A ∪ A.image f).card = 2 * A.card := by rw [Finset.card_union_of_disjoint hdisj, Finset.card_image_of_injective _ hf_inj, two_mul] calc 2 * A.card = (A ∪ A.image f).card := hcard_union.symm _ ≤ Finset.univ.card := Finset.card_le_univ _ _ = Fintype.card V := Finset.card_univ /-- Equality `2 · |A| = |V|` for a `c`-independent set forces exact alternating parity on `c`. -/ lemma isCycleIndep_half_card_next_iff {G : SimpleGraph V} (c : DirHamCycle G) {A : Finset V} (hA : IsCycleIndep c A) (hhalf : 2 * A.card = Fintype.card V) (i : Fin (Fintype.card V)) : c.toEquiv (cNext (by have := c.card_ge_three; omega) i) ∉ A ↔ c.toEquiv i ∈ A := by have hn : 0 < Fintype.card V := by have := c.card_ge_three; omega let f : V → V := fun v => c.toEquiv (cNext hn (c.toEquiv.symm v)) have hf_inj : Function.Injective f := fun x y hxy => c.toEquiv.symm.injective (cNext_injective hn (c.toEquiv.injective hxy)) have hdisj : Disjoint A (A.image f) := by rw [Finset.disjoint_left] intro x hx hfx rcases Finset.mem_image.mp hfx with ⟨a, ha, rfl⟩ exact hA (c.toEquiv.symm a) (by simpa using ha) hx have huniv : A ∪ A.image f = Finset.univ := by apply Finset.eq_univ_of_card rw [Finset.card_union_of_disjoint hdisj, Finset.card_image_of_injective _ hf_inj, ← two_mul, hhalf] constructor · intro hnot have hmem : c.toEquiv (cNext hn i) ∈ A ∪ A.image f := by rw [huniv]; exact Finset.mem_univ _ rcases Finset.mem_union.mp hmem with h1 | h2 · exact absurd h1 hnot · rcases Finset.mem_image.mp h2 with ⟨a, ha, hfa⟩ have heq : cNext hn (c.toEquiv.symm a) = cNext hn i := c.toEquiv.injective hfa have hai : a = c.toEquiv i := by have := cNext_injective hn heq simpa using congrArg c.toEquiv this rwa [← hai] · intro hi hnext exact hA i hi hnext /-- Every 3-cycle in `chordGraph c` has all pairs of distinct vertices chord-adjacent. -/ lemma triangle_chord_adj {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h3 : D.len = 3) {x y : V} (hx : x ∈ D.vertSet) (hy : y ∈ D.vertSet) (hxy : x ≠ y) : (chordGraph c).Adj x y := by rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rcases Finset.mem_image.mp hy with ⟨j, _, rfl⟩ have hij : i ≠ j := fun h => hxy (congrArg D.verts h) have hij' : i.1 ≠ j.1 := fun h => hij (Fin.ext h) have hi := i.2; have hj := j.2 have hl : 0 < D.len := by omega have hcases : j = cNext hl i ∨ i = cNext hl j := by by_cases h1 : (i.1 + 1) % 3 = j.1 · left; ext; rw [cNext_val]; split_ifs <;> omega · right; ext; rw [cNext_val]; split_ifs <;> omega rcases hcases with rfl | rfl · exact D.adj_next i · exact (chordGraph c).adj_symm (D.adj_next j) /-- Every 3-cycle in `chordGraph c` is `c`-independent! -/ lemma triangle_isCycleIndep {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h3 : D.len = 3) : IsCycleIndep c D.vertSet := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge have hxy : x ≠ y := fun h => by subst h; exact G.loopless.irrefl x (c.adj_of_mem_edgeSet hedge) exact (triangle_chord_adj h3 hx hy hxy).2 hedge /-- On a cycle `C_n` with `n ≥ 5`, there is no `K_{2,2}`: any two disjoint sets of size `≥ 2` contain a `c`-non-adjacent pair. -/ lemma no_K22_in_cycle {G : SimpleGraph V} (c : DirHamCycle G) (hn5 : 5 ≤ Fintype.card V) {S T : Finset V} (hS : 2 ≤ S.card) (hT : 2 ≤ T.card) : ∃ s ∈ S, ∃ t ∈ T, s(s, t) ∉ c.edgeSet := by by_contra hall push Not at hall obtain ⟨s₁, hs₁, s₂, hs₂, hs12⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) obtain ⟨t₁, ht₁, t₂, ht₂, ht12⟩ := Finset.one_lt_card.mp (by omega : 1 < T.card) have hsub1 : ({t₁, t₂} : Finset V) ⊆ cNbr c s₁ := by intro t ht; simp only [Finset.mem_insert, Finset.mem_singleton] at ht rcases ht with h | h <;> rw [h] · exact (mem_cNbr_iff c s₁ t₁).mpr (hall s₁ hs₁ t₁ ht₁) · exact (mem_cNbr_iff c s₁ t₂).mpr (hall s₁ hs₁ t₂ ht₂) have hsub2 : ({t₁, t₂} : Finset V) ⊆ cNbr c s₂ := by intro t ht; simp only [Finset.mem_insert, Finset.mem_singleton] at ht rcases ht with h | h <;> rw [h] · exact (mem_cNbr_iff c s₂ t₁).mpr (hall s₂ hs₂ t₁ ht₁) · exact (mem_cNbr_iff c s₂ t₂).mpr (hall s₂ hs₂ t₂ ht₂) have heq1 : ({t₁, t₂} : Finset V) = cNbr c s₁ := Finset.eq_of_subset_of_card_le hsub1 (by rw [card_cNbr, Finset.card_pair ht12]) have heq2 : ({t₁, t₂} : Finset V) = cNbr c s₂ := Finset.eq_of_subset_of_card_le hsub2 (by rw [card_cNbr, Finset.card_pair ht12]) have hnbr : cNbr c s₁ = cNbr c s₂ := heq1.symm.trans heq2 have hn : 0 < Fintype.card V := by omega let i₁ := c.toEquiv.symm s₁ let i₂ := c.toEquiv.symm s₂ have hi12 : i₁ ≠ i₂ := fun h => hs12 (c.toEquiv.symm.injective h) have hp1_mem : c.toEquiv (cPrev hn i₁) ∈ cNbr c s₂ := by rw [← hnbr]; dsimp [cNbr]; exact Finset.mem_insert_self _ _ have hn1_mem : c.toEquiv (cNext hn i₁) ∈ cNbr c s₂ := by rw [← hnbr]; dsimp [cNbr]; exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _) dsimp [cNbr] at hp1_mem hn1_mem simp only [Finset.mem_insert, Finset.mem_singleton] at hp1_mem hn1_mem have hp_eq : cPrev hn i₁ = cNext hn i₂ := by rcases hp1_mem with h | h · exfalso; apply hi12 have := c.toEquiv.injective h rw [← cNext_cPrev hn i₁, ← cNext_cPrev hn i₂, this] · exact c.toEquiv.injective h have hn_eq : cNext hn i₁ = cPrev hn i₂ := by rcases hn1_mem with h | h · exact c.toEquiv.injective h · exfalso; exact hi12 (cNext_injective hn (c.toEquiv.injective h)) have hstep1 : cNext hn (cNext hn i₁) = i₂ := by rw [hn_eq, cNext_cPrev] have hstep2 : cNext hn (cNext hn i₂) = i₁ := by rw [← hp_eq, cNext_cPrev] have h4 : cNext hn (cNext hn (cNext hn (cNext hn i₁))) = i₁ := by rw [hstep1, hstep2] have h4val : (cNext hn (cNext hn (cNext hn (cNext hn i₁)))).1 = i₁.1 := congrArg Fin.val h4 have hcn_mod : ∀ x : Fin (Fintype.card V), (cNext hn x).1 = (x.1 + 1) % Fintype.card V := fun x => by rw [cNext_val]; split_ifs with h · exact (Nat.mod_eq_of_lt h).symm · have hx : x.1 + 1 = Fintype.card V := by omega rw [hx, Nat.mod_self] rw [hcn_mod, hcn_mod, hcn_mod, hcn_mod] at h4val simp only [Nat.mod_add_mod] at h4val have h4eq : (i₁.1 + 4) % Fintype.card V = i₁.1 := by simpa [Nat.add_assoc] using h4val by_cases hlt : i₁.1 + 4 < Fintype.card V · rw [Nat.mod_eq_of_lt hlt] at h4eq; omega · have hsub : (i₁.1 + 4) % Fintype.card V = i₁.1 + 4 - Fintype.card V := by have hrew : i₁.1 + 4 = (i₁.1 + 4 - Fintype.card V) + Fintype.card V := by omega conv_lhs => rw [hrew] rw [Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [hsub] at h4eq; omega /-- Reusable transversal helper: for `n ≥ 5`, if `1 ≤ |S|`, `1 ≤ |T|`, and `4 ≤ |S| + |T|`, then `∃ s ∈ S, ∃ t ∈ T` non-adjacent on `c`. -/ lemma exists_pair_nonadj_of_sum_ge_four {G : SimpleGraph V} (c : DirHamCycle G) (hn5 : 5 ≤ Fintype.card V) {S T : Finset V} (hS : 1 ≤ S.card) (hT : 1 ≤ T.card) (hsum : 4 ≤ S.card + T.card) : ∃ s ∈ S, ∃ t ∈ T, s(s, t) ∉ c.edgeSet := by by_cases hS2 : 2 ≤ S.card · by_cases hT2 : 2 ≤ T.card · exact no_K22_in_cycle c hn5 hS2 hT2 · have hS3 : 3 ≤ S.card := by omega obtain ⟨t, ht⟩ := Finset.card_pos.mp (by omega : 0 < T.card) have hpos : 0 < (S \ cNbr c t).card := by have hle := Finset.card_sdiff_add_card_inter S (cNbr c t) have hinter : (S ∩ cNbr c t).card ≤ 2 := by calc (S ∩ cNbr c t).card ≤ (cNbr c t).card := Finset.card_le_card Finset.inter_subset_right _ = 2 := card_cNbr c t omega obtain ⟨s, hs⟩ := Finset.card_pos.mp hpos rcases Finset.mem_sdiff.mp hs with ⟨hsS, hsn⟩ exact ⟨s, hsS, t, ht, fun h => hsn ((mem_cNbr_iff c t s).mpr (by rwa [Sym2.eq_swap]))⟩ · have hT3 : 3 ≤ T.card := by omega obtain ⟨s, hs⟩ := Finset.card_pos.mp (by omega : 0 < S.card) have hpos : 0 < (T \ cNbr c s).card := by have hle := Finset.card_sdiff_add_card_inter T (cNbr c s) have hinter : (T ∩ cNbr c s).card ≤ 2 := by calc (T ∩ cNbr c s).card ≤ (cNbr c s).card := Finset.card_le_card Finset.inter_subset_right _ = 2 := card_cNbr c s omega obtain ⟨t, ht⟩ := Finset.card_pos.mp hpos rcases Finset.mem_sdiff.mp ht with ⟨htT, htn⟩ exact ⟨s, hs, t, htT, fun h => htn ((mem_cNbr_iff c s t).mpr h)⟩ /-- In a 4-cycle `D` of `chordGraph c`, any single vertex `x ∈ D` dominates all of `D` except ONE opposite vertex `v₀ ∈ D`. -/ lemma one_vert_near_dom_quad {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h4 : D.len = 4) {x : V} (hx : x ∈ D.vertSet) : ∃ v₀ ∈ D.vertSet, v₀ ≠ x ∧ ∀ w ∈ D.vertSet, w ≠ x → w ≠ v₀ → (chordGraph c).Adj w x := by rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ have hl : 0 < D.len := by omega let i2 : Fin D.len := cNext hl (cNext hl i) refine ⟨D.verts i2, Finset.mem_image.mpr ⟨i2, Finset.mem_univ _, rfl⟩, ?_, ?_⟩ · intro h have hi2 : i2 = i := D.verts.injective h have hv := congrArg Fin.val hi2 dsimp [i2] at hv; rw [cNext_val, cNext_val] at hv; split_ifs at hv <;> omega · intro w hw hwx hwv₀ rcases Finset.mem_image.mp hw with ⟨j, _, rfl⟩ have hji : j ≠ i := fun h => hwx (congrArg D.verts h) have hji2 : j ≠ i2 := fun h => hwv₀ (congrArg D.verts h) have hval2 : i2.1 = (i.1 + 2) % 4 := by dsimp [i2]; rw [cNext_val, cNext_val]; split_ifs <;> omega have hcases : j = cNext hl i ∨ i = cNext hl j := by have hi2ne : j.1 ≠ (i.1 + 2) % 4 := fun h => hji2 (Fin.ext (by omega)) by_cases h1 : j.1 = (i.1 + 1) % 4 · left; ext; rw [cNext_val]; split_ifs <;> omega · right; ext; rw [cNext_val]; split_ifs <;> omega rcases hcases with rfl | rfl · exact (chordGraph c).adj_symm (D.adj_next i) · exact D.adj_next j /-- In a 5-cycle `D` of `chordGraph c`, ANY two distinct vertices `x, y ∈ D` dominate all of `D` except **AT MOST ONE** vertex `v₀ ∈ D \ {x, y}`! -/ lemma two_verts_near_dom_pentagon {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h5 : D.len = 5) {x y : V} (hx : x ∈ D.vertSet) (hy : y ∈ D.vertSet) (hxy : x ≠ y) : ∃ v₀ ∈ D.vertSet, v₀ ≠ x ∧ v₀ ≠ y ∧ ∀ w ∈ D.vertSet, w ≠ x → w ≠ y → w ≠ v₀ → (chordGraph c).Adj w x ∨ (chordGraph c).Adj w y := by rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rcases Finset.mem_image.mp hy with ⟨j, _, rfl⟩ have hl : 0 < D.len := by omega have hij : i ≠ j := fun h => hxy (congrArg D.verts h) have hij' : i.1 ≠ j.1 := fun h => hij (Fin.ext h) have hi := i.2; have hj := j.2 have hadj_of_diff : ∀ a b : Fin D.len, (b.1 = (a.1 + 1) % 5 ∨ a.1 = (b.1 + 1) % 5) → (chordGraph c).Adj (D.verts a) (D.verts b) := by intro a b h rcases h with h1 | h2 · have : b = cNext hl a := by ext; rw [cNext_val]; split_ifs <;> omega rw [this]; exact D.adj_next a · have : a = cNext hl b := by ext; rw [cNext_val]; split_ifs <;> omega rw [this]; exact (chordGraph c).adj_symm (D.adj_next b) let k₀ : Fin D.len := if j.1 = (i.1 + 1) % 5 then ⟨(i.1 + 3) % 5, by omega⟩ else if i.1 = (j.1 + 1) % 5 then ⟨(j.1 + 3) % 5, by omega⟩ else ⟨(i.1 + 1) % 5, by omega⟩ have hk_val : k₀.1 = if j.1 = (i.1 + 1) % 5 then (i.1 + 3) % 5 else if i.1 = (j.1 + 1) % 5 then (j.1 + 3) % 5 else (i.1 + 1) % 5 := by dsimp [k₀]; split_ifs <;> rfl have hk_ne_i : k₀ ≠ i := by intro h; have hv := congrArg Fin.val h; rw [hk_val] at hv; split_ifs at hv <;> omega have hk_ne_j : k₀ ≠ j := by intro h; have hv := congrArg Fin.val h; rw [hk_val] at hv; split_ifs at hv <;> omega refine ⟨D.verts k₀, Finset.mem_image.mpr ⟨k₀, Finset.mem_univ _, rfl⟩, fun h => hk_ne_i (D.verts.injective h), fun h => hk_ne_j (D.verts.injective h), ?_⟩ intro w hw hwx hwy hwk rcases Finset.mem_image.mp hw with ⟨m, _, rfl⟩ have hm := m.2 have hmi : m.1 ≠ i.1 := fun h => hwx (congrArg D.verts (Fin.ext h)) have hmj : m.1 ≠ j.1 := fun h => hwy (congrArg D.verts (Fin.ext h)) have hmk : m.1 ≠ k₀.1 := fun h => hwk (congrArg D.verts (Fin.ext h)) rw [hk_val] at hmk have hcases : (i.1 = (m.1 + 1) % 5 ∨ m.1 = (i.1 + 1) % 5) ∨ (j.1 = (m.1 + 1) % 5 ∨ m.1 = (j.1 + 1) % 5) := by split_ifs at hmk <;> omega rcases hcases with h1 | h2 · left; exact hadj_of_diff m i h1 · right; exact hadj_of_diff m j h2 /-- In a 5-cycle `D` of `chordGraph c`, any two distinct vertices `x, y ∈ D` that are NOT adjacent in `D` dominate ALL remaining 3 vertices of `D`! -/ lemma non_adj_pair_dom_pentagon {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h5 : D.len = 5) {x y : V} (hx : x ∈ D.vertSet) (hy : y ∈ D.vertSet) (hxy : x ≠ y) (hnadj : ∀ k : Fin D.len, s(x, y) ≠ s(D.verts k, D.verts (cNext (by omega) k))) : ∀ w ∈ D.vertSet, w ≠ x → w ≠ y → (chordGraph c).Adj w x ∨ (chordGraph c).Adj w y := by rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rcases Finset.mem_image.mp hy with ⟨j, _, rfl⟩ have hl : 0 < D.len := by omega have hij : i ≠ j := fun h => hxy (congrArg D.verts h) have hni : j ≠ cNext hl i := fun h => by subst h; exact hnadj i rfl have hnj : i ≠ cNext hl j := fun h => by subst h; exact hnadj j Sym2.eq_swap have hi_ne_next : j.1 ≠ (i.1 + 1) % 5 := fun h => hni (Fin.ext (by rw [cNext_val]; split_ifs <;> omega)) have hj_ne_next : i.1 ≠ (j.1 + 1) % 5 := fun h => hnj (Fin.ext (by rw [cNext_val]; split_ifs <;> omega)) intro w hw hwx hwy rcases Finset.mem_image.mp hw with ⟨m, _, rfl⟩ have hmi : m.1 ≠ i.1 := fun h => hwx (congrArg D.verts (Fin.ext h)) have hmj : m.1 ≠ j.1 := fun h => hwy (congrArg D.verts (Fin.ext h)) have hadj_of_diff : ∀ a b : Fin D.len, (b.1 = (a.1 + 1) % 5 ∨ a.1 = (b.1 + 1) % 5) → (chordGraph c).Adj (D.verts a) (D.verts b) := by intro a b h rcases h with h1 | h2 · have : b = cNext hl a := by ext; rw [cNext_val]; split_ifs <;> omega rw [this]; exact D.adj_next a · have : a = cNext hl b := by ext; rw [cNext_val]; split_ifs <;> omega rw [this]; exact (chordGraph c).adj_symm (D.adj_next b) have hcases : (i.1 = (m.1 + 1) % 5 ∨ m.1 = (i.1 + 1) % 5) ∨ (j.1 = (m.1 + 1) % 5 ∨ m.1 = (j.1 + 1) % 5) := by omega rcases hcases with h1 | h2 · left; exact hadj_of_diff m i h1 · right; exact hadj_of_diff m j h2 /-- In a 6-cycle `D` of `chordGraph c`, ANY 3-element subset `S ⊆ D.vertSet` dominates all of `D.vertSet \ S` except **AT MOST ONE** vertex `v₀ ∈ D.vertSet \ S`! -/ lemma three_verts_near_dom_hexagon {G : SimpleGraph V} {c : DirHamCycle G} {D : CycleIn (chordGraph c)} (h6 : D.len = 6) {S : Finset V} (hSD : S ⊆ D.vertSet) (hS3 : S.card = 3) : ∃ v₀ ∈ D.vertSet, v₀ ∉ S ∧ ∀ w ∈ D.vertSet, w ∉ S → w ≠ v₀ → ∃ s ∈ S, (chordGraph c).Adj w s := by have hl : 0 < D.len := by omega let U := D.vertSet \ S have hU3 : U.card = 3 := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hSD, D.card_vertSet, h6, hS3] -- Helper: any `u = D.verts k ∈ U` with NO chord-neighbor in `S` forces `U = {prev, k, next}`! have hbad_eq : ∀ k : Fin D.len, D.verts k ∈ U → (∀ s ∈ S, ¬ (chordGraph c).Adj (D.verts k) s) → U = {D.verts (cPrev hl k), D.verts k, D.verts (cNext hl k)} := by intro k hkU hno have hpU : D.verts (cPrev hl k) ∈ U := by refine Finset.mem_sdiff.mpr ⟨Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩, fun hS => ?_⟩ have hadj : (chordGraph c).Adj (D.verts k) (D.verts (cPrev hl k)) := by have := D.adj_next (cPrev hl k); rw [cNext_cPrev] at this; exact (chordGraph c).adj_symm this exact hno _ hS hadj have hnU : D.verts (cNext hl k) ∈ U := by refine Finset.mem_sdiff.mpr ⟨Finset.mem_image.mpr ⟨_, Finset.mem_univ _, rfl⟩, fun hS => ?_⟩ exact hno _ hS (D.adj_next k) have hsub : ({D.verts (cPrev hl k), D.verts k, D.verts (cNext hl k)} : Finset V) ⊆ U := by intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl <;> assumption have h12 : D.verts (cPrev hl k) ≠ D.verts k := fun h => by have := D.verts.injective h exact cNext_ne_self (by omega) (cPrev hl k) (by rw [cNext_cPrev, this]) have h13 : D.verts (cPrev hl k) ≠ D.verts (cNext hl k) := fun h => cNext_ne_cPrev (by omega) k (D.verts.injective h).symm have h23 : D.verts k ≠ D.verts (cNext hl k) := fun h => cNext_ne_self (by omega) k (D.verts.injective h).symm have hcard3 : ({D.verts (cPrev hl k), D.verts k, D.verts (cNext hl k)} : Finset V).card = 3 := by rw [Finset.card_insert_of_notMem (by simp [h12, h13]), Finset.card_pair h23] exact (Finset.eq_of_subset_of_card_le hsub (by rw [hU3, hcard3])).symm -- Therefore AT MOST ONE element of `U` has no neighbor in `S`! by_cases hbad : ∃ v₀ ∈ U, ∀ s ∈ S, ¬ (chordGraph c).Adj v₀ s · obtain ⟨v₀, hv₀U, hno₀⟩ := hbad rcases Finset.mem_sdiff.mp hv₀U with ⟨hv₀D, hv₀S⟩ rcases Finset.mem_image.mp hv₀D with ⟨k₀, _, rfl⟩ refine ⟨D.verts k₀, hv₀D, hv₀S, ?_⟩ intro w hwD hwS hwne by_contra hnow push Not at hnow rcases Finset.mem_image.mp hwD with ⟨k₁, _, rfl⟩ have hwU : D.verts k₁ ∈ U := Finset.mem_sdiff.mpr ⟨hwD, hwS⟩ have hU_k0 := hbad_eq k₀ hv₀U hno₀ have hU_k1 := hbad_eq k₁ hwU hnow have hk1_mem : D.verts k₁ ∈ ({D.verts (cPrev hl k₀), D.verts k₀, D.verts (cNext hl k₀)} : Finset V) := by rw [← hU_k0]; exact hwU simp only [Finset.mem_insert, Finset.mem_singleton] at hk1_mem have hk10 : k₁ ≠ k₀ := fun h => hwne (congrArg D.verts h) rcases hk1_mem with h | h | h · have hk1 : k₁ = cPrev hl k₀ := D.verts.injective h -- `cPrev hl k₁` is in `U` (from `hU_k1`), hence in `{cPrev k₀, k₀, cNext k₀}` — impossible in `C₆`! have hpp : D.verts (cPrev hl k₁) ∈ ({D.verts (cPrev hl k₀), D.verts k₀, D.verts (cNext hl k₀)} : Finset V) := by rw [← hU_k0, hU_k1]; exact Finset.mem_insert_self _ _ simp only [Finset.mem_insert, Finset.mem_singleton] at hpp rcases hpp with h' | h' | h' · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cPrev_val, cPrev_val] at this; split_ifs at this <;> omega · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cPrev_val, cPrev_val] at this; split_ifs at this <;> omega · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cPrev_val, cPrev_val, cNext_val] at this; split_ifs at this <;> omega · exact hk10 (D.verts.injective h) · have hk1 : k₁ = cNext hl k₀ := D.verts.injective h have hnn : D.verts (cNext hl k₁) ∈ ({D.verts (cPrev hl k₀), D.verts k₀, D.verts (cNext hl k₀)} : Finset V) := by rw [← hU_k0, hU_k1]; exact Finset.mem_insert_of_mem (Finset.mem_insert_of_mem (Finset.mem_singleton_self _)) simp only [Finset.mem_insert, Finset.mem_singleton] at hnn rcases hnn with h' | h' | h' · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cNext_val, cNext_val, cPrev_val] at this; split_ifs at this <;> omega · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cNext_val, cNext_val] at this; split_ifs at this <;> omega · have := congrArg Fin.val (D.verts.injective h'); rw [hk1, cNext_val, cNext_val] at this; split_ifs at this <;> omega · -- Every vertex in `U` ALREADY has a neighbor in `S`! Pick any `v₀ ∈ U`. push Not at hbad obtain ⟨v₀, hv₀U⟩ := Finset.card_pos.mp (by omega : 0 < U.card) rcases Finset.mem_sdiff.mp hv₀U with ⟨hv₀D, hv₀S⟩ exact ⟨v₀, hv₀D, hv₀S, fun w hwD hwS _ => hbad w (Finset.mem_sdiff.mpr ⟨hwD, hwS⟩)⟩ omit [DecidableEq V] in /-- Helper: every 4-regular simple graph has at least 5 vertices. -/ lemma five_le_card_of_reg_four {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) [Nonempty V] : 5 ≤ Fintype.card V := by obtain ⟨v⟩ := ‹Nonempty V› have hlt : G.degree v < Fintype.card V := G.degree_lt_card_verts v rw [hreg v] at hlt omega /-- Helper: in any cycle decomposition `𝒟` of `chordGraph c`, `3 * 𝒟.length ≤ Fintype.card V`. -/ lemma three_mul_length_le_card {G : SimpleGraph V} {c : DirHamCycle G} {𝒟 : List (CycleIn (chordGraph c))} (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) : 3 * 𝒟.length ≤ Fintype.card V := by have hsum := cycle_decomp_sum_len hpw hcov have hge : ∀ L : List (CycleIn (chordGraph c)), 3 * L.length ≤ (L.map CycleIn.len).sum := by intro L induction L with | nil => simp | cons D tl ih => simp only [List.length_cons, List.map_cons, List.sum_cons] have := D.len_ge_three omega have := hge 𝒟 omega /-- **Theorem 6a (Sheehan's Conjecture for ALL `n ≤ 8`)**: Every 4-regular Hamiltonian simple graph on `n ≤ 8` vertices has at least 2 Hamiltonian cycles. -/ theorem sheehan_of_card_le_eight {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (hle : Fintype.card V ≤ 8) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) have h3 := three_mul_length_le_card hpw hcov exact exists_second_hamCycle_of_le_two_chord_components c 𝒟 hpw hcov (by omega) /-- **Theorem 6b (Sheehan's Conjecture for ALL `n = 9`)**: Every 4-regular Hamiltonian simple graph on `9` vertices has at least 2 Hamiltonian cycles (and in fact `≥ 3` whenever the chord 2-factor is `C₃ + C₃ + C₃`). -/ theorem sheehan_of_card_nine {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (h9 : Fintype.card V = 9) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) by_cases hodd1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1 · exact exists_second_hamCycle_of_le_one_odd_chord_cycle c 𝒟 hpw hcov hodd1 · by_cases hlen2 : 𝒟.length ≤ 2 · exact exists_second_hamCycle_of_le_two_chord_components c 𝒟 hpw hcov hlen2 · -- Must have `𝒟 = [T₁, T₂, T₃]` with `len = 3` each! have h3 := three_mul_length_le_card hpw hcov have hlen3 : 𝒟.length = 3 := by omega match h𝒟 : 𝒟 with | [T₁, T₂, T₃] => have hsum := cycle_decomp_sum_len hpw hcov simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] at hsum have hT1_3 : T₁.len = 3 := by have := T₁.len_ge_three; have := T₂.len_ge_three; have := T₃.len_ge_three; omega have hT2_3 : T₂.len = 3 := by have := T₁.len_ge_three; have := T₂.len_ge_three; have := T₃.len_ge_three; omega have hT3_3 : T₃.len = 3 := by have := T₁.len_ge_three; have := T₂.len_ge_three; have := T₃.len_ge_three; omega have hpw' : Disjoint T₁.vertSet T₂.vertSet ∧ Disjoint T₁.vertSet T₃.vertSet ∧ Disjoint T₂.vertSet T₃.vertSet := by rcases List.pairwise_cons.mp hpw with ⟨hA, hBC⟩ rcases List.pairwise_cons.mp hBC with ⟨hB, _⟩ exact ⟨hA _ (by simp), hA _ (by simp), hB _ (by simp)⟩ -- Pick any `a₁ ∈ T₁`, then find `c`-non-adjacent `a₂ ∈ T₂ \ cNbr a₁`, `a₃ ∈ T₃ \ cNbr a₁`! obtain ⟨a₁, ha₁⟩ := Finset.card_pos.mp (by rw [T₁.card_vertSet, hT1_3]; omega : 0 < T₁.vertSet.card) let S₂ := T₂.vertSet \ cNbr c a₁ let S₃ := T₃.vertSet \ cNbr c a₁ have hdisj23 : Disjoint (T₂.vertSet ∩ cNbr c a₁) (T₃.vertSet ∩ cNbr c a₁) := Disjoint.mono Finset.inter_subset_left Finset.inter_subset_left hpw'.2.2 have hinter_sum : (T₂.vertSet ∩ cNbr c a₁).card + (T₃.vertSet ∩ cNbr c a₁).card ≤ 2 := by rw [← Finset.card_union_of_disjoint hdisj23] calc ((T₂.vertSet ∩ cNbr c a₁) ∪ (T₃.vertSet ∩ cNbr c a₁)).card ≤ (cNbr c a₁).card := Finset.card_le_card (Finset.union_subset Finset.inter_subset_right Finset.inter_subset_right) _ = 2 := card_cNbr c a₁ have hS2_le : S₂.card + (T₂.vertSet ∩ cNbr c a₁).card = 3 := by dsimp [S₂]; rw [Finset.card_sdiff_add_card_inter, T₂.card_vertSet, hT2_3] have hS3_le : S₃.card + (T₃.vertSet ∩ cNbr c a₁).card = 3 := by dsimp [S₃]; rw [Finset.card_sdiff_add_card_inter, T₃.card_vertSet, hT3_3] obtain ⟨a₂, ha₂S, a₃, ha₃S, ha23⟩ := exists_pair_nonadj_of_sum_ge_four c (by omega) (S := S₂) (T := S₃) (by omega) (by omega) (by omega) rcases Finset.mem_sdiff.mp ha₂S with ⟨ha₂, ha12⟩ rcases Finset.mem_sdiff.mp ha₃S with ⟨ha₃, ha13⟩ have h12e : s(a₁, a₂) ∉ c.edgeSet := fun h => ha12 ((mem_cNbr_iff c a₁ a₂).mpr h) have h13e : s(a₁, a₃) ∉ c.edgeSet := fun h => ha13 ((mem_cNbr_iff c a₁ a₃).mpr h) let A : Finset V := {a₁, a₂, a₃} have hA_ind : IsCycleIndep c A := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge simp only [A, Finset.mem_insert, Finset.mem_singleton] at hx hy have hxy : x ≠ y := fun h => by subst h; exact G.loopless.irrefl x (c.adj_of_mem_edgeSet hedge) rcases hx with rfl | rfl | rfl <;> rcases hy with rfl | rfl | rfl · exact hxy rfl · exact h12e hedge · exact h13e hedge · exact h12e (by rwa [Sym2.eq_swap]) · exact hxy rfl · exact ha23 hedge · exact h13e (by rwa [Sym2.eq_swap]) · exact ha23 (by rwa [Sym2.eq_swap]) · exact hxy rfl have hdom : ∀ w : V, w ∉ A → ∃ a ∈ A, G.Adj w a ∧ s(w, a) ∉ c.edgeSet := by intro w hwA have hw1 : w ≠ a₁ := fun h => hwA (by simp [A, h]) have hw2 : w ≠ a₂ := fun h => hwA (by simp [A, h]) have hw3 : w ≠ a₃ := fun h => hwA (by simp [A, h]) obtain ⟨D, hD, hwD⟩ := hcov w simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl | rfl · exact ⟨a₁, by simp [A], triangle_chord_adj hT1_3 hwD ha₁ hw1⟩ · exact ⟨a₂, by simp [A], triangle_chord_adj hT2_3 hwD ha₂ hw2⟩ · exact ⟨a₃, by simp [A], triangle_chord_adj hT3_3 hwD ha₃ hw3⟩ exact le_trans (by decide : 2 ≤ 3) (card_hamCycles_ge_three_of_cid c A hA_ind hdom) | [] | [_] | [_, _] | _ :: _ :: _ :: _ :: _ => simp at hlen3 /-- Helper for `n = 10` with two triangles `T₁, T₂` and a 4-cycle `E₄`: `T₁` and `T₂` MUST be `c`-adjacent (since `2 · 6 > 10`), immediately triggering Theorem 4d-i! -/ private lemma sheehan_ten_ordered {G : SimpleGraph V} (h10 : Fintype.card V = 10) (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) {T₁ T₂ E₄ : CycleIn (chordGraph c)} (hT₁ : T₁ ∈ 𝒟) (hT₂ : T₂ ∈ 𝒟) (hdisj : Disjoint T₁.vertSet T₂.vertSet) (hT1_3 : T₁.len = 3) (hT2_3 : T₂.len = 3) (hE4_4 : E₄.len = 4) (hmem_all : ∀ D ∈ 𝒟, D = T₁ ∨ D = T₂ ∨ D = E₄) : 2 ≤ (hamCycles G).card := by have hT12_ne : T₁ ≠ T₂ := by intro rfl have hpos : 0 < T₁.vertSet.card := by rw [T₁.card_vertSet, hT1_3]; omega obtain ⟨v, hv⟩ := Finset.card_pos.mp hpos exact Finset.disjoint_left.mp hdisj hv hv -- Suppose no `c`-edge connects `T₁` and `T₂`; then `T₁ ∪ T₂` is `c`-independent of size 6! have hex : ∃ u ∈ T₁.vertSet, ∃ v ∈ T₂.vertSet, s(u, v) ∈ c.edgeSet := by by_contra hnone push Not at hnone have hind : IsCycleIndep c (T₁.vertSet ∪ T₂.vertSet) := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge rcases Finset.mem_union.mp hx with hx1 | hx2 <;> rcases Finset.mem_union.mp hy with hy1 | hy2 · exact (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT1_3) x hx1 y hy1 hedge · exact hnone x hx1 y hy2 hedge · exact hnone y hy1 x hx2 (by rwa [Sym2.eq_swap]) · exact (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT2_3) x hx2 y hy2 hedge have hcard6 : (T₁.vertSet ∪ T₂.vertSet).card = 6 := by rw [Finset.card_union_of_disjoint hdisj, T₁.card_vertSet, T₂.card_vertSet, hT1_3, hT2_3] have hle := two_mul_card_le_of_isCycleIndep c hind omega obtain ⟨u, hu, v, hv, huv⟩ := hex exact exists_second_hamCycle_of_two_adj_odd_chord_cycles c 𝒟 hpw hcov hT₁ hT₂ hT12_ne ⟨1, by omega⟩ ⟨1, by omega⟩ (fun D hD h1 h2 => by rcases hmem_all D hD with rfl | rfl | rfl · exact absurd rfl h1 · exact absurd rfl h2 · exact ⟨2, by omega⟩) hu hv huv /-- **Theorem 6c (Sheehan's Conjecture for ALL `n = 10`)**: Every 4-regular Hamiltonian simple graph on `10` vertices has at least 2 Hamiltonian cycles. -/ theorem sheehan_of_card_ten {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (h10 : Fintype.card V = 10) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) by_cases hodd1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1 · exact exists_second_hamCycle_of_le_one_odd_chord_cycle c 𝒟 hpw hcov hodd1 · by_cases hlen2 : 𝒟.length ≤ 2 · exact exists_second_hamCycle_of_le_two_chord_components c 𝒟 hpw hcov hlen2 · have h3 := three_mul_length_le_card hpw hcov have hlen3 : 𝒟.length = 3 := by omega match h𝒟 : 𝒟 with | [D₁, D₂, D₃] => have hsum := cycle_decomp_sum_len hpw hcov simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] at hsum have h1 := D₁.len_ge_three; have h2 := D₂.len_ge_three; have h3' := D₃.len_ge_three have hpw' : Disjoint D₁.vertSet D₂.vertSet ∧ Disjoint D₁.vertSet D₃.vertSet ∧ Disjoint D₂.vertSet D₃.vertSet := by rcases List.pairwise_cons.mp hpw with ⟨hA, hBC⟩ rcases List.pairwise_cons.mp hBC with ⟨hB, _⟩ exact ⟨hA _ (by simp), hA _ (by simp), hB _ (by simp)⟩ have hcases : (D₁.len = 3 ∧ D₂.len = 3 ∧ D₃.len = 4) ∨ (D₁.len = 3 ∧ D₃.len = 3 ∧ D₂.len = 4) ∨ (D₂.len = 3 ∧ D₃.len = 3 ∧ D₁.len = 4) := by omega rcases hcases with ⟨a, b, e⟩ | ⟨a, b, e⟩ | ⟨a, b, e⟩ · exact sheehan_ten_ordered h10 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.1 a b e (by intro D hD; simp at hD; tauto) · exact sheehan_ten_ordered h10 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.2.1 a b e (by intro D hD; simp at hD; tauto) · exact sheehan_ten_ordered h10 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.2.2 a b e (by intro D hD; simp at hD; tauto) | [] | [_] | [_, _] | _ :: _ :: _ :: _ :: _ => simp at hlen3 /-- Pure structural 4-case arc theorem on `C₁₁`: given a partition of `V` (`|V| = 11`) into two `c`-independent 3-sets `T₁, T₂` and a 5-set `P`, there ALWAYS exists a `c`-independent 4-set `{a₁, a₂, x, y}` with `a₁ ∈ T₁`, `a₂ ∈ T₂`, and `x ≠ y ∈ P`! -/ private lemma exists_near_cid_335 {G : SimpleGraph V} (h11 : Fintype.card V = 11) (c : DirHamCycle G) {T₁ T₂ P : Finset V} (hT1_card : T₁.card = 3) (hT2_card : T₂.card = 3) (hP_card : P.card = 5) (h12 : Disjoint T₁ T₂) (h1P : Disjoint T₁ P) (h2P : Disjoint T₂ P) (hcov : ∀ v : V, v ∈ T₁ ∨ v ∈ T₂ ∨ v ∈ P) (hT1_ind : IsCycleIndep c T₁) (hT2_ind : IsCycleIndep c T₂) : ∃ a₁ ∈ T₁, ∃ a₂ ∈ T₂, ∃ x ∈ P, ∃ y ∈ P, x ≠ y ∧ IsCycleIndep c {a₁, a₂, x, y} := by have hn : 0 < Fintype.card V := by omega let step : V → V := fun v => c.toEquiv (cNext hn (c.toEquiv.symm v)) let prev : V → V := fun v => c.toEquiv (cPrev hn (c.toEquiv.symm v)) have hstep_inj : Function.Injective step := fun x y h => c.toEquiv.symm.injective (cNext_injective hn (c.toEquiv.injective h)) have hprev_step : ∀ v, prev (step v) = v := fun v => by simp [step, prev, cPrev_cNext] have hstep_prev : ∀ v, step (prev v) = v := fun v => by simp [step, prev, cNext_cPrev] have hcnbr_eq : ∀ v, cNbr c v = {prev v, step v} := fun v => rfl -- Helper: any "good pair" `x ≠ y ∈ P` with `s(x, y) ∉ c.edgeSet` and `|((cNbr x ∪ cNbr y) \ P)| ≤ 2` wins! have hwin_good : ∀ x ∈ P, ∀ y ∈ P, x ≠ y → s(x, y) ∉ c.edgeSet → ((cNbr c x ∪ cNbr c y) \ P).card ≤ 2 → ∃ a₁ ∈ T₁, ∃ a₂ ∈ T₂, ∃ x' ∈ P, ∃ y' ∈ P, x' ≠ y' ∧ IsCycleIndep c {a₁, a₂, x', y'} := by intro x hxP y hyP hxy hxy_ne hout let F := (cNbr c x ∪ cNbr c y) \ P let S₁ := T₁ \ F let S₂ := T₂ \ F have hdisjF : Disjoint (T₁ ∩ F) (T₂ ∩ F) := Disjoint.mono Finset.inter_subset_left Finset.inter_subset_left h12 have hsum_int : (T₁ ∩ F).card + (T₂ ∩ F).card ≤ 2 := by rw [← Finset.card_union_of_disjoint hdisjF] calc ((T₁ ∩ F) ∪ (T₂ ∩ F)).card ≤ F.card := Finset.card_le_card (Finset.union_subset Finset.inter_subset_right Finset.inter_subset_right) _ ≤ 2 := hout have hs1 : S₁.card + (T₁ ∩ F).card = 3 := by dsimp [S₁]; rw [Finset.card_sdiff_add_card_inter, hT1_card] have hs2 : S₂.card + (T₂ ∩ F).card = 3 := by dsimp [S₂]; rw [Finset.card_sdiff_add_card_inter, hT2_card] obtain ⟨a₁, ha₁S, a₂, ha₂S, ha12⟩ := exists_pair_nonadj_of_sum_ge_four c (by omega) (S := S₁) (T := S₂) (by omega) (by omega) (by omega) rcases Finset.mem_sdiff.mp ha₁S with ⟨ha₁, ha₁F⟩ rcases Finset.mem_sdiff.mp ha₂S with ⟨ha₂, ha₂F⟩ have hno_x1 : s(a₁, x) ∉ c.edgeSet := fun h => by apply ha₁F; refine Finset.mem_sdiff.mpr ⟨Finset.mem_union_left _ ?_, Finset.disjoint_left.mp h1P ha₁⟩ exact (mem_cNbr_iff c x a₁).mpr (by rwa [Sym2.eq_swap]) have hno_y1 : s(a₁, y) ∉ c.edgeSet := fun h => by apply ha₁F; refine Finset.mem_sdiff.mpr ⟨Finset.mem_union_right _ ?_, Finset.disjoint_left.mp h1P ha₁⟩ exact (mem_cNbr_iff c y a₁).mpr (by rwa [Sym2.eq_swap]) have hno_x2 : s(a₂, x) ∉ c.edgeSet := fun h => by apply ha₂F; refine Finset.mem_sdiff.mpr ⟨Finset.mem_union_left _ ?_, Finset.disjoint_left.mp h2P ha₂⟩ exact (mem_cNbr_iff c x a₂).mpr (by rwa [Sym2.eq_swap]) have hno_y2 : s(a₂, y) ∉ c.edgeSet := fun h => by apply ha₂F; refine Finset.mem_sdiff.mpr ⟨Finset.mem_union_right _ ?_, Finset.disjoint_left.mp h2P ha₂⟩ exact (mem_cNbr_iff c y a₂).mpr (by rwa [Sym2.eq_swap]) refine ⟨a₁, ha₁, a₂, ha₂, x, hxP, y, hyP, hxy, ?_⟩ rw [isCycleIndep_iff_edges] intro u hu v hv hedge have huv : u ≠ v := fun h => by subst h; exact G.loopless.irrefl u (c.adj_of_mem_edgeSet hedge) simp only [Finset.mem_insert, Finset.mem_singleton] at hu hv rcases hu with rfl | rfl | rfl | rfl <;> rcases hv with rfl | rfl | rfl | rfl · exact huv rfl · exact ha12 hedge · exact hno_x1 hedge · exact hno_y1 hedge · exact ha12 (by rwa [Sym2.eq_swap]) · exact huv rfl · exact hno_x2 hedge · exact hno_y2 hedge · exact hno_x1 (by rwa [Sym2.eq_swap]) · exact hno_x2 (by rwa [Sym2.eq_swap]) · exact huv rfl · exact hxy_ne hedge · exact hno_y1 (by rwa [Sym2.eq_swap]) · exact hno_y2 (by rwa [Sym2.eq_swap]) · exact hxy_ne (by rwa [Sym2.eq_swap]) · exact huv rfl -- Helper for `shift k v` = `c.toEquiv (cShift hn k (c.toEquiv.symm v))`! let sh : ℕ → V → V := fun k v => c.toEquiv (cShift hn k (c.toEquiv.symm v)) have hsh_add : ∀ a b v, sh a (sh b v) = sh (b + a) v := fun a b v => by dsimp [sh]; congr 1; simp only [Equiv.symm_apply_apply]; ext; dsimp [cShift] rw [Nat.mod_add_mod, Nat.add_assoc] have hsh_zero : ∀ v, sh 0 v = v := fun v => by simp [sh, cShift_zero] have hsh_one : ∀ v, sh 1 v = step v := fun v => by dsimp [sh, step]; congr 1 have hsh_ten : ∀ v, sh 10 v = prev v := fun v => by apply hstep_inj rw [hstep_prev, ← hsh_one, hsh_add] dsimp [sh] conv_rhs => rw [← c.toEquiv.apply_symm_apply v] congr 1; ext; dsimp [cShift] have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h11] at hlt ⊢; omega have hsh_ne : ∀ (a b : ℕ) (v : V), a < 11 → b < 11 → a ≠ b → sh a v ≠ sh b v := by intro a b v ha hb hab heq have hv := congrArg Fin.val (c.toEquiv.injective heq) dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h11] at hlt hv; omega have hsh_edge_iff : ∀ (a b : ℕ) (v : V), a < 11 → b < 11 → (s(sh a v, sh b v) ∈ c.edgeSet ↔ (a + 1) % 11 = b ∨ (b + 1) % 11 = a) := by intro a b v ha hb rw [← mem_cNbr_iff, hcnbr_eq, Finset.mem_insert, Finset.mem_singleton, ← hsh_ten, ← hsh_one, hsh_add, hsh_add] constructor · rintro (h | h) · right have hv := congrArg Fin.val (c.toEquiv.injective h) dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h11] at hlt hv; omega · left have hv := congrArg Fin.val (c.toEquiv.injective h) dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h11] at hlt hv; omega · rintro (h | h) · right; dsimp [sh]; congr 1; ext; dsimp [cShift] have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h11] at hlt ⊢; omega · left; dsimp [sh]; congr 1; ext; dsimp [cShift] have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h11] at hlt ⊢; omega -- **CASE 1**: Some vertex `x ∈ P` is an interior vertex (`prev x ∈ P ∧ step x ∈ P`)! by_cases hint : ∃ x ∈ P, prev x ∈ P ∧ step x ∈ P · obtain ⟨x, hxP, hpx, hsx⟩ := hint have hrem : 0 < (P \ {x, prev x, step x}).card := by have hle := Finset.card_sdiff_add_card_inter P {x, prev x, step x} have hi : (P ∩ {x, prev x, step x}).card ≤ 3 := le_trans (Finset.card_le_card Finset.inter_subset_right) (by calc ({x, prev x, step x} : Finset V).card ≤ ({prev x, step x} : Finset V).card + 1 := Finset.card_insert_le _ _ _ ≤ 2 + 1 := by gcongr; exact Finset.card_le_two) omega obtain ⟨y, hy⟩ := Finset.card_pos.mp hrem rcases Finset.mem_sdiff.mp hy with ⟨hyP, hy_not⟩ simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hy_not have hxy : x ≠ y := Ne.symm hy_not.1 have hxy_ne : s(x, y) ∉ c.edgeSet := by rw [← mem_cNbr_iff, hcnbr_eq]; simp [hy_not.2.1, hy_not.2.2] have hout : ((cNbr c x ∪ cNbr c y) \ P).card ≤ 2 := by have hsub : (cNbr c x ∪ cNbr c y) \ P ⊆ cNbr c y := by intro w hw rcases Finset.mem_sdiff.mp hw with ⟨hwU, hwP⟩ rcases Finset.mem_union.mp hwU with hwx | hwy · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton] at hwx rcases hwx with rfl | rfl <;> exact absurd (by assumption) hwP · exact hwy exact le_trans (Finset.card_le_card hsub) (by rw [card_cNbr]) exact hwin_good x hxP y hyP hxy hxy_ne hout · push Not at hint -- No interior vertices! Look at `Q := P.filter (fun x => step x ∈ P)` (left endpoints of `P`-edges)! let Q := P.filter (fun x => step x ∈ P) -- **CASE 2**: `2 ≤ Q.card` (two 2-arcs in `P` → their left endpoints `a ≠ b` are a good pair!) by_cases hQ2 : 2 ≤ Q.card · obtain ⟨a, haQ, b, hbQ, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < Q.card) rcases Finset.mem_filter.mp haQ with ⟨haP, hsaP⟩ rcases Finset.mem_filter.mp hbQ with ⟨hbP, hsbP⟩ have hpa : prev a ∉ P := fun h => hint a haP h hsaP have hpb : prev b ∉ P := fun h => hint b hbP h hsbP have hab_ne : s(a, b) ∉ c.edgeSet := by rw [← mem_cNbr_iff, hcnbr_eq, Finset.mem_insert, Finset.mem_singleton] rintro (rfl | rfl) · exact hpa hbP · exact hpb (by rw [hprev_step]; exact haP) have hout : ((cNbr c a ∪ cNbr c b) \ P).card ≤ 2 := by have hsub : (cNbr c a ∪ cNbr c b) \ P ⊆ {prev a, prev b} := by intro w hw rcases Finset.mem_sdiff.mp hw with ⟨hwU, hwP⟩ rcases Finset.mem_union.mp hwU with hwa | hwb · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton] at hwa rcases hwa with rfl | rfl · exact Finset.mem_insert_self _ _ · exact absurd hsaP hwP · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton] at hwb rcases hwb with rfl | rfl · exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _) · exact absurd hsbP hwP exact le_trans (Finset.card_le_card hsub) Finset.card_le_two exact hwin_good a haP b hbP hab hab_ne hout · -- Now `Q.card ≤ 1`! Split on `Q.card = 1` vs `Q.card = 0`! by_cases hQ1 : Q.card = 1 · -- **CASE 3**: Unique edge `(u, step u)` in `P`! obtain ⟨u, huQ⟩ := Finset.card_pos.mp (by omega : 0 < Q.card) rcases Finset.mem_filter.mp huQ with ⟨huP, hsuP⟩ have hQ_eq : Q = {u} := (Finset.eq_singleton_iff_unique_mem.mpr ⟨huQ, fun v hv => by by_contra hne have : 2 ≤ Q.card := by have := Finset.card_le_card (Finset.insert_subset_iff.mpr ⟨hv, Finset.singleton_subset_iff.mpr huQ⟩) rw [Finset.card_pair hne] at this; exact this omega⟩) have hpu : sh 10 u ∉ P := by rw [hsh_ten]; exact fun h => hint u huP h hsuP have hsu2 : sh 2 u ∉ P := fun h => by have : sh 1 u ∈ Q := Finset.mem_filter.mpr ⟨by rwa [hsh_one], by rw [← hsh_one, hsh_add]; exact h⟩ rw [hQ_eq, Finset.mem_singleton] at this exact hsh_ne 1 0 u (by omega) (by omega) (by omega) (by rwa [hsh_zero]) -- Subcase 3a: `sh 9 u ∈ P` (`u-2 ∈ P`) → `(u, sh 9 u)` is a good pair! by_cases h9P : sh 9 u ∈ P · have hu9_ne : u ≠ sh 9 u := fun h => hsh_ne 0 9 u (by omega) (by omega) (by omega) (by rwa [hsh_zero]) have hu9_e : s(u, sh 9 u) ∉ c.edgeSet := by have heq : s(u, sh 9 u) = s(sh 0 u, sh 9 u) := by rw [hsh_zero] rw [heq, hsh_edge_iff 0 9 u (by omega) (by omega)]; omega have hout : ((cNbr c u ∪ cNbr c (sh 9 u)) \ P).card ≤ 2 := by have hsub : (cNbr c u ∪ cNbr c (sh 9 u)) \ P ⊆ {sh 10 u, sh 8 u} := by intro w hw rcases Finset.mem_sdiff.mp hw with ⟨hwU, hwP⟩ rcases Finset.mem_union.mp hwU with hwu | hw9 · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton] at hwu rcases hwu with rfl | rfl · rw [← hsh_ten]; exact Finset.mem_insert_self _ _ · exact absurd hsuP hwP · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton, ← hsh_ten, ← hsh_one, hsh_add, hsh_add] at hw9 rcases hw9 with rfl | rfl · have h19 : sh (9 + 10) u = sh 8 u := by dsimp [sh]; congr 1; ext; dsimp [cShift] generalize (c.toEquiv.symm u).1 = iu; rw [h11]; omega rw [h19]; exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _) · exact Finset.mem_insert_self _ _ exact le_trans (Finset.card_le_card hsub) Finset.card_le_two exact hwin_good u huP (sh 9 u) h9P hu9_ne hu9_e hout · -- Subcase 3b: `sh 3 u ∈ P` (`u+3 ∈ P`) → `(sh 1 u, sh 3 u)` is a good pair! by_cases h3P : sh 3 u ∈ P · have h13_ne : sh 1 u ≠ sh 3 u := hsh_ne 1 3 u (by omega) (by omega) (by omega) have h13_e : s(sh 1 u, sh 3 u) ∉ c.edgeSet := by rw [hsh_edge_iff 1 3 u (by omega) (by omega)]; omega have hout : ((cNbr c (sh 1 u) ∪ cNbr c (sh 3 u)) \ P).card ≤ 2 := by have hsub : (cNbr c (sh 1 u) ∪ cNbr c (sh 3 u)) \ P ⊆ {sh 2 u, sh 4 u} := by intro w hw rcases Finset.mem_sdiff.mp hw with ⟨hwU, hwP⟩ rcases Finset.mem_union.mp hwU with hw1 | hw3 · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton, hsh_one, hprev_step] at hw1 rcases hw1 with rfl | rfl · exact absurd huP hwP · rw [← hsh_one, ← hsh_one, hsh_add]; exact Finset.mem_insert_self _ _ · rw [hcnbr_eq, Finset.mem_insert, Finset.mem_singleton, ← hsh_ten, ← hsh_one, hsh_add, hsh_add] at hw3 rcases hw3 with rfl | rfl · have h13 : sh (3 + 10) u = sh 2 u := by dsimp [sh]; congr 1; ext; dsimp [cShift] generalize (c.toEquiv.symm u).1 = iu; rw [h11]; omega rw [h13]; exact Finset.mem_insert_self _ _ · exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _) exact le_trans (Finset.card_le_card hsub) Finset.card_le_two exact hwin_good (sh 1 u) (by rwa [hsh_one]) (sh 3 u) h3P h13_ne h13_e hout · -- Subcase 3c: `sh 9 u ∉ P` and `sh 3 u ∉ P` → `P = {u, u+1, u+4, u+6, u+8}`! have hno_adj_rem : ∀ k : ℕ, 4 ≤ k → k ≤ 7 → ¬ (sh k u ∈ P ∧ sh (k + 1) u ∈ P) := by intro k hk4 hk7 ⟨h1, h2⟩ have hmemQ : sh k u ∈ Q := Finset.mem_filter.mpr ⟨h1, by rw [← hsh_one, hsh_add]; exact h2⟩ rw [hQ_eq, Finset.mem_singleton] at hmemQ exact hsh_ne k 0 u (by omega) (by omega) (by omega) (by rwa [hsh_zero]) have hP_sub : P ⊆ {sh 0 u, sh 1 u, sh 4 u, sh 5 u, sh 6 u, sh 7 u, sh 8 u} := by intro w hwP let j := (c.toEquiv.symm w).1 let i0 := (c.toEquiv.symm u).1 let d := (j + 11 - i0) % 11 have hd_lt : d < 11 := Nat.mod_lt _ (by omega) have hw_eq : w = sh d u := by apply c.toEquiv.symm.injective dsimp [sh]; simp only [Equiv.symm_apply_apply] ext; dsimp [cShift] have hi0 : i0 < 11 := by rw [← h11]; exact (c.toEquiv.symm u).2 have hj : j < 11 := by rw [← h11]; exact (c.toEquiv.symm w).2 change j = (i0 + d) % Fintype.card V rw [h11]; dsimp [d]; rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] rw [show i0 + (j + 11 - i0) = j + 11 by omega, Nat.add_mod_right, Nat.mod_eq_of_lt hj] rw [hw_eq] at hwP ⊢ have hd2 : d ≠ 2 := fun h => hsu2 (h ▸ hwP) have hd3 : d ≠ 3 := fun h => h3P (h ▸ hwP) have hd9 : d ≠ 9 := fun h => h9P (h ▸ hwP) have hd10 : d ≠ 10 := fun h => hpu (h ▸ hwP) have hcases : d = 0 ∨ d = 1 ∨ d = 4 ∨ d = 5 ∨ d = 6 ∨ d = 7 ∨ d = 8 := by omega rcases hcases with hd | hd | hd | hd | hd | hd | hd <;> simp [hd] -- Since `|P| = 5` and `P` has no adjacent pair among `{4, 5, 6, 7, 8}`, `sh 6 u ∈ P`! have h6P : sh 6 u ∈ P := by by_contra h6not -- Then `P ∩ {4,5,6,7,8}` has at most 1 from `{4,5}` and at most 1 from `{7,8}`, total `≤ 4 < 5`! have h45 : (P ∩ {sh 4 u, sh 5 u}).card ≤ 1 := by by_contra hgt have hge2 : 2 ≤ (P ∩ {sh 4 u, sh 5 u}).card := by omega have heq : P ∩ {sh 4 u, sh 5 u} = {sh 4 u, sh 5 u} := Finset.eq_of_subset_of_card_le Finset.inter_subset_right (le_trans Finset.card_le_two hge2) have h4m : sh 4 u ∈ P := (Finset.mem_inter.mp (by rw [heq]; exact Finset.mem_insert_self _ _)).1 have h5m : sh 5 u ∈ P := (Finset.mem_inter.mp (by rw [heq]; exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _))).1 exact hno_adj_rem 4 (by omega) (by omega) ⟨h4m, h5m⟩ have h78 : (P ∩ {sh 7 u, sh 8 u}).card ≤ 1 := by by_contra hgt have hge2 : 2 ≤ (P ∩ {sh 7 u, sh 8 u}).card := by omega have heq : P ∩ {sh 7 u, sh 8 u} = {sh 7 u, sh 8 u} := Finset.eq_of_subset_of_card_le Finset.inter_subset_right (le_trans Finset.card_le_two hge2) have h7m : sh 7 u ∈ P := (Finset.mem_inter.mp (by rw [heq]; exact Finset.mem_insert_self _ _)).1 have h8m : sh 8 u ∈ P := (Finset.mem_inter.mp (by rw [heq]; exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _))).1 exact hno_adj_rem 7 (by omega) (by omega) ⟨h7m, h8m⟩ have hsub' : P ⊆ {sh 0 u, sh 1 u} ∪ (P ∩ {sh 4 u, sh 5 u}) ∪ (P ∩ {sh 7 u, sh 8 u}) := by intro w hw have hm := hP_sub hw simp only [Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with rfl | rfl | rfl | rfl | rfl | rfl | rfl · exact Finset.mem_union_left _ (Finset.mem_union_left _ (by simp)) · exact Finset.mem_union_left _ (Finset.mem_union_left _ (by simp)) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw, by simp⟩)) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw, by simp⟩)) · exact absurd hw h6not · exact Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw, by simp⟩) · exact Finset.mem_union_right _ (Finset.mem_inter.mpr ⟨hw, by simp⟩) have h01 : ({sh 0 u, sh 1 u} : Finset V).card ≤ 2 := Finset.card_le_two have hc := calc P.card ≤ ({sh 0 u, sh 1 u} ∪ (P ∩ {sh 4 u, sh 5 u}) ∪ (P ∩ {sh 7 u, sh 8 u})).card := Finset.card_le_card hsub' _ ≤ ({sh 0 u, sh 1 u} ∪ (P ∩ {sh 4 u, sh 5 u})).card + (P ∩ {sh 7 u, sh 8 u}).card := Finset.card_union_le _ _ _ ≤ ({sh 0 u, sh 1 u} : Finset V).card + (P ∩ {sh 4 u, sh 5 u}).card + (P ∩ {sh 7 u, sh 8 u}).card := by gcongr; exact Finset.card_union_le _ _ _ ≤ 2 + 1 + 1 := by omega omega -- Now `sh 2 u, sh 3 u, sh 9 u ∉ P`, and `sh 2 u, sh 3 u` are adjacent → split across `T₁, T₂`! have h23_edge : s(sh 2 u, sh 3 u) ∈ c.edgeSet := (hsh_edge_iff 2 3 u (by omega) (by omega)).mpr (Or.inl rfl) have h9_in : sh 9 u ∈ T₁ ∨ sh 9 u ∈ T₂ := by rcases hcov (sh 9 u) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h h9P have h2_in : sh 2 u ∈ T₁ ∨ sh 2 u ∈ T₂ := by rcases hcov (sh 2 u) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h hsu2 have h3_in : sh 3 u ∈ T₁ ∨ sh 3 u ∈ T₂ := by rcases hcov (sh 3 u) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h h3P -- Pick `a₁ ∈ T₁, a₂ ∈ T₂` from `{sh 9 u}` and `{sh 2 u, sh 3 u}`! have hex_pair : ∃ k₁ k₂ : ℕ, (k₁ = 9 ∧ (k₂ = 2 ∨ k₂ = 3) ∨ (k₁ = 2 ∨ k₁ = 3) ∧ k₂ = 9) ∧ sh k₁ u ∈ T₁ ∧ sh k₂ u ∈ T₂ := by rcases h9_in with h91 | h92 · rcases h2_in with h21 | h22 · rcases h3_in with h31 | h32 · exact absurd h23_edge ((isCycleIndep_iff_edges c T₁).mp hT1_ind _ h21 _ h31) · exact ⟨9, 3, Or.inl ⟨rfl, Or.inr rfl⟩, h91, h32⟩ · exact ⟨9, 2, Or.inl ⟨rfl, Or.inl rfl⟩, h91, h22⟩ · rcases h2_in with h21 | h22 · exact ⟨2, 9, Or.inr ⟨Or.inl rfl, rfl⟩, h21, h92⟩ · rcases h3_in with h31 | h32 · exact ⟨3, 9, Or.inr ⟨Or.inr rfl, rfl⟩, h31, h92⟩ · exact absurd h23_edge ((isCycleIndep_iff_edges c T₂).mp hT2_ind _ h22 _ h32) obtain ⟨k₁, k₂, hk12, hk1T1, hk2T2⟩ := hex_pair refine ⟨sh k₁ u, hk1T1, sh k₂ u, hk2T2, sh 0 u, by rwa [hsh_zero], sh 6 u, h6P, hsh_ne 0 6 u (by omega) (by omega) (by omega), ?_⟩ rw [isCycleIndep_iff_edges] intro w₁ hw₁ w₂ hw₂ hedge simp only [Finset.mem_insert, Finset.mem_singleton] at hw₁ hw₂ have hk_lt : k₁ < 11 ∧ k₂ < 11 := by rcases hk12 with ⟨rfl, rfl | rfl⟩ | ⟨rfl | rfl, rfl⟩ <;> omega rcases hw₁ with rfl | rfl | rfl | rfl <;> rcases hw₂ with rfl | rfl | rfl | rfl <;> (rw [hsh_edge_iff _ _ u (by omega) (by omega)] at hedge; rcases hk12 with ⟨rfl, rfl | rfl⟩ | ⟨rfl | rfl, rfl⟩ <;> omega) · -- **CASE 4**: `Q.card = 0` (`P` is `c`-independent of size 5 on `C₁₁`!) have hQ0 : Q = ∅ := Finset.card_eq_zero.mp (by omega) have hP_no_step : ∀ x ∈ P, step x ∉ P := fun x hx h => by have : x ∈ Q := Finset.mem_filter.mpr ⟨hx, h⟩ rw [hQ0] at this; exact Finset.notMem_empty _ this -- `P ∪ P.image step` has size `5 + 5 = 10`, leaving a UNIQUE vertex `z ∉ P ∪ P.image step`! have hdisj_Ps : Disjoint P (P.image step) := by rw [Finset.disjoint_left] intro x hx hfx rcases Finset.mem_image.mp hfx with ⟨a, ha, rfl⟩ exact hP_no_step a ha hx have hcard10 : (P ∪ P.image step).card = 10 := by rw [Finset.card_union_of_disjoint hdisj_Ps, Finset.card_image_of_injective _ hstep_inj, hP_card] have hcard1 : (Finset.univ \ (P ∪ P.image step)).card = 1 := by rw [Finset.card_sdiff, Finset.inter_univ, Finset.card_univ, h11, hcard10] obtain ⟨z, hz⟩ := Finset.card_pos.mp (by omega : 0 < (Finset.univ \ (P ∪ P.image step)).card) have hz_not : z ∉ P ∧ prev z ∉ P := by have h1 := (Finset.mem_sdiff.mp hz).2 rw [Finset.mem_union, not_or] at h1 refine ⟨h1.1, fun hp => h1.2 (Finset.mem_image.mpr ⟨prev z, hp, hstep_prev z⟩)⟩ have hP_univ : ∀ w : V, w ≠ z → w ∈ P ∨ prev w ∈ P := by intro w hwz have hsing : Finset.univ \ (P ∪ P.image step) = {z} := Finset.eq_singleton_iff_unique_mem.mpr ⟨hz, fun x hx => by by_contra hxz have : 2 ≤ (Finset.univ \ (P ∪ P.image step)).card := by have := Finset.card_le_card (Finset.insert_subset_iff.mpr ⟨hx, Finset.singleton_subset_iff.mpr hz⟩) rw [Finset.card_pair hxz] at this; exact this omega⟩ have hw_not_diff : w ∉ Finset.univ \ (P ∪ P.image step) := by rw [hsing, Finset.mem_singleton]; exact hwz have hw_in : w ∈ P ∪ P.image step := by by_contra hnot exact hw_not_diff (Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, hnot⟩) rcases Finset.mem_union.mp hw_in with h | h · exact Or.inl h · rcases Finset.mem_image.mp h with ⟨a, ha, rfl⟩ rw [hprev_step]; exact Or.inr ha -- Chain forward from `z ∉ P`: `sh 1 z ∈ P`, `sh 2 z ∉ P`, `sh 3 z ∈ P`, ..., `sh 9 z ∈ P`, `sh 10 z ∉ P`! have hstep_alt : ∀ k : ℕ, k < 10 → (sh k z ∉ P → sh (k + 1) z ∈ P) ∧ (sh k z ∈ P → sh (k + 1) z ∉ P) := by intro k hk constructor · intro hnot have hne : sh (k + 1) z ≠ z := by have h0 := hsh_ne (k + 1) 0 z (by omega) (by omega) (by omega) rwa [hsh_zero] at h0 rcases hP_univ (sh (k + 1) z) hne with h | h · exact h · exfalso; apply hnot have h1 : sh (k + 1) z = step (sh k z) := by rw [← hsh_one, hsh_add] rw [h1, hprev_step] at h; exact h · intro hin have : sh (k + 1) z = step (sh k z) := by rw [← hsh_one, hsh_add] rw [this]; exact hP_no_step _ hin have h0_not : sh 0 z ∉ P := by rw [hsh_zero]; exact hz_not.1 have h1_in : sh 1 z ∈ P := (hstep_alt 0 (by omega)).1 h0_not have h2_not : sh 2 z ∉ P := (hstep_alt 1 (by omega)).2 h1_in have h3_in : sh 3 z ∈ P := (hstep_alt 2 (by omega)).1 h2_not have h4_not : sh 4 z ∉ P := (hstep_alt 3 (by omega)).2 h3_in have h5_in : sh 5 z ∈ P := (hstep_alt 4 (by omega)).1 h4_not have h6_not : sh 6 z ∉ P := (hstep_alt 5 (by omega)).2 h5_in have h7_in : sh 7 z ∈ P := (hstep_alt 6 (by omega)).1 h6_not have h8_not : sh 8 z ∉ P := (hstep_alt 7 (by omega)).2 h7_in have h10_not : sh 10 z ∉ P := by rw [hsh_ten]; exact hz_not.2 -- Now `sh 10 z` and `sh 0 z` are adjacent and outside `P` → split across `T₁, T₂`! have h10_0_edge : s(sh 10 z, sh 0 z) ∈ c.edgeSet := (hsh_edge_iff 10 0 z (by omega) (by omega)).mpr (Or.inl rfl) have h8_in : sh 8 z ∈ T₁ ∨ sh 8 z ∈ T₂ := by rcases hcov (sh 8 z) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h h8_not have h10_in : sh 10 z ∈ T₁ ∨ sh 10 z ∈ T₂ := by rcases hcov (sh 10 z) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h h10_not have h0_in : sh 0 z ∈ T₁ ∨ sh 0 z ∈ T₂ := by rcases hcov (sh 0 z) with h | h | h · exact Or.inl h · exact Or.inr h · exact absurd h h0_not have hex_pair : ∃ k₁ k₂ : ℕ, (k₁ = 8 ∧ (k₂ = 10 ∨ k₂ = 0) ∨ (k₁ = 10 ∨ k₁ = 0) ∧ k₂ = 8) ∧ sh k₁ z ∈ T₁ ∧ sh k₂ z ∈ T₂ := by rcases h8_in with h81 | h82 · rcases h10_in with h101 | h102 · rcases h0_in with h01 | h02 · exact absurd h10_0_edge ((isCycleIndep_iff_edges c T₁).mp hT1_ind _ h101 _ h01) · exact ⟨8, 0, Or.inl ⟨rfl, Or.inr rfl⟩, h81, h02⟩ · exact ⟨8, 10, Or.inl ⟨rfl, Or.inl rfl⟩, h81, h102⟩ · rcases h10_in with h101 | h102 · exact ⟨10, 8, Or.inr ⟨Or.inl rfl, rfl⟩, h101, h82⟩ · rcases h0_in with h01 | h02 · exact ⟨0, 8, Or.inr ⟨Or.inr rfl, rfl⟩, h01, h82⟩ · exact absurd h10_0_edge ((isCycleIndep_iff_edges c T₂).mp hT2_ind _ h102 _ h02) obtain ⟨k₁, k₂, hk12, hk1T1, hk2T2⟩ := hex_pair refine ⟨sh k₁ z, hk1T1, sh k₂ z, hk2T2, sh 3 z, h3_in, sh 5 z, h5_in, hsh_ne 3 5 z (by omega) (by omega) (by omega), ?_⟩ rw [isCycleIndep_iff_edges] intro w₁ hw₁ w₂ hw₂ hedge simp only [Finset.mem_insert, Finset.mem_singleton] at hw₁ hw₂ have hk_lt : k₁ < 11 ∧ k₂ < 11 := by rcases hk12 with ⟨rfl, rfl | rfl⟩ | ⟨rfl | rfl, rfl⟩ <;> omega rcases hw₁ with rfl | rfl | rfl | rfl <;> rcases hw₂ with rfl | rfl | rfl | rfl <;> (rw [hsh_edge_iff _ _ z (by omega) (by omega)] at hedge; rcases hk12 with ⟨rfl, rfl | rfl⟩ | ⟨rfl | rfl, rfl⟩ <;> omega) /-- Helper for `n = 11` with chord 2-factor `C₃ + C₃ + C₅`. -/ private lemma sheehan_eleven_335 {G : SimpleGraph V} (h11 : Fintype.card V = 11) (c : DirHamCycle G) {T₁ T₂ D₅ : CycleIn (chordGraph c)} (h12 : Disjoint T₁.vertSet T₂.vertSet) (h15 : Disjoint T₁.vertSet D₅.vertSet) (h25 : Disjoint T₂.vertSet D₅.vertSet) (hcov : ∀ v : V, v ∈ T₁.vertSet ∨ v ∈ T₂.vertSet ∨ v ∈ D₅.vertSet) (hT1_3 : T₁.len = 3) (hT2_3 : T₂.len = 3) (hD5_5 : D₅.len = 5) : 2 ≤ (hamCycles G).card := by obtain ⟨a₁, ha₁, a₂, ha₂, x, hx, y, hy, hxy, hind⟩ := exists_near_cid_335 h11 c (by rw [T₁.card_vertSet, hT1_3]) (by rw [T₂.card_vertSet, hT2_3]) (by rw [D₅.card_vertSet, hD5_5]) h12 h15 h25 hcov (triangle_isCycleIndep hT1_3) (triangle_isCycleIndep hT2_3) obtain ⟨v₀, hv₀D5, hv₀x, hv₀y, hdom5⟩ := two_verts_near_dom_pentagon hD5_5 hx hy hxy let A : Finset V := {a₁, a₂, x, y} have hv₀A : v₀ ∉ A := by simp only [A, Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨fun h => Finset.disjoint_left.mp h15 (h ▸ ha₁) hv₀D5, fun h => Finset.disjoint_left.mp h25 (h ▸ ha₂) hv₀D5, hv₀x, hv₀y⟩ refine exists_second_hamCycle_of_near_cid c A hind v₀ hv₀A ?_ intro w hwA hwv₀ have hw1 : w ≠ a₁ := fun h => hwA (by simp [A, h]) have hw2 : w ≠ a₂ := fun h => hwA (by simp [A, h]) have hwx : w ≠ x := fun h => hwA (by simp [A, h]) have hwy : w ≠ y := fun h => hwA (by simp [A, h]) rcases hcov w with hwT1 | hwT2 | hwD5 · exact ⟨a₁, by simp [A], triangle_chord_adj hT1_3 hwT1 ha₁ hw1⟩ · exact ⟨a₂, by simp [A], triangle_chord_adj hT2_3 hwT2 ha₂ hw2⟩ · rcases hdom5 w hwD5 hwx hwy hwv₀ with h1 | h2 · exact ⟨x, by simp [A], h1⟩ · exact ⟨y, by simp [A], h2⟩ /-- **Theorem 6d (Sheehan's Conjecture for ALL `n = 11`)**: Every 4-regular Hamiltonian simple graph on `11` vertices has at least 2 Hamiltonian cycles. -/ theorem sheehan_of_card_eleven {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (h11 : Fintype.card V = 11) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) by_cases hodd1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1 · exact exists_second_hamCycle_of_le_one_odd_chord_cycle c 𝒟 hpw hcov hodd1 · by_cases hlen2 : 𝒟.length ≤ 2 · exact exists_second_hamCycle_of_le_two_chord_components c 𝒟 hpw hcov hlen2 · have h3 := three_mul_length_le_card hpw hcov have hlen3 : 𝒟.length = 3 := by omega match h𝒟 : 𝒟 with | [D₁, D₂, D₃] => have hsum := cycle_decomp_sum_len hpw hcov simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] at hsum have h1 := D₁.len_ge_three; have h2 := D₂.len_ge_three; have h3' := D₃.len_ge_three have hpw' : Disjoint D₁.vertSet D₂.vertSet ∧ Disjoint D₁.vertSet D₃.vertSet ∧ Disjoint D₂.vertSet D₃.vertSet := by rcases List.pairwise_cons.mp hpw with ⟨hA, hBC⟩ rcases List.pairwise_cons.mp hBC with ⟨hB, _⟩ exact ⟨hA _ (by simp), hA _ (by simp), hB _ (by simp)⟩ have hcov' : ∀ v : V, v ∈ D₁.vertSet ∨ v ∈ D₂.vertSet ∨ v ∈ D₃.vertSet := fun v => by obtain ⟨D, hD, hvD⟩ := hcov v; simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl | rfl <;> tauto -- Since `D₁.len + D₂.len + D₃.len = 11` and at least 2 are odd, ALL 3 are odd → `{3, 3, 5}`! have hall_odd : Odd D₁.len ∧ Odd D₂.len ∧ Odd D₃.len := by rcases Nat.even_or_odd D₁.len with he1 | ho1 <;> rcases Nat.even_or_odd D₂.len with he2 | ho2 <;> rcases Nat.even_or_odd D₃.len with he3 | ho3 · rcases he1 with ⟨a, _⟩; rcases he2 with ⟨b, _⟩; rcases he3 with ⟨d, _⟩; omega · exfalso; apply hodd1; simp [Nat.not_odd_iff_even.mpr he1, Nat.not_odd_iff_even.mpr he2, ho3] · exfalso; apply hodd1; simp [Nat.not_odd_iff_even.mpr he1, ho2, Nat.not_odd_iff_even.mpr he3] · rcases he1 with ⟨a, _⟩; rcases ho2 with ⟨b, _⟩; rcases ho3 with ⟨d, _⟩; omega · exfalso; apply hodd1; simp [ho1, Nat.not_odd_iff_even.mpr he2, Nat.not_odd_iff_even.mpr he3] · rcases ho1 with ⟨a, _⟩; rcases he2 with ⟨b, _⟩; rcases ho3 with ⟨d, _⟩; omega · rcases ho1 with ⟨a, _⟩; rcases ho2 with ⟨b, _⟩; rcases he3 with ⟨d, _⟩; omega · exact ⟨ho1, ho2, ho3⟩ rcases hall_odd with ⟨⟨a, ha⟩, ⟨b, hb⟩, ⟨d, hd⟩⟩ have hcases : (D₁.len = 3 ∧ D₂.len = 3 ∧ D₃.len = 5) ∨ (D₁.len = 3 ∧ D₃.len = 3 ∧ D₂.len = 5) ∨ (D₂.len = 3 ∧ D₃.len = 3 ∧ D₁.len = 5) := by omega rcases hcases with ⟨l1, l2, l3⟩ | ⟨l1, l2, l3⟩ | ⟨l1, l2, l3⟩ · exact sheehan_eleven_335 h11 c hpw'.1 hpw'.2.1 hpw'.2.2 hcov' l1 l2 l3 · exact sheehan_eleven_335 h11 c hpw'.2.1 hpw'.1 hpw'.2.2.symm (fun v => by rcases hcov' v with h | h | h <;> tauto) l1 l2 l3 · exact sheehan_eleven_335 h11 c hpw'.2.2 hpw'.1.symm hpw'.2.1.symm (fun v => by rcases hcov' v with h | h | h <;> tauto) l1 l2 l3 | [] | [_] | [_, _] | _ :: _ :: _ :: _ :: _ => simp at hlen3 /-- Helper for `n = 12` separated `C₃ + C₃ + C₆` via exact parity forcing + Near-Domination of `C₆`. -/ private lemma sheehan_twelve_336_sep {G : SimpleGraph V} (h12 : Fintype.card V = 12) (c : DirHamCycle G) {T₁ T₂ H₆ : CycleIn (chordGraph c)} (h12d : Disjoint T₁.vertSet T₂.vertSet) (h16 : Disjoint T₁.vertSet H₆.vertSet) (h26 : Disjoint T₂.vertSet H₆.vertSet) (hcov : ∀ v : V, v ∈ T₁.vertSet ∨ v ∈ T₂.vertSet ∨ v ∈ H₆.vertSet) (hT1_3 : T₁.len = 3) (hT2_3 : T₂.len = 3) (hH6_6 : H₆.len = 6) (hsep : ∀ u ∈ T₁.vertSet, ∀ v ∈ T₂.vertSet, s(u, v) ∉ c.edgeSet) : 2 ≤ (hamCycles G).card := by have hn : 0 < Fintype.card V := by omega let A₀ := T₁.vertSet ∪ T₂.vertSet have hA₀_ind : IsCycleIndep c A₀ := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge rcases Finset.mem_union.mp hx with hx1 | hx2 <;> rcases Finset.mem_union.mp hy with hy1 | hy2 · exact (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT1_3) x hx1 y hy1 hedge · exact hsep x hx1 y hy2 hedge · exact hsep y hy1 x hx2 (by rwa [Sym2.eq_swap]) · exact (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT2_3) x hx2 y hy2 hedge have hA₀_card : A₀.card = 6 := by rw [Finset.card_union_of_disjoint h12d, T₁.card_vertSet, T₂.card_vertSet, hT1_3, hT2_3] have hhalf : 2 * A₀.card = Fintype.card V := by omega have hnext_iff := isCycleIndep_half_card_next_iff c hA₀_ind hhalf -- `H₆.vertSet` is precisely `V \ A₀`, and is ALSO `c`-independent! have hH6_iff : ∀ v : V, v ∈ H₆.vertSet ↔ v ∉ A₀ := fun v => by constructor · intro hv hA; rcases Finset.mem_union.mp hA with h1 | h2 · exact Finset.disjoint_left.mp h16 h1 hv · exact Finset.disjoint_left.mp h26 h2 hv · intro hnot; rcases hcov v with h1 | h2 | h3 · exact absurd (Finset.mem_union_left _ h1) hnot · exact absurd (Finset.mem_union_right _ h2) hnot · exact h3 have hH6_ind : IsCycleIndep c H₆.vertSet := by intro i hi hnext have hi_not : c.toEquiv i ∉ A₀ := (hH6_iff _).mp hi have hnext_not : c.toEquiv (cNext hn i) ∉ A₀ := (hH6_iff _).mp hnext exact hi_not ((hnext_iff i).mp hnext_not) -- Since `A₀` is invariant under `cNext ∘ cNext` (a 6-cycle on `A₀`), `∃ a₁ ∈ T₁, step2 a₁ ∈ T₂`! let step2 : V → V := fun v => c.toEquiv (cNext hn (cNext hn (c.toEquiv.symm v))) have hstep2_A₀ : ∀ v ∈ A₀, step2 v ∈ A₀ := fun v hv => by have h1 : c.toEquiv (cNext hn (c.toEquiv.symm v)) ∉ A₀ := (hnext_iff _).mpr (by simpa using hv) by_contra hnot exact h1 ((hnext_iff (cNext hn (c.toEquiv.symm v))).mp hnot) have hex_bridge : ∃ a₁ ∈ T₁.vertSet, step2 a₁ ∈ T₂.vertSet := by by_contra hnone push Not at hnone have hclosed : ∀ v ∈ T₁.vertSet, step2 v ∈ T₁.vertSet := fun v hv => by have hmem := hstep2_A₀ v (Finset.mem_union_left _ hv) rcases Finset.mem_union.mp hmem with h1 | h2 · exact h1 · exact absurd h2 (hnone v hv) -- Starting from `a₀ ∈ T₁`, the 6 iterates `cShift (2k)` are 6 distinct vertices of `T₁`, contradicting `|T₁| = 3`! obtain ⟨a₀, ha₀⟩ := Finset.card_pos.mp (by rw [T₁.card_vertSet, hT1_3]; omega : 0 < T₁.vertSet.card) let i₀ := c.toEquiv.symm a₀ have hiter : ∀ k : ℕ, c.toEquiv (cShift hn (2 * k) i₀) ∈ T₁.vertSet := by intro k induction k with | zero => simpa [i₀, cShift_zero] using ha₀ | succ m ih => have hstep := hclosed _ ih have heq : step2 (c.toEquiv (cShift hn (2 * m) i₀)) = c.toEquiv (cShift hn (2 * (m + 1)) i₀) := by dsimp [step2]; simp only [Equiv.symm_apply_apply] rw [show 2 * (m + 1) = (2 * m + 1) + 1 by omega, cShift_succ, cShift_succ] rwa [heq] at hstep have hsub : (Finset.univ.image (fun k : Fin 6 => c.toEquiv (cShift hn (2 * k.1) i₀))) ⊆ T₁.vertSet := by intro w hw; rcases Finset.mem_image.mp hw with ⟨k, _, rfl⟩; exact hiter k.1 have hinj : Function.Injective (fun k : Fin 6 => c.toEquiv (cShift hn (2 * k.1) i₀)) := by intro k₁ k₂ heq have hv := congrArg Fin.val (c.toEquiv.injective heq) dsimp [cShift] at hv have hlt := i₀.2 generalize i₀.1 = iv at hlt hv rw [h12] at hlt hv; ext; omega have h6le : 6 ≤ T₁.vertSet.card := by calc 6 = (Finset.univ : Finset (Fin 6)).card := by simp _ = (Finset.univ.image (fun k : Fin 6 => c.toEquiv (cShift hn (2 * k.1) i₀))).card := (Finset.card_image_of_injective _ hinj).symm _ ≤ T₁.vertSet.card := Finset.card_le_card hsub rw [T₁.card_vertSet, hT1_3] at h6le; omega obtain ⟨a₁, ha₁, ha₂⟩ := hex_bridge let a₂ := step2 a₁ let i₁ := c.toEquiv.symm a₁ -- `cNbr a₁ ∪ cNbr a₂` has size 3 (all in `H₆`): `{cPrev i₁, cNext i₁, cNext^3 i₁}`! let F := cNbr c a₁ ∪ cNbr c a₂ have hF_sub : F ⊆ H₆.vertSet := by intro w hw rw [hH6_iff] intro hwA₀ rcases Finset.mem_union.mp hw with h1 | h2 · exact (isCycleIndep_iff_edges c A₀).mp hA₀_ind a₁ (Finset.mem_union_left _ ha₁) w hwA₀ ((mem_cNbr_iff c a₁ w).mp h1) · exact (isCycleIndep_iff_edges c A₀).mp hA₀_ind a₂ (Finset.mem_union_right _ ha₂) w hwA₀ ((mem_cNbr_iff c a₂ w).mp h2) have hF_eq : F = {c.toEquiv (cPrev hn i₁), c.toEquiv (cNext hn i₁), c.toEquiv (cNext hn (cNext hn (cNext hn i₁)))} := by ext w simp only [F, cNbr, a₂, step2, i₁, Equiv.symm_apply_apply, Finset.mem_union, Finset.mem_insert, Finset.mem_singleton, cPrev_cNext] tauto have hF_card : F.card = 3 := by rw [hF_eq] have hne : ∀ a b : Fin (Fintype.card V), a.1 ≠ b.1 → c.toEquiv a ≠ c.toEquiv b := fun a b h heq => h (congrArg Fin.val (c.toEquiv.injective heq)) have hi1 := i₁.2 have h12' : c.toEquiv (cPrev hn i₁) ≠ c.toEquiv (cNext hn i₁) := fun h => cNext_ne_cPrev (by omega) i₁ (c.toEquiv.injective h).symm have h13' : c.toEquiv (cPrev hn i₁) ≠ c.toEquiv (cNext hn (cNext hn (cNext hn i₁))) := by apply hne; rw [cPrev_val, cNext_val, cNext_val, cNext_val]; split_ifs <;> omega have h23' : c.toEquiv (cNext hn i₁) ≠ c.toEquiv (cNext hn (cNext hn (cNext hn i₁))) := by apply hne have hcn_mod : ∀ x : Fin (Fintype.card V), (cNext hn x).1 = (x.1 + 1) % Fintype.card V := fun x => by rw [cNext_val]; split_ifs with h · exact (Nat.mod_eq_of_lt h).symm · rw [show x.1 + 1 = Fintype.card V by omega, Nat.mod_self] simp only [hcn_mod, Nat.mod_add_mod] generalize i₁.1 = iv at hi1 ⊢; rw [h12] at hi1 ⊢; omega rw [Finset.card_insert_of_notMem (by simp [h12', h13']), Finset.card_pair h23'] let S := H₆.vertSet \ F have hS_sub : S ⊆ H₆.vertSet := Finset.sdiff_subset have hS_card : S.card = 3 := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hF_sub, H₆.card_vertSet, hH6_6, hF_card] obtain ⟨v₀, hv₀H, hv₀S, hdomH⟩ := three_verts_near_dom_hexagon hH6_6 hS_sub hS_card let A : Finset V := insert a₁ (insert a₂ S) have hv₀A : v₀ ∉ A := by simp only [A, Finset.mem_insert, not_or] exact ⟨fun h => Finset.disjoint_left.mp h16 (h ▸ ha₁) hv₀H, fun h => Finset.disjoint_left.mp h26 (h ▸ ha₂) hv₀H, hv₀S⟩ have hA_ind : IsCycleIndep c A := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge simp only [A, Finset.mem_insert] at hx hy have h12e : s(a₁, a₂) ∉ c.edgeSet := (isCycleIndep_iff_edges c A₀).mp hA₀_ind a₁ (Finset.mem_union_left _ ha₁) a₂ (Finset.mem_union_right _ ha₂) have h1Se : ∀ s ∈ S, s(a₁, s) ∉ c.edgeSet := fun s hs h => (Finset.mem_sdiff.mp hs).2 (Finset.mem_union_left _ ((mem_cNbr_iff c a₁ s).mpr h)) have h2Se : ∀ s ∈ S, s(a₂, s) ∉ c.edgeSet := fun s hs h => (Finset.mem_sdiff.mp hs).2 (Finset.mem_union_right _ ((mem_cNbr_iff c a₂ s).mpr h)) rcases hx with rfl | rfl | hxS <;> rcases hy with rfl | rfl | hyS · exact G.loopless.irrefl _ (c.adj_of_mem_edgeSet hedge) · exact h12e hedge · exact h1Se y hyS hedge · exact h12e (by rwa [Sym2.eq_swap]) · exact G.loopless.irrefl _ (c.adj_of_mem_edgeSet hedge) · exact h2Se y hyS hedge · exact h1Se x hxS (by rwa [Sym2.eq_swap]) · exact h2Se x hxS (by rwa [Sym2.eq_swap]) · exact (isCycleIndep_iff_edges c H₆.vertSet).mp hH6_ind x (hS_sub hxS) y (hS_sub hyS) hedge refine exists_second_hamCycle_of_near_cid c A hA_ind v₀ hv₀A ?_ intro w hwA hwv₀ have hw1 : w ≠ a₁ := fun h => hwA (by simp [A, h]) have hw2 : w ≠ a₂ := fun h => hwA (by simp [A, h]) have hwS : w ∉ S := fun h => hwA (by simp [A, h]) rcases hcov w with hwT1 | hwT2 | hwH6 · exact ⟨a₁, by simp [A], triangle_chord_adj hT1_3 hwT1 ha₁ hw1⟩ · exact ⟨a₂, by simp [A], triangle_chord_adj hT2_3 hwT2 ha₂ hw2⟩ · obtain ⟨s, hsS, hadj⟩ := hdomH w hwH6 hwS hwv₀ exact ⟨s, by simp [A, hsS], hadj⟩ /-- Helper for `n = 12` separated `C₃ + C₅ + C₄`: forces `T₁ = {k, k+2, k+4}`, `Q₄ = {k-1, k+1, k+3, k+5}`, `D₅ = {k+6, k+7, k+8, k+9, k+10}`, then 6-pairs-vs-5-edges Pigeonhole yields a Near-$C$-ID set! -/ private lemma sheehan_twelve_354_sep {G : SimpleGraph V} (h12 : Fintype.card V = 12) (c : DirHamCycle G) {T₁ D₅ Q₄ : CycleIn (chordGraph c)} (_h15 : Disjoint T₁.vertSet D₅.vertSet) (h14 : Disjoint T₁.vertSet Q₄.vertSet) (h54 : Disjoint D₅.vertSet Q₄.vertSet) (hcov : ∀ v : V, v ∈ T₁.vertSet ∨ v ∈ D₅.vertSet ∨ v ∈ Q₄.vertSet) (hT1_3 : T₁.len = 3) (hD5_5 : D₅.len = 5) (hQ4_4 : Q₄.len = 4) (hsep : ∀ u ∈ T₁.vertSet, ∀ v ∈ D₅.vertSet, s(u, v) ∉ c.edgeSet) : 2 ≤ (hamCycles G).card := by have hn : 0 < Fintype.card V := by omega let step : V → V := fun v => c.toEquiv (cNext hn (c.toEquiv.symm v)) let prev : V → V := fun v => c.toEquiv (cPrev hn (c.toEquiv.symm v)) let sh : ℕ → V → V := fun k v => c.toEquiv (cShift hn k (c.toEquiv.symm v)) have hstep_inj : Function.Injective step := fun x y h => c.toEquiv.symm.injective (cNext_injective hn (c.toEquiv.injective h)) have hprev_inj : Function.Injective prev := fun x y h => c.toEquiv.symm.injective (by have := c.toEquiv.injective h rw [← cNext_cPrev hn (c.toEquiv.symm x), ← cNext_cPrev hn (c.toEquiv.symm y), this]) have hsh_ne : ∀ (a b : ℕ) (v : V), a < 12 → b < 12 → a ≠ b → sh a v ≠ sh b v := by intro a b v ha hb hab heq have hv := congrArg Fin.val (c.toEquiv.injective heq) dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h12] at hlt hv; omega have hsh_edge_iff : ∀ (a b : ℕ) (v : V), a < 12 → b < 12 → (s(sh a v, sh b v) ∈ c.edgeSet ↔ (a + 1) % 12 = b ∨ (b + 1) % 12 = a) := by intro a b v ha hb have hiff := c.mem_edgeSet_iff (cShift hn a (c.toEquiv.symm v)) (cShift hn b (c.toEquiv.symm v)) change s(sh a v, sh b v) ∈ c.edgeSet ↔ _ at hiff rw [hiff] have hcn_mod : ∀ x : Fin (Fintype.card V), (cNext hn x).1 = (x.1 + 1) % Fintype.card V := fun x => by rw [cNext_val]; split_ifs with h · exact (Nat.mod_eq_of_lt h).symm · rw [show x.1 + 1 = Fintype.card V by omega, Nat.mod_self] have hcp_mod : ∀ x : Fin (Fintype.card V), (cPrev hn x).1 = (x.1 + 11) % Fintype.card V := fun x => by rw [cPrev_val]; have hx := x.2; generalize x.1 = xv at hx ⊢; rw [h12] at hx ⊢; split_ifs <;> omega constructor · rintro (h | h) · left have hv := congrArg Fin.val h; rw [hcn_mod] at hv; dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2; generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h12] at hlt hv; omega · right have hv := congrArg Fin.val h; rw [hcp_mod] at hv; dsimp [cShift] at hv have hlt := (c.toEquiv.symm v).2; generalize (c.toEquiv.symm v).1 = iv at hlt hv rw [h12] at hlt hv; omega · rintro (h | h) · left; ext; rw [hcn_mod]; dsimp [cShift] have hlt := (c.toEquiv.symm v).2; generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h12] at hlt ⊢; omega · right; ext; rw [hcp_mod]; dsimp [cShift] have hlt := (c.toEquiv.symm v).2; generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h12] at hlt ⊢; omega -- Every `c`-neighbor of `T₁` MUST lie in `Q₄`! have hT1_nb_Q4 : ∀ t ∈ T₁.vertSet, step t ∈ Q₄.vertSet ∧ prev t ∈ Q₄.vertSet := by intro t ht have h1 : s(t, step t) ∈ c.edgeSet := (mem_cNbr_iff c t (step t)).mp (by dsimp [cNbr]; simp [step]) have h2 : s(t, prev t) ∈ c.edgeSet := (mem_cNbr_iff c t (prev t)).mp (by dsimp [cNbr]; simp [prev]) constructor · rcases hcov (step t) with h | h | h · exact absurd h1 ((isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT1_3) t ht _ h) · exact absurd h1 (hsep t ht _ h) · exact h · rcases hcov (prev t) with h | h | h · exact absurd h2 ((isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep hT1_3) t ht _ h) · exact absurd h2 (hsep t ht _ h) · exact h -- Hence `|(T₁.image step) ∩ (T₁.image prev)| ≥ 3 + 3 - 4 = 2`, forcing `T₁ = {k, k+2, k+4}`! let I := (T₁.vertSet.image step) ∩ (T₁.vertSet.image prev) have hI_ge2 : 2 ≤ I.card := by have hsub : (T₁.vertSet.image step) ∪ (T₁.vertSet.image prev) ⊆ Q₄.vertSet := by intro x hx rcases Finset.mem_union.mp hx with h | h · rcases Finset.mem_image.mp h with ⟨t, ht, rfl⟩; exact (hT1_nb_Q4 t ht).1 · rcases Finset.mem_image.mp h with ⟨t, ht, rfl⟩; exact (hT1_nb_Q4 t ht).2 have hunion := Finset.card_union_add_card_inter (T₁.vertSet.image step) (T₁.vertSet.image prev) have hc1 : (T₁.vertSet.image step).card = 3 := by rw [Finset.card_image_of_injective _ hstep_inj, T₁.card_vertSet, hT1_3] have hc2 : (T₁.vertSet.image prev).card = 3 := by rw [Finset.card_image_of_injective _ hprev_inj, T₁.card_vertSet, hT1_3] have hle4 : ((T₁.vertSet.image step) ∪ (T₁.vertSet.image prev)).card ≤ 4 := by calc _ ≤ Q₄.vertSet.card := Finset.card_le_card hsub _ = 4 := by rw [Q₄.card_vertSet, hQ4_4] dsimp [I]; omega obtain ⟨x₁, hx₁I, x₂, hx₂I, hx12⟩ := Finset.one_lt_card.mp (by omega : 1 < I.card) have hmem_I : ∀ x ∈ I, prev x ∈ T₁.vertSet ∧ step x ∈ T₁.vertSet := fun x hx => by rcases Finset.mem_inter.mp hx with ⟨h1, h2⟩ rcases Finset.mem_image.mp h1 with ⟨t₁, ht₁, rfl⟩ rcases Finset.mem_image.mp h2 with ⟨t₂, ht₂, heq⟩ have hp : prev (step t₁) = t₁ := by simp [prev, step, cPrev_cNext] have hs : step (step t₁) = t₂ := by rw [← heq]; simp [prev, step, cNext_cPrev] exact ⟨by rwa [hp], by rwa [hs]⟩ have h1p := (hmem_I x₁ hx₁I).1; have h1s := (hmem_I x₁ hx₁I).2 have h2p := (hmem_I x₂ hx₂I).1; have h2s := (hmem_I x₂ hx₂I).2 have hne_ps : ∀ x : V, prev x ≠ step x := fun x h => cNext_ne_cPrev (by omega) (c.toEquiv.symm x) (c.toEquiv.injective h).symm -- Since `|T₁| = 3`, `{prev x₁, step x₁}` and `{prev x₂, step x₂}` MUST overlap! have hoverlap : step x₁ = prev x₂ ∨ step x₂ = prev x₁ := by by_contra hno push Not at hno have hdisj : Disjoint ({prev x₁, step x₁} : Finset V) {prev x₂, step x₂} := by rw [Finset.disjoint_left] intro w hw1 hw2 simp only [Finset.mem_insert, Finset.mem_singleton] at hw1 hw2 rcases hw1 with rfl | rfl <;> rcases hw2 with h | h · exact hx12 (hprev_inj h) · exact hno.2 h.symm · exact hno.1 h · exact hx12 (hstep_inj h) have hsub : ({prev x₁, step x₁} : Finset V) ∪ {prev x₂, step x₂} ⊆ T₁.vertSet := by intro w hw; simp only [Finset.mem_union, Finset.mem_insert, Finset.mem_singleton] at hw rcases hw with (rfl | rfl) | (rfl | rfl) <;> assumption have hc4 : 4 ≤ T₁.vertSet.card := by calc 4 = ({prev x₁, step x₁} : Finset V).card + ({prev x₂, step x₂} : Finset V).card := by rw [Finset.card_pair (hne_ps x₁), Finset.card_pair (hne_ps x₂)] _ = (({prev x₁, step x₁} : Finset V) ∪ {prev x₂, step x₂}).card := (Finset.card_union_of_disjoint hdisj).symm _ ≤ T₁.vertSet.card := Finset.card_le_card hsub rw [T₁.card_vertSet, hT1_3] at hc4; omega -- Extract base vertex `v` such that `sh 0 v, sh 2 v, sh 4 v ∈ T₁.vertSet`! have hbase : ∃ v : V, sh 0 v ∈ T₁.vertSet ∧ sh 2 v ∈ T₁.vertSet ∧ sh 4 v ∈ T₁.vertSet := by have hsh_step : ∀ m y, step (sh m y) = sh (m + 1) y := fun m y => by dsimp [step, sh]; simp only [Equiv.symm_apply_apply]; rw [cShift_succ] have hsh0 : ∀ y, sh 0 y = y := fun y => by simp [sh, cShift_zero] rcases hoverlap with h | h · refine ⟨prev x₁, by rwa [hsh0], ?_, ?_⟩ · have : sh 2 (prev x₁) = step x₁ := by rw [show (2 : ℕ) = 1 + 1 by rfl, ← hsh_step, ← hsh_step, hsh0] simp [step, prev, cNext_cPrev] rwa [this] · have : sh 4 (prev x₁) = step x₂ := by have h2 : sh 2 (prev x₁) = prev x₂ := by rw [← h, show (2 : ℕ) = 1 + 1 by rfl, ← hsh_step, ← hsh_step, hsh0] simp [step, prev, cNext_cPrev] rw [show (4 : ℕ) = 3 + 1 by rfl, ← hsh_step, show (3 : ℕ) = 2 + 1 by rfl, ← hsh_step, h2] simp [step, prev, cNext_cPrev] rwa [this] · refine ⟨prev x₂, by rwa [hsh0], ?_, ?_⟩ · have : sh 2 (prev x₂) = step x₂ := by rw [show (2 : ℕ) = 1 + 1 by rfl, ← hsh_step, ← hsh_step, hsh0] simp [step, prev, cNext_cPrev] rwa [this] · have : sh 4 (prev x₂) = step x₁ := by have h2 : sh 2 (prev x₂) = prev x₁ := by rw [← h, show (2 : ℕ) = 1 + 1 by rfl, ← hsh_step, ← hsh_step, hsh0] simp [step, prev, cNext_cPrev] rw [show (4 : ℕ) = 3 + 1 by rfl, ← hsh_step, show (3 : ℕ) = 2 + 1 by rfl, ← hsh_step, h2] simp [step, prev, cNext_cPrev] rwa [this] obtain ⟨v, hv0, hv2, hv4⟩ := hbase -- Now `sh 1 v, sh 3 v, sh 5 v, sh 11 v ∈ Q₄`, forcing `sh 6 v, sh 7 v, sh 8 v, sh 9 v, sh 10 v ∈ D₅`! have hsh_step : ∀ m, step (sh m v) = sh (m + 1) v := fun m => by dsimp [step, sh]; simp only [Equiv.symm_apply_apply]; rw [cShift_succ] have hsh_prev0 : prev (sh 0 v) = sh 11 v := by apply hstep_inj have : step (prev (sh 0 v)) = sh 0 v := by simp [step, prev, cNext_cPrev] rw [this, hsh_step, show sh 0 v = v from by simp [sh, cShift_zero]] dsimp [sh]; conv_lhs => rw [← c.toEquiv.apply_symm_apply v] congr 1; ext; dsimp [cShift] have hlt := (c.toEquiv.symm v).2 generalize (c.toEquiv.symm v).1 = iv at hlt ⊢ rw [h12] at hlt ⊢; omega have hq1 : sh 1 v ∈ Q₄.vertSet := by rw [← hsh_step 0]; exact (hT1_nb_Q4 _ hv0).1 have hq3 : sh 3 v ∈ Q₄.vertSet := by rw [← hsh_step 2]; exact (hT1_nb_Q4 _ hv2).1 have hq5 : sh 5 v ∈ Q₄.vertSet := by rw [← hsh_step 4]; exact (hT1_nb_Q4 _ hv4).1 have hq11 : sh 11 v ∈ Q₄.vertSet := by rw [← hsh_prev0]; exact (hT1_nb_Q4 _ hv0).2 have hT1_eq : T₁.vertSet = {sh 0 v, sh 2 v, sh 4 v} := by apply (Finset.eq_of_subset_of_card_le _ _).symm · intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl <;> assumption · rw [T₁.card_vertSet, hT1_3, Finset.card_insert_of_notMem (by simp [hsh_ne 0 2 v (by omega) (by omega) (by omega), hsh_ne 0 4 v (by omega) (by omega) (by omega)]), Finset.card_pair (hsh_ne 2 4 v (by omega) (by omega) (by omega))] have hQ4_eq : Q₄.vertSet = {sh 1 v, sh 3 v, sh 5 v, sh 11 v} := by apply (Finset.eq_of_subset_of_card_le _ _).symm · intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl | rfl <;> assumption · rw [Q₄.card_vertSet, hQ4_4, Finset.card_insert_of_notMem (by simp [hsh_ne 1 3 v (by omega) (by omega) (by omega), hsh_ne 1 5 v (by omega) (by omega) (by omega), hsh_ne 1 11 v (by omega) (by omega) (by omega)]), Finset.card_insert_of_notMem (by simp [hsh_ne 3 5 v (by omega) (by omega) (by omega), hsh_ne 3 11 v (by omega) (by omega) (by omega)]), Finset.card_pair (hsh_ne 5 11 v (by omega) (by omega) (by omega))] have hD5_mem : ∀ k : ℕ, 6 ≤ k → k ≤ 10 → sh k v ∈ D₅.vertSet := by intro k hk6 hk10 rcases hcov (sh k v) with h1 | h2 | h3 · rw [hT1_eq] at h1; simp only [Finset.mem_insert, Finset.mem_singleton] at h1 rcases h1 with h | h | h <;> exact absurd h (hsh_ne k _ v (by omega) (by omega) (by omega)) · exact h2 · rw [hQ4_eq] at h3; simp only [Finset.mem_insert, Finset.mem_singleton] at h3 rcases h3 with h | h | h | h <;> exact absurd h (hsh_ne k _ v (by omega) (by omega) (by omega)) -- **Pigeonhole**: 6 `c`-non-adjacent pairs in `{6,7,8,9,10}` vs 5 edges of `D₅`! have hl5 : 0 < D₅.len := by omega let E5 : Finset (Sym2 V) := Finset.univ.image (fun i : Fin D₅.len => s(D₅.verts i, D₅.verts (cNext hl5 i))) have hE5_le : E5.card ≤ 5 := by calc E5.card ≤ (Finset.univ : Finset (Fin D₅.len)).card := Finset.card_image_le _ = 5 := by rw [Finset.card_univ, Fintype.card_fin, hD5_5] let P6 : Finset (Sym2 V) := {s(sh 6 v, sh 8 v), s(sh 6 v, sh 9 v), s(sh 6 v, sh 10 v), s(sh 7 v, sh 9 v), s(sh 7 v, sh 10 v), s(sh 8 v, sh 10 v)} have hsym_ne : ∀ a b d e : ℕ, a < 12 → b < 12 → d < 12 → e < 12 → ¬ ((a = d ∧ b = e) ∨ (a = e ∧ b = d)) → s(sh a v, sh b v) ≠ s(sh d v, sh e v) := by intro a b d e ha hb hd he hne heq rw [Sym2.eq_iff] at heq rcases heq with ⟨h1, h2⟩ | ⟨h1, h2⟩ · apply hne; left; constructor <;> (by_contra h; exact hsh_ne _ _ v (by omega) (by omega) h (by assumption)) · apply hne; right; constructor <;> (by_contra h; exact hsh_ne _ _ v (by omega) (by omega) h (by assumption)) have hP6_card : P6.card = 6 := by dsimp [P6] rw [Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_insert_of_notMem, Finset.card_pair] · exact hsym_ne 7 10 8 10 (by omega) (by omega) (by omega) (by omega) (by omega) · simp only [Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨hsym_ne 7 9 7 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 7 9 8 10 (by omega) (by omega) (by omega) (by omega) (by omega)⟩ · simp only [Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨hsym_ne 6 10 7 9 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 10 7 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 10 8 10 (by omega) (by omega) (by omega) (by omega) (by omega)⟩ · simp only [Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨hsym_ne 6 9 6 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 9 7 9 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 9 7 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 9 8 10 (by omega) (by omega) (by omega) (by omega) (by omega)⟩ · simp only [Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨hsym_ne 6 8 6 9 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 8 6 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 8 7 9 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 8 7 10 (by omega) (by omega) (by omega) (by omega) (by omega), hsym_ne 6 8 8 10 (by omega) (by omega) (by omega) (by omega) (by omega)⟩ have hdiff_pos : 0 < (P6 \ E5).card := by have := Finset.card_sdiff_add_card_inter P6 E5 have hi : (P6 ∩ E5).card ≤ 5 := le_trans (Finset.card_le_card Finset.inter_subset_right) hE5_le omega obtain ⟨e, he⟩ := Finset.card_pos.mp hdiff_pos rcases Finset.mem_sdiff.mp he with ⟨heP6, heE5⟩ have hex_d : ∃ a b : ℕ, 6 ≤ a ∧ a + 2 ≤ b ∧ b ≤ 10 ∧ s(sh a v, sh b v) ∉ E5 := by dsimp [P6] at heP6 simp only [Finset.mem_insert, Finset.mem_singleton] at heP6 rcases heP6 with rfl | rfl | rfl | rfl | rfl | rfl · exact ⟨6, 8, by omega, by omega, by omega, heE5⟩ · exact ⟨6, 9, by omega, by omega, by omega, heE5⟩ · exact ⟨6, 10, by omega, by omega, by omega, heE5⟩ · exact ⟨7, 9, by omega, by omega, by omega, heE5⟩ · exact ⟨7, 10, by omega, by omega, by omega, heE5⟩ · exact ⟨8, 10, by omega, by omega, by omega, heE5⟩ obtain ⟨a, b, ha6, hab2, hb10, hab_notE5⟩ := hex_d have hdom5 := non_adj_pair_dom_pentagon hD5_5 (hD5_mem a ha6 (by omega)) (hD5_mem b (by omega) hb10) (hsh_ne a b v (by omega) (by omega) (by omega)) (fun k hk => hab_notE5 (Finset.mem_image.mpr ⟨k, Finset.mem_univ _, hk.symm⟩)) obtain ⟨v₀, hv₀Q4, hv₀q, hdom4⟩ := one_vert_near_dom_quad hQ4_4 hq3 let A : Finset V := {sh 0 v, sh 3 v, sh a v, sh b v} have hv₀A : v₀ ∉ A := by simp only [A, Finset.mem_insert, Finset.mem_singleton, not_or] exact ⟨fun h => Finset.disjoint_left.mp h14 (h ▸ hv0) hv₀Q4, hv₀q, fun h => Finset.disjoint_left.mp h54 (h ▸ hD5_mem a ha6 (by omega)) hv₀Q4, fun h => Finset.disjoint_left.mp h54 (h ▸ hD5_mem b (by omega) hb10) hv₀Q4⟩ have hA_ind : IsCycleIndep c A := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge simp only [A, Finset.mem_insert, Finset.mem_singleton] at hx hy rcases hx with rfl | rfl | rfl | rfl <;> rcases hy with rfl | rfl | rfl | rfl <;> (rw [hsh_edge_iff _ _ v (by omega) (by omega)] at hedge; omega) refine exists_second_hamCycle_of_near_cid c A hA_ind v₀ hv₀A ?_ intro w hwA hwv₀ have hw0 : w ≠ sh 0 v := fun h => hwA (by simp [A, h]) have hw3 : w ≠ sh 3 v := fun h => hwA (by simp [A, h]) have hwa : w ≠ sh a v := fun h => hwA (by simp [A, h]) have hwb : w ≠ sh b v := fun h => hwA (by simp [A, h]) rcases hcov w with hwT1 | hwD5 | hwQ4 · exact ⟨sh 0 v, by simp [A], triangle_chord_adj hT1_3 hwT1 hv0 hw0⟩ · rcases hdom5 w hwD5 hwa hwb with h1 | h2 · exact ⟨sh a v, by simp [A], h1⟩ · exact ⟨sh b v, by simp [A], h2⟩ · exact ⟨sh 3 v, by simp [A], hdom4 w hwQ4 hw3 hwv₀⟩ /-- Helper for `n = 12` with 4 triangles `C₃ + C₃ + C₃ + C₃` (`m = 4`): pure double-counting (`6 > 4`) constructs a FULL 4-vertex $C_{12}$-ID transversal, yielding **`≥ 3` Hamiltonian cycles**! -/ private lemma sheehan_twelve_3333 {G : SimpleGraph V} (h12 : Fintype.card V = 12) (c : DirHamCycle G) (T : Fin 4 → CycleIn (chordGraph c)) (hdisj : ∀ i j : Fin 4, i ≠ j → Disjoint (T i).vertSet (T j).vertSet) (hcov : ∀ v : V, ∃ i : Fin 4, v ∈ (T i).vertSet) (hlen : ∀ i : Fin 4, (T i).len = 3) : 3 ≤ (hamCycles G).card := by -- Helper: from any 4-element `c`-independent transversal `a : Fin 4 → V` (`a i ∈ T i`), win via Theorem 3b! have hwin : ∀ a : Fin 4 → V, (∀ i, a i ∈ (T i).vertSet) → (∀ i j, i ≠ j → s(a i, a j) ∉ c.edgeSet) → 3 ≤ (hamCycles G).card := by intro a ha hne let A : Finset V := Finset.univ.image a have hA_ind : IsCycleIndep c A := by rw [isCycleIndep_iff_edges] intro x hx y hy hedge rcases Finset.mem_image.mp hx with ⟨i, _, rfl⟩ rcases Finset.mem_image.mp hy with ⟨j, _, rfl⟩ by_cases hij : i = j · subst hij; exact G.loopless.irrefl _ (c.adj_of_mem_edgeSet hedge) · exact hne i j hij hedge refine card_hamCycles_ge_three_of_cid c A hA_ind ?_ intro w hwA obtain ⟨i, hwi⟩ := hcov w have hwai : w ≠ a i := fun h => hwA (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, h.symm⟩) exact ⟨a i, Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩, triangle_chord_adj (hlen i) hwi (ha i) hwai⟩ -- **CASE 1**: Some vertex `x ∈ T i₀` has BOTH `c`-neighbors in the SAME triangle `T j₀`! by_cases hsame : ∃ i₀ j₀ : Fin 4, ∃ x ∈ (T i₀).vertSet, cNbr c x ⊆ (T j₀).vertSet · obtain ⟨i₀, j₀, x, hx, hnb⟩ := hsame have hij₀ : i₀ ≠ j₀ := by intro rfl obtain ⟨y, hy⟩ := Finset.card_pos.mp (by rw [card_cNbr]; omega : 0 < (cNbr c x).card) exact (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep (hlen i₀)) x hx y (hnb hy) ((mem_cNbr_iff c x y).mp hy) -- Pick the remaining two indices `p ≠ q` outside `{i₀, j₀}`! have hrem_card : ((Finset.univ : Finset (Fin 4)) \ {i₀, j₀}).card = 2 := by rw [Finset.card_sdiff, Finset.inter_univ, Finset.card_univ, Fintype.card_fin, Finset.card_pair hij₀] obtain ⟨p, hp, q, hq, hpq⟩ := Finset.one_lt_card.mp (by omega : 1 < ((Finset.univ : Finset (Fin 4)) \ {i₀, j₀}).card) have hpi : p ≠ i₀ := fun h => (Finset.mem_sdiff.mp hp).2 (by simp [h]) have hpj : p ≠ j₀ := fun h => (Finset.mem_sdiff.mp hp).2 (by simp [h]) have hqi : q ≠ i₀ := fun h => (Finset.mem_sdiff.mp hq).2 (by simp [h]) have hqj : q ≠ j₀ := fun h => (Finset.mem_sdiff.mp hq).2 (by simp [h]) -- Pick `y ∈ (T j₀).vertSet \ cNbr c x` (size `3 - 2 = 1`)! have hy_pos : 0 < ((T j₀).vertSet \ cNbr c x).card := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hnb, (T j₀).card_vertSet, hlen j₀, card_cNbr]; omega obtain ⟨y, hyS⟩ := Finset.card_pos.mp hy_pos rcases Finset.mem_sdiff.mp hyS with ⟨hy, hynx⟩ -- Now `S_p = T p \ cNbr y`, `S_q = T q \ cNbr y` have `|S_p| + |S_q| ≥ 3 + 3 - 2 = 4`! let Sp := (T p).vertSet \ cNbr c y let Sq := (T q).vertSet \ cNbr c y have hdisj_pq : Disjoint ((T p).vertSet ∩ cNbr c y) ((T q).vertSet ∩ cNbr c y) := Disjoint.mono Finset.inter_subset_left Finset.inter_subset_left (hdisj p q hpq) have hinter_sum : ((T p).vertSet ∩ cNbr c y).card + ((T q).vertSet ∩ cNbr c y).card ≤ 2 := by rw [← Finset.card_union_of_disjoint hdisj_pq] calc (((T p).vertSet ∩ cNbr c y) ∪ ((T q).vertSet ∩ cNbr c y)).card ≤ (cNbr c y).card := Finset.card_le_card (Finset.union_subset Finset.inter_subset_right Finset.inter_subset_right) _ = 2 := card_cNbr c y have hsp : Sp.card + ((T p).vertSet ∩ cNbr c y).card = 3 := by dsimp [Sp]; rw [Finset.card_sdiff_add_card_inter, (T p).card_vertSet, hlen p] have hsq : Sq.card + ((T q).vertSet ∩ cNbr c y).card = 3 := by dsimp [Sq]; rw [Finset.card_sdiff_add_card_inter, (T q).card_vertSet, hlen q] obtain ⟨zp, hzpS, zq, hzqS, hzpzq⟩ := exists_pair_nonadj_of_sum_ge_four c (by omega) (S := Sp) (T := Sq) (by omega) (by omega) (by omega) rcases Finset.mem_sdiff.mp hzpS with ⟨hzp, hzp_ny⟩ rcases Finset.mem_sdiff.mp hzqS with ⟨hzq, hzq_ny⟩ let a : Fin 4 → V := fun k => if k = i₀ then x else if k = j₀ then y else if k = p then zp else zq have h4all : ∀ k : Fin 4, k = i₀ ∨ k = j₀ ∨ k = p ∨ k = q := by intro k by_contra hnot; push Not at hnot have hsub : ({i₀, j₀, p, q} : Finset (Fin 4)) ⊆ Finset.univ.erase k := by intro m hm; simp only [Finset.mem_insert, Finset.mem_singleton] at hm refine Finset.mem_erase.mpr ⟨?_, Finset.mem_univ _⟩ rcases hm with rfl | rfl | rfl | rfl <;> exact Ne.symm (by tauto) have hc4 : ({i₀, j₀, p, q} : Finset (Fin 4)).card = 4 := by rw [Finset.card_insert_of_notMem (by simp [hij₀, hpi.symm, hqi.symm]), Finset.card_insert_of_notMem (by simp [hpj.symm, hqj.symm]), Finset.card_pair hpq] have hle3 : (Finset.univ.erase k : Finset (Fin 4)).card = 3 := by simp have := Finset.card_le_card hsub; omega refine hwin a (fun k => by dsimp [a]; rcases h4all k with rfl | rfl | rfl | rfl · simp [hx] · simp [hij₀.symm, hy] · simp [hpi, hpj, hzp] · simp [hqi, hqj, hpq.symm, hzq]) ?_ intro k₁ k₂ hk12 hedge have hno_xp : s(x, zp) ∉ c.edgeSet := fun h => Finset.disjoint_left.mp (hdisj j₀ p hpj.symm) (hnb ((mem_cNbr_iff c x zp).mpr h)) hzp have hno_xq : s(x, zq) ∉ c.edgeSet := fun h => Finset.disjoint_left.mp (hdisj j₀ q hqj.symm) (hnb ((mem_cNbr_iff c x zq).mpr h)) hzq have hno_xy : s(x, y) ∉ c.edgeSet := fun h => hynx ((mem_cNbr_iff c x y).mpr h) have hno_yp : s(y, zp) ∉ c.edgeSet := fun h => hzp_ny ((mem_cNbr_iff c y zp).mpr h) have hno_yq : s(y, zq) ∉ c.edgeSet := fun h => hzq_ny ((mem_cNbr_iff c y zq).mpr h) dsimp [a] at hedge rcases h4all k₁ with rfl | rfl | rfl | rfl <;> rcases h4all k₂ with rfl | rfl | rfl | rfl · exact hk12 rfl · simp only [↓reduceIte, hij₀.symm] at hedge; exact hno_xy hedge · simp only [↓reduceIte, hpi, hpj] at hedge; exact hno_xp hedge · simp only [↓reduceIte, hqi, hqj, hpq.symm] at hedge; exact hno_xq hedge · simp only [↓reduceIte, hij₀.symm] at hedge; exact hno_xy (by rwa [Sym2.eq_swap]) · exact hk12 rfl · simp only [↓reduceIte, hij₀.symm, hpi, hpj] at hedge; exact hno_yp hedge · simp only [↓reduceIte, hij₀.symm, hqi, hqj, hpq.symm] at hedge; exact hno_yq hedge · simp only [↓reduceIte, hpi, hpj] at hedge; exact hno_xp (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hij₀.symm, hpi, hpj] at hedge; exact hno_yp (by rwa [Sym2.eq_swap]) · exact hk12 rfl · simp only [↓reduceIte, hpi, hpj, hqi, hqj, hpq.symm] at hedge; exact hzpzq hedge · simp only [↓reduceIte, hqi, hqj, hpq.symm] at hedge; exact hno_xq (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hij₀.symm, hqi, hqj, hpq.symm] at hedge; exact hno_yq (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hpi, hpj, hqi, hqj, hpq.symm] at hedge; exact hzpzq (by rwa [Sym2.eq_swap]) · exact hk12 rfl · -- **CASE 2 (`hno_same`)**: NO vertex has both `c`-neighbors in the same triangle! push Not at hsame have hno_same : ∀ (j : Fin 4) (v : V), ¬ (cNbr c v ⊆ (T j).vertSet) := fun j v h => by obtain ⟨i, hvi⟩ := hcov v exact hsame i j v hvi h obtain ⟨a₀, ha₀⟩ := Finset.card_pos.mp (by rw [(T 0).card_vertSet, hlen 0]; omega : 0 < (T 0).vertSet.card) -- `cNbr c a₀` has size 2, disjoint from `T 0`, and NOT contained in any single `T j`, so it hits -- EXACTLY TWO triangles among `{1, 2, 3}`, leaving ONE triangle `k₄ ∈ {1, 2, 3}` completely untouched! obtain ⟨u₁, hu₁, u₂, hu₂, hu12⟩ := Finset.one_lt_card.mp (by rw [card_cNbr]; omega : 1 < (cNbr c a₀).card) have hnb_eq : cNbr c a₀ = {u₁, u₂} := (Finset.eq_of_subset_of_card_le (Finset.insert_subset_iff.mpr ⟨hu₁, Finset.singleton_subset_iff.mpr hu₂⟩) (by rw [card_cNbr, Finset.card_pair hu12])).symm obtain ⟨j₁, hj₁⟩ := hcov u₁ obtain ⟨j₂, hj₂⟩ := hcov u₂ have hj1_ne0 : j₁ ≠ 0 := fun h => (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep (hlen 0)) a₀ ha₀ u₁ (h ▸ hj₁) ((mem_cNbr_iff c a₀ u₁).mp hu₁) have hj2_ne0 : j₂ ≠ 0 := fun h => (isCycleIndep_iff_edges c _).mp (triangle_isCycleIndep (hlen 0)) a₀ ha₀ u₂ (h ▸ hj₂) ((mem_cNbr_iff c a₀ u₂).mp hu₂) have hj12 : j₁ ≠ j₂ := fun h => hno_same j₁ a₀ (by rw [hnb_eq]; intro w hw; simp only [Finset.mem_insert, Finset.mem_singleton] at hw rcases hw with rfl | rfl · exact hj₁ · rwa [h]) -- Pick the unique remaining index `k₄ ∉ {0, j₁, j₂}`! have hk4_pos : 0 < ((Finset.univ : Finset (Fin 4)) \ {0, j₁, j₂}).card := by rw [Finset.card_sdiff, Finset.inter_univ, Finset.card_univ, Fintype.card_fin, Finset.card_insert_of_notMem (by simp [hj1_ne0.symm, hj2_ne0.symm]), Finset.card_pair hj12]; omega obtain ⟨k₄, hk₄⟩ := Finset.card_pos.mp hk4_pos have hk4_0 : k₄ ≠ 0 := fun h => (Finset.mem_sdiff.mp hk₄).2 (by simp [h]) have hk4_1 : k₄ ≠ j₁ := fun h => (Finset.mem_sdiff.mp hk₄).2 (by simp [h]) have hk4_2 : k₄ ≠ j₂ := fun h => (Finset.mem_sdiff.mp hk₄).2 (by simp [h]) have h4all : ∀ k : Fin 4, k = 0 ∨ k = j₁ ∨ k = j₂ ∨ k = k₄ := by intro k; by_contra hnot; push Not at hnot have hsub : ({0, j₁, j₂, k₄} : Finset (Fin 4)) ⊆ Finset.univ.erase k := by intro m hm; simp only [Finset.mem_insert, Finset.mem_singleton] at hm refine Finset.mem_erase.mpr ⟨?_, Finset.mem_univ _⟩ rcases hm with rfl | rfl | rfl | rfl <;> exact Ne.symm (by tauto) have hc4 : ({0, j₁, j₂, k₄} : Finset (Fin 4)).card = 4 := by rw [Finset.card_insert_of_notMem (by simp [hj1_ne0.symm, hj2_ne0.symm, hk4_0.symm]), Finset.card_insert_of_notMem (by simp [hj12, hk4_1.symm]), Finset.card_pair hk4_2.symm] have hle3 : (Finset.univ.erase k : Finset (Fin 4)).card = 3 := by simp have := Finset.card_le_card hsub; omega -- Set `S₁ = T j₁ \ {u₁}` (size 2) and `S₂ = T j₂ \ {u₂}` (size 2), `W = S₁ ∪ S₂` (size 4)! let S₁ := (T j₁).vertSet.erase u₁ let S₂ := (T j₂).vertSet.erase u₂ let W := S₁ ∪ S₂ have hS1_card : S₁.card = 2 := by rw [Finset.card_erase_of_mem hj₁, (T j₁).card_vertSet, hlen j₁] have hS2_card : S₂.card = 2 := by rw [Finset.card_erase_of_mem hj₂, (T j₂).card_vertSet, hlen j₂] have hS12_disj : Disjoint S₁ S₂ := Disjoint.mono (Finset.erase_subset _ _) (Finset.erase_subset _ _) (hdisj j₁ j₂ hj12) have hW_card : W.card = 4 := by rw [Finset.card_union_of_disjoint hS12_disj, hS1_card, hS2_card] -- **Double Counting (`6 > 4`)**: `∃ a₄ ∈ T k₄` with `(cNbr c a₄ ∩ W).card ≤ 1`! have hex_a4 : ∃ a₄ ∈ (T k₄).vertSet, (cNbr c a₄ ∩ W).card ≤ 1 := by by_contra hall push Not at hall have hsub_W : ∀ x ∈ (T k₄).vertSet, (cNbr c x ∩ W).card = 2 := fun x hx => by have hle : (cNbr c x ∩ W).card ≤ 2 := le_trans (Finset.card_le_card Finset.inter_subset_left) (by rw [card_cNbr]) have hge := hall x hx; omega -- Sum `1` over `(x ∈ T k₄, y ∈ W)` with `y ∈ cNbr c x`: LHS = `3 · 2 = 6`, RHS `≤ 4 · 1 = 4`! have hlhs : ∑ x ∈ (T k₄).vertSet, ∑ y ∈ W, (if y ∈ cNbr c x then 1 else 0) = 6 := by have hinner : ∀ x ∈ (T k₄).vertSet, ∑ y ∈ W, (if y ∈ cNbr c x then 1 else 0) = 2 := fun x hx => by rw [← Finset.card_filter] have heq : W.filter (fun y => y ∈ cNbr c x) = cNbr c x ∩ W := by ext y; simp [Finset.mem_filter, Finset.mem_inter, and_comm] rw [heq, hsub_W x hx] rw [Finset.sum_congr rfl hinner, Finset.sum_const, smul_eq_mul, (T k₄).card_vertSet, hlen k₄] have hrhs : ∑ y ∈ W, ∑ x ∈ (T k₄).vertSet, (if y ∈ cNbr c x then 1 else 0) ≤ 4 := by have hinner : ∀ y ∈ W, ∑ x ∈ (T k₄).vertSet, (if y ∈ cNbr c x then 1 else 0) ≤ 1 := fun y _ => by rw [← Finset.card_filter] by_contra hgt have hge2 : 2 ≤ ((T k₄).vertSet.filter (fun x => y ∈ cNbr c x)).card := by omega have hsub : (T k₄).vertSet.filter (fun x => y ∈ cNbr c x) ⊆ cNbr c y := fun x hx => (mem_cNbr_symm c).mp (Finset.mem_filter.mp hx).2 have heq : (T k₄).vertSet.filter (fun x => y ∈ cNbr c x) = cNbr c y := Finset.eq_of_subset_of_card_le hsub (by rw [card_cNbr]; exact hge2) exact hno_same k₄ y (by rw [← heq]; exact Finset.filter_subset _ _) calc ∑ y ∈ W, ∑ x ∈ (T k₄).vertSet, (if y ∈ cNbr c x then 1 else 0) ≤ ∑ _y ∈ W, 1 := Finset.sum_le_sum hinner _ = 4 := by rw [Finset.sum_const, smul_eq_mul, mul_one, hW_card] rw [Finset.sum_comm] at hlhs omega obtain ⟨a₄, ha₄, ha4_le1⟩ := hex_a4 -- `S₁' = S₁ \ cNbr a₄` and `S₂' = S₂ \ cNbr a₄` have `|S₁'| + |S₂'| ≥ 4 - 1 = 3`! let S₁' := S₁ \ cNbr c a₄ let S₂' := S₂ \ cNbr c a₄ have hsum3 : 3 ≤ S₁'.card + S₂'.card := by have hdisj' : Disjoint S₁' S₂' := Disjoint.mono Finset.sdiff_subset Finset.sdiff_subset hS12_disj have hunion_eq : S₁' ∪ S₂' = W \ cNbr c a₄ := by ext w; simp only [S₁', S₂', W, Finset.mem_union, Finset.mem_sdiff]; tauto rw [← Finset.card_union_of_disjoint hdisj', hunion_eq] have := Finset.card_sdiff_add_card_inter W (cNbr c a₄) rw [Finset.inter_comm] at this; omega have hS1'_le : S₁'.card ≤ 2 := le_trans (Finset.card_le_card Finset.sdiff_subset) (by omega) have hS2'_le : S₂'.card ≤ 2 := le_trans (Finset.card_le_card Finset.sdiff_subset) (by omega) -- Pick `a₁ ∈ S₁', a₂ ∈ S₂'` non-adjacent on `c` using `hno_same`! have hex_12 : ∃ a₁ ∈ S₁', ∃ a₂ ∈ S₂', s(a₁, a₂) ∉ c.edgeSet := by by_cases h2eq : S₂'.card = 2 · obtain ⟨a₁, ha₁⟩ := Finset.card_pos.mp (by omega : 0 < S₁'.card) have hnot_sub : ¬ (S₂' ⊆ cNbr c a₁) := fun hsub => by have heq : S₂' = cNbr c a₁ := Finset.eq_of_subset_of_card_le hsub (by rw [card_cNbr, h2eq]) exact hno_same j₂ a₁ (by rw [← heq]; exact Finset.Subset.trans Finset.sdiff_subset (Finset.erase_subset _ _)) rw [Finset.not_subset] at hnot_sub obtain ⟨a₂, ha₂, ha₂_not⟩ := hnot_sub exact ⟨a₁, ha₁, a₂, ha₂, fun h => ha₂_not ((mem_cNbr_iff c a₁ a₂).mpr h)⟩ · have h1eq : S₁'.card = 2 := by omega obtain ⟨a₂, ha₂⟩ := Finset.card_pos.mp (by omega : 0 < S₂'.card) have hnot_sub : ¬ (S₁' ⊆ cNbr c a₂) := fun hsub => by have heq : S₁' = cNbr c a₂ := Finset.eq_of_subset_of_card_le hsub (by rw [card_cNbr, h1eq]) exact hno_same j₁ a₂ (by rw [← heq]; exact Finset.Subset.trans Finset.sdiff_subset (Finset.erase_subset _ _)) rw [Finset.not_subset] at hnot_sub obtain ⟨a₁, ha₁, ha₁_not⟩ := hnot_sub exact ⟨a₁, ha₁, a₂, ha₂, fun h => ha₁_not ((mem_cNbr_iff c a₂ a₁).mpr (by rwa [Sym2.eq_swap]))⟩ obtain ⟨a₁, ha₁S, a₂, ha₂S, ha12⟩ := hex_12 rcases Finset.mem_sdiff.mp ha₁S with ⟨ha₁_e, ha1_n4⟩ rcases Finset.mem_erase.mp ha₁_e with ⟨ha1_nu1, ha₁⟩ rcases Finset.mem_sdiff.mp ha₂S with ⟨ha₂_e, ha2_n4⟩ rcases Finset.mem_erase.mp ha₂_e with ⟨ha2_nu2, ha₂⟩ have hno_01 : s(a₀, a₁) ∉ c.edgeSet := fun h => by have hm : a₁ ∈ cNbr c a₀ := (mem_cNbr_iff c a₀ a₁).mpr h rw [hnb_eq, Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with rfl | rfl · exact ha1_nu1 rfl · exact Finset.disjoint_left.mp (hdisj j₁ j₂ hj12) ha₁ hj₂ have hno_02 : s(a₀, a₂) ∉ c.edgeSet := fun h => by have hm : a₂ ∈ cNbr c a₀ := (mem_cNbr_iff c a₀ a₂).mpr h rw [hnb_eq, Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with rfl | rfl · exact Finset.disjoint_left.mp (hdisj j₁ j₂ hj12) hj₁ ha₂ · exact ha2_nu2 rfl have hno_04 : s(a₀, a₄) ∉ c.edgeSet := fun h => by have hm : a₄ ∈ cNbr c a₀ := (mem_cNbr_iff c a₀ a₄).mpr h rw [hnb_eq, Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with rfl | rfl · exact Finset.disjoint_left.mp (hdisj k₄ j₁ hk4_1) ha₄ hj₁ · exact Finset.disjoint_left.mp (hdisj k₄ j₂ hk4_2) ha₄ hj₂ have hno_41 : s(a₄, a₁) ∉ c.edgeSet := fun h => ha1_n4 ((mem_cNbr_iff c a₄ a₁).mpr h) have hno_42 : s(a₄, a₂) ∉ c.edgeSet := fun h => ha2_n4 ((mem_cNbr_iff c a₄ a₂).mpr h) let a : Fin 4 → V := fun k => if k = 0 then a₀ else if k = j₁ then a₁ else if k = j₂ then a₂ else a₄ refine hwin a (fun k => by dsimp [a]; rcases h4all k with rfl | rfl | rfl | rfl · simp [ha₀] · simp [hj1_ne0, ha₁] · simp [hj2_ne0, hj12.symm, ha₂] · simp [hk4_0, hk4_1, hk4_2, ha₄]) ?_ intro k₁ k₂ hk12 hedge dsimp [a] at hedge rcases h4all k₁ with rfl | rfl | rfl | rfl <;> rcases h4all k₂ with rfl | rfl | rfl | rfl · exact hk12 rfl · simp only [↓reduceIte, hj1_ne0] at hedge; exact hno_01 hedge · simp only [↓reduceIte, hj2_ne0, hj12.symm] at hedge; exact hno_02 hedge · simp only [↓reduceIte, hk4_0, hk4_1, hk4_2] at hedge; exact hno_04 hedge · simp only [↓reduceIte, hj1_ne0] at hedge; exact hno_01 (by rwa [Sym2.eq_swap]) · exact hk12 rfl · simp only [↓reduceIte, hj1_ne0, hj2_ne0, hj12.symm] at hedge; exact ha12 hedge · simp only [↓reduceIte, hj1_ne0, hk4_0, hk4_1, hk4_2] at hedge; exact hno_41 (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hj2_ne0, hj12.symm] at hedge; exact hno_02 (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hj1_ne0, hj2_ne0, hj12.symm] at hedge; exact ha12 (by rwa [Sym2.eq_swap]) · exact hk12 rfl · simp only [↓reduceIte, hj2_ne0, hj12.symm, hk4_0, hk4_1, hk4_2] at hedge; exact hno_42 (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hk4_0, hk4_1, hk4_2] at hedge; exact hno_04 (by rwa [Sym2.eq_swap]) · simp only [↓reduceIte, hj1_ne0, hk4_0, hk4_1, hk4_2] at hedge; exact hno_41 hedge · simp only [↓reduceIte, hj2_ne0, hj12.symm, hk4_0, hk4_1, hk4_2] at hedge; exact hno_42 hedge · exact hk12 rfl /-- Helper for `n = 12` with 3 chord cycles `[D₁, D₂, D₃]` where `O₁, O₂` are odd and `E` is even. -/ private lemma sheehan_twelve_two_odd {G : SimpleGraph V} (h12 : Fintype.card V = 12) (c : DirHamCycle G) (𝒟 : List (CycleIn (chordGraph c))) (hpw : 𝒟.Pairwise (fun D₁ D₂ => Disjoint D₁.vertSet D₂.vertSet)) (hcov : ∀ v : V, ∃ D ∈ 𝒟, v ∈ D.vertSet) {O₁ O₂ E : CycleIn (chordGraph c)} (hO₁ : O₁ ∈ 𝒟) (hO₂ : O₂ ∈ 𝒟) (h12d : Disjoint O₁.vertSet O₂.vertSet) (h1E : Disjoint O₁.vertSet E.vertSet) (h2E : Disjoint O₂.vertSet E.vertSet) (hcov3 : ∀ v : V, v ∈ O₁.vertSet ∨ v ∈ O₂.vertSet ∨ v ∈ E.vertSet) (hmem_all : ∀ D ∈ 𝒟, D = O₁ ∨ D = O₂ ∨ D = E) (hodd1 : Odd O₁.len) (hodd2 : Odd O₂.len) (heven : Even E.len) (hsum12 : O₁.len + O₂.len + E.len = 12) : 2 ≤ (hamCycles G).card := by have hO12_ne : O₁ ≠ O₂ := by intro rfl obtain ⟨v, hv⟩ := Finset.card_pos.mp (by rw [O₁.card_vertSet]; have := O₁.len_ge_three; omega : 0 < O₁.vertSet.card) exact Finset.disjoint_left.mp h12d hv hv by_cases hadj : ∃ u ∈ O₁.vertSet, ∃ v ∈ O₂.vertSet, s(u, v) ∈ c.edgeSet · obtain ⟨u, hu, v, hv, huv⟩ := hadj exact exists_second_hamCycle_of_two_adj_odd_chord_cycles c 𝒟 hpw hcov hO₁ hO₂ hO12_ne hodd1 hodd2 (fun D hD h1 h2 => by rcases hmem_all D hD with rfl | rfl | rfl · exact absurd rfl h1 · exact absurd rfl h2 · exact heven) hu hv huv · push Not at hadj have h1 := O₁.len_ge_three; have h2 := O₂.len_ge_three; have h3 := E.len_ge_three rcases hodd1 with ⟨a, ha⟩; rcases hodd2 with ⟨b, hb⟩; rcases heven with ⟨d, hd⟩ have hcases : (O₁.len = 3 ∧ O₂.len = 3 ∧ E.len = 6) ∨ (O₁.len = 3 ∧ O₂.len = 5 ∧ E.len = 4) ∨ (O₁.len = 5 ∧ O₂.len = 3 ∧ E.len = 4) := by omega rcases hcases with ⟨l1, l2, l3⟩ | ⟨l1, l2, l3⟩ | ⟨l1, l2, l3⟩ · exact sheehan_twelve_336_sep h12 c h12d h1E h2E hcov3 l1 l2 l3 hadj · exact sheehan_twelve_354_sep h12 c h12d h1E h2E hcov3 l1 l2 l3 hadj · exact sheehan_twelve_354_sep h12 c h12d.symm h2E h1E (fun v => by rcases hcov3 v with h | h | h <;> tauto) l2 l1 l3 (fun u hu v hv => by rw [Sym2.eq_swap]; exact hadj v hv u hu) /-- **Theorem 6e (Sheehan's Conjecture for ALL `n = 12`)**: Every 4-regular Hamiltonian simple graph on `12` vertices has at least 2 Hamiltonian cycles! -/ theorem sheehan_of_card_twelve {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (h12 : Fintype.card V = 12) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by obtain ⟨𝒟, hpw, hcov⟩ := exists_cycle_decomp_of_two_regular (chordGraph_isRegularOfDegree_two hreg c) by_cases hodd1 : (𝒟.filter fun D => decide (Odd D.len)).length ≤ 1 · exact exists_second_hamCycle_of_le_one_odd_chord_cycle c 𝒟 hpw hcov hodd1 · by_cases hlen2 : 𝒟.length ≤ 2 · exact exists_second_hamCycle_of_le_two_chord_components c 𝒟 hpw hcov hlen2 · have h3 := three_mul_length_le_card hpw hcov -- Either `𝒟.length = 3` (two odd + one even) or `𝒟.length = 4` (four triangles `3+3+3+3`)! have hlen34 : 𝒟.length = 3 ∨ 𝒟.length = 4 := by omega rcases hlen34 with hlen3 | hlen4 · match h𝒟 : 𝒟 with | [D₁, D₂, D₃] => have hsum := cycle_decomp_sum_len hpw hcov simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] at hsum have hpw' : Disjoint D₁.vertSet D₂.vertSet ∧ Disjoint D₁.vertSet D₃.vertSet ∧ Disjoint D₂.vertSet D₃.vertSet := by rcases List.pairwise_cons.mp hpw with ⟨hA, hBC⟩ rcases List.pairwise_cons.mp hBC with ⟨hB, _⟩ exact ⟨hA _ (by simp), hA _ (by simp), hB _ (by simp)⟩ have hcov3 : ∀ v : V, v ∈ D₁.vertSet ∨ v ∈ D₂.vertSet ∨ v ∈ D₃.vertSet := fun v => by obtain ⟨D, hD, hvD⟩ := hcov v; simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl | rfl <;> tauto -- Since sum is 12 (even) and ≥ 2 are odd, EXACTLY 2 are odd and 1 is even! rcases Nat.even_or_odd D₁.len with he1 | ho1 <;> rcases Nat.even_or_odd D₂.len with he2 | ho2 <;> rcases Nat.even_or_odd D₃.len with he3 | ho3 · exfalso; apply hodd1 simp only [List.filter_cons, List.filter_nil, Nat.not_odd_iff_even.mpr he1, Nat.not_odd_iff_even.mpr he2, Nat.not_odd_iff_even.mpr he3, decide_false, Bool.false_eq_true, ↓reduceIte, List.length_nil]; omega · rcases he1 with ⟨a, _⟩; rcases he2 with ⟨b, _⟩; rcases ho3 with ⟨d, _⟩; omega · rcases he1 with ⟨a, _⟩; rcases ho2 with ⟨b, _⟩; rcases he3 with ⟨d, _⟩; omega · exact sheehan_twelve_two_odd h12 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.2.2 hpw'.1.symm hpw'.2.1.symm (fun v => by rcases hcov3 v with h | h | h <;> tauto) (fun D hD => by simp at hD; tauto) ho2 ho3 he1 (by omega) · rcases ho1 with ⟨a, _⟩; rcases he2 with ⟨b, _⟩; rcases he3 with ⟨d, _⟩; omega · exact sheehan_twelve_two_odd h12 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.2.1 hpw'.1 hpw'.2.2.symm (fun v => by rcases hcov3 v with h | h | h <;> tauto) (fun D hD => by simp at hD; tauto) ho1 ho3 he2 (by omega) · exact sheehan_twelve_two_odd h12 c [D₁, D₂, D₃] hpw hcov (by simp) (by simp) hpw'.1 hpw'.2.1 hpw'.2.2 hcov3 (fun D hD => by simp at hD; tauto) ho1 ho2 he3 (by omega) · rcases ho1 with ⟨a, _⟩; rcases ho2 with ⟨b, _⟩; rcases ho3 with ⟨d, _⟩; omega | [] | [_] | [_, _] | _ :: _ :: _ :: _ :: _ => simp at hlen3 · match h𝒟 : 𝒟 with | [D₁, D₂, D₃, D₄] => have hsum := cycle_decomp_sum_len hpw hcov simp only [List.map_cons, List.map_nil, List.sum_cons, List.sum_nil, add_zero] at hsum have h1 := D₁.len_ge_three; have h2 := D₂.len_ge_three have h3' := D₃.len_ge_three; have h4 := D₄.len_ge_three let T : Fin 4 → CycleIn (chordGraph c) := ![D₁, D₂, D₃, D₄] have hlenT : ∀ i : Fin 4, (T i).len = 3 := by intro i; fin_cases i <;> dsimp [T] <;> omega have hpw' : Disjoint D₁.vertSet D₂.vertSet ∧ Disjoint D₁.vertSet D₃.vertSet ∧ Disjoint D₁.vertSet D₄.vertSet ∧ Disjoint D₂.vertSet D₃.vertSet ∧ Disjoint D₂.vertSet D₄.vertSet ∧ Disjoint D₃.vertSet D₄.vertSet := by rcases List.pairwise_cons.mp hpw with ⟨h1, h234⟩ rcases List.pairwise_cons.mp h234 with ⟨h2, h34⟩ rcases List.pairwise_cons.mp h34 with ⟨h3, _⟩ exact ⟨h1 _ (by simp), h1 _ (by simp), h1 _ (by simp), h2 _ (by simp), h2 _ (by simp), h3 _ (by simp)⟩ have hdisjT : ∀ i j : Fin 4, i ≠ j → Disjoint (T i).vertSet (T j).vertSet := by intro i j hij fin_cases i <;> fin_cases j <;> dsimp [T] · exact absurd rfl hij · exact hpw'.1 · exact hpw'.2.1 · exact hpw'.2.2.1 · exact hpw'.1.symm · exact absurd rfl hij · exact hpw'.2.2.2.1 · exact hpw'.2.2.2.2.1 · exact hpw'.2.1.symm · exact hpw'.2.2.2.1.symm · exact absurd rfl hij · exact hpw'.2.2.2.2.2 · exact hpw'.2.2.1.symm · exact hpw'.2.2.2.2.1.symm · exact hpw'.2.2.2.2.2.symm · exact absurd rfl hij have hcovT : ∀ v : V, ∃ i : Fin 4, v ∈ (T i).vertSet := fun v => by obtain ⟨D, hD, hvD⟩ := hcov v simp only [List.mem_cons, List.not_mem_nil, or_false] at hD rcases hD with rfl | rfl | rfl | rfl · exact ⟨0, hvD⟩ · exact ⟨1, hvD⟩ · exact ⟨2, hvD⟩ · exact ⟨3, hvD⟩ exact le_trans (by decide : 2 ≤ 3) (sheehan_twelve_3333 h12 c T hdisjT hcovT hlenT) | [] | [_] | [_, _] | [_, _, _] | _ :: _ :: _ :: _ :: _ :: _ => simp at hlen4 /-- **Theorem 6f (Master Small-Order Sheehan Theorem — ALL `n ≤ 12`, Zero Brute Force)**: EVERY 4-regular Hamiltonian simple graph on `n ≤ 12` vertices has at least 2 distinct Hamiltonian cycles! -/ theorem sheehan_of_card_le_twelve {G : SimpleGraph V} (hreg : G.IsRegularOfDegree 4) (hle : Fintype.card V ≤ 12) (c : DirHamCycle G) : 2 ≤ (hamCycles G).card := by by_cases h8 : Fintype.card V ≤ 8 · exact sheehan_of_card_le_eight hreg h8 c · have hcases : Fintype.card V = 9 ∨ Fintype.card V = 10 ∨ Fintype.card V = 11 ∨ Fintype.card V = 12 := by omega rcases hcases with h9 | h10 | h11 | h12 · exact sheehan_of_card_nine hreg h9 c · exact sheehan_of_card_ten hreg h10 c · exact sheehan_of_card_eleven hreg h11 c · exact sheehan_of_card_twelve hreg h12 c end SmallOrderStructural end SheehanConjecture /-! ## Complete Axiom Audit (`#print axioms` on EVERY Headline Theorem) -/ -- Section 1: 2-Switch Engine #print axioms SheehanConjecture.exists_second_hamCycle_of_crossing_chords -- Section 2: Thomason Lollipop Engine (First Lean 4 Formalization) #print axioms SheehanConjecture.card_closing_paths_eq_card_hamCycles_through_edge #print axioms SheehanConjecture.even_hamCycles_through_edge_of_odd_last #print axioms SheehanConjecture.even_hamCycles_through_edge_of_odd_deg_off #print axioms SheehanConjecture.exists_second_hamCycle_of_odd_deg_off #print axioms SheehanConjecture.card_hamCycles_ge_three_of_all_odd_deg #print axioms SheehanConjecture.even_hamCycles_bipartite_of_odd_deg_side #print axioms SheehanConjecture.card_hamCycles_ge_three_bipartite_of_odd_deg_side -- Section 3: Master Bipartite-Subdivision & Near-C-ID Parity Engine #print axioms SheehanConjecture.card_hamCycles_subdiv_le #print axioms SheehanConjecture.exists_second_hamCycle_of_near_cid #print axioms SheehanConjecture.card_hamCycles_ge_three_of_cid #print axioms SheehanConjecture.card_hamCycles_ge_four_of_three_cid_classes -- Section 4: Chord 2-Factor Cycle Decomposition & Quantitative Multiplicity Hierarchy #print axioms SheehanConjecture.exists_cycleIn_through #print axioms SheehanConjecture.exists_cycle_decomp_of_two_regular #print axioms SheehanConjecture.card_hamCycles_ge_five_of_even_chord_cycles #print axioms SheehanConjecture.card_hamCycles_ge_five_of_bipartite #print axioms SheehanConjecture.card_hamCycles_ge_six_of_even_ham_chord #print axioms SheehanConjecture.card_hamCycles_ge_four_of_odd_ham_chord #print axioms SheehanConjecture.exists_second_hamCycle_of_le_one_odd_chord_cycle #print axioms SheehanConjecture.exists_second_hamCycle_of_two_adj_odd_chord_cycles #print axioms SheehanConjecture.exists_second_hamCycle_of_le_two_chord_components -- Section 5: Vertex-Transitive, Cayley, Circulant & Torus-Grid 4-Regular Graphs #print axioms SheehanConjecture.sheehan_vertex_transitive #print axioms SheehanConjecture.sheehan_cayley #print axioms SheehanConjecture.sheehan_circulant #print axioms SheehanConjecture.card_hamCycles_circulant_one_ge #print axioms SheehanConjecture.sheehan_torus_grid #print axioms SheehanConjecture.card_hamCycles_torus_grid_even -- Section 6: Pure Structural Resolution of ALL n ≤ 12 (Zero Brute Force) #print axioms SheehanConjecture.sheehan_of_card_le_eight #print axioms SheehanConjecture.sheehan_of_card_nine #print axioms SheehanConjecture.sheehan_of_card_ten #print axioms SheehanConjecture.sheehan_of_card_eleven #print axioms SheehanConjecture.sheehan_of_card_twelve #print axioms SheehanConjecture.sheehan_of_card_le_twelve