no_shm_selinux/Sectxt_prop.thy
author chunhan
Mon, 30 Dec 2013 23:41:58 +0800
changeset 86 690636b7b6f1
parent 77 6f7b9039715f
permissions -rw-r--r--
find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
chunhan
parents:
diff changeset
     1
theory Sectxt_prop
chunhan
parents:
diff changeset
     2
imports Main Flask Flask_type Current_files_prop Current_sockets_prop Alive_prop
chunhan
parents:
diff changeset
     3
begin
chunhan
parents:
diff changeset
     4
chunhan
parents:
diff changeset
     5
context flask begin
chunhan
parents:
diff changeset
     6
chunhan
parents:
diff changeset
     7
lemma alive_obj_has_type:
chunhan
parents:
diff changeset
     8
  assumes alive: "alive s obj" and vs: "valid s"
chunhan
parents:
diff changeset
     9
  shows "\<exists> t. type_of_obj s obj = Some t"
chunhan
parents:
diff changeset
    10
using alive vs
chunhan
parents:
diff changeset
    11
proof (induct s arbitrary:obj)
chunhan
parents:
diff changeset
    12
  case Nil
chunhan
parents:
diff changeset
    13
  thus ?case
chunhan
parents:
diff changeset
    14
    by (simp add:init_alive_prop[THEN sym] init_obj_has_type)
chunhan
parents:
diff changeset
    15
next
chunhan
parents:
diff changeset
    16
  case (Cons e s)
chunhan
parents:
diff changeset
    17
  hence a2: "alive (e # s) obj" and a3: "valid (e # s)" by auto
chunhan
parents:
diff changeset
    18
  hence a4: "valid s" and a5: "os_grant s e" and a6: "grant s e" 
chunhan
parents:
diff changeset
    19
    by (auto intro:vd_cons vt_grant_os vt_grant)  
chunhan
parents:
diff changeset
    20
  hence a1: "\<And> obj. alive s obj \<Longrightarrow> \<exists>t. type_of_obj s obj = Some t" using Cons by auto
chunhan
parents:
diff changeset
    21
  have a1': "\<And> obj. type_of_obj s obj = None \<Longrightarrow> \<not> alive s obj" by (rule_tac notI, auto dest:a1)
chunhan
parents:
diff changeset
    22
  have p1: "\<And> p. p \<in> current_procs s \<Longrightarrow> \<exists> t. type_of_obj s (O_proc p) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    23
  have p2: "\<And> f. is_file s f \<Longrightarrow> \<exists> t. type_of_obj s (O_file f) = Some t"
chunhan
parents:
diff changeset
    24
    by (auto intro!:a1 simp:is_file_in_current)
chunhan
parents:
diff changeset
    25
  have p3: "\<And> f. is_dir s f \<Longrightarrow> \<exists> t. type_of_obj s (O_dir f) = Some t" 
chunhan
parents:
diff changeset
    26
    by (auto intro!:a1 simp:is_dir_in_current)
chunhan
parents:
diff changeset
    27
  have p4: "\<And> sock. is_tcp_sock s sock \<Longrightarrow> \<exists> t. type_of_obj s (O_tcp_sock sock) = Some t"
chunhan
parents:
diff changeset
    28
    by (auto intro!:a1 simp:is_tcp_in_current)
chunhan
parents:
diff changeset
    29
  have p5: "\<And> sock. is_udp_sock s sock \<Longrightarrow> \<exists> t. type_of_obj s (O_udp_sock sock) = Some t"
chunhan
parents:
diff changeset
    30
    by (auto intro!:a1 simp:is_udp_in_current)
chunhan
parents:
diff changeset
    31
  have p6: "\<And> p fd. fd \<in> current_proc_fds s p \<Longrightarrow> \<exists> t. type_of_obj s (O_fd p fd) = Some t"
chunhan
parents:
diff changeset
    32
    by (auto intro:a1)
chunhan
parents:
diff changeset
    33
  have p7: "\<And> n. n \<in> init_nodes \<Longrightarrow> \<exists> t. type_of_obj s (O_node n) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    34
(*
chunhan
parents:
diff changeset
    35
  have p8: "\<And> h. h \<in> current_shms s \<Longrightarrow> \<exists> t. type_of_obj s (O_shm h) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    36
*)
chunhan
parents:
diff changeset
    37
  have p9: "\<And> q. q \<in> current_msgqs s \<Longrightarrow> \<exists> t. type_of_obj s (O_msgq q) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    38
  have p10: "\<And> q m. \<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s\<rbrakk>
chunhan
parents:
diff changeset
    39
    \<Longrightarrow> \<exists> t. type_of_obj s (O_msg q m) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    40
  show ?case using a5 a2 a4 a3
chunhan
parents:
diff changeset
    41
    apply (case_tac e)
chunhan
parents:
diff changeset
    42
    apply (auto split:option.splits t_object.splits if_splits t_socket_type.splits
chunhan
parents:
diff changeset
    43
                dest!:a1' intro:a1 intro:p1 p2 p3 p4 p5 p6 p7 (* p8 *) p9 p10 simp:alive_simps)
chunhan
parents:
diff changeset
    44
    apply (frule_tac p = nat1 in file_fds_subset_pfds)
chunhan
parents:
diff changeset
    45
    apply (rule a1, auto)
chunhan
parents:
diff changeset
    46
    done
chunhan
parents:
diff changeset
    47
qed
chunhan
parents:
diff changeset
    48
chunhan
parents:
diff changeset
    49
lemma alive_obj_has_user:
chunhan
parents:
diff changeset
    50
  assumes alive: "alive s obj" and vs: "valid s"
chunhan
parents:
diff changeset
    51
  shows "\<exists> t. user_of_obj s obj = Some t"
chunhan
parents:
diff changeset
    52
using alive vs
chunhan
parents:
diff changeset
    53
proof (induct s arbitrary:obj)
chunhan
parents:
diff changeset
    54
  case Nil
chunhan
parents:
diff changeset
    55
  thus ?case
chunhan
parents:
diff changeset
    56
    by (simp add:init_alive_prop[THEN sym] init_obj_has_user)
chunhan
parents:
diff changeset
    57
next
chunhan
parents:
diff changeset
    58
  case (Cons e s)
chunhan
parents:
diff changeset
    59
  hence a2: "alive (e # s) obj" and a3: "valid (e # s)" by auto
chunhan
parents:
diff changeset
    60
  hence a4: "valid s" and a5: "os_grant s e" and a6: "grant s e" 
chunhan
parents:
diff changeset
    61
    by (auto intro:vd_cons vt_grant_os vt_grant)  
chunhan
parents:
diff changeset
    62
  hence a1: "\<And> obj. alive s obj \<Longrightarrow> \<exists>t. user_of_obj s obj = Some t" using Cons by auto
chunhan
parents:
diff changeset
    63
  have a1': "\<And> obj. user_of_obj s obj = None \<Longrightarrow> \<not> alive s obj" by (rule_tac notI, auto dest:a1)
chunhan
parents:
diff changeset
    64
  have p1: "\<And> p. p \<in> current_procs s \<Longrightarrow> \<exists> t. user_of_obj s (O_proc p) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    65
  have p2: "\<And> f. is_file s f \<Longrightarrow> \<exists> t. user_of_obj s (O_file f) = Some t"
chunhan
parents:
diff changeset
    66
    by (auto intro!:a1 simp:is_file_in_current)
chunhan
parents:
diff changeset
    67
  have p3: "\<And> f. is_dir s f \<Longrightarrow> \<exists> t. user_of_obj s (O_dir f) = Some t" 
chunhan
parents:
diff changeset
    68
    by (auto intro!:a1 simp:is_dir_in_current)
chunhan
parents:
diff changeset
    69
  have p4: "\<And> sock. is_tcp_sock s sock \<Longrightarrow> \<exists> t. user_of_obj s (O_tcp_sock sock) = Some t"
chunhan
parents:
diff changeset
    70
    by (auto intro!:a1 simp:is_tcp_in_current)
chunhan
parents:
diff changeset
    71
  have p5: "\<And> sock. is_udp_sock s sock \<Longrightarrow> \<exists> t. user_of_obj s (O_udp_sock sock) = Some t"
chunhan
parents:
diff changeset
    72
    by (auto intro!:a1 simp:is_udp_in_current)
chunhan
parents:
diff changeset
    73
  have p6: "\<And> p fd. fd \<in> current_proc_fds s p \<Longrightarrow> \<exists> t. user_of_obj s (O_fd p fd) = Some t"
chunhan
parents:
diff changeset
    74
    by (auto intro:a1)
chunhan
parents:
diff changeset
    75
  have p7: "\<And> n. n \<in> init_nodes \<Longrightarrow> \<exists> t. user_of_obj s (O_node n) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    76
(*
chunhan
parents:
diff changeset
    77
  have p8: "\<And> h. h \<in> current_shms s \<Longrightarrow> \<exists> t. user_of_obj s (O_shm h) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    78
*)
chunhan
parents:
diff changeset
    79
  have p9: "\<And> q. q \<in> current_msgqs s \<Longrightarrow> \<exists> t. user_of_obj s (O_msgq q) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    80
  have p10: "\<And> q m. \<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s\<rbrakk>
chunhan
parents:
diff changeset
    81
    \<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t" by (auto intro:a1)
chunhan
parents:
diff changeset
    82
  show ?case using a5 a2 a4 a3
chunhan
parents:
diff changeset
    83
    apply (case_tac e)
chunhan
parents:
diff changeset
    84
    apply (auto split:option.splits t_object.splits if_splits t_socket_type.splits
chunhan
parents:
diff changeset
    85
                dest!:a1' intro:a1 intro:p1 p2 p3 p4 p5 p6 p7 (* p8 *) p9 p10 simp:alive_simps)
chunhan
parents:
diff changeset
    86
    apply (frule_tac p = nat1 in file_fds_subset_pfds)
chunhan
parents:
diff changeset
    87
    apply (rule a1, auto)
chunhan
parents:
diff changeset
    88
    done
chunhan
parents:
diff changeset
    89
qed
chunhan
parents:
diff changeset
    90
  
chunhan
parents:
diff changeset
    91
lemma alive_obj_has_type': "\<lbrakk>type_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj" 
chunhan
parents:
diff changeset
    92
by (rule_tac notI, auto dest:alive_obj_has_type)
chunhan
parents:
diff changeset
    93
chunhan
parents:
diff changeset
    94
lemma current_proc_has_type: 
chunhan
parents:
diff changeset
    95
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_proc p) = Some t" 
chunhan
parents:
diff changeset
    96
by (auto intro:alive_obj_has_type)
chunhan
parents:
diff changeset
    97
chunhan
parents:
diff changeset
    98
lemma current_proc_has_type': 
chunhan
parents:
diff changeset
    99
  "\<lbrakk>type_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s" 
chunhan
parents:
diff changeset
   100
by (rule notI, auto dest:current_proc_has_type)
chunhan
parents:
diff changeset
   101
chunhan
parents:
diff changeset
   102
lemma is_file_has_type: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_file f) = Some t"
chunhan
parents:
diff changeset
   103
