-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathevaluate_decScript.sml
495 lines (470 loc) · 17.6 KB
/
evaluate_decScript.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
(*
Defines evaluate_dec_list which is an alternative version of
evaluate_decs from evaluateTheory. This alternative version is
adjusted to make translation faster.
*)
open preamble
open astTheory semanticPrimitivesTheory evaluateTheory
semanticPrimitivesPropsTheory evaluatePropsTheory;
open mlstringTheory integerTheory;
open namespaceTheory;
open alist_treeTheory;
val _ = new_theory "evaluate_dec";
(* --- define an alternative to evaluate_decs --- *)
(* Same as evaluate_decs from evaluateTheory but modified to not have
the cons checks (every_exp one_con_check) *)
Definition evaluate_dec_list_def:
evaluate_dec_list st env [] = (st,Rval <|v := nsEmpty; c := nsEmpty|>)
∧
evaluate_dec_list st env (d1::d2::ds) =
(case evaluate_dec_list st env [d1] of
(st1,Rval env1) =>
(case evaluate_dec_list st1 (extend_dec_env env1 env) (d2::ds) of
(st2,r) => (st2,combine_dec_result env1 r))
| (st1,Rerr v7) => (st1,Rerr v7))
∧
evaluate_dec_list st env [Dlet locs p e] =
(if ALL_DISTINCT (pat_bindings p [])
then
case evaluate st env [e] of
(st',Rval v) =>
(st',
case pmatch env.c st'.refs p (HD v) [] of
No_match => Rerr (Rraise bind_exn_v)
| Match_type_error => Rerr (Rabort Rtype_error)
| Match new_vals =>
Rval <|v := alist_to_ns new_vals; c := nsEmpty|>)
| (st',Rerr err) => (st',Rerr err)
else (st,Rerr (Rabort Rtype_error)))
∧
evaluate_dec_list st env [Dletrec locs funs] =
(st,
if ALL_DISTINCT (MAP (λ(x,y,z). x) funs)
then
Rval <|v := build_rec_env funs env nsEmpty; c := nsEmpty|>
else Rerr (Rabort Rtype_error))
∧
evaluate_dec_list st env [Dtype locs tds] =
(if EVERY check_dup_ctors tds then
(st with next_type_stamp := st.next_type_stamp + LENGTH tds,
Rval <|v := nsEmpty; c := build_tdefs st.next_type_stamp tds|>)
else (st,Rerr (Rabort Rtype_error)))
∧
evaluate_dec_list st env [Dtabbrev locs tvs tn t] =
(st,Rval <|v := nsEmpty; c := nsEmpty|>)
∧
evaluate_dec_list st env [Denv n] =
(case declare_env st.eval_state env of
NONE => (st,Rerr (Rabort Rtype_error))
| SOME (x,es') =>
(st with eval_state := es',Rval <|v := nsSing n x; c := nsEmpty|>))
∧
evaluate_dec_list st env [Dexn locs cn ts] =
(st with next_exn_stamp := st.next_exn_stamp + 1,
Rval
<|v := nsEmpty;
c := nsSing cn (LENGTH ts,ExnStamp st.next_exn_stamp)|>)
∧
evaluate_dec_list st env [Dmod mn ds] =
(case evaluate_dec_list st env ds of
(st',r) =>
(st',
case r of
Rval env' =>
Rval <|v := nsLift mn env'.v; c := nsLift mn env'.c|>
| Rerr err => Rerr err))
∧
evaluate_dec_list st env [Dlocal lds ds] =
case evaluate_dec_list st env lds of
(st1,Rval env1) => evaluate_dec_list st1 (extend_dec_env env1 env) ds
| (st1,Rerr v7) => (st1,Rerr v7)
Termination
WF_REL_TAC ‘measure $ list_size dec_size o SND o SND’
End
Definition evaluate_dec_list_with_clock_def:
evaluate_dec_list_with_clock st env k prog =
let (st',r) =
evaluate_dec_list (st with clock := k) env prog
in (st'.ffi,r)
End
Definition semantics_dec_list_def:
(semantics_dec_list st env prog (Terminate outcome io_list) ⇔
(* there is a clock for which evaluation terminates, either internally or via
FFI, and the accumulated io events match the given io_list *)
(?k ffi r.
evaluate_dec_list_with_clock st env k prog = (ffi,r) ∧
(case r of
| Rerr (Rabort (Rffi_error outcome')) =>
outcome = FFI_outcome (outcome')
| r => r ≠ Rerr (Rabort Rtimeout_error) ∧ outcome = Success) ∧
(io_list = ffi.io_events) ∧
(r ≠ Rerr (Rabort Rtype_error)))) ∧
(semantics_dec_list st env prog (Diverge io_trace) ⇔
(* for all clocks, evaluation times out *)
(!k. ?ffi.
(evaluate_dec_list_with_clock st env k prog =
(ffi, Rerr (Rabort Rtimeout_error)))) ∧
(* the io_trace is the least upper bound of the set of traces
produced for each clock *)
lprefix_lub
(IMAGE
(λk. fromList (FST (evaluate_dec_list_with_clock st env k prog)).io_events)
UNIV)
io_trace) ∧
(semantics_dec_list st env prog Fail ⇔
(* there is a clock for which evaluation produces a runtime type error *)
∃k.
SND(evaluate_dec_list_with_clock st env k prog) = Rerr (Rabort Rtype_error))
End
val env_c = “env_c: (string, string, num # stamp) namespace”
(* --- define a check that implies evaluate_dec_list is same as evalaute_decs --- *)
Definition check_cons_dec_list_def:
check_cons_dec_list ^env_c [] = SOME nsEmpty
∧
check_cons_dec_list env_c (d1::ds) =
(case check_cons_dec env_c d1 of
| NONE => NONE
| SOME env_c0 =>
case check_cons_dec_list (nsAppend env_c0 env_c) ds of
| NONE => NONE
| SOME env_c1 => SOME (nsAppend env_c1 env_c0))
∧
check_cons_dec env_c (Dlet locs p e) =
(if every_exp (one_con_check env_c) e
then SOME nsEmpty else NONE)
∧
check_cons_dec env_c (Dletrec locs funs) =
(if EVERY (λ(f,n,e). every_exp (one_con_check env_c) e) funs
then SOME nsEmpty else NONE)
∧
check_cons_dec env_c (Dtype locs tds) =
(SOME (build_tdefs 0 tds))
∧
check_cons_dec env_c (Dtabbrev locs tvs tn t) = SOME nsEmpty
∧
check_cons_dec env_c (Denv _) = SOME nsEmpty
∧
check_cons_dec env_c (Dexn locs cn ts) =
SOME (nsSing cn (LENGTH ts,ExnStamp 0))
∧
check_cons_dec env_c (Dmod mn ds) =
(case check_cons_dec_list env_c ds of
| NONE => NONE
| SOME env_c0 => SOME (nsLift mn env_c0))
∧
check_cons_dec env_c (Dlocal lds ds) =
case check_cons_dec_list env_c lds of
| NONE => NONE
| SOME env_c0 => check_cons_dec_list (nsAppend env_c0 env_c) ds
Termination
WF_REL_TAC ‘measure $ λx. case x of INL (_,ds) => list_size dec_size ds
| INR (_,d) => dec_size d’
End
Theorem check_cons_dec_list_isPREFIX:
∀env_c xs ys x.
check_cons_dec_list env_c xs = SOME x ∧ isPREFIX ys xs ⇒
∃y. check_cons_dec_list env_c ys = SOME y
Proof
Induct_on ‘xs’
\\ gvs [check_cons_dec_list_def,AllCaseEqs()]
\\ Cases_on ‘ys’ \\ gvs [check_cons_dec_list_def]
\\ rw [] \\ gvs [AllCaseEqs()]
QED
Triviality check_cons_dec_list_sing[simp]:
check_cons_dec_list env_c [d] = check_cons_dec env_c d
Proof
simp [check_cons_dec_list_def] \\ CASE_TAC \\ gvs []
QED
(* --- theorems --- *)
Definition con_check_eqv_def:
con_check_eqv (x: (string, string, num # stamp) namespace)
(y: (string, string, num # stamp) namespace) ⇔
case (x,y) of
| (Bind xs ys, Bind xs1 ys1) =>
LIST_REL (λ(a,x1,_) (b,y1,_). a = b ∧ x1 = y1) xs xs1 ∧
LIST_REL (λ(a,x1) (b,y1). a = b ∧ con_check_eqv x1 y1) ys ys1
Termination
WF_REL_TAC ‘measure $ λ(x,y). namespace_size (K 0) (K 0) (K 0) x’
End
Theorem con_check_eqv_refl[local,simp]:
∀x. con_check_eqv x x
Proof
qsuff_tac ‘∀x y. x = y ⇒ con_check_eqv x x’ >- gvs []
\\ ho_match_mp_tac con_check_eqv_ind \\ gvs []
\\ rw [] \\ Cases_on ‘y’ \\ gvs []
\\ simp [Once con_check_eqv_def]
\\ irule_at Any EVERY2_refl
\\ irule_at Any EVERY2_refl
\\ gvs [FORALL_PROD]
\\ metis_tac []
QED
Theorem con_check_eqv_nsAppend:
con_check_eqv x1 y1 ∧ con_check_eqv x2 y2 ⇒
con_check_eqv (nsAppend x1 x2) (nsAppend y1 y2)
Proof
once_rewrite_tac [con_check_eqv_def]
\\ Cases_on ‘x1’ \\ Cases_on ‘y1’ \\ Cases_on ‘x2’ \\ Cases_on ‘y2’
\\ gvs [nsAppend_def] \\ strip_tac
\\ imp_res_tac LIST_REL_LENGTH
\\ metis_tac [LIST_REL_APPEND]
QED
Theorem con_check_eqv_switch:
con_check_eqv env2 env1 ⇒
every_exp (one_con_check env1) e = every_exp (one_con_check env2) e
Proof
strip_tac \\ AP_THM_TAC \\ AP_TERM_TAC
\\ gvs [FUN_EQ_THM]
\\ Cases \\ gvs [one_con_check_def]
\\ qsuff_tac ‘∀a l. do_con_check env2 a l = do_con_check env1 a l’
\\ gvs []
\\ Cases \\ gvs [do_con_check_def]
\\ pop_assum mp_tac
\\ qid_spec_tac ‘env1’
\\ qid_spec_tac ‘env2’
\\ Induct_on ‘x’ \\ gvs []
>-
(rw [] \\ Cases_on ‘env1’ \\ Cases_on ‘env2’
\\ gvs [nsLookup_def]
\\ pop_assum mp_tac
\\ simp [Once con_check_eqv_def]
\\ qid_spec_tac ‘l0’
\\ qid_spec_tac ‘l0'’
\\ Induct \\ gvs [PULL_EXISTS,FORALL_PROD]
\\ rw [])
\\ rw []
\\ Cases_on ‘env1’ \\ Cases_on ‘env2’
\\ gvs [nsLookup_def]
\\ pop_assum mp_tac
\\ simp [Once con_check_eqv_def]
\\ rw []
\\ rename [‘LIST_REL _ l1 l2’]
\\ pop_assum mp_tac
\\ qid_spec_tac ‘l2’
\\ qid_spec_tac ‘l1’
\\ Induct \\ gvs [PULL_EXISTS,FORALL_PROD] \\ rw []
QED
Theorem con_check_eqv_build_tdefs[local]:
∀m n. con_check_eqv (build_tdefs m tds) (build_tdefs n tds)
Proof
Induct_on ‘tds’ \\ gvs [build_tdefs_def,FORALL_PROD]
\\ rw [] \\ irule con_check_eqv_nsAppend \\ gvs []
\\ gvs [alist_to_ns_def]
\\ simp [Once con_check_eqv_def,build_constrs_def]
\\ Induct_on ‘p_2’ \\ gvs [FORALL_PROD]
QED
Theorem evaluate_dec_list_eq_evaluate_decs:
∀(st:'ffi semanticPrimitives$state) env ds st1 res.
IS_SOME (check_cons_dec_list env.c ds)
⇒
evaluate_dec_list st env ds = evaluate_decs st env ds
Proof
rpt gen_tac
\\ qsuff_tac ‘
∀(st:'ffi semanticPrimitives$state) env ds n m env_1 st1 res env_c env_c1.
check_cons_dec_list env_c ds = SOME env_c1 ∧
con_check_eqv env.c env_c ∧
evaluate_dec_list st env ds = (st1,res)
⇒
evaluate_decs st env ds = (st1,res) ∧
(∀r. res = Rval r ⇒ con_check_eqv r.c env_c1)’
>- metis_tac [IS_SOME_EXISTS,EXISTS_PROD,PAIR,con_check_eqv_refl]
\\ ho_match_mp_tac evaluate_dec_list_ind
\\ rpt conj_tac
>- gvs [evaluate_def,evaluate_dec_list_def,
check_cons_dec_list_def]
>-
(rpt gen_tac \\ strip_tac
\\ simp [Once check_cons_dec_list_def]
\\ gvs [evaluate_def,evaluate_dec_list_def]
\\ rpt gen_tac \\ strip_tac
\\ simp [evaluate_decs_def]
\\ Cases_on ‘evaluate_dec_list st env [d1]’
\\ reverse $ Cases_on ‘r’
>- (gvs [] \\ gvs [AllCaseEqs()] \\ last_x_assum drule \\ gvs [])
\\ last_x_assum mp_tac \\ simp []
\\ last_x_assum mp_tac \\ simp []
\\ pop_assum mp_tac
\\ pop_assum mp_tac
\\ pop_assum mp_tac
\\ pop_assum mp_tac
\\ simp [AllCaseEqs(),EXISTS_PROD]
\\ strip_tac \\ gvs []
\\ rpt disch_tac
\\ rfs [extend_dec_env_def]
\\ last_x_assum drule \\ gvs [] \\ strip_tac
\\ last_x_assum drule \\ gvs []
\\ impl_tac
>- (irule con_check_eqv_nsAppend \\ gvs [])
\\ strip_tac
\\ gvs [combine_dec_result_def,AllCaseEqs(),PULL_EXISTS]
\\ Cases_on ‘r’ \\ gvs []
\\ irule con_check_eqv_nsAppend \\ gvs [])
>~ [‘Dlet’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ rpt gen_tac \\ strip_tac
\\ drule_all con_check_eqv_switch
\\ gvs [] \\ rw [] \\ gvs [AllCaseEqs()])
>~ [‘Dletrec’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ rpt gen_tac \\ strip_tac
\\ drule_all con_check_eqv_switch
\\ strip_tac \\ gvs []
\\ rw [] \\ gvs [AllCaseEqs()])
>~ [‘Dtype’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ rw [] \\ gvs [AllCaseEqs(),con_check_eqv_build_tdefs])
>~ [‘Dtabbrev’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def])
>~ [‘Denv’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ rw [] \\ gvs [AllCaseEqs()])
>~ [‘Dexn’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ rw [] \\ simp [Once con_check_eqv_def,nsSing_def])
>~ [‘Dmod’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ gvs [AllCaseEqs(),PULL_EXISTS]
\\ rw [] \\ gvs []
\\ res_tac \\ gvs [nsLift_def]
\\ simp [Once con_check_eqv_def])
>~ [‘Dlocal’] >-
(gvs [check_cons_dec_list_def,evaluate_decs_def,evaluate_dec_list_def]
\\ gvs [CaseEq "option",CaseEq "prod"]
\\ rpt (gen_tac ORELSE disch_then strip_assume_tac)
\\ reverse $ Cases_on ‘v1’
>- (gvs [] \\ res_tac \\ gvs [])
\\ pop_assum mp_tac \\ simp [extend_dec_env_def]
\\ last_x_assum drule
\\ last_x_assum drule
\\ asm_rewrite_tac []
\\ disch_then (strip_assume_tac o SRULE [])
\\ asm_rewrite_tac []
\\ simp [extend_dec_env_def]
\\ disch_then drule
\\ simp [con_check_eqv_nsAppend])
QED
Theorem evaluate_dec_list_set_clock:
∀s env decs s1 res.
evaluate_dec_list s env decs = (s1,res) ∧
res ≠ Rerr (Rabort Rtimeout_error) ⇒
∀ck. ∃ck1.
evaluate_dec_list (s with clock := ck1) env decs =
(s1 with clock := ck,res)
Proof
ho_match_mp_tac evaluate_dec_list_ind \\ rpt strip_tac
>- gvs [evaluate_dec_list_def,state_component_equality]
>- (gvs [evaluate_dec_list_def]
\\ reverse $ gvs [AllCaseEqs()]
>- (first_x_assum $ qspec_then ‘ck’ strip_assume_tac
\\ qexists_tac ‘ck1’ \\ gvs [])
\\ Cases_on ‘r = Rerr (Rabort Rtimeout_error)’
>- gvs [combine_dec_result_def] \\ gvs []
\\ last_x_assum $ qspec_then ‘ck’ strip_assume_tac
\\ last_x_assum $ qspec_then ‘ck1’ strip_assume_tac
\\ qexists_tac ‘ck1'’ \\ gvs [])
>~ [‘Dlet’] >-
(gvs [evaluate_dec_list_def]
\\ reverse $ gvs [AllCaseEqs()]
>- gvs [state_component_equality]
\\ drule evaluate_set_clock \\ gvs []
\\ disch_then $ qspec_then ‘ck’ strip_assume_tac
\\ qexists_tac ‘ck1’ \\ gvs [])
>~ [‘Dmod’] >-
(gvs [evaluate_dec_list_def,CaseEq"prod"]
\\ Cases_on ‘r = Rerr (Rabort Rtimeout_error)’ \\ gvs []
\\ last_x_assum $ qspec_then ‘ck’ strip_assume_tac
\\ qexists_tac ‘ck1’ \\ gvs [])
>~ [‘Dlocal’] >-
(gvs [evaluate_dec_list_def,CaseEq"prod"]
\\ Cases_on ‘v1 = Rerr (Rabort Rtimeout_error)’ \\ gvs []
\\ reverse $ Cases_on ‘v1’ \\ gvs []
>- (last_x_assum $ qspec_then ‘ck’ strip_assume_tac
\\ qexists_tac ‘ck1’ \\ gvs [])
\\ last_x_assum $ qspec_then ‘ck’ strip_assume_tac
\\ last_x_assum $ qspec_then ‘ck1’ strip_assume_tac
\\ qexists_tac ‘ck1'’ \\ gvs [])
\\ gvs [evaluate_dec_list_def,state_component_equality,AllCaseEqs()]
QED
Theorem evaluate_dec_list_cons:
∀s env d ds.
evaluate_dec_list s env (d::ds) =
case evaluate_dec_list s env [d] of
| (s1,Rval env1) =>
(case evaluate_dec_list s1 (env1 +++ env) ds of
(s2,r) => (s2,combine_dec_result env1 r))
| (s1,Rerr v7) => (s1,Rerr v7)
Proof
Cases_on ‘ds’
\\ gvs [evaluate_dec_list_def,combine_dec_result_def]
\\ rw [] \\ TOP_CASE_TAC \\ Cases_on ‘r’ \\ gvs []
QED
Theorem evaluate_dec_list_append:
∀s env xs ds.
evaluate_dec_list s env (xs ++ ds) =
case evaluate_dec_list s env xs of
| (s1,Rval env1) =>
(case evaluate_dec_list s1 (env1 +++ env) ds of
(s2,r) => (s2,combine_dec_result env1 r))
| (s1,Rerr v7) => (s1,Rerr v7)
Proof
Induct_on ‘xs’ \\ gvs [evaluate_dec_list_def]
>- (rw [] \\ TOP_CASE_TAC \\ gvs []
\\ Cases_on ‘r’ \\ gvs [combine_dec_result_def,extend_dec_env_def])
\\ once_rewrite_tac [evaluate_dec_list_cons]
\\ rpt gen_tac \\ TOP_CASE_TAC \\ Cases_on ‘r’ \\ gvs []
\\ Cases_on ‘evaluate_dec_list q (a +++ env) xs’ \\ Cases_on ‘r’ \\ gvs []
\\ gvs [combine_dec_result_def,extend_dec_env_def]
\\ ntac 5 (TOP_CASE_TAC \\ gvs [])
QED
Theorem evaluate_dec_list_add_to_clock:
∀s e p s' r extra.
evaluate_dec_list s e p = (s',r) ∧ r ≠ Rerr (Rabort Rtimeout_error) ⇒
evaluate_dec_list (s with clock := s.clock + extra) e p =
(s' with clock := s'.clock + extra,r)
Proof
ho_match_mp_tac evaluate_dec_list_ind \\ rpt strip_tac
>- gvs [evaluate_dec_list_def,state_component_equality]
>- (gvs [evaluate_dec_list_def]
\\ reverse $ gvs [AllCaseEqs()]
\\ last_x_assum $ qspec_then ‘extra’ strip_assume_tac
\\ gvs [combine_dec_result_def,AllCaseEqs()]
\\ Cases_on ‘r'’ \\ gvs [])
>~ [‘Dlet’] >-
(gvs [evaluate_dec_list_def]
\\ reverse $ gvs [AllCaseEqs()]
\\ drule evaluate_add_to_clock \\ gvs [])
>~ [‘Dmod’] >-
(gvs [evaluate_dec_list_def,CaseEq"prod"]
\\ Cases_on ‘r' = Rerr (Rabort Rtimeout_error)’ \\ gvs [])
>~ [‘Dlocal’] >-
(gvs [evaluate_dec_list_def,CaseEq"prod"]
\\ Cases_on ‘v1 = Rerr (Rabort Rtimeout_error)’ \\ gvs []
\\ reverse $ Cases_on ‘v1’ \\ gvs [])
\\ gvs [evaluate_dec_list_def,state_component_equality,AllCaseEqs()]
QED
Theorem eval_dec_list_no_eval_simulation:
∀s env decs s' res.
evaluate_dec_list s env decs = (s',res) ∧ s.eval_state = NONE ∧
res ≠ Rerr (Rabort Rtype_error) ⇒
s'.eval_state = NONE ∧
evaluate_dec_list (s with eval_state := es) env decs =
(s' with eval_state := es,res)
Proof
ho_match_mp_tac evaluate_dec_list_ind
\\ rpt conj_tac \\ rpt gen_tac \\ rpt disch_tac \\ rpt gen_tac
\\ rpt disch_tac \\ gvs []
\\ gvs [evaluate_dec_list_def,AllCaseEqs()]
\\ gvs [declare_env_def]
>- (Cases_on ‘r = Rerr (Rabort Rtype_error)’ \\ gvs [combine_dec_result_def])
\\ drule $ cj 1 evaluatePropsTheory.eval_no_eval_simulation
\\ gvs []
QED
Theorem evaluate_dec_list_call_FFI_rel_imp:
∀s e p s' r. evaluate_dec_list s e p = (s',r) ⇒ RTC call_FFI_rel s.ffi s'.ffi
Proof
ho_match_mp_tac evaluate_dec_list_ind \\ rpt strip_tac
\\ gvs [evaluate_dec_list_def,AllCaseEqs()]
\\ imp_res_tac evaluatePropsTheory.evaluate_call_FFI_rel_imp
\\ imp_res_tac RTC_TRANS
QED
val _ = export_theory();