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