Documentation

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

Explicit block-counting networks #

The block-counting network of a schedule (Turing.MultiTapePTM.blockNetwork) carries structured letters on its edges: control records and block contents (Turing.MultiTapePTM.BlockLetter). This module writes it out as an explicit Boolean tensor network (Cslib.Circuits.Frontier.ExplicitTensorNetwork), the form that a contraction algorithm reads, completing the construction of Lemma 2.2 of the note Deterministic simulations of nondeterministic and randomized time (30 October 2026) formalized in issue #1833:

  1. Binarize by a concrete injective code of the letters (Turing.MultiTapePTM.letterCode), in letterBits k s b = (s + k + 4) * b bits, where s numbers the states. A letter is numbered by Turing.MultiTapePTM.letterEquiv, composed of the standard numberings of finite products, sums, options and functions (finProdFinEquiv, finSumFinEquiv, finSuccEquiv, finFunctionFinEquiv); its code is the binary digits of its number.
  2. Subdivide every Boolean edge by an equality tensor, which makes the network bipartite.
  3. Write out (Cslib.Circuits.Frontier.TensorNetwork.toExplicit), numbering the old vertices (the intervals and sinks) first and the subdivision vertices after them, both by concrete numberings (Turing.MultiTapePTM.explicitVertexEquiv, Turing.MultiTapePTM.explicitEdgeEquiv).

Each step preserves the contraction, so the explicit networks of the schedules still sum to the accepting count (Turing.MultiTapePTM.sum_contraction_explicitBlockNetwork).

Size. With q intervals, k work tapes and m = letterBits k s b, the explicit network has 2 * (q * (3 * k + 1) * m) edges and maximum degree at most 2 * (3 * k + 1) * m, both O(b) per interval. Its first q * (3 * k + 2) vertices are the rows of a bipartition: every edge has exactly one port at a row and one at a column (Cslib.Circuits.Frontier.DescribedNetwork.IsRowsFirstBipartite). Every table has length 2 ^ (number of ports), and its entries are at most 2 ^ b.

These are the inputs of the Boolean tensor contraction theorem [OpenAI2026ETH, Theorem D.1] as the counting simulation of #1833 uses it: with b = ⌈log₂ (t + 2)⌉ and q * b ≤ 2 t, the networks have O(t) edges and maximum degree O(log t).

Main definitions #

Main results #

References #

The output tracks numbered empty ↦ 0, accept ↦ 1, other ↦ 2.

Numbering and coding the letters #

The residues modulo b > 0 numbered by their values.

@[simp]
theorem Turing.MultiTapePTM.val_zmodEquiv {b : ℕ} [NeZero b] (r : ZMod b) :
↑((zmodEquiv b) r) = r.val

The contents of a cell numbered none ↦ 0, some false ↦ 1, some true ↦ 2.

def Turing.MultiTapePTM.controlEquiv {k s : ℕ} {State : Type} {b : ℕ} [NeZero b] (e : State ≃ Fin s) :
BlockControl k State b ≃ Fin ((s + 1) * (b ^ (k + 1) * 3))

The control records numbered: the state (with none first, then the states numbered by e), then the head offsets as k + 1 digits in base b, then the output track.

The block contents numbered as b digits in base 3.

def Turing.MultiTapePTM.letterEquiv {k s : ℕ} {State : Type} {b : ℕ} [NeZero b] (e : State ≃ Fin s) :
BlockLetter k State b ≃ Fin ((s + 1) * (b ^ (k + 1) * 3) + 3 ^ b)

The letters numbered: the control records first (Turing.MultiTapePTM.controlEquiv), then the block contents (Turing.MultiTapePTM.contentsEquiv).

The number of bits of a letter: (s + k + 4) * b, for s states and k work tapes.

theorem Turing.MultiTapePTM.card_letter_le_two_pow {k s b : ℕ} [NeZero b] :
(s + 1) * (b ^ (k + 1) * 3) + 3 ^ b ≤ 2 ^ letterBits k s b

Every letter number fits in letterBits k s b bits.

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

The letter code: the letterBits k s b binary digits, least significant first, of the number of a letter (Turing.MultiTapePTM.letterEquiv).

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

The letter code is injective: letter numbers fit in letterBits k s b bits.

Numbering the edges and vertices #

The edges of a block-counting network numbered: the control edges first, then the block edges (i, h, d) in lexicographic order.

def Turing.MultiTapePTM.explicitVertexEquiv (k q m : ℕ) :
(Fin q ⊕ BlockEdge k q) ⊕ BlockEdge k q × Fin m ≃ Fin (q * (3 * k + 2) + q * (3 * k + 1) * m)

The vertices of the explicit network numbered: the old vertices first (the intervals, then the sinks in the order of their edges), then the subdivision vertices, one for each copy (e, j) of an edge.

