Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.ExplicitBlockNetwork.Table

The tables of an explicit block-counting network, on numbers #

The tables of the explicit block-counting network of a schedule (Turing.MultiTapePTM.explicitBlockNetwork) are values of the tensors of the block-counting network (Turing.MultiTapePTM.blockNetwork) at letters read from the bits of a table index. This module computes them from numbers, the form in which a polynomial-time construction produces them.

Main definitions #

Main results #

Products of numberings #

Decoding letters #

The number of control records, which come first among the letters.

The number of letters.

def Turing.MultiTapePTM.stateOfFin {s : ℕ} {State : Type} (e : State ≃ Fin s) (i : Fin (s + 1)) :
Option State

The state numbered i ≤ s: none for 0, and the state numbered i - 1 by e otherwise.

def Turing.MultiTapePTM.decodeControlData {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b n : ℕ) :
ControlData k State

The control record of a number, on plain data: the state from the quotient by b ^ (k + 1) * 3 (capped at s), the offsets as digits in base b and the output track from the remainder.

theorem Turing.MultiTapePTM.decodeControlData_controlEquiv {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (c : BlockControl k State b) :

Decoding control records inverts their numbering.

def Turing.MultiTapePTM.controlDataOfNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b n : ℕ) :
ControlData k State

The control record entering an interval from a letter number: the decoded record of a control letter, and the default record of block contents.

The cell r of the block contents numbered n, blank for a control record.

The accepting weight of the letter numbered n: one for a control record with output track accept.

def Turing.MultiTapePTM.decodeLetter {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) :
BlockLetter k State b

The letter of a number: the control record of that number for a number below controlCount, and otherwise the block contents of the remainder of n - controlCount modulo 3 ^ b. Below letterCount this inverts Turing.MultiTapePTM.letterEquiv.

