Co2sobj_prop.thy
author chunhan
Wed, 15 May 2013 11:21:39 +0800
changeset 6 8779d321cc2e
parent 4 e9c5594d5963
child 7 f27882976251
permissions -rw-r--r--
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
theory 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
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
(************ simpset for cf2sfile ***************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
declare get_parentfs_ctxts.simps [simp del]
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
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
    13
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
    14
  "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
    15
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
    16
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
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
    18
  "\<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
    19
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
    20
         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
    21
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
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
    23
  "\<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
    24
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
    25
         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
    26
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
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
    28
  "\<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
    29
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
    30
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
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
    32
  "\<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
    33
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
    34
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
    35
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
    36
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
    37
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
    38
apply (auto dest!:current_has_sec'
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
            simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop)
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
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
    41
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
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
    43
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
    44
  "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
    45
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
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
    47
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
    48
  "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
    49
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
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
    51
  "\<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
    52
      (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
    53
       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
    54
       (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
    55
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
    56
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
    57
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
    58
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
    59
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
    60
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
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
    62
  "\<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
    63
      [] \<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
    64
    | 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
    65
      (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
    66
       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
    67
       (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
    68
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
    69
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
    70
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
    71
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
    72
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
    73
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
    74
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
    75
  "\<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
    76
     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
    77
       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
    78
         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
    79
                 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
    80
                                   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
    81
               | 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
    82
         else (case (sectxt_of_obj s (O_dir (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
    83
                 Some fsec \<Rightarrow> Some (if (\<not> deleted (O_dir (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
    84
                                   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
    85
               | 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
    86
     | 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
    87
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
    88
apply (frule parentf_in_current', 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
    89
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
    90
apply (frule_tac f = pf in current_file_has_sfile, simp, erule exE)
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
    91
apply (auto dest!:is_file_has_sec' is_dir_has_sec' get_pfs_secs_prop
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
    92
            simp:cf2sfile_def split:option.splits if_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
    93
apply (case_tac "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
    94
apply (frule is_file_has_sec, 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
    95
apply (frule is_dir_has_sec, 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
    96
apply (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
    97
apply (erule exE)+
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
    98
apply (auto split:option.splits)[1]
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
    99
apply 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
   100
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
   101
apply (rule ext)
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
   102
apply (subst (1) 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
   103
apply (auto simp del:deleted.simps get_parentfs_ctxts.simps split:option.splits if_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
   104
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   105
lemma cf2sfile_open_none1:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   106
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f b = cf2sfile s f b"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   107
apply (frule vd_cons, frule vt_grant_os)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   108
apply (frule noroot_events, case_tac f, simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   109
apply (auto split:if_splits option.splits    dest!:current_has_sec' dest:parentf_in_current'
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
          simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
               get_parentfs_ctxts_simps)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   112
done
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   113
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   114
lemma cf2sfile_open_none2:
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   115
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f' b = cf2sfile s f' b"
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   116
apply (frule vd_cons, frule vt_grant_os)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   117
apply (induct f', simp add:cf2sfile_def)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   118
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
   119
               get_parentfs_ctxts_simps)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   120
done
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   121
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   122
lemma cf2sfile_open_none:
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   123
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) = cf2sfile s"
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   124
apply (rule ext, rule ext)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   125
apply (simp add:cf2sfile_open_none1 cf2sfile_open_none2)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   126
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
lemma cf2sfile_open_some1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   129
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); f' \<in> current_files s\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   130
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   131
apply (frule vd_cons, frule vt_grant_os, frule noroot_events, rule ext)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   132
apply (case_tac "f = f'", simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   133
apply (induct f', simp add:sroot_only, simp)
3
chunhan
parents: 1
diff changeset
   134
apply (frule parentf_in_current', simp+)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   135
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
   136
               get_parentfs_ctxts_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   137
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   138
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
lemma cf2sfile_open_some2:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   140
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   141
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' True = cf2sfile s f' True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
apply (frule vd_cons, drule is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   144
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
lemma cf2sfile_open_some3:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   147
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' False = cf2sfile s f' False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
apply (frule vd_cons, drule is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
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
   151
lemma cf2sfile_open_some4:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f True = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   153
     case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   154
       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
   155
                         get_parentfs_ctxts s pf) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   156
                    (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   157
                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   158
     | None \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   159
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   160
apply (case_tac f, simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   161
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
   162
               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
   163
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
   164
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
   165
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
   166
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
   167
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
   168
lemma cf2sfile_open_some5:
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
   169
  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> 
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
   170
   cf2sfile (Open p f flag fd (Some inum) # s) f False = cf2sfile s f False"
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
   171
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
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
   172
apply (case_tac 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
   173
apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
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
   174
               get_parentfs_ctxts_simps split: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
   175
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
   176
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
   177
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
   178
  "\<lbrakk>valid (Open p f flag fd opt # s); f' \<in> current_files (Open p f flag fd opt # 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
   179
   \<Longrightarrow> cf2sfile (Open p f flag fd opt # s) f' b = (
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
   180
     if (opt = None) then cf2sfile s f' b
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
   181
     else if (f' = f \<and> b) 
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
   182
     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
   183
             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
   184
                 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
   185
                          (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
   186
                        | _ \<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
   187
           | 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
   188
     else cf2sfile s f' b)"
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
   189
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
   190
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
   191
apply (case_tac "f = 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
   192
apply (auto simp:cf2sfile_open_some1 cf2sfile_open_some4 cf2sfile_open_some5 current_files_simps)
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
   193
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
   194
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
   195
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
   196
  "\<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
   197
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile 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
   198
apply (frule vd_cons, frule vt_grant_os, frule noroot_events, rule ext)
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
   199
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
   200
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
   201
apply (frule parentf_in_current', 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
   202
apply 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
   203
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
   204
apply (simp (no_asm_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
   205
apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
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
   206
               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
   207
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
   208
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
   209
lemma cf2sfile_mkdir2:
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
   210
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<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
   211
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' True = cf2sfile s f' True"
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
   212
apply (frule vd_cons, drule 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
   213
by (simp add:cf2sfile_open_some1)
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
   214
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
   215
lemma cf2sfile_mkdir3:
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
   216
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<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
   217
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' False = cf2sfile s f' False"
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 (frule vd_cons, drule is_dir_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
   219
by (simp add:cf2sfile_open_some1)
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
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_mkdir:
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
  "valid (Mkdir p f i # s)
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
   224
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) = (\<lambda> f' b. 
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
   225
    if (f' = f \<and> \<not> b) 
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
   226
    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
   227
             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
   228
                 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
   229
                          (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
   230
                        | _ \<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
   231
           | 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
   232
     else cf2sfile s f' b)"
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
   233
apply (frule vd_cons, frule vt_grant_os)
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 (rule ext, rule ext)
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
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 (auto simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
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
   237
               get_parentfs_ctxts_simps  split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   238
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   239
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
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
   241
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
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
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   245
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   246
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
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
   257
apply (induct f', simp add:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
apply (drule no_junior_noteq, simp, simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
lemma ckp'_aux: "\<not> f \<preceq> a # f' \<Longrightarrow> \<not> f \<preceq> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
by (auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
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
   266
apply (induct f', simp add:no_junior_def cf2sfile.simps, rule notI, drule cf2sfile_root_file, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   267
apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   268
apply (rule notI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   269
apply (frule ckp'_aux, simp, frule parentf_in_current', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   270
apply (case_tac "cf2sfile \<tau> f = cf2sfile \<tau> (a # f')", drule cf2sfile_inj, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   271
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   272
by (drule no_junior_noteq, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   273
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   274
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
   275
using cf2sfile_keep_path'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   276
by (auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   278
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
   279
apply (frule vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
apply (drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   281
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
apply (simp add:cf2sfile.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   283
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   284
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   285
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   286
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   287
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
   288
                           \<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
   289
apply (case_tac f, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   290
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   291
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
   292
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   293
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   294
lemma cf2sfile_open_none: "cf2sfile (Open p f flags fd None # \<tau>) f' = cf2sfile \<tau> f'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   295
apply (induct f')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   296
by (simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   297
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   298
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
   299
                       cf2sfile (Open p f flags fd opt # \<tau>) f' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   300
                         if (opt = None) then cf2sfile \<tau> f'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   301
                         else if (f' = f) then (case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   302
                                                  Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   303
                                                | _       \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   304
                              else cf2sfile \<tau> f'                                                          )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   305
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   306
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
   307
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   308
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
   309
apply (frule vt_cons', drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   310
apply (induct f, (simp add:cf2sfile.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   311
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   312
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   313
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   314
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   315
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
   316
                             \<Longrightarrow> cf2sfile (Mkdir p f inum # \<tau>) f = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   317
apply (case_tac f, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   318
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   319
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
   320
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   321
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   322
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
   323
                        cf2sfile (Mkdir p f inum # \<tau>) f' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   324
                          if (f' = f) then (case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   325
                                              Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   326
                                            | _       \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   327
                          else cf2sfile \<tau> f'               ) "
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   328
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   329
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
   330
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   331
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
   332
apply (frule vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   333
apply (drule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   334
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   335
apply (simp add:cf2sfile.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   336
apply (frule parentf_in_current', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   337
apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   338
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   339
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   340
lemma cf2sfile_linkhard_some: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   341
  "\<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
   342
apply (case_tac f\<^isub>2, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   343
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   344
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
   345
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   346
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   347
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
   348
                           cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   349
                             if (f = f\<^isub>2) then (case (parent f\<^isub>2) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   350
                                                 Some pf\<^isub>2 \<Rightarrow> SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>2)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   351
                                               | _        \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   352
                             else cf2sfile \<tau> f                 )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   353
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   354
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
   355
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   356
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   357
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
   358
by (auto simp:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   359
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   360
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
   361
apply (frule vt_grant_os, simp add:os_grant.simps, (erule exE|erule conjE)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   362
apply (rule conjI, rule notI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   363
apply (rule notI, drule vt_cons', simp add:ancenf_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   364
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   365
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   366
lemma cf2sfile_rename'1: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   367
  "\<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
   368
apply (frule vt_cons',frule vt_grant_os,  induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   369
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   370
apply (frule parentf_in_current', simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   371
apply (frule no_junior_aux, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   372
apply (simp add:os_grant.simps, (erule exE|erule conjE)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   373
apply (drule cf2sfile_rename_aux, simp, erule conjE)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   374
apply (auto simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   375
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   376
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   377
lemma cf2sfile_rename'2: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   378
  "\<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
   379
apply (frule vt_cons', induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   380
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
   381
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   382
lemma cf2sfile_rename1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   383
  "\<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
   384
apply (case_tac f\<^isub>3, simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   385
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
   386
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   387
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   388
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
   389
apply (clarsimp simp add:index_of_file.simps split:option.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   390
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
   391
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   392
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
   393
   \<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
   394
apply (induct f, simp add:no_junior_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   395
apply (case_tac "a # f = f\<^isub>3", simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   396
apply (drule cf2sfile_rename1, simp, simp add:file_renaming_prop0' file_renaming_prop0)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   397
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   398
apply (frule no_junior_noteq, simp, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   399
apply (frule_tac file_renaming_prop1')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   400
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
   401
apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop8')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   402
apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop6')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   403
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
   404
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
   405
apply (drule parentf_in_current', simp add:vt_cons')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   406
apply (simp add:cf2sfile.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   407
apply (erule file_renaming_prop6[THEN sym])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   408
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   409
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   410
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
   411
   \<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
   412
apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop5)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   413
apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   414
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
   415
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   416
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   417
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
   418
   \<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
   419
apply (case_tac "f\<^isub>2 \<preceq> f")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   420
apply (rule cf2sfile_rename2', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   421
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   422
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
   423
apply (simp add:file_after_rename_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   424
by (rule cf2sfile_rename'1, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   425
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
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
   427
                         cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
                           if (f\<^isub>3 \<preceq> f) then (case (parent f\<^isub>3) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   429
                                               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
   430
                                             | _        \<Rightarrow> [])
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   431
                           else cf2sfile \<tau> f               )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
apply (frule vt_grant_os)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   433
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
   434
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   435
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
   436
apply (rule cf2sfile_rename2, simp, drule rename_renaming_decom, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   437
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
   438
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
lemma cf2sfile_other: "\<lbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
                        \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
                        \<forall> p f im. e \<noteq> Mkdir p f im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   443
                        \<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
   444
                        \<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
   445
apply (induct f', simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
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
   447
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   449
lemmas cf2sfile_nil = init_cf2sfile
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   450
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   451
lemma cf2sfile_nil': "f \<in> current_files [] \<Longrightarrow> cf2sfile [] f = map SInit f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   452
by (simp add:cf2sfile_nil current_files_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   454
lemmas cf2sfile_simps = cf2sfile_nil cf2sfile_nil' cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
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
   457
                         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
   458
                         cf2sfile_rename2 cf2sfile_rename2' cf2sfile_rename3 cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
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
   461
by (simp add:cf2sfile_open_some' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
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
   464
by (simp add:cf2sfile_mkdir_some' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   465
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
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
   467
by (simp add:cf2sfile_linkhard_none current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
lemma cf2sfile_rename'1_inum: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
  "\<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
   471
by (simp add:cf2sfile_rename'1 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   472
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
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
   474
   \<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
   475
by (simp add:cf2sfile_rename2 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
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
   478
   \<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
   479
by (simp add:cf2sfile_rename2' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
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
   482
   \<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
   483
by (simp add:cf2sfile_rename3 current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
lemma cf2sfile_nil'_inum: "inum_of_file [] f = Some im \<Longrightarrow> cf2sfile [] f = map SInit f"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
by (simp add:cf2sfile_nil' current_files_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   488
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
   489
                         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
   490
                         cf2sfile_rename2_inum cf2sfile_rename2'_inum cf2sfile_rename3_inum cf2sfile_rename cf2sfile_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
(*************** cp2sproc simpset *********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
lemma cp2sproc_nil: "p \<in> init_processes \<Longrightarrow> cp2sproc [] p = SInit p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
by (simp add:cp2sproc_def index_of_proc.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
lemma cp2sproc_nil': "p \<in> current_procs [] \<Longrightarrow> cp2sproc [] p = SInit p"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   498
by (simp add:cp2sproc_nil current_procs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
lemma cp2sproc_clone: "cp2sproc (Clone p p' # \<tau>) p'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
                         if (p'' = p') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
                         else cp2sproc \<tau> p''           )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   504
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
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
   506
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   507
by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
lemmas cp2sproc_simps = cp2sproc_nil cp2sproc_nil' cp2sproc_clone cp2sproc_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   510
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   511
(******************** ch2sshm simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   513
lemma ch2sshm_nil: "h \<in> init_shms \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
by (simp add:ch2sshm_def index_of_shm.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   515
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
lemma ch2sshm_nil': "h \<in> current_shms [] \<Longrightarrow> ch2sshm [] h = SInit h"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   517
by (simp add:ch2sshm_nil current_shms.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
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
   520
by (simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   522
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
   523
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
by (auto simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   525
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
lemmas ch2sshm_simps = ch2sshm_nil ch2sshm_nil' ch2sshm_createshm ch2sshm_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   527
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
(********************* cm2smsg simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
lemma cm2smsg_nil: "m \<in> init_msgs \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
by (simp add:cm2smsg_def index_of_msg.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
lemma cm2smsg_nil': "m \<in> current_msgs [] \<Longrightarrow> cm2smsg [] m = SInit m"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
by (simp add:cm2smsg_nil current_msgs.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   536
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
   537
by (simp add:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   538
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
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
   540
apply (case_tac e)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
by (auto simp:cm2smsg_def index_of_msg.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   542
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
lemmas cm2smsg_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
(********************** cfd2fd_s simpset ******************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
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
   548
by (simp add:cfd2fd_s_def index_of_fd.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
lemma cfd2fd_s_nil': "fd \<in> current_proc_fds [] p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
by (simp add:cfd2fd_s_nil current_proc_fds.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   552
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   553
lemma cfd2fd_s_open: "cfd2fd_s (Open p f flags fd opt # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
                        if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
                        else cfd2fd_s \<tau> p' fd'                      )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
lemma cfd2fd_s_createsock: "cfd2fd_s (CreateSock p af st fd im # \<tau>) p' fd' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
                              if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   561
                                          else cfd2fd_s \<tau> p' fd')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
                              else cfd2fd_s \<tau> p' fd'                         )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
lemma cfd2fd_s_accept: "cfd2fd_s (Accept p fd addr port fd' im # \<tau>) p' fd'' = (
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
                          if (p' = p) then (if (fd'' = fd') then SCrea (Suc (length \<tau>))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
                                            else cfd2fd_s \<tau> p' fd'')
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
                          else cfd2fd_s \<tau> p' fd''                             )"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   569
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
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
   572
by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
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
   575
                        \<forall> p af st fd im. e \<noteq> CreateSock p af st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
                        \<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
   578
by (case_tac e, auto simp:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
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
   581
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
(************* cim2im_s simpset **************************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
(* no such lemma
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   585
lemma cim2im_s_nil: "init_itag_of_inum im = Some tag \<Longrightarrow> cim2im_s [] im = SInit im"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   586
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   587
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   588
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   589
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
   590
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
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
   593
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
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
   596
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
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
   599
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
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
   602
by (simp add:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
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
   605
                        \<forall> p f im. e \<noteq> Mkdir p f im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   606
                        \<forall> p sf st fd im. e \<noteq> CreateSock p sf st fd im;
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
                        \<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
   608
by (case_tac e, auto simp:cim2im_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   609
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   610
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
   611
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   612
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   613
lemma cig2ig_s_simp: "cig2ig_s (e # \<tau>) tag = cig2ig_s \<tau> tag"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   614
apply (case_tac tag)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   617
(******************* cobj2sobj no Suc (length \<tau>) ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   618
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   619
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
   620
apply (case_tac f, (simp add:cf2sfile.simps d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   621
apply (case_tac "index_of_file \<tau> (a # list)", (simp add:d2s_aux.simps)+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   622
by (drule index_of_file_le_length', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   623
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   624
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
   625
apply (induct f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   626
apply (simp add:no_junior_def cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   627
apply (case_tac "cf2sfile \<tau> (a # f) = SCrea (Suc (length \<tau>)) # spf") 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   628
apply (drule_tac f = "a # f" in cf2sfile_le_len, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   629
apply (simp only:cf2sfile.simps d2s_aux.simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   630
apply (drule_tac no_junior_noteq, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   631
apply (rule impI, erule impE, simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   632
apply (drule parentf_in_current', simp+)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   633
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   635
lemma cp2sproc_le_len: "cp2sproc \<tau> p = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
apply (simp add:cp2sproc_def, case_tac "index_of_proc \<tau> p")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   637
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   638
by (drule index_of_proc_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   639
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   640
lemma ch2sshm_le_len: "ch2sshm \<tau> h = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   641
apply (simp add:ch2sshm_def, case_tac "index_of_shm \<tau> h")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   642
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   643
by (drule index_of_shm_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   644
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   645
lemma cm2smsg_le_len: "cm2smsg \<tau> m = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   646
apply (simp add:cm2smsg_def, case_tac "index_of_msg \<tau> m")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   647
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   648
by (drule index_of_msg_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   649
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   650
lemma cim2im_s_le_len: "cim2im_s \<tau> im = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   651
apply (simp add:cim2im_s_def, case_tac "inum2ind \<tau> im")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   652
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   653
by (drule inum2ind_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
lemma cfd2fd_s_le_len: "cfd2fd_s \<tau> p fd = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   656
apply (simp add:cfd2fd_s_def, case_tac "index_of_fd \<tau> p fd")
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   657
apply (simp add:d2s_aux.simps)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   658
by (drule index_of_fd_le_length', simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   659
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   660
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   661
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   662
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   663
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   664
(*>*)