Section PWO_Wrap.
Variable D_P R_P D_O R_O : Set.
Variable (P : ProcedureWithOracle D_P R_P D_O R_O).
Hint Resolve (P.(S_P_EqDec)) : typeclass_instances.
Hint Resolve (P.(R_O_EqDec)) : typeclass_instances.
Variable D_O' R_O' S_W : Set.
Variable WD : D_O -> Comp (D_O' * S_W).
Variable WR : S_W -> R_O' -> Comp R_O.
Hypothesis WD_wf : forall x, well_formed_comp (WD x).
Hypothesis WR_wf : forall x y, well_formed_comp (WR x y).
Hypothesis D_O'_EqDec : EqDec D_O'.
Hypothesis R_O'_EqDec : EqDec R_O'.
Hypothesis S_W_EqDec : EqDec S_W.
Definition PWO_Wrap_P1 d_P :=
[d_O, s_P] <-$2 P.(P1) d_P;
[d_O', s_W] <-$2 WD d_O;
ret (d_O', (s_P, s_W)).
intuition.
unfold PWO_Wrap_P1.
wftac.
eapply P1_wf.
Qed.
Definition PWO_Wrap_P2 s_Ps r_O' :=
[s_P, s_W] <-2 s_Ps;
r_O <-$ WR s_W r_O';
[d_O, s_P] <-$2 P2 s_P r_O;
[d_O', s_W] <-$2 WD d_O;
ret (d_O', (s_P, s_W)).
intuition.
unfold PWO_Wrap_P2.
wftac.
eapply P2_wf.
Qed.
Definition PWO_Wrap_P3 (s_Ps : P.(S_P) * S_W) r_O' :=
[s_P, s_W] <-2 s_Ps;
r_O <-$ WR s_W r_O';
P3 s_P r_O.

Theorem PWO_Wrap_P3_wf :
forall x y, well_formed_comp (PWO_Wrap_P3 x y).