source: src/Clight/CexecSound.ma @ 2576

Last change on this file since 2576 was 2468, checked in by garnier, 7 years ago

Floats are gone from the front-end. Some trace amount might remain in RTL/RTLabs, but this should be easily fixable.
Also, work-in-progress in Clight/memoryInjections.ma

File size: 19.5 KB
RevLine 
[700]1include "Clight/Cexec.ma".
[2019]2include "Clight/CexecInd.ma".
[399]3
[487]4lemma exec_bool_of_val_sound: ∀v,ty,r.
[399]5 exec_bool_of_val v ty = OK ? r → bool_of_val v ty (of_bool r).
[487]6#v #ty #r
[2468]7cases v; [ | #sz #i (*| #f*) |  | #ptr ]
8cases ty; [ 2,10,18,26: #sz' #sg | 3,11,19,27: #ty' | 4,12,20,28: (*#r*) #ty #n
9           | 5,13,21,29: #args #rty | 6,7,14,15,22,23,30,31: #id #fs | 8,16,24,32: (*#r*) #id ]
[1516]10whd in ⊢ (??%? → ?);
[961]11[ 2: @intsize_eq_elim_elim
12  [ #NE #H destruct
13  | *; whd @eq_bv_elim
14    [ #E1 #E2 destruct @bool_of_val_false @is_false_int
[1410]15    | #E1 #E2 destruct @bool_of_val_true @is_true_int_int @E1
[961]16    ]
[487]17  ]
[2468]18(*| 8: #H cases (eq_dec f Fzero)
[1516]19  [ #e >e in H ⊢ %; >Feq_zero_true #E destruct @bool_of_val_false @is_false_float
20  | #ne >Feq_zero_false in H; // #E destruct @bool_of_val_true @is_true_float @ne
[2468]21  ]*)
22| 7: #H destruct @bool_of_val_false @is_false_pointer
23| 8: #H destruct @bool_of_val_true @is_true_pointer_pointer
[961]24| *: #H destruct
[487]25] qed.
[399]26
[487]27lemma bool_val_distinct: Vtrue ≠ Vfalse.
[1410]28% normalize #H destruct
[487]29qed.
[399]30
[487]31lemma bool_of: ∀v,ty,b. bool_of_val v ty (of_bool b) →
[399]32  if b then is_true v ty else is_false v ty.
[1336]33#v #ty #b cases b; #H inversion H; #v' #ty' #H' #ev #et #ev' //;
34@⊥ cases (bool_val_distinct) #X @X [2: @sym_eq] @ev'
[487]35qed.
[399]36
[961]37lemma try_cast_null_sound: ∀m,sz,i,ty,ty',v'. try_cast_null m sz i ty ty' = OK ? v' → cast m (Vint sz i) ty ty' v'.
38#m #sz #i #ty #ty' #v'
[1516]39whd in ⊢ (??%? → ?);
[961]40@eq_bv_elim
[487]41[ #e >e
[2468]42    cases ty; [ | #sz' #sg (* | #fs *) | (*#sp*) #ty | (*#sp*) #ty #n | #args #rty | #id #fs | #id #fs | (*#r*) #id ]
[961]43    whd in ⊢ (??%? → ?); #H [ 2: | *: destruct ]
[2468]44    cases ty' in H ⊢ %; [ | #sz'' #sg (* | #fs*) | (*#sp*) #ty | (*#sp*) #ty #n | #args #rty | #id #fs | #id #fs | (*#r*) #id ]
[961]45    try (@eq_intsize_elim #E) whd in ⊢ (??%? → ?); #H destruct @cast_ip_z //
[487]46| #_ whd in ⊢ (??%? → ?); #H destruct
47]
[2468]48qed.
[399]49
[1410]50lemma exec_cast_sound : ∀m:mem. ∀v:val. ∀ty:type. ∀ty':type. ∀v':val. exec_cast m v ty ty' = OK ? v' → cast m v ty ty' v'.
51#m #v #ty #ty' #v'
[487]52cases v;
53[ #H whd in H:(??%?); destruct;
[961]54| #sz #i cases ty;
[487]55  [ #H whd in H:(??%?); destruct;
[2468]56(* | 3: #a #H whd in H:(??%?); destruct; *)
57  | 6,7,8: #a [ 1,2: #b ] #H whd in H:(??%?); destruct;
[487]58  | #sz1 #si1 cases ty';
[1516]59    [ whd in ⊢ (??%? → ?); @intsize_eq_elim_elim
[961]60      [ #NE #H destruct
61      | *; whd #H whd in H:(??%?); destruct;
62      ]
[2468]63     (* | 3: #a whd in ⊢ (??%? → ?); @intsize_eq_elim_elim
[961]64      [ #E #H whd in H:(??%?); destruct
65      | *; whd #H whd in H:(??%?); destruct; @cast_if
[2468]66      ] *)
67    | 2,6,7,8: #a [1,2,3: #b] whd in ⊢ (??%? → ?); @intsize_eq_elim_elim
[961]68      [ 1,3,5,7: #NE #H destruct
69      | *: *; whd #H whd in H:(??%?); destruct; //
70      ]
[2468]71    | 3,4,5: [ #ty'' letin t ≝ (Tpointer ty'')
[2176]72             | #ty'' #n letin t ≝ (Tarray ty'' n)
73             | #args #rty letin t ≝ (Tfunction args rty) ]
[1516]74        whd in ⊢ (??%? → ?); @intsize_eq_elim_elim
[961]75        [ 1,3,5: #NE #H destruct
76        | *: *; whd
77          lapply (try_cast_null_sound m sz i (Tint sz si1) t v');
78          cases (try_cast_null m sz i (Tint sz si1) t);
79          [ 1,3,5: #v'' #H' #e @H' @e
80          | *: #m #_ whd in ⊢ (??%? → ?); #H destruct (H);
81          ]
[487]82        ]
83    ]
[2176]84  | *: [ #ty'' letin t ≝ (Tpointer ty'')
85       | #ty'' #n letin t ≝ (Tarray ty'' n)
86       | #args #rty letin t ≝ (Tfunction args rty) ]
[487]87        whd in ⊢ (??%? → ?);
[961]88        lapply (try_cast_null_sound m sz i t ty' v');
89        cases (try_cast_null m sz i t ty');
[487]90        [ 1,3,5: #v'' #H' #e @H' @e
[797]91        | *: #m #_ whd in ⊢ (??%? → ?); #H destruct (H);
[487]92        ]
93  ]
[2468]94(*| #f cases ty;  [ 3,4,9: #x | 2,5,6,7,8: #x #y ]
[2176]95                    [ cases ty'; [ #e | 3,4,9: #a #e | 2,6,7,8: #a #b #e | #a #b #e ]
[487]96                        whd in e:(??%?); destruct; //;
97                    | *: #e whd in e:(??%?); destruct
[2468]98                    ] *)
99| cases ty; [ 3,8: #x | 2,4,5,6,7: #x #y ]
[2176]100    whd in ⊢ (??%? → ?); #H destruct
101    cases ty' in H; normalize; try #a try #b try #c try #d destruct;
[487]102    @cast_pp_z //;
[2176]103(*
[1545]104| #ptr whd in ⊢ (??%? → ?); #e
[500]105    elim (bind_inversion ????? e) #s * #es #e'
106    elim (bind_inversion ????? e') #u * #eu #e'' -e';
107    elim (bind_inversion ????? e'') #s' * #es' #e'''; -e'';
[487]108    cut (type_region ty s);
109    [ cases ty in es:(??%?) ⊢ %; [ #e | 3: #a #e | 2,4,6,7,8,9: #a #b #e | #a #b #c #e ]
[1647]110        whd in e:(??%%); destruct; //;
[487]111    | #Hty
112        cut (type_region ty' s');
113        [ cases ty' in es' ⊢ %; [ #e | 3: #a #e | 2,4,6,7,8,9: #a #b #e | #a #b #c #e ]
[1647]114            whd in e:(??%%); destruct; //;
[487]115        | #Hty'
[1545]116            cut (s = ptype ptr). elim (eq_region_dec (ptype ptr) s) in eu; //; normalize; #_ #e destruct.
[1516]117            #e >e in Hty; #Hty
[1545]118            cases (pointer_compat_dec (pblock ptr) s') in e''';
[1647]119            #Hcompat #e''' whd in e''':(??%%); destruct /2 by cast_pp/
[487]120        ]
121    ]
[2176]122*)
123| #ptr
[2468]124  cases ty;  [ 3,8: #x | 2,4,5,6,7: #x #y ]
[2176]125  #E whd in E:(??%?); destruct
126  cases ty' in E ⊢ %; normalize #A try #B try #C try #D destruct /2/
[1410]127] qed.
[399]128
129
[2468]130
131
[487]132theorem exec_expr_sound: ∀ge:genv. ∀en:env. ∀m:mem. ∀e:expr.
[399]133(P_res ? (λx.eval_expr ge en m e (\fst x) (\snd x)) (exec_expr ge en m e)).
[498]134#ge #en #m #e @(expr_lvalue_ind ? (λe',ty.P_res ? (λr.eval_lvalue ge en m (Expr e' ty) (\fst (\fst r)) (\snd (\fst r)) (\snd r)) (exec_lvalue' ge en m e' ty)) … e)
[1516]135[ #sz #ty #c whd in ⊢ (???%); cases ty try #sz' try #sg try #x try @I whd in ⊢ (???%);
[961]136  @eq_intsize_elim #E try @I <E whd %
[2468]137(*| #ty #c whd //*)
[399]138(* expressions that are lvalues *)
[487]139| #e' #ty cases e'; //; [ #i #He' | #e #He' | #e #i #He' ] whd in He' ⊢ %;
140    @bind2_OK #x cases x; #y cases y; #sp #loc #ofs #tr #H
141    @opt_bind_OK #vl #evl whd in evl:(??%?); @(eval_Elvalue … evl)
[1516]142    >H in He'; #He' @He'
[487]143| #v #ty
144    whd in ⊢ (???%);
[1058]145    lapply (refl ? (lookup SymbolTag block en v))
[1516]146    cases (lookup SymbolTag block en v) in ⊢ (???% → %);
[487]147    [ #eget @opt_bind_OK #sploc cases sploc; #sp #loc #efind
148        whd; @(eval_Evar_global … eget efind)
149    | #loc #eget @(eval_Evar_local … eget)
150    ]
[1516]151| #ty #e #He whd in ⊢ (???%);
[2176]152    @bind2_OK #v cases v / by / * #l #ofs #tr #Hv whd
[1516]153    >Hv in He; #He
[2176]154    @eval_Ederef @He
[891]155| #ty #e'' #ty'' #He'' @bind2_OK * #loc #ofs #tr #H
[2176]156  cases ty try (try #a try #b try #c @I)
157  #ty' whd
[1516]158  @eval_Eaddrof whd in H:(??%?); >H in He''; #He'' @He''
[487]159| #ty #op #e1 #He1 @bind2_OK #v1 #tr #Hv1
160    @opt_bind_OK #v #ev
161    @(eval_Eunop … ev)
[1516]162    >Hv1 in He1; #He1 @He1
[487]163| #ty #op #e1 #e2 #He1 #He2
[1516]164    @bind2_OK #v1 #tr1 #ev1 >ev1 in He1; #He1
165    @bind2_OK #v2 #tr2 #ev2 >ev2 in He2; #He2
[487]166    @opt_bind_OK #v #ev whd in He1 He2; whd;
167    @(eval_Ebinop … He1 He2 ev)
168| #ty #ty' #e' #He'
[1516]169    @bind2_OK #v #tr #Hv >Hv in He'; #He'
[487]170    @bind_OK #v' #ev'
171    @(eval_Ecast … He' ?)
172    (* XXX /2/; *)
173    @(exec_cast_sound … ev')
174| #ty #e1 #e2 #e3 #He1 #He2 #He3
[1516]175    @bind2_OK #vb #tr1 #Hvb >Hvb in He1; #He1
[487]176    @bind_OK #b
177    cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
[1516]178    @bind2_OK #v #tr #Hv whd in Hv:(??%?);
179    [ >Hv in He2; #He2 whd in He2 Hv:(??%?) ⊢%;
[487]180        @(eval_Econdition_true … He1 ? He2) @(bool_of ??? Hb)
[1516]181    | >Hv in He3; #He3 whd in He3 Hv:(??%?) ⊢%;
[487]182        @(eval_Econdition_false … He1 ? He3) @(bool_of ??? Hb)
183    ]
184| #ty #e1 #e2 #He1 #He2
[1516]185    @bind2_OK #v1 #tr1 #Hv1 >Hv1 in He1; #He1
[487]186    @bind_OK #b1 cases b1; #eb1 lapply (exec_bool_of_val_sound … eb1); #Hb1
[1516]187    [ @bind2_OK #v2 #tr2 #Hv2 >Hv2 in He2; #He2
[487]188        @bind_OK #b2 #eb2
189        @(eval_Eandbool_2 … He1 … He2)
190        [ @(bool_of … Hb1) | @(exec_bool_of_val_sound … eb2) ]
191    | @(eval_Eandbool_1 … He1) @(bool_of … Hb1)
192    ]
193| #ty #e1 #e2 #He1 #He2
[1516]194    @bind2_OK #v1 #tr1 #Hv1 >Hv1 in He1; #He1
[487]195    @bind_OK #b1 cases b1; #eb1 lapply (exec_bool_of_val_sound … eb1); #Hb1
196    [ @(eval_Eorbool_1 … He1) @(bool_of … Hb1)
[1516]197    | @bind2_OK #v2 #tr2 #Hv2 >Hv2 in He2; #He2
[487]198        @bind_OK #b2 #eb2
199        @(eval_Eorbool_2 … He1 … He2)
200        [ @(bool_of … Hb1) | @(exec_bool_of_val_sound … eb2) ]
201    ]
[1410]202| #ty #ty' cases ty try #sz try #sg try #x //
[487]203| #ty #e' #ty' #i cases ty'; //;
204    [ #id #fs #He' @bind2_OK #x cases x; #sp #l #ofs #H
[1516]205        @bind_OK #delta #Hdelta whd in H:(??%?); >H in He'; #He'
[487]206        @(eval_Efield_struct …  He' (refl ??) Hdelta)
[1516]207    | #id #fs #He' @bind2_OK #x cases x; #sp #l #ofs #H whd in H:(??%?);
208        >H in He'; #He'
[487]209        @(eval_Efield_union … He' (refl ??))
210    ]
[1516]211| #ty #l #e' #He' @bind2_OK #v #tr1 #H >H in He'; #He'
[487]212    @(eval_Ecost … He')
[399]213(* exec_lvalue fails on non-lvalues. *)
[487]214| #e' #ty cases e';
[2468]215    [ 2,4,11: #a #H try @I @(False_ind … H) | 3: #a * | 12,13: #a #b * | 1,5,7,9,10: #a #b #H @I | 6,8: #a #b #c #H @I ]
216    try @I
[487]217] qed.
[399]218
[2176]219lemma addrof_eval_lvalue: ∀ge,en,m,e,loc,off,tr,ty.
220eval_expr ge en m (Expr (Eaddrof e) ty) (Vptr (mk_pointer loc off)) tr →
[498]221eval_lvalue ge en m e loc off tr.
[2176]222#ge #en #m #e #loc #off #tr #ty #H inversion H;
[2468]223[ 1,4: #a #b #c #H @False_ind destruct (H);
[1516]224| #a #b #c #d #e #f #H1 #g #H2 #E1 #E2 #E3 <H2 in H1; #H1 @False_ind
[487]225    @(eval_lvalue_inv_ind … H1)
226    [ #a #b #c #d #bad destruct (bad);
[498]227    | #a #b #c #d #e #bad destruct (bad);
[2176]228    | #a #b #c #d #e #f #bad destruct (bad);
[1672]229    | #a #b #c #d #e #f #g #h #i #j #k #l #bad @False_ind destruct (bad);
230    | #a #b #c #d #e #f #g #h #i #j #bad destruct (bad);
[487]231    ]
[2176]232| #e' #ty' #loc' #ofs' #tr' #H' #e1 #e2 #e3 destruct (e1 e2 e3); #E @H'
[487]233| #a #b #c #d #e #f #g #h #bad destruct (bad);
[1672]234| #a #b #c #d #e #f #g #h #i #j #k #l #bad destruct (bad);
235| #a #b #c #d #e #f #g #h #i #j #k #bad destruct (bad);
236| #a #b #c #d #e #f #g #h #i #j #k #bad destruct (bad);
237| #a #b #c #d #e #f #g #bad destruct (bad);
238| #a #b #c #d #e #f #g #h #i #j #k #l #bad destruct (bad);
239| #a #b #c #d #e #f #g #bad destruct (bad);
240| #a #b #c #d #e #f #g #h #i #j #k #l #bad  destruct (bad);
[487]241| #a #b #c #d #e #f #g #h #bad destruct (bad);
[1672]242| #a #b #c #d #e #f #bad destruct (bad);
[487]243] qed.
[399]244
[500]245lemma addrof_exec_lvalue: ∀ge,en,m,e,r,loc,off,tr.
246exec_lvalue ge en m e = OK ? 〈〈mk_block r loc,off〉,tr〉 →
[2176]247exec_expr ge en m (Expr (Eaddrof e) (Tpointer Tvoid)) = OK ? 〈Vptr (mk_pointer (mk_block r loc) off), tr〉.
[1516]248#ge #en #m #e #r #loc #off #tr #H whd in ⊢ (??%?);
249>H whd in ⊢ (??%?); cases r @refl
[487]250qed.
[399]251
[487]252theorem exec_lvalue_sound: ∀ge,en,m,e.
[498]253P_res ? (λr.eval_lvalue ge en m e (\fst (\fst r)) (\snd (\fst r)) (\snd r)) (exec_lvalue ge en m e).
[487]254#ge #en #m #e lapply (refl ? (exec_lvalue ge en m e));
255cases (exec_lvalue ge en m e) in ⊢ (???% → %);
[1516]256[ #x cases x #y cases y #loc #off #tr #H whd cases loc in H ⊢ %; #locr #loci #H
[2176]257    @(addrof_eval_lvalue … (Tpointer Tvoid))
[500]258    lapply (addrof_exec_lvalue … H) #H'
[2176]259    lapply (exec_expr_sound ge en m (Expr (Eaddrof e) (Tpointer Tvoid)))
[487]260    >H' #H'' @H''
[797]261| #msg #_ whd @I
[487]262] qed.
[399]263
264(* Plain equality versions of the above *)
265
[487]266definition exec_expr_sound' ≝ λge,en,m,e,v.
[399]267  λH:exec_expr ge en m e = OK ? v.
268  P_res_to_P ???? (exec_expr_sound ge en m e) H.
269
[498]270definition exec_lvalue_sound' ≝ λge,en,m,e,loc,off,tr.
271  λH:exec_lvalue ge en m e = OK ? 〈〈loc,off〉,tr〉.
[399]272  P_res_to_P ???? (exec_lvalue_sound ge en m e) H.
273
[487]274lemma exec_exprlist_sound: ∀ge,e,m,l. P_res ? (λvltr:list val×trace. eval_exprlist ge e m l (\fst vltr) (\snd vltr)) (exec_exprlist ge e m l).
275#ge #e #m #l elim l;
[1410]276 whd
[487]277[ %
278| #e1 #es #IH
279  @bind2_OK #v #tr1 #Hv
280  @bind2_OK #vs #tr2 #Hvs
281  whd; @eval_Econs
282  [ @(P_res_to_P … (exec_expr_sound ge e m e1) Hv)
283  | @(P_res_to_P … IH Hvs)
284  ]
285] qed.
[399]286
[487]287lemma exec_alloc_variables_sound : ∀l,en,m,en',m'.
288  exec_alloc_variables en m l = 〈en',m'〉 →
289  alloc_variables en m l en' m'.
290#l elim l
291[ #en #m #en' #m' #EXEC whd in EXEC:(??%?); destruct %
292| * #id #ty #t #IH #en #m #en' #m'
[2176]293  lapply (refl ? (alloc m O (sizeof ty) XData)) whd in ⊢ (? → ??%? → ?);
[2106]294  cases (alloc ????) in ⊢ (???% → %); #m'' #b #ALLOC #EXEC
[487]295 @(alloc_variables_cons … ALLOC)
296 @IH @EXEC
297qed.
298
299lemma exec_bind_parameters_sound : ∀ps,vs,en,m.
300  P_res ? (λm'. bind_parameters en m ps vs m') (exec_bind_parameters en m ps vs).
301#ps elim ps
302[ * //
303| * #id #ty #ps' #IH *
304    [ //
305    | #v #vs #en #m
306      @opt_bind_OK #b #GET
307      @opt_bind_OK #m' #STORE
308      lapply (refl ? (exec_bind_parameters en m' ps' vs))
[1516]309      cases (exec_bind_parameters en m' ps' vs) in ⊢ (???% → %); [2: #msg #_ %]
[487]310      #m'' #BIND
311      @(bind_parameters_cons … GET STORE)
[1516]312      lapply (IH vs en m') whd in ⊢ (% → ?); >BIND //
[487]313    ]
314] qed.
315
316lemma check_eventval_list_sound : ∀vs,tys.
317  P_res ? (λevs. eventval_list_match evs tys vs) (check_eventval_list vs tys).
318#vs0 elim vs0
319[ * //
320| #v #vs #IH *
321  [ //
[1516]322  | #ty #tys whd in ⊢ (???%);
[2468]323    cases ty [ #sz #sg | ] cases v //
324    #sz' #v @bind_OK #ev whd in ⊢ (??%? → ?);
325    @eq_intsize_elim #E #CHECKev whd in CHECKev:(??%?); destruct
326    @bind_OK #evs #CHECKevs
[961]327      @(evl_match_cons ??????? (P_res_to_P ???? (IH ?) CHECKevs))
328      //
[487]329  ]
330] qed.
331
332theorem exec_step_sound: ∀ge,st.
[399]333  P_io ??? (λr. step ge st (\fst r) (\snd r)) (exec_step ge st).
[487]334#ge #st cases st;
335[ #f #s #k #e #m cases s;
336  [ cases k;
337    [ whd in ⊢ (?????%);
338        lapply (refl ? (fn_return f)); cases (fn_return f) in ⊢ (???% → %);
339        //; #H whd;
340        @step_skip_call //;
[1410]341    | #s' #k' whd; //
[2391]342    | #ex #s' #k' @step_skip_or_continue_while % //;
[487]343    | #ex #s' #k'
344        @res_bindIO2_OK #v #tr #Hv
345        letin bexpr ≝ (exec_bool_of_val v (typeof ex));
346        lapply (refl ? bexpr);
347        cases bexpr in ⊢ (???% → %);
348        [ #b cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
349            whd in ⊢ (?????%);
350            [ @(step_skip_or_continue_dowhile_true … (exec_expr_sound' … Hv))
351              [ % // | @(bool_of … Hb) ]
352            | @(step_skip_or_continue_dowhile_false … (exec_expr_sound' … Hv))
353              [ % // | @(bool_of … Hb) ]
354            ]
[797]355        | #msg #_ //;
[487]356        ]
357    | #ex #s1 #s2 #k' @step_skip_or_continue_for2 % //;
358    | #ex #s1 #s2 #k' @step_skip_for3
359    | #k' @step_skip_break_switch % //;
360    | #r #f' #e' #k' whd in ⊢ (?????%);
361        lapply (refl ? (fn_return f)); cases (fn_return f) in ⊢ (???% → %);
362        //; #H whd;
363        @step_skip_call //;
364    ]
365  | #ex1 #ex2
366    @res_bindIO2_OK #x cases x; #y cases y; #pcl #loc #ofs #tr1 #Hlval
367    @res_bindIO2_OK #v2 #tr2 #Hv2
368    @opt_bindIO_OK #m' #em'
369    whd; @(step_assign … (exec_lvalue_sound' … Hlval) (exec_expr_sound' … Hv2) em')
370  | #lex #fex #args
371    @res_bindIO2_OK #vf #tr1 #Hvf0 lapply (exec_expr_sound' … Hvf0); #Hvf
372    @res_bindIO2_OK #vargs #tr2 #Hvargs0 lapply (P_res_to_P ???? (exec_exprlist_sound …) Hvargs0); #Hvargs
373    @opt_bindIO_OK #fd #efd
374    @bindIO_OK #ety
375    cases lex; whd;
376    [ @(step_call_none … Hvf Hvargs efd ety)
377    | #lhs'
378        @res_bindIO2_OK #x cases x; #y cases y; #pcl #loc #ofs #tr3 #Hlocofs
379        whd; @(step_call_some … (exec_lvalue_sound' … Hlocofs) Hvf Hvargs efd ety)
380    ]
[1410]381  | #s1 #s2 //
[487]382  | #ex #s1 #s2
383    @res_bindIO2_OK #v #tr #Hv
384    letin bexpr ≝ (exec_bool_of_val v (typeof ex));
385    lapply (refl ? bexpr); cases bexpr in ⊢ (???% → %); //;
386    #b cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
387    [ @(step_ifthenelse_true … (exec_expr_sound' … Hv)) @(bool_of … Hb)
388    | @(step_ifthenelse_false … (exec_expr_sound' … Hv)) @(bool_of … Hb)
389    ]
[2391]390  | #ex #s'
[487]391    @res_bindIO2_OK #v #tr #Hv
392    letin bexpr ≝ (exec_bool_of_val v (typeof ex));
393    lapply (refl ? bexpr); cases bexpr in ⊢ (???% → %); //;
394    #b cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
395    [ @(step_while_true … (exec_expr_sound' … Hv)) @(bool_of … Hb)
396    | @(step_while_false … (exec_expr_sound' … Hv)) @(bool_of … Hb)
397    ]
[1410]398  | #ex #s' //
[487]399  | #s1 #ex #s2 #s3 whd in ⊢ (?????%); elim (is_Sskip s1); #Hs1 whd in ⊢ (?????%);
400    [ >Hs1
401      @res_bindIO2_OK #v #tr #Hv
402      letin bexpr ≝ (exec_bool_of_val v (typeof ex));
403      lapply (refl ? bexpr); cases bexpr in ⊢ (???% → %); //;
404      #b cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
405      [ @(step_for_true … (exec_expr_sound' … Hv)) @(bool_of … Hb)
406      | @(step_for_false … (exec_expr_sound' … Hv)) @(bool_of … Hb)
407      ]
408    | @step_for_start //;
409    ]
[1342]410  | whd in ⊢ (?????%); cases k; // #k' @step_skip_break_switch %2 //
[487]411  | whd in ⊢ (?????%); cases k; //;
[2391]412    [ #ex #s' #k' whd; @step_skip_or_continue_while %2 ; //;
[487]413    | #ex #s' #k' whd;
414      @res_bindIO2_OK #v #tr #Hv
415      letin bexpr ≝ (exec_bool_of_val v (typeof ex));
416      lapply (refl ? bexpr); cases bexpr in ⊢ (???% → %); //;
417      #b cases b; #eb lapply (exec_bool_of_val_sound … eb); #Hb
418      [ @(step_skip_or_continue_dowhile_true … (exec_expr_sound' … Hv))
419        [ %2 ; // | @(bool_of … Hb) ]
420      | @(step_skip_or_continue_dowhile_false … (exec_expr_sound' … Hv))
421        [ %2 ; // | @(bool_of … Hb) ]
422      ]
423    | #ex #s1 #s2 #k' whd; @step_skip_or_continue_for2 %2 ; //
424    ]
425  | #r whd in ⊢ (?????%); cases r;
426    [ whd; lapply (refl ? (fn_return f)); cases (fn_return f) in ⊢ (???% → %); //; #H
427        @step_return_0 @H
428    | #ex cases (type_eq_dec (fn_return f) Tvoid); //; whd in ⊢ (% → ?????%); #Hnotvoid
429        @res_bindIO2_OK #v #tr #Hv
430        whd; @(step_return_1 … Hnotvoid (exec_expr_sound' … Hv))
431    ]
[961]432  | #ex #ls @res_bindIO2_OK * // #sz #n #tr #Hv
[2428]433    lapply (refl ? (typeof ex)) cases (typeof ex) in ⊢ (???% → %); // #sz' #sg #TY
434    whd in ⊢ (?????%); cases (sz_eq_dec sz sz') // #SZ destruct (SZ)
435    whd in ⊢ (?????%); @opt_bindIO_OK #ls' #LS
436    @(step_switch … TY LS) @(exec_expr_sound' … Hv)
[1410]437  | #l #s' //
[487]438  | #l whd in ⊢ (?????%); lapply (refl ? (find_label l (fn_body f) (call_cont k)));
439      cases (find_label l (fn_body f) (call_cont k)) in ⊢ (???% → %); //;
440      #sk cases sk; #s' #k' #H
441      @(step_goto … H)
[1410]442  | #l #s' //
[487]443  ]
444| #f0 #vargs #k #m whd in ⊢ (?????%); cases f0;
[1516]445  [ #fn whd in ⊢ (?????%);
[487]446    lapply (refl ? (exec_alloc_variables empty_env m (fn_params fn@fn_vars fn)))
[1516]447    cases (exec_alloc_variables empty_env m (fn_params fn@fn_vars fn)) in ⊢ (???% → %);
448    #en' #m' #ALLOC whd in ⊢ (?????%);
[487]449    @res_bindIO_OK #m2 #BIND
450    whd; @(step_internal_function … (exec_alloc_variables_sound … ALLOC))
451    @(P_res_to_P … (exec_bind_parameters_sound …) BIND)
[1647]452  | #id #argtys #rty @res_bindIO_OK #evs #Hevs #v'
453    @bindIO_OK #eres whd
[487]454    @step_external_function % [ @(P_res_to_P … (check_eventval_list_sound …) Hevs)
455                              | @mk_val_correct ]
456  ] 
457| #v #k' #m' whd in ⊢ (?????%); cases k'; //;
[1713]458  [ whd in ⊢ (?????%); cases v // * //
459  | #r #f #e #k whd in ⊢ (?????%); cases r //
460    * * #b #ofs #ty
461    @opt_bindIO_OK #m' #em' @step_returnstate_1 whd in em':(??%?); //
462    ]
463| //
[487]464]
465qed.
[399]466
[1244]467lemma make_initial_state_sound : ∀p. P_res ? (initial_state p) (make_initial_state p).
[487]468#p cases p; #fns #main #vars
469whd in ⊢ (???%);
470@bind_OK #m #Em
471@opt_bind_OK #x cases x; #sp #b #esb
472@opt_bind_OK #f #ef
[1244]473@(initial_state_intro … Em esb ef) @refl
[487]474qed.
[399]475
[487]476theorem exec_steps_sound: ∀ge,n,st.
[399]477 P_io ??? (λts:trace×state. star (mk_transrel ?? step) ge st (\fst ts) (\snd ts))
478 (exec_steps n ge st).
[487]479#ge #n elim n;
480[ #st whd in ⊢ (?????%); elim (is_final_state st); #H whd; %
481| #n' #IH #st whd in ⊢ (?????%); elim (is_final_state st); #H
482  [ whd; %
483  | @(P_bindIO2_OK ????????? (exec_step_sound …)) #t #s' cases s';
[1713]484      [ #f #s #k #e #m | #fd #args #k #m | #r #k #m | #r ] normalize
485      [ 1,2,3: cases m; #mc #mn #mp ] #Hstep normalize
[487]486      @(P_bindIO2_OK ????????? (IH …)) #t' #s'' #Hsteps
[1713]487      whd; @(star_step ????????? Hsteps) [ 2,5,8,11: @Hstep | 3,6,9,12: // ]
[487]488  ]
489qed.
[708]490
491lemma is_final_sound: ∀s,r. is_final s = Some ? r → final_state s r.
[1713]492* [ 4: #r #r' normalize #E destruct %
493  | *: normalize #x1 #x2 #x3 #x4 #x5 try #x6 try #x7 destruct
[1350]494  ] qed.
Note: See TracBrowser for help on using the repository browser.