(************************************************************************)
(* 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 Qmax p q := if Q_le_lt_dec p q then q else p.
Definition Qmin p q := if Q_le_lt_dec p q then p else q.

(* Specifications: *)
Lemma Qle_max_l: forall p q, p <= Qmax p q.
Lemma Qle_max_r: forall p q, q <= Qmax p q.
Lemma Qmax_lub: forall q1 q2 p, q1 <= p -> q2 <= p -> Qmax q1 q2 <= p.
Lemma Qmax_Qlt_upper_bound:forall p q1 q2, p<q1 -> p<q2 ->p < Qmax q1 q2.
Lemma Qmax_nondecreasing: forall q1 q2 p1 p2, q1 <= p1 -> q2 <= p2 -> Qmax q1 q2 <= Qmax p1 p2.
Lemma Qmin_Qmax_Qle:forall q1 q2, Qmin q1 q2 <= Qmax q1 q2.
Lemma Qmin_nondecreasing: forall q1 q2 p1 p2, q1 <= p1 -> q2 <= p2 -> Qmin q1 q2 <= Qmin p1 p2.
Lemma Qmin_glb: forall q1 q2 p, p<=q1 -> p<=q2 -> p<=Qmin q1 q2.
Lemma Qmin_Qlt_upper_bound:forall p q1 q2, p<q1 -> p<q2 ->p < Qmin q1 q2.
Lemma Qle_min_l: forall p q : Q, Qmin p q <= p.
Lemma Qle_min_r: forall p q : Q, Qmin p q <= q.
Lemma Qmax_or_informative:forall p q, {Qmax p q = p} + {Qmax p q = q}.
Lemma Qmin_or_informative:forall p q, {Qmin p q = p} + {Qmin p q = q}.
Definition Qmax4 q1 q2 q3 q4 := Qmax (Qmax q1 q2) (Qmax q3 q4).