Documentation

Complexity.Computability.TreeEval.Reader.Defs

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 #

References #

Residues #

The sum modulo p.

Instances For

    The product modulo p.

    Instances For

      The negation modulo p.

      Instances For

        The n-th power modulo p, by repeated multiplication.

        Instances For

          The residue of the unit of round j.

          Instances For

            The inverse of the unit of round j modulo a prime p, by Fermat's little theorem.

            Instances For

              The residue of a sign.

              Instances For
                def Cslib.TreeEval.Reader.chi (p : ℕ) (b : Bool) (x : ℕ) :

                The residue of x if b, and of 1 - x otherwise.

                Instances For
                  def Cslib.TreeEval.Reader.weight (p ℓ k : ℕ) (x y : List ℕ) :

                  The weight of the table entries for the inputs indexed by k at the masked registers x and y: the product of chi over the low and the high ℓ bits of k.

                  Instances For

                    Change the element at i of a list by g.

                    Instances For

                      Registers #

                      @[reducible, inline]

                      Three registers of residues.

                      Instances For

                        Register r.

                        Instances For

                          Replace register r.

                          Instances For
                            def Cslib.TreeEval.Reader.Regs.scale (p : ℕ) (r : Fin 3) (a : ℕ) (R : Regs) :

                            Multiply register r by a modulo p.

                            Instances For

                              The machine #

                              The control state.

                              • hdrLength (n : ℕ) : Ctl

                                Reading the value length from the header, n ones read so far.

                              • hdrHeight (n : ℕ) : Ctl

                                Reading the height from the header, n ones read so far.

                              • prime (q d : ℕ) : Ctl

                                Searching the prime: testing the candidate q against the divisor d.

                              • run : Ctl

                                A step of the iterative procedure.

                              • leaf (i : ℕ) : Ctl

                                Reading bit i of the leaf at the current path.

                              • scan (k : ℕ) (acc : List ℕ) : Ctl

                                Reading bit k of the table of the gate of the top frame, with the sums so far.

                              • done : Ctl

                                Halted, after emitting the value.

                              Instances For

                                A state of the machine.

                                • ell : ℕ

                                  The value length ℓ.

                                • height : ℕ

                                  The height.

                                • p : ℕ

                                  The prime.

                                • regs : Regs

                                  The registers.

                                • The stack of frames, innermost first.

                                • mode : Iter.Mode

                                  The mode of the iterative procedure.

                                • ctl : Ctl

                                  The control state.

                                Instances For

                                  The offset in the encoding of the node at the path of a stack.

                                  Instances For

                                    The steps of the iterative procedure, without input.

                                    Instances For
                                      def Cslib.TreeEval.Reader.subtractSums (p c : ℕ) (t : Fin 3) (acc : List ℕ) (R : Regs) :

                                      Subtract c times the sums acc from register t, modulo p.

                                      Instances For

                                        A step, given the bit read.

                                        Instances For

                                          The address read by a step.

                                          Instances For

                                            The initial state: reading the header.

                                            Instances For

                                              The Tree Evaluation read machine.

                                              Instances For