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/library_autobatch/Z/compare".
17 include "auto/Z/orders.ma".
18 include "auto/nat/compare.ma".
20 (* boolean equality *)
21 definition eqZb : Z \to Z \to bool \def
27 | (pos q) \Rightarrow false
28 | (neg q) \Rightarrow false]
31 [ OZ \Rightarrow false
32 | (pos q) \Rightarrow eqb p q
33 | (neg q) \Rightarrow false]
36 [ OZ \Rightarrow false
37 | (pos q) \Rightarrow false
38 | (neg q) \Rightarrow eqb p q]].
43 [ true \Rightarrow x=y
44 | false \Rightarrow x \neq y].
59 apply (not_eq_OZ_pos n).
86 apply (not_eq_OZ_neg n).
93 apply (not_eq_pos_neg n1 n).
117 theorem eqZb_elim: \forall x,y:Z.\forall P:bool \to Prop.
118 (x=y \to (P true)) \to (x \neq y \to (P false)) \to P (eqZb x y).
121 (match (eqZb x y) with
122 [ true \Rightarrow x=y
123 | false \Rightarrow x \neq y] \to P (eqZb x y))
125 (*NB qui autobatch non chiude il goal*)
128 [ (*NB qui autobatch non chiude il goal*)
130 | (*NB qui autobatch non chiude il goal*)
136 definition Z_compare : Z \to Z \to compare \def
142 | (pos m) \Rightarrow LT
143 | (neg m) \Rightarrow GT ]
144 | (pos n) \Rightarrow
147 | (pos m) \Rightarrow (nat_compare n m)
148 | (neg m) \Rightarrow GT]
149 | (neg n) \Rightarrow
152 | (pos m) \Rightarrow LT
153 | (neg m) \Rightarrow nat_compare m n ]].
155 theorem Z_compare_to_Prop :
156 \forall x,y:Z. match (Z_compare x y) with
157 [ LT \Rightarrow x < y
159 | GT \Rightarrow y < x].
174 cut (match (nat_compare n n1) with
175 [ LT \Rightarrow n<n1
176 | EQ \Rightarrow n=n1
177 | GT \Rightarrow n1<n] \to
178 match (nat_compare n n1) with
179 [ LT \Rightarrow (S n) \leq n1
180 | EQ \Rightarrow pos n = pos n1
181 | GT \Rightarrow (S n1) \leq n])
183 (*NB qui autobatch non chiude il goal*)
184 apply nat_compare_to_Prop
185 | elim (nat_compare n n1)
187 (*NB qui autobatch non chiude il goal*)
191 (*NB qui autobatch non chiude il goal*)
194 (*NB qui autobatch non chiude il goal*)
207 cut (match (nat_compare n1 n) with
208 [ LT \Rightarrow n1<n
209 | EQ \Rightarrow n1=n
210 | GT \Rightarrow n<n1] \to
211 match (nat_compare n1 n) with
212 [ LT \Rightarrow (S n1) \leq n
213 | EQ \Rightarrow neg n = neg n1
214 | GT \Rightarrow (S n) \leq n1])
216 (*NB qui autobatch non chiude il goal*)
217 apply nat_compare_to_Prop
218 | elim (nat_compare n1 n)
220 (*NB qui autobatch non chiude il goal*)
225 (*NB qui autobatch non chiude il goal*)
228 (*NB qui autobatch non chiude il goal*)