Block-counting tensor networks #
The block-counting identity, Lemma 2.2 of the note Deterministic simulations of
nondeterministic and randomized time (30 October 2026) formalized in issue #1833. Fix a closed
fair-coin table machine over Bool, an input, a block length b > 0 and a movement schedule
σ of q > 0 intervals (Turing.MultiTapePTM.Schedule). The tensor network
Turing.MultiTapePTM.blockNetwork counts the accepting choice strings of q * b bits whose run
has schedule σ (Turing.MultiTapePTM.contraction_blockNetwork), so summing over the schedules
gives the accepting count A_M(x) (Turing.MultiTapePTM.sum_contraction_blockNetwork). The proof
idea is original to that note, building on the blocking of Hopcroft, Paul and Valiant
[HPV77] (compare [Wil25], Lemma 2.1 and §3.2).
The network. The schedule fixes the block index of every head at the start of every interval
(Turing.MultiTapePTM.scheduleBlock), and hence the window of three blocks around each work head.
- There is one vertex for each interval
i, and one sink vertex for each edge. - Every edge leaves an interval (
Turing.MultiTapePTM.BlockEdge): the edge.inl icarries the control record leaving intervali, and the edge.inr (i, h, d)the contents of blockscheduleBlock σ i h + d - 1of work tapehleaving intervali. Its target is the next interval whose window contains that block, or the next interval for a control record; when there is none, it ends at its sink. - The tensor of interval
iis the interval tensor ofCslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.IntervalTensor: the number of bit stringsu ∈ {0,1}^btaking the entering record and window to the leaving ones and moving every block asσ iprescribes. The entering record comes from the control edge of intervali - 1, or is the initial record fori = 0. The entering contents of a block come from the previous interval whose window contains it, or are blank when there is none. - The sink of the last control edge accepts exactly the records whose output track is
accept; every other sink is the constant1.
Edges carry letters of Turing.MultiTapePTM.BlockLetter, a control record or the contents of a
block. A letter of the wrong kind on an edge gives weight zero, because the interval leaving
it requires the right kind.
The identity. Expanding every interval tensor as a sum over its bit strings writes the
contraction as a sum over q strings of b bits, that is over choice strings of q * b bits.
For a fixed choice string, induction over the intervals shows that an assignment of letters with
nonzero weight is forced to be the true run's: the control records and the window contents of
the true run at the end of each interval, and the run is forced to follow σ. Between two
appearances of a block in windows, the block is untouched
(Turing.MultiTapePTM.workTapes_intervalStart_eq_of_notMem_blockWindow), and within an interval
the embedded window is matched to the true run (Turing.MultiTapePTM.intervalStep_view_iff).
Conversely the true run's letters have weight one exactly when the run has schedule σ and
accepts.
Size. The network has q * (3 k + 1) edges and q * (3 k + 2) vertices, no loops, maximum
degree at most 2 * (3 k + 1), and entries at most 2 ^ b. Its letters have O(b) bits, so
binarizing (Cslib.Circuits.Frontier.TensorNetwork.binarize) and subdividing it gives a
bipartite Boolean network with O(q b) edges and degree O(b), as in the note.
Main definitions #
Turing.MultiTapePTM.scheduleBlock: block indices prescribed by a schedule.Turing.MultiTapePTM.firstAfter,Turing.MultiTapePTM.lastBefore: the next and the previous appearance of a block in windows.Turing.MultiTapePTM.InWindow,Turing.MultiTapePTM.portBlock,Turing.MultiTapePTM.portOf: windows and window entries under a schedule.Turing.MultiTapePTM.BlockEdge,Turing.MultiTapePTM.BlockLetter: edges and letters.Turing.MultiTapePTM.inControl,Turing.MultiTapePTM.inWindow,Turing.MultiTapePTM.IntervalHolds,Turing.MultiTapePTM.edgeTarget: the entering record and window of an interval, its condition, and the targets of edges.Turing.MultiTapePTM.blockNetwork: the block-counting network of a schedule.
Main results #
Turing.MultiTapePTM.blockIndex_intervalStart_eq_scheduleBlock: a run followingσhas the block indices ofσ.Turing.MultiTapePTM.contraction_blockNetwork: the network ofσcounts the accepting choice strings with scheduleσ.Turing.MultiTapePTM.sum_contraction_blockNetwork: summed over the3 ^ ((k + 1) * q)schedules, the contractions give the accepting count.Turing.MultiTapePTM.card_blockEdge,Turing.MultiTapePTM.card_blockVertex,Turing.MultiTapePTM.loopless_blockNetwork,Turing.MultiTapePTM.maxDegreeLE_blockNetwork,Turing.MultiTapePTM.tensor_blockNetwork_le: size, degree and entry bounds.
References #
Block indices prescribed by a schedule #
A run following σ has the block indices of σ. If the run replaying coins from the
start has schedule entries σ j for the intervals j < i, it starts interval i with the block
indices scheduleBlock σ i.
Appearances of a block in windows #
The first index after i satisfying p, if any.
The last index before i satisfying p, if any.
Consecutive appearances: the last appearance before i has i as its next appearance.
The network #
The edges of a block-counting network of q intervals: .inl i carries the control record
leaving interval i, and .inr (i, h, d) the contents of window entry d of work tape h
leaving interval i.
The control record of a letter, or a default for block contents.
The block contents of a letter, or blank for a control record.
The weight of the last control record: one when its output track is accept.
The control record entering interval i: the initial record for i = 0, and otherwise the
letter on the control edge leaving interval i - 1.
The window contents entering interval i: each block is read from the edge leaving the
previous interval whose window contains it, and is blank if there is none.
The edge condition at interval i for the bits u: an interval step from the entering
record and window to the letters on the edges leaving i, which must be of the right kinds,
moving the blocks as σ i prescribes.
The block-counting network of the schedule σ. It has a vertex for every interval
(.inl i) and a sink for every edge (.inr e). Every edge e leaves its interval and ends at
edgeTarget σ e. The tensor of interval i counts the bit strings u ∈ {0,1}^b for which
IntervalHolds holds; the sink of the last control edge requires the output track accept, and
every other sink is 1.
The counting identity #
A work-tape cell of a block outside the window of a configuration is outside its three blocks.
The block-counting identity for one schedule. The contraction of the network of σ is the
number of choice strings of q * b bits on which the machine accepts and whose run has movement
schedule σ.
The block-counting identity (the note's Lemma 2.2, equation (2)). Summed over the
movement schedules of q > 0 intervals of b bits, the contractions of the block-counting
networks are the accepting count on q * b bits.
Size, degree and entries #
A block-counting network has q * (3 * k + 1) edges: one control edge and three block edges
per work tape for each interval.
Every entry of a block-counting network is at most 2 ^ b: an interval tensor counts bit
strings of length b, and a sink is 0 or 1.
The target of an edge is the interval reading it next, or its sink.
The tensor of an interval counts the bit strings satisfying its condition.
The sink of a control edge accepts the last control record, and is 1 otherwise.
A block-counting network has no loops.
The degree bound. An interval has its 3 k + 1 leaving edges and at most 3 k + 1
entering edges, and a sink has at most one edge.