Documentation

Complexity.Computability.Circuit.Rational.Runtime.Lift.Defs

List programs and evaluation equivalences for the integer lift tables #

At every grid point the executable generator materializes the integer lift matrices Rational.Generator.integralLift, built from the integer Taylor test matrices Rational.IntegralTest.padded and the signed-monomial formula Rational.IntegralLift.entry. Those definitions are indexed by Fin and ZMod with a type-level modulus, and use Nat.choose. This file restates them as ordinary programs on natural numbers, integers and lists of rows, and proves that they compute the landed matrix definitions:

Magnitude bounds, bit-length budgets, and polynomial-time Turing machine certificates for these list programs are proved in Complexity/Computability/Circuit/Rational/Runtime/Lift.lean.

Main definitions #

Main results #

References #

Index bridges #

theorem Cslib.Circuits.Rational.sum_range_eq_sum_fin {A : Type u_1} [AddCommMonoid A] (m : ℕ) (f : ℕ → A) :
(List.map f (List.range m)).sum = ∑ i : Fin m, f ↑i

A sum over List.range m is a sum over Fin m.

theorem Cslib.Circuits.Rational.sum_range_eq_sum_zmod {A : Type u_1} [AddCommMonoid A] (m : ℕ) [NeZero m] (f : ℕ → A) :
(List.map f (List.range m)).sum = ∑ z : ZMod m, f z.val

A sum over List.range m is a sum over the residues modulo m.

theorem Cslib.Circuits.Rational.val_sub_eq_mod {m : ℕ} [NeZero m] (u v : ZMod m) :
(u - v).val = (u.val + m - v.val) % m

Residue subtraction on values, without truncated subtraction below zero.

theorem Cslib.Circuits.Rational.val_neg_mul_add_mul_eq_mod {m : ℕ} [NeZero m] (a u k : ZMod m) :
(-a * k + a * u).val = a.val * (u.val + m - k.val) % m

The residue -a * k + a * u of the lift formula, on values.

The residue of the row-major block coordinate is the quotient by the degree.

The position inside the block of the row-major block coordinate is the remainder.

Lists of rows #

theorem Cslib.Circuits.Rational.tabulateRows_eq_rowsOf {d : ℕ} (g : ℕ → ℕ → ℤ) (A : Matrix (Fin d) (Fin d) ℤ) (h : ∀ (i j : Fin d), g ↑i ↑j = A i j) :

A tabulated list of rows is the list of rows of a matrix it agrees with.

theorem Cslib.Circuits.Rational.natAbs_le_of_mem_rows {rows : List (List ℤ)} {C : ℕ} (h : ∀ (i j : ℕ), (rowEntry rows i j).natAbs ≤ C) {row : List ℤ} (hrow : row ∈ rows) {z : ℤ} (hz : z ∈ row) :

Every stored entry is bounded once every indexed entry is.

Coefficient rows #

Multiply a polynomial by X + c. The polynomial is given by its list of coefficients, constant coefficient first; coefficient i of the product is l[i - 1] + c * l[i].

