Fixpoint rgdcop_rec q p n :=
if n is m.+1 then
if rcoprimep p q then p
else rgdcop_rec q (rdivp p (rgcdp p q)) m
else (q == 0)%:R.
Definition rgdcop q p := rgdcop_rec q p (size p).

(* Specifications: *)
Lemma rgdcop0 q : rgdcop q 0 = (q == 0)%:R.
(* this is a bad name *)
Lemma rdivp_eq p :
p * (lead_coef d ^+ (rscalp p d))%:P = (rdivp p d) * d + (rmodp p d).
(* section variables impose an inconvenient order on parameters *)
Lemma eq_rdvdp k q1 p:
p * ((lead_coef d)^+ k)%:P = q1 * d -> rdvdp d p.