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 public import BusyBeaver.Defs meta import Lean.Elab.Term

Bridge Between ConjectureMachines and BusyBeaver (BusyBeaver.Bridge)

Connects ConjectureMachines.Machine states symbols to BusyBeaver.Machine (Fin symbols) (Fin states):

    load_rle_rows% / load_rle_machine% — Elaboration-time parsers for standard bbchallenge.org RLE transition strings (such as "1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA"), complementing load_machine_rows% for .txt tables.

    ConjectureMachines.Machine.toBB / ConjectureMachines.Cfg.toBB — Canonical embedding of finite Turing machines and configurations into BusyBeaver.

    isHalt_toBB_iff_halts & isNotHalt_toBB_iff_not_halts — Halting equivalence between BusyBeaver.IsHalt / BusyBeaver.IsNotHalt on M.toBB and ConjectureMachines.Halts M.

meta sectionnamespace BusyBeaveropen Lean Elab Termprivate def parseRleBlock (numStates numSymbols : Nat) (block : String) : TermElabM (TSyntax `term) := do let chars := block.toList if numSymbols == 0 || chars.length != 3 * numSymbols then throwError "Invalid RLE state block length: {block}" let mut cellStxs : Array (TSyntax `term) := #[] for i in [:numSymbols] do let wChar := chars[3 * i]! let dChar := chars[3 * i + 1]! let sChar := chars[3 * i + 2]! if (wChar == '-' && dChar == '-' && sChar == '-') || (wChar == 'H' && dChar == 'H' && sChar == 'H') then cellStxs := cellStxs.push (← `(none)) else if !wChar.isDigit then throwError "Invalid symbol character '{wChar}' in RLE block: {block}" if wChar.toNat - '0'.toNat >= numSymbols then throwError "Out-of-range symbol in RLE block: {block}" let wLit := Syntax.mkNumLit (String.singleton wChar) let dirStx ← match dChar with | 'L' => `(Turing.Dir.left) | 'R' => `(Turing.Dir.right) | _ => throwError "Invalid direction '{dChar}' in RLE block: {block}" if sChar < 'A' || sChar > 'Z' then throwError "Invalid state letter '{sChar}' in RLE block: {block}" let stateIdx := sChar.toNat - 'A'.toNat if stateIdx >= numStates then throwError "Out-of-range state in RLE block: {block}" let sLit := Syntax.mkNumLit (toString stateIdx) cellStxs := cellStxs.push (← `(some ($wLit, $dirStx, $sLit))) `([$cellStxs,*])private def parseRleRows (rle : String) : TermElabM (TSyntax `term) := do let blocks := rle.trimAscii.toString.splitOn "_" let numSymbols := (blocks.headD "").length / 3 let mut rowStxs : Array (TSyntax `term) := #[] for b in blocks do rowStxs := rowStxs.push (← parseRleBlock blocks.length numSymbols b) let states := Syntax.mkNumLit (toString blocks.length) let symbols := Syntax.mkNumLit (toString numSymbols) `(([$rowStxs,*] : List (List (Option (Fin $symbols × Turing.Dir × Fin $states)))))

Elaboration-time parser turning a standard bbchallenge.org RLE string (e.g. "1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA") into transition rows for ConjectureMachines.Machine.ofRows.

elab "load_rle_rows% " rle:str : term <= expectedType? => do elabTerm (← parseRleRows rle.getString) expectedType?

Elaboration-time parser turning a standard bbchallenge.org RLE string directly into a ConjectureMachines.Machine.

