Current_files_prop.thy
author chunhan
Wed, 15 May 2013 11:21:39 +0800
changeset 6 8779d321cc2e
parent 2 5a01ee1c9b4d
child 7 f27882976251
permissions -rw-r--r--
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
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
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   218
        apply (auto simp:files_hung_by_del.simps inum_of_file.simps os_grant.simps current_files_def 
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'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   225
        apply (auto simp:os_grant.simps current_files_def inum_of_file.simps split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   226
        apply (drule_tac f = pf and f' = f in hns', simp, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   227
        apply (drule_tac f = list and f' = f in fns', simp, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   228
        apply (drule_tac f = list and f' = f in dns', simp, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   229
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   230
      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
   231
        apply (clarify, case_tac a)    
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   232
        using vt os fns''
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   233
        apply (auto simp:os_grant.simps current_files_def inum_of_file.simps itag_of_inum.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   234
                         is_file_def is_dir_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   235
                    dest:ios's_im_in_cim iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
                   split:if_splits option.splits t_inode_tag.splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   237
        apply (drule_tac f = f' and pf = list in pin', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   238
        apply (drule_tac f = f' and pf = list2 in pin', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   239
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
      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
   241
                               parent f' = Some f \<longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   242
        apply (clarify, case_tac a)     
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
        using vt os hns'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
        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
   245
                   split:if_splits option.splits t_sock_addr.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   246
        apply (drule fns', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
        done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
      ultimately show ?thesis by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
    
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
(**************** hung file in current ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
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
   256
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
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
   259
by (auto dest:hung_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
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
   262
by (clarsimp simp add:current_files_def hung_file_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
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
   265
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   266
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   267
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
   268
by (auto dest:parentf_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   269
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   270
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
   271
by (clarsimp simp add:current_files_def parentf_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   272
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   273
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
   274
apply (subgoal_tac "parent (a # pf) = Some pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   275
by (erule parentf_in_current, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   276
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
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
   278
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   279
  case Nil show ?case by (auto simp: no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   281
  case (Cons a f') 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
  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
   283
  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
   284
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   285
    fix f im
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   286
    assume h1: "f \<preceq> a # f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   287
      and  h2: "inum_of_file \<tau> (a # f') = Some im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   288
      and  h3: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   289
    show "\<exists>y. inum_of_file \<tau> f = Some y"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   290
    proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   291
      have h4: "\<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 "parent (a # f') = Some f'" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   294
        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
   295
        with h1 show ?thesis by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   296
      qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   297
      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
   298
      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
   299
      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
   300
      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
   301
      ultimately show ?thesis by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   302
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   303
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   304
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   305
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   306
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
   307
by (rule ancenf_has_inum_aux[rule_format], auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   308
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   309
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
   310
by (auto dest:ancenf_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   311
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   312
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
   313
by (simp add:current_files_def, erule exE, simp add:ancenf_has_inum')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   314
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   315
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
   316
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   317
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   318
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
   319
by (simp add:current_files_def, erule exE, auto intro:file_has_no_son)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   320
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   321
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
   322
by (drule file_leveling[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   323
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   324
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
   325
by (simp add:current_files_def, erule exE, auto intro:hung_file_no_son)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   326
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   327
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
   328
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   329
  case Nil 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   330
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   331
    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
   332
next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   333
  case (Cons a pf)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   334
  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
   335
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   336
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   337
    fix f
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   338
    assume h1: "f \<in> files_hung_by_del \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   339
      and  h2: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   340
      and  h3: "a # pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   341
      and  h4: "f \<preceq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   342
      and  h5: "f \<noteq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   343
    have h6: "parent (a # pf) = Some pf" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   344
    with h2 h3 have h7: "pf \<in> current_files \<tau>" by (drule_tac parentf_in_current, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   345
    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
   346
    show False
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   347
    proof (cases "f = pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   348
      case True with h6 h2 h3 h1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   349
      show False by (auto intro!:hung_file_no_son')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   350
    next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   351
      case False with pre h1 h2 h7 h8 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   352
      show False by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   353
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   354
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   355
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   356
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   357
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
   358
by (rule hung_file_no_des_aux[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   359
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   360
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
   361
apply (frule hung_file_has_inum', simp, erule exE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   362
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
   363
by (simp add: noJ_Anc, auto dest:hung_file_no_des)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   364
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   365
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   366
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   367
(************** file_of_proc_fd in current ********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   368
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   369
lemma file_of_pfd_imp_inode_aux: "\<forall> p f. file_of_proc_fd \<tau> p fd = Some f \<and> valid \<tau> \<longrightarrow> inum_of_file \<tau> f \<noteq> None" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   370
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   371
apply (clarsimp simp add:file_of_proc_fd.simps inum_of_file.simps init_filefd_prop1 init_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   372
apply ((rule_tac allI|rule_tac impI|erule_tac conjE)+, frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   373
apply (auto simp:inum_of_file.simps file_of_proc_fd.simps os_grant.simps current_files_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   374
           split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   375
apply (simp add:pfdof_simp3)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   376
apply (simp add:proc_fd_of_file_def)+  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   377
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   378
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   379
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"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   380
by (rule file_of_pfd_imp_inode_aux[rule_format], blast)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   381
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   382
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
   383
by (auto dest!:file_of_pfd_imp_inode')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   384
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   385
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
   386
by (auto dest!:file_of_pfd_imp_inode' simp:current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   387
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   388
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   389
(*************** file_of_proc_fd is file *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   390
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   391
lemma file_of_pfd_is_file_tag:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   392
  "\<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"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   393
apply (induct \<tau> arbitrary:p, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   394
apply (drule init_filefd_prop5, simp add:is_init_file_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   395
apply (frule vd_cons, frule vt_grant_os, simp, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   396
by (auto split:option.splits t_inode_tag.splits if_splits t_socket_type.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   397
          dest:file_of_pfd_imp_inode' iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   398
          simp:is_file_def is_dir_def dir_is_empty_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   399
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   400
lemma file_of_pfd_is_file:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   401
  "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> is_file \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   402
apply (frule file_of_pfd_imp_inode, simp, erule exE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   403
apply (drule file_of_pfd_is_file_tag, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   404
by (simp add:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   405
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   406
lemma file_of_pfd_is_file':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   407
  "\<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
   408
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
   409
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   410
(************** parent file / ancestral file is dir *******************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   411
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   412
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
   413
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   414
apply (clarsimp simp:inum_of_file.simps itag_of_inum.simps init_parent_file_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   415
apply (clarify, frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   416
apply (auto simp:inum_of_file.simps itag_of_inum.simps os_grant.simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   417
                 current_files_def is_dir_def is_file_def 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   418
            dest: ios's_im_in_cim iof's_im_in_cim
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   419
           split:if_splits option.splits t_sock_addr.splits t_inode_tag.splits t_socket_type.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   420
apply (drule parentf_has_inum', simp, simp, simp)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   421
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   422
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   423
lemma parentf_has_dirtag: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   424
  "\<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
   425
   \<Longrightarrow> itag_of_inum \<tau> ipm = Some Tag_DIR"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
by (auto intro:parentf_is_dir_aux[rule_format])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   427
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
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
   429
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
   430
by (auto dest:parentf_has_dirtag)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   431
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
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
   433
by (clarsimp simp:current_files_def parentf_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   434
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
   435
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
   436
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
   437
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   438
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
   439
proof (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
  case Nil show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
    by (auto simp:current_files_def no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
next 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   443
  case (Cons a pf)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   444
  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
   445
  show ?case
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
  proof clarify
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   447
    fix f
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
    assume h1: "f \<preceq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   449
      and  h2: "f \<noteq> a # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   450
      and  h3: "a # pf \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   451
      and  h4: "valid \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   452
    have h5: "parent (a # pf) = Some pf" by simp
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
    with h3 h4 have h6: "pf \<in> current_files \<tau>" by (drule_tac parentf_in_current, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   454
    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
   455
    show "is_dir \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
    proof (cases "f = pf")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   457
      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
   458
    next
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
      case False with pre h6 h7 h4 show "is_dir \<tau> f" by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
    qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   461
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   464
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
   465
by (auto intro:ancenf_is_dir_aux[rule_format])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   467
(************* rebuild current_files simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
lemma current_files_nil: "current_files [] = init_files"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
apply (simp add:current_files_def inum_of_file.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   471
by (auto dest:inof_has_file_tag init_file_has_inum)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   472
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
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
   474
by (auto simp add:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   475
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
lemma current_files_open': "current_files (Open p f flags fd None # \<tau>) = current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
by (simp add:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   478
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   479
lemma current_files_closefd: "current_files (CloseFd p fd # \<tau>) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
     case (file_of_proc_fd \<tau> p fd) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
       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
   482
                   then current_files \<tau> - {f}
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   483
                   else current_files \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
     | _      \<Rightarrow> current_files \<tau>                                  )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
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
   488
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   489
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   490
lemma current_files_rmdir: "current_files (Rmdir 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
   491
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
lemma current_files_mkdir: "current_files (Mkdir p f ino # \<tau>) = insert f (current_files \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
by (auto simp:current_files_def inum_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
lemma current_files_linkhard: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
  "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
   498
apply (frule vt_grant_os, frule vd_cons)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
by (auto simp:current_files_def inum_of_file.simps os_grant.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
lemma rename_renaming_decom:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
  "\<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
   504
apply (case_tac "f\<^isub>2 \<preceq> f", simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
apply (simp add:file_after_rename_def split:if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   506
by (frule vd_cons, frule vt_grant_os, auto simp:os_grant.simps dest!:ancenf_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   507
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
lemma rename_renaming_decom':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
  "\<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
   510
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
   511
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
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
   513
apply (frule vt_grant_os, frule vd_cons)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
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
   515
apply (rule_tac x = x in exI, simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
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
   517
apply (erule_tac x = "file_before_rename f\<^isub>2 f\<^isub>3 x" in allE, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
apply (rule_tac x = x in exI, simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
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
   520
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
   521
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
   522
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
   523
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
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
   525
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   527
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
lemma current_files_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
  "\<lbrakk>\<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
    \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
    \<forall> p f. e \<noteq> UnLink p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
    \<forall> p f. e \<noteq> Rmdir p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
    \<forall> p f i. e \<noteq> Mkdir p f i;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
    \<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
   536
by (case_tac e, auto simp:current_files_def inum_of_file.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   537
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   538
lemmas current_files_simps = current_files_nil current_files_open current_files_open' 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
                             current_files_closefd current_files_unlink current_files_rmdir 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   540
                             current_files_mkdir current_files_linkhard current_files_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   542
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
(******************** is_file simpset *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
lemma is_file_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
  "valid (Open p f flags fd opt # s) \<Longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
   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
   548
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
            simp:is_file_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   552
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   553
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
lemma is_file_closefd:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
  "valid (CloseFd p fd # s) \<Longrightarrow> is_file (CloseFd p fd # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
     case (file_of_proc_fd s p fd) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
       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
   558
                   then (is_file s) (f := False) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
                   else is_file s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
     | _      \<Rightarrow> is_file s                                   )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   561
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
lemma is_file_unlink:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
  "valid (UnLink p f # s) \<Longrightarrow> is_file (UnLink p f # s) = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   569
     if (proc_fd_of_file s f = {}) then (is_file s) (f := False) else is_file s)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   572
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   575
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
lemma is_file_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
  "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
   578
apply (frule vd_cons, drule vt_grant_os, rule ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
apply (auto dest:finum_has_itag iof's_im_in_cim 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
           split:if_splits option.splits t_inode_tag.splits 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   581
            simp:is_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
lemma is_file_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   585
  "\<lbrakk>valid (e # \<tau>); 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   586
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   587
    \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   588
    \<forall> p f. e \<noteq> UnLink p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
    \<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
   590
apply (frule vd_cons, drule vt_grant_os, rule_tac ext, case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   593
            simp:is_file_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
lemma file_dir_conflict: "\<lbrakk>is_file s f; is_dir s f\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
by (auto simp:is_file_def is_dir_def split:option.splits t_inode_tag.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   599
lemma is_file_not_dir: "is_file s f \<Longrightarrow> \<not> is_dir s f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
by (rule notI, erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   602
lemma is_dir_not_file: "is_dir s f \<Longrightarrow> \<not> is_file s f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
by (rule notI, erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
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
   606
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
(********* is_dir simpset **********)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   608
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   609
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
   610
apply (frule vd_cons, drule vt_grant_os, rule_tac ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   611
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   612
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   613
            simp:is_dir_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   614
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
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
   617
apply (frule vd_cons, drule vt_grant_os, rule_tac ext)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   618
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   619
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   620
            simp:is_dir_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   621
apply (drule pfdof_simp2)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   622
apply (drule file_of_pfd_is_file, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   623
apply (simp add:is_file_def split:t_inode_tag.splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   624
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   625
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   626
lemma is_dir_other:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   627
  "\<lbrakk>valid (e # s);
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   628
    \<forall> p f. e \<noteq> Rmdir p f;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   629
    \<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
   630
apply (frule vd_cons, drule vt_grant_os, rule_tac ext, case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   631
apply (auto dest:finum_has_itag iof's_im_in_cim intro!:ext
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   632
           split:if_splits option.splits t_inode_tag.split t_socket_type.splits
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   633
            simp:is_file_def dir_is_empty_def is_dir_def current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
apply (drule file_of_pfd_is_file, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   635
apply (simp add:is_file_def split:t_inode_tag.splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   637
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   638
lemmas is_dir_simps = is_dir_nil is_dir_mkdir is_dir_rmdir is_dir_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   639
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   640
(*********** no root dir involved ***********)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   641
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   642
lemma root_is_dir: "valid s \<Longrightarrow> is_dir s []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   643
apply (induct s, simp add:is_dir_nil root_is_init_dir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   644
apply (frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   645
apply (auto simp:is_dir_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   646
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   647
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   648
lemma root_is_dir': "\<lbrakk>is_file s []; valid s\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   649
apply (drule root_is_dir)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   650
apply (erule file_dir_conflict, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   651
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   652
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   653
lemma noroot_execve:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
  "valid (Execve p f fds # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   656
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   657
lemma noroot_execve':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   658
  "valid (Execve p [] fds # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   659
by (drule noroot_execve, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   660
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   661
lemma noroot_open:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   662
  "valid (Open p f flags fd opt # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   663
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir' split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   664
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   665
lemma noroot_open':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   666
  "valid (Open p [] flags fd opt # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
by (drule noroot_open, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   668
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   669
lemma noroot_filefd':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   670
  "\<lbrakk>file_of_proc_fd s p fd = Some []; valid s\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   671
apply (induct s arbitrary:p, simp) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   672
apply (drule init_filefd_prop5, erule root_is_init_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   673
apply (frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   674
apply (auto split:if_splits option.splits dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   675
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   676
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   677
lemma noroot_filefd:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   678
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   679
by (rule notI, simp, erule noroot_filefd', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   680
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   681
lemma noroot_unlink:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   682
  "valid (UnLink p f # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   683
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   684
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   685
lemma noroot_unlink':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   686
  "valid (UnLink p [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
by (drule noroot_unlink, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   688
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   689
lemma noroot_rmdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   690
  "valid (Rmdir p f # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   691
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   692
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   693
lemma noroot_rmdir':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   694
  "valid (Rmdir p [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   695
by (drule noroot_rmdir, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   696
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   697
lemma noroot_mkdir:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   698
  "valid (Mkdir p f inum # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   699
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   700
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   701
lemma noroot_mkdir':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   702
  "valid (Mkdir p [] inum # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   703
by (drule noroot_mkdir, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   704
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   705
lemma noroot_linkhard:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   706
  "valid (LinkHard p f f' # s) \<Longrightarrow> f \<noteq> [] \<and> f' \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   707
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   708
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   709
lemma noroot_linkhard':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   710
  "valid (LinkHard p [] f # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   711
by (drule noroot_linkhard, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   712
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   713
lemma noroot_linkhard'':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   714
  "valid (LinkHard p f [] # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   715
by (drule noroot_linkhard, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   716
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   717
lemma noroot_truncate:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   718
  "valid (Truncate p f len # s) \<Longrightarrow> f \<noteq> []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   719
by (frule vd_cons, drule vt_grant_os, auto dest!:root_is_dir')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   720
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   721
lemma noroot_truncate':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   722
  "valid (Truncate p [] len # s) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   723
by (drule noroot_truncate, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   724
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   725
lemmas noroot_events = noroot_execve noroot_open noroot_filefd noroot_unlink noroot_rmdir
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   726
  noroot_mkdir noroot_linkhard noroot_truncate
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   727
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   728
lemmas noroot_events' = noroot_execve' noroot_open' noroot_filefd' noroot_unlink' noroot_rmdir'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   729
  noroot_mkdir' noroot_linkhard' noroot_linkhard'' noroot_truncate'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   730
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   731
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   732
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   733
end