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/z".
17 include "datatypes/bool.ma".
18 include "auto/nat/nat.ma".
20 inductive Z : Set \def
25 definition Z_of_nat \def
26 \lambda n. match n with
28 | (S n)\Rightarrow pos n].
30 coercion cic:/matita/library_autobatch/Z/z/Z_of_nat.con.
32 definition neg_Z_of_nat \def
33 \lambda n. match n with
35 | (S n)\Rightarrow neg n].
41 | (pos n) \Rightarrow (S n)
42 | (neg n) \Rightarrow (S n)].
44 definition OZ_test \def
48 | (pos n) \Rightarrow false
49 | (neg n) \Rightarrow false].
51 theorem OZ_test_to_Prop :\forall z:Z.
53 [true \Rightarrow z=OZ
54 |false \Rightarrow z \neq OZ].
57 [ (*qui autobatch non chiude il goal*)
63 (*qui autobatch non chiude il goal*)
68 (*qui autobatch non chiude il goal*)
74 theorem injective_pos: injective nat Z pos.
78 change with (abs (pos x) = abs (pos y)).
84 variant inj_pos : \forall n,m:nat. pos n = pos m \to n = m
87 theorem injective_neg: injective nat Z neg.
91 change with (abs (neg x) = abs (neg y)).
97 variant inj_neg : \forall n,m:nat. neg n = neg m \to n = m
100 theorem not_eq_OZ_pos: \forall n:nat. OZ \neq pos n.
103 (*qui autobatch non chiude il goal*)
107 theorem not_eq_OZ_neg :\forall n:nat. OZ \neq neg n.
110 (*qui autobatch non chiude il goal*)
114 theorem not_eq_pos_neg :\forall n,m:nat. pos n \neq neg m.
117 (*qui autobatch non chiude il goal*)
121 theorem decidable_eq_Z : \forall x,y:Z. decidable (x=y).
127 [ (* goal: x=OZ y=OZ *)
131 | (* goal: x=OZ 2=2 *)
134 apply not_eq_OZ_pos*)
135 | (* goal: x=OZ 2=3 *)
138 apply not_eq_OZ_neg*)
142 [ (* goal: x=pos y=OZ *)
146 apply (not_eq_OZ_pos n).
150 | (* goal: x=pos y=pos *)
151 elim (decidable_eq_nat n n1:((n=n1) \lor ((n=n1) \to False)))
164 | (* goal: x=pos y=neg *)
169 apply (not_eq_pos_neg n n1).
174 [ (* goal: x=neg y=OZ *)
178 apply (not_eq_OZ_neg n).
182 | (* goal: x=neg y=pos *)
186 apply (not_eq_pos_neg n1 n).
190 | (* goal: x=neg y=neg *)
191 elim (decidable_eq_nat n n1:((n=n1) \lor ((n=n1) \to False)))
208 (* end discrimination *)
210 definition Zsucc \def
211 \lambda z. match z with
212 [ OZ \Rightarrow pos O
213 | (pos n) \Rightarrow pos (S n)
214 | (neg n) \Rightarrow
217 | (S p) \Rightarrow neg p]].
219 definition Zpred \def
220 \lambda z. match z with
221 [ OZ \Rightarrow neg O
222 | (pos n) \Rightarrow
225 | (S p) \Rightarrow pos p]
226 | (neg n) \Rightarrow neg (S n)].
228 theorem Zpred_Zsucc: \forall z:Z. Zpred (Zsucc z) = z.
240 theorem Zsucc_Zpred: \forall z:Z. Zsucc (Zpred z) = z.