Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
03389a1
Add one-shot checkerboard proof migration
DomTheDeveloper Jul 23, 2026
61cc6a9
Migrate checkerboard all-n proof from frozen CRL commit
github-actions[bot] Jul 23, 2026
9d1faa2
Allow PR-triggered checkerboard migration
DomTheDeveloper Jul 23, 2026
8fc0535
Remove one-shot checkerboard migration workflow
DomTheDeveloper Jul 23, 2026
90ffbf0
Add checkerboard pinned Lean toolchain
DomTheDeveloper Jul 23, 2026
85f69c8
Add checkerboard Lean project configuration
DomTheDeveloper Jul 23, 2026
be4caf8
Scope checkerboard library to all-n theorem
DomTheDeveloper Jul 23, 2026
6b39a95
Add minimal checkerboard library root
DomTheDeveloper Jul 23, 2026
d1c24f0
Use minimal checkerboard root module
DomTheDeveloper Jul 23, 2026
73965ef
Add one-shot checkerboard support repair
DomTheDeveloper Jul 23, 2026
a124c0c
Make checkerboard model proofs explicit under Lean 4.32
DomTheDeveloper Jul 23, 2026
d8aec4c
Replace checkerboard fiber induction with explicit double counting
DomTheDeveloper Jul 23, 2026
7eb21d0
Make checkerboard polynomial rescalings explicit
DomTheDeveloper Jul 23, 2026
2ac1cab
Remove unused checkerboard repair workflow
DomTheDeveloper Jul 23, 2026
a4010fa
Finish checkerboard indicator-cardinality induction
DomTheDeveloper Jul 23, 2026
4936f26
Finish checkerboard fiber double counting
DomTheDeveloper Jul 23, 2026
c6f5ef3
Finish checkerboard polynomial sum distribution
DomTheDeveloper Jul 23, 2026
7341d15
Use explicit filter cases in checkerboard model
DomTheDeveloper Jul 23, 2026
eff6b30
Use explicit filter cases in checkerboard fiber sums
DomTheDeveloper Jul 23, 2026
d59a5ab
Normalize casts in checkerboard polynomial sums
DomTheDeveloper Jul 23, 2026
7b50bfe
Close checkerboard fiber commutativity goal
DomTheDeveloper Jul 23, 2026
0a9bbc2
Make checkerboard Fin polynomial specialization explicit
DomTheDeveloper Jul 23, 2026
c68bff6
Unfold checkerboard fiber induction hypothesis
DomTheDeveloper Jul 23, 2026
03d2e3d
Separate checkerboard axis pointwise normalization
DomTheDeveloper Jul 23, 2026
8b74711
Make checkerboard row and column collinearity explicit
DomTheDeveloper Jul 23, 2026
b6b2e55
Fix checkerboard casted coordinate differences
DomTheDeveloper Jul 23, 2026
5b1a99f
Rewrite checkerboard row and column coordinates directly
DomTheDeveloper Jul 23, 2026
252758d
Normalize checkerboard even-board casts
DomTheDeveloper Jul 23, 2026
b790c9d
Use explicit finite kernel decision for checkerboard n6 base
DomTheDeveloper Jul 23, 2026
aa165e4
Add compact n6 Boolean SAT certificate test
DomTheDeveloper Jul 23, 2026
f7bb930
Encode checkerboard n6 certificate as pure BitVec SAT
DomTheDeveloper Jul 23, 2026
d8650ce
Generate checkerboard n6 LRAT certificates
DomTheDeveloper Jul 23, 2026
ddac364
Prove checkerboard n6 Boolean certificate with omega
DomTheDeveloper Jul 23, 2026
b1fdf51
Export kernel-only checkerboard n6 omega certificates
DomTheDeveloper Jul 23, 2026
0b6ac8f
Add focused bridge test for checkerboard n6 omega certificate
DomTheDeveloper Jul 23, 2026
c878440
Prove checkerboard n6 certificate with bv_omega
DomTheDeveloper Jul 23, 2026
4738bcc
Use bv_omega for checkerboard Boolean indicator certificate
DomTheDeveloper Jul 23, 2026
b2c96dd
Bridge both checkerboard n6 color certificates
DomTheDeveloper Jul 23, 2026
108f18a
Repair compact checkerboard n6 arithmetic proof
DomTheDeveloper Jul 23, 2026
e191c54
Integrate explicit checkerboard n6 certificates
DomTheDeveloper Jul 23, 2026
bb9e424
Split compact checkerboard n6 certificates
DomTheDeveloper Jul 23, 2026
ad1baea
Keep checkerboard n6 indicators opaque
DomTheDeveloper Jul 23, 2026
100efa9
Use sparse checkerboard n6 dual supports
DomTheDeveloper Jul 23, 2026
10d707f
Fix checkerboard n6 normalization syntax
DomTheDeveloper Jul 23, 2026
2151891
Normalize even checkerboard quadratic identity
DomTheDeveloper Jul 23, 2026
e5aba03
Make even checkerboard cast identity explicit
DomTheDeveloper Jul 23, 2026
5fa90d6
Bridge checkerboard line cards to Boolean indicators
DomTheDeveloper Jul 23, 2026
4bee2a9
Enable finite-sum notation for checkerboard n6 bridge
DomTheDeveloper Jul 23, 2026
09ec437
Use explicit Finset sums in checkerboard n6 bridge
DomTheDeveloper Jul 23, 2026
3752ef8
Add explicit fast checkerboard n6 bridge
DomTheDeveloper Jul 23, 2026
865f796
Use explicit checkerboard n6 proof module
DomTheDeveloper Jul 23, 2026
913adfd
Normalize checkerboard filter conjunctions
DomTheDeveloper Jul 23, 2026
22a5407
Align even checkerboard cast normal form
DomTheDeveloper Jul 23, 2026
3a792ad
Repair exact checkerboard objective sums
DomTheDeveloper Jul 23, 2026
0e97a0b
Regroup even checkerboard objective sums
DomTheDeveloper Jul 23, 2026
e469ca9
Make final checkerboard bounds explicit
DomTheDeveloper Jul 23, 2026
b30957c
Finish explicit seven-board certificate
DomTheDeveloper Jul 23, 2026
017258b
Prove seven-board boundary cardinality explicitly
DomTheDeveloper Jul 23, 2026
11391b3
Fix final checkerboard theorem application
DomTheDeveloper Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Checkerboard.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Checkerboard.AllNTheorem
25 changes: 25 additions & 0 deletions Checkerboard/AllNTheorem.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Checkerboard.AllNUpper
import Checkerboard.N6Explicit

