author | chunhan |
Thu, 09 Jan 2014 22:53:45 +0800 | |
changeset 94 | 042e1e7fd505 |
parent 93 | dfde07c7cd6b |
child 95 | b7fd75d104bf |
permissions | -rw-r--r-- |
77 | 1 |
theory Enrich |
2 |
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2 |
|
3 |
Temp |
|
4 |
begin |
|
5 |
||
89 | 6 |
(* enriched objects, closely related to static objects, so are only 3 kinds *) |
78 | 7 |
datatype t_enrich_obj = |
89 | 8 |
E_proc "t_process" "t_msgq" "t_msgq" |
9 |
| E_file "t_file" "nat" |
|
94 | 10 |
| E_file_link "t_file" |
78 | 11 |
| E_msgq "t_msgq" |
89 | 12 |
|
13 |
(* objects that need dynamic indexing, all nature-numbers *) |
|
14 |
datatype t_index_obj = |
|
15 |
I_proc "t_process" |
|
16 |
| I_file "t_file" |
|
17 |
| I_fd "t_process" "t_fd" |
|
18 |
| I_inum "nat" |
|
19 |
| I_msgq "t_msgq" |
|
20 |
| I_msg "t_msgq" "t_msg" |
|
78 | 21 |
|
77 | 22 |
context tainting_s begin |
23 |
||
83 | 24 |
fun no_del_event:: "t_event list \<Rightarrow> bool" |
25 |
where |
|
26 |
"no_del_event [] = True" |
|
27 |
| "no_del_event (Kill p p' # \<tau>) = False" |
|
28 |
| "no_del_event (Exit p # s) = False" |
|
29 |
| "no_del_event (CloseFd p fd # \<tau>) = False" |
|
30 |
| "no_del_event (UnLink p f # \<tau>) = False" |
|
31 |
| "no_del_event (Rmdir p f # \<tau>) = False" |
|
32 |
(* |
|
33 |
| "no_del_event (Rename p f f' # \<tau>) = False" |
|
34 |
*) |
|
35 |
| "no_del_event (RemoveMsgq p q # \<tau>) = False" |
|
36 |
(* |
|
37 |
| "no_del_event (RecvMsg p q m # \<tau>) = False" |
|
38 |
*) |
|
39 |
| "no_del_event (_ # \<tau>) = no_del_event \<tau>" |
|
40 |
||
93 | 41 |
(* |
83 | 42 |
fun all_inums :: "t_state \<Rightarrow> t_inode_num set" |
43 |
where |
|
44 |
"all_inums [] = current_inode_nums []" |
|
45 |
| "all_inums (Open p f flags fd opt # s) = ( |
|
46 |
case opt of |
|
47 |
None \<Rightarrow> all_inums s |
|
48 |
| Some i \<Rightarrow> all_inums s \<union> {i} )" |
|
49 |
| "all_inums (Mkdir p f i # s) = (all_inums s \<union> {i})" |
|
50 |
| "all_inums (CreateSock p af st fd i # s) = (all_inums s \<union> {i})" |
|
51 |
| "all_inums (Accept p fd addr lport fd' i # s) = (all_inums s \<union> {i})" |
|
52 |
| "all_inums (_ # s) = all_inums s" |
|
53 |
||
54 |
fun all_fds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd set" |
|
55 |
where |
|
56 |
"all_fds [] = init_fds_of_proc" |
|
57 |
| "all_fds (Open p f flags fd ipt # s) = (all_fds s) (p := all_fds s p \<union> {fd})" |
|
58 |
| "all_fds (CreateSock p sf st fd i # s) = (all_fds s) (p := all_fds s p \<union> {fd})" |
|
59 |
| "all_fds (Accept p fd' raddr port fd i # s) = (all_fds s) (p := all_fds s p \<union> {fd})" |
|
60 |
| "all_fds (Clone p p' fds # s) = (all_fds s) (p' := fds)" |
|
61 |
| "all_fds (_ # s) = all_fds s" |
|
62 |
||
63 |
fun all_msgqs:: "t_state \<Rightarrow> t_msgq set" |
|
64 |
where |
|
88 | 65 |
"all_msgqs [] = {}" |
83 | 66 |
| "all_msgqs (CreateMsgq p q # s) = all_msgqs s \<union> {q}" |
67 |
| "all_msgqs (e # s) = all_msgqs s" |
|
93 | 68 |
*) |
83 | 69 |
|
70 |
fun all_msgs:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg set" |
|
71 |
where |
|
88 | 72 |
"all_msgs [] q = {}" |
83 | 73 |
| "all_msgs (CreateMsgq p q # s) q' = (if q' = q then {} else all_msgs s q')" |
74 |
| "all_msgs (SendMsg p q m # s) q' = (if q' = q then all_msgs s q \<union> {m} else all_msgs s q')" |
|
75 |
| "all_msgs (_ # s) q' = all_msgs s q'" |
|
76 |
||
77 |
fun all_files:: "t_state \<Rightarrow> t_file set" |
|
78 |
where |
|
79 |
"all_files [] = init_files " |
|
80 |
| "all_files (Open p f flags fd opt # s) = (if opt = None then all_files s else (all_files s \<union> {f}))" |
|
81 |
| "all_files (Mkdir p f inum # s) = all_files s \<union> {f}" |
|
82 |
| "all_files (LinkHard p f f' # s) = all_files s \<union> {f'}" |
|
83 |
| "all_files (e # s) = all_files s" |
|
84 |
||
89 | 85 |
(* |
83 | 86 |
fun notin_all:: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> bool" |
87 |
where |
|
88 |
"notin_all s (E_proc p) = (p \<notin> all_procs s)" |
|
89 |
| "notin_all s (E_file f) = (f \<notin> all_files s \<and> (\<exists> pf. parent f = Some pf \<and> is_dir s pf))" |
|
90 |
| "notin_all s (E_fd p fd) = (fd \<notin> all_fds s p)" |
|
91 |
| "notin_all s (E_inum i) = (i \<notin> all_inums s)" |
|
92 |
| "notin_all s (E_msgq q) = (q \<notin> all_msgqs s)" |
|
93 |
| "notin_all s (E_msg q m) = (m \<notin> all_msgs s q)" |
|
89 | 94 |
*) |
95 |
||
96 |
fun nums_of_recvmsg:: "t_state \<Rightarrow> t_process \<Rightarrow> nat" |
|
97 |
where |
|
98 |
"nums_of_recvmsg [] p' = 0" |
|
99 |
| "nums_of_recvmsg (RecvMsg p q m # s) p' = |
|
100 |
(if p' = p then Suc (nums_of_recvmsg s p) else nums_of_recvmsg s p')" |
|
101 |
| "nums_of_recvmsg (e # s) p' = nums_of_recvmsg s p'" |
|
102 |
||
103 |
lemma nums_of_recv_0: |
|
104 |
"\<lbrakk>p \<notin> current_procs s; no_del_event s; valid s\<rbrakk> \<Longrightarrow> nums_of_recvmsg s p = 0" |
|
105 |
apply (induct s, simp) |
|
106 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
107 |
apply (auto) |
|
108 |
done |
|
109 |
||
110 |
lemma new_msgq_1: |
|
111 |
"\<lbrakk>new_msgq s \<le> q; q \<le> new_msgq s - Suc 0\<rbrakk> \<Longrightarrow> False" |
|
112 |
apply (subgoal_tac "new_msgq s \<noteq> 0") |
|
113 |
apply (simp, simp add:new_msgq_def next_nat_def) |
|
114 |
done |
|
115 |
||
116 |
fun notin_cur:: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> bool" |
|
117 |
where |
|
118 |
"notin_cur s (E_proc p qmin qmax) = |
|
119 |
(p \<notin> current_procs s \<and> qmin = new_msgq s \<and> qmax = new_msgq s + (nums_of_recvmsg s p) - 1)" |
|
120 |
| "notin_cur s (E_file f inum) = |
|
121 |
(f \<notin> current_files s \<and> (\<exists> pf. parent f = Some pf \<and> is_dir s pf) \<and> inum \<notin> current_inode_nums s)" |
|
122 |
| "notin_cur s (E_file_link f) = |
|
123 |
(f \<notin> current_files s \<and> (\<exists> pf. parent f = Some pf \<and> is_dir s pf))" |
|
124 |
| "notin_cur s (E_msgq q) = (q \<notin> current_msgqs s)" |
|
83 | 125 |
|
93 | 126 |
(* |
83 | 127 |
lemma not_all_procs_cons: |
128 |
"p \<notin> all_procs (e # s) \<Longrightarrow> p \<notin> all_procs s" |
|
129 |
by (case_tac e, auto) |
|
130 |
||
131 |
lemma not_all_procs_prop: |
|
132 |
"\<lbrakk>p' \<notin> all_procs s; p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> p' \<noteq> p" |
|
133 |
apply (induct s, rule notI, simp) |
|
134 |
apply (frule vt_grant_os, frule vd_cons, frule not_all_procs_cons, simp, rule notI) |
|
135 |
apply (case_tac a, auto) |
|
136 |
done |
|
137 |
||
138 |
lemma not_all_procs_prop2: |
|
139 |
"p' \<notin> all_procs s \<Longrightarrow> p' \<notin> init_procs" |
|
140 |
apply (induct s, simp) |
|
141 |
by (case_tac a, auto) |
|
142 |
||
143 |
lemma not_all_procs_prop3: |
|
144 |
"p' \<notin> all_procs s \<Longrightarrow> p' \<notin> current_procs s" |
|
145 |
apply (induct s, simp) |
|
146 |
by (case_tac a, auto) |
|
93 | 147 |
*) |
148 |
(* |
|
84
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
149 |
lemma not_all_msgqs_cons: |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
150 |
"p \<notin> all_msgqs (e # s) \<Longrightarrow> p \<notin> all_msgqs s" |
93 | 151 |
apply (case_tac e, auto) |
84
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
152 |
|
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
153 |
lemma not_all_msgqs_prop: |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
154 |
"\<lbrakk>p' \<notin> all_msgqs s; p \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> p' \<noteq> p" |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
155 |
apply (induct s, rule notI, simp) |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
156 |
apply (frule vt_grant_os, frule vd_cons, frule not_all_msgqs_cons, simp, rule notI) |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
157 |
apply (case_tac a, auto) |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
158 |
done |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
159 |
|
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
160 |
lemma not_all_msgqs_prop3: |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
161 |
"p' \<notin> all_msgqs s \<Longrightarrow> p' \<notin> current_msgqs s" |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
162 |
apply (induct s, simp) |
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
163 |
by (case_tac a, auto) |
93 | 164 |
*) |
165 |
||
89 | 166 |
fun enrich_not_alive :: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> t_index_obj \<Rightarrow> bool" |
83 | 167 |
where |
89 | 168 |
"enrich_not_alive s obj (I_file f) = |
169 |
(f \<notin> current_files s \<and> (\<forall> inum. obj \<noteq> E_file f inum) \<and> obj \<noteq> E_file_link f)" |
|
170 |
| "enrich_not_alive s obj (I_proc p) = (p \<notin> current_procs s \<and> (\<forall> qmin qmax. obj \<noteq> E_proc p qmin qmax))" |
|
171 |
| "enrich_not_alive s obj (I_fd p fd) = |
|
172 |
((p \<in> current_procs s \<longrightarrow> fd \<notin> current_proc_fds s p) \<and> (\<forall> qmin qmax. obj \<noteq> E_proc p qmin qmax))" |
|
173 |
| "enrich_not_alive s obj (I_msgq q) = (q \<notin> current_msgqs s \<and> obj \<noteq> E_msgq q \<and> |
|
174 |
(case obj of |
|
175 |
E_proc p qmin qmax \<Rightarrow> \<not> (q \<ge> qmin \<and> q \<le> qmax) |
|
176 |
| _ \<Rightarrow> True) )" |
|
177 |
| "enrich_not_alive s obj (I_inum i) = (i \<notin> current_inode_nums s \<and> (\<forall> f. obj \<noteq> E_file f i))" |
|
178 |
| "enrich_not_alive s obj (I_msg q m) = |
|
179 |
((q \<in> current_msgqs s \<longrightarrow> m \<notin> set (msgs_of_queue s q)) \<and> obj \<noteq> E_msgq q \<and> |
|
180 |
(case obj of |
|
181 |
E_proc p qmin qmax \<Rightarrow> \<not> (q \<ge> qmin \<and> q \<le> qmax) |
|
182 |
| _ \<Rightarrow> True) )" |
|
83 | 183 |
|
184 |
lemma file_has_parent: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> pf. is_dir s pf \<and> parent f = Some pf" |
|
185 |
apply (case_tac f) |
|
186 |
apply (simp, drule root_is_dir', simp+) |
|
187 |
apply (simp add:parentf_is_dir_prop2) |
|
188 |
done |
|
189 |
||
77 | 190 |
lemma enrich_search_check: |
191 |
assumes grant: "search_check s (up, rp, tp) f" |
|
192 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f" |
|
193 |
and vd: "valid s" and f_in: "is_file s f" and f_in': "is_file s' f" |
|
194 |
and sec: "sectxt_of_obj s' (O_file f) = sectxt_of_obj s (O_file f)" |
|
195 |
shows "search_check s' (up, rp, tp) f" |
|
196 |
proof (cases f) |
|
197 |
case Nil |
|
198 |
with f_in vd have "False" |
|
199 |
by (auto dest:root_is_dir') |
|
200 |
thus ?thesis by simp |
|
201 |
next |
|
202 |
case (Cons n pf) |
|
203 |
from vd f_in obtain sf where sf: "cf2sfile s f = Some sf" |
|
204 |
apply (drule_tac is_file_in_current, drule_tac current_file_has_sfile, simp) |
|
205 |
apply (erule exE, simp) |
|
206 |
done |
|
207 |
then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons |
|
208 |
by (auto simp:cf2sfile_def split:option.splits if_splits) |
|
209 |
from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_file_in_current) |
|
210 |
then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons |
|
211 |
by (auto simp:cf2sfile_def split:option.splits if_splits) |
|
212 |
with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in' |
|
213 |
apply (simp add:cf2sfile_def split:option.splits) |
|
214 |
apply (case_tac sf, simp) |
|
215 |
done |
|
216 |
show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec |
|
217 |
apply (simp add:Cons split:option.splits) |
|
218 |
by (case_tac a, simp) |
|
219 |
qed |
|
220 |
||
78 | 221 |
lemma enrich_search_check': |
222 |
assumes grant: "search_check s (up, rp, tp) f" |
|
223 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f" |
|
224 |
and vd: "valid s" and vd': "valid s'" and f_in: "is_dir s f" and f_in': "is_dir s' f" |
|
225 |
and sec: "sectxt_of_obj s' (O_dir f) = sectxt_of_obj s (O_dir f)" |
|
226 |
shows "search_check s' (up, rp, tp) f" |
|
227 |
proof (cases f) |
|
228 |
case Nil |
|
229 |
have "sectxt_of_obj s' (O_dir []) = sectxt_of_obj s (O_dir [])" |
|
230 |
using cf2sf |
|
231 |
apply (erule_tac x = "[]" in allE) |
|
232 |
by (auto simp:cf2sfile_def root_sec_remains vd vd') |
|
233 |
thus ?thesis using grant Nil |
|
234 |
by auto |
|
235 |
next |
|
236 |
case (Cons n pf) |
|
237 |
from vd f_in obtain sf where sf: "cf2sfile s f = Some sf" |
|
238 |
apply (drule_tac is_dir_in_current, drule_tac current_file_has_sfile, simp) |
|
239 |
apply (erule exE, simp) |
|
240 |
done |
|
241 |
then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons |
|
242 |
by (auto simp:cf2sfile_def split:option.splits if_splits) |
|
243 |
from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_dir_in_current) |
|
244 |
then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons |
|
245 |
by (auto simp:cf2sfile_def split:option.splits if_splits) |
|
246 |
with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in' |
|
247 |
apply (drule_tac is_dir_not_file) |
|
248 |
apply (drule is_dir_not_file) |
|
249 |
apply (simp add:cf2sfile_def split:option.splits) |
|
250 |
apply (case_tac sf, simp) |
|
251 |
done |
|
252 |
show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec |
|
253 |
apply (drule_tac is_dir_not_file) |
|
254 |
apply (drule_tac is_dir_not_file) |
|
255 |
apply (simp add:Cons split:option.splits) |
|
256 |
by (case_tac a, simp) |
|
257 |
qed |
|
258 |
||
77 | 259 |
lemma proc_filefd_has_sfd: "\<lbrakk>fd \<in> proc_file_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> sfd. cfd2sfd s p fd = Some sfd" |
260 |
apply (simp add:proc_file_fds_def) |
|
261 |
apply (auto dest: current_filefd_has_sfd) |
|
262 |
done |
|
263 |
||
264 |
lemma enrich_inherit_fds_check: |
|
265 |
assumes grant: "inherit_fds_check s (up, nr, nt) p fds" and vd: "valid s" |
|
266 |
and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p\<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd" |
|
267 |
and fd_in: "fds \<subseteq> proc_file_fds s p" and fd_in': "fds \<subseteq> proc_file_fds s' p" |
|
268 |
shows "inherit_fds_check s' (up, nr, nt) p fds" |
|
269 |
proof- |
|
270 |
have "\<And> fd. fd \<in> fds \<Longrightarrow> sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)" |
|
271 |
proof- |
|
272 |
fix fd |
|
273 |
assume fd_in_fds: "fd \<in> fds" |
|
274 |
hence fd_in_cfds: "fd \<in> proc_file_fds s p" |
|
275 |
and fd_in_cfds': "fd \<in> proc_file_fds s' p" |
|
276 |
using fd_in fd_in' by auto |
|
277 |
with cfd2sfd |
|
278 |
have cfd_eq: "cfd2sfd s' p fd = cfd2sfd s p fd" by auto |
|
279 |
from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f" |
|
280 |
by (auto simp:proc_file_fds_def) |
|
281 |
moreover have "flags_of_proc_fd s p fd \<noteq> None" |
|
282 |
using ffd vd by (auto dest:current_filefd_has_flags) |
|
283 |
moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None" |
|
284 |
using fd_in_cfds vd |
|
285 |
apply (rule_tac notI) |
|
286 |
by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd) |
|
287 |
moreover have "cf2sfile s f \<noteq> None" |
|
288 |
apply (rule notI) |
|
289 |
apply (drule current_file_has_sfile') |
|
290 |
using ffd |
|
291 |
by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file) |
|
292 |
ultimately show "sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)" |
|
293 |
using cfd_eq |
|
294 |
by (auto simp:cfd2sfd_def split:option.splits) |
|
295 |
qed |
|
296 |
hence "sectxts_of_fds s' p fds = sectxts_of_fds s p fds" |
|
297 |
by (simp add:sectxts_of_fds_def) |
|
298 |
thus ?thesis using grant |
|
299 |
by (simp add:inherit_fds_check_def) |
|
300 |
qed |
|
301 |
||
80 | 302 |
|
303 |
lemma enrich_inherit_fds_check_dup: |
|
304 |
assumes grant: "inherit_fds_check s (up, nr, nt) p fds" and vd: "valid s" |
|
305 |
and cfd2sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p' fd = cfd2sfd s p fd" |
|
306 |
and fd_in: "fds' \<subseteq> fds \<inter> proc_file_fds s p" |
|
307 |
shows "inherit_fds_check s' (up, nr, nt) p' fds'" |
|
308 |
proof- |
|
309 |
have "sectxts_of_fds s' p' fds' \<subseteq> sectxts_of_fds s p fds" |
|
310 |
proof- |
|
311 |
have "\<And> fd sfd. \<lbrakk>fd \<in> fds'; sectxt_of_obj s' (O_fd p' fd) = Some sfd\<rbrakk> |
|
312 |
\<Longrightarrow> \<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd" |
|
313 |
proof- |
|
314 |
fix fd sfd |
|
315 |
assume fd_in_fds': "fd \<in> fds'" |
|
316 |
and sec: "sectxt_of_obj s' (O_fd p' fd) = Some sfd" |
|
317 |
from fd_in_fds' fd_in |
|
318 |
have fd_in_fds: "fd \<in> fds" and fd_in_cfds: "fd \<in> proc_file_fds s p" |
|
319 |
by auto |
|
320 |
from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f" |
|
321 |
by (auto simp:proc_file_fds_def) |
|
322 |
moreover have "flags_of_proc_fd s p fd \<noteq> None" |
|
323 |
using ffd vd by (auto dest:current_filefd_has_flags) |
|
324 |
moreover have "cf2sfile s f \<noteq> None" |
|
325 |
apply (rule notI) |
|
326 |
apply (drule current_file_has_sfile') |
|
327 |
using ffd |
|
328 |
by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file) |
|
329 |
moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None" |
|
330 |
using fd_in_cfds vd |
|
331 |
apply (rule_tac notI) |
|
332 |
by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd) |
|
333 |
ultimately |
|
334 |
have "sectxt_of_obj s (O_fd p fd) = Some sfd" |
|
335 |
using fd_in_cfds cfd2sfd sec |
|
336 |
apply (erule_tac x = fd in allE) |
|
337 |
apply (auto simp:cfd2sfd_def split:option.splits) |
|
338 |
done |
|
339 |
thus "\<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd" |
|
340 |
using fd_in_fds |
|
341 |
by (rule_tac x = fd in bexI, auto) |
|
342 |
qed |
|
343 |
thus ?thesis by (auto simp:sectxts_of_fds_def) |
|
344 |
qed |
|
345 |
thus ?thesis using grant |
|
346 |
by (auto simp:inherit_fds_check_def inherit_fds_check_ctxt_def) |
|
347 |
qed |
|
348 |
||
77 | 349 |
|
350 |
lemma enrich_valid_intro_cons: |
|
83 | 351 |
assumes vs': "valid s'" and vd': "valid (e # s)" |
77 | 352 |
and alive: "\<forall> obj. alive s obj \<longrightarrow> alive s' obj" |
83 | 353 |
and alive': "\<forall> obj. enrich_not_alive s obj' obj \<longrightarrow> enrich_not_alive s' obj' obj" |
78 | 354 |
and hungs: "files_hung_by_del s' = files_hung_by_del s" |
77 | 355 |
and cp2sp: "\<forall> p. p \<in> current_procs s \<longrightarrow> cp2sproc s' p = cp2sproc s p" |
356 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f" |
|
78 | 357 |
and cq2sq: "\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq s' q = cq2smsgq s q" |
77 | 358 |
and ffd_remain: "\<forall> p fd f. file_of_proc_fd s p fd = Some f \<longrightarrow> file_of_proc_fd s' p fd = Some f" |
78 | 359 |
and fflags_remain: "\<forall> p fd flags. flags_of_proc_fd s p fd = Some flags \<longrightarrow> flags_of_proc_fd s' p fd = Some flags" |
90 | 360 |
and sms_remain: "\<forall> q. q \<in> current_msgqs s \<longrightarrow> msgs_of_queue s' q = msgs_of_queue s q" |
78 | 361 |
(* and empty_remain: "\<forall> f. dir_is_empty s f \<longrightarrow> dir_is_empty s' f" *) |
77 | 362 |
and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd" |
83 | 363 |
and nodel: "no_del_event (e # s)" |
89 | 364 |
and notin_cur: "notin_cur (e # s) obj'" |
77 | 365 |
shows "valid (e # s')" |
83 | 366 |
proof- |
367 |
from vd' have os: "os_grant s e" and grant: "grant s e" and vd: "valid s" |
|
368 |
by (auto dest:vt_grant_os vt_grant vd_cons) |
|
78 | 369 |
show ?thesis |
83 | 370 |
proof (cases e) |
371 |
case (Execve p f fds) |
|
78 | 372 |
have p_in: "p \<in> current_procs s'" using os alive |
373 |
apply (erule_tac x = "O_proc p" in allE) |
|
83 | 374 |
by (auto simp:Execve) |
78 | 375 |
have f_in: "is_file s' f" using os alive |
376 |
apply (erule_tac x = "O_file f" in allE) |
|
83 | 377 |
by (auto simp:Execve) |
378 |
have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain |
|
379 |
by (auto simp:Execve proc_file_fds_def) |
|
380 |
have "os_grant s' e" using p_in f_in fd_in by (simp add:Execve) |
|
381 |
moreover have "grant s' e" |
|
78 | 382 |
proof- |
383 |
from grant obtain up rp tp uf rf tf |
|
384 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
385 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
83 | 386 |
by (simp add:Execve split:option.splits, blast) |
387 |
with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)" |
|
388 |
by (simp add:Execve split:option.splits del:npctxt_execve.simps, blast) |
|
78 | 389 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
390 |
using os cp2sp |
|
391 |
apply (erule_tac x = p in allE) |
|
83 | 392 |
by (auto simp:Execve co2sobj.simps cp2sproc_def split:option.splits) |
393 |
from os have f_in': "is_file s f" by (simp add:Execve) |
|
78 | 394 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf" |
83 | 395 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Execve) |
78 | 396 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf |
397 |
apply (erule_tac x = f in allE) |
|
398 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits) |
|
399 |
apply (case_tac f, simp) |
|
400 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
401 |
done |
|
83 | 402 |
have "inherit_fds_check s' (pu, nr, nt) p fds" |
403 |
proof- |
|
404 |
have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Execve |
|
405 |
by (auto simp:proc_file_fds_def) |
|
406 |
thus ?thesis using Execve grant vd cfd2sfd p1 p2 p3 os |
|
407 |
apply (rule_tac s = s in enrich_inherit_fds_check) |
|
408 |
by (simp_all split:option.splits) |
|
409 |
qed |
|
410 |
moreover have "search_check s' (pu, rp, tp) f" |
|
411 |
using p1 p2 p2' vd cf2sf f_in' grant Execve p3 f_in |
|
78 | 412 |
apply (rule_tac s = s in enrich_search_check) |
413 |
by (simp_all split:option.splits) |
|
83 | 414 |
ultimately show ?thesis using p1' p2' p3 |
415 |
apply (simp add:Execve split:option.splits) |
|
416 |
using grant Execve p1 p2 |
|
417 |
by (simp add:Execve grant p1 p2) |
|
418 |
qed |
|
419 |
ultimately show ?thesis using vs' |
|
420 |
by (erule_tac valid.intros(2), simp+) |
|
421 |
next |
|
422 |
case (Clone p p' fds) |
|
423 |
have p_in: "p \<in> current_procs s'" using os alive |
|
424 |
apply (erule_tac x = "O_proc p" in allE) |
|
425 |
by (auto simp:Clone) |
|
89 | 426 |
have p'_not_in: "p' \<notin> current_procs s'" using alive' notin_cur os Clone |
427 |
apply (erule_tac x = "I_proc p'" in allE) |
|
93 | 428 |
apply (auto simp del:nums_of_recvmsg.simps) |
83 | 429 |
done |
430 |
have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain |
|
431 |
by (auto simp:Clone proc_file_fds_def) |
|
432 |
have "os_grant s' e" using p_in p'_not_in fd_in by (simp add:Clone) |
|
433 |
moreover have "grant s' e" |
|
434 |
proof- |
|
435 |
from grant obtain up rp tp |
|
436 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
437 |
apply (simp add:Clone split:option.splits) |
|
438 |
by (case_tac a, auto) |
|
439 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
440 |
using os cp2sp |
|
441 |
apply (erule_tac x = p in allE) |
|
442 |
by (auto simp:Clone co2sobj.simps cp2sproc_def split:option.splits) |
|
443 |
have p2: "inherit_fds_check s' (up, rp, tp) p fds" |
|
444 |
proof- |
|
445 |
have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Clone |
|
446 |
by (auto simp:proc_file_fds_def) |
|
447 |
thus ?thesis using Clone grant vd cfd2sfd p1 os |
|
448 |
apply (rule_tac s = s in enrich_inherit_fds_check) |
|
449 |
by (simp_all split:option.splits) |
|
450 |
qed |
|
451 |
show ?thesis using p1 p2 p1' grant |
|
452 |
by (simp add:Clone) |
|
453 |
qed |
|
454 |
ultimately show ?thesis using vs' |
|
455 |
by (erule_tac valid.intros(2), simp+) |
|
456 |
next |
|
457 |
case (Kill p p') |
|
458 |
have p_in: "p \<in> current_procs s'" using os alive |
|
459 |
apply (erule_tac x = "O_proc p" in allE) |
|
460 |
by (auto simp:Kill) |
|
461 |
have p'_in: "p' \<in> current_procs s'" using os alive |
|
462 |
apply (erule_tac x = "O_proc p'" in allE) |
|
463 |
by (auto simp:Kill) |
|
464 |
have "os_grant s' e" using p_in p'_in by (simp add:Kill) |
|
465 |
moreover have "grant s' e" |
|
466 |
proof- |
|
467 |
from grant obtain up rp tp up' rp' tp' |
|
468 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
469 |
and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')" |
|
470 |
apply (simp add:Kill split:option.splits) |
|
471 |
by (case_tac a, case_tac aa, blast) |
|
472 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
473 |
using os cp2sp |
|
474 |
apply (erule_tac x = p in allE) |
|
475 |
by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits) |
|
476 |
from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')" |
|
477 |
using os cp2sp |
|
478 |
apply (erule_tac x = p' in allE) |
|
479 |
by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits) |
|
480 |
show ?thesis using p1 p'1 p1' p'1' grant |
|
481 |
by (simp add:Kill) |
|
482 |
qed |
|
483 |
ultimately show ?thesis using vs' |
|
484 |
by (erule_tac valid.intros(2), simp+) |
|
485 |
next |
|
486 |
case (Ptrace p p') |
|
487 |
have p_in: "p \<in> current_procs s'" using os alive |
|
488 |
apply (erule_tac x = "O_proc p" in allE) |
|
489 |
by (auto simp:Ptrace) |
|
490 |
have p'_in: "p' \<in> current_procs s'" using os alive |
|
491 |
apply (erule_tac x = "O_proc p'" in allE) |
|
492 |
by (auto simp:Ptrace) |
|
493 |
have "os_grant s' e" using p_in p'_in by (simp add:Ptrace) |
|
494 |
moreover have "grant s' e" |
|
495 |
proof- |
|
496 |
from grant obtain up rp tp up' rp' tp' |
|
497 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
498 |
and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')" |
|
499 |
apply (simp add:Ptrace split:option.splits) |
|
500 |
by (case_tac a, case_tac aa, blast) |
|
501 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
502 |
using os cp2sp |
|
503 |
apply (erule_tac x = p in allE) |
|
504 |
by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits) |
|
505 |
from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')" |
|
506 |
using os cp2sp |
|
507 |
apply (erule_tac x = p' in allE) |
|
508 |
by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits) |
|
509 |
show ?thesis using p1 p'1 p1' p'1' grant |
|
510 |
by (simp add:Ptrace) |
|
511 |
qed |
|
512 |
ultimately show ?thesis using vs' |
|
513 |
by (erule_tac valid.intros(2), simp+) |
|
514 |
next |
|
515 |
case (Exit p) |
|
516 |
have p_in: "p \<in> current_procs s'" using os alive |
|
517 |
apply (erule_tac x = "O_proc p" in allE) |
|
518 |
by (auto simp:Exit) |
|
519 |
have "os_grant s' e" using p_in by (simp add:Exit) |
|
520 |
moreover have "grant s' e" |
|
521 |
by (simp add:Exit) |
|
522 |
ultimately show ?thesis using vs' |
|
523 |
by (erule_tac valid.intros(2), simp+) |
|
524 |
next |
|
525 |
case (Open p f flags fd opt) |
|
526 |
show ?thesis |
|
527 |
proof (cases opt) |
|
528 |
case None |
|
529 |
have p_in: "p \<in> current_procs s'" using os alive |
|
530 |
apply (erule_tac x = "O_proc p" in allE) |
|
531 |
by (auto simp:Open None) |
|
532 |
have f_in: "is_file s' f" using os alive |
|
533 |
apply (erule_tac x = "O_file f" in allE) |
|
534 |
by (auto simp:Open None) |
|
535 |
have fd_not_in: "fd \<notin> current_proc_fds s' p" |
|
89 | 536 |
using os alive' p_in notin_cur Open None |
537 |
apply (erule_tac x = "I_fd p fd" in allE) |
|
93 | 538 |
apply (case_tac obj', auto) |
84
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
539 |
done |
83 | 540 |
have "os_grant s' e" using p_in f_in fd_not_in os |
541 |
by (simp add:Open None) |
|
542 |
moreover have "grant s' e" |
|
543 |
proof- |
|
544 |
from grant obtain up rp tp uf rf tf |
|
545 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
546 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
547 |
apply (simp add:Open None split:option.splits) |
|
548 |
by (case_tac a, case_tac aa, blast) |
|
549 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
550 |
using os cp2sp |
|
551 |
apply (erule_tac x = p in allE) |
|
552 |
by (auto simp:Open None co2sobj.simps cp2sproc_def split:option.splits) |
|
553 |
from os have f_in': "is_file s f" by (simp add:Open None) |
|
554 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf" |
|
555 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Open None) |
|
556 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf |
|
557 |
apply (erule_tac x = f in allE) |
|
558 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits) |
|
559 |
apply (case_tac f, simp) |
|
560 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
561 |
done |
|
562 |
have "search_check s' (up, rp, tp) f" |
|
563 |
using p1 p2 p2' vd cf2sf f_in' grant Open None f_in |
|
564 |
apply (rule_tac s = s in enrich_search_check) |
|
565 |
by (simp_all split:option.splits) |
|
566 |
thus ?thesis using p1' p2' |
|
567 |
apply (simp add:Open None split:option.splits) |
|
568 |
using grant Open None p1 p2 |
|
569 |
by simp |
|
570 |
qed |
|
571 |
ultimately show ?thesis using vs' |
|
572 |
by (erule_tac valid.intros(2), simp+) |
|
573 |
next |
|
574 |
case (Some inum) |
|
575 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf" |
|
576 |
by (auto simp:Open Some) |
|
577 |
have pf_in: "is_dir s' pf" using pf_in_s alive |
|
578 |
apply (erule_tac x = "O_dir pf" in allE) |
|
579 |
by simp |
|
580 |
have p_in: "p \<in> current_procs s'" using os alive |
|
581 |
apply (erule_tac x = "O_proc p" in allE) |
|
582 |
by (auto simp:Open Some) |
|
89 | 583 |
have f_not_in: "f \<notin> current_files s'" using os alive' Open Some notin_cur nodel |
584 |
apply (erule_tac x = "I_file f" in allE) |
|
585 |
by (case_tac obj', auto simp:current_files_simps) |
|
83 | 586 |
have fd_not_in: "fd \<notin> current_proc_fds s' p" |
89 | 587 |
using os alive' p_in Open Some notin_cur |
588 |
apply (erule_tac x = "I_fd p fd" in allE) |
|
93 | 589 |
apply (case_tac obj', auto) |
83 | 590 |
done |
591 |
have inum_not_in: "inum \<notin> current_inode_nums s'" |
|
89 | 592 |
using os alive' Open Some notin_cur nodel |
593 |
apply (erule_tac x = "I_inum inum" in allE) |
|
594 |
apply (case_tac obj', auto) |
|
595 |
apply (auto simp add:current_inode_nums_def current_file_inums_def split:if_splits) |
|
596 |
done |
|
83 | 597 |
have "os_grant s' e" using p_in pf_in parent f_not_in fd_not_in inum_not_in os |
598 |
by (simp add:Open Some hungs) |
|
599 |
moreover have "grant s' e" |
|
600 |
proof- |
|
601 |
from grant parent obtain up rp tp uf rf tf |
|
602 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
603 |
and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)" |
|
604 |
apply (simp add:Open Some split:option.splits) |
|
605 |
by (case_tac a, case_tac aa, blast) |
|
606 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
607 |
using os cp2sp |
|
608 |
apply (erule_tac x = p in allE) |
|
609 |
by (auto simp:Open Some co2sobj.simps cp2sproc_def split:option.splits) |
|
610 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf" |
|
611 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Open Some) |
|
612 |
hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s |
|
613 |
apply (erule_tac x = pf in allE) |
|
614 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp) |
|
615 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
616 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
617 |
apply (case_tac pf, simp_all) |
|
618 |
by (simp add:sroot_def root_sec_remains vd vs') |
|
619 |
have "search_check s' (up, rp, tp) pf" |
|
620 |
using p1 p2 p2' vd cf2sf pf_in grant Open Some pf_in_s parent vs' |
|
621 |
apply (rule_tac s = s in enrich_search_check') |
|
622 |
by (simp_all split:option.splits) |
|
623 |
thus ?thesis using p1' p2' parent |
|
624 |
apply (simp add:Open Some split:option.splits) |
|
625 |
using grant Open Some p1 p2 |
|
626 |
by simp |
|
627 |
qed |
|
628 |
ultimately show ?thesis using vs' |
|
629 |
by (erule_tac valid.intros(2), simp+) |
|
630 |
qed |
|
631 |
next |
|
632 |
case (ReadFile p fd) |
|
633 |
have p_in: "p \<in> current_procs s'" using os alive |
|
634 |
apply (erule_tac x = "O_proc p" in allE) |
|
635 |
by (auto simp:ReadFile) |
|
636 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive |
|
637 |
apply (erule_tac x = "O_fd p fd" in allE) |
|
638 |
by (auto simp:ReadFile) |
|
639 |
obtain f where ffd: "file_of_proc_fd s p fd = Some f" |
|
640 |
using os ReadFile by auto |
|
641 |
hence f_in_s: "is_file s f" using vd |
|
642 |
by (auto intro:file_of_pfd_is_file) |
|
643 |
obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags" |
|
644 |
using os ReadFile by auto |
|
645 |
have ffd_in: "file_of_proc_fd s' p fd = Some f" |
|
646 |
using ffd_remain ffd by auto |
|
647 |
hence f_in: "is_file s' f" using vs' |
|
648 |
by (auto intro:file_of_pfd_is_file) |
|
649 |
have flags_in: "flags_of_proc_fd s' p fd = Some flags" |
|
650 |
using fflags_remain fflag by auto |
|
651 |
have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in |
|
652 |
by (auto simp add:ReadFile is_file_in_current) |
|
653 |
moreover have "grant s' e" |
|
654 |
proof- |
|
655 |
from grant ffd obtain up rp tp uf rf tf ufd rfd tfd |
|
656 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
657 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
658 |
and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)" |
|
659 |
apply (simp add:ReadFile split:option.splits) |
|
660 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
661 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
662 |
using os cp2sp |
|
663 |
apply (erule_tac x = p in allE) |
|
664 |
by (auto simp:ReadFile co2sobj.simps cp2sproc_def split:option.splits) |
|
665 |
from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf" |
|
666 |
by (auto dest!:is_file_in_current current_file_has_sfile) |
|
667 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf |
|
668 |
apply (erule_tac x = f in allE) |
|
669 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits) |
|
670 |
apply (case_tac f, simp) |
|
671 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
672 |
done |
|
673 |
have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)" |
|
674 |
using cfd2sfd ffd_in ffd p3 f_in f_in_s vd |
|
675 |
apply (erule_tac x = p in allE) |
|
676 |
apply (erule_tac x = fd in allE) |
|
677 |
apply (simp add:proc_file_fds_def) |
|
678 |
apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits |
|
679 |
dest!:current_file_has_sfile' simp:is_file_in_current) |
|
680 |
done |
|
681 |
show ?thesis using p1' p2' p3' ffd_in ffd |
|
682 |
apply (simp add:ReadFile split:option.splits) |
|
683 |
using grant p1 p2 p3 ReadFile |
|
78 | 684 |
by simp |
685 |
qed |
|
686 |
ultimately show ?thesis using vs' |
|
687 |
by (erule_tac valid.intros(2), simp+) |
|
688 |
next |
|
83 | 689 |
case (WriteFile p fd) |
690 |
have p_in: "p \<in> current_procs s'" using os alive |
|
691 |
apply (erule_tac x = "O_proc p" in allE) |
|
692 |
by (auto simp:WriteFile) |
|
693 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive |
|
694 |
apply (erule_tac x = "O_fd p fd" in allE) |
|
695 |
by (auto simp:WriteFile) |
|
696 |
obtain f where ffd: "file_of_proc_fd s p fd = Some f" |
|
697 |
using os WriteFile by auto |
|
698 |
hence f_in_s: "is_file s f" using vd |
|
699 |
by (auto intro:file_of_pfd_is_file) |
|
700 |
obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags" |
|
701 |
using os WriteFile by auto |
|
702 |
have ffd_in: "file_of_proc_fd s' p fd = Some f" |
|
703 |
using ffd_remain ffd by auto |
|
704 |
hence f_in: "is_file s' f" using vs' |
|
705 |
by (auto intro:file_of_pfd_is_file) |
|
706 |
have flags_in: "flags_of_proc_fd s' p fd = Some flags" |
|
707 |
using fflags_remain fflag by auto |
|
708 |
have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in |
|
709 |
by (auto simp add:WriteFile is_file_in_current) |
|
710 |
moreover have "grant s' e" |
|
711 |
proof- |
|
712 |
from grant ffd obtain up rp tp uf rf tf ufd rfd tfd |
|
713 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
714 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
715 |
and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)" |
|
716 |
apply (simp add:WriteFile split:option.splits) |
|
717 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
718 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
719 |
using os cp2sp |
|
720 |
apply (erule_tac x = p in allE) |
|
721 |
by (auto simp:WriteFile co2sobj.simps cp2sproc_def split:option.splits) |
|
722 |
from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf" |
|
723 |
by (auto dest!:is_file_in_current current_file_has_sfile) |
|
724 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf |
|
725 |
apply (erule_tac x = f in allE) |
|
726 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits) |
|
727 |
apply (case_tac f, simp) |
|
728 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
729 |
done |
|
730 |
have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)" |
|
731 |
using cfd2sfd ffd_in ffd p3 f_in f_in_s vd |
|
732 |
apply (erule_tac x = p in allE) |
|
733 |
apply (erule_tac x = fd in allE) |
|
734 |
apply (simp add:proc_file_fds_def) |
|
735 |
apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits |
|
736 |
dest!:current_file_has_sfile' simp:is_file_in_current) |
|
737 |
done |
|
738 |
show ?thesis using p1' p2' p3' ffd_in ffd |
|
739 |
apply (simp add:WriteFile split:option.splits) |
|
740 |
using grant p1 p2 p3 WriteFile |
|
741 |
by simp |
|
742 |
qed |
|
743 |
ultimately show ?thesis using vs' |
|
744 |
by (erule_tac valid.intros(2), simp+) |
|
745 |
next |
|
746 |
case (CloseFd p fd) |
|
747 |
have p_in: "p \<in> current_procs s'" using os alive |
|
748 |
apply (erule_tac x = "O_proc p" in allE) |
|
749 |
by (auto simp:CloseFd) |
|
750 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive |
|
751 |
apply (erule_tac x = "O_fd p fd" in allE) |
|
752 |
by (auto simp:CloseFd) |
|
753 |
have "os_grant s' e" using p_in fd_in |
|
754 |
by (auto simp add:CloseFd) |
|
755 |
moreover have "grant s' e" |
|
756 |
by(simp add:CloseFd) |
|
757 |
ultimately show ?thesis using vs' |
|
758 |
by (erule_tac valid.intros(2), simp+) |
|
759 |
next |
|
760 |
case (UnLink p f) |
|
761 |
have p_in: "p \<in> current_procs s'" using os alive |
|
762 |
apply (erule_tac x = "O_proc p" in allE) |
|
763 |
by (auto simp:UnLink) |
|
764 |
have f_in: "is_file s' f" using os alive |
|
765 |
apply (erule_tac x = "O_file f" in allE) |
|
766 |
by (auto simp:UnLink) |
|
767 |
from os vd obtain pf where pf_in_s: "is_dir s pf" |
|
768 |
and parent: "parent f = Some pf" |
|
769 |
by (auto simp:UnLink dest!:file_has_parent) |
|
770 |
from pf_in_s alive have pf_in: "is_dir s' pf" |
|
771 |
apply (erule_tac x = "O_dir pf" in allE) |
|
772 |
by (auto simp:UnLink) |
|
773 |
have "os_grant s' e" using p_in f_in os |
|
774 |
by (simp add:UnLink hungs) |
|
775 |
moreover have "grant s' e" |
|
776 |
proof- |
|
777 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf |
|
778 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
779 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
780 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" |
|
781 |
apply (simp add:UnLink split:option.splits) |
|
782 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
783 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
784 |
using os cp2sp |
|
785 |
apply (erule_tac x = p in allE) |
|
786 |
by (auto simp:UnLink co2sobj.simps cp2sproc_def split:option.splits) |
|
787 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf" |
|
788 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:UnLink) |
|
789 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" |
|
790 |
using p2 cf2sf f_in os parent |
|
791 |
apply (erule_tac x = f in allE) |
|
792 |
apply (erule exE, clarsimp simp:UnLink) |
|
793 |
apply (frule_tac s = s in is_file_in_current, simp) |
|
794 |
by (auto simp:cf2sfile_def split:option.splits) |
|
795 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf" |
|
796 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:UnLink) |
|
797 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s |
|
798 |
apply (erule_tac x = pf in allE) |
|
799 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp) |
|
800 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
801 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
802 |
apply (case_tac pf, simp_all) |
|
803 |
by (simp add:sroot_def root_sec_remains vd vs') |
|
804 |
have "search_check s' (up, rp, tp) f" |
|
805 |
using p1 p2 p2' vd cf2sf f_in grant UnLink os parent vs' |
|
806 |
apply (rule_tac s = s in enrich_search_check) |
|
807 |
by (simp_all split:option.splits) |
|
808 |
thus ?thesis using p1' p2' p3' parent |
|
809 |
apply (simp add:UnLink split:option.splits) |
|
810 |
using grant UnLink p1 p2 p3 |
|
811 |
by simp |
|
812 |
qed |
|
813 |
ultimately show ?thesis using vs' |
|
814 |
by (erule_tac valid.intros(2), simp+) |
|
815 |
next |
|
816 |
case (Rmdir p f) |
|
817 |
have p_in: "p \<in> current_procs s'" using os alive |
|
818 |
apply (erule_tac x = "O_proc p" in allE) |
|
819 |
by (auto simp:Rmdir) |
|
820 |
have f_in: "is_dir s' f" using os alive |
|
821 |
apply (erule_tac x = "O_dir f" in allE) |
|
822 |
by (auto simp:Rmdir dir_is_empty_def) |
|
823 |
have not_root: "f \<noteq> []" using os |
|
824 |
by (auto simp:Rmdir) |
|
825 |
from os vd obtain pf where pf_in_s: "is_dir s pf" |
|
826 |
and parent: "parent f = Some pf" |
|
827 |
apply (auto simp:Rmdir dir_is_empty_def) |
|
828 |
apply (case_tac f, simp+) |
|
829 |
apply (drule parentf_is_dir_prop1, auto) |
|
830 |
done |
|
831 |
from pf_in_s alive have pf_in: "is_dir s' pf" |
|
832 |
apply (erule_tac x = "O_dir pf" in allE) |
|
833 |
by (auto simp:Rmdir) |
|
89 | 834 |
have empty_in: "dir_is_empty s' f" using os Rmdir notin_cur |
83 | 835 |
apply (clarsimp simp add:dir_is_empty_def f_in) |
836 |
using alive' |
|
89 | 837 |
apply (erule_tac x = "I_file f'" in allE) |
83 | 838 |
apply simp |
839 |
apply (erule disjE) |
|
840 |
apply (erule_tac x = f' in allE, simp) |
|
841 |
apply (case_tac obj', simp_all) |
|
842 |
apply (clarsimp) |
|
843 |
apply (drule_tac f' = f in parent_ancen) |
|
844 |
apply (simp, rule notI, simp add:noJ_Anc) |
|
845 |
apply (case_tac "f = pf") |
|
846 |
using vd' Rmdir |
|
847 |
apply (simp_all add:is_dir_rmdir) |
|
848 |
apply (erule_tac x = pf in allE) |
|
849 |
apply (drule_tac f = pf in is_dir_in_current) |
|
850 |
apply (simp add:noJ_Anc) |
|
89 | 851 |
|
852 |
apply (clarsimp) |
|
853 |
apply (drule_tac f' = f in parent_ancen) |
|
854 |
apply (simp, rule notI, simp add:noJ_Anc) |
|
855 |
apply (case_tac "f = pf") |
|
856 |
using vd' Rmdir |
|
857 |
apply (simp_all add:is_dir_rmdir) |
|
858 |
apply (erule_tac x = pf in allE) |
|
859 |
apply (drule_tac f = pf in is_dir_in_current) |
|
860 |
apply (simp add:noJ_Anc) |
|
83 | 861 |
done |
862 |
have "os_grant s' e" using p_in f_in os empty_in |
|
863 |
by (simp add:Rmdir hungs) |
|
864 |
moreover have "grant s' e" |
|
865 |
proof- |
|
866 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf |
|
867 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
868 |
and p2: "sectxt_of_obj s (O_dir f) = Some (uf, rf, tf)" |
|
869 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" |
|
870 |
apply (simp add:Rmdir split:option.splits) |
|
871 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
872 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
873 |
using os cp2sp |
|
874 |
apply (erule_tac x = p in allE) |
|
875 |
by (auto simp:Rmdir co2sobj.simps cp2sproc_def split:option.splits) |
|
876 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf" |
|
877 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:dir_is_empty_def Rmdir) |
|
878 |
hence p2': "sectxt_of_obj s' (O_dir f) = Some (uf, rf, tf)" |
|
879 |
using p2 cf2sf f_in os parent |
|
880 |
apply (erule_tac x = f in allE) |
|
881 |
apply (erule exE, clarsimp simp:Rmdir dir_is_empty_def) |
|
882 |
apply (frule_tac s = s in is_dir_in_current, simp) |
|
883 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
884 |
by (auto simp:cf2sfile_def split:option.splits) |
|
885 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf" |
|
886 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Rmdir) |
|
887 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s |
|
888 |
apply (erule_tac x = pf in allE) |
|
889 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp) |
|
890 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
891 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
892 |
apply (case_tac pf, simp_all) |
|
893 |
by (simp add:sroot_def root_sec_remains vd vs') |
|
894 |
have "search_check s' (up, rp, tp) f" |
|
895 |
using p1 p2 p2' vd cf2sf f_in grant Rmdir os parent vs' |
|
896 |
apply (rule_tac s = s in enrich_search_check') |
|
897 |
by (simp_all add:dir_is_empty_def split:option.splits) |
|
898 |
thus ?thesis using p1' p2' p3' parent |
|
899 |
apply (simp add:Rmdir split:option.splits) |
|
900 |
using grant Rmdir p1 p2 p3 |
|
901 |
by simp |
|
902 |
qed |
|
903 |
ultimately show ?thesis using vs' |
|
904 |
by (erule_tac valid.intros(2), simp+) |
|
905 |
next |
|
906 |
case (Mkdir p f inum) |
|
78 | 907 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf" |
83 | 908 |
by (auto simp:Mkdir) |
78 | 909 |
have pf_in: "is_dir s' pf" using pf_in_s alive |
910 |
apply (erule_tac x = "O_dir pf" in allE) |
|
911 |
by simp |
|
912 |
have p_in: "p \<in> current_procs s'" using os alive |
|
913 |
apply (erule_tac x = "O_proc p" in allE) |
|
83 | 914 |
by (auto simp:Mkdir) |
89 | 915 |
have f_not_in: "f \<notin> current_files s'" |
916 |
using os alive' Mkdir notin_cur |
|
917 |
apply (erule_tac x = "I_file f" in allE) |
|
918 |
by (auto simp:current_files_simps) |
|
78 | 919 |
have inum_not_in: "inum \<notin> current_inode_nums s'" |
89 | 920 |
using os alive' Mkdir notin_cur |
921 |
apply (erule_tac x = "I_inum inum" in allE) |
|
922 |
apply (auto simp:current_inode_nums_def current_file_inums_def split:if_splits) |
|
923 |
done |
|
83 | 924 |
have "os_grant s' e" using p_in pf_in parent f_not_in os inum_not_in |
925 |
by (simp add:Mkdir hungs) |
|
78 | 926 |
moreover have "grant s' e" |
927 |
proof- |
|
928 |
from grant parent obtain up rp tp uf rf tf |
|
929 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
930 |
and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)" |
|
83 | 931 |
apply (simp add:Mkdir split:option.splits) |
78 | 932 |
by (case_tac a, case_tac aa, blast) |
933 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
934 |
using os cp2sp |
|
935 |
apply (erule_tac x = p in allE) |
|
83 | 936 |
by (auto simp:Mkdir co2sobj.simps cp2sproc_def split:option.splits) |
78 | 937 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf" |
83 | 938 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Mkdir) |
78 | 939 |
hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s |
940 |
apply (erule_tac x = pf in allE) |
|
941 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp) |
|
942 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
943 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
944 |
apply (case_tac pf, simp_all) |
|
945 |
by (simp add:sroot_def root_sec_remains vd vs') |
|
946 |
have "search_check s' (up, rp, tp) pf" |
|
83 | 947 |
using p1 p2 p2' vd cf2sf pf_in grant Mkdir pf_in_s parent vs' |
78 | 948 |
apply (rule_tac s = s in enrich_search_check') |
83 | 949 |
apply (simp_all split:option.splits) |
950 |
done |
|
951 |
thus ?thesis using p1' p2' parent |
|
952 |
apply (simp add:Mkdir split:option.splits) |
|
953 |
using grant Mkdir p1 p2 |
|
954 |
apply simp |
|
955 |
done |
|
956 |
qed |
|
957 |
ultimately show ?thesis using vs' |
|
958 |
by (erule_tac valid.intros(2), simp+) |
|
959 |
next |
|
960 |
case (LinkHard p f f') |
|
961 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f' = Some pf" |
|
962 |
by (auto simp:LinkHard) |
|
963 |
have pf_in: "is_dir s' pf" using pf_in_s alive |
|
964 |
apply (erule_tac x = "O_dir pf" in allE) |
|
965 |
by simp |
|
966 |
have p_in: "p \<in> current_procs s'" using os alive |
|
967 |
apply (erule_tac x = "O_proc p" in allE) |
|
968 |
by (auto simp:LinkHard) |
|
89 | 969 |
have f'_not_in: "f' \<notin> current_files s'" |
970 |
using os alive' LinkHard notin_cur vd' |
|
971 |
apply (erule_tac x = "I_file f'" in allE) |
|
972 |
apply (auto simp:LinkHard current_files_simps) |
|
973 |
done |
|
83 | 974 |
have f_in: "is_file s' f" using os alive |
975 |
apply (erule_tac x = "O_file f" in allE) |
|
976 |
by (auto simp:LinkHard) |
|
977 |
have "os_grant s' e" using p_in pf_in parent os f_in f'_not_in |
|
978 |
by (simp add:LinkHard hungs) |
|
979 |
moreover have "grant s' e" |
|
980 |
proof- |
|
981 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf |
|
982 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
983 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
984 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" |
|
985 |
apply (simp add:LinkHard split:option.splits) |
|
986 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
987 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
988 |
using os cp2sp |
|
989 |
apply (erule_tac x = p in allE) |
|
990 |
by (auto simp:LinkHard co2sobj.simps cp2sproc_def split:option.splits) |
|
991 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf" |
|
992 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:LinkHard) |
|
993 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" |
|
994 |
using p2 cf2sf f_in os parent |
|
995 |
apply (erule_tac x = f in allE) |
|
996 |
apply (erule exE, clarsimp simp:LinkHard) |
|
997 |
apply (frule_tac s = s in is_file_in_current, simp) |
|
998 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
999 |
apply (case_tac f, simp) |
|
1000 |
by (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
1001 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf" |
|
1002 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:LinkHard) |
|
1003 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s |
|
1004 |
apply (erule_tac x = pf in allE) |
|
1005 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp) |
|
1006 |
apply (drule is_dir_not_file, drule is_dir_not_file) |
|
1007 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
1008 |
apply (case_tac pf, simp_all) |
|
1009 |
by (simp add:sroot_def root_sec_remains vd vs') |
|
1010 |
have "search_check s' (up, rp, tp) f" |
|
1011 |
using p1 p2 p2' vd cf2sf f_in grant LinkHard os parent vs' |
|
1012 |
apply (rule_tac s = s in enrich_search_check) |
|
78 | 1013 |
by (simp_all split:option.splits) |
83 | 1014 |
moreover have "search_check s' (up, rp, tp) pf" |
1015 |
using p1 p3 p3' vd cf2sf pf_in grant LinkHard os parent vs' |
|
1016 |
apply (rule_tac s = s in enrich_search_check') |
|
1017 |
apply (simp_all split:option.splits) |
|
1018 |
done |
|
1019 |
ultimately show ?thesis using p1' p2' p3' parent |
|
1020 |
apply (simp add:LinkHard split:option.splits) |
|
1021 |
using grant LinkHard p1 p2 p3 |
|
1022 |
apply simp |
|
1023 |
done |
|
1024 |
qed |
|
1025 |
ultimately show ?thesis using vs' |
|
1026 |
by (erule_tac valid.intros(2), simp+) |
|
1027 |
next |
|
1028 |
case (Truncate p f len) |
|
1029 |
have p_in: "p \<in> current_procs s'" using os alive |
|
1030 |
apply (erule_tac x = "O_proc p" in allE) |
|
1031 |
by (auto simp:Truncate) |
|
1032 |
have f_in: "is_file s' f" using os alive |
|
1033 |
apply (erule_tac x = "O_file f" in allE) |
|
1034 |
by (auto simp:Truncate) |
|
1035 |
have "os_grant s' e" using p_in f_in by (simp add:Truncate) |
|
1036 |
moreover have "grant s' e" |
|
1037 |
proof- |
|
1038 |
from grant obtain up rp tp uf rf tf |
|
1039 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
1040 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" |
|
1041 |
apply (simp add:Truncate split:option.splits) |
|
1042 |
by (case_tac a, case_tac aa, blast) |
|
1043 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
1044 |
using os cp2sp |
|
1045 |
apply (erule_tac x = p in allE) |
|
1046 |
by (auto simp:Truncate co2sobj.simps cp2sproc_def split:option.splits) |
|
1047 |
from os have f_in': "is_file s f" by (simp add:Truncate) |
|
1048 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf" |
|
1049 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Truncate) |
|
1050 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf |
|
1051 |
apply (erule_tac x = f in allE) |
|
1052 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits) |
|
1053 |
apply (case_tac f, simp) |
|
1054 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+) |
|
1055 |
done |
|
1056 |
have "search_check s' (up, rp, tp) f" |
|
1057 |
using p1 p2 p2' vd cf2sf f_in' grant Truncate f_in |
|
1058 |
apply (rule_tac s = s in enrich_search_check) |
|
1059 |
by (simp_all split:option.splits) |
|
1060 |
thus ?thesis using p1' p2' |
|
1061 |
apply (simp add:Truncate split:option.splits) |
|
1062 |
using grant Truncate p1 p2 |
|
1063 |
by (simp add:Truncate grant p1 p2) |
|
1064 |
qed |
|
1065 |
ultimately show ?thesis using vs' |
|
1066 |
by (erule_tac valid.intros(2), simp+) |
|
1067 |
next |
|
1068 |
case (CreateMsgq p q) |
|
1069 |
have p_in: "p \<in> current_procs s'" using os alive |
|
1070 |
apply (erule_tac x = "O_proc p" in allE) |
|
1071 |
by (auto simp:CreateMsgq) |
|
89 | 1072 |
have q_not_in: "q \<notin> current_msgqs s'" |
1073 |
using os alive' CreateMsgq notin_cur nodel vd |
|
1074 |
apply (erule_tac x = "I_msgq q" in allE) |
|
1075 |
apply (auto split:t_enrich_obj.splits) |
|
1076 |
apply (drule nums_of_recv_0, simp+) |
|
1077 |
apply (drule new_msgq_1, simp+) |
|
1078 |
done |
|
83 | 1079 |
have "os_grant s' e" using p_in q_not_in by (simp add:CreateMsgq) |
1080 |
moreover have "grant s' e" |
|
1081 |
proof- |
|
1082 |
from grant obtain up rp tp |
|
1083 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
1084 |
apply (simp add:CreateMsgq split:option.splits) |
|
1085 |
by (case_tac a, blast) |
|
1086 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
1087 |
using os cp2sp |
|
1088 |
apply (erule_tac x = p in allE) |
|
1089 |
by (auto simp:CreateMsgq co2sobj.simps cp2sproc_def split:option.splits) |
|
1090 |
show ?thesis using p1' |
|
1091 |
apply (simp add:CreateMsgq split:option.splits) |
|
1092 |
using grant CreateMsgq p1 |
|
78 | 1093 |
by simp |
1094 |
qed |
|
1095 |
ultimately show ?thesis using vs' |
|
1096 |
by (erule_tac valid.intros(2), simp+) |
|
83 | 1097 |
next |
1098 |
case (RemoveMsgq p q) |
|
1099 |
have p_in: "p \<in> current_procs s'" using os alive |
|
1100 |
apply (erule_tac x = "O_proc p" in allE) |
|
1101 |
by (auto simp:RemoveMsgq) |
|
1102 |
have q_in: "q \<in> current_msgqs s'" using os alive |
|
1103 |
apply (erule_tac x = "O_msgq q" in allE) |
|
78 | 1104 |
by (simp add:RemoveMsgq) |
83 | 1105 |
have "os_grant s' e" using p_in q_in by (simp add:RemoveMsgq) |
1106 |
moreover have "grant s' e" |
|
1107 |
proof- |
|
1108 |
from grant obtain up rp tp uq rq tq |
|
1109 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
1110 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)" |
|
1111 |
apply (simp add:RemoveMsgq split:option.splits) |
|
1112 |
by (case_tac a, case_tac aa, blast) |
|
1113 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
1114 |
using os cp2sp |
|
1115 |
apply (erule_tac x = p in allE) |
|
1116 |
by (auto simp:RemoveMsgq co2sobj.simps cp2sproc_def split:option.splits) |
|
1117 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)" |
|
1118 |
using os cq2sq vd |
|
1119 |
apply (erule_tac x = q in allE) |
|
1120 |
by (auto simp:RemoveMsgq co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits) |
|
1121 |
show ?thesis using p1' p2' grant p1 p2 |
|
1122 |
by (simp add:RemoveMsgq) |
|
1123 |
qed |
|
1124 |
ultimately show ?thesis using vs' |
|
1125 |
by (erule_tac valid.intros(2), simp+) |
|
1126 |
next |
|
1127 |
case (SendMsg p q m) |
|
1128 |
have p_in: "p \<in> current_procs s'" using os alive |
|
1129 |
apply (erule_tac x = "O_proc p" in allE) |
|
1130 |
by (auto simp:SendMsg) |
|
1131 |
have q_in: "q \<in> current_msgqs s'" using os alive |
|
1132 |
apply (erule_tac x = "O_msgq q" in allE) |
|
1133 |
by (simp add:SendMsg) |
|
89 | 1134 |
have m_not_in: "m \<notin> set (msgs_of_queue s' q)" |
1135 |
using os alive' notin_cur SendMsg q_in nodel vd |
|
1136 |
apply (erule_tac x = "I_msg q m" in allE) |
|
93 | 1137 |
apply (case_tac obj', auto) |
89 | 1138 |
apply (drule nums_of_recv_0, simp+) |
1139 |
apply (drule new_msgq_1, simp+) |
|
84
cebdef333899
cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents:
83
diff
changeset
|
1140 |
done |
88 | 1141 |
have "os_grant s' e" using p_in q_in m_not_in sms_remain os |
78 | 1142 |
by (simp add:SendMsg) |
83 | 1143 |
moreover have "grant s' e" |
1144 |
proof- |
|
1145 |
from grant obtain up rp tp uq rq tq |
|
1146 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
1147 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)" |
|
1148 |
apply (simp add:SendMsg split:option.splits) |
|
1149 |
by (case_tac a, case_tac aa, blast) |
|
1150 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
1151 |
using os cp2sp |
|
1152 |
apply (erule_tac x = p in allE) |
|
1153 |
by (auto simp:SendMsg co2sobj.simps cp2sproc_def split:option.splits) |
|
1154 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)" |
|
1155 |
using os cq2sq vd |
|
1156 |
apply (erule_tac x = q in allE) |
|
1157 |
by (auto simp:SendMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits) |
|
1158 |
show ?thesis using p1' p2' grant p1 p2 |
|
1159 |
by (simp add:SendMsg) |
|
1160 |
qed |
|
1161 |
ultimately show ?thesis using vs' |
|
1162 |
by (erule_tac valid.intros(2), simp+) |
|
1163 |
next |
|
1164 |
case (RecvMsg p q m) |
|
1165 |
have p_in: "p \<in> current_procs s'" using os alive |
|
1166 |
apply (erule_tac x = "O_proc p" in allE) |
|
1167 |
by (auto simp:RecvMsg) |
|
1168 |
have q_in: "q \<in> current_msgqs s'" using os alive |
|
1169 |
apply (erule_tac x = "O_msgq q" in allE) |
|
1170 |
by (simp add:RecvMsg) |
|
1171 |
have m_in: "m = hd (msgs_of_queue s' q)" |
|
1172 |
and sms_not_empty: "msgs_of_queue s' q \<noteq> []" |
|
1173 |
using os sms_remain |
|
1174 |
by (auto simp:RecvMsg) |
|
1175 |
have "os_grant s' e" using p_in q_in m_in sms_not_empty os |
|
78 | 1176 |
by (simp add:RecvMsg) |
83 | 1177 |
moreover have "grant s' e" |
1178 |
proof- |
|
1179 |
from grant obtain up rp tp uq rq tq um rm tm |
|
1180 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)" |
|
1181 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)" |
|
1182 |
and p3: "sectxt_of_obj s (O_msg q m) = Some (um, rm, tm)" |
|
1183 |
apply (simp add:RecvMsg split:option.splits) |
|
1184 |
by (case_tac a, case_tac aa, case_tac ab, blast) |
|
1185 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)" |
|
1186 |
using os cp2sp |
|
1187 |
apply (erule_tac x = p in allE) |
|
1188 |
by (auto simp:RecvMsg co2sobj.simps cp2sproc_def split:option.splits) |
|
1189 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)" |
|
1190 |
using os cq2sq vd |
|
1191 |
apply (erule_tac x = q in allE) |
|
1192 |
by (auto simp:RecvMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits) |
|
1193 |
from p3 have p3': "sectxt_of_obj s' (O_msg q m) = Some (um, rm, tm)" |
|
1194 |
using sms_remain cq2sq vd os p2 p2' p3 |
|
1195 |
apply (erule_tac x = q in allE) |
|
1196 |
apply (erule_tac x = q in allE) |
|
1197 |
apply (clarsimp simp:RecvMsg) |
|
1198 |
apply (simp add:cq2smsgq_def split:option.splits if_splits) |
|
1199 |
apply (drule current_has_sms', simp, simp) |
|
1200 |
apply (case_tac "msgs_of_queue s q", simp) |
|
1201 |
apply (simp add:cqm2sms.simps split:option.splits) |
|
1202 |
apply (auto simp add:cm2smsg_def split:option.splits if_splits)[1] |
|
1203 |
done |
|
1204 |
show ?thesis using p1' p2' p3' grant p1 p2 p3 |
|
1205 |
by (simp add:RecvMsg) |
|
1206 |
qed |
|
1207 |
ultimately show ?thesis using vs' |
|
1208 |
by (erule_tac valid.intros(2), simp+) |
|
1209 |
next |
|
1210 |
case (CreateSock p af st fd inum) |
|
1211 |
show ?thesis using grant |
|
1212 |
by (simp add:CreateSock) |
|
1213 |
next |
|
1214 |
case (Bind p fd addr) |
|
1215 |
show ?thesis using grant |
|
1216 |
by (simp add:Bind) |
|
1217 |
next |
|
1218 |
case (Connect p fd addr) |
|
1219 |
show ?thesis using grant |
|
1220 |
by (simp add:Connect) |
|
1221 |
next |
|
1222 |
case (Listen p fd) |
|
1223 |
show ?thesis using grant |
|
1224 |
by (simp add:Listen) |
|
1225 |
next |
|
1226 |
case (Accept p fd addr port fd' inum) |
|
1227 |
show ?thesis using grant |
|
1228 |
by (simp add:Accept) |
|
1229 |
next |
|
1230 |
case (SendSock p fd) |
|
1231 |
show ?thesis using grant |
|
1232 |
by (simp add:SendSock) |
|
1233 |
next |
|
1234 |
case (RecvSock p fd) |
|
1235 |
show ?thesis using grant |
|
1236 |
by (simp add:RecvSock) |
|
1237 |
next |
|
1238 |
case (Shutdown p fd how) |
|
1239 |
show ?thesis using grant |
|
1240 |
by (simp add:Shutdown) |
|
1241 |
qed |
|
1242 |
qed |
|
79 | 1243 |
|
87 | 1244 |
lemma current_proc_fds_in_curp: |
1245 |
"\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s" |
|
1246 |
apply (induct s) |
|
1247 |
apply (simp add:init_fds_of_proc_prop1) |
|
1248 |
apply (frule vt_grant_os, frule vd_cons) |
|
1249 |
apply (case_tac a, auto split:if_splits option.splits) |
|
1250 |
done |
|
79 | 1251 |
|
87 | 1252 |
lemma get_parentfs_ctxts_prop: |
1253 |
"\<lbrakk>get_parentfs_ctxts s (a # f) = Some ctxts; sectxt_of_obj s (O_dir f) = Some ctxt; valid s\<rbrakk> |
|
1254 |
\<Longrightarrow> ctxt \<in> set (ctxts)" |
|
1255 |
apply (induct f) |
|
1256 |
apply (auto split:option.splits) |
|
79 | 1257 |
done |
1258 |
||
87 | 1259 |
lemma search_check_allp_intro: |
1260 |
"\<lbrakk>search_check s sp pf; get_parentfs_ctxts s pf = Some ctxts; valid s; is_dir s pf\<rbrakk> |
|
1261 |
\<Longrightarrow> search_check_allp sp (set ctxts)" |
|
1262 |
apply (case_tac pf) |
|
1263 |
apply (simp split:option.splits if_splits add:search_check_allp_def) |
|
1264 |
apply (rule ballI) |
|
1265 |
apply (auto simp:search_check_ctxt_def search_check_dir_def split:if_splits option.splits) |
|
1266 |
apply (auto simp:search_check_allp_def search_check_file_def) |
|
1267 |
apply (frule is_dir_not_file, simp) |
|
1268 |
done |
|
79 | 1269 |
|
87 | 1270 |
lemma search_check_leveling_f: |
1271 |
"\<lbrakk>search_check s sp pf; parent f = Some pf; is_file s f; valid s; |
|
1272 |
sectxt_of_obj s (O_file f) = Some fctxt; search_check_file sp fctxt\<rbrakk> |
|
1273 |
\<Longrightarrow> search_check s sp f" |
|
1274 |
apply (case_tac f, simp+) |
|
1275 |
apply (auto split:option.splits simp:search_check_ctxt_def) |
|
1276 |
apply (frule parentf_is_dir_prop2, simp) |
|
1277 |
apply (erule get_pfs_secs_prop, simp) |
|
1278 |
apply (erule_tac search_check_allp_intro, simp_all) |
|
1279 |
apply (simp add:parentf_is_dir_prop2) |
|
1280 |
done |
|
80 | 1281 |
|
83 | 1282 |
|
79 | 1283 |
lemma current_fflag_in_fds: |
1284 |
"\<lbrakk>flags_of_proc_fd s p fd = Some flag; valid s\<rbrakk> \<Longrightarrow> fd \<in> current_proc_fds s p" |
|
1285 |
apply (induct s arbitrary:p) |
|
1286 |
apply (simp add:flags_of_proc_fd.simps file_of_proc_fd.simps init_oflags_prop2) |
|
1287 |
apply (frule vd_cons, frule vt_grant_os, case_tac a) |
|
1288 |
apply (auto split:if_splits option.splits dest:proc_fd_in_fds) |
|
80 | 1289 |
done |
79 | 1290 |
|
1291 |
lemma current_fflag_has_ffd: |
|
1292 |
"\<lbrakk>flags_of_proc_fd s p fd = Some flag; valid s\<rbrakk> \<Longrightarrow> \<exists> f. file_of_proc_fd s p fd = Some f" |
|
1293 |
apply (induct s arbitrary:p) |
|
1294 |
apply (simp add: file_of_proc_fd.simps init_fileflag_valid) |
|
1295 |
apply (frule vd_cons, frule vt_grant_os, case_tac a) |
|
1296 |
apply (auto split:if_splits option.splits dest:proc_fd_in_fds) |
|
80 | 1297 |
done |
79 | 1298 |
|
82 | 1299 |
lemma oflags_check_remove_create: |
1300 |
"oflags_check flags sp sf \<Longrightarrow> oflags_check (remove_create_flag flags) sp sf" |
|
1301 |
apply (case_tac flags) |
|
1302 |
apply (auto simp:oflags_check_def perms_of_flags_def perm_of_oflag_def split:bool.splits) |
|
1303 |
done |
|
81 | 1304 |
|
93 | 1305 |
fun enrich_msgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msgq \<Rightarrow> t_state" |
1306 |
where |
|
1307 |
"enrich_msgq [] tq dq = []" |
|
1308 |
| "enrich_msgq (CreateMsgq p q # s) tq dq = |
|
1309 |
(if (tq = q) |
|
1310 |
then (CreateMsgq p dq # CreateMsgq p q # s) |
|
1311 |
else CreateMsgq p q # (enrich_msgq s tq dq))" |
|
1312 |
| "enrich_msgq (SendMsg p q m # s) tq dq = |
|
1313 |
(if (tq = q) |
|
1314 |
then (SendMsg p dq m # SendMsg p q m # (enrich_msgq s tq dq)) |
|
1315 |
else SendMsg p q m # (enrich_msgq s tq dq))" |
|
1316 |
| "enrich_msgq (RecvMsg p q m # s) tq dq = |
|
1317 |
(if (tq = q) |
|
1318 |
then (RecvMsg p dq m # RecvMsg p q m # (enrich_msgq s tq dq)) |
|
1319 |
else RecvMsg p q m # (enrich_msgq s tq dq))" |
|
1320 |
| "enrich_msgq (e # s) tq dq = e # (enrich_msgq s tq dq)" |
|
1321 |
||
1322 |
lemma enrich_msgq_duq_in: |
|
1323 |
"\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
1324 |
\<Longrightarrow> q' \<in> current_msgqs (enrich_msgq s q q')" |
|
1325 |
apply (induct s, simp) |
|
1326 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1327 |
apply auto |
|
1328 |
done |
|
1329 |
||
1330 |
lemma enrich_msgq_duq_sms: |
|
1331 |
"\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
1332 |
\<Longrightarrow> msgs_of_queue (enrich_msgq s q q') q' = msgs_of_queue s q" |
|
1333 |
apply (induct s, simp) |
|
1334 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1335 |
apply auto |
|
1336 |
done |
|
1337 |
||
1338 |
lemma enrich_msgq_cur_inof: |
|
1339 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1340 |
\<Longrightarrow> inum_of_file (enrich_msgq s q q') f = inum_of_file s f" |
|
1341 |
apply (induct s arbitrary:f, simp) |
|
1342 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1343 |
apply (auto split:option.splits) |
|
1344 |
done |
|
1345 |
||
1346 |
lemma enrich_msgq_cur_inos: |
|
1347 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1348 |
\<Longrightarrow> inum_of_socket (enrich_msgq s q q') = inum_of_socket s" |
|
1349 |
apply (rule ext) |
|
1350 |
apply (induct s, simp) |
|
1351 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1352 |
apply (auto split:option.splits) |
|
1353 |
done |
|
1354 |
||
1355 |
lemma enrich_msgq_cur_inos': |
|
1356 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1357 |
\<Longrightarrow> inum_of_socket (enrich_msgq s q q') sock = inum_of_socket s sock" |
|
1358 |
apply (simp add:enrich_msgq_cur_inos) |
|
1359 |
done |
|
1360 |
||
1361 |
lemma enrich_msgq_cur_inums: |
|
1362 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1363 |
\<Longrightarrow> current_inode_nums (enrich_msgq s q q') = current_inode_nums s" |
|
1364 |
apply (auto simp:current_inode_nums_def current_file_inums_def |
|
1365 |
current_sock_inums_def enrich_msgq_cur_inof enrich_msgq_cur_inos) |
|
1366 |
done |
|
1367 |
||
1368 |
lemma enrich_msgq_cur_itag: |
|
1369 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1370 |
\<Longrightarrow> itag_of_inum (enrich_msgq s q q') = itag_of_inum s" |
|
1371 |
apply (rule ext) |
|
1372 |
apply (induct s, simp) |
|
1373 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1374 |
apply (auto split:option.splits t_socket_type.splits) |
|
1375 |
done |
|
1376 |
||
1377 |
lemma enrich_msgq_cur_tcps: |
|
1378 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1379 |
\<Longrightarrow> is_tcp_sock (enrich_msgq s q q') = is_tcp_sock s" |
|
1380 |
apply (rule ext) |
|
1381 |
apply (auto simp:is_tcp_sock_def enrich_msgq_cur_itag enrich_msgq_cur_inos |
|
1382 |
split:option.splits t_inode_tag.splits) |
|
1383 |
done |
|
1384 |
||
1385 |
lemma enrich_msgq_cur_udps: |
|
1386 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1387 |
\<Longrightarrow> is_udp_sock (enrich_msgq s q q') = is_udp_sock s" |
|
1388 |
apply (rule ext) |
|
1389 |
apply (auto simp:is_udp_sock_def enrich_msgq_cur_itag enrich_msgq_cur_inos |
|
1390 |
split:option.splits t_inode_tag.splits) |
|
1391 |
done |
|
1392 |
||
1393 |
lemma enrich_msgq_cur_msgqs: |
|
1394 |
"\<lbrakk>q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
1395 |
\<Longrightarrow> current_msgqs (enrich_msgq s q q') = current_msgqs s \<union> {q'}" |
|
1396 |
apply (induct s, simp) |
|
1397 |
apply (frule vt_grant_os, frule vd_cons) |
|
1398 |
apply (case_tac a, auto) |
|
1399 |
done |
|
1400 |
||
1401 |
lemma enrich_msgq_cur_msgs: |
|
1402 |
"\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
1403 |
\<Longrightarrow> msgs_of_queue (enrich_msgq s q q') = (msgs_of_queue s) (q' := msgs_of_queue s q)" |
|
1404 |
apply (rule ext, simp, rule conjI, rule impI) |
|
1405 |
apply (simp add:enrich_msgq_duq_sms) |
|
1406 |
apply (rule impI) |
|
1407 |
apply (induct s, simp) |
|
1408 |
apply (frule vt_grant_os, frule vd_cons) |
|
1409 |
apply (case_tac a, auto) |
|
1410 |
done |
|
1411 |
||
1412 |
lemma enrich_msgq_cur_procs: |
|
1413 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1414 |
\<Longrightarrow> current_procs (enrich_msgq s q q') = current_procs s" |
|
1415 |
apply (induct s, simp) |
|
1416 |
apply (frule vt_grant_os, frule vd_cons) |
|
1417 |
apply (case_tac a, auto) |
|
1418 |
done |
|
1419 |
||
1420 |
lemma enrich_msgq_cur_files: |
|
1421 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1422 |
\<Longrightarrow> current_files (enrich_msgq s q q') = current_files s" |
|
1423 |
apply (auto simp:current_files_def) |
|
1424 |
apply (simp add:enrich_msgq_cur_inof)+ |
|
1425 |
done |
|
1426 |
||
1427 |
lemma enrich_msgq_cur_fds: |
|
1428 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1429 |
\<Longrightarrow> current_proc_fds (enrich_msgq s q q') = current_proc_fds s" |
|
1430 |
apply (induct s, simp) |
|
1431 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1432 |
apply auto |
|
1433 |
done |
|
1434 |
||
1435 |
lemma enrich_msgq_filefd: |
|
1436 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1437 |
\<Longrightarrow> file_of_proc_fd (enrich_msgq s q q') = file_of_proc_fd s" |
|
1438 |
apply (rule ext, rule ext) |
|
1439 |
apply (induct s, simp) |
|
1440 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1441 |
apply auto |
|
1442 |
done |
|
1443 |
||
1444 |
lemma enrich_msgq_flagfd: |
|
1445 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1446 |
\<Longrightarrow> flags_of_proc_fd (enrich_msgq s q q') = flags_of_proc_fd s" |
|
1447 |
apply (rule ext, rule ext) |
|
1448 |
apply (induct s, simp) |
|
1449 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1450 |
apply auto |
|
1451 |
done |
|
1452 |
||
1453 |
lemma enrich_msgq_proc_fds: |
|
1454 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1455 |
\<Longrightarrow> proc_file_fds (enrich_msgq s q q') = proc_file_fds s" |
|
1456 |
apply (auto simp:proc_file_fds_def enrich_msgq_filefd) |
|
1457 |
done |
|
1458 |
||
1459 |
lemma enrich_msgq_hungs: |
|
1460 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1461 |
\<Longrightarrow> files_hung_by_del (enrich_msgq s q q') = files_hung_by_del s" |
|
1462 |
apply (induct s, simp) |
|
1463 |
apply (frule vt_grant_os, frule vd_cons, case_tac a) |
|
1464 |
apply (auto simp:files_hung_by_del.simps) |
|
1465 |
done |
|
1466 |
||
1467 |
lemma enrich_msgq_is_file: |
|
1468 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1469 |
\<Longrightarrow> is_file (enrich_msgq s q q') = is_file s" |
|
1470 |
apply (rule ext) |
|
1471 |
apply (auto simp add:is_file_def enrich_msgq_cur_itag enrich_msgq_cur_inof |
|
1472 |
split:option.splits t_inode_tag.splits) |
|
1473 |
done |
|
1474 |
||
1475 |
lemma enrich_msgq_is_dir: |
|
1476 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1477 |
\<Longrightarrow> is_dir (enrich_msgq s q q') = is_dir s" |
|
1478 |
apply (rule ext) |
|
1479 |
apply (auto simp add:is_dir_def enrich_msgq_cur_itag enrich_msgq_cur_inof |
|
1480 |
split:option.splits t_inode_tag.splits) |
|
1481 |
done |
|
1482 |
||
1483 |
lemma enrich_msgq_sameinode: |
|
1484 |
"\<lbrakk>no_del_event s; valid s\<rbrakk> |
|
1485 |
\<Longrightarrow> (f \<in> same_inode_files (enrich_msgq s q q') f') = (f \<in> same_inode_files s f')" |
|
1486 |
apply (induct s, simp) |
|
1487 |
apply (simp add:same_inode_files_def) |
|
1488 |
apply (auto simp:enrich_msgq_is_file enrich_msgq_cur_inof) |
|
1489 |
done |
|
1490 |
||
1491 |
lemma enrich_msgq_tainted_aux1: |
|
1492 |
"\<lbrakk>no_del_event s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; valid s\<rbrakk> |
|
1493 |
\<Longrightarrow> (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}) \<subseteq> tainted (enrich_msgq s q q')" |
|
1494 |
apply (induct s, simp) |
|
1495 |
apply (frule vt_grant_os, frule vd_cons) |
|
1496 |
apply (case_tac a) |
|
1497 |
apply (auto split:option.splits if_splits dest:tainted_in_current |
|
1498 |
simp:enrich_msgq_filefd enrich_msgq_sameinode) |
|
1499 |
done |
|
1500 |
||
1501 |
lemma enrich_msgq_tainted_aux2: |
|
1502 |
"\<lbrakk>no_del_event s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; valid s; valid (enrich_msgq s q q')\<rbrakk> |
|
1503 |
\<Longrightarrow> tainted (enrich_msgq s q q') \<subseteq> (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s})" |
|
1504 |
apply (induct s, simp) |
|
1505 |
apply (frule vt_grant_os, frule vd_cons) |
|
1506 |
apply (case_tac a) |
|
1507 |
apply (auto split:option.splits if_splits simp:enrich_msgq_filefd enrich_msgq_sameinode |
|
1508 |
dest:tainted_in_current vd_cons) |
|
1509 |
apply (drule_tac vd_cons)+ |
|
1510 |
apply (simp) |
|
1511 |
apply (drule set_mp) |
|
1512 |
apply simp |
|
1513 |
apply simp |
|
1514 |
apply (drule_tac s = s in tainted_in_current) |
|
1515 |
apply simp+ |
|
1516 |
done |
|
1517 |
||
1518 |
lemma enrich_msgq_alive: |
|
1519 |
"\<lbrakk>alive s obj; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
1520 |
\<Longrightarrow> alive (enrich_msgq s q q') obj" |
|
1521 |
apply (case_tac obj) |
|
1522 |
apply (simp_all add:enrich_msgq_is_file enrich_msgq_is_dir enrich_msgq_cur_msgqs |
|
1523 |
enrich_msgq_cur_msgs enrich_msgq_cur_procs enrich_msgq_cur_fds |
|
1524 |
enrich_msgq_cur_tcps enrich_msgq_cur_udps) |
|
1525 |
apply (rule impI, simp) |
|
1526 |
done |
|
1527 |
||
1528 |
lemma enrich_msgq_alive': |
|
1529 |
"\<lbrakk>alive (enrich_msgq s q q') obj; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
1530 |
\<Longrightarrow> alive s obj \<or> obj = O_msgq q' \<or> (\<exists> m. obj = O_msg q' m \<and> alive s (O_msg q m))" |
|
1531 |
apply (case_tac obj) |
|
1532 |
apply (simp_all add:enrich_msgq_is_file enrich_msgq_is_dir enrich_msgq_cur_msgqs |
|
1533 |
enrich_msgq_cur_msgs enrich_msgq_cur_procs enrich_msgq_cur_fds |
|
1534 |
enrich_msgq_cur_tcps enrich_msgq_cur_udps) |
|
1535 |
apply (auto split:if_splits) |
|
1536 |
done |
|
1537 |
||
1538 |
lemma enrich_msgq_not_alive: |
|
1539 |
"\<lbrakk>enrich_not_alive s (E_msgq q') obj; q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
1540 |
\<Longrightarrow> enrich_not_alive (enrich_msgq s q q') (E_msgq q') obj" |
|
1541 |
apply (case_tac obj) |
|
1542 |
apply (auto simp:enrich_msgq_cur_fds enrich_msgq_cur_files |
|
1543 |
enrich_msgq_cur_procs enrich_msgq_cur_inums enrich_msgq_cur_msgqs enrich_msgq_cur_msgs) |
|
1544 |
done |
|
1545 |
||
1546 |
lemma enrich_msgq_nodel: |
|
1547 |
"no_del_event (enrich_msgq s q q') = no_del_event s" |
|
1548 |
apply (induct s, simp) |
|
1549 |
by (case_tac a, auto) |
|
1550 |
||
1551 |
lemma enrich_msgq_died_proc: |
|
1552 |
"died (O_proc p) (enrich_msgq s q q') = died (O_proc p) s" |
|
1553 |
apply (induct s, simp) |
|
1554 |
by (case_tac a, auto) |
|
1555 |
||
1556 |
lemma cf2sfile_execve: |
|
1557 |
"\<lbrakk>ff \<in> current_files (Execve p f fds # s); valid (Execve p f fds # s)\<rbrakk> |
|
1558 |
\<Longrightarrow> cf2sfile (Execve p f fds # s) ff= cf2sfile s ff" |
|
1559 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1560 |
lemma cf2sfile_clone: |
|
1561 |
"\<lbrakk>ff \<in> current_files (Clone p p' fds # s); valid (Clone p p' fds # s)\<rbrakk> |
|
1562 |
\<Longrightarrow> cf2sfile (Clone p p' fds # s) ff= cf2sfile s ff" |
|
1563 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1564 |
lemma cf2sfile_ptrace: |
|
1565 |
"\<lbrakk>ff \<in> current_files (Ptrace p p' # s); valid (Ptrace p p' # s)\<rbrakk> |
|
1566 |
\<Longrightarrow> cf2sfile (Ptrace p p' # s) ff= cf2sfile s ff" |
|
1567 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1568 |
lemma cf2sfile_readfile: |
|
1569 |
"\<lbrakk>ff \<in> current_files (ReadFile p fd # s); valid (ReadFile p fd # s)\<rbrakk> |
|
1570 |
\<Longrightarrow> cf2sfile (ReadFile p fd # s) ff= cf2sfile s ff" |
|
1571 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1572 |
lemma cf2sfile_writefile: |
|
1573 |
"\<lbrakk>ff \<in> current_files (WriteFile p fd # s); valid (WriteFile p fd # s)\<rbrakk> |
|
1574 |
\<Longrightarrow> cf2sfile (WriteFile p fd # s) ff= cf2sfile s ff" |
|
1575 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1576 |
lemma cf2sfile_truncate: |
|
1577 |
"\<lbrakk>ff \<in> current_files (Truncate p f len # s); valid (Truncate p f len # s)\<rbrakk> |
|
1578 |
\<Longrightarrow> cf2sfile (Truncate p f len # s) ff= cf2sfile s ff" |
|
1579 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1580 |
lemma cf2sfile_createmsgq: |
|
1581 |
"\<lbrakk>ff \<in> current_files (CreateMsgq p q # s); valid (CreateMsgq p q # s)\<rbrakk> |
|
1582 |
\<Longrightarrow> cf2sfile (CreateMsgq p q # s) ff= cf2sfile s ff" |
|
1583 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1584 |
lemma cf2sfile_sendmsg: |
|
1585 |
"\<lbrakk>ff \<in> current_files (SendMsg p q m # s); valid (SendMsg p q m # s)\<rbrakk> |
|
1586 |
\<Longrightarrow> cf2sfile (SendMsg p q m # s) ff = cf2sfile s ff" |
|
1587 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1588 |
lemma cf2sfile_recvmsg: |
|
1589 |
"\<lbrakk>ff \<in> current_files (RecvMsg p q m # s); valid (RecvMsg p q m # s)\<rbrakk> |
|
1590 |
\<Longrightarrow> cf2sfile (RecvMsg p q m # s) ff = cf2sfile s ff" |
|
1591 |
by (auto dest:cf2sfile_other' simp:current_files_simps) |
|
1592 |
lemmas cf2sfile_other'' = cf2sfile_recvmsg cf2sfile_sendmsg cf2sfile_createmsgq cf2sfile_truncate |
|
1593 |
cf2sfile_writefile cf2sfile_readfile cf2sfile_ptrace cf2sfile_clone cf2sfile_execve |
|
1594 |
||
1595 |
lemma enrich_msgq_prop: |
|
1596 |
"\<lbrakk>valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
1597 |
\<Longrightarrow> valid (enrich_msgq s q q') \<and> |
|
1598 |
(\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp) \<and> |
|
1599 |
(\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f) \<and> |
|
1600 |
(\<forall> tq. tq \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq) \<and> |
|
1601 |
(\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd) \<and> |
|
1602 |
(cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q) \<and> |
|
1603 |
(tainted (enrich_msgq s q q') = (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}))" |
|
1604 |
proof (induct s) |
|
1605 |
case Nil |
|
1606 |
thus ?case by (auto) |
|
1607 |
next |
|
1608 |
case (Cons e s) |
|
1609 |
hence vd_cons': "valid (e # s)" and curq_cons: "q \<in> current_msgqs (e # s)" |
|
1610 |
and curq'_cons: "q' \<notin> current_msgqs (e # s)" and nodel_cons: "no_del_event (e # s)" |
|
1611 |
and os: "os_grant s e" and grant: "grant s e" and vd: "valid s" |
|
1612 |
by (auto dest:vd_cons vt_grant_os vt_grant) |
|
1613 |
from curq'_cons nodel_cons have curq': "q' \<notin> current_msgqs s" by (case_tac e, auto) |
|
1614 |
from nodel_cons have nodel: "no_del_event s" by (case_tac e, auto) |
|
1615 |
from nodel curq' vd Cons |
|
1616 |
have pre: "q \<in> current_msgqs s \<Longrightarrow> valid (enrich_msgq s q q') \<and> |
|
1617 |
(\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp) \<and> |
|
1618 |
(\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f) \<and> |
|
1619 |
(\<forall>tq. tq \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq) \<and> |
|
1620 |
(\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd) \<and> |
|
1621 |
(cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q) \<and> |
|
1622 |
(tainted (enrich_msgq s q q') = (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}))" |
|
1623 |
by auto |
|
1624 |
||
1625 |
from pre have pre_vd: "q \<in> current_msgqs s \<Longrightarrow> valid (enrich_msgq s q q')" by simp |
|
1626 |
from pre have pre_sp: "\<And> tp. \<lbrakk>tp \<in> current_procs s; q \<in> current_msgqs s\<rbrakk> |
|
1627 |
\<Longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp" by auto |
|
1628 |
from pre have pre_sf: "\<And> f. \<lbrakk>f \<in> current_files s; q \<in> current_msgqs s\<rbrakk> |
|
1629 |
\<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" by auto |
|
1630 |
from pre have pre_sq: "\<And> tq. \<lbrakk>tq \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk> |
|
1631 |
\<Longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq" by auto |
|
1632 |
from pre have pre_sfd: "\<And> tp fd. \<lbrakk>fd \<in> proc_file_fds s tp; q \<in> current_msgqs s\<rbrakk> |
|
1633 |
\<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" by auto |
|
1634 |
hence pre_sfd': "\<And> tp fd f. \<lbrakk>file_of_proc_fd s tp fd = Some f; q \<in> current_msgqs s\<rbrakk> |
|
1635 |
\<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def) |
|
1636 |
from pre have pre_duq: "q \<in> current_msgqs s \<Longrightarrow> cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q" |
|
1637 |
by auto |
|
1638 |
have vd_enrich:"q \<in> current_msgqs s \<Longrightarrow> valid (e # enrich_msgq s q q')" |
|
1639 |
apply (frule pre_vd) |
|
1640 |
apply (erule_tac s = s and obj' = "E_msgq q'" in enrich_valid_intro_cons) |
|
1641 |
apply (simp_all add:pre nodel nodel_cons curq_cons vd_cons' vd enrich_msgq_hungs) |
|
1642 |
apply (clarsimp simp:nodel vd curq' enrich_msgq_alive) |
|
1643 |
apply (rule allI, rule impI, erule enrich_msgq_not_alive) |
|
1644 |
apply (simp_all add:curq' curq'_cons nodel vd enrich_msgq_cur_msgs enrich_msgq_filefd enrich_msgq_flagfd) |
|
1645 |
done |
|
1646 |
||
1647 |
have q_neq_q': "q' \<noteq> q" using curq'_cons curq_cons by auto |
|
1648 |
||
1649 |
have vd_enrich_cons: "valid (enrich_msgq (e # s) q q')" |
|
1650 |
proof- |
|
1651 |
have "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> valid (enrich_msgq (e # s) q q')" |
|
1652 |
proof- |
|
1653 |
fix p q'' assume ev: "e = CreateMsgq p q''" |
|
1654 |
show "valid (enrich_msgq (e # s) q q')" |
|
1655 |
proof (cases "q'' = q") |
|
1656 |
case False with ev vd_enrich curq_cons |
|
1657 |
show ?thesis by simp |
|
1658 |
next |
|
1659 |
case True |
|
1660 |
have "os_grant (CreateMsgq p q # s) (CreateMsgq p q')" |
|
1661 |
using os ev |
|
1662 |
by (simp add:q_neq_q' curq') |
|
1663 |
moreover have "grant (CreateMsgq p q # s) (CreateMsgq p q')" |
|
1664 |
using grant ev |
|
1665 |
by (auto simp add:sectxt_of_obj_def split:option.splits) |
|
1666 |
ultimately |
|
1667 |
show ?thesis using ev vd_cons' True |
|
1668 |
by (auto intro: valid.intros(2)) |
|
1669 |
qed |
|
1670 |
qed |
|
1671 |
moreover have "\<And> p q'' m. \<lbrakk>e = SendMsg p q'' m; q \<in> current_msgqs s\<rbrakk> |
|
1672 |
\<Longrightarrow> valid (enrich_msgq (e # s) q q')" |
|
1673 |
proof- |
|
1674 |
fix p q'' m assume ev: "e = SendMsg p q'' m" and q_in: "q \<in> current_msgqs s" |
|
1675 |
show "valid (enrich_msgq (e # s) q q')" |
|
1676 |
proof (cases "q'' = q") |
|
1677 |
case False with ev vd_enrich q_in |
|
1678 |
show ?thesis by simp |
|
1679 |
next |
|
1680 |
case True |
|
1681 |
from grant os ev True obtain psec qsec |
|
1682 |
where psec: "sectxt_of_obj s (O_proc p) = Some psec" |
|
1683 |
and qsec: "sectxt_of_obj s (O_msgq q) = Some qsec" |
|
1684 |
by (auto split:option.splits) |
|
1685 |
from psec q_in os ev |
|
1686 |
have psec':"sectxt_of_obj (enrich_msgq s q q') (O_proc p) = Some psec" |
|
1687 |
by (auto dest!:pre_sp simp:cp2sproc_def split:option.splits) |
|
1688 |
from qsec q_in pre_duq vd |
|
1689 |
have qsec': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = Some qsec" |
|
1690 |
by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms') |
|
1691 |
show ?thesis using ev True vd_cons' q_in vd_enrich nodel vd |
|
1692 |
curq' psec psec' qsec qsec' grant os q_neq_q' |
|
1693 |
apply (simp, erule_tac valid.intros(2)) |
|
1694 |
apply (auto simp:q_neq_q' enrich_msgq_cur_msgqs enrich_msgq_cur_procs |
|
1695 |
enrich_msgq_cur_msgs sectxt_of_obj_simps) |
|
1696 |
done |
|
1697 |
qed |
|
1698 |
qed |
|
1699 |
moreover have "\<And> p q'' m. \<lbrakk>e = RecvMsg p q'' m; q \<in> current_msgqs s\<rbrakk> |
|
1700 |
\<Longrightarrow> valid (enrich_msgq (e # s) q q')" |
|
1701 |
proof- |
|
1702 |
fix p q'' m assume ev: "e = RecvMsg p q'' m" and q_in: "q \<in> current_msgqs s" |
|
1703 |
show "valid (enrich_msgq (e # s) q q')" |
|
1704 |
proof (cases "q'' = q") |
|
1705 |
case False with ev vd_enrich q_in |
|
1706 |
show ?thesis by simp |
|
1707 |
next |
|
1708 |
case True |
|
1709 |
from grant os ev True obtain psec qsec msec |
|
1710 |
where psec: "sectxt_of_obj s (O_proc p) = Some psec" |
|
1711 |
and qsec: "sectxt_of_obj s (O_msgq q) = Some qsec" |
|
1712 |
and msec: "sectxt_of_obj s (O_msg q (hd (msgs_of_queue s q))) = Some msec" |
|
1713 |
by (auto split:option.splits) |
|
1714 |
from psec q_in os ev |
|
1715 |
have psec':"sectxt_of_obj (enrich_msgq s q q') (O_proc p) = Some psec" |
|
1716 |
by (auto dest!:pre_sp simp:cp2sproc_def split:option.splits) |
|
1717 |
from qsec q_in pre_duq vd |
|
1718 |
have qsec': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = Some qsec" |
|
1719 |
by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms') |
|
1720 |
from qsec q_in vd |
|
1721 |
have qsec'': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q) = Some qsec" |
|
1722 |
apply (frule_tac pre_sq, simp_all) |
|
1723 |
by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms') |
|
1724 |
from msec q_in pre_duq vd qsec qsec' qsec'' curq' nodel |
|
1725 |
have msec': "sectxt_of_obj (enrich_msgq s q q') (O_msg q' (hd (msgs_of_queue s q))) = Some msec" |
|
1726 |
apply (auto simp:cq2smsgq_def enrich_msgq_cur_msgs |
|
1727 |
split:option.splits dest!:current_has_sms') |
|
1728 |
apply (case_tac "msgs_of_queue s q") |
|
1729 |
using os ev True apply simp |
|
1730 |
apply (simp add:cqm2sms.simps split:option.splits) |
|
1731 |
apply (auto simp:cm2smsg_def split:option.splits) |
|
1732 |
done |
|
1733 |
show ?thesis using ev True vd_cons' q_in vd_enrich nodel vd |
|
1734 |
curq' grant os q_neq_q' psec psec' msec msec' qsec qsec' |
|
1735 |
apply (simp, erule_tac valid.intros(2)) |
|
1736 |
apply (auto simp:enrich_msgq_cur_msgqs enrich_msgq_cur_procs |
|
1737 |
enrich_msgq_cur_msgs sectxt_of_obj_simps) |
|
1738 |
done |
|
1739 |
qed |
|
1740 |
qed |
|
1741 |
ultimately |
|
1742 |
show ?thesis using vd_enrich curq_cons vd_cons' |
|
1743 |
apply (case_tac e) |
|
1744 |
apply (auto simp del:enrich_msgq.simps) |
|
1745 |
apply (auto split:if_splits ) |
|
1746 |
done |
|
1747 |
qed |
|
1748 |
||
1749 |
have curpsec: "\<And> tp. \<lbrakk>tp \<in> current_procs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> |
|
1750 |
sectxt_of_obj (enrich_msgq s q q') (O_proc tp) = sectxt_of_obj s (O_proc tp)" |
|
1751 |
using pre_vd vd |
|
1752 |
apply (frule_tac pre_sp, simp) |
|
1753 |
by (auto simp:cp2sproc_def split:option.splits if_splits dest!:current_has_sec') |
|
1754 |
have curfsec: "\<And> f. \<lbrakk>is_file s f; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> |
|
1755 |
sectxt_of_obj (enrich_msgq s q q') (O_file f) = sectxt_of_obj s (O_file f)" |
|
1756 |
proof- |
|
1757 |
fix f |
|
1758 |
assume a1: "is_file s f" and a2: "q \<in> current_msgqs s" |
|
1759 |
from a2 pre_sf pre_vd |
|
1760 |
have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" |
|
1761 |
and vd_enrich: "valid (enrich_msgq s q q')" |
|
1762 |
by auto |
|
1763 |
hence csf: "cf2sfile (enrich_msgq s q q') f = cf2sfile s f" |
|
1764 |
using a1 by (auto simp:is_file_in_current) |
|
1765 |
from a1 obtain sf where csf_some: "cf2sfile s f = Some sf" |
|
1766 |
apply (case_tac "cf2sfile s f") |
|
1767 |
apply (drule current_file_has_sfile') |
|
1768 |
apply (simp add:vd, simp add:is_file_in_current, simp) |
|
1769 |
done |
|
1770 |
from a1 have a1': "is_file (enrich_msgq s q q') f" |
|
1771 |
using vd nodel by (simp add:enrich_msgq_is_file) |
|
1772 |
show "sectxt_of_obj (enrich_msgq s q q') (O_file f) = sectxt_of_obj s (O_file f)" |
|
1773 |
using csf csf_some vd_enrich vd a1 a1' |
|
1774 |
apply (auto simp:cf2sfile_def split:option.splits if_splits) |
|
1775 |
apply (case_tac f, simp_all) |
|
1776 |
apply (drule root_is_dir', simp+) |
|
1777 |
done |
|
1778 |
qed |
|
1779 |
have curdsec: "\<And> tf. \<lbrakk>is_dir s tf; q \<in> current_msgqs s\<rbrakk> |
|
1780 |
\<Longrightarrow> sectxt_of_obj (enrich_msgq s q q') (O_dir tf) = sectxt_of_obj s (O_dir tf)" |
|
1781 |
proof- |
|
1782 |
fix tf |
|
1783 |
assume a1: "is_dir s tf" and a2: "q \<in> current_msgqs s" |
|
1784 |
from a2 pre_sf pre_vd |
|
1785 |
have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" |
|
1786 |
and vd_enrich: "valid (enrich_msgq s q q')" |
|
1787 |
by auto |
|
1788 |
hence csf: "cf2sfile (enrich_msgq s q q') tf = cf2sfile s tf" |
|
1789 |
using a1 by (auto simp:is_dir_in_current) |
|
1790 |
from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf" |
|
1791 |
apply (case_tac "cf2sfile s tf") |
|
1792 |
apply (drule current_file_has_sfile') |
|
1793 |
apply (simp add:vd, simp add:is_dir_in_current, simp) |
|
1794 |
done |
|
1795 |
from a1 have a1': "is_dir (enrich_msgq s q q') tf" |
|
1796 |
using enrich_msgq_is_dir vd nodel by simp |
|
1797 |
from a1 have a3: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file) |
|
1798 |
from a1' vd have a3': "\<not> is_file (enrich_msgq s q q') tf" by (simp add:is_dir_not_file) |
|
1799 |
show "sectxt_of_obj (enrich_msgq s q q') (O_dir tf) = sectxt_of_obj s (O_dir tf)" |
|
1800 |
using csf csf_some a3 a3' vd_enrich vd |
|
1801 |
apply (auto simp:cf2sfile_def split:option.splits) |
|
1802 |
apply (case_tac tf) |
|
1803 |
apply (simp add:root_sec_remains, simp) |
|
1804 |
done |
|
1805 |
qed |
|
1806 |
have curpsecs: "\<And> tf ctxts'. \<lbrakk>is_dir s tf; q \<in> current_msgqs s; get_parentfs_ctxts s tf = Some ctxts'\<rbrakk> |
|
1807 |
\<Longrightarrow> \<exists> ctxts. get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts \<and> set ctxts = set ctxts'" |
|
1808 |
proof- |
|
1809 |
fix tf ctxts' |
|
1810 |
assume a1: "is_dir s tf" and a2: "q \<in> current_msgqs s" |
|
1811 |
and a4: "get_parentfs_ctxts s tf = Some ctxts'" |
|
1812 |
from a2 pre |
|
1813 |
have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" |
|
1814 |
and vd_enrich': "valid (enrich_msgq s q q')" |
|
1815 |
by auto |
|
1816 |
hence csf: "cf2sfile (enrich_msgq s q q') tf = cf2sfile s tf" |
|
1817 |
using a1 by (auto simp:is_dir_in_current) |
|
1818 |
from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf" |
|
1819 |
apply (case_tac "cf2sfile s tf") |
|
1820 |
apply (drule current_file_has_sfile') |
|
1821 |
apply (simp add:vd, simp add:is_dir_in_current, simp) |
|
1822 |
done |
|
1823 |
from a1 have a1': "is_dir (enrich_msgq s q q') tf" |
|
1824 |
using enrich_msgq_is_dir vd nodel by simp |
|
1825 |
from a1 have a5: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file) |
|
1826 |
from a1' vd have a5': "\<not> is_file (enrich_msgq s q q') tf" by (simp add:is_dir_not_file) |
|
1827 |
||
1828 |
from a1' pre_vd a2 obtain ctxts |
|
1829 |
where a3: "get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts" |
|
1830 |
apply (case_tac "get_parentfs_ctxts (enrich_msgq s q q') tf") |
|
1831 |
apply (drule get_pfs_secs_prop', simp+) |
|
1832 |
done |
|
1833 |
moreover have "set ctxts = set ctxts'" |
|
1834 |
proof (cases tf) |
|
1835 |
case Nil |
|
1836 |
with a3 a4 vd vd_enrich' |
|
1837 |
show ?thesis |
|
1838 |
by (simp add:get_parentfs_ctxts.simps root_sec_remains split:option.splits) |
|
1839 |
next |
|
1840 |
case (Cons a ff) |
|
1841 |
with csf csf_some a5 a5' vd_enrich' vd a3 a4 |
|
1842 |
show ?thesis |
|
1843 |
apply (auto simp:cf2sfile_def split:option.splits if_splits) |
|
1844 |
done |
|
1845 |
qed |
|
1846 |
ultimately |
|
1847 |
show "\<exists> ctxts. get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts \<and> set ctxts = set ctxts'" |
|
1848 |
by auto |
|
1849 |
qed |
|
1850 |
||
1851 |
have psec_cons: "\<And> tp. tp \<in> current_procs (e # s) \<Longrightarrow> |
|
1852 |
sectxt_of_obj (enrich_msgq (e # s) q q') (O_proc tp) = sectxt_of_obj (e # s) (O_proc tp)" |
|
1853 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd |
|
1854 |
apply (case_tac e) |
|
1855 |
apply (auto intro:curpsec simp:sectxt_of_obj_simps) |
|
1856 |
apply (frule curpsec, simp, frule curfsec, simp) |
|
1857 |
apply (auto split:option.splits)[1] |
|
1858 |
apply (frule vd_cons) defer apply (frule vd_cons) |
|
1859 |
apply (auto intro:curpsec simp:sectxt_of_obj_simps) |
|
1860 |
done |
|
1861 |
||
1862 |
||
1863 |
have sf_cons: "\<And> f. f \<in> current_files (e # s) \<Longrightarrow> cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1864 |
proof- |
|
1865 |
fix f |
|
1866 |
assume a1: "f \<in> current_files (e # s)" |
|
1867 |
hence a1': "f \<in> current_files (enrich_msgq (e # s) q q')" |
|
1868 |
using nodel_cons os vd vd_cons' vd_enrich_cons |
|
1869 |
apply (case_tac e) |
|
1870 |
apply (auto simp:current_files_simps enrich_msgq_cur_files dest:is_file_in_current split:option.splits) |
|
1871 |
done |
|
1872 |
have b1: "\<And> p f' flags fd opt. e = Open p f' flags fd opt \<Longrightarrow> |
|
1873 |
cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1874 |
proof- |
|
1875 |
fix p f' flags fd opt |
|
1876 |
assume ev: "e = Open p f' flags fd opt" |
|
1877 |
show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1878 |
proof (cases opt) |
|
1879 |
case None |
|
1880 |
with a1 a1' ev vd_cons' vd_enrich_cons curq_cons |
|
1881 |
show ?thesis |
|
1882 |
apply (simp add:cf2sfile_open_none) |
|
1883 |
apply (simp add:pre_sf current_files_simps) |
|
1884 |
done |
|
1885 |
next |
|
1886 |
case (Some inum) |
|
1887 |
show ?thesis |
|
1888 |
proof (cases "f = f'") |
|
1889 |
case False |
|
1890 |
with a1 a1' ev vd_cons' vd_enrich_cons curq_cons Some |
|
1891 |
show ?thesis |
|
1892 |
apply (simp add:cf2sfile_open) |
|
1893 |
apply (simp add:pre_sf current_files_simps) |
|
1894 |
done |
|
1895 |
next |
|
1896 |
case True |
|
1897 |
with vd_cons' ev os Some |
|
1898 |
obtain pf where pf: "parent f = Some pf" by auto |
|
1899 |
then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts" |
|
1900 |
using os vd ev Some True |
|
1901 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
1902 |
apply (drule get_pfs_secs_prop', simp, simp) |
|
1903 |
apply auto |
|
1904 |
done |
|
1905 |
||
1906 |
have "sectxt_of_obj (Open p f' flags fd (Some inum) # enrich_msgq s q q') (O_file f') = |
|
1907 |
sectxt_of_obj (Open p f' flags fd (Some inum) # s) (O_file f')" |
|
1908 |
using Some vd_enrich_cons vd_cons' ev pf True os curq_cons |
|
1909 |
by (simp add:sectxt_of_obj_simps curpsec curdsec) |
|
1910 |
moreover |
|
1911 |
have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)" |
|
1912 |
using curq_cons ev pf Some True os |
|
1913 |
by (simp add:curdsec) |
|
1914 |
moreover |
|
1915 |
have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts" |
|
1916 |
using curq_cons ev pf Some True os vd psecs |
|
1917 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
1918 |
apply (drule get_pfs_secs_prop', simp+) |
|
1919 |
apply (rule curpsecs, simp+) |
|
1920 |
done |
|
1921 |
then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'" |
|
1922 |
and psecs_eq: "set ctxts' = set ctxts" by auto |
|
1923 |
ultimately show ?thesis |
|
1924 |
using a1 a1' ev vd_cons' vd_enrich_cons Some True pf psecs |
|
1925 |
by (simp add:cf2sfile_open split:option.splits) |
|
1926 |
qed |
|
1927 |
qed |
|
1928 |
qed |
|
1929 |
have b2: "\<And> p f' inum. e = Mkdir p f' inum \<Longrightarrow> |
|
1930 |
cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1931 |
proof- |
|
1932 |
fix p f' inum |
|
1933 |
assume ev: "e = Mkdir p f' inum" |
|
1934 |
show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1935 |
proof (cases "f' = f") |
|
1936 |
case False |
|
1937 |
with a1 a1' ev vd_cons' vd_enrich_cons curq_cons |
|
1938 |
show ?thesis |
|
1939 |
apply (simp add:cf2sfile_mkdir) |
|
1940 |
apply (simp add:pre_sf current_files_simps) |
|
1941 |
done |
|
1942 |
next |
|
1943 |
case True |
|
1944 |
with vd_cons' ev os |
|
1945 |
obtain pf where pf: "parent f = Some pf" by auto |
|
1946 |
then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts" |
|
1947 |
using os vd ev True |
|
1948 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
1949 |
apply (drule get_pfs_secs_prop', simp, simp) |
|
1950 |
apply auto |
|
1951 |
done |
|
1952 |
||
1953 |
have "sectxt_of_obj (Mkdir p f' inum # enrich_msgq s q q') (O_dir f') = |
|
1954 |
sectxt_of_obj (Mkdir p f' inum # s) (O_dir f')" |
|
1955 |
using vd_enrich_cons vd_cons' ev pf True os curq_cons |
|
1956 |
by (simp add:sectxt_of_obj_simps curpsec curdsec) |
|
1957 |
moreover |
|
1958 |
have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)" |
|
1959 |
using curq_cons ev pf True os |
|
1960 |
by (simp add:curdsec) |
|
1961 |
moreover |
|
1962 |
have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts" |
|
1963 |
using curq_cons ev pf True os vd psecs |
|
1964 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
1965 |
apply (drule get_pfs_secs_prop', simp+) |
|
1966 |
apply (rule curpsecs, simp+) |
|
1967 |
done |
|
1968 |
then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'" |
|
1969 |
and psecs_eq: "set ctxts' = set ctxts" by auto |
|
1970 |
ultimately show ?thesis |
|
1971 |
using a1 a1' ev vd_cons' vd_enrich_cons True pf psecs |
|
1972 |
apply (simp add:cf2sfile_mkdir split:option.splits) |
|
1973 |
done |
|
1974 |
qed |
|
1975 |
qed |
|
1976 |
have b3: "\<And> p f' f''. e = LinkHard p f' f'' \<Longrightarrow> |
|
1977 |
cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1978 |
proof- |
|
1979 |
fix p f' f'' |
|
1980 |
assume ev: "e = LinkHard p f' f''" |
|
1981 |
show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
1982 |
proof (cases "f'' = f") |
|
1983 |
case False |
|
1984 |
with a1 a1' ev vd_cons' vd_enrich_cons curq_cons |
|
1985 |
show ?thesis |
|
1986 |
apply (simp add:cf2sfile_linkhard) |
|
1987 |
apply (simp add:pre_sf current_files_simps) |
|
1988 |
done |
|
1989 |
next |
|
1990 |
case True |
|
1991 |
with vd_cons' ev os |
|
1992 |
obtain pf where pf: "parent f = Some pf" by auto |
|
1993 |
then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts" |
|
1994 |
using os vd ev True |
|
1995 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
1996 |
apply (drule get_pfs_secs_prop', simp, simp) |
|
1997 |
apply auto |
|
1998 |
done |
|
1999 |
||
2000 |
have "sectxt_of_obj (LinkHard p f' f'' # enrich_msgq s q q') (O_file f) = |
|
2001 |
sectxt_of_obj (LinkHard p f' f'' # s) (O_file f)" |
|
2002 |
using vd_enrich_cons vd_cons' ev pf True os curq_cons |
|
2003 |
by (simp add:sectxt_of_obj_simps curpsec curdsec) |
|
2004 |
moreover |
|
2005 |
have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)" |
|
2006 |
using curq_cons ev pf True os |
|
2007 |
by (simp add:curdsec) |
|
2008 |
moreover |
|
2009 |
have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts" |
|
2010 |
using curq_cons ev pf True os vd psecs |
|
2011 |
apply (case_tac "get_parentfs_ctxts s pf") |
|
2012 |
apply (drule get_pfs_secs_prop', simp+) |
|
2013 |
apply (rule curpsecs, simp+) |
|
2014 |
done |
|
2015 |
then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'" |
|
2016 |
and psecs_eq: "set ctxts' = set ctxts" by auto |
|
2017 |
ultimately show ?thesis |
|
2018 |
using a1 a1' ev vd_cons' vd_enrich_cons True pf psecs |
|
2019 |
apply (simp add:cf2sfile_linkhard split:option.splits) |
|
2020 |
done |
|
2021 |
qed |
|
2022 |
qed |
|
2023 |
show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f" |
|
2024 |
apply (case_tac e) |
|
2025 |
prefer 6 apply (erule b1) |
|
2026 |
prefer 11 apply (erule b2) |
|
2027 |
prefer 11 apply (erule b3) |
|
2028 |
apply (simp_all only:b1 b2 b3) |
|
2029 |
using a1' a1 vd_enrich_cons vd_cons' curq_cons nodel_cons |
|
2030 |
apply (simp_all add:cf2sfile_other'' cf2sfile_simps enrich_msgq.simps no_del_event.simps split:if_splits) |
|
2031 |
apply (simp_all add:pre_sf cf2sfile_other' current_files_simps split:if_splits) |
|
2032 |
apply (drule vd_cons, simp add:cf2sfile_other', drule pre_sf, simp+)+ |
|
2033 |
done |
|
2034 |
qed |
|
2035 |
||
2036 |
have sfd_cons:"\<And> tp fd f. file_of_proc_fd (e # s) tp fd = Some f \<Longrightarrow> |
|
2037 |
cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd" |
|
2038 |
proof- |
|
2039 |
fix tp fd f |
|
2040 |
assume a1: "file_of_proc_fd (e # s) tp fd = Some f" |
|
2041 |
hence a1': "file_of_proc_fd (enrich_msgq (e # s) q q') tp fd = Some f" |
|
2042 |
using nodel_cons vd_enrich os vd_cons' |
|
2043 |
apply (case_tac e, auto simp:enrich_msgq_filefd simp del:enrich_msgq.simps) |
|
2044 |
done |
|
2045 |
have b1: "\<And> p f' flags fd' opt. e = Open p f' flags fd' opt \<Longrightarrow> |
|
2046 |
cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd" |
|
2047 |
proof- |
|
2048 |
fix p f' flags fd' opt |
|
2049 |
assume ev: "e = Open p f' flags fd' opt" |
|
2050 |
have c1': "file_of_proc_fd (Open p f' flags fd' opt # s) tp fd = Some f" |
|
2051 |
using a1' ev a1 by (simp split:if_splits) |
|
2052 |
show "cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd" thm cfd2sfd_open |
|
2053 |
proof (cases "tp = p \<and> fd = fd'") |
|
2054 |
case False |
|
2055 |
show ?thesis using ev vd_enrich_cons vd_cons' a1' a1 False curq_cons |
|
2056 |
apply (simp add:cfd2sfd_open split:if_splits del:file_of_proc_fd.simps) |
|
2057 |
apply (rule conjI, rule impI, simp) |
|
2058 |
apply (rule conjI, rule impI, simp) |
|
2059 |
apply (auto simp: False intro!:pre_sfd' split:if_splits) |
|
2060 |
done |
|
2061 |
next |
|
2062 |
case True |
|
2063 |
have "f' \<in> current_files (Open p f' flags fd' opt # s)" using ev vd_cons' os |
|
2064 |
by (auto simp:current_files_simps is_file_in_current split:option.splits) |
|
2065 |
hence "cf2sfile (Open p f' flags fd' opt # enrich_msgq s q q') f' |
|
2066 |
= cf2sfile (Open p f' flags fd' opt # s) f'" |
|
2067 |
using sf_cons ev by auto |
|
2068 |
moreover have "sectxt_of_obj (enrich_msgq s q q') (O_proc p) = sectxt_of_obj s (O_proc p)" |
|
2069 |
apply (rule curpsec) |
|
2070 |
using os ev curq_cons |
|
2071 |
by (auto split:option.splits) |
|
2072 |
ultimately show ?thesis |
|
2073 |
using ev True a1 a1' vd_enrich_cons vd_cons' |
|
2074 |
apply (simp add:cfd2sfd_open sectxt_of_obj_simps del:file_of_proc_fd.simps) |
|
2075 |
done |
|
2076 |
qed |
|
2077 |
qed |
|
2078 |
show "cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd" |
|
2079 |
apply (case_tac e) |
|
2080 |
prefer 6 apply (erule b1) |
|
2081 |
using a1' a1 vd_enrich_cons vd_cons' curq_cons |
|
2082 |
apply (simp_all only:cfd2sfd_simps enrich_msgq.simps) |
|
2083 |
apply (auto simp:cfd2sfd_simps pre_sfd' dest:vd_cons cfd2sfd_other split:if_splits) |
|
2084 |
done |
|
2085 |
qed |
|
2086 |
||
2087 |
have pfds_cons: "\<And> tp. tp \<in> current_procs (e # s) \<Longrightarrow> |
|
2088 |
cpfd2sfds (enrich_msgq (e # s) q q') tp = cpfd2sfds (e # s) tp" |
|
2089 |
apply (auto simp add:cpfd2sfds_def proc_file_fds_def) |
|
2090 |
apply (rule_tac x = fd in exI, rule conjI, rule_tac x = f in exI) |
|
2091 |
prefer 3 |
|
2092 |
apply (rule_tac x = fd in exI, rule conjI, rule_tac x = f in exI) |
|
2093 |
apply (auto simp:sfd_cons enrich_msgq_filefd nodel_cons vd_cons') |
|
2094 |
done |
|
2095 |
||
2096 |
have tainted_cons: "tainted (enrich_msgq (e # s) q q') = |
|
2097 |
(tainted (e # s) \<union> {O_msg q' m | m. O_msg q m \<in> tainted (e # s)})" |
|
2098 |
apply (rule equalityI) |
|
2099 |
using nodel_cons curq_cons curq'_cons vd_cons' vd_enrich_cons |
|
2100 |
apply (rule enrich_msgq_tainted_aux2) |
|
2101 |
using nodel_cons curq_cons curq'_cons vd_cons' |
|
2102 |
apply (rule enrich_msgq_tainted_aux1) |
|
2103 |
done |
|
2104 |
have pre_tainted: "q \<in> current_msgqs s \<Longrightarrow> tainted (enrich_msgq s q q') = |
|
2105 |
(tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s})" by (simp add:pre) |
|
2106 |
||
2107 |
have "\<forall>tp fd. fd \<in> proc_file_fds (e # s) tp \<longrightarrow> cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd" |
|
2108 |
by (auto simp:proc_file_fds_def elim!:sfd_cons) |
|
2109 |
moreover |
|
2110 |
have "\<forall>tp. tp \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_msgq (e # s) q q') tp = cp2sproc (e # s) tp" |
|
2111 |
by (auto simp:cp2sproc_def pfds_cons psec_cons enrich_msgq_died_proc split:option.splits) |
|
2112 |
moreover |
|
2113 |
have "\<forall>tq. tq \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_msgq (e # s) q q') tq = cq2smsgq (e # s) tq" |
|
2114 |
proof clarify |
|
2115 |
fix tq assume a1: "tq \<in> current_msgqs (e # s)" |
|
2116 |
||
2117 |
have curqsec: "\<And> tq. \<lbrakk>tq \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> |
|
2118 |
sectxt_of_obj (enrich_msgq s q q') (O_msgq tq) = sectxt_of_obj s (O_msgq tq)" |
|
2119 |
using pre_vd vd |
|
2120 |
apply (frule_tac pre_sq, simp) |
|
2121 |
by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms') |
|
2122 |
have cursms: "\<And> q''. \<lbrakk>q'' \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> |
|
2123 |
cqm2sms (enrich_msgq s q q') q'' (msgs_of_queue (enrich_msgq s q q') q'') = |
|
2124 |
cqm2sms s q'' (msgs_of_queue s q'')" |
|
2125 |
using pre_vd vd |
|
2126 |
apply (frule_tac pre_sq, simp) |
|
2127 |
by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms') |
|
2128 |
have qsec_cons: "sectxt_of_obj (enrich_msgq (e # s) q q') (O_msgq tq) = sectxt_of_obj (e # s) (O_msgq tq)" |
|
2129 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons curq_cons a1 |
|
2130 |
apply (case_tac e) |
|
2131 |
apply (auto intro:curqsec simp:sectxt_of_obj_simps curpsec split:option.splits dest!:current_has_sec') |
|
2132 |
apply (frule vd_cons) defer apply (frule vd_cons) |
|
2133 |
apply (auto intro:curqsec simp:sectxt_of_obj_simps) |
|
2134 |
done |
|
2135 |
have sms_cons: "cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) = |
|
2136 |
cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)" |
|
2137 |
proof- |
|
2138 |
have b1: "\<And> p q'' m. e = SendMsg p q'' m \<Longrightarrow> |
|
2139 |
cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) = |
|
2140 |
cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)" |
|
2141 |
apply (case_tac e) |
|
2142 |
using a1 curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons |
|
2143 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms pre_tainted |
|
2144 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2145 |
apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*}) |
|
2146 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms pre_tainted |
|
2147 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2148 |
done |
|
2149 |
have b2: "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> |
|
2150 |
cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) = |
|
2151 |
cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)" |
|
2152 |
using a1 curq_cons curq'_cons vd_enrich_cons vd_cons' |
|
2153 |
apply (auto simp:cqm2sms_simps intro:cursms) |
|
2154 |
apply (auto simp:cqm2sms.simps) |
|
2155 |
done |
|
2156 |
have b3: "\<And> p q'' m. e = RecvMsg p q'' m \<Longrightarrow> |
|
2157 |
cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) = |
|
2158 |
cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)" |
|
2159 |
using a1 curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons |
|
2160 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms |
|
2161 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2162 |
apply (frule vd_cons) defer apply (frule vd_cons) |
|
2163 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms |
|
2164 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2165 |
done |
|
2166 |
show "cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) = |
|
2167 |
cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)" |
|
2168 |
apply (case_tac e) |
|
2169 |
prefer 15 apply (erule b2) |
|
2170 |
prefer 15 apply (erule b1) |
|
2171 |
prefer 15 apply (erule b3) |
|
2172 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons a1 |
|
2173 |
apply (auto intro:cursms simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec |
|
2174 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2175 |
done |
|
2176 |
qed |
|
2177 |
||
2178 |
show "cq2smsgq (enrich_msgq (e # s) q q') tq = cq2smsgq (e # s) tq" |
|
2179 |
using a1 curq_cons |
|
2180 |
apply (simp add:cq2smsgq_def qsec_cons sms_cons) |
|
2181 |
done |
|
2182 |
qed |
|
2183 |
moreover |
|
2184 |
have "cq2smsgq (enrich_msgq (e # s) q q') q' = cq2smsgq (e # s) q" |
|
2185 |
proof- |
|
2186 |
have duqsec: "q \<in> current_msgqs s \<Longrightarrow> |
|
2187 |
sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = sectxt_of_obj s (O_msgq q)" |
|
2188 |
apply (frule pre_duq) using vd |
|
2189 |
by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms') |
|
2190 |
have duqsms: "q \<in> current_msgqs s \<Longrightarrow> |
|
2191 |
cqm2sms (enrich_msgq s q q') q' (msgs_of_queue (enrich_msgq s q q') q') = |
|
2192 |
cqm2sms s q (msgs_of_queue s q)" |
|
2193 |
apply (frule pre_duq) using vd |
|
2194 |
by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms') |
|
2195 |
have qsec_cons: "sectxt_of_obj (enrich_msgq (e # s) q q') (O_msgq q') = sectxt_of_obj (e # s) (O_msgq q)" |
|
2196 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons curq_cons |
|
2197 |
apply (case_tac e) |
|
2198 |
apply (auto simp:duqsec sectxt_of_obj_simps curpsec split:option.splits dest!:current_has_sec') |
|
2199 |
apply (frule vd_cons) defer apply (frule vd_cons) |
|
2200 |
apply (auto intro:duqsec simp:sectxt_of_obj_simps) |
|
2201 |
done |
|
2202 |
have sms_cons: "cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') = |
|
2203 |
cqm2sms (e # s) q (msgs_of_queue (e # s) q)" |
|
2204 |
proof- |
|
2205 |
have b1: "\<And> p q'' m. e = SendMsg p q'' m \<Longrightarrow> |
|
2206 |
cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') = |
|
2207 |
cqm2sms (e # s) q (msgs_of_queue (e # s) q)" |
|
2208 |
apply (case_tac e) |
|
2209 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons |
|
2210 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted |
|
2211 |
enrich_msgq_cur_procs enrich_msgq_cur_msgqs |
|
2212 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2213 |
apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*}) |
|
2214 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted |
|
2215 |
enrich_msgq_cur_procs enrich_msgq_cur_msgqs dest:tainted_in_current |
|
2216 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2217 |
done |
|
2218 |
have b2: "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> |
|
2219 |
cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') = |
|
2220 |
cqm2sms (e # s) q (msgs_of_queue (e # s) q)" |
|
2221 |
using curq_cons curq'_cons vd_enrich_cons vd_cons' |
|
2222 |
apply (auto simp:cqm2sms_simps intro:duqsms) |
|
2223 |
apply (auto simp:cqm2sms.simps) |
|
2224 |
done |
|
2225 |
have b3: "\<And> p q'' m. e = RecvMsg p q'' m \<Longrightarrow> |
|
2226 |
cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') = |
|
2227 |
cqm2sms (e # s) q (msgs_of_queue (e # s) q)" |
|
2228 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons |
|
2229 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted |
|
2230 |
enrich_msgq_cur_procs enrich_msgq_cur_msgqs |
|
2231 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2232 |
apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*}) |
|
2233 |
apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted |
|
2234 |
enrich_msgq_cur_procs enrich_msgq_cur_msgqs dest:tainted_in_current |
|
2235 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2236 |
done |
|
2237 |
show ?thesis |
|
2238 |
apply (case_tac e) |
|
2239 |
prefer 15 apply (erule b2) |
|
2240 |
prefer 15 apply (erule b1) |
|
2241 |
prefer 15 apply (erule b3) |
|
2242 |
using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons |
|
2243 |
apply (auto intro:duqsms simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsms |
|
2244 |
split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps) |
|
2245 |
done |
|
2246 |
qed |
|
2247 |
show ?thesis |
|
2248 |
using curq_cons |
|
2249 |
apply (simp add:cq2smsgq_def qsec_cons sms_cons) |
|
2250 |
done |
|
2251 |
qed |
|
2252 |
ultimately show ?case using vd_enrich_cons sf_cons tainted_cons |
|
2253 |
by auto |
|
2254 |
qed |
|
2255 |
||
2256 |
lemma enrich_msgq_vd: |
|
2257 |
"\<lbrakk>q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s; valid s\<rbrakk> \<Longrightarrow> |
|
2258 |
valid (enrich_msgq s q q')" |
|
2259 |
by (auto dest:enrich_msgq_prop) |
|
2260 |
||
2261 |
lemma enrich_msgq_sp: |
|
2262 |
"\<lbrakk>tp \<in> current_procs s; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2263 |
\<Longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp" |
|
2264 |
by (auto dest:enrich_msgq_prop) |
|
2265 |
||
2266 |
lemma enrich_msgq_sf: |
|
2267 |
"\<lbrakk>f \<in> current_files s; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2268 |
\<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" |
|
2269 |
by (auto dest:enrich_msgq_prop) |
|
2270 |
||
2271 |
lemma enrich_msgq_sfs: |
|
2272 |
"\<lbrakk>is_file s f; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2273 |
\<Longrightarrow> cf2sfiles (enrich_msgq s q q') f = cf2sfiles s f" |
|
2274 |
apply (auto simp add:cf2sfiles_def) |
|
2275 |
apply (rule_tac x = f' in bexI) defer |
|
2276 |
apply (simp add:enrich_msgq_sameinode) |
|
2277 |
apply (rule_tac x = f' in bexI) defer |
|
2278 |
apply (simp add:enrich_msgq_sameinode)+ |
|
2279 |
apply (drule same_inode_files_prop11, drule_tac f = f' in is_file_in_current) |
|
2280 |
apply (simp add:enrich_msgq_sf) |
|
2281 |
apply (drule same_inode_files_prop11, drule_tac f = f' in is_file_in_current) |
|
2282 |
apply (simp add:enrich_msgq_sf) |
|
2283 |
done |
|
2284 |
||
2285 |
lemma enrich_msgq_sq: |
|
2286 |
"\<lbrakk>tq \<in> current_msgqs s; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2287 |
\<Longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq" |
|
2288 |
by (auto dest:enrich_msgq_prop) |
|
2289 |
||
2290 |
lemma enrich_msgq_sfd': |
|
2291 |
"\<lbrakk>fd \<in> proc_file_fds s tp; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2292 |
\<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" |
|
2293 |
by (auto dest:enrich_msgq_prop) |
|
2294 |
||
2295 |
lemma enrich_msgq_sfd: |
|
2296 |
"\<lbrakk>file_of_proc_fd s tp fd = Some f; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2297 |
\<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" |
|
2298 |
by (auto intro:enrich_msgq_sfd' simp:proc_file_fds_def) |
|
2299 |
||
2300 |
lemma enrich_msgq_duq: |
|
2301 |
"\<lbrakk>valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2302 |
\<Longrightarrow> cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q" |
|
2303 |
by (auto dest:enrich_msgq_prop) |
|
2304 |
||
2305 |
lemma enrich_msgq_tainted: |
|
2306 |
"\<lbrakk>valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk> |
|
2307 |
\<Longrightarrow> tainted (enrich_msgq s q q') = (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s})" |
|
2308 |
by (auto dest:enrich_msgq_prop) |
|
2309 |
||
2310 |
lemma enrich_msgq_dalive: |
|
2311 |
"\<lbrakk>q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s; valid s\<rbrakk> |
|
2312 |
\<Longrightarrow> dalive (enrich_msgq s q q') obj = (dalive s obj \<or> obj = D_msgq q')" |
|
2313 |
apply (case_tac obj) |
|
2314 |
apply (auto simp:enrich_msgq_is_file enrich_msgq_is_dir enrich_msgq_cur_msgqs enrich_msgq_cur_procs) |
|
2315 |
done |
|
2316 |
||
2317 |
lemma enrich_msgq_s2ss: |
|
2318 |
"\<lbrakk>q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s; valid s\<rbrakk> \<Longrightarrow> |
|
2319 |
s2ss (enrich_msgq s q q') = s2ss s" |
|
2320 |
apply (auto simp add:s2ss_def) |
|
2321 |
apply (simp add:enrich_msgq_dalive) |
|
2322 |
apply (erule disjE) |
|
2323 |
apply (rule_tac x = obj in exI) defer |
|
2324 |
apply (rule_tac x = "D_msgq q" in exI) defer |
|
2325 |
apply (rule_tac x = obj in exI) |
|
2326 |
apply (case_tac[!] obj) |
|
2327 |
apply (auto simp:enrich_msgq_duq enrich_msgq_tainted enrich_msgq_sq enrich_msgq_sf |
|
2328 |
enrich_msgq_sp co2sobj.simps enrich_msgq_is_file enrich_msgq_is_dir |
|
2329 |
enrich_msgq_cur_procs enrich_msgq_cur_msgqs enrich_msgq_sfs |
|
2330 |
split:option.splits dest:is_dir_in_current) |
|
2331 |
done |
|
2332 |
||
82 | 2333 |
end |
77 | 2334 |
|
82 | 2335 |
end |