A canonical distributed multivariate polynomial. The backing tree map
stores only nonzero coefficients and uses the explicit comparator cmp.
- termsInternal : Std.ExtTreeMap (Mono n) R cmp
Canonical-form invariant: zero coefficients are absent.
Instances For
The absent coefficient of a monomial.
Equations
- Hex.MvPoly.coeff? m p = p.termsInternal[m]?
Instances For
Coefficient of a monomial, returning zero outside the support.
Equations
- Hex.MvPoly.coeff m p = (Hex.MvPoly.coeff? m p).getD 0
Instances For
Ordered term list, in increasing cmp order.
Equations
Instances For
Fold over terms in increasing cmp order.
Equations
- Hex.MvPoly.foldTerms f init p = Std.ExtTreeMap.foldl f init p.termsInternal
Instances For
The canonical support enumeration contains no duplicate monomials.
A monomial occurs in the ordered monomial list exactly when coefficient lookup succeeds.
A monomial occurs in the ordered monomial list exactly when its coefficient is nonzero.
Number of nonzero terms.
Equations
- p.termCount = p.termsInternal.size
Instances For
Greatest term in cmp order.
This uses the tree's logarithmic maximum-key query followed by one logarithmic
lookup. Keeping the definition in terms of the public key and lookup API gives
downstream proofs access to the complete maximum-entry specification even
though Std.ExtTreeMap.maxEntry? currently lacks corresponding lemmas.
Equations
- p.maxTerm? = p.termsInternal.maxKey?.bind fun (m : Hex.Mono n) => Option.map (fun (c : R) => (m, c)) p.termsInternal[m]?
Instances For
A maximum term is exactly a stored coefficient whose monomial bounds
every supported monomial in cmp order.
The zero polynomial.
Equations
- Hex.MvPoly.zero = { termsInternal := ∅, nonzeroInternal := ⋯ }
Instances For
Equations
- Hex.MvPoly.instZero = { zero := Hex.MvPoly.zero }
Equations
- Hex.MvPoly.instInhabited = { default := 0 }
The stored representation contains no explicit zero coefficient.
Boolean equality compares ordered term lists, avoiding the tree map's derived equality implementation in the kernel replay path.
Equations
- Hex.MvPoly.instBEqOfDecidableEq = { beq := fun (p q : Hex.MvPoly n R cmp) => decide (p.termsList = q.termsList) }
A single term, dropping it when its coefficient is zero.
Equations
Instances For
A constant polynomial.
Equations
Instances For
The variable xᵢ.
Equations
Instances For
Add c to the coefficient at m, deleting the term if the new
coefficient is zero.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build a polynomial by summing duplicate monomials and dropping all zero coefficients. Only additive structure is needed by the constructor.
Equations
- Hex.MvPoly.ofTerms ts = List.foldl (fun (p : Hex.MvPoly n R cmp) (t : Hex.Mono n × R) => p.addMonomial t.fst t.snd) 0 ts
Instances For
Every coefficient of the zero polynomial is zero.
A monomial polynomial has its supplied coefficient at the selected monomial and zero elsewhere.
A constant polynomial is supported at the zero monomial.
A variable polynomial is supported at its unit monomial.
Adding a monomial changes only the selected coefficient.
ofTerms sums the coefficients of duplicate monomials.
Filtering the canonical term list at one monomial recovers its coefficient.