rattac;
unfold ratDistance, ratSubtract in *;
rattac;
unfold minRat, maxRat in *;
rattac.
case_eq (bleRat (RatIntro n (exist (fun n : nat => n > 0) x2 g2))
(RatIntro n0 (exist (fun n : nat => n > 0) x1 g1))); intuition.
rewrite H1 in H2.
rewrite H1 in H0.
rattac.
rewrite H1 in H2.
rewrite H1 in H0.
rattac.
case_eq (bleRat (RatIntro n0 (exist (fun n : nat => n > 0) x0 g0))
(RatIntro n1 (exist (fun n : nat => n > 0) x g))); intuition.
rewrite H0 in H1.
rewrite H0 in H2.
rattac.
inversion e; clear e; subst.
apply mult_is_O in H2; intuition.
unfold posnatMult in *.
inversion H5; clear H5; subst.
assert ((RatIntro n4 (exist (fun n : nat => n > 0) x0 g0)) <= (RatIntro n3 (exist (fun n : nat => n > 0) x g))).
unfold leRat.
trivial.
eapply nat_minus_eq.
apply (leRat_mult H2).
trivial.
rewrite H0 in H1.
rewrite H0 in H2.
rattac.
unfold posnatMult in *.
simpl in *.
inversion H5; clear H5; subst.
apply mult_is_O in e. intuition.
symmetry.
eapply nat_minus_eq; trivial.
apply bleRat_total in H0.
assert (leRat (RatIntro n4 (exist (fun n : nat => n > 0) x g))
(RatIntro n3 (exist (fun n : nat => n > 0) x0 g0))).
apply H0.
apply (leRat_mult H2).
Qed.
(* is this even true ? Lemma ratDistance_comm_2 : forall r1 r2 r3 r4, ratDistance (ratDistance r1 r2) (ratDistance r3 r4) == ratDistance (ratDistance r1 r3) (ratDistance r2 r4).  intuition.  unfold ratDistance, ratSubtract. rattac. arithNormalize.  Lemma minus_eq_compat : forall n1 n2 n3 n4, n1 = n2 -> n3 = n4 -> n1 - n3 = n2 - n4.  intuition. Qed.  apply minus_eq_compat. arithSimplify. rewrite (mult_comm _ x). arithNormalize. arithSimplify. unfold minRat, maxRat in *. case_eq (bleRat (RatIntro (n7 * p8 - n8 * p7) (posnatMult p7 p8)) (RatIntro (n9 * p10 - n10 * p9) (posnatMult p9 p10))); intuition; case_eq ( bleRat (RatIntro (n3 * p4 - n4 * p3) (posnatMult p3 p4)) (RatIntro (n5 * p6 - n6 * p5) (posnatMult p5 p6))); intuition. case_eq (bleRat (RatIntro (n7 * p8 - n8 * p7) (posnatMult p7 p8)) (RatIntro (n9 * p10 - n10 * p9) (posnatMult p9 p10))); intuition. case_eq (bleRat (RatIntro (n3 * p4 - n4 * p3) (posnatMult p3 p4)) (RatIntro (n5 * p6 - n6 * p5) (posnatMult p5 p6))); intuition. rewrite H11 in H. rewrite H12 in H1. rewrite H13 in H0. rewrite H14 in H2.  inversion H; clear H; subst. inversion H0; clear H0; subst. inversion H1; clear H1; subst. inversion H2; clear H2; subst.  unfold posnatMult in *. destruct p9; destruct p10. destruct p5; destruct p6. destruct p7; destruct p8. destruct p3; destruct p4. simpl in *. inversion H1; clear H1; subst. inversion H15; clear H15; subst. inversion H16; clear H16; subst. inversion H17; clear H17; subst.  unfold minRat in *.  destruct p7.  SearchAbout minus. rattac_one. rattac_one. Abort. *)

Lemma ratSubtract_partition : forall r1 r2 r3,
r1 <= r2 ->
r2 <= r3 ->
(ratSubtract r3 r1) == (ratSubtract r2 r1) + (ratSubtract r3 r2).