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 (*CSC: the URI must disappear: there is a bug now *)
26 interpretation "natural 'less or equal to'" 'leq x y = (cic:/matita/nat/orders/le.ind#xpointer(1/1) x y).
28 definition lt: nat \to nat \to Prop \def
29 \lambda n,m:nat.(S n) \leq m.
31 (*CSC: the URI must disappear: there is a bug now *)
32 interpretation "natural 'less than'" 'lt x y = (cic:/matita/nat/orders/lt.con x y).
34 definition ge: nat \to nat \to Prop \def
35 \lambda n,m:nat.m \leq n.
37 (*CSC: the URI must disappear: there is a bug now *)
38 interpretation "natural 'greater or equal to'" 'geq x y = (cic:/matita/nat/orders/ge.con x y).
40 definition gt: nat \to nat \to Prop \def
43 (*CSC: the URI must disappear: there is a bug now *)
44 interpretation "natural 'greater than'" 'gt x y = (cic:/matita/nat/orders/gt.con x y).
46 theorem transitive_le : transitive nat le.
47 simplify.intros.elim H1.
49 apply le_S.assumption.
52 theorem trans_le: \forall n,m,p:nat. n \leq m \to m \leq p \to n \leq p
55 theorem le_S_S: \forall n,m:nat. n \leq m \to S n \leq S m.
58 apply le_S.assumption.
61 theorem le_O_n : \forall n:nat. O \leq n.
67 theorem le_n_Sn : \forall n:nat. n \leq S n.
68 intros. apply le_S.apply le_n.
71 theorem le_pred_n : \forall n:nat. pred n \leq n.
74 simplify.apply le_n_Sn.
77 theorem le_S_S_to_le : \forall n,m:nat. S n \leq S m \to n \leq m.
78 intros.change with pred (S n) \leq pred (S m).
79 elim H.apply le_n.apply trans_le ? (pred n1).assumption.
83 theorem leS_to_not_zero : \forall n,m:nat. S n \leq m \to not_zero m.
84 intros.elim H.exact I.exact I.
88 theorem not_le_Sn_O: \forall n:nat. \lnot (S n \leq O).
89 intros.simplify.intros.apply leS_to_not_zero ? ? H.
92 theorem not_le_Sn_n: \forall n:nat. \lnot (S n \leq n).
93 intros.elim n.apply not_le_Sn_O.simplify.intros.cut S n1 \leq n1.
95 apply le_S_S_to_le.assumption.
98 (* ??? this needs not le *)
99 theorem S_pred: \forall n:nat.O<n \to n=S (pred n).
100 intro.elim n.apply False_ind.exact not_le_Sn_O O H.
101 apply eq_f.apply pred_Sn.
105 theorem lt_to_le : \forall n,m:nat. n<m \to n \leq m.
106 simplify.intros.elim H.
107 apply le_S. apply le_n.
108 apply le_S. assumption.
111 theorem not_le_to_lt: \forall n,m:nat. \lnot (n \leq m) \to m<n.
113 apply nat_elim2 (\lambda n,m.\lnot (n \leq m) \to m<n).
114 intros.apply absurd (O \leq n1).apply le_O_n.assumption.
115 simplify.intros.apply le_S_S.apply le_O_n.
116 simplify.intros.apply le_S_S.apply H.intros.apply H1.apply le_S_S.
120 theorem lt_to_not_le: \forall n,m:nat. n<m \to \lnot (m \leq n).
121 simplify.intros 3.elim H.
122 apply not_le_Sn_n n H1.
123 apply H2.apply lt_to_le. apply H3.
127 theorem le_n_O_to_eq : \forall n:nat. n \leq O \to O=n.
128 intro.elim n.reflexivity.
130 (* non si applica not_le_Sn_O *)
131 apply (not_le_Sn_O ? H1).
134 theorem le_n_O_elim: \forall n:nat.n \leq O \to \forall P: nat \to Prop.
139 apply (not_le_Sn_O ? H1).
142 theorem le_n_Sm_elim : \forall n,m:nat.n \leq S m \to
143 \forall P:Prop. (S n \leq S m \to P) \to (n=S m \to P) \to P.
145 apply H2.reflexivity.
146 apply H3. apply le_S_S. assumption.
149 (* other abstract properties *)
150 theorem antisymmetric_le : antisymmetric nat le.
152 apply nat_elim2 (\lambda n,m.(n \leq m \to m \leq n \to n=m)).
153 intros.apply le_n_O_to_eq.assumption.
154 intros.apply False_ind.apply not_le_Sn_O ? H.
155 intros.apply eq_f.apply H.
156 apply le_S_S_to_le.assumption.
157 apply le_S_S_to_le.assumption.
160 theorem antisym_le: \forall n,m:nat. n \leq m \to m \leq n \to n=m
161 \def antisymmetric_le.
163 theorem decidable_le: \forall n,m:nat. decidable (n \leq m).
165 apply nat_elim2 (\lambda n,m.decidable (n \leq m)).
166 intros.simplify.left.apply le_O_n.
167 intros.simplify.right.exact not_le_Sn_O n1.
168 intros 2.simplify.intro.elim H.
169 left.apply le_S_S.assumption.
170 right.intro.apply H1.apply le_S_S_to_le.assumption.