1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/nat/orders".
17 include "logic/connectives.ma".
18 include "logic/equality.ma".
20 include "nat/plus.ma".
21 include "higher_order_defs/ordering.ma".
24 inductive le (n:nat) : nat \to Prop \def
26 | le_S : \forall m:nat. le n m \to le n (S m).
28 definition lt: nat \to nat \to Prop \def
29 \lambda n,m:nat.le (S n) m.
31 definition ge: nat \to nat \to Prop \def
32 \lambda n,m:nat.le m n.
34 definition gt: nat \to nat \to Prop \def
35 \lambda n,m:nat.lt m n.
37 theorem transitive_le : transitive nat le.
38 simplify.intros.elim H1.
40 apply le_S.assumption.
43 theorem trans_le: \forall n,m,p:nat. le n m \to le m p \to le n p
46 theorem le_S_S: \forall n,m:nat. le n m \to le (S n) (S m).
49 apply le_S.assumption.
52 theorem le_O_n : \forall n:nat. le O n.
58 theorem le_n_Sn : \forall n:nat. le n (S n).
59 intros. apply le_S.apply le_n.
62 theorem le_pred_n : \forall n:nat. le (pred n) n.
65 simplify.apply le_n_Sn.
68 theorem le_S_S_to_le : \forall n,m:nat. le (S n) (S m) \to le n m.
69 intros.change with le (pred (S n)) (pred (S m)).
70 elim H.apply le_n.apply trans_le ? (pred e2).assumption.
74 theorem leS_to_not_zero : \forall n,m:nat. (le (S n) m ) \to not_zero m.
75 intros.elim H.exact I.exact I.
79 theorem not_le_Sn_O: \forall n:nat. Not (le (S n) O).
80 intros.simplify.intros.apply leS_to_not_zero ? ? H.
83 theorem not_le_Sn_n: \forall n:nat. Not (le (S n) n).
84 intros.elim n.apply not_le_Sn_O.simplify.intros.cut le (S e1) e1.
86 apply le_S_S_to_le.assumption.
90 theorem lt_to_le : \forall n,m:nat. lt n m \to le n m.
91 simplify.intros.elim H.
92 apply le_S. apply le_n.
93 apply le_S. assumption.
96 theorem not_le_to_lt: \forall n,m:nat. Not (le n m) \to lt m n.
98 apply nat_elim2 (\lambda n,m.Not (le n m) \to lt m n).
99 intros.apply absurd (le O n1).apply le_O_n.assumption.
100 simplify.intros.apply le_S_S.apply le_O_n.
101 simplify.intros.apply le_S_S.apply H.intros.apply H1.apply le_S_S.
105 theorem lt_to_not_le: \forall n,m:nat. lt n m \to Not (le m n).
106 simplify.intros 3.elim H.
107 apply not_le_Sn_n n H1.
108 apply H2.apply lt_to_le. apply H3.
112 theorem le_n_O_to_eq : \forall n:nat. (le n O) \to (eq nat O n).
113 intro.elim n.reflexivity.
115 (* non si applica not_le_Sn_O *)
116 apply (not_le_Sn_O ? H1).
119 theorem le_n_O_elim: \forall n:nat.le n O \to \forall P: nat \to Prop.
124 apply (not_le_Sn_O ? H1).
127 theorem le_n_Sm_elim : \forall n,m:nat.le n (S m) \to
128 \forall P:Prop. (le (S n) (S m) \to P) \to (eq nat n (S m) \to P) \to P.
130 apply H2.reflexivity.
131 apply H3. apply le_S_S. assumption.
134 (* other abstract properties *)
135 theorem antisymmetric_le : antisymmetric nat le.
137 apply nat_elim2 (\lambda n,m.((le n m) \to (le m n) \to eq nat n m)).
138 intros.apply le_n_O_to_eq.assumption.
139 intros.apply False_ind.apply not_le_Sn_O ? H.
140 intros.apply eq_f.apply H.
141 apply le_S_S_to_le.assumption.
142 apply le_S_S_to_le.assumption.
145 theorem antisym_le: \forall n,m:nat. le n m \to le m n \to eq nat n m
146 \def antisymmetric_le.
148 theorem decidable_le: \forall n,m:nat. decidable (le n m).
150 apply nat_elim2 (\lambda n,m.decidable (le n m)).
151 intros.simplify.left.apply le_O_n.
152 intros.simplify.right.exact not_le_Sn_O n1.
153 intros 2.simplify.intro.elim H.
154 left.apply le_S_S.assumption.
155 right.intro.apply H1.apply le_S_S_to_le.assumption.