by (auto intro:alive_obj_has_type simp:is_file_in_current)
chunhan
parents:
diff changeset
   104
chunhan
parents:
diff changeset
   105
lemma is_file_has_type': "\<lbrakk>type_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
chunhan
parents:
diff changeset
   106
by (auto intro:notI dest:is_file_has_type)
chunhan
parents:
diff changeset
   107
chunhan
parents:
diff changeset
   108
lemma is_dir_has_type: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_dir f) = Some t"
chunhan
parents:
diff changeset
   109
by (auto intro:alive_obj_has_type simp:is_dir_in_current)
chunhan
parents:
diff changeset
   110
chunhan
parents:
diff changeset
   111
lemma is_dir_has_type': "\<lbrakk>type_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
chunhan
parents:
diff changeset
   112
by (auto intro:notI dest:is_dir_has_type)
chunhan
parents:
diff changeset
   113
chunhan
parents:
diff changeset
   114
lemma is_tcp_has_type: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_tcp_sock sock) = Some t"
chunhan
parents:
diff changeset
   115
by (auto intro:alive_obj_has_type simp:is_tcp_in_current)
chunhan
parents:
diff changeset
   116
chunhan
parents:
diff changeset
   117
lemma is_tcp_has_type': "\<lbrakk>type_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
chunhan
parents:
diff changeset
   118
by (auto intro:notI dest:is_tcp_has_type)
chunhan
parents:
diff changeset
   119
chunhan
parents:
diff changeset
   120
lemma is_udp_has_type: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_udp_sock sock) = Some t"
chunhan
parents:
diff changeset
   121
by (auto intro:alive_obj_has_type simp:is_udp_in_current)
chunhan
parents:
diff changeset
   122
chunhan
parents:
diff changeset
   123
lemma is_udp_has_type': "\<lbrakk>type_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
chunhan
parents:
diff changeset
   124
by (auto intro:notI dest:is_udp_has_type)
chunhan
parents:
diff changeset
   125
chunhan
parents:
diff changeset
   126
lemma current_fd_has_type: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_fd p fd) = Some t"
chunhan
parents:
diff changeset
   127
by (auto intro:alive_obj_has_type)
chunhan
parents:
diff changeset
   128
chunhan
parents:
diff changeset
   129
lemma current_fd_has_type': "\<lbrakk>type_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
chunhan
parents:
diff changeset
   130
by (auto intro:notI dest:current_fd_has_type)
chunhan
parents:
diff changeset
   131
chunhan
parents:
diff changeset
   132
lemma init_node_has_type: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_node n) = Some t" 
chunhan
parents:
diff changeset
   133
by (auto intro: alive_obj_has_type)
chunhan
parents:
diff changeset
   134
chunhan
parents:
diff changeset
   135
lemma init_node_has_type': "\<lbrakk>type_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes" 
chunhan
parents:
diff changeset
   136
by (auto intro:notI dest:init_node_has_type)
chunhan
parents:
diff changeset
   137
chunhan
parents:
diff changeset
   138
(*
chunhan
parents:
diff changeset
   139
lemma current_shm_has_type: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_shm h) = Some t" 
chunhan
parents:
diff changeset
   140
by (auto intro:alive_obj_has_type)
chunhan
parents:
diff changeset
   141
chunhan
parents:
diff changeset
   142
lemma current_shm_has_type': "\<lbrakk>type_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s" 
chunhan
parents:
diff changeset
   143
by (auto intro:notI dest:current_shm_has_type)
chunhan
parents:
diff changeset
   144
*)
chunhan
parents:
diff changeset
   145
lemma current_msgq_has_type: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_msgq q) = Some t" 
chunhan
parents:
diff changeset
   146
by (auto intro:alive_obj_has_type)
chunhan
parents:
diff changeset
   147
chunhan
parents:
diff changeset
   148
lemma current_msgq_has_type': "\<lbrakk>type_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   149
by (auto intro:notI dest:current_msgq_has_type)
chunhan
parents:
diff changeset
   150
chunhan
parents:
diff changeset
   151
lemma current_msg_has_type: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
   152
    \<Longrightarrow> \<exists> t. type_of_obj s (O_msg q m) = Some t" 
chunhan
parents:
diff changeset
   153
by (auto intro:alive_obj_has_type)
chunhan
parents:
diff changeset
   154
chunhan
parents:
diff changeset
   155
lemma current_msg_has_type': "\<lbrakk>type_of_obj s (O_msg q m) = None; valid s\<rbrakk>
chunhan
parents:
diff changeset
   156
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   157
by (auto dest!:current_msg_has_type)
chunhan
parents:
diff changeset
   158
chunhan
parents:
diff changeset
   159
lemmas current_has_type = alive_obj_has_type current_proc_has_type is_file_has_type is_dir_has_type 
chunhan
parents:
diff changeset
   160
  is_tcp_has_type is_udp_has_type current_fd_has_type init_node_has_type (* current_shm_has_type *)
chunhan
parents:
diff changeset
   161
  current_msgq_has_type current_msg_has_type
chunhan
parents:
diff changeset
   162
chunhan
parents:
diff changeset
   163
