intuition.
destruct b.
trivial.
rewrite evalDist_complement.
rewrite evalDist_complement.
eapply ratSubtract_eqRat_compat; intuition.
trivial.
trivial.
Qed.
Class RatRel (R : Rat -> Rat -> Prop) :=
{
refl : forall r1 r2, r1 == r2 -> R r1 r2;
trans : Transitive R;
add_proper : Proper (R ==> R ==> R) ratAdd;
mult_proper : Proper (R ==> R ==> R) ratMult
}.
Instance RatRel_trans :
forall (R : Rat -> Rat -> Prop),
RatRel R -> Transitive R.
intuition.
destruct H.
intuition.
Qed.
Instance RatRel_flip :
forall R,
RatRel R ->
RatRel (Basics.flip R).
intuition.
econstructor; intuition.
unfold Basics.flip.
eapply refl.
eapply eqRat_symm.
intuition.
unfold Proper, respectful, Basics.flip in *; intuition.
eapply add_proper; trivial.
unfold Proper, respectful, Basics.flip in *; intuition.
eapply mult_proper; trivial.
Qed.
(* The class includes equality and inequality. *)
Instance eqRat_RatRel : RatRel eqRat.
econstructor;
eauto with typeclass_instances.
Qed.
Instance leRat_RatRel : RatRel leRat.
econstructor;
eauto with typeclass_instances.
eapply eqRat_impl_leRat.
Qed.
(* This one comes up some times: *)
Instance eqRat_RatRel_1 :
RatRel (fun r r1 : Rat => r1 == r).
eapply RatRel_flip.
intuition.
Qed.

(* Specifications: *)
(* some distribution rules that use RatRel *)
Theorem evalDist_left_ident :
forall rel (B : Set)(eqd : EqDec B)(b : B)(A : Set)(c2 : B -> Comp A) a,
RatRel rel ->
rel (evalDist (x <-$ ret b; (c2 x)) a) (evalDist (c2 b) a).