[3458] | 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 | include "Traces.ma". |
---|
| 16 | |
---|
| 17 | record monoid: Type[1] ≝ |
---|
| 18 | { carrier :> Type[0] |
---|
| 19 | ; op: carrier → carrier → carrier |
---|
| 20 | ; e: carrier |
---|
| 21 | ; neutral_r : ∀x. op … x e = x |
---|
| 22 | ; neutral_l : ∀x. op … e x = x |
---|
| 23 | ; is_associative: ∀x,y,z. op … (op … x y) z = op … x (op … y z) |
---|
| 24 | }. |
---|
| 25 | |
---|
| 26 | record monoid_action (I : monoid) (M : Type[0]) : Type[0] ≝ |
---|
| 27 | { act :2> I → M → M |
---|
| 28 | ; act_neutral : ∀x.act (e …) x = x |
---|
| 29 | ; act_op : ∀i,j,x.act (op … i j) x = act j (act i x) |
---|
| 30 | }. |
---|
| 31 | |
---|
| 32 | record concrete_transition_sys : Type[2] ≝ |
---|
| 33 | { trans_sys :> abstract_status |
---|
| 34 | ; cost_mon : monoid |
---|
| 35 | ; cost_of : trans_sys → cost_mon |
---|
| 36 | }. |
---|
| 37 | |
---|
| 38 | record abstract_transition_sys (concrete_costs : Type[0]) : Type[1] ≝ |
---|
| 39 | { abs_state_t :> Type[0] |
---|
| 40 | ; abs_instr : monoid |
---|
| 41 | ; act_abs : monoid_action abs_instr abs_state_t |
---|
| 42 | ; abs_cost : abs_state_t → concrete_costs |
---|
| 43 | }. |
---|
| 44 | |
---|
| 45 | record galois_conn (C : concrete_transition_sys) |
---|
| 46 | (A : abstract_transition_sys (cost_mon C)) : Type[0] ≝ |
---|
| 47 | { rel_galois :2> C → A → Prop |
---|
| 48 | ; rel_galois_cost : ∀s,a.rel_galois … s a → abs_cost … a = cost_of … s |
---|
| 49 | ; rel_galois_prop : ∀s,s' : C.∀a : A.∀l.as_execute … l s s' → rel_galois … s a → |
---|
| 50 | ∃i : abs_instr … A.∃a' : A.rel_galois … s' a' ∧ |
---|
| 51 | act_abs ?? i a = a' |
---|
| 52 | }. |
---|
| 53 | |
---|
| 54 | record static_analysis_data : Type[2] ≝ |
---|
| 55 | { concr : concrete_transition_sys |
---|
| 56 | ; abs_d : abstract_transition_sys (cost_mon concr) |
---|
| 57 | ; instr_t : Type[0] |
---|
| 58 | ; fetch : concr → option instr_t |
---|
| 59 | ; instr_map : instr_t → abs_instr … abs_d |
---|
| 60 | }. |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | record static_galois (p : static_analysis_data) : Type[0] ≝ |
---|
| 64 | { good :> galois_conn (concr … p) (abs_d … p) |
---|
| 65 | ; instr_map_ok : ∀s,s' : (concr … p).∀a : (abs_d … p).∀l,i.as_execute … l s s' → |
---|
| 66 | fetch … p s = Some ? i → |
---|
| 67 | rel_galois … good s a → |
---|
| 68 | rel_galois … good s' (act_abs … (instr_map … p i) a) |
---|
| 69 | }. |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | |
---|