lemmas current_has_type' = alive_obj_has_type' current_proc_has_type' is_file_has_type' is_dir_has_type'
chunhan
parents:
diff changeset
   164
  is_tcp_has_type' is_udp_has_type' current_fd_has_type' init_node_has_type' (* current_shm_has_type' *)
chunhan
parents:
diff changeset
   165
  current_msgq_has_type' current_msg_has_type' 
chunhan
parents:
diff changeset
   166
chunhan
parents:
diff changeset
   167
lemma alive_obj_has_user': "\<lbrakk>user_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj" 
chunhan
parents:
diff changeset
   168
by (rule_tac notI, auto dest:alive_obj_has_user)
chunhan
parents:
diff changeset
   169
chunhan
parents:
diff changeset
   170
lemma current_proc_has_user: 
chunhan
parents:
diff changeset
   171
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_proc p) = Some t" 
chunhan
parents:
diff changeset
   172
by (auto intro:alive_obj_has_user)
chunhan
parents:
diff changeset
   173
chunhan
parents:
diff changeset
   174
lemma current_proc_has_user': 
chunhan
parents:
diff changeset
   175
  "\<lbrakk>user_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s" 
chunhan
parents:
diff changeset
   176
by (rule notI, auto dest:current_proc_has_user)
chunhan
parents:
diff changeset
   177
chunhan
parents:
diff changeset
   178
lemma is_file_has_user: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_file f) = Some t"
chunhan
parents:
diff changeset
   179
by (auto intro:alive_obj_has_user simp:is_file_in_current)
chunhan
parents:
diff changeset
   180
chunhan
parents:
diff changeset
   181
lemma is_file_has_user': "\<lbrakk>user_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
chunhan
parents:
diff changeset
   182
by (auto intro:notI dest:is_file_has_user)
chunhan
parents:
diff changeset
   183
chunhan
parents:
diff changeset
   184
lemma is_dir_has_user: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_dir f) = Some t"
chunhan
parents:
diff changeset
   185
by (auto intro:alive_obj_has_user simp:is_dir_in_current)
chunhan
parents:
diff changeset
   186
chunhan
parents:
diff changeset
   187
lemma is_dir_has_user': "\<lbrakk>user_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
chunhan
parents:
diff changeset
   188
by (auto intro:notI dest:is_dir_has_user)
chunhan
parents:
diff changeset
   189
chunhan
parents:
diff changeset
   190
lemma is_tcp_has_user: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_tcp_sock sock) = Some t"
chunhan
parents:
diff changeset
   191
by (auto intro:alive_obj_has_user simp:is_tcp_in_current)
chunhan
parents:
diff changeset
   192
chunhan
parents:
diff changeset
   193
lemma is_tcp_has_user': "\<lbrakk>user_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
chunhan
parents:
diff changeset
   194
by (auto intro:notI dest:is_tcp_has_user)
chunhan
parents:
diff changeset
   195
chunhan
parents:
diff changeset
   196
lemma is_udp_has_user: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_udp_sock sock) = Some t"
chunhan
parents:
diff changeset
   197
by (auto intro:alive_obj_has_user simp:is_udp_in_current)
chunhan
parents:
diff changeset
   198
chunhan
parents:
diff changeset
   199
lemma is_udp_has_user': "\<lbrakk>user_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
chunhan
parents:
diff changeset
   200
by (auto intro:notI dest:is_udp_has_user)
chunhan
parents:
diff changeset
   201
chunhan
parents:
diff changeset
   202
lemma current_fd_has_user: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_fd p fd) = Some t"
chunhan
parents:
diff changeset
   203
by (auto intro:alive_obj_has_user)
chunhan
parents:
diff changeset
   204
chunhan
parents:
diff changeset
   205
lemma current_fd_has_user': "\<lbrakk>user_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
chunhan
parents:
diff changeset
   206
by (auto intro:notI dest:current_fd_has_user)
chunhan
parents:
diff changeset
   207
chunhan
parents:
diff changeset
   208
lemma init_node_has_user: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_node n) = Some t" 
chunhan
parents:
diff changeset
   209
by (auto intro: alive_obj_has_user)
chunhan
parents:
diff changeset
   210
chunhan
parents:
diff changeset
   211
lemma init_node_has_user': "\<lbrakk>user_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes" 
chunhan
parents:
diff changeset
   212
by (auto intro:notI dest:init_node_has_user)
chunhan
parents:
diff changeset
   213
chunhan
parents:
diff changeset
   214
(*
chunhan
parents:
diff changeset
   215
lemma current_shm_has_user: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_shm h) = Some t" 
chunhan
parents:
diff changeset
   216
by (auto intro:alive_obj_has_user)
chunhan
parents:
diff changeset
   217
chunhan
parents:
diff changeset
   218
lemma current_shm_has_user': "\<lbrakk>user_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s" 
chunhan
parents:
diff changeset
   219
by (auto intro:notI dest:current_shm_has_user)
chunhan
parents:
diff changeset
   220
*)
chunhan
parents:
diff changeset
   221
chunhan
parents:
diff changeset
   222
lemma current_msgq_has_user: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_msgq q) = Some t" 
chunhan
parents:
diff changeset
   223
by (auto intro:alive_obj_has_user)
chunhan
parents:
diff changeset
   224
chunhan
parents:
diff changeset
   225
lemma current_msgq_has_user': "\<lbrakk>user_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   226
by (auto intro:notI dest:current_msgq_has_user)
chunhan
parents:
diff changeset
   227
chunhan
parents:
diff changeset
   228
lemma current_msg_has_user: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
   229
    \<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t" 
chunhan
parents:
diff changeset
   230
by (auto intro:alive_obj_has_user)
chunhan
parents:
diff changeset
   231
chunhan
parents:
diff changeset
   232
lemma current_msg_has_user': "\<lbrakk>user_of_obj s (O_msg q m) = None; valid s\<rbrakk>
chunhan
parents:
diff changeset
   233
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   234
by (auto dest!:current_msg_has_user)
chunhan
parents:
diff changeset
   235
chunhan
parents:
diff changeset
   236
lemmas current_has_user = alive_obj_has_user current_proc_has_user is_file_has_user is_dir_has_user 
chunhan
parents:
diff changeset
   237
  is_tcp_has_user is_udp_has_user current_fd_has_user init_node_has_user (* current_shm_has_user *)
chunhan
parents:
diff changeset
   238
  current_msgq_has_user current_msg_has_user
chunhan
parents:
diff changeset
   239
chunhan
parents:
diff changeset
   240
