]> 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 (* eq_ast lemmas missing *)
158
159 nlemma isbastbasetype_to_isastbasetype : ∀ast.isb_ast_base_type ast = true → is_ast_base_type ast.
160  #ast;
161  ncases ast;
162  nnormalize;
163  ##[ ##1: #t; #H; napply I
164  ##| ##2: #t; #n; #H; napply (bool_destruct ??? H)
165  ##| ##3: #t; #H; napply (bool_destruct ??? H)
166  ##]
167 nqed.
168
169 nlemma isntbastbasetype_to_isntastbasetype : ∀ast.isntb_ast_base_type ast = true → isnt_ast_base_type ast.
170  #ast;
171  ncases ast;
172  nnormalize;
173  ##[ ##1: #t; #H; napply (bool_destruct ??? H)
174  ##| ##2: #t; #n; #H; napply I
175  ##| ##3: #l; #H; napply I
176  ##]
177 nqed.