intuition.
unfold DM_RC_G2, DM_RC_G3.
eapply evalDist_bind_distance; intuition.
rewrite ratDistance_comm.
eapply leRat_trans.
eapply compMap_Repeat_close.
wftac.
edestruct H0.
eauto.
apply filter_In in H3.
intuition.
specialize (A2_wf b0 x0).
apply well_formed_val_exists in A2_wf.
destruct A2_wf.
econstructor.
eapply filter_In.
intuition.
eapply getSupport_In_Seq.
eauto.
eapply getSupport_In_Seq.
eauto.
simpl.
intuition.
simpl.
trivial.
eapply expRat_leRat_compat.
eapply leRat_trans.
2:{
eapply H1.
eauto.
}
comp_inline_l.
comp_skip.
inline_first.
comp_irr_l.
simpl.
intuition.
Qed.
Definition DM_RC_G4(c : A -> Comp B) :=
[a, s_A] <-$2 A1;
allB <-$ compMap _ (fun _ => (c a)) (forNats n);
allB_G <-$ compMap _ (fun b => g <-$ (A2 s_A b); ret (b, g)) allB;
ret hd_error (map (fun x => snd x) (filter (fun p => P (fst p)) allB_G)).

(* Specifications: *)
Theorem DM_RC_G4_equiv :
forall c x,
evalDist (DM_RC_G3 c) x == evalDist (DM_RC_G4 c) x.