lemmas current_has_user' = alive_obj_has_user' current_proc_has_user' is_file_has_user' is_dir_has_user'
chunhan
parents:
diff changeset
   241
  is_tcp_has_user' is_udp_has_user' current_fd_has_user' init_node_has_user' (* current_shm_has_user' *)
chunhan
parents:
diff changeset
   242
  current_msgq_has_user' current_msg_has_user' 
chunhan
parents:
diff changeset
   243
chunhan
parents:
diff changeset
   244
lemma current_proc_has_role:
chunhan
parents:
diff changeset
   245
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> r. role_of_proc s p = Some r"
chunhan
parents:
diff changeset
   246
apply (induct s arbitrary:p, simp add:init_procrole_prop2)
chunhan
parents:
diff changeset
   247
apply (frule vd_cons, frule vt_grant_os, frule vt_grant, case_tac a)
chunhan
parents:
diff changeset
   248
apply (auto split:option.splits dest:current_has_type' simp:sectxt_of_obj_def)
chunhan
parents:
diff changeset
   249
done
chunhan
parents:
diff changeset
   250
chunhan
parents:
diff changeset
   251
lemma current_proc_has_role':
chunhan
parents:
diff changeset
   252
  "\<lbrakk>role_of_proc s p = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
chunhan
parents:
diff changeset
   253
by (auto dest:current_proc_has_role)
chunhan
parents:
diff changeset
   254
chunhan
parents:
diff changeset
   255
lemma alive_obj_has_role:
chunhan
parents:
diff changeset
   256
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> r. role_of_obj s obj = Some r"
chunhan
parents:
diff changeset
   257
by (case_tac obj, auto intro:current_proc_has_role)
chunhan
parents:
diff changeset
   258
chunhan
parents:
diff changeset
   259
lemma alive_obj_has_sec:
chunhan
parents:
diff changeset
   260
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s obj = Some sec"
chunhan
parents:
diff changeset
   261
apply (frule alive_obj_has_type, simp)
chunhan
parents:
diff changeset
   262
apply (frule alive_obj_has_role, simp)
chunhan
parents:
diff changeset
   263
apply (frule alive_obj_has_user, simp)
chunhan
parents:
diff changeset
   264
apply (auto split:option.splits simp:sectxt_of_obj_def)
chunhan
parents:
diff changeset
   265
done
chunhan
parents:
diff changeset
   266
chunhan
parents:
diff changeset
   267
lemma alive_obj_has_sec':
chunhan
parents:
diff changeset
   268
  "\<lbrakk>sectxt_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
chunhan
parents:
diff changeset
   269
by (auto dest:alive_obj_has_sec)
chunhan
parents:
diff changeset
   270
chunhan
parents:
diff changeset
   271
lemma alive_obj_has_sec'':
chunhan
parents:
diff changeset
   272
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s obj = Some (u,r,t)"
chunhan
parents:
diff changeset
   273
by (auto dest:alive_obj_has_sec)
chunhan
parents:
diff changeset
   274
chunhan
parents:
diff changeset
   275
lemma current_proc_has_sec: 
chunhan
parents:
diff changeset
   276
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_proc p) = Some sec"
chunhan
parents:
diff changeset
   277
by (rule alive_obj_has_sec, simp+) 
chunhan
parents:
diff changeset
   278
chunhan
parents:
diff changeset
   279
lemma current_proc_has_sec': 
chunhan
parents:
diff changeset
   280
  "\<lbrakk>sectxt_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s" 
chunhan
parents:
diff changeset
   281
by (rule notI, auto dest:current_proc_has_sec)
chunhan
parents:
diff changeset
   282
chunhan
parents:
diff changeset
   283
lemma current_proc_has_sec'': 
chunhan
parents:
diff changeset
   284
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_proc p) = Some (u,r,t)"
chunhan
parents:
diff changeset
   285
by (drule current_proc_has_sec, auto)
chunhan
parents:
diff changeset
   286
chunhan
parents:
diff changeset
   287
lemma is_file_has_sec: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_file f) = Some sec"
chunhan
parents:
diff changeset
   288
by (rule alive_obj_has_sec, simp_all add:is_file_in_current)
chunhan
parents:
diff changeset
   289
chunhan
parents:
diff changeset
   290
lemma is_file_has_sec': "\<lbrakk>sectxt_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
chunhan
parents:
diff changeset
   291
by (auto intro:notI dest:is_file_has_sec)
chunhan
parents:
diff changeset
   292
chunhan
parents:
diff changeset
   293
lemma is_file_has_sec'': "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_file f) = Some (u,r,t)"
chunhan
parents:
diff changeset
   294
by (drule is_file_has_sec, auto)
chunhan
parents:
diff changeset
   295
chunhan
parents:
diff changeset
   296
lemma is_dir_has_sec: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_dir f) = Some sec"
chunhan
parents:
diff changeset
   297
by (rule alive_obj_has_sec, simp_all add:is_dir_in_current)
chunhan
parents:
diff changeset
   298
chunhan
parents:
diff changeset
   299
lemma is_dir_has_sec': "\<lbrakk>sectxt_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
chunhan
parents:
diff changeset
   300
by (auto intro:notI dest:is_dir_has_sec)
chunhan
parents:
diff changeset
   301
chunhan
parents:
diff changeset
   302
lemma is_dir_has_sec'': "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_dir f) = Some (u,r,t)"
chunhan
parents:
diff changeset
   303
by (drule is_dir_has_sec, auto)
chunhan
parents:
diff changeset
   304
chunhan
parents:
diff changeset
   305
lemma is_tcp_has_sec: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_tcp_sock sock) = Some sec"
chunhan
parents:
diff changeset
   306
by (rule alive_obj_has_sec, simp_all add:is_tcp_in_current)
chunhan
parents:
diff changeset
   307
chunhan
parents:
diff changeset
   308
lemma is_tcp_has_sec': "\<lbrakk>sectxt_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
chunhan
parents:
diff changeset
   309
by (auto intro:notI dest:is_tcp_has_sec)
chunhan
parents:
diff changeset
   310
chunhan
parents:
diff changeset
   311
lemma is_tcp_has_sec'': "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> 
chunhan
parents:
diff changeset
   312
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_tcp_sock sock) = Some (u,r,t)"
chunhan
parents:
diff changeset
   313
by (drule is_tcp_has_sec, simp_all add:is_tcp_in_current)
chunhan
parents:
diff changeset
   314
chunhan
parents:
diff changeset
   315
lemma is_udp_has_sec: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_udp_sock sock) = Some sec"
chunhan
parents:
diff changeset
   316
by (rule alive_obj_has_sec, simp_all add:is_udp_in_current)
chunhan
parents:
diff changeset
   317
chunhan
parents:
diff changeset
   318
lemma is_udp_has_sec': "\<lbrakk>sectxt_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
chunhan
parents:
diff changeset
   319
by (auto intro:notI dest:is_udp_has_sec)
chunhan
parents:
diff changeset
   320
chunhan
parents:
diff changeset
   321
lemma is_udp_has_sec'': "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> 
chunhan
parents:
diff changeset
   322
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_udp_sock sock) = Some (u,r,t)"
chunhan
parents:
diff changeset
   323
by (drule is_udp_has_sec, simp_all add:is_udp_in_current)
chunhan
parents:
diff changeset
   324
chunhan
parents:
diff changeset
   325
lemma current_fd_has_sec: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_fd p fd) = Some sec"
chunhan
parents:
diff changeset
   326
by (rule alive_obj_has_sec, simp+)
chunhan
parents:
diff changeset
   327
chunhan
parents:
diff changeset
   328
lemma current_fd_has_sec': "\<lbrakk>sectxt_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
chunhan
parents:
diff changeset
   329
by (auto intro:notI dest:current_fd_has_sec)
chunhan
parents:
diff changeset
   330
chunhan
parents:
diff changeset
   331
lemma current_fd_has_sec'': "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> 
chunhan
parents:
diff changeset
   332
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_fd p fd) = Some (u, r, t)"
chunhan
parents:
diff changeset
   333
by (drule current_fd_has_sec, simp+)
chunhan
parents:
diff changeset
   334
chunhan
parents:
diff changeset
   335
lemma init_node_has_sec: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_node n) = Some sec" 
chunhan
parents:
diff changeset
   336
by (rule alive_obj_has_sec, simp+)
chunhan
parents:
diff changeset
   337
chunhan
parents:
diff changeset
   338
lemma init_node_has_sec': "\<lbrakk>sectxt_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes" 
chunhan
parents:
diff changeset
   339
by (auto intro:notI dest:init_node_has_sec)
chunhan
parents:
diff changeset
   340
chunhan
parents:
diff changeset
   341
lemma init_node_has_sec'': "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_node n) = Some (u,r,t)" 
chunhan
parents:
diff changeset
   342
by (drule init_node_has_sec, simp+)
chunhan
parents:
diff changeset
   343
chunhan
parents:
diff changeset
   344
(*
chunhan
parents:
diff changeset
   345
lemma current_shm_has_sec: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_shm h) = Some sec" 
chunhan
parents:
diff changeset
   346
by (rule alive_obj_has_sec, simp+)
chunhan
parents:
diff changeset
   347
chunhan
parents:
diff changeset
   348
lemma current_shm_has_sec': "\<lbrakk>sectxt_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s" 
chunhan
parents:
diff changeset
   349
by (auto intro:notI dest:current_shm_has_sec)
chunhan
parents:
diff changeset
   350
chunhan
parents:
diff changeset
   351
lemma current_shm_has_sec'': "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_shm h) = Some (u,r,t)" 
chunhan
parents:
diff changeset
   352
by (drule current_shm_has_sec, simp+)
chunhan
parents:
diff changeset
   353
*)
chunhan
parents:
diff changeset
   354
chunhan
parents:
diff changeset
   355
lemma current_msgq_has_sec: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_msgq q) = Some sec" 
chunhan
parents:
diff changeset
   356
by (rule alive_obj_has_sec, simp+)
chunhan
parents:
diff changeset
   357
