-
Notifications
You must be signed in to change notification settings - Fork 85
/
timeFunSemScript.sml
644 lines (606 loc) · 19.6 KB
/
timeFunSemScript.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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
(*
semantics for timeLang
*)
open preamble
timeLangTheory
timeSemTheory
val _ = new_theory "timeFunSem";
Datatype:
input_delay = Delay
| Input num
End
(* a well-formed program will not produce NONE in eval_term *)
(* now returns (label, state) option *)
Definition eval_term_def:
(eval_term st (SOME i)
(Tm (Input in_signal)
cnds
clks
dest
difs) =
if i = in_signal ∧
EVERY (λck. ck IN FDOM st.clocks) clks ∧
EVERY (λ(t,c).
∃v. FLOOKUP st.clocks c = SOME v ∧
v ≤ t) difs
then SOME (LAction (Input in_signal),
st with <| clocks := resetClocks st.clocks clks
; ioAction := SOME (Input in_signal)
; location := dest
; waitTime := calculate_wtime st clks difs|>)
else NONE) ∧
(eval_term st NONE
(Tm (Output out_signal)
cnds
clks
dest
difs) =
if EVERY (λck. ck IN FDOM st.clocks) clks ∧
EVERY (λ(t,c).
∃v. FLOOKUP st.clocks c = SOME v ∧
v ≤ t) difs
then SOME (LAction (Output out_signal),
st with <| clocks := resetClocks st.clocks clks
; ioAction := SOME (Output out_signal)
; location := dest
; waitTime := calculate_wtime st clks difs|>)
else NONE) ∧
(eval_term st _ _ = NONE)
End
Definition machine_bounds_def:
machine_bounds st m tms ⇔
tms_conds_eval st tms ∧
conds_eval_lt_dimword m st tms ∧
terms_time_range m tms ∧
input_terms_actions m tms ∧
terms_wtimes_ffi_bound m st tms ∧
max_clocks st.clocks m
End
(* now returns (label, state) option *)
Definition pick_eval_input_term_def:
(pick_eval_input_term st i m (tm::tms) =
case tm of
| Tm (Input in_signal) cnds clks dest difs =>
if in_signal = i ∧
EVERY (λcnd. evalCond st cnd) cnds
then eval_term st (SOME i) tm
else pick_eval_input_term st i m tms
| _ => pick_eval_input_term st i m tms) ∧
(pick_eval_input_term st i m [] =
if i + 1 < m then SOME (LPanic (PanicInput i), st)
else NONE)
End
Definition pick_eval_output_term_def:
(pick_eval_output_term st (tm::tms) =
case tm of
| Tm (Output out_signal) cnds clks dest difs =>
if EVERY (λcnd. evalCond st cnd) cnds
then eval_term st NONE tm
else pick_eval_output_term st tms
| _ => pick_eval_output_term st tms) ∧
(pick_eval_output_term st [] = SOME (LPanic PanicTimeout, st))
End
Definition eval_input_def:
eval_input prog m n i st =
case ALOOKUP prog st.location of
| SOME tms =>
if n < m ∧ machine_bounds (resetOutput st) m tms
then pick_eval_input_term (resetOutput st) i m tms
else NONE
| _ => NONE
End
Definition eval_output_def:
eval_output prog m n st =
case ALOOKUP prog st.location of
| SOME tms =>
if n < m ∧ machine_bounds (resetOutput st) m tms
then pick_eval_output_term (resetOutput st) tms
else NONE
| _ => NONE
End
Definition eval_delay_wtime_none_def:
eval_delay_wtime_none st m n =
if n + 1 < m ∧
max_clocks (delay_clocks (st.clocks) (n + 1)) m
then SOME
(LDelay 1 ,
st with
<|clocks := delay_clocks (st.clocks) 1;
ioAction := NONE|>)
else NONE
End
Definition eval_delay_wtime_some_def:
eval_delay_wtime_some st m n w =
if 1 ≤ w ∧ w < m ∧ n + 1 < m ∧
max_clocks (delay_clocks (st.clocks) (n + 1)) m
then SOME
(LDelay 1 ,
st with
<|clocks := delay_clocks (st.clocks) 1;
waitTime := SOME (w - 1);
ioAction := NONE|>)
else NONE
End
(* rearrange the check on system time *)
Definition eval_step_def:
eval_step prog m n (or:input_delay) st =
case st.waitTime of
| NONE =>
(case or of
| Delay => eval_delay_wtime_none st m n
| Input i => eval_input prog m n i st)
| SOME w =>
if w = 0
then eval_output prog m n st
else
(case or of
| Delay => eval_delay_wtime_some st m n w
| Input i =>
if w ≠ 0 ∧ w < m
then eval_input prog m n i st
else NONE)
End
Definition next_oracle_def:
next_oracle (f:num -> input_delay) =
λn. f (n+1)
End
Definition set_oracle_def:
(set_oracle (Input _) (or:num -> input_delay) = next_oracle or) ∧
(set_oracle (Output _) or = or)
End
(*
Definition eval_steps_def:
(eval_steps 0 prog m n _ st =
if n < m ∧
(case st.waitTime of
| SOME w => w < m
| NONE => T)
then SOME ([],[])
else NONE) ∧
(eval_steps (SUC k) prog m n or st =
case eval_step prog m n (or 0) st of
| SOME (lbl, st') =>
let n' =
case lbl of
| LDelay d => d + n
| _ => n;
noracle =
case lbl of
| LDelay _ => next_oracle or
| LAction act => set_oracle act or
in
(case eval_steps k prog m n' noracle st' of
| NONE => NONE
| SOME (lbls', sts') => SOME (lbl::lbls', st'::sts'))
| NONE => NONE)
End
*)
Definition eval_steps_def:
(eval_steps 0 _ _ _ _ st = SOME ([],[])) ∧
(eval_steps (SUC k) prog m n or st =
if m - 1 <= n then SOME ([], [])
else
(case eval_step prog m n (or 0) st of
| SOME (lbl, st') =>
let n' =
case lbl of
| LDelay d => d + n
| _ => n;
noracle =
case lbl of
| LDelay _ => next_oracle or
| LAction act => set_oracle act or
in
(case eval_steps k prog m n' noracle st' of
| NONE => NONE
| SOME (lbls', sts') => SOME (lbl::lbls', st'::sts'))
| NONE => NONE))
End
(*
Definition eval_steps_def:
(eval_steps 0 _ _ _ _ st = SOME ([],[])) ∧
(eval_steps (SUC k) prog m n or st =
case eval_step prog m n (or 0) st of
| SOME (lbl, st') =>
let n' =
case lbl of
| LDelay d => d + n
| _ => n;
noracle =
case lbl of
| LDelay _ => next_oracle or
| LAction act => set_oracle act or
in
(case eval_steps k prog m n' noracle st' of
| NONE => NONE
| SOME (lbls', sts') => SOME (lbl::lbls', st'::sts'))
| NONE => NONE)
End
*)
Theorem label_from_pick_eval_input_term:
∀tms i st lbl st' m.
pick_eval_input_term st i m tms = SOME (lbl,st') ⇒
lbl = LAction (Input i) ∨
lbl = LPanic (PanicInput i)
Proof
Induct >> rw [] >>
gvs [pick_eval_input_term_def] >>
every_case_tac >> gvs [eval_term_def] >>
res_tac >> gvs []
QED
Theorem label_from_pick_eval_output_term:
∀tms st lbl st'.
pick_eval_output_term st tms = SOME (lbl,st') ⇒
(∃os. lbl = LAction (Output os)) ∨
lbl = LPanic PanicTimeout
Proof
Induct >> rw [] >>
gvs [pick_eval_output_term_def] >>
every_case_tac >> gvs [eval_term_def] >>
res_tac >> gvs []
QED
Theorem pick_eval_input_term_imp_pickTerm:
∀tms st m i st'.
machine_bounds (resetOutput st) m tms ∧
pick_eval_input_term (resetOutput st) i m tms =
SOME (LAction (Input i), st') ⇒
pickTerm (resetOutput st) m (SOME i) tms st' (LAction (Input i)) ∧
st'.ioAction = SOME (Input i)
Proof
Induct >>
rpt gen_tac >>
strip_tac >>
gs []
>- gs [pick_eval_input_term_def] >>
gs [pick_eval_input_term_def] >>
cases_on ‘h’ >> gs [] >>
cases_on ‘i'’ >> gs []
>- (
FULL_CASE_TAC >> gvs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
gs [machine_bounds_def] >>
gs [eval_term_def, evalTerm_cases] >>
rveq >> gs [state_component_equality]) >>
cases_on ‘ n' = i’ >> gvs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def] >>
disj2_tac >>
gs [tm_conds_eval_def, EVERY_MEM] >>
rw [] >> gvs [ timeLangTheory.termConditions_def] >>
res_tac >> gvs [] >>
FULL_CASE_TAC >> gvs []) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def] >>
gs [EVERY_MEM]) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def]
QED
Theorem pick_eval_output_term_imp_pickTerm:
∀tms st m os st'.
machine_bounds (resetOutput st) m tms ∧
pick_eval_output_term (resetOutput st) tms =
SOME (LAction (Output os),st') ⇒
pickTerm (resetOutput st) m NONE tms st' (LAction (Output os)) ∧
st'.ioAction = SOME (Output os)
Proof
Induct >>
rpt gen_tac >>
strip_tac >>
gs []
>- gs [pick_eval_output_term_def] >>
gs [pick_eval_output_term_def] >>
cases_on ‘h’ >> gs [] >>
reverse (cases_on ‘i’) >> gs []
>- (
FULL_CASE_TAC >> gs [] >> rveq >> gs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def] >>
gs [eval_term_def, evalTerm_cases] >>
rveq >> gs [state_component_equality]) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘os’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def] >>
gs [EVERY_MEM] >>
disj2_tac >>
rw [] >>
res_tac >> gs [] >>
FULL_CASE_TAC >> gs []) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘os’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def]
QED
Theorem pick_input_term_panic_sts_eq:
∀tms st m i st'.
pick_eval_input_term st i m tms =
SOME (LPanic (PanicInput i), st') ⇒
st = st'
Proof
Induct >>
rpt gen_tac >>
strip_tac >>
gs [pick_eval_input_term_def] >>
every_case_tac >> gvs [eval_term_def] >>
res_tac >> gvs []
QED
Theorem pick_eval_input_term_panic_imp_pickTerm:
∀tms st m i st'.
machine_bounds (resetOutput st) m tms ∧
pick_eval_input_term (resetOutput st) i m tms =
SOME (LPanic (PanicInput i), st') ⇒
pickTerm (resetOutput st) m (SOME i) tms st' (LPanic (PanicInput i))
Proof
Induct >>
rpt gen_tac >>
strip_tac >>
gs []
>- (
gs [pick_eval_input_term_def] >>
rewrite_tac [Once pickTerm_cases] >>
gs [machine_bounds_def]) >>
gs [pick_eval_input_term_def] >>
cases_on ‘h’ >> gs [] >>
cases_on ‘i'’ >> gs []
>- (
FULL_CASE_TAC >> gs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
gvs [machine_bounds_def] >>
gs [eval_term_def, evalTerm_cases] >>
rveq >> gs [state_component_equality]) >>
cases_on ‘ n' = i’ >> gvs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def] >>
gs [tms_conds_eval_def, tm_conds_eval_def, EVERY_MEM] >>
rw [] >> gvs [timeLangTheory.termConditions_def] >>
res_tac >> gvs [] >>
FULL_CASE_TAC >> gvs []) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def] >>
gs [EVERY_MEM]) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘i’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def]
QED
Theorem pick_eval_output_term_panic_imp_pickTerm:
∀tms st m st'.
machine_bounds (resetOutput st) m tms ∧
pick_eval_output_term (resetOutput st) tms =
SOME (LPanic PanicTimeout, st') ⇒
pickTerm (resetOutput st) m NONE tms st' (LPanic PanicTimeout)
Proof
Induct >>
rpt gen_tac >>
strip_tac >>
gs []
>- (
gs [pick_eval_output_term_def] >>
rewrite_tac [Once pickTerm_cases] >>
gs [machine_bounds_def]) >>
gs [pick_eval_output_term_def] >>
cases_on ‘h’ >> gs [] >>
reverse (cases_on ‘i’) >> gs []
>- (
FULL_CASE_TAC >> gs [] >> rveq >> gs []
>- (
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def] >>
gs [eval_term_def, evalTerm_cases] >>
rveq >> gs [state_component_equality]) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def] >>
gs [EVERY_MEM] >>
rw [] >>
res_tac >> gs [] >>
FULL_CASE_TAC >> gs []) >>
rewrite_tac [Once pickTerm_cases] >>
gs [] >>
last_x_assum (qspecl_then [‘st’, ‘m’, ‘st'’] mp_tac) >>
impl_tac
>- (
gs [] >>
gs [machine_bounds_def, tms_conds_eval_def, conds_eval_lt_dimword_def,
terms_time_range_def, input_terms_actions_def, terms_wtimes_ffi_bound_def,
terms_in_signals_def]) >>
strip_tac >>
gs [machine_bounds_def, terms_time_range_def,
conds_eval_lt_dimword_def, input_terms_actions_def,
terms_in_signals_def, tms_conds_eval_def, tm_conds_eval_def,
timeLangTheory.termConditions_def]
QED
Theorem eval_step_imp_step:
eval_step prog m n or st = SOME (label, st') ⇒
step prog label m n st st'
Proof
rw [] >>
fs [eval_step_def] >>
cases_on ‘st.waitTime’ >> gs [] >>
cases_on ‘or’ >> gs []
>- (
gs [eval_delay_wtime_none_def] >>
rveq >>
gs [step_cases, mkState_def] >>
gs [state_component_equality])
>- (
gs [eval_input_def] >>
FULL_CASE_TAC >> gvs [] >>
qmatch_asmsub_rename_tac ‘ALOOKUP _ _ = SOME tms’ >>
qmatch_asmsub_rename_tac ‘pick_eval_input_term _ i _ _ = _’ >>
drule label_from_pick_eval_input_term >>
strip_tac >> gvs []
>- (
imp_res_tac pick_eval_input_term_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
drule_all pick_eval_input_term_panic_imp_pickTerm >>
gs [step_cases, mkState_def])
>- (
FULL_CASE_TAC >> gs []
>- (
gs [eval_output_def] >>
every_case_tac >> rveq >> gs [] >>
rveq >> gs [] >>
qmatch_asmsub_rename_tac ‘ALOOKUP _ _ = SOME tms’ >>
drule label_from_pick_eval_output_term >>
strip_tac >> gvs []
>- (
imp_res_tac pick_eval_output_term_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
drule_all pick_eval_output_term_panic_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
gs [eval_delay_wtime_some_def] >>
rveq >>
gs [step_cases, mkState_def] >>
gs [state_component_equality]) >>
cases_on ‘x = 0’ >> gs []
>- (
gs [eval_output_def] >>
every_case_tac >> rveq >> gs [] >>
rveq >> gs [] >>
qmatch_asmsub_rename_tac ‘ALOOKUP _ _ = SOME tms’ >>
drule label_from_pick_eval_output_term >>
strip_tac >> gvs []
>- (
imp_res_tac pick_eval_output_term_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
drule_all pick_eval_output_term_panic_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
gs [eval_input_def] >>
FULL_CASE_TAC >> gs [] >> rveq >> gs [] >>
qmatch_asmsub_rename_tac ‘ALOOKUP _ _ = SOME tms’ >>
qmatch_asmsub_rename_tac ‘pick_eval_input_term _ i _ _ = _’ >>
drule label_from_pick_eval_input_term >>
strip_tac >> gvs []
>- (
imp_res_tac pick_eval_input_term_imp_pickTerm >>
gs [step_cases, mkState_def]) >>
drule_all pick_eval_input_term_panic_imp_pickTerm >>
gs [step_cases, mkState_def]
QED
Theorem eval_steps_imp_steps:
∀k prog m n or st labels sts.
eval_steps k prog m n or st = SOME (labels, sts) ⇒
steps prog labels m n st sts
Proof
Induct >> rw []
>- fs [eval_steps_def, steps_def] >>
gs [eval_steps_def] >>
every_case_tac >> gvs [] >>
TRY (cases_on ‘p’) >> gvs [] >>
gs [steps_def] >>
imp_res_tac eval_step_imp_step >>
gs [] >>
res_tac >> gs []
QED
val _ = export_theory();