-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgCorr.thy
1491 lines (1279 loc) · 57.7 KB
/
ProgCorr.thy
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
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* *********************************************************************
Theory ProgCorr.thy is part of a framework for modelling,
verification and transformation of concurrent imperative
programs. Copyright (c) 2021 M. Bortin
The framework is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more details see the license agreement (LICENSE) you should have
received along with the framework.
******************************************************************* *)
theory ProgCorr
imports RG
begin
section "Stepwise correspondence between programs"
definition prog_sim :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'b LA) \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> ('a LA \<times> 'b LA) set \<Rightarrow> bool"
where "prog_sim \<rho> \<rho>' r X \<equiv> (\<forall>(p, p') \<in> X. \<forall>(s, t) \<in> r. \<forall>p'' t'. \<rho>' \<turnstile> (p', t) -p\<rightarrow> (p'', t') \<longrightarrow>
(\<exists>s' p'''. \<rho> \<turnstile> (p, s) -p\<rightarrow> (p''', s') \<and> (s', t') \<in> r \<and> (p''', p'') \<in> X)) \<and>
(\<forall>p. (p, Skip) \<in> X \<longrightarrow> p = Skip) \<and>
(\<forall>p. (Skip, p) \<in> X \<longrightarrow> p = Skip)"
definition prog_corr :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'b LA) \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> ('a LA \<times> 'b LA) set"
where "prog_corr \<rho> \<rho>' r \<equiv> \<Union>{X. prog_sim \<rho> \<rho>' r X}"
abbreviation prog_corr' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'b LA) \<Rightarrow> 'a LA \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> 'b LA \<Rightarrow> bool"
("_, _ \<Turnstile> _ \<sqsupseteq>\<^bsub>_\<^esub> _" [71, 71, 20, 10, 20] 71)
where "\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_corr \<rho> \<rho>' r"
definition prog_mucorr :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'b LA) \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> ('a LA \<times> 'b LA) set"
where "prog_mucorr \<rho> \<rho>' r = {(p, p') |p p'. (\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p') \<and> \<rho>', \<rho> \<Turnstile> p' \<sqsupseteq>\<^bsub>r\<inverse>\<^esub> p}"
abbreviation prog_mucorr' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'b LA) \<Rightarrow> 'a LA \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> 'b LA \<Rightarrow> bool"
("_, _ \<Turnstile> _ \<approx>\<^bsub>_\<^esub> _" [71, 71, 20, 10, 20] 71)
where "\<rho>, \<rho>' \<Turnstile> p \<approx>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_mucorr \<rho> \<rho>' r"
abbreviation prog_mucorr'' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a LA \<Rightarrow> bool"
("_ \<Turnstile> _ \<approx>\<^bsub>_\<^esub> _" [71, 20, 10, 20] 71)
where "\<rho> \<Turnstile> p \<approx>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_mucorr \<rho> \<rho> r"
abbreviation prog_mucorr''' :: "'a LA \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> 'b LA \<Rightarrow> bool"
("\<Turnstile> _ \<approx>\<^bsub>_\<^esub> _" [20, 10, 20] 71)
where "\<Turnstile> p \<approx>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_mucorr (\<lambda>x. Skip) (\<lambda>x. Skip) r"
abbreviation prog_corr'' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a LA \<Rightarrow> bool"
("_ \<Turnstile> _ \<sqsupseteq>\<^bsub>_\<^esub> _" [71, 20, 20, 20] 71)
where "\<rho> \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_corr \<rho> \<rho> r"
abbreviation prog_corr'_id :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> 'a LA \<Rightarrow> bool"
("_, _ \<Turnstile> _ \<sqsupseteq> _" [71, 71, 20, 20] 71)
where "\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq> p' \<equiv> (p, p') \<in> prog_corr \<rho> \<rho>' Id"
abbreviation prog_corr'_id' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> 'a LA \<Rightarrow> bool"
("_ \<Turnstile> _ \<sqsupseteq> _" [71, 20, 20] 71)
where "\<rho> \<Turnstile> p \<sqsupseteq> p' \<equiv> (p, p') \<in> prog_corr \<rho> \<rho> Id"
abbreviation prog_corr''' :: "'a LA \<Rightarrow> ('a \<times> 'b) set \<Rightarrow> 'b LA \<Rightarrow> bool"
("\<Turnstile> _ \<sqsupseteq>\<^bsub>_\<^esub> _" [20, 20, 20] 71)
where "\<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<equiv> (p, p') \<in> prog_corr (\<lambda>x. Skip) (\<lambda>x. Skip) r"
abbreviation prog_corr'''_id :: "'a LA \<Rightarrow> 'a LA \<Rightarrow> bool"
("\<Turnstile> _ \<sqsupseteq> _" [20, 20] 71)
where "\<Turnstile> p \<sqsupseteq> p' \<equiv> (p, p') \<in> prog_corr (\<lambda>x. Skip) (\<lambda>x. Skip) Id"
abbreviation prog_mucorr'_id :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> (nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> 'a LA \<Rightarrow> bool"
("_, _ \<Turnstile> _ \<approx> _" [71, 71, 20, 20] 71)
where "\<rho>, \<rho>' \<Turnstile> p \<approx> p' \<equiv> (p, p') \<in> prog_mucorr \<rho> \<rho>' Id"
abbreviation prog_mucorr'_id' :: "(nat \<Rightarrow> 'a LA) \<Rightarrow> 'a LA \<Rightarrow> 'a LA \<Rightarrow> bool"
("_ \<Turnstile> _ \<approx> _" [71, 20, 20] 71)
where "\<rho> \<Turnstile> p \<approx> p' \<equiv> (p, p') \<in> prog_mucorr \<rho> \<rho> Id"
subsection "A fixed point characterisation"
definition "prod_rel X r = {((p, s), (q, t)) |p s q t. (p, q) \<in> X \<and> (s, t) \<in> r}"
definition "pstepR \<rho> = {((p, s), (q, t)) |p s q t. \<rho> \<turnstile> (p, s) -p\<rightarrow> (q, t)}"
definition "skip_cond X = (\<forall>(p,q)\<in>X. ((p = Skip) = (q = Skip)))"
definition "Transf \<rho> \<rho>' r X =
\<Union>{Y. prod_rel Y r O pstepR \<rho>' \<subseteq> pstepR \<rho> O prod_rel X r \<and> skip_cond Y}"
lemma prod_rel_monoL :
"A \<subseteq> B \<Longrightarrow> prod_rel A r \<subseteq> prod_rel B r"
by(clarsimp simp: prod_rel_def, fast)
lemma prog_sim_postfix_eq :
"prog_sim \<rho> \<rho>' r X = (X \<subseteq> Transf \<rho> \<rho>' r X)"
apply(clarsimp simp: prog_sim_def Transf_def)
apply(rule iffI)
apply(rule Union_upper, clarsimp)
apply(rule conjI, clarsimp simp: pstepR_def prod_rel_def)
apply(drule bspec, assumption, clarsimp)+
apply(drule spec, drule spec, drule mp, assumption)
apply(fastforce simp: relcompI)
apply(clarsimp simp: skip_cond_def, fast)
apply(rule conjI, clarsimp)
apply(drule subsetD, assumption, clarsimp)
apply(rename_tac p q s t q' t' Y)
apply(drule_tac c="((p, s), (q', t'))" in subsetD)
apply(fastforce simp: relcompI pstepR_def prod_rel_def)
apply(fastforce simp: relcompI pstepR_def prod_rel_def)
apply(rule conjI, clarsimp)
apply(drule subsetD, assumption, fastforce simp: skip_cond_def)
apply clarsimp
apply(drule subsetD, assumption, fastforce simp: skip_cond_def)
done
lemma prog_corr_gfp_eq :
"prog_corr \<rho> \<rho>' r = gfp (Transf \<rho> \<rho>' r)"
apply(simp add: prog_corr_def)
apply(subst prog_sim_postfix_eq)
apply(subst gfp_def)
by(rule refl)
theorem prog_corr_fixed :
"Transf \<rho> \<rho>' r (prog_corr \<rho> \<rho>' r) = prog_corr \<rho> \<rho>' r"
apply(subst prog_corr_gfp_eq)+
apply(rule sym, rule gfp_unfold)
apply(rule monoI)
apply(rename_tac A B, simp add: Transf_def)
apply(rule Union_least)
apply(rule Union_upper)
apply clarsimp
apply(drule_tac r=r in prod_rel_monoL)
apply(rename_tac p s p' s' q t)
apply(drule_tac c="((p, s), (q, t))" in subsetD, fast)
by fast
corollary prog_corr_sim :
"prog_sim \<rho> \<rho>' r (prog_corr \<rho> \<rho>' r)"
apply(subst prog_sim_postfix_eq)
apply(subst prog_corr_fixed)
by(rule subset_refl)
lemmas prog_corr_prop1 = prog_corr_sim[simplified prog_sim_def split_def, THEN conjunct1, rule_format]
lemmas prog_corr_prop2 = prog_corr_sim[simplified prog_sim_def split_def, THEN conjunct2, rule_format]
lemma mucorr_id_postfix_bisim :
"(prog_mucorr \<rho> \<rho> Id :: ('a LA \<times> 'a LA) set) \<subseteq> Transf \<rho> \<rho> Id (prog_mucorr \<rho> \<rho> Id) \<Longrightarrow>
\<rho> \<Turnstile> p \<approx> q \<Longrightarrow>
(\<forall>q' t. \<rho> \<turnstile> (q, s) -p\<rightarrow> (q', t) \<longrightarrow>
(\<exists>p'. \<rho> \<turnstile> (p, s) -p\<rightarrow> (p', t) \<and> \<rho> \<Turnstile> p' \<approx> q')) \<and>
(\<forall>p' t. \<rho> \<turnstile> (p, s) -p\<rightarrow> (p', t) \<longrightarrow>
(\<exists>q'. \<rho> \<turnstile> (q, s) -p\<rightarrow> (q', t) \<and> \<rho> \<Turnstile> q' \<approx> p'))"
apply(rule conjI)
apply(drule_tac subsetD, assumption)
apply(clarsimp simp: Transf_def prog_mucorr_def)
apply(drule_tac c="((p, s), (q', t))" in subsetD)
apply(clarsimp simp: prod_rel_def pstepR_def)
apply(fastforce simp: relcompI)
apply(clarsimp simp: prod_rel_def pstepR_def)
apply fast
apply(drule_tac c="(q,p)" in subsetD)
apply(clarsimp simp: prog_mucorr_def)
apply(clarsimp simp: Transf_def prog_mucorr_def)
apply(drule_tac c="((q, s), (p', t))" in subsetD)
apply(clarsimp simp: prod_rel_def pstepR_def)
apply(fastforce simp: relcompI)
apply(clarsimp simp: prod_rel_def pstepR_def)
apply fast
done
section "Further properties"
lemma small_step_eqv :
"(\<rho>, \<rho>' \<Turnstile> p \<approx> p') = ((\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq> p') \<and> (\<rho>', \<rho> \<Turnstile> p' \<sqsupseteq> p))"
by(simp add: prog_mucorr_def)
lemma prog_sim_skipD1 :
"(Skip, p) \<in> X \<Longrightarrow> prog_sim \<rho> \<rho>' r X \<Longrightarrow> p = Skip"
by(clarsimp simp: prog_sim_def)
lemma prog_sim_skipD2 :
"(p, Skip) \<in> X \<Longrightarrow> prog_sim \<rho> \<rho>' r X \<Longrightarrow> p = Skip"
by(clarsimp simp: prog_sim_def)
lemma prog_sim_step :
"(p, p') \<in> X \<Longrightarrow> prog_sim \<rho> \<rho>' r X \<Longrightarrow> (s, t) \<in> r \<Longrightarrow> \<rho>' \<turnstile> (p', t) -p\<rightarrow> (p'', t') \<Longrightarrow>
\<exists>s' p'''. \<rho> \<turnstile> (p, s) -p\<rightarrow> (p''', s') \<and> (s', t') \<in> r \<and> (p''', p'') \<in> X"
apply(simp add: prog_sim_def)
apply(drule conjunct1)
apply(drule bspec, assumption, simp)+
done
lemma prog_sim_steps :
"\<rho>' \<turnstile> (p', t) -p\<rightarrow>\<^sup>n (p'', t') \<Longrightarrow> (p, p') \<in> X \<Longrightarrow> prog_sim \<rho> \<rho>' r X \<Longrightarrow> (s, t) \<in> r \<Longrightarrow>
\<exists>s' p'''. \<rho> \<turnstile> (p, s) -p\<rightarrow>\<^sup>n (p''', s') \<and> (s', t') \<in> r \<and> (p''', p'') \<in> X"
apply(induct n arbitrary: p s p' t p'' t', simp)
apply clarsimp
apply((drule meta_spec)+, (drule meta_mp, assumption)+)
apply clarsimp
apply(drule_tac p=p''' in prog_sim_step, assumption, assumption, assumption)
apply clarify
apply(rename_tac s1 p1)
apply(rule_tac x=s1 in exI, simp)
apply(rule_tac x=p1 in exI, simp)
apply(erule relcomppI, assumption)
done
lemma prog_sim_skips :
"prog_sim \<rho> \<rho>' r {(Skip, Skip)}"
apply(clarsimp simp: prog_sim_def)
apply(erule Skip_pstep)
done
lemma prog_sim_union :
"prog_sim \<rho> \<rho>' r X \<Longrightarrow> prog_sim \<rho> \<rho>' r Z \<Longrightarrow> prog_sim \<rho> \<rho>' r (X \<union> Z)"
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(erule disjE)
apply(drule prog_sim_step, assumption+)
apply fastforce
apply(drule prog_sim_step, assumption+)
apply fastforce
apply(rule conjI, clarsimp)+
apply(erule prog_sim_skipD2, assumption)
apply(clarify, erule prog_sim_skipD2, assumption)
apply clarsimp
apply(rule conjI, clarify, erule prog_sim_skipD1, assumption)
apply(clarify, erule prog_sim_skipD1, assumption)
done
lemma prog_sim_Union :
"\<forall>x\<in>S. prog_sim \<rho> \<rho>' r x \<Longrightarrow> prog_sim \<rho> \<rho>' r (\<Union>S)"
apply(subst prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule bspec, assumption)
apply(drule prog_sim_step, assumption+)
apply fastforce
apply(rule conjI, clarsimp)
apply(drule bspec, assumption)
apply(drule prog_sim_skipD2, assumption+)
apply clarsimp
apply(drule bspec, assumption)
apply(drule prog_sim_skipD1, assumption+)
done
lemma prog_sim_comp :
"prog_sim \<rho> \<rho>' r1 X \<Longrightarrow> prog_sim \<rho>' \<rho>'' r2 X' \<Longrightarrow>
prog_sim \<rho> \<rho>'' (r1 O r2) (X O X')"
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(frule prog_sim_step, assumption, assumption, assumption)
apply clarsimp
apply(drule prog_sim_step, assumption, assumption, assumption)
apply clarsimp
apply(rename_tac t1 p1)
apply(rule_tac x=t1 in exI)
apply(rule_tac x=p1 in exI, simp)
apply(rule conjI)
apply(erule relcompI, assumption)+
apply(rule conjI, clarsimp)
apply(drule prog_sim_skipD2, assumption)
apply clarsimp
apply(drule prog_sim_skipD2, assumption+)
apply clarify
apply(drule prog_sim_skipD1, assumption)
apply clarsimp
apply(drule prog_sim_skipD1, assumption+)
done
lemma prog_sim_Id :
"prog_sim \<rho> \<rho> Id Id"
by(clarsimp simp: prog_sim_def)
lemma prog_corr_skipD1 :
"\<rho>, \<rho>' \<Turnstile> SKIP \<sqsupseteq>\<^bsub>r\<^esub> p \<Longrightarrow> p = SKIP"
by(clarsimp simp: prog_corr_prop2)
lemma prog_corr_skipD2 :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> SKIP \<Longrightarrow> p = SKIP"
by(clarsimp simp: prog_corr_prop2)
lemmas prog_corr_step = prog_sim_step[OF _ prog_corr_sim]
lemmas prog_corr_steps = prog_sim_steps[OF _ _ prog_corr_sim, rotated 1]
lemma prog_corr_trans :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r1\<^esub> p' \<Longrightarrow> \<rho>', \<rho>'' \<Turnstile> p' \<sqsupseteq>\<^bsub>r2\<^esub> p'' \<Longrightarrow>
\<rho>, \<rho>'' \<Turnstile> p \<sqsupseteq>\<^bsub>r1 O r2\<^esub> p''"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac X X')
apply(rule_tac x="X O X'" in exI)
apply(rule conjI)
apply(erule prog_sim_comp, assumption)
apply(erule relcompI, assumption)
done
lemmas prog_corr_trans' = prog_corr_trans[where ?r1.0=Id and ?r2.0=Id, simplified]
lemmas prog_corr_trans_IdL = prog_corr_trans[where ?r1.0=Id, simplified]
lemmas prog_corr_trans_IdR = prog_corr_trans[where ?r2.0=Id, simplified]
lemma prog_corr_refl :
"\<rho> \<Turnstile> p \<sqsupseteq> p"
apply(simp add: prog_corr_def)
apply(rule exI, rule conjI, rule prog_sim_Id)
by simp
lemma small_step_eqvD1 :
"\<rho>, \<rho>' \<Turnstile> p \<approx> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> p \<sqsupseteq> p'"
by(clarsimp simp: small_step_eqv)
lemma small_step_eqvD2 :
"\<rho>, \<rho>' \<Turnstile> p \<approx> p' \<Longrightarrow> \<rho>', \<rho> \<Turnstile> p' \<sqsupseteq> p"
by(clarsimp simp: small_step_eqv)
lemma small_step_eqv_refl :
"\<rho> \<Turnstile> p \<approx> p"
apply(clarsimp simp: small_step_eqv)
by(rule prog_corr_refl)
lemma small_step_eqv_sym :
"\<rho>, \<rho>' \<Turnstile> p \<approx> p' \<Longrightarrow> \<rho>', \<rho> \<Turnstile> p' \<approx> p"
by(clarsimp simp: small_step_eqv)
lemma small_step_eqv_trans :
"\<rho>, \<rho>' \<Turnstile> p \<approx> p' \<Longrightarrow> \<rho>', \<rho>'' \<Turnstile> p' \<approx> p'' \<Longrightarrow>
\<rho>, \<rho>'' \<Turnstile> p \<approx> p''"
apply(clarsimp simp: small_step_eqv)
apply(drule_tac p''=p'' in prog_corr_trans, assumption)
apply(drule_tac p=p'' in prog_corr_trans, assumption)
by simp
section "Further properties"
lemma small_step_eqv_substL :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p'' \<Longrightarrow> \<rho> \<Turnstile> p \<approx> p' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> p' \<sqsupseteq>\<^bsub>r\<^esub> p''"
apply(clarsimp simp: small_step_eqv)
apply(drule_tac p=p' in prog_corr_trans, assumption)
apply simp
done
lemma small_step_eqv_substR :
"\<rho>, \<rho>' \<Turnstile> p'' \<sqsupseteq>\<^bsub>r\<^esub> p \<Longrightarrow> \<rho>' \<Turnstile> p \<approx> p' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> p'' \<sqsupseteq>\<^bsub>r\<^esub> p'"
apply(clarsimp simp: small_step_eqv)
apply(drule_tac p=p'' in prog_corr_trans, assumption)
by simp
section "Associativity of sequencing"
lemma prog_corr_seq_assoc1 :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> q \<sqsupseteq>\<^bsub>r\<^esub> q' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> v \<sqsupseteq>\<^bsub>r\<^esub> v' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (p;q);v \<sqsupseteq>\<^bsub>r\<^esub> p';(q';v')"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac P Q V)
apply(rule_tac x="{(Seq (Seq x q) v, Seq x' (Seq q' v')) | x x'. (x, x') \<in> P} \<union>
{(Seq x v, Seq x' v') | x x'. (x, x') \<in> Q} \<union> V \<union> {(Skip, Skip)}" in exI)
apply simp
apply(subst prog_sim_def)
apply clarsimp
apply(rule conjI)
apply clarsimp
apply(erule Skip_pstep)
apply(rule conjI)
apply clarsimp
apply(rename_tac s t p'' t')
apply(erule disjE, clarsimp)
apply(case_tac "x' = SKIP", clarify)
apply(drule prog_sim_skipD2, assumption)
apply(drule Seq_pstep_Skip, clarsimp)
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI)
apply(rule pstep.Seq, rule pstep.SeqSkip)
apply fast
apply(drule Seq_pstep, assumption)
apply clarsimp
apply(drule_tac X=P and p=x in prog_sim_step[rotated -1], assumption+)
apply clarsimp
apply(rule_tac x=s' in exI, simp)
apply(rule exI, rule conjI)
apply(rule pstep.Seq, erule pstep.Seq)
apply fast
apply(erule disjE, clarsimp)
apply(case_tac "x' = SKIP", clarify)
apply(drule prog_sim_skipD2, assumption)
apply(drule Seq_pstep_Skip, clarsimp)
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI)
apply(rule pstep.SeqSkip)
apply fast
apply(drule Seq_pstep, assumption)
apply clarsimp
apply(drule_tac X=Q and p=x in prog_sim_step[rotated -1], assumption+)
apply clarsimp
apply(rule_tac x=s' in exI, simp)
apply(rule exI, rule conjI)
apply(erule pstep.Seq)
apply fast
apply(drule_tac X=V in prog_sim_step[rotated -1], assumption+)
apply fast
apply(rule conjI, clarsimp)
apply(erule prog_sim_skipD2, assumption)
apply clarsimp
apply(erule prog_sim_skipD1, assumption)
done
lemma prog_corr_seq_assoc2 :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> q \<sqsupseteq>\<^bsub>r\<^esub> q' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> v \<sqsupseteq>\<^bsub>r\<^esub> v' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> p;(q;v) \<sqsupseteq>\<^bsub>r\<^esub> (p';q');v'"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac P Q V)
apply(rule_tac x="{(Seq x (Seq q v), Seq (Seq x' q') v') | x x'. (x, x') \<in> P} \<union>
{(Seq x v, Seq x' v') | x x'. (x, x') \<in> Q} \<union> V \<union> {(Skip, Skip)}" in exI)
apply simp
apply(subst prog_sim_def)
apply clarsimp
apply(rule conjI)
apply clarsimp
apply(erule Skip_pstep)
apply(rule conjI)
apply clarsimp
apply(rename_tac s t p'' t')
apply(erule disjE, clarsimp)
apply(drule Seq_pstep, simp, clarsimp)
apply(case_tac "x' = SKIP", clarify)
apply(drule prog_sim_skipD2, assumption)
apply(drule Seq_pstep_Skip, clarsimp)
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI)
apply(rule pstep.SeqSkip)
apply fast
apply(drule Seq_pstep, simp, clarsimp)
apply(drule_tac X=P and p=x in prog_sim_step[rotated -1], assumption+)
apply clarsimp
apply(rule_tac x=s' in exI, simp)
apply(rule exI, rule conjI)
apply(erule pstep.Seq, fast)
apply(erule disjE, clarsimp)
apply(case_tac "x' = SKIP", clarify)
apply(drule prog_sim_skipD2, assumption)
apply(drule Seq_pstep_Skip, clarsimp)
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI)
apply(rule pstep.SeqSkip)
apply fast
apply(drule Seq_pstep, assumption)
apply clarsimp
apply(drule_tac X=Q and p=x in prog_sim_step[rotated -1], assumption+)
apply clarsimp
apply(rule_tac x=s' in exI, simp)
apply(rule exI, rule conjI)
apply(erule pstep.Seq)
apply fast
apply(drule_tac X=V in prog_sim_step[rotated -1], assumption+)
apply fast
apply(rule conjI, clarsimp)
apply(erule prog_sim_skipD2, assumption)
apply clarsimp
apply(erule prog_sim_skipD1, assumption)
done
theorem small_step_eqv_seq_assoc :
"\<rho> \<Turnstile> (p;q);v \<approx> p;q;v"
apply(simp add: small_step_eqv)
apply(rule conjI)
apply(rule prog_corr_seq_assoc1, (rule prog_corr_refl)+)
apply(rule prog_corr_seq_assoc2, (rule prog_corr_refl)+)
done
section "Structural correspondence rules"
lemma prog_corr_skips :
"\<rho>, \<rho>' \<Turnstile> SKIP \<sqsupseteq>\<^bsub>r\<^esub> SKIP"
apply(simp add: prog_corr_def)
apply(rule_tac x="{(Skip, Skip)}" in exI, simp)
by(rule prog_sim_skips)
lemma prog_corr_basics :
"(\<And>s t. (s, t) \<in> r \<Longrightarrow> (f s, f' t) \<in> r) \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Basic f \<sqsupseteq>\<^bsub>r\<^esub> Basic f'"
apply(simp add: prog_corr_def)
apply(rule_tac x="{(Basic f, Basic f'), (Skip, Skip)}" in exI, simp add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule Basic_pstep, clarsimp)
apply(drule meta_spec, drule meta_spec, drule meta_mp, assumption)
apply(rule exI, rule conjI, rule pstep.Basic, assumption)
apply clarsimp
by(erule Skip_pstep)
lemma prog_corr_cjumps :
"\<rho>, \<rho>' \<Turnstile> \<rho> i \<sqsupseteq>\<^bsub>r\<^esub> \<rho>' j \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow>
\<forall>(s, t) \<in> r. (s \<in> C) = (t \<in> C') \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> CJUMP C TO i OTHERWISE p END \<sqsupseteq>\<^bsub>r\<^esub> CJUMP C' TO j OTHERWISE p' END"
apply(simp add: prog_corr_def, clarify)
apply(rename_tac X Z)
apply(rule_tac x="{(CJump C i p, CJump C' j p')} \<union> X \<union> Z" in exI, simp)
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(drule CJump_pstep, clarify)
apply(erule disjE, clarsimp)
apply(rename_tac s t')
apply(rule_tac x=s in exI)
apply(rule exI, rule conjI, rule pstep.CJumpT, fast)
apply simp
apply clarsimp
apply(rename_tac s t')
apply(rule_tac x=s in exI)
apply(rule exI, rule conjI, rule pstep.CJumpF, fast)
apply simp
apply(rule conjI, clarsimp)
apply(erule disjE)
apply(drule prog_sim_step[rotated -1], assumption+)
apply fast
apply(drule prog_sim_step[rotated -1], assumption+)
apply fast
apply(rule conjI, clarify)+
apply(rule prog_sim_skipD2, assumption+)
apply(clarify, rule prog_sim_skipD2, assumption+)
apply clarify
apply(rule conjI, clarify)+
apply(rule prog_sim_skipD1, assumption+)
apply(clarify, rule prog_sim_skipD1, assumption+)
done
lemma prog_corr_whiles :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> q \<sqsupseteq>\<^bsub>r\<^esub> q' \<Longrightarrow>
\<forall>(s, t) \<in> r. (s \<in> C) = (t \<in> C') \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> WHILE C \<lbrakk>inv: I\<rbrakk> DO p SUBSEQUENTLY q OD \<sqsupseteq>\<^bsub>r\<^esub>
WHILE C' \<lbrakk>inv: I'\<rbrakk> DO p' SUBSEQUENTLY q' OD"
apply(simp add: prog_corr_def, clarify)
apply(rename_tac X Z)
apply(rule_tac x="{(While C I p q,
While C' I' p' q')} \<union>
{(SKIP;While C I p q,
SKIP;While C' I' p' q')} \<union>
{(u ; (SKIP ; While C I p q),
v ; (SKIP ; While C' I' p' q')) | u v. (u, v) \<in> X} \<union>
Z" in exI, simp)
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(drule Seq_pstep_Skip, clarify)
apply(intro exI, rule conjI, rule pstep.SeqSkip, fast)
apply(rule conjI, clarsimp)
apply(rename_tac s t p'' t')
apply(drule While_pstep, clarify)
apply(erule disjE, clarify)
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI, rule pstep.WhileT, fast, fast)
apply clarsimp
apply(rule_tac x=s in exI, simp)
apply(rule exI, rule conjI, rule pstep.WhileF, fast, fast)
apply(rule conjI, clarsimp)
apply(erule disjE, clarify)
apply(case_tac "v=SKIP", clarify)
apply(drule prog_sim_skipD2, assumption, clarify)
apply(drule Seq_pstep_Skip, clarify)
apply(intro exI, rule conjI, rule pstep.SeqSkip, fast)
apply(drule Seq_pstep, simp, clarify)
apply(drule prog_sim_step[rotated -1], assumption+)
apply clarsimp
apply(intro exI, rule conjI, erule pstep.Seq, fast)
apply(drule prog_sim_step[rotated -1], assumption+)
apply fast
apply(rule conjI, clarify)
apply(rule prog_sim_skipD2, assumption+)
apply(clarify, rule prog_sim_skipD1, assumption+)
done
subsection "Program correspondence and the parallel operator"
theorem prog_corr_parallels :
"\<forall>i<length ps. \<rho>,\<rho>' \<Turnstile> fst(ps!\<sigma> i) \<sqsupseteq>\<^bsub>r\<^esub> fst(ps'!i) \<Longrightarrow> length ps = length ps' \<Longrightarrow>
inj_on \<sigma> {0..<length ps'} \<Longrightarrow> \<forall>i<length ps'. \<sigma> i < length ps \<Longrightarrow>
\<rho>,\<rho>' \<Turnstile> Parallel ps \<sqsupseteq>\<^bsub>r\<^esub> Parallel ps'"
apply(clarsimp simp: prog_corr_def)
apply(subst (asm) Skolem_list_nth)
apply clarsimp
apply(rename_tac Xs)
apply(rule_tac x="{(Parallel u, Parallel v) |u v. length u = length v \<and> length v = length Xs \<and>
(\<forall>i<length v. prog_sim \<rho> \<rho>' r (Xs ! i) \<and> (fst (u ! \<sigma> i), fst (v ! i)) \<in> Xs ! i)}
\<union> {(Skip, Skip)}"
in exI, simp)
apply(subst prog_sim_def, clarsimp)
apply(rule conjI, clarsimp)
apply(erule Skip_pstep)
apply clarsimp
apply(rename_tac s t us p'' t' vs)
apply(drule Parallel_pstep)
apply(erule disjE, clarsimp)
apply(frule_tac x=i in spec, drule mp, assumption, erule conjE)
apply(drule_tac X="Xs!i" in prog_sim_step[rotated -1], assumption+)
apply clarify
apply(rule_tac x=s' in exI)
apply(rule exI, rule conjI, erule_tac i="\<sigma> i" in pstep.Parallel, simp, clarsimp)
apply(rename_tac j)
apply(case_tac "j = i", clarsimp)
apply(subgoal_tac "\<sigma> j \<noteq> \<sigma> i")
apply clarsimp
apply clarify
apply(erule notE, erule inj_onD, assumption, simp, simp)
apply clarsimp
apply(rule_tac x=s in exI, rule conjI, rule pstep.ParallelSkip)
apply clarsimp
apply(drule mem_nth, clarsimp)
apply(frule_tac inj_on_surj_set_intv, assumption)
apply(drule_tac x=i in spec, drule mp, assumption, erule exE)
apply(rename_tac j, clarify)
apply(drule_tac x=j in spec, drule mp, assumption, erule conjE)
apply(drule prog_sim_skipD2, assumption)
apply(drule_tac f=fst in arg_cong, simp)
by assumption
theorem Parallel_commute :
"\<forall>i<length ps. fst(ps!\<sigma> i) = fst(ps'!i) \<Longrightarrow> length ps = length ps' \<Longrightarrow>
inj_on \<sigma> {0..<length ps'} \<Longrightarrow> \<forall>i<length ps'. \<sigma> i < length ps \<Longrightarrow>
\<rho> \<Turnstile> Parallel ps \<approx> Parallel ps'"
apply(simp add: prog_mucorr_def)
apply(rule conjI)
apply(rule_tac \<sigma>=\<sigma> in prog_corr_parallels)
apply (simp add: prog_corr_refl)
apply clarsimp+
apply(subgoal_tac "\<forall>j<length ps. \<exists>i<length ps. \<sigma> i = j")
apply(drule choice'')
apply clarify
apply(rename_tac \<sigma>')
apply(rule_tac \<sigma>="\<sigma>'" in prog_corr_parallels)
apply clarify
apply(drule_tac x="\<sigma>' i" in spec)
apply(drule mp, fastforce)
apply(clarsimp simp: prog_corr_refl)+
apply(rule inj_onI, rename_tac i j)
apply(drule_tac f=\<sigma> and x="\<sigma>' i" in arg_cong)
apply fastforce
apply presburger
using inj_on_surj_set_intv by presburger
lemma prog_corr_parallels' :
"(\<And>i. i < length ps \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> fst (ps!i) \<sqsupseteq>\<^bsub>r\<^esub> fst (ps'!i)) \<Longrightarrow>
length ps = length ps' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Parallel ps \<sqsupseteq>\<^bsub>r\<^esub> Parallel ps'"
apply(rule prog_corr_parallels[where \<sigma>=id, simplified, rule_format])
by(fast, assumption, simp)
lemma prog_corr_scheme :
"(\<And>i. n \<le> i \<Longrightarrow> i < m \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> fst (f i) \<sqsupseteq>\<^bsub>r\<^esub> fst (g i)) \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Parallel (map f [n..<m]) \<sqsupseteq>\<^bsub>r\<^esub> Parallel (map g [n..<m])"
apply(rule prog_corr_parallels')
by simp+
lemma prog_corr_parallel_app :
"\<rho>, \<rho>' \<Turnstile> Parallel as \<sqsupseteq>\<^bsub>r\<^esub> Parallel as' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Parallel bs \<sqsupseteq>\<^bsub>r\<^esub> Parallel bs' \<Longrightarrow>
length as = length as' \<Longrightarrow>
length bs = length bs' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Parallel (as@bs) \<sqsupseteq>\<^bsub>r\<^esub> Parallel (as'@bs')"
apply(simp add: prog_corr_def, clarify)
apply(rename_tac A B)
apply(rule_tac x="{(Parallel (xs@zs), Parallel (xs'@zs')) | xs zs xs' zs'.
(Parallel xs, Parallel xs') \<in> A \<and> length xs = length xs' \<and>
(Parallel zs, Parallel zs') \<in> B \<and> length zs = length zs'}
\<union> {(Skip, Skip)}" in exI, simp)
apply(subst prog_sim_def, clarsimp)
apply(rule conjI, clarsimp)
apply(erule Skip_pstep)
apply(rule conjI, clarsimp)
apply(drule Parallel_pstep)
apply(erule disjE, clarsimp)
apply(case_tac "i < length xs'")
apply(subst (asm) nth_append, simp)
apply(frule_tac p'="Parallel xs'" and X=A in prog_sim_step[rotated 1], assumption)
apply(erule pstep.Parallel, assumption+)
apply clarsimp
apply(drule Parallel_pstep)
apply(erule disjE, clarsimp)
apply(rename_tac j p'')
apply(intro exI, rule conjI, rule_tac i=j in pstep.Parallel)
apply(subst nth_append, simp)
apply simp
apply(subst list_update_append, simp)+
apply(subst nth_append, simp)+
apply(intro exI, rule conjI, rule refl)+
apply simp
apply clarsimp
apply(drule_tac X=A in prog_sim_skipD1, assumption)
apply clarify
apply(drule leI)
apply(subst (asm) nth_append, simp)
apply(frule_tac p'="Parallel zs'" and X=B in prog_sim_step[rotated 1], assumption)
apply(erule pstep.Parallel, simp, assumption+)
apply clarsimp
apply(drule Parallel_pstep)
apply(erule disjE, clarsimp)
apply(rename_tac j p'')
apply(intro exI, rule conjI, rule_tac i="j+length xs" in pstep.Parallel)
apply(subst nth_append, simp)
apply simp
apply(subst list_update_append, simp)+
apply(subst nth_append, simp)+
apply(intro exI, rule conjI, rule refl)+
apply simp
apply clarsimp
apply(drule_tac X=B in prog_sim_skipD1, assumption)
apply clarify
apply clarsimp
apply(rule exI, rule conjI)
apply(rule pstep.ParallelSkip)
apply(frule_tac p="Parallel xs" in prog_sim_step, assumption+)
apply(rule pstep.ParallelSkip, clarsimp)
apply clarsimp
apply(drule_tac X=A in prog_sim_skipD2, assumption)
apply clarify
apply(drule Parallel_pstep_to_Skip)
apply(frule_tac p="Parallel zs" in prog_sim_step, assumption+)
apply(rule pstep.ParallelSkip, clarsimp)
apply clarsimp
apply(drule_tac X=B in prog_sim_skipD2, assumption)
apply clarify
apply(drule Parallel_pstep_to_Skip)
apply fastforce
apply assumption
apply(intro exI, rule conjI, rule refl)+
by simp
lemma prog_corr_parallel_Cons :
"\<rho>, \<rho>' \<Turnstile> Parallel ps \<sqsupseteq>\<^bsub>r\<^esub> Parallel ps' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow>
length ps = length ps' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Parallel ((p, a)#ps) \<sqsupseteq>\<^bsub>r\<^esub> Parallel ((p', a')#ps')"
apply(drule_tac as="[(p,a)]" and as'="[(p',a')]" in prog_corr_parallel_app[rotated 1])
apply(simp, assumption)
apply(rule prog_corr_parallels', simp)
by simp+
subsection "Further rules"
lemma prog_corr_seqs :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> q \<sqsupseteq>\<^bsub>r\<^esub> q' \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (p;q) \<sqsupseteq>\<^bsub>r\<^esub> (p';q')"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac X Z)
apply(rule_tac x="{(Seq u q, Seq v q') | u v. (u, v) \<in> X} \<union> Z" in exI, simp)
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(erule disjE, clarsimp)
apply(case_tac "v=Skip", clarify)
apply(drule prog_sim_skipD2, assumption)
apply clarify
apply(drule Seq_pstep_Skip, clarsimp)
apply(intro exI, rule conjI, rule pstep.SeqSkip)
apply fast
apply(drule Seq_pstep, assumption)
apply clarsimp
apply(drule_tac p'=v in prog_sim_step, assumption+)
apply clarify
apply(intro exI, rule conjI, erule pstep.Seq)
apply fast
apply(drule_tac X=Z in prog_sim_step[rotated 2], assumption+)
apply fast
apply(rule conjI, clarsimp)
apply(erule prog_sim_skipD2, assumption)
apply clarify
apply(erule prog_sim_skipD1, assumption)
done
lemma prog_corr_conds :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow> \<rho>, \<rho>' \<Turnstile> q \<sqsupseteq>\<^bsub>r\<^esub> q' \<Longrightarrow>
\<forall>(s, t) \<in> r. (s \<in> C) = (t \<in> C') \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (IF C THEN p ELSE q FI) \<sqsupseteq>\<^bsub>r\<^esub>
IF C' THEN p' ELSE q' FI"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac X Z)
apply(rule_tac x="{(Cond C p q, Cond C' p' q')} \<union> X \<union> Z" in exI, simp)
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(drule Cond_pstep, clarify)
apply(erule disjE, clarsimp)
apply(rename_tac s t)
apply(rule_tac x=s in exI)
apply(rule exI, rule conjI, rule pstep.CondT, fast, fast)
apply clarsimp
apply(rename_tac s t)
apply(rule_tac x=s in exI)
apply(rule exI, rule conjI, rule pstep.CondF, fast, fast)
apply(rule conjI, clarsimp)
apply(erule disjE)
apply(drule_tac X=X in prog_sim_step[rotated 2], assumption+)
apply fast
apply(drule_tac X=Z in prog_sim_step[rotated 2], assumption+)
apply fast
apply(rule conjI, clarsimp)+
apply(erule prog_sim_skipD2, assumption)
apply clarify
apply(erule prog_sim_skipD2, assumption)
apply(rule allI, rule conjI)
apply clarify
apply(erule prog_sim_skipD1, assumption)
apply clarify
apply(erule prog_sim_skipD1, assumption)
done
lemma prog_corr_awaits :
"\<rho>, \<rho>' \<Turnstile> p \<sqsupseteq>\<^bsub>r\<^esub> p' \<Longrightarrow>
\<forall>(s, t) \<in> r. t \<in> C' \<longrightarrow> s \<in> C \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (AWAIT C \<lbrakk>ann: a\<rbrakk> THEN p END) \<sqsupseteq>\<^bsub>r\<^esub> AWAIT C' \<lbrakk>ann: a'\<rbrakk> THEN p' END"
apply(clarsimp simp: prog_corr_def)
apply(rename_tac X)
apply(rule_tac x="{(Await C a p, Await C' a' p')} \<union> X" in exI, simp)
apply(subst prog_sim_def, simp)
apply(rule conjI, clarsimp)
apply(drule Await_pstep, clarify)
apply(subst (asm) rtranclp_power, clarify)
apply(drule prog_sim_steps[rotated 1], assumption+)
apply clarify
apply(frule prog_sim_skipD2, assumption)
apply clarify
apply(drule rtranclp_power[THEN iffD2, OF exI])+
apply(intro exI, rule conjI, rule pstep.Await, fast, assumption)
apply simp
apply(rule conjI, clarsimp)
apply(drule_tac X=X in prog_sim_step[rotated 2], assumption+)
apply fast
apply(rule conjI, clarsimp)
apply(erule prog_sim_skipD2, assumption)
apply clarify
apply(erule prog_sim_skipD1, assumption)
done
lemma prog_corr_await_basic :
"\<forall>(s, t) \<in> r. s \<in> C \<and> (\<exists>s'. \<rho> \<turnstile> (p, s) -p\<rightarrow>\<^sup>* (SKIP, s') \<and> (s', f t) \<in> r) \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (AWAIT C \<lbrakk>ann: a\<rbrakk> THEN p END) \<sqsupseteq>\<^bsub>r\<^esub> Basic f"
apply(clarsimp simp: prog_corr_def)
apply(rule_tac x="{(Await C a p, Basic f), (SKIP, SKIP)}" in exI, simp)
apply(simp add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule Basic_pstep, clarify)
apply(drule bspec, assumption)
apply clarsimp
apply(rule exI, rule conjI, erule pstep.Await, assumption+)
apply clarsimp
apply(erule Skip_pstep)
done
corollary prog_corr_atomic2_basic :
"\<forall>(s, t) \<in> r. (h(g s), f t) \<in> r \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (AWAIT UNIV \<lbrakk>ann: a\<rbrakk> THEN Basic g; Basic h END) \<sqsupseteq>\<^bsub>r\<^esub> Basic f"
apply(rule prog_corr_await_basic, clarsimp)
apply(drule bspec, assumption, clarsimp)
apply(rule exI, rule conjI)
apply(rule rtranclp_trans)
apply(rule r_into_rtranclp)
apply(rule pstep.Seq)
apply(rule pstep.Basic)
apply(rule rtranclp_trans)
apply(rule r_into_rtranclp)
apply(rule pstep.SeqSkip)
apply(rule r_into_rtranclp)
apply(rule pstep.Basic)
by simp
corollary prog_corr_atomic3_basic :
"\<forall>(s, t) \<in> r. (g3(g2(g1 s)), f t) \<in> r \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> (AWAIT UNIV \<lbrakk>ann: a\<rbrakk> THEN Basic g1; Basic g2; Basic g3 END) \<sqsupseteq>\<^bsub>r\<^esub> Basic f"
apply(rule prog_corr_await_basic, clarsimp)
apply(drule bspec, assumption, clarsimp)
apply(rule exI, rule conjI)
apply(rule rtranclp_trans)
apply(rule rtranclp_trans)
apply(rule r_into_rtranclp)
apply(rule pstep.Seq)
apply(rule pstep.Basic)
apply(rule r_into_rtranclp)
apply(rule pstep.SeqSkip)
apply(rule rtranclp_trans)
apply(rule rtranclp_trans)
apply(rule r_into_rtranclp)
apply(rule pstep.Seq)
apply(rule pstep.Basic)
apply(rule r_into_rtranclp)
apply(rule pstep.SeqSkip)
apply(rule r_into_rtranclp)
apply(rule pstep.Basic)
by assumption
lemma prog_corr_basic_await :
"\<forall>(s, t) \<in> r. \<forall>t'. t \<in> C \<longrightarrow> \<rho>' \<turnstile> (p, t) -p\<rightarrow>\<^sup>* (SKIP, t') \<longrightarrow> (f s, t') \<in> r \<Longrightarrow>
\<rho>, \<rho>' \<Turnstile> Basic f \<sqsupseteq>\<^bsub>r\<^esub> (AWAIT C \<lbrakk>ann: a\<rbrakk> THEN p END)"
apply(clarsimp simp: prog_corr_def)
apply(rule_tac x="{(Basic f, Await C a p), (SKIP, SKIP)}" in exI, simp)
apply(simp add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule bspec, assumption)
apply clarsimp
apply(drule Await_pstep, clarsimp)
apply(drule spec, drule mp, assumption)
apply(rule exI, rule conjI, rule pstep.Basic)
apply assumption
apply clarify
by(erule Skip_pstep)
lemmas prog_corr_basic_atomic = prog_corr_basic_await[where C=UNIV, simplified]
section "Replacement rules for the seq-normalisation"
lemma prog_corr_seqN_cond1 :
"\<rho> \<Turnstile> IF C THEN p ELSE q FI; r \<sqsupseteq>
IF C THEN p;r ELSE q;r FI"
apply(simp add: prog_corr_def)
apply(rule_tac x="{(Seq (Cond C p q) r, Cond C (Seq p r) (Seq q r))} \<union> Id" in exI, simp)
apply(simp (no_asm) add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule Cond_pstep, clarify)
apply(erule disjE, clarify)
apply(rule exI, rule conjI, rule pstep.Seq, erule pstep.CondT, simp)
apply clarify
apply(rule exI, rule conjI, rule pstep.Seq, erule pstep.CondF, simp)
apply fast
done
lemma prog_corr_seqN_cond2 :
"\<rho> \<Turnstile> IF C THEN p;r ELSE q;r FI \<sqsupseteq>
(IF C THEN p ELSE q FI; r)"
apply(simp add: prog_corr_def)
apply(rule_tac x="{(Cond C (Seq p r) (Seq q r), Seq (Cond C p q) r)} \<union> Id" in exI, simp)
apply(simp (no_asm) add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule Seq_pstep, simp, clarsimp)
apply(drule Cond_pstep, clarify)
apply(erule disjE, clarify)
apply(rule exI, rule conjI, erule pstep.CondT, simp)
apply clarify
apply(rule exI, rule conjI, erule pstep.CondF, simp)
apply fast
done
corollary eqv_seqN_cond :
"\<rho> \<Turnstile> IF C THEN p ELSE q FI; r \<approx> IF C THEN p;r ELSE q;r FI"
by(simp add: small_step_eqv, rule conjI, rule prog_corr_seqN_cond1,