Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Universal.Nondeterministic

Descriptions of nondeterministic machines #

A description d (Turing.MultiTapeTM.Universal.Desc) lists transitions as pairs of a key and an action. The simulation of d fires the first entry whose key matches the configuration and halts when there is none. Read nondeterministically, any matching entry may fire, and a running configuration that matches no entry is stuck (Turing.MultiTapeTM.Universal.NStep).

A nondeterministic machine with finitely many states and symbols, renamed into ℕ, has a description listing every permitted transition (Turing.MultiTapeTM.Universal.descN). Its steps are the renamed steps of the machine, in both directions, so the machine accepts exactly when its description reaches a halted configuration with the output [1].

Along a computation path of the machine within S cells, the description's run stays within cfgSpaceBound (descLen d) n k S bits, for inputs of length n and k work tapes. The zippers of the run hold only cells that the machine's heads have visited, so this bound holds at every configuration the run steps to.

Main definitions #

Main results #

A step of the description d, read nondeterministically, on the input x, with the output so far: a running configuration fires any entry of d whose key matches it.

Descriptions of nondeterministic machines #

noncomputable def Turing.MultiTapeTM.Universal.descN {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) :

The description of a nondeterministic machine with finitely many states and symbols, renamed into ℕ by eS and eY: an entry for every permitted transition.