theorem Turing.MultiTapePTM.decodeLetter_letterEquiv {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (l : BlockLetter k State b) :
decodeLetter e b ↑((letterEquiv e) l) = l

Decoding letters inverts their numbering.

theorem Turing.MultiTapePTM.decodeLetter_of_lt {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] {n : ℕ} (hn : n < letterCount k s b) :

Below letterCount, the letter of a number is the numbered letter.

theorem Turing.MultiTapePTM.controlData_control_decodeLetter {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) :

The control record of a decoded letter.

theorem Turing.MultiTapePTM.contents_decodeLetter {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) (r : ZMod b) :

The cells of a decoded letter.

theorem Turing.MultiTapePTM.acceptWeight_decodeLetter {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) :

The accepting weight of a decoded letter.

The window entering an interval, on numbers #

The last interval before i whose window contains the block δ of interval i's window, for the head with digit offset c, found by searching the earlier intervals from the latest.

theorem Turing.MultiTapePTM.lastBeforeNum_eq {k q : ℕ} (σ : ℕ) (i : Fin q) (h : Fin k) (δ : Fin 3) :
lastBeforeNum k σ (↑h + 1) ↑i ↑δ = Option.map Fin.val (lastBefore (InWindow (scheduleOfNat k q σ) h (portBlock (scheduleOfNat k q σ) i h δ)) i)

Previous appearances on numbers.

def Turing.MultiTapePTM.portOfNum (k σ c i i' δ : ℕ) :

The window entry, in the window of interval i', of the block δ of interval i's window, for the head with digit offset c: b(i) + δ - b(i') mod 3 from the digit counts.

theorem Turing.MultiTapePTM.val_portOf {k q : ℕ} (σ : ℕ) (i i' : Fin q) (h : Fin k) (δ : Fin 3) :
↑(portOf (scheduleOfNat k q σ) i' h (portBlock (scheduleOfNat k q σ) i h δ)) = portOfNum k σ (↑h + 1) ↑i ↑i' ↑δ

Window entries on numbers.

The tensor of an interval #

theorem Turing.MultiTapePTM.card_intervalHolds {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (i : Fin q) {x : BlockEdge k q → BlockLetter k State b} {cOut : BlockControl k State b} {wOut : Fin k → Fin 3 → ZMod b → Option Bool} (hc : x (Sum.inl i) = Sum.inl cOut) (hw : ∀ (h : Fin k) (d : Fin 3), x (Sum.inr (i, h, d)) = Sum.inr (wOut h d)) :
{u : Fin b → Bool | machine.IntervalHolds input b σ i x u}.card = machine.intervalCount b input (scheduleBlock σ ↑i) (σ i) (machine.inControl b i x) (inWindow σ i x) cOut wOut

The tensor of an interval is an interval count when the letters leaving it are a control record and block contents.

theorem Turing.MultiTapePTM.card_intervalHolds_eq_zero {k q : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) (σ : Schedule k q) (i : Fin q) {x : BlockEdge k q → BlockLetter k State b} (hx : ¬((∃ (cOut : BlockControl k State b), x (Sum.inl i) = Sum.inl cOut) ∧ ∀ (h : Fin k) (d : Fin 3), ∃ (w : ZMod b → Option Bool), x (Sum.inr (i, h, d)) = Sum.inr w)) :
{u : Fin b → Bool | machine.IntervalHolds input b σ i x u}.card = 0

The tensor of an interval vanishes when a letter leaving it has the wrong kind.

The tensors on numbers #

The block indices at the start of interval i of the schedule of σ, as digit counts.

The movements of the blocks in interval i of the schedule of σ.

def Turing.MultiTapePTM.inControlNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) (initial : State) (L : ℕ → ℕ) (i : ℕ) :
ControlData k State

The control record entering interval i, from the letter numbers L of the edges.

def Turing.MultiTapePTM.inCellsNum (k q s b σ : ℕ) (L : ℕ → ℕ) (i h : ℕ) :

The cells of the window of work tape h entering interval i, from the letter numbers L of the edges of a schedule number σ with q intervals.

def Turing.MultiTapePTM.outCellsNum (k q s b : ℕ) (L : ℕ → ℕ) (i h : ℕ) :

The cells of the window of work tape h leaving interval i, from the letter numbers L of the edges.

def Turing.MultiTapePTM.intervalEntryNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ : ℕ) (L : ℕ → ℕ) (i : ℕ) :

The tensor of interval i on numbers, from the letter numbers L of the edges: the interval count on plain data when the control edge leaving i carries a control record and its block edges carry block contents, and zero otherwise.

def Turing.MultiTapePTM.oldEntryNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ : ℕ) (L : ℕ → ℕ) (v : ℕ) :

The tensor of an old vertex on numbers: an interval (v < q), or the sink of the edge numbered v - q, which accepts the last control record and is 1 otherwise.

The tensors of the block-counting network on numbers #

theorem Turing.MultiTapePTM.exists_decodeLetter_eq_inl_iff {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) :
(∃ (c : BlockControl k State b), decodeLetter e b n = Sum.inl c) ↔ n < controlCount k s b

A decoded letter is a control record exactly below controlCount.

theorem Turing.MultiTapePTM.exists_decodeLetter_eq_inr_iff {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (n : ℕ) :
(∃ (w : ZMod b → Option Bool), decodeLetter e b n = Sum.inr w) ↔ ¬n < controlCount k s b

A decoded letter is block contents exactly from controlCount on.

theorem Turing.MultiTapePTM.blockNetwork_tensor_decodeLetter {k q s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (σ : ℕ) (u : Fin q ⊕ BlockEdge k q) (L : ℕ → ℕ) :
((machine.blockNetwork input b (scheduleOfNat k q σ)).tensor u fun (e' : BlockEdge k q) => decodeLetter e b (L ↑((blockEdgeEquiv k q) e'))) = oldEntryNum e b machine input q σ L ↑((explicitVertexEquiv k q (letterBits k s b)) (Sum.inl u))

The tensors of the block-counting network on numbers. At the letters decoded from numbers L of the edges (Turing.MultiTapePTM.decodeLetter), the tensor of an old vertex of the explicit network is Turing.MultiTapePTM.oldEntryNum at its number.

Reading letters from table indices #

theorem Turing.MultiTapePTM.letterCode_eq_iff {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (l : BlockLetter k State b) (bits : Fin (letterBits k s b) → Bool) :

Bits are the code of a letter exactly when they write its number.

theorem Turing.MultiTapePTM.mem_range_letterCode_iff {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] (bits : Fin (letterBits k s b) → Bool) :

Reading a letter code: bits are the code of a letter exactly when the number they write is below letterCount.

theorem Turing.MultiTapePTM.invFun_letterCode {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [NeZero b] {bits : Fin (letterBits k s b) → Bool} (h : Cslib.BitString.lsbValue (List.ofFn bits) < letterCount k s b) :

The letter read from the code bits is the decoded letter of their number.

The tables on numbers #

def Turing.MultiTapePTM.readNum (m : ℕ) (P : List ℕ) (j base : ℕ) :

The letter number read from the table index j at the m port numbers base, …, base + m - 1 of the port list P: its bit r is the bit of j at the position of port base + r in P.

The first number of the explicit edges of the block edge numbered n at the old vertex numbered v: its source halves when v is the interval it leaves, and its target halves otherwise.

def Turing.MultiTapePTM.lettersAt (k q m : ℕ) (P : List ℕ) (j v n : ℕ) :

The letter numbers of the block edges read at the old vertex numbered v from the table index j and the ports P.

def Turing.MultiTapePTM.validNum (k q s b σ : ℕ) (P : List ℕ) (j v : ℕ) :

Whether every block edge at the old vertex numbered v carries a letter number, read from the table index j and the ports P, below letterCount.

def Turing.MultiTapePTM.tableEntryNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ v : ℕ) (P : List ℕ) (j : ℕ) :

The table entry on numbers of the vertex numbered v with ports P at the table index j: for an old vertex, its tensor at the letters read from j when they are all valid, and zero otherwise; for the subdivision vertex of a copy, equality of the bits on its two halves.

def Turing.MultiTapePTM.explicitTableNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ v : ℕ) :

The table on numbers of the vertex numbered v: its entries at all indices below 2 ^ (number of ports).

def Turing.MultiTapePTM.explicitVerticesNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ : ℕ) :

The vertices of the explicit network on numbers: the ports and the table of every vertex number.

theorem Turing.MultiTapePTM.explicitTable_eq_explicitTableNum {k q s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) [NeZero b] (σ : ℕ) (w : (Fin q ⊕ BlockEdge k q) ⊕ BlockEdge k q × Fin (letterBits k s b)) :
((machine.blockNetwork input b (scheduleOfNat k q σ)).binarize (letterCode e)).subdivide.explicitTable (explicitEdgeEquiv k q (letterBits k s b)) w = explicitTableNum e b machine input q σ ↑((explicitVertexEquiv k q (letterBits k s b)) w)

The tables of the explicit network on numbers: the table of every vertex of the binarized, subdivided network, with the edges numbered by explicitEdgeEquiv, is explicitTableNum at the number of the vertex.

def Turing.MultiTapePTM.explicitNetworkNum {k s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) (q σ : ℕ) :

The explicit block-counting network on numbers: 2 q (3 k + 1) m edges and the vertices explicitVerticesNum.

theorem Turing.MultiTapePTM.explicitBlockNetwork_eq_explicitNetworkNum {k q s : ℕ} {State : Type} (e : State ≃ Fin s) (b : ℕ) [DecidableEq State] (machine : MultiTapePTM k Bool State) (input : List Bool) [NeZero b] (σ : ℕ) :
machine.explicitBlockNetwork input b (scheduleOfNat k q σ) e = explicitNetworkNum e b machine input q σ

The explicit block-counting network is computed on numbers: for the schedule of σ, explicitBlockNetwork is explicitNetworkNum.

Port counts #

theorem Turing.MultiTapePTM.explicitSrcNum_lt {k q m σ j : ℕ} (hj : j < 2 * (q * (3 * k + 1) * m)) :
explicitSrcNum k q m σ j < q * (3 * k + 2)

Every explicit edge starts at an old vertex.

theorem Turing.MultiTapePTM.explicitTgtNum_lt {k q m j : ℕ} (hj : j < 2 * (q * (3 * k + 1) * m)) :
explicitTgtNum k q m j < q * (3 * k + 2) + q * (3 * k + 1) * m

Every explicit edge ends at a vertex.

theorem Turing.MultiTapePTM.explicitPortsNum_eq_nil {k q m σ v : ℕ} (hv : q * (3 * k + 2) + q * (3 * k + 1) * m ≤ v) :
explicitPortsNum k q m σ v = []

A number past the vertices has no ports.

theorem Turing.MultiTapePTM.length_explicitPortsNum_le {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (b : ℕ) [NeZero b] (e : State ≃ Fin s) (σ v : ℕ) :
(explicitPortsNum k q (letterBits k s b) σ v).length ≤ 2 * (3 * k + 1) * letterBits k s b

The degree bound on numbers: every vertex number has at most 2 (3 k + 1) (letterBits k s b) ports.