DensePolyNormalized coeffs means either coeffs is empty or its last coefficient is
nonzero, so the array has no trailing zeros.
Instances For
Dense polynomials store coefficients in ascending degree order, with index i holding the
coefficient of x^i.
The packed native polynomial kernels rely on proof erasure leaving coeffs as
the sole runtime constructor field. Any new data-bearing field requires a
matching FFI update and native cross-check.
- coeffs : Array R
The stored coefficients in ascending degree order.
- normalized : DensePolyNormalized self.coeffs
Proof that
coeffscarries no trailing zeros.
Instances For
Remove trailing zeros from a coefficient list without disturbing the remaining order.
Equations
Instances For
Trimming preserves the value at every index, including indices beyond the trimmed length
where both sides default to 0.
Trimming trailing zeros never increases the coefficient-list length.
Trimming leaves the list either empty or with a nonzero last entry; this is the list-level
form of the DensePolyNormalized invariant.
Normalize a coefficient array by discarding all trailing zeros. The compiled
runtime uses the value-equal in-place implementation below, registered through
@[csimp], which pops trailing zeros off the array instead of round-tripping
through coeffs.toList.
Equations
- Hex.DensePoly.trimTrailingZeros coeffs = (Hex.DensePoly.trimTrailingZerosList coeffs.toList).toArray
Instances For
Runtime loop for trimTrailingZeros: pop trailing zeros off the array, up to n of
them. With n = coeffs.size it pops the whole trailing-zero run, reusing the input
storage in place when it is uniquely referenced rather than allocating a list.
Equations
- Hex.DensePoly.trimTrailingZerosGo coeffs 0 = coeffs
- Hex.DensePoly.trimTrailingZerosGo coeffs n.succ = if coeffs.back? = some Zero.zero then Hex.DensePoly.trimTrailingZerosGo coeffs.pop n else coeffs
Instances For
Runtime implementation of trimTrailingZeros.
Equations
- Hex.DensePoly.trimTrailingZerosImpl coeffs = Hex.DensePoly.trimTrailingZerosGo coeffs coeffs.size
Instances For
Register the value-equal trimTrailingZerosImpl as the compiled implementation of
trimTrailingZeros. Unlike @[implemented_by], the @[csimp] swap is backed by the proof
trimTrailingZerosGo_eq, so the runtime loop is verified equal to the specification.
Build a dense polynomial from a raw coefficient array by normalizing away trailing zeros.
Equations
- Hex.DensePoly.ofCoeffs coeffs = { coeffs := Hex.DensePoly.trimTrailingZeros coeffs, normalized := ⋯ }
Instances For
#p[a₀, a₁, ...] constructs a dense polynomial whose coefficient of
xⁱ is aᵢ. Trailing zero coefficients are removed by ofCoeffs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The zero polynomial.
Equations
Instances For
Equations
- Hex.DensePoly.instZero = { zero := Hex.DensePoly.zero }
Build a dense polynomial from a coefficient list by normalizing away trailing zeros.
Equations
- Hex.DensePoly.ofList coeffs = Hex.DensePoly.ofCoeffs coeffs.toArray
Instances For
Build the constant polynomial with value c. The zero constant collapses to the zero
polynomial.
Equations
Instances For
Build the monomial c * x^n. The zero coefficient collapses to the zero polynomial.
Equations
- Hex.DensePoly.monomial n c = if hc : c = Zero.zero then 0 else { coeffs := (Array.replicate n Zero.zero).push c, normalized := ⋯ }
Instances For
The normalized polynomial built from a raw coefficient array stores no more coefficients than the input array.
Characterising lemma for monomials: monomial n c has coefficient c at degree n and zero
elsewhere, even when c = 0 (in which case the polynomial is zero and every coefficient is 0).
The normalized polynomial built from a raw coefficient list stores no more coefficients than the input list.
Extensionality for normalized dense polynomials by their coefficient functions. This is the
preferred form of extensionality: it asks only for coefficient agreement, since
size agreement is forced by Hex.DensePoly.size_eq_of_coeff_eq.
Coefficient-level Boolean equality of two dense polynomials: equal stored
sizes and equal coefficients at every stored index. Because DensePoly has no
trailing zero coefficients, this decides polynomial equality. Its explicit
Bool fold also reduces on literal data after an ordinary public import.
Equations
Instances For
The zero polynomial has no stored coefficients.
A normalized dense polynomial has no stored coefficients exactly when it is the zero polynomial.
The zero polynomial has no degree.
Defaulting the degree of the zero polynomial returns the supplied default.
A constant polynomial with a nonzero scalar stores a single-element coefficient array; this is
the companion to coeffs_C_zero for the nonzero case.
A constant polynomial has size at most one, with size 0 when the scalar is zero and 1
otherwise.
The zero constant polynomial stores no coefficients.
A nonzero constant polynomial stores exactly its scalar coefficient.
The monomial with zero coefficient is the zero polynomial.
A monomial with nonzero coefficient is not the zero polynomial.
The support of a dense polynomial, listed in ascending degree order.
Equations
- p.support = List.filter (fun (i : Nat) => decide (p.coeff i ≠ Zero.zero)) (List.range p.size)
Instances For
The zero polynomial has empty support.
Return the underlying normalized coefficient array.
Instances For
The exposed normalized coefficient array has the same size as the polynomial.
View of the stored coefficients as a list, lowest degree first.
noncomputable by design: kernel-facing specifications, theorem statements,
and proofs read coefficients through this list view, while runtime code stays
on the Array API. A deliberate runtime list round-trip spells out
toArray.toList explicitly.
Instances For
The coefficient list has one entry per stored coefficient.
Normalizing the already-normalized coefficient array reconstructs the same polynomial.
Building from the reference coefficient list reconstructs the same polynomial.
Normalizing an empty coefficient array gives the zero polynomial.
Normalizing an empty coefficient list gives the zero polynomial.
An array consisting only of zeros normalizes to the zero polynomial.