-
Notifications
You must be signed in to change notification settings - Fork 108
/
Noninterference_Base.thy
1326 lines (1129 loc) · 50 KB
/
Noninterference_Base.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 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: GPL-2.0-only
*)
theory Noninterference_Base
imports "Lib.Simulation"
begin
text \<open>
Toby's extended noninterference definitions to handle dynamic assignment,
that depends on the current state, of
the domain that each action is assigned to. This is the gory details
reported in the the CPP 2012 paper
\emph{Noninterference for Operating System Kernels}.
\<close>
section \<open>Generic systems\<close>
lemma un_eq:
"\<lbrakk> S = S'; T = T' \<rbrakk> \<Longrightarrow> S \<union> T = S' \<union> T'"
by auto
lemma Un_eq:
"\<lbrakk> \<And>x y. \<lbrakk> x \<in> xs; y \<in> ys \<rbrakk> \<Longrightarrow> P x = Q y; \<exists>x. x \<in> xs; \<exists>y. y \<in> ys \<rbrakk>
\<Longrightarrow> (\<Union>x \<in> xs. P x) = (\<Union>y \<in> ys. Q y)"
by auto
lemma Int_eq:
"\<lbrakk> \<And>x y. \<lbrakk> x \<in> xs; y \<in> ys \<rbrakk> \<Longrightarrow> P x = Q y; \<exists>x. x \<in> xs; \<exists>y. y \<in> ys \<rbrakk>
\<Longrightarrow> (\<Inter>x \<in> xs. P x) = (\<Inter>y \<in> ys. Q y)"
by auto
lemma Un_eq_Int:
assumes ex: "\<exists>x. x \<in> xs"
assumes ey: "\<exists>y. y \<in> ys"
assumes a: "\<And>x y. \<lbrakk> x \<in> xs; y \<in> ys \<rbrakk> \<Longrightarrow> S x = S' y"
shows "(\<Union>x \<in> xs. S x) = (\<Inter>x \<in> ys. S' x)"
apply (rule equalityI)
apply (clarsimp)
apply (drule a, assumption, simp)
apply clarsimp
apply (insert ex ey)
apply clarsimp
apply (frule a, assumption)
apply fastforce
done
subsection\<open>Run function\<close>
primrec Run :: "('e \<Rightarrow> ('s \<times> 's) set) \<Rightarrow> 'e list \<Rightarrow> ('s \<times> 's) set" where
"Run Stepf [] = Id"
| "Run Stepf (a#as) = Stepf a O Run Stepf as"
lemma Run_mid[rule_format]:
"(s,u) \<in> Run Stepf (as @ bs) \<longrightarrow> (\<exists>t. (s,t) \<in> Run Stepf as \<and> (t,u) \<in> Run Stepf bs)"
proof (induct as arbitrary: s u bs)
case Nil show ?case
by (clarsimp)
next
case (Cons a as) show ?case
apply (clarsimp simp: relcomp_def)
apply (drule "Cons.hyps"[rule_format])
apply fastforce
done
qed
lemma Run_trans:
"\<lbrakk> (s,t) \<in> Run Stepf as; (t,u) \<in> Run Stepf bs \<rbrakk>
\<Longrightarrow> (s,u) \<in> Run Stepf (as @ bs)"
by (induct as arbitrary: bs s t u) auto
lemma Run_app:
"Run Stepf (as @ bs) = (Run Stepf as) O (Run Stepf bs)"
apply (rule equalityI)
apply (fastforce dest: Run_mid)
apply (fastforce intro: Run_trans)
done
subsection \<open>Base system locale\<close>
text \<open>An ADT with an initial state.\<close>
locale system =
fixes A :: "('a,'s,'e) data_type"
and s0 :: "'s" (* an initial state *)
begin
(* State 's' is reachable from the initial state 's0'. *)
definition reachable where
"reachable s \<equiv> \<exists>js. s \<in> execution A s0 js"
definition Step where
"Step a \<equiv> {(s,s') . s' \<in> execution A s [a]}"
(* The system is "observationally deterministic": that is, the
* observable part of the system is always deterministic. *)
definition obs_det where
"obs_det \<equiv> \<forall>s js. (\<exists>s'. execution A s js = {s'})"
lemmas obs_detD = obs_det_def[THEN meta_eq_to_obj_eq, THEN iffD1, rule_format]
(* The abstraction/concretisation functions "Init"/"Fin"
* don't abstract away information. *)
definition no_abs where
"no_abs \<equiv> \<forall>x s as . reachable s
\<longrightarrow> x \<in> steps (Simulation.Step A) (Init A s) as
\<longrightarrow> Init A (Fin A x) = {x}"
lemmas no_absD = no_abs_def[THEN meta_eq_to_obj_eq, THEN iffD1, rule_format]
end
subsection \<open>Enabled system\<close>
text\<open>
A system that is always enabled.
In particular, the system will never be in deadlock, and there
is always an enabled transition from every reachable state.\<close>
locale enabled_system = system +
assumes enabled: "(\<exists>js. s \<in> execution A s0 js) \<Longrightarrow> \<exists>s'. s' \<in> execution A s js"
begin
lemma reachable_enabled:
"reachable s \<Longrightarrow> \<exists>s'. s' \<in> execution A s js"
apply (simp add: reachable_def)
apply (erule enabled)
done
lemma enabled_Step:
"reachable s \<Longrightarrow> \<exists>s'. (s,s') \<in> Step a"
by (simp add: Step_def, blast intro: reachable_enabled)
end
subsection \<open>Step system\<close>
text \<open>A Step system is a system for which a running
a sequence of events is equivalent to performing a sequence of individual
steps: one for each event in the sequence in turn. In other words
running [a,b,c,...] is the same than running [a] then running [b] then ...
This correspond to projecting to the observable state and deducing the real
state from that observable state on each event.
We define the unwinding conditions on this kind of system\<close>
locale Step_system = system A s0
for A :: "('a,'s,'e) data_type" and s0 :: "'s" +
assumes reachable_s0: "reachable s0"
assumes execution_Run: "reachable s \<Longrightarrow> execution A s as = {s'. (s,s') \<in> Run Step as}"
begin
lemma execution_Run':
"s \<in> execution A s0 js \<Longrightarrow> execution A s as = {s'. (s,s') \<in> Run Step as}"
apply (rule execution_Run)
apply (fastforce simp: reachable_def)
done
lemma reachable_Run:
"reachable s \<Longrightarrow> \<exists>as. (s0,s) \<in> Run Step as"
apply (clarsimp simp add: reachable_def)
apply (cut_tac as=js in execution_Run[OF reachable_s0])
apply blast
done
lemma Run_reachable:
"\<exists>as. (s0,s) \<in> Run Step as \<Longrightarrow> reachable s"
apply (clarsimp simp add: reachable_def)
apply (cut_tac as=as in execution_Run[OF reachable_s0])
apply blast
done
lemma reachable_execution:
"\<lbrakk> reachable s; s' \<in> execution A s js \<rbrakk> \<Longrightarrow> reachable s'"
apply (clarsimp simp: reachable_def)
apply (rule_tac x="jsa @ js" in exI)
apply (frule execution_Run'[where s=s and as=js])
apply (simp add: execution_Run[where s=s0, simplified reachable_s0])
apply (fastforce simp: Run_app)
done
lemma reachable_Step:
"\<lbrakk> reachable s; (s,s') \<in> Step a \<rbrakk> \<Longrightarrow> reachable s'"
apply (erule reachable_execution)
apply (simp add: Step_def)
done
lemma reachable_induct_helper:
assumes a: "\<And>s s' a. \<lbrakk> reachable s; P s; (s, s') \<in> Step a \<rbrakk> \<Longrightarrow> P s'"
shows "\<lbrakk> (s0, s1) \<in> Run Step as; P s0 \<rbrakk> \<Longrightarrow> P s1"
apply (induct as arbitrary: s1 rule: rev_induct)
apply simp
apply (fastforce dest: Run_mid intro: a Run_reachable)
done
lemma reachable_induct:
"\<lbrakk> \<And>s s' a. reachable s \<Longrightarrow> (s,s') \<in> (Step a) \<Longrightarrow> P s \<Longrightarrow> P s'; reachable s1; P s0 \<rbrakk>
\<Longrightarrow> P s1"
apply (drule reachable_Run)
apply (elim exE)
apply (rule reachable_induct_helper)
apply simp+
done
end
subsection \<open>Init Fin system\<close>
text \<open>An Init Fin system a stronger kind of Step system where know directly
that Fin and Init behave nicely as nearly "inverse" of each other which imply
that projecting to observable state then deducing the original state behave
as expected in Step system.
\<close>
locale Init_Fin_system = system A s0
for A :: "('a,'s,'e) data_type" and s0 :: "'s" +
assumes reachable_s0: "reachable s0"
assumes Fin_Init: "reachable s \<Longrightarrow> Fin A ` Init A s = {s}"
assumes Init_Fin: "\<lbrakk> reachable s; x \<in> steps (Simulation.Step A) (Init A s) as \<rbrakk>
\<Longrightarrow> x \<in> Init A (Fin A x)"
assumes obs_det_or_no_abs: "obs_det \<or> no_abs"
begin
lemma execution_subset_Run:
"reachable s \<Longrightarrow> execution A s as \<subseteq> {s'. (s,s') \<in> Run Step as}"
apply (induct as arbitrary: s rule: rev_induct)
apply (simp add: execution_def steps_def Fin_Init)
apply (simp add: execution_def steps_def)
apply (rule subsetI)
apply clarsimp
apply (rule Run_trans)
apply blast
apply (cut_tac x=xc and s=s and as=xs in Init_Fin, (simp add: steps_def)+)
apply (clarsimp simp: Step_def execution_def steps_def)
apply blast
done
lemma Run_subset_execution:
"\<lbrakk> no_abs; reachable s \<rbrakk> \<Longrightarrow> {s'. (s,s') \<in> Run Step as} \<subseteq> execution A s as"
apply (induct as arbitrary: s rule: rev_induct)
apply (simp add: execution_def steps_def Fin_Init)
apply (simp add: execution_def steps_def)
apply (rule subsetI)
apply clarsimp
apply (drule Run_mid)
apply clarsimp
apply (drule_tac x=s in meta_spec)
apply clarsimp
apply (drule_tac subsetD)
apply blast
apply (clarsimp simp: Image_def image_def Step_def execution_def steps_def)
apply (rule_tac x=xc in exI)
apply clarsimp
apply (rule_tac x=xd in bexI)
apply assumption
apply (drule_tac x=xb in no_absD)
apply (simp add: steps_def Image_def)+
done
lemma Run_det:
"obs_det \<Longrightarrow> \<exists>s'. {s'. (s,s') \<in> Run Step as} = {s'}"
apply (induct as arbitrary: s rule: rev_induct)
apply simp
apply (simp add: Run_app relcomp_def)
apply (drule_tac x=s in meta_spec)
apply clarsimp
apply (drule_tac s=s' and js="[x]" in obs_detD)
apply (clarsimp simp: Step_def)
apply (rule_tac x="s'a" in exI)
apply (auto dest: equalityD1)
done
lemma eq:
"\<lbrakk> S \<subseteq> T; \<exists>x. S = {x}; \<exists>y. T = {y} \<rbrakk> \<Longrightarrow> S = T"
by blast
lemma execution_Run:
"reachable s \<Longrightarrow> execution A s as = {s'. (s,s') \<in> Run Step as}"
apply (rule disjE[OF obs_det_or_no_abs])
apply (rule eq)
apply (erule execution_subset_Run)
apply (erule obs_detD)
apply (erule Run_det)
apply (rule equalityI)
apply (erule execution_subset_Run)
apply (erule (1) Run_subset_execution)
done
end
lemma Init_Fin_system_Step_system:
"Init_Fin_system A s0 \<Longrightarrow> Step_system A s0"
apply (unfold_locales)
apply (erule Init_Fin_system.reachable_s0)
apply (erule (1) Init_Fin_system.execution_Run)
done
sublocale Init_Fin_system \<subseteq> Step_system
apply (rule Init_Fin_system_Step_system)
apply (unfold_locales)
done
subsection \<open>Init inv Fin system\<close>
text \<open>Here we go one step further than the Init_Fin_system:
In this local Init and Fin are actually inverse of each other
Fin is injective
if s : range Fin A then Init A s = {s'} and Fin A s' = s else Init A s = {}.
The internal state space is thus just a restriction of the observable state space.
\<close>
(* when Init is the inverse image of Fin, the above assumptions are met by a system
for which Fin is injective, or one that appears deterministic to an observer *)
locale Init_inv_Fin_system = system A s0
for A :: "('a,'s,'e) data_type" and s0 :: "'s" +
assumes Fin_Init_s0: "s0 \<in> Fin A ` Init A s0"
assumes Init_inv_Fin: "reachable s \<Longrightarrow> Init A s = {s'. Fin A s' = s}"
assumes Fin_inj: "inj (Fin A)"
begin
lemma inv_and_inj: "reachable s \<Longrightarrow> Fin A i = s \<Longrightarrow> Init A s = {i}"
using Fin_inj Init_inv_Fin by (blast dest: injD)
lemma s0_reachable:
"reachable s0"
apply (simp add: reachable_def)
apply (rule_tac x="[]" in exI)
apply (simp add: execution_def steps_def)
using Fin_Init_s0 .
lemma foldl_foldl_Step:
"\<lbrakk> x \<in> foldl (\<lambda>S j. data_type.Step A j `` S) M as;
M \<subseteq> foldl (\<lambda>S j. data_type.Step A j `` S) B js \<rbrakk>
\<Longrightarrow> x \<in> foldl (\<lambda>S j. data_type.Step A j `` S) (foldl (\<lambda>S j. data_type.Step A j `` S) B js) as"
apply (induct as arbitrary: x M js B rule: rev_induct)
apply fastforce
apply simp
apply (erule ImageE)
apply (drule_tac x=xb in meta_spec)
apply (drule_tac x=M in meta_spec)
apply simp
apply (drule_tac x=js in meta_spec)
apply (drule_tac x=B in meta_spec, simp)
apply (blast)
done
lemma reachable_Fin:
"\<lbrakk> reachable s; x \<in> steps (Simulation.Step A) (Init A s) as \<rbrakk>
\<Longrightarrow> reachable (Fin A x)"
apply (cut_tac s=s in Init_inv_Fin, assumption)
apply (clarsimp simp: reachable_def execution_def steps_def)
apply (rule_tac x="js@as" in exI)
apply (rule imageI)
apply (subgoal_tac "{s'. Fin A s' = Fin A xa} = {xa}")
apply simp
apply (erule foldl_foldl_Step)
apply blast
apply (blast dest: injD[OF Fin_inj])
done
end
lemma Init_inv_Fin_system_Init_Fin_system:
"Init_inv_Fin_system A s0 \<Longrightarrow> Init_Fin_system A s0"
apply (unfold_locales)
apply (erule Init_inv_Fin_system.s0_reachable)
apply (simp add: Init_inv_Fin_system.Init_inv_Fin)
apply (simp add: image_def)
apply (fastforce simp: system.reachable_def execution_def)
apply (cut_tac s="Fin A x" in Init_inv_Fin_system.Init_inv_Fin)
apply assumption
apply (blast intro: Init_inv_Fin_system.reachable_Fin)
apply simp
apply (rule disjI2)
apply (clarsimp simp: system.no_abs_def)
apply (frule Init_inv_Fin_system.Fin_inj)
apply (cut_tac s="Fin A x" in Init_inv_Fin_system.Init_inv_Fin)
apply assumption
apply (blast intro: Init_inv_Fin_system.reachable_Fin)
apply simp
apply (fastforce dest: injD)
done
sublocale Init_inv_Fin_system \<subseteq> Init_Fin_system
apply (rule Init_inv_Fin_system_Init_Fin_system)
apply (unfold_locales)
done
section \<open>Non interference\<close>
subsection \<open>Policy\<close>
text\<open>This local represent an whole infoflow policy with the all the field needed
for defining non leakage, non interference and non influence\<close>
locale noninterference_policy =
fixes dom :: "'e \<Rightarrow> 's \<Rightarrow> 'd" (* dynamic dom assignment *)
fixes uwr :: "'d \<Rightarrow> ('s \<times> 's) set" (* unwinding relation *)
fixes policy :: "('d \<times> 'd) set" (* who can send info to whom *)
fixes out :: "'d \<Rightarrow> 's \<Rightarrow> 'p" (* observable parts of d in state s *)
fixes schedDomain :: "'d"
assumes uwr_equiv_rel: "equiv UNIV (uwr u)"
assumes schedIncludesCurrentDom:
"(s,t) \<in> uwr schedDomain \<Longrightarrow> dom e s = dom e t"
assumes schedFlowsToAll:
"(schedDomain,d) \<in> policy"
assumes schedNotGlobalChannel:
"(x,schedDomain) \<in> policy \<Longrightarrow> x = schedDomain"
begin
abbreviation uwr2 :: "'s \<Rightarrow> 'd \<Rightarrow> 's \<Rightarrow> bool" ("(_/ \<sim>_\<sim>/ _)" [50,100,50] 1000) where
"s \<sim>u\<sim> t \<equiv> (s,t) \<in> uwr u"
abbreviation policy2 :: "'d \<Rightarrow> 'd \<Rightarrow> bool" (infix "\<leadsto>" 50) where
"u \<leadsto> v \<equiv> (u,v) \<in> policy"
lemma uwr_refl:
"s \<sim>(u::'d)\<sim> s"
apply (cut_tac u=u in uwr_equiv_rel)
apply (clarsimp simp: equiv_def)
apply (blast dest: refl_onD)
done
lemma uwr_sym:
"x \<sim>(u::'d)\<sim> y \<Longrightarrow> y \<sim>u\<sim> x"
apply (cut_tac u=u in uwr_equiv_rel)
apply (clarsimp simp: equiv_def)
apply (blast dest: symD)
done
lemma uwr_trans:
"\<lbrakk> x \<sim>(u::'d)\<sim> y; y \<sim>u\<sim> z \<rbrakk> \<Longrightarrow> x \<sim>u\<sim> z"
apply (cut_tac u=u in uwr_equiv_rel)
apply (clarsimp simp: equiv_def)
apply (blast dest: transD)
done
definition sameFor_dom :: "'s \<Rightarrow> 'd set \<Rightarrow> 's \<Rightarrow> bool" ("(_/ \<approx>_\<approx>/ _)" [50,100,50] 1000) where
"s \<approx>us\<approx> t \<equiv> \<forall>u\<in>us. (s,t) \<in> uwr u"
lemma sameFor_subset_dom: "\<lbrakk>s \<approx>(x::'d set)\<approx> t; y \<subseteq> x\<rbrakk> \<Longrightarrow> s \<approx>y\<approx> t"
by (fastforce simp: sameFor_dom_def)
lemma sameFor_inter_domI: "s \<approx>(S::'d set)\<approx> t \<Longrightarrow> s \<approx>(S \<inter> B)\<approx> t"
by (auto simp: sameFor_dom_def)
lemma sameFor_sym_dom:
"s \<approx>(S::'d set)\<approx> t \<Longrightarrow> t \<approx>S\<approx> s"
by (auto simp: sameFor_dom_def uwr_sym)
end
subsection \<open>Non interference system\<close>
locale noninterference_system =
enabled_system A s0 + noninterference_policy dom uwr policy out schedDomain
for A :: "('a,'s,'e) data_type"
and s0 :: "'s"
and dom :: "'e \<Rightarrow> 's \<Rightarrow> 'd"
and uwr :: "'d \<Rightarrow> ('s \<times> 's) set"
and policy :: "('d \<times> 'd) set"
and out :: "'d \<Rightarrow> 's \<Rightarrow> 'p"
and schedDomain :: "'d"
begin
(* The set of domains (which carry out actions in the list "as") which
* may influence "u", assuming we start in state "s". *)
primrec sources :: "'e list \<Rightarrow> 's \<Rightarrow> 'd \<Rightarrow> 'd set" where
sources_Nil: "sources [] s u = {u}"
| sources_Cons: "sources (a#as) s u =
(\<Union>{sources as s' u| s'. (s,s') \<in> Step a}) \<union>
{w. w = dom a s \<and> (\<exists>v s'. dom a s \<leadsto> v \<and> (s,s') \<in> Step a \<and> v \<in> sources as s' u)}"
declare sources_Nil [simp del]
declare sources_Cons [simp del]
definition obs_equiv :: "'s \<Rightarrow> 'e list \<Rightarrow> 's \<Rightarrow> 'e list \<Rightarrow> 'd \<Rightarrow> bool" where
"obs_equiv s as t bs d \<equiv>
\<forall>s' t'. s' \<in> execution A s as \<and> t' \<in> execution A t bs \<longrightarrow> out d s' = out d t'"
definition uwr_equiv :: "'s \<Rightarrow> 'e list \<Rightarrow> 's \<Rightarrow> 'e list \<Rightarrow> 'd \<Rightarrow> bool" where
"uwr_equiv s as t bs d \<equiv>
\<forall>s' t'. s' \<in> execution A s as \<and> t' \<in> execution A t bs \<longrightarrow> s' \<sim>d\<sim> t'"
text \<open>Nonleakage\<close>
definition Nonleakage :: "bool" where
"Nonleakage \<equiv> \<forall>as s u t. reachable s \<and> reachable t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> obs_equiv s as t as u"
text \<open>A generalisation of Nonleakage.\<close>
definition Nonleakage_gen :: "bool" where
"Nonleakage_gen \<equiv>
\<forall>as s u t. reachable s \<and> reachable t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> uwr_equiv s as t as u"
lemma uwr_equiv_sym:
"uwr_equiv s as t bs u \<Longrightarrow> uwr_equiv t bs s as u"
by (fastforce simp: uwr_equiv_def uwr_sym)
lemma uwr_equiv_trans:
"\<lbrakk> reachable t; uwr_equiv s as t bs x; uwr_equiv t bs u cs x \<rbrakk>
\<Longrightarrow> uwr_equiv s as u cs x"
apply (clarsimp simp: uwr_equiv_def)
apply (cut_tac s=t and js=bs in reachable_enabled)
apply assumption
apply (blast intro: uwr_trans)
done
primrec gen_purge :: "('e list \<Rightarrow> 's \<Rightarrow> 'd \<Rightarrow> 'd set) \<Rightarrow> 'd \<Rightarrow> 'e list \<Rightarrow> 's set \<Rightarrow> 'e list" where
Nil: "gen_purge source_func u [] ss = []"
| Cons: "gen_purge source_func u (a#as) ss =
(if \<exists>s\<in>ss. dom a s \<in> source_func (a#as) s u
then a # gen_purge source_func u as (\<Union>s\<in>ss. {s'. (s,s') \<in> Step a})
else gen_purge source_func u as ss)"
definition ipurge where
"ipurge \<equiv> gen_purge sources"
lemma ipurge_Nil:
"ipurge u [] ss = []"
by (auto simp: ipurge_def)
lemma ipurge_Cons:
"ipurge u (a#as) ss = (if (\<exists>s\<in>ss. dom a s \<in> sources (a#as) s u)
then a#ipurge u as (\<Union>s\<in>ss. {s'. (s,s') \<in> Step a})
else ipurge u as ss)"
by (auto simp: ipurge_def)
lemma gen_purge_shortens:
"length (gen_purge sf u as ss) \<le> length as"
apply (induct as arbitrary: ss; clarsimp)
apply (rule le_trans)
apply assumption
apply simp
done
lemma INT_cong':
assumes a: "\<And>x. Q x \<Longrightarrow> P x = P' x"
shows "\<Inter>{P x|x. Q x} = \<Inter>{P' x|x. Q x}"
by (auto simp: a)
text \<open>Standard Noninterference\<close>
definition Noninterference :: bool where
"Noninterference \<equiv> \<forall>u as s. reachable s \<longrightarrow> (obs_equiv s as s (ipurge u as {s}) u)"
text \<open>Strong Noninterference\<close>
definition Noninterference_strong :: bool where
"Noninterference_strong \<equiv> \<forall>u as bs s. reachable s
\<longrightarrow> ipurge u as {s} = ipurge u bs {s}
\<longrightarrow> obs_equiv s as s bs u"
lemma obs_equiv_sym:
"obs_equiv s as t bs u \<Longrightarrow> obs_equiv t bs s as u"
by (clarsimp simp: obs_equiv_def)
lemma obs_equiv_trans:
"\<lbrakk> reachable t; obs_equiv s as t bs u; obs_equiv t bs x cs u \<rbrakk>
\<Longrightarrow> obs_equiv s as x cs u"
apply (clarsimp simp: obs_equiv_def)
apply (cut_tac s=t and js=bs in reachable_enabled, assumption, blast)
done
lemma Noninterference_Noninterference_strong:
"Noninterference \<Longrightarrow> Noninterference_strong"
apply (clarsimp simp: Noninterference_def Noninterference_strong_def)
apply (drule_tac x=u in spec)
apply (frule_tac x=as in spec, drule_tac x=s in spec)
apply (drule_tac x=bs in spec, drule_tac x=s in spec)
apply clarsimp
apply (rule obs_equiv_trans)
apply assumption
apply assumption
apply (erule obs_equiv_sym)
done
text \<open>
Noninfluence -- the combination of Noninterference and Nonleakage.
We add the assumption about equivalence wrt the scheduler's domain, as
is common in e.g. GVW.
\<close>
definition Noninfluence :: bool where
"Noninfluence \<equiv>
\<forall>u as s t. reachable s \<and> reachable t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> obs_equiv s as t (ipurge u as {t}) u"
definition Noninfluence_strong :: "bool"
where
"Noninfluence_strong \<equiv> \<forall>u as bs s t. reachable s \<and> reachable t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> ipurge u as {s} = ipurge u bs {s}
\<longrightarrow> obs_equiv s as t bs u"
lemma notin_policyI:
"\<lbrakk> dom a s \<notin> sources (a # list) s u; \<exists>s'. (s,s') \<in> Step a \<and> ua \<in> sources list s' u \<rbrakk>
\<Longrightarrow> (dom a s,ua) \<notin> policy"
by (clarsimp simp: sources_Cons)
lemma Noninfluence_strong_Noninterference_strong:
"Noninfluence_strong \<Longrightarrow> Noninterference_strong"
apply (clarsimp simp: Noninfluence_strong_def Noninterference_strong_def)
apply (drule_tac x=u in spec, drule_tac x=as in spec, drule_tac x=bs in spec)
apply (fastforce simp: sameFor_dom_def uwr_refl)
done
lemma Noninfluence_strong_Nonleakage:
"Noninfluence_strong \<Longrightarrow> Nonleakage"
by (clarsimp simp: Noninfluence_strong_def Nonleakage_def)
text \<open>This stronger condition is needed
to make the induction proof work for Noninterference. It can be viewed
as a generalisation of Noninfluence; hence its name here.
\<close>
definition Noninfluence_gen :: bool where
"Noninfluence_gen \<equiv> \<forall>u as s ts. reachable s \<and> (\<forall>t \<in> ts. reachable t)
\<longrightarrow> (\<forall>t \<in> ts. s \<approx>(sources as s u)\<approx> t)
\<longrightarrow> (\<forall>t \<in> ts. s \<sim>schedDomain\<sim> t)
\<longrightarrow> (\<forall>t \<in> ts. uwr_equiv s as t (ipurge u as ts) u)"
definition Noninfluence_uwr :: bool where
"Noninfluence_uwr \<equiv> \<forall>u as s t. reachable s \<and> reachable t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> uwr_equiv s as t (ipurge u as {t}) u"
definition Noninfluence_strong_uwr :: bool where
"Noninfluence_strong_uwr \<equiv> \<forall>u as bs s t. reachable s \<and> reachable t
\<longrightarrow> s \<approx>(sources as s u)\<approx> t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> ipurge u as {s} = ipurge u bs {s}
\<longrightarrow> uwr_equiv s as t bs u"
definition output_consistent :: bool where
"output_consistent \<equiv> \<forall>u s s'. s \<sim>u\<sim> s' \<longrightarrow> (out u s = out u s')"
definition confidentiality_u :: bool where
"confidentiality_u \<equiv> \<forall>a u s t. reachable s \<and> reachable t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> ((dom a s \<leadsto> u) \<longrightarrow> s \<sim>dom a s\<sim> t)
\<longrightarrow> s \<sim>u\<sim> t
\<longrightarrow> (\<forall>s' t'. (s,s') \<in> Step a \<and> (t,t') \<in> Step a \<longrightarrow> s' \<sim>u\<sim> t')"
lemma no_domain_visible_nondeterminism:
"\<lbrakk> confidentiality_u; reachable s; (s,s') \<in> Step a; (s,s'') \<in> Step a \<rbrakk>
\<Longrightarrow> s' \<sim>d\<sim> s''"
apply (clarsimp simp: confidentiality_u_def)
apply (fastforce intro: uwr_refl)
done
definition integrity_u :: bool where
"integrity_u \<equiv>
\<forall>a u s. reachable s \<longrightarrow> (dom a s,u) \<notin> policy \<longrightarrow> (\<forall>s'. (s,s') \<in> Step a \<longrightarrow> s \<sim>u\<sim> s')"
(*<*)
(* integrity_u actually guarantees this (seemingly) stronger condition *)
definition integrity_u_more :: bool where
"integrity_u_more \<equiv> \<forall>a u s. reachable s
\<longrightarrow> (dom a s,u) \<notin> policy
\<longrightarrow> (\<forall>s' t. s \<sim>u\<sim> t \<and> (s,s') \<in> Step a \<longrightarrow> s' \<sim>u\<sim> t)"
lemma integrity_u_more:
"integrity_u \<Longrightarrow> integrity_u_more"
apply (clarsimp simp: integrity_u_more_def integrity_u_def)
apply (blast dest: uwr_sym uwr_trans)
done
(*>*)
lemma integrity_uD:
"\<lbrakk> integrity_u; reachable s; (dom a s,u) \<notin> policy; s \<sim>u\<sim> t; (s,s') \<in> Step a \<rbrakk>
\<Longrightarrow> s' \<sim>u\<sim> t"
apply (drule integrity_u_more)
apply (simp add: integrity_u_more_def)
done
text \<open>
A weaker version of @{prop confidentiality_u} that, with
@{prop integrity_u}, implies it.
\<close>
definition confidentiality_u_weak where
"confidentiality_u_weak \<equiv> \<forall>a u s t. reachable s \<and> reachable t
\<longrightarrow> s \<sim>schedDomain\<sim> t
\<longrightarrow> dom a s \<leadsto> u
\<longrightarrow> s \<sim>(dom a s)\<sim> t
\<longrightarrow> s \<sim>u\<sim> t
\<longrightarrow> (\<forall>s' t'. (s,s') \<in> Step a \<and> (t,t') \<in> Step a
\<longrightarrow> s' \<sim>u\<sim> t')"
lemma confidentiality_u_confidentiality_u_weak:
"confidentiality_u \<Longrightarrow> confidentiality_u_weak"
apply (simp add: confidentiality_u_def confidentiality_u_weak_def)
apply blast
done
lemma impCE':
"\<lbrakk> P \<longrightarrow> Q; \<lbrakk>P; Q\<rbrakk> \<Longrightarrow> R; \<not> P \<Longrightarrow> R \<rbrakk> \<Longrightarrow> R"
by auto
lemma confidentiality_u_weak:
"\<lbrakk> confidentiality_u_weak; integrity_u \<rbrakk>
\<Longrightarrow> confidentiality_u"
apply (clarsimp simp: confidentiality_u_def)
apply (erule impCE')
apply (subst (asm) confidentiality_u_weak_def, blast)
apply (frule integrity_uD, simp+)
apply (drule_tac s=t and t="s'" in integrity_uD)
apply assumption
apply (drule_tac e=a in schedIncludesCurrentDom)
apply simp
apply (blast intro: uwr_sym)
apply assumption
apply (erule uwr_sym)
done
lemma obs_equivI:
"\<lbrakk> output_consistent; uwr_equiv s as t bs ob \<rbrakk> \<Longrightarrow> obs_equiv s as t bs ob"
apply (clarsimp simp: obs_equiv_def)
apply (auto simp: uwr_equiv_def output_consistent_def)
done
lemma Noninfluence_uwr_Noninfluence:
"\<lbrakk> output_consistent; Noninfluence_uwr \<rbrakk> \<Longrightarrow> Noninfluence"
apply (clarsimp simp: Noninfluence_def)
apply (erule obs_equivI)
apply (auto simp: Noninfluence_uwr_def)
done
lemma Noninfluence_strong_uwr_Noninfluence_strong:
"\<lbrakk> output_consistent; Noninfluence_strong_uwr \<rbrakk> \<Longrightarrow> Noninfluence_strong"
apply (clarsimp simp: Noninfluence_strong_def)
apply (erule obs_equivI)
apply (auto simp: Noninfluence_strong_uwr_def)
done
lemma sched_equiv_preserved:
"\<lbrakk> confidentiality_u; reachable s; reachable t;
s \<sim>schedDomain\<sim> t; (s,s') \<in> Step a; (t,t') \<in> Step a \<rbrakk>
\<Longrightarrow> s' \<sim>schedDomain\<sim> t'"
apply (case_tac "dom a s = schedDomain")
apply (subst (asm) confidentiality_u_def)
apply (drule_tac x=a in spec)
apply (drule_tac x=schedDomain in spec)
apply (drule_tac x=s in spec)
apply (drule_tac x=t in spec)
apply simp
apply (subst (asm) confidentiality_u_def)
apply (blast intro: schedNotGlobalChannel)
done
lemma sched_equiv_preserved_left:
"\<lbrakk> integrity_u; s \<sim>schedDomain\<sim> t;
dom a s \<noteq> schedDomain; (s,s') \<in> Step a; reachable s \<rbrakk>
\<Longrightarrow> s' \<sim>schedDomain\<sim> t"
by (blast intro: integrity_uD schedNotGlobalChannel)
lemma Noninfluence_gen_Noninterference:
"\<lbrakk> output_consistent; Noninfluence_gen \<rbrakk> \<Longrightarrow> Noninterference"
apply (clarsimp simp: Noninterference_def Noninfluence_gen_def)
apply (erule_tac x=u in allE)
apply (erule_tac x=as in allE)
apply (erule_tac x=s in allE)
apply (erule_tac x="{s}" in allE)
apply (clarsimp simp: sameFor_dom_def uwr_refl)
apply (blast intro: obs_equivI)
done
lemma Noninfluence_gen_Noninfluence:
"\<lbrakk> output_consistent; Noninfluence_gen \<rbrakk> \<Longrightarrow> Noninfluence"
apply (clarsimp simp: Noninfluence_def Noninfluence_gen_def)
apply (erule_tac x=u in allE)
apply (erule_tac x=as in allE)
apply (erule_tac x=s in allE)
apply (erule_tac x="{t}" in allE)
apply (blast intro: obs_equivI)
done
lemma Noninfluence_gen_Noninfluence_uwr:
"Noninfluence_gen \<Longrightarrow> Noninfluence_uwr"
by (clarsimp simp: Noninfluence_uwr_def Noninfluence_gen_def)
lemma Noninfluence_gen_Noninterference_strong:
"\<lbrakk> output_consistent; Noninfluence_gen \<rbrakk> \<Longrightarrow> Noninterference_strong"
apply (rule Noninterference_Noninterference_strong)
apply (blast intro: Noninfluence_gen_Noninterference)
done
end
subsection \<open>Noninterference on enabled Step system : unwinding system\<close>
locale enabled_Step_system = enabled_system A s0 + Step_system A s0
for A :: "('a,'s,'e) data_type" and s0 :: "'s"
(* we define the unwinding conditions for any system *)
locale unwinding_system =
enabled_Step_system A s0 + noninterference_policy dom uwr policy out schedDomain
for A :: "('a,'s,'e) data_type"
and s0 :: "'s"
and dom :: "'e \<Rightarrow> 's \<Rightarrow> 'd"
and uwr :: "'d \<Rightarrow> ('s \<times> 's) set"
and policy :: "('d \<times> 'd) set"
and out :: "'d \<Rightarrow> 's \<Rightarrow> 'p"
and schedDomain :: "'d"
sublocale unwinding_system \<subseteq> noninterference_system by unfold_locales
context unwinding_system begin
lemma sources_refl:
"reachable s \<Longrightarrow> u \<in> sources as s u"
apply (induct as arbitrary: s)
apply (simp add: sources_Nil)
apply (simp add: sources_Cons)
apply (frule_tac a=a in enabled_Step)
apply (auto simp: reachable_Step)
done
lemma schedDomain_in_sources_Cons:
"\<lbrakk> reachable s; dom a s = schedDomain \<rbrakk>
\<Longrightarrow> dom a s \<in> sources (a#as) s u"
apply (unfold sources_Cons)
apply (erule ssubst)
apply (rule UnI2)
apply (clarsimp)
apply (rule_tac x=u in exI)
apply (safe)
apply (rule schedFlowsToAll)
apply (frule_tac a=a in enabled_Step)
apply (fastforce dest: sources_refl reachable_Step)
done
lemma sources_eq':
"confidentiality_u \<and> s \<sim>schedDomain\<sim> t \<and> reachable s \<and> reachable t
\<longrightarrow> sources as s u = sources as t u"
proof (induct as arbitrary: s t)
case Nil show ?case
by (simp add: sources_Nil)
next
case (Cons a as) show ?case
apply (clarsimp simp: sources_Cons)
apply (rule un_eq)
apply (simp only: Union_eq, simp only: UNION_eq[symmetric])
apply (rule Un_eq, clarsimp)
apply (metis "Cons.hyps"[rule_format] sched_equiv_preserved reachable_Step)
apply (fastforce intro: enabled_Step)
apply (fastforce intro: enabled_Step)
apply (clarsimp simp: schedIncludesCurrentDom)
apply (rule Collect_cong)
apply (rule conj_cong, rule refl)
apply (rule iff_exI)
apply (metis "Cons.hyps"[rule_format] sched_equiv_preserved reachable_Step enabled_Step)
done
qed
lemma sources_eq:
"\<lbrakk> confidentiality_u; s \<sim>schedDomain\<sim> t; reachable s; reachable t \<rbrakk>
\<Longrightarrow> sources as s u = sources as t u"
by (rule sources_eq'[rule_format], simp)
lemma sameFor_sources_dom:
"\<lbrakk> s \<approx>(sources (a#as) s u)\<approx> t; dom a s \<leadsto> x; x \<in> sources as s' u; (s,s') \<in> Step a \<rbrakk>
\<Longrightarrow> s \<sim>(dom a s)\<sim> t"
apply (simp add: sameFor_dom_def)
apply (erule bspec)
apply (subst sources_Cons)
apply (rule UnI2)
apply blast
done
lemma sources_unwinding_step:
"\<lbrakk> s \<approx>(sources (a#as) s u)\<approx> t; s \<sim>schedDomain\<sim> t; confidentiality_u;
(s,s') \<in> Step a; (t,t') \<in> Step a; reachable s; reachable t \<rbrakk>
\<Longrightarrow> s' \<approx>(sources as s' u)\<approx> t'"
apply (clarsimp simp: sameFor_dom_def sources_Cons)
apply (subst (asm) confidentiality_u_def)
apply (drule_tac x=a in spec)
apply (drule_tac x=ua in spec)
apply (drule_tac x=s in spec)
apply (drule_tac x=t in spec)
apply (fastforce intro: sameFor_sources_dom)
done
lemma ipurge_eq'_helper:
"\<lbrakk> s \<in> ss; dom a s \<in> sources (a # as) s u; \<forall>s\<in>ts. dom a s \<notin> sources (a # as) s u;
(\<forall>s t. s \<in> ss \<and> t \<in> ts \<longrightarrow> s \<sim>schedDomain\<sim> t \<and> reachable s \<and> reachable t);
t \<in> ts; confidentiality_u \<rbrakk>
\<Longrightarrow> False"
apply (cut_tac s=s and t=t and as=as and u=u in sources_eq, simp+)
apply (clarsimp simp: sources_Cons | safe)+
apply (rename_tac s')
apply (drule_tac x=t in bspec, simp)
apply clarsimp
apply (cut_tac s=t in enabled_Step, simp)
apply (erule exE, rename_tac t')
apply (drule_tac x="sources as t' u" in spec)
apply (cut_tac s=s' and t=t' and u=u in sources_eq, simp+)
apply (fastforce elim: sched_equiv_preserved)
apply (fastforce intro: reachable_Step)
apply (fastforce intro: reachable_Step)
apply (fastforce simp: schedIncludesCurrentDom)
apply (drule_tac x=t in bspec, simp)
apply clarsimp
apply (rename_tac v s')
apply (drule_tac x=v in spec, erule impE, fastforce simp: schedIncludesCurrentDom)
apply (cut_tac s=t in enabled_Step[where a=a], simp, clarsimp, rename_tac t')
apply (cut_tac s=s' and t=t' and u=u in sources_eq, simp+)
apply (fastforce elim: sched_equiv_preserved)
apply (fastforce intro: reachable_Step)
apply (fastforce intro: reachable_Step)
apply (fastforce simp: schedIncludesCurrentDom)
done
lemma ipurge_eq':
"(\<forall>s t. s\<in>ss \<and> t\<in>ts \<longrightarrow> s \<sim>schedDomain\<sim> t \<and> reachable s \<and> reachable t) \<and>
(\<exists>s. s \<in> ss) \<and> (\<exists>t. t \<in> ts) \<and> confidentiality_u
\<longrightarrow> ipurge u as ss = ipurge u as ts"
proof (induct as arbitrary: ss ts)
case Nil show ?case
apply (simp add: ipurge_def)
done
next
case (Cons a as) show ?case
apply (clarsimp simp: ipurge_Cons schedIncludesCurrentDom)
apply (intro conjI impI)
apply (rule "Cons.hyps"[rule_format])
apply clarsimp
apply (metis sched_equiv_preserved reachable_Step enabled_Step)
apply clarsimp
apply (drule ipurge_eq'_helper, simp+)[1]
apply clarsimp
apply (drule ipurge_eq'_helper, (simp add: uwr_sym)+)[1]
apply (rule "Cons.hyps"[rule_format], auto)
done
qed
lemma ipurge_eq:
"\<lbrakk> s \<sim>schedDomain\<sim> t; reachable s; reachable t; confidentiality_u \<rbrakk>
\<Longrightarrow> ipurge u as {s} = ipurge u as {t}"
by (rule ipurge_eq'[rule_format], simp)
lemma Noninfluence_uwr_Noninfluence_strong_uwr:
"\<lbrakk> confidentiality_u; Noninfluence_uwr \<rbrakk> \<Longrightarrow> Noninfluence_strong_uwr"
apply (clarsimp simp: Noninfluence_uwr_def Noninfluence_strong_uwr_def)
apply (frule_tac s=s and t=t and as=as and u=u in ipurge_eq)
apply assumption+
apply (frule_tac s=s and t=t and as=bs and u=u in ipurge_eq)
apply assumption+
apply clarsimp
apply (drule_tac x=u in spec)
apply (frule_tac x=as in spec)
apply (drule_tac x=s in spec, drule_tac x=t in spec)
apply (drule_tac x=bs in spec)
apply (drule_tac x=t in spec, drule_tac x=t in spec)
apply clarsimp
apply (rule_tac t=t in uwr_equiv_trans)
apply assumption
apply assumption
apply (rule uwr_equiv_sym)
apply (clarsimp simp: sameFor_dom_def uwr_refl)
done
lemma Noninfluence_Noninfluence_strong:
"\<lbrakk> confidentiality_u; Noninfluence \<rbrakk> \<Longrightarrow> Noninfluence_strong"
apply (clarsimp simp: Noninfluence_def Noninfluence_strong_def)
apply (frule_tac s=s and t=t and as=as and u=u in ipurge_eq)
apply assumption+
apply (frule_tac s=s and t=t and as=bs and u=u in ipurge_eq)
apply assumption+
apply clarsimp
apply (drule_tac x=u in spec)
apply (frule_tac x=as in spec)
apply (drule_tac x=s in spec, drule_tac x=t in spec)