@[simp]
theorem Turing.MultiTapeTM.Universal.descN_tapes {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) :
(descN eS eY ntm).tapes = k
@[simp]
theorem Turing.MultiTapeTM.Universal.descN_q₀ {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) :
(descN eS eY ntm).q₀ = eS ntm.q₀
theorem Turing.MultiTapeTM.Universal.mem_descN {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {e : Key × Act} :
e ∈ (descN eS eY ntm).table ↔ ∃ (q : State) (i : Option Symbol) (w : Fin k → Option Symbol) (a : Action k Symbol State), ntm.Tr q i w a ∧ e = (key (eS q) (Option.map (⇑eY) i) (Option.map ⇑eY ∘ w), Act.ofAction (Action.map eS eY a))

The entries of the description are the permitted transitions, renamed.

theorem Turing.MultiTapeTM.Universal.exists_nStep_of_step {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {input : List Symbol} {c c' : Cfg k Symbol State input} (hc : ¬c.Halted) (h : ntm.Step c c') {s : SCfg} {out : List ℕ} (hs : SCfg.WellShaped k (List.map (⇑eY) input) s) (hsc : SCfg.toCfg k (List.map (⇑eY) input) s out = Cfg.map eS eY c) :
∃ (s' : SCfg), NStep (descN eS eY ntm) (List.map (⇑eY) input) (s, out) (s', (Cfg.map eS eY c').output) ∧ SCfg.WellShaped k (List.map (⇑eY) input) s' ∧ SCfg.toCfg k (List.map (⇑eY) input) s' (Cfg.map eS eY c').output = Cfg.map eS eY c'

A step of the machine is a step of its description: from a well-shaped configuration of the simulation representing a running configuration, the description can take the renamed step.

theorem Turing.MultiTapeTM.Universal.exists_step_of_nStep {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {input : List Symbol} {c : Cfg k Symbol State input} {s s' : SCfg} {out out' : List ℕ} (hs : SCfg.WellShaped k (List.map (⇑eY) input) s) (hsc : SCfg.toCfg k (List.map (⇑eY) input) s out = Cfg.map eS eY c) (h : NStep (descN eS eY ntm) (List.map (⇑eY) input) (s, out) (s', out')) :
∃ (c' : Cfg k Symbol State input), ntm.Step c c' ∧ SCfg.WellShaped k (List.map (⇑eY) input) s' ∧ SCfg.toCfg k (List.map (⇑eY) input) s' out' = Cfg.map eS eY c'

A step of the description is a step of the machine: from a well-shaped configuration of the simulation representing a configuration of the machine, a step of the description represents a step of the machine.

Computations #

theorem Turing.MultiTapeTM.Universal.exists_computationPath_of_reflTransGen {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {input : List Symbol} {p : SCfg × List ℕ} (h : Relation.ReflTransGen (NStep (descN eS eY ntm) (List.map (⇑eY) input)) (init (descN eS eY ntm), []) p) :
∃ (π : ntm.ComputationPath input), SCfg.WellShaped k (List.map (⇑eY) input) p.1 ∧ SCfg.toCfg k (List.map (⇑eY) input) p.1 p.2 = Cfg.map eS eY π.last

The configurations the description reaches represent the last configurations of computation paths of the machine.

Runs within the space of the machine #

theorem Turing.MultiTapeTM.Universal.exists_reflTransGen_fits_of_computationPath {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {input : List Symbol} (π : ntm.ComputationPath input) {S : ℕ} (hS : π.space ≤ S) :
∃ (s : SCfg), Relation.ReflTransGen (fun (p p' : SCfg × List ℕ) => NStep (descN eS eY ntm) (List.map (⇑eY) input) p p' ∧ (eCfg p'.1).length ≤ cfgSpaceBound (descLen (descN eS eY ntm)) input.length k S) (init (descN eS eY ntm), []) (s, List.map (⇑eY) π.last.output) ∧ SCfg.WellShaped k (List.map (⇑eY) input) s ∧ SCfg.toCfg k (List.map (⇑eY) input) s (List.map (⇑eY) π.last.output) = Cfg.map eS eY π.last

A computation path of the machine within S cells is represented by a run of its description within the space bound: every configuration the run steps to is at most cfgSpaceBound (descLen d) n k S bits long.

theorem Turing.MultiTapeTM.Universal.exists_reflTransGen_of_computationPath {k : ℕ} {Symbol State : Type} [Finite State] [Finite Symbol] (eS : State ↪ ℕ) (eY : Symbol ↪ ℕ) (ntm : MultiTapeNTM k Symbol State) {input : List Symbol} (π : ntm.ComputationPath input) :
∃ (s : SCfg), Relation.ReflTransGen (NStep (descN eS eY ntm) (List.map (⇑eY) input)) (init (descN eS eY ntm), []) (s, List.map (⇑eY) π.last.output) ∧ SCfg.WellShaped k (List.map (⇑eY) input) s ∧ SCfg.toCfg k (List.map (⇑eY) input) s (List.map (⇑eY) π.last.output) = Cfg.map eS eY π.last

The last configuration of every computation path of the machine is represented by a configuration the description reaches.

theorem Turing.MultiTapeTM.Universal.accepts_iff_reflTransGen_nStep {k : ℕ} {State : Type} [Finite State] (eS : State ↪ ℕ) (ntm : MultiTapeNTM k Bool State) (input : List Bool) :
ntm.Accepts input ↔ ∃ (s : SCfg), s.state = none ∧ Relation.ReflTransGen (NStep (descN eS eBit ntm) (List.map (⇑eBit) input)) (init (descN eS eBit ntm), []) (s, [eBit true])

A machine accepts exactly when its description reaches a halted configuration with the output [1].

theorem Turing.MultiTapeTM.Universal.accepts_iff_reflTransGen_nStep_fits {k : ℕ} {State : Type} [Finite State] (eS : State ↪ ℕ) (ntm : MultiTapeNTM k Bool State) (input : List Bool) {S : ℕ} (hS : ntm.RunsInSpace input S) :
ntm.Accepts input ↔ ∃ (s : SCfg), s.state = none ∧ Relation.ReflTransGen (fun (p p' : SCfg × List ℕ) => NStep (descN eS eBit ntm) (List.map (⇑eBit) input) p p' ∧ (eCfg p'.1).length ≤ cfgSpaceBound (descLen (descN eS eBit ntm)) input.length k S) (init (descN eS eBit ntm), []) (s, [eBit true])

A machine within S cells accepts exactly when its description reaches a halted configuration with the output [1] within the space bound.