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 "nat/plus.ma".
18 include "higher_order_defs/ordering.ma".
21 inductive le (n:nat) : nat \to Prop \def
23 | le_S : \forall m:nat. le n m \to le n (S m).
25 definition lt: nat \to nat \to Prop \def
26 \lambda n,m:nat.le (S n) m.
28 definition ge: nat \to nat \to Prop \def
29 \lambda n,m:nat.le m n.
31 definition gt: nat \to nat \to Prop \def
32 \lambda n,m:nat.lt m n.
34 theorem transitive_le : transitive nat le.
35 simplify.intros.elim H1.
37 apply le_S.assumption.
40 theorem trans_le: \forall n,m,p:nat. le n m \to le m p \to le n p
43 theorem le_S_S: \forall n,m:nat. le n m \to le (S n) (S m).
46 apply le_S.assumption.
49 theorem le_O_n : \forall n:nat. le O n.
55 theorem le_n_Sn : \forall n:nat. le n (S n).
56 intros. apply le_S.apply le_n.
59 theorem le_pred_n : \forall n:nat. le (pred n) n.
62 simplify.apply le_n_Sn.
65 theorem le_S_S_to_le : \forall n,m:nat. le (S n) (S m) \to le n m.
66 intros.change with le (pred (S n)) (pred (S m)).
67 elim H.apply le_n.apply trans_le ? (pred n1).assumption.
71 theorem leS_to_not_zero : \forall n,m:nat. (le (S n) m ) \to not_zero m.
72 intros.elim H.exact I.exact I.
76 theorem not_le_Sn_O: \forall n:nat. Not (le (S n) O).
77 intros.simplify.intros.apply leS_to_not_zero ? ? H.
80 theorem not_le_Sn_n: \forall n:nat. Not (le (S n) n).
81 intros.elim n.apply not_le_Sn_O.simplify.intros.cut le (S n1) n1.
83 apply le_S_S_to_le.assumption.
86 (* ??? this needs not le *)
87 theorem S_pred: \forall n:nat.lt O n \to eq nat n (S (pred n)).
88 intro.elim n.apply False_ind.exact not_le_Sn_O O H.
89 apply eq_f.apply pred_Sn.
93 theorem lt_to_le : \forall n,m:nat. lt n m \to le n m.
94 simplify.intros.elim H.
95 apply le_S. apply le_n.
96 apply le_S. assumption.
99 theorem not_le_to_lt: \forall n,m:nat. Not (le n m) \to lt m n.
101 apply nat_elim2 (\lambda n,m.Not (le n m) \to lt m n).
102 intros.apply absurd (le O n1).apply le_O_n.assumption.
103 simplify.intros.apply le_S_S.apply le_O_n.
104 simplify.intros.apply le_S_S.apply H.intros.apply H1.apply le_S_S.
108 theorem lt_to_not_le: \forall n,m:nat. lt n m \to Not (le m n).
109 simplify.intros 3.elim H.
110 apply not_le_Sn_n n H1.
111 apply H2.apply lt_to_le. apply H3.
115 theorem le_n_O_to_eq : \forall n:nat. (le n O) \to (eq nat O n).
116 intro.elim n.reflexivity.
118 (* non si applica not_le_Sn_O *)
119 apply (not_le_Sn_O ? H1).
122 theorem le_n_O_elim: \forall n:nat.le n O \to \forall P: nat \to Prop.
127 apply (not_le_Sn_O ? H1).
130 theorem le_n_Sm_elim : \forall n,m:nat.le n (S m) \to
131 \forall P:Prop. (le (S n) (S m) \to P) \to (eq nat n (S m) \to P) \to P.
133 apply H2.reflexivity.
134 apply H3. apply le_S_S. assumption.
137 (* other abstract properties *)
138 theorem antisymmetric_le : antisymmetric nat le.
140 apply nat_elim2 (\lambda n,m.((le n m) \to (le m n) \to eq nat n m)).
141 intros.apply le_n_O_to_eq.assumption.
142 intros.apply False_ind.apply not_le_Sn_O ? H.
143 intros.apply eq_f.apply H.
144 apply le_S_S_to_le.assumption.
145 apply le_S_S_to_le.assumption.
148 theorem antisym_le: \forall n,m:nat. le n m \to le m n \to eq nat n m
149 \def antisymmetric_le.
151 theorem decidable_le: \forall n,m:nat. decidable (le n m).
153 apply nat_elim2 (\lambda n,m.decidable (le n m)).
154 intros.simplify.left.apply le_O_n.
155 intros.simplify.right.exact not_le_Sn_O n1.
156 intros 2.simplify.intro.elim H.
157 left.apply le_S_S.assumption.
158 right.intro.apply H1.apply le_S_S_to_le.assumption.