elab "load_rle_machine% " rle:str : term <= expectedType? => do elabTerm (← `(ConjectureMachines.Machine.ofRows $(← parseRleRows rle.getString))) expectedType?end BusyBeaverend@[expose] public sectionnamespace BusyBeaver

Canonical NeZero 2 instance for (states, 2) Turing machines.

instance (priority := high) instNeZeroTwo : @NeZero ℕ Zero.ofOfNat0 2 := Nat.instNeZeroSucc

Canonical NeZero 3 instance for (3, 3) Turing machines.

instance (priority := high) instNeZeroThree : @NeZero ℕ Zero.ofOfNat0 3 := Nat.instNeZeroSucc

Canonical NeZero 6 instance for (6, symbols) Turing machines.

instance (priority := high) instNeZeroSix : @NeZero ℕ Zero.ofOfNat0 6 := Nat.instNeZeroSuccend BusyBeavernamespace ConjectureMachinesopen Relation StateTransitionvariable {states symbols : ℕ} [NeZero states] [NeZero symbols]

Embed ConjectureMachines.ListBlank Γ into Mathlib's Turing.ListBlank Γ.

def ListBlank.toTuring {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : Turing.ListBlank Γ := Turing.ListBlank.mk l.toListprivate theorem ListBlank.not_isTrimmed_replicate {Γ : Type*} [Inhabited Γ] : ∀ i : ℕ, 1 ≤ i → ¬ ListBlank.IsTrimmed (List.replicate i (default : Γ)) | 0, h => absurd h (Nat.not_succ_le_zero 0) | 1, _ => fun ht => ht rfl | i + 2, _ => fun ht => ListBlank.not_isTrimmed_replicate (i + 1) (Nat.succ_pos i) htprivate theorem ListBlank.eq_of_isTrimmed_blankExtends {Γ : Type*} [Inhabited Γ] : ∀ {xs ys : List Γ}, ListBlank.IsTrimmed xs → ListBlank.IsTrimmed ys → Turing.BlankExtends xs ys → xs = ys | [], [], _, _, _ => rfl Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]i:ℕhi:[b] = [] ++ List.replicate i default⊢ [] = [b] Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]i:ℕhi:[b] = [] ++ List.replicate i default⊢ [] = [b] cases i with Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]hi:[b] = [] ++ List.replicate 0 default⊢ [] = [b] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]j:ℕhi:[b] = [] ++ List.replicate (j + 1) default⊢ [] = [b] Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]j:ℕhi:[b] = default :: List.replicate j default⊢ [] = [b] Γ:Type u_1inst✝:Inhabited Γb:Γx✝:IsTrimmed []hy:IsTrimmed [b]j:ℕhb:b = defaulttail_eq✝:[] = List.replicate j default⊢ [] = [b] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γb:Γc:Γys:List Γx✝:IsTrimmed []hy:IsTrimmed (b :: c :: ys)i:ℕhi:b :: c :: ys = [] ++ List.replicate i default⊢ [] = b :: c :: ys Γ:Type u_1inst✝:Inhabited Γb:Γc:Γys:List Γx✝:IsTrimmed []hy:IsTrimmed (b :: c :: ys)i:ℕhi:b :: c :: ys = [] ++ List.replicate i default⊢ [] = b :: c :: ys cases i with Γ:Type u_1inst✝:Inhabited Γb:Γc:Γys:List Γx✝:IsTrimmed []hy:IsTrimmed (b :: c :: ys)hi:b :: c :: ys = [] ++ List.replicate 0 default⊢ [] = b :: c :: ys All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γb:Γc:Γys:List Γx✝:IsTrimmed []hy:IsTrimmed (b :: c :: ys)j:ℕhi:b :: c :: ys = [] ++ List.replicate (j + 1) default⊢ [] = b :: c :: ys Γ:Type u_1inst✝:Inhabited Γb:Γc:Γys:List Γx✝:IsTrimmed []hy:IsTrimmed (b :: c :: ys)j:ℕhi:b :: c :: ys = List.replicate (j + 1) default⊢ [] = b :: c :: ys All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γhead✝:Γtail✝:List Γx✝¹:IsTrimmed (head✝ :: tail✝)x✝:IsTrimmed []w✝:ℕhi:[] = head✝ :: tail✝ ++ List.replicate w✝ default⊢ head✝ :: tail✝ = [] Γ:Type u_1inst✝:Inhabited Γhead✝:Γtail✝:List Γx✝¹:IsTrimmed (head✝ :: tail✝)x✝:IsTrimmed []w✝:ℕhi:[] = head✝ :: tail✝ ++ List.replicate w✝ default⊢ head✝ :: tail✝ = [] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]i:ℕhi:[b] = [a] ++ List.replicate i default⊢ [a] = [b] Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]i:ℕhi:[b] = [a] ++ List.replicate i default⊢ [a] = [b] cases i with Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]hi:[b] = [a] ++ List.replicate 0 default⊢ [a] = [b] Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]hi:[b] = [a]⊢ [a] = [b] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]j:ℕhi:[b] = [a] ++ List.replicate (j + 1) default⊢ [a] = [b] Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]j:ℕhi:[b] = a :: default :: List.replicate j default⊢ [a] = [b] Γ:Type u_1inst✝:Inhabited Γa:Γb:Γx✝¹:IsTrimmed [a]x✝:IsTrimmed [b]j:ℕhead_eq✝:b = ahnil:[] = default :: List.replicate j default⊢ [a] = [b] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)i:ℕhi:head✝ :: c :: ys = [head✝¹] ++ List.replicate i default⊢ [head✝¹] = head✝ :: c :: ys Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)i:ℕhi:head✝ :: c :: ys = [head✝¹] ++ List.replicate i default⊢ [head✝¹] = head✝ :: c :: ys Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)i:ℕhi:head✝ :: c :: ys = head✝¹ :: List.replicate i default⊢ [head✝¹] = head✝ :: c :: ys Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)i:ℕhead_eq✝:head✝ = head✝¹htl:c :: ys = List.replicate i default⊢ [head✝¹] = head✝ :: c :: ys cases i with Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)head_eq✝:head✝ = head✝¹htl:c :: ys = List.replicate 0 default⊢ [head✝¹] = head✝ :: c :: ys All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γhead✝:Γc:Γys:List Γx✝:IsTrimmed [head✝¹]hy:IsTrimmed (head✝ :: c :: ys)head_eq✝:head✝ = head✝¹j:ℕhtl:c :: ys = List.replicate (j + 1) default⊢ [head✝¹] = head✝ :: c :: ys All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γhead✝²:Γhead✝¹:Γtail✝:List Γhead✝:Γx✝¹:IsTrimmed (head✝² :: head✝¹ :: tail✝)x✝:IsTrimmed [head✝]w✝:ℕhi:[head✝] = head✝² :: head✝¹ :: tail✝ ++ List.replicate w✝ default⊢ head✝² :: head✝¹ :: tail✝ = [head✝] Γ:Type u_1inst✝:Inhabited Γhead✝²:Γhead✝¹:Γtail✝:List Γhead✝:Γx✝¹:IsTrimmed (head✝² :: head✝¹ :: tail✝)x✝:IsTrimmed [head✝]w✝:ℕhi:[head✝] = head✝² :: head✝¹ :: tail✝ ++ List.replicate w✝ default⊢ head✝² :: head✝¹ :: tail✝ = [head✝] Γ:Type u_1inst✝:Inhabited Γhead✝²:Γhead✝¹:Γtail✝:List Γhead✝:Γx✝¹:IsTrimmed (head✝² :: head✝¹ :: tail✝)x✝:IsTrimmed [head✝]w✝:ℕhead_eq✝:head✝ = head✝²htl:[] = (head✝¹ :: tail✝).append (List.replicate w✝ default)⊢ head✝² :: head✝¹ :: tail✝ = [head✝] All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γhead✝:Γb:Γxs:List Γc:Γd:Γys:List Γhx:IsTrimmed (head✝ :: b :: xs)hy:IsTrimmed (c :: d :: ys)i:ℕhi:c :: d :: ys = head✝ :: b :: xs ++ List.replicate i default⊢ head✝ :: b :: xs = c :: d :: ys Γ:Type u_1inst✝:Inhabited Γhead✝:Γb:Γxs:List Γc:Γd:Γys:List Γhx:IsTrimmed (head✝ :: b :: xs)hy:IsTrimmed (c :: d :: ys)i:ℕhi:c :: d :: ys = head✝ :: b :: xs ++ List.replicate i default⊢ head✝ :: b :: xs = c :: d :: ys Γ:Type u_1inst✝:Inhabited Γhead✝:Γb:Γxs:List Γc:Γd:Γys:List Γhx:IsTrimmed (head✝ :: b :: xs)hy:IsTrimmed (c :: d :: ys)i:ℕhac:c = head✝htl:d :: ys = (b :: xs).append (List.replicate i default)⊢ head✝ :: b :: xs = c :: d :: ys Γ:Type u_1inst✝:Inhabited Γhead✝:Γb:Γxs:List Γc:Γd:Γys:List Γhx:IsTrimmed (head✝ :: b :: xs)hy:IsTrimmed (c :: d :: ys)i:ℕhac:c = head✝htl:d :: ys = (b :: xs).append (List.replicate i default)⊢ c :: b :: xs = c :: d :: ys All goals completed! 🐙@[simp] theorem ListBlank.toTuring_inj {Γ : Type*} [Inhabited Γ] {l₁ l₂ : ListBlank Γ} : l₁.toTuring = l₂.toTuring ↔ l₁ = l₂ := Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring ↔ l₁ = l₂ Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring → l₁ = l₂Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁ = l₂ → l₁.toTuring = l₂.toTuring Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring → l₁ = l₂ Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuring⊢ l₁ = l₂ Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuring⊢ l₁.toList = l₂.toList Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₁:Turing.BlankExtends l₁.toList l₂.toList⊢ l₁.toList = l₂.toListΓ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₂:Turing.BlankExtends l₂.toList l₁.toList⊢ l₁.toList = l₂.toList Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₁:Turing.BlankExtends l₁.toList l₂.toList⊢ l₁.toList = l₂.toList All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₂:Turing.BlankExtends l₂.toList l₁.toList⊢ l₁.toList = l₂.toList All goals completed! 🐙 Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁ = l₂ → l₁.toTuring = l₂.toTuring All goals completed! 🐙@[simp] theorem ListBlank.toTuring_head {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : l.toTuring.head = l.head := rfl@[simp] theorem ListBlank.toTuring_tail {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : l.toTuring.tail = l.tail.toTuring := rfl@[simp] theorem ListBlank.toTuring_cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) (l : ListBlank Γ) : l.toTuring.cons a = (l.cons a).toTuring := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ Turing.ListBlank.cons a l.toTuring = (cons a l).toTuring Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.cons a { toList := [], isTrimmed := isTrimmed✝ }.toTuring = (cons a { toList := [], isTrimmed := isTrimmed✝ }).toTuringΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ Turing.ListBlank.cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }.toTuring = (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).toTuring Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.cons a { toList := [], isTrimmed := isTrimmed✝ }.toTuring = (cons a { toList := [], isTrimmed := isTrimmed✝ }).toTuring Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a])Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:¬a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [default] = Turing.ListBlank.mk [] All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:¬a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a]) All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ Turing.ListBlank.cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }.toTuring = (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).toTuring All goals completed! 🐙

Embed ConjectureMachines.Tape Γ into Mathlib's Turing.Tape Γ.

def Tape.toTuring {Γ : Type*} [Inhabited Γ] (T : Tape Γ) : Turing.Tape Γ := ⟨T.head, T.left.toTuring, T.right.toTuring⟩@[simp] theorem Tape.toTuring_inj {Γ : Type*} [Inhabited Γ] {T₁ T₂ : Tape Γ} : T₁.toTuring = T₂.toTuring ↔ T₁ = T₂ := Γ:Type u_1inst✝:Inhabited ΓT₁:Tape ΓT₂:Tape Γ⊢ T₁.toTuring = T₂.toTuring ↔ T₁ = T₂ Γ:Type u_1inst✝:Inhabited ΓT₂:Tape Γhead✝:Γleft✝:ListBlank Γright✝:ListBlank Γ⊢ { head := head✝, left := left✝, right := right✝ }.toTuring = T₂.toTuring ↔ { head := head✝, left := left✝, right := right✝ } = T₂; Γ:Type u_1inst✝:Inhabited Γhead✝¹:Γleft✝¹:ListBlank Γright✝¹:ListBlank Γhead✝:Γleft✝:ListBlank Γright✝:ListBlank Γ⊢ { head := head✝¹, left := left✝¹, right := right✝¹ }.toTuring = { head := head✝, left := left✝, right := right✝ }.toTuring ↔ { head := head✝¹, left := left✝¹, right := right✝¹ } = { head := head✝, left := left✝, right := right✝ }; All goals completed! 🐙

Convert a ConjectureMachines.Machine states symbols into a BusyBeaver.Machine (Fin symbols) (Fin states).

def Machine.toBB (M : Machine states symbols) : BusyBeaver.Machine (Fin symbols) (Fin states) := fun q s => (M.transition q s).map fun (a, d, q') => (some q', BusyBeaver.Stmt.write a d)

Convert a ConjectureMachines.Cfg states symbols into a BusyBeaver.Cfg (Fin symbols) (Fin states).

def Cfg.toBB (c : Cfg states symbols) : BusyBeaver.Cfg (Fin symbols) (Fin states) := ⟨some c.state, c.tape.toTuring⟩omit [NeZero states] in @[simp] theorem Cfg.toBB_inj {c₁ c₂ : Cfg states symbols} : c₁.toBB = c₂.toBB ↔ c₁ = c₂ := states:ℕsymbols:ℕinst✝:NeZero symbolsc₁:Cfg states symbolsc₂:Cfg states symbols⊢ c₁.toBB = c₂.toBB ↔ c₁ = c₂ states:ℕsymbols:ℕinst✝:NeZero symbolsc₂:Cfg states symbolsstate✝:Fin statestape✝:Tape (Fin symbols)⊢ { state := state✝, tape := tape✝ }.toBB = c₂.toBB ↔ { state := state✝, tape := tape✝ } = c₂; states:ℕsymbols:ℕinst✝:NeZero symbolsstate✝¹:Fin statestape✝¹:Tape (Fin symbols)state✝:Fin statestape✝:Tape (Fin symbols)⊢ { state := state✝¹, tape := tape✝¹ }.toBB = { state := state✝, tape := tape✝ }.toBB ↔ { state := state✝¹, tape := tape✝¹ } = { state := state✝, tape := tape✝ }; All goals completed! 🐙@[simp] theorem init_toBB : (BusyBeaver.init ([] : List (Fin symbols)) : BusyBeaver.Cfg (Fin symbols) (Fin states)) = (ConjectureMachines.init : Cfg states symbols).toBB := rfl@[simp] theorem step_toBB (M : Machine states symbols) (c : Cfg states symbols) : BusyBeaver.step M.toBB c.toBB = (ConjectureMachines.step M c).map Cfg.toBB := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ BusyBeaver.step M.toBB c.toBB = Option.map Cfg.toBB (step M c) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)⊢ BusyBeaver.step M.toBB { state := q, tape := T }.toBB = Option.map Cfg.toBB (step M { state := q, tape := T }) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (M.transition q T.head) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (M.transition q T.head) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) none = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) nonestates:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsd:Dirq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, d, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, d, q')) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) none = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) none All goals completed! 🐙 states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsd:Dirq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, d, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, d, q')) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, Turing.Dir.left, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, Turing.Dir.left, q'))states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, Turing.Dir.right, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, Turing.Dir.right, q')) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, Turing.Dir.left, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, Turing.Dir.left, q'))states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsq:Fin statesT:Tape (Fin symbols)a:Fin symbolsq':Fin states⊢ Option.map ((fun x ↦ { q := x.1, tape := Turing.Tape.move x.2.dir (Turing.Tape.write x.2.symbol { head := T.head, left := T.left.toTuring, right := T.right.toTuring }) }) ∘ fun x ↦ (some x.2.2, { symbol := x.1, dir := x.2.1 })) (some (a, Turing.Dir.right, q')) = Option.map (Cfg.toBB ∘ fun x ↦ { state := x.2.2, tape := Tape.move x.2.1 (Tape.write x.1 T) }) (some (a, Turing.Dir.right, q')) All goals completed! 🐙theorem step_toBB_isNone_iff (M : Machine states symbols) (c : Cfg states symbols) : (BusyBeaver.step M.toBB c.toBB).isNone ↔ ConjectureMachines.step M c = none := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ (BusyBeaver.step M.toBB c.toBB).isNone = true ↔ step M c = none All goals completed! 🐙theorem step_toBB_isSome_iff (M : Machine states symbols) (c : Cfg states symbols) : (BusyBeaver.step M.toBB c.toBB).isSome ↔ (ConjectureMachines.step M c).isSome := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ (BusyBeaver.step M.toBB c.toBB).isSome = true ↔ (step M c).isSome = true All goals completed! 🐙private theorem iterate_bind_none {α : Type*} (f : α → Option α) (n : ℕ) : (fun x : Option α => x.bind f)^[n] none = none := α:Type u_1f:α → Option αn:ℕ⊢ (fun x ↦ x.bind f)^[n] none = none induction n with α:Type u_1f:α → Option α⊢ (fun x ↦ x.bind f)^[0] none = none All goals completed! 🐙 α:Type u_1f:α → Option αn:ℕih:(fun x ↦ x.bind f)^[n] none = none⊢ (fun x ↦ x.bind f)^[n + 1] none = none All goals completed! 🐙private theorem iterate_bind_toBB (M : Machine states symbols) (n : ℕ) (x : Option (Cfg states symbols)) : (fun y : Option (BusyBeaver.Cfg (Fin symbols) (Fin states)) => y.bind (BusyBeaver.step M.toBB))^[n] (x.map Cfg.toBB) = ((fun y : Option (Cfg states symbols) => y.bind (ConjectureMachines.step M))^[n] x).map Cfg.toBB := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕx:Option (Cfg states symbols)⊢ (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] x) induction n generalizing x with states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsx:Option (Cfg states symbols)⊢ (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[0] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[0] x) All goals completed! 🐙 states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕih:∀ (x : Option (Cfg states symbols)), (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] x)x:Option (Cfg states symbols)⊢ (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n + 1] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n + 1] x) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕih:∀ (x : Option (Cfg states symbols)), (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] x)x:Option (Cfg states symbols)⊢ (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] ((Option.map Cfg.toBB x).bind (BusyBeaver.step M.toBB)) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (x.bind (step M))) states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕih:∀ (x : Option (Cfg states symbols)), (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] (Option.map Cfg.toBB x) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] x)x:Option (Cfg states symbols)hbind:(Option.map Cfg.toBB x).bind (BusyBeaver.step M.toBB) = Option.map Cfg.toBB (x.bind (step M))⊢ (fun y ↦ y.bind (BusyBeaver.step M.toBB))^[n] ((Option.map Cfg.toBB x).bind (BusyBeaver.step M.toBB)) = Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (x.bind (step M))) All goals completed! 🐙theorem multiStep_toBB (M : Machine states symbols) (c : Cfg states symbols) (n : ℕ) : BusyBeaver.multiStep M.toBB c.toBB n = ((fun y : Option (Cfg states symbols) => y.bind (ConjectureMachines.step M))^[n] (some c)).map Cfg.toBB := iterate_bind_toBB M n (some c)omit [NeZero states] in private theorem reaches_iff_exists_iterate (M : Machine states symbols) (c c' : Cfg states symbols) : StateTransition.Reaches (ConjectureMachines.step M) c c' ↔ ∃ n : ℕ, (fun y : Option (Cfg states symbols) => y.bind (ConjectureMachines.step M))^[n] (some c) = some c' := states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbols⊢ Reaches (step M) c c' ↔ ∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbols⊢ Reaches (step M) c c' → ∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c'states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbols⊢ (∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c') → Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbols⊢ Reaches (step M) c c' → ∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'⊢ ∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'⊢ ∃ n, (fun y ↦ y.bind (step M))^[n] (some c') = some c'states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'⊢ ∀ {a c : Cfg states symbols}, c ∈ step M a → ReflTransGen (fun a b ↦ b ∈ step M a) c c' → (∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c') → ∃ n, (fun y ↦ y.bind (step M))^[n] (some a) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'⊢ ∃ n, (fun y ↦ y.bind (step M))^[n] (some c') = some c' All goals completed! 🐙 states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'⊢ ∀ {a c : Cfg states symbols}, c ∈ step M a → ReflTransGen (fun a b ↦ b ∈ step M a) c c' → (∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c') → ∃ n, (fun y ↦ y.bind (step M))^[n] (some a) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'a:Cfg states symbolsb:Cfg states symbolshab:b ∈ step M ah✝:ReflTransGen (fun a b ↦ b ∈ step M a) b c'n:ℕhn:(fun y ↦ y.bind (step M))^[n] (some b) = some c'⊢ ∃ n, (fun y ↦ y.bind (step M))^[n] (some a) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'a:Cfg states symbolsb:Cfg states symbolshab:b ∈ step M ah✝:ReflTransGen (fun a b ↦ b ∈ step M a) b c'n:ℕhn:(fun y ↦ y.bind (step M))^[n] (some b) = some c'⊢ (fun y ↦ y.bind (step M))^[n + 1] (some a) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'a:Cfg states symbolsb:Cfg states symbolshab:b ∈ step M ah✝:ReflTransGen (fun a b ↦ b ∈ step M a) b c'n:ℕhn:(fun y ↦ y.bind (step M))^[n] (some b) = some c'⊢ (fun y ↦ y.bind (step M))^[n] ((some a).bind (step M)) = some c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsh:Reaches (step M) c c'a:Cfg states symbolsb:Cfg states symbolsh✝:ReflTransGen (fun a b ↦ b ∈ step M a) b c'n:ℕhn:(fun y ↦ y.bind (step M))^[n] (some b) = some c'hab:step M a = some b⊢ (fun y ↦ y.bind (step M))^[n] ((some a).bind (step M)) = some c' All goals completed! 🐙 states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbols⊢ (∃ n, (fun y ↦ y.bind (step M))^[n] (some c) = some c') → Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbolsc':Cfg states symbolsn:ℕhn:(fun y ↦ y.bind (step M))^[n] (some c) = some c'⊢ Reaches (step M) c c' induction n generalizing c with states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsc:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[0] (some c) = some c'⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsc:Cfg states symbolsh:c = c'⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ Reaches (step M) c c All goals completed! 🐙 states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n + 1] (some c) = some c'⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] ((some c).bind (step M)) = some c'⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (step M c) = some c'⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (step M c) = some c'hstep:step M c = none⊢ Reaches (step M) c c'states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (step M c) = some c'c₁:Cfg states symbolshstep:step M c = some c₁⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (step M c) = some c'hstep:step M c = none⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:none = some c'hstep:step M c = none⊢ Reaches (step M) c c' All goals completed! 🐙 states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (step M c) = some c'c₁:Cfg states symbolshstep:step M c = some c₁⊢ Reaches (step M) c c' states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsn:ℕih:∀ (c : Cfg states symbols), (fun y ↦ y.bind (step M))^[n] (some c) = some c' → Reaches (step M) c c'c:Cfg states symbolsc₁:Cfg states symbolshn:(fun y ↦ y.bind (step M))^[n] (some c₁) = some c'hstep:step M c = some c₁⊢ Reaches (step M) c c' All goals completed! 🐙

A ConjectureMachines.Machine halts from init if and only if its BusyBeaver image satisfies BusyBeaver.IsHalt.

theorem isHalt_toBB_iff_halts (M : Machine states symbols) : BusyBeaver.IsHalt M.toBB ↔ ConjectureMachines.Halts M := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ BusyBeaver.IsHalt M.toBB ↔ ConjectureMachines.Halts M states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) ↔ (eval (step M) init).Dom states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) ↔ ∃ y, y ∈ eval (step M) init states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) ↔ ∃ y, Reaches (step M) init y ∧ step M y = none states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) → ∃ y, Reaches (step M) init y ∧ step M y = nonestates:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ y, Reaches (step M) init y ∧ step M y = none) → ∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) → ∃ y, Reaches (step M) init y ∧ step M y = none states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolscfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hnone:(BusyBeaver.step M.toBB cfg).isNone = truen:ℕhms:BusyBeaver.multiStep M.toBB init.toBB n = some cfg⊢ ∃ y, Reaches (step M) init y ∧ step M y = none states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolscfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hnone:(BusyBeaver.step M.toBB cfg).isNone = truen:ℕhms:∃ a, (fun y ↦ y.bind (step M))^[n] (some init) = some a ∧ a.toBB = cfg⊢ ∃ y, Reaches (step M) init y ∧ step M y = none states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕc':Cfg states symbolshc':(fun y ↦ y.bind (step M))^[n] (some init) = some c'hnone:(BusyBeaver.step M.toBB c'.toBB).isNone = true⊢ ∃ y, Reaches (step M) init y ∧ step M y = none states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsn:ℕc':Cfg states symbolshc':(fun y ↦ y.bind (step M))^[n] (some init) = some c'hnone:(BusyBeaver.step M.toBB c'.toBB).isNone = true⊢ step M c' = none All goals completed! 🐙 states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∃ y, Reaches (step M) init y ∧ step M y = none) → ∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolshreach:Reaches (step M) init c'hnone:step M c' = none⊢ ∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolshreach:Reaches (step M) init c'hnone:step M c' = nonen:ℕhn:(fun y ↦ y.bind (step M))^[n] (some init) = some c'⊢ ∃ cfg, BusyBeaver.ReachesStar M.toBB init.toBB cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolshreach:Reaches (step M) init c'hnone:step M c' = nonen:ℕhn:(fun y ↦ y.bind (step M))^[n] (some init) = some c'⊢ BusyBeaver.multiStep M.toBB init.toBB n = some c'.toBB All goals completed! 🐙

A ConjectureMachines.Machine does not halt from init if and only if its BusyBeaver image satisfies BusyBeaver.IsNotHalt.

theorem isNotHalt_toBB_iff_not_halts (M : Machine states symbols) : BusyBeaver.IsNotHalt M.toBB ↔ ¬ ConjectureMachines.Halts M := states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ BusyBeaver.IsNotHalt M.toBB ↔ ¬ConjectureMachines.Halts M states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ BusyBeaver.IsNotHalt M.toBB ↔ ¬BusyBeaver.IsHalt M.toBB states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = true) ↔ ¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = true) → ¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = truestates:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) → ∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = true) → ¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnone:(BusyBeaver.step M.toBB cfg).isNone = true⊢ False states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnone:(BusyBeaver.step M.toBB cfg).isNone = truehsome:(BusyBeaver.step M.toBB cfg).isSome = true⊢ False states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnone:BusyBeaver.step M.toBB cfg = nonehsome:(BusyBeaver.step M.toBB cfg).isSome = true⊢ False All goals completed! 🐙 states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ (¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) → ∀ (cfg : BusyBeaver.Cfg (Fin symbols) (Fin states)), BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg → (BusyBeaver.step M.toBB cfg).isSome = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg⊢ (BusyBeaver.step M.toBB cfg).isSome = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnsome:¬(BusyBeaver.step M.toBB cfg).isSome = true⊢ False states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnsome:¬(BusyBeaver.step M.toBB cfg).isSome = true⊢ ∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsh:¬∃ cfg, BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = truecfg:BusyBeaver.Cfg (Fin symbols) (Fin states)hreach:BusyBeaver.ReachesStar M.toBB (BusyBeaver.init []) cfghnsome:¬(BusyBeaver.step M.toBB cfg).isSome = true⊢ (BusyBeaver.step M.toBB cfg).isNone = true All goals completed! 🐙end ConjectureMachines