]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/compiler/ast_type_lemmas.ma
freescale porting, work in progress
[helm.git] / helm / software / matita / contribs / ng_assembly / compiler / ast_type_lemmas.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* ********************************************************************** *)
16 (*                          Progetto FreeScale                            *)
17 (*                                                                        *)
18 (*   Sviluppato da: Cosimo Oliboni, oliboni@cs.unibo.it                   *)
19 (*     Cosimo Oliboni, oliboni@cs.unibo.it                                *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "compiler/ast_type.ma".
24
25 (* ************************* *)
26 (* dimensioni degli elementi *)
27 (* ************************* *)
28
29 ndefinition astbasetype_destruct_aux ≝
30 Πb1,b2:ast_base_type.ΠP:Prop.b1 = b2 →
31  match b1 with
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 ]
35   ].
36
37 ndefinition astbasetype_destruct : astbasetype_destruct_aux.
38  #b1; #b2; #P;
39  nelim b1;
40  nelim b2;
41  nnormalize;
42  #H;
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]);
46             nrewrite > H;
47             nnormalize;
48             napply I
49  ##| ##4,6: napply (False_ind (λ_.?) ?);
50             nchange with (match AST_BASE_TYPE_WORD16 with [ AST_BASE_TYPE_WORD16 ⇒ False | _ ⇒ True]);
51             nrewrite > H;
52             nnormalize;
53             napply I
54  ##| ##7,8: napply (False_ind (λ_.?) ?);
55             nchange with (match AST_BASE_TYPE_WORD32 with [ AST_BASE_TYPE_WORD32 ⇒ False | _ ⇒ True]);
56             nrewrite > H;
57             nnormalize;
58             napply I
59  ##]
60 nqed.
61
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.
64
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)
69  ##]
70 nqed.
71
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)
76  ##]
77 nqed.
78
79 nlemma asttype_destruct_base_base : ∀b1,b2.AST_TYPE_BASE b1 = AST_TYPE_BASE b2 → b1 = b2.
80  #b1; #b2; #H;
81  nchange with (match AST_TYPE_BASE b2 with [ AST_TYPE_BASE a ⇒ b1 = a | _ ⇒ False ]);
82  nrewrite < H;
83  nnormalize;
84  napply (refl_eq ??).
85 nqed.
86
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 ]);
90  nrewrite < H;
91  nnormalize;
92  napply (refl_eq ??).
93 nqed.
94
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 ]);
98  nrewrite < H;
99  nnormalize;
100  napply (refl_eq ??).
101 nqed.
102
103 nlemma asttype_destruct_struc_struct : ∀b1,b2.AST_TYPE_STRUCT b1 = AST_TYPE_STRUCT b2 → b1 = b2.
104  #b1; #b2; #H;
105  nchange with (match AST_TYPE_STRUCT b2 with [ AST_TYPE_STRUCT a ⇒ b1 = a | _ ⇒ False ]);
106  nrewrite < H;
107  nnormalize;
108  napply (refl_eq ??).
109 nqed.
110
111 ndefinition asttype_destruct_aux ≝
112 Πb1,b2:ast_type.ΠP:Prop.b1 = b2 →
113  match b1 with
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 ]
119     ] | _ ⇒ 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 ]
122   ].
123
124 ndefinition asttype_destruct : asttype_destruct_aux.
125  #b1; #b2; #P;
126  ncases b1;
127  ##[ ##1: ncases b2;
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))
131                    ##]
132           ##| ##2: #t; #n; #b; nnormalize; #H
133           ##| ##3: #l; #b; nnormalize; #H
134           ##]
135           napply (False_ind (λ_.?) ?);
136           nchange with (match AST_TYPE_BASE b with [ AST_TYPE_BASE _ ⇒ False | _ ⇒ True ]);
137           nrewrite > H; nnormalize; napply I
138  ##| ##2: ncases b2;
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
142           ##]
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
146  ##| ##3: ncases b2;
147           ##[ ##3: #l1; #l2; nnormalize; #H; napply (λx:P.x)
148           ##| ##1: #b; #l; nnormalize; #H
149           ##| ##2: #t; #n; #l; nnormalize; #H
150           ##]
151           napply (False_ind (λ_.?) ?);
152           nchange with (match AST_TYPE_STRUCT l with [ AST_TYPE_STRUCT _ ⇒ False | _ ⇒ True ]);
153           nrewrite > H; nnormalize; napply I
154  ##]
155 nqed.
156
157 nlemma symmetric_eqasttype_aux1
158  : ∀nl1,nl2.
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).
161  #nl1; #nl2; #H;
162  napply H.
163 nqed.
164
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);
170                    napply (refl_eq ??)
171           ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
172           ##| ##3: #nl2; nnormalize; napply (refl_eq ??)
173           ##]
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);
177                    nrewrite > (H st2);
178                    napply (refl_eq ??)
179           ##| ##1: #b2; nnormalize; napply (refl_eq ??)
180           ##| ##3: #nl2; nnormalize; napply (refl_eq ??)
181           ##]
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));
185                             nrewrite > (H hh2);
186                             napply (refl_eq ??)
187                    ##| ##2: #hh2; #ll2; nnormalize; napply (refl_eq ??)
188                    ##]
189           ##| ##1: #b2; nnormalize; napply (refl_eq ??)
190           ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
191           ##]
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;
196                             nrewrite > (H hh2);
197                             nrewrite > (symmetric_eqasttype_aux1 ll1 ll2 (H1 (AST_TYPE_STRUCT ll2)));
198                             napply (refl_eq ??)
199                    ##]
200           ##| ##1: #b2; nnormalize; napply (refl_eq ??)
201           ##| ##2: #st2; #n2; nnormalize; napply (refl_eq ??)
202           ##]
203  ##]
204 nqed.
205
206 ...
207
208
209 nlemma isbastbasetype_to_isastbasetype : ∀ast.isb_ast_base_type ast = true → is_ast_base_type ast.
210  #ast;
211  ncases ast;
212  nnormalize;
213  ##[ ##1: #t; #H; napply I
214  ##| ##2: #t; #n; #H; napply (bool_destruct ??? H)
215  ##| ##3: #t; #H; napply (bool_destruct ??? H)
216  ##]
217 nqed.
218
219 nlemma isntbastbasetype_to_isntastbasetype : ∀ast.isntb_ast_base_type ast = true → isnt_ast_base_type ast.
220  #ast;
221  ncases ast;
222  nnormalize;
223  ##[ ##1: #t; #H; napply (bool_destruct ??? H)
224  ##| ##2: #t; #n; #H; napply I
225  ##| ##3: #l; #H; napply I
226  ##]
227 nqed.