-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample2.thy
1212 lines (987 loc) · 36.4 KB
/
Example2.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
(*
* Copyright 2014, General Dynamics C4 Systems
*
* SPDX-License-Identifier: GPL-2.0-only
*)
theory Example2
imports Isolation_S
begin
lemma direct_caps_of_update [simp]:
"direct_caps_of (s(x := y)) =
(direct_caps_of s)(x:= case y of None \<Rightarrow> {} | Some (Entity c) \<Rightarrow> c)"
by (rule ext, simp add: direct_caps_of_def split:option.splits)
lemma direct_caps_of_empty [simp]:
"direct_caps_of Map.empty = ( \<lambda> x. {})"
by (simp add: direct_caps_of_def fun_eq_iff)
definition "id\<^sub>0 \<equiv> 0"
definition "id\<^sub>1 \<equiv> 1"
definition "id\<^sub>2 \<equiv> 2"
definition "id\<^sub>3 \<equiv> 3"
definition "id\<^sub>4 \<equiv> 4"
definition "id\<^sub>5 \<equiv> 5"
(* e0 has create caps to all of memory, and full rights to itself. *)
definition
e0_caps :: "cap set"
where
"e0_caps \<equiv> range create_cap \<union> {full_cap 0}"
definition
s0 :: "state"
where
"s0 \<equiv> [0 \<mapsto> Entity e0_caps]"
definition
s1 :: "state"
where
"s1 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1}),
1 \<mapsto> null_entity]"
definition
s2 :: "state" where
"s2 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1}),
1 \<mapsto> Entity {create_cap 2}]"
definition
s3 :: "state" where
"s3 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>}]"
definition
s4 :: "state" where
"s4 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2},
2 \<mapsto> null_entity]"
definition
s5 :: "state" where
"s5 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1, write_cap 2}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2},
2 \<mapsto> null_entity]"
definition
s6 :: "state" where
"s6 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1, write_cap 2}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2, read_cap 2},
2 \<mapsto> null_entity]"
definition
s7 :: "state" where "s7 \<equiv> s4"
definition
s8 :: "state" where
"s8 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1, full_cap 3}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2},
2 \<mapsto> null_entity,
3 \<mapsto> null_entity]"
definition
s9 :: "state" where
"s9 \<equiv> [0 \<mapsto> Entity (e0_caps \<union> {full_cap 1}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2},
2 \<mapsto> null_entity,
3 \<mapsto> null_entity]"
definition
s10 :: "state" where "s10 \<equiv> s4"
definition
s :: "state" where
"s \<equiv> [0 \<mapsto> Entity (e0_caps - {create_cap 1, create_cap 2}),
1 \<mapsto> Entity {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2},
2 \<mapsto> null_entity]"
definition
op0 :: "sysOPs" where
"op0 \<equiv> SysCreate 0 (full_cap 0) (create_cap 1)"
definition
op1 :: "sysOPs" where
"op1 \<equiv> SysGrant 0 (full_cap 1) (create_cap 2) UNIV"
definition
op2 :: "sysOPs" where
"op2 \<equiv> SysGrant 0 (full_cap 1) (full_cap 1) {Write, Store}"
definition
op3 :: "sysOPs" where
"op3 \<equiv> SysCreate 1 \<lparr>target = 1, rights = {Write, Store}\<rparr> (create_cap 2)"
definition
op4 :: "sysOPs" where
"op4 \<equiv> SysTake 0 (full_cap 1) (full_cap 2) {Write}"
definition
op5 :: "sysOPs" where
"op5 \<equiv> SysCopy 1 \<lparr>target = 1, rights = {Write, Store}\<rparr> (full_cap 2) {Read}"
definition
op6 :: "sysOPs" where
"op6 \<equiv> SysRevoke 0 (write_cap 2)"
definition
op7 :: "sysOPs" where
"op7 \<equiv> SysCreate 0 (full_cap 0) (create_cap 3)"
definition
op8 :: "sysOPs" where
"op8 \<equiv> SysRemove 0 (full_cap 0) (full_cap 3)"
definition
op9 :: "sysOPs" where
"op9 \<equiv> SysDestroy 0 (create_cap 3)"
definition
op10 :: "sysOPs" where
"op10 \<equiv> SysRemoveSet 0 (full_cap 0) {full_cap 1, create_cap 1, create_cap 2}"
definition ops :: "sysOPs list" where
(* since the CDT isn't defined, op6 is skipped
"ops \<equiv> [op10, op9, op8, op7, op6, op5, op4, op3, op2, op1, op0]"
*)
"ops \<equiv> [op10, op9, op8, op7, op3, op2, op1, op0]"
(* is_entity lemmas *)
lemma is_entity_s0_e0 [simp]:
"is_entity s0 0"
by (simp add: is_entity_def s0_def)
lemma is_entity_s1_e0 [simp]:
"is_entity s1 0"
by (simp add: is_entity_def s1_def)
lemma is_entity_s2_e0 [simp]:
"is_entity s2 0"
by (simp add: is_entity_def s2_def)
lemma is_entity_s3_e0 [simp]:
"is_entity s3 0"
by (simp add: is_entity_def s3_def)
lemma is_entity_s4_e0 [simp]:
"is_entity s4 0"
by (simp add: is_entity_def s4_def)
lemma is_entity_s5_e0 [simp]:
"is_entity s5 0"
by (simp add: is_entity_def s5_def)
lemma is_entity_s6_e0 [simp]:
"is_entity s6 0"
by (simp add: is_entity_def s6_def)
lemma is_entity_s8_e0 [simp]:
"is_entity s8 0"
by (simp add: is_entity_def s8_def)
lemma is_entity_s9_e0 [simp]:
"is_entity s9 0"
by (simp add: is_entity_def s9_def)
lemma is_entity_s_e0 [simp]:
"is_entity s 0"
by (simp add: is_entity_def s_def)
lemma is_entity_s0_e1 [simp]:
"\<not> is_entity s0 1"
by (simp add: is_entity_def s0_def)
lemma is_entity_s1_e1 [simp]:
"is_entity s1 1"
by (simp add: is_entity_def s1_def)
lemma is_entity_s2_e1 [simp]:
"is_entity s2 1"
by (simp add: is_entity_def s2_def)
lemma is_entity_s3_e1 [simp]:
"is_entity s3 1"
by (simp add: is_entity_def s3_def)
lemma is_entity_s4_e1 [simp]:
"is_entity s4 1"
by (simp add: is_entity_def s4_def)
lemma is_entity_s5_e1 [simp]:
"is_entity s5 1"
by (simp add: is_entity_def s5_def)
lemma is_entity_s3_e2 [simp]:
"\<not> is_entity s3 2"
by (simp add: is_entity_def s3_def)
lemma is_entity_s4_e3 [simp]:
"\<not> is_entity s4 3"
by (simp add: is_entity_def s4_def)
(* direct_caps_of, caps_of and similar lemmas *)
lemma direct_caps_of_s0_e0_caps [simp]:
"direct_caps_of s0 0 = e0_caps"
by (simp add: direct_caps_of_def s0_def e0_caps_def)
lemma direct_caps_of_s1_e0_caps [simp]:
"direct_caps_of s1 0 = e0_caps \<union> {full_cap 1}"
by (simp add: direct_caps_of_def s1_def e0_caps_def)
lemma direct_caps_of_s2_e0_caps [simp]:
"direct_caps_of s2 0 = e0_caps \<union> {full_cap 1}"
by (simp add: direct_caps_of_def s2_def e0_caps_def)
lemma direct_caps_of_s4_e0_caps [simp]:
"direct_caps_of s4 0 = e0_caps \<union> {full_cap 1}"
by (simp add: direct_caps_of_def s4_def e0_caps_def)
lemma direct_caps_of_s5_e0_caps [simp]:
"direct_caps_of s5 0 = e0_caps \<union> {full_cap 1, write_cap 2}"
by (simp add: direct_caps_of_def s5_def e0_caps_def)
lemma direct_caps_of_s6_e0_caps [simp]:
"direct_caps_of s6 0 = e0_caps \<union> {full_cap 1, write_cap 2}"
by (simp add: direct_caps_of_def s6_def e0_caps_def)
lemma direct_caps_of_s8_e0_caps [simp]:
"direct_caps_of s8 0 = e0_caps \<union> {full_cap 1, full_cap 3}"
by (simp add: direct_caps_of_def s8_def e0_caps_def)
lemma direct_caps_of_s9_e0_caps [simp]:
"direct_caps_of s9 0 = e0_caps \<union> {full_cap 1}"
by (simp add: direct_caps_of_def s9_def e0_caps_def)
lemma direct_caps_of_s2_e1 [simp]:
"direct_caps_of s2 1 = {create_cap 2}"
by (simp add: direct_caps_of_def s2_def)
lemma direct_caps_of_s3_e1 [simp]:
"direct_caps_of s3 1 = {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>}"
by (simp add: direct_caps_of_def s3_def)
lemma direct_caps_of_s4_e1 [simp]:
"direct_caps_of s4 1 = {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2}"
by (simp add: direct_caps_of_def s4_def)
lemma direct_caps_of_s6_e1 [simp]:
"direct_caps_of s5 1 = {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2}"
by (simp add: direct_caps_of_def s5_def)
lemma direct_caps_of_s9_e1 [simp]:
"direct_caps_of s9 1 = {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2}"
by (simp add: direct_caps_of_def s9_def)
lemma full_cap_e0_caps_in_caps_of_s0_e0_caps [simp]:
"full_cap 0 \<in> caps_of s0 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma full_cap_e1_in_caps_of_s1_e0_caps [simp]:
"full_cap 1 \<in> caps_of s1 0"
by (rule direct_cap_in_cap, simp)
lemma full_cap_e1_in_caps_of_s2_e0_caps [simp]:
"full_cap 1 \<in> caps_of s2 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma full_cap_e0_caps_in_caps_of_s4_e0_caps [simp]:
"full_cap 0 \<in> caps_of s4 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma full_cap_e1_in_caps_of_s4_e0_caps [simp]:
"full_cap 1 \<in> caps_of s4 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma full_cap_e2_in_caps_of_s4_e1 [simp]:
"full_cap 2 \<in> caps_of s4 1"
by (rule direct_cap_in_cap, simp)
lemma full_cap_e1_in_caps_of_s5_e0_caps [simp]:
"full_cap 1 \<in> caps_of s5 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma full_cap_e2_in_caps_of_s5_e0_caps [simp]:
"full_cap 2 \<in> caps_of s5 1"
by (rule direct_cap_in_cap, simp)
lemma full_cap_e0_caps_in_caps_of_s8_e0_caps [simp]:
"full_cap 0 \<in> caps_of s8 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma create_cap_in_caps_of_s0_e0_caps [simp]:
"create_cap i \<in> caps_of s0 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma create_cap_in_caps_of_s1_e0_caps [simp]:
"create_cap i \<in> caps_of s1 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma create_cap_in_caps_of_s2_e1 [simp]:
"create_cap 2 \<in> caps_of s2 1"
by (rule direct_cap_in_cap, simp)
lemma create_cap_in_caps_of_s3_e1 [simp]:
"create_cap 2 \<in> caps_of s3 1"
by (rule direct_cap_in_cap, simp)
lemma create_cap_in_caps_of_s4_e3 [simp]:
"create_cap 3 \<in> caps_of s4 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma create_cap_in_caps_of_s9_e3 [simp]:
"create_cap 3 \<in> caps_of s9 0"
by (rule direct_cap_in_cap, simp add: e0_caps_def)
lemma write_store_e1_in_caps_of_s3_e1 [simp]:
"\<lparr>target = 1, rights = {Write, Store}\<rparr> \<in> caps_of s3 1"
by (rule direct_cap_in_cap, simp)
lemma write_store_e1_in_caps_of_s5_e1 [simp]:
"\<lparr>target = 1, rights = {Write, Store}\<rparr> \<in> caps_of s5 1"
by (rule direct_cap_in_cap, simp)
lemma write_cap_e2_in_caps_of_s6_e0_caps [simp]:
"write_cap 2 \<in> caps_of s6 0"
by (rule direct_cap_in_cap, simp)
(*********************************)
(* State after the opeartions *)
(*********************************)
(* "op0 \<equiv> SysCreate 0 (full_cap 0) (create_cap 1)" *)
lemma op0_legal:
"legal op0 s0"
by (clarsimp simp: op0_def all_rights_def)
lemma execute_op0_safe:
"step op0 s0 \<subseteq> ({s0, s1})"
by (fastforce simp: op0_def step_def createOperation_def s0_def s1_def
split: if_split_asm)
lemma execute_op0_live:
"step op0 s0 \<supseteq> ({s0, s1})"
apply clarsimp
apply (rule conjI)
apply (simp add: step_def)
apply (simp add: step_def op0_legal)
apply (rule disjI2)
apply (clarsimp simp: op0_def createOperation_def)
apply (rule ext)
apply (clarsimp simp: s0_def s1_def)
done
lemma execute_op0:
"step op0 s0 = ({s0, s1})"
apply rule
apply (rule execute_op0_safe)
apply (rule execute_op0_live)
done
(* "op1 \<equiv> SysGrant 0 (full_cap 1) (create_cap 2) UNIV" *)
lemma op1_legal:
"legal op1 s1"
by (clarsimp simp: op1_def all_rights_def)
lemma execute_op1_safe:
"step op1 s1 \<subseteq> ({s1, s2})"
by (clarsimp simp: op1_def step_def grantOperation_def diminish_def
s1_def s2_def create_cap_def null_entity_def
split: if_split_asm)
lemma execute_op1_live:
"step op1 s1 \<supseteq> ({s1, s2})"
apply clarsimp
apply (rule conjI)
apply (simp add: step_def)
apply (simp add: step_def op1_legal)
apply (rule disjI2)
apply (clarsimp simp: op1_def grantOperation_def)
apply (rule ext)
apply (clarsimp simp: s1_def s2_def null_entity_def)
done
lemma execute_op1:
"step op1 s1 = ({s1, s2})"
apply rule
apply (rule execute_op1_safe)
apply (rule execute_op1_live)
done
(* "op2 \<equiv> SysGrant 0 (full_cap 1) (full_cap 1) {Write, Store}" *)
lemma op2_legal:
"legal op2 s2"
by (clarsimp simp: op2_def all_rights_def)
lemma execute_op2_safe:
"step op2 s2 \<subseteq> ({s2, s3})"
apply clarsimp
apply (rule ext)
apply (auto simp: op2_def step_def grantOperation_def diminish_def s2_def s3_def full_cap_def all_rights_def
split: if_split_asm)
done
lemma execute_op2_live:
"step op2 s2 \<supseteq> ({s2, s3})"
apply clarsimp
apply (simp add: step_def op2_legal)
apply (rule disjI2)
apply (simp add: op2_def)
apply (rule ext)
apply (fastforce simp: s2_def s3_def grantOperation_def diminish_def all_rights_def full_cap_def)
done
lemma execute_op2:
"step op2 s2 = ({s2, s3})"
apply rule
apply (rule execute_op2_safe)
apply (rule execute_op2_live)
done
(* "op3 \<equiv> SysCreate 1 (full_cap 1) (create_cap 2)" *)
lemma op3_legal:
"legal op3 s3"
by (clarsimp simp: op3_def all_rights_def)
lemma execute_op3_safe:
"step op3 s3 \<subseteq> ({s3, s4})"
apply (clarsimp, rule ext)
apply (auto simp: op3_def step_def createOperation_def s3_def s4_def
split: if_split_asm)
done
lemma execute_op3_live:
"step op3 s3 \<supseteq> ({s3, s4})"
apply clarsimp
apply (simp add: step_def op3_legal)
apply (rule disjI2)
apply (clarsimp simp: op3_def createOperation_def)
apply (rule ext)
apply (fastforce simp: s3_def s4_def)
done
lemma execute_op3:
"step op3 s3 = ({s3, s4})"
apply rule
apply (rule execute_op3_safe)
apply (rule execute_op3_live)
done
(* op4 \<equiv> SysTake 0 (full_cap 1) (full_cap 2) {Write} *)
lemma op4_legal:
"legal op4 s4"
by (clarsimp simp: op4_def all_rights_def)
lemma execute_op4_safe:
"step op4 s4 \<subseteq> ({s4, s5})"
apply (clarsimp, rule ext)
apply (auto simp: s4_def s5_def op4_def step_def takeOperation_def
diminish_def all_rights_def write_cap_def
split: if_split_asm)
done
lemma execute_op4_live:
"step op4 s4 \<supseteq> ({s4, s5})"
apply clarsimp
apply (simp add: op4_legal step_def)
apply (rule disjI2)
apply (simp add: op4_def)
apply (rule ext)
apply (fastforce simp: s4_def s5_def takeOperation_def diminish_def all_rights_def write_cap_def)
done
lemma execute_op4:
"step op4 s4 = ({s4, s5})"
apply rule
apply (rule execute_op4_safe)
apply (rule execute_op4_live)
done
(* op5 \<equiv> SysCopy 1 (full_cap 1) (full_cap 2) {Read} *)
lemma op5_legal:
"legal op5 s5"
by (clarsimp simp: op5_def all_rights_def)
lemma execute_op5_safe:
"step op5 s5 \<subseteq> ({s5, s6})"
apply (clarsimp, rule ext)
apply (auto simp: s5_def s6_def op5_def step_def copyOperation_def diminish_def all_rights_def read_cap_def
split: if_split_asm)
done
lemma execute_op5_live:
"step op5 s5 \<supseteq> ({s5, s6})"
apply clarsimp
apply (simp add: step_def op5_legal)
apply (rule disjI2)
apply (simp add: op5_def)
apply (rule ext)
apply (fastforce simp: s5_def s6_def copyOperation_def diminish_def all_rights_def read_cap_def)
done
lemma execute_op5:
"step op5 s5 = ({s5, s6})"
apply rule
apply (rule execute_op5_safe)
apply (rule execute_op5_live)
done
(* op6 \<equiv> SysRevoke 0 (read_cap 2) *)
lemma op6_legal:
"legal op6 s6"
by (clarsimp simp: op6_def all_rights_def)
lemma execute_op6_safe:
"step op6 s6 \<subseteq> ({s6, s7})"
apply (clarsimp, rule ext)
apply (auto simp: s6_def s7_def s4_def op7_def step_def revokeOperation_def
split: if_split_asm)
oops
lemma execute_op6_live:
"step op6 s6 \<supseteq> ({s6, s7})"
apply (insert op6_legal)
oops (*
apply (auto simp: step_def op6_legal op6_def s6_def s7_def s4_def revokeOperation_def fun_eq_iff)
done*)
(* Since cdt is not defined, this proof can't be done *)
lemma execute_op6_live:
"s7 \<in> step op6 s6"
oops
lemma execute_op6:
"step op6 s6 = ({s6, s7})"
oops
(* op7 \<equiv> SysCreate 0 (full_cap 0) (create_cap 3) *)
lemma op7_legal:
"legal op7 s7"
by (clarsimp simp: s7_def op7_def all_rights_def)
lemma execute_op7_safe:
"step op7 s7 \<subseteq> ({s7, s8})"
apply (clarsimp, rule ext)
apply (auto simp: s7_def s8_def s4_def op7_def step_def createOperation_def
split: if_split_asm)
done
lemma execute_op7_live:
"step op7 s7 \<supseteq> ({s7, s8})"
apply clarsimp
apply (simp add: step_def op7_legal)
apply (rule disjI2)
apply (simp add: op7_def)
apply (rule ext)
apply (fastforce simp: s7_def s8_def s4_def createOperation_def)
done
lemma execute_op7:
"step op7 s7 = ({s7, s8})"
apply rule
apply (rule execute_op7_safe)
apply (rule execute_op7_live)
done
(* op8 \<equiv> SysRemove 0 (full_cap 0) (full_cap 3) *)
lemma op8_legal:
"legal op8 s8"
by (clarsimp simp: op8_def)
lemma execute_op8_safe:
"step op8 s8 \<subseteq> ({s8, s9})"
apply clarsimp
apply (rule ext)
apply (insert op8_legal)
apply (fastforce simp: step_def op8_def s8_def s9_def removeOperation_def
full_cap_def create_cap_def all_rights_def e0_caps_def)
done
lemma execute_op8_live:
"step op8 s8 \<supseteq> ({s8, s9})"
apply (simp add: step_def op8_legal op8_def)
apply (rule disjI2)
apply (rule ext)
apply (clarsimp simp: removeOperation_def)
apply (fastforce simp: s8_def s9_def full_cap_def create_cap_def all_rights_def e0_caps_def)
done
lemma execute_op8:
"step op8 s8 = ({s8, s9})"
apply rule
apply (rule execute_op8_safe)
apply (rule execute_op8_live)
done
(* op9 \<equiv> SysDelete 0 (create_cap 3) *)
lemma op9_legal:
"legal op9 s9"
apply (simp add: op9_def)
apply (fastforce simp: s9_def e0_caps_def null_entity_def split:if_split_asm)
done
lemma execute_op9_safe:
"step op9 s9 \<subseteq> ({s9, s10})"
apply (clarsimp, rule ext)
apply (auto simp: s9_def s10_def s4_def op9_def step_def destroyOperation_def
split: if_split_asm)
done
lemma execute_op9_live:
"step op9 s9 \<supseteq> ({s9, s10})"
apply (simp add: step_def op9_legal)
apply (rule disjI2)
apply (simp add: op9_def)
apply (rule ext)
apply (clarsimp simp: destroyOperation_def step_def op9_def s9_def s10_def s4_def)
done
lemma execute_op9:
"step op9 s9 = ({s9, s10})"
apply rule
apply (rule execute_op9_safe)
apply (rule execute_op9_live)
done
(* op10 \<equiv> SysRemoveSet 0 (full_cap 0) {full_cap 1, create_cap 1, create_cap 2} *)
lemma op10_legal:
"legal op10 s10"
by (clarsimp simp: s10_def op10_def all_rights_def)
lemma e0_caps_diminished [simp]:
"e0_caps - {full_cap 1, create_cap 1, create_cap 2} = e0_caps - {create_cap 1, create_cap 2}"
by (fastforce simp: e0_caps_def create_cap_def full_cap_def all_rights_def)
lemma execute_op10_safe:
"step op10 s10 \<subseteq> ({s10, s})"
apply (clarsimp, rule ext)
apply (auto simp: s10_def op10_def step_def removeSetOperation_def s4_def s_def
split: if_split_asm)
done
lemma execute_op10_live:
"step op10 s10 \<supseteq> ({s10, s})"
apply clarsimp
apply (rule conjI)
apply (simp add: step_def)
apply (simp add: step_def op10_legal)
apply (rule disjI2)
apply (clarsimp simp: s10_def op10_def removeSetOperation_def)
apply (rule ext)
apply (fastforce simp: s4_def s_def)
done
lemma execute_op10:
"step op10 s10 = ({s10, s})"
apply rule
apply (rule execute_op10_safe)
apply (rule execute_op10_live)
done
lemma execute_ops:
"s \<in> execute ops s0"
apply (clarsimp simp: ops_def)
apply (insert execute_op0_live execute_op1_live execute_op2_live execute_op3_live
execute_op4_live execute_op5_live execute_op7_live
execute_op8_live execute_op9_live execute_op10_live)
apply (simp add: s7_def)
apply fastforce
done
(*********************************)
(* Results about the final state *)
(*********************************)
lemma store_not_in_create_cap [simp]:
"Store \<notin> rights (create_cap i)"
by (simp add: create_cap_def)
lemma store_not_in_create_cap2 [simp]:
"Store \<in> rights c \<Longrightarrow> c \<noteq> create_cap i"
by (clarsimp simp: create_cap_def)
(*********************************)
(* store_connected_direct *)
(*********************************)
lemma store_connected_direct_s_helper1:
"{c'.(c' = \<lparr>target = 0, rights = UNIV\<rparr> \<or> c' \<in> range create_cap) \<and>
c' \<noteq> \<lparr>target = 1, rights = {Create}\<rparr> \<and> c' \<noteq> \<lparr>target = 2, rights = {Create}\<rparr> \<and>
Store \<in> rights c'} = {full_cap 0}"
by (auto simp: create_cap_def full_cap_def all_rights_def e0_caps_def)
lemma store_connected_direct_s_helper2:
"{c'. (c' = \<lparr>target = 2, rights = {Create}\<rparr> \<or> c' = \<lparr>target = 1, rights = {Write, Store}\<rparr> \<or>
c' = \<lparr>target = 2, rights = UNIV\<rparr>) \<and> Store \<in> rights c'}
= {\<lparr>target = 1, rights = {Write, Store}\<rparr>, full_cap 2}"
by (auto simp: create_cap_def full_cap_def all_rights_def e0_caps_def)
lemma store_connected_direct_s:
"store_connected_direct s = {(0,0), (1,1), (1,2)}"
by (fastforce simp: store_connected_direct_def s_def e0_caps_def
full_cap_def all_rights_def create_cap_def null_entity_def
store_connected_direct_s_helper1 store_connected_direct_s_helper2
split: if_split_asm)
(*********************************)
(* store_connected *)
(*********************************)
lemma into_rtrancl [rule_format]:
"(a,b) \<in> r^* \<Longrightarrow> (\<forall>x. (x,b) \<in> r \<longrightarrow> x = b) \<longrightarrow> a = b"
apply (erule converse_rtrancl_induct)
apply simp
apply clarsimp
done
lemma into_rtrancl2 [rule_format]:
" \<And> B. \<lbrakk>(a,b) \<in> r^*; b \<in> B\<rbrakk> \<Longrightarrow> (\<forall>x.(x,b) \<in> r \<longrightarrow> x \<in> B) \<longrightarrow> a \<in> B"
thm rtrancl_induct converse_rtrancl_induct
apply (erule converse_rtrancl_induct)
apply clarsimp
apply clarsimp
oops
lemma store_connected_id:
"{(0::word32, 0), (1, 1), (1, 2)}\<^sup>* = {(1, 2)}\<^sup>* "
apply rule
apply clarsimp
apply (erule rtranclE)
apply simp
apply (fastforce dest: into_rtrancl)
apply clarsimp
apply (erule rtranclE)
apply simp
apply (fastforce dest: into_rtrancl)
done
lemma store_connected_s: "store_connected s = {(1,2)} \<union> Id"
apply simp
apply (rule equalityI)
apply (insert store_connected_direct_s)
apply (simp add: store_connected_def)
apply clarsimp
apply (erule converse_rtranclE)
apply simp
apply clarsimp
apply (erule rtranclE)
apply fastforce
apply (simp add: store_connected_id)
apply (drule rtranclD)
apply (safe, simp_all, (erule tranclE, simp, fastforce)+)
apply (fastforce simp: store_connected_def)
done
(*********************************)
(* caps_of *)
(*********************************)
lemma caps_of_s_e0_caps: "caps_of s 0 = e0_caps - {create_cap 1, create_cap 2}"
apply (clarsimp simp: caps_of_def store_connected_s Collect_disj_eq)
apply (simp add: s_def)
done
lemma caps_of_s_e0_caps_2: "caps_of s 0 = {full_cap 0} \<union> ( range create_cap - {create_cap 1, create_cap 2})"
by (fastforce simp: caps_of_s_e0_caps e0_caps_def full_cap_def create_cap_def)
lemma caps_of_s_e1: "caps_of s 1 = {create_cap 2, \<lparr> target = 1, rights = {Write, Store}\<rparr>, full_cap 2}"
apply (clarsimp simp: caps_of_def store_connected_s Collect_disj_eq)
apply (simp add: s_def null_entity_def)
done
lemma caps_of_s_e2: "caps_of s 2 = {}"
apply (simp add: caps_of_def store_connected_s)
apply (simp add: s_def null_entity_def)
done
lemma caps_of_s_e3: "\<lbrakk>e \<noteq> 0; e \<noteq> 1\<rbrakk> \<Longrightarrow> caps_of s e = {}"
apply (simp add: caps_of_def store_connected_s)
apply (simp add: s_def null_entity_def)
done
(*********************************)
(* caps_of' *)
(*********************************)
lemma extra_rights_create_cap:
"extra_rights (create_cap i) = full_cap i"
by (simp add: create_cap_def full_cap_def extra_rights_def)
lemma extra_rights_full_cap:
"extra_rights (full_cap i) = full_cap i"
by (simp add: full_cap_def extra_rights_def)
lemma extra_rights_take_cap:
"extra_rights (take_cap i) = take_cap i"
by (simp add: take_cap_def extra_rights_def)
lemma extra_rights_grant_cap:
"extra_rights (grant_cap i) = grant_cap i"
by (simp add: take_cap_def extra_rights_def)
lemma caps_of'_s_e0_caps_helper:
"extra_rights ` (range create_cap - {create_cap 1, create_cap 2}) =
range full_cap - {full_cap 1, full_cap 2}"
apply rule
apply (fastforce simp: create_cap_def extra_rights_def all_rights_def full_cap_def)
apply rule
apply (erule DiffE)
apply clarsimp
apply (rule image_eqI)
apply (rule extra_rights_create_cap [THEN sym])
apply (simp add: full_cap_def create_cap_def)
done
(*********************************)
(* connected *)
(*********************************)
lemma extra_rights_increases_rights:
"rights c \<subseteq> rights (extra_rights c)"
by (simp add: extra_rights_def all_rights_def)
lemma cap_in_caps_take_cap:
"\<lbrakk>create_cap x \<in> caps_of s y\<rbrakk> \<Longrightarrow> take_cap x \<in>cap caps_of s y"
apply (auto simp: cap_in_caps_def caps_of_def extra_rights_take_cap)
apply (rule exI, rule conjI, assumption)
apply (rule rev_bexI, simp)
apply (rule conjI)
apply (subgoal_tac "target (full_cap x) = x", simp+)
apply (simp add: extra_rights_create_cap all_rights_def)
done
lemma e0_connected_to:
"\<lbrakk>x \<noteq> 1; x \<noteq> 2\<rbrakk> \<Longrightarrow> s \<turnstile> 0 \<leftrightarrow> x"
apply (rule directly_tgs_connected_comm)
apply (simp add: directly_tgs_connected_def4)
apply (rule disjI1)
apply (rule cap_in_caps_take_cap)
apply (simp add: caps_of_s_e0_caps e0_caps_def create_cap_def)
done
lemma e1_connected_to_e2:
"s \<turnstile> 1 \<leftrightarrow> 2"
apply (simp add: directly_tgs_connected_def4)
apply (rule disjI2)+
apply (simp add: shares_caps_def)
apply (simp add: store_connected_s)
done
lemma e0_caps_not_connected_to_e1:
"\<not> (s \<turnstile> 0 \<leftrightarrow> 1)"
apply (simp add: directly_tgs_connected_def4)
apply (rule conjI)
apply (simp add: cap_in_caps_def caps_of_s_e1)
apply (rule conjI)
apply (clarsimp simp add: cap_in_caps_def caps_of_s_e0_caps e0_caps_def)
apply (erule disjE)
apply (simp add: full_cap_def)
apply clarsimp
apply (rule conjI)
apply (clarsimp simp add: cap_in_caps_def caps_of_s_e0_caps e0_caps_def)
apply (erule disjE)
apply (simp add: full_cap_def)
apply clarsimp
apply (rule conjI)
apply (simp add: cap_in_caps_def caps_of_s_e1)
apply (simp add: shares_caps_def)
apply (simp add: store_connected_s)
done
lemma e0_caps_not_connected_to_e2:
"\<not> (s \<turnstile> 0 \<leftrightarrow> 2)"
apply (simp add: directly_tgs_connected_def4)
apply (rule conjI)
apply (simp add: cap_in_caps_def caps_of_s_e2)
apply (rule conjI)
apply (clarsimp simp add: cap_in_caps_def caps_of_s_e0_caps e0_caps_def)
apply (erule disjE)
apply (simp add: full_cap_def)
apply clarsimp
apply (rule conjI)
apply (clarsimp simp add: cap_in_caps_def caps_of_s_e0_caps e0_caps_def)
apply (erule disjE)
apply (simp add: full_cap_def)
apply clarsimp
apply (rule conjI)
apply (simp add: cap_in_caps_def caps_of_s_e2)
apply (simp add: shares_caps_def)
apply (simp add: store_connected_s)
done
(*********************************)
(* connected_trans *)
(*********************************)
lemma e1_connected_trans_to_e2:
"s \<turnstile> 1 \<leftrightarrow>* 2"
apply (insert e1_connected_to_e2)
apply (simp add: tgs_connected_def)
done
lemma caps_of_to_e1:
"\<lbrakk>c \<in> caps_of s x; target c = 1\<rbrakk> \<Longrightarrow> x = 1 \<or> x = 2"
apply (case_tac "x = 0")
apply (fastforce simp: caps_of_s_e0_caps_2)
apply (case_tac "x = 1")
apply (fastforce simp: caps_of_s_e1)
apply (fastforce simp: caps_of_s_e3)
done
lemma caps_of_to_e2:
"\<lbrakk>c \<in> caps_of s x; target c = 2\<rbrakk> \<Longrightarrow> x = 1"
apply (case_tac "x = 0")
apply (fastforce simp: caps_of_s_e0_caps_2)
apply (case_tac "x = 1")
apply (fastforce simp: caps_of_s_e1)
apply (fastforce simp: caps_of_s_e3)
done
lemma cap_in_caps_caps_of_e1:
"c \<in>cap caps_of s 1 \<Longrightarrow> target c = 1 \<or> target c = 2"
by (clarsimp simp: cap_in_caps_def caps_of_s_e1)
lemma cap_in_caps_caps_of_e2:
"c \<in>cap caps_of s 2 \<Longrightarrow> False"
by (clarsimp simp: cap_in_caps_def caps_of_s_e2)
lemma cap_in_caps_caps_of_to_e1:
"\<lbrakk>c \<in>cap caps_of s x; target c = 1\<rbrakk> \<Longrightarrow> x = 1 \<or> x = 2"
apply (clarsimp simp: cap_in_caps_def)
apply (drule (1) caps_of_to_e1, simp)
done
lemma cap_in_caps_caps_of_to_e2:
"\<lbrakk>c \<in>cap caps_of s x; target c = 2\<rbrakk> \<Longrightarrow> x = 1"
apply (clarsimp simp: cap_in_caps_def)
apply (erule (1) caps_of_to_e2)
done
lemma e1_connected_to:
"s \<turnstile> 1 \<leftrightarrow> x \<Longrightarrow> x = 1 \<or> x = 2"
apply (simp add: directly_tgs_connected_def4)
apply (erule disjE)
apply (erule cap_in_caps_caps_of_to_e1, simp)
apply (erule disjE)
apply (drule cap_in_caps_caps_of_e1, simp)
apply (erule disjE)
apply (drule cap_in_caps_caps_of_e1, simp)
apply (erule disjE)
apply (erule cap_in_caps_caps_of_to_e1, simp)
apply (fastforce simp: shares_caps_def store_connected_s)
done
lemma e2_connected_to:
"s \<turnstile> 2 \<leftrightarrow> x \<Longrightarrow> x = 1 \<or> x = 2"
apply (simp add: directly_tgs_connected_def4)