Proc_fd_of_file_prop.thy
author chunhan
Thu, 12 Sep 2013 18:23:38 +0800
changeset 45 d7fab2e2a0b8
parent 1 7d9c0ed02b56
child 70 002c34a6ff4f
permissions -rw-r--r--
s2ss_writefile
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Proc_fd_of_file_prop
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
imports Main Flask Flask_type Valid_prop Current_files_prop
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     3
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
context flask begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
lemma proc_fd_in_procs: "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk>  \<Longrightarrow> p \<in> current_procs \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
apply (induct \<tau> arbitrary: f) defer
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
apply (frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
apply (auto simp:file_of_proc_fd.simps current_procs.simps os_grant.simps split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
by (drule init_filefd_valid, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
lemma proc_fd_in_fds_aux: "\<forall> p f. file_of_proc_fd \<tau> p fd = Some f \<and> valid \<tau> \<longrightarrow> fd \<in> current_proc_fds \<tau> p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
apply (induct \<tau>)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
apply (simp add:file_of_proc_fd.simps current_proc_fds.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    16
apply (clarify, drule init_filefd_valid, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    17
apply (clarify, frule vd_cons, frule vt_grant_os, case_tac a)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    18
apply (auto simp:file_of_proc_fd.simps current_proc_fds.simps split:if_splits option.splits t_sock_addr.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    20
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
lemma proc_fd_in_fds: "\<lbrakk>file_of_proc_fd \<tau> p fd = Some f; valid \<tau>\<rbrakk> \<Longrightarrow> fd \<in> current_proc_fds \<tau> p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
by (rule proc_fd_in_fds_aux[rule_format], simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    23
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
lemma proc_fd_file_in_cur: "\<lbrakk>(p, fd) \<in> proc_fd_of_file \<tau> f; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
by (auto simp:proc_fd_of_file_def intro:file_of_pfd_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
lemma proc_fd_file_in_cur': "\<lbrakk>proc_fd_of_file \<tau> f \<noteq> {}; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    28
by (auto simp:proc_fd_file_in_cur)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
lemma proc_fd_file_in_cur'': "\<lbrakk>proc_fd_of_file \<tau> f = {(p,fd)}; valid \<tau>\<rbrakk> \<Longrightarrow> f \<in> current_files \<tau>"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    31
by (auto simp:proc_fd_file_in_cur')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
lemma procfd_of_file_imp_fpfd: "proc_fd_of_file \<tau> f = {(p, fd)} \<Longrightarrow> file_of_proc_fd \<tau> p fd = Some f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    34
by (auto simp:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    35
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
lemma procfd_of_file_imp_fpfd': "proc_fd_of_file \<tau> f = {(p, fd)} \<Longrightarrow> file_of_proc_fd \<tau> p fd \<noteq> None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    37
by (auto simp:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
lemma procfd_of_file_eq_fpfd'': "(p, fd) \<in> proc_fd_of_file \<tau> f = (file_of_proc_fd \<tau> p fd = Some f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
by (auto simp:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
lemma procfd_of_file_non_empty: "file_of_proc_fd \<tau> p fd = Some f \<Longrightarrow> proc_fd_of_file \<tau> f \<noteq> {}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
by (auto simp:proc_fd_of_file_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
lemma file_of_proc_fd_in_curf: "\<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
    46
by (drule procfd_of_file_non_empty, simp add:proc_fd_file_in_cur')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
(******************* rebuild proc_fd_of_file simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
lemma proc_fd_of_file_open: "Open p f flags fd iopt # valid \<tau> \<Longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
  proc_fd_of_file (Open p f flags fd iopt # \<tau>) f' = (if (f' = f) then insert (p, fd) (proc_fd_of_file \<tau> f') else proc_fd_of_file \<tau> f')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
apply (auto simp:proc_fd_of_file_def file_of_proc_fd.simps split:if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
apply (frule vd_cons, drule vt_grant_os, case_tac iopt)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
apply (drule proc_fd_in_fds, simp, simp add:os_grant.simps nfd_notin_curfd)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
lemma proc_fd_of_file_closefd: "proc_fd_of_file (CloseFd p fd # \<tau>) f = (if (file_of_proc_fd \<tau> p fd = Some f) then (proc_fd_of_file \<tau> f - {(p,fd)}) else proc_fd_of_file \<tau> f) "
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
by (auto simp:proc_fd_of_file_def file_of_proc_fd.simps split:if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    61
lemma proc_fd_of_file_rename: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # valid \<tau>; f \<in> current_files (Rename p f\<^isub>2 f\<^isub>3 # \<tau>)\<rbrakk> \<Longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
  proc_fd_of_file (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = (if (f\<^isub>3 \<preceq> f) then proc_fd_of_file \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f) else proc_fd_of_file \<tau> f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
apply (frule vt_grant_os, frule vd_cons)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
apply (case_tac "f\<^isub>3 \<preceq> f")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
apply (subgoal_tac "f \<notin> current_files \<tau>") prefer 2 apply (rule notI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    66
apply (clarsimp simp:os_grant.simps, drule_tac f = f\<^isub>3 and f' = f in ancenf_in_current, simp, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
apply (auto simp add:proc_fd_of_file_def)[1]
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
apply (simp add:file_of_proc_fd.simps split:option.splits if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    70
apply (drule_tac f\<^isub>3 = f\<^isub>3 and f\<^isub>1 = aa and f\<^isub>2 = f\<^isub>2 in file_renaming_prop5, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
apply (drule file_of_pfd_in_current, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
apply (simp add:file_of_proc_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
apply (rule conjI, rule impI, simp add:file_renaming_prop5')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
apply (rule impI, simp add:file_before_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
apply (simp add:proc_fd_of_file_def split:if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
apply auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
apply (simp add:file_of_proc_fd.simps split:option.splits if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
apply (drule_tac f\<^isub>3 = f\<^isub>3 and f\<^isub>2 = f\<^isub>2 and f = aa in file_renaming_prop1, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
apply (simp add:current_files_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
apply (erule exE| erule conjE)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    82
apply (simp add:file_of_proc_fd.simps split:option.splits if_splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    83
apply (drule_tac f = f\<^isub>1 in rename_renaming_decom', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    88
lemma proc_fd_of_file_kill: "proc_fd_of_file (Kill p\<^isub>1 p\<^isub>2 # \<tau>) f = {(p, fd). (p, fd) \<in> proc_fd_of_file \<tau> f \<and> p \<noteq> p\<^isub>2}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    89
by (auto simp:proc_fd_of_file_def file_of_proc_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    90
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    91
lemma proc_fd_of_file_exit: "proc_fd_of_file (Exit p' # \<tau>) f = {(p, fd). (p, fd) \<in> proc_fd_of_file \<tau> f \<and> p \<noteq> p'}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    92
by (auto simp:proc_fd_of_file_def file_of_proc_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
lemma proc_fd_of_file_clone: "Clone p\<^isub>1 p\<^isub>2 # valid \<tau> \<Longrightarrow> proc_fd_of_file (Clone p\<^isub>1 p\<^isub>2 # \<tau>) f = proc_fd_of_file \<tau> f \<union> {(p\<^isub>2, fd)| fd. (p\<^isub>1, fd) \<in> proc_fd_of_file \<tau> f}" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
apply (auto simp:proc_fd_of_file_def file_of_proc_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    96
apply (frule vd_cons, drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    97
apply (drule proc_fd_in_procs, (simp add:os_grant.simps np_notin_curp)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    98
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    99
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   100
lemma proc_fd_of_file_other: "\<lbrakk>e # valid \<tau>;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   101
                               \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   102
                               \<forall> p fd. e \<noteq> CloseFd p fd;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   103
                               \<forall> p f f'. e \<noteq> Rename p f f';
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   104
                               \<forall> p p'. e \<noteq> Kill p p';
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   105
                               \<forall> p. e \<noteq> Exit p;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   106
                               \<forall> p p'. e \<noteq> Clone p p'\<rbrakk> \<Longrightarrow> proc_fd_of_file (e # \<tau>) f = proc_fd_of_file \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   107
apply (case_tac e, auto simp:proc_fd_of_file_def file_of_proc_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   108
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   109
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
lemmas proc_fd_of_file_simps = proc_fd_of_file_open proc_fd_of_file_closefd proc_fd_of_file_rename proc_fd_of_file_kill proc_fd_of_file_exit proc_fd_of_file_clone proc_fd_of_file_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   112
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   114
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   115
end