chunhan
parents:
diff changeset
   358
lemma current_msgq_has_sec': "\<lbrakk>sectxt_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   359
by (auto intro:notI dest:current_msgq_has_sec)
chunhan
parents:
diff changeset
   360
chunhan
parents:
diff changeset
   361
lemma current_msgq_has_sec'': "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> 
chunhan
parents:
diff changeset
   362
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msgq q) = Some (u,r,t)" 
chunhan
parents:
diff changeset
   363
by (drule current_msgq_has_sec, simp+)
chunhan
parents:
diff changeset
   364
chunhan
parents:
diff changeset
   365
lemma current_msg_has_sec: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
   366
    \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_msg q m) = Some sec" 
chunhan
parents:
diff changeset
   367
by (rule alive_obj_has_sec, simp+)
chunhan
parents:
diff changeset
   368
chunhan
parents:
diff changeset
   369
lemma current_msg_has_sec': "\<lbrakk>sectxt_of_obj s (O_msg q m) = None; valid s\<rbrakk>
chunhan
parents:
diff changeset
   370
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
chunhan
parents:
diff changeset
   371
by (auto dest!:current_msg_has_sec)
chunhan
parents:
diff changeset
   372
chunhan
parents:
diff changeset
   373
lemma current_msg_has_sec'': "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
   374
    \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msg q m) = Some (u, r, t)" 
chunhan
parents:
diff changeset
   375
by (drule current_msg_has_sec, simp+)
chunhan
parents:
diff changeset
   376
chunhan
parents:
diff changeset
   377
lemmas current_has_sec = alive_obj_has_sec current_proc_has_sec is_file_has_sec is_dir_has_sec 
chunhan
parents:
diff changeset
   378
  is_tcp_has_sec is_udp_has_sec current_fd_has_sec init_node_has_sec (* current_shm_has_sec *)
chunhan
parents:
diff changeset
   379
  current_msgq_has_sec current_msg_has_sec
chunhan
parents:
diff changeset
   380
chunhan
parents:
diff changeset
   381
lemmas current_has_sec' = alive_obj_has_sec' current_proc_has_sec' is_file_has_sec' is_dir_has_sec'
chunhan
parents:
diff changeset
   382
  is_tcp_has_sec' is_udp_has_sec' current_fd_has_sec' init_node_has_sec' (* current_shm_has_sec' *)
chunhan
parents:
diff changeset
   383
  current_msgq_has_sec' current_msg_has_sec' 
chunhan
parents:
diff changeset
   384
chunhan
parents:
diff changeset
   385
lemmas current_has_sec'' = alive_obj_has_sec'' current_proc_has_sec'' is_file_has_sec'' is_dir_has_sec''
chunhan
parents:
diff changeset
   386
  is_tcp_has_sec'' is_udp_has_sec'' current_fd_has_sec'' init_node_has_sec'' (* current_shm_has_sec'' *)
chunhan
parents:
diff changeset
   387
  current_msgq_has_sec'' current_msg_has_sec'' 
chunhan
parents:
diff changeset
   388
chunhan
parents:
diff changeset
   389
(************ root sec remains ************)
chunhan
parents:
diff changeset
   390
chunhan
parents:
diff changeset
   391
lemma root_type_remains:
chunhan
parents:
diff changeset
   392
  "valid s \<Longrightarrow> type_of_obj s (O_dir []) = init_type_of_obj (O_dir [])"
chunhan
parents:
diff changeset
   393
apply (induct s)
chunhan
parents:
diff changeset
   394
apply (simp)
chunhan
parents:
diff changeset
   395
apply (frule vd_cons, frule vt_grant_os, case_tac a) prefer 6 
chunhan
parents:
diff changeset
   396
by (case_tac option, auto)
chunhan
parents:
diff changeset
   397
chunhan
parents:
diff changeset
   398
lemma root_user_remains:
chunhan
parents:
diff changeset
   399
  "valid s \<Longrightarrow> user_of_obj s (O_dir []) = init_user_of_obj (O_dir [])"
chunhan
parents:
diff changeset
   400
apply (induct s)
chunhan
parents:
diff changeset
   401
apply (simp)
chunhan
parents:
diff changeset
   402
apply (frule vd_cons, frule vt_grant_os, case_tac a) prefer 6 
chunhan
parents:
diff changeset
   403
by (case_tac option, auto)
chunhan
parents:
diff changeset
   404
chunhan
parents:
diff changeset
   405
lemma root_has_type':
chunhan
parents:
diff changeset
   406
  "\<lbrakk>type_of_obj s (O_dir []) = None; valid s\<rbrakk> \<Longrightarrow> False"
chunhan
parents:
diff changeset
   407
apply (drule alive_obj_has_type', simp)
chunhan
parents:
diff changeset
   408
by (drule root_is_dir, simp)
chunhan
parents:
diff changeset
   409
chunhan
parents:
diff changeset
   410
lemma root_has_user':
chunhan
parents:
diff changeset
   411
  "\<lbrakk>user_of_obj s (O_dir []) = None; valid s\<rbrakk> \<Longrightarrow> False"
chunhan
parents:
diff changeset
   412
apply (drule alive_obj_has_user', simp)
chunhan
parents:
diff changeset
   413
by (drule root_is_dir, simp)
chunhan
parents:
diff changeset
   414
chunhan
parents:
diff changeset
   415
lemma root_has_init_type':
chunhan
parents:
diff changeset
   416
  "init_type_of_obj (O_dir []) = None \<Longrightarrow> False"
chunhan
parents:
diff changeset
   417
using init_obj_has_type[where obj = "O_dir []"] root_is_init_dir
chunhan
parents:
diff changeset
   418
by auto
chunhan
parents:
diff changeset
   419
chunhan
parents:
diff changeset
   420
lemma root_has_init_user':
chunhan
parents:
diff changeset
   421
  "init_user_of_obj (O_dir []) = None \<Longrightarrow> False"
chunhan
parents:
diff changeset
   422
using init_obj_has_user[where obj = "O_dir []"] root_is_init_dir
chunhan
parents:
diff changeset
   423
by auto
chunhan
parents:
diff changeset
   424
chunhan
parents:
diff changeset
   425
lemma root_sec_remains:
chunhan
parents:
diff changeset
   426
  "valid s \<Longrightarrow> sectxt_of_obj s (O_dir []) = init_sectxt_of_obj (O_dir [])"
chunhan
parents:
diff changeset
   427
by (auto simp:root_user_remains root_type_remains sectxt_of_obj_def init_sectxt_of_obj_def
chunhan
parents:
diff changeset
   428
        split:option.splits)
chunhan
parents:
diff changeset
   429
chunhan
parents:
diff changeset
   430
lemma root_sec_set:
chunhan
parents:
diff changeset
   431
  "\<exists> u t. sec_of_root = (u, R_object, t)"
chunhan
parents:
diff changeset
   432
by (auto simp:sec_of_root_def split:option.splits
chunhan
parents:
diff changeset
   433
        dest!: root_has_init_type' root_has_init_user')
chunhan
parents:
diff changeset
   434
chunhan
parents:
diff changeset
   435
lemma sec_of_root_set:
chunhan
parents:
diff changeset
   436
  "init_sectxt_of_obj (O_dir []) = Some sec_of_root"
chunhan
parents:
diff changeset
   437
using root_has_init_type' root_has_init_user'
chunhan
parents:
diff changeset
   438
apply (auto simp:init_sectxt_of_obj_def sec_of_root_def split:option.splits)
chunhan
parents:
diff changeset
   439
done
chunhan
parents:
diff changeset
   440
chunhan
parents:
diff changeset
   441
(*************** sectxt_of_obj simpset ****************)
chunhan
parents:
diff changeset
   442
chunhan
parents:
diff changeset
   443
lemma sec_execve:
chunhan
parents:
diff changeset
   444
  "valid (Execve p f fds # s) \<Longrightarrow> sectxt_of_obj (Execve p f fds # s) = 
chunhan
parents:
diff changeset
   445
   (sectxt_of_obj s) (O_proc p := (
chunhan
parents:
diff changeset
   446
     case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_file f)) of
chunhan
parents:
diff changeset
   447
       (Some psec, Some fsec) \<Rightarrow> npctxt_execve psec fsec
chunhan
parents:
diff changeset
   448
     | _ \<Rightarrow> None))"
chunhan
parents:
diff changeset
   449
apply (rule ext, frule vd_cons, frule vt_grant_os, frule vt_grant,case_tac x)
chunhan
parents:
diff changeset
   450
apply (auto simp:sectxt_of_obj_def split:option.splits 
chunhan
parents:
diff changeset
   451
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   452
done
chunhan
parents:
diff changeset
   453
chunhan
parents:
diff changeset
   454
lemma sec_clone:
chunhan
parents:
diff changeset
   455
  "valid (Clone p p' fds # s) \<Longrightarrow> sectxt_of_obj (Clone p p' fds # s) = (\<lambda> obj. 
chunhan
parents:
diff changeset
   456
     case obj of 
chunhan
parents:
diff changeset
   457
       O_proc p'' \<Rightarrow> if (p'' = p') then sectxt_of_obj s (O_proc p) 
chunhan
parents:
diff changeset
   458
                     else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   459
     | O_fd p'' fd \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_fd p fd)
chunhan
parents:
diff changeset
   460
                      else if (p'' = p') then None
chunhan
parents:
diff changeset
   461
                      else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   462
     | O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_tcp_sock (p, fd))
chunhan
parents:
diff changeset
   463
                               else if (p'' = p') then None
chunhan
parents:
diff changeset
   464
                               else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   465
     | O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_udp_sock (p, fd))
chunhan
parents:
diff changeset
   466
                               else if (p'' = p') then None
chunhan
parents:
diff changeset
   467
                               else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   468
     | _ \<Rightarrow> sectxt_of_obj s obj )"
chunhan
parents:
diff changeset
   469
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
chunhan
parents:
diff changeset
   470
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   471
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   472
done
chunhan
parents:
diff changeset
   473
chunhan
parents:
diff changeset
   474
lemma sec_open:
chunhan
parents:
diff changeset
   475
  "valid (Open p f flags fd opt # s) \<Longrightarrow> sectxt_of_obj (Open p f flags fd opt # s) = (\<lambda> obj. 
chunhan
parents:
diff changeset
   476
     case obj of
chunhan
parents:
diff changeset
   477
       O_file f' \<Rightarrow> if (f' = f \<and> opt \<noteq> None) then 
chunhan
parents:
diff changeset
   478
                      (case (parent f) of 
chunhan
parents:
diff changeset
   479
                         None \<Rightarrow> None
chunhan
parents:
diff changeset
   480
                       | Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
chunhan
parents:
diff changeset
   481
                                      (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
chunhan
parents:
diff changeset
   482
                                        type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
chunhan
parents:
diff changeset
   483
                                    | _ \<Rightarrow> None))
chunhan
parents:
diff changeset
   484
                    else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   485
     | O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then 
chunhan
parents:
diff changeset
   486
                        (case (sectxt_of_obj s (O_proc p)) of 
chunhan
parents:
diff changeset
   487
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   488
                         | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   489
                      else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   490
     | _ \<Rightarrow> sectxt_of_obj s obj)"
chunhan
parents:
diff changeset
   491
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
chunhan
parents:
diff changeset
   492
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   493
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   494
done
chunhan
parents:
diff changeset
   495
chunhan
parents:
diff changeset
   496
lemma sec_mkdir:
chunhan
parents:
diff changeset
   497
  "valid (Mkdir p f inum # s) \<Longrightarrow> sectxt_of_obj (Mkdir p f inum # s) = 
chunhan
parents:
diff changeset
   498
     (sectxt_of_obj s) (O_dir f := 
chunhan
parents:
diff changeset
   499
        (case parent f of 
chunhan
parents:
diff changeset
   500
           None \<Rightarrow> None
chunhan
parents:
diff changeset
   501
         | Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
chunhan
parents:
diff changeset
   502
                         (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
chunhan
parents:
diff changeset
   503
                            type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_dir True)
chunhan
parents:
diff changeset
   504
                      | _ \<Rightarrow> None)))"
