Documentation

Complexitylib.Algebraic.LowerBound.Fusion.SumOfTerms.Waring.Translation

Compiling Waring sums to ordinary arithmetic circuits #

A Waring term is syntactically nullary in the sum-of-terms basis but depends semantically on a shared family of polynomial variables. A contextual translation exposes those variables to every term gadget. The gadgets are compiled from reusable arithmetic expressions, giving exact semantics and a concrete ordinary arithmetic circuit for every sum-of-powers circuit.

Right-associated sum of arithmetic expressions, with a named zero for the empty sum.

Equations
Instances For
    def Algebraic.Fusion.SumOfTerms.Waring.Translation.expressionPower {K : Type} {variableCount : ℕ} [One K] (base : Arithmetic.Expression K variableCount) :
    ℕ → Arithmetic.Expression K variableCount

    Naive natural power expression. Tree compilation intentionally exposes every intermediate product as its own multiplication gate.

    Equations
    Instances For

      Arithmetic expression for the linear form of one Waring term.

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

        Arithmetic expression for one charged Waring term.

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

          Power expression whose base arrives on one shared input wire. Unlike termExpression, tree compilation of this expression does not duplicate the linear-form computation.

          Equations
          Instances For

            DAG-style Waring-term gadget: compute the linear form once, feed its single output to a power chain, and apply the term scale once at the end.

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

              The gate count of sharedTermCircuit is the sum of the tree gate counts of its three stages: the linear form, the shared power chain, and the final scaling. Composing the stages adds no gates. Unlike the multiplication and addition charges below, the count includes the named-constant gates.

              Arithmetic expression implementing the source addition gate after the 2n shared context inputs.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem Algebraic.Fusion.SumOfTerms.Waring.Translation.weightedCost_expressionSum {K : Type} {variableCount : ℕ} [Zero K] (addition multiplication : ℕ) (expressions : List (Arithmetic.Expression K variableCount)) :
                Arithmetic.Expression.weightedCost addition multiplication (expressionSum expressions) = (List.map (Arithmetic.Expression.weightedCost addition multiplication) expressions).sum + addition * expressions.length

                A right-associated expression sum has the sum of its subtree costs plus one addition charge per list entry (including the final addition to zero).

                theorem Algebraic.Fusion.SumOfTerms.Waring.Translation.weightedCost_expressionPower {K : Type} {variableCount : ℕ} [One K] (addition multiplication : ℕ) (base : Arithmetic.Expression K variableCount) (exponent : ℕ) :
                Arithmetic.Expression.weightedCost addition multiplication (expressionPower base exponent) = exponent * (Arithmetic.Expression.weightedCost addition multiplication base + multiplication)

                Naive power compilation repeats the base tree once per exponent step and adds one multiplication node at that step.

                @[simp]

                Exact number of multiplications in a compiled linear-form gadget.

                @[simp]

                Exact number of additions in a compiled linear-form gadget.

                Multiplicative cost of one naive compiled Waring-term gadget.

                Equations
                Instances For

                  Additive cost of one naive compiled Waring-term gadget.

                  Equations
                  Instances For
                    @[simp]

                    Exact multiplicative cost of a Waring-term expression.

                    @[simp]

                    Exact additive cost of a Waring-term expression.

                    @[simp]

                    The source-addition gadget uses no multiplication gates.

                    @[simp]

                    The source-addition gadget uses exactly one addition gate.

                    @[simp]

                    Exact addition cost of the shared term gadget.

                    theorem Algebraic.Fusion.SumOfTerms.Waring.Translation.eval_expressionSum {K : Type} {R : Type u_1} {variableCount : ℕ} [Semiring R] [Zero K] (constant : K → R) (input : Fin variableCount → R) (mapsZero : constant 0 = 0) (expressions : List (Arithmetic.Expression K variableCount)) :
                    Arithmetic.Expression.eval constant input (expressionSum expressions) = (List.map (Arithmetic.Expression.eval constant input) expressions).sum

                    Evaluation of a right-associated expression sum.

                    theorem Algebraic.Fusion.SumOfTerms.Waring.Translation.eval_expressionPower {K : Type} {R : Type u_1} {variableCount : ℕ} [Semiring R] [One K] (constant : K → R) (input : Fin variableCount → R) (mapsOne : constant 1 = 1) (base : Arithmetic.Expression K variableCount) (exponent : ℕ) :
                    Arithmetic.Expression.eval constant input (expressionPower base exponent) = Arithmetic.Expression.eval constant input base ^ exponent

                    Evaluation of the naive power expression.

                    The linear-form expression evaluates to the polynomial linear form.

                    The term expression evaluates exactly to the charged Waring term.

                    The shared term gadget computes exactly the charged Waring term.

                    Contextual compilation of Waring sum-of-terms syntax into the ordinary arithmetic basis.

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

                      Contextual Waring translation using the shared-linear-form DAG gadget for each term.

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

                        Pulling target multiplication cost through the Waring translation charges each source term by the exact naive term-gadget multiplication count and makes source addition free.

                        Pulling target addition cost through the Waring translation charges one for every source addition and charges each term by its exact internal addition count.

                        The shared translation charges each term by 2n internal additions and preserves source additions one-for-one.

                        Exact multiplication cost of contextual Waring compilation.

                        Closed multiplication-cost formula: the naive compiler pays the same quadratic gadget cost for every Waring term and nothing for source addition.

                        Exact addition cost of contextual Waring compilation.

                        Closed addition-cost formula: source additions remain single additions, while each Waring term contributes its internal quadratic addition cost.

                        Pulling ordinary polynomial semantics through the contextual translation recovers Waring sum-of-terms semantics exactly.

                        Pulling polynomial semantics through the shared-linear-form translation recovers Waring semantics exactly.

                        Contextual compilation preserves every Waring circuit's polynomial outputs.

                        Shared-linear-form contextual compilation preserves every Waring circuit's polynomial outputs.