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/Z/orders".
19 definition Zle : Z \to Z \to Prop \def
25 | (pos m) \Rightarrow True
26 | (neg m) \Rightarrow False ]
29 [ OZ \Rightarrow False
30 | (pos m) \Rightarrow n \leq m
31 | (neg m) \Rightarrow False ]
35 | (pos m) \Rightarrow True
36 | (neg m) \Rightarrow m \leq n ]].
38 (*CSC: the URI must disappear: there is a bug now *)
39 interpretation "integer 'less or equal to'" 'leq x y = (cic:/matita/Z/orders/Zle.con x y).
41 definition Zlt : Z \to Z \to Prop \def
46 [ OZ \Rightarrow False
47 | (pos m) \Rightarrow True
48 | (neg m) \Rightarrow False ]
51 [ OZ \Rightarrow False
52 | (pos m) \Rightarrow n<m
53 | (neg m) \Rightarrow False ]
57 | (pos m) \Rightarrow True
58 | (neg m) \Rightarrow m<n ]].
60 (*CSC: the URI must disappear: there is a bug now *)
61 interpretation "integer 'less than'" 'lt x y = (cic:/matita/Z/orders/Zlt.con x y).
63 theorem irreflexive_Zlt: irreflexive Z Zlt.
64 change with \forall x:Z. x < x \to False.
66 cut neg n < neg n \to False.
67 apply Hcut.apply H.simplify.apply not_le_Sn_n.
68 cut pos n < pos n \to False.
69 apply Hcut.apply H.simplify.apply not_le_Sn_n.
72 theorem irrefl_Zlt: irreflexive Z Zlt
75 definition Z_compare : Z \to Z \to compare \def
81 | (pos m) \Rightarrow LT
82 | (neg m) \Rightarrow GT ]
86 | (pos m) \Rightarrow (nat_compare n m)
87 | (neg m) \Rightarrow GT]
91 | (pos m) \Rightarrow LT
92 | (neg m) \Rightarrow nat_compare m n ]].
94 (*CSC: qui uso lt perche' ho due istanze diverse di < *)
95 theorem Zlt_neg_neg_to_lt:
96 \forall n,m:nat. neg n < neg m \to lt m n.
100 (*CSC: qui uso lt perche' ho due istanze diverse di < *)
101 theorem lt_to_Zlt_neg_neg: \forall n,m:nat.lt m n \to neg n < neg m.
106 (*CSC: qui uso lt perche' ho due istanze diverse di < *)
107 theorem Zlt_pos_pos_to_lt:
108 \forall n,m:nat. pos n < pos m \to lt n m.
112 (*CSC: qui uso lt perche' ho due istanze diverse di < *)
113 theorem lt_to_Zlt_pos_pos: \forall n,m:nat.lt n m \to pos n < pos m.
118 theorem Z_compare_to_Prop :
119 \forall x,y:Z. match (Z_compare x y) with
120 [ LT \Rightarrow x < y
122 | GT \Rightarrow y < x].
125 simplify.apply refl_eq.
128 elim y. simplify.exact I.
130 (*CSC: qui uso le perche' altrimenti ci sono troppe scelte
131 per via delle coercions! *)
132 cut match (nat_compare n1 n) with
133 [ LT \Rightarrow n1<n
134 | EQ \Rightarrow n1=n
135 | GT \Rightarrow n<n1] \to
136 match (nat_compare n1 n) with
137 [ LT \Rightarrow (le (S n1) n)
138 | EQ \Rightarrow neg n = neg n1
139 | GT \Rightarrow (le (S n) n1)].
140 apply Hcut. apply nat_compare_to_Prop.
141 elim (nat_compare n1 n).
144 simplify.apply eq_f.apply sym_eq.exact H.
146 elim y.simplify.exact I.
149 (*CSC: qui uso le perche' altrimenti ci sono troppe scelte
150 per via delle coercions! *)
151 cut match (nat_compare n n1) with
152 [ LT \Rightarrow n<n1
153 | EQ \Rightarrow n=n1
154 | GT \Rightarrow n1<n] \to
155 match (nat_compare n n1) with
156 [ LT \Rightarrow (le (S n) n1)
157 | EQ \Rightarrow pos n = pos n1
158 | GT \Rightarrow (le (S n1) n)].
159 apply Hcut. apply nat_compare_to_Prop.
160 elim (nat_compare n n1).
163 simplify.apply eq_f.exact H.
166 theorem Zlt_to_Zle: \forall x,y:Z. x < y \to Zsucc x \leq y.
168 cut OZ < y \to Zsucc OZ \leq y.
169 apply Hcut. assumption.simplify.elim y.
172 simplify.apply le_O_n.
173 cut neg n < y \to Zsucc (neg n) \leq y.
174 apply Hcut. assumption.elim n.
175 cut neg O < y \to Zsucc (neg O) \leq y.
176 apply Hcut. assumption.simplify.elim y.
177 simplify.exact I.simplify.apply not_le_Sn_O n1 H2.
179 cut neg (S n1) < y \to (Zsucc (neg (S n1))) \leq y.
180 apply Hcut. assumption.simplify.
183 simplify.apply le_S_S_to_le n2 n1 H3.