source: LTS/frame_variable_pass.ma @ 3562

Last change on this file since 3562 was 3561, checked in by piccolo, 4 years ago
File size: 5.3 KB
Line 
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
15include "Simulation.ma".
16include "variable.ma".
17
18definition update_fun : ∀A : DeqSet.∀B : Type[0].(A → B) → A → B → A → B ≝
19λA,B,f,a,b,x.if x == a then b else f x.
20
21let rec map_exp (e : expr) (map : variable → variable) on e : expr ≝
22match e with
23[  Var v ⇒ Var (map v)
24| Const n ⇒ Const n
25| Plus e1 e2 ⇒ Plus (map_exp e1 map) (map_exp e2 map)
26| Minus e1 e2 ⇒ Minus (map_exp e1 map) (map_exp e2 map)
27].
28
29let rec map_cond (c : condition) (map : variable → variable) on c : condition ≝
30match c with
31[Eq e1 e2 ⇒ Eq (map_exp e1 map) (map_exp e2 map)
32| Not c1 ⇒ Not (map_cond c1 map)
33].
34
35let rec trans_imp_instr (i : imp_Instructions) (map : variable → variable) on i : frame_Instructions  ≝
36match i with
37[ EMPTY ⇒ EMPTY …
38| RETURN rt ⇒ RETURN … rt
39| SEQ seq opt_l i ⇒
40    match seq with
41    [ sNop ⇒ SEQ … sNop opt_l (trans_imp_instr i map)
42    | sAss v e ⇒ SEQ frame_state_params flat_labels (sAss (map v) (map_exp e map)) opt_l (trans_imp_instr i map)
43    ]
44| COND cond ltrue i_true lfalse i_false instr ⇒
45    COND frame_state_params flat_labels (map_cond cond map) ltrue (trans_imp_instr i_true map) lfalse (trans_imp_instr i_false map)
46           (trans_imp_instr instr map)
47| LOOP cond ltrue i_true lfalse instr ⇒
48    LOOP frame_state_params flat_labels (map_cond cond map) ltrue (trans_imp_instr i_true map) lfalse 
49           (trans_imp_instr instr map)
50| CALL f act_p opt_l instr ⇒
51      CALL frame_state_params flat_labels f 〈(\fst act_p),(map_exp (\snd act_p) map)〉 opt_l (trans_imp_instr instr map)
52| IO lin io lout instr ⇒ ?
53].
54cases io qed.
55
56
57let rec All2 (A,B : Type[0]) (f : A → B → Prop) (l1 : list A) (l2 : list B) on l1 : Prop ≝
58match l1 with
59[ nil ⇒ match l2 with [nil ⇒ True | cons _ _ ⇒ False]
60| cons x xs ⇒ match l2 with [nil ⇒ False | cons y ys ⇒ f x y ∧ All2 … f xs ys]
61].
62
63definition store_rel : (variable → variable) → store_t → frame_store_t → Prop ≝
64λmap,st1,st2.
65All2 … (λel1,el2.\snd el1 = \snd el2 ∧ All … (λx.let 〈v,val〉 ≝ x in read_frame … (\fst el2) (to_shift + (map v)) O = return val)
66       (\fst el1)) st1 (\fst st2) ∧ \snd st2 = 〈O,O〉.
67
68definition trans_imp_prog : (variable → variable) → Program imp_env_params imp_instr_params flat_labels →
69Program frame_env_params imp_instr_params flat_labels ≝ λmap,prog.
70mk_Program ???
71(foldr …
72   (λx,tail.(mk_env_item …
73               (mk_signature frame_env_params … (f_name … (f_sig … x)) it (f_ret …(f_sig … x)))
74               (f_lab … x) (trans_imp_instr (f_body … x) map)) :: tail) (nil ?) (env … prog))
75(trans_imp_instr (main … prog) map).
76
77definition imp_variable_pass_rel ≝ 
78λmap : variable → variable.
79λprog : Program imp_state_params imp_state_params imp_state_params.
80let t_prog ≝ trans_imp_prog map prog in
81mk_relations flat_labels (operational_semantics imp_state_params imp_sem_state_params prog)
82 (operational_semantics frame_state_params frame_sem_state_params t_prog)
83(λs1,s2.store_rel map (store … s1) (store … s2) ∧ code … s2 = trans_imp_instr (code … s1) map ∧ 
84cont … s2 = foldr … (λx,rem.〈\fst x,(trans_imp_instr (\snd x) map)〉 :: rem) (nil ?) (cont … s1))
85(λ_.λ_.True).
86
87definition simulation_imp_frame ≝
88λprog : Program imp_state_params imp_state_params imp_state_params.
89λmap : variable → variable.
90λprf : All … (λx.map (f_pars imp_state_params imp_state_params (f_sig … x)) = O) (env … prog).
91mk_simulation_conditions … (imp_variable_pass_rel map prog) ???????????.
92cases daemon (*TODO*)
93qed.
94
95(*
96[ #s1 #s2 ** #H1 #H2 #H3 whd in match (as_initial ???); (*store iniziali in relazione*) cases daemon
97| cases daemon
98| cases daemon
99| #s1 #s2 #s1' #H inversion H
100  [ #s11 #s22 * #act #instr #cont #EQcode_s11 #EQcont_s11 #EQ #EQ1 destruct #EQstore #Hio1 #Hio2
101    #act_no_ret #EQ1 #EQ2 #EQ3 destruct #_ ** #Hstore #EQcode #EQcont #_ #_
102    %{(mk_state … (code … s22) (cont … s22) (store … s2) (io_info … s22))}
103    %{(t_ind … (t_base …))}
104    [2: @(cost_act … (None ?))
105    | @hide_prf whd applyS(empty) [9: <EQcode assumption |2: normalize % * |3: % |4: cases daemon (*da mettere a posto io *)
106    |5: % |6: % |7: % |8: <EQcont assumption |*:]
107    | % [ % // % // ] %1 %2 [cases daemon] %1 cases daemon
108    ]
109  |*: cases daemon 
110  ]
111|*: cases daemon
112]
113qed.*)
114   
115   
Note: See TracBrowser for help on using the repository browser.