Imports
/- Copyright (c) 2026 Google LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ module public import Cryptids.Machines

ErdosTernary15

The 15-state Turing machine erdos_ternary_15 halts on the blank tape if and only if some power 2 ^ n with n > 8 has no digit 2 in base 3, i.e. if and only if Erdős's conjecture on the ternary digits of powers of two is false.

Provenance and Attribution

    Tristan Stérin and Damien Woods, Hardness of busy beaver value BB(15) (https://arxiv.org/abs/2107.12475, 2021): the 5-state, 4-symbol machine powers_of_two_5_4 and its 15-state, 2-symbol compilation powers_of_two_15_2, published in https://github.com/tcosmo/bbsim (machines/powers_of_two_15_2.txt, commit 3f655ba2c73b) and mirrored at https://docs.bbchallenge.org/other/powers_of_two_15_2.txt. The file is kept verbatim in baselines/sources/erdos_ternary_15_sterin_woods.txt; verify.py re-derives baselines/tables/erdos_ternary_15.txt from it and checks that they match: the start state mul2_G_sim becomes 0, the other states are numbered in order of appearance, and the blank symbol b becomes 0 and a becomes 1. Their correctness proof is on paper; this file gives a Lean proof.

Machine Layout

The machine simulates a 4-symbol machine whose symbols 0, 1, 2, # are stored as cell pairs 01, 10, 11, 00. Between two passes the tape reads, from left to right, [counter] # d₀ d₁ … dₖ, where d₀ … dₖ are the base-3 digits of 2 ^ n, least significant first, and the counter cell holds #, 0, 1 or 2 when 0, 1, 2 or 3 of the powers 2 ^ 0, …, 2 ^ n have no digit 2. One pass doubles the number (states 0–3, 7–9), scans the digits from the most significant one for a 2 (states 4–6), returns to the first digit (states 10–12) and, if no 2 was found, increments the counter (states 13, 14). Some states are shared: rewinding also uses 8, and incrementing the counter also uses 8, 9 and 12. The machine halts at the fourth power without a digit 2; the first three are 2 ^ 0, 2 ^ 2 and 2 ^ 8.

@[expose] public sectionnamespace ConjectureMachines.ErdosTernary15open Turing (Dir)open StateTransition

15-state Erdős ternary machine (erdos_ternary_15, Stérin & Woods 2021).

abbrev erdosTernary15 : Machine 15 2 := Machines.erdosTernary15

Base-3 Doubling

Doubles a base-3 digit list (least significant digit first) and adds the carry c.

def dbl : List ℕ → ℕ → List ℕ | [], c => if c = 0 then [] else [c] | d :: ds, c => (2 * d + c) % 3 :: dbl ds ((2 * d + c) / 3)theorem dbl_lt (ds : List ℕ) (hds : ∀ d ∈ ds, d < 3) (c : ℕ) (hc : c ≤ 1) : ∀ d ∈ dbl ds c, d < 3 := ds:List ℕhds:∀ d ∈ ds, d < 3c:ℕhc:c ≤ 1⊢ ∀ d ∈ dbl ds c, d < 3 induction ds generalizing c with hds:∀ d ∈ [], d < 3c:ℕhc:c ≤ 1⊢ ∀ d ∈ dbl [] c, d < 3 hds:∀ d ∈ [], d < 3c:ℕhc:c ≤ 1d:ℕhd:d ∈ dbl [] c⊢ d < 3 rcases (hds:∀ d ∈ [], d < 3c:ℕhc:c ≤ 1d:ℕhd:d ∈ dbl [] c⊢ c = 0 ∨ c = 1 All goals completed! 🐙 : c = 0 ∨ c = 1) with rfl | rfl hds:∀ d ∈ [], d < 3d:ℕhc:0 ≤ 1hd:d ∈ dbl [] 0⊢ d < 3 All goals completed! 🐙 hds:∀ d ∈ [], d < 3d:ℕhc:1 ≤ 1hd:d ∈ dbl [] 1⊢ d < 3 hds:∀ d ∈ [], d < 3d:ℕhc:1 ≤ 1hd:d = 1⊢ d < 3; All goals completed! 🐙 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1⊢ ∀ d ∈ dbl (x :: xs) c, d < 3 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhd:d ∈ dbl (x :: xs) c⊢ d < 3 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhd:d ∈ dbl (x :: xs) chx:x < 3⊢ d < 3 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhx:x < 3hd:d = (2 * x + c) % 3 ∨ d ∈ dbl xs ((2 * x + c) / 3)⊢ d < 3 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1hx:x < 3⊢ (2 * x + c) % 3 < 3x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhx:x < 3hd:d ∈ dbl xs ((2 * x + c) / 3)⊢ d < 3 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1hx:x < 3⊢ (2 * x + c) % 3 < 3 All goals completed! 🐙 x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhx:x < 3hd:d ∈ dbl xs ((2 * x + c) / 3)⊢ d < 3 exact ih (fun y hy => hds y (List.mem_cons_of_mem x hy)) _ (x:ℕxs:List ℕih:(∀ d ∈ xs, d < 3) → ∀ c ≤ 1, ∀ d ∈ dbl xs c, d < 3hds:∀ d ∈ x :: xs, d < 3c:ℕhc:c ≤ 1d:ℕhx:x < 3hd:d ∈ dbl xs ((2 * x + c) / 3)⊢ (2 * x + c) / 3 ≤ 1 All goals completed! 🐙) d hd

The base-3 digits of 2 ^ n, computed by repeated doubling.

def pw : ℕ → List ℕ | 0 => [1] | n + 1 => dbl (pw n) 0theorem pw_lt (n : ℕ) : ∀ d ∈ pw n, d < 3 := n:ℕ⊢ ∀ d ∈ pw n, d < 3 induction n with ⊢ ∀ d ∈ pw 0, d < 3 All goals completed! 🐙 n:ℕih:∀ d ∈ pw n, d < 3⊢ ∀ d ∈ pw (n + 1), d < 3 exact dbl_lt (pw n) ih 0 (n:ℕih:∀ d ∈ pw n, d < 3⊢ 0 ≤ 1 All goals completed! 🐙)

The number of k ≤ n such that 2 ^ k has no digit 2 in base 3.

def cnt : ℕ → ℕ | 0 => 1 | n + 1 => cnt n + if 2 ∈ pw (n + 1) then 0 else 1theorem cnt_succ_of_mem {n : ℕ} (h : 2 ∈ pw (n + 1)) : cnt (n + 1) = cnt n := n:ℕh:2 ∈ pw (n + 1)⊢ cnt (n + 1) = cnt n All goals completed! 🐙theorem cnt_succ_of_not_mem {n : ℕ} (h : 2 ∉ pw (n + 1)) : cnt (n + 1) = cnt n + 1 := n:ℕh:2 ∉ pw (n + 1)⊢ cnt (n + 1) = cnt n + 1 All goals completed! 🐙

2 ^ 0 = 1, 2 ^ 2 = 11₃ and 2 ^ 8 = 100111₃ are the only powers 2 ^ k with k ≤ 8 without a digit 2.

theorem cnt_eight : cnt 8 = 3 := ⊢ cnt 8 = 3 All goals completed! 🐙

Tape Encoding

Left cell of the pair encoding the digit d (0 ↦ 01, 1 ↦ 10, 2 ↦ 11).

def hi : ℕ → Fin 2 | 0 => 0 | _ => 1

Right cell of the pair encoding the digit d.

def lo : ℕ → Fin 2 | 1 => 0 | _ => 1@[simp] theorem hi_zero : hi 0 = 0 := rfl@[simp] theorem hi_one : hi 1 = 1 := rfl@[simp] theorem hi_two : hi 2 = 1 := rfl@[simp] theorem lo_zero : lo 0 = 1 := rfl@[simp] theorem lo_one : lo 1 = 0 := rfl@[simp] theorem lo_two : lo 2 = 1 := rfl

The cells of a digit list, read from left to right.

def encR : List ℕ → List (Fin 2) | [] => [] | d :: ds => hi d :: lo d :: encR ds

The cells of a digit list, read from right to left.

def encL : List ℕ → List (Fin 2) | [] => [] | d :: ds => encL ds ++ [lo d, hi d]

Left cell of the counter pair (0 ↦ 00, 1 ↦ 01, 2 ↦ 10, 3 ↦ 11).

def chi : ℕ → Fin 2 | 0 => 0 | 1 => 0 | _ => 1

Right cell of the counter pair.

def clo : ℕ → Fin 2 | 1 => 1 | 3 => 1 | _ => 0def B0 : ListBlank (Fin 2) := ListBlank.mk []theorem B0_cons_zero : B0.cons 0 = B0 := ListBlank.cons_head_tail B0

Head on the first cell of L.

def Tape.mkL (L R : ListBlank (Fin 2)) : Tape (Fin 2) := ⟨L.head, L.tail, R⟩@[simp] theorem Tape.mkL_cons (a : Fin 2) (L R : ListBlank (Fin 2)) : Tape.mkL (L.cons a) R = ⟨a, L, R⟩ := a:Fin 2L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ mkL (ListBlank.cons a L) R = { head := a, left := L, right := R } All goals completed! 🐙@[simp] theorem Tape.mk'_cons (a : Fin 2) (L R : ListBlank (Fin 2)) : Tape.mk' L (R.cons a) = ⟨a, L, R⟩ := a:Fin 2L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ Tape.mk' L (ListBlank.cons a R) = { head := a, left := L, right := R } All goals completed! 🐙@[simp] theorem Tape.mk'_B0 (L : ListBlank (Fin 2)) : Tape.mk' L B0 = ⟨0, L, B0⟩ := rfl

The cells left of the first digit: the # pair, then the counter pair.

def LH (c : ℕ) : ListBlank (Fin 2) := ListBlank.append [0, 0, clo c, chi c] B0

Start of the pass that doubles 2 ^ n, with counter c.

def stageCfg (c n : ℕ) : Cfg 15 2 := ⟨1, Tape.mk' (LH c) (ListBlank.append (encR (pw n)) B0)⟩

Step Infrastructure

sectionvariable {Q : ℕ}

n steps of M from c, or none if M halts first.

def nSteps (M : Machine Q 2) (n : ℕ) : Cfg Q 2 → Option (Cfg Q 2) := Nat.rec (motive := fun _ => Cfg Q 2 → Option (Cfg Q 2)) (fun c => some c) (fun _ ih c => (step M c).bind ih) n@[simp] theorem nSteps_zero (M : Machine Q 2) (c : Cfg Q 2) : nSteps M 0 c = some c := rfl@[simp] theorem nSteps_succ (M : Machine Q 2) (n : ℕ) (c : Cfg Q 2) : nSteps M (n + 1) c = (step M c).bind (nSteps M n) := rflattribute [eqns nSteps_zero nSteps_succ] nStepstheorem nSteps_reaches {M : Machine Q 2} {n : ℕ} {c c' : Cfg Q 2} (h : nSteps M n c = some c') : Reaches (step M) c c' := Q:ℕM:Machine Q 2n:ℕc:Cfg Q 2c':Cfg Q 2h:nSteps M n c = some c'⊢ Reaches (step M) c c' induction n generalizing c with Q:ℕM:Machine Q 2c':Cfg Q 2c:Cfg Q 2h:nSteps M 0 c = some c'⊢ Reaches (step M) c c' Q:ℕM:Machine Q 2c':Cfg Q 2c:Cfg Q 2h':c = c'⊢ Reaches (step M) c c' Q:ℕM:Machine Q 2c:Cfg Q 2⊢ Reaches (step M) c c All goals completed! 🐙 Q:ℕM:Machine Q 2c':Cfg Q 2n:ℕih:∀ {c : Cfg Q 2}, nSteps M n c = some c' → Reaches (step M) c c'c:Cfg Q 2h:nSteps M (n + 1) c = some c'⊢ Reaches (step M) c c' Q:ℕM:Machine Q 2c':Cfg Q 2n:ℕih:∀ {c : Cfg Q 2}, nSteps M n c = some c' → Reaches (step M) c c'c:Cfg Q 2h:∃ a, step M c = some a ∧ Nat.rec (motive := fun x ↦ Cfg Q 2 → Option (Cfg Q 2)) (fun c ↦ some c) (fun x ih c ↦ (step M c).bind ih) n a = some c'⊢ Reaches (step M) c c' Q:ℕM:Machine Q 2c':Cfg Q 2n:ℕih:∀ {c : Cfg Q 2}, nSteps M n c = some c' → Reaches (step M) c c'c:Cfg Q 2c₁:Cfg Q 2hstep:step M c = some c₁hrest:Nat.rec (motive := fun x ↦ Cfg Q 2 → Option (Cfg Q 2)) (fun c ↦ some c) (fun x ih c ↦ (step M c).bind ih) n c₁ = some c'⊢ Reaches (step M) c c' All goals completed! 🐙theorem nSteps_add {M : Machine Q 2} (m n : ℕ) (c : Cfg Q 2) : nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n) := Q:ℕM:Machine Q 2m:ℕn:ℕc:Cfg Q 2⊢ nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n) induction m generalizing c with Q:ℕM:Machine Q 2n:ℕc:Cfg Q 2⊢ nSteps M (0 + n) c = (nSteps M 0 c).bind (nSteps M n) All goals completed! 🐙 Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2⊢ nSteps M (m + 1 + n) c = (nSteps M (m + 1) c).bind (nSteps M n) Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2⊢ (step M c).bind (nSteps M (m + n)) = ((step M c).bind (nSteps M m)).bind (nSteps M n) Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2⊢ none.bind (nSteps M (m + n)) = (none.bind (nSteps M m)).bind (nSteps M n)Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2val✝:Cfg Q 2⊢ (some val✝).bind (nSteps M (m + n)) = ((some val✝).bind (nSteps M m)).bind (nSteps M n) Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2⊢ none.bind (nSteps M (m + n)) = (none.bind (nSteps M m)).bind (nSteps M n)Q:ℕM:Machine Q 2n:ℕm:ℕih:∀ (c : Cfg Q 2), nSteps M (m + n) c = (nSteps M m c).bind (nSteps M n)c:Cfg Q 2val✝:Cfg Q 2⊢ (some val✝).bind (nSteps M (m + n)) = ((some val✝).bind (nSteps M m)).bind (nSteps M n) All goals completed! 🐙theorem nSteps_bind_eq {M : Machine Q 2} {m n : ℕ} {c c₁ c₂ : Cfg Q 2} (h₁ : nSteps M m c = some c₁) (h₂ : nSteps M n c₁ = some c₂) : nSteps M (m + n) c = some c₂ := Q:ℕM:Machine Q 2m:ℕn:ℕc:Cfg Q 2c₁:Cfg Q 2c₂:Cfg Q 2h₁:nSteps M m c = some c₁h₂:nSteps M n c₁ = some c₂⊢ nSteps M (m + n) c = some c₂ All goals completed! 🐙theorem step_one {M : Machine Q 2} {c c₁ : Cfg Q 2} (h : step M c = some c₁) : nSteps M 1 c = some c₁ := Q:ℕM:Machine Q 2c:Cfg Q 2c₁:Cfg Q 2h:step M c = some c₁⊢ nSteps M 1 c = some c₁ Q:ℕM:Machine Q 2c:Cfg Q 2c₁:Cfg Q 2h:step M c = some c₁⊢ (some c₁).bind (nSteps M 0) = some c₁; All goals completed! 🐙theorem reaches_imp_nSteps {M : Machine Q 2} {a b : Cfg Q 2} (h : Reaches (step M) a b) : ∃ k, nSteps M k a = some b := Q:ℕM:Machine Q 2a:Cfg Q 2b:Cfg Q 2h:Reaches (step M) a b⊢ ∃ k, nSteps M k a = some b induction h with Q:ℕM:Machine Q 2a:Cfg Q 2b:Cfg Q 2⊢ ∃ k, nSteps M k a = some a All goals completed! 🐙 Q:ℕM:Machine Q 2a:Cfg Q 2b:Cfg Q 2b✝:Cfg Q 2c✝:Cfg Q 2a✝:Relation.ReflTransGen (fun a b ↦ b ∈ step M a) a b✝hstep:c✝ ∈ step M b✝ih:∃ k, nSteps M k a = some b✝⊢ ∃ k, nSteps M k a = some c✝ Q:ℕM:Machine Q 2a:Cfg Q 2b:Cfg Q 2b✝:Cfg Q 2c✝:Cfg Q 2a✝:Relation.ReflTransGen (fun a b ↦ b ∈ step M a) a b✝hstep:c✝ ∈ step M b✝k:ℕhk:nSteps M k a = some b✝⊢ ∃ k, nSteps M k a = some c✝ All goals completed! 🐙theorem nSteps_eq_none_of_step_none {M : Machine Q 2} {k : ℕ} (s : ℕ) {a b : Cfg Q 2} (hk : nSteps M k a = some b) (hnone : step M b = none) (hks : k < s) : nSteps M s a = none := Q:ℕM:Machine Q 2k:ℕs:ℕa:Cfg Q 2b:Cfg Q 2hk:nSteps M k a = some bhnone:step M b = nonehks:k < s⊢ nSteps M s a = none Q:ℕM:Machine Q 2k:ℕs:ℕa:Cfg Q 2b:Cfg Q 2hk:nSteps M k a = some bhnone:step M b = nonehks:k < shs:s = k + (s - k - 1 + 1)⊢ nSteps M s a = none All goals completed! 🐙end