/-!
# Complete all-n checkerboard upper bound
-/

namespace Checkerboard

/-- For every `n ≥ 6`, every no-three-in-line subset of either checkerboard
color class has at most `2n-4` points. -/
theorem checkerboard_upper_all_n {n parity : ℕ}
(hn : 6 ≤ n) (hp : parity = 0 ∨ parity = 1)
(s : Finset (Point n))
(hcolor : Monochromatic parity s) (hntil : NoThreeInLine s) :
s.card ≤ 2 * n - 4 := by
by_cases h6 : n = 6
· subst n
rcases hp with rfl | rfl
· exact n6_zero_upper s hcolor hntil
· exact n6_one_upper s hcolor hntil
· exact checkerboard_upper_from_seven (n := n) (parity := parity)
(s := s) (by omega) hp hcolor hntil

end Checkerboard
196 changes: 196 additions & 0 deletions Checkerboard/AllNUpper.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import Checkerboard.QuadraticCosts

/-!
# The general checkerboard upper bound above the final 6×6 base case

The quadratic line cover proves `|S| ≤ 2n-4` for both checkerboard colors on
every board `n≥7`. The thin color of the 7-board uses a separate exact small
cover; all larger cases use the uniform quadratic family.
-/

namespace Checkerboard

/-- Fat color on every odd board `2m+1`, `m≥3`. -/
theorem odd_zero_upper {m : ℕ} (hm : 3 ≤ m)
(s : Finset (Point (2 * m + 1)))
(hcolor : Monochromatic 0 s) (hntil : NoThreeInLine s) :
s.card ≤ 4 * m - 2 := by
obtain ⟨hr, hc, hs, hd⟩ := oddQuadratic_nonnegative m 0
apply card_le_of_fourCertificate (oddQuadraticWeights m 0)
(q := 16 * (m : ℚ) ^ 2) (k := 4 * m - 2)
· positivity
· rw [oddQuadratic_cost_zero]
have hmQ : (3 : ℚ) ≤ m := by exact_mod_cast hm
have hmpos : (0 : ℚ) < m := by nlinarith
have hpoly : 0 < 2 * (m : ℚ) ^ 2 - 6 * m + 1 := by nlinarith
have hprod := mul_pos hmpos hpoly
have hk : 2 ≤ 4 * m := by omega
have hcast : (((4 * m - 2 : ℕ) : ℚ)) = 4 * (m : ℚ) - 2 := by
rw [Nat.cast_sub hk]
norm_num
rw [hcast]
nlinarith
· exact hr
· exact hc
· exact hs
· exact hd
· intro p
rw [oddQuadratic_coverage m 0 (Or.inl rfl) p.1 (hcolor p)]
· exact hntil

