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.
87 theorem lt_to_le : \forall n,m:nat. lt n m \to le n m.
88 simplify.intros.elim H.
89 apply le_S. apply le_n.
90 apply le_S. assumption.
93 theorem not_le_to_lt: \forall n,m:nat. Not (le n m) \to lt m n.
95 apply nat_elim2 (\lambda n,m.Not (le n m) \to lt m n).
96 intros.apply absurd (le O n1).apply le_O_n.assumption.
97 simplify.intros.apply le_S_S.apply le_O_n.
98 simplify.intros.apply le_S_S.apply H.intros.apply H1.apply le_S_S.
102 theorem lt_to_not_le: \forall n,m:nat. lt n m \to Not (le m n).
103 simplify.intros 3.elim H.
104 apply not_le_Sn_n n H1.
105 apply H2.apply lt_to_le. apply H3.
109 theorem le_n_O_to_eq : \forall n:nat. (le n O) \to (eq nat O n).
110 intro.elim n.reflexivity.
112 (* non si applica not_le_Sn_O *)
113 apply (not_le_Sn_O ? H1).
116 theorem le_n_O_elim: \forall n:nat.le n O \to \forall P: nat \to Prop.
121 apply (not_le_Sn_O ? H1).
124 theorem le_n_Sm_elim : \forall n,m:nat.le n (S m) \to
125 \forall P:Prop. (le (S n) (S m) \to P) \to (eq nat n (S m) \to P) \to P.
127 apply H2.reflexivity.
128 apply H3. apply le_S_S. assumption.
131 (* other abstract properties *)
132 theorem antisymmetric_le : antisymmetric nat le.
134 apply nat_elim2 (\lambda n,m.((le n m) \to (le m n) \to eq nat n m)).
135 intros.apply le_n_O_to_eq.assumption.
136 intros.apply False_ind.apply not_le_Sn_O ? H.
137 intros.apply eq_f.apply H.
138 apply le_S_S_to_le.assumption.
139 apply le_S_S_to_le.assumption.
142 theorem antisym_le: \forall n,m:nat. le n m \to le m n \to eq nat n m
143 \def antisymmetric_le.
145 theorem decidable_le: \forall n,m:nat. decidable (le n m).
147 apply nat_elim2 (\lambda n,m.decidable (le n m)).
148 intros.simplify.left.apply le_O_n.
149 intros.simplify.right.exact not_le_Sn_O n1.
150 intros 2.simplify.intro.elim H.
151 left.apply le_S_S.assumption.
152 right.intro.apply H1.apply le_S_S_to_le.assumption.