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 include "datatypes/bool.ma".
18 inductive Z : Set \def
23 definition Z_of_nat \def
24 \lambda n. match n with
26 | (S n)\Rightarrow pos n].
30 definition neg_Z_of_nat \def
31 \lambda n. match n with
33 | (S n)\Rightarrow neg n].
35 lemma pos_n_eq_S_n : \forall n : nat.
44 | (pos n) \Rightarrow (S n)
45 | (neg n) \Rightarrow (S n)].
47 definition OZ_test \def
51 | (pos n) \Rightarrow false
52 | (neg n) \Rightarrow false].
54 theorem OZ_test_to_Prop :\forall z:Z.
56 [true \Rightarrow z=OZ
57 |false \Rightarrow z \neq OZ].
60 simplify. unfold Not. intros (H).
62 simplify. unfold Not. intros (H).
67 theorem injective_pos: injective nat Z pos.
71 change with (abs (pos x) = abs (pos y)).
72 apply eq_f.assumption.
75 variant inj_pos : \forall n,m:nat. pos n = pos m \to n = m
78 theorem injective_neg: injective nat Z neg.
82 change with (abs (neg x) = abs (neg y)).
83 apply eq_f.assumption.
86 variant inj_neg : \forall n,m:nat. neg n = neg m \to n = m
89 theorem not_eq_OZ_pos: \forall n:nat. OZ \neq pos n.
90 unfold Not.intros (n H).
94 theorem not_eq_OZ_neg :\forall n:nat. OZ \neq neg n.
95 unfold Not.intros (n H).
99 theorem not_eq_pos_neg :\forall n,m:nat. pos n \neq neg m.
100 unfold Not.intros (n m H).
104 theorem decidable_eq_Z : \forall x,y:Z. decidable (x=y).
105 intros.unfold decidable.
109 (* goal: x=OZ y=OZ *)
112 right.apply not_eq_OZ_pos.
114 right.apply not_eq_OZ_neg.
117 (* goal: x=pos y=OZ *)
118 right.unfold Not.intro.
119 apply (not_eq_OZ_pos n). symmetry. assumption.
120 (* goal: x=pos y=pos *)
121 elim (decidable_eq_nat n n1:((n=n1) \lor ((n=n1) \to False))).
122 left.apply eq_f.assumption.
123 right.unfold Not.intros (H_inj).apply H. destruct H_inj. reflexivity.
124 (* goal: x=pos y=neg *)
125 right.unfold Not.intro.apply (not_eq_pos_neg n n1). assumption.
128 (* goal: x=neg y=OZ *)
129 right.unfold Not.intro.
130 apply (not_eq_OZ_neg n). symmetry. assumption.
131 (* goal: x=neg y=pos *)
132 right. unfold Not.intro. apply (not_eq_pos_neg n1 n). symmetry. assumption.
133 (* goal: x=neg y=neg *)
134 elim (decidable_eq_nat n n1:((n=n1) \lor ((n=n1) \to False))).
135 left.apply eq_f.assumption.
136 right.unfold Not.intro.apply H.apply injective_neg.assumption.
139 (* end discrimination *)
141 definition Zsucc \def
142 \lambda z. match z with
143 [ OZ \Rightarrow pos O
144 | (pos n) \Rightarrow pos (S n)
145 | (neg n) \Rightarrow
148 | (S p) \Rightarrow neg p]].
150 definition Zpred \def
151 \lambda z. match z with
152 [ OZ \Rightarrow neg O
153 | (pos n) \Rightarrow
156 | (S p) \Rightarrow pos p]
157 | (neg n) \Rightarrow neg (S n)].
159 theorem Zpred_Zsucc: \forall z:Z. Zpred (Zsucc z) = z.
169 theorem Zsucc_Zpred: \forall z:Z. Zsucc (Zpred z) = z.