Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

Require Import QArith_base Orders QOrderedType GenericMinMax.

Maximum and Minimum of two rational numbers

Local Open Scope Q_scope.
Qmin and Qmax are obtained the usual way from Qcompare.
Definition Qmax := gmax Qcompare.
Definition Qmin := gmin Qcompare.

Module QHasMinMax <: HasMinMax Q_as_OT.
 Module QMM := GenericMinMax Q_as_OT.
 Definition max := Qmax.
 Definition min := Qmin.
 Definition max_l := QMM.max_l.
 Definition max_r := QMM.max_r.
 Definition min_l := QMM.min_l.
 Definition min_r := QMM.min_r.
End QHasMinMax.

Module Q.
We obtain hence all the generic properties of max and min.
Include MinMaxProperties Q_as_OT QHasMinMax.

Properties specific to the Q domain

Compatibilities (consequences of monotonicity)

forall n m p : Q, Qmax (p + n) (p + m) == p + Qmax n m

forall n m p : Q, Qmax (p + n) (p + m) == p + Qmax n m
n, m, p:Q

Qmax (p + n) (p + m) == p + Qmax n m
n, m, p:Q

Proper (Qeq ==> Qeq) (Qplus p)
n, m, p:Q
Proper (Qle ==> Qle) (Qplus p)
n, m, p:Q

Proper (Qle ==> Qle) (Qplus p)
n, m, p, x, x':Q
Hx:x <= x'

p + x <= p + x'
apply Qplus_le_compat; q_order. Qed.

forall n m p : Q, Qmax (n + p) (m + p) == Qmax n m + p

forall n m p : Q, Qmax (n + p) (m + p) == Qmax n m + p
n, m, p:Q

Qmax (n + p) (m + p) == Qmax n m + p
n, m, p:Q

Qmax (p + n) (p + m) == p + Qmax n m
apply plus_max_distr_l. Qed.

forall n m p : Q, Qmin (p + n) (p + m) == p + Qmin n m

forall n m p : Q, Qmin (p + n) (p + m) == p + Qmin n m
n, m, p:Q

Qmin (p + n) (p + m) == p + Qmin n m
n, m, p:Q

Proper (Qeq ==> Qeq) (Qplus p)
n, m, p:Q
Proper (Qle ==> Qle) (Qplus p)
n, m, p:Q

Proper (Qle ==> Qle) (Qplus p)
n, m, p, x, x':Q
Hx:x <= x'

p + x <= p + x'
apply Qplus_le_compat; q_order. Qed.

forall n m p : Q, Qmin (n + p) (m + p) == Qmin n m + p

forall n m p : Q, Qmin (n + p) (m + p) == Qmin n m + p
n, m, p:Q

Qmin (n + p) (m + p) == Qmin n m + p
n, m, p:Q

Qmin (p + n) (p + m) == p + Qmin n m
apply plus_min_distr_l. Qed. End Q.