no_shm_selinux/Alive_prop.thy
author chunhan
Thu, 16 Jan 2014 11:04:04 +0800
changeset 95 b7fd75d104bf
parent 88 e832378a2ff2
permissions -rw-r--r--
update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
chunhan
parents:
diff changeset
     1
theory Alive_prop
chunhan
parents:
diff changeset
     2
imports Main Flask_type Flask Current_files_prop Current_sockets_prop Init_prop Proc_fd_of_file_prop
chunhan
parents:
diff changeset
     3
begin
chunhan
parents:
diff changeset
     4
chunhan
parents:
diff changeset
     5
context flask begin
chunhan
parents:
diff changeset
     6
chunhan
parents:
diff changeset
     7
lemma distinct_queue_msgs:
chunhan
parents:
diff changeset
     8
  "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> distinct (msgs_of_queue s q)"
88
chunhan
parents: 77
diff changeset
     9
apply (induct s, simp)
77
chunhan
parents:
diff changeset
    10
apply (frule vd_cons, frule vt_grant_os, case_tac a)
chunhan
parents:
diff changeset
    11
apply auto
chunhan
parents:
diff changeset
    12
apply (case_tac "msgs_of_queue s q", simp+)
chunhan
parents:
diff changeset
    13
done
chunhan
parents:
diff changeset
    14
chunhan
parents:
diff changeset
    15
lemma received_msg_notin: 
chunhan
parents:
diff changeset
    16
  "\<lbrakk>hd (msgs_of_queue s q) \<in> set (tl (msgs_of_queue s q)); q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> False"
chunhan
parents:
diff changeset
    17
apply (drule distinct_queue_msgs, simp)
chunhan
parents:
diff changeset
    18
apply (case_tac "msgs_of_queue s q", auto)
chunhan
parents:
diff changeset
    19
done
chunhan
parents:
diff changeset
    20
chunhan
parents:
diff changeset
    21
lemma other_msg_remains:
chunhan
parents:
diff changeset
    22
  "\<lbrakk>m \<noteq> hd (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
    23
   \<Longrightarrow> (m \<in> set (tl (msgs_of_queue s q))) = (m \<in> set (msgs_of_queue s q))"
chunhan
parents:
diff changeset
    24
apply (drule distinct_queue_msgs, simp)
chunhan
parents:
diff changeset
    25
apply (case_tac "msgs_of_queue s q", auto)
chunhan
parents:
diff changeset
    26
done
chunhan
parents:
diff changeset
    27
chunhan
parents:
diff changeset
    28
lemma is_tcp_in_current:
chunhan
parents:
diff changeset
    29
  "is_tcp_sock \<tau> s \<Longrightarrow> s \<in> current_sockets \<tau>"
chunhan
parents:
diff changeset
    30
by (auto simp:is_tcp_sock_def current_sockets_def split:option.splits)
chunhan
parents:
diff changeset
    31
chunhan
parents:
diff changeset
    32
lemma is_udp_in_current:
chunhan
parents:
diff changeset
    33
  "is_udp_sock \<tau> s \<Longrightarrow> s \<in> current_sockets \<tau>"
chunhan
parents:
diff changeset
    34
by (auto simp:is_udp_sock_def current_sockets_def split:option.splits)
chunhan
parents:
diff changeset
    35
chunhan
parents:
diff changeset
    36
(************ alive simpset **************)
chunhan
parents:
diff changeset
    37
chunhan
parents:
diff changeset
    38
lemma alive_open: 
chunhan
parents:
diff changeset
    39
  "valid (Open p f flag fd opt # s) \<Longrightarrow> alive (Open p f flag fd opt # s) = (
chunhan
parents:
diff changeset
    40
     \<lambda> obj. case obj of 
chunhan
parents:
diff changeset
    41
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then True
chunhan
parents:
diff changeset
    42
                             else alive s obj
chunhan
parents:
diff changeset
    43
            | O_file f' \<Rightarrow> (if (opt = None) then alive s obj
