Co2sobj_prop.thy
author chunhan
Thu, 16 May 2013 15:18:44 +0800
changeset 8 289a30c4cfb7
parent 7 f27882976251
child 10 ac66d8ba86d9
permissions -rw-r--r--
find bugs in deleted & inum_of_file
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
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
     3
imports Main Flask Flask_type Static Static_type Sectxt_prop Init_prop Current_files_prop Current_sockets_prop Delete_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
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   374
lemma cf2sfile_unlink:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   375
  "\<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
   376
   \<Longrightarrow> cf2sfile (UnLink p f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   377
apply (frule vd_cons, frule vt_grant_os)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   378
apply (simp add:current_files_simps split:if_splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   379
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   380
 split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   381
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   382
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   383
lemmas cf2sfile_simps = cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_other
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   384
  
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
   385
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
   386
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   387
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   388
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   389
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   390
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   391
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   392
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   393
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   394
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   395
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   396
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   397
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   398
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   399
lemma cf2sfile_keep_path: "\<lbrakk>f \<preceq> f'; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   400
apply (induct f', simp add:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   401
apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   402
apply (drule no_junior_noteq, simp, simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   403
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   404
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   405
lemma ckp'_aux: "\<not> f \<preceq> a # f' \<Longrightarrow> \<not> f \<preceq> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   406
by (auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   407
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   408
lemma cf2sfile_keep_path': "\<lbrakk>\<not> f \<preceq> f'; \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; f' \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> \<not> cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   409
apply (induct f', simp add:no_junior_def cf2sfile.simps, rule notI, drule cf2sfile_root_file, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   410
apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   411
apply (rule notI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   412
apply (frule ckp'_aux, simp, frule parentf_in_current', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   413
apply (case_tac "cf2sfile \<tau> f = cf2sfile \<tau> (a # f')", drule cf2sfile_inj, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   414
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   415
by (drule no_junior_noteq, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   416
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   417
lemma cf2sfile_keep_path'': "\<lbrakk>cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'; \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; f' \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> f \<preceq> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   418
using cf2sfile_keep_path'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   419
by (auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   420
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   421
lemma cf2sfile_open_some': "\<lbrakk>f \<in> current_files \<tau>; Open p f' flags fd (Some inum) # \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> cf2sfile (Open p f' flags fd (Some inum) # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   422
apply (frule vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   423
apply (drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   424
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   425
apply (simp add:cf2sfile.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   427
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   429
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   430
lemma cf2sfile_open_some: "\<lbrakk>Open p f flags fd (Some inum) # \<tau> \<in> vt rc_cs; parent f = Some pf\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   431
                           \<Longrightarrow> cf2sfile (Open p f flags fd (Some inum) # \<tau>) f = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
apply (case_tac f, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   433
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   434
apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_open_some')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   435
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   436
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   437
lemma cf2sfile_open_none: "cf2sfile (Open p f flags fd None # \<tau>) f' = cf2sfile \<tau> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   438
apply (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
by (simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
lemma cf2sfile_open: "\<lbrakk>Open p f flags fd opt # \<tau> \<in> vt rc_cs; f' \<in> current_files (Open p f flags fd opt # \<tau>)\<rbrakk> \<Longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
                       cf2sfile (Open p f flags fd opt # \<tau>) f' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   443
                         if (opt = None) then cf2sfile \<tau> f'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   444
                         else if (f' = f) then (case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   445
                                                  Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
                                                | _       \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   447
                              else cf2sfile \<tau> f'                                                          )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   449
by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_open_none cf2sfile_open_some cf2sfile_open_some' split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   450
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   451
lemma cf2sfile_mkdir_some': "\<lbrakk>Mkdir p f' inum # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> cf2sfile (Mkdir p f' inum # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   452
apply (frule vt_cons', drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
apply (induct f, (simp add:cf2sfile.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   454
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   457
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   458
lemma cf2sfile_mkdir_some: "\<lbrakk>Mkdir p f inum # \<tau> \<in> vt rc_cs; parent f = Some pf\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
                             \<Longrightarrow> cf2sfile (Mkdir p f inum # \<tau>) f = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
apply (case_tac f, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   461
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_mkdir_some')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   464
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   465
lemma cf2sfile_mkdir: "\<lbrakk>Mkdir p f inum # \<tau> \<in> vt rc_cs; f' \<in> current_files (Mkdir p f inum # \<tau>)\<rbrakk> \<Longrightarrow>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
                        cf2sfile (Mkdir p f inum # \<tau>) f' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   467
                          if (f' = f) then (case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
                                              Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
                                            | _       \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
                          else cf2sfile \<tau> f'               ) "
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   471
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   472
by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_mkdir_some cf2sfile_mkdir_some' split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   474
lemma cf2sfile_linkhard_none: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   475
apply (frule vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
apply (drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   478
apply (simp add:cf2sfile.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   479
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   482
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   483
lemma cf2sfile_linkhard_some: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
  "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; parent f\<^isub>2 = Some pf\<^isub>2\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f\<^isub>2 = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>2))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
apply (case_tac f\<^isub>2, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_linkhard_none)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   488
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   489
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   490
lemma cf2sfile_linkhard: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; f \<in> current_files (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>)\<rbrakk> \<Longrightarrow>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
                           cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
                             if (f = f\<^isub>2) then (case (parent f\<^isub>2) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
                                                 Some pf\<^isub>2 \<Rightarrow> SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>2)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
                                               | _        \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
                             else cf2sfile \<tau> f                 )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_linkhard_none cf2sfile_linkhard_some split:if_splits option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   498
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
lemma no_junior_aux: "\<not> f\<^isub>2 \<preceq> a # f \<Longrightarrow> \<not> f\<^isub>2 \<preceq> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
by (auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
lemma cf2sfile_rename_aux: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> f \<noteq> f\<^isub>3 \<and> \<not> f\<^isub>3 \<preceq> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   504
apply (frule vt_grant_os, simp add:os_grant.simps, (erule exE|erule conjE)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
apply (rule conjI, rule notI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   506
apply (rule notI, drule vt_cons', simp add:ancenf_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   507
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
lemma cf2sfile_rename'1: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   510
  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; \<not> (f\<^isub>2 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   511
apply (frule vt_cons',frule vt_grant_os,  induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   513
apply (frule parentf_in_current', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
apply (frule no_junior_aux, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   515
apply (simp add:os_grant.simps, (erule exE|erule conjE)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
apply (drule cf2sfile_rename_aux, simp, erule conjE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   517
apply (auto simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   520
lemma cf2sfile_rename'2: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; \<not> (f\<^isub>3 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   522
apply (frule vt_cons', induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   523
by (auto simp add:index_of_file.simps cf2sfile.simps no_junior_def split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   525
lemma cf2sfile_rename1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f\<^isub>3 = SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   527
apply (case_tac f\<^isub>3, simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
apply (auto dest!:cf2sfile_rename'2 simp add:no_junior_def cf2sfile.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
lemma index_of_file_rename1: "\<lbrakk>f\<^isub>2 \<preceq> f; f \<noteq> f\<^isub>2\<rbrakk> \<Longrightarrow> index_of_file (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = index_of_file \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
apply (clarsimp simp add:index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
by (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop3, simp, erule conjE, simp add:file_renaming_prop5)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
lemma cf2sfile_rename2: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; (file_before_rename f\<^isub>2 f\<^isub>3 f) \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>3 \<preceq> f\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   536
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   537
apply (induct f, simp add:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   538
apply (case_tac "a # f = f\<^isub>3", simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
apply (drule cf2sfile_rename1, simp, simp add:file_renaming_prop0' file_renaming_prop0)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   540
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
apply (frule no_junior_noteq, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   542
apply (frule_tac file_renaming_prop1')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
apply (frule_tac f = f\<^isub>2 and \<tau> = \<tau> in cf2sfile_keep_path, simp add:vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop8')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop6')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
apply (frule_tac f = "file_before_rename f\<^isub>2 f\<^isub>3 (a # f)" and \<tau> = \<tau> and f\<^isub>2 = f\<^isub>2 and f\<^isub>3 = f\<^isub>3 and p = p in index_of_file_rename1, simp add:file_before_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
apply (drule_tac f\<^isub>3 = f\<^isub>3 and f\<^isub>1 = f and a = a and f\<^isub>2 = f\<^isub>2 in file_renaming_prop9', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   548
apply (drule parentf_in_current', simp add:vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
apply (erule file_renaming_prop6[THEN sym])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   552
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   553
lemma cf2sfile_rename2': "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>2 \<preceq> f\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop5)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
apply (drule_tac f = "file_after_rename f\<^isub>2 f\<^isub>3 f" in cf2sfile_rename2, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
lemma cf2sfile_rename3: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   561
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
apply (case_tac "f\<^isub>2 \<preceq> f")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
apply (rule cf2sfile_rename2', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
apply (frule_tac \<tau> = \<tau> in cf2sfile_keep_path', simp add:vt_cons', simp add:os_grant.simps, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
by (rule cf2sfile_rename'1, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   569
lemma cf2sfile_rename: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files (Rename p f\<^isub>2 f\<^isub>3 # \<tau>)\<rbrakk> \<Longrightarrow>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
                         cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
                           if (f\<^isub>3 \<preceq> f) then (case (parent f\<^isub>3) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   572
                                               Some pf\<^isub>3 \<Rightarrow> file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
                                             | _        \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
                           else cf2sfile \<tau> f               )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   575
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
apply (case_tac "f = f\<^isub>3", clarsimp simp:os_grant.simps, drule cf2sfile_rename1, simp+, simp add:file_renaming_prop0' file_renaming_prop0)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   578
apply (auto simp:os_grant.simps current_files_simps intro:cf2sfile_rename'2 cf2sfile_rename1 split:if_splits option.splits) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
apply (rule cf2sfile_rename2, simp, drule rename_renaming_decom, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
apply (drule_tac f\<^isub>2 = f\<^isub>2 and f\<^isub>1 = f\<^isub>1 and f\<^isub>3 = f\<^isub>3 in file_renaming_prop5, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   581
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
lemma cf2sfile_other: "\<lbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
                        \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   585
                        \<forall> p f im. e \<noteq> Mkdir p f im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   586
                        \<forall> p f\<^isub>1 f\<^isub>2. e \<noteq> LinkHard p f\<^isub>1 f\<^isub>2;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   587
                        \<forall> p f\<^isub>2 f\<^isub>3. e \<noteq> Rename p f\<^isub>2 f\<^isub>3\<rbrakk> \<Longrightarrow> cf2sfile (e # \<tau>) f' = cf2sfile \<tau> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   588
apply (induct f', simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
apply (case_tac e, auto simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   590
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
lemmas cf2sfile_nil = init_cf2sfile
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   593
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
lemma cf2sfile_nil': "f \<in> current_files [] \<Longrightarrow> cf2sfile [] f = map SInit f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
by (simp add:cf2sfile_nil current_files_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
lemmas cf2sfile_simps = cf2sfile_nil cf2sfile_nil' cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   599
lemmas cf2sfile_simpss = cf2sfile_nil cf2sfile_nil' cf2sfile_open_some' cf2sfile_open_some cf2sfile_open_none cf2sfile_open cf2sfile_mkdir_some' cf2sfile_mkdir_some
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
                         cf2sfile_mkdir cf2sfile_linkhard_none cf2sfile_linkhard_some cf2sfile_linkhard cf2sfile_rename'1 cf2sfile_rename'2 cf2sfile_rename1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
                         cf2sfile_rename2 cf2sfile_rename2' cf2sfile_rename3 cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   602
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
lemma cf2sfile_open_some'_inum: "\<lbrakk>Open p f' flags fd (Some inum) # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (Open p f' flags fd (Some inum) # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
by (simp add:cf2sfile_open_some' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   606
lemma cf2sfile_mkdir_some'_inum: "\<lbrakk>Mkdir p f' inum # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (Mkdir p f' inum # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
by (simp add:cf2sfile_mkdir_some' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   608
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   609
lemma cf2sfile_linkhard_none_inum: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   610
by (simp add:cf2sfile_linkhard_none current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   611
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   612
lemma cf2sfile_rename'1_inum: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   613
  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im ; \<not> (f\<^isub>2 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   614
by (simp add:cf2sfile_rename'1 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
lemma cf2sfile_rename2_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f) = Some im; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>3 \<preceq> f\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   617
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   618
by (simp add:cf2sfile_rename2 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   619
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   620
lemma cf2sfile_rename2'_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>2 \<preceq> f\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   621
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   622
by (simp add:cf2sfile_rename2' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   623
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   624
lemma cf2sfile_rename3_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   625
   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   626
by (simp add:cf2sfile_rename3 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   627
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   628
lemma cf2sfile_nil'_inum: "inum_of_file [] f = Some im \<Longrightarrow> cf2sfile [] f = map SInit f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   629
by (simp add:cf2sfile_nil' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   630
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   631
lemmas cf2sfile_simps_inum = cf2sfile_nil cf2sfile_nil'_inum cf2sfile_open_some'_inum cf2sfile_open_some cf2sfile_open_none cf2sfile_open cf2sfile_mkdir_some'_inum cf2sfile_mkdir_some
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   632
                         cf2sfile_mkdir cf2sfile_linkhard_none_inum cf2sfile_linkhard_some cf2sfile_linkhard cf2sfile_rename'1_inum cf2sfile_rename'2 cf2sfile_rename1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   633
                         cf2sfile_rename2_inum cf2sfile_rename2'_inum cf2sfile_rename3_inum cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   635
(*************** cp2sproc simpset *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   637
lemma cp2sproc_nil: "p \<in> init_processes \<Longrightarrow> cp2sproc [] p = SInit p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   638
by (simp add:cp2sproc_def index_of_proc.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   639
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   640
lemma cp2sproc_nil': "p \<in> current_procs [] \<Longrightarrow> cp2sproc [] p = SInit p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   641
by (simp add:cp2sproc_nil current_procs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   642
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   643
lemma cp2sproc_clone: "cp2sproc (Clone p p' # \<tau>) p'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   644
                         if (p'' = p') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   645
                         else cp2sproc \<tau> p''           )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   646
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   647
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   648
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
   649
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   650
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   651
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   652
lemmas cp2sproc_simps = cp2sproc_nil cp2sproc_nil' cp2sproc_clone cp2sproc_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   653
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
(******************** ch2sshm simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   656
lemma ch2sshm_nil: "h \<in> init_shms \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   657
by (simp add:ch2sshm_def index_of_shm.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   658
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   659
lemma ch2sshm_nil': "h \<in> current_shms [] \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   660
by (simp add:ch2sshm_nil current_shms.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   661
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   662
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
   663
by (simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   664
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   665
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
   666
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
by (auto simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   668
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   669
lemmas ch2sshm_simps = ch2sshm_nil ch2sshm_nil' ch2sshm_createshm ch2sshm_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   670
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   671
(********************* cm2smsg simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   672
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   673
lemma cm2smsg_nil: "m \<in> init_msgs \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   674
by (simp add:cm2smsg_def index_of_msg.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   675
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   676
lemma cm2smsg_nil': "m \<in> current_msgs [] \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   677
by (simp add:cm2smsg_nil current_msgs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   678
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   679
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
   680
by (simp add:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   681
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   682
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
   683
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   684
by (auto simp:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   685
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   686
lemmas cm2smsg_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   688
(********************** cfd2fd_s simpset ******************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   689
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   690
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
   691
by (simp add:cfd2fd_s_def index_of_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   692
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   693
lemma cfd2fd_s_nil': "fd \<in> current_proc_fds [] p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   694
by (simp add:cfd2fd_s_nil current_proc_fds.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   695
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   696
lemma cfd2fd_s_open: "cfd2fd_s (Open p f flags fd opt # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   697
                        if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   698
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   699
                        else cfd2fd_s \<tau> p' fd'                      )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   700
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   701
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   702
lemma cfd2fd_s_createsock: "cfd2fd_s (CreateSock p af st fd im # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   703
                              if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   704
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   705
                              else cfd2fd_s \<tau> p' fd'                         )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   706
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   707
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   708
lemma cfd2fd_s_accept: "cfd2fd_s (Accept p fd addr port fd' im # \<tau>) p' fd'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   709
                          if (p' = p) then (if (fd'' = fd') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   710
                                            else cfd2fd_s \<tau> p' fd'')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   711
                          else cfd2fd_s \<tau> p' fd''                             )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   712
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   713
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   714
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
   715
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   716
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   717
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
   718
                        \<forall> p af st fd im. e \<noteq> CreateSock p af st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   719
                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   720
                        \<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
   721
by (case_tac e, auto simp:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   722
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   723
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
   724
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   725
(************* cim2im_s simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   726
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   727
(* no such lemma
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   728
lemma cim2im_s_nil: "init_itag_of_inum im = Some tag \<Longrightarrow> cim2im_s [] im = SInit im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   729
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   730
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   731
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   732
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
   733
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   734
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   735
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
   736
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   737
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   738
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
   739
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   740
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   741
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
   742
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   743
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   744
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
   745
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   746
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   747
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
   748
                        \<forall> p f im. e \<noteq> Mkdir p f im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   749
                        \<forall> p sf st fd im. e \<noteq> CreateSock p sf st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   750
                        \<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
   751
by (case_tac e, auto simp:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   752
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   753
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
   754
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   755
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   756
lemma cig2ig_s_simp: "cig2ig_s (e # \<tau>) tag = cig2ig_s \<tau> tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   757
apply (case_tac tag)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   758
by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   759
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   760
(******************* cobj2sobj no Suc (length \<tau>) ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   761
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   762
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
   763
apply (case_tac f, (simp add:cf2sfile.simps d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   764
apply (case_tac "index_of_file \<tau> (a # list)", (simp add:d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   765
by (drule index_of_file_le_length', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   766
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   767
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
   768
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   769
apply (simp add:no_junior_def cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   770
apply (case_tac "cf2sfile \<tau> (a # f) = SCrea (Suc (length \<tau>)) # spf") 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   771
apply (drule_tac f = "a # f" in cf2sfile_le_len, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   772
apply (simp only:cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   773
apply (drule_tac no_junior_noteq, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   774
apply (rule impI, erule impE, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   775
apply (drule parentf_in_current', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   776
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   777
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   778
lemma cp2sproc_le_len: "cp2sproc \<tau> p = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   779
apply (simp add:cp2sproc_def, case_tac "index_of_proc \<tau> p")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   780
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   781
by (drule index_of_proc_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   782
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   783
lemma ch2sshm_le_len: "ch2sshm \<tau> h = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   784
apply (simp add:ch2sshm_def, case_tac "index_of_shm \<tau> h")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   785
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   786
by (drule index_of_shm_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   787
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   788
lemma cm2smsg_le_len: "cm2smsg \<tau> m = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   789
apply (simp add:cm2smsg_def, case_tac "index_of_msg \<tau> m")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   790
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   791
by (drule index_of_msg_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   792
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   793
lemma cim2im_s_le_len: "cim2im_s \<tau> im = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   794
apply (simp add:cim2im_s_def, case_tac "inum2ind \<tau> im")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   795
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   796
by (drule inum2ind_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   797
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   798
lemma cfd2fd_s_le_len: "cfd2fd_s \<tau> p fd = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   799
apply (simp add:cfd2fd_s_def, case_tac "index_of_fd \<tau> p fd")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   800
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   801
by (drule index_of_fd_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   802
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   803
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   804
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   805
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   806
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   807
(*>*)