no_shm_selinux/Enrich2.thy
author chunhan
Thu, 09 Jan 2014 19:09:09 +0800
changeset 93 dfde07c7cd6b
parent 92 d9dc04c3ea90
child 94 042e1e7fd505
permissions -rw-r--r--
new_childf generalized
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
chunhan
parents: 87
diff changeset
     1
theory Enrich2
82
chunhan
parents:
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
83
chunhan
parents: 82
diff changeset
     3
 Temp Enrich Proc_fd_of_file_prop
82
chunhan
parents:
diff changeset
     4
begin
chunhan
parents:
diff changeset
     5
chunhan
parents:
diff changeset
     6
context tainting_s begin
chunhan
parents:
diff changeset
     7
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
     8
fun enrich_file :: "t_state \<Rightarrow> t_file \<Rightarrow> t_state \<Rightarrow> (t_file set \<times> t_state)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
     9
where
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
    10
  "enrich_file [] tf s = ({}, [])"
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
    11
| "enrich_file (Open p f flags fd (Some inum) # s) tf s =
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
    12
  "
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 91
diff changeset
    13
    
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 91
diff changeset
    14
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 91
diff changeset
    15
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
    16
91
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
    17
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
    18
lemma enrich_msgq_s2ss:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
    19
  ""
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
    20
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
    21
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
    22
thm cp2sproc_def
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
    23
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    24
(* enrich s target_proc duplicated_pro *)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    25
fun enrich_proc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> nat \<Rightarrow> t_state"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    26
where 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    27
  "enrich_proc [] tp dp n = []"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    28
| "enrich_proc (Execve p f fds # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    29
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    30
     then Execve dp f (fds \<inter> proc_file_fds s p) # Execve p f fds # (enrich_proc s tp dp n)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    31
     else Execve p f fds # (enrich_proc s tp dp n))"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    32
| "enrich_proc (Clone p p' fds # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    33
     if (tp = p') 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    34
     then Clone p dp (fds \<inter> proc_file_fds s p) # Clone p p' fds # s
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    35
     else Clone p p' fds # (enrich_proc s tp dp n))"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    36
| "enrich_proc (Open p f flags fd opt # s) tp dp n= (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    37
     if (tp = p)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    38
     then Open dp f (remove_create_flag flags) fd None # Open p f flags fd opt # (enrich_proc s tp dp n)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    39
     else Open p f flags fd opt # (enrich_proc s tp dp n))"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    40
| "enrich_proc (ReadFile p fd # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    41
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    42
     then ReadFile dp fd # ReadFile p fd # (enrich_proc s tp dp n)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    43
     else ReadFile p fd # (enrich_proc s tp dp n))"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    44
| "enrich_proc (RecvMsg p q m # s) tp dp n = (
88
chunhan
parents: 87
diff changeset
    45
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    46
     then RecvMsg dp n m # RecvMsg p q m # (enrich_msgq (enrich_proc s tp dp (n+1)) q n)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    47
     else RecvMsg p q m # (enrich_proc s tp dp n))"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    48
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    49
| "enrich_proc (CloseFd p fd # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    50
     if (tp = p \<and> fd \<in> proc_file_fds s p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    51
     then CloseFd dp fd # CloseFd p fd # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    52
     else CloseFd p fd # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    53
*)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    54
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    55
| "enrich_proc (Attach p h flag # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    56
     if (tp = p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    57
     then Attach dp h flag # Attach p h flag # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    58
     else Attach p h flag # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    59
| "enrich_proc (Detach p h # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    60
     if (tp = p) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    61
     then Detach dp h # Detach p h # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    62
     else Detach p h # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    63
*)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    64
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    65
| "enrich_proc (Kill p p' # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    66
     if (tp = p') then Kill p p' # s
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    67
     else Kill p p' # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    68
| "enrich_proc (Exit p # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    69
     if (tp = p) then Exit p # s
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    70
     else Exit p # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    71
*)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    72
| "enrich_proc (e # s) tp dp n = e # (enrich_proc s tp dp n)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    73
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    74
definition is_created_proc:: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    75
where
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    76
  "is_created_proc s p \<equiv> p \<in> current_procs s \<and> (p \<in> init_procs \<longrightarrow> died (O_proc p) s)"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    77
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    78
definition is_created_proc':: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    79
where
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    80
  "is_created_proc' s p \<equiv> p \<in> current_procs s \<and> p \<notin> init_procs"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    81
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    82
lemma created_proc_clone:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    83
  "valid (Clone p p' fds # s) \<Longrightarrow> 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    84
   is_created_proc (Clone p p' fds # s) tp = (if (tp = p') then True else is_created_proc s tp)"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    85
apply (drule vt_grant_os)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    86
apply (auto simp:is_created_proc_def dest:not_all_procs_prop2)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    87
using not_died_init_proc
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    88
by auto
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    89
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    90
lemma created_proc_exit: 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    91
  "is_created_proc (Exit p # s) tp = (if (tp = p) then False else is_created_proc s tp)"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    92
