source: LTS/Lang_meas.ma @ 3535

Last change on this file since 3535 was 3535, checked in by piccolo, 5 years ago

final statement of cerco with the first pass integrated in place

File size: 15.6 KB
Line 
1(**************************************************************************)
2(*       ___                                                              *)
3(*      ||M||                                                             *)
4(*      ||A||       A project by Andrea Asperti                           *)
5(*      ||T||                                                             *)
6(*      ||I||       Developers:                                           *)
7(*      ||T||         The HELM team.                                      *)
8(*      ||A||         http://helm.cs.unibo.it                             *)
9(*      \   /                                                             *)
10(*       \ /        This file is distributed under the terms of the       *)
11(*        v         GNU General Public License Version 2                  *)
12(*                                                                        *)
13(**************************************************************************)
14
15include "Language.ma".
16
17
18lemma top_move_source_is_empty : ∀p,p',prog.
19let 〈t_prog,m,keep〉 ≝ trans_prog … prog in
20∀l.
21∀s1,s2,s1' : state p.∀abs_top,abs_tail.
22execute_l … p' (env … prog) l s1 s2 →
23is_costlabelled_act l →
24(is_call_act l → is_call_post_label (operational_semantics p p' prog) … s1) →
25state_rel … m keep abs_top abs_tail s1 s1' → abs_top = nil ? ∧
26(is_call_act l → is_call_post_label (operational_semantics p p' t_prog) … s1').
27#p #p' #prog @pair_elim * #t_prog #m #keep #EQt_prog normalize nodelta
28#l #s1 #s2 #s1' #abs_top #abs_tail #H elim H -s1 -s2 -l
29[ #s1 #s2 * #lab #code_cont #stack #EQcode #EQcont #EQ1 #EQ2 destruct #EQstore
30  #Hio1 #Hio2 #no_ret_lab #cost_lab whd in match state_rel; normalize nodelta
31  inversion(check_continuations ?????) [ #_ #_ *] ** #Hcont #a_top #a_tail #EQcheck #_
32  normalize nodelta **** #HHcont #EQcall_post #EQstore #EQio #EQ destruct
33  >EQcont in EQcheck; whd in ⊢ (??%? → ?); inversion(cont … s1') normalize nodelta
34  [ #_ #EQ destruct] * #lab' #code_cont' #stack' #_ #EQcont'
35    change with (check_continuations ?????) in match (foldr2 ???????);
36    inversion(check_continuations ?????) [ #_ normalize #EQ destruct]
37    ** #H2 #a_top1 #a_tail1 #EQcheck >m_return_bind normalize nodelta
38    inversion(call_post_clean ?????) normalize nodelta [ #_ whd in ⊢ (??%% → ?); #EQ destruct cases HHcont]
39    * #labels #code_cleaned #EQclean normalize nodelta
40    >EQcode in EQcall_post; inversion(code ? s1')
41        [2,3,4,5,6,7: cases daemon (*ASSURDI*)
42        | #EQcode_s1' whd in ⊢ (??%% → ?); #EQ destruct cases lab' normalize nodelta
43          [ #f #c whd in ⊢ (??%% → ?); #EQ destruct %{(refl …)} cases HHcont
44          | * normalize nodelta [| #Lab cases(ret_costed_abs ??) normalize nodelta [| #xxx]] whd in ⊢ (??%% → ?);
45            #EQ destruct %{(refl …)} cases HHcont * [3: *] #EQ destruct #_ #_ [ #_] * #f * #c #EQ destruct
46          | * [|#LAB] normalize nodelta whd in ⊢ (??%% → ?); #EQ destruct % // cases HHcont * #EQ destruct
47            try cases cost_lab #_ #_ cases EQ -EQ #EQ destruct #_ * #f * #c #EQ destruct
48          ]
49        ]
50| #s1 #s2 #i #instr #st * [|#lbl] #EQcode_s1 #EQst #EQ destruct #EQcont #EQ destruct #Hios1 #Hios2 *
51  whd in match state_rel; normalize nodelta cases(check_continuations ?????) normalize nodelta [ #_ *] **
52  #H1 #a_top #a_tail normalize nodelta #_ **** #HH1 >EQcode_s1 inversion(code ? s1')
53  [1,2,4,5,6,7: cases daemon (* ASSURDI*)
54  | #i' * [|#lb] #instr' #_ #EQcode_s1' whd in ⊢ (??%% → ?); cases(call_post_clean ?????) normalize nodelta
55    [1,3: #EQ destruct] #x whd in ⊢ (??%% → ?); [ #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct ]
56    cases(get_element ???) normalize nodelta [#EQ destruct] #LAB #ll normalize nodelta cases(?==?) normalize nodelta
57    [2:  #EQ destruct] whd in ⊢ (??%% → ?); #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct #_ #_ #_ % // * #f * #c #EQ4 destruct
58 ]
59| cases daemon
60| cases daemon
61| cases daemon
62| cases daemon
63| #s1 #s2 #lin #io #lout #instr #men #EQcode  #EQeval #EQcodes2 #EQcont_s2 #EQ destruct #Hio * whd in match state_rel;
64  normalize nodelta cases(check_continuations ?????) normalize nodelta [ #_ *] **
65  #H1 #a_top #a_tail normalize nodelta #_ **** #HH1 >EQcode inversion(code ? s1')
66  [1,2,3,4,5,6: cases daemon (* ASSURDI*)
67  | #lin' #io' #lout' #i' #_ #EQcode_s1' whd in ⊢ (??%% → ?); cases(call_post_clean ?????) normalize nodelta
68    [ #EQ destruct] #x
69    cases(get_element ???) normalize nodelta [#EQ destruct] #LAB #ll normalize nodelta cases(?∧?) normalize nodelta
70    [2:  #EQ destruct] whd in ⊢ (??%% → ?); #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct #_ #_ #_ % // * #f * #c #EQ destruct
71 ]
72| #s1 #s2 #f #act_p #lbl #instr #men #env_it #EQcode #EQenv_it  #EQeval #EQ destruct #EQcodes2 #EQ destruct #_ #_ *
73  whd in match state_rel; normalize nodelta cases(check_continuations ?????) normalize nodelta [ #_ *] **
74  #H1 #a_top #a_tail normalize nodelta #Hcall **** #HH1 >EQcode inversion(code ? s1')
75  [1,2,3,4,5,7: cases daemon (* ASSURDI*)
76  |*: #f' #act_p' #lbl' #instr' #_ #EQcode_s1' whd in ⊢ (??%% → ?); cases(call_post_clean ?????) normalize nodelta
77    [ #EQ destruct] #x cases lbl' in EQcode_s1'; normalize nodelta [ #_ #EQ destruct] #lbl'' #EQcode_s1'
78    inversion(?∈?) normalize nodelta
79    [#_ cases(get_element ???) normalize nodelta [#EQ destruct] #LAB #ll normalize nodelta
80      cases(?==?) normalize nodelta
81    [2:  #EQ destruct] whd in ⊢ (??%% → ?); #EQ1 lapply(eq_to_jmeq ??? EQ1) -EQ1 #EQ1 destruct #_#_ #EQ1 destruct % //
82    #_ whd in match (is_call_post_label ??); >EQcode_s1' %
83    ]
84    #ABS whd in ⊢ (??%% → ?);  #EQ1 lapply(eq_to_jmeq ??? EQ1) -EQ1 #EQ1 destruct lapply(Hcall ?) [ %{f} %{(f_lab … env_it)} %]
85    whd in ⊢ (% → ?); whd in match (is_call_post_label ??); normalize nodelta >EQcode *
86 ]
87| #s1 #s2 #r_t #mem #stack * [|#lbl] #i #EQcode #EQcont #EQ destruct #_ #_ #EQeval #EQ1 #EQ2 destruct * #_
88  whd in match state_rel; normalize nodelta inversion(check_continuations ?????) normalize nodelta [ #_ *]
89  ** #H1 #a_top #a_tail #EQcheck normalize nodelta **** #HH1 >EQcode inversion(code … s1')
90  [1,3,4,5,6,7: cases daemon (*ASSURDI*)
91  | #r_t' #EQcode_s1' whd in ⊢ (??%% → ?); #EQ1 lapply(eq_to_jmeq ??? EQ1) -EQ1 #EQ1 destruct
92    >EQcont in EQcheck; inversion (cont ? s1') [ #_ whd in ⊢ (??%% → ?); #EQ destruct]
93    * #LAB #instrs #stack' #_ #EQcont_s1' whd in match check_continuations; normalize nodelta
94    whd in match (foldr2 ???????); change with (check_continuations ?????) in match (foldr2 ???????);
95    cases(check_continuations ?????) normalize nodelta [#EQ destruct] ** #H2 #a_top1 #a_tail1
96    normalize nodelta   whd in ⊢ (??%? → ?); cases(call_post_clean ?????) normalize nodelta [ #EQ destruct cases HH1]
97    * #ret_top #cleaned cases LAB in EQcont_s1';
98    [ #f #c #_ normalize nodelta #EQ destruct cases HH1
99    | *
100      [ #EQcont_s1' normalize nodelta #EQ destruct cases HH1 * #EQ destruct
101      | #lbl1 #EQcont_s1' whd in match ret_costed_abs; normalize nodelta inversion(? ∈ ?) normalize nodelta
102        [ #EQkeep #EQ destruct cases HH1 ** #EQ destruct #HH2 #EQ destruct #_ #_ #_ #_ % // * #f * #c #EQ destruct
103        | #EQkeep #EQ destruct #_ #_ #_ % // * #f * #c #EQ destruct
104        ]
105      ]
106    | * [|#lbl] #EQcont_s1' normalize nodelta  #EQ destruct cases HH1 *  #EQ destruct cases EQ -EQ #EQ destruct
107    ]
108  ]
109]
110qed.
111
112lemma bool_true : ∀b : bool.b=true → b. * // #EQ destruct qed.
113(*
114axiom actionlabel_of_cost_is_not_empty : ∀l : ActionLabel.
115is_costlabelled_act l → ∃c.actionlabel_to_costlabel l = [c].
116*)
117lemma labelled_action_is_correct :
118∀p,p',prog.
119no_duplicates_labels … prog →
120let 〈t_prog,m,keep〉 ≝ trans_prog … prog in
121∀s1,s2,s1' : state p.∀abs_top,abs_tail.
122∀l.is_costlabelled_act l →
123∀prf :execute_l p p' (env … prog) l s1 s2.
124state_rel … m keep abs_top abs_tail s1 s1' →
125∃abs_top'.∃s2'.
126execute_l p p' (env … t_prog) l s1' s2' ∧
127state_rel  … m keep abs_top' abs_tail s2 s2' ∧
128map_labels_on_trace … m … (actionlabel_to_costlabel l) =
129actionlabel_to_costlabel l @ abs_top'.
130#p #p' #prog  #no_dup @pair_elim * #t_prog #m #keep #EQt_prog normalize nodelta
131#s1 #s2 #s1' #abs_top #abs_tail #l #Hl #H lapply Hl -Hl elim H -s1 -s2 -l
132[ #s1 #s2 * #lbl #i #stack #EQcode_s1 #EQcont_s1 #EQ destruct #EQ destruct #EQstore #Hio1 #Hio2
133  #Hlbl #cost_lbl whd in match state_rel in ⊢ (% → ?); normalize nodelta inversion(check_continuations ?????)
134  normalize nodelta [ #_ *] ** #H1 #a_top #a_tail >EQcont_s1 inversion(cont … s1') [ #_ whd in ⊢ (??%% → ?); #EQ destruct]
135  * #lbl' #i' #stack' #_ #EQcont_s1' whd in ⊢ (??%% → ?); change with (check_continuations ?????) in match (foldr2 ???????);
136  inversion(check_continuations ?????) normalize nodelta [ #_ #EQ destruct] ** #H2 #a_top1 #a_tail1 #EQcheck
137  normalize nodelta inversion(call_post_clean ?????) normalize nodelta [#_ whd in ⊢ (??%% → ?); #EQ destruct ***** ]
138  * #gen_labels #cleaned_i' #EQclean cases lbl' in EQcont_s1'; -lbl' normalize nodelta
139  [ #f #c #_ whd in ⊢ (??%% → ?); #EQ destruct *****
140  | * [|#lbl'] normalize nodelta #_ whd in ⊢ (??%% → ?); [2: cases(ret_costed_abs ??) normalize nodelta [|#lbl'']]
141    #EQ destruct ****** [2: *] #EQ destruct @⊥ cases Hlbl #H @H %
142  | * [|#lbl'] #EQcont_s1' normalize nodelta whd in ⊢ (??%% → ?); #EQ destruct ****** [2: *] #EQ destruct
143    cases cost_lbl #HH2 #EQ destruct #EQget #EQ_cleaned #EQstore #EQio #EQ destruct
144    >EQcode_s1 in EQ_cleaned; inversion(code ? s1')
145    [2,3,4,5,6,7: cases daemon (*ASSURDI*)] #EQcode_s1' whd in ⊢ (??%% → ?); #EQ destruct
146    %{gen_labels} %{(mk_state … i' stack' (store … s1') false)} %
147    [% [ @(empty … EQcode_s1' EQcont_s1') // #_ %{lbl'} %]
148       whd >EQcheck in ⊢ (match % with [_ ⇒ ? | _ ⇒ ?]); normalize nodelta % // % // % // % // >EQclean %]
149   whd in match actionlabel_to_costlabel; normalize nodelta whd in ⊢ (??%%); >EQget >append_nil %
150 ]
151| #s1 #s2 #seq #i #store * [|#lbl] #EQcode_s1 #EQeval #EQ destruct #EQcont #EQ destruct #Hio1 #Hio2 *
152  whd in match state_rel in ⊢ (% → ?); normalize nodelta inversion(check_continuations ?????) normalize nodelta
153  [#_ *] ** #H1 #a_top #a_tail #EQcheck normalize nodelta **** #HH1 >EQcode_s1 inversion(code ? s1')
154  [1,2,4,5,6,7: cases daemon (*ASSURDI*)] #seq' #opt_l' #i' #_ #EQcode_s1' whd in ⊢ (??%% → ?);
155  inversion(call_post_clean ?????) normalize nodelta [ #_ #EQ destruct] * #genlab #cleaned #EQcleaned
156  cases opt_l' in EQcode_s1'; normalize nodelta [|#lbl'] #EQcode_s1' [| inversion(?==?) normalize nodelta #EQget]
157  whd in ⊢ (??%% → ?); #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct #EQst #EQioinfo #EQ destruct
158  %{genlab} %{(mk_state … i' (cont … s1') (store … s2) false)} % [ %
159  [ @(seq_sil … EQcode_s1') // ]
160  whd <EQcont >EQcheck normalize nodelta % // % // % // % // >EQcleaned %]
161  whd in match actionlabel_to_costlabel; normalize nodelta whd in ⊢ (??%%); >(\P EQget) >append_nil %
162| cases daemon
163| cases daemon
164| cases daemon
165| cases daemon
166| #s1 #s2 #lin #io #lout #i #store #EQcode_s1 #EQeval #EQcode_s2 #EQcont_s2. #EQ destruct #EQio_s2 *
167  whd in match state_rel in ⊢ (% → ?); normalize nodelta inversion(check_continuations ?????) normalize nodelta [#_ *]
168  ** #H1 #a_top #a_tail #EQcheck normalize nodelta **** #HH1 >EQcode_s1 inversion(code ? s1')
169  [1,2,3,4,5,6: cases daemon (*ASSURDI*) ]
170  #lin' #io' #lout' #i' #_ #EQcode_s1' whd in ⊢ (??%% → ?); inversion(call_post_clean ?????) normalize nodelta [ #_ #EQ destruct]
171  * #genlab #cleaned #EQcleaned inversion(?∧?) normalize nodelta #EQget whd in ⊢ (??%% → ?); #EQ lapply(eq_to_jmeq ??? EQ) -EQ
172  #EQ destruct #EQstore_s1_s1' #EQioinfo #EQ destruct %{[]}
173  %{(mk_state … (EMPTY …) (〈cost_act (Some ? lout),i'〉::(cont … s1')) (store … s2) true)} % [%
174  [ @(io_in … EQcode_s1') // ]
175  whd >EQcont_s2 whd in match (check_continuations ?????); change with (check_continuations ?????) in match (foldr2 ???????);
176  >EQcheck normalize nodelta >EQcleaned normalize nodelta % // % // % // % [2: >EQcode_s2 %] %
177  [2: cases(andb_Prop_true … (bool_true … EQget)) #H #_ >(\P (bool_true … H)) % ] % // % //]
178  cases(andb_Prop_true … (bool_true … EQget)) #_ #EQget'
179  whd in match actionlabel_to_costlabel; normalize nodelta whd in ⊢ (??%%); >append_nil >append_nil inversion(? == ?) in EQget';
180  [2: #_ *] #EQget' #_ >(\P EQget') %
181|*: cases daemon
182]
183qed.
184
185include "Vm.ma".
186
187theorem correctness_theorem : ∀p,p',prog.
188no_duplicates_labels … prog →
189let 〈t_prog,m,keep〉 ≝ trans_prog … prog in
190∀si,s1,s2,sn,si' : state p.∀abs_top,abs_tail.
191∀t : raw_trace (operational_semantics … p' prog) si sn.
192measurable (operational_semantics … p' prog) … s1 s2 … t →
193state_rel … m keep abs_top abs_tail si si' →
194∃abs_top',abs_tail'.∃sn'.∃t' : raw_trace (operational_semantics … p' t_prog) si' sn'.
195state_rel  … m keep abs_top' abs_tail' sn sn' ∧
196is_permutation ? (map_labels_on_trace m (chop … (get_costlabels_of_trace … t))) 
197                  (chop … (get_costlabels_of_trace … t')) ∧
198                  ∃s1',s2'.
199measurable (operational_semantics … p' t_prog)  … s1' s2' … t'.
200#p #p' #prog #no_dup @pair_elim * #t_prog #m #keep #EQt_prog normalize nodelta
201#si #s1 #s3 #sn #si' #abs_top #abs_tail #t *  #s0 * #s2 * #ti0 * #t12 * #t3n * #l1 * #l2
202* #prf1 * #prf2 ******* #pre_t12 #EQ destruct #Hl1 #Hl2 #Hcall_fin #sil_ti0 #sil_t3n #Hcall_init #Rsi_si'
203lapply(silent_in_silent … p' prog no_dup) >EQt_prog normalize nodelta #Hsilent
204cases(Hsilent … sil_ti0 … Rsi_si')
205#abs_top1 * #s0' * #t_i0' * #Rs0_s0' #sil_ti0'
206lapply(labelled_action_is_correct … p' prog no_dup) >EQt_prog normalize nodelta #Hmove
207cases(Hmove … prf1 … Rs0_s0') //
208#abs_top2 * #s1' ** #prf1' #Rs1_s1' #EQmap_l1
209lapply(correctness_lemma … p' prog no_dup) >EQt_prog normalize nodelta #H
210cases(H … pre_t12 … Rs1_s1') -H
211#abs_top3 * #s2' * #t12' ***** #Rs2_s2' #Hperm #_ #_ #pre_t12' #_
212cases(Hmove … prf2 … Rs2_s2') -Hmove //
213#abs_top4 * #s3' ** #prf2' #Rs3_s3' #EQmap_l2
214cases(Hsilent … sil_t3n … Rs3_s3')
215#abs_top5 * #sn' * #t3n' * #Rsn_sn' #sil_t3n'
216%{abs_top5} %{abs_tail} %{sn'}
217%{(t_i0' @ (t_ind … prf1' (t12' @ (t_ind … prf2' t3n'))))} %
218[ %{Rsn_sn'} >get_cost_label_append >get_cost_label_append >(get_cost_label_silent_is_empty … sil_ti0)
219  >(get_cost_label_silent_is_empty … sil_ti0') >(get_cost_label_append … (t_ind … (t_base …)))
220  >(get_cost_label_append … (t_ind … (t_base …))) in ⊢ (???%); >get_cost_label_append
221  >get_cost_label_append whd in match (get_costlabels_of_trace … (t_ind … t3n));
222  whd in match (get_costlabels_of_trace … (t_ind … t3n'));
223  >(get_cost_label_silent_is_empty … sil_t3n) >(get_cost_label_silent_is_empty … sil_t3n')
224  >append_nil cases(actionlabel_ok … Hl2) #c2 #EQc2 >EQc2 <associative_append <associative_append
225  <associative_append >chop_append_singleton <associative_append <associative_append >chop_append_singleton
226  >append_nil whd in match (get_costlabels_of_trace ??? (t_ind (operational_semantics p p' t_prog) … prf1' (t_base …)));
227  >append_nil >map_labels_on_trace_append >EQmap_l1 >associative_append @is_permutation_append_left_cancellable
228  lapply(top_move_source_is_empty … p' prog) >EQt_prog normalize nodelta #H
229  >(proj1 … (H … prf2 Hl2 … Rs2_s2')) in Hperm; [2: assumption] >append_nil @permute_equal_right
230| %{s1'} %{s3'} whd %{s0'} %{s2'} %{t_i0'} %{t12'} %{t3n'} %{l1} %{l2} %{prf1'} %{prf2'}
231  % [2: lapply(top_move_source_is_empty … p' prog) >EQt_prog normalize nodelta #H
232  @(proj2 … (H … prf1 Hl1 … Rs0_s0')) assumption ] % // % // %
233  [2: lapply(top_move_source_is_empty … p' prog) >EQt_prog normalize nodelta #H
234  @(proj2 … (H … prf2 Hl2 … Rs2_s2')) assumption ] % // % // % //
235]
236qed.
Note: See TracBrowser for help on using the repository browser.