intuition.
unfold DM_RC_G1, DM_RC_G2.
comp_skip.
comp_simp.
comp_skip.
dist_compute.
Qed.
Definition DM_RC_G3(c : A -> Comp B) :=
[a, s_A] <-$2 A1;
ls <-$ compMap _ (fun _ => b <-$ c a; g <-$ (A2 s_A b); ret (b, g)) (forNats n);
ret hd_error (map (fun x => snd x) (filter (fun p => P (fst p)) ls)).

Theorem DM_RC_G2_G3_close :
forall (c : A -> Comp B) k x,
(forall a s_A, In (a, s_A) (getSupport A1) -> well_formed_comp (c a)) ->
(forall a s_A, In (a, s_A) (getSupport A1) -> exists b, In b (filter P (getSupport (c a)))) ->
(forall a s_A, In (a, s_A) (getSupport A1) -> Pr[b <-$ c a; ret (negb (P b))] <= k) ->
| evalDist (DM_RC_G2 c) x - evalDist (DM_RC_G3 c) x | <= expRat k n.