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