1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Sviluppo: 2008-2010 *)
21 (* ********************************************************************** *)
23 include "num/comp_num.ma".
24 include "num/bool_lemmas.ma".
30 nlemma cn_destruct_1 :
32 mk_comp_num T x1 y1 = mk_comp_num T x2 y2 → x1 = x2.
33 #T; #x1; #x2; #y1; #y2; #H;
34 nchange with (match mk_comp_num ? x2 y2 with [ mk_comp_num a _ ⇒ x1 = a ]);
40 nlemma cn_destruct_2 :
42 mk_comp_num T x1 y1 = mk_comp_num T x2 y2 → y1 = y2.
43 #T; #x1; #x2; #y1; #y2; #H;
44 nchange with (match mk_comp_num ? x2 y2 with [ mk_comp_num _ b ⇒ y1 = b ]);
50 nlemma symmetric_eqcn :
52 (symmetricT T bool feq) →
53 (symmetricT (comp_num T) bool (eq2_cn T feq)).
55 #b1; nelim b1; #e1; #e2;
56 #b2; nelim b2; #e3; #e4;
57 nchange with (((feq e1 e3)⊗(feq e2 e4)) = ((feq e3 e1)⊗(feq e4 e2)));
65 (∀x,y:T.(feq x y = true) → (x = y)) →
67 ((eq2_cn T feq b1 b2 = true) → (b1 = b2))).
68 #T; #feq; #H; #b1; #b2;
71 nchange in ⊢ (% → ?) with (((feq e1 e3)⊗(feq e2 e4)) = true);
73 nrewrite < (H … (andb_true_true_l … H1));
74 nrewrite < (H … (andb_true_true_r … H1));
80 (∀x,y:T.(x = y) → (feq x y = true)) →
82 ((b1 = b2) → (eq2_cn T feq b1 b2 = true))).
83 #T; #feq; #H; #b1; #b2;
87 nrewrite < (cn_destruct_1 … H1);
88 nrewrite < (cn_destruct_2 … H1);
89 nchange with (((feq e1 e1)⊗(feq e2 e2)) = true);
90 nrewrite > (H e1 e1 (refl_eq …));
91 nrewrite > (H e2 e2 (refl_eq …));
96 nlemma decidable_cn_aux1 :
97 ∀T.∀e1,e2,e3,e4:T.e1 ≠ e3 → (mk_comp_num T e1 e2) ≠ (mk_comp_num T e3 e4).
98 #T; #e1; #e2; #e3; #e4;
100 napply (H (cn_destruct_1 … H1)).
103 nlemma decidable_cn_aux2 :
104 ∀T.∀e1,e2,e3,e4:T.e2 ≠ e4 → (mk_comp_num T e1 e2) ≠ (mk_comp_num T e3 e4).
105 #T; #e1; #e2; #e3; #e4;
107 napply (H (cn_destruct_2 … H1)).
110 nlemma decidable_cn :
111 ∀T.(∀x,y:T.decidable (x = y)) →
113 (decidable (b1 = b2))).
115 #b1; nelim b1; #e1; #e2;
116 #b2; nelim b2; #e3; #e4;
118 napply (or2_elim (e1 = e3) (e1 ≠ e3) ? (H e1 e3) …);
119 ##[ ##2: #H1; napply (or2_intro2 … (decidable_cn_aux1 T e1 e2 e3 e4 H1))
120 ##| ##1: #H1; napply (or2_elim (e2 = e4) (e2 ≠ e4) ? (H e2 e4) …);
121 ##[ ##2: #H2; napply (or2_intro2 … (decidable_cn_aux2 T e1 e2 e3 e4 H2))
122 ##| ##1: #H2; nrewrite > H1; nrewrite > H2;
123 napply (or2_intro1 … (refl_eq ? (mk_comp_num T e3 e4)))
128 nlemma neqcn_to_neq :
129 ∀T.∀feq:T → T → bool.
130 (∀x,y:T.(feq x y = false) → (x ≠ y)) →
132 ((eq2_cn T feq b1 b2 = false) → (b1 ≠ b2))).
133 #T; #feq; #H; #b1; #b2;
136 nchange with ((((feq e1 e3) ⊗ (feq e2 e4)) = false) → ?);
138 napply (or2_elim ((feq e1 e3) = false) ((feq e2 e4) = false) ? (andb_false2 … H1) …);
139 ##[ ##1: #H2; napply (decidable_cn_aux1 … (H … H2))
140 ##| ##2: #H2; napply (decidable_cn_aux2 … (H … H2))
145 ∀T.(∀x,y:T.decidable (x = y)) →
147 ((mk_comp_num T e1 e2) ≠ (mk_comp_num T e3 e4)) →
148 ((e1 ≠ e3) ∨ (e2 ≠ e4))).
149 #T; #H; #e1; #e2; #e3; #e4;
151 napply (or2_elim (e1 = e3) (e1 ≠ e3) ? (H e1 e3) …);
152 ##[ ##2: #H2; napply (or2_intro1 … H2)
153 ##| ##1: #H2; napply (or2_elim (e2 = e4) (e2 ≠ e4) ? (H e2 e4) …);
154 ##[ ##2: #H3; napply (or2_intro2 … H3)
155 ##| ##1: #H3; nrewrite > H2 in H1:(%);
157 #H1; nelim (H1 (refl_eq …))
162 nlemma neq_to_neqcn :
163 ∀T.∀feq:T → T → bool.
164 (∀x,y:T.(x ≠ y) → (feq x y = false)) →
165 (∀x,y:T.decidable (x = y)) →
167 ((b1 ≠ b2) → (eq2_cn T feq b1 b2 = false))).
168 #T; #feq; #H; #H1; #b1; #b2;
171 #H2; nchange with (((feq e1 e3) ⊗ (feq e2 e4)) = false);
172 napply (or2_elim (e1 ≠ e3) (e2 ≠ e4) ? (cn_destruct T H1 e1 e2 e3 e4 … H2) …);
173 ##[ ##1: #H3; nrewrite > (H … H3); nnormalize; napply refl_eq
174 ##| ##2: #H3; nrewrite > (H … H3);
175 nrewrite > (symmetric_andbool (feq e1 e3) false);
176 nnormalize; napply refl_eq