Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Locality

Locality of a step #

A step of a multi-tape machine reads the cells under its heads, writes at most the cells under its work heads, and moves every head by at most one cell. This file records these facts in the form used to cut a computation into local pieces.

The heads are indexed by Option (Fin k): none is the read-only input head and some i the head of work tape i. Turing.Cfg.headPos places them in coordinates where every head starts at zero; the input head's stored position inputPos is shifted by one, so its coordinate ranges over [-1, n] on an input of length n. The write-only output tape is never read and has no head here.

Two configurations agree on a family W of work-tape cells (Turing.Cfg.AgreeOn) when they have the same control state and head positions and the same work-tape contents on W. If the work heads lie in W, a step reads the same symbols in both, takes the same action, and preserves agreement on W; both append the same symbol, if any, to their outputs (Turing.MultiTapeTM.agreeOn_step). Contents outside W and earlier outputs may differ.

Main definitions #

Main results #

def Turing.Cfg.headPos {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (cfg : Cfg k Symbol State input) :
Option (Fin k) → ℤ

The position of a head, in coordinates where every head starts at zero: the input head (none) at its stored position shifted by one, and the head of work tape i (some i).

@[simp]
theorem Turing.Cfg.headPos_none {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (cfg : Cfg k Symbol State input) :
cfg.headPos none = ↑↑cfg.inputPos - 1
@[simp]
theorem Turing.Cfg.headPos_some {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (cfg : Cfg k Symbol State input) (i : Fin k) :
cfg.headPos (some i) = cfg.workTapePos i
theorem Turing.Cfg.headPos_init {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (q₀ : State) (head : Option (Fin k)) :
(init q₀ input).headPos head = 0

Every head starts at zero.

theorem Turing.Cfg.headPos_none_mem_Icc {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (cfg : Cfg k Symbol State input) :
cfg.headPos none ∈ Set.Icc (-1) ↑input.length

The input head is at a coordinate in [-1, n] on an input of length n.

theorem Turing.Action.abs_headPos_apply_sub_le {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (action : Action k Symbol State) (cfg : Cfg k Symbol State input) (head : Option (Fin k)) :
|(action.apply cfg).headPos head - cfg.headPos head| ≤ 1

An action moves every head by at most one cell.

theorem Turing.MultiTapeNTM.Step.abs_headPos_sub_le {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {ntm : MultiTapeNTM k Symbol State} {c c' : Cfg k Symbol State input} (h : ntm.Step c c') (head : Option (Fin k)) :
|c'.headPos head - c.headPos head| ≤ 1

A step moves every head by at most one cell.

structure Turing.Cfg.AgreeOn {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (W : Fin k → Set ℤ) (c c' : Cfg k Symbol State input) :

Two configurations agree on the work-tape cells W: they have the same control state, the same input and work head positions, and the same work-tape contents on W. Their outputs and their contents outside W are unconstrained.

theorem Turing.Cfg.AgreeOn.refl {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (W : Fin k → Set ℤ) (c : Cfg k Symbol State input) :
AgreeOn W c c

A configuration agrees with itself on every family of cells.

theorem Turing.Cfg.AgreeOn.symm {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : AgreeOn W c c') :
AgreeOn W c' c
theorem Turing.Cfg.AgreeOn.trans {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W : Fin k → Set ℤ} {c c' c'' : Cfg k Symbol State input} (h : AgreeOn W c c') (h' : AgreeOn W c' c'') :
AgreeOn W c c''
theorem Turing.Cfg.AgreeOn.mono {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W W' : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : AgreeOn W c c') (hW : ∀ (i : Fin k), W' i ⊆ W i) :
AgreeOn W' c c'

Agreement on more cells is agreement on fewer.

theorem Turing.Cfg.AgreeOn.headPos_eq {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : AgreeOn W c c') :

Agreeing configurations are at the same head positions.

theorem Turing.Cfg.AgreeOn.workTapeSymbols_eq {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : AgreeOn W c c') (hpos : ∀ (i : Fin k), c.workTapePos i ∈ W i) :

Agreement on cells containing the work heads gives the same read symbols.

theorem Turing.Cfg.AgreeOn.apply {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} {W : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : AgreeOn W c c') (action : Action k Symbol State) :
AgreeOn W (action.apply c) (action.apply c')

One action applied to agreeing configurations keeps them agreeing on W: it writes the same symbols under the same heads.

theorem Turing.MultiTapeTM.agreeOn_step {k : ℕ} {Symbol : Type u_1} {State : Type u_2} {input : List Symbol} (tm : MultiTapeTM k Symbol State) {W : Fin k → Set ℤ} {c c' : Cfg k Symbol State input} (h : Cfg.AgreeOn W c c') (hpos : ∀ (i : Fin k), c.workTapePos i ∈ W i) :
Cfg.AgreeOn W (step c) (step c') ∧ ∃ (e : List Symbol), (step c).output = c.output ++ e ∧ (step c').output = c'.output ++ e

Locality of a step. If two configurations agree on cells W containing their work heads, one step keeps them agreeing on W, and both append the same word to their outputs.