Documentation

Complexity.Computability.Circuit.Arithmetic.VP

p-families, p-projections and Valiant's class VP #

Valiant's algebraic analogue of P [Val79a], in the form of Bürgisser, Chapter 2. A family of polynomials over K has, for every n, a polynomial poly n in vars n variables. It is a p-family when the number of variables and the total degree are polynomially bounded in n. A p-family is in VP K when it is computed by arithmetic circuits of polynomially bounded size.

Arithmetic circuits are the library's circuits over Cslib.Circuits.arithSignature K: addition and multiplication of fan-in two and a constant gate for each element of K. A circuit computes a polynomial formally: it is evaluated in MvPolynomial (Fin n) K at the variables (Cslib.Circuits.Circuit.polynomial). Over a finite field this is stronger than computing the polynomial function. Size counts every gate, constant gates included, and there is no subtraction gate. Bürgisser counts arithmetic operations, subtraction among them, with constants free; translating between the two conventions changes sizes by at most a constant factor and does not change the class (a remark, not formalized here).

The definitions are those of the literature, with three points made explicit.

A polynomial P is a projection of Q when P arises from Q by substituting for each variable of Q a variable of P or a constant. A family f is a p-projection of g when each f n is a projection of g (t n) for a polynomially bounded t. Projections are Valiant's reductions; VP is closed under them.

Main definitions #

Main results #

References #

noncomputable def Cslib.Circuits.Circuit.polynomial {K : Type u} [CommSemiring K] {n m : ℕ} (c : Circuit (arithSignature K) n m) (j : Fin m) :

