Alive_prop.thy
author chunhan
Tue, 03 Sep 2013 09:31:40 +0800
changeset 38 9dfc8c72565a
parent 1 7d9c0ed02b56
child 41 db15ef2ee18c
permissions -rw-r--r--
found a bug: has_same_inode is a redundant concept of same_inode_files, which is the general form, has_same_inode should be deleted
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Alive_prop
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
imports Main Flask_type Flask Current_files_prop Current_sockets_prop Init_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 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_file_in_current:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
  "is_file s f \<Longrightarrow> f \<in> current_files s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    31
by (auto simp:is_file_def current_files_def split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
lemma is_dir_in_current:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    34
  "is_dir s f \<Longrightarrow> f \<in> current_files s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    35
by (auto simp:is_dir_def current_files_def split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    37
lemma is_tcp_in_current:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
  "is_tcp_sock \<tau> s \<Longrightarrow> s \<in> current_sockets \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
by (auto simp:is_tcp_sock_def current_sockets_def split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
lemma is_udp_in_current:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
  "is_udp_sock \<tau> s \<Longrightarrow> s \<in> current_sockets \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
by (auto simp:is_udp_sock_def current_sockets_def split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
(************ alive simpset **************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
lemma alive_open: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
  "valid (Open p f flag fd opt # s) \<Longrightarrow> alive (Open p f flag fd opt # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
     \<lambda> obj. case obj of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then True
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
                             else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
            | O_file f' \<Rightarrow> (if (opt = None) then alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
                           else if (f = f') then True 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
                                else alive s obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
            dest:is_dir_in_current split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    61
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
lemma alive_execve:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
  "valid (Execve p f fds # s) \<Longrightarrow> alive (Execve p f fds # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
              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
    66
                             else if (p = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
                                  else alive s (O_fd p' fd))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
            | 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
    69
                                     else if (p = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    70
                                          else alive s (O_tcp_sock (p', fd)))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
            | 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
    72
                                     else if (p = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
                                          else alive s (O_udp_sock (p', fd)))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
            | _ \<Rightarrow> alive s obj )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
            dest:is_dir_in_current split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
lemma alive_clone:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    82
  "valid (Clone p p' fds shms # s) \<Longrightarrow> alive (Clone p p' fds shms # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    83
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
              O_proc p'' \<Rightarrow> if (p'' = p') then True else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
            | O_fd p'' fd \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then True
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
                             else if (p'' = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
                                  else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    88
            | 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
    89
                                      else if (p'' = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    90
                                           else alive s (O_tcp_sock (p'', fd)))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    91
            | 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
    92
                                      else if (p'' = p') then False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
                                           else alive s (O_udp_sock (p'', fd)))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
            | _ \<Rightarrow> alive s obj )"  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    96
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    97
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    98
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    99
            dest:is_dir_in_current split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   100
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   101
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   102
lemma alive_kill:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   103
  "valid (Kill p p' # s) \<Longrightarrow> alive (Kill p p' # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   104
     \<lambda> obj. case obj of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   105
              O_proc p'' \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   106
            | O_fd p'' fd \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   107
            | O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   108
            | O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   109
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   112
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   114
            dest:is_dir_in_current split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   115
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   116
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   117
lemma alive_exit:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   118
  "valid (Exit p' # s) \<Longrightarrow> alive (Exit p' # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   119
     \<lambda> obj. case obj of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   120
              O_proc p'' \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   121
            | O_fd p'' fd \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
            | O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   123
            | O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p') then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   125
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   126
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   129
            dest:is_dir_in_current split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   130
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   131
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   132
lemma alive_closefd:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   133
  "valid (CloseFd p fd # s) \<Longrightarrow> alive (CloseFd p fd # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   134
     \<lambda> obj. case obj of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   135
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   136
            | 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
   137
            | 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
   138
            | O_file f \<Rightarrow> (case (file_of_proc_fd s p fd) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
                            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
   140
                                      then False else alive s obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   141
                          | _ \<Rightarrow> alive s obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   144
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   147
            dest:is_dir_in_current file_of_pfd_is_file' split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
lemma alive_unlink:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   151
  "valid (UnLink p f # s) \<Longrightarrow> alive (UnLink p f # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   153
              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
   154
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   155
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   156
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   157
                 is_tcp_sock_simps is_udp_sock_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   158
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   159
            dest:is_dir_in_current file_of_pfd_is_file' file_dir_conflict 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   160
           split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   161
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   162
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   163
lemma alive_rmdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   164
  "valid (Rmdir p d # s) \<Longrightarrow> alive (Rmdir p d # s) = (alive s) (O_dir d := False)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   165
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   166
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   167
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   168
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   169
            dest:is_dir_in_current file_of_pfd_is_file' file_dir_conflict 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   170
           split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   171
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   172
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   173
lemma alive_mkdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   174
  "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
   175
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   176
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   177
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   178
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   179
            dest:is_dir_in_current file_of_pfd_is_file' is_file_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   180
           split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   181
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   182
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   183
lemma alive_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   184
  "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
   185
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   186
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   187
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   188
           intro:is_tcp_in_current is_udp_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   189
            dest:is_dir_in_current file_of_pfd_is_file' is_file_in_current
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   190
           split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   191
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   192
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   193
lemma alive_createmsgq:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
  "valid (CreateMsgq p q # s) \<Longrightarrow> alive (CreateMsgq p q # s) = (alive s) (O_msgq q := True)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   195
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   196
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   197
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   198
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   199
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   200
lemma alive_sendmsg:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   201
  "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
   202
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   203
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   204
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
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_recvmsg:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   208
  "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
   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 other_msg_remains
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   212
            dest:received_msg_notin)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   213
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   214
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   215
lemma alive_removemsgq: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   216
  "valid (RemoveMsgq p q # s) \<Longrightarrow> alive (RemoveMsgq p q # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   217
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   218
              O_msgq q' \<Rightarrow> if (q' = q) then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   219
            | O_msg q' m \<Rightarrow> if (q' = q) then False else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   220
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   221
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   222
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   223
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   224
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   225
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   226
lemma alive_createshm:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   227
  "valid (CreateShM p h # s) \<Longrightarrow> alive (CreateShM p h # s) = (alive s) (O_shm h := True)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   228
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   229
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   230
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   231
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   232
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   233
lemma alive_deleteshm:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   234
  "valid (DeleteShM p h # s) \<Longrightarrow> alive (DeleteShM p h # s) = (alive s) (O_shm h := False)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   235
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   237
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   238
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   239
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
lemma alive_createsock:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   241
  "valid (CreateSock p af st fd inum # s) \<Longrightarrow> alive (CreateSock p af st fd inum # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   242
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
              O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then True else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
            | 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
   245
            | 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
   246
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
lemma alive_accept:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
  "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
   255
     \<lambda> obj. case obj of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
              O_fd p' fd'' \<Rightarrow> if (p' = p \<and> fd'' = fd') then True else alive s obj
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
            | 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
   258
            | _ \<Rightarrow> alive s obj)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac obj)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
lemma alive_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   266
  "\<lbrakk>valid (e # s); 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   267
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   268
    \<forall> p f fds. e \<noteq> Execve p f fds;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   269
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   270
    \<forall> p p'. e \<noteq> Kill p p';
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   271
    \<forall> p. e \<noteq> Exit p; 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   272
    \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   273
    \<forall> p f. e \<noteq> UnLink p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   274
    \<forall> p d. e \<noteq> Rmdir p d;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   275
    \<forall> p d inum. e \<noteq> Mkdir p d inum;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   276
    \<forall> p f f'. e \<noteq> LinkHard p f f';
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
    \<forall> p q. e \<noteq> CreateMsgq p q;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   278
    \<forall> p q m. e \<noteq> SendMsg p q m;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   279
    \<forall> p q m. e \<noteq> RecvMsg p q m;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
    \<forall> p q. e \<noteq> RemoveMsgq p q;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   281
    \<forall> p h. e \<noteq> CreateShM p h; 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
    \<forall> p h. e \<noteq> DeleteShM p h;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   283
    \<forall> p af st fd inum. e \<noteq> CreateSock p af st fd inum;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   284
    \<forall> p fd addr port fd' inum. e \<noteq> Accept p fd addr port fd' inum\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   285
   \<Longrightarrow> alive (e # s) = alive s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   286
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac x, case_tac [!] e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   287
apply (auto simp:current_files_simps current_sockets_simps is_file_simps is_dir_simps
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   288
                 is_tcp_sock_simps is_udp_sock_simps dir_is_empty_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   289
           intro:is_tcp_in_current is_udp_in_current split:t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   290
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   291
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   292
lemmas alive_simps = alive_open alive_execve alive_clone alive_kill alive_exit alive_closefd alive_unlink
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   293
  alive_rmdir alive_mkdir alive_linkhard alive_createmsgq alive_removemsgq alive_createshm alive_deleteshm
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   294
  alive_createsock alive_accept alive_other alive_sendmsg alive_recvmsg
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   295
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   296
  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   297
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   298
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   299
end