source: src/ERTL/ERTLtoERTLptrOK.ma @ 2785

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

Traces.ma repaired

File size: 56.0 KB
Line 
1
2(**************************************************************************)
3(*       ___                                                              *)
4(*      ||M||                                                             *)
5(*      ||A||       A project by Andrea Asperti                           *)
6(*      ||T||                                                             *)
7(*      ||I||       Developers:                                           *)
8(*      ||T||         The HELM team.                                      *)
9(*      ||A||         http://helm.cs.unibo.it                             *)
10(*      \   /                                                             *)
11(*       \ /        This file is distributed under the terms of the       *)
12(*        v         GNU General Public License Version 2                  *)
13(*                                                                        *)
14(**************************************************************************)
15
16include "ERTL/ERTLtoERTLptrUtils.ma".
17
18
19
20(*
21lemma get_internal_function_from_ident_ok :
22∀p : sem_params. ∀globals : list ident. ∀ge : genv_t (joint_function p globals).
23∀bl,f,fn. fetch_internal_function ? ge bl = return 〈f,fn〉 →
24get_internal_function_from_ident p globals ge f= return fn.
25#p #globals #ge #bl #f #fn #EQf
26@('bind_inversion EQf) * #f1 * #fn1 whd in match fetch_function;
27normalize nodelta #H lapply(opt_eq_from_res ???? H) -H #H @('bind_inversion H) -H
28#f2 #EQf2 #H @('bind_inversion H) -H #fn2 #EQfn2 whd in ⊢ (??%% → ??%% → ?);
29#EQ1 #EQ2 destruct whd in match get_internal_function_from_ident; normalize nodelta
30>(symbol_of_block_rev … EQf2) >m_return_bind
31cut(code_block_of_block bl = return bl)
32 [ whd in match code_block_of_block; normalize nodelta @match_reg_elim
33   [ >(pi2 ?? bl) #ABS destruct] elim bl #bl1 #EQ #prf % ] #EQbl >EQbl
34>m_return_bind >EQf %
35qed.
36*)
37
38
39
40 
41(*
42  whd in match sigma_frames_opt; whd in match m_list_map; normalize nodelta
43whd in match sigma_state in ⊢ (???????%%); normalize nodelta
44cases(st_frms … st) normalize nodelta [ @res_preserve_error1]
45* #loc_mem #bl #tl inversion(sigma_frames ????)
46[ #_ normalize nodelta @res_preserve_error1] * #loc_mem1 #bl1 #tl1
47whd in match sigma_frames; normalize nodelta inversion(sigma_frames_opt ????)
48[ #_ normalize nodelta #_ #ABS destruct] #l whd in match sigma_frames_opt;
49whd in match m_list_map; normalize nodelta whd in match (foldr ?????);
50normalize nodelta inversion(fetch_internal_function ???)
51[2: #e #_ whd in ⊢ (??%% → ?); #ABS destruct] * #id1 #fn1 #EQfn1 >m_return_bind
52normalize nodelta #H @('bind_inversion H) -H #l1
53change with (sigma_frames_opt ???? = ? → ?) #EQl1
54cut (sigma_frames prog f_lbls f_regs tl = l1)
55[whd in match sigma_frames; normalize nodelta >EQl1 %] #EQl11
56cases l [ whd in ⊢ (??%? → ?); #EQ destruct] #x #y
57whd in ⊢ (??%? → ?); #EQ1 #_ #EQ2 destruct @mfr_bind1
58[2: whd in match set_regs; whd in match set_frms; normalize nodelta
59    >EQl1 in ⊢ (???????%?); normalize nodelta
60cut(sigma_regs prog f_lbls (added_registers ERTL (prog_var_names … prog) fn1 (f_regs bl1))
61    〈loc_mem,\snd (regs … st)〉 =  〈map RegisterTag beval beval loc_mem
62       (λbv:beval.sigma_beval prog f_lbls bv)∖
63         added_registers ERTL (prog_var_names … prog) fn1 (f_regs bl1),
64   \snd  (sigma_regs prog f_lbls restr (regs ERTLptr_semantics st))〉)
65[ whd in match sigma_regs; normalize nodelta @eq_f2 [ %] cases(regs ? st)
66     #x #y %] #EQ <EQ -EQ
67change with (sigma_state ???? (set_regs ERTL_semantics 〈loc_mem,\snd (regs … st)〉
68            (set_frms ERTL_semantics tl st))) in ⊢ (???????(??%)?);
69@pop_ra_ok |
70| * #st1 #pc1 @if_elim [2: #_ @res_preserve_error1] normalize nodelta
71@eq_block_elim [2: #_ *] #EQbl1 * @if_elim
72[2: >EQbl1 @eq_block_elim [#_ *] * #H @⊥ @H <pc_block_eq [%] %
73    cases bl1 in EQbl1 EQfn1; #p1 #p2 #EQ destruct lapply p2
74    whd in match sigma_stored_pc; normalize nodelta cases(sigma_pc_opt ???)
75    normalize nodelta [2: #pc2] #p2 [#_ #EQ destruct]
76    >fetch_internal_function_no_zero [2: %] #EQ destruct
77] @eq_block_elim [2: #_ *] #EQbl11 * @mfr_return_eq1 normalize nodelta
78  cases bl1 in EQbl11 EQfn1; #p1 #p2 #EQ destruct
79  lapply p2 cases(pc_block pc1) #p11 #p22 #e #EQfn1 >EQfn1
80  %
81]
82qed.
83*)
84
85
86definition ERTLptrStatusSimulation :
87∀ prog : ertl_program.
88let trans_prog ≝ ertl_to_ertlptr prog in
89∀stack_sizes.∀ f_lbls : lbl_funct. ∀ f_regs : regs_funct.
90∀f_bl_r.
91b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
92     translate_data prog f_bl_r f_lbls f_regs →
93status_rel (ERTL_status prog stack_sizes) (ERTLptr_status trans_prog stack_sizes) ≝
94λprog,stack_sizes,f_lbls,f_regs,f_lb_r,good.
95  let trans_prog ≝ ertl_to_ertlptr prog in
96    mk_status_rel ??
97    (* sem_rel ≝ *) (λs1:ERTL_status prog stack_sizes
98       .λs2:ERTLptr_status trans_prog stack_sizes
99        .s1=sigma_state_pc prog f_lbls f_regs s2)
100    (* call_rel ≝ *) 
101          (λs1:Σs:ERTL_status prog stack_sizes
102               .as_classifier (ERTL_status prog stack_sizes) s cl_call
103       .λs2:Σs:ERTLptr_status trans_prog stack_sizes
104                .as_classifier (ERTLptr_status trans_prog stack_sizes) s cl_call
105        .
106        pc (mk_prog_params ERTL_semantics prog stack_sizes) s1
107         =sigma_stored_pc prog f_lbls
108          (pc
109           (mk_prog_params ERTLptr_semantics (ertl_to_ertlptr prog) stack_sizes)
110           s2))
111    (* sim_final ≝ *) ?.
112cases daemon
113qed.
114
115include "joint/semantics_blocks.ma".
116
117
118
119lemma as_label_ok : ∀ prog : ertl_program.
120let trans_prog ≝ ertl_to_ertlptr prog in
121∀ f_lbls,f_regs,stack_sizes.
122∀f_bl_r.
123b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
124     translate_data prog f_bl_r f_lbls f_regs →
125∀st,fn,id,stmt.
126fetch_statement ERTL_semantics (prog_var_names … prog)
127      (globalenv_noinit … prog) (pc … (sigma_state_pc prog f_lbls f_regs st)) =
128               return 〈id,fn,stmt〉 →
129as_label (ERTLptr_status trans_prog stack_sizes) st = as_label
130(ERTL_status prog stack_sizes) (sigma_state_pc prog f_lbls f_regs st).
131#prog #f_lbls #f_regs #stack_size #f_lb_r #good #st #fn #id #stmt #EQfetch
132whd in match as_label; normalize nodelta change with (pc ? ?) in ⊢ (??(??%)(??%));
133cases(b_graph_transform_program_fetch_statement … good … EQfetch)
134#init_data * #t_fn ** #EQt_fn whd in ⊢ (% → ?); cases(f_lb_r ?)
135normalize nodelta [2: #r #tl *] #EQinit destruct(EQinit) * #l_labs * #l_regs **
136#_ #_ cases stmt in EQfetch;
137[ * [ #c | * [ #c_id | #c_ptr ] #c_arg #c_dest | #reg #lbl | #s ] #nxt | #fin | * ]
138#EQfetch normalize nodelta * #bl * [1,2,3,4,5: >if_merge_right in ⊢ (% → ?); try %]
139whd in ⊢ (%→?); cases l_regs normalize nodelta [2,4,5,8,10,12: [3: *] #x #y *]
140[1,2,4,5,6:| #r #tl whd in ⊢ (% → ?); cases tl -tl normalize nodelta [2: #r1 #tl1 *]]
141#EQ destruct(EQ)
142[1,2,3,4,6: * #pre_l * #mid1 * #mid2 * #post_l *** #EQmid1
143            whd in match map_eval in ⊢ (% → ?); normalize nodelta
144            whd in ⊢ (?????%?? → ?);
145            whd in match (seq_list_in_code ???????) in ⊢ (%→?); *
146           [1,2,3,4: #EQ1 #EQ2 destruct(EQ1 EQ2) whd in EQmid1 : (???%);
147                     destruct(EQmid1) * #nxt1 * #EQt_stmt #_ #_
148           |        * #lbl1 * #rest ** #EQ destruct(EQ) * #nxt1 *
149                    #EQt_stmt #_ #_ #_ #_
150           ]
151|           * #pre_l * #mid ** #EQmid whd in ⊢ (% → ?); * #EQ destruct(EQ)
152            whd in EQmid : (???%); destruct(EQmid) #EQ destruct(EQ)
153            whd in ⊢ (% → ?); #EQt_stmt
154]
155whd in ⊢ (??%%); >EQfetch normalize nodelta whd in match fetch_statement;
156normalize nodelta >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQt_fn;
157#EQt_fn >EQt_fn >m_return_bind >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQt_stmt;
158#EQt_stmt >EQt_stmt %
159qed.
160
161include alias "basics/lists/listb.ma".
162
163lemma eval_seq_no_call_ok :
164 ∀prog.
165 let trans_prog ≝ ertl_to_ertlptr prog in
166 ∀ f_lbls,f_regs,stack_sizes.
167 ∀f_bl_r.
168 b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
169     translate_data prog f_bl_r f_lbls f_regs →
170 ∀st2 : state_pc ERTLptr_semantics.
171 let st1 ≝ sigma_state_pc prog f_lbls f_regs st2 in
172 ∀st1' : state_pc ERTL_semantics.
173 ∀f,fn,stmt,nxt.
174   fetch_statement ERTL_semantics
175     (prog_var_names (joint_function ERTL_semantics) ℕ prog)
176    (ev_genv (mk_prog_params ERTL_semantics prog stack_sizes))
177    (pc … st1) =
178      return 〈f, fn,  sequential … (step_seq ERTL … stmt) nxt〉 →
179   eval_state ERTL_semantics
180   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
181   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
182   st1 =
183    return st1' →
184 ∃st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
185 ∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes)
186  st2
187  st2'.
188 if taaf_non_empty … taf then True else
189(¬as_costed (ERTL_status prog stack_sizes) st1 ∨
190 ¬as_costed (ERTL_status prog stack_sizes) st1').
191#prog #f_lbls #f_regs #stack_size #f_bl_r #good #st2 #st1' #f #fn #stmt #nxt
192#EQfetch whd in match eval_state; normalize nodelta >EQfetch >m_return_bind
193#H @('bind_inversion H)-H #st_no_pc
194whd in match eval_statement_no_pc; normalize nodelta #EQnopc
195whd in match eval_statement_advance; normalize nodelta
196whd in match set_no_pc; whd in match next; whd in match set_pc;
197normalize nodelta whd in ⊢ (??%% → ?); #EQ destruct(EQ) lapply EQfetch
198>(fetch_stmt_ok_sigma_pc_ok … EQfetch) #EQfetch'
199lapply(fetch_statement_inv … EQfetch') * #EQfn #EQstmt
200cases(b_graph_transform_program_fetch_internal_function … good … EQfn)
201#init_data * #t_fn1 ** #EQt_fn1 whd in ⊢ (% → ?); cases (f_bl_r ?) normalize nodelta
202[2: #r #tl *] #EQ destruct(EQ) * #_ #_ #_ #_ #_ #_ #_ #fresh_regs #_ #_ #stmt_at_spec
203cases(stmt_at_spec … EQstmt) #labs * #regs ** #EQlabs #EQregs normalize nodelta
204>if_merge_right in ⊢ (% → ?); [2: %] whd in ⊢ (% → ?); * #bl * whd in ⊢ (% → ?);
205cases regs in EQregs; -regs [2: #x #y #_ *] #EQregs normalize nodelta #EQ destruct(EQ)
206#eval_spec
207lapply(err_eq_from_io ????? EQnopc) -EQnopc >(fetch_stmt_ok_sigma_state_ok … EQfetch)
208#EQnopc
209cases(eval_seq_no_pc_no_call_ok prog f_lbls f_regs ????????? EQnopc)
210[2: @(t_fn1)
211| #stnopc'' * #EQstnopc'' #EQsem %
212  [ % [@stnopc'' | @(succ_pc ERTL_semantics (pc … st2) nxt) | @(last_pop … st2)]]
213  %
214  [ whd in match sigma_state_pc; normalize nodelta @('bind_inversion EQfetch)
215    * #f1 #fn1 >(fetch_stmt_ok_sigma_pc_ok … EQfetch) #EQfn1
216    #H @('bind_inversion H) -H #stmt1 #_ whd in ⊢ (??%% → ?); #EQ destruct(EQ)
217    >EQfn1 normalize nodelta >EQsem % ]
218  % [ @(produce_trace_any_any_free_coerced) [ @f | @t_fn1 |6: @eval_spec ||| @EQt_fn1]
219    whd in match repeat_eval_seq_no_pc; normalize nodelta whd in ⊢ (??%?);
220    >EQstnopc'' %] @if_elim [#_ @I] #_ %1 % whd in match as_costed;
221    normalize nodelta * #H @H whd in ⊢ (??%?); >EQfetch %
222| #lbl whd in match code_has_label; whd in match code_has_point; normalize nodelta
223  inversion(stmt_at ????) [#_ *] #stmt1 #EQstmt1 #_ cases(stmt_at_spec … EQstmt1)
224  #labels * #registers ** #_ #EQregisters #_ -labels >EQregisters whd
225  cases(excluded_middle_list ? (λreg.bool_to_Prop(¬(reg∈registers))) ?
226         (get_used_registers_from_seq … (functs ERTL) stmt))
227  [3: #a cases(¬a∈registers) // |1: #H assumption] #H @⊥
228  cases(Exists_All … H (regs_are_in_univers … (pi2 ?? fn) … EQstmt))
229  #reg ** #H1 #H2 @H1 -H1 @notb_Prop % #H1 lapply(fresh_regs … lbl) >EQregisters
230  whd in ⊢ (% → ?); #H3 lapply(All_memb … H3 H1) ** #H4 #_ @H4 assumption
231]
232qed.
233
234lemma eval_goto_ok :
235 ∀prog : ertl_program.
236 let trans_prog ≝ ertl_to_ertlptr prog in
237∀ f_lbls,f_regs,stack_sizes.
238 ∀f_bl_r.
239 b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
240     translate_data prog f_bl_r f_lbls f_regs →
241 ∀st2.
242 let st1 ≝ (sigma_state_pc prog f_lbls f_regs st2) in
243 ∀st1',f,fn,nxt.
244   fetch_statement ERTL_semantics …
245    (globalenv_noinit ? prog) (pc … st1) =
246      return 〈f, fn,  final … (GOTO ERTL … nxt)〉 →
247   eval_state ERTL_semantics
248   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
249   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
250   st1 =
251    return st1' →
252    ∃ st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
253 ∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes)
254  st2
255  st2'.
256  bool_to_Prop (taaf_non_empty … taf).
257#prog #f_lbls #f_regs #stack_size #f_bl_r #good #st2 #st1' #f #fn #nxt #EQfetch
258whd in match eval_state; normalize nodelta >EQfetch >m_return_bind
259whd in match eval_statement_no_pc; normalize nodelta
260>m_return_bind whd in match eval_statement_advance; whd in match set_no_pc;
261whd in match goto; normalize nodelta #H lapply(err_eq_from_io ????? H) -H
262#H @('bind_inversion H) -H #new_pc lapply(fetch_statement_inv … EQfetch) *
263#EQfn #_ >(pc_of_label_eq … EQfn) whd in ⊢ (??%% → ??%% → ?);
264#EQ1 #EQ2 destruct(EQ1 EQ2)
265% [ % [ @st2 | @(mk_program_counter (pc_block (pc … st2))
266                         (offset_of_point ERTL_semantics nxt)) | @(last_pop … st2)]]
267% [ >(fetch_stmt_ok_sigma_state_ok … EQfetch) >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
268    >(fetch_stmt_ok_sigma_last_pop_ok … EQfetch) whd in match sigma_state_pc;
269    normalize nodelta >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQfn; #EQfn
270    >EQfn %]
271cases(b_graph_transform_program_fetch_statement … good … EQfetch)
272#init_data * #t_fn1 ** #EQt_fn1 whd in ⊢ (% → ?); cases (f_bl_r ?) normalize nodelta
273[2: #r #tl *] #EQ destruct(EQ) * #labs **
274[2: #hd #tl ** #_ #_ ** #pre #inst * whd in ⊢ (%→?); *] ** #EQlabs #EQf_regs
275whd in match translate_fin_step; normalize nodelta * #bl *
276whd in ⊢ (% → ?); #EQ destruct(EQ) **
277[2: #lb #tl * #mid ** #EQmid whd in ⊢ (% → ?); * #ABS destruct(ABS)] * #mid **
278whd in ⊢ (???% → ?); #EQ destruct(EQ) * #_ #_ change with (stmt_at ???? = ? → ?)
279#EQstmt >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQt_fn1; #EQt_fn1
280>(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQstmt; #EQstmt
281%{(taaf_step … (taa_base …) …)}
282[ whd in match as_classifier; normalize nodelta whd in ⊢ (??%?);
283  whd in match fetch_statement; normalize nodelta 
284  >EQt_fn1 >m_return_bind >EQstmt %
285| whd whd in match eval_state; normalize nodelta whd in match fetch_statement;
286  normalize nodelta  >EQt_fn1 >m_return_bind >EQstmt >m_return_bind
287  whd in match eval_statement_no_pc; normalize nodelta >m_return_bind
288  whd in match eval_statement_advance; normalize nodelta
289  whd in match goto; normalize nodelta >(pc_of_label_eq … EQt_fn1) %
290] @I
291qed.
292
293
294
295(*
296lemma list_elim_on_last : ∀A : Type[0].∀ P : (list A) → Prop. ∀ l.
297                 P ([ ]) → (∀pre,last. P (pre@[last])) → P l.
298#A #P #l #H1 #H2 cut(∀A.∀l : list A.l = [ ] ∨ ∃pre,last. l = pre@[last])
299[ #A #l elim l [ %1 % | #a #tl * [ #EQ destruct %2 %{([ ])} %{a} %]
300* #l1 * #a1 #EQ destruct %2 %{(a::l1)} %{a1} %]] #APP1
301lapply(APP1 … l) * [ #EQ >EQ assumption]
302 * #pre * #last #EQ >EQ @H2
303qed.*)
304
305
306
307lemma eval_return_ok :
308∀prog : ertl_program.
309let trans_prog ≝ ertl_to_ertlptr prog in
310∀ f_lbls,f_regs,stack_sizes.
311 ∀f_bl_r.
312 ∀ good :b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
313     translate_data prog f_bl_r f_lbls f_regs.
314∀st2, st1',f,fn.
315 let st1 ≝ sigma_state_pc prog f_lbls f_regs st2 in
316 fetch_statement ERTL_semantics …
317  (globalenv_noinit ? prog) (pc … st1) =
318    return 〈f, fn,  final … (RETURN ERTL … )〉 →
319 eval_state ERTL_semantics
320   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
321   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
322   st1 =
323  return st1' →
324joint_classify (mk_prog_params ERTLptr_semantics trans_prog stack_sizes)
325  st2 = cl_return ∧
326∃st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
327∃st2_after_ret.
328∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes) (* always empty in this case *)
329st2_after_ret
330st2'.
331(if taaf_non_empty … taf then
332  ¬as_costed (ERTLptr_status trans_prog stack_sizes)
333    st2_after_ret
334 else True) ∧
335eval_state … (ev_genv …  (mk_prog_params ERTLptr_semantics trans_prog stack_sizes)) st2 =
336return st2_after_ret ∧
337ret_rel ?? (ERTLptrStatusSimulation prog stack_sizes ??? good) st1' st2_after_ret.
338#prog #f_lbls #f_regs #stack_size #f_bl_r #good #st2 #st1' #f #fn #EQfetch
339whd in match eval_state; normalize nodelta >EQfetch >m_return_bind
340#H @('bind_inversion H) -H #st1_tmp whd in ⊢ (??%%→?); #EQ destruct
341whd in match set_no_pc in ⊢ (%→?); whd in match eval_statement_advance in ⊢ (%→?);
342whd in match eval_return; normalize nodelta #H lapply(err_eq_from_io ????? H) -H
343#H @('bind_inversion H) -H * #n_st #n_pc change with (ertl_pop_frame ? = ? → ?)
344>(fetch_stmt_ok_sigma_state_ok … EQfetch) #EQpop_frame
345cases(pop_frame_ok ?????? EQpop_frame) * #t_n_st #t_n_pc * #EQt_pop_frame
346normalize nodelta
347inversion (fetch_internal_function ??) normalize nodelta
348[ * #id1 #fn1 | #err ] normalize nodelta #EQfetch_fn1 #EQ destruct(EQ)
349#H @('bind_inversion H) -H #next_of_n_pc
350[2: >next_of_call_pc_error [2: % %] whd in ⊢ (???% → ?); #EQ destruct(EQ)]
351#EQnext_of_n_pc cases(next_of_call_pc_ok … good … EQnext_of_n_pc)
352#pc1 * #EQpc1 cut(pc1 = t_n_pc)
353[ @(sigma_stored_pc_inj prog f_lbls)
354  lapply EQnext_of_n_pc; <EQpc1 whd in match sigma_stored_pc; normalize nodelta
355  inversion(sigma_pc_opt ???) [1,3: #_ >next_of_call_pc_error [2,4: % %]
356  whd in ⊢ (???% → ?); #EQ destruct| #x #_ #_ % #EQ destruct] #x #EQx #_
357  lapply EQnext_of_n_pc whd in match sigma_stored_pc; normalize nodelta
358  inversion (sigma_pc_opt ???) [ #_ >next_of_call_pc_error [2: % %]
359  whd in ⊢ (???% → ?); #EQ destruct] #y #EQy #_ lapply EQpc1
360  whd in match sigma_stored_pc; normalize nodelta >EQx >EQy normalize nodelta
361  #EQ destruct %
362] #EQ destruct(EQ) #EQnxt whd in match next; whd in match set_last_pop;
363whd in match set_pc; normalize nodelta whd in ⊢ (??%% → ?); #EQ destruct(EQ)
364cases(b_graph_transform_program_fetch_statement … good … EQfetch)
365#init_data * #t_fn1 ** #EQt_fn1 whd in ⊢ (% → ?); cases (f_bl_r ?) normalize nodelta
366[2: #r #tl *] #EQ destruct(EQ) * #labs **
367[2: #hd #tl ** #_ #_ * #ibl * whd in ⊢ (%→?); *] ** #EQlabs #EQf_regs
368whd in match translate_fin_step; normalize nodelta * #bl *
369whd in ⊢ (% → ?); #EQ destruct(EQ) **
370[2: #lb #tl * #mid ** #EQmid whd in ⊢ (% → ?); * #ABS destruct(ABS)] * #mid **
371whd in ⊢ (???% → ?); #EQ destruct(EQ) * #_ #_ change with (stmt_at ???? = ? → ?)
372#EQstmt %
373[ whd in match joint_classify; normalize nodelta whd in match fetch_statement;
374  normalize nodelta <(fetch_stmt_ok_sigma_pc_ok … EQfetch) >EQt_fn1 >m_return_bind
375  >EQstmt %
376| %
377    [ %
378        [ @t_n_st
379        | @(succ_pc ERTL_semantics (sigma_stored_pc prog f_lbls t_n_pc) next_of_n_pc)
380        | @t_n_pc]
381    ]
382  % 
383    [ whd in match sigma_state_pc; normalize nodelta
384      lapply(next_of_call_pc_inv … EQnext_of_n_pc) * #id2 * #fn2 * #c_id * #c_arg
385      * #c_dest #EQfetch1 whd in match (succ_pc ???);
386      >(fetch_stmt_ok_sigma_pc_block_ok … EQfetch1) >EQfetch_fn1
387      normalize nodelta %
388    ]
389  %
390    [ %
391        [ @t_n_st
392        | @(succ_pc ERTL_semantics (sigma_stored_pc prog f_lbls t_n_pc) next_of_n_pc)
393        | @t_n_pc]
394    ]
395  %{(taaf_base … )} normalize nodelta % [% [@I]]
396    [ whd in match fetch_statement; normalize nodelta <(fetch_stmt_ok_sigma_pc_ok … EQfetch)
397      >EQt_fn1 >m_return_bind >EQstmt >m_return_bind whd in match eval_statement_no_pc;
398      normalize nodelta >m_return_bind whd in match eval_statement_advance;
399      whd in match eval_return; normalize nodelta 
400      change with (ertl_pop_frame ?) in match (pop_frame ????????);
401      >EQt_pop_frame >m_return_bind >EQnxt >m_return_bind whd in match next;
402      whd in match set_pc; whd in match set_last_pop; whd in match succ_pc;
403      normalize nodelta lapply(next_of_call_pc_inv … EQnext_of_n_pc)
404      * #id2 * #fn2 * #c_id * #c_arg * #c_dest #EQfetch1 whd in match (succ_pc ???);
405      >(fetch_stmt_ok_sigma_pc_block_ok … EQfetch1) %
406    | whd * #s1_pre #s1_call
407      cases (joint_classify_call … s1_call)
408      * #calling_i #calling * #call_spec * #arg * #dest * #nxt' #EQfetch_call
409      * #s2_pre #s2_call whd in ⊢ (% → ?); >EQfetch_call normalize nodelta
410      * #s1_pre_prf #EQpc_s2_pre whd in ⊢ (% → ?); #EQ1
411      >EQ1 in EQfetch_call; #EQfetch_call
412      cases(fetch_call_commute … good … EQfetch_call) #calling' * #pc1 *
413      #EQ1 cut(pc … s2_pre = pc1)
414      [ @(sigma_stored_pc_inj prog f_lbls) lapply(EQfetch_call)
415        whd in match sigma_stored_pc; normalize nodelta inversion(sigma_pc_opt ???)
416        [1,3: #_ >fetch_statement_no_zero [2,4: %] #EQ destruct(EQ)| #x #_ #_ % #EQ destruct]
417        #pc2 #EQpc2 #_ lapply EQ1 whd in match sigma_stored_pc;
418        normalize nodelta >EQpc2 normalize nodelta cases(sigma_pc_opt ???)
419        [2: #x normalize nodelta #EQ >EQ %] normalize nodelta #EQ <EQ in EQpc2;
420        #EQ1 lapply EQfetch_call >fetch_statement_no_zero [ #ABS destruct(ABS)]
421        whd in match sigma_stored_pc; normalize nodelta >EQ1 %
422      ] #EQ2 destruct(EQ2) #EQt_fetch_call whd >EQt_fetch_call normalize nodelta %
423       [ >EQ1 in s1_pre_prf; #EQ @(sigma_stored_pc_inj prog f_lbls)
424        lapply EQnext_of_n_pc whd in match sigma_stored_pc; normalize nodelta
425        inversion(sigma_pc_opt ???) [1,3: #_ >next_of_call_pc_error [2,4: % %]
426        whd in ⊢ (???% → ?); #EQ destruct] #pc1 #EQpc1 #_ [ % #EQ destruct]
427        lapply EQ whd in match sigma_stored_pc; normalize nodelta
428        >EQpc1 normalize nodelta inversion(sigma_pc_opt ???)
429        [2: #pc2 #_ normalize nodelta #EQ >EQ %] normalize nodelta
430        #ABS #ABS1 lapply EQnext_of_n_pc whd in match sigma_stored_pc;
431        normalize nodelta >EQpc1 >ABS1 normalize nodelta
432        >next_of_call_pc_error [2: % %] whd in ⊢ (???% → ?); #EQ destruct
433       | whd in match succ_pc; normalize nodelta
434        change with next_of_n_pc in match (point_of_succ ???);
435        change with nxt' in match (point_of_succ ???);
436        lapply EQpc_s2_pre whd in match succ_pc; normalize nodelta
437        change with next_of_n_pc in match (point_of_succ ???);
438        change with nxt' in match (point_of_succ ???); #EQ >EQ
439        cut(pc_block (pc … s1_pre) = pc_block (pc … s2_pre))
440        [2: #EQ >EQ %] >EQ1 <(pc_block_eq prog f_lbls …) [%]
441        lapply EQfetch_call whd in match sigma_stored_pc; normalize nodelta
442        cases(sigma_pc_opt ???) [ >fetch_statement_no_zero [2: %] #EQ destruct]
443        #x #_ % #EQ destruct
444       ]
445     ]
446]
447qed.
448
449
450
451lemma eval_cond_ok :
452∀prog.
453let trans_prog ≝ ertl_to_ertlptr prog in
454∀ f_lbls,f_regs,stack_sizes.
455 ∀f_bl_r.
456 ∀ good :b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
457     translate_data prog f_bl_r f_lbls f_regs.
458∀st2,st1',f,fn,a,ltrue,lfalse.
459let st1 ≝ sigma_state_pc prog f_lbls f_regs st2 in
460 fetch_statement ERTL_semantics …
461  (globalenv_noinit ? prog) (pc … st1) =
462    return 〈f, fn,  sequential … (COND ERTL … a ltrue) lfalse〉 →
463 eval_state ERTL_semantics
464   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
465   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
466   st1 = return st1' →
467as_costed (ERTL_status prog stack_sizes) st1' →
468∃ st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
469∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes)
470st2 st2'.
471bool_to_Prop (taaf_non_empty … taf).
472#prog #f_lbls #f_regs #stack_size #f_bl_r #good #st2 #st1' #f #fn #a #ltrue #lfalse
473#EQfetch whd in match eval_state; normalize nodelta >EQfetch >m_return_bind
474whd in match eval_statement_no_pc; normalize nodelta >m_return_bind
475whd in match eval_statement_advance; normalize nodelta
476change with (ps_reg_retrieve ??) in match (acca_retrieve ?????);
477#H lapply(err_eq_from_io ????? H) -H #H @('bind_inversion H) -H
478#bv >(fetch_stmt_ok_sigma_state_ok … EQfetch) in ⊢ (% → ?); whd in match set_no_pc;
479normalize nodelta #EQbv #H @('bind_inversion H) -H * #EQbool normalize nodelta
480 lapply(fetch_statement_inv … EQfetch) * #EQfn #_
481[ whd in match goto; normalize nodelta >(pc_of_label_eq ??????? EQfn) >m_return_bind
482| whd in match next; normalize nodelta
483] whd in match set_pc; normalize nodelta
484>(fetch_stmt_ok_sigma_state_ok … EQfetch) whd in match set_no_pc; normalize nodelta
485>(fetch_stmt_ok_sigma_pc_ok … EQfetch) >(fetch_stmt_ok_sigma_last_pop_ok … EQfetch)
486whd in ⊢ (??%% → ?); #EQ destruct #n_cost
487%{(mk_state_pc ? (st_no_pc … st2)
488                 (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) ?)
489                 (last_pop … st2))} [ @ltrue |3: @lfalse]
490% [1,3: whd in match sigma_state_pc; normalize nodelta
491        >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQfn; #EQfn >EQfn %]
492cases(b_graph_transform_program_fetch_statement … good … EQfetch)
493#init_data * #t_fn1 ** #EQt_fn1 whd in ⊢ (% → ?); cases (f_bl_r ?) normalize nodelta
494[2,4: #r #tl *] #EQ destruct(EQ) >if_merge_right in ⊢ (% → ?); [2,4: %] * #labs **
495[2,4: #hd #tl ** #_ #_ *** #pre #inst #post * whd in ⊢ (%→?); *] ** #EQlabs #EQf_regs
496whd in match translate_step; normalize nodelta * #bl *
497whd in ⊢ (% → ?); #EQ destruct(EQ) whd in ⊢ (% → ?); * #l1 * #mid1 * #mid2 * #l2
498*** #EQmid1 whd in ⊢ (% → ?); * #EQ1 #EQ2 destruct(EQ1 EQ2) whd in ⊢ (% → ?); *
499#nxt1 * #EQcond #EQ destruct(EQ) whd in ⊢ (% → ?); * #EQ1 #EQ2 destruct(EQ1 EQ2)
500whd in EQmid1 : (??%%); destruct(EQmid1)
501%{(taaf_step_jump … (taa_base …) …) I}
502[2,5: whd whd in ⊢ (??%?); whd in match fetch_statement; normalize nodelta 
503      <(fetch_stmt_ok_sigma_pc_ok … EQfetch) >EQt_fn1 >m_return_bind
504      >EQcond %
505|3,6: whd whd in match eval_state; normalize nodelta whd in match eval_statement_no_pc;
506      normalize nodelta whd in match fetch_statement; normalize nodelta
507      <(fetch_stmt_ok_sigma_pc_ok … EQfetch) >EQt_fn1 >m_return_bind
508      >EQcond >m_return_bind normalize nodelta >m_return_bind
509      whd in match eval_statement_advance; normalize nodelta
510      change with (ps_reg_retrieve ??) in match (acca_retrieve ?????);
511      cases(ps_reg_retrieve_ok … EQbv) #bv1 * #EQbv1 #EQsem >EQbv1
512      >m_return_bind >EQsem in EQbool; #EQbool cases(bool_of_beval_ok … EQbool)
513      #bool1 * #EQbool1 #EQ destruct(EQ) >EQbool1 >m_return_bind normalize nodelta
514      >(fetch_stmt_ok_sigma_pc_ok … EQfetch) [2: %] whd in match goto;
515      normalize nodelta >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQt_fn1; #EQt_fn1
516      >(pc_of_label_eq … EQt_fn1) >m_return_bind %
517|*: lapply n_cost whd in match as_costed; normalize nodelta
518    [ cut((mk_state_pc ERTL_semantics
519   (sigma_state prog f_lbls f_regs
520    (added_registers ERTL (prog_var_names (joint_function ERTL) ℕ prog) fn
521     (f_regs (pc_block (pc ERTLptr_semantics st2)))) st2)
522   (pc_of_point ERTL_semantics (pc_block (pc ERTLptr_semantics st2)) ltrue)
523   (sigma_stored_pc prog f_lbls (last_pop ERTLptr_semantics st2))) =
524   sigma_state_pc prog f_lbls f_regs (mk_state_pc ERTLptr_semantics st2
525    (pc_of_point ERTLptr_semantics (pc_block (pc ERTLptr_semantics st2)) ltrue)
526    (last_pop ERTLptr_semantics st2))) [ whd in match sigma_state_pc; normalize  nodelta
527    >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQfn; #EQfn >EQfn %]
528    #EQ >EQ >(as_label_ok … good … (mk_state_pc ERTLptr_semantics st2
529    (pc_of_point ERTLptr_semantics (pc_block (pc ERTLptr_semantics st2)) ltrue)
530    (last_pop ERTLptr_semantics st2))) [#H @H] cases daemon (*needs lemma see below *)
531    | cut((mk_state_pc ERTL_semantics
532   (sigma_state prog f_lbls f_regs
533    (added_registers ERTL (prog_var_names (joint_function ERTL) ℕ prog) fn
534     (f_regs (pc_block (pc ERTLptr_semantics st2)))) st2)
535   (succ_pc ERTL_semantics (pc ERTLptr_semantics st2)
536    (point_of_succ ERTLptr_semantics
537     (point_of_pc ERTLptr_semantics
538      (pc ERTL_semantics (sigma_state_pc prog f_lbls f_regs st2))) nxt1))
539   (sigma_stored_pc prog f_lbls (last_pop ERTLptr_semantics st2))) =
540   sigma_state_pc prog f_lbls f_regs (mk_state_pc ERTLptr_semantics st2
541    (pc_of_point ERTLptr_semantics (pc_block (pc ERTLptr_semantics st2))
542     (point_of_succ ERTLptr_semantics
543      (point_of_pc ERTLptr_semantics
544       (pc ERTL_semantics (sigma_state_pc prog f_lbls f_regs st2))) nxt1))
545    (last_pop ERTLptr_semantics st2))) [ whd in match sigma_state_pc; normalize  nodelta
546    >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in EQfn; #EQfn >EQfn %] #EQ >EQ
547    >(as_label_ok … good … (mk_state_pc ERTLptr_semantics st2
548    (pc_of_point ERTLptr_semantics (pc_block (pc ERTLptr_semantics st2))
549     (point_of_succ ERTLptr_semantics
550      (point_of_pc ERTLptr_semantics
551       (pc ERTL_semantics (sigma_state_pc prog f_lbls f_regs st2))) nxt1))
552    (last_pop ERTLptr_semantics st2))) [#H @H] cases daemon (*needs lemma see below ! *)
553]
554qed.
555     
556lemma eval_cost_ok :
557∀prog.
558let trans_prog ≝ ertl_to_ertlptr prog in
559∀ f_lbls,f_regs,stack_sizes.
560 ∀f_bl_r.
561 ∀ good :b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
562     translate_data prog f_bl_r f_lbls f_regs.
563∀st2,st1',f,fn,c,nxt.
564let st1 ≝ sigma_state_pc prog f_lbls f_regs st2 in
565 fetch_statement ERTL_semantics …
566  (globalenv_noinit ? prog) (pc … st1) =
567    return 〈f, fn,  sequential … (COST_LABEL ERTL … c) nxt〉 →
568 eval_state ERTL_semantics
569   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
570   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
571   st1 = return st1' →
572∃ st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
573∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes)
574st2 st2'.
575bool_to_Prop (taaf_non_empty … taf).
576#prog #f_lbls #f_regs #stack_Size #f_bl_r #good #st2 #st1' #f #fn #c #nxt
577#EQfetch whd in match eval_state; normalize nodelta >EQfetch >m_return_bind
578whd in match eval_statement_no_pc; normalize nodelta >m_return_bind
579whd in match eval_statement_advance; normalize nodelta
580>(fetch_stmt_ok_sigma_state_ok … EQfetch) whd in match set_no_pc;
581normalize nodelta >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
582>(fetch_stmt_ok_sigma_last_pop_ok … EQfetch) whd in match next;
583whd in match set_pc; normalize nodelta whd in ⊢ (??%% → ?); #EQ destruct(EQ)
584%{(set_pc ? (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) nxt) st2)}
585% [ whd in match sigma_state_pc; normalize nodelta
586    lapply(fetch_statement_inv … EQfetch) >(fetch_stmt_ok_sigma_pc_ok … EQfetch) *
587    #EQfn #_ >EQfn %] lapply EQfetch >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
588#EQfetch'
589cases(b_graph_transform_program_fetch_statement … good … EQfetch')
590#init_data * #t_fn ** #EQt_fn whd in ⊢ (% → ?); cases(f_bl_r ?) [2: #x #y *]
591normalize nodelta #EQ destruct(EQ) * #lbls * #regs ** #_ #_ whd in ⊢ (% → ?);
592* #bl * >if_merge_right [2: %] whd in ⊢ (% → ?); cases regs [2: #x #y *]
593normalize nodelta #EQ destruct(EQ) whd in ⊢ (% → ?); * #l1 * #mid1 * #mid2 * #l2
594*** #EQmid whd in ⊢ (% → ?); * #EQ1 #EQ2 destruct(EQ1 EQ2) whd in EQmid : (???%);
595destruct(EQmid) whd in ⊢ (% → ?); * #nxt1 * #EQstmt #EQ destruct(EQ)
596whd in ⊢ (% → ?); * #EQ1 #EQ2 destruct(EQ1 EQ2) %{(taaf_step … (taa_base …) …)}
597[1,2: whd [ whd in ⊢ (??%?); | whd in match eval_state; ] 
598      whd in match fetch_statement; normalize nodelta >EQt_fn >m_return_bind
599      >EQstmt [%] >m_return_bind whd in match eval_statement_no_pc;
600      normalize nodelta >m_return_bind %] @I
601qed.
602
603
604lemma eval_call_ok   :
605 ∀prog : ertl_program.
606 let trans_prog ≝ ertl_to_ertlptr prog in
607∀ f_lbls,f_regs,stack_sizes.
608 ∀f_bl_r.
609 ∀ good :b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
610     translate_data prog f_bl_r f_lbls f_regs.
611 ∀st2,st1',f,fn,called,args,dest,nxt.
612 let st1 ≝ sigma_state_pc prog f_lbls f_regs st2 in
613  fetch_statement ERTL_semantics …
614    (globalenv_noinit ? prog) (pc … st1) =
615      return 〈f, fn,
616        sequential … (CALL ERTL … called args dest ) nxt〉 →
617   eval_state … (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes)) st1 =
618    return st1' →
619∃is_call,st2_pre_call,is_call'.
620as_call_ident (ERTLptr_status trans_prog stack_sizes)
621 («st2_pre_call,is_call'») = as_call_ident (ERTL_status prog stack_sizes)
622  («st1, is_call») ∧
623(pc … st1) = sigma_stored_pc prog f_lbls (pc … st2_pre_call) ∧
624∃taa2 : trace_any_any (ERTLptr_status trans_prog stack_sizes) st2 st2_pre_call.
625∃ st2'. st1' = sigma_state_pc prog f_lbls f_regs st2' ∧
626eval_state ERTLptr_semantics …
627 (ev_genv … (mk_prog_params ERTLptr_semantics trans_prog stack_sizes)) st2_pre_call
628 =return st2'.
629#prog #f_lbls #f_regs #stack_size #f_bl_r #good #st2 #st1' #f #fn * [#c_id | #c_ptr]
630#args #dest #nxt #EQfetch lapply EQfetch >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
631#EQfetch' lapply(fetch_statement_inv … EQfetch') * #EQfn normalize nodelta #EQstmt
632cases(b_graph_transform_program_fetch_internal_function … good … EQfn)
633#init_data * #calling' ** #EQcalling' whd in ⊢ (% → ?); cases(f_bl_r ?)
634[2,4: #x #y *] normalize nodelta #EQ destruct(EQ) * #_ #_ #_ #_ #pp_labs
635#_ #fresh_labs #fresh_regs #_ #_ #H cases(H … EQstmt) -H #labels * #registers
636** #EQlabels #EQregisters normalize nodelta >if_merge_right [2,4: %]
637whd in match translate_step;
638normalize nodelta whd in ⊢ (% → ?); * #bl * whd in ⊢ (% → ?);
639cases registers in EQregisters; -registers normalize nodelta
640[2,3: [ #x #y] #_ *|4: #r #tl] #EQregisters
641[ whd in ⊢ (% → ?); cases tl in EQregisters; -tl [2: #x #y #_ *] normalize nodelta
642#EQregisters] #EQ destruct(EQ) whd in ⊢ (% → ?); *
643#pre_l * #mid1 * #mid2 * #post_l *** #EQmid1 whd in ⊢ (% → ?);
644[ * #mid * #resg ** #EQ destruct(EQ) whd in ⊢ (% → ?);
645  * #nxt1 * #EQlow change with nxt1 in ⊢ (??%? → ?); #EQ destruct(EQ)
646  whd in ⊢ (% → ?); * #mid3 * #rest1 ** #EQ destruct(EQ) * #nxt1 *
647  #EQpush1 change with nxt1 in ⊢ (??%? → ?); #EQ destruct(EQ)
648  whd in ⊢ (% → ?); * #mid4 * #rest2 ** #EQ destruct(EQ) * #nxt1 * #EQhigh
649  change with nxt1 in ⊢ (??%? → ?); #EQ destruct(EQ) whd in ⊢ (% → ?);
650  * #mid5 * #rest3 ** #EQ destruct(EQ) * #nxt1 * #EQpush2
651  change with nxt1 in ⊢ (??%? → ?); #EQ destruct(EQ) whd in ⊢ (% → ?);
652] * #EQ1 #EQ2 destruct(EQ1 EQ2) whd in EQmid1 : (??%%); destruct(EQmid1)
653whd in ⊢ (% → ?); * #nxt1 * #EQcall #EQ destruct(EQ) whd in ⊢ (% → ?);
654* #EQ destruct(EQ) change with nxt1 in ⊢ (??%? → ?); #EQ destruct(EQ)
655 whd in match eval_state; normalize nodelta >EQfetch
656>m_return_bind whd in match eval_statement_no_pc; normalize nodelta >m_return_bind
657whd in match eval_statement_advance; whd in match eval_call; normalize nodelta
658>(fetch_stmt_ok_sigma_state_ok … EQfetch) >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
659>(fetch_stmt_ok_sigma_last_pop_ok … EQfetch) #H @('bind_inversion H) -H
660#c_bl whd in match set_no_pc; normalize nodelta #H lapply(err_eq_from_io ????? H) -H
661#EQc_bl cases(block_of_call_ok ??????? EQc_bl) #c_bl' * #EQc_bl' #EQ destruct(EQ)
662#H @('bind_inversion H) -H * #f1 * [1,3: #fn1 |*: #ext_f] #EQfn1 normalize nodelta
663[3,4: #H @('bind_inversion H) -H #st whd in match eval_external_call; normalize nodelta
664      #H @('bind_inversion H) -H #list_val #_ #H @('bind_inversion H) -H #x
665      #_ #H @('bind_inversion H) -H #y whd in match do_io; normalize nodelta
666      whd in ⊢ (???% → ?); #ABS destruct(ABS) ] #H lapply(err_eq_from_io ????? H) -H
667#H @('bind_inversion H) -H #st1'' >(fetch_stmt_ok_sigma_pc_ok … EQfetch)
668>(fetch_stmt_ok_sigma_last_pop_ok … EQfetch) whd in match kind_of_call;
669normalize nodelta change with (ertl_save_frame ? it ?) in ⊢ (??%? → ?);
670[2: @PTR |4: @ID] #EQst1'' #H @('bind_inversion H) -H #st1'''
671whd in match eval_internal_call; normalize nodelta #H @('bind_inversion H) -H
672#s_size #H lapply(opt_eq_from_res ???? H) -H
673change with (stack_size ?) in ⊢ (??%? → ?); #EQs_size whd in ⊢ (??%? → ?);
674whd in ⊢ (???% → ?); #EQ destruct(EQ) whd in ⊢ (??%% → ?); #EQ destruct(EQ) %
675[1,3: @hide_prf whd in ⊢ (??%?); >EQfetch %]
676[ letin pairpc ≝ (beval_pair_of_pc (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) mid1))
677  letin st2_pre ≝ (mk_state_pc ?
678    (mk_state ? (st_frms … st2) (both_is (\fst pairpc) (\snd pairpc))
679    (carry … st2) (〈add ?? (\fst (regs … st2)) r (\snd pairpc),\snd(regs … st2)〉)
680    (m … st2))
681    (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) mid1)
682    (last_pop … st2))
683 %{st2_pre}
684| %{st2}
685] % 
686[1,3: @hide_prf whd in ⊢ (??%?); whd in match fetch_statement; normalize nodelta
687      >EQcalling' >m_return_bind [>point_of_pc_of_point ] >EQcall >m_return_bind % ]
688%
689[1,3: %
690  [1,3: whd in ⊢ (??%%); whd in match fetch_statement in ⊢ (??%?);
691        normalize nodelta >EQcalling' in ⊢ (??(match % with [_ ⇒ ? | _ ⇒ ?])?);
692        >m_return_bind in ⊢ (??(match % with [_ ⇒ ? | _ ⇒ ?])?);
693       [ >point_of_pc_of_point in ⊢ (??(match % with [_ ⇒ ? | _ ⇒ ?])?);]
694       >EQcall in ⊢ (??(match % with [_ ⇒ ? | _ ⇒ ?])?); normalize nodelta
695       >(fetch_stmt_ok_sigma_pc_ok … EQfetch) in ⊢ (???(match % with [_ ⇒ ? | _ ⇒ ?]));
696       >EQfetch' in ⊢ (???(match % with [_ ⇒ ? | _ ⇒ ?])); %
697  |*: whd in match sigma_stored_pc; whd in match sigma_pc_opt; normalize nodelta
698      @if_elim change with (pc_block(pc … st2)) in match (pc_block ?);
699      [1,3: @eqZb_elim [2,4: #_ *] #EQbl #_
700      >fetch_internal_function_no_minus_one in EQcalling'; [2,4: assumption]
701      whd in ⊢ (???% → ?); #ABS destruct(ABS) ] #_
702      [ >point_of_pc_of_point >(get_sigma_last … good … EQfn EQstmt EQlabels)
703      | >(get_sigma_idempotent … good … EQfn EQstmt EQlabels)
704      ]
705      >m_return_bind >pc_of_point_of_pc %
706  ]
707|4: %{(taa_base …)}
708|2: letin st2'' ≝ (mk_state_pc ?
709                   (mk_state ? (st_frms … st2) (empty_is) (carry … st2)
710                      (〈add ?? (\fst (regs … st2)) r (\fst pairpc),\snd(regs … st2)〉)
711                      (m … st2)) (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) mid)
712                      (last_pop … st2))
713    letin st2''' ≝ (mk_state_pc ? (set_istack ? (one_is (\fst pairpc)) st2'')
714                    (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) mid3)
715                    (last_pop … st2))
716    letin st2''''≝ (mk_state_pc ? (mk_state ? (st_frms … st2) (istack … st2''')
717    (carry … st2)
718    (〈add ?? (\fst (regs … st2''')) r (\snd pairpc),\snd (regs … st2)〉) (m … st2'''))
719    (pc_of_point ERTLptr_semantics (pc_block (pc … st2)) mid4) (last_pop … st2))
720    %{(taa_step ? st2 st2'' st2_pre ???
721        (taa_step ? st2'' st2''' st2_pre ???
722           (taa_step ? st2''' st2'''' st2_pre ???
723              (taa_step ? st2'''' st2_pre st2_pre ??? (taa_base …)))))}
724   [3,6,7,10: % whd in ⊢ (% → ?); * #H @H whd in ⊢ (??%?);
725              whd in match fetch_statement; normalize nodelta >EQcalling' >m_return_bind
726              [ >point_of_pc_of_point >EQhigh
727              | >point_of_pc_of_point >EQcall
728              | >point_of_pc_of_point >EQpush2
729              | >point_of_pc_of_point >EQpush1 ] %
730   |1,2,4,5,8,9,11,12: whd
731       [1,3,6,8: whd in match eval_state; normalize nodelta
732       |*: whd in ⊢ (??%?);
733       ]
734       whd in match fetch_statement; normalize nodelta >EQcalling' >m_return_bind
735       [1,5: >point_of_pc_of_point >EQpush1 >m_return_bind [2: %]
736       |2,6: >point_of_pc_of_point >EQpush2 >m_return_bind [2: %]
737       |3,7: >point_of_pc_of_point >EQhigh >m_return_bind [2: %]
738       |*: >EQlow >m_return_bind [2: %]
739       ]
740       whd in match eval_statement_no_pc; whd in match eval_seq_no_pc; normalize nodelta
741       whd in match (eval_ext_seq ?????????); whd in match (get_pc_from_label ?????);
742       whd in match block_of_funct_id; normalize nodelta
743       [1,2: whd in match acca_arg_retrieve; normalize nodelta
744             change with (ps_reg_retrieve ??) in match (acca_arg_retrieve_ ?????);
745             whd in match ps_reg_retrieve; whd in match reg_retrieve; normalize nodelta
746             >lookup_add_hit >m_return_bind [%| >add_idempotent %]
747       |*: @('bind_inversion EQfn) * #f2 * #fn2 whd in match fetch_function;
748           normalize nodelta #H lapply(opt_eq_from_res ???? H) -H
749           #H @('bind_inversion H) -H #f3 #EQf3 #H @('bind_inversion H) -H
750           #fn4 #_ whd in ⊢ (??%%→ ??%% → ?); #EQ1 #EQ2 destruct(EQ1 EQ2)
751          >(find_symbol_transf …
752             (λvars.transf_fundef … (λfn.(b_graph_translate … fn))) prog f)
753          >(symbol_of_block_rev … EQf3) >m_return_bind >code_block_of_block_eq
754          normalize nodelta >(pc_of_label_eq … EQcalling') normalize nodelta
755          whd in match ps_reg_store_status; normalize nodelta >m_return_bind [%]
756          whd in match eval_statement_advance; normalize nodelta whd in match set_no_pc;
757          normalize nodelta whd in match next; whd in match set_pc; normalize nodelta
758          @eq_f @eq_f3 [2,3: %] whd in match set_regs; normalize nodelta
759          cut(istack … st2 = empty_is)
760          [ @('bind_inversion EQst1'') #new_st whd in match push_ra; normalize nodelta
761            #H @('bind_inversion H) -H #new_st' whd in match push; normalize nodelta
762            #H @('bind_inversion H) -H #new_is whd in match sigma_state; normalize nodelta
763            cases(istack ? st2) [ #_ #_ #_ #_ % |3: #bv1 #bv2 whd in ⊢ (??%% → ?); #EQ destruct]
764            #bv1 whd in ⊢ (??%% → ?); #EQ destruct(EQ) whd in match set_istack; normalize nodelta
765            whd in ⊢ (??%% → ?); #EQ destruct #H @('bind_inversion H) -H #new_is2 whd in ⊢ (??%% → ?);
766            #EQ destruct(EQ) ] #EQ >EQ %
767       ]
768   ]
769]
770cases(b_graph_transform_program_fetch_internal_function … good c_bl' f1 fn1 ?)
771[2,4: whd in match fetch_internal_function; normalize nodelta lapply(err_eq_from_io ????? EQfn1)
772      -EQfn1 #EQfn1 >EQfn1 %]
773#init * #t_fn1 ** #EQt_fn1 #_ * #_ #_ #_ #EQentry #_ #_ #_ #_ #_ #_ #_
774[2: %{(mk_state_pc ? (set_frms ERTL_state (〈\fst (regs … st2_pre),pc_block(pc … st2)〉 :: (st_frms … st2))
775                                 (set_regs ERTL_state (〈empty_map …,\snd (regs … st2)〉) st2_pre))
776                     (pc_of_point (mk_prog_params ERTLptr_semantics (ertl_to_ertlptr prog) stack_size)
777                         c_bl' (joint_if_entry … t_fn1))
778                     (last_pop … st2))}
779| @('bind_inversion EQst1'') #new_st
780  cut(pc … st2 = sigma_stored_pc prog f_lbls (pc … st2))
781  [ whd in match sigma_stored_pc; whd in match sigma_pc_opt; normalize nodelta
782    @if_elim [ @eqZb_elim [2: #_ *] #EQbl >fetch_internal_function_no_minus_one in EQfn; [2: //] #EQ destruct]
783    #_ >(get_sigma_idempotent … good … EQfn EQstmt EQlabels) >m_return_bind >pc_of_point_of_pc %]
784 #EQ >EQ #EQnew_st cases(push_ra_ok … EQnew_st)
785 [2: lapply EQ whd in match sigma_stored_pc; normalize nodelta cases(sigma_pc_opt ???) [2: #x #_ % #EQ destruct]
786     normalize  nodelta #ABS >fetch_internal_function_no_zero in EQfn; [2: >ABS %] #EQ destruct]
787 #t_new_st * #EQt_new_st #new_st_t_new_st whd in ⊢ (???% → ?); #EQ destruct(EQ)
788 %{(mk_state_pc ? (set_frms ERTL_state (〈(\fst (regs … t_new_st)), pc_block (pc … st2)〉 :: (st_frms … st2))
789                             (set_regs ERTL_state (〈empty_map …,\snd(regs … st2)〉) t_new_st))
790                   (pc_of_point (mk_prog_params ERTLptr_semantics (ertl_to_ertlptr prog) stack_size)
791                         c_bl' (joint_if_entry … t_fn1))
792                   (last_pop … st2))}
793] %
794[1,3: whd in match sigma_state_pc; normalize nodelta whd in match fetch_internal_function;
795      normalize nodelta lapply(err_eq_from_io ????? EQfn1) -EQfn1 #EQfn1 >EQfn1 >m_return_bind
796      normalize nodelta @eq_f3 try % [2,4: >EQentry %] whd in match sigma_state; normalize nodelta
797      whd in match set_frms; whd in match set_regs; normalize nodelta
798      [ @('bind_inversion EQst1'') #new_st #H @('bind_inversion H) -H #new_st1
799        #H @('bind_inversion H) -H #new_is whd in match is_push; normalize nodelta
800        whd in match sigma_state; normalize nodelta cases (istack … st2) normalize nodelta
801        [3: #bv1 #bv2 whd in ⊢ (???% → ?); #EQ destruct(EQ) |2: #bv] whd in ⊢ (??%% → ?);
802        #EQ destruct(EQ) whd in ⊢ (??%% → ?); #EQ destruct(EQ) whd in ⊢ (??%% → ?); #EQ destruct
803        whd in ⊢ (???% → ?); #EQ destruct(EQ)
804      ]
805      cut(∀ a1,a2,b1,b2,c1,c2,d1,d2,e1,e2.a1=a2 → b1 = b2 → c1 = c2 → d1 = d2 → e1 = e2 →
806            mk_state ERTL_semantics a1 b1 c1 d1 e1 =
807            mk_state ERTL_semantics a2 b2 c2 d2 e2)
808       [1,3: #H1 #H2 #H3 #H4 #H5 #H6 #H7 #H8 #H9 #H10 #H11 #H12 #H13 #H14 #H15 //]
809       #APP @APP
810       [ whd in match sigma_frames in ⊢ (???%); normalize nodelta whd in match sigma_frames_opt;
811         whd in match m_list_map; normalize nodelta whd in match (foldr ?????);
812         normalize nodelta >EQfn >m_return_bind normalize nodelta
813         check coerced_step_list_in_code
814         whd in match sigma_frames; whd in match sigma_frames_opt; whd in match m_list_map;
815         normalize nodelta cases(foldr ? (Option ?) ???) [%
816        //
817        whd in ⊢
818      xxxxxxxxxxxxxxxxxxxxxxxx
819     
820      change with c_bl' in match (pc_block ?) in ⊢ (???%); >EQfn1               
821change with (ge … (ev_genv (mk_prog_params ERTL_semantics prog stack_size)))
822 in match (globalenv_noinit ? prog); >EQfn1
823change with 
824 
825          #EQnew_st whd in ⊢ (???% → ?); #EQ destruct(EQ) cases(push_ra_ok ???????? EQnew_st)
826         
827          xxxxxxxxxxx
828          lapply EQfn whd in match fetch_internal_function; whd in match fetch_function;
829          normalize nodelta
830          check find_symbol
831letin (*〈addrl,addrh〉*) x ≝  beval_pair_of_pc ? %
832
833
834
835%{(mk_state_pc ?
836    (mk_state ? (st_frms … st2)
837    (both_is (\snd (beval_pair_of_pc (pc … st2)))
838             (\fst (beval_pair_of_pc (pc … st2))))
839    (carry … st2) (regs … st2) (m … st2))
840    (pc … st2)
841    (last_pop … st2))}
842
843
844
845
846inductive ex_Type1 (A:Type[1]) (P:A → Prop) : Prop ≝
847    ex1_intro: ∀ x:A. P x →  ex_Type1 A P.
848(*interpretation "exists in Type[1]" 'exists x = (ex_Type1 ? x).*)
849
850lemma ertl_to_ertlptr_ok:
851∀prog.
852let trans_prog ≝ ertl_to_ertlptr prog in
853∀ f_lbls,f_regs,stack_sizes.
854 ∀f_bl_r.
855 b_graph_transform_program_props ERTL_semantics ERTLptr_semantics
856     translate_data prog f_bl_r f_lbls f_regs →
857   ex_Type1 … (λR.
858   status_simulation
859    (ERTL_status prog stack_sizes) (ERTLptr_status trans_prog stack_sizes) R).
860#prog #f_lbls #f_regs #stack_size #f_bl_r #good %
861[@ERTLptrStatusSimulation assumption]
862whd in match status_simulation; normalize nodelta
863whd in match ERTL_status; whd in match ERTLptr_status; normalize nodelta
864whd in ⊢ (% → % → % → % → ?); #st1 #st1' #st2
865change with
866  (eval_state ERTL_semantics (prog_var_names ???) ?? = ? → ?) 
867#EQeval @('bind_inversion EQeval)
868** #id #fn #stmt #H lapply (err_eq_from_io ????? H) -H #EQfetch
869#_  whd in match ERTLptrStatusSimulation; normalize nodelta #EQst2 destruct
870cases stmt in EQfetch; -stmt
871[ * [ #cost | #called_id #args #dest| #reg #lbl | #seq] #nxt | #fin_step | *]
872#EQfetch
873change with (joint_classify ??) in ⊢ (match % with [ _ ⇒ ? | _ ⇒ ? ]);
874[ (*COST*) whd in match joint_classify; normalize nodelta >EQfetch >m_return_bind
875  normalize nodelta
876  cases(eval_cost_ok … good … EQfetch EQeval) #st2' * #EQst2' * #taf #tafne
877  %{st2'} %{taf} >tafne normalize nodelta % [ % [@I | assumption]]
878  whd >EQst2' >(as_label_ok … good … st2') [%] cases daemon (* needs lemma see below!! *)
879| (*CALL*)  whd in match joint_classify; normalize nodelta >EQfetch >m_return_bind
880          normalize nodelta #is_call_st1
881          cases(eval_call_ok … good … EQfetch EQeval) #is_call_st1'
882          * #st2_pre_call * #is_call_st2_pre_call * * #Hcall
883          #call_rel * #taa * #st2' * #sem_rel #eval_rel
884          %{(«st2_pre_call,is_call_st2_pre_call»)} % [ % assumption]
885          %{st2'} %{st2'} %{taa} %{(taa_base …)} % [ % assumption]
886          whd >sem_rel >(as_label_ok … good … st2') [%] cases daemon (*TODO*)
887| (*COND*) whd in match joint_classify; normalize nodelta >EQfetch >m_return_bind
888          normalize nodelta #n_costed
889          cases(eval_cond_ok … good … EQfetch EQeval) [2: @n_costed]
890          #st2' * #EQst2' * #taf #tafne %{st2'} %{taf} >tafne % [% [@I|assumption]]
891          whd >EQst2' >(as_label_ok … good … st2') [%] cases daemon (*TODO*)
892| (*seq*) whd in match joint_classify; normalize nodelta >EQfetch >m_return_bind
893          normalize nodelta
894          cases (eval_seq_no_call_ok … good … EQfetch EQeval)
895          #st3 * #EQ destruct *  #taf #taf_spec %{st3} %{taf} 
896          % [% //] whd >(as_label_ok … good … st3) [%]
897          cases daemon (*needs lemma about preservation of fetch_statement *)
898|  cases fin_step in EQfetch;
899  [ (*GOTO*) #lbl #EQfetch  whd in match joint_classify; normalize nodelta
900     >EQfetch in ⊢ (match % with [ _ ⇒ ? | _ ⇒ ? ]); normalize nodelta
901    cases (eval_goto_ok … good  … EQfetch EQeval)
902    #st3 * #EQ destruct * #taf #tarne %{st3} %{taf} >tarne normalize nodelta
903    % [% //] whd >(as_label_ok … good … st3) [%]
904    cases daemon (*needs lemma about preservation of fetch_statement *)
905  | (*RETURN*) #EQfetch
906     whd in match joint_classify; normalize nodelta
907    >EQfetch in ⊢ (match % with [ _ ⇒ ? | _ ⇒ ? ]); normalize nodelta
908    cases (eval_return_ok … good … EQfetch EQeval) #is_ret
909    * #st3 * #EQ destruct * #after_ret * #taf ** #taf_prf #EQeval' #ret_prf
910    % [2: % [2: % [2: %{(taa_base …)} %{taf}] |*: ] |*:]
911    % [2: whd >(as_label_ok … good … st3) [%] cases daemon (*needs lemma *)]
912    % [2: assumption] % [2: %] % [2: assumption] % assumption
913  | (*TAILCALL*) *
914  ]
915]
916qed.
917
918(*
919lemma foo :
920 ∀P1_unser,P2_unser: unserialized_params.
921 ∀P1_sem_unser,P2_sem_unser.
922 let P1_sem ≝ make_sem_graph_params P1_unser P1_sem_unser in
923 let P2_sem ≝ make_sem_graph_params P2_unser P2_sem_unser in
924 ∀init,translate_step.
925 ∀translate_fin_step.
926 ∀closed_graph_translate.
927 let translate_internal :
928  ∀globals.
929   joint_closed_internal_function P1_sem globals →
930   joint_closed_internal_function P2_sem globals
931  ≝
932  λglobals,fun.
933   «b_graph_translate (mk_graph_params P1_sem) (mk_graph_params P2_sem) globals
934    (init globals)
935    (translate_step globals)
936    (translate_fin_step globals)
937    (pi1 … fun), closed_graph_translate globals fun» in
938 ∀prog.
939 let trans_prog ≝ transform_program ??? prog (λvarnames. transf_fundef ?? (translate_internal varnames)) in
940 ∀stack_size.
941 ∀sigma_state_pc.
942 (∀s. pc_block (pc … (sigma_state_pc s)) = pc_block … (pc … s)) →
943 ∀st : state_pc P2_sem.
944 ∀st' : state_pc P1_sem.
945 ∀f.
946 ∀fn: joint_closed_internal_function P1_sem (globals (mk_prog_params P1_sem prog stack_size)).
947 luniverse_ok … fn →
948 ∀stmt,nxt.
949 ∀P : (state_pc P2_sem) → Prop.
950 (∀pre_Instrs',last_Instrs',dst.
951   ∃st''.∃st'''.∃st''''.
952    repeat_eval_seq_no_pc (mk_prog_params P2_sem trans_prog stack_size)
953     f (translate_internal ? fn) (map_eval ?? pre_Instrs' dst) st = return st''' ∧
954    eval_seq_no_pc ? (prog_var_names … trans_prog) (ev_genv … (mk_prog_params P2_sem trans_prog stack_size))
955                      f (translate_internal … fn) (last_Instrs' dst) st''' = return st'''' ∧
956    st'' = (mk_state_pc (mk_prog_params P2_sem trans_prog stack_size)
957     st'''' (pc_of_point P2_sem (pc_block (pc … (sigma_state_pc st))) dst) (last_pop … st)) ∧
958    P st'' (*st' = sigma_state_pc st''*) ∧
959    let P2_prog_params ≝ mk_prog_params P2_sem trans_prog stack_size in
960    let P2_globals ≝ globals P2_prog_params in
961     All
962      (joint_seq … P2_globals)
963      (no_cost_label … P2_globals)
964      (map_eval (code_point P2_sem) (joint_seq … P2_globals) pre_Instrs' dst)) →
965 fetch_statement …
966  (prog_var_names (joint_function P1_sem) ℕ prog)
967  (ev_genv (mk_prog_params P1_sem prog stack_size))
968  (pc … (sigma_state_pc st)) =
969    return 〈f, fn,  sequential … (step_seq P1_sem … stmt) nxt〉 →
970 eval_state …
971 (prog_var_names (joint_function P1_sem) ℕ prog)
972 (ev_genv … (mk_prog_params P1_sem prog stack_size))
973 (sigma_state_pc st) = return st' →
974 ∃st''. (*CSC: this needs to be linked back again st' = sigma_state_pc ? good st'' ∧*)
975 P st'' ∧
976 ∃taf : trace_any_any_free (joint_abstract_status (mk_prog_params P2_sem trans_prog stack_size)) st st''.
977(if taaf_non_empty … taf then True else
978(¬as_costed (joint_abstract_status (mk_prog_params P1_sem prog stack_size)) (sigma_state_pc st) ∨
979 ¬as_costed (joint_abstract_status (mk_prog_params P1_sem prog stack_size)) st'))
980 (* the length of taf is the same of the length of ??? *).
981#P1_unser #P2_unser #P1_sem_unser #P2_sem_unser
982letin P1_sem ≝ (make_sem_graph_params P1_unser P1_sem_unser)
983letin P2_sem ≝ (make_sem_graph_params P2_unser P2_sem_unser)
984#init #translate_step #translate_fin_step #closed_graph_translate.
985letin translate_internal ≝
986 (λglobals,fun.
987   «b_graph_translate (mk_graph_params P1_sem) (mk_graph_params P2_sem) globals
988    (init globals)
989    (translate_step globals)
990    (translate_fin_step globals)
991    (pi1 … fun), closed_graph_translate globals fun»)
992#prog
993letin trans_prog ≝ (transform_program ??? prog (λvarnames. transf_fundef ?? (translate_internal varnames)))
994#stack_size #sigma_state_pc #sigma_state_pc_ok #st #st' #f #fn #fn_universe_ok #stmt #nxt #P
995#Hpass #EQfetch lapply(fetch_statement_inv … EQfetch) * #EQfn #EQstmt
996cases
997 (b_graph_translate_ok … (init …) (translate_step …) (translate_fin_step …) … fn_universe_ok)
998#_ * #MK_fresh_labels * #MK_fresh_registers **** #_ #_ #_ #_ (*CSC: useful things thrown out here *)
999#MULTI_FETCH_OK cases (MULTI_FETCH_OK … EQstmt)
1000#list_b_last * #fresh_registers ** #EQlist_b_last #EQfresh_registers
1001normalize nodelta * #Instrs * #fresh_registers_spec whd in ⊢ (% → ?);
1002@pair_elim #pre_Instrs #last_Instrs #EQInstrs * #dst * #Multi_fetch #STEP_in_code
1003#EQeval
1004cut((list
1005   (code_point P2_sem
1006    →joint_seq P2_sem (prog_var_names (joint_function P1_sem) ℕ prog)))) [ cases daemon (*Paolo should fix the lemma*)]
1007#pre_Instrs'
1008cut((code_point P2_sem
1009   →joint_seq P2_sem (prog_var_names (joint_function P1_sem) ℕ prog))) [ cases daemon (*Paolo should fix the lemma*)]
1010#last_Instrs'
1011cases (Hpass pre_Instrs' last_Instrs' dst (* MANY MORE HERE *))
1012#st'' * #st''' * #st'''' **** #REPEAT #EVAL_NO_PC_Last #EQst'' #EQst' #NO_COSTED
1013lapply(produce_trace_any_any_free … NO_COSTED … REPEAT)
1014[ cases daemon (* should be @Multi_fetch *)
1015| <sigma_state_pc_ok @(fetch_internal_function_transf … (λvars.translate_internal vars))
1016  assumption
1017| @dst
1018| @list_b_last (*wrong, should dst be destination or the last of list_b_last *)
1019] #TAAF
1020lapply
1021  (produce_step_trace (mk_prog_params P2_sem trans_prog stack_size)
1022    (mk_state_pc (mk_prog_params P2_sem trans_prog stack_size)
1023       st''' (pc_of_point P2_sem (pc_block (pc … st)) dst) (last_pop … st))
1024    f (translate_internal ? fn) (last_Instrs' dst) nxt st'''' … EVAL_NO_PC_Last)
1025[ cases daemon (* should be @STEP_In_code *)
1026| <sigma_state_pc_ok
1027  @(fetch_internal_function_transf … (λvars. translate_internal vars) … EQfn) ]
1028#LAST_STEP
1029cases daemon
1030qed.
1031
1032lemma eval_seq_no_call_ok :
1033 ∀prog.
1034 let trans_prog ≝ ertl_to_ertlptr prog in
1035 ∀good : (∀fn.good_state_transformation prog fn).     
1036 ∀stack_sizes.
1037 (*? →*)
1038 ∀st : state_pc ERTLptr_semantics.
1039 ∀st' : state_pc ERTL_semantics.
1040 ∀f,fn,stmt,nxt.
1041   fetch_statement ERTL_semantics
1042     (prog_var_names (joint_function ERTL_semantics) ℕ prog)
1043    (ev_genv (mk_prog_params ERTL_semantics prog stack_sizes))
1044    (pc … (sigma_state_pc ? good st)) =
1045      return 〈f, fn,  sequential … (step_seq ERTL … stmt) nxt〉 →
1046   eval_state ERTL_semantics
1047   (prog_var_names (joint_function ERTL_semantics) ℕ prog)
1048   (ev_genv … (mk_prog_params ERTL_semantics prog stack_sizes))
1049   (sigma_state_pc ? good st) =
1050    return st' →
1051 ∃st''. st' = sigma_state_pc ? good st'' ∧
1052 ∃taf : trace_any_any_free (ERTLptr_status trans_prog stack_sizes)
1053  st
1054  st''.
1055 bool_to_Prop (taaf_non_empty … taf).
1056#prog #good #stack_size #st #st' #f #fn #stmt #nxt #EQfetch #EQeval
1057cases (foo … translate_step translate_fin_step … EQfetch EQeval)
1058[2,3: cases daemon (* first one, take out init definition from ERTLtoERTLptr;
1059                      second one to be taken from somewhere *)
1060|4: #x cases daemon (* TO BE DONE, EASY *)
1061|5: cases daemon (* to be taken in input *)
1062|6: @(λst''.st' = sigma_state_pc ? good st'')
1063|7: cases daemon
1064| #st'' * #EQ destruct * change with ERTL_uns in match (mk_unserialized_params ???????????????);
1065  change with ERTLptr_uns in match (mk_unserialized_params ???????????????);
1066  (* change with ERTL_semantics in match (make_sem_graph_params ??);
1067  change with ERTLptr_semantics in match (make_sem_graph_params ??); *)
1068#taaf #Htaaf %{st''}
1069 % [%] cases daemon
1070 qed. *)
Note: See TracBrowser for help on using the repository browser.