The formal polynomial computed at output j of an arithmetic circuit with constants from K: the circuit evaluated in MvPolynomial (Fin n) K at the variables, the constant symbol a denoting the constant polynomial C a.

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

    Evaluating the polynomial computed by a circuit at a point of a commutative K-algebra is evaluating the circuit at that point.

    Substituting polynomials for the variables of the polynomial computed by a circuit is evaluating the circuit at those polynomials.

    @[simp]
    theorem Cslib.Circuits.Circuit.eval_polynomial {K : Type u} [CommSemiring K] {n m : ℕ} (c : Circuit (arithSignature K) n m) (x : Fin n → K) (j : Fin m) :

    Evaluating the formal polynomial computed by an arithmetic circuit at x : Fin n → K agrees with evaluating the circuit under arithInterpretation K.

    Synthesis of arithmetic circuits #

    theorem Cslib.Circuits.Synthesis.arith_const {K : Type u} {n : ℕ} {R : Type u_1} {constant : K → R} {s : Set ((Fin n → R) → R)} [Add R] [Mul R] (a : K) :
    Synthesis (arithInterpretationWith K constant) s {fun (x : Fin n → R) => constant a} 1

    A constant costs one gate.

    theorem Cslib.Circuits.Synthesis.arith_add {K : Type u} {n : ℕ} {R : Type u_1} {constant : K → R} {s : Set ((Fin n → R) → R)} {f g : (Fin n → R) → R} [Add R] [Mul R] (hf : f ∈ s) (hg : g ∈ s) :
    Synthesis (arithInterpretationWith K constant) s {fun (x : Fin n → R) => f x + g x} 1

    The sum of two available functions costs one gate.

    theorem Cslib.Circuits.Synthesis.arith_mul {K : Type u} {n : ℕ} {R : Type u_1} {constant : K → R} {s : Set ((Fin n → R) → R)} {f g : (Fin n → R) → R} [Add R] [Mul R] (hf : f ∈ s) (hg : g ∈ s) :
    Synthesis (arithInterpretationWith K constant) s {fun (x : Fin n → R) => f x * g x} 1

    The product of two available functions costs one gate.

    theorem Cslib.Circuits.Synthesis.arith_sum {K : Type u} {n : ℕ} {R : Type u_1} {constant : K → R} {s : Set ((Fin n → R) → R)} {ι : Type u_2} [AddCommMonoid R] [Mul R] (indices : Finset ι) (summand : ι → (Fin n → R) → R) (cost : ι → ℕ) (hzero : (fun (x : Fin n → R) => 0) ∈ s) (h : ∀ i ∈ indices, Synthesis (arithInterpretationWith K constant) s {summand i} (cost i)) :
    Synthesis (arithInterpretationWith K constant) s {fun (x : Fin n → R) => ∑ i ∈ indices, summand i x} (∑ i ∈ indices, (cost i + 1))

    A finite sum costs its summands and one addition each, when zero is available.

    A synthesis bound on a function F from the inputs gives a circuit, within the bound, computing the polynomial F X.

    A family of polynomials over K: for every n, a polynomial poly n in vars n variables.

    Instances For

      A p-family Bürgisser, Chapter 2: the number of variables and the total degree are polynomially bounded.

      Instances For

        Projections #

        noncomputable def Cslib.Circuits.Arithmetic.projection {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} (ρ : τ → σ ⊕ K) :

        Substitute for each variable i of a polynomial over τ the variable X k when ρ i = Sum.inl k, and the constant C a when ρ i = Sum.inr a.

        Instances For
          @[simp]
          theorem Cslib.Circuits.Arithmetic.projection_X {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} (ρ : τ → σ ⊕ K) (i : τ) :
          theorem Cslib.Circuits.Arithmetic.projection_C {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} (ρ : τ → σ ⊕ K) (a : K) :
          @[simp]

          Substituting every variable for itself changes nothing.

          theorem Cslib.Circuits.Arithmetic.projection_projection {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} {υ : Type u_3} (ρ : σ → υ ⊕ K) (ρ' : τ → σ ⊕ K) (P : MvPolynomial τ K) :
          (projection ρ) ((projection ρ') P) = (projection fun (i : τ) => Sum.elim ρ Sum.inr (ρ' i)) P

          Two successive projections are one projection: a variable substituted for a variable is substituted in turn, and a constant stays.

          def Cslib.Circuits.Arithmetic.IsProjection {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} (P : MvPolynomial σ K) (Q : MvPolynomial τ K) :

          P is a projection of Q [Val79a]: substituting for each variable of Q a variable of P or a constant of K gives P.

          Instances For

            Every polynomial is a projection of itself.

            theorem Cslib.Circuits.Arithmetic.IsProjection.trans {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} {υ : Type u_3} {P : MvPolynomial υ K} {Q : MvPolynomial σ K} {R : MvPolynomial τ K} (hPQ : IsProjection P Q) (hQR : IsProjection Q R) :

            A projection of a projection is a projection.

            theorem Cslib.Circuits.Arithmetic.totalDegree_projection_le {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} (ρ : τ → σ ⊕ K) (P : MvPolynomial τ K) :

            Projections do not raise the total degree.

            f is a p-projection of g Valiant1979Algebra; Bürgisser, Chapter 2: for a polynomially bounded t, every f.poly n is a projection of g.poly (t n).

            Instances For

              Every family is a p-projection of itself.

              A p-projection of a p-projection is a p-projection.

              Circuits for projections #

              The circuit supplying the substitution of a projection: output i is input k when ρ i = Sum.inl k, and a constant gate for a when ρ i = Sum.inr a.

              Instances For
                @[simp]
                theorem Cslib.Circuits.Arithmetic.eval_projectionCircuit {K : Type u} {n m : ℕ} {R : Type u_1} [Add R] [Mul R] (constant : K → R) (ρ : Fin m → Fin n ⊕ K) (x : Fin n → R) (i : Fin m) :
                (projectionCircuit ρ).eval (arithInterpretationWith K constant) x i = Sum.elim x constant (ρ i)

                The substitution of a projection needs at most one gate per substituted variable.

                Feeding the substitution of a projection to a circuit computes the projection of its polynomial.

                The class VP #

                Valiant's class VP over K Valiant1979Algebra; Bürgisser, Chapter 2: the p-families computed, for some polynomially bounded size function, by arithmetic circuits of that size. Nothing relates the circuits for different n: the class is nonuniform. The circuits compute the members as formal polynomials, and their degrees are bounded by the p-family condition.

                Instances For

                  VP is closed under p-projections Bürgisser, Chapter 2. A projection cannot raise the degree, but f may have arbitrarily many variables that it does not use, so the number of variables of f is required to be polynomially bounded.

                  theorem Cslib.Circuits.Arithmetic.VP.of_synthesis {K : Type u} [CommSemiring K] {f : PolynomialFamily K} (hf : f.IsPFamily) {cost : ℕ → ℕ} (hcost : PolynomiallyBounded cost) (F : (n : ℕ) → (Fin (f.vars n) → MvPolynomial (Fin (f.vars n)) K) → MvPolynomial (Fin (f.vars n)) K) (hF : ∀ (n : ℕ), F n MvPolynomial.X = f.poly n) (h : ∀ (n : ℕ), Synthesis (arithInterpretationWith K ⇑MvPolynomial.C) (inputs (f.vars n)) {F n} (cost n)) :
                  f ∈ VP K

                  A p-family is in VP when, within a polynomially bounded budget, each member f.poly n is F n X for a function F n synthesized from the inputs.

                  Degree is part of the definition #

                  The family X ^ 2 ^ n of powers of one variable.

                  Instances For

                    Repeated squaring computes X ^ 2 ^ n with at most n gates.

                    VP bounds the degree. Over a nontrivial K, the family X ^ 2 ^ n has circuits with n gates (exists_circuit_pow_two_pow) but is not in VP: its degree 2 ^ n is not polynomially bounded.