(************************************************************************)
(* 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>         *)
(************************************************************************)
Require Export Qsyntax.
Require Export Field_Theory_Q.
Require Export Q_ordered_field_properties.
Definition Qabs (q:Q):Q:=
match q with
| Zero => Zero
| Qpos qp => Qpos qp
| Qneg qp => Qpos qp
end.

(* Specifications: *)
Lemma Qabs_eq: forall q, Zero<=q -> Qabs q = q.
Lemma Qabs_non_eq: forall q, q<=Zero -> Qabs q = (-q).
Lemma Qabs_eq_pos: forall q, Zero<q -> Qabs q = q.
Lemma Qabs_non_eq_neg: forall q, q<Zero -> Qabs q = (-q).
Lemma Qabs_Qmult: forall q1 q2, Qabs (q1*q2) = (Qabs q1) * (Qabs q2).
Lemma Qabs_5: forall q p, Qabs q <= p -> (- p <= q)/\ (q<= p).
Lemma Qabs_6: forall q p, Qabs q <= p -> q<= p.
Lemma Qabs_7: forall q p, Qabs q <= p -> - p <= q.
intros q p H; apply (proj1 (Qabs_5 _ _ H)).