by (simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    93
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    94
lemma created_proc_kill:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    95
  "is_created_proc (Kill p p' # s) tp = (if (tp = p') then False else is_created_proc s tp)"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    96
by (simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    97
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    98
lemma created_proc_other:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    99
  "\<lbrakk>\<And> p p' fds. e \<noteq> Clone p p' fds;
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   100
    \<And> p. e \<noteq> Exit p;
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   101
    \<And> p p'. e \<noteq> Kill p p'\<rbrakk> \<Longrightarrow> is_created_proc (e # s) tp = is_created_proc s tp"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   102
by (case_tac e, auto simp:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   103
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   104
lemmas is_created_proc_simps = created_proc_clone created_proc_exit created_proc_kill created_proc_other
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   105
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   106
lemma no_del_died:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   107
  "\<lbrakk>no_del_event s; died obj s\<rbrakk> \<Longrightarrow> (\<exists> p fd. obj = O_fd p fd \<or> obj = O_tcp_sock (p, fd) \<or> obj = O_udp_sock (p, fd))
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   108
  \<or> (\<exists> q m. obj = O_msg q m) "
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   109
apply (induct s)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   110
apply simp
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   111
apply (case_tac a)
82
chunhan
parents:
diff changeset
   112
apply (auto split:option.splits)
chunhan
parents:
diff changeset
   113
done
chunhan
parents:
diff changeset
   114
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   115
lemma no_del_created_eq:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   116
  "no_del_event s \<Longrightarrow> is_created_proc s p = is_created_proc' s p"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   117
apply (induct s)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   118
apply (simp add:is_created_proc_def is_created_proc'_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   119
apply (case_tac a)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   120
apply (auto simp add:is_created_proc_def is_created_proc'_def dest:no_del_died)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   121
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   122
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   123
lemma enrich_proc_dup_in:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   124
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   125
   \<Longrightarrow> p' \<in> current_procs (enrich_proc s p p' i)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   126
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   127
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   128
apply (case_tac a)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   129
apply ( auto simp:is_created_proc_def Let_def enrich_msgq_cur_procs
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   130
  dest:not_all_procs_prop3)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   131
sorry
82
chunhan
parents:
diff changeset
   132
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   133
lemma enrich_proc_dup_ffd:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   134
  "\<lbrakk>file_of_proc_fd s p fd = Some f; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   135
   \<Longrightarrow> file_of_proc_fd (enrich_proc s p p' i) p' fd = Some f"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   136
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   137
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   138
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def Let_def
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   139
  dest:not_all_procs_prop3 split:if_splits option.splits)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   140
sorry
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   141
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   142
lemma enrich_proc_dup_ffd':
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   143
  "\<lbrakk>file_of_proc_fd (enrich_proc s p p' i) p' fd = Some f; is_created_proc s p; p' \<notin> all_procs s;
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   144
    no_del_event s; valid s\<rbrakk>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   145
   \<Longrightarrow> file_of_proc_fd s p fd = Some f"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   146
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   147
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   148
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def Let_def
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   149
  dest:not_all_procs_prop3 split:if_splits option.splits)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   150
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   151
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   152
lemma enrich_proc_dup_ffd_eq:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   153
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   154
  \<Longrightarrow> file_of_proc_fd (enrich_proc s p p' i) p' fd = file_of_proc_fd s p fd"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   155
apply (case_tac "file_of_proc_fd s p fd")
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   156
apply (case_tac[!] "file_of_proc_fd (enrich_proc s p p' i) p' fd")
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   157
apply (auto dest:enrich_proc_dup_ffd enrich_proc_dup_ffd')
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   158
apply (drule_tac i = i in enrich_proc_dup_ffd, simp+)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   159
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   160
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   161
lemma enrich_proc_cur_msgqs:
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   162
  "\<lbrakk>valid s\<rbrakk> \<Longrightarrow> current_msgqs (enrich_proc s p p' i) = current_msgqs s \<union> {q'. q' \<ge> new_msgq s \<and> q' \<le> new_msgq s + (nums_of_recvmsg s p) - 1}"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   163
apply (induct s, simp)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   164
apply (auto)[1]
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   165
apply (drule new_msgq_1, simp, simp)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   166
apply (frule vt_grant_os, frule vd_cons)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   167
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   168
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   169
lemma enrich_proc_not_alive:
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   170
  "\<lbrakk>enrich_not_alive s (E_proc p' (new_msgq s) (new_msgq s + (nums_of_recvmsg s p) - 1)) obj; 
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   171
    is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   172
  \<Longrightarrow> enrich_not_alive (enrich_proc s p p' (new_msgq s)) (E_proc p' (new_msgq s) (new_msgq s + (nums_of_recvmsg s p) - 1)) obj"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   173
apply (case_tac obj, simp_all)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   174
prefer 5
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   175
apply (simp add:enrich_proc_cur_msgqs)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   176
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   177
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   178
apply (auto)[1]
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   179
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   180
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   181
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   182
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   183
apply (subgoal_tac "new_msgq s \<noteq> 0")
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   184
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   185
apply arith
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   186
apply (simp_all add:enrich_proc_cur_procs enrich_proc_cur_files enrich_proc_cur_inums 
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   187
  enrich_proc_cur_msgqs enrich_proc_cur_msgs enrich_proc_cur_fds)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   188
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   189
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   190
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   191
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   192
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   193
lemma enrich_proc_dup_fflags:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   194
  "\<lbrakk>flags_of_proc_fd s p fd = Some flag; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   195
   \<Longrightarrow> flags_of_proc_fd (enrich_proc s p p') p' fd = Some (remove_create_flag flag) \<or>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   196
       flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   197
apply (induct s arbitrary:p, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   198
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   199
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def is_creat_flag_def Let_def
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   200
  dest:not_all_procs_prop3 split:if_splits option.splits)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   201
sorry
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   202
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   203
lemma enrich_proc_dup_ffds:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   204
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   205
   \<Longrightarrow> proc_file_fds (enrich_proc s p p') p' = proc_file_fds s p"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   206
apply (auto simp:proc_file_fds_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   207
apply (rule_tac x = f in exI) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   208
apply (erule enrich_proc_dup_ffd', simp+)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   209
apply (rule_tac x = f in exI)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   210
apply (erule enrich_proc_dup_ffd, simp+)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   211
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   212
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   213
lemma enrich_proc_dup_ffds_eq_fds:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   214
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   215
   \<Longrightarrow> current_proc_fds (enrich_proc s p p') p' = proc_file_fds s p"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   216
apply (induct s arbitrary:p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   217
apply (simp add: is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   218
apply (frule not_all_procs_prop3)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   219
apply (frule vd_cons, frule vt_grant_os, case_tac a)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   220
apply (auto split:if_splits option.splits dest:proc_fd_in_fds set_mp not_all_procs_prop3 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   221
  simp:proc_file_fds_def is_created_proc_def Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   222
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   223
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   224
lemma enrich_proc_dup_ffds':
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   225
  "\<lbrakk>fd \<notin> current_proc_fds (enrich_proc s p p') p'; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   226
   \<Longrightarrow> fd \<notin> proc_file_fds s p \<and> file_of_proc_fd s p fd = None"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   227
apply (auto simp:enrich_proc_dup_ffds_eq_fds)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   228
apply (simp add:proc_file_fds_def)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   229
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   230
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   231
lemma enrich_proc_cur_inof:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   232
  "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> inum_of_file (enrich_proc s p p') f = inum_of_file s f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   233
apply (induct s arbitrary:f)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   234
apply simp
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   235
apply (frule vd_cons, frule vt_grant_os, frule vt_grant)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   236
apply (case_tac a, auto)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   237
apply (auto split:option.splits simp del:grant.simps simp add:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   238
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   239
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   240
lemma not_all_procs_sock:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   241
  "\<lbrakk>p' \<notin> all_procs s; valid s\<rbrakk> \<Longrightarrow> inum_of_socket s (p', fd) = None"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   242
apply (frule not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   243
apply (case_tac "inum_of_socket s (p', fd)", simp_all)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   244
apply (drule cn_in_curp', simp+)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   245
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   246
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   247
lemma enrich_proc_cur_inos:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   248
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   249
   \<Longrightarrow> inum_of_socket (enrich_proc s p p') (tp, fd) = inum_of_socket s (tp, fd)"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   250
apply (induct s arbitrary:tp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   251
apply simp
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   252
apply (frule vd_cons, frule vt_grant_os)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   253
apply (case_tac a, auto split:option.splits simp:not_all_procs_sock Let_def)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   254
apply (simp add:proc_file_fds_def, erule exE)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   255
apply (case_tac "inum_of_socket s (nat1, fd)", simp_all)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   256
apply (drule filefd_socket_conflict, simp_all add:current_sockets_def)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   257
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   258
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   259
lemma enrich_proc_cur_inums:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   260
  "\<lbrakk>p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   261
   \<Longrightarrow> current_inode_nums (enrich_proc s p p') = current_inode_nums s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   262
apply (auto simp:current_inode_nums_def current_file_inums_def 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   263
  current_sock_inums_def enrich_proc_cur_inof enrich_proc_cur_inos)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   264
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   265
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   266
lemma enrich_proc_cur_itag:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   267
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   268
   \<Longrightarrow> itag_of_inum (enrich_proc s p p') i = itag_of_inum s i"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   269
apply (induct s)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   270
apply simp
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   271
apply (frule vd_cons, frule vt_grant_os)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   272
apply (case_tac a, auto split:option.splits t_socket_type.splits simp:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   273
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   274
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   275
lemma enrich_proc_cur_tcps:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   276
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   277
   \<Longrightarrow> is_tcp_sock (enrich_proc s p p') = is_tcp_sock s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   278
apply (rule ext, case_tac x)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   279
apply (auto simp add:is_tcp_sock_def enrich_proc_cur_itag enrich_proc_cur_inos
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   280
  split:option.splits t_inode_tag.splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   281
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   282
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   283
lemma enrich_proc_cur_udps:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   284
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   285
   \<Longrightarrow> is_udp_sock (enrich_proc s p p') = is_udp_sock s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   286
apply (rule ext, case_tac x)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   287
apply (auto simp add:is_udp_sock_def enrich_proc_cur_itag enrich_proc_cur_inos 
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   288
  split:option.splits t_inode_tag.splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   289
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   290
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   291
lemma enrich_proc_cur_msgqs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   292
  "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> q \<in> current_msgqs (enrich_proc s p p')"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   293
apply (induct s, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   294
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   295
apply (case_tac a, auto simp:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   296
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   297
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   298
lemma enrich_proc_cur_msgs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   299
  "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   300
apply (induct s, simp)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   301
apply (frule_tac p = p and p' = p' in enrich_proc_cur_msgqs, simp)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   302
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   303
apply (case_tac a, auto simp:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   304
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   305
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   306
lemma enrich_proc_cur_procs:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   307
  "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   308
   \<Longrightarrow> current_procs (enrich_proc s p p') = current_procs s \<union> {p'}"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   309
apply (induct s, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   310
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   311
apply (case_tac a, auto simp:is_created_proc_simps Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   312
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   313
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   314
lemma enrich_proc_cur_files:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   315
  "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> current_files (enrich_proc s p p') = current_files s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   316
apply (auto simp:current_files_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   317
apply (simp add: enrich_proc_cur_inof)+
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   318
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   319
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   320
lemma enrich_proc_cur_fds1:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   321
  "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s; tp \<in> current_procs s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   322
   \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = current_proc_fds s tp"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   323
apply (induct s, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   324
apply (frule vt_grant_os, frule vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   325
apply (frule not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   326
apply (case_tac a)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   327
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   328
(*
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   329
apply (auto simp:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   330
done
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   331
*)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   332
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   333
lemma enrich_proc_cur_fds1':
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   334
  "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s; tp \<noteq> p'\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   335
   \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = current_proc_fds s tp"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   336
apply (induct s, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   337
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   338
apply (frule not_all_procs_prop3) sorry  (*
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   339
apply (case_tac a)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   340
apply (auto simp:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   341
done
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   342
*)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   343
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   344
lemma enrich_proc_cur_fds:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   345
  "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   346
   \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = (if (tp = p') then proc_file_fds s p else current_proc_fds s tp)"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   347
apply (simp add:enrich_proc_cur_fds1' enrich_proc_dup_ffds_eq_fds split:if_splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   348
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   349
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   350
lemma enrich_proc_not_alive:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   351
  "\<lbrakk>enrich_not_alive s (E_proc p') obj; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   352
  \<Longrightarrow> enrich_not_alive (enrich_proc s p p') (E_proc p') obj"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   353
apply (case_tac obj)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   354
apply (simp_all add:enrich_proc_cur_procs enrich_proc_cur_files enrich_proc_cur_inums 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   355
  enrich_proc_cur_msgqs enrich_proc_cur_msgs enrich_proc_cur_fds)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   356
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   357
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   358
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   359
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   360
lemma enrich_proc_filefd:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   361
  "\<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   362
  \<Longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   363
apply (induct s arbitrary:tp, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   364
apply (frule vt_grant_os, frule vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   365
apply (frule not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   366
apply (case_tac a)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   367
apply (auto simp:is_created_proc_simps dest:proc_fd_in_procs split:if_splits)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   368
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   369
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   370
lemma enrich_proc_flagfd:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   371
  "\<lbrakk>flags_of_proc_fd s tp fd = Some f; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   372
  \<Longrightarrow> flags_of_proc_fd (enrich_proc s p p') tp fd = Some f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   373
apply (induct s arbitrary:tp, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   374
apply (frule vt_grant_os, frule vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   375
apply (frule not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   376
apply (case_tac a)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   377
apply (auto simp:is_created_proc_simps dest:proc_fd_in_procs current_fflag_has_ffd split:if_splits option.splits)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   378
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   379
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   380
lemma enrich_proc_hungs:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   381
  "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> files_hung_by_del (enrich_proc s p p') = files_hung_by_del s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   382
apply (induct s, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   383
apply (frule vt_grant_os, frule vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   384
apply (case_tac a, auto simp:files_hung_by_del.simps)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   385
sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   386
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   387
lemma enrich_proc_is_file:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   388
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   389
   \<Longrightarrow> is_file (enrich_proc s p p') = is_file s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   390
apply (rule ext, case_tac x)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   391
apply (auto simp add:is_file_def enrich_proc_cur_itag enrich_proc_cur_inof
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   392
  split:option.splits t_inode_tag.splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   393
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   394
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   395
lemma enrich_proc_is_dir:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   396
  "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   397
   \<Longrightarrow> is_dir (enrich_proc s p p') = is_dir s"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   398
apply (rule ext, case_tac x)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   399
apply (auto simp add:is_dir_def enrich_proc_cur_itag enrich_proc_cur_inof
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   400
  split:option.splits t_inode_tag.splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   401
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   402
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   403
lemma enrich_proc_alive:
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   404
  "\<lbrakk>alive s obj; valid s; is_created_proc s p; p' \<notin> all_procs s; no_del_event s\<rbrakk>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   405
   \<Longrightarrow> alive (enrich_proc s p p') obj"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   406
apply (case_tac obj)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   407
apply (simp_all add:enrich_proc_is_file enrich_proc_is_dir enrich_proc_cur_msgqs 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   408
  enrich_proc_cur_msgs enrich_proc_cur_procs enrich_proc_cur_fds
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   409
  enrich_proc_cur_tcps enrich_proc_cur_udps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   410
apply (rule impI, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   411
apply (drule current_proc_fds_in_curp, simp, simp add:not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   412
done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   413
82
chunhan
parents:
diff changeset
   414
lemma enrich_proc_prop:
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   415
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s; no_del_event s\<rbrakk>
82
chunhan
parents:
diff changeset
   416
   \<Longrightarrow> valid (enrich_proc s p p') \<and> 
chunhan
parents:
diff changeset
   417
       (\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
chunhan
parents:
diff changeset
   418
       (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and> 
chunhan
parents:
diff changeset
   419
       (\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and> 
chunhan
parents:
diff changeset
   420
       (\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>
chunhan
parents:
diff changeset
   421
       (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
chunhan
parents:
diff changeset
   422
       (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
chunhan
parents:
diff changeset
   423
proof (induct s)
chunhan
parents:
diff changeset
   424
  case Nil
chunhan
parents:
diff changeset
   425
  thus ?case by (auto simp:is_created_proc_def)
chunhan
parents:
diff changeset
   426
next
chunhan
parents:
diff changeset
   427
  case (Cons e s)
83
chunhan
parents: 82
diff changeset
   428
  hence vd_cons': "valid (e # s)" and created_cons: "is_created_proc (e # s) p"
82
chunhan
parents:
diff changeset
   429
    and all_procs_cons: "p' \<notin> all_procs (e # s)" and vd: "valid s" 
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   430
    and os: "os_grant s e" and grant: "grant s e" 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   431
    and nodel_cons: "no_del_event (e # s)"
83
chunhan
parents: 82
diff changeset
   432
    by (auto dest:vd_cons' vt_grant_os vt_grant)
82
chunhan
parents:
diff changeset
   433
  from all_procs_cons have all_procs: "p' \<notin> all_procs s" by (case_tac e, auto)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   434
  from nodel_cons have nodel: "no_del_event s" by (case_tac e, auto)
82
chunhan
parents:
diff changeset
   435
  from Cons have pre: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p') \<and>
chunhan
parents:
diff changeset
   436
     (\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
chunhan
parents:
diff changeset
   437
     (\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
chunhan
parents:
diff changeset
   438
     (\<forall>q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
chunhan
parents:
diff changeset
   439
     (\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>     
chunhan
parents:
diff changeset
   440
     (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
chunhan
parents:
diff changeset
   441
     (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   442
    using vd all_procs nodel by auto
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   443
  
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   444
  from pre have pre_vd: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p')" by simp
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   445
  have vd_enrich:"is_created_proc s p \<Longrightarrow> valid (e # enrich_proc s p p')" 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   446
    apply (frule pre_vd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   447
    apply (erule_tac s = s and obj' = "E_proc p'" in enrich_valid_intro_cons)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   448
    apply (simp_all add: pre nodel_cons all_procs_cons vd_cons')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   449
    apply (clarsimp simp:enrich_proc_alive nodel all_procs vd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   450
    apply (rule allI, rule impI, erule enrich_proc_not_alive)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   451
    apply (simp_all add:nodel all_procs vd enrich_proc_hungs enrich_proc_cur_msgs)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   452
    apply ((rule allI| rule impI)+, erule enrich_proc_filefd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   453
    apply (simp_all add:nodel all_procs vd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   454
    apply ((rule allI| rule impI)+, erule enrich_proc_flagfd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   455
    apply (simp_all add:nodel all_procs vd)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   456
    done  
82
chunhan
parents:
diff changeset
   457
  have vd_enrich_cons: "valid (enrich_proc (e # s) p p')"
chunhan
parents:
diff changeset
   458
  proof-
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   459
    have "\<And>f fds. \<lbrakk>valid (Execve p f fds # enrich_proc s p p'); is_created_proc s p; 
82
chunhan
parents:
diff changeset
   460
      valid (Execve p f fds # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
   461
      \<Longrightarrow> valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
chunhan
parents:
diff changeset
   462
    proof-
chunhan
parents:
diff changeset
   463
      fix f fds
chunhan
parents:
diff changeset
   464
      assume a1: "valid (Execve p f fds # enrich_proc s p p')" and a2: "is_created_proc s p"
chunhan
parents:
diff changeset
   465
        and a3: "valid (Execve p f fds # s)" and a0: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
   466
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
   467
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
   468
        and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
chunhan
parents:
diff changeset
   469
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
   470
        and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   471
        using pre a2
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   472
        by auto
82
chunhan
parents:
diff changeset
   473
      show "valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
chunhan
parents:
diff changeset
   474
      proof-
chunhan
parents:
diff changeset
   475
        from a0 a3 have a0': "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
chunhan
parents:
diff changeset
   476
        from a3 have grant: "grant s (Execve p f fds)" and os: "os_grant s (Execve p f fds)"
chunhan
parents:
diff changeset
   477
          by (auto dest:vt_grant_os vt_grant simp del:os_grant.simps)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   478
        have f_in: "is_file (enrich_proc s p p') f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   479
          using vd nodel os all_procs
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   480
          by (auto dest:vt_grant_os simp:enrich_proc_is_file)
82
chunhan
parents:
diff changeset
   481
        moreover have a5: "proc_file_fds s p \<subseteq> proc_file_fds (Execve p f fds # enrich_proc s p p') p'" 
chunhan
parents:
diff changeset
   482
          using a3 a0'
chunhan
parents:
diff changeset
   483
          apply (frule_tac vt_grant_os)
chunhan
parents:
diff changeset
   484
          apply (auto simp:proc_file_fds_def)
chunhan
parents:
diff changeset
   485
          apply (rule_tac x = fa in exI)
chunhan
parents:
diff changeset
   486
          apply (erule enrich_proc_dup_ffd)
chunhan
parents:
diff changeset
   487
          apply (simp_all add:vd all_procs a2)
chunhan
parents:
diff changeset
   488
          done
chunhan
parents:
diff changeset
   489
        ultimately have "os_grant (Execve p f fds # enrich_proc s p p') (Execve p' f (fds \<inter> proc_file_fds s p))"
chunhan
parents:
diff changeset
   490
          apply (auto simp:is_file_simps enrich_proc_dup_in a2 vd all_procs a1 enrich_proc_dup_ffds)
chunhan
parents:
diff changeset
   491
          done
chunhan
parents:
diff changeset
   492
        moreover have "grant (Execve p f fds # enrich_proc s p p') (Execve p' f (fds \<inter> proc_file_fds s p))"
chunhan
parents:
diff changeset
   493
        proof-
chunhan
parents:
diff changeset
   494
          from grant obtain up rp tp uf rf tf 
chunhan
parents:
diff changeset
   495
            where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents:
diff changeset
   496
            and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
   497
            by (simp split:option.splits, blast)
chunhan
parents:
diff changeset
   498
          with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
chunhan
parents:
diff changeset
   499
            by (simp split:option.splits del:npctxt_execve.simps, blast)
chunhan
parents:
diff changeset
   500
          have p1': "sectxt_of_obj (Execve p f fds # enrich_proc s p p') (O_proc p') = Some (up, rp, tp)"
chunhan
parents:
diff changeset
   501
            using p1 dup_sp a1 a0'
chunhan
parents:
diff changeset
   502
            apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   503
            by (simp add:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
   504
          from os have f_in': "is_file s f"  by simp 
chunhan
parents:
diff changeset
   505
          from vd os have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   506
            by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
   507
          hence p2': "sectxt_of_obj (Execve p f fds # enrich_proc s p p') (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
   508
            using f_in p2 cf2sf os a1
chunhan
parents:
diff changeset
   509
            apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
   510
            apply (auto dest:is_file_in_current simp:cf2sfile_def sectxt_of_obj_simps split:option.splits)
chunhan
parents:
diff changeset
   511
            apply (case_tac f, simp)
chunhan
parents:
diff changeset
   512
            apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents:
diff changeset
   513
            done 
chunhan
parents:
diff changeset
   514
          from dup_sfd a5 have "\<forall>fd. fd \<in> proc_file_fds s p \<longrightarrow> 
chunhan
parents:
diff changeset
   515
            cfd2sfd (Execve p f fds # enrich_proc s p p') p' fd = cfd2sfd s p fd"
chunhan
parents:
diff changeset
   516
            apply (rule_tac allI)
chunhan
parents:
diff changeset
   517
            apply (erule_tac x = fd in allE, clarsimp)
chunhan
parents:
diff changeset
   518
            apply (drule set_mp, simp)
chunhan
parents:
diff changeset
   519
            apply (auto simp:cfd2sfd_execve proc_file_fds_def a1)
chunhan
parents:
diff changeset
   520
            done
chunhan
parents:
diff changeset
   521
          hence "inherit_fds_check (Execve p f fds # enrich_proc s p p') (up, nr, nt) p' (fds \<inter> proc_file_fds s p)"
chunhan
parents:
diff changeset
   522
            using grant os p1 p2 p3 vd
chunhan
parents:
diff changeset
   523
            apply (clarsimp)
chunhan
parents:
diff changeset
   524
            apply (rule_tac s = s and p = p and fds = fds in enrich_inherit_fds_check_dup)
chunhan
parents:
diff changeset
   525
            apply simp_all
chunhan
parents:
diff changeset
   526
            done
chunhan
parents:
diff changeset
   527
          moreover have "search_check (Execve p f fds # enrich_proc s p p') (up, rp, tp) f"
chunhan
parents:
diff changeset
   528
            using p1 p2 p2' vd cf2sf f_in f_in' grant p3 f_in a1
chunhan
parents:
diff changeset
   529
            apply (rule_tac s = s in enrich_search_check)
chunhan
parents:
diff changeset
   530
            apply (simp_all add:is_file_simps)
chunhan
parents:
diff changeset
   531
            apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
chunhan
parents:
diff changeset
   532
            apply (drule_tac ff = fa in cf2sfile_other')
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   533
            apply (auto simp:a2 enrich_proc_cur_files nodel)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   534
            done
82
chunhan
parents:
diff changeset
   535
          ultimately show ?thesis 
chunhan
parents:
diff changeset
   536
            using p1' p2' p3
chunhan
parents:
diff changeset
   537
            apply (simp split:option.splits)
chunhan
parents:
diff changeset
   538
            using grant p1 p2
chunhan
parents:
diff changeset
   539
            apply simp
chunhan
parents:
diff changeset
   540
            done
chunhan
parents:
diff changeset
   541
        qed
chunhan
parents:
diff changeset
   542
        ultimately show ?thesis using a1
chunhan
parents:
diff changeset
   543
          by (erule_tac valid.intros(2), auto)
chunhan
parents:
diff changeset
   544
      qed
chunhan
parents:
diff changeset
   545
    qed
chunhan
parents:
diff changeset
   546
    moreover have "\<And>tp fds. \<lbrakk>valid (Clone tp p fds # s); p' \<noteq> p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> 
chunhan
parents:
diff changeset
   547
      valid (Clone tp p' (fds \<inter> proc_file_fds s tp) # Clone tp p fds # s)"
chunhan
parents:
diff changeset
   548
      apply (frule vt_grant_os, frule vt_grant, drule not_all_procs_prop3)
chunhan
parents:
diff changeset
   549
      apply (rule valid.intros(2))
chunhan
parents:
diff changeset
   550
      apply (simp_all split:option.splits add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   551
      apply (auto simp add:proc_file_fds_def)[1]
chunhan
parents:
diff changeset
   552
      apply (auto simp:inherit_fds_check_def sectxt_of_obj_simps sectxts_of_fds_def inherit_fds_check_ctxt_def)
chunhan
parents:
diff changeset
   553
      done
chunhan
parents:
diff changeset
   554
    moreover have "\<And>f flags fd opt. \<lbrakk>valid (Open p f flags fd opt # enrich_proc s p p'); 
chunhan
parents:
diff changeset
   555
      is_created_proc s p; valid (Open p f flags fd opt # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
   556
       \<Longrightarrow> valid (Open p' f (remove_create_flag flags) fd None # Open p f flags fd opt # enrich_proc s p p')"
chunhan
parents:
diff changeset
   557
    proof-
chunhan
parents:
diff changeset
   558
      fix f flags fd opt
chunhan
parents:
diff changeset
   559
      assume a1: "valid (Open p f flags fd opt # enrich_proc s p p')" and a2: "is_created_proc s p"
chunhan
parents:
diff changeset
   560
        and a3: "valid (Open p f flags fd opt # s)" and a4: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
   561
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
   562
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
   563
        and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
chunhan
parents:
diff changeset
   564
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
   565
        and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
chunhan
parents:
diff changeset
   566
        using pre a2 by auto
chunhan
parents:
diff changeset
   567
      from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3 split:option.splits)
chunhan
parents:
diff changeset
   568
      have a5: "p' \<in> current_procs (enrich_proc s p p')" 
chunhan
parents:
diff changeset
   569
        using a2 a3 vd
chunhan
parents:
diff changeset
   570
        apply (erule_tac enrich_proc_dup_in)
chunhan
parents:
diff changeset
   571
        by (simp_all add:vd a4)
chunhan
parents:
diff changeset
   572
      have a6: "is_file (Open p f flags fd opt # enrich_proc s p p') f"
chunhan
parents:
diff changeset
   573
        using a1 a3
chunhan
parents:
diff changeset
   574
        by (auto simp:is_file_open dest:vt_grant_os)
chunhan
parents:
diff changeset
   575
      have a7: "fd \<notin> current_proc_fds (enrich_proc s p p') p'"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   576
        using a2 a4 vd nodel
82
chunhan
parents:
diff changeset
   577
        apply (simp add:enrich_proc_dup_ffds_eq_fds)
chunhan
parents:
diff changeset
   578
        apply (rule notI)
chunhan
parents:
diff changeset
   579
        apply (drule_tac p = p in file_fds_subset_pfds)
chunhan
parents:
diff changeset
   580
        apply (drule set_mp, simp)
chunhan
parents:
diff changeset
   581
        using a3
chunhan
parents:
diff changeset
   582
        apply (drule_tac vt_grant_os)
chunhan
parents:
diff changeset
   583
        apply (auto split:option.splits)
chunhan
parents:
diff changeset
   584
        done
chunhan
parents:
diff changeset
   585
      from a1 have a8: "valid (enrich_proc s p p')" by (erule_tac valid.cases, auto)
chunhan
parents:
diff changeset
   586
      from a3 have grant: "grant s (Open p f flags fd opt)" and os: "os_grant s (Open p f flags fd opt)"
chunhan
parents:
diff changeset
   587
        by (auto dest:vt_grant_os vt_grant)
chunhan
parents:
diff changeset
   588
      show "valid (Open p' f (remove_create_flag flags) fd None # Open p f flags fd opt # enrich_proc s p p')"
chunhan
parents:
diff changeset
   589
      proof (cases opt)
chunhan
parents:
diff changeset
   590
        case None
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   591
        have f_in: "is_file (enrich_proc s p p') f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   592
          using vd nodel os all_procs None
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   593
          by (auto dest:vt_grant_os simp:enrich_proc_is_file) 
82
chunhan
parents:
diff changeset
   594
        from grant None obtain up rp tp uf rf tf 
chunhan
parents:
diff changeset
   595
          where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents:
diff changeset
   596
          and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
   597
          apply (simp split:option.splits)
chunhan
parents:
diff changeset
   598
          by (case_tac a, case_tac aa, blast)
chunhan
parents:
diff changeset
   599
        have p1': "sectxt_of_obj (Open p f flags fd opt # enrich_proc s p p') (O_proc p') = Some (up, rp, tp)"
chunhan
parents:
diff changeset
   600
          using p1 dup_sp a1
chunhan
parents:
diff changeset
   601
          apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   602
          by (simp add:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
   603
        from os None have f_in': "is_file s f" by simp 
chunhan
parents:
diff changeset
   604
        from vd os None have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   605
          by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
   606
        hence p2': "sectxt_of_obj (Open p f flags fd opt # enrich_proc s p p') (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
   607
          using p2 cf2sf os a1 None f_in' vd f_in
chunhan
parents:
diff changeset
   608
          apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
   609
          apply (auto dest:is_file_in_current simp:cf2sfile_def sectxt_of_obj_simps split:option.splits)
chunhan
parents:
diff changeset
   610
          apply (case_tac f, simp)
chunhan
parents:
diff changeset
   611
          apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents:
diff changeset
   612
          done 
chunhan
parents:
diff changeset
   613
        have "search_check (Open p f flags fd opt # enrich_proc s p p') (up, rp, tp) f"
chunhan
parents:
diff changeset
   614
          using p1 p2 p2' vd cf2sf f_in f_in' grant f_in a1 None
chunhan
parents:
diff changeset
   615
          apply (rule_tac s = s in enrich_search_check)
chunhan
parents:
diff changeset
   616
          apply (simp_all add:is_file_simps)
chunhan
parents:
diff changeset
   617
          apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
chunhan
parents:
diff changeset
   618
          apply (simp add:cf2sfile_open_none)
chunhan
parents:
diff changeset
   619
          done
chunhan
parents:
diff changeset
   620
        thus ?thesis using a0 a5 a6 a7 None a1
chunhan
parents:
diff changeset
   621
          apply (rule_tac valid.intros(2))
chunhan
parents:
diff changeset
   622
          apply (simp_all add:a1)
chunhan
parents:
diff changeset
   623
          apply (case_tac flags, simp add:is_creat_excl_flag_def)
chunhan
parents:
diff changeset
   624
          using p1' p2'
chunhan
parents:
diff changeset
   625
          apply simp
chunhan
parents:
diff changeset
   626
          using grant p1 p2
chunhan
parents:
diff changeset
   627
          apply (simp add:oflags_check_remove_create)
chunhan
parents:
diff changeset
   628
          done
chunhan
parents:
diff changeset
   629
      next
chunhan
parents:
diff changeset
   630
        case (Some inum)
chunhan
parents:
diff changeset
   631
        with os obtain pf where parent: "parent f = Some pf" by auto
chunhan
parents:
diff changeset
   632
        with grant Some obtain pu rp pt pfu pfr pft where
chunhan
parents:
diff changeset
   633
          p1: "sectxt_of_obj s (O_proc p) = Some (pu, rp, pt)" 
chunhan
parents:
diff changeset
   634
          and p2: "sectxt_of_obj s (O_dir pf) = Some (pfu, pfr, pft)"
chunhan
parents:
diff changeset
   635
          apply (simp split:option.splits)
chunhan
parents:
diff changeset
   636
          apply (case_tac a, case_tac aa, blast)
chunhan
parents:
diff changeset
   637
          done
chunhan
parents:
diff changeset
   638
        from p1 have p1': "sectxt_of_obj (enrich_proc s p p') (O_proc p) = Some (pu, rp, pt)"
chunhan
parents:
diff changeset
   639
          using cp2sp os
chunhan
parents:
diff changeset
   640
          apply (erule_tac x = p in allE)
chunhan
parents:
diff changeset
   641
          apply (auto split:option.splits simp:cp2sproc_def)
chunhan
parents:
diff changeset
   642
          done
chunhan
parents:
diff changeset
   643
        from os parent Some
chunhan
parents:
diff changeset
   644
        have pf_in: "is_dir s pf" by auto
chunhan
parents:
diff changeset
   645
        hence "\<exists> sf. cf2sfile s pf = Some sf" using vd
chunhan
parents:
diff changeset
   646
          by (auto dest!:is_dir_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
   647
        from a1 parent Some have pf_in': "is_dir (enrich_proc s p p') pf" 
chunhan
parents:
diff changeset
   648
          apply (frule_tac vt_grant_os)
chunhan
parents:
diff changeset
   649
          by (clarsimp)
chunhan
parents:
diff changeset
   650
        have p2': "sectxt_of_obj (enrich_proc s p p') (O_dir pf) = Some (pfu, pfr, pft)"
chunhan
parents:
diff changeset
   651
        proof-
chunhan
parents:
diff changeset
   652
          have "cf2sfile (enrich_proc s p p') pf = cf2sfile s pf"
chunhan
parents:
diff changeset
   653
            using cf2sf pf_in
chunhan
parents:
diff changeset
   654
            apply (drule_tac is_dir_in_current)
chunhan
parents:
diff changeset
   655
            apply (erule_tac x = pf in allE)
chunhan
parents:
diff changeset
   656
            by simp
chunhan
parents:
diff changeset
   657
          with pf_in pf_in' p2 vd Some a8
chunhan
parents:
diff changeset
   658
          show ?thesis            
chunhan
parents:
diff changeset
   659
            apply (frule_tac is_dir_not_file)
chunhan
parents:
diff changeset
   660
            apply (frule_tac s = "enrich_proc s p p'" in is_dir_not_file)
chunhan
parents:
diff changeset
   661
            apply (simp add:cf2sfile_def)
chunhan
parents:
diff changeset
   662
            apply (case_tac pf, simp) 
chunhan
parents:
diff changeset
   663
            apply (simp add:sroot_def root_sec_remains)            
chunhan
parents:
diff changeset
   664
            by (auto split:option.splits dest!:current_has_sec' get_pfs_secs_prop' dest:parentf_is_dir_prop1)        
chunhan
parents:
diff changeset
   665
        qed
chunhan
parents:
diff changeset
   666
        from p1 have dup: "sectxt_of_obj (Open p f flags fd (Some inum) # enrich_proc s p p') (O_proc p') 
chunhan
parents:
diff changeset
   667
          = Some (pu, rp, pt)"
chunhan
parents:
diff changeset
   668
          using a1 Some
chunhan
parents:
diff changeset
   669
          apply (simp add:sec_open)
chunhan
parents:
diff changeset
   670
          using dup_sp
chunhan
parents:
diff changeset
   671
          apply (auto split:option.splits if_splits simp:cp2sproc_def)
chunhan
parents:
diff changeset
   672
          done        
chunhan
parents:
diff changeset
   673
        have nsf: "sectxt_of_obj (Open p f flags fd (Some inum) # enrich_proc s p p') (O_file f) 
chunhan
parents:
diff changeset
   674
          = Some (pu, R_object, type_transition pt pft C_file True)"
chunhan
parents:
diff changeset
   675
          using a1 Some p1 p2 parent p2' p1'
chunhan
parents:
diff changeset
   676
          by (simp add:sec_open)
chunhan
parents:
diff changeset
   677
        have "search_check (Open p f flags fd (Some inum) # enrich_proc s p p') (pu, rp, pt) f"
chunhan
parents:
diff changeset
   678
        proof-
chunhan
parents:
diff changeset
   679
          have "search_check (Open p f flags fd (Some inum) # enrich_proc s p p') (pu, rp, pt) pf"
chunhan
parents:
diff changeset
   680
            using grant Some parent p1 p2 vd a1 pf_in pf_in' p2'
chunhan
parents:
diff changeset
   681
            apply simp 
chunhan
parents:
diff changeset
   682
            apply (rule_tac s = s in enrich_search_check') 
chunhan
parents:
diff changeset
   683
            apply (simp_all add:is_dir_simps sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   684
            apply (rule allI, rule impI)
chunhan
parents:
diff changeset
   685
            apply (case_tac "fa = f")
chunhan
parents:
diff changeset
   686
            using os Some
chunhan
parents:
diff changeset
   687
            apply simp
chunhan
parents:
diff changeset
   688
            apply (drule_tac f' = fa in cf2sfile_open)
chunhan
parents:
diff changeset
   689
            apply (simp add:current_files_simps)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   690
            using enrich_proc_cur_files a2 nodel
82
chunhan
parents:
diff changeset
   691
            apply simp
chunhan
parents:
diff changeset
   692
            apply simp
chunhan
parents:
diff changeset
   693
            using cf2sf
chunhan
parents:
diff changeset
   694
            apply simp
chunhan
parents:
diff changeset
   695
            done
chunhan
parents:
diff changeset
   696
          moreover have "is_file (Open p f flags fd (Some inum) # enrich_proc s p p') f"
chunhan
parents:
diff changeset
   697
            using a1 Some
chunhan
parents:
diff changeset
   698
            by (simp add:is_file_open)
chunhan
parents:
diff changeset
   699
          ultimately 
chunhan
parents:
diff changeset
   700
          show ?thesis
chunhan
parents:
diff changeset
   701
            using parent a1 Some nsf
chunhan
parents:
diff changeset
   702
            apply (erule_tac search_check_leveling_f)
chunhan
parents:
diff changeset
   703
            apply (simp_all)
chunhan
parents:
diff changeset
   704
            apply (simp add:search_check_file_def)
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   705
            (* create new file, grant only check pf's SEARCH permission, not newfile itself, so we make assumptions of this case in the locale *)
82
chunhan
parents:
diff changeset
   706
            apply (simp add:permission_check.simps)
chunhan
parents:
diff changeset
   707
            sorry
chunhan
parents:
diff changeset
   708
        qed
chunhan
parents:
diff changeset
   709
        thus ?thesis using a0 a5 a6 a7 a1 Some
chunhan
parents:
diff changeset
   710
          apply (rule_tac valid.intros(2))
chunhan
parents:
diff changeset
   711
          apply (simp add:a1)
chunhan
parents:
diff changeset
   712
          apply simp
chunhan
parents:
diff changeset
   713
          apply (case_tac flags, simp add:is_creat_excl_flag_def)
chunhan
parents:
diff changeset
   714
          using grant p1 p2 parent dup nsf
chunhan
parents:
diff changeset
   715
          apply (simp add:oflags_check_remove_create)
chunhan
parents:
diff changeset
   716
          done
chunhan
parents:
diff changeset
   717
      qed
chunhan
parents:
diff changeset
   718
    qed
chunhan
parents:
diff changeset
   719
    moreover have "\<And>fd. \<lbrakk>valid (CloseFd p fd # enrich_proc s p p'); is_created_proc s p; 
chunhan
parents:
diff changeset
   720
      valid (CloseFd p fd # s); p' \<notin> all_procs s; fd \<in> proc_file_fds s p\<rbrakk>
chunhan
parents:
diff changeset
   721
      \<Longrightarrow> valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
   722
    proof-
chunhan
parents:
diff changeset
   723
      fix fd
chunhan
parents:
diff changeset
   724
      assume a1: "valid (CloseFd p fd # enrich_proc s p p')" and a2: "is_created_proc s p" 
chunhan
parents:
diff changeset
   725
        and a3: "p' \<notin> all_procs s" and a4: "valid (CloseFd p fd # s)"
chunhan
parents:
diff changeset
   726
        and a5: "fd \<in> proc_file_fds s p"
chunhan
parents:
diff changeset
   727
      from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
chunhan
parents:
diff changeset
   728
      have "p' \<in> current_procs (enrich_proc s p p')" 
chunhan
parents:
diff changeset
   729
        using a2 a3 vd
chunhan
parents:
diff changeset
   730
        by (auto intro:enrich_proc_dup_in)
chunhan
parents:
diff changeset
   731
      moreover have "fd \<in> current_proc_fds (enrich_proc s p p') p'"      
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   732
        using a5 a2 a3 vd pre_vd nodel
82
chunhan
parents:
diff changeset
   733
        apply (simp)
chunhan
parents:
diff changeset
   734
        apply (drule_tac s = "enrich_proc s p p'" and p = p' in file_fds_subset_pfds)
chunhan
parents:
diff changeset
   735
        apply (erule set_mp)
chunhan
parents:
diff changeset
   736
        apply (simp add:enrich_proc_dup_ffds)
chunhan
parents:
diff changeset
   737
        done
chunhan
parents:
diff changeset
   738
      ultimately show "valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
   739
        apply (rule_tac valid.intros(2))
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   740
        apply (simp_all add:a1 a0 a2 pre_vd)
82
chunhan
parents:
diff changeset
   741
        done
chunhan
parents:
diff changeset
   742
    qed
chunhan
parents:
diff changeset
   743
    moreover have "\<And> fd. \<lbrakk>valid (ReadFile p fd # enrich_proc s p p');
chunhan
parents:
diff changeset
   744
            is_created_proc s p; valid (ReadFile p fd # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
   745
           \<Longrightarrow> valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
   746
    proof-
chunhan
parents:
diff changeset
   747
      fix fd
chunhan
parents:
diff changeset
   748
      assume a1: "valid (ReadFile p fd # enrich_proc s p p')" and a2: "is_created_proc s p"
chunhan
parents:
diff changeset
   749
        and a3: "valid (ReadFile p fd # s)" and a4: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
   750
      from a3 have os: "os_grant s (ReadFile p fd)" and grant: "grant s (ReadFile p fd)"
chunhan
parents:
diff changeset
   751
        by (auto dest:vt_grant_os vt_grant)
chunhan
parents:
diff changeset
   752
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
   753
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
   754
        and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
chunhan
parents:
diff changeset
   755
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
   756
        and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
chunhan
parents:
diff changeset
   757
        using pre a2 by auto
chunhan
parents:
diff changeset
   758
      have vd_enrich: "valid (enrich_proc s p p')" using a1 by (auto dest:valid.cases)
chunhan
parents:
diff changeset
   759
      show "valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
   760
      proof-
chunhan
parents:
diff changeset
   761
        have "os_grant (ReadFile p fd # enrich_proc s p p') (ReadFile p' fd)"
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   762
          using a1 a2 a4 vd os nodel
82
chunhan
parents:
diff changeset
   763
          apply (clarsimp simp:current_files_simps enrich_proc_dup_in enrich_proc_dup_ffds_eq_fds)
chunhan
parents:
diff changeset
   764
          apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
   765
          apply (rule conjI)
chunhan
parents:
diff changeset
   766
          apply (rule_tac x = f in exI, simp add:enrich_proc_dup_ffd)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   767
          using enrich_proc_cur_files
82
chunhan
parents:
diff changeset
   768
          apply (simp)
chunhan
parents:
diff changeset
   769
          apply (drule enrich_proc_dup_fflags)
chunhan
parents:
diff changeset
   770
          apply simp_all
chunhan
parents:
diff changeset
   771
          apply (erule disjE)
chunhan
parents:
diff changeset
   772
          apply auto
chunhan
parents:
diff changeset
   773
          apply (simp add:is_read_flag_def)
chunhan
parents:
diff changeset
   774
          done
chunhan
parents:
diff changeset
   775
        moreover have "grant (ReadFile p fd # enrich_proc s p p') (ReadFile p' fd)"
chunhan
parents:
diff changeset
   776
        proof-
chunhan
parents:
diff changeset
   777
          from grant obtain f sp sfd sf where p1: "file_of_proc_fd s p fd = Some f"
chunhan
parents:
diff changeset
   778
            and p2: "sectxt_of_obj s (O_proc p) = Some sp" 
chunhan
parents:
diff changeset
   779
            and p3: "sectxt_of_obj s (O_fd p fd) = Some sfd"
chunhan
parents:
diff changeset
   780
            and p4: "sectxt_of_obj s (O_file f) = Some sf"
chunhan
parents:
diff changeset
   781
            by (auto split:option.splits) 
chunhan
parents:
diff changeset
   782
          from os obtain flag where p0: "flags_of_proc_fd s p fd = Some flag"
chunhan
parents:
diff changeset
   783
            by auto
chunhan
parents:
diff changeset
   784
          from os have f_in_s: "f \<in> current_files s" using p1 by simp
chunhan
parents:
diff changeset
   785
          from p1 vd have isfile_s: "is_file s f" by (erule_tac file_of_pfd_is_file, simp)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   786
          hence isfile_s': "is_file (enrich_proc s p p') f"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   787
            using vd nodel all_procs a2
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
   788
            by (auto simp:enrich_proc_is_file) 
82
chunhan
parents:
diff changeset
   789
          from p0 obtain flag' where p0': "flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag'"
chunhan
parents:
diff changeset
   790
            and p0'': "(flag' = flag) \<or> (flag' = remove_create_flag flag)"
chunhan
parents:
diff changeset
   791
            using a2 a4 vd
chunhan
parents:
diff changeset
   792
            apply (drule_tac enrich_proc_dup_fflags)
chunhan
parents:
diff changeset
   793
            apply auto
chunhan
parents:
diff changeset
   794
            apply (case_tac flag, auto)
chunhan
parents:
diff changeset
   795
            apply (case_tac flag, auto)
chunhan
parents:
diff changeset
   796
            done            
chunhan
parents:
diff changeset
   797
          from p1 have p1': "file_of_proc_fd (enrich_proc s p p') p' fd = Some f"
chunhan
parents:
diff changeset
   798
            using a2 a4 vd
chunhan
parents:
diff changeset
   799
            by (simp add:enrich_proc_dup_ffd)
chunhan
parents:
diff changeset
   800
          from p2 have p2': "sectxt_of_obj (enrich_proc s p p') (O_proc p') = Some sp"
chunhan
parents:
diff changeset
   801
            using dup_sp
chunhan
parents:
diff changeset
   802
            by (auto simp:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
   803
          from p3 p1 p1' p0 p0' os have p3': "sectxt_of_obj (enrich_proc s p p') (O_fd p' fd) = Some sfd"
chunhan
parents:
diff changeset
   804
            using dup_sfd
chunhan
parents:
diff changeset
   805
            apply (erule_tac x = fd in allE)
chunhan
parents:
diff changeset
   806
            apply (auto simp:proc_file_fds_def cfd2sfd_def split:option.splits)
chunhan
parents:
diff changeset
   807
            apply (drule current_file_has_sfile')
chunhan
parents:
diff changeset
   808
            apply (simp add:vd, simp)
chunhan
parents:
diff changeset
   809
            apply (drule current_file_has_sfile')
chunhan
parents:
diff changeset
   810
            apply (simp add:vd, simp)
chunhan
parents:
diff changeset
   811
            done
chunhan
parents:
diff changeset
   812
          from p4 have p4': "sectxt_of_obj (enrich_proc s p p') (O_file f) = Some sf" 
chunhan
parents:
diff changeset
   813
            using f_in_s cf2sf isfile_s isfile_s' a1 vd_enrich vd
chunhan
parents:
diff changeset
   814
            apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
   815
            apply (simp)
chunhan
parents:
diff changeset
   816
            apply (auto simp:cf2sfile_def split:option.splits 
chunhan
parents:
diff changeset
   817
              dest!:current_has_sec' get_pfs_secs_prop' dest:parentf_is_dir is_file_in_current)
chunhan
parents:
diff changeset
   818
            apply (case_tac f, simp, drule root_is_dir', simp, simp, simp)
chunhan
parents:
diff changeset
   819
            done
chunhan
parents:
diff changeset
   820
          show ?thesis using p1' p2' p3' p4' a1
chunhan
parents:
diff changeset
   821
            apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   822
            using grant p1 p2 p3 p4 
chunhan
parents:
diff changeset
   823
            apply simp
chunhan
parents:
diff changeset
   824
            done
chunhan
parents:
diff changeset
   825
        qed
chunhan
parents:
diff changeset
   826
        ultimately show ?thesis
chunhan
parents:
diff changeset
   827
          using a1
chunhan
parents:
diff changeset
   828
          by (erule_tac valid.intros(2), simp+)
chunhan
parents:
diff changeset
   829
      qed
chunhan
parents:
diff changeset
   830
    qed
chunhan
parents:
diff changeset
   831
    ultimately show ?thesis 
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   832
      using vd_enrich created_cons vd_cons' all_procs_cons
82
chunhan
parents:
diff changeset
   833
      apply (case_tac e)
chunhan
parents:
diff changeset
   834
      apply (auto simp:is_created_proc_simps split:if_splits)
chunhan
parents:
diff changeset
   835
      done
chunhan
parents:
diff changeset
   836
  qed
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   837
  have sec_proc:
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   838
    "\<And> tp. \<lbrakk>tp \<in> current_procs s; is_created_proc s p\<rbrakk> 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   839
    \<Longrightarrow> sectxt_of_obj (enrich_proc s p p') (O_proc tp) = sectxt_of_obj s (O_proc tp)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   840
    using pre 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   841
    apply (clarsimp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   842
    apply (erule_tac x = tp in allE, auto simp:cp2sproc_def split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   843
    done
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   844
  have sf_cons:
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   845
    "\<forall>f. f \<in> current_files (e # s) \<longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   846
  proof clarify
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   847
    fix f 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   848
    assume a1: "f \<in> current_files (e # s)"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   849
    from pre have pre_sf: "\<And> f. \<lbrakk>f \<in> current_files s; is_created_proc s p\<rbrakk>
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   850
      \<Longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   851
      by auto
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   852
    from a1 have a1': "f \<in> current_files (enrich_proc (e # s) p p')"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   853
      using vd_cons' nodel_cons
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   854
      by (simp add:enrich_proc_cur_files)
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   855
    from a1 have a1'': "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   856
      using vd_cons' nodel_cons os vd vd_enrich created_cons
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   857
      apply (case_tac e)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   858
      apply (auto simp:enrich_proc_cur_files current_files_simps is_created_proc_simps
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   859
        dest:is_file_in_current is_dir_in_current split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   860
      done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   861
    
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   862
    have sec_dir:
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   863
      "\<And> tf. \<lbrakk>is_dir s tf; is_created_proc s p\<rbrakk>
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   864
      \<Longrightarrow> sectxt_of_obj (enrich_proc s p p') (O_dir tf) = sectxt_of_obj s (O_dir tf)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   865
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   866
      fix tf 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   867
      assume a1: "is_dir s tf" and a2: "is_created_proc s p"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   868
      from a2 pre
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   869
      have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   870
        and vd_enrich: "valid (enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   871
        by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   872
      hence csf: "cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   873
        using a1 by (auto simp:is_dir_in_current)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   874
      from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   875
        apply (case_tac "cf2sfile s tf")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   876
        apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   877
        apply (simp add:vd, simp add:is_dir_in_current, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   878
        done      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   879
      from a1 have a1': "is_dir (enrich_proc s p p') tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   880
        using enrich_proc_is_dir vd nodel all_procs by simp
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   881
      from a1 have a3: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   882
      from a1' vd have a3': "\<not> is_file (enrich_proc s p p') tf" by (simp add:is_dir_not_file)  
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   883
      show "sectxt_of_obj (enrich_proc s p p') (O_dir tf) = sectxt_of_obj s (O_dir tf)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   884
        using csf csf_some a3 a3' vd_enrich vd
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   885
        apply (auto simp:cf2sfile_def split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   886
        apply (case_tac tf)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   887
        apply (simp add:root_sec_remains, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   888
        done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   889
    qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   890
    have sec_file:
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   891
      "\<And> tf. \<lbrakk>is_file s tf; is_created_proc s p\<rbrakk>
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   892
      \<Longrightarrow> sectxt_of_obj (enrich_proc s p p') (O_file tf) = sectxt_of_obj s (O_file tf)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   893
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   894
      fix tf 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   895
      assume a1: "is_file s tf" and a2: "is_created_proc s p"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   896
      from a2 pre
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   897
      have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   898
        and vd_enrich: "valid (enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   899
        by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   900
      hence csf: "cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   901
        using a1 by (auto simp:is_file_in_current)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   902
      from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   903
        apply (case_tac "cf2sfile s tf")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   904
        apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   905
        apply (simp add:vd, simp add:is_file_in_current, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   906
        done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   907
      from a1 have a1': "is_file (enrich_proc s p p') tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   908
        using vd nodel all_procs by (simp add:enrich_proc_is_file)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   909
      show "sectxt_of_obj (enrich_proc s p p') (O_file tf) = sectxt_of_obj s (O_file tf)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   910
        using csf csf_some vd_enrich vd a1 a1'
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   911
        apply (auto simp:cf2sfile_def split:option.splits if_splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   912
        apply (case_tac tf, simp_all)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   913
        apply (drule root_is_dir', simp+)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   914
        done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   915
    qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   916
    have secs_dir:
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   917
      "\<And> tf ctxts'. \<lbrakk>is_dir s tf; is_created_proc s p; get_parentfs_ctxts s tf = Some ctxts'\<rbrakk>
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   918
       \<Longrightarrow> \<exists> ctxts. get_parentfs_ctxts (enrich_proc s p p') tf = Some ctxts \<and> set ctxts = set ctxts'"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   919
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   920
      fix tf ctxts'
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   921
      assume a1: "is_dir s tf" and a2: "is_created_proc s p" 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   922
        and a4: "get_parentfs_ctxts s tf = Some ctxts'"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   923
      from a2 pre
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   924
      have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   925
        and vd_enrich': "valid (enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   926
        by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   927
      hence csf: "cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   928
        using a1 by (auto simp:is_dir_in_current)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   929
      from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   930
        apply (case_tac "cf2sfile s tf")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   931
        apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   932
        apply (simp add:vd, simp add:is_dir_in_current, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   933
        done      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   934
      from a1 have a1': "is_dir (enrich_proc s p p') tf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   935
        using enrich_proc_is_dir vd nodel all_procs by simp
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   936
      from a1 have a5: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   937
      from a1' vd have a5': "\<not> is_file (enrich_proc s p p') tf" by (simp add:is_dir_not_file) 
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
   938
      
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   939
      from a1' pre_vd a2 obtain ctxts 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   940
        where a3: "get_parentfs_ctxts (enrich_proc s p p') tf = Some ctxts"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   941
        apply (case_tac "get_parentfs_ctxts (enrich_proc s p p') tf")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   942
        apply (drule get_pfs_secs_prop', simp+)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   943
        done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   944
      moreover have "set ctxts = set ctxts'"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   945
      proof (cases tf)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   946
        case Nil          
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   947
        with a3 a4 vd vd_enrich'
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   948
        show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   949
          by (simp add:get_parentfs_ctxts.simps root_sec_remains split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   950
      next
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   951
        case (Cons a ff)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   952
        with csf csf_some a5 a5' vd_enrich' vd a3 a4
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   953
        show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   954
          apply (auto simp:cf2sfile_def split:option.splits if_splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   955
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   956
      qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   957
      ultimately 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   958
      show "\<exists> ctxts. get_parentfs_ctxts (enrich_proc s p p') tf = Some ctxts \<and> set ctxts = set ctxts'"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   959
        by auto        
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   960
    qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   961
    have b1: "\<And> proc f' flags fd' opt. e = Open proc f' flags fd' opt 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   962
      \<Longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   963
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   964
      fix proc f' flags fd' opt
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   965
      assume ev: "e = Open proc f' flags fd' opt"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   966
      have b1': "cf2sfile (e # enrich_proc s p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   967
      proof (cases opt)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   968
        case None
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   969
        thus ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   970
          using vd_cons' vd_enrich a1 created_cons 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   971
          by (simp add:cf2sfile_open_none ev pre_sf 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   972
            is_created_proc_simps current_files_simps)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   973
      next
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   974
        case (Some inum)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   975
        show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   976
        proof (cases "f' = f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   977
          case True
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   978
          from a1 obtain sf where csf: "cf2sfile (e # s) f = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   979
            apply (case_tac "cf2sfile (e # s) f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   980
            apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   981
            apply (simp add:vd_cons', simp, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   982
            done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   983
          from a1 ev os Some True obtain pf where parent: "parent f = Some pf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   984
            and pdir: "is_dir s pf" and proc_in: "proc \<in> current_procs s" by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   985
          have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   986
            using ev True Some
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   987
            by (simp add:current_files_open)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   988
          thus ?thesis using ev Some csf vd_enrich True created_cons vd_cons' a1 parent pdir proc_in
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   989
            apply (simp add:is_created_proc_simps cf2sfile_open)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   990
            apply (simp add:sectxt_of_obj_simps sec_dir sec_proc split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   991
            apply (drule_tac tf = pf in secs_dir, simp+) 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   992
            apply (erule exE, erule conjE, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   993
            apply (case_tac aa, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   994
            done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   995
        next
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   996
          case False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   997
          have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   998
            using ev False Some vd_enrich a1 created_cons nodel vd
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
   999
            by (simp add:current_files_open is_created_proc_simps enrich_proc_cur_files)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1000
          with ev Some a1 vd_enrich vd_cons' created_cons False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1001
          show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1002
            apply (simp add:is_created_proc_simps cf2sfile_open)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1003
            apply (simp add:current_files_simps pre_sf)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1004
            done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1005
        qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1006
      qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1007
      show "cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f" 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1008
        using ev vd_enrich_cons
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1009
        apply simp
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1010
        apply (rule conjI, rule impI)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1011
        apply (simp add:cf2sfile_open_none)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1012
        using b1' apply (auto dest:vd_cons)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1013
        done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1014
    qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1015
    have b2: "\<And> proc f' inum. e = Mkdir proc f' inum
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1016
      \<Longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1017
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1018
      fix proc f' inum
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1019
      assume ev: "e = Mkdir proc f' inum"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1020
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1021
      show "cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1022
      proof (cases "f' = f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1023
        case True
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1024
        from a1 obtain sf where csf: "cf2sfile (e # s) f = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1025
          apply (case_tac "cf2sfile (e # s) f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1026
          apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1027
          apply (simp add:vd_cons', simp, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1028
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1029
        from a1 ev os True obtain pf where parent: "parent f = Some pf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1030
          and pdir: "is_dir s pf" and proc_in: "proc \<in> current_procs s" by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1031
        have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1032
          using ev True
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1033
          by (simp add:current_files_mkdir)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1034
        thus ?thesis using ev csf vd_enrich True created_cons vd_cons' a1 parent pdir proc_in
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1035
          apply (simp add:is_created_proc_simps cf2sfile_mkdir)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1036
          apply (simp add:sectxt_of_obj_simps sec_dir sec_proc split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1037
          apply (drule_tac tf = pf in secs_dir, simp+) 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1038
          apply (erule exE, erule conjE, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1039
          apply (case_tac aa, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1040
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1041
      next
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1042
        case False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1043
        have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1044
          using ev False vd_enrich a1 created_cons nodel vd
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1045
          by (simp add:current_files_mkdir is_created_proc_simps enrich_proc_cur_files)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1046
        with ev a1 vd_enrich vd_cons' created_cons False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1047
        show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1048
          apply (simp add:is_created_proc_simps cf2sfile_mkdir)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1049
          apply (simp add:current_files_simps pre_sf)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1050
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1051
      qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1052
    qed
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1053
    have b3: "\<And> proc f' f''. e = LinkHard proc f' f''
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1054
      \<Longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1055
    proof-
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1056
      fix proc f' f'' 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1057
      assume ev: "e = LinkHard proc f' f''"      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1058
      show "cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1059
      proof (cases "f'' = f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1060
        case True
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1061
        from a1 obtain sf where csf: "cf2sfile (e # s) f = Some sf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1062
          apply (case_tac "cf2sfile (e # s) f")
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1063
          apply (drule current_file_has_sfile')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1064
          apply (simp add:vd_cons', simp, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1065
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1066
        from a1 ev os True obtain pf where parent: "parent f'' = Some pf"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1067
          and pdir: "is_dir s pf" and proc_in: "proc \<in> current_procs s" by auto
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1068
        have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1069
          using ev True vd_enrich created_cons
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1070
          by (simp add:current_files_simps is_created_proc_simps)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1071
        thus ?thesis using ev csf vd_enrich True created_cons vd_cons' a1 parent pdir proc_in
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1072
          apply (simp add:is_created_proc_simps cf2sfile_linkhard)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1073
          apply (simp add:sectxt_of_obj_simps sec_dir sec_proc split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1074
          apply (drule_tac tf = pf in secs_dir, simp+) 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1075
          apply (erule exE, erule conjE, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1076
          apply (case_tac aa, simp)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1077
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1078
      next
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1079
        case False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1080
        have f_in: "f \<in> current_files (e # enrich_proc s p p')"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1081
          using ev False vd_enrich a1 created_cons nodel vd vd_cons'
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1082
          by (simp add:current_files_linkhard is_created_proc_simps enrich_proc_cur_files)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1083
        with ev a1 vd_enrich vd_cons' created_cons False
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1084
        show ?thesis
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1085
          apply (simp add:is_created_proc_simps cf2sfile_linkhard)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1086
          apply (simp add:current_files_simps pre_sf)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1087
          done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1088
      qed      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1089
    qed
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1090
    show "cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1091
      apply (case_tac e) 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1092
      prefer 6 apply (erule b1)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1093
      prefer 11 apply (erule b2)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1094
      prefer 11 apply (erule b3)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1095
      using vd created_cons nodel_cons vd_enrich_cons vd_cons' a1 a1'
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1096
      apply (auto intro!:pre_sf simp:cf2sfile_simps is_created_proc_simps current_files_simps
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1097
        split:if_splits dest:vd_cons cf2sfile_other')
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1098
      done
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1099
  qed
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1100
  moreover have "\<forall>tp fd. fd \<in> proc_file_fds (e # s) tp \<longrightarrow> 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1101
    cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
83
chunhan
parents: 82
diff changeset
  1102
  proof clarify
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1103
    fix tp fd 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1104
    assume a1: "fd \<in> proc_file_fds (e # s) tp"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1105
    from a1 obtain f where a1': "file_of_proc_fd (e # s) tp fd = Some f" 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1106
      by (auto simp:proc_file_fds_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1107
    from pre have pre_sfd: "\<And> tp fd. \<lbrakk>fd \<in> proc_file_fds s tp; is_created_proc s p\<rbrakk> \<Longrightarrow>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1108
      cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd" by auto
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1109
    hence pre_sfd': "\<And> tp fd f. \<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p\<rbrakk> \<Longrightarrow>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1110
      cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1111
    hence pre_sfd'': "\<And> tp fd f proc. \<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p; p = proc\<rbrakk> \<Longrightarrow>
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1112
      cfd2sfd (enrich_proc s proc p') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1113
    from a1' all_procs_cons vd_cons' have a2: "tp \<noteq> p'"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1114
      apply (drule_tac not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1115
      apply (drule proc_fd_in_procs, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1116
      by (rule notI, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1117
    have a3: "p' \<noteq> p" using all_procs_cons created_cons
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1118
      apply (drule_tac not_all_procs_prop3)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1119
      apply (rule notI, simp add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1120
      done      
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1121
    have a4: "file_of_proc_fd (enrich_proc (e # s) p p') tp fd = Some f" 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1122
      using a1' nodel_cons all_procs_cons a1' created_cons vd_cons'
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1123
      apply (frule_tac enrich_proc_filefd, simp_all)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1124
      done
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1125
    have sec_proc:
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1126
      "\<And> tp. \<lbrakk>tp \<in> current_procs s; is_created_proc s p\<rbrakk> 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1127
       \<Longrightarrow> sectxt_of_obj (enrich_proc s p p') (O_proc tp) = sectxt_of_obj s (O_proc tp)"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1128
      using pre 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1129
      apply (clarsimp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1130
      apply (erule_tac x = tp in allE, auto simp:cp2sproc_def split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1131
      done
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1132
    have sec_proc':
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1133
      "\<And> tp. \<lbrakk>tp \<in> current_procs s; is_created_proc s p; p = tp\<rbrakk> 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1134
       \<Longrightarrow> sectxt_of_obj (enrich_proc s tp p') (O_proc tp) = sectxt_of_obj s (O_proc tp)"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1135
      apply (drule_tac sec_proc, simp+)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1136
      done
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1137
    show "cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1138
    proof-
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1139
      have b1: "\<And> proc f' fds. e = Execve proc f' fds
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1140
        \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1141
        using a4 vd_enrich_cons a1' vd_cons' created_cons
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1142
        apply (simp split:if_splits del:file_of_proc_fd.simps add:a2) 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1143
        apply (simp only:cfd2sfd_execve)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1144
        apply (drule_tac s = "Execve proc f' fds # enrich_proc s proc p'" in vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1145
        apply (simp split:if_splits add:a2)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1146
        apply (drule_tac p' = proc and fd' = fd and s = "enrich_proc s proc p'" in cfd2sfd_execve, simp+)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1147
        apply (erule_tac pre_sfd'', simp add:is_created_proc_simps, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1148
        apply (drule_tac p' = tp and fd' = fd in cfd2sfd_execve, simp+)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1149
        apply (erule_tac pre_sfd'', simp add:is_created_proc_simps, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1150
        apply (simp only:cfd2sfd_execve)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1151
        apply (rule_tac pre_sfd')
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1152
        apply (auto split:if_splits simp:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1153
        done 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1154
      have b2: "\<And> proc proc' fds. e = Clone proc proc' fds
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1155
       \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1156
        using a4 vd_enrich_cons a1' vd_cons' created_cons
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1157
        apply (simp split:if_splits del:file_of_proc_fd.simps) 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1158
        apply (simp add:cfd2sfd_clone add:a2)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1159
        apply (simp add:cfd2sfd_clone split:if_splits)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1160
        apply (erule pre_sfd'', simp add:is_created_proc_simps, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1161
        apply (erule pre_sfd', simp add:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1162
        done 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1163
      have b3: "\<And> proc f' flags fd' opt. e = Open proc f' flags fd' opt 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1164
         \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1165
        using a4 a1' vd_enrich_cons vd_cons' created_cons 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1166
        apply (simp split:if_splits del:file_of_proc_fd.simps) 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1167
        
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1168
        apply (simp add:cfd2sfd_open sec_open is_created_proc_simps a2 del:file_of_proc_fd.simps)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1169
        apply (tactic {*my_clarify_tac 1*})
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1170
        apply (drule vd_cons)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1171
        apply (simp add:cfd2sfd_open sec_open a3 a2 split:if_splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1172
        apply (case_tac "proc \<in> current_procs s")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1173
        apply (simp add:sec_proc')
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1174
        apply (case_tac "sectxt_of_obj s (O_proc proc)", simp+)        
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1175
        apply (case_tac "f \<in> current_files (e # s)")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1176
        apply (drule sf_cons[rule_format], simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1177
        using vd_enrich_cons
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1178
        apply (simp add:cf2sfile_open_none)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1179
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1180
        apply (simp add:current_files_simps is_file_in_current split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1181
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1182
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1183
        apply (rule impI)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1184
        apply (simp add:cfd2sfd_open sec_open a3 a2 split:if_splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1185
        apply (drule vd_cons)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1186
        apply (drule_tac p' = tp and fd' = fd and f' = f and s = "enrich_proc s proc p'" in cfd2sfd_open)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1187
        apply (simp, rule impI, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1188
        apply (simp split:if_splits, rule conjI, rule impI, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1189
        apply (drule pre_sfd', simp, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1190
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1191
        apply (simp add:cfd2sfd_open sec_open is_created_proc_simps a2 del:file_of_proc_fd.simps)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1192
        apply (case_tac "proc \<in> current_procs s")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1193
        apply (simp add:sec_proc)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1194
        apply (case_tac "f' \<in> current_files (e # s)")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1195
        apply (drule sf_cons[rule_format], simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1196
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1197
        apply (rule impI|rule conjI)+
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1198
        apply (drule current_has_sec', simp add:vd, simp add:os)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1199
        apply (rule impI, rule impI)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1200
        apply (simp split:if_splits)
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1201
        apply (simp add:pre_sfd')
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1202
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1203
        apply (simp add:current_files_simps is_file_in_current split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1204
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1205
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1206
        done
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1207
      have b4: "\<And> proc fd'. e = ReadFile proc fd' 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1208
         \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1209
        using a4 vd_enrich_cons a1' vd_cons' created_cons
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1210
        apply (simp split:if_splits del:file_of_proc_fd.simps) 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1211
        apply (frule_tac s = "ReadFile proc fd' # enrich_proc s proc p'" in vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1212
        apply (simp add:cfd2sfd_other)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1213
        apply (erule pre_sfd'', simp add:is_created_proc_simps, simp)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1214
        apply (simp add:cfd2sfd_other)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1215
        apply (erule pre_sfd', simp add:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1216
        done 
83
chunhan
parents: 82
diff changeset
  1217
      show ?thesis
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1218
        apply (case_tac e)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1219
        apply (erule b1, erule b2) 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1220
        prefer 4 apply (erule b3) prefer 4 apply (erule b4)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1221
        using vd created_cons nodel_cons a1' a4 vd_enrich_cons vd_cons'
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1222
        apply (auto intro!:pre_sfd' simp:cfd2sfd_simps is_created_proc_simps 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1223
          simp del:file_of_proc_fd.simps split:if_splits dest:vd_cons enrich_proc_filefd)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1224
        apply (simp_all)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1225
        done
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1226
    qed
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1227
  qed
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1228
  moreover have "\<forall>q. q \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_proc (e # s) p p') q = cq2smsgq (e # s) q"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1229
  proof clarify
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1230
    fix q
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1231
    assume a1: "q \<in> current_msgqs (e # s)"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1232
    from pre have pre_smsgq: "\<And> q. \<lbrakk>q \<in> current_msgqs s; is_created_proc s p\<rbrakk>
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1233
      \<Longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1234
      by auto 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1235
    show "cq2smsgq (enrich_proc (e # s) p p') q = cq2smsgq (e # s) q"
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1236
      using vd_enrich_cons a1 created_cons nodel_cons vd_cons' os
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1237
      apply (case_tac e) 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1238
      apply (auto simp:cq2smsgq_simps cq2smsg_createmsgq is_created_proc_simps sec_proc 
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1239
        dest:cq2smsgq_other intro!:pre_smsgq split:if_splits dest:vd_cons)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1240
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1241
      apply (simp add:sectxt_of_obj_simps split:option.splits)
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1242
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1243
      thm sec_proc
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1244
      thm cq2smsgq_simps
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1245
      thm cq2smsg_createmsgq
82
chunhan
parents:
diff changeset
  1246
    sorry
86
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1247
  moreover have "\<forall>tp. tp \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_proc (e # s) p p') tp = cp2sproc (e # s) tp"
82
chunhan
parents:
diff changeset
  1248
    sorry
chunhan
parents:
diff changeset
  1249
  moreover have "cp2sproc (enrich_proc (e # s) p p') p' = cp2sproc (e # s) p"
chunhan
parents:
diff changeset
  1250
  proof-
chunhan
parents:
diff changeset
  1251
    from pre have b0: "is_created_proc s p \<Longrightarrow> cp2sproc (enrich_proc s p p') p' = cp2sproc s p" by simp
chunhan
parents:
diff changeset
  1252
    have b1: "\<And> tp f fds. \<lbrakk>valid (enrich_proc (Execve tp f fds # s) p p'); valid (Execve tp f fds # s);
chunhan
parents:
diff changeset
  1253
      is_created_proc (Execve tp f fds # s) p; p' \<notin> all_procs (Execve tp f fds # s)\<rbrakk>
chunhan
parents:
diff changeset
  1254
      \<Longrightarrow> cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  1255
    proof-
chunhan
parents:
diff changeset
  1256
      fix tp f fds
chunhan
parents:
diff changeset
  1257
      assume a1: "valid (enrich_proc (Execve tp f fds # s) p p')"
chunhan
parents:
diff changeset
  1258
      and a2: "valid (Execve tp f fds # s)" and a3: "is_created_proc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  1259
      and a4: "p' \<notin> all_procs (Execve tp f fds # s)"
chunhan
parents:
diff changeset
  1260
      show "cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  1261
      proof (cases "tp = p")
chunhan
parents:
diff changeset
  1262
        case True
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1263
        show ?thesis using True a1 a2 a3 a4 b0 vd
82
chunhan
parents:
diff changeset
  1264
          thm not_all_procs_prop3
83
chunhan
parents: 82
diff changeset
  1265
          apply (frule_tac not_all_procs_prop2)
chunhan
parents: 82
diff changeset
  1266
          apply (frule not_all_procs_prop3)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1267
          apply (simp add:is_created_proc_simps)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1268
          apply (frule vd_cons) (*
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1269
          apply (frule_tac vt_grant_os) 
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1270
          apply (frule_tac \<tau> = "enrich_proc s p p'" in vt_grant_os) *)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1271
          apply (frule_tac s = "enrich_proc s p p'" in vd_cons)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1272
          apply (frule_tac \<tau> = s in vt_grant_os)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1273
          apply (case_tac "p' = p", simp) (*
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1274
          apply (auto simp add:cp2sproc_execve sectxt_of_obj_simps enrich_proc_dup_in
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1275
            split:option.splits dest!:current_has_sec' dest:vt_grant is_file)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1276
          apply (simp_all add:is_created_proc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1277
          apply (auto simp:cp2sproc_def)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1278
          apply (simp_all add:enrich_proc_dup_in)
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1279
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1280
          
83
chunhan
parents: 82
diff changeset
  1281
          apply (auto simp:sectxt_of_obj_simps split:option.splits dest:valid.cases)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1282
  *)        
82
chunhan
parents:
diff changeset
  1283
          sorry
chunhan
parents:
diff changeset
  1284
      next
chunhan
parents:
diff changeset
  1285
        case False
chunhan
parents:
diff changeset
  1286
        show ?thesis sorry
chunhan
parents:
diff changeset
  1287
      qed
chunhan
parents:
diff changeset
  1288
    qed
chunhan
parents:
diff changeset
  1289
    have b2: "\<And> tp fd. cp2sproc (enrich_proc (ReadFile tp fd # s) p p') p' = cp2sproc (ReadFile tp fd # s) p"
chunhan
parents:
diff changeset
  1290
      sorry
chunhan
parents:
diff changeset
  1291
    have b3: "\<And> tp. cp2sproc (enrich_proc (Exit tp # s) p p') p' = cp2sproc (Exit tp # s) p"
chunhan
parents:
diff changeset
  1292
      sorry
chunhan
parents:
diff changeset
  1293
    have b4: "\<And> tp tp'. cp2sproc (enrich_proc (Kill tp tp' # s) p p') p' = cp2sproc (Kill tp tp' # s) p"
chunhan
parents:
diff changeset
  1294
      sorry
chunhan
parents:
diff changeset
  1295
    have b5: "\<And> tp tp' fds. cp2sproc (enrich_proc (Clone tp tp' fds # s) p p') p' = 
chunhan
parents:
diff changeset
  1296
      cp2sproc (Clone tp tp' fds # s) p"
chunhan
parents:
diff changeset
  1297
      sorry
chunhan
parents:
diff changeset
  1298
    have b6: "\<And> tp f flags fd opt. cp2sproc (enrich_proc (Open tp f flags fd opt # s) p p') p' =
chunhan
parents:
diff changeset
  1299
      cp2sproc (Open tp f flags fd opt # s) p"
chunhan
parents:
diff changeset
  1300
      sorry
chunhan
parents:
diff changeset
  1301
    have b7: "\<And> tp fd. cp2sproc (enrich_proc (CloseFd tp fd # s) p p') p' = cp2sproc (CloseFd tp fd # s) p"
chunhan
parents:
diff changeset
  1302
      sorry
chunhan
parents:
diff changeset
  1303
    show ?thesis using vd_enrich_cons
chunhan
parents:
diff changeset
  1304
      apply (case_tac e)
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1305
      using vd_cons' created_cons all_procs_cons
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1306
      apply (auto intro!:b1 b2 b3 b4 b5 b6 b7 simp del:enrich_proc.simps)
83
chunhan
parents: 82
diff changeset
  1307
      using created_cons vd_enrich_cons vd_cons' b0
82
chunhan
parents:
diff changeset
  1308
      apply (auto simp:cp2sproc_other is_created_proc_def)
chunhan
parents:
diff changeset
  1309
      done
chunhan
parents:
diff changeset
  1310
  qed
chunhan
parents:
diff changeset
  1311
  moreover have "\<forall> fd. fd \<in> proc_file_fds (e # s) p \<longrightarrow> 
chunhan
parents:
diff changeset
  1312
    cfd2sfd (enrich_proc (e # s) p p') p' fd = cfd2sfd (e # s) p fd"
chunhan
parents:
diff changeset
  1313
    sorry
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1314
  ultimately show ?case using vd_enrich_cons
82
chunhan
parents:
diff changeset
  1315
    by simp
chunhan
parents:
diff changeset
  1316
qed
chunhan
parents:
diff changeset
  1317
  
88
chunhan
parents: 87
diff changeset
  1318
lemma enrich_proc_s2ss:
chunhan
parents: 87
diff changeset
  1319
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> s2ss (enrich_proc s p p') = s2ss s"
82
chunhan
parents:
diff changeset
  1320
chunhan
parents:
diff changeset
  1321
lemma enrich_proc_valid:
chunhan
parents:
diff changeset
  1322
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')"
chunhan
parents:
diff changeset
  1323
by (auto dest:enrich_proc_prop)
chunhan
parents:
diff changeset
  1324
chunhan
parents:
diff changeset
  1325
lemma enrich_proc_valid:
chunhan
parents:
diff changeset
  1326
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> " 
chunhan
parents:
diff changeset
  1327
chunhan
parents:
diff changeset
  1328
lemma enrich_proc_tainted: 
chunhan
parents:
diff changeset
  1329
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
  1330
   \<Longrightarrow> tainted (enrich_proc s p p') = (if (O_proc p \<in> tainted s) 
chunhan
parents:
diff changeset
  1331
         then tainted s \<union> {O_proc p'} else tainted s)"
chunhan
parents:
diff changeset
  1332
apply (induct s)
chunhan
parents:
diff changeset
  1333
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1334
apply (frule vt_grant_os, frule vd_cons, simp)
chunhan
parents:
diff changeset
  1335
apply (frule enrich_proc_dup_in, simp+)
chunhan
parents:
diff changeset
  1336
apply (frule not_all_procs_prop3)
chunhan
parents:
diff changeset
  1337
apply (case_tac a)
chunhan
parents:
diff changeset
  1338
prefer 3
chunhan
parents:
diff changeset
  1339
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1340
apply (rule impI|rule conjI)+
chunhan
parents:
diff changeset
  1341
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1342
apply (auto simp:is_created_proc_def split:if_splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  1343
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1344
chunhan
parents:
diff changeset
  1345
prefer 4
chunhan
parents:
diff changeset
  1346
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1347
apply (rule impI|rule conjI)+
chunhan
parents:
diff changeset
  1348
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1349
apply (auto simp:is_created_proc_def split:if_splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  1350
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1351
chunhan
parents:
diff changeset
  1352
prefer 4
chunhan
parents:
diff changeset
  1353
apply (auto simp:is_created_proc_def split:if_splits option.splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  1354
chunhan
parents:
diff changeset
  1355
prefer 4
chunhan
parents:
diff changeset
  1356
apply (auto simp:is_created_proc_def split:if_splits option.splits dest:tainted_in_current enrich_proc_dup_ffd enrich_proc_dup_ffd')[1]
chunhan
parents:
diff changeset
  1357
chunhan
parents:
diff changeset
  1358
chunhan
parents:
diff changeset
  1359
chunhan
parents:
diff changeset
  1360
lemma enrich_proc_dup_tainted:
chunhan
parents:
diff changeset
  1361
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
  1362
   \<Longrightarrow> (O_proc p' \<in> tainted (enrich_proc s p p')) = (O_proc p \<in> tainted s)"
chunhan
parents:
diff changeset
  1363
apply (induct s)
chunhan
parents:
diff changeset
  1364
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  1365
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  1366
apply (case_tac a)
chunhan
parents:
diff changeset
  1367
apply (auto simp:is_created_proc_def)[1]
chunhan
parents:
diff changeset
  1368
chunhan
parents:
diff changeset
  1369
chunhan
parents:
diff changeset
  1370
lemma enrich_proc_tainted:
84
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1371
82
chunhan
parents:
diff changeset
  1372
chunhan
parents:
diff changeset
  1373
chunhan
parents:
diff changeset
  1374
end
chunhan
parents:
diff changeset
  1375
chunhan
parents:
diff changeset
  1376
end