/-- Thin color on every odd board `2m+1`, `m≥4`. -/
theorem odd_one_upper {m : ℕ} (hm : 4 ≤ m)
(s : Finset (Point (2 * m + 1)))
(hcolor : Monochromatic 1 s) (hntil : NoThreeInLine s) :
s.card ≤ 4 * m - 2 := by
obtain ⟨hr, hc, hs, hd⟩ := oddQuadratic_nonnegative m 1
apply card_le_of_fourCertificate (oddQuadraticWeights m 1)
(q := 16 * (m : ℚ) ^ 2) (k := 4 * m - 2)
· positivity
· rw [oddQuadratic_cost_one]
have hmQ : (4 : ℚ) ≤ m := by exact_mod_cast hm
have hmpos : (0 : ℚ) < m := by nlinarith
have hpoly : 0 < 2 * (m : ℚ) ^ 2 - 6 * m - 2 := by nlinarith
have hprod := mul_pos hmpos hpoly
have hk : 2 ≤ 4 * m := by omega
have hcast : (((4 * m - 2 : ℕ) : ℚ)) = 4 * (m : ℚ) - 2 := by
rw [Nat.cast_sub hk]
norm_num
rw [hcast]
nlinarith
· exact hr
· exact hc
· exact hs
· exact hd
· intro p
rw [oddQuadratic_coverage m 1 (Or.inr rfl) p.1 (hcolor p)]
· exact hntil

/-- Both colors on every even board `2m`, `m≥4`. -/
theorem even_upper {m parity : ℕ} (hm : 4 ≤ m)
(hp : parity = 0 ∨ parity = 1)
(s : Finset (Point (2 * m)))
(hcolor : Monochromatic parity s) (hntil : NoThreeInLine s) :
s.card ≤ 4 * m - 4 := by
have hm1 : 1 ≤ m := by omega
have hmQ : (4 : ℚ) ≤ m := by exact_mod_cast hm
have hcenter : (0 : ℚ) < 2 * m - 1 := by nlinarith
have hpoly : 0 < 2 * (m : ℚ) ^ 2 - 8 * m + 3 := by nlinarith
have hprod := mul_pos hcenter hpoly
have hk : 4 ≤ 4 * m := by omega
have hcast : (((4 * m - 4 : ℕ) : ℚ)) = 4 * (m : ℚ) - 4 := by
rw [Nat.cast_sub hk]
norm_num
have hpCost := hp
obtain ⟨hr, hc, hs, hd⟩ := evenQuadratic_nonnegative m parity hm1
apply card_le_of_fourCertificate (evenQuadraticWeights m parity)
(q := 4 * ((2 * m : ℚ) - 1) ^ 2) (k := 4 * m - 4)
· positivity
· rcases hpCost with rfl | rfl
· rw [evenQuadratic_cost_zero m hm1, hcast]
nlinarith
· rw [evenQuadratic_cost_one m hm1, hcast]
nlinarith
· exact hr
· exact hc
· exact hs
· exact hd
· intro p
rw [evenQuadratic_coverage m parity hp hm1 p.1 (hcolor p)]
· exact hntil

/-- Small exact cover for the exceptional thin color of the 7-board. -/
def n7ThinWeights : FourWeights 7 where
row i := if i.1 = 0 ∨ i.1 = 6 then 1 else 0
column i := if i.1 = 0 ∨ i.1 = 6 then 1 else 0
sum j :=
if j.1 % 2 = 1 then
if Nat.dist j.1 6 = 1 then 2 else if Nat.dist j.1 6 = 3 then 1 else 0
else 0
difference j :=
if j.1 % 2 = 1 then
if Nat.dist j.1 6 = 1 then 2 else if Nat.dist j.1 6 = 3 then 1 else 0
else 0

