A list-form term: an exponent list and a coefficient.
Equations
- Hex.MvPoly.Kernel.Term κ = (List Nat × κ)
Instances For
A sparse polynomial represented by a canonical list of terms.
Equations
Instances For
Equality of exponent lists, using only Nat.beq and structural recursion.
Equations
- Hex.MvPoly.Kernel.expBeqImpl [] [] = true
- Hex.MvPoly.Kernel.expBeqImpl (a :: as) (b :: bs) = (a.beq b && Hex.MvPoly.Kernel.expBeqImpl as bs)
- Hex.MvPoly.Kernel.expBeqImpl x✝¹ x✝ = false
Instances For
Kernel equality through a simple recursor; compiled calls use expBeqImpl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lexicographic comparison of exponent lists, using only Nat.blt.
Equations
- Hex.MvPoly.Kernel.expCmpImpl [] [] = Ordering.eq
- Hex.MvPoly.Kernel.expCmpImpl [] (head :: tail) = Ordering.lt
- Hex.MvPoly.Kernel.expCmpImpl (head :: tail) [] = Ordering.gt
- Hex.MvPoly.Kernel.expCmpImpl (a :: as) (b :: bs) = if a.blt b = true then Ordering.lt else if b.blt a = true then Ordering.gt else Hex.MvPoly.Kernel.expCmpImpl as bs
Instances For
Kernel comparison through a simple recursor; compiled calls use expCmpImpl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pointwise addition of exponent lists. Canonical inputs have equal length; the trailing clauses make the operation total on untrusted data.
Equations
- Hex.MvPoly.Kernel.addExpImpl [] x✝ = x✝
- Hex.MvPoly.Kernel.addExpImpl x✝ [] = x✝
- Hex.MvPoly.Kernel.addExpImpl (a :: as) (b :: bs) = a.add b :: Hex.MvPoly.Kernel.addExpImpl as bs
Instances For
Kernel exponent addition through a simple recursor; compiled calls use addExpImpl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Insert one term into descending lexicographic order, adding coefficients on a collision and dropping a zero coefficient.
Equations
Instances For
Canonicalize an arbitrary term stream by insertion.
Equations
Instances For
Insertion sum, also the total fallback for an undersupplied merge budget.
Equations
- Hex.MvPoly.Kernel.insertSum [] x✝ = x✝
- Hex.MvPoly.Kernel.insertSum (t :: ts) x✝ = Hex.MvPoly.Kernel.insert t (Hex.MvPoly.Kernel.insertSum ts x✝)
Instances For
Linear merge of descending term lists. Recursion is structural on fuel. The public caller supplies the sum of the lengths, so its fallback is never needed; the fallback keeps the denotation law unconditional.
Equations
- One or more equations did not get rendered due to their size.
- Hex.MvPoly.Kernel.merge x✝¹ [] x✝ = x✝
- Hex.MvPoly.Kernel.merge x✝¹ x✝ [] = x✝
- Hex.MvPoly.Kernel.merge 0 x✝¹ x✝ = Hex.MvPoly.Kernel.insertSum x✝¹ x✝
Instances For
Add canonical term lists in one merge pass.
Equations
- Hex.MvPoly.Kernel.add p q = Hex.MvPoly.Kernel.merge ((List.length p).add (List.length q)) p q
Instances For
Map coefficients, filtering zero results without changing exponents.
Equations
Instances For
Negate a canonical term list, defensively filtering zero results.
Equations
Instances For
Subtraction through canonical addition and negation.
Equations
Instances For
Multiply every coefficient by a scalar, filtering zero products.
Equations
- Hex.MvPoly.Kernel.smul a p = Hex.MvPoly.Kernel.mapCoeffs (fun (c : κ) => a * c) p
Instances For
Multiply one term by every term of a polynomial, canonicalizing the row.
Equations
Instances For
Kernel row multiplication; compilation uses the equation implementation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sum rows, used for the total fallback of balanced merging.
Equations
Instances For
Merge each adjacent pair of rows.
Equations
Instances For
Balanced merge rounds, structurally recursive on a row-count budget.
Equations
Instances For
Multiply via translated rows and balanced linear merges.
Equations
- Hex.MvPoly.Kernel.mul p q = Hex.MvPoly.Kernel.mergeRows (List.length p) (List.map (fun (t : Hex.MvPoly.Kernel.Term κ) => Hex.MvPoly.Kernel.mulTerm t q) p)
Instances For
The zero test for a canonical list.
Equations
Instances For
Structural equality of term lists, with explicit exponent comparison.
Equations
- Hex.MvPoly.Kernel.beqImpl [] [] = true
- Hex.MvPoly.Kernel.beqImpl (t :: ts) (u :: us) = (Hex.MvPoly.Kernel.expBeq t.fst u.fst && decide (t.snd = u.snd) && Hex.MvPoly.Kernel.beqImpl ts us)
- Hex.MvPoly.Kernel.beqImpl x✝¹ x✝ = false
Instances For
Kernel list equality; compilation uses the equation implementation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Linear-time exponentiation used by evalAt; unlike the reference
repeated-squaring helper this is visibly structural recursion on Nat.
Equations
- Hex.MvPoly.Kernel.pow a 0 = 1
- Hex.MvPoly.Kernel.pow a n.succ = Hex.MvPoly.Kernel.pow a n * a
Instances For
Evaluate a monomial at a list point, stopping at the shorter list.
Equations
- Hex.MvPoly.Kernel.evalMono (x_2 :: xs) (e :: es) = Hex.MvPoly.Kernel.pow x_2 e * Hex.MvPoly.Kernel.evalMono xs es
- Hex.MvPoly.Kernel.evalMono x✝¹ x✝ = 1
Instances For
Evaluate a term list at a point.
Equations
- Hex.MvPoly.Kernel.evalAt x [] = 0
- Hex.MvPoly.Kernel.evalAt x (u :: us) = u.snd * Hex.MvPoly.Kernel.evalMono x u.fst + Hex.MvPoly.Kernel.evalAt x us
Instances For
The zero exponent list of length n.
Equations
Instances For
Canonical lists have the declared arity, strictly descending lexicographic exponents, and no zero coefficient. The arity conjunct is essential: without it distinct exponent lists can denote the same fixed-arity monomial.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The list-form multiplicative identity is canonical.
The result .lt of the explicit comparator is lexicographic <.
Every exponent emitted by insertion is either the inserted exponent or an exponent already present.
Once the combined input length is covered, extra fuel cannot change a merge. In particular the insertion fallback is irrelevant to public addition.
The public addition budget agrees with any larger merge budget.
Mapping and filtering coefficients preserves canonical form.
Boolean check for the canonical invariant.
Equations
- Hex.MvPoly.Kernel.isCanonical n [] = true
- Hex.MvPoly.Kernel.isCanonical n [t] = (t.fst.length.beq n && decide (t.snd ≠ 0))
- Hex.MvPoly.Kernel.isCanonical n (t :: u :: ts) = (t.fst.length.beq n && decide (t.snd ≠ 0) && Hex.MvPoly.Kernel.expCmp t.fst u.fst == Ordering.gt && Hex.MvPoly.Kernel.isCanonical n (u :: ts))
Instances For
The Boolean canonicality check decides the proposition.
Read an exponent list as an n-variable monomial. Canonical inputs have
exactly length n; getD merely makes denotation total on malformed input.
Equations
- Hex.MvPoly.Kernel.mono n e = Hex.Vector.ofFn' fun (i : Fin n) => e.getD (↑i) 0
Instances For
Materialize the input once instead of repeatedly indexing a linked list.
Equations
- Hex.MvPoly.Kernel.monoFast n e = Hex.Vector.ofFn' fun (i : Fin n) => e.toArray[↑i]?.getD 0
Instances For
Denote a term list in the reference polynomial type.
Equations
Instances For
Convert a reference polynomial to the fixed canonical list order. This is a producer-side conversion; certificate replay sees only its quoted result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Inserting a term has the denotation of adding its monomial.
Normalization does not change denotation.
List addition denotes reference addition.
A merge has the denotation of the sum, for any fuel and any input.
List addition denotes reference addition.
List negation denotes reference negation.
List subtraction denotes reference subtraction.
List scalar multiplication denotes multiplication by a constant.
The list multiplicative identity denotes the reference identity.
Multiplying one term through a list denotes multiplication by its reference monomial.
Balanced merging denotes the sum of its rows, independently of fuel.
List multiplication denotes reference multiplication.
The recursive sum denotation agrees with the reference bulk constructor.
Converting a vector monomial to a list and reading it back is exact.
Producer conversion always emits a canonical list.
Producer conversion round-trips through denotation.
Producer conversion for nested polynomial lists. A matrix consumer
passes rowLists P; no matrix dependency is needed in this library.
Equations
Instances For
Entrywise denotation identifies quoted rows with the original rows.
In particular, instantiate rows with rowLists P for a reference matrix.
The linear structural power used by certificate replay has the standard semiring value.
List evaluation commutes with evaluation of the reference denotation.
A monomial absent from a well-formed list has zero coefficient in its denotation.
Reference coefficients read back the stored coefficient of a canonical list.
Canonical lists with the same coefficient function are equal.
Canonical list denotation is injective.
A canonical list is recovered by converting its denotation back to list form.
Structural equality returns true exactly for equal term lists.
The empty-list test agrees with zero denotation on canonical inputs.
Structural equality agrees with denotational equality on canonical inputs.
Reflexivity of list equality, stated at the kernel Boolean interface.