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: Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Cosimo Oliboni, oliboni@cs.unibo.it *)
21 (* ********************************************************************** *)
23 include "compiler/ast_type.ma".
25 (* ************************* *)
26 (* dimensioni degli elementi *)
27 (* ************************* *)
29 ndefinition astbasetype_destruct_aux ≝
30 Πb1,b2:ast_base_type.ΠP:Prop.b1 = b2 →
32 [ AST_BASE_TYPE_BYTE8 ⇒ match b2 with [ AST_BASE_TYPE_BYTE8 ⇒ P → P | _ ⇒ P ]
33 | AST_BASE_TYPE_WORD16 ⇒ match b2 with [ AST_BASE_TYPE_WORD16 ⇒ P → P | _ ⇒ P ]
34 | AST_BASE_TYPE_WORD32 ⇒ match b2 with [ AST_BASE_TYPE_WORD32 ⇒ P → P | _ ⇒ P ]
37 ndefinition astbasetype_destruct : astbasetype_destruct_aux.
43 ##[ ##1,5,9: napply (λx:P.x)
44 ##| ##2,3: napply (False_ind (λ_.?) ?);
45 nchange with (match AST_BASE_TYPE_BYTE8 with [ AST_BASE_TYPE_BYTE8 ⇒ False | _ ⇒ True]);
49 ##| ##4,6: napply (False_ind (λ_.?) ?);
50 nchange with (match AST_BASE_TYPE_WORD16 with [ AST_BASE_TYPE_WORD16 ⇒ False | _ ⇒ True]);
54 ##| ##7,8: napply (False_ind (λ_.?) ?);
55 nchange with (match AST_BASE_TYPE_WORD32 with [ AST_BASE_TYPE_WORD32 ⇒ False | _ ⇒ True]);
62 nlemma symmetric_eqastbasetype : symmetricT ast_base_type bool eq_ast_base_type.
63 #b1; #b2; ncases b1; ncases b2; nnormalize; napply (refl_eq ??). nqed.
65 nlemma eqastbasetype_to_eq : ∀b1,b2.eq_ast_base_type b1 b2 = true → b1 = b2.
66 #b1; #b2; ncases b1; ncases b2; nnormalize;
67 ##[ ##1,5,9: #H; napply (refl_eq ??)
68 ##| ##*: #H; napply (bool_destruct ??? H)
72 nlemma eq_to_eqastbasetype : ∀b1,b2.b1 = b2 → eq_ast_base_type b1 b2 = true.
73 #b1; #b2; ncases b1; ncases b2; nnormalize;
74 ##[ ##1,5,9: #H; napply (refl_eq ??)
75 ##| ##*: #H; napply (astbasetype_destruct ??? H)
79 nlemma asttype_destruct_base_base : ∀b1,b2.AST_TYPE_BASE b1 = AST_TYPE_BASE b2 → b1 = b2.
81 nchange with (match AST_TYPE_BASE b2 with [ AST_TYPE_BASE a ⇒ b1 = a | _ ⇒ False ]);
87 nlemma asttype_destruct_array_array_1 : ∀x1,x2,y1,y2.AST_TYPE_ARRAY x1 y1 = AST_TYPE_ARRAY x2 y2 → x1 = x2.
88 #x1; #x2; #y1; #y2; #H;
89 nchange with (match AST_TYPE_ARRAY x2 y2 with [ AST_TYPE_ARRAY a _ ⇒ x1 = a | _ ⇒ False ]);
95 nlemma asttype_destruct_array_array_2 : ∀x1,x2,y1,y2.AST_TYPE_ARRAY x1 y1 = AST_TYPE_ARRAY x2 y2 → y1 = y2.
96 #x1; #x2; #y1; #y2; #H;
97 nchange with (match AST_TYPE_ARRAY x2 y2 with [ AST_TYPE_ARRAY _ b ⇒ y1 = b | _ ⇒ False ]);
103 nlemma asttype_destruct_struc_struct : ∀b1,b2.AST_TYPE_STRUCT b1 = AST_TYPE_STRUCT b2 → b1 = b2.
105 nchange with (match AST_TYPE_STRUCT b2 with [ AST_TYPE_STRUCT a ⇒ b1 = a | _ ⇒ False ]);
111 ndefinition asttype_destruct_aux ≝
112 Πb1,b2:ast_type.ΠP:Prop.b1 = b2 →
114 [ AST_TYPE_BASE s1 ⇒ match b2 with
115 [ AST_TYPE_BASE s2 ⇒ match s1 with
116 [ AST_BASE_TYPE_BYTE8 ⇒ match s2 with [ AST_BASE_TYPE_BYTE8 ⇒ P → P | _ ⇒ P ]
117 | AST_BASE_TYPE_WORD16 ⇒ match s2 with [ AST_BASE_TYPE_WORD16 ⇒ P → P | _ ⇒ P ]
118 | AST_BASE_TYPE_WORD32 ⇒ match s2 with [ AST_BASE_TYPE_WORD32 ⇒ P → P | _ ⇒ P ]
120 | AST_TYPE_ARRAY _ _ ⇒ match b2 with [ AST_TYPE_ARRAY _ _ ⇒ P → P | _ ⇒ P ]
121 | AST_TYPE_STRUCT _ ⇒ match b2 with [ AST_TYPE_STRUCT _ ⇒ P → P | _ ⇒ P ]
124 ndefinition asttype_destruct : asttype_destruct_aux.
128 ##[ ##1: nnormalize; #s1; #s2; ncases s1; ncases s2; nnormalize;
129 ##[ ##1,5,9: #H; napply (λx:P.x)
130 ##| ##*: #H; napply (astbasetype_destruct ??? (asttype_destruct_base_base ?? H))
132 ##| ##2: #t; #n; #b; nnormalize; #H
133 ##| ##3: #l; #b; nnormalize; #H
135 napply (False_ind (λ_.?) ?);
136 nchange with (match AST_TYPE_BASE b with [ AST_TYPE_BASE _ ⇒ False | _ ⇒ True ]);
137 nrewrite > H; nnormalize; napply I
139 ##[ ##2: #t1; #n1; #t2; #n2; nnormalize; #H; napply (λx:P.x)
140 ##| ##1: #b; #t; #n; nnormalize; #H
141 ##| ##3: #l; #t; #n; nnormalize; #H
143 napply (False_ind (λ_.?) ?);
144 nchange with (match AST_TYPE_ARRAY t n with [ AST_TYPE_ARRAY _ _ ⇒ False | _ ⇒ True ]);
145 nrewrite > H; nnormalize; napply I
147 ##[ ##3: #l1; #l2; nnormalize; #H; napply (λx:P.x)
148 ##| ##1: #b; #l; nnormalize; #H
149 ##| ##2: #t; #n; #l; nnormalize; #H
151 napply (False_ind (λ_.?) ?);
152 nchange with (match AST_TYPE_STRUCT l with [ AST_TYPE_STRUCT _ ⇒ False | _ ⇒ True ]);
153 nrewrite > H; nnormalize; napply I
157 nlemma symmetric_eqasttype_aux1
159 (eq_ast_type (AST_TYPE_STRUCT nl1) (AST_TYPE_STRUCT nl2)) = (eq_ast_type (AST_TYPE_STRUCT nl2) (AST_TYPE_STRUCT nl1)) →
160 (bfold_right_neList2 ? (λx,y.eq_ast_type x y) nl1 nl2) = (bfold_right_neList2 ? (λx,y.eq_ast_type x y) nl2 nl1).
165 nlemma symmetric_eqasttype : symmetricT ast_type bool eq_ast_type.
166 #t1; napply (ast_type_index ????? t1);
167 ##[ ##1: #b1; #t2; ncases t2;
168 ##[ ##1: #b2; nchange with ((eq_ast_base_type b1 b2) = (eq_ast_base_type b2 b1));
169 nrewrite > (symmetric_eqastbasetype b1 b2);
171 ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
172 ##| ##3: #nl2; nnormalize; napply (refl_eq ??)
174 ##| ##2: #st1; #n1; #H; #t2; ncases t2;
175 ##[ ##2: #st2; #n2; nchange with (((eq_ast_type st1 st2)⊗(eq_nat n1 n2)) = ((eq_ast_type st2 st1)⊗(eq_nat n2 n1)));
176 nrewrite > (symmetric_eqnat n1 n2);
179 ##| ##1: #b2; nnormalize; napply (refl_eq ??)
180 ##| ##3: #nl2; nnormalize; napply (refl_eq ??)
182 ##| ##3: #hh1; #H; #t2; ncases t2;
183 ##[ ##3: #nl2; ncases nl2;
184 ##[ ##1: #hh2; nchange with ((eq_ast_type hh1 hh2) = (eq_ast_type hh2 hh1));
187 ##| ##2: #hh2; #ll2; nnormalize; napply (refl_eq ??)
189 ##| ##1: #b2; nnormalize; napply (refl_eq ??)
190 ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
192 ##| ##4: #hh1; #ll1; #H; #H1; #t2; ncases t2;
193 ##[ ##3: #nl2; ncases nl2;
194 ##[ ##1: #hh2; nnormalize; napply (refl_eq ??)
195 ##| ##2: #hh2; #ll2; nnormalize;
197 nrewrite > (symmetric_eqasttype_aux1 ll1 ll2 (H1 (AST_TYPE_STRUCT ll2)));
200 ##| ##1: #b2; nnormalize; napply (refl_eq ??)
201 ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
209 nlemma isbastbasetype_to_isastbasetype : ∀ast.isb_ast_base_type ast = true → is_ast_base_type ast.
213 ##[ ##1: #t; #H; napply I
214 ##| ##2: #t; #n; #H; napply (bool_destruct ??? H)
215 ##| ##3: #t; #H; napply (bool_destruct ??? H)
219 nlemma isntbastbasetype_to_isntastbasetype : ∀ast.isntb_ast_base_type ast = true → isnt_ast_base_type ast.
223 ##[ ##1: #t; #H; napply (bool_destruct ??? H)
224 ##| ##2: #t; #n; #H; napply I
225 ##| ##3: #l; #H; napply I