-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSR_lemmas_C.thy
1976 lines (1764 loc) · 81.3 KB
/
SR_lemmas_C.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
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*)
theory SR_lemmas_C
imports
StateRelation_C
"../refine/Invariants_H"
begin
declare option.weak_case_cong[cong]
section "ctes"
subsection "capabilities"
lemma cteMDBNode_cte_to_H [simp]:
"cteMDBNode (cte_to_H cte) = mdb_node_to_H (cteMDBNode_CL cte)"
unfolding cte_to_H_def
by simp
lemma cteMDBNode_CL_lift [simp]:
"cte_lift cte' = Some ctel \<Longrightarrow>
mdb_node_lift (cteMDBNode_C cte') = cteMDBNode_CL ctel"
unfolding cte_lift_def
by (fastforce split: option.splits)
lemma cteCap_cte_to_H [simp]:
"cteCap (cte_to_H cte) = cap_to_H (cap_CL cte)"
unfolding cte_to_H_def
by simp
lemma cap_CL_lift [simp]:
"cte_lift cte' = Some ctel \<Longrightarrow> cap_lift (cte_C.cap_C cte') = Some (cap_CL ctel)"
unfolding cte_lift_def
by (fastforce split: option.splits)
lemma cteCap_update_cte_to_H [simp]:
"\<lbrakk> cte_lift cte' = Some z; cap_lift cap' = Some capl\<rbrakk>
\<Longrightarrow> option_map cte_to_H (cte_lift (cte_C.cap_C_update (\<lambda>_. cap') cte')) =
Some (cteCap_update (\<lambda>_. cap_to_H capl) (cte_to_H z))"
unfolding cte_lift_def
by (clarsimp simp: cte_to_H_def split: option.splits)
lemma cteMDBNode_C_update_lift [simp]:
"cte_lift cte' = Some ctel \<Longrightarrow>
(cte_lift (cteMDBNode_C_update (\<lambda>_. m) cte') = Some x)
= (cteMDBNode_CL_update (\<lambda>_. mdb_node_lift m) ctel = x)"
unfolding cte_lift_def
by (fastforce split: option.splits)
lemma ccap_relationE:
"\<lbrakk>ccap_relation c v; \<And>vl. \<lbrakk> cap_lift v = Some vl; c = cap_to_H vl; c_valid_cap v\<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
unfolding ccap_relation_def option_map_def
apply clarsimp
apply (drule sym)
apply (clarsimp split: option.splits)
done
definition
"pageSize cap \<equiv> case cap of ArchObjectCap (PageCap _ _ sz _) \<Rightarrow> sz"
definition
"isArchCap_tag (n :: 32 word) \<equiv> n mod 2 = 1"
lemma isArchCap_tag_def2:
"isArchCap_tag n \<equiv> n && 1 = 1"
by (simp add: isArchCap_tag_def word_mod_2p_is_mask[where n=1, simplified] mask_def)
lemma framesize_to_H_not_Small [simp]:
"framesize_to_H w \<noteq> ARMSmallPage"
by (simp add: framesize_to_H_def)
lemma cap_get_tag_isCap0:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_thread_cap) = isThreadCap cap
\<and> (cap_get_tag cap' = scast cap_null_cap) = (cap = NullCap)
\<and> (cap_get_tag cap' = scast cap_async_endpoint_cap) = isAsyncEndpointCap cap
\<and> (cap_get_tag cap' = scast cap_endpoint_cap) = isEndpointCap cap
\<and> (cap_get_tag cap' = scast cap_irq_handler_cap) = isIRQHandlerCap cap
\<and> (cap_get_tag cap' = scast cap_irq_control_cap) = isIRQControlCap cap
\<and> (cap_get_tag cap' = scast cap_zombie_cap) = isZombie cap
\<and> (cap_get_tag cap' = scast cap_reply_cap) = isReplyCap cap
\<and> (cap_get_tag cap' = scast cap_untyped_cap) = isUntypedCap cap
\<and> (cap_get_tag cap' = scast cap_cnode_cap) = isCNodeCap cap
\<and> isArchCap_tag (cap_get_tag cap') = isArchCap \<top> cap
\<and> (cap_get_tag cap' = scast cap_small_frame_cap) = (isArchPageCap cap \<and> pageSize cap = ARMSmallPage)
\<and> (cap_get_tag cap' = scast cap_frame_cap) = (isArchPageCap cap \<and> pageSize cap \<noteq> ARMSmallPage)
\<and> (cap_get_tag cap' = scast cap_domain_cap) = isDomainCap cap"
using cr
apply -
apply (erule ccap_relationE)
apply (simp add: cap_to_H_def cap_lift_def Let_def isArchCap_tag_def2 isArchCap_def)
apply (clarsimp simp: isCap_simps cap_tag_defs word_le_nat_alt pageSize_def Let_def
split: split_if_asm) -- "takes a while"
done
lemma cap_get_tag_isCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_thread_cap) = (isThreadCap cap)"
and "(cap_get_tag cap' = scast cap_null_cap) = (cap = NullCap)"
and "(cap_get_tag cap' = scast cap_async_endpoint_cap) = (isAsyncEndpointCap cap)"
and "(cap_get_tag cap' = scast cap_endpoint_cap) = (isEndpointCap cap)"
and "(cap_get_tag cap' = scast cap_irq_handler_cap) = (isIRQHandlerCap cap)"
and "(cap_get_tag cap' = scast cap_irq_control_cap) = (isIRQControlCap cap)"
and "(cap_get_tag cap' = scast cap_zombie_cap) = (isZombie cap)"
and "(cap_get_tag cap' = scast cap_reply_cap) = isReplyCap cap"
and "(cap_get_tag cap' = scast cap_untyped_cap) = (isUntypedCap cap)"
and "(cap_get_tag cap' = scast cap_cnode_cap) = (isCNodeCap cap)"
and "isArchCap_tag (cap_get_tag cap') = isArchCap \<top> cap"
and "(cap_get_tag cap' = scast cap_small_frame_cap) = (isArchPageCap cap \<and> pageSize cap = ARMSmallPage)"
and "(cap_get_tag cap' = scast cap_frame_cap) = (isArchPageCap cap \<and> pageSize cap \<noteq> ARMSmallPage)"
and "(cap_get_tag cap' = scast cap_domain_cap) = isDomainCap cap"
using cap_get_tag_isCap0 [OF cr] by auto
lemma cap_get_tag_NullCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_null_cap) = (cap = NullCap)"
using cr
apply -
apply (rule iffI)
apply (clarsimp simp add: cap_lifts cap_get_tag_isCap cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_ThreadCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_thread_cap) =
(cap = ThreadCap (ctcb_ptr_to_tcb_ptr (Ptr (cap_thread_cap_CL.capTCBPtr_CL (cap_thread_cap_lift cap')))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_AsyncEndpointCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_async_endpoint_cap) =
(cap = AsyncEndpointCap
(capAEPPtr_CL (cap_async_endpoint_cap_lift cap'))
(capAEPBadge_CL (cap_async_endpoint_cap_lift cap'))
(to_bool (capAEPCanSend_CL (cap_async_endpoint_cap_lift cap')))
(to_bool (capAEPCanReceive_CL (cap_async_endpoint_cap_lift cap'))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_EndpointCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_endpoint_cap) =
(cap = EndpointCap (capEPPtr_CL (cap_endpoint_cap_lift cap'))
(capEPBadge_CL (cap_endpoint_cap_lift cap'))
(to_bool (capCanSend_CL (cap_endpoint_cap_lift cap')))
(to_bool (capCanReceive_CL (cap_endpoint_cap_lift cap')))
(to_bool (capCanGrant_CL (cap_endpoint_cap_lift cap'))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_CNodeCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_cnode_cap) =
(cap = capability.CNodeCap (capCNodePtr_CL (cap_cnode_cap_lift cap'))
(unat (capCNodeRadix_CL (cap_cnode_cap_lift cap')))
(capCNodeGuard_CL (cap_cnode_cap_lift cap'))
(unat (capCNodeGuardSize_CL (cap_cnode_cap_lift cap'))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def Let_def)
apply (simp add: cap_get_tag_isCap isCap_simps Let_def)
done
lemma cap_get_tag_IRQHandlerCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_irq_handler_cap) =
(cap = capability.IRQHandlerCap (ucast (capIRQ_CL (cap_irq_handler_cap_lift cap'))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_IRQControlCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_irq_control_cap) =
(cap = capability.IRQControlCap)"
using cr
apply -
apply (rule iffI)
apply (clarsimp simp add: cap_lifts cap_get_tag_isCap isCap_simps cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_ZombieCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_zombie_cap) =
(cap =
(if isZombieTCB_C (capZombieType_CL (cap_zombie_cap_lift cap'))
then capability.Zombie (capZombieID_CL (cap_zombie_cap_lift cap') && ~~ mask 5) ZombieTCB
(unat (capZombieID_CL (cap_zombie_cap_lift cap') && mask 5))
else let radix = unat (capZombieType_CL (cap_zombie_cap_lift cap'))
in capability.Zombie (capZombieID_CL (cap_zombie_cap_lift cap') && ~~ mask (radix + 1))
(ZombieCNode radix)
(unat (capZombieID_CL (cap_zombie_cap_lift cap') && mask (radix + 1)))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps Let_def
split: split_if_asm)
done
lemma cap_get_tag_ReplyCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_reply_cap) =
(cap =
ReplyCap (ctcb_ptr_to_tcb_ptr (Ptr (cap_reply_cap_CL.capTCBPtr_CL (cap_reply_cap_lift cap'))))
(to_bool (capReplyMaster_CL (cap_reply_cap_lift cap'))))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_UntypedCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_untyped_cap) =
(cap = UntypedCap (capPtr_CL (cap_untyped_cap_lift cap'))
(unat (capBlockSize_CL (cap_untyped_cap_lift cap')))
(unat (capFreeIndex_CL (cap_untyped_cap_lift cap') << 4)))"
using cr
apply -
apply (rule iffI)
apply (erule ccap_relationE)
apply (clarsimp simp add: cap_lifts cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemma cap_get_tag_DomainCap:
assumes cr: "ccap_relation cap cap'"
shows "(cap_get_tag cap' = scast cap_domain_cap) = (cap = DomainCap)"
using cr
apply -
apply (rule iffI)
apply (clarsimp simp add: cap_lifts cap_get_tag_isCap cap_to_H_def)
apply (simp add: cap_get_tag_isCap isCap_simps)
done
lemmas cap_get_tag_to_H_iffs =
cap_get_tag_NullCap
cap_get_tag_ThreadCap
cap_get_tag_AsyncEndpointCap
cap_get_tag_EndpointCap
cap_get_tag_CNodeCap
cap_get_tag_IRQHandlerCap
cap_get_tag_IRQControlCap
cap_get_tag_ZombieCap
cap_get_tag_UntypedCap
cap_get_tag_DomainCap
lemmas cap_get_tag_to_H = cap_get_tag_to_H_iffs [THEN iffD1]
subsection "mdb"
lemma cmdbnode_relation_mdb_node_to_H [simp]:
"cte_lift cte' = Some y
\<Longrightarrow> cmdbnode_relation (mdb_node_to_H (cteMDBNode_CL y)) (cteMDBNode_C cte')"
unfolding cmdbnode_relation_def mdb_node_to_H_def mdb_node_lift_def cte_lift_def
by (fastforce split: option.splits)
(* MOVE --- here down doesn't really belong here, maybe in a haskell specific file?*)
lemma tcb_cte_cases_in_range1:
assumes tc:"tcb_cte_cases (y - x) = Some v"
and al: "is_aligned x 9"
shows "x \<le> y"
proof -
from tc obtain q where yq: "y = x + q" and qv: "q < 2 ^ 9"
unfolding tcb_cte_cases_def
by (simp add: diff_eq_eq split: split_if_asm)
have "x \<le> x + 2 ^ 9 - 1" using al
by (rule is_aligned_no_overflow)
hence "x \<le> x + q" using qv
apply simp
apply unat_arith
apply simp
done
thus ?thesis using yq by simp
qed
lemma tcb_cte_cases_in_range2:
assumes tc: "tcb_cte_cases (y - x) = Some v"
and al: "is_aligned x 9"
shows "y \<le> x + 2 ^ 9 - 1"
proof -
from tc obtain q where yq: "y = x + q" and qv: "q \<le> 2 ^ 9 - 1"
unfolding tcb_cte_cases_def
by (simp add: diff_eq_eq split: split_if_asm)
have "x + q \<le> x + (2 ^ 9 - 1)" using qv
apply (rule word_plus_mono_right)
apply (rule is_aligned_no_overflow' [OF al])
done
thus ?thesis using yq by (simp add: field_simps)
qed
lemmas tcbSlots =
tcbCTableSlot_def tcbVTableSlot_def
tcbReplySlot_def tcbCallerSlot_def tcbIPCBufferSlot_def
lemma updateObject_cte_tcb:
assumes tc: "tcb_cte_cases (ptr - ptr') = Some (accF, updF)"
shows "updateObject ctea (KOTCB tcb) ptr ptr' next =
(do alignCheck ptr' (objBits tcb);
magnitudeCheck ptr' next (objBits tcb);
return (KOTCB (updF (\<lambda>_. ctea) tcb))
od)"
using tc unfolding tcb_cte_cases_def
apply -
apply (clarsimp simp add: updateObject_cte Let_def
tcb_cte_cases_def objBits_simps tcbSlots shiftl_t2n
split: split_if_asm cong: if_cong)
done
definition
tcb_no_ctes_proj :: "tcb \<Rightarrow> Structures_H.thread_state \<times> word32 \<times> word32 \<times> (ARMMachineTypes.register \<Rightarrow> word32) \<times> bool \<times> word8 \<times> word8 \<times> nat \<times> fault option"
where
"tcb_no_ctes_proj t \<equiv> (tcbState t, tcbFaultHandler t, tcbIPCBuffer t, tcbContext t, tcbQueued t,
tcbPriority t, tcbDomain t, tcbTimeSlice t, tcbFault t)"
lemma tcb_cte_cases_proj_eq [simp]:
"tcb_cte_cases p = Some (getF, setF) \<Longrightarrow>
tcb_no_ctes_proj tcb = tcb_no_ctes_proj (setF f tcb)"
unfolding tcb_no_ctes_proj_def tcb_cte_cases_def
by (auto split: split_if_asm)
lemma map_to_ctes_upd_cte':
"[| ksPSpace s p = Some (KOCTE cte'); is_aligned p 4; ps_clear p 4 s |]
==> map_to_ctes (ksPSpace s(p |-> KOCTE cte)) = (map_to_ctes (ksPSpace s))(p |-> cte)"
apply (erule (1) map_to_ctes_upd_cte)
apply (simp add: field_simps ps_clear_def3)
done
lemma map_to_ctes_upd_tcb':
"[| ksPSpace s p = Some (KOTCB tcb'); is_aligned p 9;
ps_clear p 9 s |]
==> map_to_ctes (ksPSpace s(p |-> KOTCB tcb)) =
(%x. if EX getF setF.
tcb_cte_cases (x - p) = Some (getF, setF) &
getF tcb ~= getF tcb'
then case tcb_cte_cases (x - p) of
Some (getF, setF) => Some (getF tcb)
else ctes_of s x)"
apply (erule (1) map_to_ctes_upd_tcb)
apply (simp add: field_simps ps_clear_def3)
done
lemma tcb_cte_cases_inv [simp]:
"tcb_cte_cases p = Some (getF, setF) \<Longrightarrow> getF (setF (\<lambda>_. v) tcb) = v"
unfolding tcb_cte_cases_def
by (simp split: split_if_asm)
declare insert_dom [simp]
lemma in_alignCheck':
"(z \<in> fst (alignCheck x n s)) = (snd z = s \<and> is_aligned x n)"
by (cases z, simp add: in_alignCheck)
lemma fst_setCTE0:
assumes ct: "cte_at' dest s"
shows "\<exists>(v, s') \<in> fst (setCTE dest cte s).
(s' = s \<lparr> ksPSpace := ksPSpace s' \<rparr>)
\<and> (dom (ksPSpace s) = dom (ksPSpace s'))
\<and> (\<forall>x \<in> dom (ksPSpace s).
case (the (ksPSpace s x)) of
KOCTE _ \<Rightarrow> (\<exists>cte. ksPSpace s' x = Some (KOCTE cte))
| KOTCB t \<Rightarrow> (\<exists>t'. ksPSpace s' x = Some (KOTCB t') \<and> tcb_no_ctes_proj t = tcb_no_ctes_proj t')
| _ \<Rightarrow> ksPSpace s' x = ksPSpace s x)"
using ct
apply -
apply (clarsimp simp: setCTE_def setObject_def
bind_def return_def assert_opt_def gets_def split_beta get_def
modify_def put_def)
apply (erule cte_wp_atE')
apply (rule ps_clear_lookupAround2, assumption+)
apply simp
apply (erule is_aligned_no_overflow)
apply (simp (no_asm_simp) del: fun_upd_apply cong: option.case_cong)
apply (simp add: return_def updateObject_cte
bind_def assert_opt_def gets_def split_beta get_def
modify_def put_def unless_def when_def
cte_level_bits_def objBits_simps
cong: bex_cong)
apply (rule bexI [where x = "((), s)"])
apply (frule_tac s' = s in in_magnitude_check [where v = "()"])
apply simp
apply assumption
apply simp
apply (erule bexI [rotated])
apply (simp cong: if_cong)
apply rule
apply (simp split: kernel_object.splits)
apply (fastforce simp: tcb_no_ctes_proj_def)
apply (simp add: in_alignCheck)
(* clag *)
apply (rule ps_clear_lookupAround2, assumption+)
apply (erule (1) tcb_cte_cases_in_range1)
apply (erule (1) tcb_cte_cases_in_range2)
apply (simp add: return_def del: fun_upd_apply cong: bex_cong option.case_cong)
apply (subst updateObject_cte_tcb)
apply assumption
apply (simp add: bind_def return_def assert_opt_def gets_def split_beta get_def when_def
modify_def put_def unless_def when_def in_alignCheck')
apply (simp add: objBits_simps)
apply (simp add: magnitudeCheck_def return_def split: option.splits
cong: bex_cong if_cong)
apply (simp split: kernel_object.splits)
apply (fastforce simp: tcb_no_ctes_proj_def)
apply (simp add: magnitudeCheck_def when_def return_def fail_def
linorder_not_less
split: option.splits
cong: bex_cong if_cong)
apply rule
apply (simp split: kernel_object.splits)
apply (fastforce simp: tcb_no_ctes_proj_def)
done
(* duplicates *)
lemma pspace_alignedD' [intro?]:
assumes lu: "ksPSpace s x = Some v"
and al: "pspace_aligned' s"
shows "is_aligned x (objBitsKO v)"
using al lu unfolding pspace_aligned'_def
apply -
apply (drule (1) bspec [OF _ domI])
apply simp
done
lemma pspace_distinctD' [intro?]:
"\<lbrakk> ksPSpace s x = Some v; pspace_distinct' s \<rbrakk> \<Longrightarrow> ps_clear x (objBitsKO v) s"
apply (simp add: pspace_distinct'_def)
apply (drule bspec, erule domI)
apply simp
done
lemma ctes_of_ksI [intro?]:
fixes s :: "kernel_state"
assumes ks: "ksPSpace s x = Some (KOCTE cte)"
and pa: "pspace_aligned' s" (* yuck *)
and pd: "pspace_distinct' s"
shows "ctes_of s x = Some cte"
proof (rule ctes_of_eq_cte_wp_at')
from ks show "cte_wp_at' (op = cte) x s"
proof (rule cte_wp_at_cteI' [OF _ _ _ refl])
from ks pa have "is_aligned x (objBitsKO (KOCTE cte))" ..
thus "is_aligned x cte_level_bits"
unfolding cte_level_bits_def by (simp add: objBits_simps)
from ks pd have "ps_clear x (objBitsKO (KOCTE cte)) s" ..
thus "ps_clear x cte_level_bits s"
unfolding cte_level_bits_def by (simp add: objBits_simps)
qed
qed
lemma fst_setCTE:
assumes ct: "cte_at' dest s"
and rl: "\<And>s'. \<lbrakk> ((), s') \<in> fst (setCTE dest cte s);
(s' = s \<lparr> ksPSpace := ksPSpace s' \<rparr>);
(ctes_of s' = ctes_of s(dest \<mapsto> cte));
(map_to_eps (ksPSpace s) = map_to_eps (ksPSpace s'));
(map_to_aeps (ksPSpace s) = map_to_aeps (ksPSpace s'));
(map_to_pdes (ksPSpace s) = map_to_pdes (ksPSpace s'));
(map_to_ptes (ksPSpace s) = map_to_ptes (ksPSpace s'));
(map_to_asidpools (ksPSpace s) = map_to_asidpools (ksPSpace s'));
(map_to_user_data (ksPSpace s) = map_to_user_data (ksPSpace s'));
(option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s)
= option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s')) \<rbrakk> \<Longrightarrow> P"
shows "P"
proof -
(* Unpack the existential and bind x, theorems in this. Yuck *)
from fst_setCTE0 [where cte = cte, OF ct] guess s' by clarsimp
note thms = this
from thms have ceq: "ctes_of s' = ctes_of s(dest \<mapsto> cte)"
apply -
apply (erule use_valid [OF _ setCTE_ctes_of_wp])
apply simp
done
show ?thesis
proof (rule rl)
show "map_to_eps (ksPSpace s) = map_to_eps (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: endpoint option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_ep)
thus "(projectKO_opt (the (ksPSpace s' x)) :: endpoint option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
(* clag \<dots> *)
show "map_to_aeps (ksPSpace s) = map_to_aeps (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: async_endpoint option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_aep)
thus "(projectKO_opt (the (ksPSpace s' x)) :: async_endpoint option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
show "map_to_pdes (ksPSpace s) = map_to_pdes (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: pde option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_pde)
thus "(projectKO_opt (the (ksPSpace s' x)) :: pde option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
show "map_to_ptes (ksPSpace s) = map_to_ptes (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: pte option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_pte)
thus "(projectKO_opt (the (ksPSpace s' x)) :: pte option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
show "map_to_asidpools (ksPSpace s) = map_to_asidpools (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: asidpool option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_asidpool)
thus "(projectKO_opt (the (ksPSpace s' x)) :: asidpool option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
show "map_to_user_data (ksPSpace s) = map_to_user_data (ksPSpace s')"
proof (rule map_comp_eqI)
fix x
assume xin: "x \<in> dom (ksPSpace s')"
then obtain ko where ko: "ksPSpace s x = Some ko" by (clarsimp simp: thms(3)[symmetric])
moreover from xin obtain ko' where ko': "ksPSpace s' x = Some ko'" by clarsimp
ultimately have "(projectKO_opt ko' :: user_data option) = projectKO_opt ko" using xin thms(4) ceq
by - (drule (1) bspec, cases ko, auto simp: projectKO_opt_user_data)
thus "(projectKO_opt (the (ksPSpace s' x)) :: user_data option) = projectKO_opt (the (ksPSpace s x))" using ko ko'
by simp
qed fact
show "option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s) =
option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s')"
proof (rule ext)
fix x
have dm: "dom (map_to_tcbs (ksPSpace s)) = dom (map_to_tcbs (ksPSpace s'))"
using thms(3) thms(4)
apply -
apply (rule set_eqI)
apply rule
apply (frule map_comp_subset_domD)
apply simp
apply (drule (1) bspec)
apply (clarsimp simp: projectKOs dom_map_comp)
apply (frule map_comp_subset_domD)
apply (drule (1) bspec)
apply (auto simp: dom_map_comp projectKOs split: kernel_object.splits)
apply fastforce
done
{
assume "x \<in> dom (map_to_tcbs (ksPSpace s))"
hence "option_map tcb_no_ctes_proj (map_to_tcbs (ksPSpace s) x)
= option_map tcb_no_ctes_proj (map_to_tcbs (ksPSpace s') x)"
using thms(3) thms(4)
apply -
apply (frule map_comp_subset_domD)
apply simp
apply (drule (1) bspec)
apply (clarsimp simp: dom_map_comp projectKOs projectKO_opt_tcb)
apply (case_tac y)
apply simp_all
apply clarsimp
done
} moreover
{
assume "x \<notin> dom (map_to_tcbs (ksPSpace s))"
hence "option_map tcb_no_ctes_proj (map_to_tcbs (ksPSpace s) x)
= option_map tcb_no_ctes_proj (map_to_tcbs (ksPSpace s') x)"
apply -
apply (frule subst [OF dm])
apply (simp add: dom_def)
done
} ultimately show "(option_map tcb_no_ctes_proj \<circ> (map_to_tcbs (ksPSpace s))) x
= (option_map tcb_no_ctes_proj \<circ> (map_to_tcbs (ksPSpace s'))) x"
by auto
qed
qed fact+
qed
lemma ctes_of_cte_at:
"ctes_of s p = Some x \<Longrightarrow> cte_at' p s"
by (simp add: cte_wp_at_ctes_of)
lemma cor_map_relI:
assumes dm: "dom am = dom am'"
and rl: "\<And>x y y' z. \<lbrakk> am x = Some y; am' x = Some y';
rel y z \<rbrakk> \<Longrightarrow> rel y' z"
shows "cmap_relation am cm sz rel \<Longrightarrow> cmap_relation am' cm sz rel"
unfolding cmap_relation_def
apply -
apply clarsimp
apply rule
apply (simp add: dm)
apply rule
apply (frule_tac P = "\<lambda>s. x \<in> s" in ssubst [OF dm])
apply (drule (1) bspec)
apply (erule domD [where m = am, THEN exE])
apply (rule rl, assumption+)
apply (clarsimp simp add: dom_def)
apply simp
done
lemma setCTE_tcb_case:
assumes om: "option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s) =
option_map tcb_no_ctes_proj \<circ> map_to_tcbs (ksPSpace s')"
and rel: "cmap_relation (map_to_tcbs (ksPSpace s)) (clift (t_hrs_' (globals x))) tcb_ptr_to_ctcb_ptr ctcb_relation"
shows "cmap_relation (map_to_tcbs (ksPSpace s')) (clift (t_hrs_' (globals x))) tcb_ptr_to_ctcb_ptr ctcb_relation"
using om
proof (rule cor_map_relI [OF option_map_eq_dom_eq])
fix x tcb tcb' z
assume y: "map_to_tcbs (ksPSpace s) x = Some tcb"
and y': "map_to_tcbs (ksPSpace s') x = Some tcb'" and rel: "ctcb_relation tcb z"
hence "tcb_no_ctes_proj tcb = tcb_no_ctes_proj tcb'" using om
apply -
apply (simp add: o_def)
apply (drule fun_cong [where x = x])
apply simp
done
thus "ctcb_relation tcb' z" using rel
unfolding tcb_no_ctes_proj_def ctcb_relation_def cfault_rel_def
by auto
qed fact+
lemma lifth_update:
"clift (t_hrs_' s) ptr = clift (t_hrs_' s') ptr
\<Longrightarrow> lifth ptr s = lifth ptr s'"
unfolding lifth_def
by simp
lemma getCTE_exs_valid:
"cte_at' dest s \<Longrightarrow> \<lbrace>op = s\<rbrace> getCTE dest \<exists>\<lbrace>\<lambda>r. op = s\<rbrace>"
unfolding exs_valid_def getCTE_def cte_wp_at'_def
by clarsimp
lemma cmap_domE1:
"\<lbrakk> f ` dom am = dom cm; am x = Some v; \<And>v'. cm (f x) = Some v' \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply (drule equalityD1)
apply (drule subsetD)
apply (erule imageI [OF domI])
apply (clarsimp simp: dom_def)
done
lemma cmap_domE2:
"\<lbrakk> f ` dom am = dom cm; cm x = Some v'; \<And>x' v. \<lbrakk> x = f x'; am x' = Some v \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
apply (drule equalityD2)
apply (drule subsetD)
apply (erule domI)
apply (clarsimp elim: imageE simp: dom_def)
done
lemma cmap_relationE1:
"\<lbrakk> cmap_relation am cm f rel; am x = Some y;
\<And>y'. \<lbrakk>am x = Some y; rel y y'; cm (f x) = Some y'\<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
unfolding cmap_relation_def
apply clarsimp
apply (erule (1) cmap_domE1)
apply (drule (1) bspec [OF _ domI])
apply clarsimp
done
lemma cmap_relationE2:
"\<lbrakk> cmap_relation am cm f rel; cm x = Some y';
\<And>x' y. \<lbrakk>x = f x'; rel y y'; am x' = Some y\<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
unfolding cmap_relation_def
apply clarsimp
apply (erule (1) cmap_domE2)
apply (drule (1) bspec [OF _ domI])
apply clarsimp
done
lemma cmap_relationI:
assumes doms: "f ` dom am = dom cm"
and rel: "\<And>x v v'. \<lbrakk>am x = Some v; cm (f x) = Some v' \<rbrakk> \<Longrightarrow> rel v v'"
shows "cmap_relation am cm f rel"
unfolding cmap_relation_def using doms
proof (rule conjI)
show "\<forall>x\<in>dom am. rel (the (am x)) (the (cm (f x)))"
proof
fix x
assume "x \<in> dom am"
then obtain v where "am x = Some v" ..
moreover with doms obtain v' where "cm (f x) = Some v'" by (rule cmap_domE1)
ultimately show "rel (the (am x)) (the (cm (f x)))"
by (simp add: rel)
qed
qed
lemma cmap_relation_relI:
assumes "cmap_relation am cm f rel"
and "am x = Some v"
and "cm (f x) = Some v'"
shows "rel v v'"
using assms
by (fastforce elim!: cmap_relationE1)
lemma cspace_cte_relationE:
"\<lbrakk> cmap_relation am cm Ptr ccte_relation; am x = Some y;
\<And>z k'. \<lbrakk>cm (Ptr x) = Some k'; cte_lift k' = Some z; cte_to_H z = y; c_valid_cte k' \<rbrakk> \<Longrightarrow> P
\<rbrakk> \<Longrightarrow> P"
apply (erule (1) cmap_relationE1)
apply (clarsimp simp: ccte_relation_def option_map_Some_eq2)
done
lemma cmdbnode_relationE:
"\<lbrakk>cmdbnode_relation m v; m = mdb_node_to_H (mdb_node_lift v) \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
unfolding cmdbnode_relation_def
apply (drule sym)
apply clarsimp
done
(* Used when the rel changes as well *)
lemma cmap_relation_upd_relI:
fixes am :: "word32 \<rightharpoonup> 'a" and cm :: "'b typ_heap"
assumes cr: "cmap_relation am cm f rel"
and cof: "am dest = Some v"
and cl: "cm (f dest) = Some v'"
and cc: "rel' nv nv'"
and rel: "\<And>x ov ov'. \<lbrakk> x \<noteq> dest; am x = Some ov; cm (f x) = Some ov'; rel ov ov' \<rbrakk> \<Longrightarrow> rel' ov ov'"
and inj: "inj f"
shows "cmap_relation (am(dest \<mapsto> nv)) (cm(f dest \<mapsto> nv')) f rel'"
using assms
apply -
apply (rule cmap_relationE1, assumption+)
apply clarsimp
apply (rule cmap_relationI)
apply (simp add: cmap_relation_def)
apply (case_tac "x = dest")
apply simp
apply (simp add: inj_eq split: split_if_asm)
apply (erule (2) rel)
apply (erule (2) cmap_relation_relI)
done
lemma cmap_relation_updI:
fixes am :: "word32 \<rightharpoonup> 'a" and cm :: "'b typ_heap"
assumes cr: "cmap_relation am cm f rel"
and cof: "am dest = Some v"
and cl: "cm (f dest) = Some v'"
and cc: "rel nv nv'"
and inj: "inj f"
shows "cmap_relation (am(dest \<mapsto> nv)) (cm(f dest \<mapsto> nv')) f rel"
using cr cof cl cc
apply (rule cmap_relation_upd_relI)
apply simp
apply fact
done
declare inj_Ptr[simp]
(* Ugh *)
lemma cpspace_cte_relation_upd_capI:
assumes cr: "cmap_relation (map_to_ctes am) (clift cm) Ptr ccte_relation"
and cof: "map_to_ctes am dest = Some cte"
and cl: "clift cm (Ptr dest) = Some cte'"
and cc: "ccap_relation capl cap"
shows "cmap_relation ((map_to_ctes am)(dest \<mapsto> (cteCap_update (\<lambda>_. capl) cte)))
((clift cm)(Ptr dest \<mapsto> cte_C.cap_C_update (\<lambda>_. cap) cte')) Ptr ccte_relation"
using cr cof cl cc
apply -
apply (frule (2) cmap_relation_relI)
apply (erule (2) cmap_relation_updI)
apply (clarsimp elim!: ccap_relationE simp: map_comp_Some_iff ccte_relation_def)
apply (subst (asm) option_map_Some_eq2)
apply clarsimp
apply (simp add: c_valid_cte_def cl_valid_cte_def)
apply simp
done
lemma cte_to_H_mdb_node_update [simp]:
"cte_to_H (cteMDBNode_CL_update (\<lambda>_. m) cte) =
cteMDBNode_update (\<lambda>_. mdb_node_to_H m) (cte_to_H cte)"
unfolding cte_to_H_def
by simp
lemma cspace_cte_relation_upd_mdbI:
assumes cr: "cmap_relation (map_to_ctes am) (clift cm) Ptr ccte_relation"
and cof: "map_to_ctes am dest = Some cte"
and cl: "clift cm (Ptr dest) = Some cte'"
and cc: "cmdbnode_relation mdbl m"
shows "cmap_relation ((map_to_ctes am)(dest \<mapsto> cteMDBNode_update (\<lambda>_. mdbl) cte))
((clift cm)(Ptr dest \<mapsto> cte_C.cteMDBNode_C_update (\<lambda>_. m) cte')) Ptr ccte_relation"
using cr cof cl cc
apply -
apply (frule (2) cmap_relation_relI)
apply (erule (2) cmap_relation_updI)
apply (clarsimp elim!: cmdbnode_relationE
simp: map_comp_Some_iff ccte_relation_def c_valid_cte_def cl_valid_cte_def option_map_Some_eq2)
apply simp
done
(* FIXME: move, generic *)
lemma aligned_neg_mask [simp]:
"is_aligned x n \<Longrightarrow> x && ~~ mask n = x"
apply (erule is_aligned_get_word_bits)
apply (rule iffD2 [OF mask_in_range])
apply assumption
apply simp
apply (simp add: power_overflow NOT_mask)
done
lemma mdb_node_to_H_mdbPrev_update[simp]:
"mdb_node_to_H (mdbPrev_CL_update (\<lambda>_. x) m)
= mdbPrev_update (\<lambda>_. x) (mdb_node_to_H m)"
unfolding mdb_node_to_H_def by simp
lemma mdb_node_to_H_mdbNext_update[simp]:
"mdb_node_to_H (mdbNext_CL_update (\<lambda>_. x) m)
= mdbNext_update (\<lambda>_. x) (mdb_node_to_H m)"
unfolding mdb_node_to_H_def by simp
lemma mdb_node_to_H_mdbRevocable_update[simp]:
"mdb_node_to_H (mdbRevocable_CL_update (\<lambda>_. x) m)
= mdbRevocable_update (\<lambda>_. to_bool x) (mdb_node_to_H m)"
unfolding mdb_node_to_H_def by simp
lemma mdb_node_to_H_mdbFirstBadged_update[simp]:
"mdb_node_to_H (mdbFirstBadged_CL_update (\<lambda>_. x) m)
= mdbFirstBadged_update (\<lambda>_. to_bool x) (mdb_node_to_H m)"
unfolding mdb_node_to_H_def by simp
declare to_bool_from_bool [simp]
lemma mdbNext_to_H [simp]:
"mdbNext (mdb_node_to_H n) = mdbNext_CL n"
unfolding mdb_node_to_H_def
by simp
lemma mdbPrev_to_H [simp]:
"mdbPrev (mdb_node_to_H n) = mdbPrev_CL n"
unfolding mdb_node_to_H_def
by simp
declare word_neq_0_conv [simp del]
lemma ctes_of_not_0 [simp]:
assumes vm: "valid_mdb' s"
and cof: "ctes_of s p = Some cte"
shows "p \<noteq> 0"
proof -
from vm have "no_0 (ctes_of s)"
unfolding valid_mdb'_def by auto
thus ?thesis using cof
by auto
qed
(* For getting rid of the generated guards -- will probably break with c_guard*)
lemma ctes_of_aligned_3 [simp]:
assumes pa: "pspace_aligned' s"
and cof: "ctes_of s p = Some cte"
shows "is_aligned p 3"
proof -
from cof have "cte_wp_at' (op = cte) p s"
by (simp add: cte_wp_at_ctes_of)
thus ?thesis
apply (rule cte_wp_atE')
apply (simp add: cte_level_bits_def is_aligned_weaken)
apply (simp add: tcb_cte_cases_def field_simps split: split_if_asm )
apply ((erule aligned_add_aligned, simp_all add: is_aligned_def word_bits_conv)[1])+
apply (simp add: is_aligned_weaken)
done
qed
lemma mdbNext_not_zero_eq:
"cmdbnode_relation n n' \<Longrightarrow> \<forall>s s'. (s, s') \<in> rf_sr (*ja \<and> (is_aligned (mdbNext n) 3)*)
\<longrightarrow> (mdbNext n \<noteq> 0) = (s' \<in> {_. mdbNext_CL (mdb_node_lift n') \<noteq> 0})"
apply clarsimp
apply (erule cmdbnode_relationE)
apply (fastforce simp: mdbNext_to_H)
done
lemma mdbPrev_not_zero_eq:
"cmdbnode_relation n n' \<Longrightarrow> \<forall>s s'. (s, s') \<in> rf_sr (*ja\<and> (is_aligned (mdbPrev n) 3)*)
\<longrightarrow> (mdbPrev n \<noteq> 0) = (s' \<in> {_. mdbPrev_CL (mdb_node_lift n') \<noteq> 0})"
apply clarsimp
apply (erule cmdbnode_relationE)
apply (unfold mdb_node_to_H_def)
apply (fastforce)
done
declare is_aligned_0 [simp]
abbreviation
"nullCapPointers cte \<equiv> cteCap cte = NullCap \<and> mdbNext (cteMDBNode cte) = nullPointer \<and> mdbPrev (cteMDBNode cte) = nullPointer"
lemma nullCapPointers_def:
"is_an_abbreviation" unfolding is_an_abbreviation_def by simp
lemma valid_mdb_ctes_of_next:
"\<lbrakk> valid_mdb' s; ctes_of s p = Some cte; mdbNext (cteMDBNode cte) \<noteq> 0 \<rbrakk> \<Longrightarrow> cte_at' (mdbNext (cteMDBNode cte)) s"
unfolding valid_mdb'_def valid_mdb_ctes_def
apply clarsimp
apply (erule (2) valid_dlistE)
apply (simp add: cte_wp_at_ctes_of)
done
lemma valid_mdb_ctes_of_prev:
"\<lbrakk> valid_mdb' s; ctes_of s p = Some cte; mdbPrev (cteMDBNode cte) \<noteq> 0 \<rbrakk> \<Longrightarrow> cte_at' (mdbPrev (cteMDBNode cte)) s"
unfolding valid_mdb'_def valid_mdb_ctes_def
apply clarsimp
apply (erule (2) valid_dlistE)
apply (simp add: cte_wp_at_ctes_of)
done
context kernel
begin
definition
rf_sr :: "(KernelStateData_H.kernel_state \<times> cstate) set"
where
"rf_sr \<equiv> {(s, s'). cstate_relation s (globals s')}"
lemma cmap_relation_tcb [intro]:
"(s, s') \<in> rf_sr \<Longrightarrow> cpspace_tcb_relation (ksPSpace s) (t_hrs_' (globals s'))"
unfolding rf_sr_def state_relation_def cstate_relation_def cpspace_relation_def
by (simp add: Let_def)
lemma cmap_relation_ep [intro]:
"(s, s') \<in> rf_sr \<Longrightarrow> cpspace_ep_relation (ksPSpace s) (t_hrs_' (globals s'))"
unfolding rf_sr_def state_relation_def cstate_relation_def cpspace_relation_def
by (simp add: Let_def)
lemma cmap_relation_aep [intro]:
"(s, s') \<in> rf_sr \<Longrightarrow> cpspace_aep_relation (ksPSpace s) (t_hrs_' (globals s'))"
unfolding rf_sr_def state_relation_def cstate_relation_def cpspace_relation_def
by (simp add: Let_def)
lemma cmap_relation_cte [intro]: