Documentation

Complexity.Computability.Circuit.Boolean.GateElimination

Gate elimination: parity needs 3 (n - 1) binary gates #

A De Morgan circuit computing the parity of n bits has at least 3 (n - 1) AND and OR gates, however many negations and constants it uses (three_mul_le_cost_of_computes_parity). This is Schnorr's bound [Sch74], Jukna, Section 1.6. It is attained by chaining x ⊕ y = (x ∨ y) ∧ ¬(x ∧ y), which spends three binary gates on each bit after the first (exists_computes_parity), so 3 (n - 1) is the exact count (isLeast_cost_parity). It is the prototypical gate-elimination argument: fixing one bit suitably makes three binary gates superfluous and leaves the parity of the other bits, possibly negated.

The proof does not rewrite circuits. For a restriction (partial assignment) ρ it counts the nonredundant gates: AND and OR gates whose function, once the bits fixed by ρ are hardwired, is neither constant, nor a literal, nor one of its arguments up to negation (GateElimination.NonRedundant). Fixing more bits never makes a redundant gate nonredundant (GateElimination.nonRedundant_update_subset). Every nonredundant gate survives the simplifications of the textbook proof, so their number is a lower bound on the number of binary gates, and it is what each step of the proof decreases.

The step follows Schnorr. Consider the nonredundant gates from which a chain of nonredundant gates, negations and gates that compute one of their arguments up to negation leads to the output. The first of them reads two different bits xᵢ and xⱼ, each of which, suitably fixed, makes it constant. Another of them reads xᵢ: otherwise fixing xⱼ would make the output ignore xᵢ. Fixing xᵢ then makes three of them redundant: the first gate, the other reader of xᵢ, and a gate reading the first one, or reading the other reader of xᵢ if that is the same gate.

Main definitions #

Main results #

References #

Constants, literals and negations #

φ is ψ or its negation.

Instances For

    φ is constant or a literal.

    Instances For
      theorem Cslib.Circuits.Boolean.GateElimination.EqUpToNeg.trans {n : ℕ} {φ ψ χ : BooleanFunction n} (h₁ : EqUpToNeg φ ψ) (h₂ : EqUpToNeg ψ χ) :
      EqUpToNeg φ χ
      theorem Cslib.Circuits.Boolean.GateElimination.isConstOrLiteral_of_eq_comp {n : ℕ} {φ : BooleanFunction n} {i : Fin n} (f : Bool → Bool) (h : ∀ (x : BitString n), φ x = f (x i)) :

      A function of bit i alone is constant or a literal.

      A constant or a literal is bit i up to negation or ignores it.

      Gates #

      Restricted programs #

      The function computed at wire w once the bits fixed by ρ are hardwired.

      Instances For

        Fixing one more free bit is restricting the restricted function.

        A wire that is another up to negation is constant when the other is, after fixing a bit.

        theorem Cslib.Circuits.Boolean.GateElimination.restricted_update_of_parity {n g : ℕ} {p : Program signature n g} {ρ : BitString.PartialAssignment (Fin n)} {i : Fin n} {o : Wire n g} (hi : ρ i = none) (b : Bool) {c : Bool} (ho : ∀ (x : BitString n), restricted p ρ o x = (c ^^ parityOn ρ.free x)) (x : BitString n) :

        Fixing a free bit of the parity of all free bits leaves the parity of the others, possibly negated.

        Nonredundant gates #

        Gate k is a nonredundant binary gate once the bits fixed by ρ are hardwired: an AND or OR gate whose function is neither constant, nor a literal, nor one of its arguments up to negation.

        Instances For

          The nonredundant binary gates under ρ.

          Instances For

            There are at most as many nonredundant gates as binary gates.

            Fixing one more bit only makes gates redundant.

            Wires that may matter #

            Eliminating three gates #

            theorem Cslib.Circuits.Boolean.GateElimination.exists_card_add_three_le {n g : ℕ} (p : Program signature n g) {ρ : BitString.PartialAssignment (Fin n)} (o : Wire n g) {c : Bool} (ho : ∀ (x : BitString n), restricted p ρ o x = (c ^^ parityOn ρ.free x)) (hV : 2 ≤ ρ.free.card) :
            ∃ (i : Fin n) (b : Bool), ρ i = none ∧ (nonRedundant p (Function.update ρ i (some b))).card + 3 ≤ (nonRedundant p ρ).card

            Schnorr's elimination step. If, under ρ, the wire o computes the parity of all free bits, possibly negated, and at least two bits are free, then fixing one free bit suitably makes at least three nonredundant gates redundant.

            theorem Cslib.Circuits.Boolean.GateElimination.three_mul_le_card_nonRedundant {n g : ℕ} (p : Program signature n g) (o : Wire n g) (m : ℕ) (ρ : BitString.PartialAssignment (Fin n)) (c : Bool) (hρ : ρ.free.card = m + 1) (ho : ∀ (x : BitString n), restricted p ρ o x = (c ^^ parityOn ρ.free x)) :
            3 * m ≤ (nonRedundant p ρ).card

            Under a restriction leaving m + 1 bits free for which the wire o computes their parity, possibly negated, at least 3 m gates are nonredundant.

            Schnorr's bound. A De Morgan circuit computing the parity of n bits has at least 3 (n - 1) AND and OR gates, however many negations and constants it uses.

            The least number of AND and OR gates in a De Morgan circuit computing the parity of n bits is 3 (n - 1).

            A De Morgan circuit computing the parity of n bits has at least 3 (n - 1) gates.

            The De Morgan circuit complexity of the parity of n bits is at least 3 (n - 1).