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 NAxioms NSub GenericMinMax.

Properties of minimum and maximum specific to natural numbers

Module Type NMaxMinProp (Import N : NAxiomsMiniSig').
Include NSubProp N.
Zero

forall n : t, max 0 n == n

forall n : t, max 0 n == n
n:t

max 0 n == n
n:t

0 <= n
apply le_0_l. Qed.

forall n : t, max n 0 == n

forall n : t, max n 0 == n
n:t

max n 0 == n
n:t

0 <= n
apply le_0_l. Qed.

forall n : t, min 0 n == 0

forall n : t, min 0 n == 0
n:t

min 0 n == 0
n:t

0 <= n
apply le_0_l. Qed.

forall n : t, min n 0 == 0

forall n : t, min n 0 == 0
n:t

min n 0 == 0
n:t

0 <= n
apply le_0_l. Qed.
The following results are concrete instances of max_monotone and similar lemmas.
Succ

forall n m : t, S (max n m) == max (S n) (S m)

forall n m : t, S (max n m) == max (S n) (S m)
n, m:t

S (max n m) == max (S n) (S m)
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; now rewrite <- ?succ_le_mono. Qed.

forall n m : t, S (min n m) == min (S n) (S m)

forall n m : t, S (min n m) == min (S n) (S m)
n, m:t

S (min n m) == min (S n) (S m)
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; now rewrite <- ?succ_le_mono. Qed.
Add

forall n m p : t, max (p + n) (p + m) == p + max n m

forall n m p : t, max (p + n) (p + m) == p + max n m
n, m, p:t

max (p + n) (p + m) == p + max n m
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; now rewrite <- ?add_le_mono_l. Qed.

forall n m p : t, max (n + p) (m + p) == max n m + p

forall n m p : t, max (n + p) (m + p) == max n m + p
n, m, p:t

max (n + p) (m + p) == max n m + p
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; now rewrite <- ?add_le_mono_r. Qed.

forall n m p : t, min (p + n) (p + m) == p + min n m

forall n m p : t, min (p + n) (p + m) == p + min n m
n, m, p:t

min (p + n) (p + m) == p + min n m
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; now rewrite <- ?add_le_mono_l. Qed.

forall n m p : t, min (n + p) (m + p) == min n m + p

forall n m p : t, min (n + p) (m + p) == min n m + p
n, m, p:t

min (n + p) (m + p) == min n m + p
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; now rewrite <- ?add_le_mono_r. Qed.
Mul

forall n m p : t, max (p * n) (p * m) == p * max n m

forall n m p : t, max (p * n) (p * m) == p * max n m
n, m, p:t

max (p * n) (p * m) == p * max n m
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; try order; now apply mul_le_mono_l. Qed.

forall n m p : t, max (n * p) (m * p) == max n m * p

forall n m p : t, max (n * p) (m * p) == max n m * p
n, m, p:t

max (n * p) (m * p) == max n m * p
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; try order; now apply mul_le_mono_r. Qed.

forall n m p : t, min (p * n) (p * m) == p * min n m

forall n m p : t, min (p * n) (p * m) == p * min n m
n, m, p:t

min (p * n) (p * m) == p * min n m
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; try order; now apply mul_le_mono_l. Qed.

forall n m p : t, min (n * p) (m * p) == min n m * p

forall n m p : t, min (n * p) (m * p) == min n m * p
n, m, p:t

min (n * p) (m * p) == min n m * p
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; try order; now apply mul_le_mono_r. Qed.
Sub

forall n m p : t, max (p - n) (p - m) == p - min n m

forall n m p : t, max (p - n) (p - m) == p - min n m
n, m, p:t

max (p - n) (p - m) == p - min n m
n, m, p:t
H:n <= m

max (p - n) (p - m) == p - min n m
n, m, p:t
H:m <= n
max (p - n) (p - m) == p - min n m
n, m, p:t
H:n <= m

max (p - n) (p - m) == p - n
n, m, p:t
H:m <= n
max (p - n) (p - m) == p - min n m
n, m, p:t
H:n <= m

p - m <= p - n
n, m, p:t
H:m <= n
max (p - n) (p - m) == p - min n m
n, m, p:t
H:m <= n

max (p - n) (p - m) == p - min n m
n, m, p:t
H:m <= n

max (p - n) (p - m) == p - m
n, m, p:t
H:m <= n

p - n <= p - m
now apply sub_le_mono_l. Qed.

forall n m p : t, max (n - p) (m - p) == max n m - p

forall n m p : t, max (n - p) (m - p) == max n m - p
n, m, p:t

max (n - p) (m - p) == max n m - p
destruct (le_ge_cases n m); [rewrite 2 max_r | rewrite 2 max_l]; try order; now apply sub_le_mono_r. Qed.

forall n m p : t, min (p - n) (p - m) == p - max n m

forall n m p : t, min (p - n) (p - m) == p - max n m
n, m, p:t

min (p - n) (p - m) == p - max n m
n, m, p:t
H:n <= m

min (p - n) (p - m) == p - max n m
n, m, p:t
H:m <= n
min (p - n) (p - m) == p - max n m
n, m, p:t
H:n <= m

min (p - n) (p - m) == p - m
n, m, p:t
H:m <= n
min (p - n) (p - m) == p - max n m
n, m, p:t
H:n <= m

p - m <= p - n
n, m, p:t
H:m <= n
min (p - n) (p - m) == p - max n m
n, m, p:t
H:m <= n

min (p - n) (p - m) == p - max n m
n, m, p:t
H:m <= n

min (p - n) (p - m) == p - n
n, m, p:t
H:m <= n

p - n <= p - m
now apply sub_le_mono_l. Qed.

forall n m p : t, min (n - p) (m - p) == min n m - p

forall n m p : t, min (n - p) (m - p) == min n m - p
n, m, p:t

min (n - p) (m - p) == min n m - p
destruct (le_ge_cases n m); [rewrite 2 min_l | rewrite 2 min_r]; try order; now apply sub_le_mono_r. Qed. End NMaxMinProp.