FormalConjecturesForMathlib/Computability/TuringMachine/BusyBeavers.lean
Explanation legend Lean4 Domain Explanation Language (L4DEL)
L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.
- L4DEL
- Lean4 Domain Explanation Language
Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.
Project sources: Pinned project documentation, Formal Conjectures paper, arXiv v1
25 declarations, 0 contain sorry, 0 declared as axioms
Turing Machines, Busy Beaver version.
A variant on the definition of the TM0 model in Mathlib: while the statements the
TM can make in the usual TM0 are split into two categories (either write at the
current position or move left/right), we want to combine the two to stick to the
BB convention: first write at the current position and then move left/right.
Note that this Turing Machine model also works with states of type Option Γ. This
is because in the busy beaver context, the turing machines also have an addition
"halting" state
See also https://git.sr.ht/~vigoux/busybeaver for a different approach to formalising these objects.
Imports (3)
Imported by 2 files
- structure
Turing.BusyBeaver.StmtA Turing machine "statement" is just a command to write a symbol on the tape (at the current position) and then move left or right line 56 sourceSource documentation
A Turing machine "statement" is just a command to write a symbol on the tape (at the current position) and then move left or right.
no axioms what this means
structure Stmt where write :: …
- def
Turing.BusyBeaver.MachineDocumented declaration: Machine line 75 sourceSource documentation
A Post-Turing machine with symbol type
Γand label typeΛis a function which, given the current stateq : Λand the tape heada : Γ, either halts (returnsnone) or returns a new stateq' : Option Λand aStmtdescribing what to do: a command to write a symbol and move left or right. Notice that there are two ways of halting at a given(state, head)pair: either the machine halts immediately (i.e. the function returnsnone), or the machine moves to the "halting state", i.e.none : Option Λand performs one last action.Typically, both
ΛandΓare required to be inhabited; the default value forΓis the "blank" tape value, and the default value ofΛis the initial state.no axioms what this means
Statement uses:
InhabitedProof uses:
Option,Prod, Turing.BusyBeaver.Stmtdef Machine [Inhabited Λ] := …
- instance
Turing.BusyBeaver.Machine.inhabitedline 78 sourceno axioms what this means
Statement uses:
Inhabited, Turing.BusyBeaver.MachineProof uses:
id,inferInstance,Option,Prod, Turing.BusyBeaver.Stmt2 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- structure
Turing.BusyBeaver.CfgThe configuration state of a Turing machine during operation consists of a label (machine state), and a tape line 88 sourceSource documentation
The configuration state of a Turing machine during operation consists of a label (machine state), and a tape. The tape is represented in the form
(a, L, R), meaning the tape looks likeL.rev ++ [a] ++ Rwith the machine currently reading thea. The lists are automatically extended with blanks as the machine moves around.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabitedstructure Cfg [Inhabited Γ] where …
- instance
Turing.BusyBeaver.Cfg.inhabitedline 99 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.CfgProof uses:
Inhabited.mk,Turing.BusyBeaver.Cfg.mk,Inhabited.default,Option,Turing.Tape2 instances, coercions and auxiliary constants left out.
- def
Turing.BusyBeaver.Machine.stepExecution semantics of the Turing machine line 104 sourceSource documentation
Execution semantics of the Turing machine.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,OptionProof uses:
Turing.BusyBeaver.Machine.step.match_3,Turing.Tape,Option.none,Option.map,Prod, Turing.BusyBeaver.Stmt,Turing.BusyBeaver.Machine.step.match_2,Turing.BusyBeaver.Cfg.mk,Turing.BusyBeaver.Machine.step.match_1,Turing.Dir,Turing.Tape.move,Turing.Tape.write,Turing.Tape.headdef step (M : Machine Γ Λ) : Cfg Γ Λ → Option (Cfg Γ Λ) | ⟨none, _⟩ => none | ⟨some q, T⟩ => (M q T.1).map fun ⟨q', a⟩ ↦ ⟨q', match a with | Stmt.write a d => (T.write a).move d⟩ /-- The statement `Reaches M s₁ s₂` means that `s₂` is obtained starting from `s₁` after a finite number of steps from `s₂`. -/Mentions: Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg, Turing.BusyBeaver.Machine.Reaches
- def
Turing.BusyBeaver.Machine.ReachesThe statementReaches M s₁ s₂means thats₂is obtained starting froms₁after a finite number of steps froms₂line 112 sourceSource documentation
The statement
Reaches M s₁ s₂means thats₂is obtained starting froms₁after a finite number of steps froms₂.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.CfgProof uses:
Relation.ReflTransGen,Membership.mem,Option, Turing.BusyBeaver.Machine.step1 instances, coercions and auxiliary constants left out.
def Reaches (M : Machine Γ Λ) : Cfg Γ Λ → Cfg Γ Λ → Prop := ReflTransGen fun a b ↦ b ∈ step M a
Mentions: Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg, Turing.BusyBeaver.Machine.step
- def
Turing.BusyBeaver.Machine.initThe initial configuration line 115 sourceSource documentation
The initial configuration.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited,List, Turing.BusyBeaver.CfgProof uses:
Turing.BusyBeaver.Cfg.mk,Option.some,Inhabited.default,Turing.Tape.mk₁def init (l : List Γ) : Cfg Γ Λ := ⟨some default, Tape.mk₁ l⟩
Mentions: Turing.BusyBeaver.Cfg
- def
Turing.BusyBeaver.Machine.evalEvaluate a Turing machine on initial input to a final state, if it terminates line 119 sourceSource documentation
Evaluate a Turing machine on initial input to a final state, if it terminates.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,List,Part,Turing.ListBlankProof uses:
Part.map, Turing.BusyBeaver.Cfg,Turing.Tape.right₀,Turing.BusyBeaver.Cfg.tape,StateTransition.eval, Turing.BusyBeaver.Machine.step, Turing.BusyBeaver.Machine.initdef eval (M : Machine Γ Λ) (l : List Γ) : Part (ListBlank Γ) := …
Mentions: Turing.BusyBeaver.Machine
- def
Turing.BusyBeaver.Machine.multiStepline 122 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Nat,OptionProof uses:
Nat.iterate,Option.bind, Turing.BusyBeaver.Machine.step,Option.some - lemma
Turing.BusyBeaver.Machine.multiStep_zeroline 126 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Eq,Option, Turing.BusyBeaver.Machine.multiStep,OfNat.ofNat,Nat,Option.someProof uses:
rfl2 instances, coercions and auxiliary constants left out.
- lemma
Turing.BusyBeaver.Machine.multiStep_oneline 130 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Eq,Option, Turing.BusyBeaver.Machine.multiStep,OfNat.ofNat,Nat, Turing.BusyBeaver.Machine.stepProof uses:
rfl2 instances, coercions and auxiliary constants left out.
- lemma
Turing.BusyBeaver.Machine.multiStep_succline 134 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Nat,Eq,Option, Turing.BusyBeaver.Machine.multiStep,HAdd.hAdd,OfNat.ofNat,Option.bind, Turing.BusyBeaver.Machine.stepProof uses:
Eq.mpr,Nat.iterate,Option.some,id,congrArg,Turing.BusyBeaver.Machine.multiStep.eq_1,Function.comp,Nat.succ,Function.iterate_succ',Function.comp_apply,Eq.refl6 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Turing.BusyBeaver.Machine.multiStep_eq_none_monoline 139 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Nat,Eq,Option, Turing.BusyBeaver.Machine.multiStep,Option.none,LE.leProof uses:
Nat.le.rec,Nat.le,Eq.mpr,Nat.succ,Option.bind, Turing.BusyBeaver.Machine.step,id,congrArg,HAdd.hAdd,OfNat.ofNat, Turing.BusyBeaver.Machine.multiStep_succ,Eq.refl5 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- def
Turing.BusyBeaver.Machine.IsHaltingInputM.IsHaltingInput lis the predicate thatMis a halting configuration forMline 154 sourceSource documentation
M.IsHaltingInput lis the predicate thatMis a halting configuration forM.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,ListProof uses:
Part.Dom,Turing.ListBlank, Turing.BusyBeaver.Machine.evaldef IsHaltingInput (l : List Γ) : Prop := (eval M l).Dom
Mentions: Turing.BusyBeaver.Machine.eval
- def
Turing.BusyBeaver.Machine.IsHaltingConfigurationM.HaltsAtConfiguration sis the predicate thatMis a halting configuration forMline 161 sourceSource documentation
M.HaltsAtConfiguration sis the predicate thatMis a halting configuration forM.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.CfgProof uses:
Eq,Bool,Option.isNone, Turing.BusyBeaver.Machine.step,Bool.truedef IsHaltingConfiguration (s : Cfg Γ Λ) : Prop := (step M s).isNone
Mentions: Turing.BusyBeaver.Cfg, Turing.BusyBeaver.Machine.step
- class
Turing.BusyBeaver.Machine.IsHaltingThe property that a Turing MachineMeventually halts when starting from an empty tape line 166 sourceSource documentation
The property that a Turing Machine
Meventually halts when starting from an empty tapestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machineclass IsHalting : Prop where …
- def
Turing.BusyBeaver.Machine.HaltsAfterThe predicate that a machine starting at configurationsstops after at mostnsteps, i.e. reaches a configuration from which there are no defined transitions line 173 sourceSource documentation
The predicate that a machine starting at configuration
sstops after at mostnsteps, i.e. reaches a configuration from which there are no defined transitions.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,NatProof uses:
Eq,Option, Turing.BusyBeaver.Machine.multiStep,HAdd.hAdd,OfNat.ofNat,Option.none3 instances, coercions and auxiliary constants left out.
def HaltsAfter (s : Cfg Γ Λ) (n : ℕ) : Prop := …
Mentions: Turing.BusyBeaver.Cfg
- lemma
Turing.BusyBeaver.Machine.haltsAfter_zero_iffline 176 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Iff, Turing.BusyBeaver.Machine.HaltsAfter,OfNat.ofNat,Nat,Eq,Option, Turing.BusyBeaver.Machine.step,Option.noneProof uses:
Eq.mpr, Turing.BusyBeaver.Machine.multiStep,HAdd.hAdd,id,congrArg,Turing.BusyBeaver.Machine.HaltsAfter.eq_1,Nat.iterate,Option.bind,Option.some,Turing.BusyBeaver.Machine.multiStep.eq_1,Function.iterate_one,Option.bind_some,Iff.rfl4 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Turing.BusyBeaver.Machine.isHalting_iff_exists_haltsAtline 180 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,Iff, Turing.BusyBeaver.Machine.IsHalting,Exists,Nat, Turing.BusyBeaver.Machine.HaltsAfter, Turing.BusyBeaver.Machine.init,List.nilProof uses:
Iff.intro,Iff.mpr,Eq,Option, Turing.BusyBeaver.Cfg,Nat.iterate,Option.bind, Turing.BusyBeaver.Machine.step,HAdd.hAdd,OfNat.ofNat,Option.some,Option.none,Part.Dom,StateTransition.eval, StateTransition.eval_dom_iff,Turing.BusyBeaver.Machine.IsHalting.halts,Turing.BusyBeaver.Machine.IsHalting.mk,Iff.mp3 instances, coercions and auxiliary constants left out.
- lemma
Turing.BusyBeaver.Machine.exists_of_not_haltsAfterline 183 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine, Turing.BusyBeaver.Cfg,Nat,Not, Turing.BusyBeaver.Machine.HaltsAfter,Exists,Turing.Tape,Eq,Option, Turing.BusyBeaver.Machine.multiStep,Option.some,Turing.BusyBeaver.Cfg.mkProof uses:
Mathlib.Tactic.Contrapose.contrapose₂,Eq.mpr,Ne,id,implies_congr,binderNameHint,Eq.trans,forall_congr,Eq.refl,HAdd.hAdd,OfNat.ofNat,Option.none,congrArg,Turing.BusyBeaver.Machine.HaltsAfter.eq_1,Option.bind, Turing.BusyBeaver.Machine.step, Turing.BusyBeaver.Machine.multiStep_succ,Or,Option.eq_none_or_eq_some,of_eq_trueand 14 more13 instances, coercions and auxiliary constants left out.
Tactic trace: 13 steps
Open to load the checked before-and-after goal states.
- lemma
Turing.BusyBeaver.Machine.not_isHalting_iff_forall_isSome_multiStepline 195 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,Iff,Not, Turing.BusyBeaver.Machine.IsHalting,Nat,Eq,Bool,Option.isSome, Turing.BusyBeaver.Cfg, Turing.BusyBeaver.Machine.multiStep, Turing.BusyBeaver.Machine.init,List.nil,HAdd.hAdd,OfNat.ofNat,Bool.trueProof uses:
Eq.mpr,Exists, Turing.BusyBeaver.Machine.HaltsAfter,id,congrFun',congrArg,Option,Option.none,Ne,forall_congr,Iff.rfl9 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
- lemma
Turing.BusyBeaver.Machine.not_isHalting_of_forall_isSomeline 201 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,Exists, Turing.BusyBeaver.Stmt,Eq,Option,Prod,Option.some,Prod.mk,Not, Turing.BusyBeaver.Machine.IsHaltingProof uses:
Eq.mpr,Nat,Bool,Option.isSome, Turing.BusyBeaver.Cfg, Turing.BusyBeaver.Machine.multiStep, Turing.BusyBeaver.Machine.init,List.nil,HAdd.hAdd,OfNat.ofNat,Bool.true,id,congrArg,propext, Turing.BusyBeaver.Machine.not_isHalting_iff_forall_isSome_multiStep,Nat.recAux,Inhabited.default,Turing.Tape.head,Turing.Tape.mk₁,of_eq_trueand 21 more6 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
- def
Turing.BusyBeaver.Machine.haltingNumberline 215 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,ENatProof uses:
InfSet.sInf,Set.ofPred,Exists,Nat, Turing.BusyBeaver.Machine.HaltsAfter, Turing.BusyBeaver.Machine.init,List.nil,Eq9 instances, coercions and auxiliary constants left out.
- theorem
Turing.BusyBeaver.Machine.haltingNumber_defline 220 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Inhabited, Turing.BusyBeaver.Machine,Nat,Exists, Turing.BusyBeaver.Cfg,Eq,Option, Turing.BusyBeaver.Machine.multiStep, Turing.BusyBeaver.Machine.init,List.nil,Option.some,HAdd.hAdd,OfNat.ofNat,Option.none,ENat, Turing.BusyBeaver.Machine.haltingNumberProof uses:
IsGLB.sInf_eq,Set.ofPred, Turing.BusyBeaver.Machine.HaltsAfter,IsLeast.isGLB,And.intro,Membership.mem,Set,lowerBounds,Exists.intro,Eq.mpr,id,congrArg,Turing.BusyBeaver.Machine.HaltsAfter.eq_1,rfl,LE.le,ENat.recTopCoe,Top.top,le_top,Eq.symm,Decidable.byContradictionand 16 more54 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.