private theorem n7Thin_cost : fourCost n7ThinWeights = 32 := by
norm_num [fourCost, n7ThinWeights, Fin.sum_univ_succ, Nat.dist]
have hboundary :
({x : Fin 7 | x = 0 ∨ (x : ℕ) = 6} : Finset (Fin 7)).card = 2 := by
decide
rw [hboundary]
norm_num

private theorem n7Thin_nonnegative :
(∀ i, 0 ≤ n7ThinWeights.row i) ∧
(∀ i, 0 ≤ n7ThinWeights.column i) ∧
(∀ i, 0 ≤ n7ThinWeights.sum i) ∧
∀ i, 0 ≤ n7ThinWeights.difference i := by
constructor
· intro i
fin_cases i <;> norm_num [n7ThinWeights]
constructor
· intro i
fin_cases i <;> norm_num [n7ThinWeights]
constructor
· intro i
fin_cases i <;> norm_num [n7ThinWeights, Nat.dist]
· intro i
fin_cases i <;> norm_num [n7ThinWeights, Nat.dist]

private theorem n7Thin_cover :
∀ p : Point 7, InColor 1 p → 3 ≤ fourCoverage n7ThinWeights p := by
rintro ⟨i, j⟩ hp
fin_cases i <;> fin_cases j
all_goals
norm_num [InColor] at hp
all_goals
norm_num [fourCoverage, n7ThinWeights, sumIndex,
differenceIndex, Nat.dist]

/-- Exceptional thin-color bound on the 7-board. -/
theorem n7_one_upper (s : Finset (Point 7))
(hcolor : Monochromatic 1 s) (hntil : NoThreeInLine s) : s.card ≤ 10 := by
obtain ⟨hr, hc, hs, hd⟩ := n7Thin_nonnegative
apply card_le_of_fourCertificate n7ThinWeights (q := 3) (k := 10)
· norm_num
· rw [n7Thin_cost]
norm_num
· exact hr
· exact hc
· exact hs
· exact hd
· intro p
exact n7Thin_cover p.1 (hcolor p)
· exact hntil

/-- Fat-color bound on the 7-board. -/
theorem n7_zero_upper (s : Finset (Point 7))
(hcolor : Monochromatic 0 s) (hntil : NoThreeInLine s) : s.card ≤ 10 := by
simpa using odd_zero_upper (m := 3) (by decide) s hcolor hntil

/-- The general bound for all boards `n≥7` and either color. -/
theorem checkerboard_upper_from_seven {n parity : ℕ}
(hn : 7 ≤ n) (hp : parity = 0 ∨ parity = 1)
(s : Finset (Point n))
(hcolor : Monochromatic parity s) (hntil : NoThreeInLine s) :
s.card ≤ 2 * n - 4 := by
obtain ⟨m, hEven | hOdd⟩ := n.even_or_odd'
· subst n
have hm : 4 ≤ m := by omega
have h := even_upper hm hp s hcolor hntil
omega
· subst n
have hm : 3 ≤ m := by omega
by_cases hsmall : m = 3
· subst m
rcases hp with rfl | rfl
· exact n7_zero_upper s hcolor hntil
· exact n7_one_upper s hcolor hntil
· have hm4 : 4 ≤ m := by omega
rcases hp with rfl | rfl
· have h := odd_zero_upper hm s hcolor hntil
omega
· have h := odd_one_upper hm4 s hcolor hntil
omega

end Checkerboard
120 changes: 120 additions & 0 deletions Checkerboard/FiberSums.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import Mathlib

namespace Checkerboard

open scoped BigOperators

section

variable {α β R : Type*} [DecidableEq α] [DecidableEq β]

def fiberCard (s : Finset α) (f : α → β) (b : β) : ℕ :=
(s.filter fun a => f a = b).card

@[simp] theorem fiberCard_empty (f : α → β) (b : β) :
fiberCard ∅ f b = 0 := by simp [fiberCard]