Instances For

    The coefficients of (X + c) ^ k, constant coefficient first, computed by k shift-and-add steps from [1].

    Instances For

      The coefficient rows coeffRow c k for k < M.

      Instances For
        theorem Cslib.Circuits.Rational.getD_shiftAddRow (c : ℤ) (l : List ℤ) (i : ℕ) :
        (shiftAddRow c l).getD i 0 = (0 :: l).getD i 0 + c * l.getD i 0

        coeffRow computes the coefficients of (X + C c) ^ k.

        theorem Cslib.Circuits.Rational.getD_coeffRow_eq (c : ℤ) (k i : ℕ) :
        (coeffRow c k).getD i 0 = c ^ (k - i) * ↑(k.choose i)

        The closed form of the coefficient rows, as in IntegralTest.full.

        The integer Taylor test matrix #

        def Cslib.Circuits.Rational.testTerm (M : ℕ) (minus plus : List (List ℤ)) (t : ℤ) (u v q : ℕ) :

        The summand q of entry (u, v) of the integer Taylor test matrix: coefficient u of (X - a) ^ (M - 1 - q) times coefficient q of (X + a) ^ v times t ^ q, read from the coefficient rows minus and plus.

        Instances For
          def Cslib.Circuits.Rational.testTerms (M : ℕ) (minus plus : List (List ℤ)) (t : ℤ) (u v : ℕ) :

          The summands of entry (u, v) of the integer Taylor test matrix.

          Instances For
            def Cslib.Circuits.Rational.testEntry (M N : ℕ) (minus plus : List (List ℤ)) (t : ℤ) (u v : ℕ) :

            Entry (u, v) of the integer Taylor test matrix; the columns from N on are zero.

            Instances For

              The integer Taylor test matrix IntegralTest.padded M N a t as a list of rows.

              Instances For
                theorem Cslib.Circuits.Rational.testEntry_eq (M N : ℕ) (a t : ℤ) (u v : Fin M) :
                testEntry M N (coeffRows (-a) M) (coeffRows a M) t ↑u ↑v = IntegralTest.padded M N a t u v
                theorem Cslib.Circuits.Rational.rowEntry_testRows (M N : ℕ) (a t : ℤ) (u v : Fin M) :
                rowEntry (testRows M N a t) ↑u ↑v = IntegralTest.padded M N a t u v

                The list program computes the integer Taylor test matrix.

                The Taylor rows, read at residues, are the residue-indexed Generator.integerTest.

                @[simp]
                theorem Cslib.Circuits.Rational.length_testRows (M N : ℕ) (a t : ℤ) :
                (testRows M N a t).length = M

                The integer lift #

                The signed coefficient of the cyclotomic regular representation on natural numbers: CyclotomicRing.signedEntry with the residue replaced by its value.

                Instances For
                  def Cslib.Circuits.Rational.liftTerm (M Dg : ℕ) (T : List (List ℤ)) (p r : ℤ) (u v i j α κ : ℕ) :

                  The term (α, κ) of entry ((u, i), (v, j)) of the integer lift with test matrix T, with M residues and cyclotomic degree Dg. The residue β of IntegralLift.entry is forced to be u - v, which is (u + M - v) % M; κ - β and α * (u - κ) are computed likewise.

                  Instances For
                    def Cslib.Circuits.Rational.liftTerms (M Dg : ℕ) (T : List (List ℤ)) (p r : ℤ) (u v i j α : ℕ) :

                    The terms κ < M of the inner sum, for the residue α.

                    Instances For
                      def Cslib.Circuits.Rational.liftSums (M Dg : ℕ) (T : List (List ℤ)) (p r : ℤ) (u v i j : ℕ) :

                      The inner sums α < M of an integer lift entry.

                      Instances For
                        def Cslib.Circuits.Rational.liftEntry (M Dg : ℕ) (T : List (List ℤ)) (p r : ℤ) (u v i j : ℕ) :

                        Entry ((u, i), (v, j)) of the integer lift: a double sum of M ^ 2 terms.

                        Instances For

                          The integer lift matrix with test matrix T, in the row-major block order: index i is the pair (i / Dg, i % Dg).

                          Instances For

                            The n + 1 integer lift matrices at the grid point (t, p, r), with truncation N, M residues and cyclotomic degree Dg.

                            Instances For

                              The double sum computes the integer lift formula, for any list of rows that agrees with the test matrix at residues.

                              The integer lift entry of Generator.integralLift, on the residues of the test rows.

                              The entries of a lift table are the entries of Generator.integralLift.

                              theorem Cslib.Circuits.Rational.liftTable_eq (n N e : ℕ) (x : Fin 3 → ℕ) (a : Fin (n + 1)) :

                              The list program computes Generator.integralLift.

                              theorem Cslib.Circuits.Rational.rowEntry_liftTable (n N e : ℕ) (x : Fin 3 → ℕ) (a : Fin (n + 1)) (i j : Fin (Generator.matrixDimension e)) :
                              rowEntry (liftTable (CyclotomicRing.dimension e) (CyclotomicRing.degree e) (testRows (CyclotomicRing.dimension e) N ↑↑a ↑(x 0)) ↑(x 1) ↑(x 2)) ↑i ↑j = Generator.integralLift n N e x a i j
                              theorem Cslib.Circuits.Rational.liftRows_eq (n N e : ℕ) (x : Fin 3 → ℕ) :
                              liftRows n N (CyclotomicRing.dimension e) (CyclotomicRing.degree e) (x 0) (x 1) (x 2) = List.map (fun (a : Fin (n + 1)) => rowsOf (Generator.integralLift n N e x a)) (List.finRange (n + 1))

                              The list program computes all integer lift matrices at a grid point.

                              The list program computes the executable generator's dense input tables.

                              @[simp]
                              theorem Cslib.Circuits.Rational.length_liftTable (M Dg : ℕ) (T : List (List ℤ)) (p r : ℤ) :
                              (liftTable M Dg T p r).length = M * Dg
                              @[simp]
                              theorem Cslib.Circuits.Rational.length_liftRows (n N M Dg t p r : ℕ) :
                              (liftRows n N M Dg t p r).length = n + 1