Section MakeRingPol.
(* Ring elements *)
Variable R:Type.
Variable (rO rI : R) (radd rmul rsub: R->R->R) (ropp : R->R).
Variable req : R -> R -> Prop.
(* Ring properties *)
Variable Rsth : Equivalence req.
Variable Reqe : ring_eq_ext radd rmul ropp req.
Variable ARth : almost_ring_theory rO rI radd rmul rsub ropp req.
(* Coefficients *)
Variable C: Type.
Variable (cO cI: C) (cadd cmul csub : C->C->C) (copp : C->C).
Variable ceqb : C->C->bool.
Variable phi : C -> R.
Variable CRmorph : ring_morph rO rI radd rmul rsub ropp req
cO cI cadd cmul csub copp ceqb phi.
(* Power coefficients *)
Variable Cpow : Type.
Variable Cp_phi : N -> Cpow.
Variable rpow : R -> Cpow -> R.
Variable pow_th : power_theory rI rmul req Cp_phi rpow.
(* R notations *)
Notation "0" := rO. Notation "1" := rI.
Infix "+" := radd. Infix "*" := rmul.
Infix "-" := rsub. Notation "- x" := (ropp x).
Infix "==" := req.
Infix "^" := (pow_pos rmul).
(* C notations *)
Infix "+!" := cadd. Infix "*!" := cmul.
Infix "-! " := csub. Notation "-! x" := (copp x).
Infix "?=!" := ceqb. Notation "[ x ]" := (phi x).
(* Useful tactics *)
Add Morphism radd with signature (req ==> req ==> req) as radd_ext.
Hint Rewrite
Pphi0
Pphi1
mkPinj_ok
mkPX_ok
(morph0 CRmorph)
(morph1 CRmorph)
(morph0 CRmorph)
(morph_add CRmorph)
(morph_mul CRmorph)
(morph_sub CRmorph)
(morph_opp CRmorph)
: Esimpl.
(* Quicker than autorewrite with Esimpl :-) *)
Ltac Esimpl := try rewrite_db Esimpl; rsimpl; simpl.
Hint Rewrite PaddC_ok PsubC_ok PmulC_ok Popp_ok : Esimpl.
Ltac destr_mfactor R S := match goal with
| H : context [MFactor ?P _] |- context [MFactor ?P ?M] =>
specialize (H M); destruct MFactor as (R,S)
end.

Lemma Mphi_ok P M l :
let (Q,R) := MFactor P M in
P@l == Q@l + M@@l * R@l.