Notation cps T := ((T -> fF) -> fF).Definition ret T1 : T1 -> cps T1 := fun x k => k x.Definition bind T1 T2 (x : cps T1) (f : T1 -> cps T2) : cps T2 :=
  fun k => x (fun x => f x k).End ClosedFieldQE.Definition cpsif T (c : fF) (t : T) (e : T) : cps T :=
  fun k => GRing.If c (k t) (k e).Notation eval := GRing.eval.Notation rterm := GRing.rterm.Notation qf_eval := GRing.qf_eval.Definition rpoly (p : polyF) := all (@rterm F) p.Definition qf_red_cps T (x : cps T) (y : _ -> T) :=
   forall e k, qf_eval e (x k) = qf_eval e (k (y e)).Definition qf_cps T D (x : cps T) :=
  forall k, (forall y, D y -> qf (k y)) -> qf (x k).

(* Specifications: *)
Lemma qf_cps_ret T D (x : T) : D x -> qf_cps D (ret x).
Lemma qf_cps_bind T1 D1 T2 D2 (x : cps T1) (f : T1 -> cps T2) : qf_cps D1 x -> (forall x, D1 x -> qf_cps D2 (f x)) -> qf_cps D2 (bind x f).
Lemma sizeTP (pf : polyF) : sizeT pf ->_e size (eval_poly e pf).
Lemma sizeT_qf (p : polyF) : rpoly p -> qf_cps xpredT (sizeT p).
Lemma isnull_qf (p : polyF) : rpoly p -> qf_cps xpredT (isnull p).