no_shm_selinux/Enrich.thy
author chunhan
Mon, 30 Dec 2013 23:41:58 +0800
changeset 86 690636b7b6f1
parent 84 cebdef333899
child 87 8d18cfc845dd
permissions -rw-r--r--
find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
chunhan
parents:
diff changeset
     1
theory Enrich
chunhan
parents:
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
chunhan
parents:
diff changeset
     3
 Temp
chunhan
parents:
diff changeset
     4
begin
chunhan
parents:
diff changeset
     5
83
chunhan
parents: 82
diff changeset
     6
(* objects that need dynamic indexing, all nature-numbers *)
78
chunhan
parents: 77
diff changeset
     7
datatype t_enrich_obj = 
chunhan
parents: 77
diff changeset
     8
  E_proc "t_process"
chunhan
parents: 77
diff changeset
     9
| E_file "t_file"
chunhan
parents: 77
diff changeset
    10
| E_fd   "t_process" "t_fd"
chunhan
parents: 77
diff changeset
    11
| E_inum "nat"
chunhan
parents: 77
diff changeset
    12
| E_msgq "t_msgq"
chunhan
parents: 77
diff changeset
    13
| E_msg  "t_msgq"    "t_msg"
chunhan
parents: 77
diff changeset
    14
77
chunhan
parents:
diff changeset
    15
context tainting_s begin
chunhan
parents:
diff changeset
    16
83
chunhan
parents: 82
diff changeset
    17
fun no_del_event:: "t_event list \<Rightarrow> bool"
chunhan
parents: 82
diff changeset
    18
where
chunhan
parents: 82
diff changeset
    19
  "no_del_event [] = True"
chunhan
parents: 82
diff changeset
    20
| "no_del_event (Kill p p' # \<tau>)  = False"
chunhan
parents: 82
diff changeset
    21
| "no_del_event (Exit p # s) = False"
chunhan
parents: 82
diff changeset
    22
| "no_del_event (CloseFd p fd # \<tau>) = False"
chunhan
parents: 82
diff changeset
    23
| "no_del_event (UnLink p f # \<tau>) = False"
chunhan
parents: 82
diff changeset
    24
| "no_del_event (Rmdir p f # \<tau>)  = False"
chunhan
parents: 82
diff changeset
    25
(*
chunhan
parents: 82
diff changeset
    26
| "no_del_event (Rename p f f' # \<tau>)  = False"
chunhan
parents: 82
diff changeset
    27
*)
chunhan
parents: 82
diff changeset
    28
| "no_del_event (RemoveMsgq p q # \<tau>) = False"
chunhan
parents: 82
diff changeset
    29
(*
chunhan
parents: 82
diff changeset
    30
| "no_del_event (RecvMsg p q m # \<tau>)  = False"
chunhan
parents: 82
diff changeset
    31
*)
chunhan
parents: 82
diff changeset
    32
| "no_del_event (_ # \<tau>) = no_del_event \<tau>"
chunhan
parents: 82
diff changeset
    33
chunhan
parents: 82
diff changeset
    34
fun all_inums :: "t_state \<Rightarrow> t_inode_num set"
chunhan
parents: 82
diff changeset
    35
where
chunhan
parents: 82
diff changeset
    36
  "all_inums [] = current_inode_nums []"
chunhan
parents: 82
diff changeset
    37
| "all_inums (Open p f flags fd opt # s) = (
chunhan
parents: 82
diff changeset
    38
    case opt of
chunhan
parents: 82
diff changeset
    39
      None \<Rightarrow> all_inums s
chunhan
parents: 82
diff changeset
    40
    | Some i \<Rightarrow> all_inums s \<union> {i} )"
chunhan
parents: 82
diff changeset
    41
| "all_inums (Mkdir p f i # s) = (all_inums s \<union> {i})"
chunhan
parents: 82
diff changeset
    42
| "all_inums (CreateSock p af st fd i # s) = (all_inums s \<union> {i})"
chunhan
parents: 82
diff changeset
    43
| "all_inums (Accept p fd addr lport fd' i # s) = (all_inums s \<union> {i})"
chunhan
parents: 82
diff changeset
    44
| "all_inums (_ # s) = all_inums s"
chunhan
parents: 82
diff changeset
    45
chunhan
parents: 82
diff changeset
    46
fun all_fds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd set"
chunhan
parents: 82
diff changeset
    47
where
chunhan
parents: 82
diff changeset
    48
  "all_fds [] = init_fds_of_proc"
chunhan
parents: 82
diff changeset
    49
| "all_fds (Open p f flags fd ipt # s) = (all_fds s) (p := all_fds s p \<union> {fd})"
chunhan
parents: 82
diff changeset
    50
| "all_fds (CreateSock p sf st fd i # s) = (all_fds s) (p := all_fds s p \<union> {fd})"
chunhan
parents: 82
diff changeset
    51
| "all_fds (Accept p fd' raddr port fd i # s) = (all_fds s) (p := all_fds s p \<union> {fd})"
chunhan
parents: 82
diff changeset
    52
| "all_fds (Clone p p' fds # s) = (all_fds s) (p' := fds)"
chunhan
parents: 82
diff changeset
    53
| "all_fds (_ # s) = all_fds s"
chunhan
parents: 82
diff changeset
    54
chunhan
parents: 82
diff changeset
    55
fun all_msgqs:: "t_state \<Rightarrow> t_msgq set"
chunhan
parents: 82
diff changeset
    56
where
chunhan
parents: 82
diff changeset
    57
  "all_msgqs [] = init_msgqs"
chunhan
parents: 82
diff changeset
    58
| "all_msgqs (CreateMsgq p q # s) = all_msgqs s \<union> {q}"
chunhan
parents: 82
diff changeset
    59
| "all_msgqs (e # s) = all_msgqs s"
chunhan
parents: 82
diff changeset
    60
chunhan
parents: 82
diff changeset
    61
fun all_msgs:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg set"
chunhan
parents: 82
diff changeset
    62
where
chunhan
parents: 82
diff changeset
    63
  "all_msgs [] q = set (init_msgs_of_queue q)"
chunhan
parents: 82
diff changeset
    64
| "all_msgs (CreateMsgq p q # s) q' = (if q' = q then {} else all_msgs s q')"
chunhan
parents: 82
diff changeset
    65
| "all_msgs (SendMsg p q m # s) q' = (if q' = q then all_msgs s q \<union> {m} else all_msgs s q')"
chunhan
parents: 82
diff changeset
    66
| "all_msgs (_ # s) q' = all_msgs s q'"
chunhan
parents: 82
diff changeset
    67
chunhan
parents: 82
diff changeset
    68
fun all_files:: "t_state \<Rightarrow> t_file set"
chunhan
parents: 82
diff changeset
    69
where
chunhan
parents: 82
diff changeset
    70
  "all_files [] = init_files "
chunhan
parents: 82
diff changeset
    71
| "all_files (Open p f flags fd opt # s) = (if opt = None then all_files s else (all_files s \<union> {f}))"
chunhan
parents: 82
diff changeset
    72
| "all_files (Mkdir p f inum # s) = all_files s \<union> {f}"
chunhan
parents: 82
diff changeset
    73
| "all_files (LinkHard p f f' # s) = all_files s \<union> {f'}"
chunhan
parents: 82
diff changeset
    74
| "all_files (e # s) = all_files s"
chunhan
parents: 82
diff changeset
    75
chunhan
parents: 82
diff changeset
    76
fun notin_all:: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> bool"
chunhan
parents: 82
diff changeset
    77
where
chunhan
parents: 82
diff changeset
    78
  "notin_all s (E_proc p)  = (p \<notin> all_procs s)"
chunhan
parents: 82
diff changeset
    79
| "notin_all s (E_file f)  = (f \<notin> all_files s \<and> (\<exists> pf. parent f = Some pf \<and> is_dir s pf))"
chunhan
parents: 82
diff changeset
    80
| "notin_all s (E_fd p fd) = (fd \<notin> all_fds s p)"
chunhan
parents: 82
diff changeset
    81
| "notin_all s (E_inum i)  = (i \<notin> all_inums s)"
chunhan
parents: 82
diff changeset
    82
| "notin_all s (E_msgq q)  = (q \<notin> all_msgqs s)"
chunhan
parents: 82
diff changeset
    83
| "notin_all s (E_msg q m) = (m \<notin> all_msgs s q)"
chunhan
parents: 82
diff changeset
    84
chunhan
parents: 82
diff changeset
    85
lemma not_all_procs_cons:
chunhan
parents: 82
diff changeset
    86
  "p \<notin> all_procs (e # s) \<Longrightarrow> p \<notin> all_procs s"
chunhan
parents: 82
diff changeset
    87
by (case_tac e, auto)
chunhan
parents: 82
diff changeset
    88
chunhan
parents: 82
diff changeset
    89
lemma not_all_procs_prop:
chunhan
parents: 82
diff changeset
    90
  "\<lbrakk>p' \<notin> all_procs s; p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> p' \<noteq> p"
chunhan
parents: 82
diff changeset
    91
apply (induct s, rule notI, simp)
chunhan
parents: 82
diff changeset
    92
apply (frule vt_grant_os, frule vd_cons, frule not_all_procs_cons, simp, rule notI)
chunhan
parents: 82
diff changeset
    93
apply (case_tac a, auto)
chunhan
parents: 82
diff changeset
    94
done
chunhan
parents: 82
diff changeset
    95
chunhan
parents: 82
diff changeset
    96
lemma not_all_procs_prop2:
chunhan
parents: 82
diff changeset
    97
  "p' \<notin> all_procs s \<Longrightarrow> p' \<notin> init_procs"
chunhan
parents: 82
diff changeset
    98
apply (induct s, simp)
chunhan
parents: 82
diff changeset
    99
by (case_tac a, auto)
chunhan
parents: 82
diff changeset
   100
chunhan
parents: 82
diff changeset
   101
lemma not_all_procs_prop3:
chunhan
parents: 82
diff changeset
   102
  "p' \<notin> all_procs s \<Longrightarrow> p' \<notin> current_procs s"
chunhan
parents: 82
diff changeset
   103
apply (induct s, simp)
chunhan
parents: 82
diff changeset
   104
by (case_tac a, auto)
chunhan
parents: 82
diff changeset
   105
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
   106
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
   107
  "p \<notin> all_msgqs (e # s) \<Longrightarrow> p \<notin> all_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
   108
