Definition redivpT (p : polyF) (q : polyF) : cps (nat * polyF * polyF) :=
'let b <- isnull q;
if b then ret (0%N, [::0%T], p) else
'let sq <- sizeT q; 'let sp <- sizeT p;
'let lq <- lead_coefT q;
redivp_rec_loopT q sq lq 0 [::0%T] p sp.

Lemma redivpT_qf (p : polyF) (q : polyF) : rpoly p -> rpoly q ->
qf_cps (fun x => [&& rpoly x.1.2 & rpoly x.2]) (redivpT p q).