-
Notifications
You must be signed in to change notification settings - Fork 337
Computation models for polynomials and finitely supported functions
Eric Wieser edited this page Apr 28, 2024
·
19 revisions
Today, MvPolynomial
and Polynomial
are both implemented in terms of Finsupp
. As a result, all of:
Finsupp
Polynomial
MvPolynomial
Basis
are largely noncomputable
.
Possible designs include:
- De-classicalized
Finsupp
: promote anyClassical.decEq
terms to typeclass parameters. As a reminder, this stores the exactFinset
of non-zero values. -
DFinsupp
: we already have a working model here. This stores aMultiset
that is a superset of all the non-zero values. -
DFinsupp'
: A version ofDFinsupp
that stores aFinset
that is a superset. - Quotient of generators: an approach similar to
FreeAlgebra
. This could represent1 + 3x^2
asadd (monomial 0 1) (monomial 2 3)
and quotient by algebraic rules.
The following table outlines the computational behavior that ι →₀ R
could have under these strategies.
Operation | De-classicalized Finsupp
|
DFinsupp |
DFinsupp' |
Quotient of inductive type |
---|---|---|---|---|
f i (aka p.coeff i ) |
✓ | ✓ | ✓ | DecidableEq ι |
single i r (aka X ) |
DecidableEq ι DecidableEq R
|
DecidableEq ι |
DecidableEq ι |
✓ |
support |
✓ |
DecidableEq ι DecidableEq R
|
DecidableEq R |
DecidableEq ι DecidableEq R
|
+ |
DecidableEq ι DecidableEq R
|
✓ | DecidableEq ι |
✓ |
Recall that Polynomial
s are ℕ →₀ R
with ι = ℕ
, so DecidableEq ι
is not at all a burden here.
MvPolynomial
s are (σ →₀ ℕ) →₀ R
with ι = σ →₀ ℕ
, so DecidableEq ι
amounts to DecidableEq σ
.
DFinsupp
has the nice property of matching the computation model of Pi
(via Pi.single
, Function.support
, and the usual arithmetic).
Algorithmically though it is inefficient as the preSupport
set grows with each operation.
TODO: describe norm_num
-style computation.
- 2019-02-24 free_comm_ring: "I agree that
mv_polynomial
should have decidable_eq removed, but this isn't the only way to achieve that". This talks about the quotient approach a little. - 2019-08-14 timeout when working with ideal of polynomial ring: this thread mentions the main attempt to remove
decidable_eq
, but doesn't really justify the reason to. - 2022-08-14 nonconstructive polynomials
- 2023-06-04 Making a computable version of MvPolynomial.monomial
- #5942 Add a DecidableEq instance for Polynomial
- 2023-09-21 Computable degree-bound polynomials
- 2023-12-09 Removing classicality from
single
andupdate
for#eval
ingfun₀
notation - 2024-02-20 Why is
Polynomial
noncomputable? - 2024-04-26 rfl for finite sets (of
Polynomial
s)