chunhan
parents:
diff changeset
   505
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
chunhan
parents:
diff changeset
   506
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   507
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   508
done
chunhan
parents:
diff changeset
   509
chunhan
parents:
diff changeset
   510
lemma sec_linkhard:
chunhan
parents:
diff changeset
   511
  "valid (LinkHard p f f' # s) \<Longrightarrow> sectxt_of_obj (LinkHard p f f' # s) = 
chunhan
parents:
diff changeset
   512
     (sectxt_of_obj s) (O_file f' := 
chunhan
parents:
diff changeset
   513
        (case parent f' of 
chunhan
parents:
diff changeset
   514
           None \<Rightarrow> None
chunhan
parents:
diff changeset
   515
         | Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
chunhan
parents:
diff changeset
   516
                         (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
chunhan
parents:
diff changeset
   517
                            type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
chunhan
parents:
diff changeset
   518
                      | _ \<Rightarrow> None)))"
chunhan
parents:
diff changeset
   519
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
chunhan
parents:
diff changeset
   520
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   521
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   522
done
chunhan
parents:
diff changeset
   523
chunhan
parents:
diff changeset
   524
lemma sec_createmsgq:
chunhan
parents:
diff changeset
   525
  "valid (CreateMsgq p q # s) \<Longrightarrow> sectxt_of_obj (CreateMsgq p q # s) = (sectxt_of_obj s) (O_msgq q := 
chunhan
parents:
diff changeset
   526
     (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   527
        Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   528
      | _ \<Rightarrow> None))"
chunhan
parents:
diff changeset
   529
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
chunhan
parents:
diff changeset
   530
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   531
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   532
done
chunhan
parents:
diff changeset
   533
chunhan
parents:
diff changeset
   534
lemma sec_sendmsg:
chunhan
parents:
diff changeset
   535
  "valid (SendMsg p q m # s) \<Longrightarrow> sectxt_of_obj (SendMsg p q m # s) = (sectxt_of_obj s) (O_msg q m := 
chunhan
parents:
diff changeset
   536
     (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_msgq q)) of 
chunhan
parents:
diff changeset
   537
        (Some psec, Some qsec) \<Rightarrow> Some (fst psec, R_object, 
chunhan
parents:
diff changeset
   538
           type_transition ((snd o snd) psec) ((snd o snd) qsec) C_msg False)
chunhan
parents:
diff changeset
   539
      | _ \<Rightarrow> None))"
chunhan
parents:
diff changeset
   540
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
chunhan
parents:
diff changeset
   541
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   542
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   543
done
chunhan
parents:
diff changeset
   544
chunhan
parents:
diff changeset
   545
(*
chunhan
parents:
diff changeset
   546
lemma sec_createshm:
chunhan
parents:
diff changeset
   547
  "valid (CreateShM p h # s) \<Longrightarrow> sectxt_of_obj (CreateShM p h # s) = (sectxt_of_obj s) (O_shm h := 
chunhan
parents:
diff changeset
   548
     case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   549
        Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   550
      | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   551
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
chunhan
parents:
diff changeset
   552
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   553
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   554
done
chunhan
parents:
diff changeset
   555
*)
chunhan
parents:
diff changeset
   556
chunhan
parents:
diff changeset
   557
lemma sec_createsock:
chunhan
parents:
diff changeset
   558
  "valid (CreateSock p af st fd inum # s) \<Longrightarrow> sectxt_of_obj (CreateSock p af st fd inum # s) = (\<lambda> obj. 
chunhan
parents:
diff changeset
   559
     case obj of       
chunhan
parents:
diff changeset
   560
       O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then 
chunhan
parents:
diff changeset
   561
                        (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   562
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   563
                         | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   564
                      else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   565
     | O_tcp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = STREAM) then 
chunhan
parents:
diff changeset
   566
                                 (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   567
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   568
                                  | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   569
                               else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   570
     | O_udp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = DGRAM) then 
chunhan
parents:
diff changeset
   571
                                 (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   572
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   573
                                  | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   574
                               else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   575
     | _ \<Rightarrow> sectxt_of_obj s obj )"
chunhan
parents:
diff changeset
   576
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
chunhan
parents:
diff changeset
   577
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   578
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   579
done
chunhan
parents:
diff changeset
   580
