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 "common/comp.ma".
24 include "num/bool_lemmas.ma".
26 (* **************************** *)
27 (* TIPI PER I MODULI DI MEMORIA *)
28 (* **************************** *)
30 (* tipi di memoria:RAM/ROM/non installata *)
31 ninductive memory_type : Type ≝
32 MEM_READ_ONLY: memory_type
33 | MEM_READ_WRITE: memory_type
34 | MEM_OUT_OF_BOUND: memory_type.
36 (* iteratore sugli ottali *)
37 ndefinition forall_memory_type ≝ λP.
38 P MEM_READ_ONLY ⊗ P MEM_READ_WRITE ⊗ P MEM_OUT_OF_BOUND.
41 ndefinition eq_memorytype ≝
43 [ MEM_READ_ONLY ⇒ match m2 with [ MEM_READ_ONLY ⇒ true | _ ⇒ false ]
44 | MEM_READ_WRITE ⇒ match m2 with [ MEM_READ_WRITE ⇒ true | _ ⇒ false ]
45 | MEM_OUT_OF_BOUND ⇒ match m2 with [ MEM_OUT_OF_BOUND ⇒ true | _ ⇒ false ]
48 ndefinition memorytype_destruct_aux ≝
49 Πn1,n2:memory_type.ΠP:Prop.n1 = n2 →
50 match eq_memorytype n1 n2 with [ true ⇒ P → P | false ⇒ P ].
52 ndefinition memorytype_destruct : memorytype_destruct_aux.
60 nlemma eq_to_eqmemorytype : ∀n1,n2.n1 = n2 → eq_memorytype n1 n2 = true.
68 nlemma neqmemorytype_to_neq : ∀n1,n2.eq_memorytype n1 n2 = false → n1 ≠ n2.
70 napply (not_to_not (n1 = n2) (eq_memorytype n1 n2 = true) …);
71 ##[ ##1: napply (eq_to_eqmemorytype n1 n2)
72 ##| ##2: napply (eqfalse_to_neqtrue … H)
76 nlemma eqmemorytype_to_eq : ∀n1,n2.eq_memorytype n1 n2 = true → n1 = n2.
81 ##[ ##1,5,9: #H; napply refl_eq
82 ##| ##*: #H; ndestruct (*napply (bool_destruct … H)*)
86 nlemma neq_to_neqmemorytype : ∀n1,n2.n1 ≠ n2 → eq_memorytype n1 n2 = false.
88 napply (neqtrue_to_eqfalse (eq_memorytype n1 n2));
89 napply (not_to_not (eq_memorytype n1 n2 = true) (n1 = n2) ? H);
90 napply (eqmemorytype_to_eq n1 n2).
93 nlemma decidable_memorytype : ∀x,y:memory_type.decidable (x = y).
95 napply (or2_elim (eq_memorytype x y = true) (eq_memorytype x y = false) ? (decidable_bexpr ?));
96 ##[ ##1: #H; napply (or2_intro1 (x = y) (x ≠ y) (eqmemorytype_to_eq … H))
97 ##| ##2: #H; napply (or2_intro2 (x = y) (x ≠ y) (neqmemorytype_to_neq … H))
101 nlemma symmetric_eqmemorytype : symmetricT memory_type bool eq_memorytype.
103 napply (or2_elim (n1 = n2) (n1 ≠ n2) ? (decidable_memorytype n1 n2));
104 ##[ ##1: #H; nrewrite > H; napply refl_eq
105 ##| ##2: #H; nrewrite > (neq_to_neqmemorytype n1 n2 H);
106 napply (symmetric_eq ? (eq_memorytype n2 n1) false);
107 napply (neq_to_neqmemorytype n2 n1 (symmetric_neq ? n1 n2 H))
111 nlemma memorytype_is_comparable : comparable.
113 ##[ napply MEM_READ_ONLY
114 ##| napply forall_memory_type
115 ##| napply eq_memorytype
116 ##| napply eqmemorytype_to_eq
117 ##| napply eq_to_eqmemorytype
118 ##| napply neqmemorytype_to_neq
119 ##| napply neq_to_neqmemorytype
120 ##| napply decidable_memorytype
121 ##| napply symmetric_eqmemorytype
125 unification hint 0 ≔ ⊢ carr memorytype_is_comparable ≡ memory_type.