Sectxt_prop.thy
author chunhan
Thu, 16 Jan 2014 11:04:04 +0800
changeset 95 b7fd75d104bf
parent 73 924ab7a4e7fa
permissions -rw-r--r--
update
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)
73
chunhan
parents: 31
diff changeset
    42
    apply (frule_tac p = nat1 in file_fds_subset_pfds)
chunhan
parents: 31
diff changeset
    43
    apply (rule a1, auto)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
    done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
lemma alive_obj_has_user:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
  assumes alive: "alive s obj" and vs: "valid s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
  shows "\<exists> t. user_of_obj s obj = Some t"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
using alive vs
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
proof (induct s arbitrary:obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
  case Nil
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
  thus ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
    by (simp add:init_alive_prop[THEN sym] init_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
  case (Cons e s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
  hence a2: "alive (e # s) obj" and a3: "valid (e # s)" by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
  hence a4: "valid s" and a5: "os_grant s e" and a6: "grant s e" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
    by (auto intro:vd_cons vt_grant_os vt_grant)  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
  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
    61
  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
    62
  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
    63
  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
    64
    by (auto intro!:a1 simp:is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
  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
    66
    by (auto intro!:a1 simp:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
  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
    68
    by (auto intro!:a1 simp:is_tcp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
  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
    70
    by (auto intro!:a1 simp:is_udp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
  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
    72
    by (auto intro:a1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
  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
    74
  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
    75
  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
    76
  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
    77
    \<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t" by (auto intro:a1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
  show ?case using a5 a2 a4 a3
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
    apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
    apply (auto split:option.splits t_object.splits if_splits t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
                dest!:a1' intro:a1 intro:p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 simp:alive_simps)
73
chunhan
parents: 31
diff changeset
    82
    apply (frule_tac p = nat1 in file_fds_subset_pfds)
chunhan
parents: 31
diff changeset
    83
    apply (rule a1, auto)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
    done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
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
    88
by (rule_tac notI, auto dest: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>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
    92
by (auto intro:alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
lemma current_proc_has_type': 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
  "\<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
    96
by (rule notI, auto dest:current_proc_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    97
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    98
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
    99
by (auto intro:alive_obj_has_type simp:is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   100
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   101
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
   102
by (auto intro:notI dest:is_file_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   103
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   104
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
   105
by (auto intro:alive_obj_has_type simp:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   106
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   107
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
   108
by (auto intro:notI dest:is_dir_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   109
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
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
   111
by (auto intro:alive_obj_has_type simp:is_tcp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   112
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
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
   114
by (auto intro:notI dest:is_tcp_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   115
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   116
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
   117
by (auto intro:alive_obj_has_type simp:is_udp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   118
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   119
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
   120
by (auto intro:notI dest:is_udp_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   121
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
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
   123
by (auto intro:alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   125
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
   126
by (auto intro:notI dest:current_fd_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
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
   129
by (auto intro: alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   130
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   131
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
   132
by (auto intro:notI dest:init_node_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   133
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   134
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
   135
by (auto intro:alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   136
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   137
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
   138
by (auto intro:notI dest:current_shm_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   140
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
   141
by (auto intro:alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
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
   144
by (auto intro:notI dest:current_msgq_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
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
   147
    \<Longrightarrow> \<exists> t. type_of_obj s (O_msg q m) = Some t" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
by (auto intro:alive_obj_has_type)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
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
   151
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
by (auto dest!: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
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
   159
  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
   160
  current_msgq_has_type' current_msg_has_type' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   161
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   162
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
   163
by (rule_tac notI, auto dest: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>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
   167
by (auto intro:alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   168
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   169
lemma current_proc_has_user': 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   170
  "\<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
   171
by (rule notI, auto dest:current_proc_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   172
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   173
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
   174
by (auto intro:alive_obj_has_user simp:is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   175
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   176
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
   177
by (auto intro:notI dest:is_file_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   178
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   179
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
   180
by (auto intro:alive_obj_has_user simp:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   181
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   182
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
   183
by (auto intro:notI dest:is_dir_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   184
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   185
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
   186
by (auto intro:alive_obj_has_user simp:is_tcp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   187
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   188
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
   189
by (auto intro:notI dest:is_tcp_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   190
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   191
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
   192
by (auto intro:alive_obj_has_user simp:is_udp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   193
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
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
   195
by (auto intro:notI dest:is_udp_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   196
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   197
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
   198
by (auto intro:alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   199
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   200
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
   201
by (auto intro:notI dest:current_fd_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   202
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   203
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
   204
by (auto intro: alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   205
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   206
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
   207
by (auto intro:notI dest:init_node_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   208
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   209
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
   210
by (auto intro:alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   211
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   212
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
   213
by (auto intro:notI dest:current_shm_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   214
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   215
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
   216
by (auto intro:alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   217
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   218
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
   219
by (auto intro:notI dest:current_msgq_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   220
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   221
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
   222
    \<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   223
by (auto intro:alive_obj_has_user)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   224
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   225
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
   226
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   227
by (auto dest!: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
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
   234
  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
   235
  current_msgq_has_user' current_msg_has_user' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   237
lemma current_proc_has_role:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   238
  "\<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
   239
apply (induct s arbitrary:p, simp add:init_procrole_prop2)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
apply (frule vd_cons, frule vt_grant_os, frule vt_grant, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   241
apply (auto split:option.splits dest:current_has_type' simp:sectxt_of_obj_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   242
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
lemma current_proc_has_role':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   245
  "\<lbrakk>role_of_proc s p = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   246
by (auto dest:current_proc_has_role)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
lemma alive_obj_has_role:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> r. role_of_obj s obj = Some r"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
by (case_tac obj, auto intro:current_proc_has_role)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
lemma alive_obj_has_sec:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s obj = Some sec"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
apply (frule alive_obj_has_type, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
apply (frule alive_obj_has_role, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
apply (frule alive_obj_has_user, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
apply (auto split:option.splits simp:sectxt_of_obj_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
done
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>sectxt_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
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 alive_obj_has_sec'':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
  "\<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
   266
by (auto dest:alive_obj_has_sec)
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>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
   270
by (rule alive_obj_has_sec, simp+) 
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>sectxt_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   274
by (rule notI, auto dest:current_proc_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   275
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   276
lemma current_proc_has_sec'': 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
  "\<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
   278
by (drule current_proc_has_sec, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   279
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
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
   281
by (rule alive_obj_has_sec, simp_all add:is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   283
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
   284
by (auto intro:notI dest:is_file_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   285
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   286
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
   287
by (drule is_file_has_sec, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   288
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   289
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
   290
by (rule alive_obj_has_sec, simp_all add:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   291
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   292
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
   293
by (auto intro:notI dest:is_dir_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   294
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   295
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
   296
by (drule is_dir_has_sec, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   297
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   298
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
   299
by (rule alive_obj_has_sec, simp_all add:is_tcp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   300
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   301
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
   302
by (auto intro:notI dest:is_tcp_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   303
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   304
lemma is_tcp_has_sec'': "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   305
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_tcp_sock sock) = Some (u,r,t)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   306
by (drule is_tcp_has_sec, simp_all add:is_tcp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   307
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   308
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
   309
by (rule alive_obj_has_sec, simp_all add:is_udp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   310
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   311
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
   312
by (auto intro:notI dest:is_udp_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   313
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   314
lemma is_udp_has_sec'': "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   315
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_udp_sock sock) = Some (u,r,t)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   316
by (drule is_udp_has_sec, simp_all add:is_udp_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   317
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   318
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
   319
by (rule alive_obj_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   320
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   321
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
   322
by (auto intro:notI dest:current_fd_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   323
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   324
lemma current_fd_has_sec'': "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   325
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_fd p fd) = Some (u, r, t)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   326
by (drule current_fd_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   327
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   328
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
   329
by (rule alive_obj_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   330
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   331
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
   332
by (auto intro:notI dest:init_node_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   333
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   334
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
   335
by (drule init_node_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   336
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   337
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
   338
by (rule alive_obj_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   339
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   340
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
   341
by (auto intro:notI dest:current_shm_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   342
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   343
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
   344
by (drule current_shm_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   345
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   346
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
   347
by (rule alive_obj_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   348
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   349
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
   350
by (auto intro:notI dest:current_msgq_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   351
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   352
lemma current_msgq_has_sec'': "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   353
  \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msgq q) = Some (u,r,t)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   354
by (drule current_msgq_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>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   357
    \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_msg q m) = Some sec" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   358
by (rule alive_obj_has_sec, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   359
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   360
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
   361
    \<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   362
by (auto dest!:current_msg_has_sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   363
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   364
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
   365
    \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msg q m) = Some (u, r, t)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   366
by (drule current_msg_has_sec, simp+)
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
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   376
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
   377
  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
   378
  current_msgq_has_sec'' current_msg_has_sec'' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   379
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   380
(************ root sec remains ************)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   381
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   382
lemma root_type_remains:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   383
  "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
   384
apply (induct s)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   385
apply (simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   386
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
   387
by (case_tac option, auto)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   388
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   389
lemma root_user_remains:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   390
  "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
   391
apply (induct s)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   392
apply (simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   393
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
   394
by (case_tac option, auto)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   395
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   396
lemma root_has_type':
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   397
  "\<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
   398
apply (drule alive_obj_has_type', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   399
by (drule root_is_dir, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   400
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   401
lemma root_has_user':
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   402
  "\<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
   403
apply (drule alive_obj_has_user', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   404
by (drule root_is_dir, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   405
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   406
lemma root_has_init_type':
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   407
  "init_type_of_obj (O_dir []) = None \<Longrightarrow> False"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   408
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
   409
by auto
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   410
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   411
lemma root_has_init_user':
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   412
  "init_user_of_obj (O_dir []) = None \<Longrightarrow> False"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   413
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
   414
by auto
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   415
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   416
lemma root_sec_remains:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   417
  "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
   418
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
   419
        split:option.splits)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   420
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   421
lemma root_sec_set:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   422
  "\<exists> u t. sec_of_root = (u, R_object, t)"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   423
by (auto simp:sec_of_root_def split:option.splits
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   424
        dest!: root_has_init_type' root_has_init_user')
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   425
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   426
lemma sec_of_root_set:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   427
  "init_sectxt_of_obj (O_dir []) = Some sec_of_root"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   428
using root_has_init_type' root_has_init_user'
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   429
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
   430
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 1
diff changeset
   431
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
(*************** sectxt_of_obj simpset ****************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   433
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   434
lemma sec_execve:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   435
  "valid (Execve p f fds # s) \<Longrightarrow> sectxt_of_obj (Execve p f fds # s) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   436
   (sectxt_of_obj s) (O_proc p := (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   437
     case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_file f)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   438
       (Some psec, Some fsec) \<Rightarrow> npctxt_execve psec fsec
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
     | _ \<Rightarrow> None))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
apply (rule ext, frule vd_cons, frule vt_grant_os, frule vt_grant,case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
apply (auto simp:sectxt_of_obj_def split:option.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   443
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   444
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   445
lemma sec_clone:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
  "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
   447
     case obj of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
       O_proc p'' \<Rightarrow> if (p'' = p') then sectxt_of_obj s (O_proc p) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   449
                     else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   450
     | 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
   451
                      else if (p'' = p') then None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   452
                      else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
     | 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
   454
                               else if (p'' = p') then None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
                               else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
     | 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
   457
                               else if (p'' = p') then None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   458
                               else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
     | _ \<Rightarrow> sectxt_of_obj s obj )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   461
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   464
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   465
lemma sec_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
  "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
   467
     case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
       O_file f' \<Rightarrow> if (f' = f \<and> opt \<noteq> None) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
                      (case (parent f) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
                         None \<Rightarrow> None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   471
                       | 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
   472
                                      (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
                                        type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   474
                                    | _ \<Rightarrow> None))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   475
                    else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
     | O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
                        (case (sectxt_of_obj s (O_proc p)) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   478
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   479
                         | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
                      else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
     | _ \<Rightarrow> sectxt_of_obj s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   482
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   483
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
lemma sec_mkdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   488
  "valid (Mkdir p f inum # s) \<Longrightarrow> sectxt_of_obj (Mkdir p f inum # s) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   489
     (sectxt_of_obj s) (O_dir f := 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   490
        (case parent f of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
           None \<Rightarrow> None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
         | 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
   493
                         (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
                            type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_dir True)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
                      | _ \<Rightarrow> None)))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   498
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
lemma sec_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
  "valid (LinkHard p f f' # s) \<Longrightarrow> sectxt_of_obj (LinkHard p f f' # s) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
     (sectxt_of_obj s) (O_file f' := 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   504
        (case parent f' of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
           None \<Rightarrow> None
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   506
         | 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
   507
                         (Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object, 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
                            type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
                      | _ \<Rightarrow> None)))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   510
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   511
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   513
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   515
lemma sec_createmsgq:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
  "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
   517
     (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
        Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
      | _ \<Rightarrow> None))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   520
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   522
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   523
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   525
lemma sec_sendmsg:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
  "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
   527
     (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_msgq q)) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
        (Some psec, Some qsec) \<Rightarrow> Some (fst psec, R_object, 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
           type_transition ((snd o snd) psec) ((snd o snd) qsec) C_msg False)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
      | _ \<Rightarrow> None))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   536
lemma sec_createshm:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   537
  "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
   538
     case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
        Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   540
      | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   542
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
lemma sec_createsock:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
  "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
   548
     case obj of       
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
       O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
                        (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   552
                         | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   553
                      else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
     | O_tcp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = STREAM) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
                                 (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
                                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
                               else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
     | O_udp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = DGRAM) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
                                 (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   561
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
                                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
                               else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
     | _ \<Rightarrow> sectxt_of_obj s obj )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   569
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
lemma sec_accept: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
  "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
   572
     case obj of       
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
       O_fd p' fd'' \<Rightarrow> if (p' = p \<and> fd'' = fd') then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
                        (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   575
                           Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
                         | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
                      else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   578
     | O_tcp_sock (p', fd'') \<Rightarrow> if (p' = p \<and> fd'' = fd') then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
                                 (case (sectxt_of_obj s (O_proc p)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
                                    Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   581
                                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
                               else sectxt_of_obj s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
     | _ \<Rightarrow> sectxt_of_obj s obj )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   585
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   586
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   587
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   588
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
lemma sec_others :
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   590
  "\<lbrakk>valid (e # s); 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
    \<forall> p f fds. e \<noteq> Execve p f fds;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   593
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
    \<forall> p f inum. e \<noteq> Mkdir p f inum;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
    \<forall> p f f'. e \<noteq> LinkHard p f f';
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
    \<forall> p q. e \<noteq> CreateMsgq p q;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
    \<forall> p q m. e \<noteq> SendMsg p q m;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
    \<forall> p h. e \<noteq> CreateShM p h;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   599
    \<forall> p af st fd inum. e \<noteq> CreateSock p af st fd inum;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
    \<forall> p fd addr port fd' inum. e \<noteq> Accept p fd addr port fd' inum
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
   \<rbrakk> \<Longrightarrow> sectxt_of_obj (e # s) = sectxt_of_obj s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   602
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac e, case_tac[!] x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
           dest!:current_has_type' current_proc_has_role' current_has_user')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   606
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   607
lemma sec_kill: 
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   608
  "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
   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_ptrace:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   612
  "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
   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_exit:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   616
  "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
   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_readfile:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   620
  "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
   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_writefile:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   624
  "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
   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_closefd:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   628
  "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
   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_unlink:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   632
  "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
   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_Rmdir:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   636
  "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
   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_truncate:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   640
  "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
   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_recvmsg:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   644
  "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
   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_removemsgq:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   648
  "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
   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_attach:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   652
  "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
   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_detach:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   656
  "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
   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_deleteshm:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   660
  "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
   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_bind:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   664
  "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
   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_connect:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   668
  "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
   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_listen:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   672
  "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
   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_sendsock:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   676
  "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
   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_recvsock:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   680
  "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
   681
by (auto dest!:sec_others)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   682
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   683
lemma sec_shutdown:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   684
  "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
   685
by (auto dest!:sec_others)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   686
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
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
   688
  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
   689
  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
   690
  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
   691
  sec_recvsock sec_shutdown
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 8
diff changeset
   692
(* init_sectxt_prop *)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   693
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   694
(**************** get_parentfs_ctxts simpset **************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   695
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   696
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
   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 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_prop2: "\<lbrakk>is_file s (x # pf); 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 is_file_def current_files_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   703
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   704
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
   705
apply (rule_tac f = "x # pf" in parentf_is_dir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   706
by (auto simp:is_dir_def current_files_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   707
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   708
lemma get_pfs_secs_prop':
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   709
  "\<lbrakk>get_parentfs_ctxts s f = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   710
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   711
by (auto split:option.splits dest:current_has_sec' parentf_is_dir_prop1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   712
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   713
lemma get_pfs_secs_prop:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   714
  "\<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
   715
using get_pfs_secs_prop'
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   716
by (auto)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   717
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   718
lemma get_pfs_secs_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   719
  "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
   720
apply (frule noroot_events, frule vd_cons, frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   721
apply (rule ext, induct_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   722
by (auto split:option.splits simp:sectxt_of_obj_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   723
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   724
lemma get_pfs_secs_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   725
  "\<lbrakk>valid (e # s); \<forall> p f inum. e \<noteq> Mkdir p f inum\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   726
   \<Longrightarrow> get_parentfs_ctxts (e # s) = get_parentfs_ctxts s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   727
apply (frule vd_cons, frule vt_grant_os, rule ext, induct_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   728
apply (case_tac [!] e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   729
apply (auto split:option.splits if_splits simp:sectxt_of_obj_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   730
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   731
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   732
lemma get_pfs_secs_mkdir1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   733
  assumes mkdir: "valid (Mkdir p f inum # s)" and noteq: "is_dir s f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   734
  shows "get_parentfs_ctxts (Mkdir p f inum # s) f' = get_parentfs_ctxts s f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   735
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   736
  from mkdir have vd: "valid s" and os: "os_grant s (Mkdir p f inum)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   737
    by (frule_tac vd_cons, simp, frule_tac vt_grant_os, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   738
  from mkdir have notroot: "f \<noteq> []" by (auto intro!:noroot_mkdir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   739
  show ?thesis using noteq
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   740
  proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   741
    case Nil
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   742
    show ?case using notroot mkdir by (simp add:sectxt_of_obj_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   743
  next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   744
    case (Cons a f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   745
    hence p1: "is_dir s f'" using vd by (simp add:parentf_is_dir_prop1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   746
    from Cons have p2: "is_dir s (a # f')" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   747
    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
   748
    from p2 os have p4: "a # f' \<noteq> f" by (auto simp:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   749
    from p1 os have p5: "f' \<noteq> f"  by (auto simp:is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   750
    show ?case using mkdir vd os p4 p5  p1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   751
      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
   752
              split:option.splits   dest:current_has_sec' get_pfs_secs_prop')
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   753
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   754
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   755
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   756
lemma get_pfs_secs_mkdir2:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   757
  "valid (Mkdir p f inum # s) \<Longrightarrow> get_parentfs_ctxts (Mkdir p f inum # s) f = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   758
     case f of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   759
       [] \<Rightarrow> get_parentfs_ctxts s []
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   760
     | 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
   761
                 (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
   762
               | _ \<Rightarrow> None))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   763
apply (frule vd_cons, frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   764
apply (frule noroot_events, case_tac f)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   765
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
   766
          simp:sectxt_of_obj_simps is_dir_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   767
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   768
lemmas get_parentfs_ctxts_simps = get_pfs_secs_other get_pfs_secs_mkdir1 get_pfs_secs_mkdir2
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   769
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   770
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   771
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   772
end