Section TwoWorldsEquiv_eta.
Variable eta : nat.
Definition StandardDef_G :=
b <-$ {0, 1};
b' <-$ f eta b;
ret (eqb b b').
unfold StandardDef_G.
rewrite rndBool_bind.
assert ( Pr[b' <-$ f eta true; ret eqb true b'] == Pr[f eta true]).
symmetry.
rewrite <- evalDist_right_ident.
comp_skip.
fcf_compute.
rewrite H.
clear H.
assert ( Pr  [b' <-$ f eta false; ret eqb false b' ] == (ratSubtract 1 (Pr[f eta false]))).
assert (Pr  [b' <-$ f eta false; ret eqb false b' ]  == evalDist (f eta false) false).
symmetry.
rewrite <- evalDist_right_ident.
comp_skip.
fcf_compute.
rewrite H.
clear H.
eapply evalDist_bool_complement.
wftac.
rewrite H.
clear H.
rewrite <- ratMult_distrib.
rewrite <- (ratMult_1_r (1/2)) at 2.
rewrite ratMult_ratDistance_factor_l.
eapply ratMult_eqRat_compat; intuition.
assert ((Pr  [f eta false])  + ratSubtract 1 (Pr  [f eta false]) == 1).
rewrite <- ratSubtract_ratAdd_assoc.
eapply ratSubtract_ratAdd_inverse.
eapply evalDist_le_1.
unfold eq_dec.
rewrite <- H at 2.
rewrite ratDistance_add_same_r.
reflexivity.
Grab Existential Variables.
exact _.
exact _.
Qed.
rewrite StandardDef_equiv_2W_h.
rewrite ratDistance_comm.
intuition.
Qed.
End TwoWorldsEquiv_eta.
unfold negligible.
intuition.
destruct (H c).
exists x.
intuition.
eapply H0.
intuition.
rewrite H2.
rewrite Def_equiv_2W.
rewrite ratMult_comm.
eapply ratMult_small_le.
eapply rat_le_1.
simpl.
omega.
Qed.

Theorem TwoWorlds_equiv_b :
negligible (fun eta => | Pr[StandardDef_G eta] - 1 / 2 |) ->
negligible (fun eta => (| Pr[f eta false] - Pr[f eta true] |)).