Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.IntervalCount

Interval counts on list data #

The interval tensor of the block-counting networks of #1833 (Turing.MultiTapePTM.intervalCount) takes a control record with offsets in ZMod b and window contents indexed by ZMod b. This module restates it on plain data, the form in which a polynomial-time construction of the networks computes it: a control record with offsets as natural numbers (Turing.MultiTapePTM.ControlData, Turing.MultiTapePTM.controlData) and the window of each work tape as the list of its 3 b cells (Turing.MultiTapePTM.windowCells).

On such data, the finite storage of the embedded window is Turing.MultiTapePTM.localStartData, and the interval condition (Turing.MultiTapePTM.LocalIntervalStepData) compares the state and output track after the replay, the coordinate of every head with its prescribed block start plus offset, and the cells of every window with the given lists. Block indices and offsets need no division: a coordinate z has block index q and offset r modulo b exactly when r < b and z = b q + r. The interval count (Turing.MultiTapePTM.localIntervalCount) counts the coin strings of the enumeration Cslib.BitString.enumList b satisfying the condition, and agrees with the interval tensor (Turing.MultiTapePTM.localIntervalCount_eq_intervalCount).

Main definitions #

Main results #

Plain data #

@[reducible, inline]

A control record on plain data: the state, the offset of every head as a natural number, and the output track.

def Turing.MultiTapePTM.controlData {k : ℕ} {State : Type} {b : ℕ} (c : BlockControl k State b) :
ControlData k State

A control record as plain data: its offsets by their values.

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

The finite storage of the configuration embedded at block indices J with the control record cIn and the window cells wIn (the 3 b cells of each window, left to right): each work tape holds the cells of its window with its head on cell b + offset.

theorem Turing.MultiTapePTM.localStartData_controlData {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) :
(localStartData b input J (controlData cIn) fun (h : Fin k) => windowCells b (wIn h)) = localStart b input J cIn wIn

On the data of a control record and window contents, localStartData is localStart.

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

The coordinate of every head of finite storage: the input position less one for the input head, and the absolute position for a work head.

def Turing.MultiTapePTM.LocalCfg.windowCellsAt {k : ℕ} {State : Type} (b : ℕ) (j : ℤ) (l : LocalCfg k State) (h : Fin k) :

The 3 b cells of the window of work tape h around block index j, left to right.

Block indices and offsets without division #

theorem Turing.MultiTapePTM.intCast_eq_and_ediv_eq_iff {b : ℕ} [NeZero b] (z q : ℤ) (r : ZMod b) :
↑z = r ∧ z / ↑b = q ↔ z = ↑b * q + ↑r.val

A coordinate has block index q and offset r exactly when it is b q + r.

theorem Turing.MultiTapePTM.blockControl_eq_and_blockIndex_iff {k : ℕ} {State : Type} {b : ℕ} [NeZero b] (l : LocalCfg k State) (c : BlockControl k State b) (J : Option (Fin k) → ℤ) :
(LocalCfg.blockControl b l = c ∧ ∀ (head : Option (Fin k)), LocalCfg.blockIndex b l head = J head) ↔ l.state = c.1 ∧ l.track = c.2.2 ∧ ∀ (head : Option (Fin k)), l.headCoord head = ↑b * J head + ↑(c.2.1 head).val

The offsets and block indices of finite storage, compared with a control record's offsets and prescribed block indices, are its head coordinates.

theorem Turing.MultiTapePTM.windowContents_eq_iff {k : ℕ} {State : Type} {b : ℕ} [NeZero b] (l : LocalCfg k State) (J : Option (Fin k) → ℤ) (w : Fin k → Fin 3 → ZMod b → Option Bool) :
LocalCfg.windowContents b J l = w ↔ ∀ (h : Fin k), LocalCfg.windowCellsAt b (J (some h)) l h = windowCells b (w h)

The window contents of finite storage are w exactly when the cells of every window are the window cells of w.

The interval condition and count on plain data #

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

The interval condition on plain data: replaying coins on the finite storage of the embedded window leaves the state and the output track of cOut, puts every head at its prescribed block start b (J + δ) plus its offset in cOut, which is below b, and leaves the window cells wOut.

Instances For
    @[instance_reducible]
    instance Turing.MultiTapePTM.instDecidableLocalIntervalStepDataOfDecidableEq {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [DecidableEq State] (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : ControlData k State) (wIn : Fin k → List (Option Bool)) (cOut : ControlData k State) (wOut : Fin k → List (Option Bool)) (coins : List Bool) :
    Decidable (machine.LocalIntervalStepData b input J δ cIn wIn cOut wOut coins)
    theorem Turing.MultiTapePTM.localIntervalStepData_iff {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) (coins : List Bool) :
    machine.LocalIntervalStepData b input J δ (controlData cIn) (fun (h : Fin k) => windowCells b (wIn h)) (controlData cOut) (fun (h : Fin k) => windowCells b (wOut h)) coins ↔ machine.LocalIntervalStep b input J δ cIn wIn coins cOut wOut

    The interval condition on plain data is the interval condition on finite storage.

    def Turing.MultiTapePTM.localIntervalCount {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [DecidableEq State] (input : List Bool) (J : Option (Fin k) → ℤ) (δ : Option (Fin k) → SignType) (cIn : ControlData k State) (wIn : Fin k → List (Option Bool)) (cOut : ControlData k State) (wOut : Fin k → List (Option Bool)) :

    The interval count on plain data: the number of coin strings of b bits satisfying the interval condition.

    theorem Turing.MultiTapePTM.localIntervalCount_eq_intervalCount {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [DecidableEq State] [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.localIntervalCount b input J δ (controlData cIn) (fun (h : Fin k) => windowCells b (wIn h)) (controlData cOut) fun (h : Fin k) => windowCells b (wOut h)) = machine.intervalCount b input J δ cIn wIn cOut wOut

    The interval count on plain data is the interval tensor.