private theorem fiberCard_mul_eq_sum [CommSemiring R]
(s : Finset α) (f : α → β) (b : β) (g : β → R) :
(fiberCard s f b : R) * g b =
∑ a ∈ s, if f a = b then g b else 0 := by
classical
induction s using Finset.induction_on with
| empty => simp [fiberCard]
| @insert a s ha ih =>
by_cases h : f a = b
· have hnot : a ∉ s.filter fun x => f x = b := by
intro hmem
exact ha (Finset.mem_filter.mp hmem).1
have hfilter : (insert a s).filter (fun x => f x = b) =
insert a (s.filter fun x => f x = b) := by
ext x
by_cases hxa : x = a
· subst x; simp [ha, h]
· simp [hxa]
have ih' :
((s.filter fun x => f x = b).card : R) * g b =
∑ x ∈ s, if f x = b then g b else 0 := by
simpa [fiberCard] using ih
rw [fiberCard, hfilter]
rw [Finset.sum_insert ha, if_pos h]
simp only [Finset.card_insert_of_notMem hnot, Nat.cast_add, Nat.cast_one,
add_mul, one_mul]
rw [ih']
ac_rfl
· have hfilter : (insert a s).filter (fun x => f x = b) =
s.filter fun x => f x = b := by
ext x
by_cases hxa : x = a
· subst x; simp [ha, h]
· simp [hxa]
rw [fiberCard, hfilter]
rw [Finset.sum_insert ha, if_neg h]
simpa [fiberCard] using ih

theorem sum_fiberCard_mul [Fintype β] [CommSemiring R]
(s : Finset α) (f : α → β) (g : β → R) :
∑ b : β, (fiberCard s f b : R) * g b =
∑ a ∈ s, g (f a) := by
classical
calc
∑ b : β, (fiberCard s f b : R) * g b =
∑ b : β, ∑ a ∈ s, if f a = b then g b else 0 := by
apply Finset.sum_congr rfl
intro b _
exact fiberCard_mul_eq_sum s f b g
_ = ∑ a ∈ s, ∑ b : β, if f a = b then g b else 0 := by
rw [Finset.sum_comm]
_ = ∑ a ∈ s, g (f a) := by
apply Finset.sum_congr rfl
intro a _
simp

theorem sum_fiberCard [Fintype β] (s : Finset α) (f : α → β) :
∑ b : β, fiberCard s f b = s.card := by
simpa using sum_fiberCard_mul (R := ℕ) s f (fun _ => 1)

theorem sum_fiberCard_cast [Fintype β] [CommSemiring R]
(s : Finset α) (f : α → β) :
∑ b : β, (fiberCard s f b : R) = (s.card : R) := by
simpa using sum_fiberCard_mul (R := R) s f (fun _ => 1)

theorem card_le_sum_capacity [Fintype β]
(s : Finset α) (f : α → β) (capacity : β → ℕ)
(hcapacity : ∀ b, fiberCard s f b ≤ capacity b) :
s.card ≤ ∑ b, capacity b := by
rw [← sum_fiberCard s f]
exact Finset.sum_le_sum fun b _ => hcapacity b

theorem sum_defect_mul [Fintype β]
(s : Finset α) (f : α → β) (capacity : β → ℕ)
(coordinate : β → ℝ)
(hcapacity : ∀ b, fiberCard s f b ≤ capacity b) :
(∑ b, ((capacity b - fiberCard s f b : ℕ) : ℝ) * coordinate b) =
(∑ b, (capacity b : ℝ) * coordinate b) -
∑ a ∈ s, coordinate (f a) := by
calc
(∑ b, ((capacity b - fiberCard s f b : ℕ) : ℝ) * coordinate b) =
∑ b, ((capacity b : ℝ) - (fiberCard s f b : ℝ)) * coordinate b := by
apply Finset.sum_congr rfl
intro b _
rw [Nat.cast_sub (hcapacity b)]
_ = (∑ b, (capacity b : ℝ) * coordinate b) -
∑ b, (fiberCard s f b : ℝ) * coordinate b := by
simp only [sub_mul, Finset.sum_sub_distrib]
_ = (∑ b, (capacity b : ℝ) * coordinate b) -
∑ a ∈ s, coordinate (f a) := by
rw [sum_fiberCard_mul]

theorem sum_defect_mul_sq [Fintype β]
(s : Finset α) (f : α → β) (capacity : β → ℕ)
(coordinate : β → ℝ)
(hcapacity : ∀ b, fiberCard s f b ≤ capacity b) :
(∑ b, ((capacity b - fiberCard s f b : ℕ) : ℝ) * coordinate b ^ 2) =
(∑ b, (capacity b : ℝ) * coordinate b ^ 2) -
∑ a ∈ s, coordinate (f a) ^ 2 := by
simpa using sum_defect_mul s f capacity (fun b => coordinate b ^ 2) hcapacity

end

end Checkerboard
Loading