Changeset 1926
- Timestamp:
- 05/08/12 18:09:02 (13 months ago)
- Files:
-
- 1 modified
-
src/common/StructuredTraces.ma (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/common/StructuredTraces.ma
r1921 r1926 2 2 include "basics/bool.ma". 3 3 include "basics/jmeq.ma". 4 include "common/CostLabel.ma". 5 include "utilities/option.ma". 4 6 include "basics/lists/listb.ma". 5 7 include "ASM/Util.ma". … … 12 14 13 15 record abstract_status : Type[1] ≝ 14 { 15 as_status :> Type[0] 16 { as_status :> Type[0] 16 17 ; as_execute : as_status → as_status → Prop 17 18 ; as_pc : DeqSet 18 19 ; as_pc_of : as_status → as_pc 19 20 ; as_classifier : as_status → status_class → Prop 20 ; as_ costed : as_status → Prop21 ; as_label : as_status → option costlabel 21 22 ; as_after_return : (Σs:as_status. as_classifier s cl_call) → as_status → Prop 22 23 ; as_final: as_status → Prop … … 25 26 (* temporary alias for backward compatibility *) 26 27 definition final_abstract_status ≝ abstract_status. 28 29 definition as_costed : ∀a_s : abstract_status.a_s → Prop ≝ 30 λa_s,st.as_label ? st ≠ None ?. 31 32 definition as_label_safe : ∀a_s : abstract_status. 33 (Σs : a_s.as_costed ? s) → costlabel ≝ 34 λa_s,st_sig.opt_safe … (pi2 … st_sig). 27 35 28 36 inductive trace_ends_with_ret: Type[0] ≝ … … 113 121 | tal_base_call pre _ _ _ _ _ _ _ ⇒ [as_pc_of … pre] 114 122 ]. 115 116 definition as_trace_any_label_length':117 ∀S: abstract_status.118 ∀trace_ends_flag: trace_ends_with_ret.119 ∀start_status: S.120 ∀final_status: S.121 ∀the_trace: trace_any_label S trace_ends_flag start_status final_status.122 nat ≝123 λS: abstract_status.124 λtrace_ends_flag: trace_ends_with_ret.125 λstart_status: S.126 λfinal_status: S.127 λthe_trace: trace_any_label S trace_ends_flag start_status final_status.128 |tal_pc_list … the_trace|.129 123 130 124 let rec tlr_unrepeating S st1 st2 (tlr : trace_label_return S st1 st2) on tlr : Prop ≝ … … 146 140 bool_to_Prop (notb (memb ? (as_pc_of … st1) (tal_pc_list … tl))) ∧ 147 141 tal_unrepeating … tl 148 | tal_base_call status_pre_fun_call status_start_fun_call status_final _ _ _149 fun_call_trace _ ⇒ tlr_unrepeating … fun_call_trace150 142 | _ ⇒ True 143 ]. 144 145 definition tll_hd_label : ∀S : abstract_status.∀fl,st1,st2. 146 trace_label_label S fl st1 st2 → costlabel ≝ 147 λS,fl,st1,st2,tr.match tr with 148 [ tll_base _ st1' _ _ prf ⇒ as_label_safe … «st1', prf» ]. 149 150 definition tlr_hd_label : ∀S : abstract_status.∀st1,st2. 151 trace_label_return S st1 st2 → costlabel ≝ 152 λS,st1,st2,tr.match tr with 153 [ tlr_base st1' st2' tll ⇒ tll_hd_label … tll 154 | tlr_step st1' st2' _ tll _ ⇒ tll_hd_label … tll 151 155 ]. 152 156 … … 196 200 . 197 201 202 definition tlc_hd_label : ∀S : abstract_status.∀st1,st2. 203 trace_label_call S st1 st2 → costlabel ≝ 204 λS,st1,st2,tr.match tr with 205 [ tlc_base st1' _ _ prf ⇒ as_label_safe … «st1', prf» 206 ]. 207 198 208 coinductive trace_label_diverges (S:abstract_status) : S → Type[0] ≝ 199 209 | tld_step: … … 212 222 trace_label_diverges S status_start_fun_call → 213 223 trace_label_diverges S status_initial. 224 225 definition tld_hd_label : ∀S : abstract_status.∀st. 226 trace_label_diverges S st → costlabel ≝ 227 λS,st,tr.match tr with 228 [ tld_step st' st'' tll _ ⇒ tll_hd_label … tll 229 | tld_base st' st'' _ tlc _ _ _ ⇒ tlc_hd_label … tlc 230 ]. 214 231 215 232 (* Version in Prop for showing existence. *) … … 279 296 ]. 280 297 298 definition tal_tl_label : ∀S : abstract_status.∀st1,st2. 299 trace_any_label S doesnt_end_with_ret st1 st2 → costlabel ≝ 300 λS,st1,st2,tr.as_label_safe … «st2, trace_any_label_label … tr». 301 281 302 lemma trace_label_label_label : ∀S,s,s',f. 282 303 ∀tr:trace_label_label S f s s'. match f with [ doesnt_end_with_ret ⇒ as_costed S s' | ends_with_ret ⇒ True ]. … … 285 306 #f #start #end #tr' #C @(trace_any_label_label … tr') 286 307 qed. 308 309 definition tll_tl_label : ∀S : abstract_status.∀st1,st2. 310 trace_label_label S doesnt_end_with_ret st1 st2 → costlabel ≝ 311 λS,st1,st2,tr.as_label_safe … «st2, trace_label_label_label … tr». 287 312 288 313 lemma trace_any_call_call : ∀S,s,s'. … … 338 363 ]. 339 364 340 (* TODO: use as_label for forcing same labels *)341 365 let rec tlr_rel S1 st1 st1' S2 st2 st2' 342 366 (tlr1 : trace_label_return S1 st1 st1') … … 359 383 (tll2 : trace_label_label S2 fl2 st2 st2') on tll1 : Prop ≝ 360 384 match tll1 with 361 [ tll_base fl1 st1 st1' tal1 _⇒385 [ tll_base fl1 st1 st1' tal1 H ⇒ 362 386 match tll2 with 363 [ tll_base fl2 st2 st2 tal2 _ ⇒ tal_rel … tal1 tal2 387 [ tll_base fl2 st2 st2 tal2 G ⇒ 388 as_label_safe … («?, H») = as_label_safe … («?, G») ∧ 389 tal_rel … tal1 tal2 364 390 ] 365 391 ] … … 389 415 | tal_step_default fl1 st1 st1' st1'' _ tl1 _ _ ⇒ 390 416 tal_rel … tl1 tal2 (* <- this makes it many to many *) 391 ]. 417 ].
