Documentation

Complexity.Computability.Circuit.Arithmetic

Affine, polynomial and arithmetic bases #

Three ways of computing over a commutative semiring F:

The affine and arithmetic bases are polynomial. Over a finite field every operation is a polynomial, so the distinction matters only over infinite fields, where it is essential: an infinite field admits injections F × F → F, through which a single wire can carry any amount of information.

In an arithmetic circuit the constants are leaves, and Cslib.Circuits.Circuit.innerSize counts exactly the additions and multiplications.

Main definitions #

Main results #

References #

@[reducible, inline]

The affine basis over F: an operation of arity k is a vector of k coefficients and a constant.

Instances For

    An affine operation with coefficients a and constant b computes x ↦ ∑ i, a i * x i + b.

    Instances For
      @[simp]
      theorem Cslib.Circuits.affineInterpretation_apply (F : Type u) [Semiring F] (k : ℕ) (a : Fin k → F) (b : F) (x : Fin k → F) :
      affineInterpretation F ⟨k, (a, b)⟩ x = ∑ i : Fin k, a i * x i + b

      An affine operation with arity k, coefficients a and constant b.

      inductive Cslib.Circuits.ArithOp (F : Type u) :

      The operations of the arithmetic basis.

      Instances For
        @[reducible, inline]

        The arity of an arithmetic operation: two for addition and multiplication, zero for a constant.

        Instances For
          @[reducible, inline]

          The arithmetic basis: addition and multiplication of arity two, and constants of arity zero.

          Instances For
            def Cslib.Circuits.arithInterpretationWith (F : Type u) {R : Type u_1} [Add R] [Mul R] (constant : F → R) :

            Addition and multiplication in R, with constant symbols interpreted by constant. For example, MvPolynomial.C interprets field constants as constant polynomials.

            Instances For

              Addition, multiplication and constants.

              Instances For
                @[simp]
                theorem Cslib.Circuits.arithInterpretationWith_add {F : Type u} {R : Type u_1} [Add R] [Mul R] (constant : F → R) (x : Fin 2 → R) :
                arithInterpretationWith F constant ArithOp.add x = x 0 + x 1
                @[simp]
                theorem Cslib.Circuits.arithInterpretationWith_mul {F : Type u} {R : Type u_1} [Add R] [Mul R] (constant : F → R) (x : Fin 2 → R) :
                arithInterpretationWith F constant ArithOp.mul x = x 0 * x 1
                @[simp]
                theorem Cslib.Circuits.arithInterpretationWith_const {F : Type u} {R : Type u_1} [Add R] [Mul R] (constant : F → R) (c : F) (x : Fin 0 → R) :
                arithInterpretationWith F constant (ArithOp.const c) x = constant c

                Multiplications cost one; additions and constants are free. Multiplication by a scalar still costs one.

                Instances For

                  Additions cost one; multiplications and constants are free.

                  Instances For
                    theorem Cslib.Circuits.Circuit.eval_arithInterpretationWith_mvPolynomial {F : Type u} {R : Type u_1} [CommSemiring R] {n m : ℕ} (c : Circuit (arithSignature F) n m) (constant : F → R) (x : Fin n → R) (j : Fin m) :

                    Evaluating the formal polynomial computed by a circuit agrees with evaluating the circuit in the coefficient semiring. The converse need not hold over a finite field.

                    An interpretation is polynomial when every operation is given by a polynomial in its arguments.

                    Instances For

                      Arithmetic circuits have fan-in at most two.