Documentation

CslibFrontier.Computability.Circuit.Arithmetic.ComputedWithin

Polynomials computed within a number of nodes #

ComputedWithin P s says that the polynomial P, in variables of any type σ, is computed by an arithmetic circuit with at most s nodes: some n of its variables feed a circuit c : Circuit (arithSignature K) n 1 whose output is P as a formal polynomial, and n + c.size ≤ s. Inputs count one node each, like constants, additions and multiplications. This is the node count of Arora and Barak, Section 6.1 and of the circuits of Claude, VP ≠ VNP over every field, which are lists of s polynomials, each a variable, a constant, or the sum or product of two earlier ones. For polynomial families the convention does not matter: Cslib.Circuits.Arithmetic.mem_VP_iff characterizes VP by ComputedWithin.

A polynomial is affine (IsAffine) when it is a constant or a * X i + b, and P is an affine projection of Q (IsAffineProjection) when P arises from Q by substituting an affine polynomial for every variable. Affine polynomials have total degree at most 1 (IsAffine.totalDegree_le), and substituting affine polynomials into one gives an affine polynomial (IsAffine.aeval). Substituting affine polynomials into a circuit costs at most four gates for each input, hence at most a factor five (ComputedWithin.of_isAffineProjection).

Main definitions #

Main results #

References #

Polynomials of combined circuits #

Renaming the variables of the polynomial computed by a circuit is evaluating the circuit at the renamed variables.

def Cslib.Circuits.ArithOp.map {K : Type u} {L : Type u_1} (f : K → L) :

The arithmetic operation with its constant mapped along f.

