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