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.
intros p; case p; simpl in |- *; auto.
intros a l q; case q; unfold LetP in |- *; simpl in |- *; auto.
intros a0 l0 H' H'0.
cut (canonical A0 eqA ltM l0);
[ intros Op1 | apply canonical_imp_canonical with (a := a0) ];
auto.
cut (canonical A0 eqA ltM l);
[ intros Op2 | apply canonical_imp_canonical with (a := a) ];
auto.
cut (~ zeroP (A:=A) A0 eqA (n:=n) a);
[ intros Z0 | apply canonical_nzeroP with (ltM := ltM) (p := l); auto ].
cut (~ zeroP (A:=A) A0 eqA (n:=n) a0);
[ intros Z1 | apply canonical_nzeroP with (ltM := ltM) (p := l0) ];
auto.
Qed.
Hint Resolve spolyf_canonical.

Theorem spolyf_pO :
forall (a : list (Term A n)) (Ca : canonical A0 eqA ltM a),
eqP A eqA n (spolyf a a Ca Ca) (pO A n).