Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.FastContractionMachine

The native machine of the fast contraction algorithm #

The stack recursion of Cslib.Circuits.Frontier.FastContraction.scheme, for a child builder mk, as one native machine for the contraction modulo 2 ^ P of an explicit network (r, G), with the precision P in binary: the root descriptors are tables (T = List ℕ), read by the entry procedure tableEntry. The encodings, the leaf certificate (FastContraction.leafCertificate ce, from a native certificate ce of any entry procedure), the root network (FastContraction.rootNet) and its polynomial-time construction are stated for every type of root descriptors.

The root. The precision is first capped at the encoded length of the network (ExplicitTensorNetwork.capPrecision), which does not change the residue. The root call (FastContraction.root) has the scale s = m, the number of edges of G, depth 0, edge bound m + 1, the capped precision p, the tables of G as descriptors (FastContraction.rootNet) and the modulus f = X ^ (2 ⬝ 3 ^ t) + X ^ (3 ^ t) + 1 (FastContraction.modulus), irreducible modulo 2 (Cslib.irreducible_trinomial), whose 2 ⬝ 3 ^ t > 4 ⌊log₂ m⌋ + 2 binary digits give the interpolation points of every call of the schedule.

The fuel and the fallback. The number of calls of the recursion depends, through the schedule's constant, on the ratio of the precision to the number of edges, which the machine does not know in advance. So the machine runs the recursion for a fixed clock 2 ^ (K₀ (m + p) / √⌊log₂ (m + p)⌋) (FastContraction.fuel), and returns the constant coordinate of the root's value when the run has returned a value tagged with depth 0, and direct summation otherwise (FastContraction.fastValue). A value tagged 0 is the root's value for every fuel (FastContraction.eq_value_of_run). So for a predicate WF on calls, if the step of every well-formed active call is correct (FastContraction.StepCorrect) and well-formedness passes to the children (FastContraction.WFChildren), the result is the contraction modulo 2 ^ P on every input whose root call satisfies WF, whether or not the clock suffices (FastContraction.fastValue_eq); the clock matters only for the running time.

Main definitions #

Main results #

References #

Encodings #

@[reducible, inline]

The encoding of the parameters of a call: the scale, the depth, the edge bound and the precision in unary, the coefficients of the modulus in binary and the number of rows in binary.

@[reducible, inline]

The encoding of a call: its parameters and its network, with the root descriptors encoded by encT.

@[reducible, inline]

The encoding of a frame: the cursor state and the accumulator, in binary.

@[reducible, inline]

The encoding of a tagged value: the depth in unary and the coefficient list in binary.

The leaves #

The leaf certificate: direct summation over the coefficient lists of A_p, with the native evaluator of the vertex descriptors built from a native certificate ce of the entry procedure of the roots, tagged with the depth.

The root #

The exponent t of the modulus, with 2 ^ (t + 1) > 4 ⌊log₂ m⌋ + 2.

The modulus X ^ (2 ⬝ 3 ^ t) + X ^ (3 ^ t) + 1, by its coefficients below the leading one.

The modulus has 2 ⬝ 3 ^ t coefficients.

The modulus has a coefficient.

The modulus is the trinomial X ^ (2 ⬝ 3 ^ t) + X ^ (3 ^ t) + 1 over ℤ.

The root descriptors of a network as vertex descriptors; for an explicit network, its tables.

The root call of a capped input (p, r, G): scale m, depth 0, edge bound m + 1, precision p, the modulus and the tables of G.

The clock of a capped input (p, r, G): 2 ^ (K₀ (m + p) / √⌊log₂ (m + p)⌋).

The root computes the contraction of G: in A_p, the contraction of the tables read as constants is the image of the contraction of G.

theorem Cslib.Circuits.Frontier.FastContraction.getD_mod_of_val_eq {p : ℕ} {fl y : List ℕ} {k : ℕ} (hfl : fl ≠ []) (h : GaloisRingArith.val p fl y = ↑k) :
y.getD 0 0 % 2 ^ p = k % 2 ^ p

Reading off the constant coordinate. If a coefficient list has the value of a natural number k in A_p, with f of positive degree, its constant coordinate is k modulo 2 ^ p.

The root and the clock in polynomial time #

3 ^ t ≤ (4 ⌊log₂ m⌋ + 2) ^ 2 for the exponent t of the modulus.

The result #

The result of the machine on an input (P, r, G): with the capped precision p, the constant coordinate of a returned root value modulo 2 ^ p if the run returns a value tagged 0, and direct summation otherwise.

The machine is correct on well-formed inputs, whether or not the clock fuel suffices. If the step of an active call is correct and well-formedness passes to the children, then on every input whose root is well-formed the result is the contraction modulo 2 ^ P.

The machine #

@[reducible, inline]

The encoding of an input (P, r, G): the precision and the number of rows in binary, and the network.

The fast machine: cap the precision and run the recursion; on a value tagged 0, read off its constant coordinate, and otherwise sum directly. It computes fastValue.