diff options
author | Samuel Mimram <samuel.mimram@ens-lyon.org> | 2004-07-28 21:54:47 +0000 |
---|---|---|
committer | Samuel Mimram <samuel.mimram@ens-lyon.org> | 2004-07-28 21:54:47 +0000 |
commit | 6b649aba925b6f7462da07599fe67ebb12a3460e (patch) | |
tree | 43656bcaa51164548f3fa14e5b10de5ef1088574 /theories/Arith/Max.v |
Imported Upstream version 8.0pl1upstream/8.0pl1
Diffstat (limited to 'theories/Arith/Max.v')
-rwxr-xr-x | theories/Arith/Max.v | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/theories/Arith/Max.v b/theories/Arith/Max.v new file mode 100755 index 00000000..82673ed0 --- /dev/null +++ b/theories/Arith/Max.v @@ -0,0 +1,85 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +(*i $Id: Max.v,v 1.7.2.1 2004/07/16 19:31:00 herbelin Exp $ i*) + +Require Import Arith. + +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). +Proof. +auto with arith. +Qed. + +Lemma max_comm : forall n m, max n m = max m n. +Proof. +induction n; induction m; simpl in |- *; auto with arith. +Qed. + +(** [max] and [le] *) + +Lemma max_l : forall n m, m <= n -> max n m = n. +Proof. +induction n; induction m; simpl in |- *; auto with arith. +Qed. + +Lemma max_r : forall n m, n <= m -> max n m = m. +Proof. +induction n; induction m; simpl in |- *; auto with arith. +Qed. + +Lemma le_max_l : forall n m, n <= max n m. +Proof. +induction n; intros; simpl in |- *; auto with arith. +elim m; intros; simpl in |- *; auto with arith. +Qed. + +Lemma le_max_r : forall n m, m <= max n m. +Proof. +induction n; simpl in |- *; auto with arith. +induction m; simpl in |- *; auto with arith. +Qed. +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}. +Proof. +induction n; induction m; simpl in |- *; auto with arith. +elim (IHn m); intro H; elim H; auto. +Qed. + +Lemma max_case : forall n m (P:nat -> Set), P n -> P m -> P (max n m). +Proof. +induction n; simpl in |- *; auto with arith. +induction m; intros; simpl in |- *; auto with arith. +pattern (max n m) in |- *; apply IHn; auto with arith. +Qed. + +Lemma max_case2 : forall n m (P:nat -> Prop), P n -> P m -> P (max n m). +Proof. +induction n; simpl in |- *; auto with arith. +induction m; intros; simpl in |- *; auto with arith. +pattern (max n m) in |- *; apply IHn; auto with arith. +Qed. + |