(***********************)
(* Regarding rationals *)
(***********************)
Definition frac (a b : Z) := ((IZR a) / (IZR b))%R.
Definition is_rat (r : R) :=
exists pq : Z * Z, let (p,q) := pq in ~(q = 0) /\ r = (frac p q).
Definition is_ratp (c : R * R) := let (x,y) := c in (is_rat x) /\ (is_rat y).

(* Specifications: *)
Lemma frac_eq : forall a b c d : Z,
b <> 0 -> c <> 0 -> (frac a (b * c)) = (frac d c) -> a = b * d.
Lemma frac_rat : forall a b : Z,
b <> 0 -> (frac a b >= 0)%R -> (frac a b <= 1)%R ->
a >= 0 /\ b > 0 /\ a <= b \/ a <= 0 /\ b < 0 /\ b <= a.
Lemma frac_simp : forall a b c : Z,
b <> 0 -> c <> 0 -> frac (c * a) (c * b) = frac a b.
Lemma frac_opp : forall a b : Z, b <> 0 -> frac (-a) (-b) = frac a b.
Lemma relp_rat : forall r : R, (is_rat r) -> (r >= 0)%R -> (r <= 1)%R ->
exists pq : Z * Z,
let (p,q) := pq in
(p >= 0) /\ (q > 0) /\ (p <= q) /\ (rel_prime p q) /\ r = (frac p q).