Co2sobj_prop.thy
author chunhan
Tue, 21 May 2013 08:01:33 +0800
changeset 10 ac66d8ba86d9
parent 8 289a30c4cfb7
child 11 3e7617baa6a3
permissions -rw-r--r--
fix bugs and proofs
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 Co2sobj_prop
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
     3
imports Main Flask Flask_type Static Static_type Sectxt_prop Init_prop Current_files_prop Current_sockets_prop Delete_prop Proc_fd_of_file_prop
1
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 tainting_s begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
     9
(****************** cf2sfile path simpset ***************)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    11
lemma sroot_only:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    12
  "cf2sfile s [] = Some sroot"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    13
by (simp add:cf2sfile_def)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    14
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    15
lemma not_file_is_dir:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    16
  "\<lbrakk>\<not> is_file s f; f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_dir s f"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    17
by (auto simp:is_file_def current_files_def is_dir_def 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    18
         dest:finum_has_itag finum_has_ftag' split:t_inode_tag.splits option.splits)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    19
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    20
lemma not_dir_is_file:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    21
  "\<lbrakk>\<not> is_dir s f; f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_file s f"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    22
by (auto simp:is_file_def current_files_def is_dir_def 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    23
         dest:finum_has_itag finum_has_ftag' split:t_inode_tag.splits option.splits)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    24
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    25
lemma is_file_or_dir:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    26
  "\<lbrakk>f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_file s f \<or> is_dir s f"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    27
by (auto dest:not_dir_is_file)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    28
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    29
lemma current_file_has_sfile:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    30
  "\<lbrakk>f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> \<exists> sf. cf2sfile s f = Some sf"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    31
apply (induct f)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    32
apply (rule_tac x = "sroot" in exI, simp add:sroot_only)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    33
apply (frule parentf_in_current', simp, clarsimp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    34
apply (frule parentf_is_dir'', simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    35
apply (frule is_file_or_dir, simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    36
apply (auto dest!:current_has_sec'
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
    37
            simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop')
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    38
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    39
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    40
definition sectxt_of_pf :: "t_state \<Rightarrow> t_file \<Rightarrow> security_context_t option"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    41
where
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    42
  "sectxt_of_pf s f = (case f of [] \<Rightarrow> None | (a # pf) \<Rightarrow> sectxt_of_obj s (O_dir pf))"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    43
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    44
definition get_parentfs_ctxts' :: "t_state \<Rightarrow> t_file \<Rightarrow> (security_context_t list) option"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    45
where
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    46
  "get_parentfs_ctxts' s f = (case f of [] \<Rightarrow> None | (a # pf) \<Rightarrow> get_parentfs_ctxts s pf)"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    47
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    48
lemma is_file_has_sfile:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    49
  "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec psec asecs. cf2sfile s f = Some 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    50
      (if (\<not> deleted (O_file f) s \<and> is_init_file f) then Init f else Created,
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    51
       sec, Some psec, set asecs) \<and> (sectxt_of_obj s (O_file f) = Some sec) \<and>
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    52
       (sectxt_of_pf s f = Some psec) \<and> (get_parentfs_ctxts' s f = Some asecs)"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    53
apply (case_tac f, simp, drule root_is_dir', simp, simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    54
apply (frule is_file_in_current)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    55
apply (drule current_file_has_sfile, simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    56
apply (auto simp:cf2sfile_def sectxt_of_pf_def get_parentfs_ctxts'_def split:if_splits option.splits)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    57
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    58
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    59
lemma is_dir_has_sfile:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    60
  "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> (case f of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    61
      [] \<Rightarrow> cf2sfile s f = Some sroot
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    62
    | a # pf \<Rightarrow> (\<exists> sec psec asecs. cf2sfile s f = Some 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    63
      (if (\<not> deleted (O_dir f) s \<and> is_init_dir f) then Init f else Created,
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    64
       sec, Some psec, set asecs) \<and> (sectxt_of_obj s (O_dir f) = Some sec) \<and>
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    65
       (sectxt_of_obj s (O_dir pf) = Some psec) \<and> (get_parentfs_ctxts s pf = Some asecs)))"
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    66
apply (case_tac f, simp add:sroot_only)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    67
apply (frule is_dir_in_current, frule is_dir_not_file)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    68
apply (drule current_file_has_sfile, simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    69
apply (auto simp:cf2sfile_def split:if_splits option.splits)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    70
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    71
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    72
lemma sroot_set:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    73
  "valid s \<Longrightarrow> \<exists> sec. sroot = (Init [], sec, None, {}) \<and> sectxt_of_obj s (O_dir []) = Some sec"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    74
apply (frule root_is_dir)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    75
apply (drule is_dir_has_sec, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    76
apply (auto simp:sroot_def sec_of_root_def sectxt_of_obj_def type_of_obj.simps 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    77
                 root_type_remains root_user_remains
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    78
           dest!:root_has_type' root_has_user' root_has_init_type' root_has_init_user'
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    79
           split:option.splits)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    80
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    81
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    82
lemma cf2sfile_path_file:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    83
  "\<lbrakk>is_file s (f # pf); valid s\<rbrakk>
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    84
   \<Longrightarrow> cf2sfile s (f # pf) = (
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    85
     case (cf2sfile s pf) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    86
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    87
          (case (sectxt_of_obj s (O_file (f # pf))) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    88
              Some fsec \<Rightarrow> Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    89
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    90
           | None \<Rightarrow> None)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    91
     | _ \<Rightarrow> None)"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    92
apply (frule is_file_in_current, drule parentf_is_dir'', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    93
apply (frule is_dir_has_sfile, simp, frule is_file_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    94
apply (frule sroot_set)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    95
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    96
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    97
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    98
lemma cf2sfile_path_dir:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    99
  "\<lbrakk>is_dir s (f # pf); valid s\<rbrakk>
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   100
   \<Longrightarrow> cf2sfile s (f # pf) = (
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   101
     case (cf2sfile s pf) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   102
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   103
          (case (sectxt_of_obj s (O_dir (f # pf))) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   104
              Some fsec \<Rightarrow> Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   105
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   106
           | None \<Rightarrow> None)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   107
     | _ \<Rightarrow> None)"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   108
apply (frule is_dir_in_current, drule parentf_is_dir'', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   109
apply (frule_tac f = "f # pf" in is_dir_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   110
apply (frule_tac f = "pf" in is_dir_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   111
apply (frule sroot_set)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   112
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   113
done  
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   114
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   115
lemma cf2sfile_path:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   116
  "\<lbrakk>f # pf \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = (
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   117
     case (cf2sfile s pf) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   118
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> (if (is_file s (f # pf))
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   119
         then (case (sectxt_of_obj s (O_file (f # pf))) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   120
                 Some fsec \<Rightarrow> Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   121
                                   else Created, fsec, Some pfsec, asecs \<union> {pfsec})
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   122
               | None \<Rightarrow> None)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   123
         else (case (sectxt_of_obj s (O_dir (f # pf))) of
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   124
                 Some fsec \<Rightarrow> Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   125
                                   else Created, fsec, Some pfsec, asecs \<union> {pfsec})
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   126
               | None \<Rightarrow> None)           )
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   127
     | None \<Rightarrow> None)"
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   128
apply (drule is_file_or_dir, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   129
apply (erule disjE)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   130
apply (frule cf2sfile_path_file, simp) defer
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   131
apply (frule cf2sfile_path_dir, simp, drule is_dir_not_file)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   132
apply (auto split:option.splits)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   133
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   134
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   135
lemma cf2sfile_path_file_prop1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   136
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   137
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   138
                 Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   139
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   140
               sectxt_of_obj s (O_file (f # pf)) = Some fsec"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   141
apply (frule is_file_has_sfile, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   142
by (auto simp:cf2sfile_path_file)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   143
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   144
lemma cf2sfile_path_file_prop2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   145
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   146
    sectxt_of_obj s (O_file (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   147
      Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   148
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   149
by (drule cf2sfile_path_file_prop1, auto)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   150
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   151
lemma cf2sfile_path_dir_prop1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   152
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   153
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   154
                 Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   155
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   156
               sectxt_of_obj s (O_dir (f # pf)) = Some fsec"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   157
apply (frule is_dir_has_sfile, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   158
by (auto simp:cf2sfile_path_dir)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   159
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   160
lemma cf2sfile_path_dir_prop2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   161
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   162
    sectxt_of_obj s (O_dir (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   163
      Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   164
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   165
by (drule cf2sfile_path_dir_prop1, auto)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   166
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   167
(**************** cf2sfile event list simpset ****************)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   168
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   169
lemma cf2sfile_open_none':
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   170
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f'= cf2sfile s f'"
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   171
apply (frule vd_cons, frule vt_grant_os)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   172
apply (induct f', simp add:cf2sfile_def)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   173
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   174
               get_parentfs_ctxts_simps)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   175
done
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   176
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   177
lemma cf2sfile_open_none:
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   178
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) = cf2sfile s"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   179
apply (rule ext)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   180
by (simp add:cf2sfile_open_none')
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   181
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   182
lemma cf2sfile_open_some1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   183
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); f' \<in> current_files s\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   184
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   185
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   186
apply (case_tac "f = f'", simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   187
apply (induct f', simp add:sroot_only, simp)
3
chunhan
parents: 1
diff changeset
   188
apply (frule parentf_in_current', simp+)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   189
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   190
               get_parentfs_ctxts_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   191
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   192
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   193
lemma cf2sfile_open_some2:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   195
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   196
apply (frule vd_cons, drule is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   197
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   198
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   199
lemma cf2sfile_open_some3:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   200
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   201
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   202
apply (frule vd_cons, drule is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   203
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   204
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   205
lemma cf2sfile_open_some4:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   206
  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f = (
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   207
     case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   208
       Some pf \<Rightarrow> (case (sectxt_of_obj (Open p f flag fd (Some inum) # s) (O_file f), sectxt_of_obj s (O_dir pf), 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   209
                         get_parentfs_ctxts s pf) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   210
                    (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   211
                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   212
     | None \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   213
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   214
apply (case_tac f, simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   215
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   216
               get_parentfs_ctxts_simps)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   217
apply (rule impI, (erule conjE)+)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   218
apply (drule not_deleted_init_file, simp+)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   219
apply (simp add:is_file_in_current)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   220
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   221
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   222
lemma cf2sfile_open:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   223
  "\<lbrakk>valid (Open p f flag fd opt # s); f' \<in> current_files (Open p f flag fd opt # s)\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   224
   \<Longrightarrow> cf2sfile (Open p f flag fd opt # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   225
     if (opt = None) then cf2sfile s f'
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   226
     else if (f' = f) 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   227
     then (case (parent f) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   228
             Some pf \<Rightarrow> (case (sectxt_of_obj (Open p f flag fd opt # s) (O_file f), sectxt_of_obj s (O_dir pf), 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   229
                 get_parentfs_ctxts s pf) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   230
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   231
                        | _ \<Rightarrow> None)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   232
           | None \<Rightarrow> None)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   233
     else cf2sfile s f')"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   234
apply (case_tac opt)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   235
apply (simp add:cf2sfile_open_none)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   236
apply (case_tac "f = f'")
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   237
apply (simp add:cf2sfile_open_some4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   238
apply (simp add:cf2sfile_open_some1 current_files_simps)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   239
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   240
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   241
lemma cf2sfile_mkdir1:
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   242
  "\<lbrakk>valid (Mkdir p f i # s); f' \<in> current_files s\<rbrakk>
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   243
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   244
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   245
apply (case_tac "f = f'", simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   246
apply (induct f', simp add:sroot_only, simp)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   247
apply (frule parentf_in_current', simp+)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   248
apply (case_tac "f = f'", simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   249
apply (simp add:cf2sfile_path is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   250
               get_parentfs_ctxts_simps split:if_splits option.splits)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   251
done
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   252
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   253
lemma cf2sfile_mkdir2:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   254
  "\<lbrakk>valid (Mkdir p f i # s); is_file s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   255
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   256
apply (frule vd_cons, drule is_file_in_current)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   257
by (simp add:cf2sfile_mkdir1)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   258
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   259
lemma cf2sfile_mkdir3:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   260
  "\<lbrakk>valid (Mkdir p f i # s); is_dir s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   261
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   262
apply (frule vd_cons, drule is_dir_in_current)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   263
by (simp add:cf2sfile_mkdir1)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   264
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   265
lemma cf2sfile_mkdir4:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   266
  "valid (Mkdir p f i # s)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   267
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f = (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   268
         Some pf \<Rightarrow> (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   269
                           get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   270
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   271
                    | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   272
       | None \<Rightarrow> None)"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   273
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   274
apply (case_tac f, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   275
apply (clarsimp simp:os_grant.simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   276
apply (simp add:sectxt_of_obj_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   277
apply (frule current_proc_has_sec, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   278
apply (frule is_dir_has_sec, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   279
apply (frule get_pfs_secs_prop, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   280
apply (frule is_dir_not_file)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   281
apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   282
               get_parentfs_ctxts_simps split:option.splits if_splits 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   283
            dest:not_deleted_init_dir is_dir_in_current not_deleted_init_file is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   284
done
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   285
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   286
lemma cf2sfile_mkdir:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   287
  "\<lbrakk>valid (Mkdir p f i # s); f' \<in> current_files (Mkdir p f i # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   288
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   289
    if (f' = f) 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   290
    then (case (parent f) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   291
             Some pf \<Rightarrow> (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), 
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   292
                 get_parentfs_ctxts s pf) of
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   293
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   294
                        | _ \<Rightarrow> None)
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   295
           | None \<Rightarrow> None)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   296
     else cf2sfile s f')"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   297
apply (case_tac "f = f'")
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   298
apply (simp add:cf2sfile_mkdir4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   299
apply (simp add:cf2sfile_mkdir1 current_files_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   300
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   301
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   302
lemma cf2sfile_linkhard1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   303
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   304
   \<Longrightarrow> cf2sfile (LinkHard p oldf f# s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   305
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   306
apply (case_tac "f = f'", simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   307
apply (induct f', simp add:sroot_only, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   308
apply (frule parentf_in_current', simp+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   309
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   310
               get_parentfs_ctxts_simps split:if_splits option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   311
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   312
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   313
lemma cf2sfile_linkhard2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   314
  "\<lbrakk>valid (LinkHard p oldf f # s); is_file s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   315
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   316
apply (frule vd_cons, drule is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   317
by (simp add:cf2sfile_linkhard1)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   318
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   319
lemma cf2sfile_linkhard3:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   320
  "\<lbrakk>valid (LinkHard p oldf f # s); is_dir s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   321
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   322
apply (frule vd_cons, drule is_dir_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   323
by (simp add:cf2sfile_linkhard1)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   324
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   325
lemma cf2sfile_linkhard4:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   326
  "valid (LinkHard p oldf f # s)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   327
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f = (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   328
         Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   329
                           get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   330
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   331
                    | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   332
       | None \<Rightarrow> None)"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   333
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   334
apply (case_tac f, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   335
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   336
               get_parentfs_ctxts_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   337
apply (rule impI, (erule conjE)+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   338
apply (drule not_deleted_init_file, simp+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   339
apply (simp add:is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   340
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   341
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   342
lemma cf2sfile_linkhard:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   343
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files (LinkHard p oldf f # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   344
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   345
    if (f' = f) 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   346
    then (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   347
             Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   348
                 get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   349
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   350
                        | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   351
           | None \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   352
     else cf2sfile s f')"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   353
apply (case_tac "f = f'")
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   354
apply (simp add:cf2sfile_linkhard4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   355
apply (simp add:cf2sfile_linkhard1 current_files_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   356
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   357
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   358
lemma cf2sfile_other:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   359
  "\<lbrakk>ff \<in> current_files s;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   360
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   361
    \<forall> p fd. e \<noteq> CloseFd p fd;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   362
    \<forall> p f. e \<noteq> UnLink p f;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   363
    \<forall> p f. e \<noteq> Rmdir p f;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   364
    \<forall> p f i. e \<noteq> Mkdir p f i;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   365
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   366
    valid (e # s)\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   367
apply (frule vd_cons, frule vt_grant_os)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   368
apply (induct ff, simp add:sroot_only)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   369
apply (frule parentf_in_current', simp+, case_tac e)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   370
apply (auto simp:current_files_simps is_file_simps is_dir_simps sectxt_of_obj_simps cf2sfile_path 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   371
           split:if_splits option.splits)                     
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   372
done     
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   373
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   374
lemma cf2sfile_other':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   375
  "\<lbrakk>valid (e # s); 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   376
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   377
    \<forall> p fd. e \<noteq> CloseFd p fd;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   378
    \<forall> p f. e \<noteq> UnLink p f;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   379
    \<forall> p f. e \<noteq> Rmdir p f;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   380
    \<forall> p f i. e \<noteq> Mkdir p f i;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   381
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   382
    ff \<in> current_files s\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   383
by (auto intro!:cf2sfile_other)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   384
  
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   385
lemma cf2sfile_unlink:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   386
  "\<lbrakk>valid (UnLink p f # s); f' \<in> current_files (UnLink p f # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   387
   \<Longrightarrow> cf2sfile (UnLink p f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   388
apply (frule vd_cons, frule vt_grant_os)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   389
apply (simp add:current_files_simps split:if_splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   390
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   391
           split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   392
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   393
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   394
lemma cf2sfile_rmdir:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   395
  "\<lbrakk>valid (Rmdir p f # s); f' \<in> current_files (Rmdir p f # s)\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   396
   \<Longrightarrow> cf2sfile (Rmdir p f # s) f' = cf2sfile s f'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   397
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   398
apply (simp add:current_files_simps split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   399
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   400
           split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   401
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   402
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   403
lemma pfdof_simp5: "\<lbrakk>proc_fd_of_file s f = {(p, fd)}; file_of_proc_fd s p fd = None\<rbrakk> \<Longrightarrow> False"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   404
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   405
by (simp add:pfdof_simp2, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   406
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   407
lemma pfdof_simp6: "proc_fd_of_file s f = {(p, fd)} \<Longrightarrow> file_of_proc_fd s p fd = Some f"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   408
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   409
by (simp add:pfdof_simp2, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   410
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   411
lemma cf2sfile_closefd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   412
  "\<lbrakk>valid (CloseFd p fd # s); f \<in> current_files (CloseFd p fd # s)\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   413
   \<Longrightarrow> cf2sfile (CloseFd p fd # s) f = cf2sfile s f"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   414
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   415
apply (simp add:current_files_simps split:if_splits option.splits) 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   416
(* costs too much time, but solved
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   417
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   418
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   419
           split:if_splits option.splits  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   420
            dest:init_file_dir_conflict pfdof_simp5 pfdof_simp6 file_of_pfd_is_file
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   421
                 not_deleted_init_file not_deleted_init_dir is_file_not_dir is_dir_not_file
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   422
            dest!:current_has_sec')
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   423
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   424
*)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   425
sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   427
lemmas cf2sfile_simps = cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_other
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   428
  cf2sfile_unlink cf2sfile_rmdir cf2sfile_closefd
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   429
  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   430
(*********** cfd2sfd simpset *********)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   431
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   432
lemma cfd2sfd_open1:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   433
  "valid (Open p f flags fd opt # s)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   434
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p fd = 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   435
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   436
        (Some sec, Some sf) \<Rightarrow> Some (sec, flags, sf)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   437
      | _ \<Rightarrow> None)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   438
by (simp add:cfd2sfd_def sectxt_of_obj_simps split:if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   440
lemma cfd2sfd_open_some2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   441
  "\<lbrakk>valid (Open p f flags fd (Some inum) # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   442
  \<Longrightarrow> cfd2sfd (Open p f flags fd (Some inum) # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   443
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   444
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   445
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   446
apply (case_tac "f = f'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   447
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_some1)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   448
apply (case_tac "p = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   449
apply (rule conjI, rule impI, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   450
apply (drule cf2sfile_open_some1, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   451
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   452
apply simp
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   453
apply (drule cf2sfile_open_some1, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   454
apply (auto split:option.splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   457
lemma cfd2sfd_open_none2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   458
  "\<lbrakk>valid (Open p f flags fd None # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   459
  \<Longrightarrow> cfd2sfd (Open p f flags fd None # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   460
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   461
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   462
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   463
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   464
apply (case_tac "p = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   465
apply (rule conjI, rule impI, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   466
apply (drule cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   467
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   468
apply simp
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   469
apply (drule cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   470
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   471
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   472
  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   473
lemma cfd2sfd_open2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   474
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   475
  \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   476
apply (case_tac opt)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   477
apply (simp add:cfd2sfd_open_none2)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   478
apply (simp add:cfd2sfd_open_some2)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   479
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   481
lemma cfd2sfd_open:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   482
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd (Open p f flags fd opt # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   483
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = (if (p' = p \<and> fd' = fd) then 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   484
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   485
        (Some sec, Some sf) \<Rightarrow> Some (sec, flags, sf)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   486
      | _ \<Rightarrow> None)         else cfd2sfd s p' fd')"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   487
apply (simp split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   488
apply (simp add:cfd2sfd_open1 split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   489
apply (simp add:cfd2sfd_open2)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   490
apply (rule impI, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   493
lemma cfd2sfd_closefd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   494
  "\<lbrakk>valid (CloseFd p fd # s); file_of_proc_fd (CloseFd p fd # s) p' fd' = Some f\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   495
   \<Longrightarrow> cfd2sfd (CloseFd p fd # s) p' fd' = cfd2sfd  s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   496
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   497
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   498
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   499
apply (frule cf2sfile_closefd, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   500
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   501
apply (auto split:option.splits if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   502
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   504
lemma cfd2sfd_clone:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   505
  "\<lbrakk>valid (Clone p p' fds shms # s); file_of_proc_fd (Clone p p' fds shms # s) p'' fd' = Some f\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   506
   \<Longrightarrow> cfd2sfd (Clone p p' fds shms # s) p'' fd' = (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   507
     if (p'' = p') then cfd2sfd s p fd'
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   508
     else cfd2sfd s p'' fd')"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   509
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   510
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   511
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   512
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   513
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   514
apply (case_tac "p'' = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   515
apply (auto split:option.splits if_splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   516
apply (simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   517
apply (auto split:option.splits if_splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   520
lemma cfd2sfd_execve:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   521
  "\<lbrakk>valid (Execve p f fds # s); file_of_proc_fd (Execve p f fds # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   522
   \<Longrightarrow> cfd2sfd (Execve p f fds # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   523
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   524
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   525
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   526
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   527
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   528
apply (case_tac "p' = p", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   529
apply (auto split:option.splits if_splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   530
apply (simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   531
apply (auto split:option.splits if_splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   534
lemma cfd2sfd_kill:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   535
  "\<lbrakk>valid (Kill p p'' # s); file_of_proc_fd (Kill p p'' # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   536
   \<Longrightarrow> cfd2sfd (Kill p p'' # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   537
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   538
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   539
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   540
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   541
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   542
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   543
apply (auto split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   546
lemma cfd2sfd_exit:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   547
  "\<lbrakk>valid (Exit p # s); file_of_proc_fd (Exit p # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   548
   \<Longrightarrow> cfd2sfd (Exit p # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   549
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   550
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   551
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   552
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   553
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   554
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   555
apply (auto split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   558
lemma cfd2sfd_other:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   559
  "\<lbrakk>valid (e # s); file_of_proc_fd (e # s) p' fd' = Some f';
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   560
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   561
    \<forall> p p'' fds shms. e \<noteq> Clone p p'' fds shms\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   562
   \<Longrightarrow> cfd2sfd (e # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   563
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   564
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   565
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   566
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   567
apply (case_tac e)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   568
apply (auto intro!:cfd2sfd_execve cfd2sfd_closefd cfd2sfd_kill cfd2sfd_exit)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   569
apply (auto simp:cfd2sfd_def sectxt_of_obj_simps current_files_simps cf2sfile_simps split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   570
apply (auto dest!:current_has_sec' dest:file_of_proc_fd_in_curf proc_fd_in_fds)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   571
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   572
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   573
lemmas cfd2sfd_simps = cfd2sfd_open cfd2sfd_clone cfd2sfd_other
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   574
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   575
(********** cpfd2sfds simpset **********)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   576
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   577
lemma current_filefd_has_flags:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   578
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists> flags. flags_of_proc_fd s p fd = Some flags"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   579
apply (induct s arbitrary:p)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   580
apply (simp only:flags_of_proc_fd.simps file_of_proc_fd.simps init_filefd_prop4)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   581
apply (frule vd_cons, frule vt_grant_os, case_tac a)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   582
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   583
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   584
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   585
lemma current_filefd_has_flags':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   586
  "\<lbrakk>flags_of_proc_fd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   587
apply (case_tac "file_of_proc_fd s p fd")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   588
apply (simp, drule current_filefd_has_flags, simp+)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   590
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   591
lemma current_file_has_sfile':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   592
  "\<lbrakk>cf2sfile s f = None; valid s\<rbrakk> \<Longrightarrow> f \<notin> current_files s"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   593
by (rule notI, drule current_file_has_sfile, simp+)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   595
lemma current_filefd_has_sfd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   596
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists>sfd. cfd2sfd s p fd = Some sfd"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   597
by (auto simp:cfd2sfd_def split:option.splits dest!:current_has_sec' current_file_has_sfile' 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   598
         dest:file_of_proc_fd_in_curf proc_fd_in_fds current_filefd_has_flags)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   599
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   600
lemma current_filefd_has_sfd':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   601
  "\<lbrakk>cfd2sfd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   602
by (case_tac "file_of_proc_fd s p fd", auto dest:current_filefd_has_sfd)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   604
definition cpfd2sfds' :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sfd set"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   605
where
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   606
  "cpfd2sfds' s p \<equiv> {sfd. \<exists> fd f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd}"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   608
definition cph2spshs' :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc_sshm set"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   609
where
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   610
  "cph2spshs' s p \<equiv> {(sh, flag). \<exists> h. (p, flag) \<in> procs_of_shm s h \<and> ch2sshm s h = Some sh}"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   611
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   612
lemma "x \<in> cph2spshs' s p \<Longrightarrow> False"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   613
apply (simp add:cph2spshs'_def)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   614
apply (case_tac x, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   617
lemma cpfd2sfds_open_some1:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   618
  "valid (Open p f flags fd (Some inum) # s) \<Longrightarrow>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   619
   cpfd2sfds (Open p f flags fd (Some inum) # s) p = (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   620
    case (cfd2sfd (Open p f flags fd (Some inum) # s) p fd) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   621
        Some sfd \<Rightarrow> (cpfd2sfds s p) \<union> {sfd}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   622
      | _ \<Rightarrow> cpfd2sfds s p)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   623
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   624
apply (split option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   625
apply (rule conjI, rule impI, drule current_filefd_has_sfd', simp, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   626
apply (rule allI, rule impI)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   627
apply (rule set_eqI, rule iffI)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   628
unfolding cpfd2sfds_def
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   629
thm CollectE
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   630
apply (erule CollectE)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   631
apply (erule CollectE, (erule conjE|erule exE)+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   632
apply (simp only:file_of_proc_fd.simps split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   633
apply (simp add:cpfd2sfds_def)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   635
apply (auto simp:cpfd2sfds_def split:option.splits if_splits dest:file_of_proc_fd_in_curf proc_fd_in_fds proc_fd_in_procs)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   637
lemma cpfd2sfds_open1:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   638
  "valid (Open p f flags fd opt # s) \<Longrightarrow>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   639
   cpfd2sfds (Open p f flags fd opt # s) p = (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   640
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   641
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, flags, sf)}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   642
      | _ \<Rightarrow> cpfd2sfds s p)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   643
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   644
apply (case_tac opt)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   645
apply (auto simp:sectxt_of_obj_simps current_files_simps dest!:current_has_sec' current_file_has_sfile'
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   646
  split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   647
apply (auto simp:cpfd2sfds_def split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   648
apply (auto simp:cfd2sfd_open cf2sfile_open sectxt_of_obj_simps current_files_simps split:option.splits if_splits dest!:current_has_sec' current_file_has_sfile')
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   649
apply (frule cfd2sfd_open1)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   650
apply (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   651
apply (simp add:cpfd2sfds_def)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   652
apply (auto simp add:cpfd2sfds_def split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   653
apply (auto dest!:current_has_sec')
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   655
lemma cpfd2sfds_open:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   656
  "valid (Open p f flags fd opt # s)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   657
   \<Longrightarrow> cpfd2sfds (Open p f flags fd opt # s) = (cpfd2sfds s) (p := (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   658
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   659
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, flags, sf)}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   660
      | _ \<Rightarrow> cpfd2sfds s p))"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   661
apply (frule cfd2sfd_open1)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   662
apply (rule ext)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   663
apply (simp add:cpfd2sfds_def)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   664
apply (auto simp add:cpfd2sfds_def split:option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   665
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   666
lemma cpfd2sfds_simps = 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   668
(******** cp2sproc simpset *********)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   669
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   670
lemma cp2sproc_nil: "p \<in> init_processes \<Longrightarrow> cp2sproc [] p = SInit p"
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   671
apply (simp add:cp2sproc_def)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   672
by (simp add:cp2sproc_def index_of_proc.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   673
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   674
lemma cp2sproc_nil': "p \<in> current_procs [] \<Longrightarrow> cp2sproc [] p = SInit p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   675
by (simp add:cp2sproc_nil current_procs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   676
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   677
lemma cp2sproc_clone: "cp2sproc (Clone p p' # \<tau>) p'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   678
                         if (p'' = p') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   679
                         else cp2sproc \<tau> p''           )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   680
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   681
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   682
lemma cp2sproc_other: "\<forall> p p'. e \<noteq> Clone p p' \<Longrightarrow> cp2sproc (e # \<tau>) p'' = cp2sproc \<tau> p''"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   683
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   684
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   685
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   686
lemmas cp2sproc_simps = cp2sproc_nil cp2sproc_nil' cp2sproc_clone cp2sproc_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   688
(******************** ch2sshm simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   689
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   690
lemma ch2sshm_nil: "h \<in> init_shms \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   691
by (simp add:ch2sshm_def index_of_shm.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   692
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   693
lemma ch2sshm_nil': "h \<in> current_shms [] \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   694
by (simp add:ch2sshm_nil current_shms.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   695
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   696
lemma ch2sshm_createshm: "ch2sshm (CreateShM p h # \<tau>) h' = (if (h' = h) then SCrea (Suc (length \<tau>)) else ch2sshm \<tau> h')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   697
by (simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   698
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   699
lemma ch2sshm_other: "\<forall> p h. e \<noteq> CreateShM p h \<Longrightarrow> ch2sshm (e # \<tau>) h' = ch2sshm \<tau> h'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   700
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   701
by (auto simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   702
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   703
lemmas ch2sshm_simps = ch2sshm_nil ch2sshm_nil' ch2sshm_createshm ch2sshm_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   704
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   705
(********************* cm2smsg simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   706
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   707
lemma cm2smsg_nil: "m \<in> init_msgs \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   708
by (simp add:cm2smsg_def index_of_msg.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   709
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   710
lemma cm2smsg_nil': "m \<in> current_msgs [] \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   711
by (simp add:cm2smsg_nil current_msgs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   712
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   713
lemma cm2smsg_createmsg: "cm2smsg (CreateMsg p m # \<tau>) m' = (if (m' = m) then SCrea (Suc (length \<tau>)) else cm2smsg \<tau> m')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   714
by (simp add:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   715
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   716
lemma cm2smsg_other: "\<forall> p m. e \<noteq> CreateMsg p m \<Longrightarrow> cm2smsg (e # \<tau>) m' = cm2smsg \<tau> m'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   717
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   718
by (auto simp:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   719
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   720
lemmas cm2smsg_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   721
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   722
(********************** cfd2fd_s simpset ******************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   723
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   724
lemma cfd2fd_s_nil: "fd \<in> init_fds_of_proc p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   725
by (simp add:cfd2fd_s_def index_of_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   726
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   727
lemma cfd2fd_s_nil': "fd \<in> current_proc_fds [] p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   728
by (simp add:cfd2fd_s_nil current_proc_fds.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   729
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   730
lemma cfd2fd_s_open: "cfd2fd_s (Open p f flags fd opt # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   731
                        if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   732
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   733
                        else cfd2fd_s \<tau> p' fd'                      )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   734
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   735
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   736
lemma cfd2fd_s_createsock: "cfd2fd_s (CreateSock p af st fd im # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   737
                              if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   738
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   739
                              else cfd2fd_s \<tau> p' fd'                         )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   740
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   741
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   742
lemma cfd2fd_s_accept: "cfd2fd_s (Accept p fd addr port fd' im # \<tau>) p' fd'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   743
                          if (p' = p) then (if (fd'' = fd') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   744
                                            else cfd2fd_s \<tau> p' fd'')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   745
                          else cfd2fd_s \<tau> p' fd''                             )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   746
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   747
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   748
lemma cfd2fd_s_clone: "cfd2fd_s (Clone p p' # \<tau>) p'' fd = (if (p'' = p') then cfd2fd_s \<tau> p fd else cfd2fd_s \<tau> p'' fd)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   749
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   750
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   751
lemma cfd2fd_s_other: "\<lbrakk>\<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   752
                        \<forall> p af st fd im. e \<noteq> CreateSock p af st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   753
                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   754
                        \<forall> p p'. e \<noteq> Clone p p'\<rbrakk> \<Longrightarrow> cfd2fd_s (e # \<tau>) p'' fd'' = cfd2fd_s \<tau> p'' fd''"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   755
by (case_tac e, auto simp:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   756
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   757
lemmas cfd2fd_s_simps = cfd2fd_s_nil cfd2fd_s_nil' cfd2fd_s_open cfd2fd_s_createsock cfd2fd_s_accept cfd2fd_s_clone cfd2fd_s_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   758
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   759
(************* cim2im_s simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   760
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   761
(* no such lemma
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   762
lemma cim2im_s_nil: "init_itag_of_inum im = Some tag \<Longrightarrow> cim2im_s [] im = SInit im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   763
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   764
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   765
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   766
lemma cim2im_s_open: "cim2im_s (Open p f flags fd (Some im) # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   767
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   768
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   769
lemma cim2im_s_open': "cim2im_s (Open p f flags fd None # \<tau>) im = cim2im_s \<tau> im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   770
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   771
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   772
lemma cim2im_s_mkdir: "cim2im_s (Mkdir p f im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   773
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   774
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   775
lemma cim2im_s_createsock: "cim2im_s (CreateSock p sf st fd im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   776
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   777
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   778
lemma cim2im_s_accept: "cim2im_s (Accept p fd addr port fd' im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   779
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   780
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   781
lemma cim2im_s_other: "\<lbrakk>\<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   782
                        \<forall> p f im. e \<noteq> Mkdir p f im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   783
                        \<forall> p sf st fd im. e \<noteq> CreateSock p sf st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   784
                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im\<rbrakk> \<Longrightarrow> cim2im_s (e # \<tau>) im = cim2im_s \<tau> im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   785
by (case_tac e, auto simp:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   786
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   787
lemmas cim2im_s_simps = cim2im_s_open cim2im_s_open' cim2im_s_mkdir cim2im_s_createsock cim2im_s_accept cim2im_s_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   788
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   789
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   790
lemma cig2ig_s_simp: "cig2ig_s (e # \<tau>) tag = cig2ig_s \<tau> tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   791
apply (case_tac tag)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   792
by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   793
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   794
(******************* cobj2sobj no Suc (length \<tau>) ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   795
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   796
lemma cf2sfile_le_len: "\<lbrakk>cf2sfile \<tau> f = SCrea (Suc (length \<tau>)) # spf; f \<in> current_files \<tau>; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   797
apply (case_tac f, (simp add:cf2sfile.simps d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   798
apply (case_tac "index_of_file \<tau> (a # list)", (simp add:d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   799
by (drule index_of_file_le_length', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   800
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   801
lemma cf2sfile_le_len': "\<lbrakk>SCrea (Suc (length \<tau>)) # spf \<preceq> cf2sfile \<tau> f; f \<in> current_files \<tau>; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   802
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   803
apply (simp add:no_junior_def cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   804
apply (case_tac "cf2sfile \<tau> (a # f) = SCrea (Suc (length \<tau>)) # spf") 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   805
apply (drule_tac f = "a # f" in cf2sfile_le_len, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   806
apply (simp only:cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   807
apply (drule_tac no_junior_noteq, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   808
apply (rule impI, erule impE, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   809
apply (drule parentf_in_current', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   810
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   811
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   812
lemma cp2sproc_le_len: "cp2sproc \<tau> p = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   813
apply (simp add:cp2sproc_def, case_tac "index_of_proc \<tau> p")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   814
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   815
by (drule index_of_proc_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   816
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   817
lemma ch2sshm_le_len: "ch2sshm \<tau> h = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   818
apply (simp add:ch2sshm_def, case_tac "index_of_shm \<tau> h")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   819
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   820
by (drule index_of_shm_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   821
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   822
lemma cm2smsg_le_len: "cm2smsg \<tau> m = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   823
apply (simp add:cm2smsg_def, case_tac "index_of_msg \<tau> m")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   824
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   825
by (drule index_of_msg_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   826
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   827
lemma cim2im_s_le_len: "cim2im_s \<tau> im = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   828
apply (simp add:cim2im_s_def, case_tac "inum2ind \<tau> im")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   829
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   830
by (drule inum2ind_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   831
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   832
lemma cfd2fd_s_le_len: "cfd2fd_s \<tau> p fd = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   833
apply (simp add:cfd2fd_s_def, case_tac "index_of_fd \<tau> p fd")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   834
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   835
by (drule index_of_fd_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   836
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   837
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   838
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   839
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   840
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   841
(*>*)