Documentation

Complexity.Computability.Circuit.Boolean.SemiCircuit.Equation

Equations over 𝔽₂ #

The equations of the affine system of a fair semi-circuit (Cslib.Circuits.Boolean.SemiCircuit): an equation states that the sum over 𝔽₂ of the values of its terms, a finite set of internal values, is a constant. Rerouting a term to a literal (Equation.subst) preserves the truth of the equation on assignments giving the term the value of the literal (Equation.holds_subst) and does not add terms (Equation.card_subst_le). An affine gate becomes an equation with at most three terms (affEqn, affEqn_holds).

Main definitions #

Main results #

References #

Equations #

An equation of the affine system: the sum over 𝔽₂ of the values of its terms is rhs.

  • terms : Finset ℕ

    The internal values occurring in the equation.

  • rhs : Bool

    The right-hand side.

Instances For

    Adding t to a set of terms over 𝔽₂ removes it if present and inserts it otherwise.

    theorem Cslib.Circuits.Boolean.SemiCircuit.sum_symmDiff_singleton (s : Finset ℕ) (t : ℕ) (val : ℕ → Bool) :
    ∑ i ∈ symmDiff s {t}, val i = ∑ i ∈ s, val i + val t

    The equation holds under an assignment of the internal values.

    Instances For

      Reroute the term v of an equation to the literal ℓ.

      Instances For
        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.holds_subst {E : Equation} {v : ℕ} {ℓ : Lit} {val : ℕ → Bool} (h : val v = ℓ.eval val) :
        (E.subst v ℓ).Holds val ↔ E.Holds val

        Rerouting v to a literal with the value of v preserves the truth of every equation.

        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.mem_subst_of_ne {E : Equation} {v : ℕ} {ℓ : Lit} {z : ℕ} (hzv : z ≠ v) (hzℓ : ℓ.arg ≠ Arg.node z) :
        z ∈ (E.subst v ℓ).terms ↔ z ∈ E.terms
        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.notMem_subst {E : Equation} {v : ℕ} {ℓ : Lit} (hℓ : ℓ.arg ≠ Arg.node v) :
        v ∉ (E.subst v ℓ).terms
        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.holds_congr {E : Equation} {val val' : ℕ → Bool} (h : ∀ i ∈ E.terms, val i = val' i) :
        E.Holds val ↔ E.Holds val'
        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.holds_subst_update {E : Equation} {v : ℕ} {ℓ : Lit} (hℓ : ℓ.arg ≠ Arg.node v) (val : ℕ → Bool) :
        (E.subst v ℓ).Holds val ↔ E.Holds (Function.update val v (ℓ.eval val))

        An equation with v rerouted to a literal not reading v holds exactly when the equation holds on the assignment giving v the value of the literal.

        theorem Cslib.Circuits.Boolean.SemiCircuit.Equation.holds_update_iff {E : Equation} {v p r : ℕ} (hterms : E.terms = {v, p, r}) (hvp : v ≠ p) (hvr : v ≠ r) (hpr : p ≠ r) (val : ℕ → Bool) (c : Bool) :
        E.Holds (Function.update val p (val r ^^ c)) ↔ val v = (E.rhs ^^ c)

        Once p = r + c, the equation v + p + r = rhs reads v = rhs + c.

        Moving affine gates into the affine system #

        Add the argument a with coefficient b to the terms and right-hand side of an equation.

        Instances For
          theorem Cslib.Circuits.Boolean.SemiCircuit.sum_addArg (p : Finset ℕ × Bool) (b : Bool) (a : Arg) (val : ℕ → Bool) :
          ∑ i ∈ (addArg p b a).1, val i + (addArg p b a).2 = ∑ i ∈ p.1, val i + p.2 + (b && Arg.eval val a)
          theorem Cslib.Circuits.Boolean.SemiCircuit.mem_addArg {p : Finset ℕ × Bool} {b : Bool} {a : Arg} {z : ℕ} (h : z ∈ (addArg p b a).1) :
          z ∈ p.1 ∨ a = Arg.node z

          The equation J + b₁ t₁ + b₂ t₂ = c replacing the affine gate J = b₁ t₁ + b₂ t₂ + c.

          Instances For
            theorem Cslib.Circuits.Boolean.SemiCircuit.affEqn_holds {g : Gate} (hg : IsAffineOp g.op) (J : ℕ) (val : ℕ → Bool) :
            (affEqn g J).Holds val ↔ val J = g.eval val