Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.IntervalSimulation

Interval steps by finite simulation #

An interval step (Turing.MultiTapePTM.IntervalStep) replays coins from a configuration whose work tapes are functions on ℤ. This module decides it by a simulation on finite storage, the first step towards computing the block-counting networks of #1833 in polynomial time.

Finite storage (Turing.MultiTapePTM.LocalCfg) keeps the control, the input position as a natural number, every work tape as a Cslib.Turing.BiTape around its head together with the head's absolute position, and only the track of the output (Turing.MultiTapeNTM.ChoiceTable.OutputTrack), which is all a control record keeps. One coin step (Turing.MultiTapePTM.localCoinStep) applies the table's action; on halted storage it changes nothing. Finite storage represents a configuration (Turing.MultiTapePTM.LocalCfg.Represents) when it has its control, input position, head positions, output track and the contents of every work tape around its head; steps preserve this (Turing.MultiTapePTM.LocalCfg.Represents.localRun).

The window. The configuration embedded at block indices J with control record cIn and window contents wIn (Turing.embedCfg) is represented by Turing.MultiTapePTM.localStart, which loads the 3 b cells of each window into a tape (Cslib.Turing.BiTape.ofCells). Its control record, block indices and window contents are read back from finite storage (Turing.MultiTapePTM.LocalCfg.blockControl, Turing.MultiTapePTM.LocalCfg.blockIndex, Turing.MultiTapePTM.LocalCfg.windowContents).

Main definitions #

Main results #

Finite storage and its steps #

structure Turing.MultiTapePTM.LocalCfg (k : ℕ) (State : Type) :

Finite storage for replaying an interval: the control, the input position (0 and |input| + 1 are the end cells), every work tape around its head with the head's absolute position, and the track of the output.

def Turing.MultiTapePTM.coinAction {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (state : Option State) (symbol : Option Bool) (work : Fin k → Option Bool) (bit : Bool) :
Action k Bool State

The action from a control under a coin: the table's action when running, and the action that changes nothing when halted.

def Turing.MultiTapePTM.localCoinStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (l : LocalCfg k State) (bit : Bool) :
LocalCfg k State

One coin step on finite storage.

def Turing.MultiTapePTM.localRun {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input coins : List Bool) (l : LocalCfg k State) :
LocalCfg k State

Replaying coins on finite storage.

structure Turing.MultiTapePTM.LocalCfg.Represents {k : ℕ} {State : Type} {input : List Bool} (l : LocalCfg k State) (c : Cfg k Bool State input) :

Finite storage represents a configuration when it has its control, input position, head positions and output track, and every work tape holds the configuration's tape around its head.

theorem Turing.MultiTapePTM.withCoin_step_eq {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (bit : Bool) {input : List Bool} (c : Cfg k Bool State input) :

A coin step of a fair-coin table applies coinAction.

theorem Turing.MultiTapePTM.LocalCfg.Represents.localCoinStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) {input : List Bool} {l : LocalCfg k State} {c : Cfg k Bool State input} (h : l.Represents c) (bit : Bool) :
(machine.localCoinStep input l bit).Represents (MultiTapeTM.step c)

A coin step preserves the representation.

theorem Turing.MultiTapePTM.LocalCfg.Represents.localRun {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) {input : List Bool} {l : LocalCfg k State} {c : Cfg k Bool State input} (h : l.Represents c) (coins : List Bool) :
(machine.localRun input coins l).Represents (machine.stepCoins coins c)

A replay preserves the representation.

Reading a configuration's view off finite storage #

def Turing.MultiTapePTM.LocalCfg.blockControl {k : ℕ} {State : Type} (b : ℕ) (l : LocalCfg k State) :
BlockControl k State b

The control record of finite storage: its control, the offset of every head in its block, and its output track.

def Turing.MultiTapePTM.LocalCfg.blockIndex {k : ℕ} {State : Type} (b : ℕ) (l : LocalCfg k State) :
Option (Fin k) → ℤ

The block index of every head of finite storage.

def Turing.MultiTapePTM.LocalCfg.windowContents {k : ℕ} {State : Type} (b : ℕ) (J : Option (Fin k) → ℤ) (l : LocalCfg k State) :
Fin k → Fin 3 → ZMod b → Option Bool

The contents of the windows around block indices J, read off finite storage.

theorem Turing.MultiTapePTM.LocalCfg.Represents.blockControl {k : ℕ} {State : Type} {b : ℕ} {input : List Bool} {l : LocalCfg k State} {c : Cfg k Bool State input} (h : l.Represents c) :
theorem Turing.MultiTapePTM.LocalCfg.Represents.blockIndex {k : ℕ} {State : Type} {b : ℕ} {input : List Bool} {l : LocalCfg k State} {c : Cfg k Bool State input} (h : l.Represents c) :
theorem Turing.MultiTapePTM.LocalCfg.Represents.windowContents {k : ℕ} {State : Type} {b : ℕ} {input : List Bool} {l : LocalCfg k State} {c : Cfg k Bool State input} (h : l.Represents c) (J : Option (Fin k) → ℤ) :

The finite storage of an embedded window #

The 3 b cells of the three blocks of a window, left to right.

def Turing.MultiTapePTM.localStart {k : ℕ} {State : Type} (b : ℕ) (input : List Bool) (J : Option (Fin k) → ℤ) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) :
LocalCfg k State

