Variant edivp_spec (m d : {poly R}) :
nat * {poly R} * {poly R} -> bool -> Type :=
|Redivp_spec k (q r: {poly R}) of
(lead_coef d ^+ k) *: m = q * d + r & lead_coef d \notin GRing.unit &
(d != 0 -> size r < size d) : edivp_spec m d (k, q, r) false
|Fedivp_spec (q r: {poly R}) of m = q * d + r & (lead_coef d \in GRing.unit) &
(d != 0 -> size r < size d) : edivp_spec m d (0%N, q, r) true.

Lemma divp_eq  p q :
(lead_coef q ^+ (scalp p q)) *: p = (p %/ q) * q + (p %% q).