Reverse-substitution progress measures over a commutative semiring #
This is the constant-alphabet-generic core of arithmetic reverse substitution. Every input and gate wire receives a formal variable, and gates are eliminated in reverse topological order. Addition and multiplication substitute the last variable by the corresponding expression in prior wire variables; a named constant substitutes its constant polynomial.
Measure exposes one local law for each operation. These laws telescope over
the circuit DAG, so shared gates are charged exactly once.
Arithmetic interpretation on semiring-coefficient polynomials, with named
constants interpreted by constant.
Equations
- Algebraic.Fusion.Arithmetic.Progress.General.polynomialInterpretation constant V = Algebraic.Arithmetic.interpretation fun (scalar : K) => MvPolynomial.C (constant scalar)
Instances For
Formal polynomial computed by one arithmetic line from variables naming
all wires in its prefix, each wire named by its position Wire.index.
Equations
- Algebraic.Fusion.Arithmetic.Progress.General.lineFormalResult constant { op := Algebraic.Arithmetic.Op.add, wires := wires } = MvPolynomial.X (wires 0).index + MvPolynomial.X (wires 1).index
- Algebraic.Fusion.Arithmetic.Progress.General.lineFormalResult constant { op := Algebraic.Arithmetic.Op.mul, wires := wires } = MvPolynomial.X (wires 0).index * MvPolynomial.X (wires 1).index
- Algebraic.Fusion.Arithmetic.Progress.General.lineFormalResult constant { op := Algebraic.Arithmetic.Op.constant scalar, wires := wires } = MvPolynomial.C (constant scalar)
Instances For
Eliminate the new last gate-variable by substituting its formal result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Expand every formal gate-variable by eliminating gates in reverse topological order.
Equations
- One or more equations did not get rendered due to their size.
- Algebraic.Fusion.Arithmetic.Progress.General.programExpansionHom constant Cslib.Circuits.Program.empty = AlgHom.id R (MvPolynomial (Fin (n + 0)) R)
Instances For
Expanding a formal wire-variable gives the polynomial carried by that wire in the original program.
The formal output variable of a single-output circuit.
Equations
- Algebraic.Fusion.Arithmetic.Progress.General.circuitFormalOutput circuit = MvPolynomial.X (circuit.outputs 0).index
Instances For
Polynomial obtained by reverse-substituting every gate into the formal output variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reverse substitution recovers ordinary polynomial evaluation.
A polymorphic polynomial progress measure compatible with all three reverse substitutions.
- value (variableCount : ℕ) : MvPolynomial (Fin variableCount) R → ℕ
Quantity assigned to polynomials over each finite variable set.
- variable_zero (variableCount : ℕ) (coordinate : Fin variableCount) : self.value variableCount (MvPolynomial.X coordinate) = 0
A single formal variable has zero progress.
- add_substitution_le (variableCount : ℕ) (polynomial : MvPolynomial (Fin (variableCount + 1)) R) (left right : Fin variableCount) : self.value variableCount ((MvPolynomial.bind₁ fun (i : Fin (variableCount + 1)) => Fin.lastCases (MvPolynomial.X left + MvPolynomial.X right) MvPolynomial.X i) polynomial) ≤ self.value (variableCount + 1) polynomial + operationCost Arithmetic.Op.add
Substituting the last variable by a sum obeys the addition charge.
- mul_substitution_le (variableCount : ℕ) (polynomial : MvPolynomial (Fin (variableCount + 1)) R) (left right : Fin variableCount) : self.value variableCount ((MvPolynomial.bind₁ fun (i : Fin (variableCount + 1)) => Fin.lastCases (MvPolynomial.X left * MvPolynomial.X right) MvPolynomial.X i) polynomial) ≤ self.value (variableCount + 1) polynomial + operationCost Arithmetic.Op.mul
Substituting the last variable by a product obeys the multiplication charge.
- constant_substitution_le (variableCount : ℕ) (polynomial : MvPolynomial (Fin (variableCount + 1)) R) (scalar : K) : self.value variableCount ((MvPolynomial.bind₁ fun (i : Fin (variableCount + 1)) => Fin.lastCases (MvPolynomial.C (constant scalar)) MvPolynomial.X i) polynomial) ≤ self.value (variableCount + 1) polynomial + operationCost (Arithmetic.Op.constant scalar)
Substituting the last variable by a named constant obeys its operation charge.
Instances For
One reverse gate substitution obeys the local progress estimate.
Reverse substitution telescopes local progress across a whole program.
The measure of the expanded output is bounded by circuit cost.
Any arithmetic circuit producing a target polynomial pays its progress measure.