source: LTS/Simulation.ma @ 3506

Last change on this file since 3506 was 3506, checked in by sacerdot, 5 years ago

Refactoring.

File size: 20.7 KB
Line 
1include "Traces.ma".
2
3record relations (S1,S2 : abstract_status) : Type[0] ≝
4 { Srel: S1 → S2 → Prop
5 ; Crel: S1 → S2 → Prop
6 }.
7
8definition Rrel ≝ λS1,S2 : abstract_status.λrel : relations S1 S2.λs,s'.
9 ∀s1,s1'. as_syntactical_succ S1 s1 s → Crel … rel s1 s1' → as_syntactical_succ S2 s1' s'.
10
11record simulation_conditions (S1,S2 : abstract_status) (rel : relations S1 S2) : Prop ≝
12 { initial_is_initial :
13   ∀s1,s2.Srel … rel s1 s2 → (bool_to_Prop (as_initial … s1) →  bool_to_Prop (as_initial … s2))
14 ; final_is_final :
15   ∀s1,s2.Srel … rel s1 s2 → (bool_to_Prop(as_final … s1) → bool_to_Prop (as_final … s2))
16 ; simulate_tau:
17     ∀s1:S1.∀s2:S2.∀s1':S1.
18      as_execute … (cost_act (None ?))  s1 s1'→
19      Srel … rel s1 s2 → as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
20      ∃s2'. ∃t: raw_trace S2 s2 s2'.
21        Srel … rel s1' s2' ∧ silent_trace … t
22 ; simulate_label:
23     ∀s1:S1.∀s2:S2.∀l.∀s1':S1.
24      as_execute S1 (cost_act (Some ? l)) s1 s1' →
25      as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
26      Srel … rel s1 s2 →
27      ∃s2',s2'',s2'''.
28       ∃t1: raw_trace S2 s2 s2'.
29       as_execute … (cost_act (Some ? l)) s2' s2'' ∧
30       ∃t3: raw_trace … s2'' s2'''.
31        Srel … rel  s1' s2''' ∧ silent_trace … t1 ∧ pre_silent_trace … t3
32 ; simulate_call_pl:
33     ∀s1:S1.∀s2:S2.∀s1':S1.∀f,l.
34      is_call_post_label … s1 →
35      as_execute … (call_act f l) s1 s1' →
36      as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
37      Srel … rel s1 s2 →
38      ∃s2',s2'',s2'''.
39       ∃t1: raw_trace S2 s2 s2'.
40       as_execute … (call_act f l) s2' s2'' ∧
41       bool_to_Prop(is_call_post_label … s2') ∧
42       ∃t3: raw_trace S2 s2'' s2'''.
43        Srel … rel s1' s2''' ∧ silent_trace … t1 ∧ pre_silent_trace … t3
44 ; simulate_ret_l:
45     ∀s1:S1.∀s2:S2.∀s1':S1.∀l.
46      as_execute S1 (ret_act (Some ? l)) s1 s1' →
47      as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
48      Srel  … rel s1 s2 →
49      ∃s2',s2'',s2'''.
50       ∃t1: raw_trace S2 s2 s2'.
51       as_execute … (ret_act (Some ? l)) s2' s2'' ∧
52       ∃t3: raw_trace S2 s2'' s2'''.
53        Srel … rel s1' s2''' ∧ silent_trace … t1 ∧ pre_silent_trace … t3
54 ; simulate_call_n:
55     ∀s1:S1.∀s2:S2.∀s1':S1.∀f,l.
56      as_execute … (call_act f l) s1 s1' →
57      ¬ is_call_post_label … s1 →
58      as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
59      Srel … rel s1 s2 →
60      ∃s2',s2'',s2'''.
61       ∃t1: raw_trace S2 s2 s2'.
62       bool_to_Prop (¬ is_call_post_label … s2') ∧
63       as_execute … (call_act f l) s2' s2'' ∧
64       ∃t3: raw_trace S2 s2'' s2'''.
65        Srel … rel s1' s2''' ∧ silent_trace … t1 ∧ pre_silent_trace … t3
66        ∧ Crel … rel s1 s2'
67 ; simulate_ret_n:
68     ∀s1:S1.∀s2:S2.∀s1':S1.
69      as_execute … (ret_act (None ?)) s1 s1' →
70      as_classify … s1 ≠ cl_io → as_classify … s1' ≠ cl_io →
71      Srel … rel s1 s2 →
72      ∃s2',s2'',s2''': S2.
73       ∃t1: raw_trace S2 s2 s2'.
74       as_execute … (ret_act (None ?)) s2' s2''  ∧
75       ∃t3: raw_trace S2 s2'' s2'''.
76        Srel … rel s1' s2''' ∧ pre_silent_trace … t1 ∧ pre_silent_trace … t3
77        ∧ Rrel … rel s1' s2''
78 ; simulate_io_in :
79   ∀s1:S1.∀s2:S2.∀s1':S1.∀l.
80   as_execute … (cost_act … (Some ? l)) s1 s1' →
81   as_classify … s1 ≠ cl_io → as_classify … s1' = cl_io →
82   Srel … rel s1 s2 →
83   ∃s2',s2''.∃t: raw_trace … s2 s2'.
84   pre_silent_trace … t ∧ as_execute … (cost_act … (Some ? l)) s2' s2'' ∧
85   as_classify … s2'' = cl_io ∧ Srel … rel s1' s2''
86; simulate_io_out :
87   ∀s1:S1.∀s2:S2.∀s1':S1.∀l.
88   as_execute … (cost_act … (Some ? l)) s1 s1' →
89   as_classify … s1 = cl_io → as_classify … s1' ≠ cl_io →
90   Srel … rel s1 s2 →
91   ∃s2',s2''.∃t : raw_trace … s2' s2''.
92   pre_silent_trace … t ∧ as_execute … (cost_act … (Some ? l)) s2 s2' ∧
93   as_classify … s2 = cl_io ∧ Srel … rel s1' s2''
94 }.
95
96lemma append_premeasurable_silent : ∀S : abstract_status.
97∀st1',st1,st2 : S.∀t : raw_trace S st1 st2.∀t' : raw_trace S st1' st1.
98pre_measurable_trace … t → silent_trace … t' → 
99pre_measurable_trace … (t' @ t).
100#S #st1' #st1 #st2 #t #t' lapply t -t elim t'
101[ #st #t #Hpre #_ whd in ⊢ (????%); assumption]
102#s1 #s2 #s3 #l #prf #tl #IH #t #Hpre * [2: * #H @⊥ @H %] #H inversion H in ⊢ ?;
103[ #s #H1 #EQ1 #EQ2 destruct #EQ destruct]
104#s1' #s2' #s3' #prf' #tl' #Hclass #silent_tl' #_ #EQ1 #EQ2 #EQ3
105destruct #_ whd in ⊢ (????%); %2
106[ assumption
107| %{(None ?)} %
108| @IH try assumption
109]
110% assumption
111qed.
112
113lemma pre_silent_is_premeasurable : ∀S : abstract_status.
114∀st1,st2 : S. ∀t : raw_trace S st1 st2.pre_silent_trace … t
115→ pre_measurable_trace … t.
116#S #st1 #st2 #t elim t
117[ #st #H inversion H in ⊢ ?; [ #st' #Hst #EQ1 #EQ2 #EQ3 destruct #_ %1 @Hst ]
118#st' #st'' #st''' #prf #tl #Hst'' #pre_tl #_ #EQ1 #EQ2 #EQ3 destruct ]
119-t -st1 -st2 #st1 #st2 #st3 #l #prf #tl #IH #H inversion H in ⊢ ?;
120[ #st #H2 #EQ1 #EQ2 #EQ3 destruct] #st1' #st2' #st3' #prf' #tl' #Hst2' #pre_tl'
121#_ #EQ1 #EQ2 #EQ3 destruct #_ %2 [ assumption | whd %{(None ?)} % ]
122@IH assumption
123qed.
124
125lemma append_tind_commute : ∀S : abstract_status.∀st1,st2,st3,st4 : S.∀l.
126    ∀prf : as_execute … l st1 st2. ∀t1 : raw_trace S st2 st3.
127    ∀t2 : raw_trace S st3 st4.t_ind … prf (t1 @ t2) = (t_ind … prf t1) @ t2.
128#S #st1 #st2 #st3 #st4 #l #prf #t1 #t2 % qed.   
129
130lemma append_silent_premeasurable : ∀S : abstract_status.
131∀st1',st1,st2 : S.∀t : raw_trace S st1 st2.∀t' : raw_trace S st1' st1.
132pre_measurable_trace … t' → silent_trace … t →
133pre_measurable_trace … (t' @ t).
134#S #st1' #st1 #st2 #t #t' #Ht' lapply t -t elim Ht'
135[ #st #Hst #r * [ #H1 @pre_silent_is_premeasurable assumption ]
136  inversion r [2: #H1 #H2 #H3 #H4 #H5 #H6 #H7 #H8 #H9 #H10 #H11 cases H11
137  #ABS @⊥ @ABS % ] #s' #EQ1 #EQ2 #EQ3 destruct #_
138  %1 assumption
139|2,3,4: #s1 #s2 #s3 #l #prf #tl #Hs1 * #x [|| * #l' ] #EQ destruct
140  [|| #Hs1_post ] #pre_tl #IH #r #pre_sil_r [ %2 | %3 | %4 ]
141  try ( %{x} %) try @IH try assumption % ]
142#s1 #s2 #s3 #s4 #s5 #l1 #l2 #pr1 #t1 #t2 #prf2 #Hs1 #Hs3 * #f * #l1'
143#EQ destruct #Hpost_s1 #pre_t1 #pre_t2 #Hs1_s4 #EQ destruct #IH1 #IH2
144#r #pre_r normalize
145>append_tind_commute >append_tind_commute >append_associative
146<append_tind_commute in ⊢ (????(??????%)); %5
147try assumption [1,3: whd [ %{f} %{l1'} ] % ] @IH2 assumption
148qed.
149
150(*
151lemma append_well_formed_silent : ∀S : abstract_status.
152∀st1',st1,st2 : S.∀t : raw_trace S st1 st2.∀t' : raw_trace S st1' st1.
153well_formed_trace … t → pre_silent_trace … t' →
154(is_trace_non_empty … t' → as_classify … st) →
155well_formed_trace … (t' @ t).
156#S #st1' #st1 #st2 #t #t' lapply t -t elim t'
157[ #st #t #H #_ #_ assumption ]
158#s1' #s2' #s3' #l #prf #tl #IH #t #well_formed_t #H
159inversion H in ⊢ ?;
160[ #st #EQ1 #EQ2 #EQ3 destruct]
161#st1'' #st2' #st3' #prf' #tl' #Hclass #silent_tl #_
162#EQ1 destruct #EQ #EQ1 destruct #_ #Hclass1 %2
163[2: >(Hclass1 I) % #EQ destruct]
164@IH try assumption #_ assumption
165qed.*)
166
167(*
168lemma well_formed_append : ∀S : abstract_status.
169∀st1,st2,st3 : S. ∀t1 : raw_trace S st1 st2.∀t2 : raw_trace S st2 st3.
170well_formed_trace … (t1 @ t2) → well_formed_trace … t1 ∧ well_formed_trace … t2.
171#S #st1 #st2 #st3 #t1 #t2 #H %
172[ lapply H -H lapply t2 -t2 elim t1 [ //] #st1' #st2' #st3' #l #exe #tl #IH #r
173#H inversion H in ⊢ ?; [ #st #EQ1 #EQ2 #EQ3 normalize in EQ3; destruct ]
174#st1'' #st2'' #st3'' #l' #prf' #tl' #wf_tl' [#Hst1'' | * #x #EQ destruct] #_
175#EQ1 #EQ2 normalize in ⊢ (% → ?); #EQ3 destruct #_
176[ %2 [ @IH assumption ] assumption | %3 [ @IH assumption ] %{x} % ]
177]
178lapply H lapply t2 -t2 elim t1 [ #st #r normalize //]
179#s1 #s2 #s3 #l #prf #tl #IH #r #H inversion H in ⊢ ?;
180[ #st #EQ1 #EQ2 normalize #EQ3 destruct ]
181#s1' #s2' #s3' #l' #prf' #tl' #wf_tl' #Hs1' #_ normalize #EQ1 #EQ2 #EQ3 destruct
182#_ @IH assumption
183qed.
184
185
186lemma append_well_formed : ∀S : abstract_status.
187∀st1,st2,st3 : S.∀t1 : raw_trace S st1 st2.∀t2 : raw_trace S st2 st3.
188well_formed_trace … t1 → well_formed_trace … t2 → well_formed_trace … (t1 @ t2).
189#S #st1 #st2 #st3 #t1 #t2 #H lapply t2 -t2 elim H
190[ #st #r #H1 @H1 ]
191#s1 #s2 #s3 #l #prf #tl #wf_tl #Hs1 #IH #r #wf_r normalize [ %2 | %3]
192try @IH assumption
193qed.
194(*
195lemma silent_is_well_formed : ∀S : abstract_status.
196∀st1,st2 : S.∀t : raw_trace … st1 st2.silent_trace … t → well_formed_trace … t.
197#S #st1 #st2 #t elim t [ #st #_ %]
198#s1 #s2 #s3 #l #prf #tl #IH * #H inversion H [ #st #EQ1 #EQ2 #EQ3 destruct]
199#s1' #s2' #s3' #prf' #tl' #Hs2' #tl' #_ #EQ1 #EQ2 #EQ3 destruct #_ #H1 %2
200[ @IH % [2: #_ ] assumption | >(H1 I) % #EQ destruct]
201qed.
202*)
203*)
204lemma get_cost_label_invariant_for_append_silent_trace_l :∀S : abstract_status.
205∀st1,st2,st3 : S.∀t1 : raw_trace S st1 st2.∀t2 : raw_trace S st2 st3.
206silent_trace … t1 →
207get_costlabels_of_trace … (t1 @ t2) = get_costlabels_of_trace … t2.
208#S #st1 #st2 #st3 #t1 elim t1
209[#st #t2 #_ %] #st1' #st2' #st3' #l' #prf #tl #IH #t2 *
210[2: whd in match is_trace_non_empty; normalize nodelta * #ABS @⊥ @ABS %]
211#H inversion H in ⊢ ?; [ #st #H1 #EQ1 #EQ2 #EQ3 destruct]
212#st1'' #st2'' #st3'' #prf'' #tl'' #Hclass #Htl'' #_ #EQ1 #EQ2 #EQ3 destruct
213#_ whd in ⊢ (??%?); >IH [%] %1 assumption
214qed.
215
216(*
217lemma raw_trace_ind_r : ∀S : abstract_status.
218∀P : (∀st1,st2.raw_trace S st1 st2 → Prop).
219(∀st : S.P … (t_base … st)) →
220(∀st1,st2,st3,l.
221 ∀prf : as_execute S l st2 st3.
222 ∀tl : raw_trace S st1 st2. P … tl → P … (tl @ (t_ind … prf … (t_base … st3)))) →
223∀st1,st2 : S.∀t : raw_trace S st1 st2.P … t.
224#S #P #base #ind #st1 #st2 #t elim t [ assumption]
225#st1 #st2 #st3 #l #prf #raw #IH
226*)
227
228lemma head_of_premeasurable_is_not_io : ∀S : abstract_status.
229∀st1,st2 : S. ∀t : raw_trace … st1 st2.pre_measurable_trace … t →
230as_classify … st1 ≠ cl_io.
231#S #st1 #st2 #t #H inversion H //
232qed.
233
234theorem simulates_pre_mesurable:
235 ∀S1,S2 : abstract_status.∀rel : relations S1 S2.
236 ∀s1,s1' : S1. ∀t1: raw_trace S1 s1 s1'.
237  simulation_conditions … rel →
238  pre_measurable_trace … t1 →
239  ∀s2 : S2.
240 as_classify … s2 ≠ cl_io →   Srel … rel s1 s2 →
241  ∃s2'. ∃t2: raw_trace … s2 s2'.
242    pre_measurable_trace … t2 ∧
243    get_costlabels_of_trace … t1 = get_costlabels_of_trace … t2 ∧
244    Srel … rel s1' s2'.
245#S1 #S2 #rel #s1 #s1' #t1 #good #pre_measurable elim pre_measurable
246[ #st #H1 #s2 #REL #Hs2 %{s2} %{(t_base …)}
247  /8 by refl, silent_empty, conj, pre_silent_is_premeasurable/
248| #st1 #st2 #st3 #l #execute #tl #ClASS ** [|#c] #EQ destruct
249  #pre_measurable_tl #IH #s2 #classify_s2 #REL
250  [ cases(simulate_tau … good … execute … REL) /2/ #s2'' * #t_s2'' * #RELst2s2''
251    #silent_ts2'' cases(IH … RELst2s2'')
252    [2: cases silent_ts2'' /2 by pre_silent_io/ inversion t_s2''
253        [ #x #EQ1 #EQ2 #EQ3 destruct // ]
254        #H13 #H14 #H15 #H16 #H17 #H18 #H19 #H20 #H21 #H22 destruct * #ABS @⊥ @ABS % ]
255    #s3 * #ts3 ** #pre_meas_ts3 #EQcost #RELst3s3
256    %{s3} %{(t_s2'' @ ts3)} % [2: assumption] % /2 by append_premeasurable_silent/
257    whd in ⊢ (??%?); /2/
258  | cases(simulate_label … good … execute … REL)
259    [2,3: /2/]
260    #s2'' * #s2''' * #s2'''' * #t_s2'' * #exe_s2''' * #t_s2'''' ** #RELst2_s2''''
261    #sil_ts2'' #sil_t_s2'''' cases(IH … RELst2_s2'''')  /2 by pre_silent_io/
262    #s3 * #t_s3 ** #pre_s3 #EQcost #RElst3s3 %{s3}
263    %{(t_s2'' @ (t_ind … exe_s2''' …))}  [ @(t_s2'''' @ t_s3) ] % [2: assumption]
264    %
265    [ @append_premeasurable_silent // %2 /2 by ex_intro/
266       [ cases sil_ts2'' [/2 by pre_silent_io/ ] inversion t_s2''
267         [ #H31 #H32 #H33 #H34 #H35 destruct assumption ]
268         #H37 #H38 #H39 #H40 #H41 #H42 #H43 #H44 #H45 #H46 #H47 destruct
269         cases H47 #ABS @⊥ @ABS % ]
270       @append_premeasurable_silent // % //
271    | whd in ⊢ (??%?); >EQcost >get_cost_label_invariant_for_append_silent_trace_l
272      [2: assumption] whd in ⊢ (???%);
273      >get_cost_label_invariant_for_append_silent_trace_l //
274    ]
275  ]
276  % assumption
277| #s2 #s2' #s2'' #l #class_s2 #exe_s2_s2' #tl whd in ⊢ (% → ?); * #ret_lab #EQ destruct(EQ)
278  #pre_meas_tl #IH #s2 #class_s2 #RELst1s2
279  cases(simulate_ret_l … good … exe_s2_s2' … RELst1s2) [2,3: /2/ ]
280  #st1 * #st2 * #st3 * #t1 * #exe_s2'' * #t2 ** #rel_s2_s2'''
281  #sil_t1 #sil_t2 cases(IH … rel_s2_s2''')
282  [2: @(pre_silent_io … sil_t2) assumption]
283  #s2_fin * #t_fin ** #pre_t_fin #EQcost #REL
284  %{s2_fin} %{(t1 @ (t_ind … exe_s2'' … t2) @ t_fin)} % [2: assumption]
285  % [2: whd in ⊢ (??%?);
286        >(get_cost_label_invariant_for_append_silent_trace_l … sil_t1)
287        whd in ⊢ (???%);
288        >(get_cost_label_invariant_for_append_silent_trace_l … (or_introl … sil_t2))
289        @eq_f assumption ]
290  @append_premeasurable_silent [2: //] %3
291  [2,3: /3 by append_premeasurable_silent, ex_intro, or_introl/ ]
292  cases sil_t1 [ /2 by pre_silent_io/ ] inversion t1
293  [ #H49 #H50 #H51 #H52 #H53 destruct //]
294  #H55 #H56 #H57 #H58 #H59 #H60 #H61 #H62 #H63 #H64 #H65 destruct cases H65
295  #ABS @⊥ @ABS %
296| #s1 #s2 #s3 #l #exe_s1_s2 #tl #class_s1 * #f * #lab #EQ destruct
297  #post #pre_tl #IH #s2' #io_s2' #REL_s1_s2'
298   cases(simulate_call_pl … good … post … exe_s1_s2 … REL_s1_s2')
299   [2,3: /2 by head_of_premeasurable_is_not_io/ ]
300   #s' * #s2'' * #s2''' * #t1 ** #exe_s2'' #post' * #t2 ** #REL #sil_t1 #sil_t2
301   cases(IH  … REL)
302   [2: /2 by pre_silent_io/ ]
303   #s2_fin * #t_fin ** #pre_t_fin #EQcost #REL1 %{s2_fin}
304   %{(t1 @ (t_ind … exe_s2'' … t2) @ t_fin)} % [2: assumption] %
305   [2: whd in ⊢ (??%?);
306        >(get_cost_label_invariant_for_append_silent_trace_l … sil_t1)
307        whd in ⊢ (???%);
308        >(get_cost_label_invariant_for_append_silent_trace_l …  (or_introl … sil_t2))
309        @eq_f assumption ]
310   @append_premeasurable_silent try assumption
311     %4 try assumption
312     [ cases sil_t1 [/2 by pre_silent_io/ ] inversion t1 [#H67 #H68 #H69 #H70 #H71 destruct //]
313       #H73 #H74 #H75 #H76 #H77 #H78 #H79 #H80 #H81 #H82 #H83 destruct cases H83
314       #ABS @⊥ @ABS %
315     | whd %{f} %{lab} %
316     | @append_premeasurable_silent // % assumption
317     ]
318| #st1 #st2 #st3 #st4 #st5 #l1 #l2 #exe_12 #t1 #t2 #exe_34 #class_1 #class_3 *
319  #f * #l #EQ destruct #Hst1 #pre_t1 #pre_t2 #succ_14 whd in ⊢ (% → ?); #EQ destruct
320  #IH1 #IH2 #st1' #Hst1' #REL cases(simulate_call_n … good … exe_12 … Hst1 … REL) [2,3: /2/ ]
321  #st1'' * #st1''' * #st2' * #tr1 ** #nps_st1'' #exe_12' * #tr2 *** #REL1 #sil_tr1
322  #sil_tr2 #call_rel cases(IH1 … REL1)
323  [2: /2 by pre_silent_io/ ]
324  #st3' * #tr3 ** #pre_tr3 #EQcost_tr3 #REL2
325  cases(simulate_ret_n … good … exe_34 … REL2) [2,3: /2 by head_of_premeasurable_is_not_io/ ]
326  #st3'' * #st4' * #st4'' *
327  #tr4 * #exe_34' * #tr5 *** #REL3 #sil_tr4 #sil_tr5 #RET_REL cases(IH2 … REL3) [2: /2 by pre_silent_io/ ]
328  #st5' * #tr6 ** #pre_tr6 #EQcost_tr6 #REL4 %{st5'}
329  %{(tr1 @ (t_ind … exe_12' …  ((tr2 @ tr3 @ tr4) @ (t_ind … exe_34' … (tr5 @tr6)))))}
330  % [2: assumption] %
331  [ @append_premeasurable_silent try assumption %5
332       [1,2: /2 by pre_silent_io/
333             cases sil_tr1 /2 by pre_silent_io/ inversion tr1
334             [ #H85 #H86 #H87 #H88 #H89 destruct // ]
335             #H97 #H98 #H99 #H100 #H101 #H102 #H103 #H104 #H105 #H106 #H107 destruct
336             cases H107 #ABS @⊥ @ABS %
337       | whd %{f} %{l} %
338       | assumption
339       | @append_premeasurable_silent try assumption [2: % //]
340         @append_silent_premeasurable // % //
341       | @append_premeasurable_silent try assumption
342       | @(RET_REL … call_rel) assumption
343       | %
344       ]
345  | >get_cost_label_invariant_for_append_silent_trace_l [2: // ]
346    whd in ⊢ (??%%); @eq_f >append_associative
347    >get_cost_label_invariant_for_append_silent_trace_l in ⊢ (???%);
348    [2: % // ] >append_associative
349    >get_cost_label_append in ⊢ (???%);
350    >get_cost_label_invariant_for_append_silent_trace_l in ⊢ (???%);
351    [2: % //] normalize
352    >get_cost_label_invariant_for_append_silent_trace_l in ⊢ (???%);
353    [2: % // ] >get_cost_label_append in ⊢ (??%?); @eq_f2
354    assumption
355  ]
356  % //
357]
358qed.
359
360(* IDEA: aggiungere stati di I/O e cambiare la semantica del linguaggio
361   sorgente; aggiungere nella pre_measurable il vincolo nessuno stato e' di I/O;
362   cambiare la definizione di traccia tornando a una sola etichetta sugli archi *)
363
364(*
365lemma cl_io_case : ∀P : status_class → Prop. P cl_io → (∀x.x≠cl_io → P x) → ∀s.P s.
366#P #H1 #H2 * // @H2 % #EQ destruct qed.
367
368lemma case_cl_io : ∀s : status_class.decidable … (s = cl_io).
369* [2: %%] %2 % #EQ destruct qed.
370
371lemma tail_of_premeasurable_is_not_io : ∀S : abstract_status.
372∀st1,st2 : S. ∀t : raw_trace … st1 st2.pre_measurable_trace … t →
373as_classify … st2 ≠ cl_io.
374#S #st1 #st2 #t #H elim H //
375qed.
376
377lemma get_cost_label_invariant_for_append_silent_trace_r :∀S : abstract_status.
378∀st1,st2,st3 : S.∀t1 : raw_trace S st1 st2.∀t2 : raw_trace S st2 st3.
379silent_trace … t2 →
380get_costlabels_of_trace … (t1 @ t2) = get_costlabels_of_trace … t1.
381#S #st1 #st2 #st3 #t1 #t2 #H >get_cost_label_append
382>(get_cost_label_silent_is_empty … H) //
383qed.
384
385lemma instr_execute_commute : ∀S1,S2 :abstract_status.
386∀rel : relations S1 S2.
387simulation_conditions … rel →
388∀s1,s1': S1.∀l.l ≠ cost_act (None ?) →  as_execute … l s1 s1' →
389(as_classify … s1 ≠ cl_io ∨ as_classify … s1' ≠ cl_io) →
390∀s2.
391Srel … rel s1 s2 →
392∃s2' : S2.∃tr : raw_trace … s2 s2'.silent_trace … tr ∧
393∃s2'' : S2.as_execute … l s2' s2'' ∧ ∃s2''' : S2.
394∃tr' : raw_trace … s2'' s2'''. silent_trace … tr' ∧ Srel … rel s1' s2''' ∧
395(is_call_act l → is_call_post_label … s1 → is_call_post_label … s2') ∧
396(as_classify … s1' ≠ cl_io → as_classify … s2'' ≠ cl_io).
397#S1 #S2 #rel #good #s1 #s1' #l #l_notau #prf #HIO #s2 #REL cases(case_cl_io … (as_classify … s1))
398[ #EQs1_io cases(io_exiting … EQs1_io … prf) #lab #EQ destruct(EQ)
399  cases HIO [ >EQs1_io * #EQ @⊥ @EQ % ] #Hio_s1'
400  cases(simulate_io_out … good … prf … EQs1_io Hio_s1' … REL)
401  #s2' * #s2'' * #t *** #sil_t #prf' #class_io #REL'
402  %{s2} %{(t_base …)} % [ %2 % * ] %{s2'} % // %{s2''} %{t} % 
403  [2: #_ @(head_of_premeasurable_is_not_io … t) @pre_silent_is_premeasurable
404     assumption ] % [  %//  % // ] * #f * #l #EQ destruct
405| #Hclass_s1 cases(case_cl_io … (as_classify … s1'))
406  [ #EQs1' cases(io_entering … EQs1' … prf) #l1 #EQ destruct(EQ)
407    cases(simulate_io_in … good … prf … Hclass_s1 EQs1' …  REL) #s2' * #s2'' * #t
408    *** #sil_t #exe #Hclass_s2'' #REL'  %{s2'} %{t} %{(or_introl … sil_t)} %{s2''}
409    %{exe} %{s2''} %{(t_base …)} % [2: >EQs1' * #H @⊥ @H % ] %
410     [ /4 by or_intror, conj, nmk/] * #f * #l #EQ destruct
411  | #Hclass_s1' cases l in prf l_notau;
412    [ #f #l #prf #_ inversion(is_call_post_label … s1)
413      [ #Hpost cases(simulate_call_pl … good … prf … REL)
414        [2: >Hpost % |3,4: assumption]
415        #s2' * #s2'' * #s2''' * #t1 ** #exe #Hpost' * #t3 * * #REL #sil_t1 #sil_t3
416        %{s2'} %{t1} %{sil_t1} %{s2''} %{exe} %{s2'''} %{t3} %
417        [2: #_ @(head_of_premeasurable_is_not_io … t3) /2 by pre_silent_is_premeasurable/ ]
418        % [ /4 by or_introl, conj/ ] /3 by /
419     | #Hpost cases(simulate_call_n … good … prf … REL)
420       [2: >Hpost % |3,4: // ] #s2' * #s2'' * #s2''' * #t1 ** #Hpost' #exe * #t3
421       *** #REL' #sil_t1 #sil_t3 #_ %{s2'} %{t1} %{sil_t1} %{s2''} %{exe} %{s2'''}
422       %{t3} % [2: #_ @(head_of_premeasurable_is_not_io … t3) /2 by pre_silent_is_premeasurable/ ]
423       % [2: #_ *] % //
424     ]
425   | *
426     [ #prf #_ cases(simulate_ret_n … good … prf … REL) [2,3: //] #s2' * #s2''
427       * #s2''' * #t1 * #exe * #t3 *** #REL' #sil_t1 #sil_t3 #_ %{s2'}
428       %{t1} %{(or_introl … sil_t1)} %{s2''} %{exe} %{s2'''} %{t3} %
429       [2: #_ @(head_of_premeasurable_is_not_io … t3) /2 by pre_silent_is_premeasurable/ ]
430       % [ % // % // ] * #f * #l #EQ destruct
431     | #l #prf #_ cases(simulate_ret_l … good … prf … REL) [2,3: //]
432       #s2' * #s2'' * #s2''' * #t1 * #exe * #t3 ** #REL' #sil_t1 #sil_t3
433       %{s2'} %{t1} %{sil_t1} %{s2''} %{exe} %{s2'''} %{t3} %
434       [2: #_ @(head_of_premeasurable_is_not_io … t3) /2 by pre_silent_is_premeasurable/ ]
435       % [ % // % //] * #f * #l #EQ destruct
436    ]
437  | * [ #_ * #H @⊥ @H % ] #lab #prf #_
438    cases(simulate_label … prf … REL) [2,3,4: // ] #s2' * #s2'' * #s2''' * #t1
439    * #exe * #t3 ** #REL' #sil_t1 #sil_t3 %{s2'} %{t1} %{sil_t1} %{s2''} %{exe}
440    %{s2'''} %{t3} %
441    [2: #_ @(head_of_premeasurable_is_not_io … t3) /2 by pre_silent_is_premeasurable/ ]
442    % [% // % //] * #f * #l #EQ destruct
443  ]
444  % //
445]
446qed.
447*)
Note: See TracBrowser for help on using the repository browser.