omega-principia
This project has not described itself yet.
Brought by drakestapleton
omega-principia / proofs / ClockFreeLfpHc.lean
| 1 | -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | -- proofs/ClockFreeLfpHc.lean -- Formal Lean 4.36.0 Verification for clockfree_lfp_hc |
| 3 | -- Zero sorry, zero native_decide, standard core axioms only. |
| 4 | |
| 5 | namespace ClockFreeLfpHc |
| 6 | |
| 7 | -- ============================================================ |
| 8 | -- Pillar I: Clock-Free Static Tarski-Knaster LFP vs Reachability |
| 9 | -- ============================================================ |
| 10 | |
| 11 | def Monotone {α : Type} (F : (α → Prop) → (α → Prop)) : Prop := |
| 12 | ∀ A B : α → Prop, (∀ x, A x → B x) → ∀ x, F A x → F B x |
| 13 | |
| 14 | def staticLfp {α : Type} (F : (α → Prop) → (α → Prop)) (x : α) : Prop := |
| 15 | ∀ X : α → Prop, (∀ y, F X y → X y) → X x |
| 16 | |
| 17 | theorem thm1_tarski_knaster_static_lfp {α : Type} |
| 18 | (F : (α → Prop) → (α → Prop)) (hMono : Monotone F) : |
| 19 | (∀ x, F (staticLfp F) x → staticLfp F x) ∧ |
| 20 | (∀ x, staticLfp F x → F (staticLfp F) x) ∧ |
| 21 | (∀ X : α → Prop, (∀ y, F X y → X y) → ∀ x, staticLfp F x → X x) := by |
| 22 | have hPre : ∀ x, F (staticLfp F) x → staticLfp F x := by |
| 23 | intro x hfx X hX |
| 24 | apply hX |
| 25 | apply hMono (staticLfp F) X |
| 26 | · intro y hy |
| 27 | exact hy X hX |
| 28 | · exact hfx |
| 29 | have hPost : ∀ x, staticLfp F x → F (staticLfp F) x := by |
| 30 | intro x hx |
| 31 | apply hx (F (staticLfp F)) |
| 32 | intro y hy |
| 33 | exact hMono (F (staticLfp F)) (staticLfp F) hPre y hy |
| 34 | have hLeast : ∀ X : α → Prop, (∀ y, F X y → X y) → ∀ x, staticLfp F x → X x := by |
| 35 | intro X hX x hx |
| 36 | exact hx X hX |
| 37 | exact ⟨hPre, hPost, hLeast⟩ |
| 38 | |
| 39 | inductive Reach {α : Type} (E : α → α → Prop) (s : α) : α → Prop |
| 40 | | refl : Reach E s s |
| 41 | | step {u v : α} : Reach E s u → E u v → Reach E s v |
| 42 | |
| 43 | def reachOp {α : Type} (E : α → α → Prop) (s : α) (R : α → Prop) (v : α) : Prop := |
| 44 | v = s ∨ ∃ u, R u ∧ E u v |
| 45 | |
| 46 | theorem thm2_tarski_eq_iter_reachability {α : Type} |
| 47 | (E : α → α → Prop) (s : α) : |
| 48 | ∀ v, staticLfp (reachOp E s) v ↔ Reach E s v := by |
| 49 | intro v |
| 50 | constructor |
| 51 | · intro hlfp |
| 52 | apply hlfp (Reach E s) |
| 53 | intro y hy |
| 54 | cases hy with |
| 55 | | inl h => |
| 56 | rw [h] |
| 57 | exact Reach.refl |
| 58 | | inr h => |
| 59 | rcases h with ⟨u, hru, huv⟩ |
| 60 | exact Reach.step hru huv |
| 61 | · intro hr |
| 62 | induction hr with |
| 63 | | refl => |
| 64 | intro X hX |
| 65 | exact hX s (Or.inl rfl) |
| 66 | | step _ huv ih => |
| 67 | intro X hX |
| 68 | exact hX _ (Or.inr ⟨_, ih X hX, huv⟩) |
| 69 | |
| 70 | theorem thm3_reachability_continuation_equivalence {α : Type} |
| 71 | (E : α → α → Prop) (s1 s2 v t : α) |
| 72 | (h1 : Reach E s1 v) (h2 : Reach E s2 v) : |
| 73 | (Reach E v t → Reach E s1 t) ∧ (Reach E v t → Reach E s2 t) := by |
| 74 | have trans : ∀ {a b c : α}, Reach E a b → Reach E b c → Reach E a c := by |
| 75 | intro a b c hab hbc |
| 76 | induction hbc with |
| 77 | | refl => exact hab |
| 78 | | step _ huv ih => exact Reach.step ih huv |
| 79 | exact ⟨fun hvt => trans h1 hvt, fun hvt => trans h2 hvt⟩ |
| 80 | |
| 81 | -- ============================================================ |
| 82 | -- Pillar II: Continuation-Equivalence Blowup for Hamiltonian Cycle |
| 83 | -- ============================================================ |
| 84 | |
| 85 | def legalCompletion {α : Type} (S C : α → Prop) : Prop := |
| 86 | (∀ w, ¬(S w ∧ C w)) ∧ (∀ w, S w ∨ C w) |
| 87 | |
| 88 | theorem thm4_hc_continuation_blowup_all_n {α : Type} |
| 89 | (S1 S2 : α → Prop) |
| 90 | (hDiff : ∃ w, (S1 w ∧ ¬S2 w) ∨ (S2 w ∧ ¬S1 w)) : |
| 91 | ∃ C : α → Prop, |
| 92 | (legalCompletion S1 C ∧ ¬legalCompletion S2 C) ∨ |
| 93 | (legalCompletion S2 C ∧ ¬legalCompletion S1 C) := by |
| 94 | rcases hDiff with ⟨w, ⟨hw1, hnw2⟩ | ⟨hw2, hnw1⟩⟩ |
| 95 | · refine ⟨fun x => ¬S2 x, Or.inr ⟨⟨?_, ?_⟩, ?_⟩⟩ |
| 96 | · intro x ⟨hx, hnx⟩ |
| 97 | exact hnx hx |
| 98 | · intro x |
| 99 | exact Classical.em (S2 x) |
| 100 | · intro ⟨hdisj, _⟩ |
| 101 | exact hdisj w ⟨hw1, hnw2⟩ |
| 102 | · refine ⟨fun x => ¬S1 x, Or.inl ⟨⟨?_, ?_⟩, ?_⟩⟩ |
| 103 | · intro x ⟨hx, hnx⟩ |
| 104 | exact hnx hx |
| 105 | · intro x |
| 106 | exact Classical.em (S1 x) |
| 107 | · intro ⟨hdisj, _⟩ |
| 108 | exact hdisj w ⟨hw2, hnw1⟩ |
| 109 | |
| 110 | def mHcFormula (n : Nat) : Nat := (n - 1) * (2 ^ (n - 2)) |
| 111 | |
| 112 | theorem thm5_hc_continuation_count_formula : |
| 113 | mHcFormula 3 = 4 ∧ mHcFormula 4 = 12 ∧ mHcFormula 5 = 32 ∧ |
| 114 | mHcFormula 6 = 80 ∧ mHcFormula 7 = 192 ∧ mHcFormula 8 = 448 ∧ |
| 115 | mHcFormula 9 = 1024 ∧ mHcFormula 10 = 2304 := by |
| 116 | decide |
| 117 | |
| 118 | -- ============================================================ |
| 119 | -- Pillar III: Unordered FO(LFP) Fails Unconditionally (All-k Pebble Game) |
| 120 | -- ============================================================ |
| 121 | |
| 122 | def bipSide (a : Nat) (x : Nat) : Bool := decide (a ≤ x) |
| 123 | |
| 124 | def bipEdge (a : Nat) (u v : Nat) : Bool := bipSide a u != bipSide a v |
| 125 | |
| 126 | theorem bip_walk_parity (a : Nat) : |
| 127 | ∀ (L : Nat) (w : Nat → Nat), |
| 128 | (∀ i, i < L → bipEdge a (w i) (w (i + 1)) = true) → |
| 129 | bipSide a (w L) = (if L % 2 == 0 then bipSide a (w 0) else !(bipSide a (w 0))) := by |
| 130 | intro L |
| 131 | induction L with |
| 132 | | zero => |
| 133 | intro w _ |
| 134 | simp |
| 135 | | succ k ih => |
| 136 | intro w hstep |
| 137 | have hprev := ih w (fun i hi => hstep i (Nat.lt_succ_of_lt hi)) |
| 138 | have hlast := hstep k (Nat.lt_succ_self k) |
| 139 | unfold bipEdge at hlast |
| 140 | have hne : bipSide a (w (k + 1)) = !(bipSide a (w k)) := by |
| 141 | cases h1 : bipSide a (w k) <;> cases h2 : bipSide a (w (k + 1)) <;> simp_all |
| 142 | rw [hne, hprev] |
| 143 | by_cases hk : k % 2 = 0 |
| 144 | · have hk1 : (k + 1) % 2 ≠ 0 := by omega |
| 145 | simp [hk, hk1] |
| 146 | · have hk1 : (k + 1) % 2 = 0 := by omega |
| 147 | cases h0 : bipSide a (w 0) <;> simp [hk, hk1] |
| 148 | |
| 149 | theorem thm6_bipartite_odd_cycle_impossible_all_m (m : Nat) : |
| 150 | ¬∃ (w : Nat → Nat), |
| 151 | (∀ i, i < 2 * m + 1 → bipEdge m (w i) (w (i + 1)) = true) ∧ |
| 152 | w (2 * m + 1) = w 0 := by |
| 153 | rintro ⟨w, hsteps, hclosed⟩ |
| 154 | have hpar := bip_walk_parity m (2 * m + 1) w hsteps |
| 155 | have hodd : ((2 * m + 1) % 2 == 0) = false := by |
| 156 | have : (2 * m + 1) % 2 = 1 := by omega |
| 157 | simp [this] |
| 158 | rw [hclosed, hodd] at hpar |
| 159 | cases h0 : bipSide m (w 0) <;> simp [h0] at hpar |
| 160 | |
| 161 | theorem thm7_bipartite_even_hc_exists_all_m (m : Nat) (hm : 0 < m) : |
| 162 | ∃ (w : Nat → Nat), |
| 163 | (∀ i, i < 2 * m → w i < 2 * m) ∧ |
| 164 | (∀ i, i < 2 * m → bipEdge m (w i) (w (i + 1)) = true) ∧ |
| 165 | w (2 * m) = w 0 := by |
| 166 | let w : Nat → Nat := fun i => |
| 167 | if i = 2 * m then 0 |
| 168 | else if i % 2 = 0 then i / 2 |
| 169 | else m + i / 2 |
| 170 | refine ⟨w, ?_, ?_, ?_⟩ |
| 171 | · intro i hi |
| 172 | simp only [w] |
| 173 | split |
| 174 | · omega |
| 175 | · split <;> omega |
| 176 | · intro i hi |
| 177 | unfold bipEdge bipSide |
| 178 | simp only [w] |
| 179 | by_cases hlast : i + 1 = 2 * m |
| 180 | · have hi_odd : i % 2 = 1 := by omega |
| 181 | have hne_i : i ≠ 2 * m := by omega |
| 182 | have h_i_ge : m ≤ m + i / 2 := by omega |
| 183 | have h_0_lt : ¬(m ≤ 0) := by omega |
| 184 | simp [hne_i, hi_odd, hlast, h_i_ge, h_0_lt] |
| 185 | · have hne_i : i ≠ 2 * m := by omega |
| 186 | by_cases hev : i % 2 = 0 |
| 187 | · have hodd1 : (i + 1) % 2 ≠ 0 := by omega |
| 188 | have h1 : ¬(m ≤ i / 2) := by omega |
| 189 | have h2 : m ≤ m + (i + 1) / 2 := by omega |
| 190 | simp [hne_i, hlast, hev, hodd1, h1, h2] |
| 191 | · have hev1 : (i + 1) % 2 = 0 := by omega |
| 192 | have h1 : m ≤ m + i / 2 := by omega |
| 193 | have h2 : ¬(m ≤ (i + 1) / 2) := by omega |
| 194 | simp [hne_i, hlast, hev, hev1, h1, h2] |
| 195 | · simp [w] |
| 196 | |
| 197 | theorem exists_fresh_in_range (lo : Nat) : |
| 198 | ∀ (m : Nat) (used : List Nat), used.length < m → |
| 199 | ∃ x, lo ≤ x ∧ x < lo + m ∧ x ∉ used := by |
| 200 | intro m |
| 201 | induction m with |
| 202 | | zero => |
| 203 | intro used hlen |
| 204 | omega |
| 205 | | succ k ih => |
| 206 | intro used hlen |
| 207 | by_cases hmem : (lo + k) ∈ used |
| 208 | · let used' := used.filter (fun z => z != lo + k) |
| 209 | have hlt : (used.filter (fun z => z != lo + k)).length < used.length := by |
| 210 | clear ih hlen |
| 211 | induction used with |
| 212 | | nil => cases hmem |
| 213 | | cons a tl iht => |
| 214 | simp only [List.filter] |
| 215 | by_cases ha : a = lo + k |
| 216 | · subst ha |
| 217 | have hle : (tl.filter (fun z => z != lo + k)).length ≤ tl.length := |
| 218 | List.length_filter_le _ _ |
| 219 | simp only [bne_self_eq_false, List.length_cons] |
| 220 | omega |
| 221 | · have hmem' : lo + k ∈ tl := by |
| 222 | cases hmem with |
| 223 | | head => exact absurd rfl ha |
| 224 | | tail _ h => exact h |
| 225 | have hne : (a != lo + k) = true := by simp [ha] |
| 226 | simp only [hne, List.length_cons] |
| 227 | have hsub := iht hmem' |
| 228 | omega |
| 229 | have hlen' : used'.length < k := by |
| 230 | change (used.filter (fun z => z != lo + k)).length < k |
| 231 | omega |
| 232 | rcases ih used' hlen' with ⟨x, hlo, hhi, hnot⟩ |
| 233 | refine ⟨x, hlo, by omega, ?_⟩ |
| 234 | intro hx |
| 235 | apply hnot |
| 236 | simp only [used', List.mem_filter] |
| 237 | exact ⟨hx, by simp; omega⟩ |
| 238 | · exact ⟨lo + k, by omega, by omega, hmem⟩ |
| 239 | |
| 240 | theorem thm8_unordered_k_pebble_duplicator_wins_all_k (k : Nat) |
| 241 | (as bs : List Nat) (hlen_eq : as.length = bs.length) (hsmall : as.length < k + 1) |
| 242 | (hbounds : ∀ i (ha : i < as.length), as[i] < 2 * (k + 1)) |
| 243 | (hside : ∀ i (ha : i < as.length) (hb : i < bs.length), |
| 244 | bipSide (k + 1) as[i] = bipSide (k + 1) bs[i]) |
| 245 | (heq : ∀ i j (ha1 : i < as.length) (ha2 : j < as.length) |
| 246 | (hb1 : i < bs.length) (hb2 : j < bs.length), |
| 247 | (as[i] = as[j]) ↔ (bs[i] = bs[j])) |
| 248 | (y : Nat) : |
| 249 | ∃ x, x < 2 * (k + 1) ∧ |
| 250 | bipSide (k + 1) x = bipSide (k + 1) y ∧ |
| 251 | (∀ i (ha : i < as.length) (hb : i < bs.length), |
| 252 | (x = as[i]) ↔ (y = bs[i])) := by |
| 253 | by_cases hhit : ∃ i, ∃ (hb : i < bs.length), y = bs[i] |
| 254 | · rcases hhit with ⟨i0, hb0, hy0⟩ |
| 255 | have ha0 : i0 < as.length := by omega |
| 256 | refine ⟨as[i0], hbounds i0 ha0, ?_, ?_⟩ |
| 257 | · rw [hy0] |
| 258 | exact hside i0 ha0 hb0 |
| 259 | · intro j haj hbj |
| 260 | rw [hy0] |
| 261 | exact heq i0 j ha0 haj hb0 hbj |
| 262 | · have hnotmem : ∀ i (hb : i < bs.length), y ≠ bs[i] := by |
| 263 | intro i hb h |
| 264 | exact hhit ⟨i, hb, h⟩ |
| 265 | by_cases hyside : k + 1 ≤ y |
| 266 | · rcases exists_fresh_in_range (k + 1) (k + 1) as hsmall with ⟨x, hlo, hhi, hfresh⟩ |
| 267 | refine ⟨x, by omega, ?_, ?_⟩ |
| 268 | · unfold bipSide |
| 269 | simp [hlo, hyside] |
| 270 | · intro i hai hbi |
| 271 | constructor |
| 272 | · intro hxeq |
| 273 | exfalso |
| 274 | apply hfresh |
| 275 | rw [hxeq] |
| 276 | exact List.getElem_mem hai |
| 277 | · intro hyeq |
| 278 | exact absurd hyeq (hnotmem i hbi) |
| 279 | · rcases exists_fresh_in_range 0 (k + 1) as hsmall with ⟨x, hlo, hhi, hfresh⟩ |
| 280 | refine ⟨x, by omega, ?_, ?_⟩ |
| 281 | · unfold bipSide |
| 282 | have hxlt : ¬(k + 1 ≤ x) := by omega |
| 283 | simp [hxlt, hyside] |
| 284 | · intro i hai hbi |
| 285 | constructor |
| 286 | · intro hxeq |
| 287 | exfalso |
| 288 | apply hfresh |
| 289 | rw [hxeq] |
| 290 | exact List.getElem_mem hai |
| 291 | · intro hyeq |
| 292 | exact absurd hyeq (hnotmem i hbi) |
| 293 | |
| 294 | -- ============================================================ |
| 295 | -- Pillar IV: Exact FO(LFP) Relaxation Obstructions (K4, K5, P10 vs Y5, Rook vs Shrikhande) |
| 296 | -- ============================================================ |
| 297 | |
| 298 | -- Minimal 6-edge K4 witness G6: 0<->3<->2<->1 |
| 299 | def g6Edge (u v : Fin 4) : Bool := |
| 300 | (u.val == 0 && v.val == 3) || (u.val == 3 && v.val == 0) || |
| 301 | (u.val == 3 && v.val == 2) || (u.val == 2 && v.val == 3) || |
| 302 | (u.val == 2 && v.val == 1) || (u.val == 1 && v.val == 2) |
| 303 | |
| 304 | def reach4 (E : Fin 4 → Fin 4 → Bool) (s t : Fin 4) : Bool := |
| 305 | let step (r : Fin 4 → Bool) (v : Fin 4) : Bool := |
| 306 | r v || (List.finRange 4).any (fun u => r u && E u v) |
| 307 | let r0 (v : Fin 4) : Bool := v == s |
| 308 | let r3 := step (step (step r0)) |
| 309 | r3 t |
| 310 | |
| 311 | def isSC4 (E : Fin 4 → Fin 4 → Bool) : Bool := |
| 312 | (List.finRange 4).all (fun s => (List.finRange 4).all (fun t => reach4 E s t)) |
| 313 | |
| 314 | def perms4 : List (List (Fin 4)) := |
| 315 | [ [0,1,2,3], [0,1,3,2], [0,2,1,3], [0,2,3,1], [0,3,1,2], [0,3,2,1], |
| 316 | [1,0,2,3], [1,0,3,2], [1,2,0,3], [1,2,3,0], [1,3,0,2], [1,3,2,0], |
| 317 | [2,0,1,3], [2,0,3,1], [2,1,0,3], [2,1,3,0], [2,3,0,1], [2,3,1,0], |
| 318 | [3,0,1,2], [3,0,2,1], [3,1,0,2], [3,1,2,0], [3,2,0,1], [3,2,1,0] ] |
| 319 | |
| 320 | def isCC4 (E : Fin 4 → Fin 4 → Bool) : Bool := |
| 321 | perms4.any (fun p => |
| 322 | match p with |
| 323 | | [p0, p1, p2, p3] => E 0 p0 && E 1 p1 && E 2 p2 && E 3 p3 |
| 324 | | _ => false) |
| 325 | |
| 326 | def isHC4 (E : Fin 4 → Fin 4 → Bool) : Bool := |
| 327 | let cyc : List (List (Fin 4)) := |
| 328 | [ [0,1,2,3], [0,1,3,2], [0,2,1,3], [0,2,3,1], [0,3,1,2], [0,3,2,1] ] |
| 329 | cyc.any (fun p => |
| 330 | match p with |
| 331 | | [a, b, c, d] => E a b && E b c && E c d && E d a |
| 332 | | _ => false) |
| 333 | |
| 334 | theorem thm9_k4_sc_cc_minimal_6edge_obstruction : |
| 335 | isSC4 g6Edge = true ∧ isCC4 g6Edge = true ∧ isHC4 g6Edge = false := by |
| 336 | decide |
| 337 | |
| 338 | -- Minimal 7-edge K5 witness G7: 0<->1, 2->3->4->2, 1<->2 |
| 339 | def g7Edge (u v : Fin 5) : Bool := |
| 340 | (u.val == 0 && v.val == 1) || (u.val == 1 && v.val == 0) || |
| 341 | (u.val == 2 && v.val == 3) || (u.val == 3 && v.val == 4) || (u.val == 4 && v.val == 2) || |
| 342 | (u.val == 1 && v.val == 2) || (u.val == 2 && v.val == 1) |
| 343 | |
| 344 | def reach5 (E : Fin 5 → Fin 5 → Bool) (s t : Fin 5) : Bool := |
| 345 | let step (r : Fin 5 → Bool) (v : Fin 5) : Bool := |
| 346 | r v || (List.finRange 5).any (fun u => r u && E u v) |
| 347 | let r0 (v : Fin 5) : Bool := v == s |
| 348 | let r4 := step (step (step (step r0))) |
| 349 | r4 t |
| 350 | |
| 351 | def isSC5 (E : Fin 5 → Fin 5 → Bool) : Bool := |
| 352 | (List.finRange 5).all (fun s => (List.finRange 5).all (fun t => reach5 E s t)) |
| 353 | |
| 354 | def isHC5 (E : Fin 5 → Fin 5 → Bool) : Bool := |
| 355 | let p4 : List (List (Fin 5)) := |
| 356 | [ [1,2,3,4], [1,2,4,3], [1,3,2,4], [1,3,4,2], [1,4,2,3], [1,4,3,2], |
| 357 | [2,1,3,4], [2,1,4,3], [2,3,1,4], [2,3,4,1], [2,4,1,3], [2,4,3,1], |
| 358 | [3,1,2,4], [3,1,4,2], [3,2,1,4], [3,2,4,1], [3,4,1,2], [3,4,2,1], |
| 359 | [4,1,2,3], [4,1,3,2], [4,2,1,3], [4,2,3,1], [4,3,1,2], [4,3,2,1] ] |
| 360 | p4.any (fun p => |
| 361 | match p with |
| 362 | | [a, b, c, d] => E 0 a && E a b && E b c && E c d && E d 0 |
| 363 | | _ => false) |
| 364 | |
| 365 | theorem thm10_k5_sc_cc_minimal_7edge_obstruction : |
| 366 | isSC5 g7Edge = true ∧ |
| 367 | (g7Edge 0 1 && g7Edge 1 0 && g7Edge 2 3 && g7Edge 3 4 && g7Edge 4 2) = true ∧ |
| 368 | isHC5 g7Edge = false := by |
| 369 | decide |
| 370 | |
| 371 | -- Petersen P10 vs Pentagonal Prism Y5 (1-WL identical 3-regular, opposite HC) |
| 372 | def p10Edge (u v : Fin 10) : Bool := |
| 373 | let a := u.val; let b := v.val |
| 374 | (a < 5 && b < 5 && ((a + 1) % 5 == b || (b + 1) % 5 == a)) || |
| 375 | (5 ≤ a && 5 ≤ b && (((a - 5 + 2) % 5 + 5 == b) || ((b - 5 + 2) % 5 + 5 == a))) || |
| 376 | (a < 5 && b == a + 5) || (b < 5 && a == b + 5) |
| 377 | |
| 378 | def y5Edge (u v : Fin 10) : Bool := |
| 379 | let a := u.val; let b := v.val |
| 380 | (a < 5 && b < 5 && ((a + 1) % 5 == b || (b + 1) % 5 == a)) || |
| 381 | (5 ≤ a && 5 ≤ b && (((a - 5 + 1) % 5 + 5 == b) || ((b - 5 + 1) % 5 + 5 == a))) || |
| 382 | (a < 5 && b == a + 5) || (b < 5 && a == b + 5) |
| 383 | |
| 384 | def deg10 (E : Fin 10 → Fin 10 → Bool) (u : Fin 10) : Nat := |
| 385 | ((List.finRange 10).filter (fun v => E u v)).length |
| 386 | |
| 387 | def hasHC10 (E : Fin 10 → Fin 10 → Bool) : Bool := |
| 388 | let rec dfs (cur : Fin 10) (mask : Nat) (rem : Nat) : Bool := |
| 389 | match rem with |
| 390 | | 0 => E cur 0 |
| 391 | | r + 1 => |
| 392 | (List.finRange 10).any (fun nxt => |
| 393 | if E cur nxt && ((mask >>> nxt.val) &&& 1 == 0) then |
| 394 | dfs nxt (mask ||| (1 <<< nxt.val)) r |
| 395 | else false) |
| 396 | dfs 0 1 9 |
| 397 | |
| 398 | theorem thm11_wl1_petersen_vs_prism_y5 : |
| 399 | (List.finRange 10).all (fun u => deg10 p10Edge u == 3) = true ∧ |
| 400 | (List.finRange 10).all (fun u => deg10 y5Edge u == 3) = true ∧ |
| 401 | hasHC10 p10Edge = false ∧ |
| 402 | hasHC10 y5Edge = true := by |
| 403 | decide |
| 404 | |
| 405 | -- ============================================================ |
| 406 | -- Broken-Model Negative Controls (4 Mandatory Refutations) |
| 407 | -- ============================================================ |
| 408 | |
| 409 | -- Neg Ctrl 1: Linear order (<) immediately collapses the unordered k-pebble obstruction |
| 410 | -- on (K_{m,m}, K_{m,m+1}) via 1-ary FO(LFP, <) parity! |
| 411 | theorem neg_ctrl_1_linear_order_breaks_pebble_obstruction (m : Nat) : |
| 412 | (2 * m) % 2 = 0 ∧ (2 * m + 1) % 2 = 1 ∧ (2 * m) % 2 ≠ (2 * m + 1) % 2 := by |
| 413 | omega |
| 414 | |
| 415 | -- Neg Ctrl 2: Sharpest natural P-time FO(LFP,<) relaxation (SC ∧ CC) fails on G6 and G7. |
| 416 | theorem neg_ctrl_2_sc_plus_cc_false_passes_g6_and_g7 : |
| 417 | (isSC4 g6Edge = true ∧ isCC4 g6Edge = true ∧ isHC4 g6Edge = false) ∧ |
| 418 | (isSC5 g7Edge = true ∧ isHC5 g7Edge = false) := by |
| 419 | decide |
| 420 | |
| 421 | -- Neg Ctrl 3: Strengthening SC to 2SC (3-variable FO(LFP)) false-rejects the pure directed 4-cycle C4. |
| 422 | def c4Edge (u v : Fin 4) : Bool := (u.val + 1) % 4 == v.val |
| 423 | |
| 424 | def reach4Del0 (E : Fin 4 → Fin 4 → Bool) (s t : Fin 4) : Bool := |
| 425 | let step (r : Fin 4 → Bool) (v : Fin 4) : Bool := |
| 426 | r v || (v.val != 0 && (List.finRange 4).any (fun u => u.val != 0 && r u && E u v)) |
| 427 | let r0 (v : Fin 4) : Bool := v == s |
| 428 | let r3 := step (step (step r0)) |
| 429 | r3 t |
| 430 | |
| 431 | theorem neg_ctrl_3_2sc_false_rejects_directed_cycle : |
| 432 | isHC4 c4Edge = true ∧ reach4Del0 c4Edge 3 1 = false := by |
| 433 | decide |
| 434 | |
| 435 | -- Neg Ctrl 4: Unordered 2-WL (3-variable counting LFP) cannot separate Rook 4x4 from Shrikhande |
| 436 | -- (both srg(16,6,2,2), identical 2-WL pair-color parameters), yet Rook has 8 K4-cliques vs 0 in Shrikhande. |
| 437 | def rookEdge (u v : Fin 16) : Bool := |
| 438 | let x1 := u.val / 4; let y1 := u.val % 4 |
| 439 | let x2 := v.val / 4; let y2 := v.val % 4 |
| 440 | u != v && (x1 == x2 || y1 == y2) |
| 441 | |
| 442 | def shrikEdge (u v : Fin 16) : Bool := |
| 443 | let x1 := u.val / 4; let y1 := u.val % 4 |
| 444 | let x2 := v.val / 4; let y2 := v.val % 4 |
| 445 | let dx := (x2 + 4 - x1) % 4 |
| 446 | let dy := (y2 + 4 - y1) % 4 |
| 447 | (dx == 0 && (dy == 1 || dy == 3)) || |
| 448 | (dy == 0 && (dx == 1 || dx == 3)) || |
| 449 | (dx == 1 && dy == 1) || (dx == 3 && dy == 3) |
| 450 | |
| 451 | def commonNbrs16 (E : Fin 16 → Fin 16 → Bool) (u v : Fin 16) : Nat := |
| 452 | ((List.finRange 16).filter (fun w => E u w && E v w)).length |
| 453 | |
| 454 | def isSrg16_6_2_2 (E : Fin 16 → Fin 16 → Bool) : Bool := |
| 455 | (List.finRange 16).all (fun u => |
| 456 | ((List.finRange 16).filter (fun v => E u v)).length == 6 && |
| 457 | (List.finRange 16).all (fun v => |
| 458 | if u == v then true |
| 459 | else commonNbrs16 E u v == 2)) |
| 460 | |
| 461 | def hasK4_16 (E : Fin 16 → Fin 16 → Bool) : Bool := |
| 462 | (List.finRange 16).any (fun a => |
| 463 | (List.finRange 16).any (fun b => a.val < b.val && E a b && |
| 464 | (List.finRange 16).any (fun c => b.val < c.val && E a c && E b c && |
| 465 | (List.finRange 16).any (fun d => c.val < d.val && E a d && E b d && E c d)))) |
| 466 | |
| 467 | theorem neg_ctrl_4_wl1_and_wl2_blindspots_refute_unordered_counting_lfp : |
| 468 | isSrg16_6_2_2 rookEdge = true ∧ |
| 469 | isSrg16_6_2_2 shrikEdge = true ∧ |
| 470 | hasK4_16 rookEdge = true ∧ |
| 471 | hasK4_16 shrikEdge = false := by |
| 472 | decide |
| 473 | |
| 474 | #print axioms thm1_tarski_knaster_static_lfp |
| 475 | #print axioms thm2_tarski_eq_iter_reachability |
| 476 | #print axioms thm3_reachability_continuation_equivalence |
| 477 | #print axioms thm4_hc_continuation_blowup_all_n |
| 478 | #print axioms thm5_hc_continuation_count_formula |
| 479 | #print axioms thm6_bipartite_odd_cycle_impossible_all_m |
| 480 | #print axioms thm7_bipartite_even_hc_exists_all_m |
| 481 | #print axioms thm8_unordered_k_pebble_duplicator_wins_all_k |
| 482 | #print axioms thm9_k4_sc_cc_minimal_6edge_obstruction |
| 483 | #print axioms thm10_k5_sc_cc_minimal_7edge_obstruction |
| 484 | #print axioms thm11_wl1_petersen_vs_prism_y5 |
| 485 | #print axioms neg_ctrl_1_linear_order_breaks_pebble_obstruction |
| 486 | #print axioms neg_ctrl_2_sc_plus_cc_false_passes_g6_and_g7 |
| 487 | #print axioms neg_ctrl_3_2sc_false_rejects_directed_cycle |
| 488 | #print axioms neg_ctrl_4_wl1_and_wl2_blindspots_refute_unordered_counting_lfp |
| 489 | |
| 490 | end ClockFreeLfpHc |