]> matita.cs.unibo.it Git - helm.git/blob - matitaB/matita/contribs/ng_assembly2/compiler/ast_base_type.ma
mod change (-x)
[helm.git] / matitaB / matita / contribs / ng_assembly2 / compiler / ast_base_type.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: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Sviluppo: 2008-2010                                                  *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "compiler/ast_base_type_base.ma".
24 include "common/comp.ma".
25 include "num/bool_lemmas.ma".
26
27 (* ************************* *)
28 (* dimensioni degli elementi *)
29 (* ************************* *)
30
31 ndefinition astbasetype_destruct_aux ≝
32 Πb1,b2:ast_base_type.ΠP:Prop.b1 = b2 →
33  match eq_astbasetype b1 b2 with [ true ⇒ P → P | false ⇒ P ].
34
35 ndefinition astbasetype_destruct : astbasetype_destruct_aux.
36  #b1; #b2; #P; #H;
37  nrewrite < H;
38  nelim b1;
39  nnormalize;
40  napply (λx.x).
41 nqed.
42
43 nlemma eq_to_eqastbasetype : ∀n1,n2.n1 = n2 → eq_astbasetype n1 n2 = true.
44  #n1; #n2; #H;
45  nrewrite > H;
46  nelim n2;
47  nnormalize;
48  napply refl_eq.
49 nqed.
50
51 nlemma neqastbasetype_to_neq : ∀n1,n2.eq_astbasetype n1 n2 = false → n1 ≠ n2.
52  #n1; #n2; #H;
53  napply (not_to_not (n1 = n2) (eq_astbasetype n1 n2 = true) …);
54  ##[ ##1: napply (eq_to_eqastbasetype n1 n2)
55  ##| ##2: napply (eqfalse_to_neqtrue … H)
56  ##]
57 nqed.
58
59 nlemma eqastbasetype_to_eq : ∀b1,b2.eq_astbasetype b1 b2 = true → b1 = b2.
60  #b1; #b2; ncases b1; ncases b2; nnormalize;
61  ##[ ##1,5,9: #H; napply refl_eq
62  ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
63  ##]
64 nqed.
65
66 nlemma neq_to_neqastbasetype : ∀n1,n2.n1 ≠ n2 → eq_astbasetype n1 n2 = false.
67  #n1; #n2; #H;
68  napply (neqtrue_to_eqfalse (eq_astbasetype n1 n2));
69  napply (not_to_not (eq_astbasetype n1 n2 = true) (n1 = n2) ? H);
70  napply (eqastbasetype_to_eq n1 n2).
71 nqed.
72
73 nlemma decidable_astbasetype : ∀x,y:ast_base_type.decidable (x = y).
74  #x; #y; nnormalize;
75  napply (or2_elim (eq_astbasetype x y = true) (eq_astbasetype x y = false) ? (decidable_bexpr ?));
76  ##[ ##1: #H; napply (or2_intro1 (x = y) (x ≠ y) (eqastbasetype_to_eq … H))
77  ##| ##2: #H; napply (or2_intro2 (x = y) (x ≠ y) (neqastbasetype_to_neq … H))
78  ##]
79 nqed.
80
81 nlemma symmetric_eqastbasetype : symmetricT ast_base_type bool eq_astbasetype.
82  #n1; #n2;
83  napply (or2_elim (n1 = n2) (n1 ≠ n2) ? (decidable_astbasetype n1 n2));
84  ##[ ##1: #H; nrewrite > H; napply refl_eq
85  ##| ##2: #H; nrewrite > (neq_to_neqastbasetype n1 n2 H);
86           napply (symmetric_eq ? (eq_astbasetype n2 n1) false);
87           napply (neq_to_neqastbasetype n2 n1 (symmetric_neq ? n1 n2 H))
88  ##]
89 nqed.
90
91 nlemma astbasetype_is_comparable : comparable.
92  @ ast_base_type
93   ##[ napply AST_BASE_TYPE_BYTE8
94   ##| napply forall_astbasetype
95   ##| napply eq_astbasetype
96   ##| napply eqastbasetype_to_eq
97   ##| napply eq_to_eqastbasetype
98   ##| napply neqastbasetype_to_neq
99   ##| napply neq_to_neqastbasetype
100   ##| napply decidable_astbasetype
101   ##| napply symmetric_eqastbasetype
102   ##]
103 nqed.
104
105 unification hint 0 ≔ ⊢ carr astbasetype_is_comparable ≡ ast_base_type.
106