chunhan
parents:
diff changeset
    44
                           else if (f = f') then True 
chunhan
parents:
diff changeset
    45
                                else alive s obj)
chunhan
parents:
diff changeset
    46
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
    47
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
    48
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
    49
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
    50
            dest:is_dir_in_current split:if_splits option.splits)
chunhan
parents:
diff changeset
    51
done
chunhan
parents:
diff changeset
    52
chunhan
parents:
diff changeset
    53
(* sock is not inherited on Execve, Clone cases, cause I simplified it with os_grant. 
chunhan
parents:
diff changeset
    54
 * chunhan, 2013-11-20
chunhan
parents:
diff changeset
    55
lemma alive_execve:
chunhan
parents:
diff changeset
    56
  "valid (Execve p f fds # s) \<Longrightarrow> alive (Execve p f fds # s) = (
chunhan
parents:
diff changeset
    57
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
    58
              O_fd p' fd \<Rightarrow> (if (p = p' \<and> fd \<in> fds) then alive s (O_fd p fd)
chunhan
parents:
diff changeset
    59
                             else if (p = p') then False
chunhan
parents:
diff changeset
    60
                                  else alive s (O_fd p' fd))
chunhan
parents:
diff changeset
    61
            | O_tcp_sock (p', fd) \<Rightarrow> (if (p = p' \<and> fd \<in> fds) then alive s (O_tcp_sock (p, fd))
chunhan
parents:
diff changeset
    62
                                     else if (p = p') then False
chunhan
parents:
diff changeset
    63
                                          else alive s (O_tcp_sock (p', fd)))
chunhan
parents:
diff changeset
    64
            | O_udp_sock (p', fd) \<Rightarrow> (if (p = p' \<and> fd \<in> fds) then alive s (O_udp_sock (p, fd))
chunhan
parents:
diff changeset
    65
                                     else if (p = p') then False
chunhan
parents:
diff changeset
    66
                                          else alive s (O_udp_sock (p', fd)))
chunhan
parents:
diff changeset
    67
            | _ \<Rightarrow> alive s obj )"
chunhan
parents:
diff changeset
    68
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
    69
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
    70
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
    71
            dest:is_dir_in_current split:if_splits option.splits)
chunhan
parents:
diff changeset
    72
chunhan
parents:
diff changeset
    73
done
chunhan
parents:
diff changeset
    74
chunhan
parents:
diff changeset
    75
lemma alive_clone:
chunhan
parents:
diff changeset
    76
  "valid (Clone p p' fds shms # s) \<Longrightarrow> alive (Clone p p' fds shms # s) = (
chunhan
parents:
diff changeset
    77
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
    78
              O_proc p'' \<Rightarrow> if (p'' = p') then True else alive s obj
chunhan
parents:
diff changeset
    79
            | O_fd p'' fd \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then True
chunhan
parents:
diff changeset
    80
                             else if (p'' = p') then False
chunhan
parents:
diff changeset
    81
                                  else alive s obj
chunhan
parents:
diff changeset
    82
            | O_tcp_sock (p'', fd) \<Rightarrow> (if (p'' = p' \<and> fd \<in> fds) then alive s (O_tcp_sock (p, fd))
chunhan
parents:
diff changeset
    83
                                      else if (p'' = p') then False
chunhan
parents:
diff changeset
    84
                                           else alive s (O_tcp_sock (p'', fd)))
chunhan
parents:
diff changeset
    85
            | O_udp_sock (p'', fd) \<Rightarrow> (if (p'' = p' \<and> fd \<in> fds) then alive s (O_udp_sock (p, fd))
chunhan
parents:
diff changeset
    86
                                      else if (p'' = p') then False
chunhan
parents:
diff changeset
    87
                                           else alive s (O_udp_sock (p'', fd)))
chunhan
parents:
diff changeset
    88
            | _ \<Rightarrow> alive s obj )"  
chunhan
parents:
diff changeset
    89
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
    90
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
    91
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
    92
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
    93
            dest:is_dir_in_current split:if_splits option.splits)
chunhan
parents:
diff changeset
    94
done
chunhan
parents:
diff changeset
    95
*)
chunhan
parents:
diff changeset
    96
chunhan
parents:
diff changeset
    97
lemma alive_execve:
chunhan
parents:
diff changeset
    98
  "valid (Execve p f fds # s) \<Longrightarrow> alive (Execve p f fds # s) = (
chunhan
parents:
diff changeset
    99
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   100
              O_fd p' fd \<Rightarrow> (if (p = p' \<and> fd \<in> fds) then alive s (O_fd p fd)
chunhan
parents:
diff changeset
   101
                             else if (p = p') then False
chunhan
parents:
diff changeset
   102
                                  else alive s (O_fd p' fd))
chunhan
parents:
diff changeset
   103
            | O_tcp_sock (p', fd) \<Rightarrow> (if (p = p') then False
chunhan
parents:
diff changeset
   104
                                      else alive s (O_tcp_sock (p', fd)))
chunhan
parents:
diff changeset
   105
            | O_udp_sock (p', fd) \<Rightarrow> (if (p = p') then False
chunhan
parents:
diff changeset
   106
                                      else alive s (O_udp_sock (p', fd)))
chunhan
parents:
diff changeset
   107
            | _ \<Rightarrow> alive s obj )"
chunhan
parents:
diff changeset
   108
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   109
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   110
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   111
            dest:is_dir_in_current split:if_splits option.splits
chunhan
parents:
diff changeset
   112
  dest:file_fds_subset_pfds[where s = s] udp_notin_file_fds tcp_notin_file_fds)
chunhan
parents:
diff changeset
   113
done
chunhan
parents:
diff changeset
   114
chunhan
parents:
diff changeset
   115
lemma alive_clone:
chunhan
parents:
diff changeset
   116
  "valid (Clone p p' fds # s) \<Longrightarrow> alive (Clone p p' fds # s) = (
chunhan
parents:
diff changeset
   117
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   118
              O_proc p'' \<Rightarrow> if (p'' = p') then True else alive s obj
chunhan
parents:
diff changeset
   119
            | O_fd p'' fd \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then True
chunhan
parents:
diff changeset
   120
                             else if (p'' = p') then False
chunhan
parents:
diff changeset
   121
                                  else alive s obj
chunhan
parents:
diff changeset
   122
            | O_tcp_sock (p'', fd) \<Rightarrow> (if (p'' = p') then False
chunhan
parents:
diff changeset
   123
                                      else alive s (O_tcp_sock (p'', fd)))
chunhan
parents:
diff changeset
   124
            | O_udp_sock (p'', fd) \<Rightarrow> (if (p'' = p') then False
chunhan
parents:
diff changeset
   125
                                       else alive s (O_udp_sock (p'', fd)))
chunhan
parents:
diff changeset
   126
            | _ \<Rightarrow> alive s obj )"  
chunhan
parents:
diff changeset
   127
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   128
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   129
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   130
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   131
            dest:is_dir_in_current split:if_splits option.splits
chunhan
parents:
diff changeset
   132
  dest:file_fds_subset_pfds[where s = s] udp_notin_file_fds tcp_notin_file_fds)
chunhan
parents:
diff changeset
   133
done
chunhan
parents:
diff changeset
   134
chunhan
parents:
diff changeset
   135
lemma alive_kill:
chunhan
parents:
diff changeset
   136
  "valid (Kill p p' # s) \<Longrightarrow> alive (Kill p p' # s) = (
chunhan
parents:
diff changeset
   137
     \<lambda> obj. case obj of 
chunhan
parents:
diff changeset
   138
              O_proc p'' \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   139
            | O_fd p'' fd \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   140
            | O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   141
            | O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   142
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   143
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   144
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   145
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   146
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   147
            dest:is_dir_in_current split:if_splits option.splits)
chunhan
parents:
diff changeset
   148
done
chunhan
parents:
diff changeset
   149
chunhan
parents:
diff changeset
   150
lemma alive_exit:
chunhan
parents:
diff changeset
   151
  "valid (Exit p' # s) \<Longrightarrow> alive (Exit p' # s) = (
chunhan
parents:
diff changeset
   152
     \<lambda> obj. case obj of 
chunhan
parents:
diff changeset
   153
              O_proc p'' \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   154
            | O_fd p'' fd \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   155
            | O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   156
            | O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
chunhan
parents:
diff changeset
   157
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   158
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   159
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   160
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   161
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   162
            dest:is_dir_in_current split:if_splits option.splits)
chunhan
parents:
diff changeset
   163
done
chunhan
parents:
diff changeset
   164
chunhan
parents:
diff changeset
   165
lemma alive_closefd:
chunhan
parents:
diff changeset
   166
  "valid (CloseFd p fd # s) \<Longrightarrow> alive (CloseFd p fd # s) = (
chunhan
parents:
diff changeset
   167
     \<lambda> obj. case obj of 
chunhan
parents:
diff changeset
   168
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then False else alive s obj
chunhan
parents:
diff changeset
   169
            | O_tcp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd) then False else alive s obj
chunhan
parents:
diff changeset
   170
            | O_udp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd) then False else alive s obj
chunhan
parents:
diff changeset
   171
            | O_file f \<Rightarrow> (case (file_of_proc_fd s p fd) of
chunhan
parents:
diff changeset
   172
                            Some f' \<Rightarrow> (if (f = f' \<and> proc_fd_of_file s f = {(p, fd)} \<and> f \<in> files_hung_by_del s) 
chunhan
parents:
diff changeset
   173
                                      then False else alive s obj)
chunhan
parents:
diff changeset
   174
                          | _ \<Rightarrow> alive s obj)
chunhan
parents:
diff changeset
   175
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   176
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   177
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   178
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   179
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   180
            dest:is_dir_in_current file_of_pfd_is_file' split:if_splits option.splits)
chunhan
parents:
diff changeset
   181
done
chunhan
parents:
diff changeset
   182
chunhan
parents:
diff changeset
   183
lemma alive_unlink:
chunhan
parents:
diff changeset
   184
  "valid (UnLink p f # s) \<Longrightarrow> alive (UnLink p f # s) = (
chunhan
parents:
diff changeset
   185
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   186
              O_file f' \<Rightarrow> if (f' = f \<and> proc_fd_of_file s f = {}) then False else alive s obj
chunhan
parents:
diff changeset
   187
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   188
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   189
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   190
                 is_tcp_sock_simps is_udp_sock_simps
chunhan
parents:
diff changeset
   191
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   192
            dest:is_dir_in_current file_of_pfd_is_file' file_dir_conflict 
chunhan
parents:
diff changeset
   193
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   194
done
chunhan
parents:
diff changeset
   195
chunhan
parents:
diff changeset
   196
lemma alive_rmdir:
chunhan
parents:
diff changeset
   197
  "valid (Rmdir p d # s) \<Longrightarrow> alive (Rmdir p d # s) = (alive s) (O_dir d := False)"
chunhan
parents:
diff changeset
   198
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   199
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   200
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   201
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   202
            dest:is_dir_in_current file_of_pfd_is_file' file_dir_conflict 
chunhan
parents:
diff changeset
   203
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   204
done
chunhan
parents:
diff changeset
   205
chunhan
parents:
diff changeset
   206
lemma alive_mkdir:
chunhan
parents:
diff changeset
   207
  "valid (Mkdir p d inum # s) \<Longrightarrow> alive (Mkdir p d inum # s) = (alive s) (O_dir d := True)"
chunhan
parents:
diff changeset
   208
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   209
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   210
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   211
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   212
            dest:is_dir_in_current file_of_pfd_is_file' is_file_in_current
chunhan
parents:
diff changeset
   213
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   214
done
chunhan
parents:
diff changeset
   215
chunhan
parents:
diff changeset
   216
lemma alive_linkhard:
chunhan
parents:
diff changeset
   217
  "valid (LinkHard p f f' # s) \<Longrightarrow> alive (LinkHard p f f' # s) = (alive s) (O_file f' := True)"
chunhan
parents:
diff changeset
   218
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   219
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   220
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   221
           intro:is_tcp_in_current is_udp_in_current
chunhan
parents:
diff changeset
   222
            dest:is_dir_in_current file_of_pfd_is_file' is_file_in_current
chunhan
parents:
diff changeset
   223
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   224
done
chunhan
parents:
diff changeset
   225
chunhan
parents:
diff changeset
   226
lemma alive_createmsgq:
chunhan
parents:
diff changeset
   227
  "valid (CreateMsgq p q # s) \<Longrightarrow> alive (CreateMsgq p q # s) = (alive s) (O_msgq q := True)"
chunhan
parents:
diff changeset
   228
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   229
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   230
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
chunhan
parents:
diff changeset
   231
done
chunhan
parents:
diff changeset
   232
chunhan
parents:
diff changeset
   233
lemma alive_sendmsg:
chunhan
parents:
diff changeset
   234
  "valid (SendMsg p q m # s) \<Longrightarrow> alive (SendMsg p q m # s) = (alive s) (O_msg q m := True)"
chunhan
parents:
diff changeset
   235
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   236
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   237
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
chunhan
parents:
diff changeset
   238
done
chunhan
parents:
diff changeset
   239
chunhan
parents:
diff changeset
   240
lemma alive_recvmsg:
chunhan
parents:
diff changeset
   241
  "valid (RecvMsg p q m # s) \<Longrightarrow> alive (RecvMsg p q m # s) = (alive s) (O_msg q m := False)"
chunhan
parents:
diff changeset
   242
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   243
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   244
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def other_msg_remains
chunhan
parents:
diff changeset
   245
            dest:received_msg_notin)
chunhan
parents:
diff changeset
   246
done
chunhan
parents:
diff changeset
   247
chunhan
parents:
diff changeset
   248
lemma alive_removemsgq: 
chunhan
parents:
diff changeset
   249
  "valid (RemoveMsgq p q # s) \<Longrightarrow> alive (RemoveMsgq p q # s) = (
chunhan
parents:
diff changeset
   250
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   251
              O_msgq q' \<Rightarrow> if (q' = q) then False else alive s obj
chunhan
parents:
diff changeset
   252
            | O_msg q' m \<Rightarrow> if (q' = q) then False else alive s obj
chunhan
parents:
diff changeset
   253
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   254
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   255
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   256
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
chunhan
parents:
diff changeset
   257
done
chunhan
parents:
diff changeset
   258
chunhan
parents:
diff changeset
   259
(*
chunhan
parents:
diff changeset
   260
lemma alive_createshm:
chunhan
parents:
diff changeset
   261
  "valid (CreateShM p h # s) \<Longrightarrow> alive (CreateShM p h # s) = (alive s) (O_shm h := True)"
chunhan
parents:
diff changeset
   262
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   263
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   264
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
chunhan
parents:
diff changeset
   265
done
chunhan
parents:
diff changeset
   266
chunhan
parents:
diff changeset
   267
lemma alive_deleteshm:
chunhan
parents:
diff changeset
   268
  "valid (DeleteShM p h # s) \<Longrightarrow> alive (DeleteShM p h # s) = (alive s) (O_shm h := False)"
chunhan
parents:
diff changeset
   269
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
chunhan
parents:
diff changeset
   270
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   271
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
chunhan
parents:
diff changeset
   272
done
chunhan
parents:
diff changeset
   273
*)
chunhan
parents:
diff changeset
   274
chunhan
parents:
diff changeset
   275
lemma alive_createsock:
chunhan
parents:
diff changeset
   276
  "valid (CreateSock p af st fd inum # s) \<Longrightarrow> alive (CreateSock p af st fd inum # s) = (
chunhan
parents:
diff changeset
   277
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   278
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then True else alive s obj
chunhan
parents:
diff changeset
   279
            | O_tcp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = STREAM) then True else alive s obj
chunhan
parents:
diff changeset
   280
            | O_udp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = DGRAM) then True else alive s obj
chunhan
parents:
diff changeset
   281
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   282
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   283
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   284
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   285
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
chunhan
parents:
diff changeset
   286
done
chunhan
parents:
diff changeset
   287
chunhan
parents:
diff changeset
   288
lemma alive_accept:
chunhan
parents:
diff changeset
   289
  "valid (Accept p fd addr port fd' inum # s) \<Longrightarrow> alive (Accept p fd addr port fd' inum # s) = (
chunhan
parents:
diff changeset
   290
     \<lambda> obj. case obj of
chunhan
parents:
diff changeset
   291
              O_fd p' fd'' \<Rightarrow> if (p' = p \<and> fd'' = fd') then True else alive s obj
chunhan
parents:
diff changeset
   292
            | O_tcp_sock (p', fd'') \<Rightarrow> if (p' = p \<and> fd'' = fd') then True else alive s obj
chunhan
parents:
diff changeset
   293
            | _ \<Rightarrow> alive s obj)"
chunhan
parents:
diff changeset
   294
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
chunhan
parents:
diff changeset
   295
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   296
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   297
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
chunhan
parents:
diff changeset
   298
done
chunhan
parents:
diff changeset
   299
chunhan
parents:
diff changeset
   300
lemma alive_other:
chunhan
parents:
diff changeset
   301
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
   302
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
chunhan
parents:
diff changeset
   303
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
   304
    \<forall> p p' fds. e \<noteq> Clone p p' fds;
chunhan
parents:
diff changeset
   305
    \<forall> p p'. e \<noteq> Kill p p';
chunhan
parents:
diff changeset
   306
    \<forall> p. e \<noteq> Exit p; 
chunhan
parents:
diff changeset
   307
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
   308
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents:
diff changeset
   309
    \<forall> p d. e \<noteq> Rmdir p d;
chunhan
parents:
diff changeset
   310
    \<forall> p d inum. e \<noteq> Mkdir p d inum;
chunhan
parents:
diff changeset
   311
    \<forall> p f f'. e \<noteq> LinkHard p f f';
chunhan
parents:
diff changeset
   312
    \<forall> p q. e \<noteq> CreateMsgq p q;
chunhan
parents:
diff changeset
   313
    \<forall> p q m. e \<noteq> SendMsg p q m;
chunhan
parents:
diff changeset
   314
    \<forall> p q m. e \<noteq> RecvMsg p q m;
chunhan
parents:
diff changeset
   315
    \<forall> p q. e \<noteq> RemoveMsgq p q;
chunhan
parents:
diff changeset
   316
    \<forall> p af st fd inum. e \<noteq> CreateSock p af st fd inum;
chunhan
parents:
diff changeset
   317
    \<forall> p fd addr port fd' inum. e \<noteq> Accept p fd addr port fd' inum\<rbrakk>
chunhan
parents:
diff changeset
   318
   \<Longrightarrow> alive (e # s) = alive s" (* 
chunhan
parents:
diff changeset
   319
    \<forall> p h. e \<noteq> CreateShM p h; 
chunhan
parents:
diff changeset
   320
    \<forall> p h. e \<noteq> DeleteShM p h;*)
chunhan
parents:
diff changeset
   321
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x, case_tac [!] e)
chunhan
parents:
diff changeset
   322
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   323
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
chunhan
parents:
diff changeset
   324
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
chunhan
parents:
diff changeset
   325
done
chunhan
parents:
diff changeset
   326
chunhan
parents:
diff changeset
   327
lemmas alive_simps = alive_open alive_execve alive_clone alive_kill alive_exit alive_closefd alive_unlink
chunhan
parents:
diff changeset
   328
  alive_rmdir alive_mkdir alive_linkhard alive_createmsgq alive_removemsgq (* alive_createshm alive_deleteshm *)
chunhan
parents:
diff changeset
   329
  alive_createsock alive_accept alive_other alive_sendmsg alive_recvmsg
chunhan
parents:
diff changeset
   330
chunhan
parents:
diff changeset
   331
  
chunhan
parents:
diff changeset
   332
end
chunhan
parents:
diff changeset
   333
chunhan
parents:
diff changeset
   334
end