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