-
Notifications
You must be signed in to change notification settings - Fork 0
/
TcbQueue_C.thy
1222 lines (1107 loc) · 46.6 KB
/
TcbQueue_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 TcbQueue_C
imports SR_lemmas_C
begin
context kernel
begin
lemma tcb_queueD:
assumes queue_rel: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and valid_aep: "distinct queue"
and in_queue: "tcbp \<in> set queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
shows "(if tcbp = hd queue then getPrev tcb = qprev
else (\<exists>n < (length queue) - 1. getPrev tcb = tcb_ptr_to_ctcb_ptr (queue ! n)
\<and> tcbp = queue ! Suc n))
\<and> (if tcbp = last queue then getNext tcb = NULL
else (\<exists>n < (length queue) - 1. tcbp = queue ! n
\<and> getNext tcb = tcb_ptr_to_ctcb_ptr (queue ! Suc n)))"
(is "?prev tcb queue qprev \<and> ?next tcb queue")
using queue_rel in_queue valid_aep
proof (induct queue arbitrary: qprev qhead)
case Nil
thus ?case by simp
next
case (Cons tcb' tcbs qprev' qhead')
have "tcbp = tcb' \<or> tcbp \<in> set tcbs" using Cons.prems by simp
thus ?case
proof
assume tcbp: "tcbp = tcb'"
hence "?prev tcb (tcb' # tcbs) qprev'"
using Cons.prems cs_tcb by clarsimp
moreover
have "?next tcb (tcb' # tcbs)"
proof (cases "tcbs = []")
case True
thus ?thesis using tcbp Cons.prems cs_tcb by clarsimp
next
case False
hence "tcbp \<noteq> last tcbs" using tcbp Cons.prems by clarsimp
thus ?thesis using False tcbp Cons.prems cs_tcb
apply clarsimp
apply (rule exI [where x = 0])
apply simp
apply (cases tcbs)
apply simp_all
done
qed
ultimately show ?thesis ..
next
assume tcbp: "tcbp \<in> set tcbs"
obtain tcb2 where cs_tcb2: "mp (tcb_ptr_to_ctcb_ptr tcb') = Some tcb2"
and rel2: "tcb_queue_relation getNext getPrev mp tcbs (tcb_ptr_to_ctcb_ptr tcb') (getNext tcb2)"
using Cons.prems
by clarsimp
have ih: "?prev tcb tcbs (tcb_ptr_to_ctcb_ptr tcb') \<and> ?next tcb tcbs"
proof (rule Cons.hyps)
from Cons.prems show (* "\<forall>t\<in>set tcbs. tcb_at' t s"
and *) "distinct tcbs" by simp_all
qed fact+
from tcbp Cons.prems have tcbp_not_tcb': "tcbp \<noteq> tcb'" by clarsimp
from tcbp have tcbsnz: "tcbs \<noteq> []" by clarsimp
hence hd_tcbs: "hd tcbs = tcbs ! 0" by (simp add: hd_conv_nth)
show ?case
proof (rule conjI)
show "?prev tcb (tcb' # tcbs) qprev'"
using ih [THEN conjunct1] tcbp_not_tcb' hd_tcbs tcbsnz
apply (clarsimp split: split_if_asm)
apply fastforce
apply (rule_tac x = "Suc n" in exI)
apply simp
done
next
show "?next tcb (tcb' # tcbs)"
using ih [THEN conjunct2] tcbp_not_tcb' hd_tcbs tcbsnz
apply (clarsimp split: split_if_asm)
apply (rule_tac x = "Suc n" in exI)
apply simp
done
qed
qed
qed
lemma tcb_queue_memberD:
assumes queue_rel: "tcb_queue_relation getNext getPrev (cslift s') queue qprev qhead"
and in_queue: "tcbp \<in> set queue"
and valid_aep: "\<forall>t\<in>set queue. tcb_at' t s"
and rf_sr: "(s, s') \<in> rf_sr"
shows "\<exists>tcb. cslift s' (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
using assms
apply -
apply (drule (1) bspec)
apply (drule (1) tcb_at_h_t_valid)
apply (clarsimp simp add: h_t_valid_clift_Some_iff)
done
lemma tcb_queue_valid_ptrsD:
assumes in_queue: "tcbp \<in> set queue"
and rf_sr: "(s, s') \<in> rf_sr"
and valid_aep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and queue_rel: "tcb_queue_relation getNext getPrev (cslift s') queue NULL qhead"
shows "\<exists>tcb. cslift s' (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb
\<and> (getPrev tcb \<noteq> NULL \<longrightarrow> s' \<Turnstile>\<^sub>c (getPrev tcb)
\<and> getPrev tcb \<in> tcb_ptr_to_ctcb_ptr ` set queue)
\<and> (getNext tcb \<noteq> NULL \<longrightarrow> s' \<Turnstile>\<^sub>c (getNext tcb)
\<and> getNext tcb \<in> tcb_ptr_to_ctcb_ptr ` set queue)"
using assms
apply -
apply (frule (3) tcb_queue_memberD)
apply (elim exE)
apply (frule (3) tcb_queueD)
apply (auto intro!: tcb_at_h_t_valid elim!: bspec split: split_if_asm)
done
lemma tcb_queue_relation_restrict0:
"set queue \<subseteq> S \<Longrightarrow> tcb_queue_relation getNext getPrev mp queue qprev qhead =
tcb_queue_relation getNext getPrev (restrict_map mp (tcb_ptr_to_ctcb_ptr ` S)) queue qprev qhead"
proof (induct queue arbitrary: S qprev qhead)
case Nil thus ?case by simp
next
case (Cons tcb tcbs S' qprev' qhead')
thus ?case
using Cons by auto
qed
lemma tcb_queue_relation_restrict:
"tcb_queue_relation getNext getPrev mp queue qprev qhead =
tcb_queue_relation getNext getPrev (restrict_map mp (tcb_ptr_to_ctcb_ptr ` set queue)) queue qprev qhead"
apply (rule tcb_queue_relation_restrict0)
apply simp
done
lemma tcb_queue_relation_only_next_prev:
assumes mapeq: "option_map getNext \<circ> mp = option_map getNext \<circ> mp'" "option_map getPrev \<circ> mp = option_map getPrev \<circ> mp'"
shows "tcb_queue_relation getNext getPrev mp queue qprev qhead = tcb_queue_relation getNext getPrev mp' queue qprev qhead"
proof (induct queue arbitrary: qprev qhead)
case Nil thus ?case by simp
next
case (Cons tcb tcbs qprev' qhead')
thus ?case
apply clarsimp
apply (rule iffI)
apply clarsimp
apply (frule compD [OF mapeq(1)])
apply clarsimp
apply (frule compD [OF mapeq(2)])
apply clarsimp
apply clarsimp
apply (frule compD [OF mapeq(1) [symmetric]])
apply clarsimp
apply (frule compD [OF mapeq(2) [symmetric]])
apply clarsimp
done
qed
lemma tcb_queue_relation_cong:
assumes queuec: "queue = queue'"
and qpc: "qprev = qprev'"
and qhc: "qhead = qhead'"
and mpc: "\<And>p. p \<in> tcb_ptr_to_ctcb_ptr ` set queue' \<Longrightarrow> mp p = mp' p"
shows "tcb_queue_relation getNext getPrev mp queue qprev qhead =
tcb_queue_relation getNext getPrev mp' queue' qprev' qhead'" (is "?LHS = ?RHS")
proof -
have "?LHS = tcb_queue_relation getNext getPrev (mp |` (tcb_ptr_to_ctcb_ptr ` set queue')) queue' qprev' qhead'"
by (simp add: queuec qpc qhc, subst tcb_queue_relation_restrict, rule refl)
also have "\<dots> = tcb_queue_relation getNext getPrev (mp' |` (tcb_ptr_to_ctcb_ptr ` set queue')) queue' qprev' qhead'"
by (simp add: mpc cong: restrict_map_cong)
also have "\<dots> = ?RHS"
by (simp add: tcb_queue_relation_restrict [symmetric])
finally show ?thesis .
qed
lemma tcb_queue_relation'_cong:
assumes queuec: "queue = queue'"
and qhc: "qhead = qhead'"
and qpc: "qend = qend'"
and mpc: "\<And>p. p \<in> tcb_ptr_to_ctcb_ptr ` set queue' \<Longrightarrow> mp p = mp' p"
shows "tcb_queue_relation' getNext getPrev mp queue qhead qend =
tcb_queue_relation' getNext getPrev mp' queue' qhead' qend'" (is "?LHS = ?RHS")
proof -
have "?LHS = tcb_queue_relation' getNext getPrev (mp |` (tcb_ptr_to_ctcb_ptr ` set queue')) queue' qhead' qend'"
by (clarsimp simp add: queuec qpc qhc tcb_queue_relation'_def , subst tcb_queue_relation_restrict, rule refl)
also have "\<dots> = tcb_queue_relation' getNext getPrev (mp' |` (tcb_ptr_to_ctcb_ptr ` set queue')) queue' qhead' qend'"
by (simp add: mpc cong: restrict_map_cong)
also have "\<dots> = ?RHS"
by (simp add: tcb_queue_relation'_def tcb_queue_relation_restrict [symmetric])
finally show ?thesis .
qed
(* MOVE *)
lemma tcb_aligned':
"tcb_at' t s \<Longrightarrow> is_aligned t 9"
apply (drule obj_at_aligned')
apply (simp add: objBits_simps)
apply (simp add: objBits_simps)
done
lemma tcb_at_not_NULL:
assumes tat: "tcb_at' t s"
shows "tcb_ptr_to_ctcb_ptr t \<noteq> NULL"
proof
assume "tcb_ptr_to_ctcb_ptr t = NULL"
with tat have "tcb_at' (ctcb_ptr_to_tcb_ptr NULL) s"
apply -
apply (erule subst)
apply simp
done
hence "is_aligned (ctcb_ptr_to_tcb_ptr NULL) 9"
by (rule tcb_aligned')
moreover have "ctcb_ptr_to_tcb_ptr NULL !! 8"
unfolding ctcb_ptr_to_tcb_ptr_def ctcb_offset_def
by simp
ultimately show False by (simp add: is_aligned_nth)
qed
lemma tcb_queue_relation_not_NULL:
assumes tq: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s"
shows "\<forall>t \<in> set queue. tcb_ptr_to_ctcb_ptr t \<noteq> NULL"
proof (cases "queue = []")
case True thus ?thesis by simp
next
case False
show ?thesis
proof (rule ballI, rule notI)
fix t
assume tq: "t \<in> set queue" and "tcb_ptr_to_ctcb_ptr t = NULL"
hence "ctcb_ptr_to_tcb_ptr NULL \<in> set queue"
apply -
apply (erule subst)
apply simp
done
with valid_ep(1) have "tcb_at' (ctcb_ptr_to_tcb_ptr NULL) s" ..
thus False
apply -
apply (drule tcb_at_not_NULL)
apply simp
done
qed
qed
lemmas tcb_queue_relation_not_NULL' = bspec [OF tcb_queue_relation_not_NULL]
lemma tcb_queue_relation_head_hd:
assumes tq: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and tcbs: "queue \<noteq> []"
shows "ctcb_ptr_to_tcb_ptr qhead = hd queue"
using assms
apply (cases queue)
apply simp
apply simp
done
lemma tcb_queue_relation_next_not_NULL:
assumes tq: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and tcbs: "queue \<noteq> []"
shows "qhead \<noteq> NULL"
proof -
have "ctcb_ptr_to_tcb_ptr qhead \<in> set queue" using tq tcbs
by (simp add: tcb_queue_relation_head_hd)
with tq valid_ep(1) have "tcb_ptr_to_ctcb_ptr (ctcb_ptr_to_tcb_ptr qhead) \<noteq> NULL"
by (rule tcb_queue_relation_not_NULL')
thus ?thesis by simp
qed
lemma tcb_queue_relation_ptr_rel:
assumes tq: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and prev_not_queue: "ctcb_ptr_to_tcb_ptr qprev \<notin> set queue"
and in_queue: "tcbp \<in> set queue"
shows "tcb_ptr_to_ctcb_ptr tcbp \<noteq> getNext tcb \<and> tcb_ptr_to_ctcb_ptr tcbp \<noteq> getPrev tcb
\<and> (getNext tcb \<noteq> NULL \<longrightarrow> getNext tcb \<noteq> getPrev tcb)"
using tq valid_ep in_queue cs_tcb prev_not_queue
apply -
apply (frule (3) tcb_queueD)
apply (frule (2) tcb_queue_relation_not_NULL')
apply (simp split: split_if_asm)
apply (rule not_sym)
apply (rule notI)
apply simp
apply (clarsimp simp: inj_eq distinct_conv_nth)
apply (intro conjI impI)
apply (clarsimp simp: inj_eq distinct_conv_nth)
apply (rule not_sym)
apply clarsimp
apply clarsimp
apply (clarsimp simp: inj_eq)
apply (intro conjI impI)
apply (clarsimp simp: distinct_conv_nth)
apply (erule_tac s = "queue ! Suc n" in subst)
apply (clarsimp simp: distinct_conv_nth)
apply clarsimp
apply (case_tac "na = Suc n")
apply hypsubst
apply (clarsimp simp: distinct_conv_nth)
apply (clarsimp simp: distinct_conv_nth)
done
lemma distinct_cons_nth:
assumes dxs: "distinct xs"
and ln: "n < length xs"
and x: "x \<notin> set xs"
shows "(x # xs) ! n \<noteq> xs ! n"
proof
assume n: "(x # xs) ! n = xs ! n"
have ln': "n < length (x # xs)" using ln by simp
have sln: "Suc n < length (x # xs)" using ln by simp
from n have "(x # xs) ! n = (x # xs) ! Suc n" by simp
moreover have "distinct (x # xs)" using dxs x by simp
ultimately show False
unfolding distinct_conv_nth
apply -
apply (drule spec, drule mp [OF _ ln'])
apply (drule spec, drule mp [OF _ sln])
apply simp
done
qed
lemma distinct_nth:
assumes dist: "distinct xs"
and ln: "n < length xs"
and lm: "m < length xs"
shows "(xs ! n = xs ! m) = (n = m)"
using dist ln lm
apply (cases "n = m")
apply simp
apply (clarsimp simp: distinct_conv_nth)
done
lemma distinct_nth_cons:
assumes dist: "distinct xs"
and xxs: "x \<notin> set xs"
and ln: "n < length xs"
and lm: "m < length xs"
shows "((x # xs) ! n = xs ! m) = (n = Suc m)"
proof (cases "n = Suc m")
case True
thus ?thesis by simp
next
case False
have ln': "n < length (x # xs)" using ln by simp
have lm': "Suc m < length (x # xs)" using lm by simp
have "distinct (x # xs)" using dist xxs by simp
thus ?thesis using False
unfolding distinct_conv_nth
apply -
apply (drule spec, drule mp [OF _ ln'])
apply (drule spec, drule mp [OF _ lm'])
apply clarsimp
done
qed
lemma distinct_nth_cons':
assumes dist: "distinct xs"
and xxs: "x \<notin> set xs"
and ln: "n < length xs"
and lm: "m < length xs"
shows "(xs ! n = (x # xs) ! m) = (m = Suc n)"
proof (cases "m = Suc n")
case True
thus ?thesis by simp
next
case False
have ln': "Suc n < length (x # xs)" using ln by simp
have lm': "m < length (x # xs)" using lm by simp
have "distinct (x # xs)" using dist xxs by simp
thus ?thesis using False
unfolding distinct_conv_nth
apply -
apply (drule spec, drule mp [OF _ ln'])
apply (drule spec, drule mp [OF _ lm'])
apply clarsimp
done
qed
lemma nth_first_not_member:
assumes xxs: "x \<notin> set xs"
and ln: "n < length xs"
shows "((x # xs) ! n = x) = (n = 0)"
using xxs ln
apply (cases n)
apply simp
apply clarsimp
done
lemma tcb_queue_next_prev:
assumes qr: "tcb_queue_relation getNext getPrev mp queue qprev qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and tcb': "mp (tcb_ptr_to_ctcb_ptr tcbp') = Some tcb'"
and tq: "tcbp \<in> set queue" "tcbp' \<in> set queue"
and prev_not_queue: "ctcb_ptr_to_tcb_ptr qprev \<notin> set queue"
and tcbs: "tcbp \<noteq> tcbp'"
shows "(getNext tcb = tcb_ptr_to_ctcb_ptr tcbp') =
(getPrev tcb' = tcb_ptr_to_ctcb_ptr tcbp)"
using qr valid_ep prev_not_queue tq tcb tcb' tcbs
apply -
apply (frule (1) tcb_queueD)
apply (rule tq(1))
apply (rule tcb)
apply (frule (1) tcb_queueD)
apply (rule tq(2))
apply (rule tcb')
apply (cases queue)
apply simp
apply (cut_tac bspec [OF tcb_queue_relation_not_NULL, OF qr valid_ep(1) tq(1)])
apply (cut_tac bspec [OF tcb_queue_relation_not_NULL, OF qr valid_ep(1) tq(2)])
apply (simp add: inj_eq split: split_if_asm)
apply clarsimp
apply clarsimp
apply (clarsimp simp: last_conv_nth distinct_nth distinct_nth_cons)
apply (clarsimp simp: last_conv_nth distinct_nth distinct_nth_cons)
apply (subgoal_tac "list ! Suc na \<noteq> tcbp'")
apply clarsimp
apply clarsimp
apply (clarsimp simp: last_conv_nth distinct_nth distinct_nth_cons nth_first_not_member)
apply (fastforce simp: last_conv_nth distinct_nth distinct_nth_cons nth_first_not_member)
apply (clarsimp simp: last_conv_nth distinct_nth distinct_nth_cons distinct_nth_cons' nth_first_not_member)
apply (fastforce simp: last_conv_nth distinct_nth distinct_nth_cons distinct_nth_cons' nth_first_not_member)
done
lemma null_not_in:
"\<lbrakk>tcb_queue_relation getNext getPrev mp queue qprev qhead; \<forall>t\<in>set queue. tcb_at' t s; distinct queue\<rbrakk>
\<Longrightarrow> ctcb_ptr_to_tcb_ptr NULL \<notin> set queue"
apply -
apply (rule notI)
apply (drule (2) tcb_queue_relation_not_NULL')
apply simp
done
lemma tcb_queue_relationI':
"\<lbrakk> tcb_queue_relation getNext getPrev hp queue NULL qhead;
qend = (if queue = [] then NULL else (tcb_ptr_to_ctcb_ptr (last queue))) \<rbrakk>
\<Longrightarrow> tcb_queue_relation' getNext getPrev hp queue qhead qend"
unfolding tcb_queue_relation'_def
by simp
lemma tcb_queue_relationE':
"\<lbrakk> tcb_queue_relation' getNext getPrev hp queue qhead qend;
\<lbrakk> tcb_queue_relation getNext getPrev hp queue NULL qhead;
qend = (if queue = [] then NULL else (tcb_ptr_to_ctcb_ptr (last queue))) \<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
unfolding tcb_queue_relation'_def
by simp
lemma tcb_queue_relation'_queue_rel:
"tcb_queue_relation' getNext getPrev hp queue qhead qend
\<Longrightarrow> tcb_queue_relation getNext getPrev hp queue NULL qhead"
unfolding tcb_queue_relation'_def
by simp
lemma tcb_queue_singleton_iff:
assumes queue_rel: "tcb_queue_relation getNext getPrev mp queue NULL qhead"
and in_queue: "tcbp \<in> set queue"
and valid_aep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
shows "(queue = [tcbp]) = (getNext tcb = NULL \<and> getPrev tcb = NULL)"
proof (rule iffI)
assume "queue = [tcbp]"
thus "(getNext tcb = NULL \<and> getPrev tcb = NULL)" using queue_rel cs_tcb
by clarsimp
next
assume asms: "getNext tcb = NULL \<and> getPrev tcb = NULL"
hence "hd queue = tcbp" using queue_rel valid_aep in_queue cs_tcb
apply -
apply (drule (3) tcb_queueD)
apply (rule classical)
apply clarsimp
apply (cut_tac x = "queue ! n" in bspec [OF tcb_queue_relation_not_NULL [OF queue_rel valid_aep(1)]])
apply clarsimp
apply simp
done
moreover have "last queue = tcbp" using queue_rel valid_aep in_queue cs_tcb asms
apply -
apply (drule (3) tcb_queueD)
apply (rule classical)
apply clarsimp
apply (cut_tac x = "queue ! Suc n" in bspec [OF tcb_queue_relation_not_NULL [OF queue_rel valid_aep(1)]])
apply clarsimp
apply simp
done
moreover have "queue \<noteq> []" using in_queue by clarsimp
ultimately show "queue = [tcbp]" using valid_aep in_queue
apply clarsimp
apply (simp add: hd_conv_nth last_conv_nth nth_eq_iff_index_eq)
apply (cases queue)
apply simp
apply simp
done
qed
lemma distinct_remove1_take_drop:
"\<lbrakk> distinct ls; n < length ls \<rbrakk> \<Longrightarrow> remove1 (ls ! n) ls = (take n ls) @ drop (Suc n) ls"
proof (induct ls arbitrary: n)
case Nil thus ?case by simp
next
case (Cons x xs n)
show ?case
proof (cases n)
case 0
thus ?thesis by simp
next
case (Suc m)
hence "((x # xs) ! n) \<noteq> x" using Cons.prems by clarsimp
thus ?thesis using Suc Cons.prems by (clarsimp simp add: Cons.hyps)
qed
qed
definition
"upd_unless_null \<equiv> \<lambda>p v f. if p = NULL then f else fun_upd f p (Some v)"
lemma upd_unless_null_cong_helper:
"\<And>p p' v mp S. \<lbrakk> p' \<in> tcb_ptr_to_ctcb_ptr ` S; ctcb_ptr_to_tcb_ptr p \<notin> S \<rbrakk> \<Longrightarrow> (upd_unless_null p v mp) p' = mp p'"
unfolding upd_unless_null_def
apply simp
apply (intro impI conjI)
apply (erule imageE)
apply hypsubst
apply (simp only: ctcb_ptr_to_ctcb_ptr)
apply blast
done
lemma tcbDequeue_update0:
assumes in_queue: "tcbp \<in> set queue"
and valid_aep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and queue_rel: "tcb_queue_relation tn tp mp queue qprev qhead"
and prev_not_queue: "ctcb_ptr_to_tcb_ptr qprev \<notin> set queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and f: "\<And>v f g. tn (tn_update f v) = f (tn v) \<and> tp (tp_update g v) = g (tp v)
\<and> tn (tp_update f v) = tn v \<and> tp (tn_update g v) = tp v"
shows "tcb_queue_relation tn tp
(upd_unless_null (tn tcb) (tp_update (\<lambda>_. tp tcb) (the (mp (tn tcb))))
(upd_unless_null (tp tcb) (tn_update (\<lambda>_. tn tcb) (the (mp (tp tcb)))) mp))
(remove1 tcbp queue)
(if tcb_ptr_to_ctcb_ptr tcbp = qhead then tp tcb else qprev)
(if tcb_ptr_to_ctcb_ptr tcbp = qhead then tn tcb else qhead)"
(is "tcb_queue_relation tn tp ?mp (remove1 tcbp queue) (?qprev qprev qhead) (?qhead qhead)")
using queue_rel valid_aep prev_not_queue in_queue
proof (induct queue arbitrary: qprev qhead)
case Nil
thus ?case by simp
next
case (Cons tcb' tcbs qprev' qhead')
have "tcbp = tcb' \<or> tcbp \<in> set tcbs" using Cons.prems by simp
thus ?case
proof
assume tcbp: "tcbp = tcb'"
hence qp: "qprev' = tp tcb" and qh: "qhead' = tcb_ptr_to_ctcb_ptr tcb'"
using Cons.prems cs_tcb by auto
from Cons.prems have tq: "tcb_queue_relation tn tp mp tcbs (tcb_ptr_to_ctcb_ptr tcb') (tn tcb)"
using Cons.prems cs_tcb tcbp by clarsimp
note ind_prems = Cons.prems
note ind_hyp = Cons.hyps
show ?thesis
proof (cases tcbs)
case Nil thus ?thesis using Cons.prems tcbp cs_tcb by clarsimp
next
case (Cons tcbs_hd tcbss)
have nnull: "tn tcb \<noteq> NULL" using tq
proof (rule tcb_queue_relation_next_not_NULL)
from ind_prems show "\<forall>t\<in>set tcbs. tcb_at' t s"
and "distinct tcbs" by simp_all
show "tcbs \<noteq> []" using Cons by simp
qed
from Cons ind_prems have "tcbs_hd \<notin> set tcbss" by simp
hence mpeq: "\<And>p. p \<in> tcb_ptr_to_ctcb_ptr ` set tcbss \<Longrightarrow> ?mp p = mp p"
using tq cs_tcb tcbp Cons nnull ind_prems
apply -
apply (subst upd_unless_null_cong_helper, assumption, clarsimp)+
apply simp
done
have "tcb_ptr_to_ctcb_ptr tcbp \<noteq> tn tcb \<and> tcb_ptr_to_ctcb_ptr tcbp \<noteq> tp tcb
\<and> tn tcb \<noteq> tp tcb" using tq cs_tcb ind_prems nnull
apply -
apply (drule (5) tcb_queue_relation_ptr_rel)
apply clarsimp
done
hence "?mp (tcb_ptr_to_ctcb_ptr tcbs_hd) = Some (tp_update (\<lambda>_. tp tcb) (the (mp (tn tcb))))"
using qp qh tq cs_tcb tcbp Cons nnull
by (simp add: upd_unless_null_def)
thus ?thesis using qp qh tq cs_tcb tcbp Cons nnull
apply (simp (no_asm) add: tcbp Cons split del: split_if)
apply (subst tcb_queue_relation_cong [OF refl refl refl mpeq])
apply assumption
apply (clarsimp simp: f)
done
qed
next
assume inset: "tcbp \<in> set tcbs"
hence tcbp: "tcbp \<noteq> tcb'" using Cons.prems by clarsimp
obtain tcb2 where cs_tcb2: "mp (tcb_ptr_to_ctcb_ptr tcb') = Some tcb2"
and rel2: "tcb_queue_relation tn tp mp tcbs (tcb_ptr_to_ctcb_ptr tcb') (tn tcb2)"
and qh: "qhead' = tcb_ptr_to_ctcb_ptr tcb'"
and qp: "qprev' = tp tcb2"
using Cons.prems
by clarsimp
have nnull: "tcb_ptr_to_ctcb_ptr tcb' \<noteq> NULL" using Cons.prems
apply -
apply (erule (1) tcb_queue_relation_not_NULL')
apply simp
done
have ih: "tcb_queue_relation tn tp ?mp (remove1 tcbp tcbs)
(?qprev (tcb_ptr_to_ctcb_ptr tcb') (tn tcb2))
(?qhead (tn tcb2))" using rel2
proof (rule Cons.hyps)
from Cons.prems show "\<forall>t\<in>set tcbs. tcb_at' t s"
and "distinct tcbs"
and "ctcb_ptr_to_tcb_ptr (tcb_ptr_to_ctcb_ptr tcb') \<notin> set tcbs" by simp_all
qed fact
have tcb_next: "tn tcb \<noteq> tcb_ptr_to_ctcb_ptr tcb'"
using Cons.prems tcb_queue_next_prev[OF Cons.prems(1), OF _ _ cs_tcb cs_tcb2]
tcbp qp[symmetric]
by auto
show ?thesis using tcbp
proof (cases "tn tcb2 = tcb_ptr_to_ctcb_ptr tcbp")
case True
hence tcb_prev: "tp tcb = tcb_ptr_to_ctcb_ptr tcb'" using Cons.prems cs_tcb2 cs_tcb not_sym [OF tcbp]
apply -
apply (subst tcb_queue_next_prev [symmetric], assumption+)
apply simp
apply simp
apply simp
apply (rule not_sym [OF tcbp])
apply simp
done
hence "?mp (tcb_ptr_to_ctcb_ptr tcb') = Some (tn_update (\<lambda>_. tn tcb) tcb2)"
using tcb_next nnull cs_tcb2 unfolding upd_unless_null_def by simp
thus ?thesis using tcbp cs_tcb qh qp True ih tcb_prev
by (simp add: inj_eq f)
next
case False
hence tcb_prev: "tp tcb \<noteq> tcb_ptr_to_ctcb_ptr tcb'"
using Cons.prems cs_tcb2 cs_tcb not_sym [OF tcbp]
apply -
apply (subst tcb_queue_next_prev [symmetric], assumption+)
apply simp
apply simp
apply simp
apply (rule not_sym [OF tcbp])
apply simp
done
hence "?mp (tcb_ptr_to_ctcb_ptr tcb') = Some tcb2"
using tcb_next nnull cs_tcb2 unfolding upd_unless_null_def by simp
thus ?thesis using tcbp cs_tcb qh qp False ih tcb_prev
by (simp add: inj_eq)
qed
qed
qed
lemma tcbDequeue_update:
assumes queue_rel: "tcb_queue_relation' tn tp mp queue qhead qend"
and in_queue: "tcbp \<in> set queue"
and valid_aep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and f: "\<And>v f g. tn (tn_update f v) = f (tn v) \<and> tp (tp_update g v) = g (tp v)
\<and> tn (tp_update f v) = tn v \<and> tp (tn_update g v) = tp v"
shows "tcb_queue_relation' tn tp
(upd_unless_null (tn tcb) (tp_update (\<lambda>_. tp tcb) (the (mp (tn tcb))))
(upd_unless_null (tp tcb) (tn_update (\<lambda>_. tn tcb) (the (mp (tp tcb)))) mp))
(remove1 tcbp queue)
(if tp tcb = NULL then tn tcb else qhead)
(if tn tcb = NULL then tp tcb else qend)"
proof -
have ne: "NULL = (if tcb_ptr_to_ctcb_ptr tcbp = qhead then tp tcb else NULL)"
using queue_rel in_queue cs_tcb
apply -
apply (drule tcb_queue_relation'_queue_rel)
apply (clarsimp split: split_if)
apply (cases queue)
apply simp
apply clarsimp
done
have if2: "(if tp tcb = NULL then tn tcb else qhead) =
(if tcb_ptr_to_ctcb_ptr tcbp = qhead then tn tcb else qhead)"
using tcb_queue_relation'_queue_rel [OF queue_rel] in_queue cs_tcb valid_aep
apply -
apply (cases queue)
apply simp
apply (frule (3) tcb_queueD)
apply (simp add: inj_eq)
apply (intro impI)
apply simp
apply (elim conjE exE)
apply (cut_tac x = "queue ! n"
in bspec [OF tcb_queue_relation_not_NULL [OF tcb_queue_relation'_queue_rel [OF queue_rel] valid_aep(1)]])
apply (rule nth_mem)
apply clarsimp
apply clarsimp
done
note null_not_in' = null_not_in [OF tcb_queue_relation'_queue_rel [OF queue_rel] valid_aep(1) valid_aep(2)]
show ?thesis
proof (rule tcb_queue_relationI')
show "tcb_queue_relation tn tp
(upd_unless_null (tn tcb)
(tp_update (\<lambda>_. tp tcb) (the (mp (tn tcb))))
(upd_unless_null (tp tcb)
(tn_update (\<lambda>_. tn tcb) (the (mp (tp tcb)))) mp))
(remove1 tcbp queue) NULL
(if tp tcb = NULL then tn tcb else qhead)"
using in_queue valid_aep tcb_queue_relation'_queue_rel [OF queue_rel] null_not_in' cs_tcb
by (subst ne, subst if2, rule tcbDequeue_update0[rotated -1, OF f])
next
have r1: "(remove1 tcbp queue = []) = (tn tcb = NULL \<and> tp tcb = NULL)"
using in_queue tcb_queue_relation'_queue_rel [OF queue_rel] cs_tcb valid_aep null_not_in'
apply -
apply (subst tcb_queue_singleton_iff [symmetric], assumption+)
apply (fastforce simp: remove1_empty)
done
have "queue \<noteq> []" using in_queue by clarsimp
thus "(if tn tcb = NULL then tp tcb else qend) =
(if remove1 tcbp queue = [] then NULL else tcb_ptr_to_ctcb_ptr (last (remove1 tcbp queue)))"
using queue_rel in_queue cs_tcb valid_aep
tcb_queue_relation_not_NULL [OF tcb_queue_relation'_queue_rel [OF queue_rel] valid_aep(1)]
apply -
apply (erule tcb_queue_relationE')
apply (frule (3) tcb_queueD)
apply (subst r1)
apply simp
apply (intro impI conjI)
apply (subgoal_tac "tcbp = last queue")
apply simp
apply (subgoal_tac "(remove1 (last queue) queue) \<noteq> []")
apply (clarsimp simp: inj_eq last_conv_nth nth_eq_iff_index_eq length_remove1
distinct_remove1_take_drop split: split_if_asm)
apply arith
apply (clarsimp simp: remove1_empty last_conv_nth hd_conv_nth nth_eq_iff_index_eq not_le split: split_if_asm)
apply (cases queue)
apply simp
apply simp
apply (fastforce simp: inj_eq split: split_if_asm)
apply (clarsimp simp: last_conv_nth distinct_remove1_take_drop nth_eq_iff_index_eq inj_eq split: split_if_asm)
apply arith
apply (simp add: nth_append min_def nth_eq_iff_index_eq)
apply clarsimp
apply arith
done
qed
qed
lemmas tcbEPDequeue_update
= tcbDequeue_update[where tn=tcbEPNext_C and tn_update=tcbEPNext_C_update
and tp=tcbEPPrev_C and tp_update=tcbEPPrev_C_update,
simplified]
lemma tcb_queue_relation_ptr_rel':
assumes tq: "tcb_queue_relation getNext getPrev mp queue NULL qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and in_queue: "tcbp \<in> set queue"
shows "tcb_ptr_to_ctcb_ptr tcbp \<noteq> getNext tcb \<and> tcb_ptr_to_ctcb_ptr tcbp \<noteq> getPrev tcb
\<and> (getNext tcb \<noteq> NULL \<longrightarrow> getNext tcb \<noteq> getPrev tcb)"
using tq valid_ep cs_tcb null_not_in [OF tq valid_ep(1) valid_ep(2)] in_queue
by (rule tcb_queue_relation_ptr_rel)
lemma tcb_queue_head_empty_iff:
"\<lbrakk> tcb_queue_relation getNext getPrev mp queue NULL qhead; \<forall>t \<in> set queue. tcb_at' t s \<rbrakk> \<Longrightarrow>
(qhead = NULL) = (queue = [])"
apply (rule classical)
apply (cases queue)
apply simp
apply (frule (1) tcb_queue_relation_not_NULL)
apply clarsimp
done
lemma ctcb_ptr_to_tcb_ptr_aligned:
assumes al: "is_aligned (ctcb_ptr_to_tcb_ptr ptr) 9"
shows "is_aligned (ptr_val ptr) 8"
proof -
have "is_aligned (ptr_val (tcb_ptr_to_ctcb_ptr (ctcb_ptr_to_tcb_ptr ptr))) 8"
unfolding tcb_ptr_to_ctcb_ptr_def using al
apply simp
apply (erule aligned_add_aligned)
apply (unfold ctcb_offset_def, rule is_aligned_triv)
apply (simp add: word_bits_conv)+
done
thus ?thesis by simp
qed
(* FIXME: name clash with Aligned.is_aligned_neg_mask. *)
(* FIXME: superceded by GenericLib.is_aligned_neg_mask_eq. Remove! *)
lemma is_aligned_neg_mask:
"\<lbrakk> is_aligned p n; m \<le> n \<rbrakk> \<Longrightarrow> p && ~~ mask m = p"
by (simp add: is_aligned_nth)
lemma tcb_queue_relation_next_mask_4:
assumes tq: "tcb_queue_relation getNext getPrev mp queue NULL qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and in_queue: "tcbp \<in> set queue"
shows "ptr_val (getNext tcb) && ~~ mask 4 = ptr_val (getNext tcb)"
proof (cases "(getNext tcb) = NULL")
case True
thus ?thesis by simp
next
case False
hence "ctcb_ptr_to_tcb_ptr (getNext tcb) \<in> set queue" using assms
apply -
apply (drule (3) tcb_queueD)
apply (clarsimp split: split_if_asm)
done
with valid_ep(1) have "tcb_at' (ctcb_ptr_to_tcb_ptr (getNext tcb)) s" ..
hence "is_aligned (ctcb_ptr_to_tcb_ptr (getNext tcb)) 9" by (rule tcb_aligned')
hence "is_aligned (ptr_val (getNext tcb)) 8" by (rule ctcb_ptr_to_tcb_ptr_aligned)
thus ?thesis by (simp add: is_aligned_neg_mask)
qed
lemma tcb_queue_relation_prev_mask_4:
assumes tq: "tcb_queue_relation getNext getPrev mp queue NULL qhead"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and in_queue: "tcbp \<in> set queue"
shows "ptr_val (getPrev tcb) && ~~ mask 4 = ptr_val (getPrev tcb)"
proof (cases "(getPrev tcb) = NULL")
case True
thus ?thesis by simp
next
case False
hence "ctcb_ptr_to_tcb_ptr (getPrev tcb) \<in> set queue" using assms
apply -
apply (drule (3) tcb_queueD)
apply (clarsimp split: split_if_asm)
done
with valid_ep(1) have "tcb_at' (ctcb_ptr_to_tcb_ptr (getPrev tcb)) s" ..
hence "is_aligned (ctcb_ptr_to_tcb_ptr (getPrev tcb)) 9" by (rule tcb_aligned')
hence "is_aligned (ptr_val (getPrev tcb)) 8" by (rule ctcb_ptr_to_tcb_ptr_aligned)
thus ?thesis by (simp add: is_aligned_neg_mask)
qed
lemma tcb_queue_relation'_next_mask_4:
assumes tq: "tcb_queue_relation' getNext getPrev mp queue qhead qend"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and in_queue: "tcbp \<in> set queue"
shows "ptr_val (getNext tcb) && ~~ mask 4 = ptr_val (getNext tcb)"
by (rule tcb_queue_relation_next_mask_4 [OF tcb_queue_relation'_queue_rel], fact+)
lemma tcb_queue_relation'_prev_mask_4:
assumes tq: "tcb_queue_relation' getNext getPrev mp queue qhead qend"
and valid_ep: "\<forall>t\<in>set queue. tcb_at' t s" "distinct queue"
and cs_tcb: "mp (tcb_ptr_to_ctcb_ptr tcbp) = Some tcb"
and in_queue: "tcbp \<in> set queue"
shows "ptr_val (getPrev tcb) && ~~ mask 4 = ptr_val (getPrev tcb)"
by (rule tcb_queue_relation_prev_mask_4 [OF tcb_queue_relation'_queue_rel], fact+)
lemma cready_queues_relation_null_queue_ptrs:
assumes rel: "cready_queues_relation mp cq aq"
and same: "option_map tcb_null_ep_ptrs \<circ> mp' = option_map tcb_null_ep_ptrs \<circ> mp"
shows "cready_queues_relation mp' cq aq"
using rel
apply (clarsimp simp: cready_queues_relation_def Let_def all_conj_distrib)
apply (drule spec, drule spec, drule mp, (erule conjI)+, assumption)
apply (clarsimp simp: tcb_queue_relation'_def)
apply (erule iffD2 [OF tcb_queue_relation_only_next_prev, rotated -1])
apply (rule ext)
apply (case_tac "mp' x")
apply (frule compD [OF same])
apply simp
apply (frule compD [OF same])
apply (clarsimp simp: tcb_null_ep_ptrs_def)
apply (case_tac z, case_tac a)
apply simp
-- "clag"
apply (rule ext)
apply (case_tac "mp' x")
apply (frule compD [OF same])
apply simp
apply (frule compD [OF same])
apply (clarsimp simp: tcb_null_ep_ptrs_def)
apply (case_tac z, case_tac a)
apply simp
done
lemma cready_queues_relation_not_queue_ptrs:
assumes rel: "cready_queues_relation mp cq aq"
and same: "option_map tcbSchedNext_C \<circ> mp' = option_map tcbSchedNext_C \<circ> mp"
"option_map tcbSchedPrev_C \<circ> mp' = option_map tcbSchedPrev_C \<circ> mp"
shows "cready_queues_relation mp' cq aq"
using rel
apply (clarsimp simp: cready_queues_relation_def tcb_queue_relation'_def Let_def all_conj_distrib)
apply (drule spec, drule spec, drule mp, (erule conjI)+, assumption)
apply clarsimp
apply (erule iffD2 [OF tcb_queue_relation_only_next_prev, rotated -1])
apply (rule same)
apply (rule same)
done
lemma aep_ep_disjoint:
assumes srs: "sym_refs (state_refs_of' s)"
and epat: "ko_at' ep epptr s"
and aepat: "ko_at' aep aepptr s"
and aepq: "isWaitingAEP aep"
and epq: "isSendEP ep \<or> isRecvEP ep"
shows "set (epQueue ep) \<inter> set (aepQueue aep) = {}"
using srs epat aepat aepq epq
apply -
apply (subst disjoint_iff_not_equal, intro ballI, rule notI)
apply (drule sym_refs_ko_atD', clarsimp)+
apply clarsimp
apply (clarsimp simp: isWaitingAEP_def isSendEP_def isRecvEP_def split: async_endpoint.splits endpoint.splits)
apply (drule (1) bspec)+
apply (clarsimp simp: ko_wp_at'_def refs_of_rev')
apply (drule (1) bspec)+
apply (clarsimp simp: ko_wp_at'_def refs_of_rev')
done
lemma aep_aep_disjoint:
assumes srs: "sym_refs (state_refs_of' s)"
and aepat: "ko_at' aep aepptr s"
and aepat': "ko_at' aep' aepptr' s"
and aepq: "isWaitingAEP aep"
and aepq': "isWaitingAEP aep'"
and neq: "aepptr' \<noteq> aepptr"
shows "set (aepQueue aep) \<inter> set (aepQueue aep') = {}"
using srs aepat aepat' aepq aepq' neq
apply -
apply (subst disjoint_iff_not_equal, intro ballI, rule notI)
apply (drule sym_refs_ko_atD', clarsimp)+
apply clarsimp
apply (clarsimp simp: isWaitingAEP_def split: async_endpoint.splits)
apply (drule (1) bspec)+
apply (clarsimp simp: ko_wp_at'_def refs_of_rev')
done
lemma tcb_queue_relation'_empty[simp]:
"tcb_queue_relation' getNext getPrev mp [] qhead qend =
(qend = tcb_Ptr 0 \<and> qhead = tcb_Ptr 0)"
by (simp add: tcb_queue_relation'_def)
lemma casync_endpoint_relation_aep_queue:
fixes aep :: "async_endpoint"
defines "qs \<equiv> if isWaitingAEP aep then set (aepQueue aep) else {}"
assumes aep: "casync_endpoint_relation (cslift t) aep' b"
and srs: "sym_refs (state_refs_of' s)"
and koat: "ko_at' aep aepptr s"
and koat': "ko_at' aep' aepptr' s"
and mpeq: "(cslift t' |` (- (tcb_ptr_to_ctcb_ptr ` qs))) = (cslift t |` (- (tcb_ptr_to_ctcb_ptr ` qs)))"
and neq: "aepptr' \<noteq> aepptr"