def Turing.MultiTapePTM.explicitEdgeEquiv (k q m : ℕ) :
BlockEdge k q × Fin m ⊕ BlockEdge k q × Fin m ≃ Fin (2 * (q * (3 * k + 1) * m))

The edges of the explicit network numbered: the source halves of the copies (e, j) first, then their target halves.

theorem Turing.MultiTapePTM.explicitVertexEquiv_inl (k q m : ℕ) (v : Fin q ⊕ BlockEdge k q) :
↑((explicitVertexEquiv k q m) (Sum.inl v)) < q * (3 * k + 2)

The old vertices come first.

theorem Turing.MultiTapePTM.le_explicitVertexEquiv_inr (k q m : ℕ) (p : BlockEdge k q × Fin m) :
q * (3 * k + 2) ≤ ↑((explicitVertexEquiv k q m) (Sum.inr p))

The subdivision vertices come after the old ones.

The explicit network #

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

The explicit block-counting network of the schedule σ: the block-counting network binarized by the letter code (Turing.MultiTapePTM.letterCode), subdivided by equality tensors and written out with the old vertices first. Its first q * (3 * k + 2) vertices are the rows of its bipartition.

theorem Turing.MultiTapePTM.contraction_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) [Fintype State] :
(machine.explicitBlockNetwork input b σ e).contraction = (machine.blockNetwork input b σ).contraction

Writing the network out preserves its contraction.

theorem Turing.MultiTapePTM.sum_contraction_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (e : State ≃ Fin s) [Finite State] (hq : 0 < q) :
∑ σ : Schedule k q, (machine.explicitBlockNetwork input b σ e).contraction = machine.acceptCount input (q * b)

The block-counting identity for the explicit networks (the note's Lemma 2.2, equation (2)). Summed over the movement schedules of q > 0 intervals of b bits, the contractions of the explicit block-counting networks are the accepting count on q * b bits.

theorem Turing.MultiTapePTM.numEdges_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) :
(machine.explicitBlockNetwork input b σ e).numEdges = 2 * (q * (3 * k + 1) * letterBits k s b)

The explicit network has 2 * (q * (3 * k + 1) * letterBits k s b) edges: two halves of each of the letterBits k s b copies of each of the q * (3 * k + 1) edges.

theorem Turing.MultiTapePTM.length_vertices_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) :
(machine.explicitBlockNetwork input b σ e).vertices.length = q * (3 * k + 2) + q * (3 * k + 1) * letterBits k s b

The explicit network has q * (3 * k + 2) old vertices and one subdivision vertex for each copy of an edge.

theorem Turing.MultiTapePTM.maxDegree_explicitBlockNetwork_le {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) :
(machine.explicitBlockNetwork input b σ e).maxDegree ≤ 2 * (3 * k + 1) * letterBits k s b

The degree bound: at most 2 * (3 * k + 1) * letterBits k s b ports at every vertex, O(b) for a fixed machine.

theorem Turing.MultiTapePTM.isRowsFirstBipartite_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) :

The bipartition: the first q * (3 * k + 2) vertices, the old ones, are rows; every edge joins an old vertex to a subdivision vertex.

theorem Turing.MultiTapePTM.admissible_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) {t : ℕ} (hb : b ≤ 3 * Nat.log 2 t) (hqb : q * b ≤ 2 * t) :
Cslib.Circuits.Frontier.DescribedNetwork.IsRowsFirstBipartite (machine.explicitBlockNetwork input b σ e) (q * (3 * k + 2)) ∧ (machine.explicitBlockNetwork input b σ e).numEdges ≤ 6 * (3 * k + 1) * (s + k + 4) * t ∧ (machine.explicitBlockNetwork input b σ e).maxDegree ≤ 6 * (3 * k + 1) * (s + k + 4) * Nat.log 2 t

Admissibility at a clock t. With blocks of b ≤ 3 ⌊log₂ t⌋ steps and padded time q * b ≤ 2 t, the explicit network is rows-first bipartite with O(t) edges and maximum degree O(log t), with the constant 6 (3 k + 1) (s + k + 4) of the machine. For the counting simulation, b = ⌈log₂ (t + 2)⌉ (Nat.clog_two_add_two_le_three_mul_log_two).

theorem Turing.MultiTapePTM.length_table_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) {p : List ℕ × List ℕ} (hp : p ∈ (machine.explicitBlockNetwork input b σ e).vertices) :
p.2.length = 2 ^ p.1.length

Every table of the explicit network lists the values at all bits on its ports.

theorem Turing.MultiTapePTM.entry_le_explicitBlockNetwork {k q s : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) (input : List Bool) (b : ℕ) [NeZero b] (σ : Schedule k q) (e : State ≃ Fin s) {p : List ℕ × List ℕ} (hp : p ∈ (machine.explicitBlockNetwork input b σ e).vertices) {a : ℕ} (ha : a ∈ p.2) :
a ≤ 2 ^ b

The entry bound: every table entry of the explicit network is at most 2 ^ b.