The finite storage of the configuration embedded at block indices J with control record cIn and window contents wIn (Turing.embedCfg): each work tape holds the cells of its window with its head on cell b + offset, in the middle block.

theorem Turing.MultiTapePTM.windowCell_eq {k : ℕ} (b : ℕ) [NeZero b] (J : Option (Fin k) → ℤ) (w : Fin k → Fin 3 → ZMod b → Option Bool) (h : Fin k) (c : ℤ) :
windowCell b J w h (↑b * (J (some h) - 1) + c) = if 0 ≤ c then (windowCells b (w h)).getD c.toNat none else none

The window cells hold the window: the cell at offset c from the start of the window is entry c / b of the window at c mod b.

theorem Turing.MultiTapePTM.represents_localStart {k : ℕ} {State : Type} (b : ℕ) [NeZero b] (input : List Bool) (J : Option (Fin k) → ℤ) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) :
(localStart b input J cIn wIn).Represents (embedCfg b J cIn wIn)

The finite storage of an embedded window represents it.

Interval steps by finite simulation #

def Turing.MultiTapePTM.LocalIntervalStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) (coins : List Bool) (cOut : BlockControl k State b) (wOut : Fin k → Fin 3 → ZMod b → Option Bool) :

The interval condition on finite storage: replaying coins on the finite storage of the embedded window leaves the control record cOut and the window contents wOut, and moves the block of every head h by δ h.

Instances For
    @[instance_reducible]
    instance Turing.MultiTapePTM.instDecidableLocalIntervalStepOfDecidableEq {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [NeZero b] [DecidableEq State] (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) (coins : List Bool) (cOut : BlockControl k State b) (wOut : Fin k → Fin 3 → ZMod b → Option Bool) :
    Decidable (machine.LocalIntervalStep b input J δ cIn wIn coins cOut wOut)
    theorem Turing.MultiTapePTM.intervalStep_iff_localIntervalStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [NeZero b] (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) (coins : List Bool) (cOut : BlockControl k State b) (wOut : Fin k → Fin 3 → ZMod b → Option Bool) :
    machine.IntervalStep b input J δ cIn wIn coins cOut wOut ↔ machine.LocalIntervalStep b input J δ cIn wIn coins cOut wOut

    Interval steps are decided by finite simulation.

    theorem Turing.MultiTapePTM.intervalCount_eq_card_localIntervalStep {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [NeZero b] (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : BlockControl k State b) (wIn : Fin k → Fin 3 → ZMod b → Option Bool) (cOut : BlockControl k State b) (wOut : Fin k → Fin 3 → ZMod b → Option Bool) :
    machine.intervalCount b input J δ cIn wIn cOut wOut = {u : Fin b → Bool | machine.LocalIntervalStep b input J δ cIn wIn (List.ofFn u) cOut wOut}.card

    Interval tensors by finite simulation: the interval tensor counts the bit strings that satisfy the interval condition on finite storage.