Equivalence between SingleTapeTM and Mathlib's TM0 and TM1 #
This file bridges CSLib's single-tape Turing machine model (Cslib.Turing.SingleTapeTM) with
Mathlib's Post–Turing and Wang B-machine models (_root_.Turing.TM0 and _root_.Turing.TM1) as
well as StateTransition.eval and StateTransition.EvalsToInTime.
Main definitions #
Cslib.Turing.SingleTapeTM.toTM1: step-exact embedding of aSingleTapeTM Symbolinto_root_.Turing.TM1.Cslib.Turing.SingleTapeTM.toTM0: compilation of aSingleTapeTM Symbolinto_root_.Turing.TM0via_root_.Turing.TM1to0.tr.Cslib.Turing.SingleTapeTM.ofTM0: compilation of a finitely supported_root_.Turing.TM0.Machine (Option Symbol) Λinto aSingleTapeTM Symbol.Cslib.Turing.SingleTapeTM.ofTM1: compilation of a finitely supported_root_.Turing.TM1machine into aSingleTapeTM Symbol.
Main results #
Cslib.Turing.SingleTapeTM.outputs_iff_mem_eval:tm.Outputs l l'holds if and only iftm.haltCfg l' ∈ StateTransition.eval tm.step (tm.initCfg l).Cslib.Turing.SingleTapeTM.outputsWithinTime_iff_evalsToInTime:tm.OutputsWithinTime l l' mholds if and only ifStateTransition.EvalsToInTime tm.step (tm.initCfg l) (some (tm.haltCfg l')) mis nonempty.Cslib.Turing.SingleTapeTM.map_ofTM1Cfg_step,eval_toTM1,eval_toTM0_eq_eval_toTM1:toTM1is a step-for-step simulation oftm, andtoTM0preserveseval.Cslib.Turing.SingleTapeTM.outputsWithinTime_ofTM0_iff,outputs_ofTM0_iff,eval_ofTM0,eval_ofTM1:ofTM0preserves step counts, up to one final halting step, and terminal tape evaluations;ofTM1preserves terminal tape evaluations.
References #
Connection with StateTransition #
tm.Outputs l l' holds if and only if StateTransition.eval tm.step (tm.initCfg l)
evaluates to tm.haltCfg l'.
tm.OutputsWithinTime l l' m holds if and only if StateTransition.EvalsToInTime reaches
some (tm.haltCfg l') in at most m steps.
Embedding SingleTapeTM into Mathlib's TM1 and TM0 #
Branching helper for optional head movement in TM1 using the stored head symbol.
Instances For
Next-state helper in TM1 using the stored head symbol.
Instances For
Step-exact embedding of a SingleTapeTM Symbol into Mathlib's _root_.Turing.TM1.
Each step loads the current tape head into the local store Option Symbol, writes the new symbol,
performs the optional move, and transitions to the next state (or halts), all in a single TM1
step.
Instances For
Forgetful projection from TM1 configurations to SingleTapeTM configurations.
Instances For
Lift a SingleTapeTM configuration to a TM1 configuration with local variable v.
Instances For
One step of tm.toTM1 on a lifted configuration tm.toTM1Cfg c v takes exactly one step of
tm and updates the local store to c.BiTape.head.
ofTM1Cfg commutes with a single step of TM1.step tm.toTM1 and tm.step.
Running tm.toTM1 from TM1.init (l.map some) and projecting via ofTM1Cfg agrees with
StateTransition.eval tm.step (tm.initCfg l).
If tm outputs l' on input l, then tm.toTM1 evaluates (l.map some) to
ListBlank.mk (l'.map some).
tm.OutputsWithinTime l l' m is equivalent to tm.toTM1 reaching the halted configuration
tm.toTM1Cfg (tm.haltCfg l') v in at most m steps.
Compilation of tm : SingleTapeTM Symbol into a Mathlib _root_.Turing.TM0.Machine via
_root_.Turing.TM1to0.tr.
Instances For
Finite state set supporting tm.toTM0.
Instances For
If tm outputs l' on input l, then tm.toTM0 evaluates (l.map some) to
ListBlank.mk (l'.map some).
Compiling Mathlib's TM0 and TM1 to SingleTapeTM #
Compile a Mathlib _root_.Turing.TM0.Machine (Option Symbol) Λ supported on a finite state set
S : Finset Λ into a SingleTapeTM Symbol.
Each non-halting TM0 transition (move d or write a') executes in 1 SingleTapeTM step, and
halting (M q a = none) transitions to none in 1 step while leaving the tape unchanged.
Instances For
Translate a TM0 configuration with state in S to an active (ofTM0 M S hs).Cfg.
Instances For
(ofTM0 M S hs).OutputsWithinTime l l' (t + 1) holds if and only if M reaches a halting
configuration with tape BiTape.equivTape (BiTape.mk₁ l') in at most t steps.
(ofTM0 M S hs).Outputs l l' holds if and only if StateTransition.eval (TM0.step M) on
TM0.init (l.map some) halts with tape BiTape.equivTape (BiTape.mk₁ l').
Evaluating ofTM0 M S hs on l and reading right₀ of the final tape produces the exact
same partial result as _root_.Turing.TM0.eval M (l.map some).
If ofTM0 M S hs outputs l' on input l, then _root_.Turing.TM0.eval M (l.map some)
evaluates to ListBlank.mk (l'.map some).
Compile a finitely supported Mathlib _root_.Turing.TM1 machine into a SingleTapeTM Symbol
by composing _root_.Turing.TM1to0.tr with SingleTapeTM.ofTM0.
Instances For
Evaluating ofTM1 M S hs on l and reading right₀ of the final tape produces the exact
same partial result as _root_.Turing.TM1.eval M (l.map some).
If ofTM1 M S hs outputs l' on input l, then _root_.Turing.TM1.eval M (l.map some)
evaluates to ListBlank.mk (l'.map some).