A read machine for Tree Evaluation #
The Cook–Mertz procedure as a Turing.ReadMachine on the encoding of an instance. Its state holds
natural numbers only, so that one state type serves all instances: the value length, the height
and the prime p found at the start, three registers of residues modulo p, the stack of frames of
Cslib.TreeEval.Iter and a control state.
The machine reads the header, finds the least prime p ≥ 2ℓ + 2, and then follows the iterative
procedure over ZMod p with the units 1, …, p - 1, reading the input only at a leaf, bit by bit,
and for the update of a round, in one pass over the table of the gate. That pass accumulates, for
every output bit i, the sum of the weights ∏ⱼ χ of the table entries for i that are set,
which is the multilinear extension of output bit i at the masked registers. At the end it emits
register 2.
Main definitions #
Cslib.TreeEval.Reader.State: the states of the machine.Cslib.TreeEval.Reader.machine: the machine.
References #
- J. Cook and I. Mertz, Tree Evaluation is in Space O(log n · log log n)
- O. Goldreich, On the Cook–Mertz Tree Evaluation procedure, Algorithm 1, which the machine runs.
Residues #
The inverse of the unit of round j modulo a prime p, by Fermat's little theorem.
Instances For
Registers #
Three registers of residues.
Instances For
The machine #
The control state.
- hdrLength (n : ℕ) : Ctl
Reading the value length from the header,
nones read so far. - hdrHeight (n : ℕ) : Ctl
Reading the height from the header,
nones read so far. - prime (q d : ℕ) : Ctl
Searching the prime: testing the candidate
qagainst the divisord. - run : Ctl
A step of the iterative procedure.
- leaf (i : ℕ) : Ctl
Reading bit
iof the leaf at the current path. - scan (k : ℕ) (acc : List ℕ) : Ctl
Reading bit
kof the table of the gate of the top frame, with the sums so far. - done : Ctl
Halted, after emitting the value.
Instances For
The offset in the encoding of the node at the path of a stack.
Instances For
The Tree Evaluation read machine.