Current_files_prop.thy
author chunhan
Wed, 20 Nov 2013 16:24:16 +0800
changeset 71 db0e8601c229
parent 40 8557d7872fdb
permissions -rw-r--r--
update socket/filefds conflict
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
theory Current_files_prop
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     3
imports Main Flask_type Flask My_list_prefix Init_prop Valid_prop
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
context init begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
lemma current_files_ndef: "f \<notin> current_files \<tau> \<Longrightarrow> inum_of_file \<tau> f = None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
by (simp add:current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
(************** file_of_proc_fd vs proc_fd_of_file *****************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
lemma pfdof_simp1: "file_of_proc_fd \<tau> p fd = Some f \<Longrightarrow> (p, fd) \<in> proc_fd_of_file \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
by (simp add:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    16
lemma pfdof_simp2: "(p, fd) \<in> proc_fd_of_file \<tau> f \<Longrightarrow> file_of_proc_fd \<tau> p fd = Some f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    17
by (simp add:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    18
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
lemma pfdof_simp3: "proc_fd_of_file \<tau> f = {(p, fd)} \<Longrightarrow> \<forall> p' fd'. (file_of_proc_fd \<tau> p' fd' = Some f \<longrightarrow> p = p' \<and> fd = fd')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    20
by (simp add:proc_fd_of_file_def, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
lemma pfdof_simp4: "\<lbrakk>file_of_proc_fd \<tau> p' fd' = Some f; proc_fd_of_file \<tau> f = {(p, fd)}\<rbrakk> \<Longrightarrow> p' = p \<and> fd' = fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    23
by (drule pfdof_simp3, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
context flask begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    28
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
(***************** inode number lemmas *************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    31
lemma iof's_im_in_cim: "inum_of_file \<tau> f = Some im \<Longrightarrow> im \<in> current_inode_nums \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
by (auto simp add:current_inode_nums_def current_file_inums_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    34
lemma ios's_im_in_cim: "inum_of_socket \<tau> s = Some im \<Longrightarrow> im \<in> current_inode_nums \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    35
by (case_tac s, auto simp add:current_inode_nums_def current_sock_inums_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    37
lemma fim_noninter_sim_aux[rule_format]:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
  "\<forall> f s. inum_of_file \<tau> f = Some im \<and> inum_of_socket \<tau> s = Some im \<and> valid \<tau> \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
apply (clarsimp simp:inum_of_file.simps inum_of_socket.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
apply (drule init_inum_sock_file_noninter, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
apply ((rule allI|rule impI|erule conjE)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
apply (frule vd_cons, frule vt_grant_os, simp, case_tac a) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
apply (auto simp:inum_of_file.simps inum_of_socket.simps split:if_splits option.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
            dest:ios's_im_in_cim iof's_im_in_cim)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
lemma fim_noninter_sim':"\<lbrakk>inum_of_file \<tau> f = Some im; inum_of_socket \<tau> s = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
by (auto intro:fim_noninter_sim_aux)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
lemma fim_noninter_sim'':"\<lbrakk>inum_of_socket \<tau> s = Some im; inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
by (auto intro:fim_noninter_sim_aux)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
lemma fim_noninter_sim: "valid \<tau> \<Longrightarrow> (current_file_inums \<tau>) \<inter> (current_sock_inums \<tau>) = {}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
by (auto simp:current_file_inums_def current_sock_inums_def intro:fim_noninter_sim_aux[rule_format])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
(******************* file inum has inode tag ************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
lemma finum_has_itag_aux[rule_format]: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
  "\<forall> f im. inum_of_file \<tau> f = Some im \<and> valid \<tau> \<longrightarrow> itag_of_inum \<tau> im \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    61
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
apply (clarsimp simp:inum_of_file.simps itag_of_inum.simps init_inum_of_file_props)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
apply (clarify, frule vt_grant_os, frule vd_cons, case_tac a) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
apply (auto simp add:inum_of_file.simps itag_of_inum.simps os_grant.simps current_files_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
                dest:fim_noninter_sim'' split:option.splits if_splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    66
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
lemma finum_has_itag: "\<lbrakk>inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> tag. itag_of_inum \<tau> im = Some tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
by (auto dest:conjI[THEN finum_has_itag_aux])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    70
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
(*********************** file inum is file itag *************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
lemma finum_has_ftag_aux[rule_format]: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
  "\<forall> f tag. inum_of_file \<tau> f = Some im \<and> itag_of_inum \<tau> im = Some tag \<and> valid \<tau> \<longrightarrow> is_file_dir_itag tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
apply (clarsimp simp:inum_of_file.simps itag_of_inum.simps init_inum_of_file_props)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
apply (clarify, frule vt_grant_os, frule vd_cons, case_tac a) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
apply (auto simp:inum_of_file.simps os_grant.simps current_files_def itag_of_inum.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
           split:if_splits option.splits t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
            dest:ios's_im_in_cim iof's_im_in_cim)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    82
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    83
lemma finum_has_ftag:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
  "\<lbrakk>inum_of_file \<tau> f = Some im; itag_of_inum \<tau> im = Some tag; valid \<tau>\<rbrakk> \<Longrightarrow> is_file_dir_itag tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
by (auto intro:finum_has_ftag_aux)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
lemma finum_has_ftag': 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    88
  "\<lbrakk>inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> itag_of_inum \<tau> im = Some Tag_FILE \<or> itag_of_inum \<tau> im = Some Tag_DIR"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    89
apply (frule finum_has_itag, simp, erule exE, drule finum_has_ftag, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    90
apply (case_tac tag, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    91
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    92
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
(******************* sock inum has inode tag ************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
lemma sinum_has_itag_aux[rule_format]: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    96
  "\<forall> s im. inum_of_socket \<tau> s = Some im \<and> valid \<tau> \<longrightarrow> itag_of_inum \<tau> im \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    97
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    98
apply (clarsimp simp:inum_of_socket.simps itag_of_inum.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    99
apply (drule init_inumos_prop4, clarsimp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   100
apply (clarify, frule vt_grant_os, frule vd_cons, case_tac a) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   101
apply (auto simp add:inum_of_socket.simps itag_of_inum.simps os_grant.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   102
                dest:fim_noninter_sim'' ios's_im_in_cim iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   103
               split:option.splits if_splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   104
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   105
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   106
lemma sinum_has_itag: "\<lbrakk>inum_of_socket \<tau> s = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> tag. itag_of_inum \<tau> im = Some tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   107
by (auto dest:conjI[THEN sinum_has_itag_aux])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   108
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   109
(********************** socket inum is socket itag **********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
lemma sinum_has_stag_aux[rule_format]: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   112
  "\<forall> s tag. inum_of_socket \<tau> s = Some im \<and> itag_of_inum \<tau> im = Some tag \<and> valid \<tau> \<longrightarrow> is_sock_itag tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   114
apply (clarsimp simp:inum_of_socket.simps itag_of_inum.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   115
apply (drule init_inumos_prop4, clarsimp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   116
apply (clarify, frule vt_grant_os, frule vd_cons, case_tac a) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   117
apply (auto simp add:inum_of_socket.simps itag_of_inum.simps os_grant.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   118
                dest:fim_noninter_sim'' ios's_im_in_cim iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   119
               split:option.splits if_splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   120
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   121
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
lemma sinum_has_stag: "\<lbrakk>inum_of_socket \<tau> s = Some im; itag_of_inum \<tau> im = Some tag; valid \<tau>\<rbrakk> \<Longrightarrow> is_sock_itag tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   123
by (auto dest:conjI[THEN sinum_has_stag_aux])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   125
lemma sinum_has_stag': 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   126
  "\<lbrakk>inum_of_socket \<tau> s = Some im; valid \<tau>\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
   \<Longrightarrow> itag_of_inum \<tau> im = Some Tag_UDP_SOCK \<or> itag_of_inum \<tau> im = Some Tag_TCP_SOCK"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
apply (frule sinum_has_itag, simp, erule exE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   129
apply (drule sinum_has_stag, simp+, case_tac tag, simp+)
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
(************************************ 4 in 1 *************************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   133
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   134
lemma file_leveling: "valid \<tau> \<longrightarrow> (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   135
                        (\<forall> f. f \<in> files_hung_by_del \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   136
                        (\<forall> f pf im. parent f = Some pf \<and> inum_of_file \<tau> f = Some im \<longrightarrow> inum_of_file \<tau> pf \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   137
                        (\<forall> f f' im. is_file \<tau> f \<and> parent f' = Some f \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> False) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   138
                        (\<forall> f f' im. f \<in> files_hung_by_del \<tau> \<and> inum_of_file \<tau> f' = Some im \<and> parent f' = Some f \<longrightarrow> False) )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
proof (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   140
  case Nil 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   141
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
    apply (auto simp:inum_of_file.simps files_hung_by_del.simps is_file_def itag_of_inum.simps parent_file_in_init split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
    apply (drule init_files_hung_by_del_props, simp add:init_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   144
    apply (rule init_parent_file_has_inum, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
    apply (rule init_file_has_no_son', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
    apply (rule init_file_hung_has_no_son, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   147
    done   
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
  case (Cons a \<tau>)  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
  assume pre: "valid \<tau> \<longrightarrow>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   151
  (\<forall> f. f \<in> files_hung_by_del \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
  (\<forall>f pf im. parent f = Some pf \<and> inum_of_file \<tau> f = Some im \<longrightarrow> inum_of_file \<tau> pf \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   153
  (\<forall>f f' im. is_file \<tau> f \<and> parent f' = Some f \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> False) \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   154
  (\<forall>f f' im. f \<in> files_hung_by_del \<tau> \<and> inum_of_file \<tau> f' = Some im \<and> parent f' = Some f \<longrightarrow> False)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   155
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   156
  proof 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   157
    assume cons:"valid (a # \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   158
    show "(\<forall>f. f \<in> files_hung_by_del (a # \<tau>) \<longrightarrow> inum_of_file (a # \<tau>) f \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   159
          (\<forall>f pf im. parent f = Some pf \<and> inum_of_file (a # \<tau>) f = Some im \<longrightarrow> inum_of_file (a # \<tau>) pf \<noteq> None) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   160
          (\<forall>f f' im. is_file (a # \<tau>) f \<and> parent f' = Some f \<and> inum_of_file (a # \<tau>) f' = Some im \<longrightarrow> False) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   161
          (\<forall>f f' im. f \<in> files_hung_by_del (a # \<tau>) \<and> inum_of_file (a # \<tau>) f' = Some im \<and> parent f' = Some f \<longrightarrow> False)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   162
    proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   163
      have vt: "valid \<tau>" using cons by (auto dest:vd_cons)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   164
      have os: "os_grant \<tau> a" using cons by (auto dest:vt_grant_os)  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   165
      have fin: "\<forall>f. f \<in> files_hung_by_del \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None" using vt pre by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   166
      have pin: "\<forall>f pf im. parent f = Some pf \<and> inum_of_file \<tau> f = Some im \<longrightarrow> inum_of_file \<tau> pf \<noteq> None" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   167
        using vt pre apply (erule_tac impE, simp) by ((erule_tac conjE)+, assumption)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   168
      have fns: "\<forall>f f' im. is_file \<tau> f \<and> parent f' = Some f \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   169
        using vt pre apply (erule_tac impE, simp) by ((erule_tac conjE)+, assumption)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   170
      have hns: "\<forall>f f' im. f \<in> files_hung_by_del \<tau> \<and> inum_of_file \<tau> f' = Some im \<and> parent f' = Some f \<longrightarrow> False" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   171
        using vt pre apply (erule_tac impE, simp) by ((erule_tac conjE)+, assumption)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   172
      have ain: "\<forall>f' f im. f \<preceq> f' \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   173
      proof 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   174
        fix f' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   175
        show " \<forall>f im. f \<preceq> f' \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   176
        proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   177
          case Nil show ?case by (auto simp: no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   178
        next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   179
          case (Cons a f') 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   180
          assume pre:"\<forall>f im. f \<preceq> f' \<and> inum_of_file \<tau> f' = Some im \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   181
          show "\<forall>f im. f \<preceq> a # f' \<and> inum_of_file \<tau> (a # f') = Some im \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   182
          proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   183
            fix f im
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   184
            assume h1: "f \<preceq> a # f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   185
              and  h2: "inum_of_file \<tau> (a # f') = Some im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   186
            show "\<exists>y. inum_of_file \<tau> f = Some y"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   187
            proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   188
              have h3: "\<exists> y. inum_of_file \<tau> f' = Some y" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   189
              proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   190
                have "parent (a # f') = Some f'" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   191
                hence "\<exists> y. inum_of_file \<tau> f' = Some y" using pin h2 by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   192
                with h1 show ?thesis by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   193
              qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
              from h1 have "f = a # f' \<or> f = f' \<or> f \<preceq> f'" by (induct f, auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   195
              moreover have "f = a # f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y" using h2 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   196
              moreover have "f = f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y"  using h3 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   197
              moreover have "f \<preceq> f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y" using pre h3 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   198
              ultimately show ?thesis by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   199
            qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   200
          qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   201
        qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   202
      qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   203
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   204
      have fin': "\<And> f. f \<in> files_hung_by_del \<tau> \<Longrightarrow> \<exists> im. inum_of_file \<tau> f = Some im" using fin by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   205
      have pin': "\<And> f pf im. \<lbrakk>parent f = Some pf; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> \<exists> im'. inum_of_file \<tau> pf = Some im'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   206
        using pin by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   207
      have fns': "\<And> f f' im. \<lbrakk>is_file \<tau> f; parent f' = Some f; inum_of_file \<tau> f' = Some im\<rbrakk> \<Longrightarrow> False" using fns by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   208
      have fns'': "\<And> f f' im im'. \<lbrakk>itag_of_inum \<tau> im = Some Tag_FILE; inum_of_file \<tau> f = Some im; parent f' = Some f; inum_of_file \<tau> f' = Some im'\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   209
        by (rule_tac f = f and f' = f' in fns', auto simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   210
      have hns': "\<And> f f' im. \<lbrakk>f \<in> files_hung_by_del \<tau>; inum_of_file \<tau> f' = Some im; parent f' = Some f\<rbrakk> \<Longrightarrow> False" using hns by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   211
      have ain': "\<And> f f' im. \<lbrakk>f \<preceq> f'; inum_of_file \<tau> f' = Some im\<rbrakk> \<Longrightarrow> \<exists> im'. inum_of_file \<tau> f = Some im'" using ain by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   212
      have dns': "\<And> f f' im. \<lbrakk>dir_is_empty \<tau> f; parent f' = Some f; inum_of_file \<tau> f' = Some im\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   213
        apply (auto simp:dir_is_empty_def current_files_def is_dir_def split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   214
        by (erule_tac x = f' in allE, simp add:noJ_Anc parent_is_ancen, drule parent_is_parent, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   215
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   216
      have "\<forall> f. f \<in> files_hung_by_del (a # \<tau>) \<longrightarrow> inum_of_file (a # \<tau>) f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   217
        apply (clarify, case_tac a) using os fin
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   218
        apply (auto simp:files_hung_by_del.simps inum_of_file.simps os_grant.simps current_files_def is_file_def 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   219
                   split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   220
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   221
      moreover 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   222
      have "\<forall>f pf im. parent f = Some pf \<and> inum_of_file (a # \<tau>) f = Some im \<longrightarrow> inum_of_file (a # \<tau>) pf \<noteq> None" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   223
        apply (clarify, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   224
        using vt os pin'
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   225
        apply (auto simp:os_grant.simps current_files_def inum_of_file.simps is_file_def is_dir_def 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   226
                   split:if_splits option.splits t_inode_tag.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   227
        apply (drule_tac f = pf and f' = f in hns', simp, simp, simp)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   228
        apply (rule_tac f = list and f' = f in fns', simp add:is_file_def, simp, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   229
        apply (rule_tac f = list and f' = f in dns', simp add:is_dir_def, simp, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   230
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   231
      moreover have "\<forall>f f' im. is_file (a # \<tau>) f \<and> parent f' = Some f \<and> inum_of_file (a # \<tau>) f' = Some im \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   232
        apply (clarify, case_tac a)    
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   233
        using vt os fns'' cons
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   234
        apply (auto simp:os_grant.simps current_files_def inum_of_file.simps itag_of_inum.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   235
                         is_file_def is_dir_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
                    dest:ios's_im_in_cim iof's_im_in_cim
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   237
                   split:if_splits option.splits t_inode_tag.splits t_socket_type.splits) 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   238
        apply (rule_tac im = a and f = f and f' = f' in fns'', simp+)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   239
        apply (drule_tac f = f' and pf = list in pin', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
        apply (drule_tac f = f' and pf = list2 in pin', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   241
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   242
      moreover have "\<forall>f f' im. f \<in> files_hung_by_del (a # \<tau>) \<and> inum_of_file (a # \<tau>) f' = Some im \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
                               parent f' = Some f \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
        apply (clarify, case_tac a)     
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   245
        using vt os hns'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   246
        apply (auto simp:os_grant.simps current_files_def inum_of_file.simps files_hung_by_del.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
                   split:if_splits option.splits t_sock_addr.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
        apply (drule fns', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
      ultimately show ?thesis by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
    
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
(**************** hung file in current ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
lemma hung_file_has_inum:"\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
lemma hung_file_has_inum': "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> im. inum_of_file \<tau> f = Some im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
by (auto dest:hung_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
lemma hung_file_in_current: "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
by (clarsimp simp add:current_files_def hung_file_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   266
lemma parentf_has_inum: "\<lbrakk>parent f = Some pf; inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> inum_of_file \<tau> pf \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   267
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   268
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   269
lemma parentf_has_inum': "\<lbrakk>parent f = Some pf; inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> im'. inum_of_file \<tau> pf = Some im'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   270
by (auto dest:parentf_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   271
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   272
lemma parentf_in_current: "\<lbrakk>parent f = Some pf; f \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   273
by (clarsimp simp add:current_files_def parentf_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   274
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   275
lemma parentf_in_current': "\<lbrakk>a # pf \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   276
apply (subgoal_tac "parent (a # pf) = Some pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
by (erule parentf_in_current, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   278
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   279
lemma ancenf_has_inum_aux: "\<forall> f im. f \<preceq> f' \<and> inum_of_file \<tau> f' = Some im \<and> valid \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   281
  case Nil show ?case by (auto simp: no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   283
  case (Cons a f') 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   284
  assume pre:"\<forall>f im. f \<preceq> f' \<and> inum_of_file \<tau> f' = Some im \<and> valid \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   285
  show "\<forall>f im. f \<preceq> a # f' \<and> inum_of_file \<tau> (a # f') = Some im \<and> valid \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   286
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   287
    fix f im
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   288
    assume h1: "f \<preceq> a # f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   289
      and  h2: "inum_of_file \<tau> (a # f') = Some im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   290
      and  h3: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   291
    show "\<exists>y. inum_of_file \<tau> f = Some y"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   292
    proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   293
      have h4: "\<exists> y. inum_of_file \<tau> f' = Some y" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   294
      proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   295
        have "parent (a # f') = Some f'" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   296
        hence "\<exists> y. inum_of_file \<tau> f' = Some y" using parentf_has_inum' h2 h3 by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   297
        with h1 show ?thesis by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   298
      qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   299
      from h1 have "f = a # f' \<or> f = f' \<or> f \<preceq> f'" by (induct f, auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   300
      moreover have "f = a # f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y" using h2 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   301
      moreover have "f = f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y"  using h4 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   302
      moreover have "f \<preceq> f' \<Longrightarrow> \<exists>y. inum_of_file \<tau> f = Some y" using pre h3 h4 by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   303
      ultimately show ?thesis by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   304
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   305
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   306
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   307
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   308
lemma ancenf_has_inum: "\<lbrakk>f \<preceq> f'; inum_of_file \<tau> f' = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> inum_of_file \<tau> f \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   309
by (rule ancenf_has_inum_aux[rule_format], auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   310
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   311
lemma ancenf_has_inum': "\<lbrakk>f \<preceq> f'; inum_of_file \<tau> f' = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> im'. inum_of_file \<tau> f = Some im'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   312
by (auto dest:ancenf_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   313
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   314
lemma ancenf_in_current: "\<lbrakk>f \<preceq> f'; f' \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   315
by (simp add:current_files_def, erule exE, simp add:ancenf_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   316
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   317
lemma file_has_no_son: "\<lbrakk>is_file \<tau> f; parent f' = Some f; inum_of_file \<tau> f' = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   318
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   319
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   320
lemma file_has_no_son': "\<lbrakk>is_file \<tau> f; parent f' = Some f; f' \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   321
by (simp add:current_files_def, erule exE, auto intro:file_has_no_son)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   322
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   323
lemma hung_file_no_son: "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>; inum_of_file \<tau> f' = Some im; parent f' = Some f\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   324
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   325
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   326
lemma hung_file_no_son': "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>; f' \<in> current_files \<tau>; parent f' = Some f\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   327
by (simp add:current_files_def, erule exE, auto intro:hung_file_no_son)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   328
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   329
lemma hung_file_no_des_aux: "\<forall> f. f \<in> files_hung_by_del \<tau> \<and> valid \<tau> \<and> f' \<in> current_files \<tau> \<and> f \<preceq> f' \<and> f \<noteq> f' \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   330
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   331
  case Nil 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   332
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   333
    by (auto simp:files_hung_by_del.simps current_files_def inum_of_file.simps no_junior_def split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   334
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   335
  case (Cons a pf)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   336
  assume pre: "\<forall>f. f \<in> files_hung_by_del \<tau> \<and> valid \<tau> \<and> pf \<in> current_files \<tau> \<and> f \<preceq> pf \<and> f \<noteq> pf\<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   337
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   338
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   339
    fix f
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   340
    assume h1: "f \<in> files_hung_by_del \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   341
      and  h2: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   342
      and  h3: "a # pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   343
      and  h4: "f \<preceq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   344
      and  h5: "f \<noteq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   345
    have h6: "parent (a # pf) = Some pf" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   346
    with h2 h3 have h7: "pf \<in> current_files \<tau>" by (drule_tac parentf_in_current, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   347
    from h4 h5 have h8: "f \<preceq> pf" by (erule_tac no_juniorE, case_tac zs, auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   348
    show False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   349
    proof (cases "f = pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   350
      case True with h6 h2 h3 h1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   351
      show False by (auto intro!:hung_file_no_son')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   352
    next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   353
      case False with pre h1 h2 h7 h8 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   354
      show False by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   355
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   356
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   357
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   358
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   359
lemma hung_file_no_des: "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>; f' \<in> current_files \<tau>; f \<preceq> f'; f \<noteq> f'\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   360
by (rule hung_file_no_des_aux[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   361
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   362
(* current version, dir can not be opened, so hung_files are all files 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   363
lemma hung_file_is_leaf: "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> is_file \<tau> f \<or> dir_is_empty \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   364
apply (frule hung_file_has_inum', simp, erule exE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   365
apply (auto simp add:is_file_def dir_is_empty_def is_dir_def  dest:finum_has_itag finum_has_ftag split:option.splits if_splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   366
by (simp add: noJ_Anc, auto dest:hung_file_no_des)
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   367
*)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   368
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   369
lemma hung_file_has_filetag:
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   370
  "\<lbrakk>f \<in> files_hung_by_del s; inum_of_file s f = Some im; valid s\<rbrakk> \<Longrightarrow> itag_of_inum s im = Some Tag_FILE"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   371
apply (induct s)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   372
apply (simp add:files_hung_by_del.simps)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   373
apply (drule init_files_hung_prop2, (erule exE)+)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   374
apply (drule init_filefd_prop5, clarsimp simp:is_init_file_def split:t_inode_tag.splits option.splits)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   375
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   376
apply (frule vd_cons, frule vt_grant_os, case_tac a)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   377
apply (auto simp:files_hung_by_del.simps is_file_def is_dir_def current_files_def current_inode_nums_def
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   378
    split:if_splits option.splits t_inode_tag.splits t_socket_type.splits 
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   379
     dest:hung_file_has_inum iof's_im_in_cim)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   380
done
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   381
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   382
lemma hung_file_is_file: "\<lbrakk>f \<in> files_hung_by_del \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> is_file \<tau> f"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   383
apply (frule hung_file_has_inum', simp, erule exE)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   384
apply (drule hung_file_has_filetag, auto simp:is_file_def)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   385
done
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   386
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   387
(*********************** 2 in 1 *********************)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   388
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   389
lemma file_of_pfd_2in1: "valid s \<Longrightarrow> ( 
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   390
   (\<forall> p fd f. file_of_proc_fd s p fd = Some f \<longrightarrow> inum_of_file s f \<noteq> None) \<and>
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   391
   (\<forall> p fd f. file_of_proc_fd s p fd = Some f \<longrightarrow> is_file s f) )"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   392
proof (induct s)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   393
  case Nil
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   394
  show ?case
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   395
    by (auto dest:init_filefd_valid simp:is_file_def)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   396
next
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   397
  case (Cons e s)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   398
  hence vd_e: "valid (e # s)" and vd_s: "valid s"  and os: "os_grant s e"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   399
    and pfd: "\<And> p fd f. file_of_proc_fd s p fd = Some f \<Longrightarrow> inum_of_file s f \<noteq> None"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   400
    and isf: "\<And> p fd f. file_of_proc_fd s p fd = Some f \<Longrightarrow> is_file s f"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   401
    by (auto dest:vd_cons vt_grant_os)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   402
  from pfd have pfd': "\<And> p fd f. inum_of_file s f = None \<Longrightarrow> file_of_proc_fd s p fd \<noteq> Some f"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   403
    by (rule_tac notI, drule_tac pfd, simp)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   404
  
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   405
  have "\<forall>p fd f. file_of_proc_fd (e # s) p fd = Some f \<longrightarrow> inum_of_file (e # s) f \<noteq> None"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   406
    apply (case_tac e)  using os
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   407
    apply (auto simp:inum_of_file.simps file_of_proc_fd.simps os_grant.simps current_files_def
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   408
                 dir_is_empty_def is_file_def is_dir_def
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   409
               split:if_splits option.splits dest:pfd)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   410
    apply (simp add:pfdof_simp3)+
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   411
    apply (simp add:proc_fd_of_file_def)  
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   412
    apply (drule isf, simp add:is_file_def split:t_inode_tag.splits)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   413
    done
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   414
  moreover 
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   415
  have "\<forall>p fd f. file_of_proc_fd (e # s) p fd = Some f \<longrightarrow> is_file (e # s) f"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   416
    apply (case_tac e)  using os
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   417
    apply (auto split:option.splits t_inode_tag.splits if_splits t_socket_type.splits 
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   418
                 dest:pfd isf iof's_im_in_cim
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   419
                 simp:is_file_def is_dir_def dir_is_empty_def current_files_def)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   420
    apply (simp add:pfdof_simp3)+
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   421
    apply (simp add:proc_fd_of_file_def)  
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   422
    done
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   423
  ultimately show ?case by auto
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   424
qed
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   425
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   427
(************** file_of_proc_fd in current ********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   429
lemma file_of_pfd_imp_inode': "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> inum_of_file \<tau> f \<noteq> None"
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   430
by (drule file_of_pfd_2in1, blast)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   431
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
lemma file_of_pfd_imp_inode: "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> \<exists> im. inum_of_file \<tau> f = Some im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   433
by (auto dest!:file_of_pfd_imp_inode')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   434
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   435
lemma file_of_pfd_in_current: "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   436
by (auto dest!:file_of_pfd_imp_inode' simp:current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   437
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   438
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
(*************** file_of_proc_fd is file *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
lemma file_of_pfd_is_file:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
  "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> is_file \<tau> f"
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   443
by (drule file_of_pfd_2in1, auto simp:is_file_def)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   444
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   445
lemma file_of_pfd_is_file':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
  "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; is_dir \<tau> f; valid \<tau>\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   447
by (drule file_of_pfd_is_file, auto simp:is_file_def is_dir_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   449
lemma file_of_pfd_is_file_tag:
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   450
  "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> itag_of_inum \<tau> im = Some Tag_FILE"
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   451
by (drule file_of_pfd_is_file, auto simp:is_file_def split:option.splits t_inode_tag.splits)
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   452
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
(************** parent file / ancestral file is dir *******************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   454
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
lemma parentf_is_dir_aux: "\<forall> f pf. parent f = Some pf \<and> inum_of_file \<tau> f = Some im \<and> inum_of_file \<tau> pf = Some ipm \<and> valid \<tau> \<longrightarrow> itag_of_inum \<tau> ipm = Some Tag_DIR"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   457
apply (clarsimp simp:inum_of_file.simps itag_of_inum.simps init_parent_file_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   458
apply (clarify, frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
apply (auto simp:inum_of_file.simps itag_of_inum.simps os_grant.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
                 current_files_def is_dir_def is_file_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   461
            dest: ios's_im_in_cim iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
           split:if_splits option.splits t_sock_addr.splits t_inode_tag.splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
apply (drule parentf_has_inum', simp, simp, simp)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   464
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   465
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
lemma parentf_has_dirtag: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   467
  "\<lbrakk>parent f = Some pf; inum_of_file \<tau> f = Some im; inum_of_file \<tau> pf = Some ipm; valid \<tau>\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
   \<Longrightarrow> itag_of_inum \<tau> ipm = Some Tag_DIR"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
by (auto intro:parentf_is_dir_aux[rule_format])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   471
lemma parentf_is_dir': "\<lbrakk>parent f = Some pf; inum_of_file \<tau> f = Some im; valid \<tau>\<rbrakk> \<Longrightarrow> is_dir \<tau> pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   472
apply (frule parentf_has_inum', simp+, erule exE, simp add:is_dir_def split:t_inode_tag.splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
by (auto dest:parentf_has_dirtag)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   474
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   475
lemma parentf_is_dir: "\<lbrakk>parent f = Some pf; f \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> is_dir \<tau> pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
by (clarsimp simp:current_files_def parentf_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 2
diff changeset
   478
lemma parentf_is_dir'': "\<lbrakk>f # pf \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> is_dir \<tau> pf"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 2
diff changeset
   479
by (auto intro!:parentf_is_dir)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 2
diff changeset
   480
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
lemma ancenf_is_dir_aux: "\<forall> f. f \<preceq> f' \<and> f \<noteq> f' \<and> f' \<in> current_files \<tau> \<and> valid \<tau> \<longrightarrow> is_dir \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   482
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   483
  case Nil show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
    by (auto simp:current_files_def no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
next 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
  case (Cons a pf)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
  assume pre: "\<forall>f. f \<preceq> pf \<and> f \<noteq> pf \<and> pf \<in> current_files \<tau> \<and> valid \<tau> \<longrightarrow> is_dir \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   488
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   489
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   490
    fix f
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
    assume h1: "f \<preceq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
      and  h2: "f \<noteq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
      and  h3: "a # pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
      and  h4: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
    have h5: "parent (a # pf) = Some pf" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
    with h3 h4 have h6: "pf \<in> current_files \<tau>" by (drule_tac parentf_in_current, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
    from h1 h2 have h7: "f \<preceq> pf" by (erule_tac no_juniorE, case_tac zs, auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   498
    show "is_dir \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
    proof (cases "f = pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
      case True with h3 h4 h5 show "is_dir \<tau> f" by (drule_tac parentf_is_dir, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
    next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
      case False with pre h6 h7 h4 show "is_dir \<tau> f" by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   504
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   506
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   507
lemma ancenf_is_dir: "\<lbrakk>f \<preceq> f'; f \<noteq> f'; f' \<in> current_files \<tau>; valid \<tau>\<rbrakk> \<Longrightarrow> is_dir \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
by (auto intro:ancenf_is_dir_aux[rule_format])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   510
(************* rebuild current_files simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   511
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
lemma current_files_nil: "current_files [] = init_files"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   513
apply (simp add:current_files_def inum_of_file.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
by (auto dest:inof_has_file_tag init_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   515
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
lemma current_files_open: "current_files (Open p f flags fd (Some i) # \<tau>) = insert f (current_files \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   517
by (auto simp add:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
lemma current_files_open': "current_files (Open p f flags fd None # \<tau>) = current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   520
by (simp add:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   522
lemma current_files_closefd: "current_files (CloseFd p fd # \<tau>) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   523
     case (file_of_proc_fd \<tau> p fd) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
       Some f \<Rightarrow> ( if ((proc_fd_of_file \<tau> f = {(p, fd)}) \<and> (f \<in> files_hung_by_del \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   525
                   then current_files \<tau> - {f}
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
                   else current_files \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   527
     | _      \<Rightarrow> current_files \<tau>                                  )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
lemma current_files_unlink: "current_files (UnLink p f # \<tau>) = (if (proc_fd_of_file \<tau> f = {}) then (current_files \<tau>) - {f} else current_files \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
9
87fdf2de0ffa update proof scripts after Rmdir case
chunhan
parents: 7
diff changeset
   533
lemma current_files_rmdir: "current_files (Rmdir p f # \<tau>) = current_files \<tau> - {f}"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   536
lemma current_files_mkdir: "current_files (Mkdir p f ino # \<tau>) = insert f (current_files \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   537
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   538
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
lemma current_files_linkhard: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   540
  "valid (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) \<Longrightarrow> current_files (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) = insert f\<^isub>2 (current_files \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
apply (frule vt_grant_os, frule vd_cons)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   542
by (auto simp:current_files_def inum_of_file.simps os_grant.simps is_file_def split:option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
lemma rename_renaming_decom:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
  "\<lbrakk>f\<^isub>3 \<preceq> file_after_rename f\<^isub>2 f\<^isub>3 f; Rename p f\<^isub>2 f\<^isub>3 # valid \<tau>; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> f\<^isub>2 \<preceq> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
apply (case_tac "f\<^isub>2 \<preceq> f", simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   548
apply (simp add:file_after_rename_def split:if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
by (frule vd_cons, frule vt_grant_os, auto simp:os_grant.simps dest!:ancenf_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
lemma rename_renaming_decom':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   552
  "\<lbrakk>\<not> f\<^isub>3 \<preceq> file_after_rename f\<^isub>2 f\<^isub>3 f; Rename p f\<^isub>2 f\<^isub>3 # valid \<tau>; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> \<not> f\<^isub>2 \<preceq> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   553
by (case_tac "f\<^isub>2 \<preceq> f", drule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop1, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
lemma current_files_rename: "Rename p f\<^isub>2 f\<^isub>3 # valid \<tau> \<Longrightarrow> current_files (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) = {file_after_rename f\<^isub>2 f\<^isub>3 f\<^isub>1| f\<^isub>1. f\<^isub>1 \<in> current_files \<tau>}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
apply (frule vt_grant_os, frule vd_cons)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
apply (auto simp:current_files_def inum_of_file.simps os_grant.simps split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
apply (rule_tac x = x in exI, simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
apply (frule_tac f\<^isub>2 = f\<^isub>2 in file_renaming_prop1', drule_tac f\<^isub>2 = f\<^isub>2 in file_renaming_prop5')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
apply (erule_tac x = "file_before_rename f\<^isub>2 f\<^isub>3 x" in allE, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   561
apply (rule_tac x = x in exI, simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
apply (drule_tac a = f\<^isub>3 and b = f\<^isub>2 in no_junior_conf, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
apply (drule_tac f = f\<^isub>3 and f' = f\<^isub>2 in ancenf_has_inum', simp, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
apply (drule_tac f\<^isub>2 = f\<^isub>2 in rename_renaming_decom, simp, simp add:current_files_def, simp add:file_renaming_prop5)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
apply (drule_tac f\<^isub>2 = f\<^isub>2 in rename_renaming_decom', simp, simp add:current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
apply (drule_tac f\<^isub>2 = f\<^isub>2 in rename_renaming_decom', simp, simp add:current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   569
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   572
lemma current_files_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
  "\<lbrakk>\<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
    \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   575
    \<forall> p f. e \<noteq> UnLink p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
    \<forall> p f. e \<noteq> Rmdir p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
    \<forall> p f i. e \<noteq> Mkdir p f i;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   578
    \<forall> p f f'. e \<noteq> LinkHard p f f'\<rbrakk> \<Longrightarrow> current_files (e # \<tau>) = current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
by (case_tac e, auto simp:current_files_def inum_of_file.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   581
lemmas current_files_simps = current_files_nil current_files_open current_files_open' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
                             current_files_closefd current_files_unlink current_files_rmdir 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
                             current_files_mkdir current_files_linkhard current_files_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   585
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   586
(******************** is_file simpset *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   587
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   588
lemma is_file_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
  "valid (Open p f flags fd opt # s) \<Longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   590
   is_file (Open p f flags fd opt # s) = (if (opt = None) then is_file s else (is_file s) (f:= True))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   593
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
            simp:is_file_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
lemma is_file_closefd:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
  "valid (CloseFd p fd # s) \<Longrightarrow> is_file (CloseFd p fd # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   599
     case (file_of_proc_fd s p fd) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
       Some f \<Rightarrow> ( if ((proc_fd_of_file s f = {(p, fd)}) \<and> (f \<in> files_hung_by_del s))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
                   then (is_file s) (f := False) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   602
                   else is_file s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
     | _      \<Rightarrow> is_file s                                   )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   606
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   608
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   609
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   610
lemma is_file_unlink:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   611
  "valid (UnLink p f # s) \<Longrightarrow> is_file (UnLink p f # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   612
     if (proc_fd_of_file s f = {}) then (is_file s) (f := False) else is_file s)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   613
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   614
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   617
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   618
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   619
lemma is_file_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   620
  "valid (LinkHard p f f' # s) \<Longrightarrow> is_file (LinkHard p f f' # s) = (is_file s) (f' := True)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   621
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   622
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   623
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   624
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   625
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   626
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   627
lemma is_file_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   628
  "\<lbrakk>valid (e # \<tau>); 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   629
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   630
    \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   631
    \<forall> p f. e \<noteq> UnLink p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   632
    \<forall> p f f'. e \<noteq> LinkHard p f f'\<rbrakk> \<Longrightarrow> is_file (e # \<tau>) = is_file \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   633
apply (frule vd_cons, drule vt_grant_os, rule_tac ext, case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   635
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
            simp:is_file_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   637
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   638
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   639
lemma file_dir_conflict: "\<lbrakk>is_file s f; is_dir s f\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   640
by (auto simp:is_file_def is_dir_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   641
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   642
lemma is_file_not_dir: "is_file s f \<Longrightarrow> \<not> is_dir s f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   643
by (rule notI, erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   644
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   645
lemma is_dir_not_file: "is_dir s f \<Longrightarrow> \<not> is_file s f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   646
by (rule notI, erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   647
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   648
lemmas is_file_simps = is_file_nil is_file_open is_file_closefd is_file_unlink is_file_linkhard is_file_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   649
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   650
(********* is_dir simpset **********)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   651
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   652
lemma is_dir_mkdir: "valid (Mkdir p f i # s) \<Longrightarrow> is_dir (Mkdir p f i # s) = (is_dir s) (f := True)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   653
apply (frule vd_cons, drule vt_grant_os, rule_tac ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   656
            simp:is_dir_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   657
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   658
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   659
lemma is_dir_rmdir: "valid (Rmdir p f # s) \<Longrightarrow> is_dir (Rmdir p f # s) = (is_dir s) (f := False)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   660
apply (frule vd_cons, drule vt_grant_os, rule_tac ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   661
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   662
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   663
            simp:is_dir_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   664
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   665
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   666
lemma is_dir_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
  "\<lbrakk>valid (e # s);
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   668
    \<forall> p f. e \<noteq> Rmdir p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   669
    \<forall> p f i. e \<noteq> Mkdir p f i\<rbrakk> \<Longrightarrow> is_dir (e # s) = is_dir s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   670
apply (frule vd_cons, drule vt_grant_os, rule_tac ext, case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   671
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   672
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   673
            simp:is_file_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   674
apply (drule file_of_pfd_is_file, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   675
apply (simp add:is_file_def split:t_inode_tag.splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   676
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   677
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   678
lemmas is_dir_simps = is_dir_nil is_dir_mkdir is_dir_rmdir is_dir_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   679
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   680
(*********** no root dir involved ***********)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   681
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   682
lemma root_is_dir: "valid s \<Longrightarrow> is_dir s []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   683
apply (induct s, simp add:is_dir_nil root_is_init_dir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   684
apply (frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   685
apply (auto simp:is_dir_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   686
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   688
lemma root_is_dir': "\<lbrakk>is_file s []; valid s\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   689
apply (drule root_is_dir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   690
apply (erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   691
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   692
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   693
lemma noroot_execve:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   694
  "valid (Execve p f fds # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   695
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   696
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   697
lemma noroot_execve':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   698
  "valid (Execve p [] fds # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   699
by (drule noroot_execve, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   700
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   701
lemma noroot_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   702
  "valid (Open p f flags fd opt # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   703
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir' split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   704
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   705
lemma noroot_open':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   706
  "valid (Open p [] flags fd opt # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   707
by (drule noroot_open, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   708
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   709
lemma noroot_filefd':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   710
  "\<lbrakk>file_of_proc_fd s p fd = Some []; valid s\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   711
apply (induct s arbitrary:p, simp) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   712
apply (drule init_filefd_prop5, erule root_is_init_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   713
apply (frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   714
apply (auto split:if_splits option.splits dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   715
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   716
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   717
lemma noroot_filefd:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   718
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   719
by (rule notI, simp, erule noroot_filefd', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   720
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   721
lemma noroot_unlink:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   722
  "valid (UnLink p f # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   723
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   724
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   725
lemma noroot_unlink':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   726
  "valid (UnLink p [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   727
by (drule noroot_unlink, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   728
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   729
lemma noroot_rmdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   730
  "valid (Rmdir p f # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   731
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   732
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   733
lemma noroot_rmdir':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   734
  "valid (Rmdir p [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   735
by (drule noroot_rmdir, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   736
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   737
lemma noroot_mkdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   738
  "valid (Mkdir p f inum # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   739
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   740
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   741
lemma noroot_mkdir':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   742
  "valid (Mkdir p [] inum # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   743
by (drule noroot_mkdir, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   744
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   745
lemma noroot_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   746
  "valid (LinkHard p f f' # s) \<Longrightarrow> f \<noteq> [] \<and> f' \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   747
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   748
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   749
lemma noroot_linkhard':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   750
  "valid (LinkHard p [] f # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   751
by (drule noroot_linkhard, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   752
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   753
lemma noroot_linkhard'':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   754
  "valid (LinkHard p f [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   755
by (drule noroot_linkhard, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   756
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   757
lemma noroot_truncate:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   758
  "valid (Truncate p f len # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   759
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   760
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   761
lemma noroot_truncate':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   762
  "valid (Truncate p [] len # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   763
by (drule noroot_truncate, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   764
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   765
lemmas noroot_events = noroot_execve noroot_open noroot_filefd noroot_unlink noroot_rmdir
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   766
  noroot_mkdir noroot_linkhard noroot_truncate
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   767
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   768
lemmas noroot_events' = noroot_execve' noroot_open' noroot_filefd' noroot_unlink' noroot_rmdir'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   769
  noroot_mkdir' noroot_linkhard' noroot_linkhard'' noroot_truncate'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   770
40
chunhan
parents: 9
diff changeset
   771
chunhan
parents: 9
diff changeset
   772
lemma is_file_in_current:
chunhan
parents: 9
diff changeset
   773
  "is_file s f \<Longrightarrow> f \<in> current_files s"
chunhan
parents: 9
diff changeset
   774
by (auto simp:is_file_def current_files_def split:option.splits)
chunhan
parents: 9
diff changeset
   775
chunhan
parents: 9
diff changeset
   776
lemma is_dir_in_current:
chunhan
parents: 9
diff changeset
   777
  "is_dir s f \<Longrightarrow> f \<in> current_files s"
chunhan
parents: 9
diff changeset
   778
by (auto simp:is_dir_def current_files_def split:option.splits)
chunhan
parents: 9
diff changeset
   779
chunhan
parents: 9
diff changeset
   780
chunhan
parents: 9
diff changeset
   781
(* simpset for same_inode_files: Current_files_prop.thy *)
chunhan
parents: 9
diff changeset
   782
chunhan
parents: 9
diff changeset
   783
lemma same_inode_files_nil:
chunhan
parents: 9
diff changeset
   784
  "same_inode_files [] = init_same_inode_files"
chunhan
parents: 9
diff changeset
   785
by (rule ext, simp add:same_inode_files_def init_same_inode_files_def is_file_nil)
chunhan
parents: 9
diff changeset
   786
chunhan
parents: 9
diff changeset
   787
lemma iof's_im_in_cim': "Some im = inum_of_file \<tau> f \<Longrightarrow> im \<in> current_inode_nums \<tau>"
chunhan
parents: 9
diff changeset
   788
by (auto simp add:current_inode_nums_def current_file_inums_def)
chunhan
parents: 9
diff changeset
   789
chunhan
parents: 9
diff changeset
   790
lemma same_inode_files_open:
chunhan
parents: 9
diff changeset
   791
  "valid (Open p f flags fd opt # s) \<Longrightarrow> same_inode_files (Open p f flags fd opt # s) = (\<lambda> f'.
chunhan
parents: 9
diff changeset
   792
     if (f' = f \<and> opt \<noteq> None) then {f} else same_inode_files s f')"
chunhan
parents: 9
diff changeset
   793
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents: 9
diff changeset
   794
apply (auto simp:same_inode_files_def is_file_simps split:if_splits option.splits
chunhan
parents: 9
diff changeset
   795
            dest:iof's_im_in_cim iof's_im_in_cim')
chunhan
parents: 9
diff changeset
   796
apply (drule is_file_in_current)
chunhan
parents: 9
diff changeset
   797
apply (simp add:current_files_def)
chunhan
parents: 9
diff changeset
   798
done
chunhan
parents: 9
diff changeset
   799
chunhan
parents: 9
diff changeset
   800
lemma same_inode_files_linkhard:
chunhan
parents: 9
diff changeset
   801
  "valid (LinkHard p oldf f # s) \<Longrightarrow> same_inode_files (LinkHard p oldf f # s) = (\<lambda> f'. 
chunhan
parents: 9
diff changeset
   802
     if (f' = f \<or> f' \<in> same_inode_files s oldf) 
chunhan
parents: 9
diff changeset
   803
     then same_inode_files s oldf \<union> {f}
chunhan
parents: 9
diff changeset
   804
     else same_inode_files s f')"
chunhan
parents: 9
diff changeset
   805
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents: 9
diff changeset
   806
apply (auto simp:same_inode_files_def is_file_simps split:if_splits option.splits
chunhan
parents: 9
diff changeset
   807
            dest:iof's_im_in_cim iof's_im_in_cim')
chunhan
parents: 9
diff changeset
   808
apply (drule is_file_in_current)
chunhan
parents: 9
diff changeset
   809
apply (simp add:current_files_def is_file_def)
chunhan
parents: 9
diff changeset
   810
apply (simp add:is_file_def)
chunhan
parents: 9
diff changeset
   811
done
chunhan
parents: 9
diff changeset
   812
chunhan
parents: 9
diff changeset
   813
lemma inum_of_file_none_prop:
chunhan
parents: 9
diff changeset
   814
  "\<lbrakk>inum_of_file s f = None; valid s\<rbrakk> \<Longrightarrow> f \<notin> current_files s"
chunhan
parents: 9
diff changeset
   815
by (simp add:current_files_def)
chunhan
parents: 9
diff changeset
   816
chunhan
parents: 9
diff changeset
   817
lemma same_inode_files_closefd:
chunhan
parents: 9
diff changeset
   818
  "\<lbrakk>valid (CloseFd p fd # s); f' \<in> current_files (CloseFd p fd # s)\<rbrakk> \<Longrightarrow> 
chunhan
parents: 9
diff changeset
   819
   same_inode_files (CloseFd p fd # s) f' = (
chunhan
parents: 9
diff changeset
   820
     case (file_of_proc_fd s p fd) of 
chunhan
parents: 9
diff changeset
   821
       Some f \<Rightarrow> (if ((proc_fd_of_file s f = {(p, fd)}) \<and> (f \<in> files_hung_by_del s))
chunhan
parents: 9
diff changeset
   822
                 then same_inode_files s f' - {f}
chunhan
parents: 9
diff changeset
   823
                 else same_inode_files s f' )
chunhan
parents: 9
diff changeset
   824
     | None   \<Rightarrow> same_inode_files s f' )"
chunhan
parents: 9
diff changeset
   825
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 9
diff changeset
   826
apply (auto simp:same_inode_files_def is_file_closefd current_files_closefd 
chunhan
parents: 9
diff changeset
   827
           split:if_splits option.splits
chunhan
parents: 9
diff changeset
   828
            dest:iof's_im_in_cim iof's_im_in_cim' inum_of_file_none_prop)
chunhan
parents: 9
diff changeset
   829
done
chunhan
parents: 9
diff changeset
   830
chunhan
parents: 9
diff changeset
   831
lemma same_inode_files_unlink:
chunhan
parents: 9
diff changeset
   832
  "\<lbrakk>valid (UnLink p f # s); f' \<in> current_files (UnLink p f # s)\<rbrakk> 
chunhan
parents: 9
diff changeset
   833
   \<Longrightarrow> same_inode_files (UnLink p f # s) f' = (
chunhan
parents: 9
diff changeset
   834
     if (proc_fd_of_file s f = {}) 
chunhan
parents: 9
diff changeset
   835
     then same_inode_files s f' - {f}
chunhan
parents: 9
diff changeset
   836
     else same_inode_files s f')"
chunhan
parents: 9
diff changeset
   837
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 9
diff changeset
   838
apply (auto simp:same_inode_files_def is_file_unlink current_files_unlink 
chunhan
parents: 9
diff changeset
   839
           split:if_splits option.splits
chunhan
parents: 9
diff changeset
   840
            dest:iof's_im_in_cim iof's_im_in_cim' inum_of_file_none_prop)
chunhan
parents: 9
diff changeset
   841
done
chunhan
parents: 9
diff changeset
   842
chunhan
parents: 9
diff changeset
   843
lemma same_inode_files_mkdir:
chunhan
parents: 9
diff changeset
   844
  "valid (Mkdir p f inum # s) \<Longrightarrow> same_inode_files (Mkdir p f inum # s) = (same_inode_files s)"
chunhan
parents: 9
diff changeset
   845
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents: 9
diff changeset
   846
apply (auto simp:same_inode_files_def is_file_simps current_files_simps 
chunhan
parents: 9
diff changeset
   847
           split:if_splits option.splits
chunhan
parents: 9
diff changeset
   848
            dest:iof's_im_in_cim iof's_im_in_cim' inum_of_file_none_prop is_file_in_current)
chunhan
parents: 9
diff changeset
   849
apply (simp add:current_files_def is_file_def)
chunhan
parents: 9
diff changeset
   850
done
chunhan
parents: 9
diff changeset
   851
chunhan
parents: 9
diff changeset
   852
lemma same_inode_files_other:
chunhan
parents: 9
diff changeset
   853
  "\<lbrakk>valid (e # s); 
chunhan
parents: 9
diff changeset
   854
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
chunhan
parents: 9
diff changeset
   855
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents: 9
diff changeset
   856
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents: 9
diff changeset
   857
    \<forall> p f f'. e \<noteq> LinkHard p f f'\<rbrakk> \<Longrightarrow> same_inode_files (e # s)  = same_inode_files s"
chunhan
parents: 9
diff changeset
   858
apply (frule vt_grant_os, frule vd_cons, rule ext, case_tac e)
chunhan
parents: 9
diff changeset
   859
apply (auto simp:same_inode_files_def is_file_simps current_files_simps dir_is_empty_def
chunhan
parents: 9
diff changeset
   860
           split:if_splits option.splits
chunhan
parents: 9
diff changeset
   861
            dest:iof's_im_in_cim iof's_im_in_cim' inum_of_file_none_prop is_file_not_dir)
chunhan
parents: 9
diff changeset
   862
apply (simp add:is_file_def is_dir_def current_files_def split:option.splits t_inode_tag.splits)+
chunhan
parents: 9
diff changeset
   863
done
chunhan
parents: 9
diff changeset
   864
 
chunhan
parents: 9
diff changeset
   865
lemmas same_inode_files_simps = same_inode_files_nil same_inode_files_open same_inode_files_linkhard
chunhan
parents: 9
diff changeset
   866
  same_inode_files_closefd same_inode_files_unlink same_inode_files_mkdir same_inode_files_other
chunhan
parents: 9
diff changeset
   867
chunhan
parents: 9
diff changeset
   868
lemma same_inode_files_prop1:
chunhan
parents: 9
diff changeset
   869
  "f \<in> same_inode_files s f' \<Longrightarrow> f \<in> current_files s"
chunhan
parents: 9
diff changeset
   870
by (simp add:same_inode_files_def is_file_def current_files_def split:if_splits option.splits)
chunhan
parents: 9
diff changeset
   871
chunhan
parents: 9
diff changeset
   872
lemma same_inode_files_prop2:
chunhan
parents: 9
diff changeset
   873
  "\<lbrakk>f \<in> same_inode_files s f'; f'' \<notin> current_files s\<rbrakk> \<Longrightarrow> f \<noteq> f''"
chunhan
parents: 9
diff changeset
   874
by (auto dest:same_inode_files_prop1)
chunhan
parents: 9
diff changeset
   875
chunhan
parents: 9
diff changeset
   876
lemma same_inode_files_prop3:
chunhan
parents: 9
diff changeset
   877
  "\<lbrakk>f \<in> same_inode_files s f'; is_dir s f''\<rbrakk> \<Longrightarrow> f \<noteq> f''"
chunhan
parents: 9
diff changeset
   878
apply (rule notI)
chunhan
parents: 9
diff changeset
   879
apply (simp add:same_inode_files_def is_file_def is_dir_def 
chunhan
parents: 9
diff changeset
   880
          split:if_splits option.splits t_inode_tag.splits)
chunhan
parents: 9
diff changeset
   881
done
chunhan
parents: 9
diff changeset
   882
chunhan
parents: 9
diff changeset
   883
lemma same_inode_files_prop4:
chunhan
parents: 9
diff changeset
   884
  "\<lbrakk>f' \<in> same_inode_files s f; f'' \<in> same_inode_files s f'\<rbrakk> \<Longrightarrow> f'' \<in> same_inode_files s f"
chunhan
parents: 9
diff changeset
   885
by (auto simp:same_inode_files_def split:if_splits)
chunhan
parents: 9
diff changeset
   886
chunhan
parents: 9
diff changeset
   887
lemma same_inode_files_prop5:
chunhan
parents: 9
diff changeset
   888
  "f' \<in> same_inode_files s f \<Longrightarrow> f \<in> same_inode_files s f'"
chunhan
parents: 9
diff changeset
   889
by (auto simp:same_inode_files_def is_file_def split:if_splits)
chunhan
parents: 9
diff changeset
   890
chunhan
parents: 9
diff changeset
   891
lemma same_inode_files_prop6:
chunhan
parents: 9
diff changeset
   892
  "f' \<in> same_inode_files s f \<Longrightarrow> same_inode_files s f' = same_inode_files s f"
chunhan
parents: 9
diff changeset
   893
by (auto simp:same_inode_files_def is_file_def split:if_splits)
chunhan
parents: 9
diff changeset
   894
chunhan
parents: 9
diff changeset
   895
lemma same_inode_files_prop7:
chunhan
parents: 9
diff changeset
   896
  "f' \<in> same_inode_files s f \<Longrightarrow> has_same_inode s f f'"
chunhan
parents: 9
diff changeset
   897
by (auto simp:same_inode_files_def is_file_def has_same_inode_def split:if_splits option.splits)
chunhan
parents: 9
diff changeset
   898
chunhan
parents: 9
diff changeset
   899
lemma same_inode_files_prop8:
chunhan
parents: 9
diff changeset
   900
  "f' \<in> same_inode_files s f \<Longrightarrow> has_same_inode s f' f"
chunhan
parents: 9
diff changeset
   901
by (auto simp:same_inode_files_def is_file_def has_same_inode_def split:if_splits option.splits)
chunhan
parents: 9
diff changeset
   902
chunhan
parents: 9
diff changeset
   903
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   904
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   905
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   906
end