no_shm_selinux/Enrich2.thy
author chunhan
Wed, 08 Jan 2014 18:40:38 +0800
changeset 91 1a1df29d3507
parent 90 003cac7b8bf5
child 92 d9dc04c3ea90
permissions -rw-r--r--
enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
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
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
     8
fun enrich_msgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msgq \<Rightarrow> t_state"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
     9
where
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    10
  "enrich_msgq [] tq dq = []"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    11
| "enrich_msgq (CreateMsgq p q # s) tq dq = 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    12
    (if (tq = q) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    13
     then (CreateMsgq p dq # CreateMsgq p q # s)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    14
     else CreateMsgq p q # (enrich_msgq s tq dq))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    15
| "enrich_msgq (SendMsg p q m # s) tq dq = 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    16
    (if (tq = q) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    17
     then (SendMsg p dq m # SendMsg p q m # (enrich_msgq s tq dq))
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    18
     else SendMsg p q m # (enrich_msgq s tq dq))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    19
| "enrich_msgq (RecvMsg p q m # s) tq dq = 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    20
    (if (tq = q) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    21
     then (RecvMsg p dq m # RecvMsg p q m # (enrich_msgq s tq dq))
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    22
     else RecvMsg p q m # (enrich_msgq s tq dq))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    23
| "enrich_msgq (e # s) tq dq = e # (enrich_msgq s tq dq)"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    24
88
chunhan
parents: 87
diff changeset
    25
lemma enrich_msgq_duq_in:
chunhan
parents: 87
diff changeset
    26
  "\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk>
chunhan
parents: 87
diff changeset
    27
   \<Longrightarrow> q' \<in> current_msgqs (enrich_msgq s q q')"
chunhan
parents: 87
diff changeset
    28
apply (induct s, simp)
chunhan
parents: 87
diff changeset
    29
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
    30
apply auto
chunhan
parents: 87
diff changeset
    31
done
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
    32
88
chunhan
parents: 87
diff changeset
    33
lemma enrich_msgq_duq_sms:
chunhan
parents: 87
diff changeset
    34
  "\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk>
chunhan
parents: 87
diff changeset
    35
   \<Longrightarrow> msgs_of_queue (enrich_msgq s q q') q' = msgs_of_queue s q"
chunhan
parents: 87
diff changeset
    36
apply (induct s, simp)
chunhan
parents: 87
diff changeset
    37
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
    38
apply auto
chunhan
parents: 87
diff changeset
    39
done
chunhan
parents: 87
diff changeset
    40
chunhan
parents: 87
diff changeset
    41
lemma enrich_msgq_cur_inof:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    42
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    43
   \<Longrightarrow> inum_of_file (enrich_msgq s q q') f = inum_of_file s f"
chunhan
parents: 87
diff changeset
    44
apply (induct s arbitrary:f, simp)
chunhan
parents: 87
diff changeset
    45
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
    46
apply (auto split:option.splits)
chunhan
parents: 87
diff changeset
    47
done
chunhan
parents: 87
diff changeset
    48
chunhan
parents: 87
diff changeset
    49
lemma enrich_msgq_cur_inos:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    50
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    51
   \<Longrightarrow> inum_of_socket (enrich_msgq s q q') = inum_of_socket s"
chunhan
parents: 87
diff changeset
    52
apply (rule ext)
chunhan
parents: 87
diff changeset
    53
apply (induct s, simp)
chunhan
parents: 87
diff changeset
    54
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
    55
apply (auto split:option.splits)
chunhan
parents: 87
diff changeset
    56
done
chunhan
parents: 87
diff changeset
    57
chunhan
parents: 87
diff changeset
    58
lemma enrich_msgq_cur_inos':
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    59
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    60
   \<Longrightarrow> inum_of_socket (enrich_msgq s q q') sock = inum_of_socket s sock"
chunhan
parents: 87
diff changeset
    61
apply (simp add:enrich_msgq_cur_inos)
chunhan
parents: 87
diff changeset
    62
done
chunhan
parents: 87
diff changeset
    63
chunhan
parents: 87
diff changeset
    64
lemma enrich_msgq_cur_inums:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    65
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    66
   \<Longrightarrow> current_inode_nums (enrich_msgq s q q') = current_inode_nums s"
chunhan
parents: 87
diff changeset
    67
apply (auto simp:current_inode_nums_def current_file_inums_def 
chunhan
parents: 87
diff changeset
    68
  current_sock_inums_def enrich_msgq_cur_inof enrich_msgq_cur_inos)
chunhan
parents: 87
diff changeset
    69
done
chunhan
parents: 87
diff changeset
    70
chunhan
parents: 87
diff changeset
    71
lemma enrich_msgq_cur_itag:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    72
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    73
   \<Longrightarrow> itag_of_inum (enrich_msgq s q q') = itag_of_inum s"
chunhan
parents: 87
diff changeset
    74
apply (rule ext)
chunhan
parents: 87
diff changeset
    75
apply (induct s, simp)
chunhan
parents: 87
diff changeset
    76
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
    77
apply (auto split:option.splits t_socket_type.splits)
chunhan
parents: 87
diff changeset
    78
done
chunhan
parents: 87
diff changeset
    79
chunhan
parents: 87
diff changeset
    80
lemma enrich_msgq_cur_tcps:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    81
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    82
   \<Longrightarrow> is_tcp_sock (enrich_msgq s q q') = is_tcp_sock s"
chunhan
parents: 87
diff changeset
    83
apply (rule ext)
chunhan
parents: 87
diff changeset
    84
apply (auto simp:is_tcp_sock_def enrich_msgq_cur_itag enrich_msgq_cur_inos
chunhan
parents: 87
diff changeset
    85
  split:option.splits t_inode_tag.splits)
chunhan
parents: 87
diff changeset
    86
done
chunhan
parents: 87
diff changeset
    87
chunhan
parents: 87
diff changeset
    88
lemma enrich_msgq_cur_udps:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    89
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    90
   \<Longrightarrow> is_udp_sock (enrich_msgq s q q') = is_udp_sock s"
chunhan
parents: 87
diff changeset
    91
apply (rule ext)
chunhan
parents: 87
diff changeset
    92
apply (auto simp:is_udp_sock_def enrich_msgq_cur_itag enrich_msgq_cur_inos
chunhan
parents: 87
diff changeset
    93
  split:option.splits t_inode_tag.splits)
chunhan
parents: 87
diff changeset
    94
done
chunhan
parents: 87
diff changeset
    95
chunhan
parents: 87
diff changeset
    96
lemma enrich_msgq_cur_msgqs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
    97
  "\<lbrakk>q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
    98
   \<Longrightarrow> current_msgqs (enrich_msgq s q q') = current_msgqs s \<union> {q'}"
chunhan
parents: 87
diff changeset
    99
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   100
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 87
diff changeset
   101
apply (case_tac a, auto)
chunhan
parents: 87
diff changeset
   102
done
chunhan
parents: 87
diff changeset
   103
chunhan
parents: 87
diff changeset
   104
lemma enrich_msgq_cur_msgs:
chunhan
parents: 87
diff changeset
   105
  "\<lbrakk>q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk>
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   106
   \<Longrightarrow> msgs_of_queue (enrich_msgq s q q') =  (msgs_of_queue s) (q' := msgs_of_queue s q)" 
88
chunhan
parents: 87
diff changeset
   107
apply (rule ext, simp, rule conjI, rule impI)
chunhan
parents: 87
diff changeset
   108
apply (simp add:enrich_msgq_duq_sms)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   109
apply (rule impI) 
88
chunhan
parents: 87
diff changeset
   110
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   111
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 87
diff changeset
   112
apply (case_tac a, auto)
chunhan
parents: 87
diff changeset
   113
done
chunhan
parents: 87
diff changeset
   114
chunhan
parents: 87
diff changeset
   115
lemma enrich_msgq_cur_procs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   116
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   117
   \<Longrightarrow> current_procs (enrich_msgq s q q') = current_procs s"
chunhan
parents: 87
diff changeset
   118
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   119
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 87
diff changeset
   120
apply (case_tac a, auto)
chunhan
parents: 87
diff changeset
   121
done
chunhan
parents: 87
diff changeset
   122
  
chunhan
parents: 87
diff changeset
   123
lemma enrich_msgq_cur_files:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   124
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   125
   \<Longrightarrow> current_files (enrich_msgq s q q') = current_files s"
chunhan
parents: 87
diff changeset
   126
apply (auto simp:current_files_def)
chunhan
parents: 87
diff changeset
   127
apply (simp add:enrich_msgq_cur_inof)+
chunhan
parents: 87
diff changeset
   128
done
chunhan
parents: 87
diff changeset
   129
chunhan
parents: 87
diff changeset
   130
lemma enrich_msgq_cur_fds:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   131
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   132
   \<Longrightarrow> current_proc_fds (enrich_msgq s q q') = current_proc_fds s"
chunhan
parents: 87
diff changeset
   133
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   134
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
   135
apply auto
chunhan
parents: 87
diff changeset
   136
done
chunhan
parents: 87
diff changeset
   137
chunhan
parents: 87
diff changeset
   138
lemma enrich_msgq_filefd:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   139
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   140
   \<Longrightarrow> file_of_proc_fd (enrich_msgq s q q') = file_of_proc_fd s"
chunhan
parents: 87
diff changeset
   141
apply (rule ext, rule ext)
chunhan
parents: 87
diff changeset
   142
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   143
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
   144
apply auto
chunhan
parents: 87
diff changeset
   145
done
chunhan
parents: 87
diff changeset
   146
chunhan
parents: 87
diff changeset
   147
lemma enrich_msgq_flagfd:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   148
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   149
   \<Longrightarrow> flags_of_proc_fd (enrich_msgq s q q') = flags_of_proc_fd s"
chunhan
parents: 87
diff changeset
   150
apply (rule ext, rule ext)
chunhan
parents: 87
diff changeset
   151
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   152
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
   153
apply auto
chunhan
parents: 87
diff changeset
   154
done
chunhan
parents: 87
diff changeset
   155
chunhan
parents: 87
diff changeset
   156
lemma enrich_msgq_proc_fds:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   157
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   158
   \<Longrightarrow> proc_file_fds (enrich_msgq s q q') = proc_file_fds s"
chunhan
parents: 87
diff changeset
   159
apply (auto simp:proc_file_fds_def enrich_msgq_filefd)
chunhan
parents: 87
diff changeset
   160
done
chunhan
parents: 87
diff changeset
   161
chunhan
parents: 87
diff changeset
   162
lemma enrich_msgq_hungs:
chunhan
parents: 87
diff changeset
   163
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
chunhan
parents: 87
diff changeset
   164
   \<Longrightarrow> files_hung_by_del (enrich_msgq s q q') = files_hung_by_del s"
chunhan
parents: 87
diff changeset
   165
apply (induct s, simp)
chunhan
parents: 87
diff changeset
   166
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents: 87
diff changeset
   167
apply (auto simp:files_hung_by_del.simps)
chunhan
parents: 87
diff changeset
   168
done
chunhan
parents: 87
diff changeset
   169
  
chunhan
parents: 87
diff changeset
   170
lemma enrich_msgq_is_file:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   171
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   172
   \<Longrightarrow> is_file (enrich_msgq s q q') = is_file s"
chunhan
parents: 87
diff changeset
   173
apply (rule ext)
chunhan
parents: 87
diff changeset
   174
apply (auto simp add:is_file_def enrich_msgq_cur_itag enrich_msgq_cur_inof
chunhan
parents: 87
diff changeset
   175
  split:option.splits t_inode_tag.splits)
chunhan
parents: 87
diff changeset
   176
done
chunhan
parents: 87
diff changeset
   177
chunhan
parents: 87
diff changeset
   178
lemma enrich_msgq_is_dir:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   179
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
88
chunhan
parents: 87
diff changeset
   180
   \<Longrightarrow> is_dir (enrich_msgq s q q') = is_dir s"
chunhan
parents: 87
diff changeset
   181
apply (rule ext)
chunhan
parents: 87
diff changeset
   182
apply (auto simp add:is_dir_def enrich_msgq_cur_itag enrich_msgq_cur_inof
chunhan
parents: 87
diff changeset
   183
  split:option.splits t_inode_tag.splits)
chunhan
parents: 87
diff changeset
   184
done
chunhan
parents: 87
diff changeset
   185
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
   186
lemma enrich_msgq_sameinode:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   187
  "\<lbrakk>no_del_event s; valid s\<rbrakk>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   188
  \<Longrightarrow> (f \<in> same_inode_files (enrich_msgq s q q') f') = (f \<in> same_inode_files s f')"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   189
apply (induct s, simp)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   190
apply (simp add:same_inode_files_def)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   191
apply (auto simp:enrich_msgq_is_file enrich_msgq_cur_inof)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   192
done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   193
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   194
lemma enrich_msgq_tainted_aux1:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   195
  "\<lbrakk>no_del_event s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; valid s\<rbrakk>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   196
   \<Longrightarrow> (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}) \<subseteq> tainted (enrich_msgq s q q')"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   197
apply (induct s, simp) 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   198
apply (frule vt_grant_os, frule vd_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   199
apply (case_tac a)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   200
apply (auto split:option.splits if_splits dest:tainted_in_current
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   201
  simp:enrich_msgq_filefd enrich_msgq_sameinode)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   202
done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   203
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   204
lemma enrich_msgq_tainted_aux2:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   205
  "\<lbrakk>no_del_event s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; valid s; valid (enrich_msgq s q q')\<rbrakk>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   206
   \<Longrightarrow> tainted (enrich_msgq s q q') \<subseteq> (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s})"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   207
apply (induct s, simp) 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   208
apply (frule vt_grant_os, frule vd_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   209
apply (case_tac a)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   210
apply (auto split:option.splits if_splits simp:enrich_msgq_filefd enrich_msgq_sameinode 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   211
  dest:tainted_in_current vd_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   212
apply (drule_tac vd_cons)+
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   213
apply (simp)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   214
apply (drule set_mp)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   215
apply simp
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   216
apply simp
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   217
apply (drule_tac s = s in tainted_in_current)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   218
apply simp+
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   219
done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   220
88
chunhan
parents: 87
diff changeset
   221
lemma enrich_msgq_alive:
chunhan
parents: 87
diff changeset
   222
  "\<lbrakk>alive s obj; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk>
chunhan
parents: 87
diff changeset
   223
   \<Longrightarrow> alive (enrich_msgq s q q') obj"
chunhan
parents: 87
diff changeset
   224
apply (case_tac obj)
chunhan
parents: 87
diff changeset
   225
apply (simp_all add:enrich_msgq_is_file enrich_msgq_is_dir enrich_msgq_cur_msgqs 
chunhan
parents: 87
diff changeset
   226
  enrich_msgq_cur_msgs enrich_msgq_cur_procs enrich_msgq_cur_fds
chunhan
parents: 87
diff changeset
   227
  enrich_msgq_cur_tcps enrich_msgq_cur_udps)
chunhan
parents: 87
diff changeset
   228
apply (rule impI, simp)
chunhan
parents: 87
diff changeset
   229
done
chunhan
parents: 87
diff changeset
   230
chunhan
parents: 87
diff changeset
   231
lemma enrich_msgq_alive':
chunhan
parents: 87
diff changeset
   232
  "\<lbrakk>alive (enrich_msgq s q q') obj; valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk>
chunhan
parents: 87
diff changeset
   233
   \<Longrightarrow> alive s obj \<or> obj = O_msgq q' \<or> (\<exists> m. obj = O_msg q' m \<and> alive s (O_msg q m))"
chunhan
parents: 87
diff changeset
   234
apply (case_tac obj)
chunhan
parents: 87
diff changeset
   235
apply (simp_all add:enrich_msgq_is_file enrich_msgq_is_dir enrich_msgq_cur_msgqs 
chunhan
parents: 87
diff changeset
   236
  enrich_msgq_cur_msgs enrich_msgq_cur_procs enrich_msgq_cur_fds
chunhan
parents: 87
diff changeset
   237
  enrich_msgq_cur_tcps enrich_msgq_cur_udps)
chunhan
parents: 87
diff changeset
   238
apply (auto split:if_splits)
chunhan
parents: 87
diff changeset
   239
done
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   240
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   241
lemma enrich_msgq_not_alive:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   242
  "\<lbrakk>enrich_not_alive s (E_msgq q') obj; q' \<notin> current_msgqs s; q \<in> current_msgqs s; no_del_event s; valid s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   243
   \<Longrightarrow> enrich_not_alive (enrich_msgq s q q') (E_msgq q') obj"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   244
apply (case_tac obj)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   245
apply (auto simp:enrich_msgq_cur_fds enrich_msgq_cur_files 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   246
  enrich_msgq_cur_procs enrich_msgq_cur_inums enrich_msgq_cur_msgqs enrich_msgq_cur_msgs)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   247
done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   248
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
   249
lemma enrich_msgq_nodel:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   250
  "no_del_event (enrich_msgq s q q') = no_del_event s"
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   251
apply (induct s, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   252
by (case_tac a, auto)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   253
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
   254
lemma enrich_msgq_died_proc:
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   255
  "died (O_proc p) (enrich_msgq s q q') = died (O_proc p) s"
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   256
apply (induct s, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   257
by (case_tac a, auto)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   258
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   259
lemma cf2sfile_execve:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   260
  "\<lbrakk>ff \<in> current_files (Execve p f fds # s); valid (Execve p f fds # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   261
   \<Longrightarrow> cf2sfile (Execve p f fds # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   262
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   263
lemma cf2sfile_clone:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   264
  "\<lbrakk>ff \<in> current_files (Clone p p' fds # s); valid (Clone p p' fds # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   265
   \<Longrightarrow> cf2sfile (Clone p p' fds # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   266
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   267
lemma cf2sfile_ptrace:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   268
  "\<lbrakk>ff \<in> current_files (Ptrace p p' # s); valid (Ptrace p p' # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   269
   \<Longrightarrow> cf2sfile (Ptrace p p' # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   270
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   271
lemma cf2sfile_readfile:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   272
  "\<lbrakk>ff \<in> current_files (ReadFile p fd # s); valid (ReadFile p fd # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   273
   \<Longrightarrow> cf2sfile (ReadFile p fd # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   274
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   275
lemma cf2sfile_writefile:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   276
  "\<lbrakk>ff \<in> current_files (WriteFile p fd # s); valid (WriteFile p fd # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   277
   \<Longrightarrow> cf2sfile (WriteFile p fd # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   278
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   279
lemma cf2sfile_truncate:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   280
  "\<lbrakk>ff \<in> current_files (Truncate p f len # s); valid (Truncate p f len # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   281
   \<Longrightarrow> cf2sfile (Truncate p f len # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   282
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   283
lemma cf2sfile_createmsgq:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   284
  "\<lbrakk>ff \<in> current_files (CreateMsgq p q # s); valid (CreateMsgq p q # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   285
   \<Longrightarrow> cf2sfile (CreateMsgq p q # s) ff= cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   286
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   287
lemma cf2sfile_sendmsg:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   288
  "\<lbrakk>ff \<in> current_files (SendMsg p q m # s); valid (SendMsg p q m # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   289
   \<Longrightarrow> cf2sfile (SendMsg p q m # s) ff = cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   290
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   291
lemma cf2sfile_recvmsg:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   292
  "\<lbrakk>ff \<in> current_files (RecvMsg p q m # s); valid (RecvMsg p q m # s)\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   293
   \<Longrightarrow> cf2sfile (RecvMsg p q m # s) ff = cf2sfile s ff"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   294
by (auto dest:cf2sfile_other' simp:current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   295
lemmas cf2sfile_other'' = cf2sfile_recvmsg cf2sfile_sendmsg cf2sfile_createmsgq cf2sfile_truncate
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   296
  cf2sfile_writefile cf2sfile_readfile cf2sfile_ptrace cf2sfile_clone cf2sfile_execve
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   297
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   298
lemma enrich_msgq_prop:
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   299
  "\<lbrakk>valid s; q \<in> current_msgqs s; q' \<notin> current_msgqs s; no_del_event s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   300
   \<Longrightarrow> valid (enrich_msgq s q q') \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   301
       (\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp) \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   302
       (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f) \<and> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   303
       (\<forall> tq. tq \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq) \<and> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   304
       (\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd) \<and>
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
   305
       (cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q) \<and>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   306
       (tainted (enrich_msgq s q q') = (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}))"
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   307
proof (induct s)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   308
  case Nil
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   309
  thus ?case by (auto)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   310
next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   311
  case (Cons e s)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   312
  hence vd_cons': "valid (e # s)" and curq_cons: "q \<in> current_msgqs (e # s)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   313
    and curq'_cons: "q' \<notin> current_msgqs (e # s)" and nodel_cons: "no_del_event (e # s)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   314
    and os: "os_grant s e" and grant: "grant s e"  and vd: "valid s"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   315
    by (auto dest:vd_cons vt_grant_os vt_grant)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   316
  from curq'_cons nodel_cons have curq': "q' \<notin> current_msgqs s" by (case_tac e, auto)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   317
  from nodel_cons have nodel: "no_del_event s" by (case_tac e, auto)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   318
  from nodel curq' vd Cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   319
  have pre: "q \<in> current_msgqs s \<Longrightarrow> valid (enrich_msgq s q q') \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   320
     (\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp) \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   321
     (\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f) \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   322
     (\<forall>tq. tq \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq) \<and>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   323
     (\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd) \<and>
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
   324
     (cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q) \<and>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   325
     (tainted (enrich_msgq s q q') = (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s}))"
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   326
    by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   327
  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   328
  from pre have pre_vd: "q \<in> current_msgqs s \<Longrightarrow> valid (enrich_msgq s q q')" by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   329
  from pre have pre_sp: "\<And> tp. \<lbrakk>tp \<in> current_procs s; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   330
    \<Longrightarrow> cp2sproc (enrich_msgq s q q') tp = cp2sproc s tp" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   331
  from pre have pre_sf: "\<And> f. \<lbrakk>f \<in> current_files s; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   332
    \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   333
  from pre have pre_sq: "\<And> tq. \<lbrakk>tq \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   334
    \<Longrightarrow> cq2smsgq (enrich_msgq s q q') tq = cq2smsgq s tq" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   335
  from pre have pre_sfd: "\<And> tp fd. \<lbrakk>fd \<in> proc_file_fds s tp; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   336
    \<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   337
  hence pre_sfd': "\<And> tp fd f. \<lbrakk>file_of_proc_fd s tp fd = Some f; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   338
    \<Longrightarrow> cfd2sfd (enrich_msgq s q q') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   339
  from pre have pre_duq: "q \<in> current_msgqs s \<Longrightarrow> cq2smsgq (enrich_msgq s q q') q' = cq2smsgq s q"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   340
    by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   341
  have vd_enrich:"q \<in> current_msgqs s \<Longrightarrow> valid (e # enrich_msgq s q q')" 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   342
    apply (frule pre_vd)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   343
    apply (erule_tac s = s and obj' = "E_msgq q'" in enrich_valid_intro_cons)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   344
    apply (simp_all add:pre nodel nodel_cons curq_cons vd_cons' vd enrich_msgq_hungs)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   345
    apply (clarsimp simp:nodel vd curq' enrich_msgq_alive)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   346
    apply (rule allI, rule impI, erule enrich_msgq_not_alive)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   347
    apply (simp_all add:curq' curq'_cons nodel vd enrich_msgq_cur_msgs enrich_msgq_filefd enrich_msgq_flagfd)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   348
    done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   349
  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   350
  have q_neq_q': "q' \<noteq> q" using curq'_cons curq_cons by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   351
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   352
  have vd_enrich_cons: "valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   353
  proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   354
    have "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   355
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   356
      fix p q'' assume ev: "e = CreateMsgq p q''" 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   357
      show "valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   358
      proof (cases "q'' = q")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   359
        case False with ev vd_enrich curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   360
        show ?thesis by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   361
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   362
        case True 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   363
        have "os_grant (CreateMsgq p q # s) (CreateMsgq p q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   364
          using os ev
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   365
          by (simp add:q_neq_q' curq')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   366
        moreover have "grant (CreateMsgq p q # s) (CreateMsgq p q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   367
          using grant ev
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   368
          by (auto simp add:sectxt_of_obj_def split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   369
        ultimately 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   370
        show ?thesis using  ev vd_cons' True 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   371
          by (auto intro: valid.intros(2))
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   372
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   373
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   374
    moreover have "\<And> p q'' m. \<lbrakk>e = SendMsg p q'' m; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   375
      \<Longrightarrow> valid (enrich_msgq (e # s) q q')" 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   376
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   377
      fix p q'' m assume ev: "e = SendMsg p q'' m" and q_in: "q \<in> current_msgqs s"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   378
      show "valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   379
      proof (cases "q'' = q")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   380
        case False with ev vd_enrich q_in
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   381
        show ?thesis by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   382
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   383
        case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   384
        from grant os ev True obtain psec qsec 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   385
          where psec: "sectxt_of_obj s (O_proc p) = Some psec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   386
          and qsec: "sectxt_of_obj s (O_msgq q) = Some qsec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   387
          by (auto split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   388
        from psec q_in os ev 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   389
        have psec':"sectxt_of_obj (enrich_msgq s q q') (O_proc p) = Some psec"  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   390
          by (auto dest!:pre_sp simp:cp2sproc_def split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   391
        from qsec q_in pre_duq vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   392
        have qsec': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = Some qsec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   393
          by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   394
        show ?thesis using ev True vd_cons' q_in vd_enrich nodel vd 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   395
          curq' psec psec' qsec qsec' grant os q_neq_q'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   396
          apply (simp, erule_tac valid.intros(2))    
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   397
          apply (auto simp:q_neq_q' enrich_msgq_cur_msgqs enrich_msgq_cur_procs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   398
            enrich_msgq_cur_msgs sectxt_of_obj_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   399
          done        
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   400
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   401
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   402
    moreover have "\<And> p q'' m. \<lbrakk>e = RecvMsg p q'' m; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   403
           \<Longrightarrow> valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   404
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   405
      fix p q'' m assume ev: "e = RecvMsg p q'' m" and q_in: "q \<in> current_msgqs s"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   406
      show "valid (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   407
      proof (cases "q'' = q")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   408
        case False with ev vd_enrich q_in
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   409
        show ?thesis by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   410
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   411
        case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   412
        from grant os ev True obtain psec qsec msec
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   413
          where psec: "sectxt_of_obj s (O_proc p) = Some psec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   414
          and qsec: "sectxt_of_obj s (O_msgq q) = Some qsec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   415
          and msec: "sectxt_of_obj s (O_msg q (hd (msgs_of_queue s q))) = Some msec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   416
          by (auto split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   417
        from psec q_in os ev 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   418
        have psec':"sectxt_of_obj (enrich_msgq s q q') (O_proc p) = Some psec"  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   419
          by (auto dest!:pre_sp simp:cp2sproc_def split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   420
        from qsec q_in pre_duq vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   421
        have qsec': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = Some qsec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   422
          by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   423
        from qsec q_in vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   424
        have qsec'': "sectxt_of_obj (enrich_msgq s q q') (O_msgq q) = Some qsec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   425
          apply (frule_tac pre_sq, simp_all)          
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   426
          by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sms')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   427
        from msec q_in pre_duq vd qsec qsec' qsec'' curq' nodel
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   428
        have msec': "sectxt_of_obj (enrich_msgq s q q') (O_msg q' (hd (msgs_of_queue s q))) = Some msec"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   429
          apply (auto simp:cq2smsgq_def  enrich_msgq_cur_msgs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   430
            split:option.splits dest!:current_has_sms')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   431
          apply (case_tac "msgs_of_queue s q")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   432
          using os ev True apply simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   433
          apply (simp add:cqm2sms.simps split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   434
          apply (auto simp:cm2smsg_def split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   435
          done          
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   436
        show ?thesis using ev True vd_cons' q_in vd_enrich nodel vd 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   437
          curq'  grant os q_neq_q' psec psec' msec msec' qsec qsec'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   438
          apply (simp, erule_tac valid.intros(2))
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   439
          apply (auto simp:enrich_msgq_cur_msgqs enrich_msgq_cur_procs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   440
            enrich_msgq_cur_msgs sectxt_of_obj_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   441
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   442
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   443
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   444
    ultimately
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   445
    show ?thesis using vd_enrich curq_cons vd_cons'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   446
      apply (case_tac e)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   447
      apply (auto simp del:enrich_msgq.simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   448
      apply (auto split:if_splits )
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   449
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   450
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   451
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   452
  have curpsec: "\<And> tp. \<lbrakk>tp \<in> current_procs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   453
    sectxt_of_obj (enrich_msgq s q q') (O_proc tp) = sectxt_of_obj s (O_proc tp)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   454
    using pre_vd vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   455
    apply (frule_tac pre_sp, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   456
    by (auto simp:cp2sproc_def split:option.splits if_splits dest!:current_has_sec')    
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   457
  have curfsec: "\<And> f. \<lbrakk>is_file s f; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   458
    sectxt_of_obj (enrich_msgq s q q') (O_file f) = sectxt_of_obj s (O_file f)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   459
  proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   460
    fix f 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   461
    assume a1: "is_file s f" and a2: "q \<in> current_msgqs s"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   462
    from a2 pre_sf pre_vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   463
    have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   464
      and vd_enrich: "valid (enrich_msgq s q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   465
      by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   466
    hence csf: "cf2sfile (enrich_msgq s q q') f = cf2sfile s f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   467
      using a1 by (auto simp:is_file_in_current)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   468
    from a1 obtain sf where csf_some: "cf2sfile s f = Some sf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   469
      apply (case_tac "cf2sfile s f")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   470
      apply (drule current_file_has_sfile')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   471
      apply (simp add:vd, simp add:is_file_in_current, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   472
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   473
    from a1 have a1': "is_file (enrich_msgq s q q') f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   474
      using vd nodel by (simp add:enrich_msgq_is_file)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   475
    show "sectxt_of_obj (enrich_msgq s q q') (O_file f) = sectxt_of_obj s (O_file f)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   476
      using csf csf_some vd_enrich vd a1 a1'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   477
      apply (auto simp:cf2sfile_def split:option.splits if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   478
      apply (case_tac f, simp_all)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   479
      apply (drule root_is_dir', simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   480
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   481
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   482
  have curdsec: "\<And> tf. \<lbrakk>is_dir s tf; q \<in> current_msgqs s\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   483
    \<Longrightarrow> sectxt_of_obj (enrich_msgq s q q') (O_dir tf) = sectxt_of_obj s (O_dir tf)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   484
  proof-  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   485
    fix tf 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   486
    assume a1: "is_dir s tf" and a2: "q \<in> current_msgqs s"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   487
    from a2 pre_sf pre_vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   488
    have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   489
      and vd_enrich: "valid (enrich_msgq s q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   490
      by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   491
    hence csf: "cf2sfile (enrich_msgq s q q') tf = cf2sfile s tf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   492
      using a1 by (auto simp:is_dir_in_current)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   493
    from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   494
      apply (case_tac "cf2sfile s tf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   495
      apply (drule current_file_has_sfile')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   496
      apply (simp add:vd, simp add:is_dir_in_current, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   497
      done      
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   498
    from a1 have a1': "is_dir (enrich_msgq s q q') tf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   499
      using enrich_msgq_is_dir vd nodel by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   500
    from a1 have a3: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   501
    from a1' vd have a3': "\<not> is_file (enrich_msgq s q q') tf" by (simp add:is_dir_not_file)  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   502
    show "sectxt_of_obj (enrich_msgq s q q') (O_dir tf) = sectxt_of_obj s (O_dir tf)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   503
      using csf csf_some a3 a3' vd_enrich vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   504
      apply (auto simp:cf2sfile_def split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   505
      apply (case_tac tf)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   506
      apply (simp add:root_sec_remains, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   507
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   508
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   509
  have curpsecs: "\<And> tf ctxts'. \<lbrakk>is_dir s tf; q \<in> current_msgqs s; get_parentfs_ctxts s tf = Some ctxts'\<rbrakk>
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   510
    \<Longrightarrow> \<exists> ctxts. get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts \<and> set ctxts = set ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   511
  proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   512
    fix tf ctxts'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   513
    assume a1: "is_dir s tf" and a2: "q \<in> current_msgqs s" 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   514
      and a4: "get_parentfs_ctxts s tf = Some ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   515
    from a2 pre
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   516
    have pre': "\<And>f. f \<in> current_files s \<Longrightarrow> cf2sfile (enrich_msgq s q q') f = cf2sfile s f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   517
      and vd_enrich': "valid (enrich_msgq s q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   518
      by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   519
    hence csf: "cf2sfile (enrich_msgq s q q') tf = cf2sfile s tf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   520
      using a1 by (auto simp:is_dir_in_current)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   521
    from a1 obtain sf where csf_some: "cf2sfile s tf = Some sf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   522
      apply (case_tac "cf2sfile s tf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   523
      apply (drule current_file_has_sfile')
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   524
      apply (simp add:vd, simp add:is_dir_in_current, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   525
      done      
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   526
    from a1 have a1': "is_dir (enrich_msgq s q q') tf"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   527
      using enrich_msgq_is_dir vd nodel by simp
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   528
    from a1 have a5: "\<not> is_file s tf" using vd by (simp add:is_dir_not_file)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   529
    from a1' vd have a5': "\<not> is_file (enrich_msgq s q q') tf" by (simp add:is_dir_not_file) 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   530
    
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   531
    from a1' pre_vd a2 obtain ctxts 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   532
      where a3: "get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   533
      apply (case_tac "get_parentfs_ctxts (enrich_msgq s q q') tf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   534
      apply (drule get_pfs_secs_prop', simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   535
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   536
    moreover have "set ctxts = set ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   537
    proof (cases tf)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   538
      case Nil          
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   539
      with a3 a4 vd vd_enrich'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   540
      show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   541
        by (simp add:get_parentfs_ctxts.simps root_sec_remains split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   542
    next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   543
      case (Cons a ff)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   544
      with csf csf_some a5 a5' vd_enrich' vd a3 a4
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   545
      show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   546
        apply (auto simp:cf2sfile_def split:option.splits if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   547
        done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   548
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   549
    ultimately 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   550
    show "\<exists> ctxts. get_parentfs_ctxts (enrich_msgq s q q') tf = Some ctxts \<and> set ctxts = set ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   551
      by auto        
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   552
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   553
    
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   554
  have psec_cons: "\<And> tp. tp \<in> current_procs (e # s) \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   555
    sectxt_of_obj (enrich_msgq (e # s) q q') (O_proc tp) = sectxt_of_obj (e # s) (O_proc tp)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   556
    using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   557
    apply (case_tac e)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   558
    apply (auto intro:curpsec simp:sectxt_of_obj_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   559
    apply (frule curpsec, simp, frule curfsec, simp)    
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   560
    apply (auto split:option.splits)[1]
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   561
    apply (frule vd_cons) defer apply (frule vd_cons)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   562
    apply (auto intro:curpsec simp:sectxt_of_obj_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   563
    done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   564
  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   565
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   566
  have sf_cons: "\<And> f. f \<in> current_files (e # s) \<Longrightarrow> cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   567
  proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   568
    fix f
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   569
    assume a1: "f \<in> current_files (e # s)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   570
    hence a1': "f \<in> current_files (enrich_msgq (e # s) q q')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   571
      using nodel_cons os vd vd_cons' vd_enrich_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   572
      apply (case_tac e)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   573
      apply (auto simp:current_files_simps enrich_msgq_cur_files dest:is_file_in_current split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   574
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   575
    have b1: "\<And> p f' flags fd opt. e = Open p f' flags fd opt \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   576
      cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   577
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   578
      fix p f' flags fd opt 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   579
      assume ev: "e = Open p f' flags fd opt"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   580
      show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   581
      proof (cases opt)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   582
        case None
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   583
        with a1 a1' ev vd_cons' vd_enrich_cons curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   584
        show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   585
          apply (simp add:cf2sfile_open_none)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   586
          apply (simp add:pre_sf current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   587
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   588
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   589
        case (Some inum)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   590
        show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   591
        proof (cases "f = f'")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   592
          case False
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   593
          with a1 a1' ev vd_cons' vd_enrich_cons curq_cons Some
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   594
          show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   595
            apply (simp add:cf2sfile_open)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   596
            apply (simp add:pre_sf current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   597
            done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   598
        next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   599
          case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   600
          with vd_cons' ev os Some
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   601
          obtain pf where pf: "parent f = Some pf" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   602
          then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   603
            using os vd ev Some True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   604
            apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   605
            apply (drule get_pfs_secs_prop', simp, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   606
            apply auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   607
            done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   608
            
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   609
          have "sectxt_of_obj (Open p f' flags fd (Some inum) # enrich_msgq s q q') (O_file f') = 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   610
                sectxt_of_obj (Open p f' flags fd (Some inum) # s) (O_file f')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   611
            using Some vd_enrich_cons vd_cons' ev pf True os curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   612
            by (simp add:sectxt_of_obj_simps curpsec curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   613
          moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   614
          have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   615
            using curq_cons ev pf Some True os 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   616
            by (simp add:curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   617
          moreover
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   618
          have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   619
            using curq_cons ev pf Some True os vd psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   620
            apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   621
            apply (drule get_pfs_secs_prop', simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   622
            apply (rule curpsecs, simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   623
            done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   624
          then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   625
            and psecs_eq: "set ctxts' = set ctxts" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   626
          ultimately show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   627
            using a1 a1' ev vd_cons' vd_enrich_cons Some True pf psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   628
            by (simp add:cf2sfile_open split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   629
        qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   630
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   631
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   632
    have b2: "\<And> p f' inum. e = Mkdir p f' inum \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   633
      cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   634
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   635
      fix p f' inum
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   636
      assume ev: "e = Mkdir p f' inum"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   637
      show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   638
      proof (cases "f' = f")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   639
        case False
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   640
        with a1 a1' ev vd_cons' vd_enrich_cons curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   641
        show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   642
          apply (simp add:cf2sfile_mkdir)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   643
          apply (simp add:pre_sf current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   644
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   645
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   646
        case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   647
        with vd_cons' ev os
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   648
        obtain pf where pf: "parent f = Some pf" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   649
        then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   650
          using os vd ev True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   651
          apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   652
          apply (drule get_pfs_secs_prop', simp, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   653
          apply auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   654
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   655
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   656
        have "sectxt_of_obj (Mkdir p f' inum # enrich_msgq s q q') (O_dir f') = 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   657
          sectxt_of_obj (Mkdir p f' inum # s) (O_dir f')"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   658
          using vd_enrich_cons vd_cons' ev pf True os curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   659
          by (simp add:sectxt_of_obj_simps curpsec curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   660
        moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   661
        have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   662
          using curq_cons ev pf True os 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   663
          by (simp add:curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   664
        moreover
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   665
        have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   666
          using curq_cons ev pf True os vd psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   667
          apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   668
          apply (drule get_pfs_secs_prop', simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   669
          apply (rule curpsecs, simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   670
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   671
        then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   672
          and psecs_eq: "set ctxts' = set ctxts" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   673
        ultimately show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   674
          using a1 a1' ev vd_cons' vd_enrich_cons True pf psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   675
          apply (simp add:cf2sfile_mkdir split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   676
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   677
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   678
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   679
    have b3: "\<And> p f' f''. e = LinkHard p f' f'' \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   680
      cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   681
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   682
      fix p f' f''
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   683
      assume ev: "e = LinkHard p f' f''"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   684
      show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   685
      proof (cases "f'' = f")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   686
        case False
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   687
        with a1 a1' ev vd_cons' vd_enrich_cons curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   688
        show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   689
          apply (simp add:cf2sfile_linkhard)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   690
          apply (simp add:pre_sf current_files_simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   691
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   692
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   693
        case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   694
        with vd_cons' ev os
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   695
        obtain pf where pf: "parent f = Some pf" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   696
        then obtain ctxts where psecs: "get_parentfs_ctxts s pf = Some ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   697
          using os vd ev True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   698
          apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   699
          apply (drule get_pfs_secs_prop', simp, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   700
          apply auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   701
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   702
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   703
        have "sectxt_of_obj (LinkHard p f' f'' # enrich_msgq s q q') (O_file f) = 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   704
          sectxt_of_obj (LinkHard p f' f'' # s) (O_file f)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   705
          using vd_enrich_cons vd_cons' ev pf True os curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   706
          by (simp add:sectxt_of_obj_simps curpsec curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   707
        moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   708
        have "sectxt_of_obj (enrich_msgq s q q') (O_dir pf) = sectxt_of_obj s (O_dir pf)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   709
          using curq_cons ev pf True os 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   710
          by (simp add:curdsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   711
        moreover
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   712
        have "\<exists> ctxts'. get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts' \<and> set ctxts' = set ctxts"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   713
          using curq_cons ev pf True os vd psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   714
          apply (case_tac "get_parentfs_ctxts s pf")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   715
          apply (drule get_pfs_secs_prop', simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   716
          apply (rule curpsecs, simp+)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   717
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   718
        then obtain ctxts' where psecs': "get_parentfs_ctxts (enrich_msgq s q q') pf = Some ctxts'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   719
          and psecs_eq: "set ctxts' = set ctxts" by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   720
        ultimately show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   721
          using a1 a1' ev vd_cons' vd_enrich_cons True pf psecs
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   722
          apply (simp add:cf2sfile_linkhard split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   723
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   724
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   725
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   726
    show "cf2sfile (enrich_msgq (e # s) q q') f = cf2sfile (e # s) f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   727
      apply (case_tac e)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   728
      prefer 6 apply (erule b1)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   729
      prefer 11 apply (erule b2)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   730
      prefer 11 apply (erule b3)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   731
      apply (simp_all only:b1 b2 b3)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   732
      using a1' a1 vd_enrich_cons vd_cons' curq_cons nodel_cons 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   733
      apply (simp_all add:cf2sfile_other'' cf2sfile_simps enrich_msgq.simps no_del_event.simps split:if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   734
      apply (simp_all add:pre_sf cf2sfile_other' current_files_simps split:if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   735
      apply (drule vd_cons, simp add:cf2sfile_other', drule pre_sf, simp+)+
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   736
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   737
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   738
  
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   739
  have sfd_cons:"\<And> tp fd f. file_of_proc_fd (e # s) tp fd = Some f \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   740
    cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   741
  proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   742
    fix tp fd f
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   743
    assume a1: "file_of_proc_fd (e # s) tp fd = Some f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   744
    hence a1': "file_of_proc_fd (enrich_msgq (e # s) q q') tp fd = Some f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   745
      using nodel_cons vd_enrich os vd_cons'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   746
      apply (case_tac e, auto simp:enrich_msgq_filefd simp del:enrich_msgq.simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   747
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   748
    have b1: "\<And> p f' flags fd' opt. e = Open p f' flags fd' opt \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   749
      cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   750
    proof-
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   751
      fix p f' flags fd' opt
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   752
      assume ev: "e = Open p f' flags fd' opt"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   753
      have c1': "file_of_proc_fd (Open p f' flags fd' opt # s) tp fd = Some f"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   754
        using a1' ev a1 by (simp split:if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   755
      show "cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd"        thm cfd2sfd_open
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   756
      proof (cases "tp = p \<and> fd = fd'")
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   757
        case False
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   758
        show ?thesis using ev vd_enrich_cons vd_cons' a1' a1 False curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   759
          apply (simp add:cfd2sfd_open split:if_splits del:file_of_proc_fd.simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   760
          apply (rule conjI, rule impI, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   761
          apply (rule conjI, rule impI, simp)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   762
          apply (auto simp: False  intro!:pre_sfd' split:if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   763
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   764
      next
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   765
        case True
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   766
        have "f' \<in> current_files (Open p f' flags fd' opt # s)" using ev vd_cons' os
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   767
          by (auto simp:current_files_simps is_file_in_current split:option.splits) 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   768
        hence "cf2sfile (Open p f' flags fd' opt # enrich_msgq s q q') f' 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   769
          = cf2sfile (Open p f' flags fd' opt # s) f'"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   770
          using sf_cons ev by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   771
        moreover have "sectxt_of_obj (enrich_msgq s q q') (O_proc p) = sectxt_of_obj s (O_proc p)"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   772
          apply (rule curpsec)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   773
          using os ev curq_cons   
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   774
          by (auto split:option.splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   775
        ultimately show ?thesis
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   776
          using ev True a1 a1' vd_enrich_cons vd_cons'
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   777
          apply (simp add:cfd2sfd_open sectxt_of_obj_simps del:file_of_proc_fd.simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   778
          done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   779
      qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   780
    qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   781
    show "cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   782
      apply (case_tac e)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   783
      prefer 6 apply (erule b1)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   784
      using a1' a1 vd_enrich_cons vd_cons' curq_cons
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   785
      apply (simp_all only:cfd2sfd_simps enrich_msgq.simps)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   786
      apply (auto simp:cfd2sfd_simps pre_sfd' dest:vd_cons cfd2sfd_other split:if_splits)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   787
      done
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   788
  qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   789
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   790
  have pfds_cons: "\<And> tp. tp \<in> current_procs (e # s) \<Longrightarrow> 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   791
    cpfd2sfds (enrich_msgq (e # s) q q') tp = cpfd2sfds (e # s) tp"
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
   792
    apply (auto simp add:cpfd2sfds_def proc_file_fds_def)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   793
    apply (rule_tac x = fd in exI, rule conjI, rule_tac x = f in exI)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   794
    prefer 3
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   795
    apply (rule_tac x = fd in exI, rule conjI, rule_tac x = f in exI)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   796
    apply (auto simp:sfd_cons enrich_msgq_filefd nodel_cons vd_cons')
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   797
    done  
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   798
  
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
   799
  have tainted_cons: "tainted (enrich_msgq (e # s) q q') = 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   800
    (tainted (e # s) \<union> {O_msg q' m | m. O_msg q m \<in> tainted (e # s)})"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   801
    apply (rule equalityI)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   802
    using nodel_cons curq_cons curq'_cons vd_cons' vd_enrich_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   803
    apply (rule enrich_msgq_tainted_aux2)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   804
    using nodel_cons curq_cons curq'_cons vd_cons' 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   805
    apply (rule enrich_msgq_tainted_aux1)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   806
    done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   807
  have pre_tainted: "q \<in> current_msgqs s \<Longrightarrow> tainted (enrich_msgq s q q') = 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   808
    (tainted s \<union> {O_msg q' m| m. O_msg q m \<in> tainted s})" by (simp add:pre)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   809
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   810
  have "\<forall>tp fd. fd \<in> proc_file_fds (e # s) tp \<longrightarrow> cfd2sfd (enrich_msgq (e # s) q q') tp fd = cfd2sfd (e # s) tp fd"
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   811
    by (auto simp:proc_file_fds_def elim!:sfd_cons)
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   812
  moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   813
  have "\<forall>tp. tp \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_msgq (e # s) q q') tp = cp2sproc (e # s) tp"
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
   814
    by (auto simp:cp2sproc_def pfds_cons psec_cons enrich_msgq_died_proc split:option.splits)    
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   815
  moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   816
  have "\<forall>tq. tq \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_msgq (e # s) q q') tq = cq2smsgq (e # s) tq"
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
   817
  proof clarify
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   818
    fix tq assume a1: "tq \<in> current_msgqs (e # s)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   819
    
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   820
    have curqsec: "\<And> tq. \<lbrakk>tq \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   821
      sectxt_of_obj (enrich_msgq s q q') (O_msgq tq) = sectxt_of_obj s (O_msgq tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   822
      using pre_vd vd
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   823
      apply (frule_tac pre_sq, simp)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   824
      by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms')
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   825
    have cursms: "\<And> q''. \<lbrakk>q'' \<in> current_msgqs s; q \<in> current_msgqs s\<rbrakk> \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   826
      cqm2sms (enrich_msgq s q q') q'' (msgs_of_queue (enrich_msgq s q q') q'') =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   827
      cqm2sms s q'' (msgs_of_queue s q'')"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   828
      using pre_vd vd
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   829
      apply (frule_tac pre_sq, simp)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   830
      by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms')
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   831
    have qsec_cons: "sectxt_of_obj (enrich_msgq (e # s) q q') (O_msgq tq) = sectxt_of_obj (e # s) (O_msgq tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   832
      using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons curq_cons a1
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   833
      apply (case_tac e)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   834
      apply (auto intro:curqsec simp:sectxt_of_obj_simps curpsec split:option.splits dest!:current_has_sec')      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   835
      apply (frule vd_cons) defer apply (frule vd_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   836
      apply (auto intro:curqsec simp:sectxt_of_obj_simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   837
      done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   838
    have sms_cons: "cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   839
      cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   840
    proof-      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   841
      have b1: "\<And> p q'' m. e = SendMsg p q'' m \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   842
        cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   843
        cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   844
        apply (case_tac e)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   845
        using a1 curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   846
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms pre_tainted       
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   847
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   848
        apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*})
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   849
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms pre_tainted       
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   850
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   851
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   852
      have b2: "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   853
        cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   854
        cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   855
        using a1 curq_cons curq'_cons vd_enrich_cons vd_cons'
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   856
        apply (auto simp:cqm2sms_simps intro:cursms)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   857
        apply (auto simp:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   858
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   859
      have b3: "\<And> p q'' m. e = RecvMsg p q'' m \<Longrightarrow>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   860
        cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   861
        cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   862
        using a1 curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   863
        apply (auto  simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms        
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   864
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   865
        apply (frule vd_cons) defer apply (frule vd_cons) 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   866
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec cursms        
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   867
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   868
        done      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   869
      show "cqm2sms (enrich_msgq (e # s) q q') tq (msgs_of_queue (enrich_msgq (e # s) q q') tq) =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   870
        cqm2sms (e # s) tq (msgs_of_queue (e # s) tq)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   871
        apply (case_tac e)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   872
        prefer 15 apply (erule b2)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   873
        prefer 15 apply (erule b1)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   874
        prefer 15 apply (erule b3)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   875
        using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons a1
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   876
        apply (auto intro:cursms simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons curqsec 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   877
          split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   878
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   879
    qed
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   880
    
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   881
    show "cq2smsgq (enrich_msgq (e # s) q q') tq = cq2smsgq (e # s) tq"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   882
      using a1 curq_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   883
      apply (simp add:cq2smsgq_def qsec_cons sms_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   884
      done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   885
  qed
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   886
  moreover 
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   887
  have "cq2smsgq (enrich_msgq (e # s) q q') q' = cq2smsgq (e # s) q"
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
   888
  proof-
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   889
    have duqsec: "q \<in> current_msgqs s \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   890
      sectxt_of_obj (enrich_msgq s q q') (O_msgq q') = sectxt_of_obj s (O_msgq q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   891
      apply (frule pre_duq) using vd
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   892
      by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms')
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   893
    have duqsms: "q \<in> current_msgqs s \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   894
      cqm2sms (enrich_msgq s q q') q' (msgs_of_queue (enrich_msgq s q q') q') =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   895
      cqm2sms s q (msgs_of_queue s q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   896
      apply (frule pre_duq) using vd
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   897
      by (auto simp:cq2smsgq_def split:option.splits if_splits dest!:current_has_sec' current_has_sms')
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   898
    have qsec_cons: "sectxt_of_obj (enrich_msgq (e # s) q q') (O_msgq q') = sectxt_of_obj (e # s) (O_msgq q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   899
      using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons curq_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   900
      apply (case_tac e)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   901
      apply (auto simp:duqsec sectxt_of_obj_simps curpsec split:option.splits dest!:current_has_sec')      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   902
      apply (frule vd_cons) defer apply (frule vd_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   903
      apply (auto intro:duqsec simp:sectxt_of_obj_simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   904
      done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   905
    have sms_cons: "cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') = 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   906
      cqm2sms (e # s) q (msgs_of_queue (e # s) q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   907
    proof-
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   908
      have b1: "\<And> p q'' m. e = SendMsg p q'' m \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   909
        cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   910
        cqm2sms (e # s) q (msgs_of_queue (e # s) q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   911
        apply (case_tac e)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   912
        using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   913
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   914
          enrich_msgq_cur_procs enrich_msgq_cur_msgqs
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   915
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   916
        apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*})
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   917
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   918
          enrich_msgq_cur_procs enrich_msgq_cur_msgqs    dest:tainted_in_current      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   919
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   920
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   921
      have b2: "\<And> p q''. e = CreateMsgq p q'' \<Longrightarrow> 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   922
        cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   923
        cqm2sms (e # s) q (msgs_of_queue (e # s) q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   924
        using curq_cons curq'_cons vd_enrich_cons vd_cons'
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   925
        apply (auto simp:cqm2sms_simps intro:duqsms)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   926
        apply (auto simp:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   927
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   928
      have b3: "\<And> p q'' m. e = RecvMsg p q'' m \<Longrightarrow>
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   929
        cqm2sms (enrich_msgq (e # s) q q') q' (msgs_of_queue (enrich_msgq (e # s) q q') q') =
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   930
        cqm2sms (e # s) q (msgs_of_queue (e # s) q)"
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   931
        using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   932
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   933
          enrich_msgq_cur_procs enrich_msgq_cur_msgqs
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   934
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   935
        apply (tactic {*ALLGOALS (ftac @{thm vd_cons})*})
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   936
        apply (auto simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsec duqsms pre_tainted
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   937
          enrich_msgq_cur_procs enrich_msgq_cur_msgqs    dest:tainted_in_current      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   938
            split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   939
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   940
      show ?thesis
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   941
      apply (case_tac e)      
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   942
        prefer 15 apply (erule b2)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   943
        prefer 15 apply (erule b1)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   944
        prefer 15 apply (erule b3)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   945
        using curq_cons vd_enrich_cons vd_cons' os pre_vd nodel_cons vd curq'_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   946
        apply (auto intro:duqsms simp:sectxt_of_obj_simps cqm2sms_simps curpsec qsec_cons duqsms 
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   947
          split:option.splits dest!:current_has_sec' current_has_sms' simp del:cqm2sms.simps)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   948
        done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   949
    qed
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   950
    show ?thesis
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   951
      using curq_cons
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   952
      apply (simp add:cq2smsgq_def qsec_cons sms_cons)
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   953
      done
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   954
  qed
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   955
  ultimately show ?case using vd_enrich_cons sf_cons tainted_cons
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   956
    by auto
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   957
qed
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   958
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   959
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
   960
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   961
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
   962
  ""
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   963
1a1df29d3507 enrich msgq done; but find bugs of s2ss, it should only considerate 'appropriate' objects, not including msg/fd ...
chunhan
parents: 90
diff changeset
   964
90
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   965
thm cp2sproc_def
003cac7b8bf5 enrich_msgq
chunhan
parents: 89
diff changeset
   966
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   967
(* enrich s target_proc duplicated_pro *)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   968
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
   969
where 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   970
  "enrich_proc [] tp dp n = []"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   971
| "enrich_proc (Execve p f fds # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   972
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   973
     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
   974
     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
   975
| "enrich_proc (Clone p p' fds # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   976
     if (tp = p') 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   977
     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
   978
     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
   979
| "enrich_proc (Open p f flags fd opt # s) tp dp n= (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   980
     if (tp = p)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   981
     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
   982
     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
   983
| "enrich_proc (ReadFile p fd # s) tp dp n = (
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   984
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   985
     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
   986
     else ReadFile p fd # (enrich_proc s tp dp n))"
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   987
| "enrich_proc (RecvMsg p q m # s) tp dp n = (
88
chunhan
parents: 87
diff changeset
   988
     if (tp = p) 
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
   989
     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
   990
     else RecvMsg p q m # (enrich_proc s tp dp n))"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   991
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   992
| "enrich_proc (CloseFd p fd # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   993
     if (tp = p \<and> fd \<in> proc_file_fds s p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   994
     then CloseFd dp fd # CloseFd p fd # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   995
     else CloseFd p fd # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   996
*)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   997
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   998
| "enrich_proc (Attach p h flag # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
   999
     if (tp = p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1000
     then Attach dp h flag # Attach p h flag # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1001
     else Attach p h flag # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1002
| "enrich_proc (Detach p h # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1003
     if (tp = p) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1004
     then Detach dp h # Detach p h # (enrich_proc s tp dp)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1005
     else Detach p h # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1006
*)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1007
(*
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1008
| "enrich_proc (Kill p p' # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1009
     if (tp = p') then Kill p p' # s
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1010
     else Kill p p' # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1011
| "enrich_proc (Exit p # s) tp dp = (
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1012
     if (tp = p) then Exit p # s
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1013
     else Exit p # (enrich_proc s tp dp))"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1014
*)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1015
| "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
  1016
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1017
definition is_created_proc:: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1018
where
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1019
  "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
  1020
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1021
definition is_created_proc':: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1022
where
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1023
  "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
  1024
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1025
lemma created_proc_clone:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1026
  "valid (Clone p p' fds # s) \<Longrightarrow> 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1027
   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
  1028
apply (drule vt_grant_os)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1029
apply (auto simp:is_created_proc_def dest:not_all_procs_prop2)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1030
using not_died_init_proc
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1031
by auto
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1032
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1033
lemma created_proc_exit: 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1034
  "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
  1035
by (simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1036
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1037
lemma created_proc_kill:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1038
  "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
  1039
by (simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1040
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1041
lemma created_proc_other:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1042
  "\<lbrakk>\<And> p p' fds. e \<noteq> Clone p p' fds;
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1043
    \<And> p. e \<noteq> Exit p;
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1044
    \<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
  1045
by (case_tac e, auto simp:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1046
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1047
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
  1048
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1049
lemma no_del_died:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1050
  "\<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
  1051
  \<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
  1052
apply (induct s)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1053
apply simp
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1054
apply (case_tac a)
82
chunhan
parents:
diff changeset
  1055
apply (auto split:option.splits)
chunhan
parents:
diff changeset
  1056
done
chunhan
parents:
diff changeset
  1057
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1058
lemma no_del_created_eq:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1059
  "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
  1060
apply (induct s)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1061
apply (simp add:is_created_proc_def is_created_proc'_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1062
apply (case_tac a)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1063
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
  1064
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1065
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1066
lemma enrich_proc_dup_in:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1067
  "\<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
  1068
   \<Longrightarrow> p' \<in> current_procs (enrich_proc s p p' i)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1069
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1070
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1071
apply (case_tac a)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1072
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
  1073
  dest:not_all_procs_prop3)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1074
sorry
82
chunhan
parents:
diff changeset
  1075
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1076
lemma enrich_proc_dup_ffd:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1077
  "\<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
  1078
   \<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
  1079
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1080
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1081
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
  1082
  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
  1083
sorry
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1084
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1085
lemma enrich_proc_dup_ffd':
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1086
  "\<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
  1087
    no_del_event s; valid s\<rbrakk>
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1088
   \<Longrightarrow> file_of_proc_fd s p fd = Some f"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1089
apply (induct s, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1090
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1091
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
  1092
  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
  1093
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
  1094
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1095
lemma enrich_proc_dup_ffd_eq:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1096
  "\<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
  1097
  \<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
  1098
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
  1099
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
  1100
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
  1101
apply (drule_tac i = i in enrich_proc_dup_ffd, simp+)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1102
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1103
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1104
lemma enrich_proc_cur_msgqs:
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1105
  "\<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
  1106
apply (induct s, simp)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1107
apply (auto)[1]
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1108
apply (drule new_msgq_1, simp, simp)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1109
apply (frule vt_grant_os, frule vd_cons)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1110
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1111
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1112
lemma enrich_proc_not_alive:
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1113
  "\<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
  1114
    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
  1115
  \<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
  1116
apply (case_tac obj, simp_all)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1117
prefer 5
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1118
apply (simp add:enrich_proc_cur_msgqs)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1119
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1120
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1121
apply (auto)[1]
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1122
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1123
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1124
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1125
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1126
apply (subgoal_tac "new_msgq s \<noteq> 0")
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1127
apply simp
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1128
apply arith
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1129
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
  1130
  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
  1131
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1132
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1133
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1134
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1135
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1136
lemma enrich_proc_dup_fflags:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1137
  "\<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
  1138
   \<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
  1139
       flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag"
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1140
apply (induct s arbitrary:p, simp add:is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1141
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1142
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
  1143
  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
  1144
sorry
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1145
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1146
lemma enrich_proc_dup_ffds:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1147
  "\<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
  1148
   \<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
  1149
apply (auto simp:proc_file_fds_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1150
apply (rule_tac x = f in exI) 
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1151
apply (erule enrich_proc_dup_ffd', simp+)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1152
apply (rule_tac x = f in exI)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1153
apply (erule enrich_proc_dup_ffd, simp+)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1154
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1155
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1156
lemma enrich_proc_dup_ffds_eq_fds:
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1157
  "\<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
  1158
   \<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
  1159
apply (induct s arbitrary:p)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1160
apply (simp add: is_created_proc_def)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1161
apply (frule not_all_procs_prop3)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1162
apply (frule vd_cons, frule vt_grant_os, case_tac a)
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1163
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
  1164
  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
  1165
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1166
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1167
lemma enrich_proc_dup_ffds':
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1168
  "\<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
  1169
   \<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
  1170
apply (auto simp:enrich_proc_dup_ffds_eq_fds)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1171
apply (simp add:proc_file_fds_def)
87
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1172
done
8d18cfc845dd remove init message queue
chunhan
parents: 86
diff changeset
  1173
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
  1174
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
  1175
  "\<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
  1176
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
  1177
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
  1178
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
  1179
apply (case_tac a, auto)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1180
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
  1181
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
  1182
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1183
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
  1184
  "\<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
  1185
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
  1186
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
  1187
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
  1188
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
  1189
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1190
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
  1191
  "\<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
  1192
   \<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
  1193
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
  1194
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
  1195
apply (frule vd_cons, frule vt_grant_os)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1196
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
  1197
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
  1198
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
  1199
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
  1200
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
  1201
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1202
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
  1203
  "\<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
  1204
   \<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
  1205
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
  1206
  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
  1207
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
  1208
cebdef333899 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
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
  1210
  "\<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
  1211
   \<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
  1212
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
  1213
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
  1214
apply (frule vd_cons, frule vt_grant_os)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1215
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
  1216
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
  1217
cebdef333899 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
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
  1219
  "\<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
  1220
   \<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
  1221
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
  1222
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
  1223
  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
  1224
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
  1225
cebdef333899 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
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
  1227
  "\<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
  1228
   \<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
  1229
apply (rule ext, case_tac x)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1230
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
  1231
  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
  1232
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
  1233
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1234
lemma enrich_proc_cur_msgqs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1235
  "\<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
  1236
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
  1237
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1238
apply (case_tac a, auto simp:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1239
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
  1240
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1241
lemma enrich_proc_cur_msgs:
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1242
  "\<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
  1243
apply (induct s, simp)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1244
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
  1245
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1246
apply (case_tac a, auto simp:Let_def)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1247
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
  1248
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1249
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
  1250
  "\<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
  1251
   \<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
  1252
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
  1253
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1254
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
  1255
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
  1256
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1257
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
  1258
  "\<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
  1259
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
  1260
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
  1261
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
  1262
cebdef333899 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
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
  1264
  "\<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
  1265
   \<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
  1266
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
  1267
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
  1268
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
  1269
apply (case_tac a)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1270
sorry
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1271
(*
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
  1272
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
  1273
done
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1274
*)
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
  1275
cebdef333899 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
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
  1277
  "\<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
  1278
   \<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
  1279
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
  1280
apply (frule vt_grant_os, frule vd_cons)
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1281
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
  1282
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
  1283
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
  1284
done
89
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1285
*)
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
  1286
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1287
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
  1288
  "\<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
  1289
   \<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
  1290
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
  1291
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
  1292
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1293
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
  1294
  "\<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
  1295
  \<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
  1296
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
  1297
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
  1298
  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
  1299
defer
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1300
apply (rule impI, rule notI)
ded3f83f6cb9 make clear of Indexing-objects and enrich-objects
chunhan
parents: 88
diff changeset
  1301
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
  1302
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1303
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
  1304
  "\<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
  1305
  \<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
  1306
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
  1307
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
  1308
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
  1309
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
  1310
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
  1311
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
  1312
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1313
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
  1314
  "\<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
  1315
  \<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
  1316
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
  1317
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
  1318
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
  1319
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
  1320
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
  1321
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
  1322
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1323
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
  1324
  "\<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
  1325
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
  1326
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
  1327
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
  1328
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
  1329
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1330
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
  1331
  "\<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
  1332
   \<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
  1333
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
  1334
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
  1335
  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
  1336
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
  1337
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1338
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
  1339
  "\<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
  1340
   \<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
  1341
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
  1342
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
  1343
  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
  1344
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
  1345
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  1346
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
  1347
  "\<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
  1348
   \<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
  1349
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
  1350
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
  1351
  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
  1352
  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
  1353
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
  1354
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
  1355
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
  1356
82
chunhan
parents:
diff changeset
  1357
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
  1358
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s; no_del_event s\<rbrakk>
82
chunhan
parents:
diff changeset
  1359
   \<Longrightarrow> valid (enrich_proc s p p') \<and> 
chunhan
parents:
diff changeset
  1360
       (\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
chunhan
parents:
diff changeset
  1361
       (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and> 
chunhan
parents:
diff changeset
  1362
       (\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and> 
chunhan
parents:
diff changeset
  1363
       (\<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
  1364
       (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
chunhan
parents:
diff changeset
  1365
       (\<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
  1366
proof (induct s)
chunhan
parents:
diff changeset
  1367
  case Nil
chunhan
parents:
diff changeset
  1368
  thus ?case by (auto simp:is_created_proc_def)
chunhan
parents:
diff changeset
  1369
next
chunhan
parents:
diff changeset
  1370
  case (Cons e s)
83
chunhan
parents: 82
diff changeset
  1371
  hence vd_cons': "valid (e # s)" and created_cons: "is_created_proc (e # s) p"
82
chunhan
parents:
diff changeset
  1372
    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
  1373
    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
  1374
    and nodel_cons: "no_del_event (e # s)"
83
chunhan
parents: 82
diff changeset
  1375
    by (auto dest:vd_cons' vt_grant_os vt_grant)
82
chunhan
parents:
diff changeset
  1376
  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
  1377
  from nodel_cons have nodel: "no_del_event s" by (case_tac e, auto)
82
chunhan
parents:
diff changeset
  1378
  from Cons have pre: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p') \<and>
chunhan
parents:
diff changeset
  1379
     (\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
chunhan
parents:
diff changeset
  1380
     (\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
chunhan
parents:
diff changeset
  1381
     (\<forall>q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
chunhan
parents:
diff changeset
  1382
     (\<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
  1383
     (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
chunhan
parents:
diff changeset
  1384
     (\<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
  1385
    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
  1386
  
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1387
  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
  1388
  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
  1389
    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
  1390
    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
  1391
    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
  1392
    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
  1393
    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
  1394
    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
  1395
    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
  1396
    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
  1397
    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
  1398
    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
  1399
    done  
82
chunhan
parents:
diff changeset
  1400
  have vd_enrich_cons: "valid (enrich_proc (e # s) p p')"
chunhan
parents:
diff changeset
  1401
  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
  1402
    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
  1403
      valid (Execve p f fds # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
  1404
      \<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
  1405
    proof-
chunhan
parents:
diff changeset
  1406
      fix f fds
chunhan
parents:
diff changeset
  1407
      assume a1: "valid (Execve p f fds # enrich_proc s p p')" and a2: "is_created_proc s p"
chunhan
parents:
diff changeset
  1408
        and a3: "valid (Execve p f fds # s)" and a0: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
  1409
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
  1410
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
  1411
        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
  1412
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
  1413
        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
  1414
        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
  1415
        by auto
82
chunhan
parents:
diff changeset
  1416
      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
  1417
      proof-
chunhan
parents:
diff changeset
  1418
        from a0 a3 have a0': "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
chunhan
parents:
diff changeset
  1419
        from a3 have grant: "grant s (Execve p f fds)" and os: "os_grant s (Execve p f fds)"
chunhan
parents:
diff changeset
  1420
          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
  1421
        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
  1422
          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
  1423
          by (auto dest:vt_grant_os simp:enrich_proc_is_file)
82
chunhan
parents:
diff changeset
  1424
        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
  1425
          using a3 a0'
chunhan
parents:
diff changeset
  1426
          apply (frule_tac vt_grant_os)
chunhan
parents:
diff changeset
  1427
          apply (auto simp:proc_file_fds_def)
chunhan
parents:
diff changeset
  1428
          apply (rule_tac x = fa in exI)
chunhan
parents:
diff changeset
  1429
          apply (erule enrich_proc_dup_ffd)
chunhan
parents:
diff changeset
  1430
          apply (simp_all add:vd all_procs a2)
chunhan
parents:
diff changeset
  1431
          done
chunhan
parents:
diff changeset
  1432
        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
  1433
          apply (auto simp:is_file_simps enrich_proc_dup_in a2 vd all_procs a1 enrich_proc_dup_ffds)
chunhan
parents:
diff changeset
  1434
          done
chunhan
parents:
diff changeset
  1435
        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
  1436
        proof-
chunhan
parents:
diff changeset
  1437
          from grant obtain up rp tp uf rf tf 
chunhan
parents:
diff changeset
  1438
            where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents:
diff changeset
  1439
            and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
  1440
            by (simp split:option.splits, blast)
chunhan
parents:
diff changeset
  1441
          with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
chunhan
parents:
diff changeset
  1442
            by (simp split:option.splits del:npctxt_execve.simps, blast)
chunhan
parents:
diff changeset
  1443
          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
  1444
            using p1 dup_sp a1 a0'
chunhan
parents:
diff changeset
  1445
            apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
  1446
            by (simp add:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
  1447
          from os have f_in': "is_file s f"  by simp 
chunhan
parents:
diff changeset
  1448
          from vd os have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
  1449
            by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
  1450
          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
  1451
            using f_in p2 cf2sf os a1
chunhan
parents:
diff changeset
  1452
            apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
  1453
            apply (auto dest:is_file_in_current simp:cf2sfile_def sectxt_of_obj_simps split:option.splits)
chunhan
parents:
diff changeset
  1454
            apply (case_tac f, simp)
chunhan
parents:
diff changeset
  1455
            apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents:
diff changeset
  1456
            done 
chunhan
parents:
diff changeset
  1457
          from dup_sfd a5 have "\<forall>fd. fd \<in> proc_file_fds s p \<longrightarrow> 
chunhan
parents:
diff changeset
  1458
            cfd2sfd (Execve p f fds # enrich_proc s p p') p' fd = cfd2sfd s p fd"
chunhan
parents:
diff changeset
  1459
            apply (rule_tac allI)
chunhan
parents:
diff changeset
  1460
            apply (erule_tac x = fd in allE, clarsimp)
chunhan
parents:
diff changeset
  1461
            apply (drule set_mp, simp)
chunhan
parents:
diff changeset
  1462
            apply (auto simp:cfd2sfd_execve proc_file_fds_def a1)
chunhan
parents:
diff changeset
  1463
            done
chunhan
parents:
diff changeset
  1464
          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
  1465
            using grant os p1 p2 p3 vd
chunhan
parents:
diff changeset
  1466
            apply (clarsimp)
chunhan
parents:
diff changeset
  1467
            apply (rule_tac s = s and p = p and fds = fds in enrich_inherit_fds_check_dup)
chunhan
parents:
diff changeset
  1468
            apply simp_all
chunhan
parents:
diff changeset
  1469
            done
chunhan
parents:
diff changeset
  1470
          moreover have "search_check (Execve p f fds # enrich_proc s p p') (up, rp, tp) f"
chunhan
parents:
diff changeset
  1471
            using p1 p2 p2' vd cf2sf f_in f_in' grant p3 f_in a1
chunhan
parents:
diff changeset
  1472
            apply (rule_tac s = s in enrich_search_check)
chunhan
parents:
diff changeset
  1473
            apply (simp_all add:is_file_simps)
chunhan
parents:
diff changeset
  1474
            apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
chunhan
parents:
diff changeset
  1475
            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
  1476
            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
  1477
            done
82
chunhan
parents:
diff changeset
  1478
          ultimately show ?thesis 
chunhan
parents:
diff changeset
  1479
            using p1' p2' p3
chunhan
parents:
diff changeset
  1480
            apply (simp split:option.splits)
chunhan
parents:
diff changeset
  1481
            using grant p1 p2
chunhan
parents:
diff changeset
  1482
            apply simp
chunhan
parents:
diff changeset
  1483
            done
chunhan
parents:
diff changeset
  1484
        qed
chunhan
parents:
diff changeset
  1485
        ultimately show ?thesis using a1
chunhan
parents:
diff changeset
  1486
          by (erule_tac valid.intros(2), auto)
chunhan
parents:
diff changeset
  1487
      qed
chunhan
parents:
diff changeset
  1488
    qed
chunhan
parents:
diff changeset
  1489
    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
  1490
      valid (Clone tp p' (fds \<inter> proc_file_fds s tp) # Clone tp p fds # s)"
chunhan
parents:
diff changeset
  1491
      apply (frule vt_grant_os, frule vt_grant, drule not_all_procs_prop3)
chunhan
parents:
diff changeset
  1492
      apply (rule valid.intros(2))
chunhan
parents:
diff changeset
  1493
      apply (simp_all split:option.splits add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
  1494
      apply (auto simp add:proc_file_fds_def)[1]
chunhan
parents:
diff changeset
  1495
      apply (auto simp:inherit_fds_check_def sectxt_of_obj_simps sectxts_of_fds_def inherit_fds_check_ctxt_def)
chunhan
parents:
diff changeset
  1496
      done
chunhan
parents:
diff changeset
  1497
    moreover have "\<And>f flags fd opt. \<lbrakk>valid (Open p f flags fd opt # enrich_proc s p p'); 
chunhan
parents:
diff changeset
  1498
      is_created_proc s p; valid (Open p f flags fd opt # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
  1499
       \<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
  1500
    proof-
chunhan
parents:
diff changeset
  1501
      fix f flags fd opt
chunhan
parents:
diff changeset
  1502
      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
  1503
        and a3: "valid (Open p f flags fd opt # s)" and a4: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
  1504
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
  1505
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
  1506
        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
  1507
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
  1508
        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
  1509
        using pre a2 by auto
chunhan
parents:
diff changeset
  1510
      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
  1511
      have a5: "p' \<in> current_procs (enrich_proc s p p')" 
chunhan
parents:
diff changeset
  1512
        using a2 a3 vd
chunhan
parents:
diff changeset
  1513
        apply (erule_tac enrich_proc_dup_in)
chunhan
parents:
diff changeset
  1514
        by (simp_all add:vd a4)
chunhan
parents:
diff changeset
  1515
      have a6: "is_file (Open p f flags fd opt # enrich_proc s p p') f"
chunhan
parents:
diff changeset
  1516
        using a1 a3
chunhan
parents:
diff changeset
  1517
        by (auto simp:is_file_open dest:vt_grant_os)
chunhan
parents:
diff changeset
  1518
      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
  1519
        using a2 a4 vd nodel
82
chunhan
parents:
diff changeset
  1520
        apply (simp add:enrich_proc_dup_ffds_eq_fds)
chunhan
parents:
diff changeset
  1521
        apply (rule notI)
chunhan
parents:
diff changeset
  1522
        apply (drule_tac p = p in file_fds_subset_pfds)
chunhan
parents:
diff changeset
  1523
        apply (drule set_mp, simp)
chunhan
parents:
diff changeset
  1524
        using a3
chunhan
parents:
diff changeset
  1525
        apply (drule_tac vt_grant_os)
chunhan
parents:
diff changeset
  1526
        apply (auto split:option.splits)
chunhan
parents:
diff changeset
  1527
        done
chunhan
parents:
diff changeset
  1528
      from a1 have a8: "valid (enrich_proc s p p')" by (erule_tac valid.cases, auto)
chunhan
parents:
diff changeset
  1529
      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
  1530
        by (auto dest:vt_grant_os vt_grant)
chunhan
parents:
diff changeset
  1531
      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
  1532
      proof (cases opt)
chunhan
parents:
diff changeset
  1533
        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
  1534
        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
  1535
          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
  1536
          by (auto dest:vt_grant_os simp:enrich_proc_is_file) 
82
chunhan
parents:
diff changeset
  1537
        from grant None obtain up rp tp uf rf tf 
chunhan
parents:
diff changeset
  1538
          where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
chunhan
parents:
diff changeset
  1539
          and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
chunhan
parents:
diff changeset
  1540
          apply (simp split:option.splits)
chunhan
parents:
diff changeset
  1541
          by (case_tac a, case_tac aa, blast)
chunhan
parents:
diff changeset
  1542
        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
  1543
          using p1 dup_sp a1
chunhan
parents:
diff changeset
  1544
          apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
  1545
          by (simp add:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
  1546
        from os None have f_in': "is_file s f" by simp 
chunhan
parents:
diff changeset
  1547
        from vd os None have "\<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
  1548
          by (auto dest!:is_file_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
  1549
        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
  1550
          using p2 cf2sf os a1 None f_in' vd f_in
chunhan
parents:
diff changeset
  1551
          apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
  1552
          apply (auto dest:is_file_in_current simp:cf2sfile_def sectxt_of_obj_simps split:option.splits)
chunhan
parents:
diff changeset
  1553
          apply (case_tac f, simp)
chunhan
parents:
diff changeset
  1554
          apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
chunhan
parents:
diff changeset
  1555
          done 
chunhan
parents:
diff changeset
  1556
        have "search_check (Open p f flags fd opt # enrich_proc s p p') (up, rp, tp) f"
chunhan
parents:
diff changeset
  1557
          using p1 p2 p2' vd cf2sf f_in f_in' grant f_in a1 None
chunhan
parents:
diff changeset
  1558
          apply (rule_tac s = s in enrich_search_check)
chunhan
parents:
diff changeset
  1559
          apply (simp_all add:is_file_simps)
chunhan
parents:
diff changeset
  1560
          apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
chunhan
parents:
diff changeset
  1561
          apply (simp add:cf2sfile_open_none)
chunhan
parents:
diff changeset
  1562
          done
chunhan
parents:
diff changeset
  1563
        thus ?thesis using a0 a5 a6 a7 None a1
chunhan
parents:
diff changeset
  1564
          apply (rule_tac valid.intros(2))
chunhan
parents:
diff changeset
  1565
          apply (simp_all add:a1)
chunhan
parents:
diff changeset
  1566
          apply (case_tac flags, simp add:is_creat_excl_flag_def)
chunhan
parents:
diff changeset
  1567
          using p1' p2'
chunhan
parents:
diff changeset
  1568
          apply simp
chunhan
parents:
diff changeset
  1569
          using grant p1 p2
chunhan
parents:
diff changeset
  1570
          apply (simp add:oflags_check_remove_create)
chunhan
parents:
diff changeset
  1571
          done
chunhan
parents:
diff changeset
  1572
      next
chunhan
parents:
diff changeset
  1573
        case (Some inum)
chunhan
parents:
diff changeset
  1574
        with os obtain pf where parent: "parent f = Some pf" by auto
chunhan
parents:
diff changeset
  1575
        with grant Some obtain pu rp pt pfu pfr pft where
chunhan
parents:
diff changeset
  1576
          p1: "sectxt_of_obj s (O_proc p) = Some (pu, rp, pt)" 
chunhan
parents:
diff changeset
  1577
          and p2: "sectxt_of_obj s (O_dir pf) = Some (pfu, pfr, pft)"
chunhan
parents:
diff changeset
  1578
          apply (simp split:option.splits)
chunhan
parents:
diff changeset
  1579
          apply (case_tac a, case_tac aa, blast)
chunhan
parents:
diff changeset
  1580
          done
chunhan
parents:
diff changeset
  1581
        from p1 have p1': "sectxt_of_obj (enrich_proc s p p') (O_proc p) = Some (pu, rp, pt)"
chunhan
parents:
diff changeset
  1582
          using cp2sp os
chunhan
parents:
diff changeset
  1583
          apply (erule_tac x = p in allE)
chunhan
parents:
diff changeset
  1584
          apply (auto split:option.splits simp:cp2sproc_def)
chunhan
parents:
diff changeset
  1585
          done
chunhan
parents:
diff changeset
  1586
        from os parent Some
chunhan
parents:
diff changeset
  1587
        have pf_in: "is_dir s pf" by auto
chunhan
parents:
diff changeset
  1588
        hence "\<exists> sf. cf2sfile s pf = Some sf" using vd
chunhan
parents:
diff changeset
  1589
          by (auto dest!:is_dir_in_current current_file_has_sfile)
chunhan
parents:
diff changeset
  1590
        from a1 parent Some have pf_in': "is_dir (enrich_proc s p p') pf" 
chunhan
parents:
diff changeset
  1591
          apply (frule_tac vt_grant_os)
chunhan
parents:
diff changeset
  1592
          by (clarsimp)
chunhan
parents:
diff changeset
  1593
        have p2': "sectxt_of_obj (enrich_proc s p p') (O_dir pf) = Some (pfu, pfr, pft)"
chunhan
parents:
diff changeset
  1594
        proof-
chunhan
parents:
diff changeset
  1595
          have "cf2sfile (enrich_proc s p p') pf = cf2sfile s pf"
chunhan
parents:
diff changeset
  1596
            using cf2sf pf_in
chunhan
parents:
diff changeset
  1597
            apply (drule_tac is_dir_in_current)
chunhan
parents:
diff changeset
  1598
            apply (erule_tac x = pf in allE)
chunhan
parents:
diff changeset
  1599
            by simp
chunhan
parents:
diff changeset
  1600
          with pf_in pf_in' p2 vd Some a8
chunhan
parents:
diff changeset
  1601
          show ?thesis            
chunhan
parents:
diff changeset
  1602
            apply (frule_tac is_dir_not_file)
chunhan
parents:
diff changeset
  1603
            apply (frule_tac s = "enrich_proc s p p'" in is_dir_not_file)
chunhan
parents:
diff changeset
  1604
            apply (simp add:cf2sfile_def)
chunhan
parents:
diff changeset
  1605
            apply (case_tac pf, simp) 
chunhan
parents:
diff changeset
  1606
            apply (simp add:sroot_def root_sec_remains)            
chunhan
parents:
diff changeset
  1607
            by (auto split:option.splits dest!:current_has_sec' get_pfs_secs_prop' dest:parentf_is_dir_prop1)        
chunhan
parents:
diff changeset
  1608
        qed
chunhan
parents:
diff changeset
  1609
        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
  1610
          = Some (pu, rp, pt)"
chunhan
parents:
diff changeset
  1611
          using a1 Some
chunhan
parents:
diff changeset
  1612
          apply (simp add:sec_open)
chunhan
parents:
diff changeset
  1613
          using dup_sp
chunhan
parents:
diff changeset
  1614
          apply (auto split:option.splits if_splits simp:cp2sproc_def)
chunhan
parents:
diff changeset
  1615
          done        
chunhan
parents:
diff changeset
  1616
        have nsf: "sectxt_of_obj (Open p f flags fd (Some inum) # enrich_proc s p p') (O_file f) 
chunhan
parents:
diff changeset
  1617
          = Some (pu, R_object, type_transition pt pft C_file True)"
chunhan
parents:
diff changeset
  1618
          using a1 Some p1 p2 parent p2' p1'
chunhan
parents:
diff changeset
  1619
          by (simp add:sec_open)
chunhan
parents:
diff changeset
  1620
        have "search_check (Open p f flags fd (Some inum) # enrich_proc s p p') (pu, rp, pt) f"
chunhan
parents:
diff changeset
  1621
        proof-
chunhan
parents:
diff changeset
  1622
          have "search_check (Open p f flags fd (Some inum) # enrich_proc s p p') (pu, rp, pt) pf"
chunhan
parents:
diff changeset
  1623
            using grant Some parent p1 p2 vd a1 pf_in pf_in' p2'
chunhan
parents:
diff changeset
  1624
            apply simp 
chunhan
parents:
diff changeset
  1625
            apply (rule_tac s = s in enrich_search_check') 
chunhan
parents:
diff changeset
  1626
            apply (simp_all add:is_dir_simps sectxt_of_obj_simps)
chunhan
parents:
diff changeset
  1627
            apply (rule allI, rule impI)
chunhan
parents:
diff changeset
  1628
            apply (case_tac "fa = f")
chunhan
parents:
diff changeset
  1629
            using os Some
chunhan
parents:
diff changeset
  1630
            apply simp
chunhan
parents:
diff changeset
  1631
            apply (drule_tac f' = fa in cf2sfile_open)
chunhan
parents:
diff changeset
  1632
            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
  1633
            using enrich_proc_cur_files a2 nodel
82
chunhan
parents:
diff changeset
  1634
            apply simp
chunhan
parents:
diff changeset
  1635
            apply simp
chunhan
parents:
diff changeset
  1636
            using cf2sf
chunhan
parents:
diff changeset
  1637
            apply simp
chunhan
parents:
diff changeset
  1638
            done
chunhan
parents:
diff changeset
  1639
          moreover have "is_file (Open p f flags fd (Some inum) # enrich_proc s p p') f"
chunhan
parents:
diff changeset
  1640
            using a1 Some
chunhan
parents:
diff changeset
  1641
            by (simp add:is_file_open)
chunhan
parents:
diff changeset
  1642
          ultimately 
chunhan
parents:
diff changeset
  1643
          show ?thesis
chunhan
parents:
diff changeset
  1644
            using parent a1 Some nsf
chunhan
parents:
diff changeset
  1645
            apply (erule_tac search_check_leveling_f)
chunhan
parents:
diff changeset
  1646
            apply (simp_all)
chunhan
parents:
diff changeset
  1647
            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
  1648
            (* 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
  1649
            apply (simp add:permission_check.simps)
chunhan
parents:
diff changeset
  1650
            sorry
chunhan
parents:
diff changeset
  1651
        qed
chunhan
parents:
diff changeset
  1652
        thus ?thesis using a0 a5 a6 a7 a1 Some
chunhan
parents:
diff changeset
  1653
          apply (rule_tac valid.intros(2))
chunhan
parents:
diff changeset
  1654
          apply (simp add:a1)
chunhan
parents:
diff changeset
  1655
          apply simp
chunhan
parents:
diff changeset
  1656
          apply (case_tac flags, simp add:is_creat_excl_flag_def)
chunhan
parents:
diff changeset
  1657
          using grant p1 p2 parent dup nsf
chunhan
parents:
diff changeset
  1658
          apply (simp add:oflags_check_remove_create)
chunhan
parents:
diff changeset
  1659
          done
chunhan
parents:
diff changeset
  1660
      qed
chunhan
parents:
diff changeset
  1661
    qed
chunhan
parents:
diff changeset
  1662
    moreover have "\<And>fd. \<lbrakk>valid (CloseFd p fd # enrich_proc s p p'); is_created_proc s p; 
chunhan
parents:
diff changeset
  1663
      valid (CloseFd p fd # s); p' \<notin> all_procs s; fd \<in> proc_file_fds s p\<rbrakk>
chunhan
parents:
diff changeset
  1664
      \<Longrightarrow> valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
  1665
    proof-
chunhan
parents:
diff changeset
  1666
      fix fd
chunhan
parents:
diff changeset
  1667
      assume a1: "valid (CloseFd p fd # enrich_proc s p p')" and a2: "is_created_proc s p" 
chunhan
parents:
diff changeset
  1668
        and a3: "p' \<notin> all_procs s" and a4: "valid (CloseFd p fd # s)"
chunhan
parents:
diff changeset
  1669
        and a5: "fd \<in> proc_file_fds s p"
chunhan
parents:
diff changeset
  1670
      from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
chunhan
parents:
diff changeset
  1671
      have "p' \<in> current_procs (enrich_proc s p p')" 
chunhan
parents:
diff changeset
  1672
        using a2 a3 vd
chunhan
parents:
diff changeset
  1673
        by (auto intro:enrich_proc_dup_in)
chunhan
parents:
diff changeset
  1674
      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
  1675
        using a5 a2 a3 vd pre_vd nodel
82
chunhan
parents:
diff changeset
  1676
        apply (simp)
chunhan
parents:
diff changeset
  1677
        apply (drule_tac s = "enrich_proc s p p'" and p = p' in file_fds_subset_pfds)
chunhan
parents:
diff changeset
  1678
        apply (erule set_mp)
chunhan
parents:
diff changeset
  1679
        apply (simp add:enrich_proc_dup_ffds)
chunhan
parents:
diff changeset
  1680
        done
chunhan
parents:
diff changeset
  1681
      ultimately show "valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
  1682
        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
  1683
        apply (simp_all add:a1 a0 a2 pre_vd)
82
chunhan
parents:
diff changeset
  1684
        done
chunhan
parents:
diff changeset
  1685
    qed
chunhan
parents:
diff changeset
  1686
    moreover have "\<And> fd. \<lbrakk>valid (ReadFile p fd # enrich_proc s p p');
chunhan
parents:
diff changeset
  1687
            is_created_proc s p; valid (ReadFile p fd # s); p' \<notin> all_procs s\<rbrakk>
chunhan
parents:
diff changeset
  1688
           \<Longrightarrow> valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
  1689
    proof-
chunhan
parents:
diff changeset
  1690
      fix fd
chunhan
parents:
diff changeset
  1691
      assume a1: "valid (ReadFile p fd # enrich_proc s p p')" and a2: "is_created_proc s p"
chunhan
parents:
diff changeset
  1692
        and a3: "valid (ReadFile p fd # s)" and a4: "p' \<notin> all_procs s"
chunhan
parents:
diff changeset
  1693
      from a3 have os: "os_grant s (ReadFile p fd)" and grant: "grant s (ReadFile p fd)"
chunhan
parents:
diff changeset
  1694
        by (auto dest:vt_grant_os vt_grant)
chunhan
parents:
diff changeset
  1695
      have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
chunhan
parents:
diff changeset
  1696
        and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
chunhan
parents:
diff changeset
  1697
        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
  1698
        and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
chunhan
parents:
diff changeset
  1699
        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
  1700
        using pre a2 by auto
chunhan
parents:
diff changeset
  1701
      have vd_enrich: "valid (enrich_proc s p p')" using a1 by (auto dest:valid.cases)
chunhan
parents:
diff changeset
  1702
      show "valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
chunhan
parents:
diff changeset
  1703
      proof-
chunhan
parents:
diff changeset
  1704
        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
  1705
          using a1 a2 a4 vd os nodel
82
chunhan
parents:
diff changeset
  1706
          apply (clarsimp simp:current_files_simps enrich_proc_dup_in enrich_proc_dup_ffds_eq_fds)
chunhan
parents:
diff changeset
  1707
          apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
  1708
          apply (rule conjI)
chunhan
parents:
diff changeset
  1709
          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
  1710
          using enrich_proc_cur_files
82
chunhan
parents:
diff changeset
  1711
          apply (simp)
chunhan
parents:
diff changeset
  1712
          apply (drule enrich_proc_dup_fflags)
chunhan
parents:
diff changeset
  1713
          apply simp_all
chunhan
parents:
diff changeset
  1714
          apply (erule disjE)
chunhan
parents:
diff changeset
  1715
          apply auto
chunhan
parents:
diff changeset
  1716
          apply (simp add:is_read_flag_def)
chunhan
parents:
diff changeset
  1717
          done
chunhan
parents:
diff changeset
  1718
        moreover have "grant (ReadFile p fd # enrich_proc s p p') (ReadFile p' fd)"
chunhan
parents:
diff changeset
  1719
        proof-
chunhan
parents:
diff changeset
  1720
          from grant obtain f sp sfd sf where p1: "file_of_proc_fd s p fd = Some f"
chunhan
parents:
diff changeset
  1721
            and p2: "sectxt_of_obj s (O_proc p) = Some sp" 
chunhan
parents:
diff changeset
  1722
            and p3: "sectxt_of_obj s (O_fd p fd) = Some sfd"
chunhan
parents:
diff changeset
  1723
            and p4: "sectxt_of_obj s (O_file f) = Some sf"
chunhan
parents:
diff changeset
  1724
            by (auto split:option.splits) 
chunhan
parents:
diff changeset
  1725
          from os obtain flag where p0: "flags_of_proc_fd s p fd = Some flag"
chunhan
parents:
diff changeset
  1726
            by auto
chunhan
parents:
diff changeset
  1727
          from os have f_in_s: "f \<in> current_files s" using p1 by simp
chunhan
parents:
diff changeset
  1728
          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
  1729
          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
  1730
            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
  1731
            by (auto simp:enrich_proc_is_file) 
82
chunhan
parents:
diff changeset
  1732
          from p0 obtain flag' where p0': "flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag'"
chunhan
parents:
diff changeset
  1733
            and p0'': "(flag' = flag) \<or> (flag' = remove_create_flag flag)"
chunhan
parents:
diff changeset
  1734
            using a2 a4 vd
chunhan
parents:
diff changeset
  1735
            apply (drule_tac enrich_proc_dup_fflags)
chunhan
parents:
diff changeset
  1736
            apply auto
chunhan
parents:
diff changeset
  1737
            apply (case_tac flag, auto)
chunhan
parents:
diff changeset
  1738
            apply (case_tac flag, auto)
chunhan
parents:
diff changeset
  1739
            done            
chunhan
parents:
diff changeset
  1740
          from p1 have p1': "file_of_proc_fd (enrich_proc s p p') p' fd = Some f"
chunhan
parents:
diff changeset
  1741
            using a2 a4 vd
chunhan
parents:
diff changeset
  1742
            by (simp add:enrich_proc_dup_ffd)
chunhan
parents:
diff changeset
  1743
          from p2 have p2': "sectxt_of_obj (enrich_proc s p p') (O_proc p') = Some sp"
chunhan
parents:
diff changeset
  1744
            using dup_sp
chunhan
parents:
diff changeset
  1745
            by (auto simp:cp2sproc_def split:option.splits)
chunhan
parents:
diff changeset
  1746
          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
  1747
            using dup_sfd
chunhan
parents:
diff changeset
  1748
            apply (erule_tac x = fd in allE)
chunhan
parents:
diff changeset
  1749
            apply (auto simp:proc_file_fds_def cfd2sfd_def split:option.splits)
chunhan
parents:
diff changeset
  1750
            apply (drule current_file_has_sfile')
chunhan
parents:
diff changeset
  1751
            apply (simp add:vd, simp)
chunhan
parents:
diff changeset
  1752
            apply (drule current_file_has_sfile')
chunhan
parents:
diff changeset
  1753
            apply (simp add:vd, simp)
chunhan
parents:
diff changeset
  1754
            done
chunhan
parents:
diff changeset
  1755
          from p4 have p4': "sectxt_of_obj (enrich_proc s p p') (O_file f) = Some sf" 
chunhan
parents:
diff changeset
  1756
            using f_in_s cf2sf isfile_s isfile_s' a1 vd_enrich vd
chunhan
parents:
diff changeset
  1757
            apply (erule_tac x = f in allE)
chunhan
parents:
diff changeset
  1758
            apply (simp)
chunhan
parents:
diff changeset
  1759
            apply (auto simp:cf2sfile_def split:option.splits 
chunhan
parents:
diff changeset
  1760
              dest!:current_has_sec' get_pfs_secs_prop' dest:parentf_is_dir is_file_in_current)
chunhan
parents:
diff changeset
  1761
            apply (case_tac f, simp, drule root_is_dir', simp, simp, simp)
chunhan
parents:
diff changeset
  1762
            done
chunhan
parents:
diff changeset
  1763
          show ?thesis using p1' p2' p3' p4' a1
chunhan
parents:
diff changeset
  1764
            apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
  1765
            using grant p1 p2 p3 p4 
chunhan
parents:
diff changeset
  1766
            apply simp
chunhan
parents:
diff changeset
  1767
            done
chunhan
parents:
diff changeset
  1768
        qed
chunhan
parents:
diff changeset
  1769
        ultimately show ?thesis
chunhan
parents:
diff changeset
  1770
          using a1
chunhan
parents:
diff changeset
  1771
          by (erule_tac valid.intros(2), simp+)
chunhan
parents:
diff changeset
  1772
      qed
chunhan
parents:
diff changeset
  1773
    qed
chunhan
parents:
diff changeset
  1774
    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
  1775
      using vd_enrich created_cons vd_cons' all_procs_cons
82
chunhan
parents:
diff changeset
  1776
      apply (case_tac e)
chunhan
parents:
diff changeset
  1777
      apply (auto simp:is_created_proc_simps split:if_splits)
chunhan
parents:
diff changeset
  1778
      done
chunhan
parents:
diff changeset
  1779
  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
  1780
  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
  1781
    "\<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
  1782
    \<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
  1783
    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
  1784
    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
  1785
    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
  1786
    done
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1787
  have sf_cons:
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1788
    "\<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
  1789
  proof clarify
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1790
    fix f 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1791
    assume a1: "f \<in> current_files (e # s)"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1792
    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
  1793
      \<Longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1794
      by auto
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1795
    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
  1796
      using vd_cons' nodel_cons
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  1797
      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
  1798
    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
  1799
      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
  1800
      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
  1801
      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
  1802
        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
  1803
      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
  1804
    
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1805
    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
  1806
      "\<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
  1807
      \<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
  1808
    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
  1809
      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
  1810
      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
  1811
      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
  1812
      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
  1813
        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
  1814
        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
  1815
      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
  1816
        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
  1817
      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
  1818
        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
  1819
        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
  1820
        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
  1821
        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
  1822
      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
  1823
        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
  1824
      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
  1825
      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
  1826
      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
  1827
        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
  1828
        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
  1829
        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
  1830
        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
  1831
        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
  1832
    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
  1833
    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
  1834
      "\<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
  1835
      \<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
  1836
    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
  1837
      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
  1838
      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
  1839
      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
  1840
      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
  1841
        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
  1842
        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
  1843
      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
  1844
        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
  1845
      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
  1846
        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
  1847
        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
  1848
        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
  1849
        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
  1850
      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
  1851
        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
  1852
      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
  1853
        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
  1854
        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
  1855
        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
  1856
        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
  1857
        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
  1858
    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
  1859
    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
  1860
      "\<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
  1861
       \<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
  1862
    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
  1863
      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
  1864
      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
  1865
        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
  1866
      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
  1867
      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
  1868
        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
  1869
        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
  1870
      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
  1871
        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
  1872
      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
  1873
        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
  1874
        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
  1875
        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
  1876
        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
  1877
      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
  1878
        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
  1879
      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
  1880
      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
  1881
      
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
  1882
      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
  1883
        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
  1884
        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
  1885
        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
  1886
        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
  1887
      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
  1888
      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
  1889
        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
  1890
        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
  1891
        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
  1892
          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
  1893
      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
  1894
        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
  1895
        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
  1896
        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
  1897
          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
  1898
          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
  1899
      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
  1900
      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
  1901
      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
  1902
        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
  1903
    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
  1904
    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
  1905
      \<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
  1906
    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
  1907
      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
  1908
      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
  1909
      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
  1910
      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
  1911
        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
  1912
        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
  1913
          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
  1914
          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
  1915
            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
  1916
      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
  1917
        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
  1918
        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
  1919
        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
  1920
          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
  1921
          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
  1922
            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
  1923
            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
  1924
            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
  1925
            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
  1926
          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
  1927
            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
  1928
          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
  1929
            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
  1930
            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
  1931
          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
  1932
            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
  1933
            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
  1934
            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
  1935
            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
  1936
            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
  1937
            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
  1938
        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
  1939
          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
  1940
          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
  1941
            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
  1942
            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
  1943
          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
  1944
          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
  1945
            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
  1946
            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
  1947
            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
  1948
        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
  1949
      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
  1950
      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
  1951
        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
  1952
        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
  1953
        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
  1954
        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
  1955
        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
  1956
        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
  1957
    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
  1958
    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
  1959
      \<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
  1960
    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
  1961
      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
  1962
      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
  1963
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  1964
      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
  1965
      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
  1966
        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
  1967
        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
  1968
          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
  1969
          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
  1970
          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
  1971
          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
  1972
        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
  1973
          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
  1974
        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
  1975
          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
  1976
          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
  1977
        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
  1978
          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
  1979
          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
  1980
          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
  1981
          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
  1982
          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
  1983
          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
  1984
      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
  1985
        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
  1986
        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
  1987
          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
  1988
          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
  1989
        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
  1990
        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
  1991
          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
  1992
          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
  1993
          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
  1994
      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
  1995
    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
  1996
    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
  1997
      \<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
  1998
    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
  1999
      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
  2000
      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
  2001
      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
  2002
      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
  2003
        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
  2004
        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
  2005
          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
  2006
          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
  2007
          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
  2008
          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
  2009
        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
  2010
          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
  2011
        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
  2012
          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
  2013
          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
  2014
        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
  2015
          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
  2016
          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
  2017
          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
  2018
          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
  2019
          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
  2020
          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
  2021
      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
  2022
        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
  2023
        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
  2024
          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
  2025
          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
  2026
        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
  2027
        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
  2028
          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
  2029
          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
  2030
          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
  2031
      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
  2032
    qed
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2033
    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
  2034
      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
  2035
      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
  2036
      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
  2037
      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
  2038
      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
  2039
      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
  2040
        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
  2041
      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
  2042
  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
  2043
  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
  2044
    cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
83
chunhan
parents: 82
diff changeset
  2045
  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
  2046
    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
  2047
    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
  2048
    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
  2049
      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
  2050
    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
  2051
      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
  2052
    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
  2053
      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
  2054
    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
  2055
      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
  2056
    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
  2057
      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
  2058
      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
  2059
      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
  2060
    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
  2061
      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
  2062
      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
  2063
      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
  2064
    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
  2065
      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
  2066
      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
  2067
      done
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2068
    have sec_proc:
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2069
      "\<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
  2070
       \<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
  2071
      using pre 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2072
      apply (clarsimp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2073
      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
  2074
      done
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2075
    have sec_proc':
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2076
      "\<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
  2077
       \<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
  2078
      apply (drule_tac sec_proc, simp+)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2079
      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
  2080
    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
  2081
    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
  2082
      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
  2083
        \<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
  2084
        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
  2085
        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
  2086
        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
  2087
        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
  2088
        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
  2089
        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
  2090
        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
  2091
        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
  2092
        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
  2093
        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
  2094
        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
  2095
        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
  2096
        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
  2097
      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
  2098
       \<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
  2099
        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
  2100
        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
  2101
        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
  2102
        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
  2103
        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
  2104
        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
  2105
        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
  2106
      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
  2107
         \<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
  2108
        using a4 a1' vd_enrich_cons vd_cons' created_cons 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2109
        apply (simp split:if_splits del:file_of_proc_fd.simps) 
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2110
        
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2111
        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
  2112
        apply (tactic {*my_clarify_tac 1*})
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2113
        apply (drule vd_cons)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2114
        apply (simp add:cfd2sfd_open sec_open a3 a2 split:if_splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2115
        apply (case_tac "proc \<in> current_procs s")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2116
        apply (simp add:sec_proc')
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2117
        apply (case_tac "sectxt_of_obj s (O_proc proc)", simp+)        
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2118
        apply (case_tac "f \<in> current_files (e # s)")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2119
        apply (drule sf_cons[rule_format], simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2120
        using vd_enrich_cons
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2121
        apply (simp add:cf2sfile_open_none)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2122
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2123
        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
  2124
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2125
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2126
        apply (rule impI)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2127
        apply (simp add:cfd2sfd_open sec_open a3 a2 split:if_splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2128
        apply (drule vd_cons)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2129
        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
  2130
        apply (simp, rule impI, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2131
        apply (simp split:if_splits, rule conjI, rule impI, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2132
        apply (drule pre_sfd', simp, simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2133
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2134
        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
  2135
        apply (case_tac "proc \<in> current_procs s")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2136
        apply (simp add:sec_proc)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2137
        apply (case_tac "f' \<in> current_files (e # s)")
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2138
        apply (drule sf_cons[rule_format], simp)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2139
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2140
        apply (rule impI|rule conjI)+
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2141
        apply (drule current_has_sec', simp add:vd, simp add:os)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2142
        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
  2143
        apply (simp split:if_splits)
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2144
        apply (simp add:pre_sfd')
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2145
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2146
        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
  2147
        using os
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2148
        apply (simp split:option.splits)
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 84
diff changeset
  2149
        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
  2150
      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
  2151
         \<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
  2152
        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
  2153
        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
  2154
        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
  2155
        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
  2156
        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
  2157
        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
  2158
        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
  2159
        done 
83
chunhan
parents: 82
diff changeset
  2160
      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
  2161
        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
  2162
        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
  2163
        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
  2164
        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
  2165
        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
  2166
          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
  2167
        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
  2168
        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
  2169
    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
  2170
  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
  2171
  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
  2172
  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
  2173
    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
  2174
    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
  2175
    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
  2176
      \<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
  2177
      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
  2178
    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
  2179
      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
  2180
      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
  2181
      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
  2182
        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
  2183
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  2184
      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
  2185
      
690636b7b6f1 find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
chunhan
parents: 85
diff changeset
  2186
      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
  2187
      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
  2188
      thm cq2smsg_createmsgq
82
chunhan
parents:
diff changeset
  2189
    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
  2190
  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
  2191
    sorry
chunhan
parents:
diff changeset
  2192
  moreover have "cp2sproc (enrich_proc (e # s) p p') p' = cp2sproc (e # s) p"
chunhan
parents:
diff changeset
  2193
  proof-
chunhan
parents:
diff changeset
  2194
    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
  2195
    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
  2196
      is_created_proc (Execve tp f fds # s) p; p' \<notin> all_procs (Execve tp f fds # s)\<rbrakk>
chunhan
parents:
diff changeset
  2197
      \<Longrightarrow> cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  2198
    proof-
chunhan
parents:
diff changeset
  2199
      fix tp f fds
chunhan
parents:
diff changeset
  2200
      assume a1: "valid (enrich_proc (Execve tp f fds # s) p p')"
chunhan
parents:
diff changeset
  2201
      and a2: "valid (Execve tp f fds # s)" and a3: "is_created_proc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  2202
      and a4: "p' \<notin> all_procs (Execve tp f fds # s)"
chunhan
parents:
diff changeset
  2203
      show "cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
chunhan
parents:
diff changeset
  2204
      proof (cases "tp = p")
chunhan
parents:
diff changeset
  2205
        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
  2206
        show ?thesis using True a1 a2 a3 a4 b0 vd
82
chunhan
parents:
diff changeset
  2207
          thm not_all_procs_prop3
83
chunhan
parents: 82
diff changeset
  2208
          apply (frule_tac not_all_procs_prop2)
chunhan
parents: 82
diff changeset
  2209
          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
  2210
          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
  2211
          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
  2212
          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
  2213
          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
  2214
          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
  2215
          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
  2216
          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
  2217
          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
  2218
            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
  2219
          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
  2220
          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
  2221
          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
  2222
cebdef333899 cfd2sfd, OF_create flag should not be in the sfd, cause all-duplicated sfd could not have this flag
chunhan
parents: 83
diff changeset
  2223
          
83
chunhan
parents: 82
diff changeset
  2224
          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
  2225
  *)        
82
chunhan
parents:
diff changeset
  2226
          sorry
chunhan
parents:
diff changeset
  2227
      next
chunhan
parents:
diff changeset
  2228
        case False
chunhan
parents:
diff changeset
  2229
        show ?thesis sorry
chunhan
parents:
diff changeset
  2230
      qed
chunhan
parents:
diff changeset
  2231
    qed
chunhan
parents:
diff changeset
  2232
    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
  2233
      sorry
chunhan
parents:
diff changeset
  2234
    have b3: "\<And> tp. cp2sproc (enrich_proc (Exit tp # s) p p') p' = cp2sproc (Exit tp # s) p"
chunhan
parents:
diff changeset
  2235
      sorry
chunhan
parents:
diff changeset
  2236
    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
  2237
      sorry
chunhan
parents:
diff changeset
  2238
    have b5: "\<And> tp tp' fds. cp2sproc (enrich_proc (Clone tp tp' fds # s) p p') p' = 
chunhan
parents:
diff changeset
  2239
      cp2sproc (Clone tp tp' fds # s) p"
chunhan
parents:
diff changeset
  2240
      sorry
chunhan
parents:
diff changeset
  2241
    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
  2242
      cp2sproc (Open tp f flags fd opt # s) p"
chunhan
parents:
diff changeset
  2243
      sorry
chunhan
parents:
diff changeset
  2244
    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
  2245
      sorry
chunhan
parents:
diff changeset
  2246
    show ?thesis using vd_enrich_cons
chunhan
parents:
diff changeset
  2247
      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
  2248
      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
  2249
      apply (auto intro!:b1 b2 b3 b4 b5 b6 b7 simp del:enrich_proc.simps)
83
chunhan
parents: 82
diff changeset
  2250
      using created_cons vd_enrich_cons vd_cons' b0
82
chunhan
parents:
diff changeset
  2251
      apply (auto simp:cp2sproc_other is_created_proc_def)
chunhan
parents:
diff changeset
  2252
      done
chunhan
parents:
diff changeset
  2253
  qed
chunhan
parents:
diff changeset
  2254
  moreover have "\<forall> fd. fd \<in> proc_file_fds (e # s) p \<longrightarrow> 
chunhan
parents:
diff changeset
  2255
    cfd2sfd (enrich_proc (e # s) p p') p' fd = cfd2sfd (e # s) p fd"
chunhan
parents:
diff changeset
  2256
    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
  2257
  ultimately show ?case using vd_enrich_cons
82
chunhan
parents:
diff changeset
  2258
    by simp
chunhan
parents:
diff changeset
  2259
qed
chunhan
parents:
diff changeset
  2260
  
88
chunhan
parents: 87
diff changeset
  2261
lemma enrich_proc_s2ss:
chunhan
parents: 87
diff changeset
  2262
  "\<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
  2263
chunhan
parents:
diff changeset
  2264
lemma enrich_proc_valid:
chunhan
parents:
diff changeset
  2265
  "\<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
  2266
by (auto dest:enrich_proc_prop)
chunhan
parents:
diff changeset
  2267
chunhan
parents:
diff changeset
  2268
lemma enrich_proc_valid:
chunhan
parents:
diff changeset
  2269
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> " 
chunhan
parents:
diff changeset
  2270
chunhan
parents:
diff changeset
  2271
lemma enrich_proc_tainted: 
chunhan
parents:
diff changeset
  2272
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
  2273
   \<Longrightarrow> tainted (enrich_proc s p p') = (if (O_proc p \<in> tainted s) 
chunhan
parents:
diff changeset
  2274
         then tainted s \<union> {O_proc p'} else tainted s)"
chunhan
parents:
diff changeset
  2275
apply (induct s)
chunhan
parents:
diff changeset
  2276
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2277
apply (frule vt_grant_os, frule vd_cons, simp)
chunhan
parents:
diff changeset
  2278
apply (frule enrich_proc_dup_in, simp+)
chunhan
parents:
diff changeset
  2279
apply (frule not_all_procs_prop3)
chunhan
parents:
diff changeset
  2280
apply (case_tac a)
chunhan
parents:
diff changeset
  2281
prefer 3
chunhan
parents:
diff changeset
  2282
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  2283
apply (rule impI|rule conjI)+
chunhan
parents:
diff changeset
  2284
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2285
apply (auto simp:is_created_proc_def split:if_splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  2286
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2287
chunhan
parents:
diff changeset
  2288
prefer 4
chunhan
parents:
diff changeset
  2289
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  2290
apply (rule impI|rule conjI)+
chunhan
parents:
diff changeset
  2291
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2292
apply (auto simp:is_created_proc_def split:if_splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  2293
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2294
chunhan
parents:
diff changeset
  2295
prefer 4
chunhan
parents:
diff changeset
  2296
apply (auto simp:is_created_proc_def split:if_splits option.splits dest:tainted_in_current)[1]
chunhan
parents:
diff changeset
  2297
chunhan
parents:
diff changeset
  2298
prefer 4
chunhan
parents:
diff changeset
  2299
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
  2300
chunhan
parents:
diff changeset
  2301
chunhan
parents:
diff changeset
  2302
chunhan
parents:
diff changeset
  2303
lemma enrich_proc_dup_tainted:
chunhan
parents:
diff changeset
  2304
  "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
chunhan
parents:
diff changeset
  2305
   \<Longrightarrow> (O_proc p' \<in> tainted (enrich_proc s p p')) = (O_proc p \<in> tainted s)"
chunhan
parents:
diff changeset
  2306
apply (induct s)
chunhan
parents:
diff changeset
  2307
apply (simp add:is_created_proc_def)
chunhan
parents:
diff changeset
  2308
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  2309
apply (case_tac a)
chunhan
parents:
diff changeset
  2310
apply (auto simp:is_created_proc_def)[1]
chunhan
parents:
diff changeset
  2311
chunhan
parents:
diff changeset
  2312
chunhan
parents:
diff changeset
  2313
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
  2314
82
chunhan
parents:
diff changeset
  2315
chunhan
parents:
diff changeset
  2316
chunhan
parents:
diff changeset
  2317
end
chunhan
parents:
diff changeset
  2318
chunhan
parents:
diff changeset
  2319
end