(************************************************************************)
(* Copyright 2006 Milad Niqui                                           *)
(* This file is distributed under the terms of the                      *)
(* GNU Lesser General Public License Version 2.1                        *)
(* A copy of the license can be found at                                *)
(*                  <http://www.gnu.org/licenses/lgpl-2.1.html>         *)
(************************************************************************)
(* This file contains properties of the injection from Q into R. *)
(** We define the injection from Q into R *)
Definition Q_to_R (q:Q) : R := ((IZR (numerator q))/(IZR (denominator q)))%R.
Coercion Q_to_R : Q>->R.
intros [ |p|p].
simpl; rewrite Q_to_R_Zero; ring.
(* Qpos *)
unfold Q_to_R, numerator, denominator, decode_Q, Qopp, fst, snd.
destruct (interp_non_zero p) as [p0 [q0 H]].
rewrite H.
repeat rewrite Ropp_Ropp_IZR; repeat rewrite <- INR_IZR_INZ.
field; auto.
(* Qneg *)
unfold Q_to_R, numerator, denominator, decode_Q, Qopp, fst, snd.
destruct (interp_non_zero p) as [p0 [q0 H]].
rewrite H.
repeat rewrite Ropp_Ropp_IZR; repeat rewrite <- INR_IZR_INZ.
field; auto.
Qed.

Lemma Q_to_R_not_eq: forall x y, ~(x=y)->~(Q_to_R x = Q_to_R y).