-
Notifications
You must be signed in to change notification settings - Fork 13
[WIP] replace the infrastructure of mpoly with monalg
#116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b90beb8 to
8a04263
Compare
827e452 to
0a52c6f
Compare
|
Hi @CohenCyril @Tragicus @proux01, I hope to reimplement |
|
Thanks for the heads up. It might well be a good opportunity for me to rewrite the multipoly refinement in CoqEAL, to target the structure used by ring/lra rather than those heavy maps on top of Stdlib. Or maybe CoqEAL will be subsumed by Trocq by then, who knows. Anyway, go ahead. |
71bc07d to
9fa0d33
Compare
@proux01 I need the refinement from |
|
I ported the first 1800 lines of |
9fa0d33 to
6d0b7d1
Compare
|
I see a few issues that make the porting non-trivial:
I'm taking a break from this PR until the 17th (which happens to be the next MC dev meeting). |
AFAIK, the only use of that refinement is in ValidSDP: https://github.com/validsdp/validsdp/blob/master/theories/validsdp.v Class list_of_poly_of T monom polyT := list_of_poly_op :
polyT -> seq (monom * T).
Definition max_coeff (p : polyT) : T :=
foldl (fun m mc => max m (max mc.2 (-mc.2)%C)) 0%C (list_of_poly_op p).
Inductive p_real_cst :=
| PConstR0
| PConstQq (_ : bigZ) (_ : bigN)
| PConstIZR (_ : BinNums.Z)
| PConstRdiv (_ : p_real_cst) (_ : positive)
| PConstRopp (_ : p_real_cst)
| PConstRinv (_ : positive).
Inductive p_abstr_poly :=
| PConst (_ : p_real_cst)
| PVar (_ : nat)
| POpp (_ : p_abstr_poly)
| PAdd (_ : p_abstr_poly) (_ : p_abstr_poly)
| PSub (_ : p_abstr_poly) (_ : p_abstr_poly)
| PMul (_ : p_abstr_poly) (_ : p_abstr_poly)
| PPowN (_ : p_abstr_poly) (_ : binnat.N)
| PPown (_ : p_abstr_poly) (_ : nat)
| PCompose (_ : p_abstr_poly) (_ : seq p_abstr_poly)
.
Fixpoint interp_poly_ssr (n : nat) (ap : abstr_poly) {struct ap} : {mpoly rat[n]} :=
match ap with
| Const t => (bigQ2rat t)%:MP_[n]
| Var i =>
match n with
| O => 0%:MP_[O]
| S n' => 'X_(inord i)
end
| Add a0 a1 => (interp_poly_ssr n a0 + interp_poly_ssr n a1)%R
| Sub a0 a1 => (interp_poly_ssr n a0 - interp_poly_ssr n a1)%R
| Mul a0 a1 => (interp_poly_ssr n a0 * interp_poly_ssr n a1)%R
| PowN a0 n' => mpoly_exp (interp_poly_ssr n a0) n'
| Compose a0 qi =>
let qi' := map (interp_poly_ssr n) qi in
match sumb (size qi' == size qi) with
| right prf => 0%:MP_[n]
| left prf =>
comp_mpoly (tcast (eqP prf) (in_tuple qi'))
(interp_poly_ssr (size qi) a0)
end
end.As I said, I'm fine with some breaking changes on that multipoly.v file in CoqEAL and having to do some porting work in validsdp. Not eveything needs to be exactly backward compatible and nice deprecations here. |
6d0b7d1 to
eb28e0d
Compare
eb28e0d to
d477d82
Compare
9fd7152 to
cf817f0
Compare
cf817f0 to
2b27f90
Compare
2b27f90 to
095de44
Compare
61ece29 to
1577d5c
Compare
1577d5c to
ae119ee
Compare
Currently, the Multinomials library has two representations of polynomials:
mpoly.v: old, less general (e.g., variables must be an ordinal, variables must be commutative), but more resultsmonalg.v: new, more general (e.g., variables can be anychoiceType, the type of polynomials can be instantiated with commutative, non-commutative, and mixed commutative and non-commutative monomials), but fewer resultsThis PR is the first step in unifying these two representations: reimplementing
mpoly.vusing the infrastructure provided bymonalg.v. By doing so, I expect that we can removefreeg.vand some part ofmpoly.v, and that we can identify what is lacking inmonalg.v.Then, a later step would be to port the remaining results in
mpoly.v(e.g., monomial ordering) tomonalg.vwith some generalizations (e.g., extending the monomial algebra hierarchy with monomial ordering, which allows us to choose the monomial order).See also: #19