Transition Table

theorem stepR {q q' : Fin 15} {a b : Fin 2} (h : erdosTernary15.transition q a = some (b, .right, q')) (L R : ListBlank (Fin 2)) : step erdosTernary15 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', Tape.mk' (L.cons b) R⟩ := q:Fin 15q':Fin 15a:Fin 2b:Fin 2h:erdosTernary15.transition q a = some (b, Dir.right, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step erdosTernary15 { state := q, tape := { head := a, left := L, right := R } } = some { state := q', tape := Tape.mk' (ListBlank.cons b L) R } q:Fin 15q':Fin 15a:Fin 2b:Fin 2h:erdosTernary15.transition q a = some (b, Dir.right, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ some { state := q', tape := Tape.move Dir.right (Tape.write b { head := a, left := L, right := R }) } = some { state := q', tape := Tape.mk' (ListBlank.cons b L) R }; All goals completed! 🐙theorem stepL {q q' : Fin 15} {a b : Fin 2} (h : erdosTernary15.transition q a = some (b, .left, q')) (L R : ListBlank (Fin 2)) : step erdosTernary15 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', Tape.mkL L (R.cons b)⟩ := q:Fin 15q':Fin 15a:Fin 2b:Fin 2h:erdosTernary15.transition q a = some (b, Dir.left, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step erdosTernary15 { state := q, tape := { head := a, left := L, right := R } } = some { state := q', tape := Tape.mkL L (ListBlank.cons b R) } q:Fin 15q':Fin 15a:Fin 2b:Fin 2h:erdosTernary15.transition q a = some (b, Dir.left, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ some { state := q', tape := Tape.move Dir.left (Tape.write b { head := a, left := L, right := R }) } = some { state := q', tape := Tape.mkL L (ListBlank.cons b R) }; All goals completed! 🐙theorem s0_0 (L R) : step erdosTernary15 ⟨0, ⟨0, L, R⟩⟩ = some ⟨8, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s0_1 (L R) : step erdosTernary15 ⟨0, ⟨1, L, R⟩⟩ = some ⟨7, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s1_0 (L R) : step erdosTernary15 ⟨1, ⟨0, L, R⟩⟩ = some ⟨3, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s1_1 (L R) : step erdosTernary15 ⟨1, ⟨1, L, R⟩⟩ = some ⟨2, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s2_0 (L R) : step erdosTernary15 ⟨2, ⟨0, L, R⟩⟩ = some ⟨1, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s2_1 (L R) : step erdosTernary15 ⟨2, ⟨1, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s3_0 (L R) : step erdosTernary15 ⟨3, ⟨0, L, R⟩⟩ = some ⟨5, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s3_1 (L R) : step erdosTernary15 ⟨3, ⟨1, L, R⟩⟩ = some ⟨1, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s4_0 (L R) : step erdosTernary15 ⟨4, ⟨0, L, R⟩⟩ = some ⟨6, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s4_1 (L R) : step erdosTernary15 ⟨4, ⟨1, L, R⟩⟩ = some ⟨5, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s5_0 (L R) : step erdosTernary15 ⟨5, ⟨0, L, R⟩⟩ = some ⟨4, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s5_1 (L R) : step erdosTernary15 ⟨5, ⟨1, L, R⟩⟩ = some ⟨10, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s6_0 (L R) : step erdosTernary15 ⟨6, ⟨0, L, R⟩⟩ = some ⟨13, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s6_1 (L R) : step erdosTernary15 ⟨6, ⟨1, L, R⟩⟩ = some ⟨4, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s7_0 (L R) : step erdosTernary15 ⟨7, ⟨0, L, R⟩⟩ = some ⟨9, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s7_1 (L R) : step erdosTernary15 ⟨7, ⟨1, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s8_0 (L R) : step erdosTernary15 ⟨8, ⟨0, L, R⟩⟩ = some ⟨1, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s8_1 (L R) : step erdosTernary15 ⟨8, ⟨1, L, R⟩⟩ = some ⟨1, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s9_0 (L R) : step erdosTernary15 ⟨9, ⟨0, L, R⟩⟩ = some ⟨12, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s9_1 (L R) : step erdosTernary15 ⟨9, ⟨1, L, R⟩⟩ = some ⟨7, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s10_0 (L R) : step erdosTernary15 ⟨10, ⟨0, L, R⟩⟩ = some ⟨12, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s10_1 (L R) : step erdosTernary15 ⟨10, ⟨1, L, R⟩⟩ = some ⟨11, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s11_0 (L R) : step erdosTernary15 ⟨11, ⟨0, L, R⟩⟩ = some ⟨10, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s11_1 (L R) : step erdosTernary15 ⟨11, ⟨1, L, R⟩⟩ = some ⟨10, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s12_0 (L R) : step erdosTernary15 ⟨12, ⟨0, L, R⟩⟩ = some ⟨8, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rtheorem s12_1 (L R) : step erdosTernary15 ⟨12, ⟨1, L, R⟩⟩ = some ⟨10, Tape.mkL L (R.cons 1)⟩ := stepL rfl L Rtheorem s13_0 (L R) : step erdosTernary15 ⟨13, ⟨0, L, R⟩⟩ = some ⟨12, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s13_1 (L R) : step erdosTernary15 ⟨13, ⟨1, L, R⟩⟩ = some ⟨14, Tape.mkL L (R.cons 0)⟩ := stepL rfl L Rtheorem s14_0 (L R) : step erdosTernary15 ⟨14, ⟨0, L, R⟩⟩ = some ⟨9, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rtheorem s14_1 (L R : ListBlank (Fin 2)) : step erdosTernary15 ⟨14, ⟨1, L, R⟩⟩ = none := rfl

Runs the machine through a fixed sequence of steps on a concrete tape.

local macro "tm_run" : tactic => `(tactic| simp only [nSteps_succ, nSteps_zero, Option.bind_some, s0_0, s0_1, s1_0, s1_1, s2_0, s2_1, s3_0, s3_1, s4_0, s4_1, s5_0, s5_1, s6_0, s6_1, s7_0, s7_1, s8_0, s8_1, s9_0, s9_1, s10_0, s10_1, s11_0, s11_1, s12_0, s12_1, s13_0, s13_1, s14_0, Tape.mk'_cons, Tape.mkL_cons, Tape.mk'_B0, ListBlank.append, hi_zero, hi_one, hi_two, lo_zero, lo_one, lo_two])

Doubling Pass (States 0–3, 7–9)

The doubling state for carry c: mul2_F (1) for carry 0, mul2_G (0) for carry 1.

def st : ℕ → Fin 15 | 0 => 1 | _ => 0theorem digit_step (d c : ℕ) (hd : d < 3) (hc : c ≤ 1) (L R : ListBlank (Fin 2)) : ∃ s, nSteps erdosTernary15 s ⟨st c, ⟨hi d, L, R.cons (lo d)⟩⟩ = some ⟨st ((2 * d + c) / 3), Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) R⟩ := d:ℕc:ℕhd:d < 3hc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) R } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) R } rcases (d:ℕc:ℕhd:d < 3hc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ d = 0 ∨ d = 1 ∨ d = 2 All goals completed! 🐙 : d = 0 ∨ d = 1 ∨ d = 2) with rfl | rfl | rfl c:ℕhc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := st ((2 * 0 + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 0 + c) % 3), hi ((2 * 0 + c) % 3)] L) R }c:ℕhc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := st ((2 * 1 + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 1 + c) % 3), hi ((2 * 1 + c) % 3)] L) R }c:ℕhc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := st ((2 * 2 + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 2 + c) % 3), hi ((2 * 2 + c) % 3)] L) R } rcases (c:ℕhc:c ≤ 1L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ c = 0 ∨ c = 1 All goals completed! 🐙 : c = 0 ∨ c = 1) with rfl | rfl L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 0, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := st ((2 * 0 + 0) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 0 + 0) % 3), hi ((2 * 0 + 0) % 3)] L) R }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 1, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := st ((2 * 0 + 1) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 0 + 1) % 3), hi ((2 * 0 + 1) % 3)] L) R }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 0, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := st ((2 * 1 + 0) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 1 + 0) % 3), hi ((2 * 1 + 0) % 3)] L) R }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 1, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := st ((2 * 1 + 1) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 1 + 1) % 3), hi ((2 * 1 + 1) % 3)] L) R }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 0, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := st ((2 * 2 + 0) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 2 + 0) % 3), hi ((2 * 2 + 0) % 3)] L) R }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 1, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := st ((2 * 2 + 1) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * 2 + 1) % 3), hi ((2 * 2 + 1) % 3)] L) R } L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 0, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 2, hi 2] L) R } L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 1, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 0, hi 0] L) R } exact ⟨2, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:0 ≤ 1⊢ nSteps erdosTernary15 2 { state := 1, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 0, hi 0] L) R } All goals completed! 🐙⟩ L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 0, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 1, hi 1] L) R } exact ⟨2, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3hc:1 ≤ 1⊢ nSteps erdosTernary15 2 { state := 0, tape := { head := hi 0, left := L, right := ListBlank.cons (lo 0) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 1, hi 1] L) R } All goals completed! 🐙⟩ L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 1, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 2, hi 2] L) R } exact ⟨2, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:0 ≤ 1⊢ nSteps erdosTernary15 2 { state := 1, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := 1, tape := Tape.mk' (ListBlank.append [lo 2, hi 2] L) R } All goals completed! 🐙⟩ L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 0, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 0, hi 0] L) R } exact ⟨4, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3hc:1 ≤ 1⊢ nSteps erdosTernary15 4 { state := 0, tape := { head := hi 1, left := L, right := ListBlank.cons (lo 1) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 0, hi 0] L) R } All goals completed! 🐙⟩ L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 1, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 1, hi 1] L) R } exact ⟨2, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:0 ≤ 1⊢ nSteps erdosTernary15 2 { state := 1, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 1, hi 1] L) R } All goals completed! 🐙⟩ L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := 0, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 2, hi 2] L) R } exact ⟨2, L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3hc:1 ≤ 1⊢ nSteps erdosTernary15 2 { state := 0, tape := { head := hi 2, left := L, right := ListBlank.cons (lo 2) R } } = some { state := 0, tape := Tape.mk' (ListBlank.append [lo 2, hi 2] L) R } All goals completed! 🐙⟩theorem blank_step (L : ListBlank (Fin 2)) : nSteps erdosTernary15 3 ⟨1, Tape.mk' L B0⟩ = some ⟨4, Tape.mkL L B0⟩ := L:ListBlank (Fin 2)⊢ nSteps erdosTernary15 3 { state := 1, tape := Tape.mk' L B0 } = some { state := 4, tape := Tape.mkL L B0 } L:ListBlank (Fin 2)⊢ some { state := 4, tape := Tape.mkL L (ListBlank.cons 0 (ListBlank.cons 0 B0)) } = some { state := 4, tape := Tape.mkL L B0 } All goals completed! 🐙

One pass doubles the digit list ds with carry c; it ends in state 4 on the right cell of the most significant digit.

theorem mul2_pass (ds : List ℕ) (hds : ∀ d ∈ ds, d < 3) (c : ℕ) (hc : c ≤ 1) (L : ListBlank (Fin 2)) : ∃ s, nSteps erdosTernary15 s ⟨st c, Tape.mk' L (ListBlank.append (encR ds) B0)⟩ = some ⟨4, Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0⟩ := ds:List ℕhds:∀ d ∈ ds, d < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 } induction ds generalizing c L with hds:∀ d ∈ [], d < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] c)) L) B0 } rcases (hds:∀ d ∈ [], d < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)⊢ c = 0 ∨ c = 1 All goals completed! 🐙 : c = 0 ∨ c = 1) with rfl | rfl hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:0 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 0, tape := Tape.mk' L (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 0)) L) B0 } All goals completed! 🐙 hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ ∃ s, nSteps erdosTernary15 s { state := st 1, tape := Tape.mk' L (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) L) B0 } hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ nSteps erdosTernary15 2 { state := st 1, tape := Tape.mk' L (ListBlank.append (encR []) B0) } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L)) B0 }hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ nSteps erdosTernary15 3 { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L)) B0 } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) L) B0 } hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ nSteps erdosTernary15 2 { state := st 1, tape := Tape.mk' L (ListBlank.append (encR []) B0) } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L)) B0 } hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ nSteps erdosTernary15 2 { state := 0, tape := Tape.mk' L B0 } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L)) B0 }; All goals completed! 🐙 hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)hc:1 ≤ 1⊢ nSteps erdosTernary15 3 { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L)) B0 } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) L) B0 } All goals completed! 🐙 d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (d :: ds) c)) L) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (d :: ds) c)) L) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) (ListBlank.append (encR ds) B0) } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) }⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (d :: ds) c)) L) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) (ListBlank.append (encR ds) B0) } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) }s₂:ℕhs₂:nSteps erdosTernary15 s₂ { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)) B0 }⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (d :: ds) c)) L) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) (ListBlank.append (encR ds) B0) } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) }s₂:ℕhs₂:nSteps erdosTernary15 s₂ { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)) B0 }e:ListBlank.append (encL (dbl (d :: ds) c)) L = ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (d :: ds) c)) L) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) (ListBlank.append (encR ds) B0) } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) }s₂:ℕhs₂:nSteps erdosTernary15 s₂ { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)) B0 }e:ListBlank.append (encL (dbl (d :: ds) c)) L = ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)⊢ ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)) B0 } d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ c ≤ 1, ∀ (L : ListBlank (Fin 2)), ∃ s, nSteps erdosTernary15 s { state := st c, tape := Tape.mk' L (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds c)) L) B0 }hds:∀ d_1 ∈ d :: ds, d_1 < 3c:ℕhc:c ≤ 1L:ListBlank (Fin 2)hd:d < 3s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st c, tape := { head := hi d, left := L, right := ListBlank.cons (lo d) (ListBlank.append (encR ds) B0) } } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) }s₂:ℕhs₂:nSteps erdosTernary15 s₂ { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)) B0 }e:ListBlank.append (encL (dbl (d :: ds) c)) L = ListBlank.append (encL (dbl ds ((2 * d + c) / 3))) (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L)⊢ nSteps erdosTernary15 s₁ { state := st c, tape := Tape.mk' L (ListBlank.append (encR (d :: ds)) B0) } = some { state := st ((2 * d + c) / 3), tape := Tape.mk' (ListBlank.append [lo ((2 * d + c) % 3), hi ((2 * d + c) % 3)] L) (ListBlank.append (encR ds) B0) } All goals completed! 🐙

Search for a 2 (States 4–6, 10–12)

theorem pair_scan (q : Fin 15) (hq : q = 4 ∨ q = 10) (d : ℕ) (hd : d < 3) (L R : ListBlank (Fin 2)) : nSteps erdosTernary15 2 ⟨q, ⟨lo d, L.cons (hi d), R⟩⟩ = some ⟨if q = 10 ∨ d = 2 then 10 else 4, Tape.mkL L ((R.cons (lo d)).cons (hi d))⟩ := q:Fin 15hq:q = 4 ∨ q = 10d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := q, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := R } } = some { state := if q = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) R)) } d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := R } } = some { state := if 4 = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) R)) }d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 10, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := R } } = some { state := if 10 = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) R)) } d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := R } } = some { state := if 4 = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) R)) }d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 10, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := R } } = some { state := if 10 = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) R)) } rcases (d:ℕhd:d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ d = 0 ∨ d = 1 ∨ d = 2 All goals completed! 🐙 : d = 0 ∨ d = 1 ∨ d = 2) with rfl | rfl | rfl L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := lo 0, left := ListBlank.cons (hi 0) L, right := R } } = some { state := if 4 = 10 ∨ 0 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 0) (ListBlank.cons (lo 0) R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := lo 1, left := ListBlank.cons (hi 1) L, right := R } } = some { state := if 4 = 10 ∨ 1 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 1) (ListBlank.cons (lo 1) R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := lo 2, left := ListBlank.cons (hi 2) L, right := R } } = some { state := if 4 = 10 ∨ 2 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 2) (ListBlank.cons (lo 2) R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3⊢ nSteps erdosTernary15 2 { state := 10, tape := { head := lo 0, left := ListBlank.cons (hi 0) L, right := R } } = some { state := if 10 = 10 ∨ 0 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 0) (ListBlank.cons (lo 0) R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3⊢ nSteps erdosTernary15 2 { state := 10, tape := { head := lo 1, left := ListBlank.cons (hi 1) L, right := R } } = some { state := if 10 = 10 ∨ 1 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 1) (ListBlank.cons (lo 1) R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ nSteps erdosTernary15 2 { state := 10, tape := { head := lo 2, left := ListBlank.cons (hi 2) L, right := R } } = some { state := if 10 = 10 ∨ 2 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi 2) (ListBlank.cons (lo 2) R)) } L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ some { state := 10, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) } = some { state := if True ∨ True then 10 else 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) } L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3⊢ some { state := 4, tape := Tape.mkL L (ListBlank.cons 0 (ListBlank.cons 1 R)) } = some { state := if 4 = 10 ∨ 0 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons 0 (ListBlank.cons 1 R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3⊢ some { state := 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 0 R)) } = some { state := if 4 = 10 ∨ 1 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 0 R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ some { state := 10, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) } = some { state := if 4 = 10 ∨ True then 10 else 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:0 < 3⊢ some { state := 10, tape := Tape.mkL L (ListBlank.cons 0 (ListBlank.cons 1 R)) } = some { state := if True ∨ 0 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons 0 (ListBlank.cons 1 R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:1 < 3⊢ some { state := 10, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 0 R)) } = some { state := if True ∨ 1 = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 0 R)) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)hd:2 < 3⊢ some { state := 10, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) } = some { state := if True ∨ True then 10 else 4, tape := Tape.mkL L (ListBlank.cons 1 (ListBlank.cons 1 R)) } All goals completed! 🐙

Scanning left over ds from its most significant digit finds a 2 iff 2 ∈ ds; after a 2 the machine keeps moving left in the rewind states.

theorem find2_scan (ds : List ℕ) (hds : ∀ d ∈ ds, d < 3) (L R : ListBlank (Fin 2)) : nSteps erdosTernary15 (2 * ds.length) ⟨4, Tape.mkL (ListBlank.append (encL ds) L) R⟩ = some ⟨if 2 ∈ ds then 10 else 4, Tape.mkL L (ListBlank.append (encR ds) R)⟩ := ds:List ℕhds:∀ d ∈ ds, d < 3L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) } induction ds generalizing L with R:ListBlank (Fin 2)hds:∀ d ∈ [], d < 3L:ListBlank (Fin 2)⊢ nSteps erdosTernary15 (2 * [].length) { state := 4, tape := Tape.mkL (ListBlank.append (encL []) L) R } = some { state := if 2 ∈ [] then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR []) R) } All goals completed! 🐙 R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)⊢ nSteps erdosTernary15 (2 * (d :: ds).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (d :: ds)) L) R } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3⊢ nSteps erdosTernary15 (2 * (d :: ds).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (d :: ds)) L) R } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }⊢ nSteps erdosTernary15 (2 * (d :: ds).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (d :: ds)) L) R } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }⊢ nSteps erdosTernary15 2 { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10⊢ nSteps erdosTernary15 2 { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10⊢ nSteps erdosTernary15 2 { state := if 2 ∈ ds then 10 else 4, tape := { head := lo d, left := ListBlank.cons (hi d) L, right := ListBlank.append (encR ds) R } } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10⊢ some { state := if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4, tape := Tape.mkL L (ListBlank.cons (hi d) (ListBlank.cons (lo d) (ListBlank.append (encR ds) R))) } = some { state := if 2 ∈ d :: ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR (d :: ds)) R) } R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4 R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∈ ds⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ ds⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4 R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∈ ds⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ ds⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4 R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ dshd₂:d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ dshd₂:¬d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4 R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∈ dshd₂:d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∈ dshd₂:¬d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ dshd₂:d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4R:ListBlank (Fin 2)d:ℕds:List ℕih:(∀ d ∈ ds, d < 3) → ∀ (L : ListBlank (Fin 2)), nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) L) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL L (ListBlank.append (encR ds) R) }hds:∀ d_1 ∈ d :: ds, d_1 < 3L:ListBlank (Fin 2)hd:d < 3h₁:nSteps erdosTernary15 (2 * ds.length) { state := 4, tape := Tape.mkL (ListBlank.append (encL ds) (ListBlank.append [lo d, hi d] L)) R } = some { state := if 2 ∈ ds then 10 else 4, tape := Tape.mkL (ListBlank.append [lo d, hi d] L) (ListBlank.append (encR ds) R) }hq:(if 2 ∈ ds then 10 else 4) = 4 ∨ (if 2 ∈ ds then 10 else 4) = 10h₂:2 ∉ dshd₂:¬d = 2⊢ (if (if 2 ∈ ds then 10 else 4) = 10 ∨ d = 2 then 10 else 4) = if 2 ∈ d :: ds then 10 else 4 All goals completed! 🐙

The # Cell and the Counter

theorem hash_rewind (c : ℕ) (R : ListBlank (Fin 2)) : nSteps erdosTernary15 3 ⟨10, Tape.mkL (LH c) R⟩ = some ⟨1, Tape.mk' (LH c) R⟩ := c:ℕR:ListBlank (Fin 2)⊢ nSteps erdosTernary15 3 { state := 10, tape := Tape.mkL (LH c) R } = some { state := 1, tape := Tape.mk' (LH c) R } c:ℕR:ListBlank (Fin 2)⊢ nSteps erdosTernary15 3 { state := 10, tape := { head := 0, left := ListBlank.cons 0 (ListBlank.cons (clo c) (ListBlank.cons (chi c) B0)), right := R } } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons (clo c) (ListBlank.cons (chi c) B0)))) R } All goals completed! 🐙theorem hash_find (c : ℕ) (R : ListBlank (Fin 2)) : nSteps erdosTernary15 2 ⟨4, Tape.mkL (LH c) R⟩ = some ⟨13, Tape.mkL (ListBlank.append [clo c, chi c] B0) ((R.cons 0).cons 0)⟩ := c:ℕR:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 4, tape := Tape.mkL (LH c) R } = some { state := 13, tape := Tape.mkL (ListBlank.append [clo c, chi c] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } c:ℕR:ListBlank (Fin 2)⊢ nSteps erdosTernary15 2 { state := 4, tape := { head := 0, left := ListBlank.cons 0 (ListBlank.cons (clo c) (ListBlank.cons (chi c) B0)), right := R } } = some { state := 13, tape := { head := clo c, left := ListBlank.cons (chi c) B0, right := ListBlank.cons 0 (ListBlank.cons 0 R) } } All goals completed! 🐙theorem counter_inc (c : ℕ) (hc : c < 3) (R : ListBlank (Fin 2)) : ∃ s, nSteps erdosTernary15 s ⟨13, Tape.mkL (ListBlank.append [clo c, chi c] B0) ((R.cons 0).cons 0)⟩ = some ⟨1, Tape.mk' (LH (c + 1)) R⟩ := c:ℕhc:c < 3R:ListBlank (Fin 2)⊢ ∃ s, nSteps erdosTernary15 s { state := 13, tape := Tape.mkL (ListBlank.append [clo c, chi c] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (c + 1)) R } rcases (c:ℕhc:c < 3R:ListBlank (Fin 2)⊢ c = 0 ∨ c = 1 ∨ c = 2 All goals completed! 🐙 : c = 0 ∨ c = 1 ∨ c = 2) with rfl | rfl | rfl R:ListBlank (Fin 2)hc:0 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := 13, tape := Tape.mkL (ListBlank.append [clo 0, chi 0] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (0 + 1)) R } exact ⟨3, R:ListBlank (Fin 2)hc:0 < 3⊢ nSteps erdosTernary15 3 { state := 13, tape := Tape.mkL (ListBlank.append [clo 0, chi 0] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (0 + 1)) R } R:ListBlank (Fin 2)hc:0 < 3⊢ nSteps erdosTernary15 3 { state := 13, tape := { head := 0, left := ListBlank.cons 0 B0, right := ListBlank.cons 0 (ListBlank.cons 0 R) } } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 1 (ListBlank.cons 0 B0)))) R }; All goals completed! 🐙⟩ R:ListBlank (Fin 2)hc:1 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := 13, tape := Tape.mkL (ListBlank.append [clo 1, chi 1] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (1 + 1)) R } exact ⟨5, R:ListBlank (Fin 2)hc:1 < 3⊢ nSteps erdosTernary15 5 { state := 13, tape := Tape.mkL (ListBlank.append [clo 1, chi 1] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (1 + 1)) R } R:ListBlank (Fin 2)hc:1 < 3⊢ nSteps erdosTernary15 5 { state := 13, tape := { head := 1, left := ListBlank.cons 0 B0, right := ListBlank.cons 0 (ListBlank.cons 0 R) } } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 1 B0)))) R }; All goals completed! 🐙⟩ R:ListBlank (Fin 2)hc:2 < 3⊢ ∃ s, nSteps erdosTernary15 s { state := 13, tape := Tape.mkL (ListBlank.append [clo 2, chi 2] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (2 + 1)) R } exact ⟨3, R:ListBlank (Fin 2)hc:2 < 3⊢ nSteps erdosTernary15 3 { state := 13, tape := Tape.mkL (ListBlank.append [clo 2, chi 2] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 1, tape := Tape.mk' (LH (2 + 1)) R } R:ListBlank (Fin 2)hc:2 < 3⊢ nSteps erdosTernary15 3 { state := 13, tape := { head := 0, left := ListBlank.cons 1 B0, right := ListBlank.cons 0 (ListBlank.cons 0 R) } } = some { state := 1, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 1 (ListBlank.cons 1 B0)))) R }; All goals completed! 🐙⟩theorem counter_halt (R : ListBlank (Fin 2)) : ∃ cfg, nSteps erdosTernary15 1 ⟨13, Tape.mkL (ListBlank.append [clo 3, chi 3] B0) ((R.cons 0).cons 0)⟩ = some cfg ∧ step erdosTernary15 cfg = none := R:ListBlank (Fin 2)⊢ ∃ cfg, nSteps erdosTernary15 1 { state := 13, tape := Tape.mkL (ListBlank.append [clo 3, chi 3] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some cfg ∧ step erdosTernary15 cfg = none R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 1 { state := 13, tape := Tape.mkL (ListBlank.append [clo 3, chi 3] B0) (ListBlank.cons 0 (ListBlank.cons 0 R)) } = some { state := 14, tape := { head := 1, left := B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 0 R)) } } R:ListBlank (Fin 2)⊢ nSteps erdosTernary15 1 { state := 13, tape := { head := 1, left := ListBlank.cons 1 B0, right := ListBlank.cons 0 (ListBlank.cons 0 R) } } = some { state := 14, tape := { head := 1, left := B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.cons 0 R)) } } All goals completed! 🐙

Stages

theorem stage_scan (c n : ℕ) : ∃ s, nSteps erdosTernary15 s (stageCfg c n) = some ⟨if 2 ∈ pw (n + 1) then 10 else 4, Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0)⟩ := c:ℕn:ℕ⊢ ∃ s, nSteps erdosTernary15 s (stageCfg c n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) } c:ℕn:ℕs₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 0, tape := Tape.mk' (LH c) (ListBlank.append (encR (pw n)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (pw n) 0)) (LH c)) B0 }⊢ ∃ s, nSteps erdosTernary15 s (stageCfg c n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) } c:ℕn:ℕs₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 0, tape := Tape.mk' (LH c) (ListBlank.append (encR (pw n)) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl (pw n) 0)) (LH c)) B0 }h₂:nSteps erdosTernary15 (2 * (pw (n + 1)).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (pw (n + 1))) (LH c)) B0 } = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, nSteps erdosTernary15 s (stageCfg c n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) } All goals completed! 🐙theorem stage_keep (c n : ℕ) (h : 2 ∈ pw (n + 1)) : ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg c (n + 1)) := c:ℕn:ℕh:2 ∈ pw (n + 1)⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg c (n + 1)) c:ℕn:ℕh:2 ∈ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg c (n + 1)) c:ℕn:ℕh:2 ∈ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := 10, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg c (n + 1)) exact ⟨s₁ + 3, c:ℕn:ℕh:2 ∈ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := 10, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ 1 ≤ s₁ + 3 All goals completed! 🐙, nSteps_bind_eq hs₁ (hash_rewind c _)⟩theorem stage_inc (c n : ℕ) (hc : c < 3) (h : 2 ∉ pw (n + 1)) : ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg (c + 1) (n + 1)) := c:ℕn:ℕhc:c < 3h:2 ∉ pw (n + 1)⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg (c + 1) (n + 1)) c:ℕn:ℕhc:c < 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg (c + 1) (n + 1)) c:ℕn:ℕhc:c < 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg (c + 1) (n + 1)) c:ℕn:ℕhc:c < 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }s₃:ℕhs₃:nSteps erdosTernary15 s₃ { state := 13, tape := Tape.mkL (ListBlank.append [clo c, chi c] B0) (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.append (encR (pw (n + 1))) B0))) } = some { state := 1, tape := Tape.mk' (LH (c + 1)) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s, 1 ≤ s ∧ nSteps erdosTernary15 s (stageCfg c n) = some (stageCfg (c + 1) (n + 1)) exact ⟨s₁ + 2 + s₃, c:ℕn:ℕhc:c < 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg c n) = some { state := 4, tape := Tape.mkL (LH c) (ListBlank.append (encR (pw (n + 1))) B0) }s₃:ℕhs₃:nSteps erdosTernary15 s₃ { state := 13, tape := Tape.mkL (ListBlank.append [clo c, chi c] B0) (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.append (encR (pw (n + 1))) B0))) } = some { state := 1, tape := Tape.mk' (LH (c + 1)) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ 1 ≤ s₁ + 2 + s₃ All goals completed! 🐙, nSteps_bind_eq (nSteps_bind_eq hs₁ (hash_find c _)) hs₃⟩theorem stage_halt (n : ℕ) (h : 2 ∉ pw (n + 1)) : ∃ s cfg, nSteps erdosTernary15 s (stageCfg 3 n) = some cfg ∧ step erdosTernary15 cfg = none := n:ℕh:2 ∉ pw (n + 1)⊢ ∃ s cfg, nSteps erdosTernary15 s (stageCfg 3 n) = some cfg ∧ step erdosTernary15 cfg = none n:ℕh:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg 3 n) = some { state := if 2 ∈ pw (n + 1) then 10 else 4, tape := Tape.mkL (LH 3) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s cfg, nSteps erdosTernary15 s (stageCfg 3 n) = some cfg ∧ step erdosTernary15 cfg = none n:ℕh:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg 3 n) = some { state := 4, tape := Tape.mkL (LH 3) (ListBlank.append (encR (pw (n + 1))) B0) }⊢ ∃ s cfg, nSteps erdosTernary15 s (stageCfg 3 n) = some cfg ∧ step erdosTernary15 cfg = none n:ℕh:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ (stageCfg 3 n) = some { state := 4, tape := Tape.mkL (LH 3) (ListBlank.append (encR (pw (n + 1))) B0) }cfg:Cfg 15 2hcfg:nSteps erdosTernary15 1 { state := 13, tape := Tape.mkL (ListBlank.append [clo 3, chi 3] B0) (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.append (encR (pw (n + 1))) B0))) } = some cfghnone:step erdosTernary15 cfg = none⊢ ∃ s cfg, nSteps erdosTernary15 s (stageCfg 3 n) = some cfg ∧ step erdosTernary15 cfg = none All goals completed! 🐙theorem init_eq : (init : Cfg 15 2) = ⟨st 1, Tape.mk' (LH 0) (ListBlank.append (encR []) B0)⟩ := ⊢ init = { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } this:LH 0 = B0⊢ init = { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } this:LH 0 = B0⊢ init = { state := st 1, tape := Tape.mk' B0 (ListBlank.append (encR []) B0) } All goals completed! 🐙theorem boot : ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) := ⊢ ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 }⊢ ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 }h₂:nSteps erdosTernary15 (2 * (dbl [] 1).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 } = some { state := if 2 ∈ dbl [] 1 then 10 else 4, tape := Tape.mkL (LH 0) (ListBlank.append (encR (dbl [] 1)) B0) }⊢ ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 }h₂:nSteps erdosTernary15 (2 * (dbl [] 1).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 } = some { state := 4, tape := Tape.mkL (LH 0) (ListBlank.append (encR (dbl [] 1)) B0) }⊢ ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 }h₂:nSteps erdosTernary15 (2 * (dbl [] 1).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 } = some { state := 4, tape := Tape.mkL (LH 0) (ListBlank.append (encR (dbl [] 1)) B0) }s₃:ℕhs₃:nSteps erdosTernary15 s₃ { state := 13, tape := Tape.mkL (ListBlank.append [clo 0, chi 0] B0) (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.append (encR (dbl [] 1)) B0))) } = some { state := 1, tape := Tape.mk' (LH (0 + 1)) (ListBlank.append (encR (dbl [] 1)) B0) }⊢ ∃ s, nSteps erdosTernary15 s init = some (stageCfg 1 0) s₁:ℕhs₁:nSteps erdosTernary15 s₁ { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 }h₂:nSteps erdosTernary15 (2 * (dbl [] 1).length) { state := 4, tape := Tape.mkL (ListBlank.append (encL (dbl [] 1)) (LH 0)) B0 } = some { state := 4, tape := Tape.mkL (LH 0) (ListBlank.append (encR (dbl [] 1)) B0) }s₃:ℕhs₃:nSteps erdosTernary15 s₃ { state := 13, tape := Tape.mkL (ListBlank.append [clo 0, chi 0] B0) (ListBlank.cons 0 (ListBlank.cons 0 (ListBlank.append (encR (dbl [] 1)) B0))) } = some { state := 1, tape := Tape.mk' (LH (0 + 1)) (ListBlank.append (encR (dbl [] 1)) B0) }⊢ ∃ s, nSteps erdosTernary15 s { state := st 1, tape := Tape.mk' (LH 0) (ListBlank.append (encR []) B0) } = some (stageCfg 1 0) All goals completed! 🐙

Counting Powers Without a Digit 2

theorem reach (n : ℕ) (hn : cnt n ≤ 3) : ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n) := n:ℕhn:cnt n ≤ 3⊢ ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n) induction n with hn:cnt 0 ≤ 3⊢ ∃ s, 0 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt 0) 0) hn:cnt 0 ≤ 3s:ℕhs:nSteps erdosTernary15 s init = some (stageCfg 1 0)⊢ ∃ s, 0 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt 0) 0) All goals completed! 🐙 n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt (n + 1) ≤ 3⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt (n + 1)) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt (n + 1) ≤ 3h:2 ∈ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt (n + 1)) (n + 1))n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt (n + 1) ≤ 3h:2 ∉ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt (n + 1)) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt (n + 1) ≤ 3h:2 ∈ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt (n + 1)) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n ≤ 3h:2 ∈ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n ≤ 3h:2 ∈ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n ≤ 3h:2 ∈ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)s₂:ℕhs₂1:1 ≤ s₂hs₂:nSteps erdosTernary15 s₂ (stageCfg (cnt n) n) = some (stageCfg (cnt n) (n + 1))⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) (n + 1)) exact ⟨s₁ + s₂, n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n ≤ 3h:2 ∈ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)s₂:ℕhs₂1:1 ≤ s₂hs₂:nSteps erdosTernary15 s₂ (stageCfg (cnt n) n) = some (stageCfg (cnt n) (n + 1))⊢ n + 1 ≤ s₁ + s₂ All goals completed! 🐙, nSteps_bind_eq hs₁ hs₂⟩ n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt (n + 1) ≤ 3h:2 ∉ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt (n + 1)) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n + 1 ≤ 3h:2 ∉ pw (n + 1)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n + 1) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n + 1 ≤ 3h:2 ∉ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n + 1) (n + 1)) n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n + 1 ≤ 3h:2 ∉ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)s₂:ℕhs₂1:1 ≤ s₂hs₂:nSteps erdosTernary15 s₂ (stageCfg (cnt n) n) = some (stageCfg (cnt n + 1) (n + 1))⊢ ∃ s, n + 1 ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n + 1) (n + 1)) exact ⟨s₁ + s₂, n:ℕih:cnt n ≤ 3 → ∃ s, n ≤ s ∧ nSteps erdosTernary15 s init = some (stageCfg (cnt n) n)hn:cnt n + 1 ≤ 3h:2 ∉ pw (n + 1)s₁:ℕhs₁n:n ≤ s₁hs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)s₂:ℕhs₂1:1 ≤ s₂hs₂:nSteps erdosTernary15 s₂ (stageCfg (cnt n) n) = some (stageCfg (cnt n + 1) (n + 1))⊢ n + 1 ≤ s₁ + s₂ All goals completed! 🐙, nSteps_bind_eq hs₁ hs₂⟩theorem halt_of (n : ℕ) (h3 : cnt n = 3) (h : 2 ∉ pw (n + 1)) : ∃ s cfg, nSteps erdosTernary15 s init = some cfg ∧ step erdosTernary15 cfg = none := n:ℕh3:cnt n = 3h:2 ∉ pw (n + 1)⊢ ∃ s cfg, nSteps erdosTernary15 s init = some cfg ∧ step erdosTernary15 cfg = none n:ℕh3:cnt n = 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ init = some (stageCfg (cnt n) n)⊢ ∃ s cfg, nSteps erdosTernary15 s init = some cfg ∧ step erdosTernary15 cfg = none n:ℕh3:cnt n = 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ init = some (stageCfg 3 n)⊢ ∃ s cfg, nSteps erdosTernary15 s init = some cfg ∧ step erdosTernary15 cfg = none n:ℕh3:cnt n = 3h:2 ∉ pw (n + 1)s₁:ℕhs₁:nSteps erdosTernary15 s₁ init = some (stageCfg 3 n)s₂:ℕcfg:Cfg 15 2hs₂:nSteps erdosTernary15 s₂ (stageCfg 3 n) = some cfghnone:step erdosTernary15 cfg = none⊢ ∃ s cfg, nSteps erdosTernary15 s init = some cfg ∧ step erdosTernary15 cfg = none All goals completed! 🐙theorem cnt_stays (K : ℕ) (hK : 8 ≤ K) (hall : ∀ m, 8 < m → m ≤ K → 2 ∈ pw m) : cnt K = 3 := K:ℕhK:8 ≤ Khall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m⊢ cnt K = 3 induction K, hK using Nat.le_induction with K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ 8 → 2 ∈ pw m⊢ cnt 8 = 3 All goals completed! 🐙 K✝:ℕK:ℕhK:8 ≤ Kih:(∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m) → cnt K = 3hall:∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m⊢ cnt (K + 1) = 3 K✝:ℕK:ℕhK:8 ≤ Kih:(∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m) → cnt K = 3hall:∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m⊢ cnt K = 3 exact ih fun m hm hmK => hall m hm (K✝:ℕK:ℕhK:8 ≤ Kih:(∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m) → cnt K = 3hall:∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw mm:ℕhm:8 < mhmK:m ≤ K⊢ m ≤ K + 1 All goals completed! 🐙)theorem first_free (n : ℕ) (h8 : 8 < n) (h : 2 ∉ pw n) : ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1) := n:ℕh8:8 < nh:2 ∉ pw n⊢ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1) n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)⊢ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1) rcases key (n - 1) (n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)⊢ 8 ≤ n - 1 All goals completed! 🐙) with h3 | hm n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)h3:cnt (n - 1) = 3⊢ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1) exact ⟨n - 1, h3, n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)h3:cnt (n - 1) = 3⊢ 2 ∉ pw (n - 1 + 1) rwa [Nat.sub_add_cancel (n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)h3:cnt (n - 1) = 3⊢ 1 ≤ n All goals completed! 🐙)]⟩ n:ℕh8:8 < nh:2 ∉ pw nkey:∀ (j : ℕ), 8 ≤ j → cnt j = 3 ∨ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)hm:∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1)⊢ ∃ m, cnt m = 3 ∧ 2 ∉ pw (m + 1) All goals completed! 🐙theorem free_or_none (K : ℕ) : (∃ m, 8 < m ∧ m ≤ K ∧ 2 ∉ pw m) ∨ (∀ m, 8 < m → m ≤ K → 2 ∈ pw m) := K:ℕ⊢ (∃ m, 8 < m ∧ m ≤ K ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m induction K with ⊢ (∃ m, 8 < m ∧ m ≤ 0 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ 0 → 2 ∈ pw m exact Or.inr fun m hm hmK => absurd hmK (m:ℕhm:8 < mhmK:m ≤ 0⊢ ¬m ≤ 0 All goals completed! 🐙) K:ℕih:(∃ m, 8 < m ∧ m ≤ K ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕm:ℕhm:8 < mhmK:m ≤ Khfree:2 ∉ pw m⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw mK:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕm:ℕhm:8 < mhmK:m ≤ Khfree:2 ∉ pw m⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m exact Or.inl ⟨m, hm, K:ℕm:ℕhm:8 < mhmK:m ≤ Khfree:2 ∉ pw m⊢ m ≤ K + 1 All goals completed! 🐙, hfree⟩ K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw m⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw mK:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)m:ℕhm:8 < mhmK:m ≤ K + 1⊢ 2 ∈ pw m rcases (K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)m:ℕhm:8 < mhmK:m ≤ K + 1⊢ m ≤ K ∨ m = K + 1 All goals completed! 🐙 : m ≤ K ∨ m = K + 1) with hmK' | rfl K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)m:ℕhm:8 < mhmK:m ≤ K + 1hmK':m ≤ K⊢ 2 ∈ pw m All goals completed! 🐙 K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∈ pw (K + 1)hm:8 < K + 1hmK:K + 1 ≤ K + 1⊢ 2 ∈ pw (K + 1) All goals completed! 🐙 K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)hK:8 < K + 1⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw mK:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)hK:¬8 < K + 1⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)hK:8 < K + 1⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m All goals completed! 🐙 K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)hK:¬8 < K + 1⊢ (∃ m, 8 < m ∧ m ≤ K + 1 ∧ 2 ∉ pw m) ∨ ∀ (m : ℕ), 8 < m → m ≤ K + 1 → 2 ∈ pw m exact Or.inr fun m hm hmK => absurd hm (K:ℕhall:∀ (m : ℕ), 8 < m → m ≤ K → 2 ∈ pw mh:2 ∉ pw (K + 1)hK:¬8 < K + 1m:ℕhm:8 < mhmK:m ≤ K + 1⊢ ¬8 < m All goals completed! 🐙)

Halting Equivalence

The 15-state machine erdosTernary15 (erdos_ternary_15) halts on the blank tape if and only if some power 2 ^ n with n > 8 has no digit 2 in base 3, with the digits computed by pw.

theorem halts_erdosTernary15_iff_exists_free : ConjectureMachines.Halts erdosTernary15 ↔ ∃ n, 8 < n ∧ 2 ∉ pw n := ⊢ ConjectureMachines.Halts erdosTernary15 ↔ ∃ n, 8 < n ∧ 2 ∉ pw n ⊢ (eval (step erdosTernary15) init).Dom ↔ ∃ n, 8 < n ∧ 2 ∉ pw n ⊢ (eval (step erdosTernary15) init).Dom → ∃ n, 8 < n ∧ 2 ∉ pw n⊢ (∃ n, 8 < n ∧ 2 ∉ pw n) → (eval (step erdosTernary15) init).Dom ⊢ (eval (step erdosTernary15) init).Dom → ∃ n, 8 < n ∧ 2 ∉ pw n hdom:(eval (step erdosTernary15) init).Dom⊢ ∃ n, 8 < n ∧ 2 ∉ pw n hdom:∃ y, y ∈ eval (step erdosTernary15) init⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hb:b ∈ eval (step erdosTernary15) init⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hb:Reaches (step erdosTernary15) init b ∧ step erdosTernary15 b = none⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = none⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some b⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bm:ℕhm:8 < mhfree:2 ∉ pw m⊢ ∃ n, 8 < n ∧ 2 ∉ pw nb:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bhall:∀ (m : ℕ), 8 < m → m ≤ k + 9 → 2 ∈ pw m⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bm:ℕhm:8 < mhfree:2 ∉ pw m⊢ ∃ n, 8 < n ∧ 2 ∉ pw n All goals completed! 🐙 b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bhall:∀ (m : ℕ), 8 < m → m ≤ k + 9 → 2 ∈ pw m⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bhall:∀ (m : ℕ), 8 < m → m ≤ k + 9 → 2 ∈ pw mh3:cnt (k + 9) = 3⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bhall:∀ (m : ℕ), 8 < m → m ≤ k + 9 → 2 ∈ pw mh3:cnt (k + 9) = 3s:ℕhks:k + 9 ≤ shs:nSteps erdosTernary15 s init = some (stageCfg (cnt (k + 9)) (k + 9))⊢ ∃ n, 8 < n ∧ 2 ∉ pw n b:Cfg 15 2hreach:Reaches (step erdosTernary15) init bhnone:step erdosTernary15 b = nonek:ℕhk:nSteps erdosTernary15 k init = some bhall:∀ (m : ℕ), 8 < m → m ≤ k + 9 → 2 ∈ pw mh3:cnt (k + 9) = 3s:ℕhks:k + 9 ≤ shs:none = some (stageCfg (cnt (k + 9)) (k + 9))⊢ ∃ n, 8 < n ∧ 2 ∉ pw n All goals completed! 🐙 ⊢ (∃ n, 8 < n ∧ 2 ∉ pw n) → (eval (step erdosTernary15) init).Dom n:ℕh8:8 < nhfree:2 ∉ pw n⊢ (eval (step erdosTernary15) init).Dom n:ℕh8:8 < nhfree:2 ∉ pw nm:ℕh3:cnt m = 3hm:2 ∉ pw (m + 1)⊢ (eval (step erdosTernary15) init).Dom n:ℕh8:8 < nhfree:2 ∉ pw nm:ℕh3:cnt m = 3hm:2 ∉ pw (m + 1)s:ℕcfg:Cfg 15 2hs:nSteps erdosTernary15 s init = some cfghnone:step erdosTernary15 cfg = none⊢ (eval (step erdosTernary15) init).Dom n:ℕh8:8 < nhfree:2 ∉ pw nm:ℕh3:cnt m = 3hm:2 ∉ pw (m + 1)s:ℕcfg:Cfg 15 2hs:nSteps erdosTernary15 s init = some cfghnone:step erdosTernary15 cfg = none⊢ ∃ y, y ∈ eval (step erdosTernary15) init All goals completed! 🐙end ConjectureMachines.ErdosTernary15