Co2sobj_prop.thy
author chunhan
Tue, 04 Jun 2013 15:37:49 +0800
changeset 17 570f90f175ee
parent 16 c8b7c24f1db6
child 18 9b42765ce554
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
theory Co2sobj_prop
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
     3
imports Main Flask Flask_type Static Static_type Sectxt_prop Init_prop Current_files_prop Current_sockets_prop Delete_prop Proc_fd_of_file_prop
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
context tainting_s begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
     9
(****************** cf2sfile path simpset ***************)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
11
chunhan
parents: 10
diff changeset
    11
thm cpfd2sfds_def
chunhan
parents: 10
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'
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
    39
            simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop')
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
    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
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    74
lemma sroot_set:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    75
  "valid s \<Longrightarrow> \<exists> sec. sroot = (Init [], sec, None, {}) \<and> sectxt_of_obj s (O_dir []) = Some sec"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    76
apply (frule root_is_dir)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    77
apply (drule is_dir_has_sec, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    78
apply (auto simp:sroot_def sec_of_root_def sectxt_of_obj_def type_of_obj.simps 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    79
                 root_type_remains root_user_remains
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    80
           dest!:root_has_type' root_has_user' root_has_init_type' root_has_init_user'
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    81
           split:option.splits)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    82
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    83
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    84
lemma cf2sfile_path_file:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    85
  "\<lbrakk>is_file s (f # pf); valid s\<rbrakk>
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    86
   \<Longrightarrow> cf2sfile s (f # pf) = (
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    87
     case (cf2sfile s pf) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    88
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    89
          (case (sectxt_of_obj s (O_file (f # pf))) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    90
              Some fsec \<Rightarrow> Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    91
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    92
           | None \<Rightarrow> None)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    93
     | _ \<Rightarrow> None)"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    94
apply (frule is_file_in_current, drule parentf_is_dir'', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    95
apply (frule is_dir_has_sfile, simp, frule is_file_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    96
apply (frule sroot_set)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    97
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    98
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
    99
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   100
lemma cf2sfile_path_dir:
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   101
  "\<lbrakk>is_dir s (f # pf); valid s\<rbrakk>
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   102
   \<Longrightarrow> cf2sfile s (f # pf) = (
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   103
     case (cf2sfile s pf) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   104
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   105
          (case (sectxt_of_obj s (O_dir (f # pf))) of
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   106
              Some fsec \<Rightarrow> Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   107
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   108
           | None \<Rightarrow> None)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   109
     | _ \<Rightarrow> None)"
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   110
apply (frule is_dir_in_current, drule parentf_is_dir'', simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   111
apply (frule_tac f = "f # pf" in is_dir_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   112
apply (frule_tac f = "pf" in is_dir_has_sfile, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   113
apply (frule sroot_set)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   114
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   115
done  
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   116
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
   117
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
   118
  "\<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
   119
     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
   120
       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
   121
         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
   122
                 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
   123
                                   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
   124
               | 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
   125
         else (case (sectxt_of_obj s (O_dir (f # pf))) of
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   126
                 Some fsec \<Rightarrow> Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   127
                                   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
   128
               | 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
   129
     | None \<Rightarrow> None)"
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   130
apply (drule is_file_or_dir, simp)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   131
apply (erule disjE)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   132
apply (frule cf2sfile_path_file, simp) defer
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   133
apply (frule cf2sfile_path_dir, simp, drule is_dir_not_file)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   134
apply (auto split:option.splits)
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   135
done
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   136
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   137
lemma cf2sfile_path_file_prop1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   138
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   139
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   140
                 Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   141
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   142
               sectxt_of_obj s (O_file (f # pf)) = Some fsec"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   143
apply (frule is_file_has_sfile, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   144
by (auto simp:cf2sfile_path_file)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   145
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   146
lemma cf2sfile_path_file_prop2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   147
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   148
    sectxt_of_obj s (O_file (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   149
      Some (if (\<not> deleted (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   150
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   151
by (drule cf2sfile_path_file_prop1, auto)
7
f27882976251 finally get cf2sfile path property done
chunhan
parents: 6
diff changeset
   152
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   153
lemma cf2sfile_path_dir_prop1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   154
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   155
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   156
                 Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   157
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   158
               sectxt_of_obj s (O_dir (f # pf)) = Some fsec"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   159
apply (frule is_dir_has_sfile, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   160
by (auto simp:cf2sfile_path_dir)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   161
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   162
lemma cf2sfile_path_dir_prop2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   163
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   164
    sectxt_of_obj s (O_dir (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   165
      Some (if (\<not> deleted (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   166
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   167
by (drule cf2sfile_path_dir_prop1, auto)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   168
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   169
(**************** cf2sfile event list simpset ****************)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   170
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   171
lemma cf2sfile_open_none':
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   172
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f'= cf2sfile s f'"
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   173
apply (frule vd_cons, frule vt_grant_os)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   174
apply (induct f', simp add:cf2sfile_def)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   175
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
   176
               get_parentfs_ctxts_simps)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   177
done
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   178
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   179
lemma cf2sfile_open_none:
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   180
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) = cf2sfile s"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   181
apply (rule ext)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   182
by (simp add:cf2sfile_open_none')
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   183
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   184
lemma cf2sfile_open_some1:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   185
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); f' \<in> current_files s\<rbrakk>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   186
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   187
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   188
apply (case_tac "f = f'", simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   189
apply (induct f', simp add:sroot_only, simp)
3
chunhan
parents: 1
diff changeset
   190
apply (frule parentf_in_current', simp+)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   191
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
   192
               get_parentfs_ctxts_simps)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   193
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   195
lemma cf2sfile_open_some2:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   196
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   197
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   198
apply (frule vd_cons, drule is_file_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   199
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   200
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   201
lemma cf2sfile_open_some3:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   202
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   203
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   204
apply (frule vd_cons, drule is_dir_in_current)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   205
by (simp add:cf2sfile_open_some1)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   206
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
   207
lemma cf2sfile_open_some4:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   208
  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f = (
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   209
     case (parent f) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   210
       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
   211
                         get_parentfs_ctxts s pf) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   212
                    (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   213
                  | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   214
     | None \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   215
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
4
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   216
apply (case_tac f, simp)
e9c5594d5963 fixed bugs in deleted definition
chunhan
parents: 3
diff changeset
   217
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
   218
               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
   219
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
   220
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
   221
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
   222
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
   223
8779d321cc2e 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
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
   225
  "\<lbrakk>valid (Open p f flag fd opt # s); f' \<in> current_files (Open p f flag fd opt # s)\<rbrakk>
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   226
   \<Longrightarrow> cf2sfile (Open p f flag fd opt # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   227
     if (opt = None) then cf2sfile s f'
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   228
     else if (f' = f) 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   229
     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
   230
             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
   231
                 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
   232
                          (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
   233
                        | _ \<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
   234
           | None \<Rightarrow> None)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   235
     else cf2sfile s f')"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   236
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
   237
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
   238
apply (case_tac "f = f'")
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   239
apply (simp add:cf2sfile_open_some4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   240
apply (simp add:cf2sfile_open_some1 current_files_simps)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   241
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
   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
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
   244
  "\<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
   245
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   246
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   247
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
   248
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
   249
apply (frule parentf_in_current', simp+)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   250
apply (case_tac "f = f'", simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   251
apply (simp add:cf2sfile_path is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   252
               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
   253
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
   254
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   255
lemma cf2sfile_mkdir2:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   256
  "\<lbrakk>valid (Mkdir p f i # s); is_file s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   257
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   258
apply (frule vd_cons, drule is_file_in_current)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   259
by (simp add:cf2sfile_mkdir1)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   260
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   261
lemma cf2sfile_mkdir3:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   262
  "\<lbrakk>valid (Mkdir p f i # s); is_dir s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   263
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   264
apply (frule vd_cons, drule is_dir_in_current)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   265
by (simp add:cf2sfile_mkdir1)
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   266
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   267
lemma cf2sfile_mkdir4:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   268
  "valid (Mkdir p f i # s)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   269
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f = (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   270
         Some pf \<Rightarrow> (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   271
                           get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   272
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   273
                    | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   274
       | None \<Rightarrow> None)"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   275
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   276
apply (case_tac f, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   277
apply (clarsimp simp:os_grant.simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   278
apply (simp add:sectxt_of_obj_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   279
apply (frule current_proc_has_sec, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   280
apply (frule is_dir_has_sec, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   281
apply (frule get_pfs_secs_prop, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   282
apply (frule is_dir_not_file)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   283
apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   284
               get_parentfs_ctxts_simps split:option.splits if_splits 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   285
            dest:not_deleted_init_dir is_dir_in_current not_deleted_init_file is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   286
done
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   287
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   288
lemma cf2sfile_mkdir:
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   289
  "\<lbrakk>valid (Mkdir p f i # s); f' \<in> current_files (Mkdir p f i # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   290
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   291
    if (f' = f) 
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   292
    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
   293
             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
   294
                 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
   295
                          (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
   296
                        | _ \<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
   297
           | None \<Rightarrow> None)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   298
     else cf2sfile s f')"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   299
apply (case_tac "f = f'")
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   300
apply (simp add:cf2sfile_mkdir4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   301
apply (simp add:cf2sfile_mkdir1 current_files_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   302
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   303
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   304
lemma cf2sfile_linkhard1:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   305
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files s\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   306
   \<Longrightarrow> cf2sfile (LinkHard p oldf f# s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   307
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   308
apply (case_tac "f = f'", simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   309
apply (induct f', simp add:sroot_only, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   310
apply (frule parentf_in_current', simp+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   311
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   312
               get_parentfs_ctxts_simps split:if_splits option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   313
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   314
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   315
lemma cf2sfile_linkhard2:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   316
  "\<lbrakk>valid (LinkHard p oldf f # s); is_file s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   317
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   318
apply (frule vd_cons, drule is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   319
by (simp add:cf2sfile_linkhard1)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   320
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   321
lemma cf2sfile_linkhard3:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   322
  "\<lbrakk>valid (LinkHard p oldf f # s); is_dir s f'\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   323
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   324
apply (frule vd_cons, drule is_dir_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   325
by (simp add:cf2sfile_linkhard1)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   326
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   327
lemma cf2sfile_linkhard4:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   328
  "valid (LinkHard p oldf f # s)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   329
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f = (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   330
         Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   331
                           get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   332
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   333
                    | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   334
       | None \<Rightarrow> None)"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   335
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   336
apply (case_tac f, simp)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   337
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   338
               get_parentfs_ctxts_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   339
apply (rule impI, (erule conjE)+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   340
apply (drule not_deleted_init_file, simp+)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   341
apply (simp add:is_file_in_current)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   342
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   343
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   344
lemma cf2sfile_linkhard:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   345
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files (LinkHard p oldf f # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   346
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = (
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   347
    if (f' = f) 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   348
    then (case (parent f) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   349
             Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   350
                 get_parentfs_ctxts s pf) of
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   351
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   352
                        | _ \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   353
           | None \<Rightarrow> None)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   354
     else cf2sfile s f')"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   355
apply (case_tac "f = f'")
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   356
apply (simp add:cf2sfile_linkhard4 split:option.splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   357
apply (simp add:cf2sfile_linkhard1 current_files_simps)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   358
done
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   359
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   360
lemma cf2sfile_other:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   361
  "\<lbrakk>ff \<in> current_files s;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   362
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   363
    \<forall> p fd. e \<noteq> CloseFd p fd;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   364
    \<forall> p f. e \<noteq> UnLink p f;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   365
    \<forall> p f. e \<noteq> Rmdir p f;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   366
    \<forall> p f i. e \<noteq> Mkdir p f i;
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   367
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   368
    valid (e # s)\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   369
apply (frule vd_cons, frule vt_grant_os)
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   370
apply (induct ff, simp add:sroot_only)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   371
apply (frule parentf_in_current', simp+, case_tac e)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   372
apply (auto simp:current_files_simps is_file_simps is_dir_simps sectxt_of_obj_simps cf2sfile_path 
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   373
           split:if_splits option.splits)                     
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   374
done     
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 4
diff changeset
   375
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   376
lemma cf2sfile_other':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   377
  "\<lbrakk>valid (e # s); 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   378
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   379
    \<forall> p fd. e \<noteq> CloseFd p fd;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   380
    \<forall> p f. e \<noteq> UnLink p f;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   381
    \<forall> p f. e \<noteq> Rmdir p f;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   382
    \<forall> p f i. e \<noteq> Mkdir p f i;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   383
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   384
    ff \<in> current_files s\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   385
by (auto intro!:cf2sfile_other)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   386
  
8
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   387
lemma cf2sfile_unlink:
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   388
  "\<lbrakk>valid (UnLink p f # s); f' \<in> current_files (UnLink p f # s)\<rbrakk>
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   389
   \<Longrightarrow> cf2sfile (UnLink p f # s) f' = cf2sfile s f'"
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   390
apply (frule vd_cons, frule vt_grant_os)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   391
apply (simp add:current_files_simps split:if_splits)
289a30c4cfb7 find bugs in deleted & inum_of_file
chunhan
parents: 7
diff changeset
   392
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   393
           split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   394
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   395
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   396
lemma cf2sfile_rmdir:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   397
  "\<lbrakk>valid (Rmdir p f # s); f' \<in> current_files (Rmdir p f # s)\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   398
   \<Longrightarrow> cf2sfile (Rmdir p f # s) f' = cf2sfile s f'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   399
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   400
apply (simp add:current_files_simps split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   401
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   402
           split:if_splits option.splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   403
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   404
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   405
lemma pfdof_simp5: "\<lbrakk>proc_fd_of_file s f = {(p, fd)}; file_of_proc_fd s p fd = None\<rbrakk> \<Longrightarrow> False"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   406
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   407
by (simp add:pfdof_simp2, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   408
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   409
lemma pfdof_simp6: "proc_fd_of_file s f = {(p, fd)} \<Longrightarrow> file_of_proc_fd s p fd = Some f"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   410
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   411
by (simp add:pfdof_simp2, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   412
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   413
lemma cf2sfile_closefd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   414
  "\<lbrakk>valid (CloseFd p fd # s); f \<in> current_files (CloseFd p fd # s)\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   415
   \<Longrightarrow> cf2sfile (CloseFd p fd # s) f = cf2sfile s f"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   416
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   417
apply (simp add:current_files_simps split:if_splits option.splits) 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   418
(* costs too much time, but solved
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   419
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   420
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   421
           split:if_splits option.splits  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   422
            dest:init_file_dir_conflict pfdof_simp5 pfdof_simp6 file_of_pfd_is_file
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   423
                 not_deleted_init_file not_deleted_init_dir is_file_not_dir is_dir_not_file
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   424
            dest!:current_has_sec')
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   425
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   426
*)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   427
sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   429
lemmas cf2sfile_simps = cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_other
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   430
  cf2sfile_unlink cf2sfile_rmdir cf2sfile_closefd
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   431
  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   432
(*********** cfd2sfd simpset *********)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   433
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   434
lemma cfd2sfd_open1:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   435
  "valid (Open p f flags fd opt # s)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   436
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p fd = 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   437
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   438
        (Some sec, Some sf) \<Rightarrow> Some (sec, flags, sf)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   439
      | _ \<Rightarrow> None)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   440
by (simp add:cfd2sfd_def sectxt_of_obj_simps split:if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   442
lemma cfd2sfd_open_some2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   443
  "\<lbrakk>valid (Open p f flags fd (Some inum) # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   444
  \<Longrightarrow> cfd2sfd (Open p f flags fd (Some inum) # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   445
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   446
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   447
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   448
apply (case_tac "f = f'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   449
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_some1)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   450
apply (case_tac "p = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   451
apply (rule conjI, rule impI, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   452
apply (drule cf2sfile_open_some1, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   453
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   454
apply simp
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   455
apply (drule cf2sfile_open_some1, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   456
apply (auto split:option.splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   457
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   458
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   459
lemma cfd2sfd_open_none2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   460
  "\<lbrakk>valid (Open p f flags fd None # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   461
  \<Longrightarrow> cfd2sfd (Open p f flags fd None # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   462
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   463
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   464
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   465
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   466
apply (case_tac "p = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   467
apply (rule conjI, rule impI, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   468
apply (drule cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   469
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   470
apply simp
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   471
apply (drule cf2sfile_open_none)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   472
apply (auto split:option.splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   473
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   474
  
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   475
lemma cfd2sfd_open2:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   476
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   477
  \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   478
apply (case_tac opt)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   479
apply (simp add:cfd2sfd_open_none2)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   480
apply (simp add:cfd2sfd_open_some2)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   482
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   483
lemma cfd2sfd_open:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   484
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd (Open p f flags fd opt # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   485
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = (if (p' = p \<and> fd' = fd) then 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   486
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   487
        (Some sec, Some sf) \<Rightarrow> Some (sec, flags, sf)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   488
      | _ \<Rightarrow> None)         else cfd2sfd s p' fd')"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   489
apply (simp split:if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   490
apply (simp add:cfd2sfd_open1 split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   491
apply (simp add:cfd2sfd_open2)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   492
apply (rule impI, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   495
lemma cfd2sfd_closefd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   496
  "\<lbrakk>valid (CloseFd p fd # s); file_of_proc_fd (CloseFd p fd # s) p' fd' = Some f\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   497
   \<Longrightarrow> cfd2sfd (CloseFd p fd # s) p' fd' = cfd2sfd  s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   498
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   499
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   500
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   501
apply (frule cf2sfile_closefd, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   502
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   503
apply (auto split:option.splits if_splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   504
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   506
lemma cfd2sfd_clone:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   507
  "\<lbrakk>valid (Clone p p' fds shms # s); file_of_proc_fd (Clone p p' fds shms # s) p'' fd' = Some f\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   508
   \<Longrightarrow> cfd2sfd (Clone p p' fds shms # s) p'' fd' = (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   509
     if (p'' = p') then cfd2sfd s p fd'
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   510
     else cfd2sfd s p'' fd')"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   511
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   512
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   513
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   514
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   515
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   516
apply (case_tac "p'' = p'", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   517
apply (auto split:option.splits if_splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   518
apply (simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   519
apply (auto split:option.splits if_splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   520
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   522
lemma cfd2sfd_execve:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   523
  "\<lbrakk>valid (Execve p f fds # s); file_of_proc_fd (Execve p f fds # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   524
   \<Longrightarrow> cfd2sfd (Execve p f fds # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   525
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   526
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   527
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   528
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   529
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   530
apply (case_tac "p' = p", simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   531
apply (auto split:option.splits if_splits)[1]
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   532
apply (simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   533
apply (auto split:option.splits if_splits)[1]
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   536
lemma cfd2sfd_kill:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   537
  "\<lbrakk>valid (Kill p p'' # s); file_of_proc_fd (Kill p p'' # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   538
   \<Longrightarrow> cfd2sfd (Kill p p'' # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   539
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   540
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   541
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   542
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   543
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   544
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   545
apply (auto split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   548
lemma cfd2sfd_exit:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   549
  "\<lbrakk>valid (Exit p # s); file_of_proc_fd (Exit p # s) p' fd' = Some f'\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   550
   \<Longrightarrow> cfd2sfd (Exit p # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   551
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   552
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   553
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   554
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   555
apply (frule_tac cf2sfile_other', simp+)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   556
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   557
apply (auto split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   560
lemma cfd2sfd_other:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   561
  "\<lbrakk>valid (e # s); file_of_proc_fd (e # s) p' fd' = Some f';
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   562
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   563
    \<forall> p p'' fds shms. e \<noteq> Clone p p'' fds shms\<rbrakk>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   564
   \<Longrightarrow> cfd2sfd (e # s) p' fd' = cfd2sfd s p' fd'"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   565
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   566
apply (frule proc_fd_in_fds, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   567
apply (frule proc_fd_in_procs, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   568
apply (frule file_of_proc_fd_in_curf, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   569
apply (case_tac e)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   570
apply (auto intro!:cfd2sfd_execve cfd2sfd_closefd cfd2sfd_kill cfd2sfd_exit)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   571
apply (auto simp:cfd2sfd_def sectxt_of_obj_simps current_files_simps cf2sfile_simps split:option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   572
apply (auto dest!:current_has_sec' dest:file_of_proc_fd_in_curf proc_fd_in_fds)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   573
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   574
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   575
lemmas cfd2sfd_simps = cfd2sfd_open cfd2sfd_clone cfd2sfd_other
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   576
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   577
(********** cpfd2sfds simpset **********)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   578
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   579
lemma current_filefd_has_flags:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   580
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists> flags. flags_of_proc_fd s p fd = Some flags"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   581
apply (induct s arbitrary:p)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   582
apply (simp only:flags_of_proc_fd.simps file_of_proc_fd.simps init_filefd_prop4)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   583
apply (frule vd_cons, frule vt_grant_os, case_tac a)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   584
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   585
done
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   586
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   587
lemma current_filefd_has_flags':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   588
  "\<lbrakk>flags_of_proc_fd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   589
apply (case_tac "file_of_proc_fd s p fd")
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   590
apply (simp, drule current_filefd_has_flags, simp+)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   593
lemma current_file_has_sfile':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   594
  "\<lbrakk>cf2sfile s f = None; valid s\<rbrakk> \<Longrightarrow> f \<notin> current_files s"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   595
by (rule notI, drule current_file_has_sfile, simp+)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   597
lemma current_filefd_has_sfd:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   598
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists>sfd. cfd2sfd s p fd = Some sfd"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   599
by (auto simp:cfd2sfd_def split:option.splits dest!:current_has_sec' current_file_has_sfile' 
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   600
         dest:file_of_proc_fd_in_curf proc_fd_in_fds current_filefd_has_flags)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   601
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   602
lemma current_filefd_has_sfd':
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   603
  "\<lbrakk>cfd2sfd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   604
by (case_tac "file_of_proc_fd s p fd", auto dest:current_filefd_has_sfd)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   606
lemma cpfd2sfds_open1:
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   607
  "valid (Open p f flags fd opt # s) \<Longrightarrow>
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   608
   cpfd2sfds (Open p f flags fd opt # s) p = (
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   609
    case (cfd2sfd (Open p f flags fd opt # s) p fd) of
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   610
        Some sfd \<Rightarrow> (cpfd2sfds s p) \<union> {sfd}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   611
      | _ \<Rightarrow> cpfd2sfds s p)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   612
apply (frule vd_cons, frule vt_grant_os)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   613
apply (split option.splits)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   614
apply (rule conjI, rule impI, drule current_filefd_has_sfd', simp, simp)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   615
apply (rule allI, rule impI)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   616
apply (rule set_eqI, rule iffI)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   617
apply (case_tac "x = a", simp)
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   618
unfolding cpfd2sfds_def
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   619
apply (erule CollectE, (erule conjE|erule bexE)+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   620
apply (simp add:proc_file_fds_def split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   621
apply (erule exE, rule_tac x = fda in exI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   622
apply (simp add:cfd2sfd_open2)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   623
apply (case_tac "x = a", simp add:proc_file_fds_def)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   624
apply (rule_tac x = fd in exI, simp+)
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   625
apply (erule conjE|erule bexE)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   626
apply (rule_tac x = fda in bexI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   627
apply (simp add:proc_file_fds_def, erule exE)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   628
apply (simp add:cfd2sfd_open2)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   629
apply (simp add:proc_file_fds_def)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   630
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   631
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   632
lemma cpfd2sfds_open1':
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   633
  "valid (Open p f flags fd opt # s) \<Longrightarrow>
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   634
   cpfd2sfds (Open p f flags fd opt # s) p = (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   635
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   636
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, flags, sf)}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   637
      | _ \<Rightarrow> cpfd2sfds s p)"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   638
apply (frule cfd2sfd_open1)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   639
apply (auto dest:cpfd2sfds_open1 split:option.splits)
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   640
done
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   641
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   642
lemma cpfd2sfds_open2:
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   643
  "\<lbrakk>valid (Open p f flags fd opt # s); p' \<noteq> p\<rbrakk> \<Longrightarrow> cpfd2sfds (Open p f flags fd opt # s) p' = cpfd2sfds s p'"
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   644
apply (frule vt_grant_os, frule vd_cons)
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   645
unfolding cpfd2sfds_def
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   646
apply (rule set_eqI, rule iffI)
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   647
apply (simp add:proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   648
apply (erule exE|erule conjE)+
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   649
apply (simp only:file_of_proc_fd.simps cfd2sfd_open2 split:if_splits)
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   650
apply (rule_tac x = fda in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   651
apply (simp add:proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   652
apply (erule exE|erule conjE)+
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   653
apply (rule_tac x = fda in exI, simp add:cfd2sfd_open2)
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   654
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   656
lemma cpfd2sfds_open:
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   657
  "valid (Open p f flags fd opt # s)
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   658
   \<Longrightarrow> cpfd2sfds (Open p f flags fd opt # s) = (cpfd2sfds s) (p := (
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   659
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   660
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, flags, sf)}
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   661
      | _ \<Rightarrow> cpfd2sfds s p))"
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
   662
apply (rule ext)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   663
apply (case_tac "x \<noteq> p")
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   664
apply (simp add:cpfd2sfds_open2)
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   665
apply (simp add:cpfd2sfds_open1')
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   666
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   668
lemma cpfd2sfds_execve:
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   669
  "valid (Execve p f fds # s) 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   670
   \<Longrightarrow> cpfd2sfds (Execve p f fds # s) = (cpfd2sfds s) (p := {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   671
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   672
apply (rule ext)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   673
apply (rule set_eqI, rule iffI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   674
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   675
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   676
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   677
apply (frule_tac p' = p and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   678
apply (rule_tac x = fd in bexI, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   679
apply (simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   680
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   681
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   682
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   683
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   684
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   685
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   686
apply (simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   687
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   688
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   689
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   690
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   691
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   692
lemma cpfd2sfds_clone:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   693
  "valid (Clone p p' fds shms # s) 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   694
   \<Longrightarrow> cpfd2sfds (Clone p p' fds shms # s) = (cpfd2sfds s) (p' := {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   695
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   696
apply (rule ext)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   697
apply (rule set_eqI, rule iffI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   698
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   699
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   700
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   701
apply (frule_tac p'' = p' and fd' = fd in cfd2sfd_clone, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   702
apply (rule_tac x = fd in bexI, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   703
apply (simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   704
apply (frule_tac p'' = x and fd' = fd in cfd2sfd_clone, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   705
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   706
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   707
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   708
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   709
apply (frule_tac p'' = p' and fd' = fd in cfd2sfd_clone, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   710
apply (simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   711
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   712
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   713
apply (frule_tac p'' = x and fd' = fd in cfd2sfd_clone, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   714
done
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   715
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   716
lemma cpfd2sfds_other:
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   717
  "\<lbrakk>valid (e # s);
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   718
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   719
    \<forall> p f fds. e \<noteq> Execve p f fds;
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   720
    \<forall> p p'. e \<noteq> Kill p p';
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   721
    \<forall> p. e \<noteq> Exit p;
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   722
    \<forall> p fd. e \<noteq> CloseFd p fd;
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   723
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms\<rbrakk> \<Longrightarrow> cpfd2sfds (e # s) = cpfd2sfds s"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   724
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   725
apply (rule ext)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   726
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   727
apply (case_tac e)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   728
using cfd2sfd_other
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   729
by auto
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   730
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   731
lemma cpfd2sfds_kill:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   732
  "valid (Kill p p' # s) \<Longrightarrow> cpfd2sfds (Kill p p' # s) = (cpfd2sfds s) (p' := {})"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   733
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   734
apply (rule ext, rule set_eqI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   735
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   736
apply (rule iffI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   737
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   738
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   739
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   740
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   741
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   742
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   743
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   744
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   745
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   746
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   747
lemma cpfd2sfds_exit:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   748
  "valid (Exit p # s) \<Longrightarrow> cpfd2sfds (Exit p # s) = (cpfd2sfds s) (p := {})"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   749
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   750
apply (rule ext, rule set_eqI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   751
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   752
apply (rule iffI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   753
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   754
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   755
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   756
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   757
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   758
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   759
apply (rule_tac x = fd in exI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   760
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   761
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   762
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   763
lemma cpfd2sfds_closefd:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   764
  "valid (CloseFd p fd # s) \<Longrightarrow> cpfd2sfds (CloseFd p fd # s) = (cpfd2sfds s) (p := 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   765
     if (fd \<in> proc_file_fds s p)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   766
     then (case (cfd2sfd s p fd) of 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   767
             Some sfd \<Rightarrow> (if (\<exists> fd' f'. fd' \<noteq> fd \<and> file_of_proc_fd s p fd' = Some f' \<and> cfd2sfd s p fd' = Some sfd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   768
                          then cpfd2sfds s p else cpfd2sfds s p - {sfd})
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   769
           | _        \<Rightarrow> cpfd2sfds s p)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   770
     else cpfd2sfds s p)"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   771
apply (frule vd_cons)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   772
apply (rule ext, rule set_eqI, rule iffI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   773
unfolding cpfd2sfds_def proc_file_fds_def
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   774
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   775
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   776
apply (rule conjI, rule impI, rule conjI, rule impI, erule exE)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   777
apply (frule_tac p = p and fd = fd in current_filefd_has_sfd, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   778
apply (erule exE, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   779
apply (rule conjI, rule impI, (erule exE|erule conjE)+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   780
apply (rule_tac x = fda in exI, simp, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   781
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   782
apply (rule impI, rule conjI)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   783
apply (rule_tac x = fda in exI, simp, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   784
apply (rule notI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   785
apply (erule_tac x = fda in allE, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   786
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   787
apply (rule impI, simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   788
apply (erule exE, rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   789
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   790
apply (rule impI| rule conjI)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   791
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   792
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   793
apply (rule impI, simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   794
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
   795
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   796
apply (simp split:if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   797
apply (frule_tac p = p and fd = fd in current_filefd_has_sfd, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   798
apply (erule exE, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   799
apply (case_tac "\<exists>fd'. fd' \<noteq> fd \<and> (\<exists>f'. file_of_proc_fd s p fd' = Some f') \<and> cfd2sfd s p fd' = Some sfd")
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   800
apply simp
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   801
apply (case_tac "xa = sfd")
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   802
apply (erule exE|erule conjE)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   803
apply (rule_tac x = fd' in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   804
apply (erule exE|erule conjE)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   805
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   806
apply (rule notI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   807
apply (simp, (erule exE|erule conjE)+)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   808
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   809
apply (rule notI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   810
apply (erule exE|erule conjE)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   811
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   812
apply (rule notI, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   813
apply (simp add:cpfd2sfds_def proc_file_fds_def)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   814
apply (erule exE|erule conjE)+
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   815
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   816
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   817
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   818
lemmas cpfd2sfds_simps = cpfd2sfds_open cpfd2sfds_execve cpfd2sfds_clone cpfd2sfds_kill cpfd2sfds_exit
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   819
  cpfd2sfds_closefd cpfd2sfds_other
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   820
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   821
(********* ch2sshm simpset ********)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   822
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   823
lemma ch2sshm_createshm:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   824
  "valid (CreateShM p h # s) 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   825
   \<Longrightarrow> ch2sshm (CreateShM p h # s) = (ch2sshm s) (h := 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   826
     (case (sectxt_of_obj (CreateShM p h # s) (O_shm h)) of
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   827
                    Some sec \<Rightarrow> 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   828
 Some (if (\<not> deleted (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   829
                  | _ \<Rightarrow> None))"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   830
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   831
apply (auto simp:ch2sshm_def sectxt_of_obj_simps dest!:current_has_sec' split:option.splits if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   832
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   833
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   834
lemma ch2sshm_other:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   835
  "\<lbrakk>valid (e # s); 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   836
    \<forall> p h. e \<noteq> CreateShM p h; 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   837
    h' \<in> current_shms (e # s)\<rbrakk> \<Longrightarrow> ch2sshm (e # s) h' = ch2sshm s h'"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   838
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   839
apply (case_tac e)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   840
apply (auto simp:ch2sshm_def sectxt_of_obj_simps dest!:current_has_sec' split:option.splits if_splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   841
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   842
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   843
lemmas ch2sshm_simps = ch2sshm_createshm ch2sshm_other
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   844
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   845
lemma current_shm_has_sh:
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   846
  "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> sh. ch2sshm s h = Some sh"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   847
by (auto simp:ch2sshm_def split:option.splits dest!:current_has_sec')
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   848
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   849
lemma current_shm_has_sh':
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   850
  "\<lbrakk>ch2sshm s h = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   851
by (auto dest:current_shm_has_sh)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   852
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   853
(********** cph2spshs simpset **********)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   854
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   855
  (*???*) lemma procs_of_shm_prop1: "\<lbrakk> p_flag \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> h \<in> current_shms s"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   856
apply (induct s arbitrary:p_flag)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   857
apply (case_tac p_flag, simp, drule init_procs_has_shm, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   858
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   859
apply (case_tac a, auto split:if_splits option.splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   860
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   861
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   862
lemma procs_of_shm_prop2: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   863
apply (induct s arbitrary:p flag)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   864
apply (simp, drule init_procs_has_shm, simp)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   865
apply (frule vd_cons, frule vt_grant_os)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   866
apply (case_tac a, auto split:if_splits option.splits)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   867
done
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   868
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   869
lemma procs_of_shm_prop3: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; (p, flag') \<in> procs_of_shm s h; valid s\<rbrakk>
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   870
  \<Longrightarrow> flag = flag'"
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   871
apply (induct s arbitrary:p flag flag')
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   872
apply (simp, drule_tac flag = flag in init_procs_has_shm, drule_tac flag = flag' in init_procs_has_shm, simp)
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   873
apply (frule vd_cons, frule vt_grant_os)
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   874
apply (case_tac a, auto split:if_splits option.splits dest:procs_of_shm_prop2)
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   875
done
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   876
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   877
lemma procs_of_shm_prop4: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> flag_of_proc_shm s p h = Some flag"
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   878
apply (induct s arbitrary:p flag)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   879
apply (simp, drule init_procs_has_shm, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   880
apply (frule vd_cons, frule vt_grant_os)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   881
apply (case_tac a, auto split:if_splits option.splits dest:procs_of_shm_prop2)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   882
done
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   883
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   884
lemma procs_of_shm_prop4':
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   885
  "\<lbrakk>flag_of_proc_shm s p h = None; valid s\<rbrakk> \<Longrightarrow> \<forall> flag. (p, flag) \<notin> procs_of_shm s h"
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   886
by (auto dest:procs_of_shm_prop4)
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   887
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   888
lemma cph2spshs_attach:
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   889
  "valid (Attach p h flag # s) \<Longrightarrow> 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   890
   cph2spshs (Attach p h flag # s) = (cph2spshs s) (p := 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   891
     (case (ch2sshm s h) of 
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   892
        Some sh \<Rightarrow> cph2spshs s p \<union> {(sh, flag)}
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   893
      | _       \<Rightarrow> cph2spshs s p) )"
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   894
apply (frule vd_cons, frule vt_grant_os, rule ext)
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   895
using ch2sshm_other[where e = "Attach p h flag" and s = s]
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   896
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   897
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 simp:cph2spshs_def)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   898
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   899
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   900
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   901
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   902
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   903
apply (case_tac "ha = h", simp, frule procs_of_shm_prop1, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   904
apply (rule_tac x = ha in exI, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   905
apply (rule_tac x = ha in exI, simp, drule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   906
apply (rule_tac x = ha in exI, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   907
apply (frule procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   908
apply (rule impI, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   909
done
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   910
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   911
lemma cph2spshs_detach: "valid (Detach p h # s) \<Longrightarrow> 
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   912
  cph2spshs (Detach p h # s) = (cph2spshs s) (p := 
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   913
    (case (ch2sshm s h, flag_of_proc_shm s p h) of 
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   914
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p,flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   915
                  then cph2spshs s p else cph2spshs s p - {(sh, flag)}
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   916
     | _       \<Rightarrow> cph2spshs s p)             )"
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   917
apply (frule vd_cons, frule vt_grant_os, rule ext)
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   918
apply (case_tac "x = p")  defer
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   919
using ch2sshm_other[where e = "Detach p h" and s = s] 
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   920
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   921
dest!:current_shm_has_sh' procs_of_shm_prop4' dest:procs_of_shm_prop1 procs_of_shm_prop3 simp:cph2spshs_def) [1]
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   922
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp, simp)
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   923
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp, simp)
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   924
apply (rule impI, simp)
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   925
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   926
apply (clarsimp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   927
apply (frule current_shm_has_sh, simp, erule exE)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   928
apply (frule procs_of_shm_prop4, simp, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   929
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   930
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   931
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   932
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   933
apply (case_tac "ha = h", simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   934
apply (rule_tac x = sha in exI, rule_tac x = flaga in exI, rule_tac x = ha in exI, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   935
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   936
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   937
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   938
apply (case_tac "ha = h", simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   939
apply (rule_tac x = h' in exI, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   940
apply (frule_tac flag = flag and flag' = flaga in procs_of_shm_prop3, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   941
apply (frule_tac flag = flaga in procs_of_shm_prop4, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   942
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   943
apply (frule_tac h = h' in procs_of_shm_prop1, simp, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   944
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   945
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   946
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   947
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   948
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   949
apply (erule CollectE | erule exE| erule conjE| rule DiffI |rule CollectI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   950
apply (simp split:if_splits)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   951
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   952
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   953
apply (rule notI, simp split:if_splits)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   954
apply (erule_tac x = ha in allE, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   955
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   956
apply (erule CollectE | erule exE| erule conjE| erule DiffE |rule CollectI)+
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   957
apply (simp split:if_splits)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   958
apply (erule_tac x = ha in allE, simp, rule_tac x = ha in exI, simp)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   959
apply (case_tac "ha = h", simp add:procs_of_shm_prop3, frule_tac h = ha in procs_of_shm_prop1, simp+)
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   960
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
14
cc1e46225a81 shm attached at most once
chunhan
parents: 13
diff changeset
   961
done
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
   962
16
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   963
lemma cph2spshs_deleteshm:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   964
  "valid (DeleteShM p h # s) \<Longrightarrow>     
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   965
   cph2spshs (DeleteShM p h # s) = (\<lambda> p'. 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   966
    (case (ch2sshm s h, flag_of_proc_shm s p' h) of 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   967
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p', flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   968
                  then cph2spshs s p' else cph2spshs s p' - {(sh, flag)}
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   969
     | _       \<Rightarrow> cph2spshs s p')   )"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   970
apply (frule vd_cons, frule vt_grant_os, rule ext)
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
   971
16
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   972
apply (clarsimp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   973
apply (frule current_shm_has_sh, simp, erule exE, simp, simp split:option.splits)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   974
apply (rule conjI, rule impI)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   975
using ch2sshm_other[where e = "DeleteShM p h" and s = s] 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   976
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   977
dest!:current_shm_has_sh' procs_of_shm_prop4' dest:procs_of_shm_prop1 procs_of_shm_prop3 simp:cph2spshs_def) [1]
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   978
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   979
apply (rule_tac x = ha in exI, simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   980
apply (case_tac "ha = h", simp+, frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   981
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   982
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   983
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   984
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   985
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   986
apply (case_tac "ha = h", simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   987
apply (rule_tac x = sha in exI, rule_tac x = flag in exI, rule_tac x = ha in exI, simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   988
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   989
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   990
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   991
apply (case_tac "ha = h", simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   992
apply (rule_tac x = h' in exI, simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   993
apply (frule_tac flag = flag in procs_of_shm_prop4, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   994
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   995
apply (frule_tac h = h' in procs_of_shm_prop1, simp, simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   996
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   997
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   998
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
   999
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1000
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1001
apply (erule CollectE | erule exE| erule conjE| rule DiffI |rule CollectI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1002
apply (simp split:if_splits)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1003
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1004
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1005
apply (rule notI, simp split:if_splits)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1006
apply (erule_tac x = ha in allE, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1007
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1008
apply (erule CollectE | erule exE| erule conjE| erule DiffE |rule CollectI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1009
apply (simp split:if_splits)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1010
apply (erule_tac x = ha in allE, simp, rule_tac x = ha in exI, simp)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1011
apply (case_tac "ha = h", simp add:procs_of_shm_prop4)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1012
apply (frule_tac h = ha in procs_of_shm_prop1, simp+)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1013
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1014
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1015
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1016
lemma flag_of_proc_shm_prop1:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1017
  "\<lbrakk>flag_of_proc_shm s p h = Some flag; valid s\<rbrakk> \<Longrightarrow> (p, flag) \<in> procs_of_shm s h"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1018
apply (induct s arbitrary:p)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1019
apply (simp add:init_shmflag_has_proc)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1020
apply (frule vt_grant_os, frule vd_cons, case_tac a, auto split:if_splits option.splits)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1021
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1022
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1023
lemma cph2spshs_clone:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1024
  "valid (Clone p p' fds shms # s) \<Longrightarrow> 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1025
   cph2spshs (Clone p p' fds shms # s) = (cph2spshs s) (p' := 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1026
     {(sh, flag) | h sh flag. h \<in> shms \<and> ch2sshm s h = Some sh \<and> flag_of_proc_shm s p h = Some flag} )"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1027
apply (frule vd_cons, frule vt_grant_os, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1028
using ch2sshm_other[where e = "Clone p p' fds shms" and s = s]
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1029
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1030
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1031
apply (erule_tac x = h in allE, frule procs_of_shm_prop1, simp, simp add:procs_of_shm_prop4)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1032
apply (rule_tac x = h in exI, simp, frule flag_of_proc_shm_prop1, simp+, simp add:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1033
apply (rule_tac x = h in exI, simp, frule procs_of_shm_prop1, simp+)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1034
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1035
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1036
lemma cph2spshs_execve:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1037
  "valid (Execve p f fds # s) \<Longrightarrow>
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1038
  cph2spshs (Execve p f fds # s) = (cph2spshs s) (p := {})"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1039
apply (frule vd_cons, frule vt_grant_os, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1040
using ch2sshm_other[where e = "Execve p f fds" and s = s]
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1041
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1042
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1043
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1044
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1045
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1046
lemma cph2spshs_kill:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1047
  "valid (Kill p p' # s) \<Longrightarrow> cph2spshs (Kill p p' # s) = (cph2spshs s) (p' := {})"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1048
apply (frule vd_cons, frule vt_grant_os, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1049
using ch2sshm_other[where e = "Kill p p'" and s = s]
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1050
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1051
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1052
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1053
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1054
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1055
lemma cph2spshs_exit:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1056
  "valid (Exit p # s) \<Longrightarrow> cph2spshs (Exit p # s) = (cph2spshs s) (p := {})"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1057
apply (frule vd_cons, frule vt_grant_os, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1058
using ch2sshm_other[where e = "Exit p" and s = s]
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1059
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1060
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1061
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1062
done
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1063
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1064
lemma cph2spshs_createshm:
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1065
  "valid (CreateShM p h # s) \<Longrightarrow> cph2spshs (CreateShM p h # s) = cph2spshs s"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1066
apply (frule vt_grant_os, frule vd_cons, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1067
apply (auto simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1068
using ch2sshm_createshm
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1069
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1070
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1071
apply (rule_tac x = ha in exI, auto simp:procs_of_shm_prop1)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1072
done
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 14
diff changeset
  1073
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
  1074
lemma cph2spshs_other:
16
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1075
  "\<lbrakk>valid (e # s); 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1076
    \<forall> p h flag. e \<noteq> Attach p h flag;
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1077
    \<forall> p h. e \<noteq> Detach p h;
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1078
    \<forall> p h. e \<noteq> DeleteShM p h;
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1079
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1080
    \<forall> p f fds. e \<noteq> Execve p f fds;
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1081
    \<forall> p p'. e \<noteq> Kill p p';
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1082
    \<forall> p. e \<noteq> Exit p\<rbrakk> \<Longrightarrow> cph2spshs (e # s) = cph2spshs s"
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1083
apply (frule vt_grant_os, frule vd_cons, rule ext)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1084
unfolding cph2spshs_def 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1085
apply (rule set_eqI, rule iffI)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1086
apply (erule CollectE | erule conjE| erule exE| rule conjI| rule impI| rule CollectI)+
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1087
apply (frule procs_of_shm_prop1, simp, rule_tac x= sh in exI, rule_tac x = flag in exI, rule_tac x = h in exI)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1088
apply (case_tac e)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1089
using ch2sshm_other[where e = e and s = s] 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1090
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1091
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1092
 simp:ch2sshm_createshm)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1093
apply (rule_tac x = h in exI, case_tac e)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1094
using ch2sshm_other[where e = e and s = s] 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1095
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1096
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1097
 simp:ch2sshm_createshm)
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1098
done
13
7b5e9fbeaf93 co2sobj simpset
chunhan
parents: 12
diff changeset
  1099
16
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1100
lemmas cph2spshs_simps = cph2spshs_attach cph2spshs_detach cph2spshs_deleteshm cph2spshs_clone cph2spshs_execve
c8b7c24f1db6 done with cph2spshs simpset
chunhan
parents: 15
diff changeset
  1101
  cph2spshs_exit cph2spshs_kill cph2spshs_other
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1102
10
ac66d8ba86d9 fix bugs and proofs
chunhan
parents: 8
diff changeset
  1103
(******** cp2sproc simpset *********)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1104
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1105
lemma not_init_intro_proc: (*???*)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1106
  "\<lbrakk>p \<notin> current_procs s; valid s\<rbrakk> \<Longrightarrow> deleted (O_proc p) s \<or> p \<notin> init_procs"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1107
using not_deleted_init_proc by auto
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1108
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1109
lemma not_init_intro_proc': (*???*)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1110
  "\<lbrakk>p \<notin> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<not> (\<not> deleted (O_proc p) s \<and> p \<in> init_procs)"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1111
using not_deleted_init_proc by auto
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1112
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1113
lemma cp2sproc_clone:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1114
  "valid (Clone p p' fds shms # s) \<Longrightarrow> cp2sproc (Clone p p' fds shms # s) = (cp2sproc s) (p' := 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1115
     case (sectxt_of_obj s (O_proc p)) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1116
       Some sec \<Rightarrow> Some (Created, sec, 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1117
  {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd},
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1118
  {(sh, flag) | h sh flag. h \<in> shms \<and> ch2sshm s h = Some sh \<and> flag_of_proc_shm s p h = Some flag})
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1119
     | _        \<Rightarrow> None)"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1120
apply (frule cph2spshs_clone, frule cpfd2sfds_clone)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1121
apply (frule vd_cons, frule vt_grant_os, simp only:os_grant.simps)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1122
apply ((erule exE| erule conjE)+, frule not_init_intro_proc, simp, rule ext, case_tac "x = p'", simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1123
apply (auto simp:cp2sproc_def sectxt_of_obj_simps dest!:current_has_sec' 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1124
            dest:current_proc_has_sec split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1125
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1126
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1127
lemma cp2sproc_other:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1128
  "\<lbrakk>valid (e # s); 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1129
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1130
    \<forall> p fd. e \<noteq> CloseFd p fd;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1131
    \<forall> p h flag. e \<noteq> Attach p h flag;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1132
    \<forall> p h. e \<noteq> Detach p h;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1133
    \<forall> p h. e \<noteq> DeleteShM p h;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1134
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1135
    \<forall> p f fds. e \<noteq> Execve p f fds;
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1136
    \<forall> p p'. e \<noteq> Kill p p';
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1137
    \<forall> p. e \<noteq> Exit p\<rbrakk> \<Longrightarrow> cp2sproc (e # s) = cp2sproc s"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1138
apply (frule cph2spshs_other, simp+, frule cpfd2sfds_other, simp+)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1139
apply (frule vt_grant_os, frule vd_cons, rule ext, case_tac e, simp_all) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1140
apply (auto simp:cp2sproc_def sectxt_of_obj_simps dest!:current_has_sec' 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1141
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1142
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1143
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1144
lemma cp2sproc_open:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1145
  "valid (Open p f flags fd opt # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1146
   cp2sproc (Open p f flags fd opt # s) = (cp2sproc s) (p :=      
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1147
     case (sectxt_of_obj s (O_proc p), sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1148
           cf2sfile (Open p f flags fd opt # s) f) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1149
       (Some sec, Some fdsec, Some sf) \<Rightarrow> Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1150
                                               then Init p else Created, sec, 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1151
                                                (cpfd2sfds s p) \<union> {(fdsec, flags, sf)}, cph2spshs s p)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1152
     | _        \<Rightarrow> None)"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1153
apply (frule cph2spshs_other, simp, simp, simp, simp, simp, simp, simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1154
apply (frule cpfd2sfds_open, frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1155
apply (case_tac "x = p") 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1156
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1157
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1158
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1159
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1160
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1161
lemma cp2sproc_closefd:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1162
  "valid (CloseFd p fd # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1163
   cp2sproc (CloseFd p fd # s) = (cp2sproc s) (p := 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1164
     if (fd \<in> proc_file_fds s p)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1165
     then (case (cfd2sfd s p fd) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1166
             Some sfd \<Rightarrow> (if (\<exists> fd' f'. fd' \<noteq> fd \<and> file_of_proc_fd s p fd' = Some f' \<and> cfd2sfd s p fd' = Some sfd)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1167
                          then cp2sproc s p 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1168
                          else (case (sectxt_of_obj s (O_proc p)) of
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1169
                                  Some sec \<Rightarrow> Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1170
                                                    then Init p else Created, 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1171
                                                    sec, cpfd2sfds s p - {sfd}, cph2spshs s p)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1172
                                | _        \<Rightarrow> None))
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1173
           | _        \<Rightarrow> cp2sproc s p)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1174
     else cp2sproc s p)"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1175
apply (frule cpfd2sfds_closefd, frule cph2spshs_other, simp, simp, simp, simp, simp, simp, simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1176
apply (frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1177
apply (case_tac "x = p") 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1178
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1179
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1180
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1181
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1182
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1183
lemma cp2sproc_attach:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1184
  "valid (Attach p h flag # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1185
   cp2sproc (Attach p h flag # s) = (cp2sproc s) (p := 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1186
     (case (ch2sshm s h) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1187
        Some sh \<Rightarrow> (case (sectxt_of_obj s (O_proc p)) of
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1188
                      Some sec \<Rightarrow> Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1189
                                        then Init p else Created, 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1190
                                        sec, cpfd2sfds s p, cph2spshs s p \<union> {(sh, flag)})
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1191
                    | _        \<Rightarrow> None)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1192
      | _       \<Rightarrow> cp2sproc s p) )"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1193
apply (frule cph2spshs_attach, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1194
apply (frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1195
apply (case_tac "x = p") 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1196
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1197
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1198
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1199
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1200
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1201
lemma cp2sproc_detach:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1202
  "valid (Detach p h # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1203
   cp2sproc (Detach p h # s) = (cp2sproc s) (p := 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1204
    (case (ch2sshm s h, flag_of_proc_shm s p h) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1205
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p,flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1206
                              then cp2sproc s p 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1207
                              else (case (sectxt_of_obj s (O_proc p)) of
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1208
                                      Some sec \<Rightarrow> Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1209
                                                       then Init p else Created, sec,
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1210
                                                       cpfd2sfds s p, cph2spshs s p - {(sh, flag)})
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1211
                                    | None     \<Rightarrow> None)                   
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1212
     | _       \<Rightarrow> cp2sproc s p)             )"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1213
apply (frule cph2spshs_detach, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1214
apply (frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1215
apply (case_tac "x = p") 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1216
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1217
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1218
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1219
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1220
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1221
lemma cp2sproc_deleteshm:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1222
  "valid (DeleteShM p h # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1223
   cp2sproc (DeleteShM p h # s) = (\<lambda> p'. 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1224
    (case (ch2sshm s h, flag_of_proc_shm s p' h) of 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1225
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p', flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1226
                              then cp2sproc s p' 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1227
                              else (case (sectxt_of_obj s (O_proc p')) of
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1228
                                      Some sec \<Rightarrow> Some (if (\<not> deleted (O_proc p') s \<and> p' \<in> init_procs) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1229
                                                       then Init p' else Created, sec,
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1230
                                                       cpfd2sfds s p', cph2spshs s p' - {(sh, flag)})
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1231
                                    | None     \<Rightarrow> None)                   
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1232
     | _       \<Rightarrow> cp2sproc s p')             )"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1233
apply (frule cph2spshs_deleteshm, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1234
apply (frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1235
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1236
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1237
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1238
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1239
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1240
lemma cp2sproc_execve:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1241
  "valid (Execve p f fds # s) \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1242
   cp2sproc (Execve p f fds # s) = (cp2sproc s) (p := 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1243
     (case (sectxt_of_obj (Execve p f fds # s) (O_proc p)) of
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1244
        Some sec \<Rightarrow> Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1245
                         {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd}, {})
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1246
      | _        \<Rightarrow> None)                        )"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1247
apply (frule cph2spshs_execve, frule cpfd2sfds_execve)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1248
apply (frule vt_grant_os, frule vd_cons, rule ext)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1249
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1250
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1251
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1252
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1253
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1254
lemma cp2sproc_kill:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1255
  "\<lbrakk>valid (Kill p p' # s); p'' \<noteq> p'\<rbrakk> \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1256
   cp2sproc (Kill p p' # s) p'' = (cp2sproc s) p''"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1257
apply (frule cph2spshs_kill, frule cpfd2sfds_kill)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1258
apply (frule vt_grant_os, frule vd_cons)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1259
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1260
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1261
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1262
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1263
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1264
lemma cp2sproc_kill':
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1265
  "\<lbrakk>valid (Kill p p' # s); p'' \<in> current_procs (Kill p p' # s)\<rbrakk> \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1266
   cp2sproc (Kill p p' # s) p'' = (cp2sproc s) p''"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1267
by (drule_tac p'' = p'' in cp2sproc_kill, simp+)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1268
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1269
lemma cp2sproc_exit:
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1270
  "\<lbrakk>valid (Exit p # s); p' \<noteq> p\<rbrakk> \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1271
   cp2sproc (Exit p # s) p' = (cp2sproc s) p'"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1272
apply (frule cph2spshs_exit, frule cpfd2sfds_exit)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1273
apply (frule vt_grant_os, frule vd_cons)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1274
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1275
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1276
            dest:current_proc_has_sec not_deleted_init_proc split:option.splits if_splits)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1277
done
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1278
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1279
lemma cp2sproc_exit':
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1280
  "\<lbrakk>valid (Exit p # s); p' \<in> current_procs (Exit p # s)\<rbrakk> \<Longrightarrow> 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1281
   cp2sproc (Exit p # s) p' = (cp2sproc s) p'"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1282
by (drule_tac p'= p' in cp2sproc_exit, simp+)
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1283
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1284
lemmas cp2sproc_simps = cp2sproc_open cp2sproc_closefd cp2sproc_attach cp2sproc_detach cp2sproc_deleteshm
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1285
  cp2sproc_clone cp2sproc_execve cp2sproc_kill cp2sproc_exit cp2sproc_other 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1286
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1287
(********************* cm2smsg simpset ***********************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1288
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1289
lemma cm2smsg_other: "\<lbrakk>valid (e # s); \<forall> p q m. e \<noteq> SendMsg p q m\<rbrakk> \<Longrightarrow> cm2smsg (e # s) = cm2smsg s"
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1290
apply (frule vt_grant_os, frule vd_cons, rule ext, rule ext)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1291
apply (case_tac e)
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1292
apply (auto simp:cm2smsg_def sectxt_of_obj_simps split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1293
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1294
lemmas cm2smsg_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1295
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1296
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1297
17
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1298
(********************* cq2smsgq simpset ***********************) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1299
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1300
lemma cq2smsgq_other: "\<forall> p m. e \<noteq> CreateMsg p m \<Longrightarrow> cm2smsg (e # \<tau>) m' = cm2smsg \<tau> m'" 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1301
apply (case_tac e) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1302
by (auto simp:cm2smsg_def index_of_msg.simps d2s_aux.simps) 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1303
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1304
lemmas cq2smsgq_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other 
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1305
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1306
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1307
570f90f175ee updated
chunhan
parents: 16
diff changeset
  1308
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1309
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1310
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1311
(*<*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1312
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
  1313
(*>*)