Library Coq.Arith.Max



Require Import Le.

Open Local Scope nat_scope.

Implicit Types m n : nat.

maximum of two natural numbers


Fixpoint max n m {struct n} : nat :=
  match n, m with
    | O, _ => m
    | S n', O => n
    | S n', S m' => S (max n' m')
  end.

Simplifications of max


Lemma max_SS : forall n m, S (max n m) = max (S n) (S m).

Theorem max_assoc : forall m n p : nat, max m (max n p) = max (max m n) p.

Lemma max_comm : forall n m, max n m = max m n.

max and le


Lemma max_l : forall n m, m <= n -> max n m = n.

Lemma max_r : forall n m, n <= m -> max n m = m.

Lemma le_max_l : forall n m, n <= max n m.

Lemma le_max_r : forall n m, m <= max n m.
Hint Resolve max_r max_l le_max_l le_max_r: arith v62.

max n m is equal to n or m


Lemma max_dec : forall n m, {max n m = n} + {max n m = m}.

Lemma max_case : forall n m (P:nat -> Type), P n -> P m -> P (max n m).

Notation max_case2 := max_case (only parsing).