[700] | 1 | include "Clight/Cexec.ma". |
---|
[226] | 2 | |
---|
[487] | 3 | definition yields ≝ λA.λa:res A.λv':A. |
---|
[399] | 4 | match a with [ OK v ⇒ v' = v | _ ⇒ False ]. |
---|
[239] | 5 | |
---|
[399] | 6 | (* This tells us that some execution of a results in v'. |
---|
[239] | 7 | (There may be many possible executions due to I/O, but we're trying to prove |
---|
| 8 | that one particular one exists corresponding to a derivation in the inductive |
---|
| 9 | semantics.) *) |
---|
[487] | 10 | let rec yieldsIO (A:Type[0]) (a:IO io_out io_in A) (v':A) on a : Prop ≝ |
---|
[399] | 11 | match a with [ Value v ⇒ v' = v | Interact _ k ⇒ ∃r.yieldsIO A (k r) v' | _ ⇒ False ]. |
---|
| 12 | |
---|
[487] | 13 | definition yields_sig : ∀A,P. res (Sig A P) → A → Prop ≝ |
---|
[1603] | 14 | λA,P,e,v. match e with [ OK v' ⇒ match v' with [ mk_Sig v'' _ ⇒ v = v'' ] | _ ⇒ False]. |
---|
[399] | 15 | |
---|
[487] | 16 | let rec yieldsIO_sig (A:Type[0]) (P:A → Prop) (e:IO io_out io_in (Sig A P)) (v:A) on e : Prop ≝ |
---|
[239] | 17 | match e with |
---|
[1603] | 18 | [ Value v' ⇒ match v' with [ mk_Sig v'' _ ⇒ v = v'' ] |
---|
[399] | 19 | | Interact _ k ⇒ ∃r.yieldsIO_sig A P (k r) v |
---|
[239] | 20 | | _ ⇒ False]. |
---|
| 21 | |
---|
[487] | 22 | lemma remove_io_sig: ∀A. ∀P:A → Prop. ∀a,v',p. |
---|
[399] | 23 | yieldsIO A a v' → |
---|
[487] | 24 | yieldsIO_sig A P (io_inject io_out io_in A P (Some ? a) p) v'. |
---|
| 25 | #A #P #a elim a; |
---|
| 26 | [ #a #k #IH #v' #p #H whd in H ⊢ %; elim H; #r #H' %{ r} @IH @H' |
---|
| 27 | | #v #v' #p #H @H |
---|
[797] | 28 | | #a #b #c *; |
---|
[487] | 29 | ] qed. |
---|
[399] | 30 | |
---|
[487] | 31 | lemma yields_eq: ∀A,a,v'. yields A a v' → a = OK ? v'. |
---|
[1516] | 32 | #A #a #v' cases a; // #m whd in ⊢ (% → ?); *; |
---|
[487] | 33 | qed. |
---|
[399] | 34 | |
---|
[1603] | 35 | lemma yields_sig_eq: ∀A,P,e,v. yields_sig A P e v → ∃p. e = OK ? (mk_Sig … v p). |
---|
[487] | 36 | #A #P #e #v cases e; |
---|
| 37 | [ #vp cases vp; #v' #p #H whd in H; >H %{ p} @refl |
---|
[797] | 38 | | #m *; |
---|
[487] | 39 | ] qed. |
---|
[399] | 40 | |
---|
[499] | 41 | lemma is_pointer_compat_true: ∀b,sp. |
---|
| 42 | pointer_compat b sp → |
---|
| 43 | is_pointer_compat b sp = true. |
---|
| 44 | #b #sp #H whd in ⊢ (??%?); |
---|
| 45 | elim (pointer_compat_dec b sp); |
---|
[487] | 46 | [ // |
---|
| 47 | | #H' @False_ind @(absurd … H H') |
---|
| 48 | ] qed. |
---|
[226] | 49 | |
---|
[487] | 50 | theorem is_det: ∀p,s,s'. |
---|
[226] | 51 | initial_state p s → initial_state p s' → s = s'. |
---|
[487] | 52 | #p #s #s' #H1 #H2 |
---|
[1510] | 53 | inversion H1; #b1 #f1 #ge1 #m1 #e11 #e12 #e13 #e14 #e15 #e16 |
---|
| 54 | inversion H2; #b2 #f2 #ge2 #m2 #e21 #e22 #e23 #e24 #e25 #e26 |
---|
[1516] | 55 | >e11 in e21; #e1 >(?:ge1 = ge2) in e13 e14; |
---|
[487] | 56 | [ 2: destruct (e1) skip (e11); @refl ] |
---|
| 57 | #e13 #e14 |
---|
[485] | 58 | |
---|
[1516] | 59 | >e12 in e22; #e2 destruct (e2) skip (e12); |
---|
[485] | 60 | |
---|
[1516] | 61 | >e13 in e23; #e3 >(?:b1 = b2) in e14; |
---|
[487] | 62 | [ >e24 #e4 >(?:f2 = f1) |
---|
| 63 | [ //; |
---|
| 64 | | destruct (e4) skip (e24 e25); //; |
---|
| 65 | ] |
---|
| 66 | | destruct (e3) skip (e13); // |
---|
| 67 | ] qed. |
---|
[226] | 68 | |
---|
| 69 | |
---|
[487] | 70 | theorem the_initial_state: |
---|
[1244] | 71 | ∀p,s. initial_state p s → yields ? (make_initial_state p) s. |
---|
| 72 | #p #s cases p; #globs #fns #main #H |
---|
[487] | 73 | inversion H; |
---|
[1510] | 74 | #b #f #ge #m #e1 #e2 #e3 #e4 #e5 #e6 |
---|
[487] | 75 | whd in ⊢ (??%?); |
---|
| 76 | >e2 |
---|
| 77 | whd in ⊢ (??%?); |
---|
[1521] | 78 | change with (make_global (mk_program ?? globs fns main)) in e1:(??%?); |
---|
[1244] | 79 | >e1 |
---|
[487] | 80 | >e3 |
---|
| 81 | whd in ⊢ (??%?); |
---|
| 82 | >e4 |
---|
| 83 | whd; @refl |
---|
| 84 | qed. |
---|
[385] | 85 | |
---|
[487] | 86 | lemma cast_complete: ∀m,v,ty,ty',v'. |
---|
[399] | 87 | cast m v ty ty' v' → yields ? (exec_cast m v ty ty') v'. |
---|
[487] | 88 | #m #v #ty #ty' #v' #H |
---|
| 89 | elim H; |
---|
[1516] | 90 | [ #m #sz1 #sz2 #sg1 #sg2 #i whd in ⊢ (??%?); >intsize_eq_elim_true @refl |
---|
[487] | 91 | | #m #f #sz #szi #sg @refl |
---|
[1516] | 92 | | #m #sz #sz' #sg #i whd in ⊢ (??%?); >intsize_eq_elim_true @refl |
---|
[487] | 93 | | #m #f #sz #sz' @refl |
---|
[1545] | 94 | | #m #ty #ty' * #r #b #pc #ofs #r' #H1 #H2 #pc' |
---|
[1516] | 95 | elim H1 in pc ⊢ %; [ #r1 #ty1 #pc | #r1 #ty1 #n1 #pc | #tys1 #ty1 #pc letin r1 ≝ Code ] |
---|
| 96 | whd in ⊢ (??%?); |
---|
| 97 | [ 1,2: @(dec_true ? (eq_region_dec r1 r1) (refl ??) …) #H0 whd in ⊢ (??%?); ] |
---|
[500] | 98 | elim H2 in pc' ⊢ %; [ 1,4,7: #sp2 #ty2 | 2,5,8: #sp2 #ty2 #n2 | 3,6,9: #tys2 #ty2 letin sp2 ≝ Code ] |
---|
[1516] | 99 | #pc' whd in ⊢ (??%?); |
---|
[500] | 100 | @(dec_true ? (pointer_compat_dec b sp2) pc') // |
---|
[1516] | 101 | | #m #sz #si #ty'' #r #H cases H; [ #s #t | #s #t #n | #tys #ty0 ] whd in ⊢ (??%?); |
---|
| 102 | >intsize_eq_elim_true whd in ⊢ (??%?); cases sz //; |
---|
[487] | 103 | | #m #t #t' #r #r' #H #H' cases H; try #a try #b try #c cases H'; try #d try #e try #f |
---|
[500] | 104 | whd in ⊢ (??%?); try @refl @(dec_true ? (eq_region_dec a a) (refl ??)) #H0 @refl |
---|
[487] | 105 | ] qed. |
---|
[226] | 106 | |
---|
| 107 | (* Use to narrow down the choice of expression to just the lvalues. *) |
---|
[498] | 108 | lemma lvalue_expr: ∀ge,env,m,e,ty,l,ofs,tr. ∀P:expr_descr → Prop. |
---|
| 109 | eval_lvalue ge env m (Expr e ty) l ofs tr → |
---|
[226] | 110 | (∀id. P (Evar id)) → (∀e'. P (Ederef e')) → (∀e',id. P (Efield e' id)) → |
---|
| 111 | P e. |
---|
[498] | 112 | #ge #env #m #e #ty #l #ofs #tr #P #H @(eval_lvalue_inv_ind … H) |
---|
[1566] | 113 | [ #id #l' #ty' #e1 #e2 #e3 #e4 #e5 #e6 destruct; // |
---|
[1672] | 114 | | #id #l' #ty' #e1 #e2 #e3 #e4 #e5 #e6 #e7 destruct; // |
---|
| 115 | | #e' #ty' #sp #l' #pc #ofs #tr #H' #e1 #e2 #e3 #e4 #e5 -H destruct; // |
---|
| 116 | | #e' #id #ty' #l' #ofs #id' #fs #d #tr #H' #e1 #e2 #e3 #e4 #e5 #e6 #e7 -H destruct; // |
---|
| 117 | | #e' #id #ty' #l' #ofs #id' #fs #tr #H' #e1 #e2 #e3 #e4 #e5 #e6 -H destruct; // |
---|
[487] | 118 | ] qed. |
---|
[226] | 119 | |
---|
[487] | 120 | lemma bool_of_val_3_complete : ∀v,ty,r. bool_of_val v ty r → ∃b. r = of_bool b ∧ yields ? (exec_bool_of_val v ty) b. |
---|
| 121 | #v #ty #r #H elim H; #v #t #H' elim H'; |
---|
[1516] | 122 | [ #sz #sg #i #ne %{ true} % //; whd in ⊢ (??%?); >intsize_eq_elim_true |
---|
[961] | 123 | >(eq_bv_false … ne) // |
---|
[1545] | 124 | | * #r #b #pc #i #i0 #s %{ true} % // |
---|
[487] | 125 | | #f #s #ne %{ true} % //; whd; >(Feq_zero_false … ne) //; |
---|
[1516] | 126 | | #sz #sg %{ false} % // whd in ⊢ (??%?); >intsize_eq_elim_true >eq_bv_true // |
---|
[487] | 127 | | #r #r' #t %{ false} % //; |
---|
| 128 | | #s %{ false} % //; whd; >(Feq_zero_true …) //; |
---|
| 129 | ] |
---|
| 130 | qed. |
---|
[226] | 131 | |
---|
[487] | 132 | lemma bool_of_true: ∀v,ty. is_true v ty → yields ? (exec_bool_of_val v ty) true. |
---|
| 133 | #v #ty #H elim H; |
---|
[1516] | 134 | [ #i #is #s #ne whd in ⊢ (??%?); >intsize_eq_elim_true >(eq_bv_false … ne) //; |
---|
[1545] | 135 | | * #p #b #i #i0 #s // |
---|
[487] | 136 | | #f #s #ne whd; >(Feq_zero_false … ne) //; |
---|
| 137 | ] |
---|
| 138 | qed. |
---|
[226] | 139 | |
---|
[487] | 140 | lemma bool_of_false: ∀v,ty. is_false v ty → yields ? (exec_bool_of_val v ty) false. |
---|
| 141 | #v #ty #H elim H; |
---|
[1516] | 142 | [ #sz #sg whd in ⊢ (??%?); >intsize_eq_elim_true >eq_bv_true //; |
---|
[487] | 143 | | #r #r' #t //; |
---|
| 144 | | #s whd; >(Feq_zero_true …) //; |
---|
| 145 | ] |
---|
| 146 | qed. |
---|
[226] | 147 | |
---|
[487] | 148 | lemma expr_lvalue_complete: ∀ge,env,m. |
---|
[399] | 149 | (∀e,v,tr. eval_expr ge env m e v tr → yields ? (exec_expr ge env m e) (〈v,tr〉)) ∧ |
---|
[498] | 150 | (∀e,l,off,tr. eval_lvalue ge env m e l off tr → yields ? (exec_lvalue ge env m e) (〈〈l,off〉,tr〉)). |
---|
[487] | 151 | #ge #env #m |
---|
| 152 | @(combined_expr_lvalue_ind ge env m |
---|
[399] | 153 | (λe,v,tr,H. yields ? (exec_expr ge env m e) (〈v,tr〉)) |
---|
[498] | 154 | (λe,l,off,tr,H. yields ? (exec_lvalue ge env m e) (〈〈l,off〉,tr〉))); |
---|
[1516] | 155 | [ #sz #sg #i whd in ⊢ (??%?); >eq_intsize_true @refl |
---|
[487] | 156 | | #f #ty @refl |
---|
[498] | 157 | | #e #ty #l #off #v #tr #H1 #H2 @(lvalue_expr … H1) |
---|
[487] | 158 | [ #id | #e' | #e' #id ] #H3 |
---|
[1516] | 159 | whd in ⊢ (??%?); |
---|
[1521] | 160 | [ change with (exec_lvalue' ge env m (Evar id) ty) in H3:(??%?); |
---|
| 161 | | change with (exec_lvalue' ge env m (Ederef e') ty) in H3:(??%?); |
---|
| 162 | | change with (exec_lvalue' ge env m (Efield e' id) ty) in H3:(??%?); |
---|
[891] | 163 | ] |
---|
[487] | 164 | >(yields_eq ??? H3) |
---|
[1521] | 165 | whd in ⊢ (??%?); change with (load_value_of_type' ty m 〈l,off〉) in H2:(??%?); |
---|
[891] | 166 | >H2 @refl |
---|
[500] | 167 | | #e #ty #r #l #pc #off #tr #H1 #H2 whd in ⊢ (??%?); |
---|
[1516] | 168 | >(yields_eq ??? H2) whd in ⊢ (??%?); |
---|
[500] | 169 | @(dec_true ? (pointer_compat_dec l r) pc) #pc' whd |
---|
[487] | 170 | @refl |
---|
[961] | 171 | | #ty' #sz #sg @refl |
---|
[487] | 172 | | #op #e #ty #v1 #v #tr #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 173 | >(yields_eq ??? H3) |
---|
| 174 | whd in ⊢ (??%?); >H2 @refl |
---|
| 175 | | #op #e1 #e2 #ty #v1 #v2 #v #tr1 #tr2 #H1 #H2 #e3 #H4 #H5 whd in ⊢ (??%?); |
---|
| 176 | >(yields_eq ??? H4) whd in ⊢ (??%?); |
---|
| 177 | >(yields_eq ??? H5) whd in ⊢ (??%?); |
---|
| 178 | >e3 @refl |
---|
| 179 | | #e1 #e2 #e3 #ty #v1 #v2 #tr1 #tr2 #H1 #H2 #H3 #H4 #H5 whd in ⊢ (??%?); |
---|
| 180 | >(yields_eq ??? H4) whd in ⊢ (??%?); |
---|
| 181 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 182 | >(yields_eq ??? H5) |
---|
| 183 | @refl |
---|
| 184 | | #e1 #e2 #e3 #ty #v1 #v2 #tr1 #tr2 #H1 #H2 #H3 #H4 #H5 whd in ⊢ (??%?); |
---|
| 185 | >(yields_eq ??? H4) whd in ⊢ (??%?); |
---|
| 186 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 187 | >(yields_eq ??? H5) |
---|
| 188 | @refl |
---|
| 189 | | #e1 #e2 #ty #v1 #tr #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 190 | >(yields_eq ??? H3) whd in ⊢ (??%?); |
---|
| 191 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 192 | @refl |
---|
| 193 | | #e1 #e2 #ty #v1 #v2 #v #tr1 #tr2 #H1 #H2 #H3 #H4 #H5 #H6 whd in ⊢ (??%?); |
---|
| 194 | >(yields_eq ??? H5) whd in ⊢ (??%?); |
---|
| 195 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 196 | >(yields_eq ??? H6) whd in ⊢ (??%?); |
---|
| 197 | elim (bool_of_val_3_complete … H4); #b *; #evb #Hb |
---|
| 198 | >(yields_eq ??? Hb) whd in ⊢ (??%?); <evb |
---|
| 199 | @refl |
---|
| 200 | | #e1 #e2 #ty #v1 #tr #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 201 | >(yields_eq ??? H3) whd in ⊢ (??%?); |
---|
| 202 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 203 | @refl |
---|
| 204 | | #e1 #e2 #ty #v1 #v2 #v #tr1 #tr2 #H1 #H2 #H3 #H4 #H5 #H6 whd in ⊢ (??%?); |
---|
| 205 | >(yields_eq ??? H5) whd in ⊢ (??%?); |
---|
| 206 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 207 | >(yields_eq ??? H6) whd in ⊢ (??%?); |
---|
| 208 | elim (bool_of_val_3_complete … H4); #b *; #evb #Hb |
---|
| 209 | >(yields_eq ??? Hb) whd in ⊢ (??%?); <evb |
---|
| 210 | @refl |
---|
| 211 | | #e #ty #ty' #v1 #v #tr #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 212 | >(yields_eq ??? H3) whd in ⊢ (??%?); |
---|
| 213 | >(yields_eq ??? (cast_complete … H2)) |
---|
| 214 | @refl |
---|
| 215 | | #e #ty #v #l #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 216 | >(yields_eq ??? H2) whd in ⊢ (??%?); |
---|
| 217 | @refl |
---|
[253] | 218 | |
---|
[226] | 219 | (* lvalues *) |
---|
[487] | 220 | | #id #l #ty #e1 whd in ⊢ (??%?); >e1 @refl |
---|
[498] | 221 | | #id #l #ty #e1 #e2 whd in ⊢ (??%?); >e1 |
---|
[487] | 222 | >e2 @refl |
---|
[500] | 223 | | #e #ty #r #l #pc #ofs #tr #H1 #H2 whd in ⊢ (??%?); |
---|
[487] | 224 | >(yields_eq ??? H2) |
---|
| 225 | @refl |
---|
[498] | 226 | | #e #i #ty #l #ofs #id #fList #delta #tr #H1 #H2 #H3 #H4 cases e in H2 H4 ⊢ %; |
---|
[487] | 227 | #e' #ty' #H2 whd in H2:(??%?); >H2 #H4 whd in ⊢ (??%?); |
---|
| 228 | >(yields_eq ??? H4) whd in ⊢ (??%?); |
---|
| 229 | >H3 @refl |
---|
[498] | 230 | | #e #i #ty #l #ofs #id #fList #tr cases e; #e' #ty' #H1 #H2 |
---|
[487] | 231 | whd in H2:(??%?); >H2 #H3 whd in ⊢ (??%?); |
---|
| 232 | >(yields_eq ??? H3) @refl |
---|
| 233 | ] qed. |
---|
[226] | 234 | |
---|
[487] | 235 | theorem expr_complete: ∀ge,env,m. |
---|
[399] | 236 | ∀e,v,tr. eval_expr ge env m e v tr → yields ? (exec_expr ge env m e) (〈v,tr〉). |
---|
[487] | 237 | #ge #env #m elim (expr_lvalue_complete ge env m); /2/; qed. |
---|
[226] | 238 | |
---|
[487] | 239 | theorem exprlist_complete: ∀ge,env,m,es,vs,tr. |
---|
[399] | 240 | eval_exprlist ge env m es vs tr → yields ? (exec_exprlist ge env m es) (〈vs,tr〉). |
---|
[487] | 241 | #ge #env #m #es #vs #tr #H elim H; |
---|
| 242 | [ @refl |
---|
| 243 | | #e #et #v #vt #tr #trt #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 244 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 245 | >(yields_eq ??? H3) |
---|
| 246 | @refl |
---|
| 247 | ] qed. |
---|
[239] | 248 | |
---|
[487] | 249 | theorem lvalue_complete: ∀ge,env,m. |
---|
[498] | 250 | ∀e,l,off,tr. eval_lvalue ge env m e l off tr → yields ? (exec_lvalue ge env m e) (〈〈l,off〉,tr〉). |
---|
[487] | 251 | #ge #env #m elim (expr_lvalue_complete ge env m); /2/; qed. |
---|
[239] | 252 | |
---|
[487] | 253 | let rec P_typelist (P:type → Prop) (l:typelist) on l : Prop ≝ |
---|
[239] | 254 | match l with |
---|
| 255 | [ Tnil ⇒ True |
---|
| 256 | | Tcons h t ⇒ P h ∧ P_typelist P t |
---|
| 257 | ]. |
---|
| 258 | |
---|
[487] | 259 | let rec type_ind2l |
---|
[239] | 260 | (P:type → Prop) (Q:typelist → Prop) |
---|
| 261 | (vo:P Tvoid) |
---|
| 262 | (it:∀i,s. P (Tint i s)) |
---|
| 263 | (fl:∀f. P (Tfloat f)) |
---|
| 264 | (pt:∀s,t. P t → P (Tpointer s t)) |
---|
| 265 | (ar:∀s,t,n. P t → P (Tarray s t n)) |
---|
| 266 | (fn:∀tl,t. Q tl → P t → P (Tfunction tl t)) |
---|
| 267 | (st:∀i,fl. P (Tstruct i fl)) |
---|
| 268 | (un:∀i,fl. P (Tunion i fl)) |
---|
[481] | 269 | (cp:∀r,i. P (Tcomp_ptr r i)) |
---|
[239] | 270 | (nl:Q Tnil) |
---|
| 271 | (cs:∀t,tl. P t → Q tl → Q (Tcons t tl)) |
---|
| 272 | (t:type) on t : P t ≝ |
---|
| 273 | match t return λt'.P t' with |
---|
| 274 | [ Tvoid ⇒ vo |
---|
| 275 | | Tint i s ⇒ it i s |
---|
| 276 | | Tfloat s ⇒ fl s |
---|
| 277 | | Tpointer s t' ⇒ pt s t' (type_ind2l P Q vo it fl pt ar fn st un cp nl cs t') |
---|
| 278 | | Tarray s t' n ⇒ ar s t' n (type_ind2l P Q vo it fl pt ar fn st un cp nl cs t') |
---|
| 279 | | Tfunction tl t' ⇒ fn tl t' (typelist_ind2l P Q vo it fl pt ar fn st un cp nl cs tl) (type_ind2l P Q vo it fl pt ar fn st un cp nl cs t') |
---|
| 280 | | Tstruct i fs ⇒ st i fs |
---|
| 281 | | Tunion i fs ⇒ un i fs |
---|
[481] | 282 | | Tcomp_ptr r i ⇒ cp r i |
---|
[239] | 283 | ] |
---|
| 284 | and typelist_ind2l |
---|
| 285 | (P:type → Prop) (Q:typelist → Prop) |
---|
| 286 | (vo:P Tvoid) |
---|
| 287 | (it:∀i,s. P (Tint i s)) |
---|
| 288 | (fl:∀f. P (Tfloat f)) |
---|
| 289 | (pt:∀s,t. P t → P (Tpointer s t)) |
---|
| 290 | (ar:∀s,t,n. P t → P (Tarray s t n)) |
---|
| 291 | (fn:∀tl,t. Q tl → P t → P (Tfunction tl t)) |
---|
| 292 | (st:∀i,fl. P (Tstruct i fl)) |
---|
| 293 | (un:∀i,fl. P (Tunion i fl)) |
---|
[481] | 294 | (cp:∀r,i. P (Tcomp_ptr r i)) |
---|
[239] | 295 | (nl:Q Tnil) |
---|
| 296 | (cs:∀t,tl. P t → Q tl → Q (Tcons t tl)) |
---|
| 297 | (ts:typelist) on ts : Q ts ≝ |
---|
| 298 | match ts return λts'.Q ts' with |
---|
| 299 | [ Tnil ⇒ nl |
---|
| 300 | | Tcons t tl ⇒ cs t tl (type_ind2l P Q vo it fl pt ar fn st un cp nl cs t) |
---|
| 301 | (typelist_ind2l P Q vo it fl pt ar fn st un cp nl cs tl) |
---|
| 302 | ]. |
---|
| 303 | |
---|
[487] | 304 | lemma assert_type_eq_true: ∀t. ∃p.assert_type_eq t t = OK ? p. |
---|
| 305 | #t whd in ⊢ (??(λ_.??%?)); cases (type_eq_dec t t); #E |
---|
| 306 | [ %{ E} // |
---|
| 307 | | @False_ind @(absurd ?? E) // |
---|
| 308 | ] qed. |
---|
[239] | 309 | |
---|
[487] | 310 | lemma alloc_vars_complete: ∀env,m,l,env',m'. |
---|
[239] | 311 | alloc_variables env m l env' m' → |
---|
[487] | 312 | exec_alloc_variables env m l = 〈env', m'〉. |
---|
| 313 | #env #m #l #env' #m' #H elim H; |
---|
| 314 | [ #env'' #m'' % |
---|
| 315 | | #env1 #m1 #id #ty #l1 #m2 #loc #m3 #env2 #H1 #H2 #H3 |
---|
[1516] | 316 | < H3 whd in H1:(??%?) ⊢ (??%?); |
---|
[2120] | 317 | >H1 |
---|
[1058] | 318 | @refl |
---|
[487] | 319 | ] qed. |
---|
[239] | 320 | |
---|
[487] | 321 | lemma bind_params_complete: ∀e,m,params,vs,m2. |
---|
[239] | 322 | bind_parameters e m params vs m2 → |
---|
[487] | 323 | yields ? (exec_bind_parameters e m params vs) m2. |
---|
| 324 | #e #m #params #vs #m2 #H elim H; |
---|
| 325 | [ //; |
---|
| 326 | | #env1 #m1 #id #ty #l #v #tl #loc #m2 #m3 #H1 #H2 #H3 #H4 |
---|
[1516] | 327 | whd in ⊢ (??%?); |
---|
[487] | 328 | >H1 whd in ⊢ (??%?); |
---|
| 329 | >H2 whd in ⊢ (??%?); |
---|
| 330 | @H4 |
---|
| 331 | ] qed. |
---|
[239] | 332 | |
---|
[487] | 333 | lemma eventval_match_complete': ∀ev,ty,v. |
---|
| 334 | eventval_match ev ty v → yields ? (check_eventval' v ty) ev. |
---|
[1516] | 335 | #ev #ty #v #H elim H; // #sz #sg #i whd in ⊢ (??%?); >eq_intsize_true @refl qed. |
---|
[239] | 336 | |
---|
[487] | 337 | lemma eventval_list_match_complete: ∀vs,tys,evs. |
---|
| 338 | eventval_list_match evs tys vs → yields ? (check_eventval_list vs tys) evs. |
---|
| 339 | #vs #tys #evs #H elim H; |
---|
| 340 | [ // |
---|
[1516] | 341 | | #e #etl #ty #tytl #v #vtl #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
| 342 | >(yields_eq ??? (eventval_match_complete' … H1)) whd in ⊢ (??%?); |
---|
| 343 | >(yields_eq ??? H3) whd in ⊢ (??%?); // |
---|
[487] | 344 | ] qed. |
---|
[239] | 345 | |
---|
[487] | 346 | theorem step_complete: ∀ge,s,tr,s'. |
---|
[399] | 347 | step ge s tr s' → yieldsIO ? (exec_step ge s) 〈tr,s'〉. |
---|
[487] | 348 | #ge #s #tr #s' #H elim H; |
---|
[498] | 349 | [ #f #e #e1 #k #e2 #m #loc #ofs #v #m' #tr1 #tr2 #H1 #H2 #H3 whd in ⊢ (??%?); |
---|
[1516] | 350 | >(yields_eq ??? (lvalue_complete … H1)) whd in ⊢ (??%?); |
---|
| 351 | >(yields_eq ??? (expr_complete … H2)) whd in ⊢ (??%?); |
---|
[1521] | 352 | change with (store_value_of_type' (typeof e) m 〈loc,ofs〉 v) in H3:(??%?); |
---|
[487] | 353 | >H3 @refl |
---|
| 354 | | #f #e #eargs #k #ef #m #vf #vargs #f' #tr1 #tr2 #H1 #H2 #H3 #H4 whd in ⊢ (??%?); |
---|
| 355 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 356 | >(yields_eq ??? (exprlist_complete … H2)) whd in ⊢ (??%?); |
---|
| 357 | >H3 whd in ⊢ (??%?); |
---|
| 358 | >H4 elim (assert_type_eq_true (fun_typeof e)); #pty #ety >ety |
---|
| 359 | @refl |
---|
[498] | 360 | | #f #el #ef #eargs #k #env #m #loc #ofs #vf #vargs #f' #tr1 #tr2 #tr3 #H1 #H2 #H3 #H4 #H5 whd in ⊢ (??%?); |
---|
[487] | 361 | >(yields_eq ??? (expr_complete … H2)) whd in ⊢ (??%?); |
---|
| 362 | >(yields_eq ??? (exprlist_complete … H3)) whd in ⊢ (??%?); |
---|
| 363 | >H4 whd in ⊢ (??%?); |
---|
| 364 | >H5 elim (assert_type_eq_true (fun_typeof ef)); #pty #ety >ety |
---|
| 365 | whd in ⊢ (??%?); |
---|
| 366 | >(yields_eq ??? (lvalue_complete … H1)) whd in ⊢ (??%?); |
---|
| 367 | @refl |
---|
| 368 | | #f #s1 #s2 #k #env #m @refl |
---|
| 369 | | 5,6,7: #f #s #k #env #m @refl |
---|
| 370 | | #f #e #s1 #s2 #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 371 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 372 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 373 | @refl |
---|
| 374 | | #f #e #s1 #s2 #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 375 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 376 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 377 | @refl |
---|
| 378 | | #f #e #s #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 379 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 380 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 381 | @refl |
---|
| 382 | | #f #e #s #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 383 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 384 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 385 | @refl |
---|
| 386 | | #f #s1 #e #s2 #k #env #m #H cases H; #es1 >es1 @refl |
---|
| 387 | | 13,14: #f #e #s #k #env #m @refl |
---|
| 388 | | #f #s1 #e #s2 #k #env #m #v #tr *; #es1 >es1 #H1 #H2 whd in ⊢ (??%?); |
---|
| 389 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 390 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 391 | @refl |
---|
| 392 | | #f #s1 #e #s2 #k #env #m #v #tr *; #es1 >es1 #H1 #H2 whd in ⊢ (??%?); |
---|
| 393 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 394 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 395 | @refl |
---|
| 396 | | #f #e #s #k #env #m @refl |
---|
| 397 | | #f #s1 #e #s2 #s3 #k #env #m #nskip whd in ⊢ (??%?); cases (is_Sskip s1); |
---|
| 398 | [ #H @False_ind @(absurd ? H nskip) |
---|
| 399 | | #H whd in ⊢ (??%?); @refl ] |
---|
| 400 | | #f #e #s1 #s2 #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 401 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 402 | >(yields_eq ??? (bool_of_false ?? H2)) |
---|
| 403 | @refl |
---|
| 404 | | #f #e #s1 #s2 #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 405 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 406 | >(yields_eq ??? (bool_of_true ?? H2)) |
---|
| 407 | @refl |
---|
| 408 | | #f #s1 #e #s2 #s3 #k #env #m *; #es1 >es1 @refl |
---|
| 409 | | 22,23: #f #e #s1 #s2 #k #env #m @refl |
---|
| 410 | | #f #k #env #m #H whd in ⊢ (??%?); >H @refl |
---|
| 411 | | #f #e #k #env #m #v #tr #H1 #H2 whd in ⊢ (??%?); |
---|
| 412 | @(dec_false ? (type_eq_dec (fn_return f) Tvoid) H1) #pf' |
---|
| 413 | whd in ⊢ (??%?); |
---|
| 414 | >(yields_eq ??? (expr_complete … H2)) whd in ⊢ (??%?); |
---|
| 415 | @refl |
---|
| 416 | | #f #k #env #m cases k; |
---|
| 417 | [ #H1 #H2 whd in ⊢ (??%?); >H2 @refl |
---|
| 418 | | #s' #k' whd in ⊢ (% → ?); *; |
---|
| 419 | | 3,4: #e' #s' #k' whd in ⊢ (% → ?); *; |
---|
| 420 | | 5,6: #e' #s1' #s2' #k' whd in ⊢ (% → ?); *; |
---|
| 421 | | #k' whd in ⊢ (% → ?); *; |
---|
| 422 | | #r #f' #env' #k' #H1 #H2 whd in ⊢ (??%?); >H2 @refl |
---|
| 423 | ] |
---|
[961] | 424 | | #f #e #s #k #env #m #sz #i #tr #H1 whd in ⊢ (??%?); |
---|
[487] | 425 | >(yields_eq ??? (expr_complete … H1)) whd in ⊢ (??%?); |
---|
| 426 | @refl |
---|
| 427 | | #f #s #k #env #m *; #es >es @refl |
---|
| 428 | | #f #k #env #m @refl |
---|
| 429 | | #f #l #s #k #env #m @refl |
---|
| 430 | | #f #l #k #env #m #s #k' #H1 whd in ⊢ (??%?); >H1 @refl |
---|
| 431 | | #f #args #k #m1 #env #m2 #m3 #H1 #H2 whd in ⊢ (??%?); |
---|
| 432 | >(alloc_vars_complete … H1) whd in ⊢ (??%?); |
---|
| 433 | >(yields_eq ??? (bind_params_complete … H2)) |
---|
| 434 | // |
---|
| 435 | | #id #tys #rty #args #k #m #rv #tr #H whd in ⊢ (??%?); |
---|
[1516] | 436 | inversion H; #f' #args' #rv' #eargs #erv #H1 #H2 #e1 #e2 #e3 #e4 #e5 <e1 in H1 H2; |
---|
[487] | 437 | #H1 #H2 |
---|
| 438 | >(yields_eq ??? (eventval_list_match_complete … H1)) whd in ⊢ (??%?); |
---|
[1510] | 439 | whd; inversion H2; [ #sz #sg #x | #x #sz ] #e5 #e6 #e7 #e8 %{ x} whd in ⊢ (??%?); |
---|
[487] | 440 | @refl |
---|
| 441 | | #v #f #env #k #m @refl |
---|
[891] | 442 | | #v #f #env #k #m1 #m2 #loc #ofs #ty |
---|
[1521] | 443 | change with (store_value_of_type' ty m1 〈loc,ofs〉 v) in ⊢ (??%? → ?); |
---|
[1516] | 444 | #H whd in ⊢ (??%?); >H @refl |
---|
[487] | 445 | | #f #l #s #k #env #m @refl |
---|
[1713] | 446 | | #r #m // |
---|
[487] | 447 | ] qed. |
---|
[708] | 448 | |
---|
| 449 | lemma is_final_complete : ∀s,r. final_state s r → is_final s = Some ? r. |
---|
[1713] | 450 | #s0 #r0 * #r @refl qed. |
---|
[1930] | 451 | |
---|