Documentation

CslibFrontier.Computability.Machines.Turing.SingleTape.TM0Restrict

Configurations and state restriction for Turing.TM0 machines #

This module provides basic configuration constructors, step evaluation lemmas, and state-set restriction for Mathlib's Post–Turing machine model _root_.Turing.TM0.

A configuration c : TM0.Cfg Γ Λ can be viewed as having state q, scanned symbol a, left tape L (nearest first) and right tape R (TM0.cfgOf q a L R). Transition steps (TM0.step) evaluate on cfgOf according to whether the machine writes, moves, or halts (TM0.step_of_eq_*). Halting on an input is defined by TM0.Halts M l and characterized by (TM0.eval M l).Dom (TM0.eval_dom_iff).

When a subset S ⊆ Λ supports M (TM0.Supports M S, meaning S contains default and is closed under transitions of M), TM0.restrict M hS is the restricted machine with state type S. Its execution preserves evaluation domains (TM0.eval_restrict_dom), turning an infinite-state machine supported on a finite subset into a finite-state machine.

Main definitions #

Main results #

References #

def Turing.TM0.cfgOf {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] (q : Λ) (a : Γ) (L R : List Γ) :
Cfg Γ Λ

The configuration with state q, scanned symbol a, the cells L to the left (nearest first) and the cells R to the right.

theorem Turing.TM0.exists_cfgOf {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] (c : Cfg Γ Λ) :
∃ (q : Λ) (a : Γ) (L : List Γ) (R : List Γ), c = cfgOf q a L R
theorem Turing.TM0.init_eq {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (l : List Γ) :
theorem Turing.TM0.step_of_eq_none {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Machine Γ Λ} {q : Λ} {a : Γ} (h : M q a = none) (L R : List Γ) :
step M (cfgOf q a L R) = none
theorem Turing.TM0.step_of_eq_write {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} {b : Γ} (h : M q a = some (q', Stmt.write b)) (L R : List Γ) :
step M (cfgOf q a L R) = some (cfgOf q' b L R)
theorem Turing.TM0.step_of_eq_right {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} (h : M q a = some (q', Stmt.move Dir.right)) (L R : List Γ) :
step M (cfgOf q a L R) = some (cfgOf q' R.headI (a :: L) R.tail)
theorem Turing.TM0.step_of_eq_left {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} (h : M q a = some (q', Stmt.move Dir.left)) (L R : List Γ) :
step M (cfgOf q a L R) = some (cfgOf q' L.headI L.tail (a :: R))
def Turing.TM0.Halts {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Machine Γ Λ) (l : List Γ) :

The machine halts on input l.

theorem Turing.TM0.eval_dom_iff {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Machine Γ Λ) (l : List Γ) :
(eval M l).Dom ↔ Halts M l

Restricting a machine to a supporting set of states #

def Turing.TM0.restrict {Γ : Type u_1} {Λ : Type u_2} [Inhabited Λ] (M : Machine Γ Λ) {S : Set Λ} (hS : Supports M S) [Inhabited ↑S] :
Machine Γ ↑S

The restriction of a TM0 machine to a set of states supporting it.

def Turing.TM0.liftCfg {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] {S : Set Λ} (c : Cfg Γ ↑S) :
Cfg Γ Λ

The configuration of the original machine underlying a configuration of the restriction.

theorem Turing.TM0.step_liftCfg {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Machine Γ Λ) {S : Set Λ} (hS : Supports M S) [Inhabited ↑S] (c : Cfg Γ ↑S) :
theorem Turing.TM0.restrict_respects {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Machine Γ Λ) {S : Set Λ} (hS : Supports M S) [Inhabited ↑S] :
StateTransition.Respects (step (restrict M hS)) (step M) fun (c : Cfg Γ ↑S) (c' : Cfg Γ Λ) => liftCfg c = c'
@[instance_reducible]
def Turing.TM0.Supports.inhabited {Γ : Type u_1} {Λ : Type u_2} [Inhabited Λ] {M : Machine Γ Λ} {S : Set Λ} (hS : Supports M S) :

Canonical Inhabited instance for a set of states supporting a machine.

theorem Turing.TM0.eval_restrict_dom {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Machine Γ Λ) {S : Set Λ} (hS : Supports M S) [Inhabited ↑S] (hd : ↑default = default := by rfl) (l : List Γ) :
(eval (restrict M hS) l).Dom ↔ (eval M l).Dom