source: src/joint/semanticsUtils.ma @ 2783

Last change on this file since 2783 was 2783, checked in by piccolo, 7 years ago

modified joint_closed_internal_function definition (added condition on pseudo-registers)
added new record for parameters
modified state definition with option for framesT

File size: 21.6 KB
Line 
1include "joint/joint_semantics.ma".
2include alias "common/Identifiers.ma".
3include "utilities/hide.ma".
4include "ASM/BitVectorTrie.ma".
5include "joint/TranslateUtils.ma".
6include "common/ExtraMonads.ma".
7include "common/extraGlobalenvs.ma".
8
9record hw_register_env : Type[0] ≝
10  { reg_env : BitVectorTrie beval 6
11  ; other_bit : bebit
12  }.
13
14definition empty_hw_register_env: hw_register_env ≝
15  mk_hw_register_env (Stub …) BBundef.
16
17include alias "ASM/BitVectorTrie.ma".
18
19definition hwreg_retrieve: hw_register_env → Register → beval ≝
20 λenv,r. lookup … (bitvector_of_register r) (reg_env env) BVundef.
21
22definition hwreg_store: Register → beval → hw_register_env → hw_register_env ≝
23 λr,v,env.mk_hw_register_env (insert … (bitvector_of_register r) v (reg_env env))
24  (other_bit env).
25
26definition hwreg_set_other : bebit → hw_register_env → hw_register_env ≝
27λv,env.mk_hw_register_env (reg_env env) v.
28
29definition hwreg_retrieve_sp : hw_register_env → res xpointer ≝
30λenv.
31let spl ≝ hwreg_retrieve env RegisterSPL in
32let sph ≝ hwreg_retrieve env RegisterSPH in
33! ptr ← pointer_of_address 〈spl, sph〉 ;
34match ptype ptr return λx.ptype ptr = x → res xpointer with
35[ XData ⇒ λprf.return «ptr, prf»
36| _ ⇒ λ_.Error … [MSG BadPointer]
37] (refl …).
38
39definition hwreg_store_sp : hw_register_env → xpointer → hw_register_env ≝
40λenv,sp.
41let 〈spl, sph〉 ≝ beval_pair_of_pointer sp in
42hwreg_store RegisterSPH sph (hwreg_store RegisterSPL spl env).
43
44(*** Store/retrieve on pseudo-registers ***)
45include alias "common/Identifiers.ma".
46
47record reg_sp : Type[0] ≝
48{ reg_sp_env :> identifier_map RegisterTag beval
49; stackp : xpointer
50}.
51
52definition reg_store ≝ λreg,v,locals. OK ? (add RegisterTag beval locals reg v).
53
54definition reg_retrieve : register_env beval → register → res beval ≝
55 λlocals,reg. opt_to_res … [MSG BadRegister; CTX ? reg] (lookup … locals reg).
56
57definition reg_sp_store ≝ λreg,v,locals.
58! locals' ← reg_store reg v (reg_sp_env locals) ;
59return mk_reg_sp locals' (stackp locals).
60
61definition reg_sp_retrieve ≝ λlocals.reg_retrieve locals.
62
63(*** Store/retrieve on hardware registers ***)
64
65definition init_hw_register_env: xpointer → hw_register_env ≝
66 λsp.hwreg_store_sp empty_hw_register_env sp.
67
68(******************************** GRAPHS **************************************)
69
70record sem_graph_params : Type[1] ≝
71{ sgp_pars : uns_params
72; sgp_sup : ∀F.sem_unserialized_params sgp_pars F
73}.
74
75
76definition sem_graph_params_to_graph_params :
77  ∀pars : sem_graph_params.graph_params ≝
78  λpars.mk_graph_params (sgp_pars pars).
79
80coercion graph_params_from_sem_graph_params nocomposites :
81  ∀pars : sem_graph_params.
82  graph_params ≝ sem_graph_params_to_graph_params
83  on _pars : sem_graph_params to graph_params.
84
85definition sem_graph_params_to_sem_params :
86  ∀pars : sem_graph_params.
87  sem_params ≝
88  λpars.
89  mk_sem_params
90    (pars : graph_params)
91    (sgp_sup pars ?)
92    (word_of_identifier ?)
93    (an_identifier ?)
94    ? (refl …).
95* #p % qed.
96
97coercion sem_params_from_sem_graph_params :
98  ∀pars : sem_graph_params.
99  sem_params ≝ sem_graph_params_to_sem_params
100  on _pars : sem_graph_params to sem_params.
101
102
103(******************************** LINEAR **************************************)
104
105lemma succ_pos_of_nat_of_pos : ∀p.succ_pos_of_nat (nat_of_pos p) = succ p.
106@pos_elim [%]
107#p #IH >nat_possucc whd in ⊢ (??%?); >IH % qed.
108
109record sem_lin_params : Type[1] ≝
110{ slp_pars : uns_params
111; slp_sup : ∀F.sem_unserialized_params slp_pars F
112}.
113
114definition sem_lin_params_to_lin_params :
115  ∀pars : sem_lin_params.lin_params ≝
116  λpars.mk_lin_params (slp_pars pars).
117
118coercion lin_params_from_sem_lin_params nocomposites :
119  ∀pars : sem_lin_params.
120  lin_params ≝ sem_lin_params_to_lin_params
121  on _pars : sem_lin_params to lin_params.
122
123definition sem_lin_params_to_sem_params :
124  ∀pars : sem_lin_params.
125  sem_params ≝
126  λpars.
127  mk_sem_params
128    (pars : lin_params)
129    (slp_sup pars ?)
130    succ_pos_of_nat
131    (λp.pred (nat_of_pos p))
132    ??.
133[ #n >nat_succ_pos %
134| @pos_cases [%] #p >nat_possucc @succ_pos_of_nat_of_pos
135] qed.
136
137coercion sem_params_from_sem_lin_params :
138  ∀pars : sem_lin_params.
139  sem_params ≝ sem_lin_params_to_sem_params
140  on _pars : sem_lin_params to sem_params.
141
142
143lemma fetch_statement_eq : ∀p:sem_params.∀g.
144  ∀ge : genv_t (joint_function p g).∀ptr : program_counter.
145  ∀i,fn,s.
146  fetch_internal_function … ge (pc_block ptr) = OK … 〈i, fn〉 →
147  let pt ≝ point_of_pc … ptr in
148  stmt_at … (joint_if_code … fn) pt = Some ? s →
149  fetch_statement … ge ptr = OK … 〈i, fn, s〉.
150#p #g #ge #ptr #i #f #s #EQ1 #EQ2
151whd in match fetch_statement; normalize nodelta >EQ1 >m_return_bind
152>EQ2 %
153qed.
154
155lemma fetch_statement_inv : ∀p:sem_params.∀g.
156  ∀ge : genv_t (joint_function p g).∀ptr : program_counter.
157  ∀i,fn,s.
158  fetch_statement … ge ptr = OK … 〈i, fn, s〉 →
159  fetch_internal_function … ge (pc_block ptr) = OK … 〈i, fn〉 ∧
160  let pt ≝ point_of_pc p ptr in
161  stmt_at … (joint_if_code … fn) pt = Some ? s.
162#p #g #ge #ptr #i #fn #s #H
163elim (bind_inversion ????? H) * #i #f' * #EQ1 -H #H
164elim (bind_inversion ????? H) #s' * #H
165lapply (opt_eq_from_res ???? H) -H #EQ2
166whd in ⊢ (??%%→?); #EQ destruct(EQ) %{EQ1 EQ2}
167qed.
168
169definition pm_P : ∀A,B.∀P : A → B → Prop.positive_map A → positive_map B → Prop ≝
170λA,B,P,mA,mB.
171∀p.
172match lookup_opt … p mA with
173[ Some a ⇒
174  match lookup_opt … p mB with
175  [ Some b ⇒ P a b
176  | _ ⇒ False
177  ]
178| _ ⇒ match lookup_opt … p mB with
179  [ Some _ ⇒ False
180  | _ ⇒ True
181  ]
182].
183
184definition match_funct_map :
185  ∀M : matching.
186  ∀vars.positive_map (m_A M vars) → positive_map (m_B M vars) → Prop ≝
187  λM,vars.pm_P … (match_fundef M ?).
188
189lemma pm_P_insert :
190  ∀A,B,P.
191  ∀p,a1,a2,m1,m2.P a1 a2 → pm_P A B P m1 m2 →
192  pm_P … P (insert … p a1 m1) (insert … p a2 m2).
193#A #B #P #p #a1 #a2 #m1 #m2 #Pa1a2 #Pm1m2
194#p'
195@(eqb_elim p' p) #H destruct
196[ >lookup_opt_insert_hit >lookup_opt_insert_hit @Pa1a2
197| >(lookup_opt_insert_miss … a1 … H) >(lookup_opt_insert_miss … a2 … H)
198  @Pm1m2
199]
200qed.
201
202lemma pm_P_set_None :
203  ∀A,B,P.
204  ∀p,m1,m2.pm_P A B P m1 m2 →
205  pm_P … P (pm_set … p (None ?) m1) (pm_set … p (None ?) m2).
206#A #B #P #p #m1 #m2 #Pm1m2
207#p'
208@(eqb_elim p' p) #H destruct
209[ >lookup_opt_pm_set_hit >lookup_opt_pm_set_hit %
210| >(lookup_opt_pm_set_miss … H) >(lookup_opt_pm_set_miss … H)
211  @Pm1m2
212]
213qed.
214
215record match_genv_t (M : matching)
216  (vars : list ident)
217  (ge1 : genv_t (m_A M vars)) (ge2 : genv_t (m_B M vars)) : Prop ≝
218{ symbols_eq : symbols … ge1 = symbols … ge2
219; nextfunction_eq : nextfunction … ge1 = nextfunction … ge2
220; functions_match : pm_P … (match_fundef M ?) (functions … ge1) (functions … ge2)
221}.
222
223lemma add_globals_match :
224  ∀M : matching.∀initV,initW.
225  ∀vars1,vars2.
226  ∀vars.
227(*  let vars1' ≝ map … (λx.\fst (\fst x)) vars1 in
228  let vars2' ≝ map … (λx.\fst (\fst x)) vars2 in *)
229  ∀env_mem1 : genv_t (m_A M vars) × mem.
230  ∀env_mem2 : genv_t (m_B M vars) × mem.
231  All2 (ident×region×(m_V M)) (ident×region×(m_W M))
232      (match_var_entry M) vars1 vars2 →
233  nextblock … (\snd env_mem1) = nextblock … (\snd env_mem2) →
234  match_genv_t M vars
235    (\fst env_mem1) (\fst env_mem2) →
236  match_genv_t M vars
237    (\fst (add_globals … initV env_mem1 vars1))
238    (\fst (add_globals … initW env_mem2 vars2)).
239#M #init1 #init2 #vars1
240elim vars1 -vars1 [2: ** #id1 #r1 #v1 #tl1 #IH ]
241* [2,4: ** #id2 #r2 #v2 #tl2 ]
242#vars * #env1 #mem1 * #env2 #mem2 *
243[2: #_ #H @H ]
244#H inversion H #id' #r' #v1' #v2' #P #EQ1 #EQ2 #_ destruct -H #H
245#EQnxtbl #G @(IH tl2 … H)
246cases mem1 in EQnxtbl; -mem1 #mem1 #nbl1 #prf1
247cases mem2 -mem2 #mem2 #nbl2 #prf2 #EQ destruct
248[ % ]
249normalize nodelta %
250whd in match add_symbol;
251whd in match drop_fn; normalize nodelta
252[ >(symbols_eq … G) %
253| @(nextfunction_eq … G)
254| >(symbols_eq … G) cases (lookup ? block ??) normalize nodelta
255  [2: ** [2,3: #p] normalize nodelta ]
256  try @pm_P_set_None
257  @(functions_match … G)
258]
259qed.
260
261lemma add_functs_match :
262  ∀M : matching.
263  ∀vars.
264  ∀functs1,functs2.
265(*  let vars1' ≝ map … (λx.\fst (\fst x)) vars1 in
266  let vars2' ≝ map … (λx.\fst (\fst x)) vars2 in *)
267  ∀env1 : genv_t (m_A M vars).
268  ∀env2 : genv_t (m_B M vars).
269  All2 …
270    (match_funct_entry M vars vars) functs1 functs2 →
271  match_genv_t M vars env1 env2 →
272  match_genv_t M vars
273    (add_functs … env1 functs1)
274    (add_functs … env2 functs2).
275#M #vars #functs1 elim functs1 -functs1 [2: * #id1 #f1 #tl1 #IH ]
276* [2,4: * #id2 #f2 #tl2 ]
277#env1 #env2 *
278[2: #H @H ]
279#H
280cut (id1 = id2 ∧ match_fundef M … f1 f2)
281[ @(match_funct_entry_inv M ??????? H) #v #i #f1 #f2 #H %{H} % ]
282* #EQ destruct #Pf1f2 #Ptl1tl2 #G
283lapply (IH … Ptl1tl2 G) -G #G
284%
285whd in
286  match (add_functs ?? (? :: tl1));
287whd in
288  match (add_functs ?? (? :: tl2));
289change with (add_functs ?? tl1) in match (foldr ???? tl1);
290change with (add_functs ?? tl2) in match (foldr ???? tl2);
291whd in match drop_fn; normalize nodelta
292[ >(nextfunction_eq … G)  >(symbols_eq … G) %
293| >(nextfunction_eq … G) %
294| >(symbols_eq … G) cases (lookup ? block ??) normalize nodelta
295  [2: ** [2,3: #p] normalize nodelta ]
296  >(nextfunction_eq … G)
297  @(pm_P_insert … Pf1f2)
298  try @pm_P_set_None @(functions_match … G)
299]
300qed.
301
302lemma globalenv_match:
303    ∀M:matching.∀initV,initW.
304     (∀v,w. match_var_entry M v w →
305      size_init_data_list (initV (\snd v)) = size_init_data_list (initW (\snd w))) →
306    ∀p: program (m_A M) (m_V M). ∀p': program (m_B M) (m_W M).
307    ∀MATCH:match_program … M p p'.
308    match_genv_t M ? (globalenv … initV p)
309      (globalenv … initW p' ⌈prog_var_names … p' ↦ prog_var_names … p⌉).
310[2: @sym_eq @(matching_vars … (mp_vars … MATCH)) ]
311* #A #B #V #W #Pf #Pv #iV #iW #init_eq
312* #vars1 #functs1 #main1
313* #vars2 #functs2 #main2
314*
315whd in match prog_var_names;
316normalize nodelta;
317#Mvars #Mfns #EQmain destruct
318lapply (sym_eq ????)
319#E
320lapply Mfns lapply functs2 -functs2
321whd in match globalenv; whd in match globalenv_allocmem;
322whd in match prog_var_names in E ⊢ %;
323normalize nodelta in E ⊢ %;
324>E normalize nodelta #functs2 #Mfns
325@add_globals_match [ assumption | % ]
326@add_functs_match [ assumption ]
327% try % #p %
328qed.
329
330lemma symbols_transf:
331 ∀A,B,V,init.∀prog_in : program A V.
332 ∀trans : ∀vars.A vars → B vars.
333 let prog_out ≝ transform_program … prog_in trans in
334 symbols … (globalenv … init prog_out) = symbols … (globalenv … init prog_in).
335#A #B #V #iV #p #tf whd
336lapply (transform_program_match … tf p)
337#MATCH
338>(symbols_eq … (globalenv_match … MATCH))
339[2: @iV |3: #v #w * // ]
340lapply (sym_eq ????)
341whd in match (prog_var_names ???); whd in match (prog_vars B ??);
342#E >(K ?? E) normalize nodelta %
343qed.
344
345
346lemma functions_transf:
347 ∀A,B,V,init.∀prog_in : program A V.
348 ∀trans : ∀vars.A vars → B vars.
349 let prog_out ≝ transform_program … prog_in trans in
350 ∀p.lookup_opt … p (functions … (globalenv … init prog_out)) =
351 option_map ?? (trans ?) (lookup_opt … p (functions … (globalenv … init prog_in))).
352#A #B #V #iV #p #tf #n
353lapply (transform_program_match … tf p)
354#MATCH
355whd in match globalenv; whd in match globalenv_allocmem;
356normalize nodelta
357lapply (functions_match … (globalenv_match … MATCH) n)
358[ @iV | @iV | #v #w * // ]
359lapply (sym_eq ????)
360whd in match (prog_var_names ???); whd in match (prog_vars B ??);
361#E >(K ?? E) normalize nodelta
362cases (lookup_opt ???) [2: #x ] normalize nodelta
363cases (lookup_opt ???) [2,4: #y ] normalize nodelta
364[ #EQ <EQ % |*: * % ]
365qed.
366
367lemma symbol_for_block_transf :
368 ∀A,B,V,init.∀prog_in : program A V.
369 ∀trans : ∀vars.A vars → B vars.
370 let prog_out ≝ transform_program … prog_in trans in
371 ∀bl.
372 symbol_for_block … (globalenv … init prog_out) bl =
373 symbol_for_block … (globalenv … init prog_in) bl.
374#A #B #V #iV #p #tf whd
375#bl
376whd in match symbol_for_block; normalize nodelta
377>(symbols_transf … tf) %
378qed.
379
380include alias "common/Pointers.ma".
381
382lemma fetch_function_transf :
383 ∀A,B,V,init.∀prog_in : program A V.
384 ∀trans : ∀vars.A vars → B vars.
385 let prog_out ≝ transform_program … prog_in trans in
386 ∀bl.
387 fetch_function … (globalenv … init prog_out) bl =
388 ! 〈i, f〉 ← fetch_function … (globalenv … init prog_in) bl ;
389 return 〈i, trans … f〉.
390#A #B #V #init #prog_in #trans #bl
391whd in match fetch_function; normalize nodelta
392>(symbol_for_block_transf A B V init prog_in trans)
393cases (symbol_for_block ???) [ % ] #id >m_return_bind >m_return_bind
394whd in match find_funct_ptr; normalize nodelta
395whd in match (block_region (pi1 ?? bl));
396cases (block_id (pi1 ?? bl)) [2,3: #p] normalize nodelta try %
397>(functions_transf A B V init prog_in trans p)
398cases (lookup_opt ???) //
399qed.
400
401lemma fetch_internal_function_transf :
402 ∀A,B.∀prog_in : program (λvars.fundef (A vars)) ℕ.
403 ∀trans : ∀vars.A vars → B vars.
404 let prog_out ≝ transform_program … prog_in (λvars.transf_fundef … (trans vars)) in
405 ∀bl.
406 fetch_internal_function … (globalenv_noinit … prog_out) bl =
407 ! 〈i, f〉 ← fetch_internal_function … (globalenv_noinit … prog_in) bl ;
408 return 〈i, trans … f〉.
409#A #B #prog #trans #bl
410 whd in match fetch_internal_function; normalize nodelta
411>(fetch_function_transf … prog)
412cases (fetch_function ???)
413[ * #id * #f % | #e % ]
414qed.
415
416include alias "utilities/binary/positive.ma".
417
418lemma pm_map_add_ind : ∀A.∀P : positive_map A → Prop.
419(∀m.(∀p.lookup_opt A p m = None ?) → P m) →
420(∀m,p,v.P m → lookup_opt A p m = None ? → P (insert A p v m)) →
421∀m.P m.
422#A #P #H1 #H2 #m lapply H2 lapply H1 lapply P -P elim m -m
423[ #P #H1 #_ @H1 #p % ]
424#o #l #r #IHl #IHr #P #H1 #H2
425@IHl #l'
426[ #empty_l' @IHr #r'
427  [ #empty_r' cases o [ @H1 * try #p normalize // ]
428    #v change with (P (insert ? one v (pm_node ? (None ?) ??)))
429    @H2 [ @H1 * try #p normalize // | % ]
430  ]
431]
432#p #v #H #G
433[ change with (P (insert ? (p1 p) v (pm_node ? ???)))
434| change with (P (insert ? (p0 p) v (pm_node ? ???)))
435] @H2 assumption
436qed.
437
438include alias "basics/logic.ma".
439include alias "common/PositiveMap.ma".
440
441lemma swap_neg : ∀A,B : Prop.(A → B) → ¬B → ¬A.
442#A #B #impl * #Bf % #At @Bf @impl @At qed-.
443
444definition b_graph_transform_program_props ≝
445  λsrc,dst : sem_graph_params.
446  λdata,prog_in.
447  λinit_regs : block → list register.
448  λf_lbls : block → label → option (list label).
449  λf_regs : block → label → option (list register).
450   let prog_out ≝ b_graph_transform_program src dst data prog_in in
451   let src_genv ≝ globalenv_noinit ? prog_in in
452   let dst_genv ≝ globalenv_noinit ? prog_out in
453  ∀bl,def_in.
454  find_funct_ptr … src_genv bl = return (Internal ? def_in) →
455  ∃init_data,def_out.
456  find_funct_ptr … dst_genv bl = return (Internal ? def_out) ∧
457  bind_new_instantiates … init_data (data … def_in) (init_regs bl) ∧
458  b_graph_translate_props src dst ? init_data (init_regs bl)
459    def_in def_out (f_lbls bl) (f_regs bl).
460 
461lemma make_b_graph_transform_program_props :
462 ∀src,dst:sem_graph_params.
463 ∀data : ∀globals.joint_closed_internal_function src globals →
464  bind_new register (b_graph_translate_data src dst globals).
465 ∀prog_in : joint_program src.
466 let prog_out ≝ b_graph_transform_program … data prog_in in
467 let src_genv ≝ globalenv_noinit ? prog_in in
468 let dst_genv ≝ globalenv_noinit ? prog_out in
469 ∃init_regs : block → list register.
470 ∃f_lbls : block → label → option (list label).
471 ∃f_regs : block → label → option (list register).
472 b_graph_transform_program_props src dst data prog_in init_regs f_lbls f_regs.
473#src #dst #data #prog_in
474whd in match b_graph_transform_program_props; normalize nodelta
475letin prog_out ≝ (b_graph_transform_program … data prog_in)
476letin src_genv ≝ (globalenv_noinit ? prog_in)
477letin dst_genv ≝ (globalenv_noinit ? prog_out)
478cut (∀p.lookup_opt ? p (functions ? dst_genv) =
479     option_map ?? (transf_fundef … (λf.b_graph_translate … (data … f) f))
480      (lookup_opt ? p (functions ? src_genv)))
481[ @functions_transf ]
482cases dst_genv #functs2 #nextf2 #symbols2 #H2
483cases src_genv #functs1 #nextf1 #symbols1 #H1
484lapply H2 lapply H1 lapply functs2
485@(pm_map_add_ind … functs1) -functs1 -functs2 #functs1
486[ #functs1_empty | #p #f #IH #p_not_in ]
487#functs2 #H1 #H2 #transf
488[ %{(λ_.[ ])} %{(λ_.λ_.None ?)} %{(λ_.λ_.None ?)}
489  #bl #def_in #ABS @⊥ lapply ABS -ABS
490  whd in match find_funct_ptr;
491  normalize nodelta
492  whd in match (block_region bl);
493  cases (block_id bl) normalize nodelta
494  [2,3: #p [2: >functs1_empty ]]
495  normalize #ABS destruct
496]
497cases (IH (pm_set … p (None ?) functs2) ???)
498[2: @hide_prf #b #G @(H1 b ?) @(swap_neg … G) -G @(eqb_elim b p)
499  [ #EQ destruct >lookup_opt_insert_hit #ABS destruct ]
500  #NEQ >(lookup_opt_insert_miss ? f b p … NEQ) #H @H
501|3: @hide_prf #b #G @(H2 b ?) @(swap_neg … G) -G @(eqb_elim b p)
502  [ #EQ destruct >lookup_opt_pm_set_hit #_ % ]
503  #NEQ >(lookup_opt_pm_set_miss … b p … NEQ) #H @H
504|4: #b @(eqb_elim b p)
505  [ #EQ destruct >lookup_opt_pm_set_hit >p_not_in % ]
506  #NEQ >(lookup_opt_pm_set_miss … b p … NEQ) >transf
507  >(lookup_opt_insert_miss ? f b p … NEQ) %
508]
509-IH cases f in H1 transf; -f #f #H1 #transf
510#init_regs * #f_lbls * #f_regs #props
511[ (* internal *)
512  letin upd ≝ (λA : Type[0].λf : block → A.
513    λid.λv,id'.
514    if eq_block id id' then v else f id')
515  cases (pi2 ?? (b_graph_translate … (data … f) f))
516  #loc_data * #loc_init_regs * #loc_f_lbls * #loc_f_regs *
517  #inst_loc_data #loc_props
518  letin bl ≝ (mk_block (neg p))
519  %{(upd … init_regs bl loc_init_regs)}
520  %{(upd … f_lbls bl loc_f_lbls)}
521  %{(upd … f_regs bl loc_f_regs)}
522| (* external, nothing changes *)
523  %{init_regs}
524  %{f_lbls}
525  %{f_regs}
526]
527* #p' #def_in
528whd in match find_funct_ptr; normalize nodelta
529whd in match (block_region (mk_block p'));
530cases p' -p' [2,3,5,6: #p' ] normalize nodelta
531[1,3,5,6: #ABS normalize in ABS; destruct]
532@(eqb_elim p' p) #pp' destruct
533[1,3: >lookup_opt_insert_hit whd in ⊢ (??%%→?); #EQ destruct(EQ)
534  %{loc_data} %
535  [2: % [ % ]
536    [ >transf >lookup_opt_insert_hit %
537    |*: >eq_block_b_b assumption
538    ]
539  |]
540|*: >(lookup_opt_insert_miss ???? functs1 … pp')
541  [ @eq_block_elim [ #EQ destruct cases (absurd ?? pp') % ] #_ normalize nodelta]
542  #EQ lapply (props (mk_block (neg p')) def_in EQ)
543  whd in match find_funct_ptr; normalize nodelta
544  >(lookup_opt_pm_set_miss … functs2 … pp') #H @H
545]
546qed.
547
548lemma b_graph_transform_program_fetch_internal_function :
549 ∀src,dst:sem_graph_params.
550 ∀data : ∀globals.joint_closed_internal_function src globals →
551  bind_new register (b_graph_translate_data src dst globals).
552 ∀prog_in : joint_program src.
553 ∀init_regs : block → list register.
554 ∀f_lbls : block → label → option (list label).
555 ∀f_regs : block → label → option (list register).
556 b_graph_transform_program_props … data prog_in init_regs f_lbls f_regs →
557 let prog_out ≝ b_graph_transform_program … data prog_in in
558 let src_genv ≝ globalenv_noinit ? prog_in in
559 let dst_genv ≝ globalenv_noinit ? prog_out in
560 ∀bl,id,def_in.
561 fetch_internal_function … src_genv bl = return 〈id, def_in〉 →
562 ∃init_data,def_out.
563 fetch_internal_function … dst_genv bl = return 〈id, def_out〉 ∧
564 bind_new_instantiates … init_data (data … def_in) (init_regs bl) ∧
565 b_graph_translate_props src dst ? init_data (init_regs bl)
566    def_in def_out (f_lbls bl) (f_regs bl).
567#src #dst #data #prog_in
568#init_regs #f_lbls #f_regs #props
569#bl #id #def_in
570#H @('bind_inversion H) * #id' * #def_in' -H
571normalize nodelta #H whd in ⊢ (??%%→?); #EQ destruct
572@('bind_inversion (opt_eq_from_res … H)) -H #id' #EQ1
573#H @('bind_inversion H) -H #def_in' #H
574whd in ⊢ (??%%→?); #EQ destruct
575cases (props … H)
576#loc_data * #def_out ** #H1 #H2 #H3
577%{loc_data} %{def_out}
578%{H3} %{H2}
579whd in match fetch_internal_function;
580whd in match fetch_function; normalize nodelta
581>symbol_for_block_transf >EQ1 >m_return_bind
582>H1 %
583qed.
584
585lemma b_graph_transform_program_fetch_statement :
586 ∀src,dst:sem_graph_params.
587 ∀data : ∀globals.joint_closed_internal_function src globals →
588  bind_new register (b_graph_translate_data src dst globals).
589 ∀prog_in : joint_program src.
590 ∀init_regs : block → list register.
591 ∀f_lbls : block → label → option (list label).
592 ∀f_regs : block → label → option (list register).
593 b_graph_transform_program_props … data prog_in init_regs f_lbls f_regs →
594 let prog_out ≝ b_graph_transform_program … data prog_in in
595 let src_genv ≝ globalenv_noinit ? prog_in in
596 let dst_genv ≝ globalenv_noinit ? prog_out in
597 ∀pc,id,def_in,s.
598 fetch_statement … src_genv pc = return 〈id, def_in, s〉 →
599 ∃init_data,def_out.
600 let bl ≝ pc_block pc in
601 fetch_internal_function … dst_genv bl = return 〈id, def_out〉 ∧
602 bind_new_instantiates … init_data (data … def_in) (init_regs bl) ∧
603 let l ≝ point_of_pc dst pc in
604 ∃lbls,regs.
605 f_lbls bl l = Some ? lbls ∧
606 f_regs bl l = Some ? regs ∧
607  match s with
608  [ sequential s' nxt ⇒
609    let block ≝
610      if eq_identifier … (joint_if_entry … def_in) l then
611        append_seq_list … (f_step … init_data l s') (added_prologue … init_data)
612      else
613        f_step … init_data l s' in
614    l ~❨block, l::lbls, regs❩~> nxt in joint_if_code … def_out
615  | final s' ⇒
616    l ~❨f_fin … init_data l s', l::lbls, regs❩~> it in joint_if_code … def_out
617  | FCOND abs _ _ _ ⇒ Ⓧabs
618  ].
619#src #dst #data #prog_in
620#init_regs #f_lbls #f_regs #props
621#pc #id #def_in #s
622#H @('bind_inversion H) * #id' #def_in' -H
623#EQfif
624#H @('bind_inversion H) -H #s
625#H lapply (opt_eq_from_res ???? H) -H
626#EQstmt_at whd in ⊢ (??%%→?); #EQ destruct
627cases (b_graph_transform_program_fetch_internal_function … props … EQfif)
628#a * #b ** #H1 #H2 #H3 %{a} %{b} %
629[ %{H1 H2} | @(multi_fetch_ok … H3 … EQstmt_at) ]
630qed.
Note: See TracBrowser for help on using the repository browser.