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