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
exact congrArg (c :: ·) (ListBlank.eq_of_isTrimmed_blankExtends hx hy ⟨i, htl⟩) All goals completed! 🐙@[simp]
theorem ListBlank.toTuring_inj {Γ : Type*} [Inhabited Γ] {l₁ l₂ : ListBlank Γ} :
l₁.toTuring = l₂.toTuring ↔ l₁ = l₂ := by Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring ↔ l₁ = l₂
constructor mp Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring → l₁ = l₂mpr Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁ = l₂ → l₁.toTuring = l₂.toTuring
· mp Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁.toTuring = l₂.toTuring → l₁ = l₂ intro h mp Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuring⊢ l₁ = l₂
apply ListBlank.ext mp Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuring⊢ l₁.toList = l₂.toList
rcases Quotient.exact' h with h₁ | h₂ mp.inl Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₁:Turing.BlankExtends l₁.toList l₂.toList⊢ l₁.toList = l₂.toListmp.inr Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₂:Turing.BlankExtends l₂.toList l₁.toList⊢ l₁.toList = l₂.toList
· mp.inl Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₁:Turing.BlankExtends l₁.toList l₂.toList⊢ l₁.toList = l₂.toList exact ListBlank.eq_of_isTrimmed_blankExtends l₁.isTrimmed l₂.isTrimmed h₁ All goals completed! 🐙
· mp.inr Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toTuring = l₂.toTuringh₂:Turing.BlankExtends l₂.toList l₁.toList⊢ l₁.toList = l₂.toList exact (ListBlank.eq_of_isTrimmed_blankExtends l₂.isTrimmed l₁.isTrimmed h₂).symm All goals completed! 🐙
· mpr Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γ⊢ l₁ = l₂ → l₁.toTuring = l₂.toTuring exact congrArg _ 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 := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ Turing.ListBlank.cons a l.toTuring = (cons a l).toTuring
rcases l with ⟨_ | ⟨b, xs⟩, _⟩ nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.cons a { toList := [], isTrimmed := isTrimmed✝ }.toTuring =
(cons a { toList := [], isTrimmed := isTrimmed✝ }).toTuringcons Γ: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
· nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.cons a { toList := [], isTrimmed := isTrimmed✝ }.toTuring =
(cons a { toList := [], isTrimmed := isTrimmed✝ }).toTuring change Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a]) nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk (if a = default then [] else [a])
by_cases ha : a = default pos Γ: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])neg Γ: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])
· pos Γ: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]) rw [ite_eq_left ha, pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk [] ha pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [default] = Turing.ListBlank.mk []] pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:a = default⊢ Turing.ListBlank.mk [default] = Turing.ListBlank.mk []
exact Quotient.sound' (Or.inr ⟨1, rfl⟩) All goals completed! 🐙
· neg Γ: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]) rw [ite_eq_right ha neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []ha:¬a = default⊢ Turing.ListBlank.mk [a] = Turing.ListBlank.mk [a]] All goals completed! 🐙
· cons Γ: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 rfl 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₂ := by Γ:Type u_1inst✝:Inhabited ΓT₁:Tape ΓT₂:Tape Γ⊢ T₁.toTuring = T₂.toTuring ↔ T₁ = T₂
cases T₁ mk Γ: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₂; cases T₂ mk.mk Γ: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✝ }; simp [Tape.toTuring] 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₂ := by states:ℕsymbols:ℕinst✝:NeZero symbolsc₁:Cfg states symbolsc₂:Cfg states symbols⊢ c₁.toBB = c₂.toBB ↔ c₁ = c₂
cases c₁ mk 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₂; cases c₂ mk.mk 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✝ }; simp [Cfg.toBB] 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 := by 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)
obtain ⟨q, T⟩ := 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 })
simp only [Cfg.toBB, BusyBeaver.step, Machine.toBB, ConjectureMachines.step, Option.map_map,
Tape.toTuring] 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)
rcases M.transition q T.head with _ | ⟨a, d, q'⟩ none 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) }) nonesome 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'))
· none 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 rfl All goals completed! 🐙
· some 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')) cases d some.left 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'))some.right 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')) <;> some.left 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'))some.right 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'))
simp [Cfg.toBB, Tape.move, Tape.write, Turing.Tape.move, Turing.Tape.write, Tape.toTuring] 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 := by 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
rw [step_toBB, states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ (Option.map Cfg.toBB (step M c)).isNone = true ↔ step M c = none Option.isNone_iff_eq_none, states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ Option.map Cfg.toBB (step M c) = none ↔ step M c = none Option.map_eq_none_iff states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ step M c = none ↔ 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 := by 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
rw [step_toBB, states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ (Option.map Cfg.toBB (step M c)).isSome = true ↔ (step M c).isSome = true Option.isSome_map states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ (step M c).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 := by α:Type u_1f:α → Option αn:ℕ⊢ (fun x ↦ x.bind f)^[n] none = none
induction n with
| zero => zero α:Type u_1f:α → Option α⊢ (fun x ↦ x.bind f)^[0] none = none rfl All goals completed! 🐙
| succ n ih => succ α:Type u_1f:α → Option αn:ℕih:(fun x ↦ x.bind f)^[n] none = none⊢ (fun x ↦ x.bind f)^[n + 1] none = none rw [Function.iterate_succ_apply, succ α:Type u_1f:α → Option αn:ℕih:(fun x ↦ x.bind f)^[n] none = none⊢ (fun x ↦ x.bind f)^[n] (none.bind f) = none Option.bind_none, succ α:Type u_1f:α → Option αn:ℕih:(fun x ↦ x.bind f)^[n] none = none⊢ (fun x ↦ x.bind f)^[n] none = none ih succ α:Type u_1f:α → Option αn:ℕih:(fun x ↦ x.bind f)^[n] none = none⊢ 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 := by 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
| zero => zero 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) rfl All goals completed! 🐙
| succ n ih => succ 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)
rw [Function.iterate_succ_apply, succ 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 + 1] x) Function.iterate_succ_apply succ 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)))] succ 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)))
have hbind :
(x.map Cfg.toBB).bind (BusyBeaver.step M.toBB) =
(x.bind (ConjectureMachines.step M)).map Cfg.toBB := by 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)
cases x none 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)⊢ (Option.map Cfg.toBB none).bind (BusyBeaver.step M.toBB) = Option.map Cfg.toBB (none.bind (step M))some 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)val✝:Cfg states symbols⊢ (Option.map Cfg.toBB (some val✝)).bind (BusyBeaver.step M.toBB) = Option.map Cfg.toBB ((some val✝).bind (step M)) <;> none 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)⊢ (Option.map Cfg.toBB none).bind (BusyBeaver.step M.toBB) = Option.map Cfg.toBB (none.bind (step M))some 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)val✝:Cfg states symbols⊢ (Option.map Cfg.toBB (some val✝)).bind (BusyBeaver.step M.toBB) = Option.map Cfg.toBB ((some val✝).bind (step M)) simp [step_toBB] succ 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)))
rw [hbind, succ 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 (step M))) =
Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (x.bind (step M))) ih succ 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))⊢ Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (x.bind (step M))) =
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' := by 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'
constructor mp 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'mpr 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'
· mp 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' intro h mp 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'
refine Relation.ReflTransGen.head_induction_on h ?_ ?_ mp.refine_1 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'mp.refine_2 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'
· mp.refine_1 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' exact ⟨0, rfl⟩ All goals completed! 🐙
· mp.refine_2 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' intro a b hab _ ⟨n, hn⟩ mp.refine_2 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'
refine ⟨n + 1, ?_⟩ mp.refine_2 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'
rw [Function.iterate_succ_apply mp.refine_2 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'] mp.refine_2 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'
simp only [Option.mem_def] at hab mp.refine_2 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'
simpa [Option.bind, hab] using hn All goals completed! 🐙
· mpr 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' rintro ⟨n, hn⟩ mpr 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
| zero => mpr.zero 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'
injection hn with h mpr.zero states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc':Cfg states symbolsc:Cfg states symbolsh:c = c'⊢ Reaches (step M) c c'
subst h mpr.zero states:ℕsymbols:ℕinst✝:NeZero symbolsM:Machine states symbolsc:Cfg states symbols⊢ Reaches (step M) c c
exact Relation.ReflTransGen.refl All goals completed! 🐙
| succ n ih => mpr.succ 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'
rw [Function.iterate_succ_apply mpr.succ 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'] at hn mpr.succ 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'
change (fun y : Option (Cfg states symbols) =>
y.bind (ConjectureMachines.step M))^[n] (ConjectureMachines.step M c) = some c' at hn mpr.succ 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'
rcases hstep : ConjectureMachines.step M c with _ | c₁ mpr.succ.none 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'mpr.succ.some 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'
· mpr.succ.none 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' rw [hstep, mpr.succ.none 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] none = some c'hstep:step M c = none⊢ Reaches (step M) c c' iterate_bind_none mpr.succ.none 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'] at hn mpr.succ.none 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'
cases hn All goals completed! 🐙
· mpr.succ.some 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' rw [hstep mpr.succ.some 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'] at hn mpr.succ.some 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'
exact Relation.ReflTransGen.head hstep (ih c₁ hn) 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 := by states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ BusyBeaver.IsHalt M.toBB ↔ ConjectureMachines.Halts M
unfold BusyBeaver.IsHalt ConjectureMachines.Halts 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
rw [Part.dom_iff_mem 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 (BusyBeaver.init []) cfg ∧ (BusyBeaver.step M.toBB cfg).isNone = true) ↔
∃ y, y ∈ eval (step M) init
simp only [StateTransition.mem_eval, init_toBB] 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
constructor mp 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 = nonempr 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
· mp 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 rintro ⟨cfg, ⟨n, hms⟩, hnone⟩ mp 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
rw [multiStep_toBB, mp 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:Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (some init)) = some cfg⊢ ∃ y, Reaches (step M) init y ∧ step M y = none Option.map_eq_some_iff mp 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] at hms mp 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
obtain ⟨c', hc', rfl⟩ := hms mp 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
refine ⟨c', (reaches_iff_exists_iterate M init c').mpr ⟨n, hc'⟩, ?_⟩ mp 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
exact (step_toBB_isNone_iff M c').mp hnone All goals completed! 🐙
· mpr 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 rintro ⟨c', hreach, hnone⟩ mpr 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
obtain ⟨n, hn⟩ := (reaches_iff_exists_iterate M init c').mp hreach mpr 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
refine ⟨c'.toBB, ⟨n, ?_⟩, (step_toBB_isNone_iff M c').mpr hnone⟩ mpr 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
rw [multiStep_toBB, mpr 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'⊢ Option.map Cfg.toBB ((fun y ↦ y.bind (step M))^[n] (some init)) = some c'.toBB hn, mpr 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'⊢ Option.map Cfg.toBB (some c') = some c'.toBB Option.map_some mpr 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'⊢ some c'.toBB = 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 := by states:ℕsymbols:ℕinst✝¹:NeZero statesinst✝:NeZero symbolsM:Machine states symbols⊢ BusyBeaver.IsNotHalt M.toBB ↔ ¬ConjectureMachines.Halts M
rw [← isHalt_toBB_iff_halts 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⊢ BusyBeaver.IsNotHalt M.toBB ↔ ¬BusyBeaver.IsHalt M.toBB
unfold BusyBeaver.IsNotHalt BusyBeaver.IsHalt 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
constructor mp 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 = truempr 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
· mp 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 intro h ⟨cfg, hreach, hnone⟩ mp 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
have hsome := h cfg hreach mp 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
rw [Option.isNone_iff_eq_none mp 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] at hnone mp 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
simp [hnone] at hsome All goals completed! 🐙
· mpr 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 intro h cfg hreach mpr 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
by_contra hnsome mpr 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
apply h mpr 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
refine ⟨cfg, hreach, ?_⟩ mpr 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
simpa using hnsome All goals completed! 🐙end ConjectureMachines