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 Orders Rbase Rbasic_fun ROrderedType GenericMinMax.
Local Open Scope R_scope.
The functions Rmax and Rmin implement indeed
a maximum and a minimum
forall x y : R, y <= x -> Rmax x y = xforall x y : R, y <= x -> Rmax x y = xforall x y : R, y <= x -> (if Rle_dec x y then y else x) = xdestruct Rle_dec as [H'|H']; [| apply Rnot_le_lt in H' ]; unfold Rle in *; intuition. Qed.x, y:RH:y <= x(if Rle_dec x y then y else x) = xforall x y : R, x <= y -> Rmax x y = yforall x y : R, x <= y -> Rmax x y = yforall x y : R, x <= y -> (if Rle_dec x y then y else x) = ydestruct Rle_dec as [H'|H']; [| apply Rnot_le_lt in H' ]; unfold Rle in *; intuition. Qed.x, y:RH:x <= y(if Rle_dec x y then y else x) = yforall x y : R, x <= y -> Rmin x y = xforall x y : R, x <= y -> Rmin x y = xforall x y : R, x <= y -> (if Rle_dec x y then x else y) = xdestruct Rle_dec as [H'|H']; [| apply Rnot_le_lt in H' ]; unfold Rle in *; intuition. Qed.x, y:RH:x <= y(if Rle_dec x y then x else y) = xforall x y : R, y <= x -> Rmin x y = yforall x y : R, y <= x -> Rmin x y = yforall x y : R, y <= x -> (if Rle_dec x y then x else y) = ydestruct Rle_dec as [H'|H']; [| apply Rnot_le_lt in H' ]; unfold Rle in *; intuition. Qed. Module RHasMinMax <: HasMinMax R_as_OT. Definition max := Rmax. Definition min := Rmin. Definition max_l := Rmax_l. Definition max_r := Rmax_r. Definition min_l := Rmin_l. Definition min_r := Rmin_r. End RHasMinMax. Module R.x, y:RH:y <= x(if Rle_dec x y then x else y) = y
We obtain hence all the generic properties of max and min.
Include UsualMinMaxProperties R_as_OT RHasMinMax.
Compatibilities (consequences of monotonicity)
forall n m p : R, Rmax (p + n) (p + m) = p + Rmax n mforall n m p : R, Rmax (p + n) (p + m) = p + Rmax n mn, m, p:RRmax (p + n) (p + m) = p + Rmax n mn, m, p:RProper (Rle ==> Rle) (Rplus p)apply Rplus_le_compat_l. Qed.n, m, p, x, y:Rx <= y -> p + x <= p + yforall n m p : R, Rmax (n + p) (m + p) = Rmax n m + pforall n m p : R, Rmax (n + p) (m + p) = Rmax n m + pn, m, p:RRmax (n + p) (m + p) = Rmax n m + papply plus_max_distr_l. Qed.n, m, p:RRmax (p + n) (p + m) = p + Rmax n mforall n m p : R, Rmin (p + n) (p + m) = p + Rmin n mforall n m p : R, Rmin (p + n) (p + m) = p + Rmin n mn, m, p:RRmin (p + n) (p + m) = p + Rmin n mn, m, p:RProper (Rle ==> Rle) (Rplus p)apply Rplus_le_compat_l. Qed.n, m, p, x, y:Rx <= y -> p + x <= p + yforall n m p : R, Rmin (n + p) (m + p) = Rmin n m + pforall n m p : R, Rmin (n + p) (m + p) = Rmin n m + pn, m, p:RRmin (n + p) (m + p) = Rmin n m + papply plus_min_distr_l. Qed.n, m, p:RRmin (p + n) (p + m) = p + Rmin n m
Anti-monotonicity swaps the role of min and max
forall n m : R, - Rmax n m = Rmin (- n) (- m)forall n m : R, - Rmax n m = Rmin (- n) (- m)n, m:R- Rmax n m = Rmin (- n) (- m)n, m:RRmin (- n) (- m) = - Rmax n mn, m:RProper (Rle ==> Basics.flip Rle) Roppn, m:Rforall x y : R, x <= y -> - y <= - xapply Ropp_le_ge_contravar; auto. Qed.n, m, x, y:RH:x <= y- x >= - yforall n m : R, - Rmin n m = Rmax (- n) (- m)forall n m : R, - Rmin n m = Rmax (- n) (- m)n, m:R- Rmin n m = Rmax (- n) (- m)n, m:RRmax (- n) (- m) = - Rmin n mn, m:RProper (Rle ==> Basics.flip Rle) Roppn, m:Rforall x y : R, x <= y -> - y <= - xapply Ropp_le_ge_contravar; auto. Qed.n, m, x, y:RH:x <= y- x >= - yforall n m p : R, Rmax (p - n) (p - m) = p - Rmin n mforall n m p : R, Rmax (p - n) (p - m) = p - Rmin n mforall n m p : R, Rmax (p + - n) (p + - m) = p + - Rmin n mn, m, p:RRmax (p + - n) (p + - m) = p + - Rmin n mapply plus_max_distr_l. Qed.n, m, p:RRmax (p + - n) (p + - m) = p + Rmax (- n) (- m)forall n m p : R, Rmax (n - p) (m - p) = Rmax n m - pforall n m p : R, Rmax (n - p) (m - p) = Rmax n m - pforall n m p : R, Rmax (n + - p) (m + - p) = Rmax n m + - papply plus_max_distr_r. Qed.n, m, p:RRmax (n + - p) (m + - p) = Rmax n m + - pforall n m p : R, Rmin (p - n) (p - m) = p - Rmax n mforall n m p : R, Rmin (p - n) (p - m) = p - Rmax n mforall n m p : R, Rmin (p + - n) (p + - m) = p + - Rmax n mn, m, p:RRmin (p + - n) (p + - m) = p + - Rmax n mapply plus_min_distr_l. Qed.n, m, p:RRmin (p + - n) (p + - m) = p + Rmin (- n) (- m)forall n m p : R, Rmin (n - p) (m - p) = Rmin n m - pforall n m p : R, Rmin (n - p) (m - p) = Rmin n m - pforall n m p : R, Rmin (n + - p) (m + - p) = Rmin n m + - papply plus_min_distr_r. Qed. End R.n, m, p:RRmin (n + - p) (m + - p) = Rmin n m + - p