chunhan
parents:
diff changeset
   581
lemma sec_accept: 
chunhan
parents:
diff changeset
   582
  "valid (Accept p fd addr port fd' inum # s) \<Longrightarrow> sectxt_of_obj (Accept p fd addr port fd' inum # s) = (\<lambda> obj. 
chunhan
parents:
diff changeset
   583
     case obj of       
chunhan
parents:
diff changeset
   584
       O_fd p' fd'' \<Rightarrow> if (p' = p \<and> fd'' = fd') then 
chunhan
parents:
diff changeset
   585
                        (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   586
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   587
                         | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   588
                      else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   589
     | O_tcp_sock (p', fd'') \<Rightarrow> if (p' = p \<and> fd'' = fd') then 
chunhan
parents:
diff changeset
   590
                                 (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   591
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
chunhan
parents:
diff changeset
   592
                                  | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   593
                               else sectxt_of_obj s obj
chunhan
parents:
diff changeset
   594
     | _ \<Rightarrow> sectxt_of_obj s obj )"
chunhan
parents:
diff changeset
   595
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
chunhan
parents:
diff changeset
   596
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   597
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   598
done
chunhan
parents:
diff changeset
   599
chunhan
parents:
diff changeset
   600
lemma sec_others :
chunhan
parents:
diff changeset
   601
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
   602
    \<forall> p p' fds. e \<noteq> Clone p p' fds;
chunhan
parents:
diff changeset
   603
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
   604
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
chunhan
parents:
diff changeset
   605
    \<forall> p f inum. e \<noteq> Mkdir p f inum;
chunhan
parents:
diff changeset
   606
    \<forall> p f f'. e \<noteq> LinkHard p f f';
chunhan
parents:
diff changeset
   607
    \<forall> p q. e \<noteq> CreateMsgq p q;
chunhan
parents:
diff changeset
   608
    \<forall> p q m. e \<noteq> SendMsg p q m;
chunhan
parents:
diff changeset
   609
    \<forall> p af st fd inum. e \<noteq> CreateSock p af st fd inum;
chunhan
parents:
diff changeset
   610
    \<forall> p fd addr port fd' inum. e \<noteq> Accept p fd addr port fd' inum
chunhan
parents:
diff changeset
   611
   \<rbrakk> \<Longrightarrow> sectxt_of_obj (e # s) = sectxt_of_obj s" (*
chunhan
parents:
diff changeset
   612
    \<forall> p h. e \<noteq> CreateShM p h;*)
chunhan
parents:
diff changeset
   613
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac e, case_tac[!] x)
chunhan
parents:
diff changeset
   614
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
chunhan
parents:
diff changeset
   615
           dest!:current_has_type' current_proc_has_role' current_has_user')
chunhan
parents:
diff changeset
   616
done
chunhan
parents:
diff changeset
   617
chunhan
parents:
diff changeset
   618
lemma sec_kill: 
chunhan
parents:
diff changeset
   619
  "valid (Kill p p' # s) \<Longrightarrow> sectxt_of_obj (Kill p p' # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   620
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   621
chunhan
parents:
diff changeset
   622
lemma sec_ptrace:
chunhan
parents:
diff changeset
   623
  "valid (Ptrace p p' # s) \<Longrightarrow> sectxt_of_obj (Ptrace p p' # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   624
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   625
chunhan
parents:
diff changeset
   626
lemma sec_exit:
chunhan
parents:
diff changeset
   627
  "valid (Exit p # s) \<Longrightarrow> sectxt_of_obj (Exit p # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   628
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   629
chunhan
parents:
diff changeset
   630
lemma sec_readfile:
chunhan
parents:
diff changeset
   631
  "valid (ReadFile p fd # s) \<Longrightarrow> sectxt_of_obj (ReadFile p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   632
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   633
chunhan
parents:
diff changeset
   634
lemma sec_writefile:
chunhan
parents:
diff changeset
   635
  "valid (WriteFile p fd # s) \<Longrightarrow> sectxt_of_obj (WriteFile p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   636
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   637
chunhan
parents:
diff changeset
   638
lemma sec_closefd:
chunhan
parents:
diff changeset
   639
  "valid (CloseFd p fd # s) \<Longrightarrow> sectxt_of_obj (CloseFd p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   640
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   641
chunhan
parents:
diff changeset
   642
lemma sec_unlink:
chunhan
parents:
diff changeset
   643
  "valid (UnLink p f # s) \<Longrightarrow> sectxt_of_obj (UnLink p f # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   644
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   645
chunhan
parents:
diff changeset
   646
lemma sec_Rmdir:
chunhan
parents:
diff changeset
   647
  "valid (Rmdir p f # s) \<Longrightarrow> sectxt_of_obj (Rmdir p f # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   648
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   649
chunhan
parents:
diff changeset
   650
lemma sec_truncate:
chunhan
parents:
diff changeset
   651
  "valid (Truncate p f len # s) \<Longrightarrow> sectxt_of_obj (Truncate p f len # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   652
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   653
chunhan
parents:
diff changeset
   654
lemma sec_recvmsg:
chunhan
parents:
diff changeset
   655
  "valid (RecvMsg p q m # s) \<Longrightarrow> sectxt_of_obj (RecvMsg p q m # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   656
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   657
chunhan
parents:
diff changeset
   658
lemma sec_removemsgq:
chunhan
parents:
diff changeset
   659
  "valid (RemoveMsgq p q # s) \<Longrightarrow> sectxt_of_obj (RemoveMsgq p q # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   660
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   661
chunhan
parents:
diff changeset
   662
(*
chunhan
parents:
diff changeset
   663
lemma sec_attach:
chunhan
parents:
diff changeset
   664
  "valid (Attach p h flag # s) \<Longrightarrow> sectxt_of_obj (Attach p h flag # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   665
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   666
chunhan
parents:
diff changeset
   667
lemma sec_detach:
chunhan
parents:
diff changeset
   668
  "valid (Detach p h # s) \<Longrightarrow> sectxt_of_obj (Detach p h # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   669
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   670
chunhan
parents:
diff changeset
   671
lemma sec_deleteshm:
chunhan
parents:
diff changeset
   672
  "valid (DeleteShM p h # s) \<Longrightarrow> sectxt_of_obj (DeleteShM p h # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   673
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   674
*)
chunhan
parents:
diff changeset
   675
chunhan
parents:
diff changeset
   676
lemma sec_bind:
chunhan
parents:
diff changeset
   677
  "valid (Bind p fd addr # s) \<Longrightarrow> sectxt_of_obj (Bind p fd addr # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   678
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   679
chunhan
parents:
diff changeset
   680
lemma sec_connect:
chunhan
parents:
diff changeset
   681
  "valid (Connect p fd addr # s) \<Longrightarrow> sectxt_of_obj (Connect p fd addr # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   682
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   683
chunhan
parents:
diff changeset
   684
lemma sec_listen:
chunhan
parents:
diff changeset
   685
  "valid (Listen p fd # s) \<Longrightarrow> sectxt_of_obj (Listen p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   686
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   687
chunhan
parents:
diff changeset
   688
lemma sec_sendsock:
chunhan
parents:
diff changeset
   689
  "valid (SendSock p fd # s) \<Longrightarrow> sectxt_of_obj (SendSock p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   690
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   691
chunhan
parents:
diff changeset
   692
lemma sec_recvsock:
chunhan
parents:
diff changeset
   693
  "valid (RecvSock p fd # s) \<Longrightarrow> sectxt_of_obj (RecvSock p fd # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   694
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   695
chunhan
parents:
diff changeset
   696
lemma sec_shutdown:
chunhan
parents:
diff changeset
   697
  "valid (Shutdown p fd how # s) \<Longrightarrow> sectxt_of_obj (Shutdown p fd how # s) = sectxt_of_obj s"
chunhan
parents:
diff changeset
   698
by (auto dest!:sec_others)
chunhan
parents:
diff changeset
   699
chunhan
parents:
diff changeset
   700
lemmas sectxt_of_obj_simps = sec_execve sec_open sec_mkdir sec_linkhard sec_createmsgq sec_sendmsg
chunhan
parents:
diff changeset
   701
 (* sec_createshm *) sec_createsock sec_accept sec_clone sec_kill sec_ptrace sec_exit sec_readfile
chunhan
parents:
diff changeset
   702
  sec_writefile sec_closefd sec_unlink sec_Rmdir sec_truncate sec_recvmsg sec_removemsgq
chunhan
parents:
diff changeset
   703
  (* sec_attach sec_detach sec_deleteshm *) sec_bind sec_connect sec_listen sec_sendsock
chunhan
parents:
diff changeset
   704
  sec_recvsock sec_shutdown
chunhan
parents:
diff changeset
   705
(* init_sectxt_prop *)
chunhan
parents:
diff changeset
   706
chunhan
parents:
diff changeset
   707
(**************** get_parentfs_ctxts simpset **************)
chunhan
parents:
diff changeset
   708
chunhan
parents:
diff changeset
   709
lemma parentf_is_dir_prop1: "\<lbrakk>is_dir s (x # pf); valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
chunhan
parents:
diff changeset
   710
apply (rule_tac f = "x # pf" in parentf_is_dir)
chunhan
parents:
diff changeset
   711
by (auto simp:is_dir_def current_files_def split:option.splits t_inode_tag.splits)
chunhan
parents:
diff changeset
   712
chunhan
parents:
diff changeset
   713
lemma parentf_is_dir_prop2: "\<lbrakk>is_file s (x # pf); valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
chunhan
parents:
diff changeset
   714
apply (rule_tac f = "x # pf" in parentf_is_dir)
chunhan
parents:
diff changeset
   715
by (auto simp:is_dir_def is_file_def current_files_def split:option.splits t_inode_tag.splits)
chunhan
parents:
diff changeset
   716
chunhan
parents:
diff changeset
   717
lemma parentf_is_dir_prop3: "\<lbrakk>(x # pf) \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
chunhan
parents:
diff changeset
   718
apply (rule_tac f = "x # pf" in parentf_is_dir)
chunhan
parents:
diff changeset
   719
by (auto simp:is_dir_def current_files_def split:option.splits t_inode_tag.splits)
chunhan
parents:
diff changeset
   720
chunhan
parents:
diff changeset
   721
lemma get_pfs_secs_prop':
chunhan
parents:
diff changeset
   722
  "\<lbrakk>get_parentfs_ctxts s f = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
chunhan
parents:
diff changeset
   723
apply (induct f)
chunhan
parents:
diff changeset
   724
by (auto split:option.splits dest:current_has_sec' parentf_is_dir_prop1)
chunhan
parents:
diff changeset
   725
chunhan
parents:
diff changeset
   726
lemma get_pfs_secs_prop:
chunhan
parents:
diff changeset
   727
  "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> asecs. get_parentfs_ctxts s f = Some asecs"
chunhan
parents:
diff changeset
   728
using get_pfs_secs_prop'
chunhan
parents:
diff changeset
   729
by (auto)
chunhan
parents:
diff changeset
   730
chunhan
parents:
diff changeset
   731
lemma get_pfs_secs_open:
chunhan
parents:
diff changeset
   732
  "valid (Open p f flags fd opt # s) \<Longrightarrow> get_parentfs_ctxts (Open p f flags fd opt # s) = get_parentfs_ctxts s"
chunhan
parents:
diff changeset
   733
apply (frule noroot_events, frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   734
apply (rule ext, induct_tac x)
chunhan
parents:
diff changeset
   735
by (auto split:option.splits simp:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   736
chunhan
parents:
diff changeset
   737
lemma get_pfs_secs_other:
chunhan
parents:
diff changeset
   738
  "\<lbrakk>valid (e # s); \<forall> p f inum. e \<noteq> Mkdir p f inum\<rbrakk> 
chunhan
parents:
diff changeset
   739
   \<Longrightarrow> get_parentfs_ctxts (e # s) = get_parentfs_ctxts s"
chunhan
parents:
diff changeset
   740
apply (frule vd_cons, frule vt_grant_os, rule ext, induct_tac x)
chunhan
parents:
diff changeset
   741
apply (case_tac [!] e)
chunhan
parents:
diff changeset
   742
apply (auto split:option.splits if_splits simp:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   743
done
chunhan
parents:
diff changeset
   744
chunhan
parents:
diff changeset
   745
lemma get_pfs_secs_mkdir1:
chunhan
parents:
diff changeset
   746
  assumes mkdir: "valid (Mkdir p f inum # s)" and noteq: "is_dir s f'"
chunhan
parents:
diff changeset
   747
  shows "get_parentfs_ctxts (Mkdir p f inum # s) f' = get_parentfs_ctxts s f'"
chunhan
parents:
diff changeset
   748
proof-
chunhan
parents:
diff changeset
   749
  from mkdir have vd: "valid s" and os: "os_grant s (Mkdir p f inum)"
chunhan
parents:
diff changeset
   750
    by (frule_tac vd_cons, simp, frule_tac vt_grant_os, simp)
chunhan
parents:
diff changeset
   751
  from mkdir have notroot: "f \<noteq> []" by (auto intro!:noroot_mkdir)
chunhan
parents:
diff changeset
   752
  show ?thesis using noteq
chunhan
parents:
diff changeset
   753
  proof (induct f')
chunhan
parents:
diff changeset
   754
    case Nil
chunhan
parents:
diff changeset
   755
    show ?case using notroot mkdir by (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   756
  next
chunhan
parents:
diff changeset
   757
    case (Cons a f')
chunhan
parents:
diff changeset
   758
    hence p1: "is_dir s f'" using vd by (simp add:parentf_is_dir_prop1)
chunhan
parents:
diff changeset
   759
    from Cons have p2: "is_dir s (a # f')" by simp
chunhan
parents:
diff changeset
   760
    from Cons p1 have p3: "get_parentfs_ctxts (Mkdir p f inum # s) f' = get_parentfs_ctxts s f'" by simp
chunhan
parents:
diff changeset
   761
    from p2 os have p4: "a # f' \<noteq> f" by (auto simp:is_dir_in_current)
chunhan
parents:
diff changeset
   762
    from p1 os have p5: "f' \<noteq> f"  by (auto simp:is_dir_in_current)
chunhan
parents:
diff changeset
   763
    show ?case using mkdir vd os p4 p5  p1
chunhan
parents:
diff changeset
   764
      by (auto simp:sectxt_of_obj_simps is_dir_simps p3
chunhan
parents:
diff changeset
   765
              split:option.splits   dest:current_has_sec' get_pfs_secs_prop')
chunhan
parents:
diff changeset
   766
  qed
chunhan
parents:
diff changeset
   767
qed
chunhan
parents:
diff changeset
   768
chunhan
parents:
diff changeset
   769
lemma get_pfs_secs_mkdir2:
chunhan
parents:
diff changeset
   770
  "valid (Mkdir p f inum # s) \<Longrightarrow> get_parentfs_ctxts (Mkdir p f inum # s) f = (
chunhan
parents:
diff changeset
   771
     case f of 
chunhan
parents:
diff changeset
   772
       [] \<Rightarrow> get_parentfs_ctxts s []
chunhan
parents:
diff changeset
   773
     | x#pf \<Rightarrow> (case (get_parentfs_ctxts s pf, sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
chunhan
parents:
diff changeset
   774
                 (Some pfsecs, Some psec, Some pfsec) \<Rightarrow> Some ((fst psec, R_object, type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_dir True) # pfsecs)
chunhan
parents:
diff changeset
   775
               | _ \<Rightarrow> None))"
chunhan
parents:
diff changeset
   776
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   777
apply (frule noroot_events, case_tac f)
chunhan
parents:
diff changeset
   778
by (auto split:option.splits dest:current_has_sec' get_pfs_secs_prop' get_pfs_secs_mkdir1
chunhan
parents:
diff changeset
   779
          simp:sectxt_of_obj_simps is_dir_simps)
chunhan
parents:
diff changeset
   780
chunhan
parents:
diff changeset
   781
lemmas get_parentfs_ctxts_simps = get_pfs_secs_other get_pfs_secs_mkdir1 get_pfs_secs_mkdir2
chunhan
parents:
diff changeset
   782
chunhan
parents:
diff changeset
   783
end
chunhan
parents:
diff changeset
   784
chunhan
parents:
diff changeset
   785
end