Documentation

Complexitylib.Algebraic.Basis.DeMorgan.Arithmetic

Boolean arithmetic in the De Morgan basis #

Boolean-ring addition is XOR and multiplication is AND. This module gives a concrete translation from arithmetic circuits over Bool to the manuscript's De Morgan basis. XOR is implemented by

(left OR right) AND NOT (left AND right),

so it costs four standard gates; AND costs one; Boolean constants are free in the weighted model. Composing this translation with the reusable arithmetic expression compiler yields verified De Morgan circuits for Boolean polynomials, together with an exact 4 * additions + multiplications cost.

The De Morgan circuit simulating each Boolean arithmetic operation: exclusive or for addition, conjunction for multiplication, and a constant gate.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[simp]

    The simulation of each Boolean arithmetic operation uses arithmeticGateCount gates.

    The concrete operation circuits have the intended Boolean-ring semantics.

    The pulled-back manuscript cost is exactly four per XOR and one per AND.

    XOR a finite family of Boolean-ring expressions. The empty sum is the constant false expression.

    Equations
    Instances For
      @[simp]
      theorem Algebraic.DeMorgan.ArithmeticExpression.finSum_eval {n : ℕ} (count : ℕ) (terms : Fin count → Arithmetic.Expression Bool n) (input : Fin n → Bool) :
      Arithmetic.Expression.eval id input (finSum count terms) = ∑ index : Fin count, Arithmetic.Expression.eval id input (terms index)

      Evaluation of the expression-level finite sum is Boolean-ring summation.

      theorem Algebraic.DeMorgan.ArithmeticExpression.finSum_weightedCost {n : ℕ} (addition multiplication count : ℕ) (terms : Fin count → Arithmetic.Expression Bool n) :
      Arithmetic.Expression.weightedCost addition multiplication (finSum count terms) = ∑ index : Fin count, Arithmetic.Expression.weightedCost addition multiplication (terms index) + count * addition

      Exact weighted expression cost of a finite XOR fold.

      Compile a Boolean-ring expression into the De Morgan basis.

      Equations
      Instances For
        @[simp]
        theorem Algebraic.DeMorgan.ArithmeticExpression.circuit_eval {n : ℕ} (expression : Arithmetic.Expression Bool n) (input : Fin n → Bool) :
        (circuit expression).eval interpretation input 0 = Arithmetic.Expression.eval id input expression

        Compiled Boolean expressions have exactly their Boolean-ring semantics.

        @[simp]

        Exact standard De Morgan cost of a compiled Boolean expression.