source: src/joint/semantics_blocks.ma @ 2655

Last change on this file since 2655 was 2655, checked in by tranquil, 8 years ago

new step in code semantic lemma

File size: 6.8 KB
Line 
1include "joint/blocks.ma".
2include "joint/Traces.ma".
3include "joint/semanticsUtils.ma".
4
5include "common/StatusSimulation.ma". (* for trace_any_any_free *)
6
7(* let rec seq_list_labels p g (b : list (joint_step p g)) on b : list label ≝
8  match b with
9  [ nil ⇒ [ ]
10  | cons hd tl ⇒ step_labels … hd @ seq_list_labels … tl
11  ].*)
12
13definition repeat_eval_seq_no_pc ≝
14  λp : evaluation_params.λcurr_id,curr_fn.
15  m_fold … (eval_seq_no_pc … (ev_genv … p) curr_id curr_fn).
16
17definition taaf_cons : ∀S : abstract_status.∀s1,s2,s3.
18  as_execute S s1 s2 →
19  as_classifier … s1 cl_other →
20  ∀taaf : trace_any_any_free S s2 s3.
21  (if taaf_non_empty … taaf then ¬as_costed … s2 else True) →
22  trace_any_any_free S s1 s3 ≝
23λS,s1,s2,s3,H,I,tl.
24match tl return λs2,s3,tl.
25  as_execute … s1 s2 →
26  if taaf_non_empty … tl then ¬as_costed … s2 else True →
27  trace_any_any_free S s1 s3
28with
29[ taaf_base s2 ⇒ λH.λ_.taaf_step … (taa_base …) H I
30| taaf_step s2 s3 s4 taa H' I' ⇒
31  λH,J.taaf_step … (taa_step … H I J taa) H' I'
32| taaf_step_jump s2 s3 s4 taa H' I' K' ⇒
33  λH,J.taaf_step_jump … (taa_step ???? H I J taa) H' I' K'
34] H.
35
36lemma taaf_cons_non_empty : ∀S,s1,s2,s3,H,I,tl,J.
37bool_to_Prop (taaf_non_empty … (taaf_cons S s1 s2 s3 H I tl J)).
38#S #s1 #s2 #s3 #H #I #tl lapply H -H cases tl
39[ #s #H * % |*: #s2 #s3 #s4 #taa #H' #I' [2: #K'] #H #J % ]
40qed.
41
42lemma produce_step_trace :
43  ∀p : evaluation_params.
44  ∀st : state_pc p.
45  ∀curr_id,curr_fn.
46  ∀s : joint_seq p (globals p).
47  ∀dst : code_point p.
48  ∀st' : state p.
49  fetch_internal_function … (ev_genv p) (pc_block (pc … st)) =
50    return 〈curr_id, curr_fn〉 →
51  let src ≝ point_of_pc p (pc … st) in
52  step_in_code … (joint_if_code … curr_fn) src s dst →
53  eval_seq_no_pc p (globals p) (ev_genv p) curr_id curr_fn s st = return st' →
54  as_execute (joint_abstract_status p) st
55    (mk_state_pc ? st' (pc_of_point p (pc_block (pc … st)) dst) (last_pop … st)).
56#p #st#curr_id #curr_fn #s #dst #st' #EQfetch * #nxt * #EQstmt_at #EQdst
57#EQeval whd whd in match eval_state; whd in match eval_statement_no_pc;
58whd in match fetch_statement; normalize nodelta >EQfetch >m_return_bind
59>EQstmt_at >m_return_bind normalize nodelta >EQeval >m_return_bind
60whd in ⊢ (??%%); @eq_f whd in match next; normalize nodelta
61whd in match (pc ??);  whd in match succ_pc; normalize nodelta >EQdst %
62qed.
63
64let rec produce_trace_any_any_free_aux
65  (p : evaluation_params)
66  (st : state_pc p)
67  curr_id curr_fn
68  (b : list (joint_seq p (globals p))) on b :
69  ∀l : list (code_point p).
70  ∀dst : code_point p.
71  ∀st' : state p.
72  fetch_internal_function … (ev_genv p) (pc_block (pc … st)) =
73    return 〈curr_id, curr_fn〉 →
74  let src ≝ point_of_pc p (pc … st) in
75  step_list_in_code … (joint_if_code … curr_fn) src b l dst →
76  All ? (no_cost_label …) b →
77  repeat_eval_seq_no_pc p curr_id curr_fn b st = return st' →
78  Σtaaf : trace_any_any_free (joint_abstract_status p) st
79    (mk_state_pc ? st' (pc_of_point p (pc_block (pc … st)) dst) (last_pop … st)).
80  (not_empty … b ↔ bool_to_Prop (taaf_non_empty … taaf)) ≝
81  match b
82  return λb.∀l,dst.?→?→?→?→?→ Σtaaf.(not_empty ? b ↔ bool_to_Prop (taaf_non_empty … taaf))
83  with
84  [ nil ⇒
85    λl,dst,st',fd_prf,in_code,all_other,EQ1.
86    «taaf_base (joint_abstract_status p) st
87    ⌈trace_any_any_free ??? ↦ ?⌉,?»
88  | cons hd tl ⇒
89    λl.
90    match l return λx.∀dst,st'.?→?→?→?→Σtaaf.(True ↔ bool_to_Prop (taaf_non_empty … taaf)) with
91    [ nil ⇒ λdst,st',fd_prf,in_code.⊥
92    | cons mid rest ⇒
93      λdst,st',fd_prf,in_code,all_other,EQ1.
94      let mid_pc ≝ pc_of_point p (pc_block (pc … st)) mid in
95      match eval_seq_no_pc … (ev_genv p) curr_id curr_fn hd st
96      return λx.eval_seq_no_pc … (ev_genv p) curr_id curr_fn hd st = x →
97      Σtaaf : trace_any_any_free (joint_abstract_status p) st
98        (mk_state_pc ? st' (pc_of_point p (pc_block (pc … st)) dst) (last_pop … st)).
99        (True ↔ bool_to_Prop (taaf_non_empty … taaf)) with
100      [ OK st_mid ⇒ λEQ2.
101        let tr_tl ≝ produce_trace_any_any_free_aux ?
102            (mk_state_pc ? st_mid mid_pc (last_pop … st))
103            curr_id curr_fn tl rest dst ????? in
104        «taaf_cons … tr_tl ?,?»
105      | _ ⇒ λEQ2.⊥
106      ] (refl …)
107    ]
108  ]. @hide_prf
109[1,2: [2: % [*] generalize in ⊢ (?(???? (match % with [ _ ⇒ ?])) → ?); ]
110  whd in EQ1 : (??%%);
111  cases l in in_code; whd in ⊢ (%→?); [2,4: #hd #tl * ] #EQ destruct
112  >pc_of_point_of_pc cases st // #a #b #c #e >(K ?? e) normalize nodelta *
113| @in_code
114|12: whd in EQ1 : (??%%); >EQ2 in EQ1; whd in ⊢ (??%?→?); #EQ1 destruct(EQ1)
115|4: cases tr_tl -tr_tl #tr_tl cases tl in in_code all_other;
116  [ #_ #_ * #_ cases (taaf_non_empty ????)
117    [ #ABS cases (ABS I) | #_ % ]
118  | #hd' #tl' ** #nxt * #EQstmt_at #EQ_nxt cases rest [*] #mid' #rest' *
119    * #nxt' * #EQstmt_at' #EQ_nxt' #_ * #hd_other * #hd_other'
120    #_ * #H #_ >(H I) % whd in ⊢ (%→?);
121    whd in ⊢ (?(??%?)→?); whd in match (as_pc_of ??);
122    >fetch_statement_eq [2: whd in match point_of_pc;
123    normalize nodelta >point_of_offset_of_point @EQstmt_at' |3: @fd_prf |*:]
124    normalize nodelta
125    >(no_label_uncosted … hd_other') * #ABS @ABS %
126  ]
127|7: % [2: #_ %] * @taaf_cons_non_empty
128]
129change with (! y ← ? ; repeat_eval_seq_no_pc ????? = ?) in EQ1;
130>EQ2 in EQ1; >m_return_bind
131cases in_code -in_code * #nxt * #EQ_stmt_at #EQ_mid #rest_in_code
132cases all_other -all_other #hd_no_cost #tl_other
133#EQ1
134try assumption
135[2: whd whd in match eval_state; normalize nodelta
136  >(fetch_statement_eq … fd_prf EQ_stmt_at)
137  >m_return_bind
138  whd in match eval_statement_no_pc; normalize nodelta
139  >EQ2 >m_return_bind
140  whd in match eval_statement_advance; normalize nodelta
141  whd in match next; normalize nodelta
142  whd in match succ_pc; normalize nodelta
143  >EQ_mid %
144|1: whd whd in ⊢ (??%?);
145  >(fetch_statement_eq … fd_prf EQ_stmt_at) normalize nodelta %
146|3: normalize nodelta >point_of_pc_of_point assumption
147]
148qed.
149
150definition produce_trace_any_any_free :
151  ∀p : evaluation_params.
152  ∀st : state_pc p.
153  ∀curr_id,curr_fn.
154  ∀b : list (joint_seq p (globals p)).
155  ∀l : list (code_point p).
156  ∀dst : code_point p.
157  ∀st' : state p.
158  fetch_internal_function … (ev_genv p) (pc_block (pc … st)) =
159    return 〈curr_id, curr_fn〉 →
160  let src ≝ point_of_pc p (pc … st) in
161  step_list_in_code … (joint_if_code … curr_fn) src b l dst →
162  All ? (no_cost_label …) b →
163  repeat_eval_seq_no_pc p curr_id curr_fn b st = return st' →
164  trace_any_any_free (joint_abstract_status p) st
165    (mk_state_pc ? st' (pc_of_point p (pc_block (pc … st)) dst) (last_pop … st)) ≝
166  λp,st,curr_id,curr_fn,b,l,dst,st',prf1,prf2,prf3,prf4.
167  produce_trace_any_any_free_aux p st curr_id curr_fn b l dst st' prf1 prf2 prf3 prf4.
Note: See TracBrowser for help on using the repository browser.