Section Pspoly.
Load "hCoefStructure".
Load "hOrderStructure".
Load "hReducestar".
Definition spolyf :
forall (p q : list (Term A n)) (Cp : canonical A0 eqA ltM p)
(Cq : canonical A0 eqA ltM q), list (Term A n).
intros p1; case p1.
intros p2 H' H'0; exact (pO A n).
intros a p11 p2; case p2.
intros H' H'0; exact (pO A n).
intros b p22 H' H'0.
apply LetP with (A := Term A n) (h := ppc (A:=A) A1 (n:=n) a b).
intros u H'1.
cut (~ zeroP (A:=A) A0 eqA (n:=n) a);
[ intros nZa | apply canonical_nzeroP with (ltM := ltM) (p := p11); auto ].
cut (~ zeroP (A:=A) A0 eqA (n:=n) b);
[ intros nZb | apply canonical_nzeroP with (ltM := ltM) (p := p22); auto ].
exact
(minuspf A A0 A1 eqA invA minusA multA eqA_dec n ltM ltM_dec
(mults (A:=A) multA (n:=n)
(divTerm (A:=A) (A0:=A0) (eqA:=eqA) divA (n:=n) u (b:=a) nZa) p11)
(mults (A:=A) multA (n:=n)
(divTerm (A:=A) (A0:=A0) (eqA:=eqA) divA (n:=n) u (b:=b) nZb) p22)).
Defined.

Theorem spolyf_canonical :
forall (p q : list (Term A n)) (Cp : canonical A0 eqA ltM p)
(Cq : canonical A0 eqA ltM q), canonical A0 eqA ltM (spolyf p q Cp Cq).