Instances For
    theorem Cslib.Circuits.ArithOp.map_comp {K : Type u} {L : Type u_1} {M : Type u_2} (f : K → L) (f' : L → M) :
    (map f').comp (map f) = map (f' ∘ f)

    Mapping constants twice is mapping them along the composite.

    instance Cslib.Circuits.ArithOp.map_preserves {K : Type u} {L : Type u_1} {R : Type u_2} [Add R] [Mul R] (f : K → L) (constant : L → R) :

    Mapping constants along f and interpreting them by constant means interpreting them by constant ∘ f.

    theorem Cslib.Circuits.Circuit.map_eval_arith {K : Type u} {n m : ℕ} {A : Type u_1} {B : Type u_2} [NonAssocSemiring A] [NonAssocSemiring B] (h : A →+* B) (c : Circuit (arithSignature K) n m) (constant : K → A) (x : Fin n → A) (j : Fin m) :
    h (c.eval (arithInterpretationWith K constant) x j) = c.eval (arithInterpretationWith K (⇑h ∘ constant)) (⇑h ∘ x) j

    A ring homomorphism commutes with evaluating an arithmetic circuit.

    theorem Cslib.Circuits.Circuit.polynomial_mapOp {K : Type u} {n m : ℕ} {L : Type u_1} [CommSemiring L] (f : K → L) (c : Circuit (arithSignature K) n m) (j : Fin m) :

    The polynomial computed by a circuit with constants mapped along f is the circuit evaluated with the constants C (f a).

    theorem Cslib.Circuits.Circuit.polynomial_mapOp_ringHom {K : Type u} [CommSemiring K] {n m : ℕ} {L : Type u_1} [CommSemiring L] (φ : K →+* L) (c : Circuit (arithSignature K) n m) (j : Fin m) :

    Mapping the constants of a circuit along a ring homomorphism maps the coefficients of its polynomials.

    Computation within a number of nodes #

    P is computed by an arithmetic circuit with at most s nodes, counting its inputs: for some n, a circuit with n inputs, fed with the variables x, computes P as a formal polynomial, and n plus the number of its gates is at most s. Constants count as gates.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.mono {K : Type u} [CommSemiring K] {σ : Type u_1} {P : MvPolynomial σ K} {s t : ℕ} (h : ComputedWithin P s) (hst : s ≤ t) :

    A bound on the number of nodes may be raised.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.pos {K : Type u} [CommSemiring K] {σ : Type u_1} {P : MvPolynomial σ K} {s : ℕ} (h : ComputedWithin P s) :
    0 < s

    A circuit has at least one node: its output is an input or a gate.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.rename {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} {P : MvPolynomial σ K} {s : ℕ} (f : σ → τ) (h : ComputedWithin P s) :

    Renaming the variables keeps the number of nodes.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.map {K : Type u} [CommSemiring K] {σ : Type u_1} {P : MvPolynomial σ K} {s : ℕ} {L : Type u_3} [CommSemiring L] (φ : K →+* L) (h : ComputedWithin P s) :

    Mapping the coefficients along a ring homomorphism keeps the number of nodes.

    A variable is computed by one node, an input.

    A constant is computed by one node, a constant gate.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.add {K : Type u} [CommSemiring K] {σ : Type u_1} {P Q : MvPolynomial σ K} {s t : ℕ} (hP : ComputedWithin P s) (hQ : ComputedWithin Q t) :
    ComputedWithin (P + Q) (s + t + 1)

    A sum costs the nodes of both summands and one addition.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.mul {K : Type u} [CommSemiring K] {σ : Type u_1} {P Q : MvPolynomial σ K} {s t : ℕ} (hP : ComputedWithin P s) (hQ : ComputedWithin Q t) :
    ComputedWithin (P * Q) (s + t + 1)

    A product costs the nodes of both factors and one multiplication.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.sum {K : Type u} [CommSemiring K] {σ : Type u_1} {s : ℕ} {ι : Type u_3} (A : Finset ι) {f : ι → MvPolynomial σ K} (h : ∀ i ∈ A, ComputedWithin (f i) s) :
    ComputedWithin (∑ i ∈ A, f i) (A.card * (s + 1) + 1)

    A sum of polynomials computed within s nodes each.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.prod {K : Type u} [CommSemiring K] {σ : Type u_1} {s : ℕ} {ι : Type u_3} (A : Finset ι) {f : ι → MvPolynomial σ K} (h : ∀ i ∈ A, ComputedWithin (f i) s) :
    ComputedWithin (∏ i ∈ A, f i) (A.card * (s + 1) + 1)

    A product of polynomials computed within s nodes each.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.exists_steps {K : Type u} [CommSemiring K] {σ : Type u_1} {P : MvPolynomial σ K} {s : ℕ} (h : ComputedWithin P s) :
    ∃ (l : ℕ → MvPolynomial σ K), (∀ k < s, (∃ (i : σ), l k = MvPolynomial.X i) ∨ (∃ (a : K), l k = MvPolynomial.C a) ∨ (∃ i < k, ∃ j < k, l k = l i + l j) ∨ ∃ i < k, ∃ j < k, l k = l i * l j) ∧ ∃ k < s, l k = P

    A polynomial computed within s nodes is entry k < s of a list in which every entry below s is a variable, a constant, or the sum or product of two earlier entries. The list holds the values of the wires of the circuit in program order, inputs first, and 0 after them.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.exists_finset_lift {K : Type u} [CommSemiring K] {σ : Type u_1} {P : MvPolynomial σ K} {s : ℕ} (h : ComputedWithin P s) :
    ∃ (S : Finset K), ∀ {B : Type u_3} [inst : CommSemiring B] (ι : B →+* K), ↑S ⊆ Set.range ⇑ι → ∃ (Q : MvPolynomial σ B), ComputedWithin Q s ∧ (MvPolynomial.map ι) Q = P

    A polynomial computed within s nodes has a finite set of constants: along any ring homomorphism whose range contains them, it is the image of a polynomial computed within s nodes. The set holds the constants of the gates of a circuit for P, with 0 for the gates that are not constants.

    Affine projections #

    P is affine: a constant, or a constant multiple of a variable plus a constant.

    An affine polynomial has total degree at most 1.

    theorem Cslib.Circuits.Arithmetic.IsAffine.aeval {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} {P : MvPolynomial τ K} (hP : IsAffine P) {ρ : τ → MvPolynomial σ K} (hρ : ∀ (i : τ), IsAffine (ρ i)) :

    Substituting affine polynomials into an affine polynomial gives an affine polynomial.

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

    P is an affine projection of Q: substituting an affine polynomial for every variable of Q gives P.

    A projection, which substitutes variables and constants, is an affine projection.

    theorem Cslib.Circuits.Arithmetic.ComputedWithin.of_isAffineProjection {K : Type u} [CommSemiring K] {σ : Type u_1} {τ : Type u_2} {P : MvPolynomial σ K} {Q : MvPolynomial τ K} {s : ℕ} (hQ : ComputedWithin Q s) (h : IsAffineProjection P Q) :

    Affine projections cost at most a factor five. Each input of a circuit for Q is replaced by its own input and at most four gates computing the substituted affine polynomial.

    VP #

    VP by circuit sizes. A family is in VP exactly when it is a p-family whose members are computed within a polynomially bounded number of nodes.