by (case_tac e, 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
   109
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
   110
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
   111
  "\<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
   112
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
   113
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
   114
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
   115
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
   116
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
   117
lemma not_all_msgqs_prop2:
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
   118
  "p' \<notin> all_msgqs s \<Longrightarrow> p' \<notin> init_msgqs"
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
   119
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
   120
by (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
   121
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
   122
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
   123
  "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
   124
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
   125
by (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
   126
83
chunhan
parents: 82
diff changeset
   127
fun enrich_not_alive :: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> t_enrich_obj \<Rightarrow> bool"
chunhan
parents: 82
diff changeset
   128
where
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
   129
  "enrich_not_alive s obj (E_file f)  = (f \<notin> current_files s \<and> obj \<noteq> E_file f)"
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
   130
| "enrich_not_alive s obj (E_proc p)  = (p \<notin> current_procs s \<and> obj \<noteq> E_proc 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
   131
| "enrich_not_alive s obj (E_fd p fd) = 
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
   132
  ((p \<in> current_procs s \<longrightarrow> fd \<notin> current_proc_fds s p) \<and> obj \<noteq> E_fd p fd \<and> obj \<noteq> E_proc 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
   133
| "enrich_not_alive s obj (E_msgq q)  = (q \<notin> current_msgqs s \<and> obj \<noteq> E_msgq q)"
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
   134
| "enrich_not_alive s obj (E_inum i)  = (i \<notin> current_inode_nums s \<and> obj \<noteq> E_inum i)"
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
   135
| "enrich_not_alive s obj (E_msg q m) = 
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
   136
  ((q \<in> current_msgqs s \<longrightarrow> m \<notin> set (msgs_of_queue s q)) \<and> obj \<noteq> E_msg q m \<and> obj \<noteq> E_msgq q)"
83
chunhan
parents: 82
diff changeset
   137
chunhan
parents: 82
diff changeset
   138
lemma file_has_parent: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> pf. is_dir s pf \<and> parent f = Some pf"
chunhan
parents: 82
diff changeset
   139
apply (case_tac f)
chunhan
parents: 82
diff changeset
   140
apply (simp, drule root_is_dir', simp+)
chunhan
parents: 82
diff changeset
   141
apply (simp add:parentf_is_dir_prop2)
chunhan
parents: 82
diff changeset
   142
done
chunhan
parents: 82
diff changeset
   143
77
chunhan
parents:
diff changeset
   144
(* enrich s target_proc duplicated_pro *)
chunhan
parents:
diff changeset
   145
fun enrich_proc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> t_state"
chunhan
parents:
diff changeset
   146
where 
chunhan
parents:
diff changeset
   147
  "enrich_proc [] tp dp = []"
chunhan
parents:
diff changeset
   148
| "enrich_proc (Execve p f fds # s) tp dp = (
chunhan
parents:
diff changeset
   149
     if (tp = p) 
chunhan
parents:
diff changeset
   150
     then Execve dp f (fds \<inter> proc_file_fds s p) # Execve p f fds # (enrich_proc s tp dp)
chunhan
parents:
diff changeset
   151
     else Execve p f fds # (enrich_proc s tp dp))"
chunhan
parents:
diff changeset
   152
| "enrich_proc (Clone p p' fds # s) tp dp = (
chunhan
parents:
diff changeset
   153
     if (tp = p') 
chunhan
parents:
diff changeset
   154
     then Clone p dp (fds \<inter> proc_file_fds s p) # Clone p p' fds # s
chunhan
parents:
diff changeset
   155
     else Clone p p' fds # (enrich_proc s tp dp))"
chunhan
parents:
diff changeset
   156
| "enrich_proc (Open p f flags fd opt # s) tp dp = (
chunhan
parents:
diff changeset
   157
     if (tp = p)
81
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
   158
     then Open dp f (remove_create_flag flags) fd None # Open p f flags fd opt # (enrich_proc s tp dp)
77
chunhan
parents:
diff changeset
   159
     else Open p f flags fd opt # (enrich_proc s tp dp))"
81
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
   160
| "enrich_proc (ReadFile p fd # s) tp dp = (
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
   161
     if (tp = p) 
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
   162
     then ReadFile dp fd # ReadFile p fd # (enrich_proc s tp dp)
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
   163
     else ReadFile p fd # (enrich_proc s tp dp))"
83
chunhan
parents: 82
diff changeset
   164
(*
77
chunhan
parents:
diff changeset
   165
| "enrich_proc (CloseFd p fd # s) tp dp = (
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   166
     if (tp = p \<and> fd \<in> proc_file_fds s p)
77
chunhan
parents:
diff changeset
   167
     then CloseFd dp fd # CloseFd p fd # (enrich_proc s tp dp)
chunhan
parents:
diff changeset
   168
     else CloseFd p fd # (enrich_proc s tp dp))"
83
chunhan
parents: 82
diff changeset
   169
*)
77
chunhan
parents:
diff changeset
   170
(*
chunhan
parents:
diff changeset
   171
| "enrich_proc (Attach p h flag # s) tp dp = (
chunhan
parents:
diff changeset
   172
     if (tp = p)
chunhan
parents:
diff changeset
   173
     then Attach dp h flag # Attach p h flag # (enrich_proc s tp dp)
chunhan
parents:
diff changeset
   174
     else Attach p h flag # (enrich_proc s tp dp))"
chunhan
parents:
diff changeset
   175
| "enrich_proc (Detach p h # s) tp dp = (
chunhan
parents:
diff changeset
   176
     if (tp = p) 
chunhan
parents:
diff changeset
   177
     then Detach dp h # Detach p h # (enrich_proc s tp dp)
chunhan
parents:
diff changeset
   178
     else Detach p h # (enrich_proc s tp dp))"
chunhan
parents:
diff changeset
   179
*)
83
chunhan
parents: 82
diff changeset
   180
(*
77
chunhan
parents:
diff changeset
   181
| "enrich_proc (Kill p p' # s) tp dp = (
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
   182
     if (tp = p') then Kill p p' # s
77
chunhan
parents:
diff changeset
   183
     else Kill p p' # (enrich_proc s tp dp))"
chunhan
parents:
diff changeset
   184
| "enrich_proc (Exit p # s) tp dp = (
chunhan
parents:
diff changeset
   185
     if (tp = p) then Exit p # s
chunhan
parents:
diff changeset
   186
     else Exit p # (enrich_proc s tp dp))"
83
chunhan
parents: 82
diff changeset
   187
*)
77
chunhan
parents:
diff changeset
   188
| "enrich_proc (e # s) tp dp = e # (enrich_proc s tp dp)"
chunhan
parents:
diff changeset
   189
83
chunhan
parents: 82
diff changeset
   190
definition is_created_proc:: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
chunhan
parents: 82
diff changeset
   191
where
chunhan
parents: 82
diff changeset
   192
  "is_created_proc s p \<equiv> p \<in> current_procs s \<and> (p \<in> init_procs \<longrightarrow> died (O_proc p) s)"
chunhan
parents: 82
diff changeset
   193
chunhan
parents: 82
diff changeset
   194
definition is_created_proc':: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
chunhan
parents: 82
diff changeset
   195
where
chunhan
parents: 82
diff changeset
   196
  "is_created_proc' s p \<equiv> p \<in> current_procs s \<and> p \<notin> init_procs"
chunhan
parents: 82
diff changeset
   197
chunhan
parents: 82
diff changeset
   198
lemma no_del_died:
chunhan
parents: 82
diff changeset
   199
  "\<lbrakk>no_del_event s; died obj s\<rbrakk> \<Longrightarrow> (\<exists> p fd. obj = O_fd p fd \<or> obj = O_tcp_sock (p, fd) \<or> obj = O_udp_sock (p, fd))
chunhan
parents: 82
diff changeset
   200
  \<or> (\<exists> q m. obj = O_msg q m) "
chunhan
parents: 82
diff changeset
   201
apply (induct s)
chunhan
parents: 82
diff changeset
   202
apply simp
chunhan
parents: 82
diff changeset
   203
apply (case_tac a)
chunhan
parents: 82
diff changeset
   204
apply (auto split:option.splits)
chunhan
parents: 82
diff changeset
   205
done
chunhan
parents: 82
diff changeset
   206
chunhan
parents: 82
diff changeset
   207
lemma no_del_created_eq:
chunhan
parents: 82
diff changeset
   208
  "no_del_event s \<Longrightarrow> is_created_proc s p = is_created_proc' s p"
chunhan
parents: 82
diff changeset
   209
apply (induct s)
chunhan
parents: 82
diff changeset
   210
apply (simp add:is_created_proc_def is_created_proc'_def)
chunhan
parents: 82
diff changeset
   211
apply (case_tac a)
chunhan
parents: 82
diff changeset
   212
apply (auto simp add:is_created_proc_def is_created_proc'_def dest:no_del_died)
chunhan
parents: 82
diff changeset
   213
done
chunhan
parents: 82
diff changeset
   214
77
chunhan
parents:
diff changeset
   215
lemma enrich_search_check:
chunhan
parents:
diff changeset
   216
  assumes grant: "search_check s (up, rp, tp) f"
chunhan
parents:
diff changeset
   217
  and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
chunhan
parents:
diff changeset
   218
  and vd: "valid s" and f_in: "is_file s f"  and f_in': "is_file s' f"
chunhan
parents:
diff changeset
   219
  and sec: "sectxt_of_obj s' (O_file f) = sectxt_of_obj s (O_file f)"
chunhan
parents:
diff changeset
   220
  shows "search_check s' (up, rp, tp) f"
chunhan
parents:
diff changeset
   221
proof (cases f)
chunhan
parents:
diff changeset
   222
  case Nil
chunhan
parents:
diff changeset
   223
  with f_in vd have "False" 
chunhan
parents:
diff changeset
   224
    by (auto dest:root_is_dir') 
chunhan
parents:
diff changeset
   225
  thus ?thesis by simp
chunhan
parents:
diff changeset
   226
next
chunhan
parents:
diff changeset
   227
  case (Cons n pf)
chunhan
parents:
diff changeset
   228
  from vd f_in obtain sf where sf: "cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   229
    apply (drule_tac is_file_in_current, drule_tac current_file_has_sfile, simp)
chunhan
parents:
diff changeset
   230
    apply (erule exE, simp)
chunhan
parents:
diff changeset
   231
    done
chunhan
parents:
diff changeset
   232
  then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons
chunhan
parents:
diff changeset
   233
    by (auto simp:cf2sfile_def split:option.splits if_splits)
chunhan
parents:
diff changeset
   234
  from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_file_in_current)
chunhan
parents:
diff changeset
   235
  then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons
chunhan
parents:
diff changeset
   236
    by (auto simp:cf2sfile_def split:option.splits if_splits)
chunhan
parents:
diff changeset
   237
  with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in'
chunhan
parents:
diff changeset
   238
    apply (simp add:cf2sfile_def split:option.splits)
chunhan
parents:
diff changeset
   239
    apply (case_tac sf, simp)
chunhan
parents:
diff changeset
   240
    done
chunhan
parents:
diff changeset
   241
  show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec
chunhan
parents:
diff changeset
   242
    apply (simp add:Cons split:option.splits)
chunhan
parents:
diff changeset
   243
    by (case_tac a, simp)
chunhan
parents:
diff changeset
   244
qed
chunhan
parents:
diff changeset
   245
78
chunhan
parents: 77
diff changeset
   246
lemma enrich_search_check':
chunhan
parents: 77
diff changeset
   247
  assumes grant: "search_check s (up, rp, tp) f"
chunhan
parents: 77
diff changeset
   248
  and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
chunhan
parents: 77
diff changeset
   249
  and vd: "valid s" and vd': "valid s'" and f_in: "is_dir s f"  and f_in': "is_dir s' f"
chunhan
parents: 77
diff changeset
   250
  and sec: "sectxt_of_obj s' (O_dir f) = sectxt_of_obj s (O_dir f)"
chunhan
parents: 77
diff changeset
   251
  shows "search_check s' (up, rp, tp) f"
chunhan
parents: 77
diff changeset
   252
proof (cases f)
chunhan
parents: 77
diff changeset
   253
  case Nil
chunhan
parents: 77
diff changeset
   254
  have "sectxt_of_obj s' (O_dir []) = sectxt_of_obj s (O_dir [])"
chunhan
parents: 77
diff changeset
   255
    using cf2sf 
chunhan
parents: 77
diff changeset
   256
    apply (erule_tac x = "[]" in allE)
chunhan
parents: 77
diff changeset
   257
    by (auto simp:cf2sfile_def root_sec_remains vd vd')
chunhan
parents: 77
diff changeset
   258
  thus ?thesis using grant Nil 
chunhan
parents: 77
diff changeset
   259
    by auto
chunhan
parents: 77
diff changeset
   260
next
chunhan
parents: 77
diff changeset
   261
  case (Cons n pf)
chunhan
parents: 77
diff changeset
   262
  from vd f_in obtain sf where sf: "cf2sfile s f = Some sf"
chunhan
parents: 77
diff changeset
   263
    apply (drule_tac is_dir_in_current, drule_tac current_file_has_sfile, simp)
chunhan
parents: 77
diff changeset
   264
    apply (erule exE, simp)
chunhan
parents: 77
diff changeset
   265
    done
chunhan
parents: 77
diff changeset
   266
  then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons
chunhan
parents: 77
diff changeset
   267
    by (auto simp:cf2sfile_def split:option.splits if_splits)
chunhan
parents: 77
diff changeset
   268
  from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_dir_in_current)
chunhan
parents: 77
diff changeset
   269
  then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons
chunhan
parents: 77
diff changeset
   270
    by (auto simp:cf2sfile_def split:option.splits if_splits)
chunhan
parents: 77
diff changeset
   271
  with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in'
chunhan
parents: 77
diff changeset
   272
    apply (drule_tac is_dir_not_file)
chunhan
parents: 77
diff changeset
   273
    apply (drule is_dir_not_file)    
chunhan
parents: 77
diff changeset
   274
    apply (simp add:cf2sfile_def split:option.splits)
chunhan
parents: 77
diff changeset
   275
    apply (case_tac sf, simp)
chunhan
parents: 77
diff changeset
   276
    done
chunhan
parents: 77
diff changeset
   277
  show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec
chunhan
parents: 77
diff changeset
   278
    apply (drule_tac is_dir_not_file)
chunhan
parents: 77
diff changeset
   279
    apply (drule_tac is_dir_not_file)
chunhan
parents: 77
diff changeset
   280
    apply (simp add:Cons split:option.splits)
chunhan
parents: 77
diff changeset
   281
    by (case_tac a, simp)
chunhan
parents: 77
diff changeset
   282
qed
chunhan
parents: 77
diff changeset
   283
77
chunhan
parents:
diff changeset
   284
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"
chunhan
parents:
diff changeset
   285
apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
   286
apply (auto dest: current_filefd_has_sfd)
chunhan
parents:
diff changeset
   287
done
chunhan
parents:
diff changeset
   288
chunhan
parents:
diff changeset
   289
lemma enrich_inherit_fds_check:
chunhan
parents:
diff changeset
   290
  assumes grant: "inherit_fds_check s (up, nr, nt) p fds"  and vd: "valid s"
chunhan
parents:
diff changeset
   291
  and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p\<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd"
chunhan
parents:
diff changeset
   292
  and fd_in: "fds \<subseteq> proc_file_fds s p" and fd_in': "fds \<subseteq> proc_file_fds s' p"
chunhan
parents:
diff changeset
   293
  shows "inherit_fds_check s' (up, nr, nt) p fds"
chunhan
parents:
diff changeset
   294
proof-
chunhan
parents:
diff changeset
   295
  have "\<And> fd. fd \<in> fds \<Longrightarrow> sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)"
chunhan
parents:
diff changeset
   296
  proof-
chunhan
parents:
diff changeset
   297
    fix fd
chunhan
parents:
diff changeset
   298
    assume fd_in_fds: "fd \<in> fds"
chunhan
parents:
diff changeset
   299
    hence fd_in_cfds: "fd \<in> proc_file_fds s p" 
chunhan
parents:
diff changeset
   300
      and fd_in_cfds': "fd \<in> proc_file_fds s' p" 
chunhan
parents:
diff changeset
   301
      using fd_in fd_in' by auto
chunhan
parents:
diff changeset
   302
    with cfd2sfd
chunhan
parents:
diff changeset
   303
    have cfd_eq: "cfd2sfd s' p fd = cfd2sfd s p fd" by auto
chunhan
parents:
diff changeset
   304
    from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f"
chunhan
parents:
diff changeset
   305
      by (auto simp:proc_file_fds_def)
chunhan
parents:
diff changeset
   306
    moreover have "flags_of_proc_fd s p fd \<noteq> None"
chunhan
parents:
diff changeset
   307
      using ffd vd by (auto dest:current_filefd_has_flags)
chunhan
parents:
diff changeset
   308
    moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None"
chunhan
parents:
diff changeset
   309
      using fd_in_cfds vd
chunhan
parents:
diff changeset
   310
      apply (rule_tac notI)
chunhan
parents:
diff changeset
   311
      by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd)
chunhan
parents:
diff changeset
   312
    moreover have "cf2sfile s f \<noteq> None"
chunhan
parents:
diff changeset
   313
      apply (rule notI)
chunhan
parents:
diff changeset
   314
      apply (drule current_file_has_sfile')
chunhan
parents:
diff changeset
   315
      using ffd
chunhan
parents:
diff changeset
   316
      by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file)
chunhan
parents:
diff changeset
   317
    ultimately show "sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)"
chunhan
parents:
diff changeset
   318
      using cfd_eq
chunhan
parents:
diff changeset
   319
      by (auto simp:cfd2sfd_def split:option.splits)
chunhan
parents:
diff changeset
   320
  qed
chunhan
parents:
diff changeset
   321
  hence "sectxts_of_fds s' p fds = sectxts_of_fds s p fds"
chunhan
parents:
diff changeset
   322
    by (simp add:sectxts_of_fds_def)
chunhan
parents:
diff changeset
   323
  thus ?thesis using grant
chunhan
parents:
diff changeset
   324
    by (simp add:inherit_fds_check_def)
chunhan
parents:
diff changeset
   325
qed
chunhan
parents:
diff changeset
   326
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   327
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   328
lemma enrich_inherit_fds_check_dup:
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   329
  assumes grant: "inherit_fds_check s (up, nr, nt) p fds"  and vd: "valid s"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   330
  and cfd2sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p' fd = cfd2sfd s p fd"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   331
  and fd_in: "fds' \<subseteq> fds \<inter> proc_file_fds s p" 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   332
  shows "inherit_fds_check s' (up, nr, nt) p' fds'"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   333
proof- 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   334
  have "sectxts_of_fds s' p' fds' \<subseteq> sectxts_of_fds s p fds"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   335
  proof-
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   336
    have "\<And> fd sfd. \<lbrakk>fd \<in> fds'; sectxt_of_obj s' (O_fd p' fd) = Some sfd\<rbrakk> 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   337
                     \<Longrightarrow> \<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   338
    proof-
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   339
      fix fd sfd
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   340
      assume fd_in_fds': "fd \<in> fds'"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   341
        and sec: "sectxt_of_obj s' (O_fd p' fd) = Some sfd"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   342
      from fd_in_fds' fd_in
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   343
      have fd_in_fds: "fd \<in> fds" and fd_in_cfds: "fd \<in> proc_file_fds s p" 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   344
        by auto
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   345
      from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   346
        by (auto simp:proc_file_fds_def)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   347
      moreover have "flags_of_proc_fd s p fd \<noteq> None"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   348
        using ffd vd by (auto dest:current_filefd_has_flags)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   349
      moreover have "cf2sfile s f \<noteq> None"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   350
        apply (rule notI)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   351
        apply (drule current_file_has_sfile')
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   352
        using ffd
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   353
        by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   354
      moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   355
        using fd_in_cfds vd
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   356
        apply (rule_tac notI)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   357
        by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   358
      ultimately 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   359
      have "sectxt_of_obj s (O_fd p fd) = Some sfd"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   360
        using fd_in_cfds cfd2sfd sec
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   361
        apply (erule_tac x = fd in allE)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   362
        apply (auto simp:cfd2sfd_def split:option.splits)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   363
        done
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   364
      thus "\<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   365
        using fd_in_fds
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   366
        by (rule_tac x = fd in bexI, auto)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   367
    qed
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   368
    thus ?thesis by (auto simp:sectxts_of_fds_def)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   369
  qed
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   370
  thus ?thesis using grant
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   371
    by (auto simp:inherit_fds_check_def inherit_fds_check_ctxt_def)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   372
qed
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
   373
77
chunhan
parents:
diff changeset
   374
chunhan
parents:
diff changeset
   375
lemma enrich_valid_intro_cons:
83
chunhan
parents: 82
diff changeset
   376
  assumes vs': "valid s'" and vd': "valid (e # s)"
77
chunhan
parents:
diff changeset
   377
    and alive: "\<forall> obj. alive s obj \<longrightarrow> alive s' obj"
83
chunhan
parents: 82
diff changeset
   378
    and alive': "\<forall> obj. enrich_not_alive s obj' obj \<longrightarrow> enrich_not_alive s' obj' obj"
78
chunhan
parents: 77
diff changeset
   379
    and hungs: "files_hung_by_del s' = files_hung_by_del s"
77
chunhan
parents:
diff changeset
   380
    and cp2sp: "\<forall> p. p \<in> current_procs s \<longrightarrow> cp2sproc s' p = cp2sproc s p"
chunhan
parents:
diff changeset
   381
    and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
78
chunhan
parents: 77
diff changeset
   382
    and cq2sq: "\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq s' q = cq2smsgq s q"
77
chunhan
parents:
diff changeset
   383
    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
chunhan
parents: 77
diff changeset
   384
    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"
chunhan
parents: 77
diff changeset
   385
    and sms_remain: "\<forall> q. msgs_of_queue s' q = msgs_of_queue s q"
chunhan
parents: 77
diff changeset
   386
   (* and empty_remain: "\<forall> f. dir_is_empty s f \<longrightarrow> dir_is_empty s' f" *)
77
chunhan
parents:
diff changeset
   387
    and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd"
83
chunhan
parents: 82
diff changeset
   388
    and nodel: "no_del_event (e # s)"
chunhan
parents: 82
diff changeset
   389
    and notin_all: "notin_all (e # s) obj'"
77
chunhan
parents:
diff changeset
   390
  shows "valid (e # s')"
83
chunhan
parents: 82
diff changeset
   391
proof-
chunhan
parents: 82
diff changeset
   392
  from vd' have os: "os_grant s e" and grant: "grant s e" and vd: "valid s"
chunhan
parents: 82
diff changeset
   393
    by (auto dest:vt_grant_os vt_grant vd_cons)
78
chunhan
parents: 77
diff changeset
   394
  show ?thesis
83
chunhan
parents: 82
diff changeset
   395
  proof (cases e)
chunhan
parents: 82
diff changeset
   396
    case (Execve p f fds)
78
chunhan
parents: 77
diff changeset
   397
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 77
diff changeset
   398
      apply (erule_tac x = "O_proc p" in allE)
83
chunhan
parents: 82
diff changeset
   399
      by (auto simp:Execve)
78
chunhan
parents: 77
diff changeset
   400
    have f_in: "is_file s' f" using os alive
chunhan
parents: 77
diff changeset
   401
      apply (erule_tac x = "O_file f" in allE)
83
chunhan
parents: 82
diff changeset
   402
      by (auto simp:Execve)
chunhan
parents: 82
diff changeset
   403
    have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain
chunhan
parents: 82
diff changeset
   404
      by (auto simp:Execve proc_file_fds_def)
chunhan
parents: 82
diff changeset
   405
    have "os_grant s' e" using p_in f_in fd_in by (simp add:Execve)
chunhan
parents: 82
diff changeset
   406
    moreover have "grant s' e"
78
chunhan
parents: 77
diff changeset
   407
    proof-
chunhan
parents: 77
diff changeset
   408
      from grant obtain up rp tp uf rf tf 
chunhan
parents: 77
diff changeset
   409
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 77
diff changeset
   410
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
83
chunhan
parents: 82
diff changeset
   411
        by (simp add:Execve split:option.splits, blast)
chunhan
parents: 82
diff changeset
   412
      with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
chunhan
parents: 82
diff changeset
   413
        by (simp add:Execve split:option.splits del:npctxt_execve.simps, blast)
78
chunhan
parents: 77
diff changeset
   414
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 77
diff changeset
   415
        using os cp2sp
chunhan
parents: 77
diff changeset
   416
        apply (erule_tac x = p in allE)
83
chunhan
parents: 82
diff changeset
   417
        by (auto simp:Execve co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   418
      from os have f_in': "is_file s f" by (simp add:Execve)
78
chunhan
parents: 77
diff changeset
   419
      from vd os have "\<exists> sf. cf2sfile s f = Some sf"
83
chunhan
parents: 82
diff changeset
   420
        by (auto dest!:is_file_in_current current_file_has_sfile simp:Execve)
78
chunhan
parents: 77
diff changeset
   421
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
chunhan
parents: 77
diff changeset
   422
        apply (erule_tac x = f in allE)
chunhan
parents: 77
diff changeset
   423
        apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
chunhan
parents: 77
diff changeset
   424
        apply (case_tac f, simp)
chunhan
parents: 77
diff changeset
   425
        apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 77
diff changeset
   426
        done
83
chunhan
parents: 82
diff changeset
   427
      have "inherit_fds_check s' (pu, nr, nt) p fds"
chunhan
parents: 82
diff changeset
   428
      proof-
chunhan
parents: 82
diff changeset
   429
        have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Execve
chunhan
parents: 82
diff changeset
   430
          by (auto simp:proc_file_fds_def)
chunhan
parents: 82
diff changeset
   431
        thus ?thesis using Execve grant vd cfd2sfd p1 p2 p3 os
chunhan
parents: 82
diff changeset
   432
          apply (rule_tac s = s in enrich_inherit_fds_check)
chunhan
parents: 82
diff changeset
   433
          by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   434
      qed
chunhan
parents: 82
diff changeset
   435
      moreover have "search_check s' (pu, rp, tp) f"
chunhan
parents: 82
diff changeset
   436
        using p1 p2 p2' vd cf2sf f_in' grant Execve p3 f_in
78
chunhan
parents: 77
diff changeset
   437
        apply (rule_tac s = s in enrich_search_check)
chunhan
parents: 77
diff changeset
   438
        by (simp_all split:option.splits)
83
chunhan
parents: 82
diff changeset
   439
      ultimately show ?thesis using p1' p2' p3
chunhan
parents: 82
diff changeset
   440
        apply (simp add:Execve split:option.splits) 
chunhan
parents: 82
diff changeset
   441
        using grant Execve p1 p2
chunhan
parents: 82
diff changeset
   442
        by (simp add:Execve grant p1 p2)
chunhan
parents: 82
diff changeset
   443
    qed
chunhan
parents: 82
diff changeset
   444
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   445
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   446
  next
chunhan
parents: 82
diff changeset
   447
    case (Clone p p' fds)
chunhan
parents: 82
diff changeset
   448
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   449
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   450
      by (auto simp:Clone)
chunhan
parents: 82
diff changeset
   451
    have p'_not_in: "p' \<notin> current_procs s'" using  alive' notin_all os Clone
chunhan
parents: 82
diff changeset
   452
      apply (erule_tac x = "E_proc p'" in allE)
chunhan
parents: 82
diff changeset
   453
      apply (auto dest:not_all_procs_prop3)
chunhan
parents: 82
diff changeset
   454
      done
chunhan
parents: 82
diff changeset
   455
    have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain
chunhan
parents: 82
diff changeset
   456
      by (auto simp:Clone proc_file_fds_def)
chunhan
parents: 82
diff changeset
   457
    have "os_grant s' e" using p_in p'_not_in fd_in by (simp add:Clone)
chunhan
parents: 82
diff changeset
   458
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   459
    proof-
chunhan
parents: 82
diff changeset
   460
      from grant obtain up rp tp 
chunhan
parents: 82
diff changeset
   461
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   462
        apply (simp add:Clone split:option.splits)
chunhan
parents: 82
diff changeset
   463
        by (case_tac a, auto)
chunhan
parents: 82
diff changeset
   464
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   465
        using os cp2sp
chunhan
parents: 82
diff changeset
   466
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   467
        by (auto simp:Clone co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   468
      have p2: "inherit_fds_check s' (up, rp, tp) p fds"
chunhan
parents: 82
diff changeset
   469
      proof-
chunhan
parents: 82
diff changeset
   470
        have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Clone
chunhan
parents: 82
diff changeset
   471
          by (auto simp:proc_file_fds_def)
chunhan
parents: 82
diff changeset
   472
        thus ?thesis using Clone grant vd cfd2sfd p1 os
chunhan
parents: 82
diff changeset
   473
          apply (rule_tac s = s in enrich_inherit_fds_check)
chunhan
parents: 82
diff changeset
   474
          by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   475
      qed
chunhan
parents: 82
diff changeset
   476
      show ?thesis using p1 p2 p1' grant
chunhan
parents: 82
diff changeset
   477
        by (simp add:Clone)
chunhan
parents: 82
diff changeset
   478
    qed
chunhan
parents: 82
diff changeset
   479
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   480
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   481
  next
chunhan
parents: 82
diff changeset
   482
    case (Kill p p')
chunhan
parents: 82
diff changeset
   483
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   484
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   485
      by (auto simp:Kill)
chunhan
parents: 82
diff changeset
   486
    have p'_in: "p' \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   487
      apply (erule_tac x = "O_proc p'" in allE)
chunhan
parents: 82
diff changeset
   488
      by (auto simp:Kill)
chunhan
parents: 82
diff changeset
   489
    have "os_grant s' e" using p_in p'_in by (simp add:Kill)
chunhan
parents: 82
diff changeset
   490
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   491
    proof-
chunhan
parents: 82
diff changeset
   492
      from grant obtain up rp tp up' rp' tp'
chunhan
parents: 82
diff changeset
   493
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   494
        and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')"
chunhan
parents: 82
diff changeset
   495
        apply (simp add:Kill split:option.splits)
chunhan
parents: 82
diff changeset
   496
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
   497
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   498
        using os cp2sp
chunhan
parents: 82
diff changeset
   499
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   500
        by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   501
      from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')"
chunhan
parents: 82
diff changeset
   502
        using os cp2sp
chunhan
parents: 82
diff changeset
   503
        apply (erule_tac x = p' in allE)
chunhan
parents: 82
diff changeset
   504
        by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   505
      show ?thesis using p1 p'1 p1' p'1' grant
chunhan
parents: 82
diff changeset
   506
        by (simp add:Kill)
chunhan
parents: 82
diff changeset
   507
    qed
chunhan
parents: 82
diff changeset
   508
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   509
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   510
  next
chunhan
parents: 82
diff changeset
   511
    case (Ptrace p p')
chunhan
parents: 82
diff changeset
   512
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   513
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   514
      by (auto simp:Ptrace)
chunhan
parents: 82
diff changeset
   515
    have p'_in: "p' \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   516
      apply (erule_tac x = "O_proc p'" in allE)
chunhan
parents: 82
diff changeset
   517
      by (auto simp:Ptrace)
chunhan
parents: 82
diff changeset
   518
    have "os_grant s' e" using p_in p'_in by (simp add:Ptrace)
chunhan
parents: 82
diff changeset
   519
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   520
    proof-
chunhan
parents: 82
diff changeset
   521
      from grant obtain up rp tp up' rp' tp'
chunhan
parents: 82
diff changeset
   522
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   523
        and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')"
chunhan
parents: 82
diff changeset
   524
        apply (simp add:Ptrace split:option.splits)
chunhan
parents: 82
diff changeset
   525
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
   526
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   527
        using os cp2sp
chunhan
parents: 82
diff changeset
   528
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   529
        by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   530
      from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')"
chunhan
parents: 82
diff changeset
   531
        using os cp2sp
chunhan
parents: 82
diff changeset
   532
        apply (erule_tac x = p' in allE)
chunhan
parents: 82
diff changeset
   533
        by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   534
      show ?thesis using p1 p'1 p1' p'1' grant
chunhan
parents: 82
diff changeset
   535
        by (simp add:Ptrace)
chunhan
parents: 82
diff changeset
   536
    qed
chunhan
parents: 82
diff changeset
   537
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   538
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   539
  next
chunhan
parents: 82
diff changeset
   540
    case (Exit p)
chunhan
parents: 82
diff changeset
   541
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   542
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   543
      by (auto simp:Exit)
chunhan
parents: 82
diff changeset
   544
    have "os_grant s' e" using p_in by (simp add:Exit)
chunhan
parents: 82
diff changeset
   545
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   546
      by (simp add:Exit)
chunhan
parents: 82
diff changeset
   547
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   548
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   549
  next
chunhan
parents: 82
diff changeset
   550
    case (Open p f flags fd opt)
chunhan
parents: 82
diff changeset
   551
    show ?thesis
chunhan
parents: 82
diff changeset
   552
    proof (cases opt)
chunhan
parents: 82
diff changeset
   553
      case None
chunhan
parents: 82
diff changeset
   554
      have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   555
        apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   556
        by (auto simp:Open None)
chunhan
parents: 82
diff changeset
   557
      have f_in: "is_file s' f" using os alive
chunhan
parents: 82
diff changeset
   558
        apply (erule_tac x = "O_file f" in allE)
chunhan
parents: 82
diff changeset
   559
        by (auto simp:Open None)
chunhan
parents: 82
diff changeset
   560
      have fd_not_in: "fd \<notin> current_proc_fds s' p"
chunhan
parents: 82
diff changeset
   561
        using os alive' p_in notin_all Open None
chunhan
parents: 82
diff changeset
   562
        apply (erule_tac x = "E_fd p fd" in allE)
chunhan
parents: 82
diff changeset
   563
        apply (case_tac obj')
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
   564
        apply (auto dest:not_all_procs_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
   565
        done
83
chunhan
parents: 82
diff changeset
   566
      have "os_grant s' e" using p_in f_in fd_not_in os
chunhan
parents: 82
diff changeset
   567
        by (simp add:Open None)
chunhan
parents: 82
diff changeset
   568
      moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   569
      proof-
chunhan
parents: 82
diff changeset
   570
        from grant obtain up rp tp uf rf tf 
chunhan
parents: 82
diff changeset
   571
          where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   572
          and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   573
          apply (simp add:Open None split:option.splits)
chunhan
parents: 82
diff changeset
   574
          by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
   575
        from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   576
          using os cp2sp
chunhan
parents: 82
diff changeset
   577
          apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   578
          by (auto simp:Open None co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   579
        from os have f_in': "is_file s f" by (simp add:Open None)
chunhan
parents: 82
diff changeset
   580
        from vd os have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
   581
          by (auto dest!:is_file_in_current current_file_has_sfile simp:Open None)
chunhan
parents: 82
diff changeset
   582
        hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
chunhan
parents: 82
diff changeset
   583
          apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
   584
          apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   585
          apply (case_tac f, simp)
chunhan
parents: 82
diff changeset
   586
          apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 82
diff changeset
   587
          done
chunhan
parents: 82
diff changeset
   588
        have "search_check s' (up, rp, tp) f"
chunhan
parents: 82
diff changeset
   589
          using p1 p2 p2' vd cf2sf f_in' grant Open None f_in
chunhan
parents: 82
diff changeset
   590
          apply (rule_tac s = s in enrich_search_check)
chunhan
parents: 82
diff changeset
   591
          by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   592
        thus ?thesis using p1' p2' 
chunhan
parents: 82
diff changeset
   593
          apply (simp add:Open None split:option.splits) 
chunhan
parents: 82
diff changeset
   594
          using grant Open None p1 p2 
chunhan
parents: 82
diff changeset
   595
          by simp
chunhan
parents: 82
diff changeset
   596
      qed
chunhan
parents: 82
diff changeset
   597
      ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   598
        by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   599
    next
chunhan
parents: 82
diff changeset
   600
      case (Some inum)
chunhan
parents: 82
diff changeset
   601
      from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf"
chunhan
parents: 82
diff changeset
   602
        by (auto simp:Open Some)
chunhan
parents: 82
diff changeset
   603
      have pf_in: "is_dir s' pf" using pf_in_s alive
chunhan
parents: 82
diff changeset
   604
        apply (erule_tac x = "O_dir pf" in allE)
chunhan
parents: 82
diff changeset
   605
        by simp
chunhan
parents: 82
diff changeset
   606
      have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   607
        apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   608
        by (auto simp:Open Some)
chunhan
parents: 82
diff changeset
   609
      have f_not_in: "f \<notin> current_files s'" using os alive' Open Some notin_all
chunhan
parents: 82
diff changeset
   610
        apply (erule_tac x = "E_file f" in allE)
chunhan
parents: 82
diff changeset
   611
        apply (case_tac obj')
chunhan
parents: 82
diff changeset
   612
        by auto
chunhan
parents: 82
diff changeset
   613
      have fd_not_in: "fd \<notin> current_proc_fds s' p"
chunhan
parents: 82
diff changeset
   614
        using os alive' p_in Open Some notin_all
chunhan
parents: 82
diff changeset
   615
        apply (erule_tac x = "E_fd p fd" in allE)
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
   616
        apply (case_tac obj', auto dest:not_all_procs_prop3)
83
chunhan
parents: 82
diff changeset
   617
        done
chunhan
parents: 82
diff changeset
   618
      have inum_not_in: "inum \<notin> current_inode_nums s'"
chunhan
parents: 82
diff changeset
   619
        using os alive' Open Some notin_all
chunhan
parents: 82
diff changeset
   620
        apply (erule_tac x = "E_inum inum" in allE)
chunhan
parents: 82
diff changeset
   621
        by (case_tac obj', auto)
chunhan
parents: 82
diff changeset
   622
      have "os_grant s' e" using p_in pf_in parent f_not_in fd_not_in inum_not_in os
chunhan
parents: 82
diff changeset
   623
        by (simp add:Open Some hungs)
chunhan
parents: 82
diff changeset
   624
      moreover have "grant s' e"  
chunhan
parents: 82
diff changeset
   625
      proof-
chunhan
parents: 82
diff changeset
   626
        from grant parent obtain up rp tp uf rf tf 
chunhan
parents: 82
diff changeset
   627
          where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   628
          and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   629
          apply (simp add:Open Some split:option.splits)
chunhan
parents: 82
diff changeset
   630
          by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
   631
        from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   632
          using os cp2sp
chunhan
parents: 82
diff changeset
   633
          apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   634
          by (auto simp:Open Some co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   635
        from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
chunhan
parents: 82
diff changeset
   636
          by (auto dest!:is_dir_in_current current_file_has_sfile simp:Open Some)
chunhan
parents: 82
diff changeset
   637
        hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s
chunhan
parents: 82
diff changeset
   638
          apply (erule_tac x = pf in allE)
chunhan
parents: 82
diff changeset
   639
          apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 82
diff changeset
   640
          apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 82
diff changeset
   641
          apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   642
          apply (case_tac pf, simp_all)
chunhan
parents: 82
diff changeset
   643
          by (simp add:sroot_def root_sec_remains vd vs')
chunhan
parents: 82
diff changeset
   644
        have "search_check s' (up, rp, tp) pf"
chunhan
parents: 82
diff changeset
   645
          using p1 p2 p2' vd cf2sf pf_in grant Open Some pf_in_s parent vs'
chunhan
parents: 82
diff changeset
   646
          apply (rule_tac s = s in enrich_search_check')
chunhan
parents: 82
diff changeset
   647
          by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   648
        thus ?thesis using p1' p2' parent 
chunhan
parents: 82
diff changeset
   649
          apply (simp add:Open Some split:option.splits) 
chunhan
parents: 82
diff changeset
   650
          using grant Open Some p1 p2 
chunhan
parents: 82
diff changeset
   651
          by simp
chunhan
parents: 82
diff changeset
   652
      qed
chunhan
parents: 82
diff changeset
   653
      ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   654
        by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   655
    qed
chunhan
parents: 82
diff changeset
   656
  next
chunhan
parents: 82
diff changeset
   657
    case (ReadFile p fd)
chunhan
parents: 82
diff changeset
   658
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   659
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   660
      by (auto simp:ReadFile)
chunhan
parents: 82
diff changeset
   661
    have fd_in: "fd \<in> current_proc_fds s' p" using os alive
chunhan
parents: 82
diff changeset
   662
      apply (erule_tac x = "O_fd p fd" in allE)
chunhan
parents: 82
diff changeset
   663
      by (auto simp:ReadFile)
chunhan
parents: 82
diff changeset
   664
    obtain f where ffd: "file_of_proc_fd s p fd = Some f"
chunhan
parents: 82
diff changeset
   665
      using os ReadFile by auto
chunhan
parents: 82
diff changeset
   666
    hence f_in_s: "is_file s f" using vd
chunhan
parents: 82
diff changeset
   667
      by (auto intro:file_of_pfd_is_file)
chunhan
parents: 82
diff changeset
   668
    obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags"
chunhan
parents: 82
diff changeset
   669
      using os ReadFile by auto
chunhan
parents: 82
diff changeset
   670
    have ffd_in: "file_of_proc_fd s' p fd = Some f"
chunhan
parents: 82
diff changeset
   671
      using ffd_remain ffd by auto
chunhan
parents: 82
diff changeset
   672
    hence f_in: "is_file s' f" using vs'
chunhan
parents: 82
diff changeset
   673
      by (auto intro:file_of_pfd_is_file)
chunhan
parents: 82
diff changeset
   674
    have flags_in: "flags_of_proc_fd s' p fd = Some flags"
chunhan
parents: 82
diff changeset
   675
      using fflags_remain fflag by auto
chunhan
parents: 82
diff changeset
   676
    have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in 
chunhan
parents: 82
diff changeset
   677
      by (auto simp add:ReadFile is_file_in_current)
chunhan
parents: 82
diff changeset
   678
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   679
    proof-
chunhan
parents: 82
diff changeset
   680
      from grant ffd obtain up rp tp uf rf tf ufd rfd tfd
chunhan
parents: 82
diff changeset
   681
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   682
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
chunhan
parents: 82
diff changeset
   683
        and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)"
chunhan
parents: 82
diff changeset
   684
        apply (simp add:ReadFile split:option.splits)
chunhan
parents: 82
diff changeset
   685
        by (case_tac a, case_tac aa, case_tac ab, blast)
chunhan
parents: 82
diff changeset
   686
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   687
        using os cp2sp
chunhan
parents: 82
diff changeset
   688
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   689
        by (auto simp:ReadFile co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   690
      from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
   691
        by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents: 82
diff changeset
   692
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf
chunhan
parents: 82
diff changeset
   693
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
   694
        apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   695
        apply (case_tac f, simp)
chunhan
parents: 82
diff changeset
   696
        apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 82
diff changeset
   697
        done
chunhan
parents: 82
diff changeset
   698
      have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)" 
chunhan
parents: 82
diff changeset
   699
        using cfd2sfd ffd_in ffd p3 f_in f_in_s vd
chunhan
parents: 82
diff changeset
   700
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   701
        apply (erule_tac x = fd in allE)
chunhan
parents: 82
diff changeset
   702
        apply (simp add:proc_file_fds_def)
chunhan
parents: 82
diff changeset
   703
        apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits
chunhan
parents: 82
diff changeset
   704
          dest!:current_file_has_sfile' simp:is_file_in_current)
chunhan
parents: 82
diff changeset
   705
        done
chunhan
parents: 82
diff changeset
   706
      show ?thesis using p1' p2' p3' ffd_in ffd
chunhan
parents: 82
diff changeset
   707
        apply (simp add:ReadFile split:option.splits) 
chunhan
parents: 82
diff changeset
   708
        using grant p1 p2 p3 ReadFile
78
chunhan
parents: 77
diff changeset
   709
        by simp
chunhan
parents: 77
diff changeset
   710
    qed
chunhan
parents: 77
diff changeset
   711
    ultimately show ?thesis using vs'
chunhan
parents: 77
diff changeset
   712
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 77
diff changeset
   713
  next
83
chunhan
parents: 82
diff changeset
   714
    case (WriteFile p fd)
chunhan
parents: 82
diff changeset
   715
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   716
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   717
      by (auto simp:WriteFile)
chunhan
parents: 82
diff changeset
   718
    have fd_in: "fd \<in> current_proc_fds s' p" using os alive
chunhan
parents: 82
diff changeset
   719
      apply (erule_tac x = "O_fd p fd" in allE)
chunhan
parents: 82
diff changeset
   720
      by (auto simp:WriteFile)
chunhan
parents: 82
diff changeset
   721
    obtain f where ffd: "file_of_proc_fd s p fd = Some f"
chunhan
parents: 82
diff changeset
   722
      using os WriteFile by auto
chunhan
parents: 82
diff changeset
   723
    hence f_in_s: "is_file s f" using vd
chunhan
parents: 82
diff changeset
   724
      by (auto intro:file_of_pfd_is_file)
chunhan
parents: 82
diff changeset
   725
    obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags"
chunhan
parents: 82
diff changeset
   726
      using os WriteFile by auto
chunhan
parents: 82
diff changeset
   727
    have ffd_in: "file_of_proc_fd s' p fd = Some f"
chunhan
parents: 82
diff changeset
   728
      using ffd_remain ffd by auto
chunhan
parents: 82
diff changeset
   729
    hence f_in: "is_file s' f" using vs'
chunhan
parents: 82
diff changeset
   730
      by (auto intro:file_of_pfd_is_file)
chunhan
parents: 82
diff changeset
   731
    have flags_in: "flags_of_proc_fd s' p fd = Some flags"
chunhan
parents: 82
diff changeset
   732
      using fflags_remain fflag by auto
chunhan
parents: 82
diff changeset
   733
    have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in 
chunhan
parents: 82
diff changeset
   734
      by (auto simp add:WriteFile is_file_in_current)
chunhan
parents: 82
diff changeset
   735
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   736
    proof-
chunhan
parents: 82
diff changeset
   737
      from grant ffd obtain up rp tp uf rf tf ufd rfd tfd
chunhan
parents: 82
diff changeset
   738
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   739
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
chunhan
parents: 82
diff changeset
   740
        and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)"
chunhan
parents: 82
diff changeset
   741
        apply (simp add:WriteFile split:option.splits)
chunhan
parents: 82
diff changeset
   742
        by (case_tac a, case_tac aa, case_tac ab, blast)
chunhan
parents: 82
diff changeset
   743
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   744
        using os cp2sp
chunhan
parents: 82
diff changeset
   745
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   746
        by (auto simp:WriteFile co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   747
      from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
   748
        by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents: 82
diff changeset
   749
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf
chunhan
parents: 82
diff changeset
   750
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
   751
        apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   752
        apply (case_tac f, simp)
chunhan
parents: 82
diff changeset
   753
        apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 82
diff changeset
   754
        done
chunhan
parents: 82
diff changeset
   755
      have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)" 
chunhan
parents: 82
diff changeset
   756
        using cfd2sfd ffd_in ffd p3 f_in f_in_s vd
chunhan
parents: 82
diff changeset
   757
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   758
        apply (erule_tac x = fd in allE)
chunhan
parents: 82
diff changeset
   759
        apply (simp add:proc_file_fds_def)
chunhan
parents: 82
diff changeset
   760
        apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits
chunhan
parents: 82
diff changeset
   761
          dest!:current_file_has_sfile' simp:is_file_in_current)
chunhan
parents: 82
diff changeset
   762
        done
chunhan
parents: 82
diff changeset
   763
      show ?thesis using p1' p2' p3' ffd_in ffd
chunhan
parents: 82
diff changeset
   764
        apply (simp add:WriteFile split:option.splits) 
chunhan
parents: 82
diff changeset
   765
        using grant p1 p2 p3 WriteFile
chunhan
parents: 82
diff changeset
   766
        by simp
chunhan
parents: 82
diff changeset
   767
    qed
chunhan
parents: 82
diff changeset
   768
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   769
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   770
  next
chunhan
parents: 82
diff changeset
   771
    case (CloseFd p fd)
chunhan
parents: 82
diff changeset
   772
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   773
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   774
      by (auto simp:CloseFd)
chunhan
parents: 82
diff changeset
   775
    have fd_in: "fd \<in> current_proc_fds s' p" using os alive
chunhan
parents: 82
diff changeset
   776
      apply (erule_tac x = "O_fd p fd" in allE)
chunhan
parents: 82
diff changeset
   777
      by (auto simp:CloseFd)
chunhan
parents: 82
diff changeset
   778
    have "os_grant s' e" using p_in fd_in 
chunhan
parents: 82
diff changeset
   779
      by (auto simp add:CloseFd)
chunhan
parents: 82
diff changeset
   780
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   781
      by(simp add:CloseFd)
chunhan
parents: 82
diff changeset
   782
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   783
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   784
  next
chunhan
parents: 82
diff changeset
   785
    case (UnLink p f)
chunhan
parents: 82
diff changeset
   786
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   787
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   788
      by (auto simp:UnLink)
chunhan
parents: 82
diff changeset
   789
    have f_in: "is_file s' f" using os alive
chunhan
parents: 82
diff changeset
   790
      apply (erule_tac x = "O_file f" in allE)
chunhan
parents: 82
diff changeset
   791
      by (auto simp:UnLink)
chunhan
parents: 82
diff changeset
   792
    from os vd obtain pf where pf_in_s: "is_dir s pf"
chunhan
parents: 82
diff changeset
   793
      and parent: "parent f = Some pf"
chunhan
parents: 82
diff changeset
   794
      by (auto simp:UnLink dest!:file_has_parent)
chunhan
parents: 82
diff changeset
   795
    from pf_in_s alive have pf_in: "is_dir s' pf"
chunhan
parents: 82
diff changeset
   796
      apply (erule_tac x = "O_dir pf" in allE)
chunhan
parents: 82
diff changeset
   797
      by (auto simp:UnLink)
chunhan
parents: 82
diff changeset
   798
    have "os_grant s' e" using p_in f_in os
chunhan
parents: 82
diff changeset
   799
      by (simp add:UnLink hungs)
chunhan
parents: 82
diff changeset
   800
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   801
    proof-    
chunhan
parents: 82
diff changeset
   802
      from grant parent obtain up rp tp uf rf tf upf rpf tpf
chunhan
parents: 82
diff changeset
   803
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   804
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   805
        and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" 
chunhan
parents: 82
diff changeset
   806
        apply (simp add:UnLink split:option.splits)
chunhan
parents: 82
diff changeset
   807
        by (case_tac a, case_tac aa, case_tac ab, blast) 
chunhan
parents: 82
diff changeset
   808
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   809
        using os cp2sp
chunhan
parents: 82
diff changeset
   810
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   811
        by (auto simp:UnLink co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   812
      from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
   813
        by (auto dest!:is_file_in_current current_file_has_sfile simp:UnLink)
chunhan
parents: 82
diff changeset
   814
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   815
        using p2 cf2sf f_in os parent 
chunhan
parents: 82
diff changeset
   816
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
   817
        apply (erule exE, clarsimp simp:UnLink)
chunhan
parents: 82
diff changeset
   818
        apply (frule_tac s = s in is_file_in_current, simp)
chunhan
parents: 82
diff changeset
   819
        by (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   820
      from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
chunhan
parents: 82
diff changeset
   821
        by (auto dest!:is_dir_in_current current_file_has_sfile simp:UnLink)
chunhan
parents: 82
diff changeset
   822
      hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
chunhan
parents: 82
diff changeset
   823
        apply (erule_tac x = pf in allE)
chunhan
parents: 82
diff changeset
   824
        apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 82
diff changeset
   825
        apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 82
diff changeset
   826
        apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   827
        apply (case_tac pf, simp_all)
chunhan
parents: 82
diff changeset
   828
        by (simp add:sroot_def root_sec_remains vd vs')
chunhan
parents: 82
diff changeset
   829
      have "search_check s' (up, rp, tp) f"
chunhan
parents: 82
diff changeset
   830
        using p1 p2 p2' vd cf2sf f_in grant UnLink os parent vs'
chunhan
parents: 82
diff changeset
   831
        apply (rule_tac s = s in enrich_search_check)
chunhan
parents: 82
diff changeset
   832
        by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   833
      thus ?thesis using p1' p2' p3' parent 
chunhan
parents: 82
diff changeset
   834
        apply (simp add:UnLink split:option.splits) 
chunhan
parents: 82
diff changeset
   835
        using grant UnLink p1 p2 p3
chunhan
parents: 82
diff changeset
   836
        by simp
chunhan
parents: 82
diff changeset
   837
    qed
chunhan
parents: 82
diff changeset
   838
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   839
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   840
  next
chunhan
parents: 82
diff changeset
   841
    case (Rmdir p f)
chunhan
parents: 82
diff changeset
   842
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   843
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   844
      by (auto simp:Rmdir)
chunhan
parents: 82
diff changeset
   845
    have f_in: "is_dir s' f" using os alive
chunhan
parents: 82
diff changeset
   846
      apply (erule_tac x = "O_dir f" in allE)
chunhan
parents: 82
diff changeset
   847
      by (auto simp:Rmdir dir_is_empty_def)
chunhan
parents: 82
diff changeset
   848
    have not_root: "f \<noteq> []" using os 
chunhan
parents: 82
diff changeset
   849
      by (auto simp:Rmdir)
chunhan
parents: 82
diff changeset
   850
    from os vd obtain pf where pf_in_s: "is_dir s pf"
chunhan
parents: 82
diff changeset
   851
      and parent: "parent f = Some pf"
chunhan
parents: 82
diff changeset
   852
      apply (auto simp:Rmdir dir_is_empty_def)
chunhan
parents: 82
diff changeset
   853
      apply (case_tac f, simp+)
chunhan
parents: 82
diff changeset
   854
      apply (drule parentf_is_dir_prop1, auto)
chunhan
parents: 82
diff changeset
   855
      done
chunhan
parents: 82
diff changeset
   856
    from pf_in_s alive have pf_in: "is_dir s' pf"
chunhan
parents: 82
diff changeset
   857
      apply (erule_tac x = "O_dir pf" in allE)
chunhan
parents: 82
diff changeset
   858
      by (auto simp:Rmdir)
chunhan
parents: 82
diff changeset
   859
    have empty_in: "dir_is_empty s' f" using os Rmdir notin_all 
chunhan
parents: 82
diff changeset
   860
      apply (clarsimp simp add:dir_is_empty_def f_in)
chunhan
parents: 82
diff changeset
   861
      using alive'
chunhan
parents: 82
diff changeset
   862
      apply (erule_tac x = "E_file f'" in allE)
chunhan
parents: 82
diff changeset
   863
      apply simp
chunhan
parents: 82
diff changeset
   864
      apply (erule disjE)
chunhan
parents: 82
diff changeset
   865
      apply (erule_tac x = f' in allE, simp)
chunhan
parents: 82
diff changeset
   866
      apply (case_tac obj', simp_all)
chunhan
parents: 82
diff changeset
   867
      apply (clarsimp)
chunhan
parents: 82
diff changeset
   868
      apply (drule_tac f' = f in parent_ancen)
chunhan
parents: 82
diff changeset
   869
      apply (simp, rule notI, simp add:noJ_Anc)
chunhan
parents: 82
diff changeset
   870
      apply (case_tac "f = pf")
chunhan
parents: 82
diff changeset
   871
      using vd' Rmdir
chunhan
parents: 82
diff changeset
   872
      apply (simp_all add:is_dir_rmdir)
chunhan
parents: 82
diff changeset
   873
      apply (erule_tac x = pf in allE)
chunhan
parents: 82
diff changeset
   874
      apply (drule_tac f = pf in is_dir_in_current)
chunhan
parents: 82
diff changeset
   875
      apply (simp add:noJ_Anc)
chunhan
parents: 82
diff changeset
   876
      done
chunhan
parents: 82
diff changeset
   877
    have "os_grant s' e" using p_in f_in os empty_in
chunhan
parents: 82
diff changeset
   878
      by (simp add:Rmdir hungs)
chunhan
parents: 82
diff changeset
   879
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
   880
    proof-
chunhan
parents: 82
diff changeset
   881
      from grant parent obtain up rp tp uf rf tf upf rpf tpf
chunhan
parents: 82
diff changeset
   882
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   883
        and p2: "sectxt_of_obj s (O_dir f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   884
        and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" 
chunhan
parents: 82
diff changeset
   885
        apply (simp add:Rmdir split:option.splits)
chunhan
parents: 82
diff changeset
   886
        by (case_tac a, case_tac aa, case_tac ab, blast) 
chunhan
parents: 82
diff changeset
   887
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   888
        using os cp2sp
chunhan
parents: 82
diff changeset
   889
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
   890
        by (auto simp:Rmdir co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
   891
      from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
   892
        by (auto dest!:is_dir_in_current current_file_has_sfile simp:dir_is_empty_def Rmdir)
chunhan
parents: 82
diff changeset
   893
      hence p2': "sectxt_of_obj s' (O_dir f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   894
        using p2 cf2sf f_in os parent 
chunhan
parents: 82
diff changeset
   895
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
   896
        apply (erule exE, clarsimp simp:Rmdir dir_is_empty_def)
chunhan
parents: 82
diff changeset
   897
        apply (frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 82
diff changeset
   898
        apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 82
diff changeset
   899
        by (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   900
      from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
chunhan
parents: 82
diff changeset
   901
        by (auto dest!:is_dir_in_current current_file_has_sfile simp:Rmdir)
chunhan
parents: 82
diff changeset
   902
      hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
chunhan
parents: 82
diff changeset
   903
        apply (erule_tac x = pf in allE)
chunhan
parents: 82
diff changeset
   904
        apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 82
diff changeset
   905
        apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 82
diff changeset
   906
        apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
   907
        apply (case_tac pf, simp_all)
chunhan
parents: 82
diff changeset
   908
        by (simp add:sroot_def root_sec_remains vd vs')
chunhan
parents: 82
diff changeset
   909
      have "search_check s' (up, rp, tp) f"
chunhan
parents: 82
diff changeset
   910
        using p1 p2 p2' vd cf2sf f_in grant Rmdir os parent vs'
chunhan
parents: 82
diff changeset
   911
        apply (rule_tac s = s in enrich_search_check')
chunhan
parents: 82
diff changeset
   912
        by (simp_all add:dir_is_empty_def split:option.splits)
chunhan
parents: 82
diff changeset
   913
      thus ?thesis using p1' p2' p3' parent 
chunhan
parents: 82
diff changeset
   914
        apply (simp add:Rmdir split:option.splits) 
chunhan
parents: 82
diff changeset
   915
        using grant Rmdir p1 p2 p3
chunhan
parents: 82
diff changeset
   916
        by simp
chunhan
parents: 82
diff changeset
   917
    qed
chunhan
parents: 82
diff changeset
   918
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   919
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   920
  next
chunhan
parents: 82
diff changeset
   921
    case (Mkdir p f inum)
78
chunhan
parents: 77
diff changeset
   922
    from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf"
83
chunhan
parents: 82
diff changeset
   923
      by (auto simp:Mkdir)
78
chunhan
parents: 77
diff changeset
   924
    have pf_in: "is_dir s' pf" using pf_in_s alive
chunhan
parents: 77
diff changeset
   925
      apply (erule_tac x = "O_dir pf" in allE)
chunhan
parents: 77
diff changeset
   926
      by simp
chunhan
parents: 77
diff changeset
   927
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 77
diff changeset
   928
      apply (erule_tac x = "O_proc p" in allE)
83
chunhan
parents: 82
diff changeset
   929
      by (auto simp:Mkdir)
chunhan
parents: 82
diff changeset
   930
    have f_not_in: "f \<notin> current_files s'" using os alive' Mkdir notin_all
78
chunhan
parents: 77
diff changeset
   931
      apply (erule_tac x = "E_file f" in allE)
83
chunhan
parents: 82
diff changeset
   932
      by (auto)
78
chunhan
parents: 77
diff changeset
   933
    have inum_not_in: "inum \<notin> current_inode_nums s'"
83
chunhan
parents: 82
diff changeset
   934
      using os alive' Mkdir notin_all
78
chunhan
parents: 77
diff changeset
   935
      apply (erule_tac x = "E_inum inum" in allE)
83
chunhan
parents: 82
diff changeset
   936
      by (auto)
chunhan
parents: 82
diff changeset
   937
    have "os_grant s' e" using p_in pf_in parent f_not_in os inum_not_in
chunhan
parents: 82
diff changeset
   938
      by (simp add:Mkdir hungs)
78
chunhan
parents: 77
diff changeset
   939
    moreover have "grant s' e"  
chunhan
parents: 77
diff changeset
   940
    proof-
chunhan
parents: 77
diff changeset
   941
      from grant parent obtain up rp tp uf rf tf 
chunhan
parents: 77
diff changeset
   942
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 77
diff changeset
   943
        and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)" 
83
chunhan
parents: 82
diff changeset
   944
        apply (simp add:Mkdir split:option.splits)
78
chunhan
parents: 77
diff changeset
   945
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 77
diff changeset
   946
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 77
diff changeset
   947
        using os cp2sp
chunhan
parents: 77
diff changeset
   948
        apply (erule_tac x = p in allE)
83
chunhan
parents: 82
diff changeset
   949
        by (auto simp:Mkdir co2sobj.simps cp2sproc_def split:option.splits)
78
chunhan
parents: 77
diff changeset
   950
      from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
83
chunhan
parents: 82
diff changeset
   951
        by (auto dest!:is_dir_in_current current_file_has_sfile simp:Mkdir)
78
chunhan
parents: 77
diff changeset
   952
      hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s
chunhan
parents: 77
diff changeset
   953
        apply (erule_tac x = pf in allE)
chunhan
parents: 77
diff changeset
   954
        apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 77
diff changeset
   955
        apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 77
diff changeset
   956
        apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 77
diff changeset
   957
        apply (case_tac pf, simp_all)
chunhan
parents: 77
diff changeset
   958
        by (simp add:sroot_def root_sec_remains vd vs')
chunhan
parents: 77
diff changeset
   959
      have "search_check s' (up, rp, tp) pf"
83
chunhan
parents: 82
diff changeset
   960
        using p1 p2 p2' vd cf2sf pf_in grant Mkdir pf_in_s parent vs'
78
chunhan
parents: 77
diff changeset
   961
        apply (rule_tac s = s in enrich_search_check')
83
chunhan
parents: 82
diff changeset
   962
        apply (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
   963
        done
chunhan
parents: 82
diff changeset
   964
      thus ?thesis using p1' p2' parent 
chunhan
parents: 82
diff changeset
   965
        apply (simp add:Mkdir split:option.splits) 
chunhan
parents: 82
diff changeset
   966
        using grant Mkdir p1 p2 
chunhan
parents: 82
diff changeset
   967
        apply simp 
chunhan
parents: 82
diff changeset
   968
        done
chunhan
parents: 82
diff changeset
   969
    qed
chunhan
parents: 82
diff changeset
   970
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
   971
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
   972
  next
chunhan
parents: 82
diff changeset
   973
    case (LinkHard p f f')
chunhan
parents: 82
diff changeset
   974
    from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f' = Some pf"
chunhan
parents: 82
diff changeset
   975
      by (auto simp:LinkHard)
chunhan
parents: 82
diff changeset
   976
    have pf_in: "is_dir s' pf" using pf_in_s alive
chunhan
parents: 82
diff changeset
   977
      apply (erule_tac x = "O_dir pf" in allE)
chunhan
parents: 82
diff changeset
   978
      by simp
chunhan
parents: 82
diff changeset
   979
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
   980
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
   981
      by (auto simp:LinkHard)
chunhan
parents: 82
diff changeset
   982
    have f'_not_in: "f' \<notin> current_files s'" using os alive' LinkHard notin_all
chunhan
parents: 82
diff changeset
   983
      apply (erule_tac x = "E_file f'" in allE)
chunhan
parents: 82
diff changeset
   984
      by (auto simp:LinkHard)
chunhan
parents: 82
diff changeset
   985
    have f_in: "is_file s' f" using os alive
chunhan
parents: 82
diff changeset
   986
      apply (erule_tac x = "O_file f" in allE)
chunhan
parents: 82
diff changeset
   987
      by (auto simp:LinkHard)
chunhan
parents: 82
diff changeset
   988
    have "os_grant s' e" using p_in pf_in parent os f_in f'_not_in
chunhan
parents: 82
diff changeset
   989
      by (simp add:LinkHard hungs)
chunhan
parents: 82
diff changeset
   990
    moreover have "grant s' e"
chunhan
parents: 82
diff changeset
   991
    proof-
chunhan
parents: 82
diff changeset
   992
      from grant parent obtain up rp tp uf rf tf upf rpf tpf
chunhan
parents: 82
diff changeset
   993
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   994
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
   995
        and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)" 
chunhan
parents: 82
diff changeset
   996
        apply (simp add:LinkHard split:option.splits)
chunhan
parents: 82
diff changeset
   997
        by (case_tac a, case_tac aa, case_tac ab, blast) 
chunhan
parents: 82
diff changeset
   998
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
   999
        using os cp2sp
chunhan
parents: 82
diff changeset
  1000
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1001
        by (auto simp:LinkHard co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1002
      from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
  1003
        by (auto dest!:is_file_in_current current_file_has_sfile simp:LinkHard)
chunhan
parents: 82
diff changeset
  1004
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
  1005
        using p2 cf2sf f_in os parent 
chunhan
parents: 82
diff changeset
  1006
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
  1007
        apply (erule exE, clarsimp simp:LinkHard)
chunhan
parents: 82
diff changeset
  1008
        apply (frule_tac s = s in is_file_in_current, simp)
chunhan
parents: 82
diff changeset
  1009
        apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
  1010
        apply (case_tac f, simp)
chunhan
parents: 82
diff changeset
  1011
        by (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 82
diff changeset
  1012
      from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
chunhan
parents: 82
diff changeset
  1013
        by (auto dest!:is_dir_in_current current_file_has_sfile simp:LinkHard)
chunhan
parents: 82
diff changeset
  1014
      hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
chunhan
parents: 82
diff changeset
  1015
        apply (erule_tac x = pf in allE)
chunhan
parents: 82
diff changeset
  1016
        apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
chunhan
parents: 82
diff changeset
  1017
        apply (drule is_dir_not_file, drule is_dir_not_file)
chunhan
parents: 82
diff changeset
  1018
        apply (auto simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
  1019
        apply (case_tac pf, simp_all)
chunhan
parents: 82
diff changeset
  1020
        by (simp add:sroot_def root_sec_remains vd vs')
chunhan
parents: 82
diff changeset
  1021
      have "search_check s' (up, rp, tp) f"
chunhan
parents: 82
diff changeset
  1022
        using p1 p2 p2' vd cf2sf f_in grant LinkHard os parent vs'
chunhan
parents: 82
diff changeset
  1023
        apply (rule_tac s = s in enrich_search_check)
78
chunhan
parents: 77
diff changeset
  1024
        by (simp_all split:option.splits)
83
chunhan
parents: 82
diff changeset
  1025
      moreover have "search_check s' (up, rp, tp) pf"
chunhan
parents: 82
diff changeset
  1026
        using p1 p3 p3' vd cf2sf pf_in grant LinkHard os parent vs'
chunhan
parents: 82
diff changeset
  1027
        apply (rule_tac s = s in enrich_search_check')
chunhan
parents: 82
diff changeset
  1028
        apply (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
  1029
        done
chunhan
parents: 82
diff changeset
  1030
      ultimately show ?thesis using p1' p2' p3' parent 
chunhan
parents: 82
diff changeset
  1031
        apply (simp add:LinkHard split:option.splits) 
chunhan
parents: 82
diff changeset
  1032
        using grant LinkHard p1 p2 p3
chunhan
parents: 82
diff changeset
  1033
        apply simp 
chunhan
parents: 82
diff changeset
  1034
        done
chunhan
parents: 82
diff changeset
  1035
    qed
chunhan
parents: 82
diff changeset
  1036
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
  1037
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
  1038
  next
chunhan
parents: 82
diff changeset
  1039
    case (Truncate p f len)
chunhan
parents: 82
diff changeset
  1040
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
  1041
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
  1042
      by (auto simp:Truncate)
chunhan
parents: 82
diff changeset
  1043
    have f_in: "is_file s' f" using os alive
chunhan
parents: 82
diff changeset
  1044
      apply (erule_tac x = "O_file f" in allE)
chunhan
parents: 82
diff changeset
  1045
      by (auto simp:Truncate)
chunhan
parents: 82
diff changeset
  1046
    have "os_grant s' e" using p_in f_in by (simp add:Truncate)
chunhan
parents: 82
diff changeset
  1047
    moreover have "grant s' e"
chunhan
parents: 82
diff changeset
  1048
    proof-
chunhan
parents: 82
diff changeset
  1049
      from grant obtain up rp tp uf rf tf 
chunhan
parents: 82
diff changeset
  1050
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1051
        and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents: 82
diff changeset
  1052
        apply (simp add:Truncate split:option.splits)
chunhan
parents: 82
diff changeset
  1053
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
  1054
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1055
        using os cp2sp
chunhan
parents: 82
diff changeset
  1056
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1057
        by (auto simp:Truncate co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1058
      from os have f_in': "is_file s f" by (simp add:Truncate)
chunhan
parents: 82
diff changeset
  1059
      from vd os have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents: 82
diff changeset
  1060
        by (auto dest!:is_file_in_current current_file_has_sfile simp:Truncate)
chunhan
parents: 82
diff changeset
  1061
      hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
chunhan
parents: 82
diff changeset
  1062
        apply (erule_tac x = f in allE)
chunhan
parents: 82
diff changeset
  1063
        apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
chunhan
parents: 82
diff changeset
  1064
        apply (case_tac f, simp)
chunhan
parents: 82
diff changeset
  1065
        apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents: 82
diff changeset
  1066
        done
chunhan
parents: 82
diff changeset
  1067
      have "search_check s' (up, rp, tp) f"
chunhan
parents: 82
diff changeset
  1068
        using p1 p2 p2' vd cf2sf f_in' grant Truncate f_in
chunhan
parents: 82
diff changeset
  1069
        apply (rule_tac s = s in enrich_search_check)
chunhan
parents: 82
diff changeset
  1070
        by (simp_all split:option.splits)
chunhan
parents: 82
diff changeset
  1071
      thus ?thesis using p1' p2' 
chunhan
parents: 82
diff changeset
  1072
        apply (simp add:Truncate split:option.splits) 
chunhan
parents: 82
diff changeset
  1073
        using grant Truncate p1 p2
chunhan
parents: 82
diff changeset
  1074
        by (simp add:Truncate grant p1 p2)
chunhan
parents: 82
diff changeset
  1075
    qed
chunhan
parents: 82
diff changeset
  1076
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
  1077
      by (erule_tac valid.intros(2), simp+)
chunhan
parents: 82
diff changeset
  1078
  next
chunhan
parents: 82
diff changeset
  1079
    case (CreateMsgq p q)
chunhan
parents: 82
diff changeset
  1080
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
  1081
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
  1082
      by (auto simp:CreateMsgq)
chunhan
parents: 82
diff changeset
  1083
    have q_not_in: "q \<notin> current_msgqs s'" using os alive' CreateMsgq notin_all
chunhan
parents: 82
diff changeset
  1084
      apply (erule_tac x = "E_msgq q" in allE)
chunhan
parents: 82
diff changeset
  1085
      by auto
chunhan
parents: 82
diff changeset
  1086
    have "os_grant s' e" using p_in q_not_in by (simp add:CreateMsgq)
chunhan
parents: 82
diff changeset
  1087
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
  1088
    proof-
chunhan
parents: 82
diff changeset
  1089
      from grant obtain up rp tp 
chunhan
parents: 82
diff changeset
  1090
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1091
        apply (simp add:CreateMsgq split:option.splits)
chunhan
parents: 82
diff changeset
  1092
        by (case_tac a, blast)
chunhan
parents: 82
diff changeset
  1093
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1094
        using os cp2sp
chunhan
parents: 82
diff changeset
  1095
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1096
        by (auto simp:CreateMsgq co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1097
      show ?thesis using p1' 
chunhan
parents: 82
diff changeset
  1098
        apply (simp add:CreateMsgq split:option.splits) 
chunhan
parents: 82
diff changeset
  1099
        using grant CreateMsgq p1
78
chunhan
parents: 77
diff changeset
  1100
        by simp
chunhan
parents: 77
diff changeset
  1101
    qed
chunhan
parents: 77
diff changeset
  1102
    ultimately show ?thesis using vs'
chunhan
parents: 77
diff changeset
  1103
      by (erule_tac valid.intros(2), simp+)
83
chunhan
parents: 82
diff changeset
  1104
  next
chunhan
parents: 82
diff changeset
  1105
    case (RemoveMsgq p q)
chunhan
parents: 82
diff changeset
  1106
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
  1107
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
  1108
      by (auto simp:RemoveMsgq)
chunhan
parents: 82
diff changeset
  1109
    have q_in: "q \<in> current_msgqs s'" using os alive
chunhan
parents: 82
diff changeset
  1110
      apply (erule_tac x = "O_msgq q" in allE)
78
chunhan
parents: 77
diff changeset
  1111
      by (simp add:RemoveMsgq)
83
chunhan
parents: 82
diff changeset
  1112
    have "os_grant s' e" using p_in q_in by (simp add:RemoveMsgq)
chunhan
parents: 82
diff changeset
  1113
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
  1114
    proof-
chunhan
parents: 82
diff changeset
  1115
      from grant obtain up rp tp uq rq tq
chunhan
parents: 82
diff changeset
  1116
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1117
        and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1118
        apply (simp add:RemoveMsgq split:option.splits)
chunhan
parents: 82
diff changeset
  1119
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
  1120
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1121
        using os cp2sp
chunhan
parents: 82
diff changeset
  1122
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1123
        by (auto simp:RemoveMsgq co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1124
      from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1125
        using os cq2sq vd
chunhan
parents: 82
diff changeset
  1126
        apply (erule_tac x = q in allE)
chunhan
parents: 82
diff changeset
  1127
        by (auto simp:RemoveMsgq co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
chunhan
parents: 82
diff changeset
  1128
      show ?thesis using p1' p2' grant p1 p2
chunhan
parents: 82
diff changeset
  1129
        by (simp add:RemoveMsgq)
chunhan
parents: 82
diff changeset
  1130
    qed
chunhan
parents: 82
diff changeset
  1131
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
  1132
      by (erule_tac valid.intros(2), simp+)  
chunhan
parents: 82
diff changeset
  1133
  next
chunhan
parents: 82
diff changeset
  1134
    case (SendMsg p q m)
chunhan
parents: 82
diff changeset
  1135
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
  1136
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
  1137
      by (auto simp:SendMsg)
chunhan
parents: 82
diff changeset
  1138
    have q_in: "q \<in> current_msgqs s'" using os alive
chunhan
parents: 82
diff changeset
  1139
      apply (erule_tac x = "O_msgq q" in allE)
chunhan
parents: 82
diff changeset
  1140
      by (simp add:SendMsg)
chunhan
parents: 82
diff changeset
  1141
    have m_not_in: "m \<notin> set (msgs_of_queue s' q)" using os alive' notin_all SendMsg q_in
chunhan
parents: 82
diff changeset
  1142
      apply (erule_tac x = "E_msg q m" in allE)
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
  1143
      apply (case_tac obj', auto dest: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
  1144
      done
83
chunhan
parents: 82
diff changeset
  1145
    have "os_grant s' e" using p_in q_in m_not_in
78
chunhan
parents: 77
diff changeset
  1146
      by (simp add:SendMsg)
83
chunhan
parents: 82
diff changeset
  1147
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
  1148
    proof-
chunhan
parents: 82
diff changeset
  1149
      from grant obtain up rp tp uq rq tq
chunhan
parents: 82
diff changeset
  1150
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1151
        and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1152
        apply (simp add:SendMsg split:option.splits)
chunhan
parents: 82
diff changeset
  1153
        by (case_tac a, case_tac aa, blast)
chunhan
parents: 82
diff changeset
  1154
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1155
        using os cp2sp
chunhan
parents: 82
diff changeset
  1156
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1157
        by (auto simp:SendMsg co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1158
      from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1159
        using os cq2sq vd
chunhan
parents: 82
diff changeset
  1160
        apply (erule_tac x = q in allE)
chunhan
parents: 82
diff changeset
  1161
        by (auto simp:SendMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
chunhan
parents: 82
diff changeset
  1162
      show ?thesis using p1' p2' grant p1 p2
chunhan
parents: 82
diff changeset
  1163
        by (simp add:SendMsg)
chunhan
parents: 82
diff changeset
  1164
    qed
chunhan
parents: 82
diff changeset
  1165
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
  1166
      by (erule_tac valid.intros(2), simp+)  
chunhan
parents: 82
diff changeset
  1167
  next
chunhan
parents: 82
diff changeset
  1168
    case (RecvMsg p q m)
chunhan
parents: 82
diff changeset
  1169
    have p_in: "p \<in> current_procs s'" using os alive
chunhan
parents: 82
diff changeset
  1170
      apply (erule_tac x = "O_proc p" in allE)
chunhan
parents: 82
diff changeset
  1171
      by (auto simp:RecvMsg)
chunhan
parents: 82
diff changeset
  1172
    have q_in: "q \<in> current_msgqs s'" using os alive
chunhan
parents: 82
diff changeset
  1173
      apply (erule_tac x = "O_msgq q" in allE)
chunhan
parents: 82
diff changeset
  1174
      by (simp add:RecvMsg) 
chunhan
parents: 82
diff changeset
  1175
    have m_in: "m = hd (msgs_of_queue s' q)" 
chunhan
parents: 82
diff changeset
  1176
      and sms_not_empty: "msgs_of_queue s' q \<noteq> []"
chunhan
parents: 82
diff changeset
  1177
      using os sms_remain
chunhan
parents: 82
diff changeset
  1178
      by (auto simp:RecvMsg)
chunhan
parents: 82
diff changeset
  1179
    have "os_grant s' e" using p_in q_in m_in sms_not_empty os
78
chunhan
parents: 77
diff changeset
  1180
      by (simp add:RecvMsg)
83
chunhan
parents: 82
diff changeset
  1181
    moreover have "grant s' e" 
chunhan
parents: 82
diff changeset
  1182
    proof-
chunhan
parents: 82
diff changeset
  1183
      from grant obtain up rp tp uq rq tq um rm tm
chunhan
parents: 82
diff changeset
  1184
        where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1185
        and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1186
        and p3: "sectxt_of_obj s (O_msg q m) = Some (um, rm, tm)"
chunhan
parents: 82
diff changeset
  1187
        apply (simp add:RecvMsg split:option.splits)
chunhan
parents: 82
diff changeset
  1188
        by (case_tac a, case_tac aa, case_tac ab, blast)
chunhan
parents: 82
diff changeset
  1189
      from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
chunhan
parents: 82
diff changeset
  1190
        using os cp2sp
chunhan
parents: 82
diff changeset
  1191
        apply (erule_tac x = p in allE)
chunhan
parents: 82
diff changeset
  1192
        by (auto simp:RecvMsg co2sobj.simps cp2sproc_def split:option.splits)
chunhan
parents: 82
diff changeset
  1193
      from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
chunhan
parents: 82
diff changeset
  1194
        using os cq2sq vd
chunhan
parents: 82
diff changeset
  1195
        apply (erule_tac x = q in allE)
chunhan
parents: 82
diff changeset
  1196
        by (auto simp:RecvMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
chunhan
parents: 82
diff changeset
  1197
      from p3 have p3': "sectxt_of_obj s' (O_msg q m) = Some (um, rm, tm)"
chunhan
parents: 82
diff changeset
  1198
        using sms_remain cq2sq vd os p2 p2' p3 
chunhan
parents: 82
diff changeset
  1199
        apply (erule_tac x = q in allE)
chunhan
parents: 82
diff changeset
  1200
        apply (erule_tac x = q in allE)
chunhan
parents: 82
diff changeset
  1201
        apply (clarsimp simp:RecvMsg)
chunhan
parents: 82
diff changeset
  1202
        apply (simp add:cq2smsgq_def split:option.splits if_splits)
chunhan
parents: 82
diff changeset
  1203
        apply (drule current_has_sms', simp, simp)
chunhan
parents: 82
diff changeset
  1204
        apply (case_tac "msgs_of_queue s q", simp)
chunhan
parents: 82
diff changeset
  1205
        apply (simp add:cqm2sms.simps split:option.splits)
chunhan
parents: 82
diff changeset
  1206
        apply (auto simp add:cm2smsg_def split:option.splits if_splits)[1]
chunhan
parents: 82
diff changeset
  1207
        apply (case_tac "msgs_of_queue s q", simp)
chunhan
parents: 82
diff changeset
  1208
        apply (simp add:cqm2sms.simps split:option.splits)
chunhan
parents: 82
diff changeset
  1209
        apply (auto simp add:cm2smsg_def split:option.splits if_splits)[1]
chunhan
parents: 82
diff changeset
  1210
        done
chunhan
parents: 82
diff changeset
  1211
      show ?thesis using p1' p2' p3' grant p1 p2 p3
chunhan
parents: 82
diff changeset
  1212
        by (simp add:RecvMsg)
chunhan
parents: 82
diff changeset
  1213
    qed
chunhan
parents: 82
diff changeset
  1214
    ultimately show ?thesis using vs'
chunhan
parents: 82
diff changeset
  1215
      by (erule_tac valid.intros(2), simp+)  
chunhan
parents: 82
diff changeset
  1216
  next
chunhan
parents: 82
diff changeset
  1217
    case (CreateSock p af st fd inum)
chunhan
parents: 82
diff changeset
  1218
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1219
      by (simp add:CreateSock)
chunhan
parents: 82
diff changeset
  1220
  next
chunhan
parents: 82
diff changeset
  1221
    case (Bind p fd addr)
chunhan
parents: 82
diff changeset
  1222
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1223
      by (simp add:Bind)
chunhan
parents: 82
diff changeset
  1224
  next
chunhan
parents: 82
diff changeset
  1225
    case (Connect p fd addr)
chunhan
parents: 82
diff changeset
  1226
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1227
      by (simp add:Connect)
chunhan
parents: 82
diff changeset
  1228
  next
chunhan
parents: 82
diff changeset
  1229
    case (Listen p fd)
chunhan
parents: 82
diff changeset
  1230
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1231
      by (simp add:Listen)
chunhan
parents: 82
diff changeset
  1232
  next
chunhan
parents: 82
diff changeset
  1233
    case (Accept p fd addr port fd' inum)
chunhan
parents: 82
diff changeset
  1234
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1235
      by (simp add:Accept)
chunhan
parents: 82
diff changeset
  1236
  next
chunhan
parents: 82
diff changeset
  1237
    case (SendSock p fd)
chunhan
parents: 82
diff changeset
  1238
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1239
      by (simp add:SendSock)
chunhan
parents: 82
diff changeset
  1240
  next
chunhan
parents: 82
diff changeset
  1241
    case (RecvSock p fd)
chunhan
parents: 82
diff changeset
  1242
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1243
      by (simp add:RecvSock)
chunhan
parents: 82
diff changeset
  1244
  next
chunhan
parents: 82
diff changeset
  1245
    case (Shutdown p fd how)
chunhan
parents: 82
diff changeset
  1246
    show ?thesis using grant
chunhan
parents: 82
diff changeset
  1247
      by (simp add:Shutdown)
chunhan
parents: 82
diff changeset
  1248
  qed 
chunhan
parents: 82
diff changeset
  1249
qed
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1250
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1251
lemma created_proc_clone:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1252
  "valid (Clone p p' fds # s) \<Longrightarrow> 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1253
   is_created_proc (Clone p p' fds # s) tp = (if (tp = p') then True else is_created_proc s tp)"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1254
apply (drule vt_grant_os)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1255
apply (auto simp:is_created_proc_def dest:not_all_procs_prop2)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1256
using not_died_init_proc
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1257
by auto
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1258
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1259
lemma created_proc_exit: 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1260
  "is_created_proc (Exit p # s) tp = (if (tp = p) then False else is_created_proc s tp)"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1261
by (simp add:is_created_proc_def)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1262
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1263
lemma created_proc_kill:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1264
  "is_created_proc (Kill p p' # s) tp = (if (tp = p') then False else is_created_proc s tp)"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1265
by (simp add:is_created_proc_def)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1266
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1267
lemma created_proc_other:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1268
  "\<lbrakk>\<And> p p' fds. e \<noteq> Clone p p' fds;
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1269
    \<And> p. e \<noteq> Exit p;
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1270
    \<And> p p'. e \<noteq> Kill p p'\<rbrakk> \<Longrightarrow> is_created_proc (e # s) tp = is_created_proc s tp"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1271
by (case_tac e, auto simp:is_created_proc_def)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1272
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1273
lemmas is_created_proc_simps = created_proc_clone created_proc_exit created_proc_kill created_proc_other
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1274
(*
77
chunhan
parents:
diff changeset
  1275
chunhan
parents:
diff changeset
  1276
chunhan
parents:
diff changeset
  1277
chunhan
parents:
diff changeset
  1278
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1279
       (p \<in> current_procs s \<longrightarrow> co2sobj (enrich_proc s p p') (O_proc p') = co2sobj (enrich_proc s p p') (O_proc p)) \<and>
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1280
       (\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p')  obj) \<and> 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1281
       (\<forall> p'. p' \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1282
       (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1283
       (Tainted (enrich_proc s p p') = (Tainted s \<union> (if (O_proc p \<in> Tainted s) then {O_proc p'} else {})))"*)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1284
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1285
lemma enrich_proc_dup_in:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1286
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1287
   \<Longrightarrow> p' \<in> current_procs (enrich_proc s p p')"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1288
apply (induct s, simp add:is_created_proc_def)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1289
apply (frule vt_grant_os, frule vd_cons)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1290
apply (case_tac a, auto simp:is_created_proc_def dest:not_all_procs_prop3)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1291
done
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1292
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1293
lemma enrich_proc_dup_ffd:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1294
  "\<lbrakk>file_of_proc_fd s p fd = Some f; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1295
   \<Longrightarrow> file_of_proc_fd (enrich_proc s p p') p' fd = Some f"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1296
apply (induct s, simp add:is_created_proc_def)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1297
apply (frule vt_grant_os, frule vd_cons)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1298
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1299
  dest:not_all_procs_prop3 split:if_splits option.splits)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1300
done 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1301
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1302
lemma enrich_proc_dup_ffd':
83
chunhan
parents: 82
diff changeset
  1303
  "\<lbrakk>file_of_proc_fd (enrich_proc s p p') p' fd = Some f; is_created_proc s p; p' \<notin> all_procs s;
chunhan
parents: 82
diff changeset
  1304
    no_del_event s; valid s\<rbrakk>
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1305
   \<Longrightarrow> file_of_proc_fd s p fd = Some f"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1306
apply (induct s, simp add:is_created_proc_def)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1307
apply (frule vt_grant_os, frule vd_cons)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1308
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1309
  dest:not_all_procs_prop3 split:if_splits option.splits)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1310
done 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1311
83
chunhan
parents: 82
diff changeset
  1312
lemma enrich_proc_dup_ffd_eq:
chunhan
parents: 82
diff changeset
  1313
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
chunhan
parents: 82
diff changeset
  1314
  \<Longrightarrow> file_of_proc_fd (enrich_proc s p p') p' fd = file_of_proc_fd s p fd"
chunhan
parents: 82
diff changeset
  1315
apply (case_tac "file_of_proc_fd s p fd")
chunhan
parents: 82
diff changeset
  1316
apply (case_tac[!] "file_of_proc_fd (enrich_proc s p p') p' fd")
chunhan
parents: 82
diff changeset
  1317
apply (auto dest:enrich_proc_dup_ffd enrich_proc_dup_ffd')
chunhan
parents: 82
diff changeset
  1318
done
chunhan
parents: 82
diff changeset
  1319
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1320
lemma current_fflag_in_fds:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1321
  "\<lbrakk>flags_of_proc_fd s p fd = Some flag; valid s\<rbrakk> \<Longrightarrow> fd \<in> current_proc_fds s p"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1322
apply (induct s arbitrary:p)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1323
apply (simp add:flags_of_proc_fd.simps file_of_proc_fd.simps init_oflags_prop2) 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1324
apply (frule vd_cons, frule vt_grant_os, case_tac a)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1325
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1326
done
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1327
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1328
lemma current_fflag_has_ffd:
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1329
  "\<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"
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1330
apply (induct s arbitrary:p)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1331
apply (simp add: file_of_proc_fd.simps init_fileflag_valid) 
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1332
apply (frule vd_cons, frule vt_grant_os, case_tac a)
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1333
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1334
done
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1335
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1336
lemma enrich_proc_dup_fflags:
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1337
  "\<lbrakk>flags_of_proc_fd s p fd = Some flag; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1338
   \<Longrightarrow> flags_of_proc_fd (enrich_proc s p p') p' fd = Some (remove_create_flag flag) \<or>
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1339
       flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1340
apply (induct s arbitrary:p, simp add:is_created_proc_def)
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1341
apply (frule vt_grant_os, frule vd_cons)
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1342
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def is_creat_flag_def
79
c09fcbcdb871 fixed bug in flags_of_proc_fd
chunhan
parents: 78
diff changeset
  1343
  dest:not_all_procs_prop3 split:if_splits option.splits)
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1344
done
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1345
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1346
lemma enrich_proc_dup_ffds:
83
chunhan
parents: 82
diff changeset
  1347
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
80
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1348
   \<Longrightarrow> proc_file_fds (enrich_proc s p p') p' = proc_file_fds s p"
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1349
apply (auto simp:proc_file_fds_def)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1350
apply (rule_tac x = f in exI) 
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1351
apply (erule enrich_proc_dup_ffd', simp+)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1352
apply (rule_tac x = f in exI)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1353
apply (erule enrich_proc_dup_ffd, simp+)
c9cfc416fa2d fixed bug in enrich_proc
chunhan
parents: 79
diff changeset
  1354
done
77
chunhan
parents:
diff changeset
  1355
82
chunhan
parents: 81
diff changeset
  1356
lemma enrich_proc_dup_ffds_eq_fds:
83
chunhan
parents: 82
diff changeset
  1357
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
82
chunhan
parents: 81
diff changeset
  1358
   \<Longrightarrow> current_proc_fds (enrich_proc s p p') p' = proc_file_fds s p"
chunhan
parents: 81
diff changeset
  1359
apply (induct s arbitrary:p)
chunhan
parents: 81
diff changeset
  1360
apply (simp add: is_created_proc_def)
chunhan
parents: 81
diff changeset
  1361
apply (frule not_all_procs_prop3)
chunhan
parents: 81
diff changeset
  1362
apply (frule vd_cons, frule vt_grant_os, case_tac a)
chunhan
parents: 81
diff changeset
  1363
apply (auto split:if_splits option.splits dest:proc_fd_in_fds set_mp not_all_procs_prop3 
chunhan
parents: 81
diff changeset
  1364
  simp:proc_file_fds_def is_created_proc_def)
chunhan
parents: 81
diff changeset
  1365
done
81
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
  1366
82
chunhan
parents: 81
diff changeset
  1367
lemma oflags_check_remove_create: 
chunhan
parents: 81
diff changeset
  1368
  "oflags_check flags sp sf \<Longrightarrow> oflags_check (remove_create_flag flags) sp sf"
chunhan
parents: 81
diff changeset
  1369
apply (case_tac flags)
chunhan
parents: 81
diff changeset
  1370
apply (auto simp:oflags_check_def perms_of_flags_def perm_of_oflag_def split:bool.splits)
chunhan
parents: 81
diff changeset
  1371
done
81
1ac0c3031ed2 fixed bugs in enrich_proc
chunhan
parents: 80
diff changeset
  1372
82
chunhan
parents: 81
diff changeset
  1373
end
77
chunhan
parents:
diff changeset
  1374
82
chunhan
parents: 81
diff changeset
  1375
end