no_shm_selinux/Co2sobj_prop.thy
author chunhan
Mon, 30 Dec 2013 23:41:58 +0800
changeset 86 690636b7b6f1
parent 85 1d1aa5bdd37d
child 87 8d18cfc845dd
permissions -rw-r--r--
find bug: a created proc can be tainted by a message, which cannot remain and maynot be duplicated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
chunhan
parents:
diff changeset
     1
(*<*)
chunhan
parents:
diff changeset
     2
theory Co2sobj_prop
chunhan
parents:
diff changeset
     3
imports Main Flask Flask_type Static Static_type Sectxt_prop Init_prop Current_files_prop Current_sockets_prop Delete_prop Proc_fd_of_file_prop Tainted_prop Valid_prop Init_prop Alive_prop
chunhan
parents:
diff changeset
     4
begin
chunhan
parents:
diff changeset
     5
(*<*)
chunhan
parents:
diff changeset
     6
chunhan
parents:
diff changeset
     7
ML {*
chunhan
parents:
diff changeset
     8
fun print_ss ss =
chunhan
parents:
diff changeset
     9
let
chunhan
parents:
diff changeset
    10
val {simps, congs, procs, ...} = Raw_Simplifier.dest_ss ss
chunhan
parents:
diff changeset
    11
in
chunhan
parents:
diff changeset
    12
simps
chunhan
parents:
diff changeset
    13
end
chunhan
parents:
diff changeset
    14
*}
chunhan
parents:
diff changeset
    15
chunhan
parents:
diff changeset
    16
chunhan
parents:
diff changeset
    17
context tainting_s begin
chunhan
parents:
diff changeset
    18
chunhan
parents:
diff changeset
    19
(********************* cm2smsg simpset ***********************)
chunhan
parents:
diff changeset
    20
chunhan
parents:
diff changeset
    21
lemma cm2smsg_other: 
chunhan
parents:
diff changeset
    22
  "\<lbrakk>valid (e # s); \<forall> p q m. e \<noteq> SendMsg p q m; \<forall> p q m. e \<noteq> RecvMsg p q m; \<forall> p q. e \<noteq> RemoveMsgq p q\<rbrakk> 
chunhan
parents:
diff changeset
    23
   \<Longrightarrow> cm2smsg (e # s) = cm2smsg s"
chunhan
parents:
diff changeset
    24
apply (frule vt_grant_os, frule vd_cons, rule ext, rule ext)
chunhan
parents:
diff changeset
    25
unfolding cm2smsg_def
chunhan
parents:
diff changeset
    26
apply (case_tac e)
chunhan
parents:
diff changeset
    27
apply (auto simp:sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    28
           split:t_object.splits option.splits if_splits 
chunhan
parents:
diff changeset
    29
           dest!:current_has_sec')
chunhan
parents:
diff changeset
    30
done
chunhan
parents:
diff changeset
    31
chunhan
parents:
diff changeset
    32
lemma cm2smsg_sendmsg:
chunhan
parents:
diff changeset
    33
  "valid (SendMsg p q m # s) \<Longrightarrow> cm2smsg (SendMsg p q m # s) = (\<lambda> q' m'. 
chunhan
parents:
diff changeset
    34
     if (q' = q \<and> m' = m)
chunhan
parents:
diff changeset
    35
     then (case (sectxt_of_obj (SendMsg p q m # s) (O_msg q m)) of
chunhan
parents:
diff changeset
    36
             Some sec \<Rightarrow> Some (Created, sec, O_msg q m \<in> tainted (SendMsg p q m # s))
chunhan
parents:
diff changeset
    37
           | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
    38
     else cm2smsg s q' m') "
chunhan
parents:
diff changeset
    39
apply (frule vd_cons, frule vt_grant_os, rule ext, rule ext)
chunhan
parents:
diff changeset
    40
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    41
  split:if_splits option.splits dest:not_died_init_msg
chunhan
parents:
diff changeset
    42
  dest!:current_has_sec')
chunhan
parents:
diff changeset
    43
done
chunhan
parents:
diff changeset
    44
chunhan
parents:
diff changeset
    45
lemma cm2smsg_recvmsg1:
chunhan
parents:
diff changeset
    46
  "\<lbrakk>q' \<noteq> q; valid (RecvMsg p q m # s)\<rbrakk> \<Longrightarrow> cm2smsg (RecvMsg p q m # s) q' = cm2smsg s q'"
chunhan
parents:
diff changeset
    47
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
    48
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    49
  split:if_splits option.splits)
chunhan
parents:
diff changeset
    50
done
chunhan
parents:
diff changeset
    51
chunhan
parents:
diff changeset
    52
lemma cm2smsg_recvmsg2:
chunhan
parents:
diff changeset
    53
  "\<lbrakk>m' \<noteq> m; valid (RecvMsg p q m # s)\<rbrakk> \<Longrightarrow> cm2smsg (RecvMsg p q m # s) q m' = cm2smsg s q m'"
chunhan
parents:
diff changeset
    54
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
    55
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    56
  split:if_splits option.splits)
chunhan
parents:
diff changeset
    57
done
chunhan
parents:
diff changeset
    58
chunhan
parents:
diff changeset
    59
lemma cm2smsg_recvmsg1':
chunhan
parents:
diff changeset
    60
  "\<lbrakk>valid (RecvMsg p q m # s); q' \<noteq> q\<rbrakk> \<Longrightarrow> cm2smsg (RecvMsg p q m # s) q' = cm2smsg s q'"
chunhan
parents:
diff changeset
    61
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
    62
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    63
  split:if_splits option.splits)
chunhan
parents:
diff changeset
    64
done
chunhan
parents:
diff changeset
    65
chunhan
parents:
diff changeset
    66
lemma cm2smsg_recvmsg2':
chunhan
parents:
diff changeset
    67
  "\<lbrakk>valid (RecvMsg p q m # s); m' \<noteq> m\<rbrakk> \<Longrightarrow> cm2smsg (RecvMsg p q m # s) q m' = cm2smsg s q m'"
chunhan
parents:
diff changeset
    68
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
    69
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    70
  split:if_splits option.splits)
chunhan
parents:
diff changeset
    71
done
chunhan
parents:
diff changeset
    72
chunhan
parents:
diff changeset
    73
lemma cm2smsg_removemsgq:
chunhan
parents:
diff changeset
    74
  "\<lbrakk>q' \<noteq> q; valid (RemoveMsgq p q # s)\<rbrakk> \<Longrightarrow> cm2smsg (RemoveMsgq p q # s) q' = cm2smsg s q'"
chunhan
parents:
diff changeset
    75
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
    76
apply (auto simp:cm2smsg_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
    77
  split:if_splits option.splits)
chunhan
parents:
diff changeset
    78
done
chunhan
parents:
diff changeset
    79
chunhan
parents:
diff changeset
    80
lemmas cm2smsg_simps = cm2smsg_nil_prop cm2smsg_sendmsg cm2smsg_recvmsg1' cm2smsg_recvmsg2'
chunhan
parents:
diff changeset
    81
  cm2smsg_removemsgq cm2smsg_other
chunhan
parents:
diff changeset
    82
chunhan
parents:
diff changeset
    83
lemma init_cm2smsg_has_smsg:
chunhan
parents:
diff changeset
    84
  "\<lbrakk>m \<in> set (init_msgs_of_queue q); q \<in> init_msgqs\<rbrakk> \<Longrightarrow> \<exists> sm. init_cm2smsg q m = Some sm"
chunhan
parents:
diff changeset
    85
by (auto simp:init_cm2smsg_def split:option.splits dest:init_msg_has_ctxt)
chunhan
parents:
diff changeset
    86
chunhan
parents:
diff changeset
    87
lemma hd_set_prop1:
chunhan
parents:
diff changeset
    88
  "hd l \<notin> set l \<Longrightarrow> l = []"
chunhan
parents:
diff changeset
    89
by (case_tac l, auto)
chunhan
parents:
diff changeset
    90
chunhan
parents:
diff changeset
    91
lemma tl_set_prop1:
chunhan
parents:
diff changeset
    92
  "a \<in> set (tl l) \<Longrightarrow> a \<in> set l"
chunhan
parents:
diff changeset
    93
by (case_tac l, auto)
chunhan
parents:
diff changeset
    94
chunhan
parents:
diff changeset
    95
lemma current_has_smsg:
chunhan
parents:
diff changeset
    96
  "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sm. cm2smsg s q m = Some sm"
chunhan
parents:
diff changeset
    97
apply (induct s)
chunhan
parents:
diff changeset
    98
apply (simp only:cm2smsg_nil_prop msgs_of_queue.simps current_msgqs.simps init_cm2smsg_has_smsg)
chunhan
parents:
diff changeset
    99
chunhan
parents:
diff changeset
   100
apply (frule vt_grant_os, frule vd_cons, case_tac a)
chunhan
parents:
diff changeset
   101
apply (auto simp:cm2smsg_def sectxt_of_obj_simps split:if_splits option.splits
chunhan
parents:
diff changeset
   102
  dest!:current_has_sec' hd_set_prop1 dest:not_died_init_msg tl_set_prop1)
chunhan
parents:
diff changeset
   103
done 
chunhan
parents:
diff changeset
   104
chunhan
parents:
diff changeset
   105
lemma current_has_smsg':
chunhan
parents:
diff changeset
   106
  "\<lbrakk>cm2smsg s q m = None; q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> m \<notin> set (msgs_of_queue s q)"
chunhan
parents:
diff changeset
   107
by (auto dest:current_has_smsg)
chunhan
parents:
diff changeset
   108
chunhan
parents:
diff changeset
   109
lemma cqm2sms_has_sms_aux:
chunhan
parents:
diff changeset
   110
  "\<forall> m \<in> set ms. sectxt_of_obj s (O_msg q m) \<noteq> None \<Longrightarrow> (\<exists> sms. cqm2sms s q ms = Some sms)"
chunhan
parents:
diff changeset
   111
by (induct ms, auto split:option.splits simp:cm2smsg_def)
chunhan
parents:
diff changeset
   112
chunhan
parents:
diff changeset
   113
lemma current_has_sms:
chunhan
parents:
diff changeset
   114
  "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sms. cqm2sms s q (msgs_of_queue s q) = Some sms"
chunhan
parents:
diff changeset
   115
apply (rule cqm2sms_has_sms_aux)
chunhan
parents:
diff changeset
   116
apply (auto dest:current_msg_has_sec)
chunhan
parents:
diff changeset
   117
done
chunhan
parents:
diff changeset
   118
chunhan
parents:
diff changeset
   119
lemma current_has_sms':
chunhan
parents:
diff changeset
   120
  "\<lbrakk>cqm2sms s q (msgs_of_queue s q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s"
chunhan
parents:
diff changeset
   121
by (auto dest:current_has_sms)
chunhan
parents:
diff changeset
   122
chunhan
parents:
diff changeset
   123
(********************* cqm2sms simpset ***********************) 
chunhan
parents:
diff changeset
   124
chunhan
parents:
diff changeset
   125
lemma cqm2sms_other:
chunhan
parents:
diff changeset
   126
  "\<lbrakk>valid (e # s); \<forall> p m. e \<noteq> CreateMsgq p q; \<forall> p q m. e \<noteq> SendMsg p q m; 
chunhan
parents:
diff changeset
   127
    \<forall> p q m. e \<noteq> RecvMsg p q m; \<forall> p q. e \<noteq> RemoveMsgq p q\<rbrakk> 
chunhan
parents:
diff changeset
   128
   \<Longrightarrow> cqm2sms (e # s) = cqm2sms s"
chunhan
parents:
diff changeset
   129
apply (rule ext, rule ext)
chunhan
parents:
diff changeset
   130
apply (induct_tac xa, simp)
chunhan
parents:
diff changeset
   131
apply (frule vt_grant_os, frule vd_cons, case_tac e)
chunhan
parents:
diff changeset
   132
apply (auto split:option.splits dest:cm2smsg_other) 
chunhan
parents:
diff changeset
   133
done
chunhan
parents:
diff changeset
   134
chunhan
parents:
diff changeset
   135
lemma cqm2sms_createmsgq:
chunhan
parents:
diff changeset
   136
  "valid (CreateMsgq p q # s) \<Longrightarrow> cqm2sms (CreateMsgq p q # s) = (\<lambda> q' ms'. 
chunhan
parents:
diff changeset
   137
     if (q' = q \<and> ms' = []) then Some []
chunhan
parents:
diff changeset
   138
     else cqm2sms s q' ms')"
chunhan
parents:
diff changeset
   139
apply (rule ext, rule ext)
chunhan
parents:
diff changeset
   140
apply (frule vt_grant_os, frule vd_cons, induct_tac ms')
chunhan
parents:
diff changeset
   141
apply (auto split:if_splits option.splits dest:cm2smsg_other)
chunhan
parents:
diff changeset
   142
done
chunhan
parents:
diff changeset
   143
chunhan
parents:
diff changeset
   144
lemma cqm2sms_2:
chunhan
parents:
diff changeset
   145
  "cqm2sms s q (ms @ [m]) = 
chunhan
parents:
diff changeset
   146
     (case (cqm2sms s q ms, cm2smsg s q m) of 
chunhan
parents:
diff changeset
   147
       (Some sms, Some sm) \<Rightarrow> Some (sms @ [sm]) 
chunhan
parents:
diff changeset
   148
     | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   149
apply (induct ms, simp split:option.splits)
chunhan
parents:
diff changeset
   150
by (auto split:option.splits)
chunhan
parents:
diff changeset
   151
chunhan
parents:
diff changeset
   152
lemmas cqm2sms_simps2 = cqm2sms.simps(1) cqm2sms_2
chunhan
parents:
diff changeset
   153
chunhan
parents:
diff changeset
   154
declare cqm2sms.simps [simp del]
chunhan
parents:
diff changeset
   155
chunhan
parents:
diff changeset
   156
lemma cqm2sms_prop1:
chunhan
parents:
diff changeset
   157
  "cqm2sms s q ms = None \<Longrightarrow> \<exists> m \<in> set ms. cm2smsg s q m = None"
chunhan
parents:
diff changeset
   158
by (induct ms, auto simp:cqm2sms.simps split:option.splits)
chunhan
parents:
diff changeset
   159
chunhan
parents:
diff changeset
   160
lemma cqm2sms_sendmsg1:
chunhan
parents:
diff changeset
   161
  "\<lbrakk>valid (SendMsg p q m # s); m \<notin> set ms\<rbrakk>
chunhan
parents:
diff changeset
   162
   \<Longrightarrow> cqm2sms (SendMsg p q m # s) q' ms = cqm2sms s q' ms"
chunhan
parents:
diff changeset
   163
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   164
apply (frule cm2smsg_sendmsg)
chunhan
parents:
diff changeset
   165
apply (induct ms rule:rev_induct)
chunhan
parents:
diff changeset
   166
apply (auto split:if_splits option.splits  simp:cqm2sms_simps2)
chunhan
parents:
diff changeset
   167
done
chunhan
parents:
diff changeset
   168
chunhan
parents:
diff changeset
   169
lemma cqm2sms_sendmsg2:
chunhan
parents:
diff changeset
   170
  "\<lbrakk>valid (SendMsg p q m # s); q' \<noteq> q\<rbrakk>
chunhan
parents:
diff changeset
   171
   \<Longrightarrow> cqm2sms (SendMsg p q m # s) q' ms = cqm2sms s q' ms"
chunhan
parents:
diff changeset
   172
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   173
apply (frule cm2smsg_sendmsg)
chunhan
parents:
diff changeset
   174
apply (induct ms rule:rev_induct)
chunhan
parents:
diff changeset
   175
apply (auto split:if_splits option.splits  simp:cqm2sms_simps2)
chunhan
parents:
diff changeset
   176
done
chunhan
parents:
diff changeset
   177
chunhan
parents:
diff changeset
   178
lemma cqm2sms_sendmsg3:
chunhan
parents:
diff changeset
   179
  "\<lbrakk>valid (SendMsg p q m # s); ms' = msgs_of_queue (SendMsg p q m # s) q\<rbrakk>
chunhan
parents:
diff changeset
   180
   \<Longrightarrow> cqm2sms (SendMsg p q m # s) q ms' = 
chunhan
parents:
diff changeset
   181
     (case (cqm2sms s q (msgs_of_queue s q), sectxt_of_obj (SendMsg p q m # s) (O_msg q m)) of
chunhan
parents:
diff changeset
   182
       (Some sms, Some sec) \<Rightarrow> Some (sms @ [(Created, sec, O_msg q m \<in> tainted (SendMsg p q m # s))])
chunhan
parents:
diff changeset
   183
     | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   184
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   185
apply (frule cm2smsg_sendmsg)
chunhan
parents:
diff changeset
   186
apply (auto split:if_splits option.splits  simp:cqm2sms_simps2 cqm2sms_sendmsg1)
chunhan
parents:
diff changeset
   187
done
chunhan
parents:
diff changeset
   188
chunhan
parents:
diff changeset
   189
lemma cqm2sms_sendmsg:
chunhan
parents:
diff changeset
   190
  "\<lbrakk>valid (SendMsg p q m # s); ms' = msgs_of_queue (SendMsg p q m # s) q'\<rbrakk> 
chunhan
parents:
diff changeset
   191
   \<Longrightarrow> cqm2sms (SendMsg p q m # s) q' ms' = (
chunhan
parents:
diff changeset
   192
     if (q' = q) 
chunhan
parents:
diff changeset
   193
     then (case (cqm2sms s q (msgs_of_queue s q), sectxt_of_obj (SendMsg p q m # s) (O_msg q m)) of
chunhan
parents:
diff changeset
   194
             (Some sms, Some sec) \<Rightarrow> Some (sms @ [(Created, sec, O_msg q m \<in> tainted (SendMsg p q m # s))])
chunhan
parents:
diff changeset
   195
           | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   196
     else cqm2sms s q' ms' )"
chunhan
parents:
diff changeset
   197
apply (simp split:if_splits add:cqm2sms_sendmsg2 cqm2sms_sendmsg3)
chunhan
parents:
diff changeset
   198
done
chunhan
parents:
diff changeset
   199
chunhan
parents:
diff changeset
   200
lemma cqm2sms_recvmsg1:
chunhan
parents:
diff changeset
   201
  "\<lbrakk>valid (RecvMsg p q m # s); m \<notin> set ms\<rbrakk> 
chunhan
parents:
diff changeset
   202
   \<Longrightarrow> cqm2sms (RecvMsg p q m # s) q ms = cqm2sms s q ms"
chunhan
parents:
diff changeset
   203
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   204
apply (induct ms rule:rev_induct)
chunhan
parents:
diff changeset
   205
apply (auto split:if_splits option.splits simp:cqm2sms_simps2 cm2smsg_recvmsg2')
chunhan
parents:
diff changeset
   206
done
chunhan
parents:
diff changeset
   207
chunhan
parents:
diff changeset
   208
lemma cqm2sms_recvmsg2:
chunhan
parents:
diff changeset
   209
  "\<lbrakk>valid (RecvMsg p q m # s); q' \<noteq> q\<rbrakk>
chunhan
parents:
diff changeset
   210
   \<Longrightarrow> cqm2sms (RecvMsg p q m # s) q' ms = cqm2sms s q' ms"
chunhan
parents:
diff changeset
   211
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   212
apply (induct ms rule:rev_induct)
chunhan
parents:
diff changeset
   213
apply (auto split:if_splits option.splits simp:cqm2sms_simps2 cm2smsg_recvmsg1')
chunhan
parents:
diff changeset
   214
done
chunhan
parents:
diff changeset
   215
chunhan
parents:
diff changeset
   216
lemma cqm2sms_recvmsg:
chunhan
parents:
diff changeset
   217
  "\<lbrakk>valid (RecvMsg p q m # s); ms = msgs_of_queue (RecvMsg p q m # s) q'\<rbrakk>
chunhan
parents:
diff changeset
   218
   \<Longrightarrow> cqm2sms (RecvMsg p q m # s) q' ms = (
chunhan
parents:
diff changeset
   219
     if (q' = q) 
chunhan
parents:
diff changeset
   220
     then (case (cqm2sms s q (msgs_of_queue s q)) of
chunhan
parents:
diff changeset
   221
             Some sms \<Rightarrow> Some (tl sms)
chunhan
parents:
diff changeset
   222
           | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   223
     else cqm2sms s q' ms)"
chunhan
parents:
diff changeset
   224
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   225
apply (auto split:if_splits option.splits simp:cqm2sms_recvmsg1 cqm2sms_recvmsg2 
chunhan
parents:
diff changeset
   226
     dest!:current_has_sms')
chunhan
parents:
diff changeset
   227
apply (case_tac "msgs_of_queue s q", simp)
chunhan
parents:
diff changeset
   228
apply (frule_tac ms = "tl (msgs_of_queue s q)" in cqm2sms_recvmsg1)
chunhan
parents:
diff changeset
   229
apply (drule_tac q = q in distinct_queue_msgs, simp+)
chunhan
parents:
diff changeset
   230
apply (case_tac a, auto simp:cqm2sms.simps split:option.splits if_splits)
chunhan
parents:
diff changeset
   231
done
chunhan
parents:
diff changeset
   232
chunhan
parents:
diff changeset
   233
lemma cqm2sms_removemsgq:
chunhan
parents:
diff changeset
   234
  "\<lbrakk>valid (RemoveMsgq p q # s); q' \<noteq> q; q' \<in> current_msgqs s\<rbrakk> 
chunhan
parents:
diff changeset
   235
   \<Longrightarrow> cqm2sms (RemoveMsgq p q # s) q' ms = cqm2sms s q' ms"
chunhan
parents:
diff changeset
   236
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
   237
apply (induct ms rule:rev_induct)
chunhan
parents:
diff changeset
   238
apply (auto simp:cqm2sms_simps2 cm2smsg_removemsgq split:option.splits if_splits)
chunhan
parents:
diff changeset
   239
done
chunhan
parents:
diff changeset
   240
  
chunhan
parents:
diff changeset
   241
lemmas cqm2sms_simps = cqm2sms_other cqm2sms_createmsgq cqm2sms_sendmsg cqm2sms_recvmsg cqm2sms_removemsgq
chunhan
parents:
diff changeset
   242
chunhan
parents:
diff changeset
   243
(********************* cq2smsgq simpset ***********************) 
chunhan
parents:
diff changeset
   244
 
chunhan
parents:
diff changeset
   245
lemma cq2smsgq_other: 
chunhan
parents:
diff changeset
   246
  "\<lbrakk>valid (e # s); \<forall> p q. e \<noteq> CreateMsgq p q; \<forall> p q m. e \<noteq> SendMsg p q m; 
chunhan
parents:
diff changeset
   247
    \<forall> p q m. e \<noteq> RecvMsg p q m; \<forall> p q. e \<noteq> RemoveMsgq p q\<rbrakk> 
chunhan
parents:
diff changeset
   248
   \<Longrightarrow> cq2smsgq (e # s) = cq2smsgq s" 
chunhan
parents:
diff changeset
   249
apply (frule cqm2sms_other, simp+)
chunhan
parents:
diff changeset
   250
apply (frule vd_cons, frule vt_grant_os, rule ext, case_tac e) 
chunhan
parents:
diff changeset
   251
apply (auto simp:cq2smsgq_def sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   252
           split:t_object.splits option.splits if_splits 
chunhan
parents:
diff changeset
   253
            dest:not_died_init_msg) 
chunhan
parents:
diff changeset
   254
done
chunhan
parents:
diff changeset
   255
chunhan
parents:
diff changeset
   256
lemma cq2smsg_createmsgq:
chunhan
parents:
diff changeset
   257
  "valid (CreateMsgq p q # s)
chunhan
parents:
diff changeset
   258
   \<Longrightarrow> cq2smsgq (CreateMsgq p q # s) = (cq2smsgq s) (q := 
chunhan
parents:
diff changeset
   259
     case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
   260
       Some psec \<Rightarrow> Some (Created, (fst psec, R_object, (snd o snd) psec), [])
chunhan
parents:
diff changeset
   261
     | None     \<Rightarrow> None)"
chunhan
parents:
diff changeset
   262
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   263
apply (frule cqm2sms_createmsgq)
chunhan
parents:
diff changeset
   264
apply (rule ext, auto simp:cq2smsgq_def sec_createmsgq 
chunhan
parents:
diff changeset
   265
  split:option.splits if_splits dest:not_died_init_msgq)
chunhan
parents:
diff changeset
   266
done
chunhan
parents:
diff changeset
   267
chunhan
parents:
diff changeset
   268
lemma cq2smsg_sendmsg:
chunhan
parents:
diff changeset
   269
  "valid (SendMsg p q m # s) 
chunhan
parents:
diff changeset
   270
   \<Longrightarrow> cq2smsgq (SendMsg p q m # s) = (cq2smsgq s) (q := 
chunhan
parents:
diff changeset
   271
     case (cq2smsgq s q, sectxt_of_obj (SendMsg p q m # s) (O_msg q m)) of 
chunhan
parents:
diff changeset
   272
       (Some (qi, sec, sms), Some msec) \<Rightarrow> 
chunhan
parents:
diff changeset
   273
          Some (qi, sec, sms @ [(Created, msec, O_msg q m \<in> tainted (SendMsg p q m # s))])
chunhan
parents:
diff changeset
   274
     | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   275
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   276
apply (rule ext)
chunhan
parents:
diff changeset
   277
apply (frule_tac q' = x in cqm2sms_sendmsg, simp)
chunhan
parents:
diff changeset
   278
apply (auto simp:cq2smsgq_def sectxt_of_obj_simps  split:option.splits if_splits
chunhan
parents:
diff changeset
   279
  dest!:current_has_sms' current_has_sec')
chunhan
parents:
diff changeset
   280
done
chunhan
parents:
diff changeset
   281
chunhan
parents:
diff changeset
   282
lemma current_has_smsgq:
chunhan
parents:
diff changeset
   283
  "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sq. cq2smsgq s q = Some sq"
chunhan
parents:
diff changeset
   284
by (auto simp:cq2smsgq_def split:option.splits dest!:current_has_sec' current_has_sms')
chunhan
parents:
diff changeset
   285
chunhan
parents:
diff changeset
   286
lemma current_has_smsgq':
chunhan
parents:
diff changeset
   287
  "\<lbrakk>cq2smsgq s q = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s"
chunhan
parents:
diff changeset
   288
by (auto dest:current_has_smsgq)
chunhan
parents:
diff changeset
   289
chunhan
parents:
diff changeset
   290
lemma cq2smsg_recvmsg:
chunhan
parents:
diff changeset
   291
  "valid (RecvMsg p q m # s) 
chunhan
parents:
diff changeset
   292
   \<Longrightarrow> cq2smsgq (RecvMsg p q m # s) = (cq2smsgq s) (q := 
chunhan
parents:
diff changeset
   293
    case (cq2smsgq s q) of
chunhan
parents:
diff changeset
   294
      Some (qi, sec, sms) \<Rightarrow> Some (qi, sec, tl sms)
chunhan
parents:
diff changeset
   295
    | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   296
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   297
apply (rule ext, frule_tac q' = x in cqm2sms_recvmsg, simp)
chunhan
parents:
diff changeset
   298
apply (auto simp add:cq2smsgq_def sectxt_of_obj_simps split:option.splits if_splits 
chunhan
parents:
diff changeset
   299
  dest!:current_has_sec' current_has_sms' current_has_smsgq')
chunhan
parents:
diff changeset
   300
done
chunhan
parents:
diff changeset
   301
chunhan
parents:
diff changeset
   302
lemma cq2smsg_removemsgq:
chunhan
parents:
diff changeset
   303
  "\<lbrakk>valid (RemoveMsgq p q # s); q' \<noteq> q; q' \<in> current_msgqs s\<rbrakk>
chunhan
parents:
diff changeset
   304
   \<Longrightarrow> cq2smsgq (RemoveMsgq p q # s) q' = cq2smsgq s q'"
chunhan
parents:
diff changeset
   305
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   306
apply (auto simp:cq2smsgq_def sectxt_of_obj_simps cqm2sms_removemsgq split:if_splits option.splits 
chunhan
parents:
diff changeset
   307
  dest!:current_has_sec' current_has_sms' current_has_smsgq')
chunhan
parents:
diff changeset
   308
done
chunhan
parents:
diff changeset
   309
chunhan
parents:
diff changeset
   310
lemmas cq2smsgq_simps = cq2smsgq_other cq2smsg_sendmsg cq2smsg_recvmsg cq2smsg_removemsgq
chunhan
parents:
diff changeset
   311
chunhan
parents:
diff changeset
   312
lemma sm_in_sqsms_init_aux:
chunhan
parents:
diff changeset
   313
  "\<lbrakk>m \<in> set ms; init_cm2smsg q m = Some sm; q \<in> init_msgqs; 
chunhan
parents:
diff changeset
   314
    init_cqm2sms q ms = Some sms\<rbrakk> \<Longrightarrow> sm \<in> set sms"
chunhan
parents:
diff changeset
   315
apply (induct ms arbitrary:m sm sms)
chunhan
parents:
diff changeset
   316
by (auto split:if_splits option.splits)
chunhan
parents:
diff changeset
   317
chunhan
parents:
diff changeset
   318
lemma sm_in_sqsms_init:
chunhan
parents:
diff changeset
   319
  "\<lbrakk>m \<in> set (init_msgs_of_queue q); init_cm2smsg q m = Some sm; q \<in> init_msgqs; 
chunhan
parents:
diff changeset
   320
    init_cqm2sms q (init_msgs_of_queue q) = Some sms\<rbrakk> \<Longrightarrow> sm \<in> set sms"
chunhan
parents:
diff changeset
   321
by (simp add:sm_in_sqsms_init_aux)
chunhan
parents:
diff changeset
   322
chunhan
parents:
diff changeset
   323
lemma cqm2sms_prop0:
chunhan
parents:
diff changeset
   324
  "\<lbrakk>m \<in> set ms; cm2smsg s q m = Some sm; cqm2sms s q ms = Some sms\<rbrakk> \<Longrightarrow> sm \<in> set sms"
chunhan
parents:
diff changeset
   325
apply (induct ms arbitrary:m sm sms)
chunhan
parents:
diff changeset
   326
apply (auto simp:cqm2sms.simps split:option.splits)
chunhan
parents:
diff changeset
   327
done
chunhan
parents:
diff changeset
   328
chunhan
parents:
diff changeset
   329
lemma sm_in_sqsms:
chunhan
parents:
diff changeset
   330
  "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s; cq2smsgq s q = Some (qi, qsec, sms);
chunhan
parents:
diff changeset
   331
    cm2smsg s q m = Some sm\<rbrakk> \<Longrightarrow> sm \<in> set sms"
chunhan
parents:
diff changeset
   332
proof (induct s arbitrary:m q qi qsec sms sm)
chunhan
parents:
diff changeset
   333
  case Nil
chunhan
parents:
diff changeset
   334
  thus ?case 
chunhan
parents:
diff changeset
   335
    by (simp add:cq2smsga_nil_prop cm2smsg_nil_prop init_cq2smsgq_def sm_in_sqsms_init 
chunhan
parents:
diff changeset
   336
           split:option.splits)
chunhan
parents:
diff changeset
   337
next
chunhan
parents:
diff changeset
   338
  case (Cons e s)
chunhan
parents:
diff changeset
   339
  hence p1:"\<And> m q qi qsec sms sm. \<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s; 
chunhan
parents:
diff changeset
   340
    cq2smsgq s q = Some (qi, qsec, sms); cm2smsg s q m = Some sm\<rbrakk>
chunhan
parents:
diff changeset
   341
    \<Longrightarrow> sm \<in> set sms" and p2: "m \<in> set (msgs_of_queue (e # s) q)" 
chunhan
parents:
diff changeset
   342
    and p3: "q \<in> current_msgqs (e # s)" and p4: "valid (e # s)"
chunhan
parents:
diff changeset
   343
    and p5: "cq2smsgq (e # s) q = Some (qi, qsec, sms)"
chunhan
parents:
diff changeset
   344
    and p6: "cm2smsg (e # s) q m = Some sm" by auto
chunhan
parents:
diff changeset
   345
  from p4 have os: "os_grant s e" and vd: "valid s" by (auto dest:vd_cons vt_grant_os)
chunhan
parents:
diff changeset
   346
(*
chunhan
parents:
diff changeset
   347
  from p1 have p1':
chunhan
parents:
diff changeset
   348
    "\<And> m q qi qsec sms sm ms. \<lbrakk>m \<in> set ms; set ms \<subseteq> set (msgs_of_queue s q); q \<in> current_msgqs s;
chunhan
parents:
diff changeset
   349
    valid s; cq2smsgq s q = Some (qi, qsec, sms); cm2smsg s q m = Some sm\<rbrakk>
chunhan
parents:
diff changeset
   350
    \<Longrightarrow> sm \<in> set "
chunhan
parents:
diff changeset
   351
*)
chunhan
parents:
diff changeset
   352
  show ?case using p2 p3 p4 p5 p6 vd os
chunhan
parents:
diff changeset
   353
    apply (case_tac e)
chunhan
parents:
diff changeset
   354
    apply (auto simp:cq2smsgq_simps cm2smsg_simps split:if_splits option.splits intro:p1)
chunhan
parents:
diff changeset
   355
chunhan
parents:
diff changeset
   356
    apply (rule_tac m = m and q = q and qi = qi and qsec = qsec in p1, simp+)
chunhan
parents:
diff changeset
   357
    apply (case_tac "q = nat2", simp)
chunhan
parents:
diff changeset
   358
    apply (drule cq2smsg_createmsgq, simp, simp)
chunhan
parents:
diff changeset
   359
chunhan
parents:
diff changeset
   360
    apply (drule_tac m = m and q = q and qi = qi and qsec = "(aa,ab,b)" in p1, simp+)
chunhan
parents:
diff changeset
   361
    apply (drule_tac m = m and q = q and qi = qi and qsec = "(aa,ab,b)" in p1, simp+)
chunhan
parents:
diff changeset
   362
chunhan
parents:
diff changeset
   363
    apply (simp add:cq2smsgq_def split:option.splits)
chunhan
parents:
diff changeset
   364
    apply (rule_tac m = m and sm = sm in cqm2sms_prop0, simp+)
chunhan
parents:
diff changeset
   365
    apply (simp add:cqm2sms_recvmsg)
chunhan
parents:
diff changeset
   366
    done
chunhan
parents:
diff changeset
   367
qed
chunhan
parents:
diff changeset
   368
chunhan
parents:
diff changeset
   369
(****************** cf2sfile path simpset ***************)
chunhan
parents:
diff changeset
   370
chunhan
parents:
diff changeset
   371
lemma sroot_only:
chunhan
parents:
diff changeset
   372
  "cf2sfile s [] = Some sroot"
chunhan
parents:
diff changeset
   373
by (simp add:cf2sfile_def)
chunhan
parents:
diff changeset
   374
chunhan
parents:
diff changeset
   375
lemma not_file_is_dir:
chunhan
parents:
diff changeset
   376
  "\<lbrakk>\<not> is_file s f; f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_dir s f"
chunhan
parents:
diff changeset
   377
by (auto simp:is_file_def current_files_def is_dir_def 
chunhan
parents:
diff changeset
   378
         dest:finum_has_itag finum_has_ftag' split:t_inode_tag.splits option.splits)
chunhan
parents:
diff changeset
   379
chunhan
parents:
diff changeset
   380
lemma not_dir_is_file:
chunhan
parents:
diff changeset
   381
  "\<lbrakk>\<not> is_dir s f; f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_file s f"
chunhan
parents:
diff changeset
   382
by (auto simp:is_file_def current_files_def is_dir_def 
chunhan
parents:
diff changeset
   383
         dest:finum_has_itag finum_has_ftag' split:t_inode_tag.splits option.splits)
chunhan
parents:
diff changeset
   384
chunhan
parents:
diff changeset
   385
lemma is_file_or_dir:
chunhan
parents:
diff changeset
   386
  "\<lbrakk>f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_file s f \<or> is_dir s f"
chunhan
parents:
diff changeset
   387
by (auto dest:not_dir_is_file)
chunhan
parents:
diff changeset
   388
chunhan
parents:
diff changeset
   389
lemma current_file_has_sfile:
chunhan
parents:
diff changeset
   390
  "\<lbrakk>f \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> \<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   391
apply (induct f)
chunhan
parents:
diff changeset
   392
apply (rule_tac x = "sroot" in exI, simp add:sroot_only)
chunhan
parents:
diff changeset
   393
apply (frule parentf_in_current', simp, clarsimp)
chunhan
parents:
diff changeset
   394
apply (frule parentf_is_dir'', simp)
chunhan
parents:
diff changeset
   395
apply (frule is_file_or_dir, simp)
chunhan
parents:
diff changeset
   396
apply (auto dest!:current_has_sec'
chunhan
parents:
diff changeset
   397
            simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop')
chunhan
parents:
diff changeset
   398
done
chunhan
parents:
diff changeset
   399
chunhan
parents:
diff changeset
   400
definition sectxt_of_pf :: "t_state \<Rightarrow> t_file \<Rightarrow> security_context_t option"
chunhan
parents:
diff changeset
   401
where
chunhan
parents:
diff changeset
   402
  "sectxt_of_pf s f = (case f of [] \<Rightarrow> None | (a # pf) \<Rightarrow> sectxt_of_obj s (O_dir pf))"
chunhan
parents:
diff changeset
   403
chunhan
parents:
diff changeset
   404
definition get_parentfs_ctxts' :: "t_state \<Rightarrow> t_file \<Rightarrow> (security_context_t list) option"
chunhan
parents:
diff changeset
   405
where
chunhan
parents:
diff changeset
   406
  "get_parentfs_ctxts' s f = (case f of [] \<Rightarrow> None | (a # pf) \<Rightarrow> get_parentfs_ctxts s pf)"
chunhan
parents:
diff changeset
   407
chunhan
parents:
diff changeset
   408
lemma is_file_has_sfile:
chunhan
parents:
diff changeset
   409
  "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec psec asecs. cf2sfile s f = Some 
chunhan
parents:
diff changeset
   410
      (if (\<not> died (O_file f) s \<and> is_init_file f) then Init f else Created,
chunhan
parents:
diff changeset
   411
       sec, Some psec, set asecs) \<and> (sectxt_of_obj s (O_file f) = Some sec) \<and>
chunhan
parents:
diff changeset
   412
       (sectxt_of_pf s f = Some psec) \<and> (get_parentfs_ctxts' s f = Some asecs)"
chunhan
parents:
diff changeset
   413
apply (case_tac f, simp, drule root_is_dir', simp, simp)
chunhan
parents:
diff changeset
   414
apply (frule is_file_in_current)
chunhan
parents:
diff changeset
   415
apply (drule current_file_has_sfile, simp)
chunhan
parents:
diff changeset
   416
apply (auto simp:cf2sfile_def sectxt_of_pf_def get_parentfs_ctxts'_def split:if_splits option.splits)
chunhan
parents:
diff changeset
   417
done
chunhan
parents:
diff changeset
   418
chunhan
parents:
diff changeset
   419
lemma is_file_has_sfile':
chunhan
parents:
diff changeset
   420
  "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   421
by (drule is_file_has_sfile, auto)
chunhan
parents:
diff changeset
   422
chunhan
parents:
diff changeset
   423
lemma is_dir_has_sfile:
chunhan
parents:
diff changeset
   424
  "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> (case f of
chunhan
parents:
diff changeset
   425
      [] \<Rightarrow> cf2sfile s f = Some sroot
chunhan
parents:
diff changeset
   426
    | a # pf \<Rightarrow> (\<exists> sec psec asecs. cf2sfile s f = Some 
chunhan
parents:
diff changeset
   427
      (if (\<not> died (O_dir f) s \<and> is_init_dir f) then Init f else Created,
chunhan
parents:
diff changeset
   428
       sec, Some psec, set asecs) \<and> (sectxt_of_obj s (O_dir f) = Some sec) \<and>
chunhan
parents:
diff changeset
   429
       (sectxt_of_obj s (O_dir pf) = Some psec) \<and> (get_parentfs_ctxts s pf = Some asecs)))"
chunhan
parents:
diff changeset
   430
apply (case_tac f, simp add:sroot_only)
chunhan
parents:
diff changeset
   431
apply (frule is_dir_in_current, frule is_dir_not_file)
chunhan
parents:
diff changeset
   432
apply (drule current_file_has_sfile, simp)
chunhan
parents:
diff changeset
   433
apply (auto simp:cf2sfile_def split:if_splits option.splits)
chunhan
parents:
diff changeset
   434
done
chunhan
parents:
diff changeset
   435
chunhan
parents:
diff changeset
   436
lemma is_dir_has_sdir':
chunhan
parents:
diff changeset
   437
  "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sf. cf2sfile s f = Some sf"
chunhan
parents:
diff changeset
   438
apply (case_tac f)
chunhan
parents:
diff changeset
   439
apply (rule_tac x = sroot in exI)
chunhan
parents:
diff changeset
   440
apply (simp add:sroot_only)
chunhan
parents:
diff changeset
   441
apply (drule is_dir_has_sfile, auto)
chunhan
parents:
diff changeset
   442
done
chunhan
parents:
diff changeset
   443
chunhan
parents:
diff changeset
   444
lemma sroot_set:
chunhan
parents:
diff changeset
   445
  "valid s \<Longrightarrow> \<exists> sec. sroot = (Init [], sec, None, {}) \<and> sectxt_of_obj s (O_dir []) = Some sec"
chunhan
parents:
diff changeset
   446
apply (frule root_is_dir)
chunhan
parents:
diff changeset
   447
apply (drule is_dir_has_sec, simp)
chunhan
parents:
diff changeset
   448
apply (auto simp:sroot_def sec_of_root_def sectxt_of_obj_def type_of_obj.simps 
chunhan
parents:
diff changeset
   449
                 root_type_remains root_user_remains
chunhan
parents:
diff changeset
   450
           dest!:root_has_type' root_has_user' root_has_init_type' root_has_init_user'
chunhan
parents:
diff changeset
   451
           split:option.splits)
chunhan
parents:
diff changeset
   452
done
chunhan
parents:
diff changeset
   453
chunhan
parents:
diff changeset
   454
lemma cf2sfile_path_file:
chunhan
parents:
diff changeset
   455
  "\<lbrakk>is_file s (f # pf); valid s\<rbrakk>
chunhan
parents:
diff changeset
   456
   \<Longrightarrow> cf2sfile s (f # pf) = (
chunhan
parents:
diff changeset
   457
     case (cf2sfile s pf) of
chunhan
parents:
diff changeset
   458
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
chunhan
parents:
diff changeset
   459
          (case (sectxt_of_obj s (O_file (f # pf))) of
chunhan
parents:
diff changeset
   460
              Some fsec \<Rightarrow> Some (if (\<not> died (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   461
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
chunhan
parents:
diff changeset
   462
           | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   463
     | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   464
apply (frule is_file_in_current, drule parentf_is_dir'', simp)
chunhan
parents:
diff changeset
   465
apply (frule is_dir_has_sfile, simp, frule is_file_has_sfile, simp)
chunhan
parents:
diff changeset
   466
apply (frule sroot_set)
chunhan
parents:
diff changeset
   467
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
chunhan
parents:
diff changeset
   468
done
chunhan
parents:
diff changeset
   469
chunhan
parents:
diff changeset
   470
lemma cf2sfile_path_dir:
chunhan
parents:
diff changeset
   471
  "\<lbrakk>is_dir s (f # pf); valid s\<rbrakk>
chunhan
parents:
diff changeset
   472
   \<Longrightarrow> cf2sfile s (f # pf) = (
chunhan
parents:
diff changeset
   473
     case (cf2sfile s pf) of
chunhan
parents:
diff changeset
   474
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> 
chunhan
parents:
diff changeset
   475
          (case (sectxt_of_obj s (O_dir (f # pf))) of
chunhan
parents:
diff changeset
   476
              Some fsec \<Rightarrow> Some (if (\<not> died (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   477
                                else Created, fsec, Some pfsec, asecs \<union> {pfsec})
chunhan
parents:
diff changeset
   478
           | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   479
     | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   480
apply (frule is_dir_in_current, drule parentf_is_dir'', simp)
chunhan
parents:
diff changeset
   481
apply (frule_tac f = "f # pf" in is_dir_has_sfile, simp)
chunhan
parents:
diff changeset
   482
apply (frule_tac f = "pf" in is_dir_has_sfile, simp)
chunhan
parents:
diff changeset
   483
apply (frule sroot_set)
chunhan
parents:
diff changeset
   484
apply (case_tac pf, (clarsimp simp:get_parentfs_ctxts'_def sectxt_of_pf_def)+) 
chunhan
parents:
diff changeset
   485
done  
chunhan
parents:
diff changeset
   486
chunhan
parents:
diff changeset
   487
lemma cf2sfile_path:
chunhan
parents:
diff changeset
   488
  "\<lbrakk>f # pf \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = (
chunhan
parents:
diff changeset
   489
     case (cf2sfile s pf) of
chunhan
parents:
diff changeset
   490
       Some (pfi, pfsec, psec, asecs) \<Rightarrow> (if (is_file s (f # pf))
chunhan
parents:
diff changeset
   491
         then (case (sectxt_of_obj s (O_file (f # pf))) of
chunhan
parents:
diff changeset
   492
                 Some fsec \<Rightarrow> Some (if (\<not> died (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   493
                                   else Created, fsec, Some pfsec, asecs \<union> {pfsec})
chunhan
parents:
diff changeset
   494
               | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   495
         else (case (sectxt_of_obj s (O_dir (f # pf))) of
chunhan
parents:
diff changeset
   496
                 Some fsec \<Rightarrow> Some (if (\<not> died (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   497
                                   else Created, fsec, Some pfsec, asecs \<union> {pfsec})
chunhan
parents:
diff changeset
   498
               | None \<Rightarrow> None)           )
chunhan
parents:
diff changeset
   499
     | None \<Rightarrow> None)"
chunhan
parents:
diff changeset
   500
apply (drule is_file_or_dir, simp)
chunhan
parents:
diff changeset
   501
apply (erule disjE)
chunhan
parents:
diff changeset
   502
apply (frule cf2sfile_path_file, simp) defer
chunhan
parents:
diff changeset
   503
apply (frule cf2sfile_path_dir, simp, drule is_dir_not_file)
chunhan
parents:
diff changeset
   504
apply (auto split:option.splits)
chunhan
parents:
diff changeset
   505
done
chunhan
parents:
diff changeset
   506
chunhan
parents:
diff changeset
   507
lemma cf2sfile_path_file_prop1:
chunhan
parents:
diff changeset
   508
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
chunhan
parents:
diff changeset
   509
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
chunhan
parents:
diff changeset
   510
                 Some (if (\<not> died (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   511
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
chunhan
parents:
diff changeset
   512
               sectxt_of_obj s (O_file (f # pf)) = Some fsec"
chunhan
parents:
diff changeset
   513
apply (frule is_file_has_sfile, simp)
chunhan
parents:
diff changeset
   514
by (auto simp:cf2sfile_path_file)
chunhan
parents:
diff changeset
   515
chunhan
parents:
diff changeset
   516
lemma cf2sfile_path_file_prop2:
chunhan
parents:
diff changeset
   517
  "\<lbrakk>is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
chunhan
parents:
diff changeset
   518
    sectxt_of_obj s (O_file (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
chunhan
parents:
diff changeset
   519
      Some (if (\<not> died (O_file (f # pf)) s \<and> is_init_file (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   520
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
chunhan
parents:
diff changeset
   521
by (drule cf2sfile_path_file_prop1, auto)
chunhan
parents:
diff changeset
   522
chunhan
parents:
diff changeset
   523
lemma cf2sfile_path_dir_prop1:
chunhan
parents:
diff changeset
   524
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\<rbrakk>
chunhan
parents:
diff changeset
   525
   \<Longrightarrow> \<exists> fsec. cf2sfile s (f # pf) = 
chunhan
parents:
diff changeset
   526
                 Some (if (\<not> died (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   527
                       else Created, fsec, Some pfsec, asecs \<union> {pfsec}) \<and> 
chunhan
parents:
diff changeset
   528
               sectxt_of_obj s (O_dir (f # pf)) = Some fsec"
chunhan
parents:
diff changeset
   529
apply (frule is_dir_has_sfile, simp)
chunhan
parents:
diff changeset
   530
by (auto simp:cf2sfile_path_dir)
chunhan
parents:
diff changeset
   531
chunhan
parents:
diff changeset
   532
lemma cf2sfile_path_dir_prop2:
chunhan
parents:
diff changeset
   533
  "\<lbrakk>is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); 
chunhan
parents:
diff changeset
   534
    sectxt_of_obj s (O_dir (f # pf)) = Some fsec; valid s\<rbrakk> \<Longrightarrow> cf2sfile s (f # pf) = 
chunhan
parents:
diff changeset
   535
      Some (if (\<not> died (O_dir (f # pf)) s \<and> is_init_dir (f # pf)) then Init (f # pf)
chunhan
parents:
diff changeset
   536
            else Created, fsec, Some pfsec, asecs \<union> {pfsec})"
chunhan
parents:
diff changeset
   537
by (drule cf2sfile_path_dir_prop1, auto)
chunhan
parents:
diff changeset
   538
chunhan
parents:
diff changeset
   539
(**************** cf2sfile event list simpset ****************)
chunhan
parents:
diff changeset
   540
chunhan
parents:
diff changeset
   541
lemma cf2sfile_open_none':
chunhan
parents:
diff changeset
   542
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f'= cf2sfile s f'"
chunhan
parents:
diff changeset
   543
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   544
apply (induct f', simp add:cf2sfile_def)
chunhan
parents:
diff changeset
   545
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   546
               get_parentfs_ctxts_simps)
chunhan
parents:
diff changeset
   547
done
chunhan
parents:
diff changeset
   548
chunhan
parents:
diff changeset
   549
lemma cf2sfile_open_none:
chunhan
parents:
diff changeset
   550
  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) = cf2sfile s"
chunhan
parents:
diff changeset
   551
apply (rule ext)
chunhan
parents:
diff changeset
   552
by (simp add:cf2sfile_open_none')
chunhan
parents:
diff changeset
   553
chunhan
parents:
diff changeset
   554
lemma cf2sfile_open_some1:
chunhan
parents:
diff changeset
   555
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); f' \<in> current_files s\<rbrakk>
chunhan
parents:
diff changeset
   556
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   557
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   558
apply (case_tac "f = f'", simp)
chunhan
parents:
diff changeset
   559
apply (induct f', simp add:sroot_only, simp)
chunhan
parents:
diff changeset
   560
apply (frule parentf_in_current', simp+)
chunhan
parents:
diff changeset
   561
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   562
               get_parentfs_ctxts_simps)
chunhan
parents:
diff changeset
   563
done
chunhan
parents:
diff changeset
   564
chunhan
parents:
diff changeset
   565
lemma cf2sfile_open_some2:
chunhan
parents:
diff changeset
   566
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<rbrakk>
chunhan
parents:
diff changeset
   567
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   568
apply (frule vd_cons, drule is_file_in_current)
chunhan
parents:
diff changeset
   569
by (simp add:cf2sfile_open_some1)
chunhan
parents:
diff changeset
   570
chunhan
parents:
diff changeset
   571
lemma cf2sfile_open_some3:
chunhan
parents:
diff changeset
   572
  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<rbrakk>
chunhan
parents:
diff changeset
   573
   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   574
apply (frule vd_cons, drule is_dir_in_current)
chunhan
parents:
diff changeset
   575
by (simp add:cf2sfile_open_some1)
chunhan
parents:
diff changeset
   576
chunhan
parents:
diff changeset
   577
lemma cf2sfile_open_some4:
chunhan
parents:
diff changeset
   578
  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f = (
chunhan
parents:
diff changeset
   579
     case (parent f) of
chunhan
parents:
diff changeset
   580
       Some pf \<Rightarrow> (case (sectxt_of_obj (Open p f flag fd (Some inum) # s) (O_file f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   581
                         get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   582
                    (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   583
                  | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   584
     | None \<Rightarrow> None)"
chunhan
parents:
diff changeset
   585
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   586
apply (case_tac f, simp)
chunhan
parents:
diff changeset
   587
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   588
               get_parentfs_ctxts_simps)
chunhan
parents:
diff changeset
   589
apply (rule impI, (erule conjE)+)
chunhan
parents:
diff changeset
   590
apply (drule not_died_init_file, simp+)
chunhan
parents:
diff changeset
   591
apply (simp add:is_file_in_current)
chunhan
parents:
diff changeset
   592
done
chunhan
parents:
diff changeset
   593
chunhan
parents:
diff changeset
   594
lemma cf2sfile_open:
chunhan
parents:
diff changeset
   595
  "\<lbrakk>valid (Open p f flag fd opt # s); f' \<in> current_files (Open p f flag fd opt # s)\<rbrakk>
chunhan
parents:
diff changeset
   596
   \<Longrightarrow> cf2sfile (Open p f flag fd opt # s) f' = (
chunhan
parents:
diff changeset
   597
     if (opt = None) then cf2sfile s f'
chunhan
parents:
diff changeset
   598
     else if (f' = f) 
chunhan
parents:
diff changeset
   599
     then (case (parent f) of
chunhan
parents:
diff changeset
   600
             Some pf \<Rightarrow> (case (sectxt_of_obj (Open p f flag fd opt # s) (O_file f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   601
                 get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   602
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   603
                        | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   604
           | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   605
     else cf2sfile s f')"
chunhan
parents:
diff changeset
   606
apply (case_tac opt)
chunhan
parents:
diff changeset
   607
apply (simp add:cf2sfile_open_none)
chunhan
parents:
diff changeset
   608
apply (case_tac "f = f'")
chunhan
parents:
diff changeset
   609
apply (simp add:cf2sfile_open_some4 split:option.splits)
chunhan
parents:
diff changeset
   610
apply (simp add:cf2sfile_open_some1 current_files_simps)
chunhan
parents:
diff changeset
   611
done
chunhan
parents:
diff changeset
   612
chunhan
parents:
diff changeset
   613
lemma cf2sfile_mkdir1:
chunhan
parents:
diff changeset
   614
  "\<lbrakk>valid (Mkdir p f i # s); f' \<in> current_files s\<rbrakk>
chunhan
parents:
diff changeset
   615
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   616
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   617
apply (case_tac "f = f'", simp)
chunhan
parents:
diff changeset
   618
apply (induct f', simp add:sroot_only, simp)
chunhan
parents:
diff changeset
   619
apply (frule parentf_in_current', simp+)
chunhan
parents:
diff changeset
   620
apply (case_tac "f = f'", simp)
chunhan
parents:
diff changeset
   621
apply (simp add:cf2sfile_path is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   622
               get_parentfs_ctxts_simps split:if_splits option.splits)
chunhan
parents:
diff changeset
   623
done
chunhan
parents:
diff changeset
   624
chunhan
parents:
diff changeset
   625
lemma cf2sfile_mkdir2:
chunhan
parents:
diff changeset
   626
  "\<lbrakk>valid (Mkdir p f i # s); is_file s f'\<rbrakk>
chunhan
parents:
diff changeset
   627
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   628
apply (frule vd_cons, drule is_file_in_current)
chunhan
parents:
diff changeset
   629
by (simp add:cf2sfile_mkdir1)
chunhan
parents:
diff changeset
   630
chunhan
parents:
diff changeset
   631
lemma cf2sfile_mkdir3:
chunhan
parents:
diff changeset
   632
  "\<lbrakk>valid (Mkdir p f i # s); is_dir s f'\<rbrakk>
chunhan
parents:
diff changeset
   633
   \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   634
apply (frule vd_cons, drule is_dir_in_current)
chunhan
parents:
diff changeset
   635
by (simp add:cf2sfile_mkdir1)
chunhan
parents:
diff changeset
   636
chunhan
parents:
diff changeset
   637
lemma cf2sfile_mkdir4:
chunhan
parents:
diff changeset
   638
  "valid (Mkdir p f i # s)
chunhan
parents:
diff changeset
   639
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f = (case (parent f) of
chunhan
parents:
diff changeset
   640
         Some pf \<Rightarrow> (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   641
                           get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   642
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   643
                    | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   644
       | None \<Rightarrow> None)"
chunhan
parents:
diff changeset
   645
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   646
apply (case_tac f, simp)
chunhan
parents:
diff changeset
   647
apply (clarsimp simp:os_grant.simps)
chunhan
parents:
diff changeset
   648
apply (simp add:sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   649
apply (frule current_proc_has_sec, simp)
chunhan
parents:
diff changeset
   650
apply (frule is_dir_has_sec, simp)
chunhan
parents:
diff changeset
   651
apply (frule get_pfs_secs_prop, simp)
chunhan
parents:
diff changeset
   652
apply (frule is_dir_not_file)
chunhan
parents:
diff changeset
   653
apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   654
               get_parentfs_ctxts_simps split:option.splits if_splits 
chunhan
parents:
diff changeset
   655
            dest:not_died_init_dir is_dir_in_current not_died_init_file is_file_in_current)
chunhan
parents:
diff changeset
   656
done
chunhan
parents:
diff changeset
   657
chunhan
parents:
diff changeset
   658
lemma cf2sfile_mkdir:
chunhan
parents:
diff changeset
   659
  "\<lbrakk>valid (Mkdir p f i # s); f' \<in> current_files (Mkdir p f i # s)\<rbrakk>
chunhan
parents:
diff changeset
   660
  \<Longrightarrow> cf2sfile (Mkdir p f i # s) f' = (
chunhan
parents:
diff changeset
   661
    if (f' = f) 
chunhan
parents:
diff changeset
   662
    then (case (parent f) of
chunhan
parents:
diff changeset
   663
             Some pf \<Rightarrow> (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   664
                 get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   665
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   666
                        | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   667
           | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   668
     else cf2sfile s f')"
chunhan
parents:
diff changeset
   669
apply (case_tac "f = f'")
chunhan
parents:
diff changeset
   670
apply (simp add:cf2sfile_mkdir4 split:option.splits)
chunhan
parents:
diff changeset
   671
apply (simp add:cf2sfile_mkdir1 current_files_simps)
chunhan
parents:
diff changeset
   672
done
chunhan
parents:
diff changeset
   673
chunhan
parents:
diff changeset
   674
lemma cf2sfile_linkhard1:
chunhan
parents:
diff changeset
   675
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files s\<rbrakk>
chunhan
parents:
diff changeset
   676
   \<Longrightarrow> cf2sfile (LinkHard p oldf f# s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   677
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   678
apply (case_tac "f = f'", simp)
chunhan
parents:
diff changeset
   679
apply (induct f', simp add:sroot_only, simp)
chunhan
parents:
diff changeset
   680
apply (frule parentf_in_current', simp+)
chunhan
parents:
diff changeset
   681
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   682
               get_parentfs_ctxts_simps split:if_splits option.splits)
chunhan
parents:
diff changeset
   683
done
chunhan
parents:
diff changeset
   684
chunhan
parents:
diff changeset
   685
lemma cf2sfile_linkhard2:
chunhan
parents:
diff changeset
   686
  "\<lbrakk>valid (LinkHard p oldf f # s); is_file s f'\<rbrakk>
chunhan
parents:
diff changeset
   687
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   688
apply (frule vd_cons, drule is_file_in_current)
chunhan
parents:
diff changeset
   689
by (simp add:cf2sfile_linkhard1)
chunhan
parents:
diff changeset
   690
chunhan
parents:
diff changeset
   691
lemma cf2sfile_linkhard3:
chunhan
parents:
diff changeset
   692
  "\<lbrakk>valid (LinkHard p oldf f # s); is_dir s f'\<rbrakk>
chunhan
parents:
diff changeset
   693
   \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   694
apply (frule vd_cons, drule is_dir_in_current)
chunhan
parents:
diff changeset
   695
by (simp add:cf2sfile_linkhard1)
chunhan
parents:
diff changeset
   696
chunhan
parents:
diff changeset
   697
lemma cf2sfile_linkhard4:
chunhan
parents:
diff changeset
   698
  "valid (LinkHard p oldf f # s)
chunhan
parents:
diff changeset
   699
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f = (case (parent f) of
chunhan
parents:
diff changeset
   700
         Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   701
                           get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   702
                      (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   703
                    | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   704
       | None \<Rightarrow> None)"
chunhan
parents:
diff changeset
   705
apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
chunhan
parents:
diff changeset
   706
apply (case_tac f, simp)
chunhan
parents:
diff changeset
   707
apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
chunhan
parents:
diff changeset
   708
               get_parentfs_ctxts_simps)
chunhan
parents:
diff changeset
   709
apply (rule impI, (erule conjE)+)
chunhan
parents:
diff changeset
   710
apply (drule not_died_init_file, simp+)
chunhan
parents:
diff changeset
   711
apply (simp add:is_file_in_current)
chunhan
parents:
diff changeset
   712
done
chunhan
parents:
diff changeset
   713
chunhan
parents:
diff changeset
   714
lemma cf2sfile_linkhard:
chunhan
parents:
diff changeset
   715
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> current_files (LinkHard p oldf f # s)\<rbrakk>
chunhan
parents:
diff changeset
   716
  \<Longrightarrow> cf2sfile (LinkHard p oldf f # s) f' = (
chunhan
parents:
diff changeset
   717
    if (f' = f) 
chunhan
parents:
diff changeset
   718
    then (case (parent f) of
chunhan
parents:
diff changeset
   719
             Some pf \<Rightarrow> (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), 
chunhan
parents:
diff changeset
   720
                 get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   721
                          (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   722
                        | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
   723
           | None \<Rightarrow> None)
chunhan
parents:
diff changeset
   724
     else cf2sfile s f')"
chunhan
parents:
diff changeset
   725
apply (case_tac "f = f'")
chunhan
parents:
diff changeset
   726
apply (simp add:cf2sfile_linkhard4 split:option.splits)
chunhan
parents:
diff changeset
   727
apply (simp add:cf2sfile_linkhard1 current_files_simps)
chunhan
parents:
diff changeset
   728
done
chunhan
parents:
diff changeset
   729
chunhan
parents:
diff changeset
   730
lemma cf2sfile_other:
chunhan
parents:
diff changeset
   731
  "\<lbrakk>ff \<in> current_files s;
chunhan
parents:
diff changeset
   732
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
chunhan
parents:
diff changeset
   733
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
   734
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents:
diff changeset
   735
    \<forall> p f. e \<noteq> Rmdir p f;
chunhan
parents:
diff changeset
   736
    \<forall> p f i. e \<noteq> Mkdir p f i;
chunhan
parents:
diff changeset
   737
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
chunhan
parents:
diff changeset
   738
    valid (e # s)\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
chunhan
parents:
diff changeset
   739
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   740
apply (induct ff, simp add:sroot_only)
chunhan
parents:
diff changeset
   741
apply (frule parentf_in_current', simp+, case_tac e)
chunhan
parents:
diff changeset
   742
apply (auto simp:current_files_simps is_file_simps is_dir_simps sectxt_of_obj_simps cf2sfile_path 
chunhan
parents:
diff changeset
   743
           split:if_splits option.splits)                     
chunhan
parents:
diff changeset
   744
done     
chunhan
parents:
diff changeset
   745
chunhan
parents:
diff changeset
   746
lemma cf2sfile_other':
chunhan
parents:
diff changeset
   747
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
   748
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
chunhan
parents:
diff changeset
   749
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
   750
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents:
diff changeset
   751
    \<forall> p f. e \<noteq> Rmdir p f;
chunhan
parents:
diff changeset
   752
    \<forall> p f i. e \<noteq> Mkdir p f i;
chunhan
parents:
diff changeset
   753
    \<forall> p f f'. e \<noteq> LinkHard p f f'; 
chunhan
parents:
diff changeset
   754
    ff \<in> current_files s\<rbrakk> \<Longrightarrow> cf2sfile (e # s) ff = cf2sfile s ff"
chunhan
parents:
diff changeset
   755
by (auto intro!:cf2sfile_other)
chunhan
parents:
diff changeset
   756
  
chunhan
parents:
diff changeset
   757
lemma cf2sfile_unlink:
chunhan
parents:
diff changeset
   758
  "\<lbrakk>valid (UnLink p f # s); f' \<in> current_files (UnLink p f # s)\<rbrakk>
chunhan
parents:
diff changeset
   759
   \<Longrightarrow> cf2sfile (UnLink p f # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   760
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   761
apply (simp add:current_files_simps split:if_splits)
chunhan
parents:
diff changeset
   762
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   763
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   764
done
chunhan
parents:
diff changeset
   765
chunhan
parents:
diff changeset
   766
lemma cf2sfile_rmdir:
chunhan
parents:
diff changeset
   767
  "\<lbrakk>valid (Rmdir p f # s); f' \<in> current_files (Rmdir p f # s)\<rbrakk>
chunhan
parents:
diff changeset
   768
   \<Longrightarrow> cf2sfile (Rmdir p f # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
   769
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   770
apply (simp add:current_files_simps split:if_splits)
chunhan
parents:
diff changeset
   771
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps
chunhan
parents:
diff changeset
   772
           split:if_splits option.splits)
chunhan
parents:
diff changeset
   773
done
chunhan
parents:
diff changeset
   774
chunhan
parents:
diff changeset
   775
lemma pfdof_simp5: "\<lbrakk>proc_fd_of_file s f = {(p, fd)}; file_of_proc_fd s p fd = None\<rbrakk> \<Longrightarrow> False"
chunhan
parents:
diff changeset
   776
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
chunhan
parents:
diff changeset
   777
by (simp add:pfdof_simp2, simp)
chunhan
parents:
diff changeset
   778
chunhan
parents:
diff changeset
   779
lemma pfdof_simp6: "proc_fd_of_file s f = {(p, fd)} \<Longrightarrow> file_of_proc_fd s p fd = Some f"
chunhan
parents:
diff changeset
   780
apply (subgoal_tac "(p, fd) \<in> proc_fd_of_file s f")
chunhan
parents:
diff changeset
   781
by (simp add:pfdof_simp2, simp)
chunhan
parents:
diff changeset
   782
chunhan
parents:
diff changeset
   783
lemma cf2sfile_closefd:
chunhan
parents:
diff changeset
   784
  "\<lbrakk>valid (CloseFd p fd # s); f \<in> current_files (CloseFd p fd # s)\<rbrakk>
chunhan
parents:
diff changeset
   785
   \<Longrightarrow> cf2sfile (CloseFd p fd # s) f = cf2sfile s f"
chunhan
parents:
diff changeset
   786
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   787
apply (simp add:current_files_simps split:if_splits option.splits) 
chunhan
parents:
diff changeset
   788
(* costs too much time, but solved *)
chunhan
parents:
diff changeset
   789
(*
chunhan
parents:
diff changeset
   790
apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps 
chunhan
parents:
diff changeset
   791
           split:if_splits option.splits  
chunhan
parents:
diff changeset
   792
            dest:init_file_dir_conflict pfdof_simp5 pfdof_simp6 file_of_pfd_is_file
chunhan
parents:
diff changeset
   793
                 not_died_init_file not_died_init_dir is_file_not_dir is_dir_not_file
chunhan
parents:
diff changeset
   794
            dest!:current_has_sec') 
chunhan
parents:
diff changeset
   795
done
chunhan
parents:
diff changeset
   796
*)
chunhan
parents:
diff changeset
   797
sorry
chunhan
parents:
diff changeset
   798
chunhan
parents:
diff changeset
   799
lemmas cf2sfile_simps = cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_other
chunhan
parents:
diff changeset
   800
  cf2sfile_unlink cf2sfile_rmdir cf2sfile_closefd
chunhan
parents:
diff changeset
   801
  
chunhan
parents:
diff changeset
   802
(*********** cfd2sfd simpset *********)
chunhan
parents:
diff changeset
   803
chunhan
parents:
diff changeset
   804
lemma cfd2sfd_open1:
chunhan
parents:
diff changeset
   805
  "valid (Open p f flags fd opt # s)
chunhan
parents:
diff changeset
   806
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p fd = 
chunhan
parents:
diff changeset
   807
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
   808
        (Some sec, Some sf) \<Rightarrow> Some (sec, remove_create_flag flags, sf)
77
chunhan
parents:
diff changeset
   809
      | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   810
by (simp add:cfd2sfd_def sectxt_of_obj_simps split:if_splits)
chunhan
parents:
diff changeset
   811
chunhan
parents:
diff changeset
   812
lemma cfd2sfd_open_some2:
chunhan
parents:
diff changeset
   813
  "\<lbrakk>valid (Open p f flags fd (Some inum) # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   814
  \<Longrightarrow> cfd2sfd (Open p f flags fd (Some inum) # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   815
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   816
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   817
apply (frule file_of_proc_fd_in_curf, simp)
chunhan
parents:
diff changeset
   818
apply (case_tac "f = f'", simp)
chunhan
parents:
diff changeset
   819
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_some1)
chunhan
parents:
diff changeset
   820
apply (case_tac "p = p'", simp)
chunhan
parents:
diff changeset
   821
apply (rule conjI, rule impI, simp)
chunhan
parents:
diff changeset
   822
apply (drule cf2sfile_open_some1, simp)
chunhan
parents:
diff changeset
   823
apply (auto split:option.splits)[1]
chunhan
parents:
diff changeset
   824
apply simp
chunhan
parents:
diff changeset
   825
apply (drule cf2sfile_open_some1, simp)
chunhan
parents:
diff changeset
   826
apply (auto split:option.splits)[1]
chunhan
parents:
diff changeset
   827
done
chunhan
parents:
diff changeset
   828
chunhan
parents:
diff changeset
   829
lemma cfd2sfd_open_none2:
chunhan
parents:
diff changeset
   830
  "\<lbrakk>valid (Open p f flags fd None # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   831
  \<Longrightarrow> cfd2sfd (Open p f flags fd None # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   832
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   833
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   834
apply (frule file_of_proc_fd_in_curf, simp)
chunhan
parents:
diff changeset
   835
apply (simp add:cfd2sfd_def sectxt_of_obj_simps cf2sfile_open_none)
chunhan
parents:
diff changeset
   836
apply (case_tac "p = p'", simp)
chunhan
parents:
diff changeset
   837
apply (rule conjI, rule impI, simp)
chunhan
parents:
diff changeset
   838
apply (drule cf2sfile_open_none)
chunhan
parents:
diff changeset
   839
apply (auto split:option.splits)[1]
chunhan
parents:
diff changeset
   840
apply simp
chunhan
parents:
diff changeset
   841
apply (drule cf2sfile_open_none)
chunhan
parents:
diff changeset
   842
apply (auto split:option.splits)[1]
chunhan
parents:
diff changeset
   843
done
chunhan
parents:
diff changeset
   844
  
chunhan
parents:
diff changeset
   845
lemma cfd2sfd_open2:
chunhan
parents:
diff changeset
   846
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd s p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   847
  \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   848
apply (case_tac opt)
chunhan
parents:
diff changeset
   849
apply (simp add:cfd2sfd_open_none2)
chunhan
parents:
diff changeset
   850
apply (simp add:cfd2sfd_open_some2)
chunhan
parents:
diff changeset
   851
done
chunhan
parents:
diff changeset
   852
chunhan
parents:
diff changeset
   853
lemma cfd2sfd_open:
chunhan
parents:
diff changeset
   854
  "\<lbrakk>valid (Open p f flags fd opt # s); file_of_proc_fd (Open p f flags fd opt # s) p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   855
   \<Longrightarrow> cfd2sfd (Open p f flags fd opt # s) p' fd' = (if (p' = p \<and> fd' = fd) then 
chunhan
parents:
diff changeset
   856
     (case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
   857
        (Some sec, Some sf) \<Rightarrow> Some (sec, remove_create_flag flags, sf)
77
chunhan
parents:
diff changeset
   858
      | _ \<Rightarrow> None)         else cfd2sfd s p' fd')"
chunhan
parents:
diff changeset
   859
apply (simp split:if_splits)
chunhan
parents:
diff changeset
   860
apply (simp add:cfd2sfd_open1 split:option.splits)
chunhan
parents:
diff changeset
   861
apply (simp add:cfd2sfd_open2)
chunhan
parents:
diff changeset
   862
apply (rule impI, simp)
chunhan
parents:
diff changeset
   863
done
chunhan
parents:
diff changeset
   864
chunhan
parents:
diff changeset
   865
lemma cfd2sfd_closefd:
chunhan
parents:
diff changeset
   866
  "\<lbrakk>valid (CloseFd p fd # s); file_of_proc_fd (CloseFd p fd # s) p' fd' = Some f\<rbrakk>
chunhan
parents:
diff changeset
   867
   \<Longrightarrow> cfd2sfd (CloseFd p fd # s) p' fd' = cfd2sfd  s p' fd'"
chunhan
parents:
diff changeset
   868
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   869
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   870
apply (frule file_of_proc_fd_in_curf, simp)
chunhan
parents:
diff changeset
   871
apply (frule cf2sfile_closefd, simp)
chunhan
parents:
diff changeset
   872
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   873
apply (auto split:option.splits if_splits)
chunhan
parents:
diff changeset
   874
done
chunhan
parents:
diff changeset
   875
chunhan
parents:
diff changeset
   876
lemma cfd2sfd_clone:
chunhan
parents:
diff changeset
   877
  "\<lbrakk>valid (Clone p p' fds # s); file_of_proc_fd (Clone p p' fds # s) p'' fd' = Some f\<rbrakk>
chunhan
parents:
diff changeset
   878
   \<Longrightarrow> cfd2sfd (Clone p p' fds # s) p'' fd' = (
chunhan
parents:
diff changeset
   879
     if (p'' = p') then cfd2sfd s p fd'
chunhan
parents:
diff changeset
   880
     else cfd2sfd s p'' fd')"
chunhan
parents:
diff changeset
   881
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   882
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   883
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
chunhan
parents:
diff changeset
   884
apply (frule_tac cf2sfile_other', simp+)
chunhan
parents:
diff changeset
   885
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   886
apply (case_tac "p'' = p'", simp)
chunhan
parents:
diff changeset
   887
apply (auto split:option.splits if_splits)[1]
chunhan
parents:
diff changeset
   888
apply (simp)
chunhan
parents:
diff changeset
   889
apply (auto split:option.splits if_splits)[1]
chunhan
parents:
diff changeset
   890
done
chunhan
parents:
diff changeset
   891
chunhan
parents:
diff changeset
   892
lemma cfd2sfd_execve:
chunhan
parents:
diff changeset
   893
  "\<lbrakk>valid (Execve p f fds # s); file_of_proc_fd (Execve p f fds # s) p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   894
   \<Longrightarrow> cfd2sfd (Execve p f fds # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   895
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   896
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   897
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
chunhan
parents:
diff changeset
   898
apply (frule_tac cf2sfile_other', simp+)
chunhan
parents:
diff changeset
   899
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   900
apply (case_tac "p' = p", simp)
chunhan
parents:
diff changeset
   901
apply (auto split:option.splits if_splits)[1]
chunhan
parents:
diff changeset
   902
apply (simp)
chunhan
parents:
diff changeset
   903
apply (auto split:option.splits if_splits)[1]
chunhan
parents:
diff changeset
   904
done
chunhan
parents:
diff changeset
   905
chunhan
parents:
diff changeset
   906
lemma cfd2sfd_kill:
chunhan
parents:
diff changeset
   907
  "\<lbrakk>valid (Kill p p'' # s); file_of_proc_fd (Kill p p'' # s) p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   908
   \<Longrightarrow> cfd2sfd (Kill p p'' # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   909
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   910
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   911
apply (frule proc_fd_in_procs, simp)
chunhan
parents:
diff changeset
   912
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
chunhan
parents:
diff changeset
   913
apply (frule_tac cf2sfile_other', simp+)
chunhan
parents:
diff changeset
   914
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   915
apply (auto split:option.splits if_splits)
chunhan
parents:
diff changeset
   916
done
chunhan
parents:
diff changeset
   917
chunhan
parents:
diff changeset
   918
lemma cfd2sfd_exit:
chunhan
parents:
diff changeset
   919
  "\<lbrakk>valid (Exit p # s); file_of_proc_fd (Exit p # s) p' fd' = Some f'\<rbrakk>
chunhan
parents:
diff changeset
   920
   \<Longrightarrow> cfd2sfd (Exit p # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   921
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   922
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   923
apply (frule proc_fd_in_procs, simp)
chunhan
parents:
diff changeset
   924
apply (frule file_of_proc_fd_in_curf, simp, simp add:current_files_simps)
chunhan
parents:
diff changeset
   925
apply (frule_tac cf2sfile_other', simp+)
chunhan
parents:
diff changeset
   926
apply (simp add:cfd2sfd_def sectxt_of_obj_simps)
chunhan
parents:
diff changeset
   927
apply (auto split:option.splits if_splits)
chunhan
parents:
diff changeset
   928
done
chunhan
parents:
diff changeset
   929
chunhan
parents:
diff changeset
   930
lemma cfd2sfd_other:
chunhan
parents:
diff changeset
   931
  "\<lbrakk>valid (e # s); file_of_proc_fd (e # s) p' fd' = Some f';
chunhan
parents:
diff changeset
   932
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
chunhan
parents:
diff changeset
   933
    \<forall> p p'' fds. e \<noteq> Clone p p'' fds\<rbrakk>
chunhan
parents:
diff changeset
   934
   \<Longrightarrow> cfd2sfd (e # s) p' fd' = cfd2sfd s p' fd'"
chunhan
parents:
diff changeset
   935
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   936
apply (frule proc_fd_in_fds, simp)
chunhan
parents:
diff changeset
   937
apply (frule proc_fd_in_procs, simp)
chunhan
parents:
diff changeset
   938
apply (frule file_of_proc_fd_in_curf, simp)
chunhan
parents:
diff changeset
   939
apply (case_tac e)
chunhan
parents:
diff changeset
   940
apply (auto intro!:cfd2sfd_execve cfd2sfd_closefd cfd2sfd_kill cfd2sfd_exit)
chunhan
parents:
diff changeset
   941
apply (auto simp:cfd2sfd_def sectxt_of_obj_simps current_files_simps cf2sfile_simps split:option.splits)
chunhan
parents:
diff changeset
   942
apply (auto dest!:current_has_sec' dest:file_of_proc_fd_in_curf proc_fd_in_fds)
chunhan
parents:
diff changeset
   943
done
chunhan
parents:
diff changeset
   944
chunhan
parents:
diff changeset
   945
lemmas cfd2sfd_simps = cfd2sfd_open cfd2sfd_clone cfd2sfd_other
chunhan
parents:
diff changeset
   946
chunhan
parents:
diff changeset
   947
(********** cpfd2sfds simpset **********)
chunhan
parents:
diff changeset
   948
chunhan
parents:
diff changeset
   949
lemma current_filefd_has_flags:
chunhan
parents:
diff changeset
   950
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists> flags. flags_of_proc_fd s p fd = Some flags"
chunhan
parents:
diff changeset
   951
apply (induct s arbitrary:p)
chunhan
parents:
diff changeset
   952
apply (simp only:flags_of_proc_fd.simps file_of_proc_fd.simps init_filefd_prop4)
chunhan
parents:
diff changeset
   953
apply (frule vd_cons, frule vt_grant_os, case_tac a)
chunhan
parents:
diff changeset
   954
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
chunhan
parents:
diff changeset
   955
done
chunhan
parents:
diff changeset
   956
chunhan
parents:
diff changeset
   957
lemma current_filefd_has_flags':
chunhan
parents:
diff changeset
   958
  "\<lbrakk>flags_of_proc_fd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
chunhan
parents:
diff changeset
   959
apply (case_tac "file_of_proc_fd s p fd")
chunhan
parents:
diff changeset
   960
apply (simp, drule current_filefd_has_flags, simp+)
chunhan
parents:
diff changeset
   961
done
chunhan
parents:
diff changeset
   962
chunhan
parents:
diff changeset
   963
lemma current_file_has_sfile':
chunhan
parents:
diff changeset
   964
  "\<lbrakk>cf2sfile s f = None; valid s\<rbrakk> \<Longrightarrow> f \<notin> current_files s"
chunhan
parents:
diff changeset
   965
by (rule notI, drule current_file_has_sfile, simp+)
chunhan
parents:
diff changeset
   966
chunhan
parents:
diff changeset
   967
lemma current_filefd_has_sfd:
chunhan
parents:
diff changeset
   968
  "\<lbrakk>file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> \<exists>sfd. cfd2sfd s p fd = Some sfd"
chunhan
parents:
diff changeset
   969
by (auto simp:cfd2sfd_def split:option.splits dest!:current_has_sec' current_file_has_sfile' 
chunhan
parents:
diff changeset
   970
         dest:file_of_proc_fd_in_curf proc_fd_in_fds current_filefd_has_flags)
chunhan
parents:
diff changeset
   971
chunhan
parents:
diff changeset
   972
lemma current_filefd_has_sfd':
chunhan
parents:
diff changeset
   973
  "\<lbrakk>cfd2sfd s p fd = None; valid s\<rbrakk> \<Longrightarrow> file_of_proc_fd s p fd = None"
chunhan
parents:
diff changeset
   974
by (case_tac "file_of_proc_fd s p fd", auto dest:current_filefd_has_sfd)
chunhan
parents:
diff changeset
   975
chunhan
parents:
diff changeset
   976
lemma cpfd2sfds_open1:
chunhan
parents:
diff changeset
   977
  "valid (Open p f flags fd opt # s) \<Longrightarrow>
chunhan
parents:
diff changeset
   978
   cpfd2sfds (Open p f flags fd opt # s) p = (
chunhan
parents:
diff changeset
   979
    case (cfd2sfd (Open p f flags fd opt # s) p fd) of
chunhan
parents:
diff changeset
   980
        Some sfd \<Rightarrow> (cpfd2sfds s p) \<union> {sfd}
chunhan
parents:
diff changeset
   981
      | _ \<Rightarrow> cpfd2sfds s p)"
chunhan
parents:
diff changeset
   982
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
   983
apply (split option.splits)
chunhan
parents:
diff changeset
   984
apply (rule conjI, rule impI, drule current_filefd_has_sfd', simp, simp)
chunhan
parents:
diff changeset
   985
apply (rule allI, rule impI)
chunhan
parents:
diff changeset
   986
apply (rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
   987
apply (case_tac "x = a", simp)
chunhan
parents:
diff changeset
   988
unfolding cpfd2sfds_def
chunhan
parents:
diff changeset
   989
apply (erule CollectE, (erule conjE|erule bexE)+)
chunhan
parents:
diff changeset
   990
apply (simp add:proc_file_fds_def split:if_splits)
chunhan
parents:
diff changeset
   991
apply (erule exE, rule_tac x = fda in exI)
chunhan
parents:
diff changeset
   992
apply (simp add:cfd2sfd_open2)
chunhan
parents:
diff changeset
   993
apply (case_tac "x = a", simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
   994
apply (rule_tac x = fd in exI, simp+)
chunhan
parents:
diff changeset
   995
apply (erule conjE|erule bexE)+
chunhan
parents:
diff changeset
   996
apply (rule_tac x = fda in bexI)
chunhan
parents:
diff changeset
   997
apply (simp add:proc_file_fds_def, erule exE)
chunhan
parents:
diff changeset
   998
apply (simp add:cfd2sfd_open2)
chunhan
parents:
diff changeset
   999
apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
  1000
done
chunhan
parents:
diff changeset
  1001
chunhan
parents:
diff changeset
  1002
lemma cpfd2sfds_open1':
chunhan
parents:
diff changeset
  1003
  "valid (Open p f flags fd opt # s) \<Longrightarrow>
chunhan
parents:
diff changeset
  1004
   cpfd2sfds (Open p f flags fd opt # s) p = (
chunhan
parents:
diff changeset
  1005
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
  1006
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, remove_create_flag flags, sf)}
77
chunhan
parents:
diff changeset
  1007
      | _ \<Rightarrow> cpfd2sfds s p)"
chunhan
parents:
diff changeset
  1008
apply (frule cfd2sfd_open1)
chunhan
parents:
diff changeset
  1009
apply (auto dest:cpfd2sfds_open1 split:option.splits)
chunhan
parents:
diff changeset
  1010
done
chunhan
parents:
diff changeset
  1011
chunhan
parents:
diff changeset
  1012
lemma cpfd2sfds_open2:
chunhan
parents:
diff changeset
  1013
  "\<lbrakk>valid (Open p f flags fd opt # s); p' \<noteq> p\<rbrakk> \<Longrightarrow> cpfd2sfds (Open p f flags fd opt # s) p' = cpfd2sfds s p'"
chunhan
parents:
diff changeset
  1014
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  1015
unfolding cpfd2sfds_def
chunhan
parents:
diff changeset
  1016
apply (rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1017
apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
  1018
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1019
apply (simp only:file_of_proc_fd.simps cfd2sfd_open2 split:if_splits)
chunhan
parents:
diff changeset
  1020
apply (rule_tac x = fda in exI, simp)
chunhan
parents:
diff changeset
  1021
apply (simp add:proc_file_fds_def)
chunhan
parents:
diff changeset
  1022
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1023
apply (rule_tac x = fda in exI, simp add:cfd2sfd_open2)
chunhan
parents:
diff changeset
  1024
done
chunhan
parents:
diff changeset
  1025
chunhan
parents:
diff changeset
  1026
lemma cpfd2sfds_open:
chunhan
parents:
diff changeset
  1027
  "valid (Open p f flags fd opt # s)
chunhan
parents:
diff changeset
  1028
   \<Longrightarrow> cpfd2sfds (Open p f flags fd opt # s) = (cpfd2sfds s) (p := (
chunhan
parents:
diff changeset
  1029
    case (sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), cf2sfile (Open p f flags fd opt # s) f) of
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
  1030
        (Some sec, Some sf) \<Rightarrow> (cpfd2sfds s p) \<union> {(sec, remove_create_flag flags, sf)}
77
chunhan
parents:
diff changeset
  1031
      | _ \<Rightarrow> cpfd2sfds s p))"
chunhan
parents:
diff changeset
  1032
apply (rule ext)
chunhan
parents:
diff changeset
  1033
apply (case_tac "x \<noteq> p")
chunhan
parents:
diff changeset
  1034
apply (simp add:cpfd2sfds_open2)
chunhan
parents:
diff changeset
  1035
apply (simp add:cpfd2sfds_open1')
chunhan
parents:
diff changeset
  1036
done
chunhan
parents:
diff changeset
  1037
chunhan
parents:
diff changeset
  1038
lemma cpfd2sfds_execve:
chunhan
parents:
diff changeset
  1039
  "valid (Execve p f fds # s) 
chunhan
parents:
diff changeset
  1040
   \<Longrightarrow> cpfd2sfds (Execve p f fds # s) = (cpfd2sfds s) (p := {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})"
chunhan
parents:
diff changeset
  1041
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1042
apply (rule ext)
chunhan
parents:
diff changeset
  1043
apply (rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1044
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1045
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1046
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1047
apply (frule_tac p' = p and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1048
apply (rule_tac x = fd in bexI, simp+)
chunhan
parents:
diff changeset
  1049
apply (simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1050
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1051
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1052
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1053
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1054
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1055
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1056
apply (simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1057
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1058
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1059
apply (frule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1060
done
chunhan
parents:
diff changeset
  1061
chunhan
parents:
diff changeset
  1062
lemma cpfd2sfds_clone:
chunhan
parents:
diff changeset
  1063
  "valid (Clone p p' fds # s) 
chunhan
parents:
diff changeset
  1064
   \<Longrightarrow> cpfd2sfds (Clone p p' fds # s) = (cpfd2sfds s) (p' := {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})"
chunhan
parents:
diff changeset
  1065
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1066
apply (rule ext)
chunhan
parents:
diff changeset
  1067
apply (rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1068
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1069
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1070
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1071
apply (frule_tac p'' = p' and fd' = fd in cfd2sfd_clone, simp+)
chunhan
parents:
diff changeset
  1072
apply (rule_tac x = fd in bexI, simp+)
chunhan
parents:
diff changeset
  1073
apply (simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1074
apply (frule_tac p'' = x and fd' = fd in cfd2sfd_clone, simp+)
chunhan
parents:
diff changeset
  1075
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1076
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1077
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1078
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1079
apply (frule_tac p'' = p' and fd' = fd in cfd2sfd_clone, simp+)
chunhan
parents:
diff changeset
  1080
apply (simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1081
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1082
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1083
apply (frule_tac p'' = x and fd' = fd in cfd2sfd_clone, simp+)
chunhan
parents:
diff changeset
  1084
done
chunhan
parents:
diff changeset
  1085
chunhan
parents:
diff changeset
  1086
lemma cpfd2sfds_other:
chunhan
parents:
diff changeset
  1087
  "\<lbrakk>valid (e # s);
chunhan
parents:
diff changeset
  1088
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
chunhan
parents:
diff changeset
  1089
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
  1090
    \<forall> p p'. e \<noteq> Kill p p';
chunhan
parents:
diff changeset
  1091
    \<forall> p. e \<noteq> Exit p;
chunhan
parents:
diff changeset
  1092
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
  1093
    \<forall> p p' fds. e \<noteq> Clone p p' fds\<rbrakk> \<Longrightarrow> cpfd2sfds (e # s) = cpfd2sfds s"
chunhan
parents:
diff changeset
  1094
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1095
apply (rule ext)
chunhan
parents:
diff changeset
  1096
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1097
apply (case_tac e)
chunhan
parents:
diff changeset
  1098
using cfd2sfd_other
chunhan
parents:
diff changeset
  1099
by auto
chunhan
parents:
diff changeset
  1100
chunhan
parents:
diff changeset
  1101
lemma cpfd2sfds_kill:
chunhan
parents:
diff changeset
  1102
  "valid (Kill p p' # s) \<Longrightarrow> cpfd2sfds (Kill p p' # s) = (cpfd2sfds s) (p' := {})"
chunhan
parents:
diff changeset
  1103
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1104
apply (rule ext, rule set_eqI)
chunhan
parents:
diff changeset
  1105
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1106
apply (rule iffI)
chunhan
parents:
diff changeset
  1107
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1108
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1109
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1110
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1111
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1112
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1113
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1114
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1115
done
chunhan
parents:
diff changeset
  1116
chunhan
parents:
diff changeset
  1117
lemma cpfd2sfds_exit:
chunhan
parents:
diff changeset
  1118
  "valid (Exit p # s) \<Longrightarrow> cpfd2sfds (Exit p # s) = (cpfd2sfds s) (p := {})"
chunhan
parents:
diff changeset
  1119
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1120
apply (rule ext, rule set_eqI)
chunhan
parents:
diff changeset
  1121
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1122
apply (rule iffI)
chunhan
parents:
diff changeset
  1123
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1124
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1125
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1126
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1127
apply (simp split:if_splits add: cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1128
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1129
apply (rule_tac x = fd in exI, simp)
chunhan
parents:
diff changeset
  1130
apply (drule_tac p' = x and fd' = fd in cfd2sfd_other, simp+)
chunhan
parents:
diff changeset
  1131
done
chunhan
parents:
diff changeset
  1132
chunhan
parents:
diff changeset
  1133
lemma cpfd2sfds_closefd:
chunhan
parents:
diff changeset
  1134
  "valid (CloseFd p fd # s) \<Longrightarrow> cpfd2sfds (CloseFd p fd # s) = (cpfd2sfds s) (p := 
chunhan
parents:
diff changeset
  1135
     if (fd \<in> proc_file_fds s p)
chunhan
parents:
diff changeset
  1136
     then (case (cfd2sfd s p fd) of 
chunhan
parents:
diff changeset
  1137
             Some sfd \<Rightarrow> (if (\<exists> fd' f'. fd' \<noteq> fd \<and> file_of_proc_fd s p fd' = Some f' \<and> cfd2sfd s p fd' = Some sfd)
chunhan
parents:
diff changeset
  1138
                          then cpfd2sfds s p else cpfd2sfds s p - {sfd})
chunhan
parents:
diff changeset
  1139
           | _        \<Rightarrow> cpfd2sfds s p)
chunhan
parents:
diff changeset
  1140
     else cpfd2sfds s p)"
chunhan
parents:
diff changeset
  1141
apply (frule vd_cons)
chunhan
parents:
diff changeset
  1142
apply (rule ext, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1143
unfolding cpfd2sfds_def proc_file_fds_def
chunhan
parents:
diff changeset
  1144
apply (erule CollectE| erule bexE| erule conjE| erule exE| rule conjI)+
chunhan
parents:
diff changeset
  1145
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1146
apply (rule conjI, rule impI, rule conjI, rule impI, erule exE)
chunhan
parents:
diff changeset
  1147
apply (frule_tac p = p and fd = fd in current_filefd_has_sfd, simp)
chunhan
parents:
diff changeset
  1148
apply (erule exE, simp)
chunhan
parents:
diff changeset
  1149
apply (rule conjI, rule impI, (erule exE|erule conjE)+)
chunhan
parents:
diff changeset
  1150
apply (rule_tac x = fda in exI, simp, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1151
chunhan
parents:
diff changeset
  1152
apply (rule impI, rule conjI)
chunhan
parents:
diff changeset
  1153
apply (rule_tac x = fda in exI, simp, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1154
apply (rule notI, simp)
chunhan
parents:
diff changeset
  1155
apply (erule_tac x = fda in allE, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1156
chunhan
parents:
diff changeset
  1157
apply (rule impI, simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1158
apply (erule exE, rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1159
chunhan
parents:
diff changeset
  1160
apply (rule impI| rule conjI)+
chunhan
parents:
diff changeset
  1161
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1162
chunhan
parents:
diff changeset
  1163
apply (rule impI, simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1164
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1165
chunhan
parents:
diff changeset
  1166
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1167
apply (frule_tac p = p and fd = fd in current_filefd_has_sfd, simp)
chunhan
parents:
diff changeset
  1168
apply (erule exE, simp)
chunhan
parents:
diff changeset
  1169
apply (case_tac "\<exists>fd'. fd' \<noteq> fd \<and> (\<exists>f'. file_of_proc_fd s p fd' = Some f') \<and> cfd2sfd s p fd' = Some sfd")
chunhan
parents:
diff changeset
  1170
apply simp
chunhan
parents:
diff changeset
  1171
apply (case_tac "xa = sfd")
chunhan
parents:
diff changeset
  1172
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1173
apply (rule_tac x = fd' in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1174
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1175
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1176
apply (rule notI, simp)
chunhan
parents:
diff changeset
  1177
apply (simp, (erule exE|erule conjE)+)
chunhan
parents:
diff changeset
  1178
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1179
apply (rule notI, simp)
chunhan
parents:
diff changeset
  1180
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1181
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1182
apply (rule notI, simp)
chunhan
parents:
diff changeset
  1183
apply (simp add:cpfd2sfds_def proc_file_fds_def)
chunhan
parents:
diff changeset
  1184
apply (erule exE|erule conjE)+
chunhan
parents:
diff changeset
  1185
apply (rule_tac x = fda in exI, simp add:cfd2sfd_closefd)
chunhan
parents:
diff changeset
  1186
done
chunhan
parents:
diff changeset
  1187
chunhan
parents:
diff changeset
  1188
lemmas cpfd2sfds_simps = cpfd2sfds_open cpfd2sfds_execve cpfd2sfds_clone cpfd2sfds_kill cpfd2sfds_exit
chunhan
parents:
diff changeset
  1189
  cpfd2sfds_closefd cpfd2sfds_other
chunhan
parents:
diff changeset
  1190
chunhan
parents:
diff changeset
  1191
(********* ch2sshm simpset ********)
chunhan
parents:
diff changeset
  1192
(*
chunhan
parents:
diff changeset
  1193
lemma ch2sshm_createshm:
chunhan
parents:
diff changeset
  1194
  "valid (CreateShM p h # s) 
chunhan
parents:
diff changeset
  1195
   \<Longrightarrow> ch2sshm (CreateShM p h # s) = (ch2sshm s) (h := 
chunhan
parents:
diff changeset
  1196
     (case (sectxt_of_obj (CreateShM p h # s) (O_shm h)) of
chunhan
parents:
diff changeset
  1197
                    Some sec \<Rightarrow> 
chunhan
parents:
diff changeset
  1198
 Some (if (\<not> died (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec)
chunhan
parents:
diff changeset
  1199
                  | _ \<Rightarrow> None))"
chunhan
parents:
diff changeset
  1200
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1201
apply (auto simp:ch2sshm_def sectxt_of_obj_simps dest!:current_has_sec' split:option.splits if_splits)
chunhan
parents:
diff changeset
  1202
done
chunhan
parents:
diff changeset
  1203
chunhan
parents:
diff changeset
  1204
lemma ch2sshm_other:
chunhan
parents:
diff changeset
  1205
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
  1206
    \<forall> p h. e \<noteq> CreateShM p h; 
chunhan
parents:
diff changeset
  1207
    h' \<in> current_shms (e # s)\<rbrakk> \<Longrightarrow> ch2sshm (e # s) h' = ch2sshm s h'"
chunhan
parents:
diff changeset
  1208
apply (frule vd_cons, frule vt_grant_os)
chunhan
parents:
diff changeset
  1209
apply (case_tac e)
chunhan
parents:
diff changeset
  1210
apply (auto simp:ch2sshm_def sectxt_of_obj_simps dest!:current_has_sec' split:option.splits if_splits)
chunhan
parents:
diff changeset
  1211
done
chunhan
parents:
diff changeset
  1212
chunhan
parents:
diff changeset
  1213
lemmas ch2sshm_simps = ch2sshm_createshm ch2sshm_other
chunhan
parents:
diff changeset
  1214
chunhan
parents:
diff changeset
  1215
lemma current_shm_has_sh:
chunhan
parents:
diff changeset
  1216
  "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> sh. ch2sshm s h = Some sh"
chunhan
parents:
diff changeset
  1217
by (auto simp:ch2sshm_def split:option.splits dest!:current_has_sec')
chunhan
parents:
diff changeset
  1218
chunhan
parents:
diff changeset
  1219
lemma current_shm_has_sh':
chunhan
parents:
diff changeset
  1220
  "\<lbrakk>ch2sshm s h = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s"
chunhan
parents:
diff changeset
  1221
by (auto dest:current_shm_has_sh)
chunhan
parents:
diff changeset
  1222
chunhan
parents:
diff changeset
  1223
(********** cph2spshs simpset **********)
chunhan
parents:
diff changeset
  1224
chunhan
parents:
diff changeset
  1225
lemma cph2spshs_attach:
chunhan
parents:
diff changeset
  1226
  "valid (Attach p h flag # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1227
   cph2spshs (Attach p h flag # s) = (cph2spshs s) (p := 
chunhan
parents:
diff changeset
  1228
     (case (ch2sshm s h) of 
chunhan
parents:
diff changeset
  1229
        Some sh \<Rightarrow> cph2spshs s p \<union> {(sh, flag)}
chunhan
parents:
diff changeset
  1230
      | _       \<Rightarrow> cph2spshs s p) )"
chunhan
parents:
diff changeset
  1231
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1232
using ch2sshm_other[where e = "Attach p h flag" and s = s]
chunhan
parents:
diff changeset
  1233
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1234
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1235
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1236
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1237
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1238
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1239
apply (erule_tac x = ha in allE, frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1240
apply (case_tac "ha = h", simp, frule procs_of_shm_prop1, simp)
chunhan
parents:
diff changeset
  1241
apply (rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1242
apply (rule_tac x = ha in exI, simp, drule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1243
apply (rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1244
apply (frule procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1245
apply (rule impI, simp)
chunhan
parents:
diff changeset
  1246
done
chunhan
parents:
diff changeset
  1247
chunhan
parents:
diff changeset
  1248
lemma cph2spshs_detach: "valid (Detach p h # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1249
  cph2spshs (Detach p h # s) = (cph2spshs s) (p := 
chunhan
parents:
diff changeset
  1250
    (case (ch2sshm s h, flag_of_proc_shm s p h) of 
chunhan
parents:
diff changeset
  1251
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p,flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
chunhan
parents:
diff changeset
  1252
                  then cph2spshs s p else cph2spshs s p - {(sh, flag)}
chunhan
parents:
diff changeset
  1253
     | _       \<Rightarrow> cph2spshs s p)             )"
chunhan
parents:
diff changeset
  1254
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1255
apply (case_tac "x = p")  defer
chunhan
parents:
diff changeset
  1256
using ch2sshm_other[where e = "Detach p h" and s = s] 
chunhan
parents:
diff changeset
  1257
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1258
dest!:current_shm_has_sh' procs_of_shm_prop4' dest:procs_of_shm_prop1 procs_of_shm_prop3 simp:cph2spshs_def) [1]
chunhan
parents:
diff changeset
  1259
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1260
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1261
apply (rule impI, simp)
chunhan
parents:
diff changeset
  1262
chunhan
parents:
diff changeset
  1263
apply (clarsimp)
chunhan
parents:
diff changeset
  1264
apply (frule current_shm_has_sh, simp, erule exE)
chunhan
parents:
diff changeset
  1265
apply (frule procs_of_shm_prop4, simp, simp)
chunhan
parents:
diff changeset
  1266
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
chunhan
parents:
diff changeset
  1267
chunhan
parents:
diff changeset
  1268
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1269
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
chunhan
parents:
diff changeset
  1270
apply (case_tac "ha = h", simp)
chunhan
parents:
diff changeset
  1271
apply (rule_tac x = sha in exI, rule_tac x = flaga in exI, rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1272
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1273
chunhan
parents:
diff changeset
  1274
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
chunhan
parents:
diff changeset
  1275
apply (case_tac "ha = h", simp)
chunhan
parents:
diff changeset
  1276
apply (rule_tac x = h' in exI, simp)
chunhan
parents:
diff changeset
  1277
apply (frule_tac flag = flag and flag' = flaga in procs_of_shm_prop3, simp+)
chunhan
parents:
diff changeset
  1278
apply (frule_tac flag = flaga in procs_of_shm_prop4, simp+)
chunhan
parents:
diff changeset
  1279
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1280
apply (frule_tac h = h' in procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1281
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1282
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1283
chunhan
parents:
diff changeset
  1284
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
chunhan
parents:
diff changeset
  1285
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1286
apply (erule CollectE | erule exE| erule conjE| rule DiffI |rule CollectI)+
chunhan
parents:
diff changeset
  1287
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1288
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1289
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1290
apply (rule notI, simp split:if_splits)
chunhan
parents:
diff changeset
  1291
apply (erule_tac x = ha in allE, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1292
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1293
apply (erule CollectE | erule exE| erule conjE| erule DiffE |rule CollectI)+
chunhan
parents:
diff changeset
  1294
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1295
apply (erule_tac x = ha in allE, simp, rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1296
apply (case_tac "ha = h", simp add:procs_of_shm_prop3, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1297
using ch2sshm_other[where e = "Detach p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1298
done
chunhan
parents:
diff changeset
  1299
chunhan
parents:
diff changeset
  1300
lemma cph2spshs_deleteshm:
chunhan
parents:
diff changeset
  1301
  "valid (DeleteShM p h # s) \<Longrightarrow>     
chunhan
parents:
diff changeset
  1302
   cph2spshs (DeleteShM p h # s) = (\<lambda> p'. 
chunhan
parents:
diff changeset
  1303
    (case (ch2sshm s h, flag_of_proc_shm s p' h) of 
chunhan
parents:
diff changeset
  1304
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p', flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
chunhan
parents:
diff changeset
  1305
                  then cph2spshs s p' else cph2spshs s p' - {(sh, flag)}
chunhan
parents:
diff changeset
  1306
     | _       \<Rightarrow> cph2spshs s p')   )"
chunhan
parents:
diff changeset
  1307
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1308
chunhan
parents:
diff changeset
  1309
apply (clarsimp)
chunhan
parents:
diff changeset
  1310
apply (frule current_shm_has_sh, simp, erule exE, simp, simp split:option.splits)
chunhan
parents:
diff changeset
  1311
apply (rule conjI, rule impI)
chunhan
parents:
diff changeset
  1312
using ch2sshm_other[where e = "DeleteShM p h" and s = s] 
chunhan
parents:
diff changeset
  1313
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1314
dest!:current_shm_has_sh' procs_of_shm_prop4' dest:procs_of_shm_prop1 procs_of_shm_prop3 simp:cph2spshs_def) [1]
chunhan
parents:
diff changeset
  1315
apply (rule_tac x = ha in exI, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1316
apply (rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1317
apply (case_tac "ha = h", simp+, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1318
chunhan
parents:
diff changeset
  1319
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
chunhan
parents:
diff changeset
  1320
chunhan
parents:
diff changeset
  1321
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1322
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
chunhan
parents:
diff changeset
  1323
apply (case_tac "ha = h", simp)
chunhan
parents:
diff changeset
  1324
apply (rule_tac x = sha in exI, rule_tac x = flag in exI, rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1325
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1326
chunhan
parents:
diff changeset
  1327
apply (erule CollectE | erule exE| erule conjE| rule CollectI)+
chunhan
parents:
diff changeset
  1328
apply (case_tac "ha = h", simp)
chunhan
parents:
diff changeset
  1329
apply (rule_tac x = h' in exI, simp)
chunhan
parents:
diff changeset
  1330
apply (frule_tac flag = flag in procs_of_shm_prop4, simp+)
chunhan
parents:
diff changeset
  1331
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1332
apply (frule_tac h = h' in procs_of_shm_prop1, simp, simp)
chunhan
parents:
diff changeset
  1333
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1334
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1335
chunhan
parents:
diff changeset
  1336
apply (rule allI | rule conjI| erule conjE | erule exE | rule impI)+
chunhan
parents:
diff changeset
  1337
apply (simp only:cph2spshs_def, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1338
apply (erule CollectE | erule exE| erule conjE| rule DiffI |rule CollectI)+
chunhan
parents:
diff changeset
  1339
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1340
apply (rule_tac x = ha in exI, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1341
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1342
apply (rule notI, simp split:if_splits)
chunhan
parents:
diff changeset
  1343
apply (erule_tac x = ha in allE, simp, frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1344
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1345
apply (erule CollectE | erule exE| erule conjE| erule DiffE |rule CollectI)+
chunhan
parents:
diff changeset
  1346
apply (simp split:if_splits)
chunhan
parents:
diff changeset
  1347
apply (erule_tac x = ha in allE, simp, rule_tac x = ha in exI, simp)
chunhan
parents:
diff changeset
  1348
apply (case_tac "ha = h", simp add:procs_of_shm_prop4)
chunhan
parents:
diff changeset
  1349
apply (frule_tac h = ha in procs_of_shm_prop1, simp+)
chunhan
parents:
diff changeset
  1350
using ch2sshm_other[where e = "DeleteShM p h" and s = s] apply (simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1351
done
chunhan
parents:
diff changeset
  1352
chunhan
parents:
diff changeset
  1353
lemma flag_of_proc_shm_prop1:
chunhan
parents:
diff changeset
  1354
  "\<lbrakk>flag_of_proc_shm s p h = Some flag; valid s\<rbrakk> \<Longrightarrow> (p, flag) \<in> procs_of_shm s h"
chunhan
parents:
diff changeset
  1355
apply (induct s arbitrary:p)
chunhan
parents:
diff changeset
  1356
apply (simp add:init_shmflag_has_proc)
chunhan
parents:
diff changeset
  1357
apply (frule vt_grant_os, frule vd_cons, case_tac a, auto split:if_splits option.splits)
chunhan
parents:
diff changeset
  1358
done
chunhan
parents:
diff changeset
  1359
chunhan
parents:
diff changeset
  1360
lemma cph2spshs_clone:
chunhan
parents:
diff changeset
  1361
  "valid (Clone p p' fds shms # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1362
   cph2spshs (Clone p p' fds shms # s) = (cph2spshs s) (p' := 
chunhan
parents:
diff changeset
  1363
     {(sh, flag) | h sh flag. h \<in> shms \<and> ch2sshm s h = Some sh \<and> flag_of_proc_shm s p h = Some flag} )"
chunhan
parents:
diff changeset
  1364
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1365
using ch2sshm_other[where e = "Clone p p' fds shms" and s = s]
chunhan
parents:
diff changeset
  1366
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1367
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1368
apply (erule_tac x = h in allE, frule procs_of_shm_prop1, simp, simp add:procs_of_shm_prop4)
chunhan
parents:
diff changeset
  1369
apply (rule_tac x = h in exI, simp, frule flag_of_proc_shm_prop1, simp+, simp add:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1370
apply (rule_tac x = h in exI, simp, frule procs_of_shm_prop1, simp+)+
chunhan
parents:
diff changeset
  1371
done
chunhan
parents:
diff changeset
  1372
chunhan
parents:
diff changeset
  1373
lemma cph2spshs_execve:
chunhan
parents:
diff changeset
  1374
  "valid (Execve p f fds # s) \<Longrightarrow>
chunhan
parents:
diff changeset
  1375
  cph2spshs (Execve p f fds # s) = (cph2spshs s) (p := {})"
chunhan
parents:
diff changeset
  1376
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1377
using ch2sshm_other[where e = "Execve p f fds" and s = s]
chunhan
parents:
diff changeset
  1378
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1379
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1380
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
chunhan
parents:
diff changeset
  1381
done
chunhan
parents:
diff changeset
  1382
chunhan
parents:
diff changeset
  1383
lemma cph2spshs_kill:
chunhan
parents:
diff changeset
  1384
  "valid (Kill p p' # s) \<Longrightarrow> cph2spshs (Kill p p' # s) = (cph2spshs s) (p' := {})"
chunhan
parents:
diff changeset
  1385
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1386
using ch2sshm_other[where e = "Kill p p'" and s = s]
chunhan
parents:
diff changeset
  1387
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1388
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1389
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
chunhan
parents:
diff changeset
  1390
done
chunhan
parents:
diff changeset
  1391
chunhan
parents:
diff changeset
  1392
lemma cph2spshs_exit:
chunhan
parents:
diff changeset
  1393
  "valid (Exit p # s) \<Longrightarrow> cph2spshs (Exit p # s) = (cph2spshs s) (p := {})"
chunhan
parents:
diff changeset
  1394
apply (frule vd_cons, frule vt_grant_os, rule ext)
chunhan
parents:
diff changeset
  1395
using ch2sshm_other[where e = "Exit p" and s = s]
chunhan
parents:
diff changeset
  1396
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1397
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1398
apply (rule_tac x = h in exI, simp add:procs_of_shm_prop1)+
chunhan
parents:
diff changeset
  1399
done
chunhan
parents:
diff changeset
  1400
chunhan
parents:
diff changeset
  1401
lemma cph2spshs_createshm:
chunhan
parents:
diff changeset
  1402
  "valid (CreateShM p h # s) \<Longrightarrow> cph2spshs (CreateShM p h # s) = cph2spshs s"
chunhan
parents:
diff changeset
  1403
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1404
apply (auto simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1405
using ch2sshm_createshm
chunhan
parents:
diff changeset
  1406
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1407
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 simp:cph2spshs_def)
chunhan
parents:
diff changeset
  1408
apply (rule_tac x = ha in exI, auto simp:procs_of_shm_prop1)
chunhan
parents:
diff changeset
  1409
done
chunhan
parents:
diff changeset
  1410
chunhan
parents:
diff changeset
  1411
lemma cph2spshs_other:
chunhan
parents:
diff changeset
  1412
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
  1413
    \<forall> p h flag. e \<noteq> Attach p h flag;
chunhan
parents:
diff changeset
  1414
    \<forall> p h. e \<noteq> Detach p h;
chunhan
parents:
diff changeset
  1415
    \<forall> p h. e \<noteq> DeleteShM p h;
chunhan
parents:
diff changeset
  1416
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
chunhan
parents:
diff changeset
  1417
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
  1418
    \<forall> p p'. e \<noteq> Kill p p';
chunhan
parents:
diff changeset
  1419
    \<forall> p. e \<noteq> Exit p\<rbrakk> \<Longrightarrow> cph2spshs (e # s) = cph2spshs s"
chunhan
parents:
diff changeset
  1420
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1421
unfolding cph2spshs_def 
chunhan
parents:
diff changeset
  1422
apply (rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1423
apply (erule CollectE | erule conjE| erule exE| rule conjI| rule impI| rule CollectI)+
chunhan
parents:
diff changeset
  1424
apply (frule procs_of_shm_prop1, simp, rule_tac x= sh in exI, rule_tac x = flag in exI, rule_tac x = h in exI)
chunhan
parents:
diff changeset
  1425
apply (case_tac e)
chunhan
parents:
diff changeset
  1426
using ch2sshm_other[where e = e and s = s] 
chunhan
parents:
diff changeset
  1427
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1428
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3
chunhan
parents:
diff changeset
  1429
 simp:ch2sshm_createshm)
chunhan
parents:
diff changeset
  1430
apply (rule_tac x = h in exI, case_tac e)
chunhan
parents:
diff changeset
  1431
using ch2sshm_other[where e = e and s = s] 
chunhan
parents:
diff changeset
  1432
apply (auto split del:t_open_must_flag.splits t_open_option_flag.splits split add:if_splits option.splits
chunhan
parents:
diff changeset
  1433
dest!:current_shm_has_sh' dest: procs_of_shm_prop1 procs_of_shm_prop2 procs_of_shm_prop3 
chunhan
parents:
diff changeset
  1434
 simp:ch2sshm_createshm)
chunhan
parents:
diff changeset
  1435
done
chunhan
parents:
diff changeset
  1436
chunhan
parents:
diff changeset
  1437
lemmas cph2spshs_simps = cph2spshs_attach cph2spshs_detach cph2spshs_deleteshm cph2spshs_clone cph2spshs_execve
chunhan
parents:
diff changeset
  1438
  cph2spshs_exit cph2spshs_kill cph2spshs_other
chunhan
parents:
diff changeset
  1439
*)
chunhan
parents:
diff changeset
  1440
(******** cp2sproc simpset *********)
chunhan
parents:
diff changeset
  1441
chunhan
parents:
diff changeset
  1442
lemma cp2sproc_clone:
chunhan
parents:
diff changeset
  1443
  "valid (Clone p p' fds # s) \<Longrightarrow> cp2sproc (Clone p p' fds # s) = (cp2sproc s) (p' := 
chunhan
parents:
diff changeset
  1444
     case (sectxt_of_obj s (O_proc p)) of 
chunhan
parents:
diff changeset
  1445
       Some sec \<Rightarrow> Some (Created, sec, 
chunhan
parents:
diff changeset
  1446
  {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})
chunhan
parents:
diff changeset
  1447
     | _        \<Rightarrow> None)" (* ,
chunhan
parents:
diff changeset
  1448
  {(sh, flag) | h sh flag. h \<in> shms \<and> ch2sshm s h = Some sh \<and> flag_of_proc_shm s p h = Some flag} *)
chunhan
parents:
diff changeset
  1449
apply (frule cpfd2sfds_clone) (*
chunhan
parents:
diff changeset
  1450
apply (frule cph2spshs_clone, frule cpfd2sfds_clone) *)
chunhan
parents:
diff changeset
  1451
apply (frule vd_cons, frule vt_grant_os, simp only:os_grant.simps)
chunhan
parents:
diff changeset
  1452
apply ((erule exE| erule conjE)+, frule not_init_intro_proc, simp, rule ext, case_tac "x = p'", simp)
chunhan
parents:
diff changeset
  1453
apply (auto simp:cp2sproc_def sectxt_of_obj_simps dest!:current_has_sec' 
chunhan
parents:
diff changeset
  1454
            dest:current_proc_has_sec split:option.splits if_splits)
chunhan
parents:
diff changeset
  1455
done
chunhan
parents:
diff changeset
  1456
chunhan
parents:
diff changeset
  1457
lemma cp2sproc_other:
chunhan
parents:
diff changeset
  1458
  "\<lbrakk>valid (e # s); 
chunhan
parents:
diff changeset
  1459
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
chunhan
parents:
diff changeset
  1460
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
  1461
    \<forall> p p' fds. e \<noteq> Clone p p' fds;
chunhan
parents:
diff changeset
  1462
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
  1463
    \<forall> p p'. e \<noteq> Kill p p';
chunhan
parents:
diff changeset
  1464
    \<forall> p. e \<noteq> Exit p\<rbrakk> \<Longrightarrow> cp2sproc (e # s) = cp2sproc s" (*
chunhan
parents:
diff changeset
  1465
    \<forall> p h flag. e \<noteq> Attach p h flag;
chunhan
parents:
diff changeset
  1466
    \<forall> p h. e \<noteq> Detach p h;
chunhan
parents:
diff changeset
  1467
    \<forall> p h. e \<noteq> DeleteShM p h;*)
chunhan
parents:
diff changeset
  1468
apply (frule cpfd2sfds_other, simp+)(*
chunhan
parents:
diff changeset
  1469
apply (frule cph2spshs_other, simp+, frule cpfd2sfds_other, simp+)*)
chunhan
parents:
diff changeset
  1470
apply (frule vt_grant_os, frule vd_cons, rule ext, case_tac e, simp_all) 
chunhan
parents:
diff changeset
  1471
apply (auto simp:cp2sproc_def sectxt_of_obj_simps dest!:current_has_sec' 
chunhan
parents:
diff changeset
  1472
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1473
done
chunhan
parents:
diff changeset
  1474
chunhan
parents:
diff changeset
  1475
lemma cp2sproc_open:
chunhan
parents:
diff changeset
  1476
  "valid (Open p f flags fd opt # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1477
   cp2sproc (Open p f flags fd opt # s) = (cp2sproc s) (p :=      
chunhan
parents:
diff changeset
  1478
     case (sectxt_of_obj s (O_proc p), sectxt_of_obj (Open p f flags fd opt # s) (O_fd p fd), 
chunhan
parents:
diff changeset
  1479
           cf2sfile (Open p f flags fd opt # s) f) of 
chunhan
parents:
diff changeset
  1480
       (Some sec, Some fdsec, Some sf) \<Rightarrow> Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) 
chunhan
parents:
diff changeset
  1481
                                               then Init p else Created, sec, 
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
  1482
                                                (cpfd2sfds s p) \<union> {(fdsec, remove_create_flag flags, sf)})
77
chunhan
parents:
diff changeset
  1483
     | _        \<Rightarrow> None)" (*, cph2spshs s p 
chunhan
parents:
diff changeset
  1484
apply (frule cph2spshs_other, simp, simp, simp, simp, simp, simp, simp) *)
chunhan
parents:
diff changeset
  1485
apply (frule cpfd2sfds_open, frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1486
apply (case_tac "x = p") 
chunhan
parents:
diff changeset
  1487
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1488
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1489
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1490
done
chunhan
parents:
diff changeset
  1491
chunhan
parents:
diff changeset
  1492
lemma cp2sproc_closefd:
chunhan
parents:
diff changeset
  1493
  "valid (CloseFd p fd # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1494
   cp2sproc (CloseFd p fd # s) = (cp2sproc s) (p := 
chunhan
parents:
diff changeset
  1495
     if (fd \<in> proc_file_fds s p)
chunhan
parents:
diff changeset
  1496
     then (case (cfd2sfd s p fd) of 
chunhan
parents:
diff changeset
  1497
             Some sfd \<Rightarrow> (if (\<exists> fd' f'. fd' \<noteq> fd \<and> file_of_proc_fd s p fd' = Some f' \<and> cfd2sfd s p fd' = Some sfd)
chunhan
parents:
diff changeset
  1498
                          then cp2sproc s p 
chunhan
parents:
diff changeset
  1499
                          else (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
  1500
                                  Some sec \<Rightarrow> Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) 
chunhan
parents:
diff changeset
  1501
                                                    then Init p else Created, 
chunhan
parents:
diff changeset
  1502
                                                    sec, cpfd2sfds s p - {sfd})
chunhan
parents:
diff changeset
  1503
                                | _        \<Rightarrow> None))
chunhan
parents:
diff changeset
  1504
           | _        \<Rightarrow> cp2sproc s p)
chunhan
parents:
diff changeset
  1505
     else cp2sproc s p)"(*, cph2spshs s p *)
chunhan
parents:
diff changeset
  1506
apply (frule cpfd2sfds_closefd) (*
chunhan
parents:
diff changeset
  1507
apply (frule cpfd2sfds_closefd, frule cph2spshs_other, simp, simp, simp, simp, simp, simp, simp) *)
chunhan
parents:
diff changeset
  1508
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1509
apply (case_tac "x = p") 
chunhan
parents:
diff changeset
  1510
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1511
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1512
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1513
done
chunhan
parents:
diff changeset
  1514
chunhan
parents:
diff changeset
  1515
(*
chunhan
parents:
diff changeset
  1516
lemma cp2sproc_attach:
chunhan
parents:
diff changeset
  1517
  "valid (Attach p h flag # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1518
   cp2sproc (Attach p h flag # s) = (cp2sproc s) (p := 
chunhan
parents:
diff changeset
  1519
     (case (ch2sshm s h) of 
chunhan
parents:
diff changeset
  1520
        Some sh \<Rightarrow> (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
  1521
                      Some sec \<Rightarrow> Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) 
chunhan
parents:
diff changeset
  1522
                                        then Init p else Created, 
chunhan
parents:
diff changeset
  1523
                                        sec, cpfd2sfds s p, cph2spshs s p \<union> {(sh, flag)})
chunhan
parents:
diff changeset
  1524
                    | _        \<Rightarrow> None)
chunhan
parents:
diff changeset
  1525
      | _       \<Rightarrow> cp2sproc s p) )"
chunhan
parents:
diff changeset
  1526
apply (frule cph2spshs_attach, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
chunhan
parents:
diff changeset
  1527
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1528
apply (case_tac "x = p") 
chunhan
parents:
diff changeset
  1529
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1530
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1531
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1532
done
chunhan
parents:
diff changeset
  1533
chunhan
parents:
diff changeset
  1534
lemma cp2sproc_detach:
chunhan
parents:
diff changeset
  1535
  "valid (Detach p h # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1536
   cp2sproc (Detach p h # s) = (cp2sproc s) (p := 
chunhan
parents:
diff changeset
  1537
    (case (ch2sshm s h, flag_of_proc_shm s p h) of 
chunhan
parents:
diff changeset
  1538
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p,flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
chunhan
parents:
diff changeset
  1539
                              then cp2sproc s p 
chunhan
parents:
diff changeset
  1540
                              else (case (sectxt_of_obj s (O_proc p)) of
chunhan
parents:
diff changeset
  1541
                                      Some sec \<Rightarrow> Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) 
chunhan
parents:
diff changeset
  1542
                                                       then Init p else Created, sec,
chunhan
parents:
diff changeset
  1543
                                                       cpfd2sfds s p, cph2spshs s p - {(sh, flag)})
chunhan
parents:
diff changeset
  1544
                                    | None     \<Rightarrow> None)                   
chunhan
parents:
diff changeset
  1545
     | _       \<Rightarrow> cp2sproc s p)             )"
chunhan
parents:
diff changeset
  1546
apply (frule cph2spshs_detach, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
chunhan
parents:
diff changeset
  1547
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1548
apply (case_tac "x = p") 
chunhan
parents:
diff changeset
  1549
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1550
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1551
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1552
done
chunhan
parents:
diff changeset
  1553
chunhan
parents:
diff changeset
  1554
lemma cp2sproc_deleteshm:
chunhan
parents:
diff changeset
  1555
  "valid (DeleteShM p h # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1556
   cp2sproc (DeleteShM p h # s) = (\<lambda> p'. 
chunhan
parents:
diff changeset
  1557
    (case (ch2sshm s h, flag_of_proc_shm s p' h) of 
chunhan
parents:
diff changeset
  1558
       (Some sh, Some flag) \<Rightarrow> if (\<exists> h'. h' \<noteq> h \<and> (p', flag) \<in> procs_of_shm s h' \<and> ch2sshm s h' = Some sh)
chunhan
parents:
diff changeset
  1559
                              then cp2sproc s p' 
chunhan
parents:
diff changeset
  1560
                              else (case (sectxt_of_obj s (O_proc p')) of
chunhan
parents:
diff changeset
  1561
                                      Some sec \<Rightarrow> Some (if (\<not> died (O_proc p') s \<and> p' \<in> init_procs) 
chunhan
parents:
diff changeset
  1562
                                                       then Init p' else Created, sec,
chunhan
parents:
diff changeset
  1563
                                                       cpfd2sfds s p', cph2spshs s p' - {(sh, flag)})
chunhan
parents:
diff changeset
  1564
                                    | None     \<Rightarrow> None)                   
chunhan
parents:
diff changeset
  1565
     | _       \<Rightarrow> cp2sproc s p')             )"
chunhan
parents:
diff changeset
  1566
apply (frule cph2spshs_deleteshm, frule cpfd2sfds_other, simp, simp, simp, simp, simp, simp)
chunhan
parents:
diff changeset
  1567
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1568
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1569
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1570
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1571
done
chunhan
parents:
diff changeset
  1572
*)
chunhan
parents:
diff changeset
  1573
chunhan
parents:
diff changeset
  1574
lemma cp2sproc_execve:
chunhan
parents:
diff changeset
  1575
  "valid (Execve p f fds # s) \<Longrightarrow> 
chunhan
parents:
diff changeset
  1576
   cp2sproc (Execve p f fds # s) = (cp2sproc s) (p := 
chunhan
parents:
diff changeset
  1577
     (case (sectxt_of_obj (Execve p f fds # s) (O_proc p)) of
chunhan
parents:
diff changeset
  1578
        Some sec \<Rightarrow> Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, 
chunhan
parents:
diff changeset
  1579
                         {sfd. \<exists> fd \<in> fds. \<exists> f. file_of_proc_fd s p fd = Some f \<and> cfd2sfd s p fd = Some sfd})
chunhan
parents:
diff changeset
  1580
      | _        \<Rightarrow> None)                        )" (*, {}
chunhan
parents:
diff changeset
  1581
apply (frule cph2spshs_execve, frule cpfd2sfds_execve) *)
chunhan
parents:
diff changeset
  1582
apply (frule cpfd2sfds_execve)
chunhan
parents:
diff changeset
  1583
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1584
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1585
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1586
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1587
done
chunhan
parents:
diff changeset
  1588
chunhan
parents:
diff changeset
  1589
lemma cp2sproc_kill:
chunhan
parents:
diff changeset
  1590
  "\<lbrakk>valid (Kill p p' # s); p'' \<noteq> p'\<rbrakk> \<Longrightarrow> 
chunhan
parents:
diff changeset
  1591
   cp2sproc (Kill p p' # s) p'' = (cp2sproc s) p''" (*
chunhan
parents:
diff changeset
  1592
apply (frule cph2spshs_kill, frule cpfd2sfds_kill) *)
chunhan
parents:
diff changeset
  1593
apply (frule cpfd2sfds_kill)
chunhan
parents:
diff changeset
  1594
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  1595
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1596
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1597
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1598
done
chunhan
parents:
diff changeset
  1599
chunhan
parents:
diff changeset
  1600
lemma cp2sproc_kill':
chunhan
parents:
diff changeset
  1601
  "\<lbrakk>valid (Kill p p' # s); p'' \<in> current_procs (Kill p p' # s)\<rbrakk> \<Longrightarrow> 
chunhan
parents:
diff changeset
  1602
   cp2sproc (Kill p p' # s) p'' = (cp2sproc s) p''"
chunhan
parents:
diff changeset
  1603
by (drule_tac p'' = p'' in cp2sproc_kill, simp+)
chunhan
parents:
diff changeset
  1604
chunhan
parents:
diff changeset
  1605
lemma cp2sproc_exit:
chunhan
parents:
diff changeset
  1606
  "\<lbrakk>valid (Exit p # s); p' \<noteq> p\<rbrakk> \<Longrightarrow> 
chunhan
parents:
diff changeset
  1607
   cp2sproc (Exit p # s) p' = (cp2sproc s) p'" (*
chunhan
parents:
diff changeset
  1608
apply (frule cph2spshs_exit, frule cpfd2sfds_exit) *)
chunhan
parents:
diff changeset
  1609
apply (frule cpfd2sfds_exit)
chunhan
parents:
diff changeset
  1610
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  1611
apply (auto simp:cp2sproc_def sectxt_of_obj_simps current_files_simps 
chunhan
parents:
diff changeset
  1612
           dest!:current_has_sec' dest!:current_file_has_sfile' dest:is_file_in_current is_dir_in_current
chunhan
parents:
diff changeset
  1613
            dest:current_proc_has_sec not_died_init_proc split:option.splits if_splits)
chunhan
parents:
diff changeset
  1614
done
chunhan
parents:
diff changeset
  1615
chunhan
parents:
diff changeset
  1616
lemma cp2sproc_exit':
chunhan
parents:
diff changeset
  1617
  "\<lbrakk>valid (Exit p # s); p' \<in> current_procs (Exit p # s)\<rbrakk> \<Longrightarrow> 
chunhan
parents:
diff changeset
  1618
   cp2sproc (Exit p # s) p' = (cp2sproc s) p'"
chunhan
parents:
diff changeset
  1619
by (drule_tac p'= p' in cp2sproc_exit, simp+)
chunhan
parents:
diff changeset
  1620
chunhan
parents:
diff changeset
  1621
lemmas cp2sproc_simps = cp2sproc_open cp2sproc_closefd (* cp2sproc_attach cp2sproc_detach cp2sproc_deleteshm *)
chunhan
parents:
diff changeset
  1622
  cp2sproc_clone cp2sproc_execve cp2sproc_kill cp2sproc_exit cp2sproc_other 
chunhan
parents:
diff changeset
  1623
chunhan
parents:
diff changeset
  1624
lemma current_proc_has_sp:
chunhan
parents:
diff changeset
  1625
  "\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sp. cp2sproc s p = Some sp"
chunhan
parents:
diff changeset
  1626
by (auto simp:cp2sproc_def split:option.splits dest!:current_has_sec')
chunhan
parents:
diff changeset
  1627
chunhan
parents:
diff changeset
  1628
lemma current_proc_has_sp':
chunhan
parents:
diff changeset
  1629
  "\<lbrakk>cp2sproc s p = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
chunhan
parents:
diff changeset
  1630
by (auto dest:current_proc_has_sp)
chunhan
parents:
diff changeset
  1631
chunhan
parents:
diff changeset
  1632
(* simpset for cf2sfiles *)
chunhan
parents:
diff changeset
  1633
chunhan
parents:
diff changeset
  1634
lemma cf2sfiles_open:
chunhan
parents:
diff changeset
  1635
  "\<lbrakk>valid (Open p f flag fd opt # s); f' \<in> current_files (Open p f flag fd opt # s)\<rbrakk>
chunhan
parents:
diff changeset
  1636
   \<Longrightarrow> cf2sfiles (Open p f flag fd opt # s) f' = (
chunhan
parents:
diff changeset
  1637
     if (f' = f \<and> opt \<noteq> None) 
chunhan
parents:
diff changeset
  1638
     then (case cf2sfile (Open p f flag fd opt # s) f of 
chunhan
parents:
diff changeset
  1639
             Some sf \<Rightarrow> {sf}  
chunhan
parents:
diff changeset
  1640
           | _       \<Rightarrow> {} )
chunhan
parents:
diff changeset
  1641
     else cf2sfiles s f')"
chunhan
parents:
diff changeset
  1642
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents:
diff changeset
  1643
apply (auto simp:cf2sfiles_def cf2sfile_open_none cf2sfile_simps same_inode_files_open
chunhan
parents:
diff changeset
  1644
  split:if_splits option.splits dest!:current_file_has_sfile' dest:cf2sfile_open)
chunhan
parents:
diff changeset
  1645
apply (rule_tac x = "f'a" in bexI, drule same_inode_files_prop1, simp add:cf2sfile_open_some1, simp)+
chunhan
parents:
diff changeset
  1646
done
chunhan
parents:
diff changeset
  1647
chunhan
parents:
diff changeset
  1648
lemma cf2sfiles_other:
chunhan
parents:
diff changeset
  1649
  "\<lbrakk>valid (e # s);
chunhan
parents:
diff changeset
  1650
    \<forall> p f flag fd opt. e \<noteq> Open p f flag fd opt;
chunhan
parents:
diff changeset
  1651
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
  1652
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents:
diff changeset
  1653
    \<forall> p f f'. e \<noteq> LinkHard p f f'\<rbrakk> \<Longrightarrow> cf2sfiles (e # s) = cf2sfiles s"
chunhan
parents:
diff changeset
  1654
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1655
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI)
chunhan
parents:
diff changeset
  1656
apply (drule Set.CollectD, erule bexE, rule CollectI)
chunhan
parents:
diff changeset
  1657
apply (rule_tac x = f' in bexI, case_tac e)
chunhan
parents:
diff changeset
  1658
apply (auto simp:cf2sfiles_def cf2sfile_simps same_inode_files_simps current_files_simps
chunhan
parents:
diff changeset
  1659
  split:if_splits option.splits dest!:current_file_has_sfile' dest:same_inode_files_prop1 cf2sfile_other')
chunhan
parents:
diff changeset
  1660
apply (drule_tac f' = f' in cf2sfile_rmdir)
chunhan
parents:
diff changeset
  1661
apply (simp add:current_files_simps same_inode_files_prop1 same_inode_files_prop3 dir_is_empty_def)+
chunhan
parents:
diff changeset
  1662
chunhan
parents:
diff changeset
  1663
apply (rule_tac x = f' in bexI, case_tac e)
chunhan
parents:
diff changeset
  1664
apply (auto simp:cf2sfiles_def cf2sfile_simps same_inode_files_simps current_files_simps
chunhan
parents:
diff changeset
  1665
  split:if_splits option.splits dest!:current_file_has_sfile' dest:same_inode_files_prop1 cf2sfile_other')
chunhan
parents:
diff changeset
  1666
apply (drule_tac f' = f' in cf2sfile_rmdir)
chunhan
parents:
diff changeset
  1667
apply (simp add:current_files_simps same_inode_files_prop1 same_inode_files_prop3 dir_is_empty_def)+
chunhan
parents:
diff changeset
  1668
done
chunhan
parents:
diff changeset
  1669
chunhan
parents:
diff changeset
  1670
lemma cf2sfile_linkhard1':
chunhan
parents:
diff changeset
  1671
  "\<lbrakk>valid (LinkHard p oldf f # s); f' \<in> same_inode_files s f''\<rbrakk>
chunhan
parents:
diff changeset
  1672
   \<Longrightarrow> cf2sfile (LinkHard p oldf f# s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
  1673
apply (drule same_inode_files_prop1)
chunhan
parents:
diff changeset
  1674
by (simp add:cf2sfile_linkhard1)
chunhan
parents:
diff changeset
  1675
chunhan
parents:
diff changeset
  1676
lemma cf2sfiles_linkhard:
chunhan
parents:
diff changeset
  1677
  "valid (LinkHard p oldf f # s) \<Longrightarrow> cf2sfiles (LinkHard p oldf f # s) = (\<lambda> f'. 
chunhan
parents:
diff changeset
  1678
     if (f' = f \<or> f' \<in> same_inode_files s oldf)
chunhan
parents:
diff changeset
  1679
     then (case (cf2sfile (LinkHard p oldf f # s) f) of
chunhan
parents:
diff changeset
  1680
             Some sf \<Rightarrow> cf2sfiles s oldf \<union> {sf}
chunhan
parents:
diff changeset
  1681
           | _       \<Rightarrow> {})
chunhan
parents:
diff changeset
  1682
     else cf2sfiles s f')"
chunhan
parents:
diff changeset
  1683
apply (frule vt_grant_os, frule vd_cons, rule ext)
chunhan
parents:
diff changeset
  1684
apply (auto simp:cf2sfiles_def cf2sfile_linkhard1' same_inode_files_linkhard current_files_linkhard 
chunhan
parents:
diff changeset
  1685
  split:if_splits option.splits dest!:current_file_has_sfile' current_has_sec' dest:same_inode_files_prop1)
chunhan
parents:
diff changeset
  1686
done
chunhan
parents:
diff changeset
  1687
chunhan
parents:
diff changeset
  1688
lemma cf2sfile_unlink':
chunhan
parents:
diff changeset
  1689
  "\<lbrakk>valid (UnLink p f # s); f' \<in> same_inode_files (UnLink p f # s) f''\<rbrakk>
chunhan
parents:
diff changeset
  1690
   \<Longrightarrow> cf2sfile (UnLink p f # s) f' = cf2sfile s f'"
chunhan
parents:
diff changeset
  1691
apply (drule same_inode_files_prop1)
chunhan
parents:
diff changeset
  1692
by (simp add:cf2sfile_unlink)
chunhan
parents:
diff changeset
  1693
chunhan
parents:
diff changeset
  1694
lemma cf2sfiles_unlink:
chunhan
parents:
diff changeset
  1695
  "\<lbrakk>valid (UnLink p f # s); f' \<in> current_files (UnLink p f # s)\<rbrakk> \<Longrightarrow> cf2sfiles (UnLink p f # s) f' = ( 
chunhan
parents:
diff changeset
  1696
     if (f' \<in> same_inode_files s f \<and> proc_fd_of_file s f = {} \<and> 
chunhan
parents:
diff changeset
  1697
         (\<forall> f'' \<in> same_inode_files s f. f'' \<noteq> f \<longrightarrow> cf2sfile s f'' \<noteq> cf2sfile s f)) then 
chunhan
parents:
diff changeset
  1698
        (case (cf2sfile s f) of 
chunhan
parents:
diff changeset
  1699
           Some sf \<Rightarrow> cf2sfiles s f' - {sf}
chunhan
parents:
diff changeset
  1700
         | _       \<Rightarrow> {})
chunhan
parents:
diff changeset
  1701
     else cf2sfiles s f')"
chunhan
parents:
diff changeset
  1702
apply (frule vt_grant_os, frule vd_cons, simp add:current_files_simps split:if_splits)
chunhan
parents:
diff changeset
  1703
apply (rule conjI, clarify, frule is_file_has_sfile', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1704
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1705
apply (erule bexE, frule_tac f' = f' in same_inode_files_unlink)
chunhan
parents:
diff changeset
  1706
apply (simp add:current_files_unlink, simp, erule conjE)
chunhan
parents:
diff changeset
  1707
apply (erule_tac x = f'a in ballE, frule_tac f' = "f'a" in cf2sfile_unlink)
chunhan
parents:
diff changeset
  1708
apply (simp add:current_files_unlink same_inode_files_prop1, simp)
chunhan
parents:
diff changeset
  1709
apply (rule_tac x = f'a in bexI, simp, simp)
chunhan
parents:
diff changeset
  1710
apply (drule_tac f = f and f' = f' and f'' = f'a in same_inode_files_prop4, simp+)
chunhan
parents:
diff changeset
  1711
apply (erule conjE|erule exE|erule bexE)+
chunhan
parents:
diff changeset
  1712
apply (case_tac "f'a = f", simp)
chunhan
parents:
diff changeset
  1713
apply (frule_tac f' = f' in same_inode_files_unlink, simp add:current_files_unlink)
chunhan
parents:
diff changeset
  1714
apply (frule_tac f' = f'a in cf2sfile_unlink, simp add:current_files_unlink same_inode_files_prop1)
chunhan
parents:
diff changeset
  1715
apply (rule_tac x = f'a in bexI, simp, simp)
chunhan
parents:
diff changeset
  1716
chunhan
parents:
diff changeset
  1717
apply (rule impI)+
chunhan
parents:
diff changeset
  1718
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1719
apply (erule bexE, frule_tac f' = f' in same_inode_files_unlink)
chunhan
parents:
diff changeset
  1720
apply (simp add:current_files_unlink, simp, (erule conjE)+)
chunhan
parents:
diff changeset
  1721
apply (rule_tac x = f'a in bexI, frule_tac f' = "f'a" in cf2sfile_unlink)
chunhan
parents:
diff changeset
  1722
apply (simp add:current_files_unlink same_inode_files_prop1, simp, simp)
chunhan
parents:
diff changeset
  1723
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_unlink)
chunhan
parents:
diff changeset
  1724
apply (simp add:current_files_unlink, simp)
chunhan
parents:
diff changeset
  1725
apply (case_tac "f'a = f", simp)
chunhan
parents:
diff changeset
  1726
apply (frule_tac f = f' and f' = f in same_inode_files_prop5, simp)
chunhan
parents:
diff changeset
  1727
apply (erule bexE, erule conjE)
chunhan
parents:
diff changeset
  1728
apply (rule_tac x = f'' in bexI)
chunhan
parents:
diff changeset
  1729
apply (drule_tac f' = f'' in cf2sfile_unlink, simp add:current_files_unlink same_inode_files_prop1)
chunhan
parents:
diff changeset
  1730
apply (simp, simp, erule same_inode_files_prop4, simp)
chunhan
parents:
diff changeset
  1731
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1732
apply (drule_tac f' = f'a in cf2sfile_unlink, simp add:current_files_unlink same_inode_files_prop1)
chunhan
parents:
diff changeset
  1733
apply (simp, simp)
chunhan
parents:
diff changeset
  1734
chunhan
parents:
diff changeset
  1735
chunhan
parents:
diff changeset
  1736
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1737
apply (erule bexE, frule_tac f' = f' in same_inode_files_unlink)
chunhan
parents:
diff changeset
  1738
apply (simp add:current_files_unlink, simp)
chunhan
parents:
diff changeset
  1739
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1740
apply (frule_tac f' = f'a in cf2sfile_unlink)
chunhan
parents:
diff changeset
  1741
apply (simp add:same_inode_files_prop1 current_files_unlink, simp, simp)
chunhan
parents:
diff changeset
  1742
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_unlink)
chunhan
parents:
diff changeset
  1743
apply (simp add:current_files_unlink, simp)
chunhan
parents:
diff changeset
  1744
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1745
apply (frule_tac f' = f'a in cf2sfile_unlink)
chunhan
parents:
diff changeset
  1746
apply (simp add:same_inode_files_prop1 current_files_unlink, simp, simp)
chunhan
parents:
diff changeset
  1747
done
chunhan
parents:
diff changeset
  1748
chunhan
parents:
diff changeset
  1749
lemma cf2sfiles_closefd:
chunhan
parents:
diff changeset
  1750
  "\<lbrakk>valid (CloseFd p fd # s); f' \<in> current_files (CloseFd p fd # s)\<rbrakk> \<Longrightarrow> cf2sfiles (CloseFd p fd # s) f' = (
chunhan
parents:
diff changeset
  1751
     case (file_of_proc_fd s p fd) of
chunhan
parents:
diff changeset
  1752
       Some f \<Rightarrow> if (f' \<in> same_inode_files s f \<and> proc_fd_of_file s f = {(p, fd)} \<and> f \<in> files_hung_by_del s \<and> 
chunhan
parents:
diff changeset
  1753
                    (\<forall> f'' \<in> same_inode_files s f. f'' \<noteq> f \<longrightarrow> cf2sfile s f'' \<noteq> cf2sfile s f)) 
chunhan
parents:
diff changeset
  1754
                 then (case (cf2sfile s f) of 
chunhan
parents:
diff changeset
  1755
                         Some sf \<Rightarrow> cf2sfiles s f' - {sf}
chunhan
parents:
diff changeset
  1756
                       | _       \<Rightarrow> {})
chunhan
parents:
diff changeset
  1757
                 else cf2sfiles s f'
chunhan
parents:
diff changeset
  1758
     | _       \<Rightarrow> cf2sfiles s f')"
chunhan
parents:
diff changeset
  1759
chunhan
parents:
diff changeset
  1760
apply (frule vt_grant_os, frule vd_cons, case_tac "file_of_proc_fd s p fd")
chunhan
parents:
diff changeset
  1761
apply (simp_all add:current_files_simps split:if_splits)
chunhan
parents:
diff changeset
  1762
chunhan
parents:
diff changeset
  1763
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1764
apply (erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1765
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1766
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1767
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1768
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1769
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1770
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1771
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1772
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1773
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1774
chunhan
parents:
diff changeset
  1775
apply (rule conjI, clarify, frule file_of_pfd_is_file, simp)
chunhan
parents:
diff changeset
  1776
apply (frule is_file_has_sfile', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1777
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1778
apply (erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1779
apply (simp add:current_files_closefd, simp, erule conjE)
chunhan
parents:
diff changeset
  1780
apply (erule_tac x = f'a in ballE, frule_tac f = "f'a" in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1781
apply (simp add:current_files_closefd same_inode_files_prop1, simp)
chunhan
parents:
diff changeset
  1782
apply (rule_tac x = f'a in bexI, simp, simp)
chunhan
parents:
diff changeset
  1783
apply (drule_tac f = a and f' = f' and f'' = f'a in same_inode_files_prop4, simp+)
chunhan
parents:
diff changeset
  1784
apply (erule conjE|erule exE|erule bexE)+
chunhan
parents:
diff changeset
  1785
apply (case_tac "f'a = a", simp)
chunhan
parents:
diff changeset
  1786
apply (frule_tac f' = f' in same_inode_files_closefd, simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1787
apply (frule_tac f = f'a in cf2sfile_closefd, simp add:current_files_closefd same_inode_files_prop1)
chunhan
parents:
diff changeset
  1788
apply (rule_tac x = f'a in bexI, simp, simp)
chunhan
parents:
diff changeset
  1789
chunhan
parents:
diff changeset
  1790
apply (rule impI)+
chunhan
parents:
diff changeset
  1791
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1792
apply (erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1793
apply (simp add:current_files_closefd, simp, (erule conjE)+)
chunhan
parents:
diff changeset
  1794
apply (rule_tac x = f'a in bexI, frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1795
apply (simp add:current_files_closefd same_inode_files_prop1, simp, simp)
chunhan
parents:
diff changeset
  1796
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1797
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1798
apply (case_tac "f'a = a", simp)
chunhan
parents:
diff changeset
  1799
apply (frule_tac f = f' and f' = a in same_inode_files_prop5, simp)
chunhan
parents:
diff changeset
  1800
apply (erule bexE, erule conjE)
chunhan
parents:
diff changeset
  1801
apply (rule_tac x = f'' in bexI)
chunhan
parents:
diff changeset
  1802
apply (drule_tac f = f'' in cf2sfile_closefd, simp add:current_files_closefd same_inode_files_prop1)
chunhan
parents:
diff changeset
  1803
apply (simp, simp, erule same_inode_files_prop4, simp)
chunhan
parents:
diff changeset
  1804
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1805
apply (drule_tac f = f'a in cf2sfile_closefd, simp add:current_files_closefd same_inode_files_prop1)
chunhan
parents:
diff changeset
  1806
apply (simp, simp)
chunhan
parents:
diff changeset
  1807
chunhan
parents:
diff changeset
  1808
apply (rule conjI, clarify)
chunhan
parents:
diff changeset
  1809
chunhan
parents:
diff changeset
  1810
apply (rule impI)
chunhan
parents:
diff changeset
  1811
apply (case_tac "a \<in> files_hung_by_del s", simp_all)
chunhan
parents:
diff changeset
  1812
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1813
apply (erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1814
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1815
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1816
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1817
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1818
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1819
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1820
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1821
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1822
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1823
apply (simp add:cf2sfiles_def, rule set_eqI, rule iffI, drule CollectD)
chunhan
parents:
diff changeset
  1824
apply (erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1825
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1826
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1827
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1828
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1829
apply (drule CollectD, erule bexE, frule_tac f' = f' in same_inode_files_closefd)
chunhan
parents:
diff changeset
  1830
apply (simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  1831
apply (rule_tac x = f'a in bexI)
chunhan
parents:
diff changeset
  1832
apply (frule_tac f = f'a in cf2sfile_closefd)
chunhan
parents:
diff changeset
  1833
apply (simp add:same_inode_files_prop1 current_files_closefd, simp, simp)
chunhan
parents:
diff changeset
  1834
done
chunhan
parents:
diff changeset
  1835
chunhan
parents:
diff changeset
  1836
lemmas cf2sfiles_simps = cf2sfiles_open cf2sfiles_linkhard cf2sfiles_other
chunhan
parents:
diff changeset
  1837
  cf2sfiles_unlink cf2sfiles_closefd
chunhan
parents:
diff changeset
  1838
  
chunhan
parents:
diff changeset
  1839
chunhan
parents:
diff changeset
  1840
(* simpset for co2sobj *)
chunhan
parents:
diff changeset
  1841
chunhan
parents:
diff changeset
  1842
lemma co2sobj_execve:
chunhan
parents:
diff changeset
  1843
  "\<lbrakk>valid (Execve p f fds # s); alive (Execve p f fds # s) obj\<rbrakk> \<Longrightarrow> co2sobj (Execve p f fds # s) obj = (
chunhan
parents:
diff changeset
  1844
      if (obj = O_proc p)
chunhan
parents:
diff changeset
  1845
      then (case (cp2sproc (Execve p f fds # s) p) of
chunhan
parents:
diff changeset
  1846
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s \<or> O_file f \<in> tainted s))
chunhan
parents:
diff changeset
  1847
            | _       \<Rightarrow> None) 
chunhan
parents:
diff changeset
  1848
      else co2sobj s obj )"
chunhan
parents:
diff changeset
  1849
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1850
apply (simp_all add:current_files_simps cf2sfiles_other (* ch2sshm_other *) cq2smsgq_other)
chunhan
parents:
diff changeset
  1851
apply (case_tac "cp2sproc (Execve p f fds # s) p")
chunhan
parents:
diff changeset
  1852
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents:
diff changeset
  1853
apply (simp (no_asm_simp) add:cp2sproc_execve split:option.splits)
chunhan
parents:
diff changeset
  1854
apply (simp add:is_dir_simps, frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1855
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1856
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1857
done
chunhan
parents:
diff changeset
  1858
chunhan
parents:
diff changeset
  1859
lemma co2sobj_execve':
chunhan
parents:
diff changeset
  1860
  "\<lbrakk>valid (Execve p f fds # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Execve p f fds # s) obj = (
chunhan
parents:
diff changeset
  1861
      if (obj = O_proc p)
chunhan
parents:
diff changeset
  1862
      then (case (cp2sproc (Execve p f fds # s) p) of
chunhan
parents:
diff changeset
  1863
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s \<or> O_file f \<in> tainted s))
chunhan
parents:
diff changeset
  1864
            | _       \<Rightarrow> None) 
chunhan
parents:
diff changeset
  1865
      else co2sobj s obj )"
chunhan
parents:
diff changeset
  1866
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1867
apply (simp_all add:current_files_simps cf2sfiles_other (* ch2sshm_other *) cq2smsgq_other)
chunhan
parents:
diff changeset
  1868
apply (case_tac "cp2sproc (Execve p f fds # s) p")
chunhan
parents:
diff changeset
  1869
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents:
diff changeset
  1870
apply (simp (no_asm_simp) add:cp2sproc_execve split:option.splits)
chunhan
parents:
diff changeset
  1871
apply (frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1872
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1873
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1874
done
chunhan
parents:
diff changeset
  1875
chunhan
parents:
diff changeset
  1876
lemma co2sobj_clone':
chunhan
parents:
diff changeset
  1877
  "\<lbrakk>valid (Clone p p' fds # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Clone p p' fds # s) obj = (
chunhan
parents:
diff changeset
  1878
      if (obj = O_proc p')
chunhan
parents:
diff changeset
  1879
      then (case (cp2sproc (Clone p p' fds # s) p') of
chunhan
parents:
diff changeset
  1880
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1881
            | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1882
      else co2sobj s obj )"
chunhan
parents:
diff changeset
  1883
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1884
apply (simp_all add:current_files_simps cf2sfiles_other (* ch2sshm_other *) cq2smsgq_other)
chunhan
parents:
diff changeset
  1885
apply (case_tac "cp2sproc (Clone p p' fds # s) p'")
chunhan
parents:
diff changeset
  1886
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents:
diff changeset
  1887
apply ((erule conjE)+, frule_tac p = p in current_proc_has_sec, simp, erule exE, simp)
chunhan
parents:
diff changeset
  1888
apply (simp (no_asm_simp) add:cp2sproc_clone split:option.splits)
chunhan
parents:
diff changeset
  1889
apply (case_tac "nat = p'", simp, simp)
chunhan
parents:
diff changeset
  1890
apply (frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1891
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1892
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1893
done
chunhan
parents:
diff changeset
  1894
chunhan
parents:
diff changeset
  1895
lemma co2sobj_clone:
chunhan
parents:
diff changeset
  1896
  "\<lbrakk>valid (Clone p p' fds # s); alive (Clone p p' fds # s) obj\<rbrakk> 
chunhan
parents:
diff changeset
  1897
   \<Longrightarrow> co2sobj (Clone p p' fds # s) obj = (
chunhan
parents:
diff changeset
  1898
      if (obj = O_proc p')
chunhan
parents:
diff changeset
  1899
      then (case (cp2sproc (Clone p p' fds # s) p') of
chunhan
parents:
diff changeset
  1900
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1901
            | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1902
      else co2sobj s obj )"
chunhan
parents:
diff changeset
  1903
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1904
apply (simp_all add:current_files_simps cf2sfiles_other (* ch2sshm_other *)  cq2smsgq_other)
chunhan
parents:
diff changeset
  1905
apply (rule conjI, rule impI, simp)
chunhan
parents:
diff changeset
  1906
apply (case_tac "cp2sproc (Clone p p' fds # s) p'")
chunhan
parents:
diff changeset
  1907
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents:
diff changeset
  1908
apply ((erule conjE)+, frule_tac p = p in current_proc_has_sec, simp, erule exE, simp)
chunhan
parents:
diff changeset
  1909
apply (rule impI,rule notI, drule tainted_in_current, simp+)
chunhan
parents:
diff changeset
  1910
apply (rule impI, simp)
chunhan
parents:
diff changeset
  1911
apply (drule current_proc_has_sp, simp, (erule exE|erule conjE)+)
chunhan
parents:
diff changeset
  1912
apply (simp (no_asm_simp) add:cp2sproc_clone tainted_in_current split:option.splits)
chunhan
parents:
diff changeset
  1913
chunhan
parents:
diff changeset
  1914
apply (simp add:is_dir_simps, frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1915
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1916
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1917
done
chunhan
parents:
diff changeset
  1918
chunhan
parents:
diff changeset
  1919
(*
chunhan
parents:
diff changeset
  1920
lemma co2sobj_ptrace:
chunhan
parents:
diff changeset
  1921
  "\<lbrakk>valid (Ptrace p p' # s); alive s obj\<rbrakk>\<Longrightarrow> co2sobj (Ptrace p p' # s) obj = (
chunhan
parents:
diff changeset
  1922
     case obj of
chunhan
parents:
diff changeset
  1923
       O_proc p'' \<Rightarrow> if (info_flow_shm s p' p'') 
chunhan
parents:
diff changeset
  1924
                     then (case (cp2sproc s p'') of 
chunhan
parents:
diff changeset
  1925
                             Some sp \<Rightarrow> Some (S_proc sp (O_proc p'' \<in> tainted s \<or> O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1926
                           | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1927
                     else if (info_flow_shm s p p'')
chunhan
parents:
diff changeset
  1928
                          then (case (cp2sproc s p'') of 
chunhan
parents:
diff changeset
  1929
                                  Some sp \<Rightarrow> Some (S_proc sp (O_proc p'' \<in> tainted s \<or> O_proc p' \<in> tainted s))
chunhan
parents:
diff changeset
  1930
                                | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1931
                          else co2sobj s (O_proc p'')
chunhan
parents:
diff changeset
  1932
    | _          \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  1933
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1934
apply (simp_all add:current_files_simps ch2sshm_other cq2smsgq_other cf2sfiles_other)
chunhan
parents:
diff changeset
  1935
chunhan
parents:
diff changeset
  1936
apply (auto simp:cp2sproc_other split:option.splits
chunhan
parents:
diff changeset
  1937
  dest!:current_proc_has_sec' current_proc_has_sp' intro:info_flow_shm_tainted)[1]
chunhan
parents:
diff changeset
  1938
chunhan
parents:
diff changeset
  1939
apply (frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1940
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1941
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1942
done
chunhan
parents:
diff changeset
  1943
*)
chunhan
parents:
diff changeset
  1944
chunhan
parents:
diff changeset
  1945
lemma co2sobj_ptrace:
chunhan
parents:
diff changeset
  1946
  "\<lbrakk>valid (Ptrace p p' # s); alive s obj\<rbrakk>\<Longrightarrow> co2sobj (Ptrace p p' # s) obj = (
chunhan
parents:
diff changeset
  1947
     case obj of
chunhan
parents:
diff changeset
  1948
       O_proc p'' \<Rightarrow> if (p'' = p') 
chunhan
parents:
diff changeset
  1949
                     then (case (cp2sproc s p'') of 
chunhan
parents:
diff changeset
  1950
                             Some sp \<Rightarrow> Some (S_proc sp (O_proc p'' \<in> tainted s \<or> O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1951
                           | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1952
                     else if (p'' = p)
chunhan
parents:
diff changeset
  1953
                          then (case (cp2sproc s p'') of 
chunhan
parents:
diff changeset
  1954
                                  Some sp \<Rightarrow> Some (S_proc sp (O_proc p'' \<in> tainted s \<or> O_proc p' \<in> tainted s))
chunhan
parents:
diff changeset
  1955
                                | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1956
                          else co2sobj s (O_proc p'')
chunhan
parents:
diff changeset
  1957
    | _          \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  1958
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1959
apply (simp_all add:current_files_simps cq2smsgq_other cf2sfiles_other)
chunhan
parents:
diff changeset
  1960
chunhan
parents:
diff changeset
  1961
apply (auto simp:cp2sproc_other split:option.splits
chunhan
parents:
diff changeset
  1962
  dest!:current_proc_has_sec' current_proc_has_sp')[1]
chunhan
parents:
diff changeset
  1963
chunhan
parents:
diff changeset
  1964
apply (frule_tac s = s in is_dir_has_sdir', simp, erule exE, simp)
chunhan
parents:
diff changeset
  1965
apply (frule_tac ff = list in cf2sfile_other', simp_all)
chunhan
parents:
diff changeset
  1966
apply (simp add:is_dir_in_current)
chunhan
parents:
diff changeset
  1967
done
chunhan
parents:
diff changeset
  1968
chunhan
parents:
diff changeset
  1969
chunhan
parents:
diff changeset
  1970
lemma co2sobj_open:
chunhan
parents:
diff changeset
  1971
  "\<lbrakk>valid (Open p f flag fd opt # s); alive (Open p f flag fd opt # s) obj\<rbrakk> 
chunhan
parents:
diff changeset
  1972
   \<Longrightarrow> co2sobj (Open p f flag fd opt # s) obj = (case obj of 
chunhan
parents:
diff changeset
  1973
     O_file f' \<Rightarrow> if (f' = f \<and> opt \<noteq> None)
chunhan
parents:
diff changeset
  1974
                  then (case (cf2sfile (Open p f flag fd opt # s) f) of
chunhan
parents:
diff changeset
  1975
                          Some sf \<Rightarrow> Some (S_file {sf} (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1976
                        | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1977
                  else co2sobj s (O_file f')
chunhan
parents:
diff changeset
  1978
   | O_proc p' \<Rightarrow> if (p' = p) 
chunhan
parents:
diff changeset
  1979
                  then (case (cp2sproc (Open p f flag fd opt # s) p) of
chunhan
parents:
diff changeset
  1980
                          Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  1981
                        | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  1982
                  else co2sobj s (O_proc p')
chunhan
parents:
diff changeset
  1983
   | _         \<Rightarrow> co2sobj s obj )"
chunhan
parents:
diff changeset
  1984
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  1985
apply (auto simp:cp2sproc_simps split:option.splits
chunhan
parents:
diff changeset
  1986
           dest!:current_proc_has_sp' (* intro:info_flow_shm_tainted *))[1]
chunhan
parents:
diff changeset
  1987
chunhan
parents:
diff changeset
  1988
apply (simp split:if_splits t_object.splits) 
chunhan
parents:
diff changeset
  1989
apply ((rule conjI | rule impI| erule conjE| erule exE)+)
chunhan
parents:
diff changeset
  1990
apply ( simp, (erule exE|erule conjE)+)
chunhan
parents:
diff changeset
  1991
apply (case_tac "cf2sfile (Open p f flag fd (Some y) # s) f")
chunhan
parents:
diff changeset
  1992
apply (drule current_file_has_sfile', simp, simp add:current_files_simps, simp)
chunhan
parents:
diff changeset
  1993
apply (frule_tac f' = f in cf2sfiles_open, simp add:current_files_simps, simp)
chunhan
parents:
diff changeset
  1994
apply (frule_tac f' = list in cf2sfiles_open, simp add:is_file_in_current)
chunhan
parents:
diff changeset
  1995
apply (rule impI)
chunhan
parents:
diff changeset
  1996
apply (case_tac "list = f", simp, simp split:option.splits)
chunhan
parents:
diff changeset
  1997
apply (case_tac "cf2sfile (Open p f flag fd opt # s) f")
chunhan
parents:
diff changeset
  1998
apply (drule current_file_has_sfile', simp)
chunhan
parents:
diff changeset
  1999
apply (simp add:current_files_simps is_file_in_current split:option.splits)
chunhan
parents:
diff changeset
  2000
apply (rule impI, simp add:cf2sfiles_open is_file_in_current split:option.splits)
chunhan
parents:
diff changeset
  2001
apply (rule impI, rule conjI)
chunhan
parents:
diff changeset
  2002
apply (drule_tac f' = f in cf2sfiles_open)
chunhan
parents:
diff changeset
  2003
apply (simp add:current_files_simps, simp)
chunhan
parents:
diff changeset
  2004
apply (rule notI, drule tainted_in_current, simp, simp add:is_file_in_current)
chunhan
parents:
diff changeset
  2005
chunhan
parents:
diff changeset
  2006
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2007
chunhan
parents:
diff changeset
  2008
apply (frule is_dir_in_current)
chunhan
parents:
diff changeset
  2009
apply (frule_tac f' = list in cf2sfile_open)
chunhan
parents:
diff changeset
  2010
apply (simp add:current_files_simps split:option.splits)
chunhan
parents:
diff changeset
  2011
apply (simp split:if_splits option.splits)
chunhan
parents:
diff changeset
  2012
done
chunhan
parents:
diff changeset
  2013
chunhan
parents:
diff changeset
  2014
(*
chunhan
parents:
diff changeset
  2015
lemma co2sobj_readfile:
chunhan
parents:
diff changeset
  2016
  "\<lbrakk>valid (ReadFile p fd # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (ReadFile p fd # s) obj = (
chunhan
parents:
diff changeset
  2017
     case obj of
chunhan
parents:
diff changeset
  2018
       O_proc p' \<Rightarrow> (case (file_of_proc_fd s p fd) of
chunhan
parents:
diff changeset
  2019
                       Some f \<Rightarrow> (if (info_flow_shm s p p' \<and> O_file f \<in> tainted s)
chunhan
parents:
diff changeset
  2020
                                  then (case (cp2sproc s p') of
chunhan
parents:
diff changeset
  2021
                                          Some sp \<Rightarrow> Some (S_proc sp True)
chunhan
parents:
diff changeset
  2022
                                        | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2023
                                  else co2sobj s obj)
chunhan
parents:
diff changeset
  2024
                    | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2025
     | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2026
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2027
apply (auto simp:cp2sproc_simps split:option.splits
chunhan
parents:
diff changeset
  2028
           dest!:current_proc_has_sp' intro:info_flow_shm_tainted)[1]
chunhan
parents:
diff changeset
  2029
apply (simp_all add:current_files_simps is_dir_simps ch2sshm_other cq2smsgq_other)
chunhan
parents:
diff changeset
  2030
chunhan
parents:
diff changeset
  2031
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' 
chunhan
parents:
diff changeset
  2032
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps 
chunhan
parents:
diff changeset
  2033
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2034
done
chunhan
parents:
diff changeset
  2035
*)
chunhan
parents:
diff changeset
  2036
lemma co2sobj_readfile:
chunhan
parents:
diff changeset
  2037
  "\<lbrakk>valid (ReadFile p fd # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (ReadFile p fd # s) obj = (
chunhan
parents:
diff changeset
  2038
     case obj of
chunhan
parents:
diff changeset
  2039
       O_proc p' \<Rightarrow> (case (file_of_proc_fd s p fd) of
chunhan
parents:
diff changeset
  2040
                       Some f \<Rightarrow> (if (p' = p \<and> O_file f \<in> tainted s)
chunhan
parents:
diff changeset
  2041
                                  then (case (cp2sproc s p') of
chunhan
parents:
diff changeset
  2042
                                          Some sp \<Rightarrow> Some (S_proc sp True)
chunhan
parents:
diff changeset
  2043
                                        | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2044
                                  else co2sobj s obj)
chunhan
parents:
diff changeset
  2045
                    | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2046
     | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2047
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2048
apply (auto simp:cp2sproc_simps split:option.splits dest!:current_proc_has_sp')[1]
chunhan
parents:
diff changeset
  2049
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2050
chunhan
parents:
diff changeset
  2051
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' 
chunhan
parents:
diff changeset
  2052
             simp:current_files_simps cf2sfile_simps cf2sfiles_simps
chunhan
parents:
diff changeset
  2053
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2054
done
chunhan
parents:
diff changeset
  2055
chunhan
parents:
diff changeset
  2056
lemma co2sobj_writefile:
chunhan
parents:
diff changeset
  2057
  "\<lbrakk>valid (WriteFile p fd # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (WriteFile p fd # s) obj = (
chunhan
parents:
diff changeset
  2058
     case obj of
chunhan
parents:
diff changeset
  2059
       O_file f' \<Rightarrow> (case (file_of_proc_fd s p fd) of
chunhan
parents:
diff changeset
  2060
                       Some f \<Rightarrow> (if (f \<in> same_inode_files s f') 
chunhan
parents:
diff changeset
  2061
                                  then Some (S_file (cf2sfiles s f') 
chunhan
parents:
diff changeset
  2062
                                                    (O_file f' \<in> tainted s \<or> O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  2063
                                  else co2sobj s obj)
chunhan
parents:
diff changeset
  2064
                    | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2065
     | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2066
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2067
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other) (* ch2sshm_other*)
chunhan
parents:
diff changeset
  2068
chunhan
parents:
diff changeset
  2069
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2070
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2071
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2072
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2073
chunhan
parents:
diff changeset
  2074
(* should delete has_same_inode !?!?*)
chunhan
parents:
diff changeset
  2075
by (auto simp:same_inode_files_def is_file_def has_same_inode_def split:if_splits option.splits)
chunhan
parents:
diff changeset
  2076
chunhan
parents:
diff changeset
  2077
lemma co2sobj_closefd:
chunhan
parents:
diff changeset
  2078
  "\<lbrakk>valid (CloseFd p fd # s); alive (CloseFd p fd # s) obj\<rbrakk> \<Longrightarrow> co2sobj (CloseFd p fd # s) obj = (
chunhan
parents:
diff changeset
  2079
      case obj of 
chunhan
parents:
diff changeset
  2080
        O_file f' \<Rightarrow> (case (file_of_proc_fd s p fd) of 
chunhan
parents:
diff changeset
  2081
                        Some f \<Rightarrow> (if (f' \<in> same_inode_files s f \<and> proc_fd_of_file s f = {(p, fd)} \<and>
chunhan
parents:
diff changeset
  2082
                                       f \<in> files_hung_by_del s \<and> (\<forall> f'' \<in> same_inode_files s f. 
chunhan
parents:
diff changeset
  2083
                                       f'' \<noteq> f \<longrightarrow> cf2sfile s f'' \<noteq> cf2sfile s f))
chunhan
parents:
diff changeset
  2084
                                   then (case (cf2sfile s f, co2sobj s (O_file f')) of
chunhan
parents:
diff changeset
  2085
                                           (Some sf, Some (S_file sfs b)) \<Rightarrow> Some (S_file (sfs - {sf}) b)
chunhan
parents:
diff changeset
  2086
                                         | _                              \<Rightarrow> None)
chunhan
parents:
diff changeset
  2087
                                   else co2sobj s obj)
chunhan
parents:
diff changeset
  2088
                     | _       \<Rightarrow> co2sobj s obj)
chunhan
parents:
diff changeset
  2089
      | O_proc p' \<Rightarrow> (if (p = p') 
chunhan
parents:
diff changeset
  2090
                      then (case (cp2sproc (CloseFd p fd # s) p) of
chunhan
parents:
diff changeset
  2091
                              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  2092
                            | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2093
                      else co2sobj s obj)
chunhan
parents:
diff changeset
  2094
      | _         \<Rightarrow> co2sobj s obj) "
chunhan
parents:
diff changeset
  2095
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2096
apply (simp_all add:current_files_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2097
apply (auto simp:cp2sproc_simps cf2sfiles_simps split:option.splits if_splits
chunhan
parents:
diff changeset
  2098
           dest!:current_proc_has_sp') [1](* intro:info_flow_shm_tainted)[1] *)
chunhan
parents:
diff changeset
  2099
chunhan
parents:
diff changeset
  2100
apply (frule is_file_in_current)
chunhan
parents:
diff changeset
  2101
apply (case_tac "file_of_proc_fd s p fd")
chunhan
parents:
diff changeset
  2102
apply (simp)
chunhan
parents:
diff changeset
  2103
apply (drule_tac f' = list in cf2sfiles_closefd, simp add:current_files_closefd, simp)
chunhan
parents:
diff changeset
  2104
apply (frule_tac f' = list in cf2sfiles_closefd, simp)
chunhan
parents:
diff changeset
  2105
apply (simp add:is_file_simps current_files_simps)
chunhan
parents:
diff changeset
  2106
apply (auto simp add: cf2sfile_closefd split:if_splits option.splits
chunhan
parents:
diff changeset
  2107
  dest!:current_file_has_sfile' dest:hung_file_in_current)[1]
chunhan
parents:
diff changeset
  2108
chunhan
parents:
diff changeset
  2109
apply (simp add:is_dir_simps, frule is_dir_in_current)
chunhan
parents:
diff changeset
  2110
apply (frule_tac f = list in cf2sfile_closefd)
chunhan
parents:
diff changeset
  2111
apply (clarsimp simp:current_files_closefd split:option.splits)
chunhan
parents:
diff changeset
  2112
apply (drule file_of_pfd_is_file', simp+)
chunhan
parents:
diff changeset
  2113
done
chunhan
parents:
diff changeset
  2114
chunhan
parents:
diff changeset
  2115
lemma co2sobj_unlink:
chunhan
parents:
diff changeset
  2116
  "\<lbrakk>valid (UnLink p f # s); alive (UnLink p f # s) obj\<rbrakk> \<Longrightarrow> co2sobj (UnLink p f # s) obj = (
chunhan
parents:
diff changeset
  2117
      case obj of
chunhan
parents:
diff changeset
  2118
        O_file f' \<Rightarrow> if (f' \<in> same_inode_files s f \<and> proc_fd_of_file s f = {} \<and> 
chunhan
parents:
diff changeset
  2119
                        (\<forall> f'' \<in> same_inode_files s f. f'' \<noteq> f \<longrightarrow> cf2sfile s f'' \<noteq> cf2sfile s f))
chunhan
parents:
diff changeset
  2120
                     then (case (cf2sfile s f, co2sobj s (O_file f')) of
chunhan
parents:
diff changeset
  2121
                             (Some sf, Some (S_file sfs b)) \<Rightarrow> Some (S_file (sfs - {sf}) b)
chunhan
parents:
diff changeset
  2122
                           | _                              \<Rightarrow> None)
chunhan
parents:
diff changeset
  2123
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2124
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2125
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2126
apply (simp_all add:current_files_simps cq2smsgq_other) (* ch2sshm_other*)
chunhan
parents:
diff changeset
  2127
apply (auto simp:cp2sproc_simps split:option.splits if_splits
chunhan
parents:
diff changeset
  2128
           dest!:current_proc_has_sp')[1] (* intro:info_flow_shm_tainted) *)
chunhan
parents:
diff changeset
  2129
apply (frule is_file_in_current)
chunhan
parents:
diff changeset
  2130
apply (frule_tac f' = list in cf2sfile_unlink, simp)
chunhan
parents:
diff changeset
  2131
apply (frule_tac f' = list in cf2sfiles_unlink, simp)
chunhan
parents:
diff changeset
  2132
apply (simp add:is_file_simps current_files_simps)
chunhan
parents:
diff changeset
  2133
apply (auto simp add: is_file_in_current split:if_splits option.splits
chunhan
parents:
diff changeset
  2134
  dest!:current_file_has_sfile')[1]
chunhan
parents:
diff changeset
  2135
chunhan
parents:
diff changeset
  2136
apply (simp add:is_dir_simps, frule is_dir_in_current)
chunhan
parents:
diff changeset
  2137
apply (frule_tac f' = list in cf2sfile_unlink)
chunhan
parents:
diff changeset
  2138
apply (clarsimp simp:current_files_unlink split:option.splits)
chunhan
parents:
diff changeset
  2139
apply (drule file_dir_conflict, simp+)
chunhan
parents:
diff changeset
  2140
done
chunhan
parents:
diff changeset
  2141
chunhan
parents:
diff changeset
  2142
lemma co2sobj_rmdir:
chunhan
parents:
diff changeset
  2143
  "\<lbrakk>valid (Rmdir p f # s); alive (Rmdir p f # s) obj\<rbrakk> \<Longrightarrow> co2sobj (Rmdir p f # s) obj = co2sobj s obj"
chunhan
parents:
diff changeset
  2144
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2145
apply (simp_all add:current_files_simps cq2smsgq_other) (* ch2sshm_other*)
chunhan
parents:
diff changeset
  2146
apply (auto simp:cp2sproc_simps split:option.splits if_splits
chunhan
parents:
diff changeset
  2147
           dest!:current_proc_has_sp')[1] (* intro:info_flow_shm_tainted*)
chunhan
parents:
diff changeset
  2148
apply (simp add:is_file_simps dir_is_empty_def)
chunhan
parents:
diff changeset
  2149
apply (case_tac "f = list", drule file_dir_conflict, simp, simp)
chunhan
parents:
diff changeset
  2150
apply (simp add:cf2sfiles_other)
chunhan
parents:
diff changeset
  2151
apply (auto simp:cf2sfile_simps dest:is_dir_in_current)
chunhan
parents:
diff changeset
  2152
done
chunhan
parents:
diff changeset
  2153
chunhan
parents:
diff changeset
  2154
lemma co2sobj_mkdir:
chunhan
parents:
diff changeset
  2155
  "\<lbrakk>valid (Mkdir p f i # s); alive (Mkdir p f i # s) obj\<rbrakk> \<Longrightarrow> co2sobj (Mkdir p f i # s) obj = (
chunhan
parents:
diff changeset
  2156
      if (obj = O_dir f) 
chunhan
parents:
diff changeset
  2157
      then (case (cf2sfile (Mkdir p f i # s) f) of 
chunhan
parents:
diff changeset
  2158
              Some sf \<Rightarrow> Some (S_dir sf)
chunhan
parents:
diff changeset
  2159
            | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2160
      else co2sobj s obj)"
chunhan
parents:
diff changeset
  2161
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2162
apply (simp_all add:current_files_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2163
apply (auto simp:cp2sproc_simps split:option.splits if_splits
chunhan
parents:
diff changeset
  2164
           dest!:current_proc_has_sp')[1] (* intro:info_flow_shm_tainted *)
chunhan
parents:
diff changeset
  2165
apply (frule_tac cf2sfiles_other, simp+)
chunhan
parents:
diff changeset
  2166
apply (frule is_dir_in_current, rule impI, simp add:current_files_mkdir)
chunhan
parents:
diff changeset
  2167
apply (frule current_file_has_sfile, simp, erule exE, simp)
chunhan
parents:
diff changeset
  2168
apply (drule cf2sfile_mkdir1, simp+)
chunhan
parents:
diff changeset
  2169
done
chunhan
parents:
diff changeset
  2170
chunhan
parents:
diff changeset
  2171
lemma co2sobj_linkhard:
chunhan
parents:
diff changeset
  2172
  "\<lbrakk>valid (LinkHard p oldf f # s); alive (LinkHard p oldf f # s) obj\<rbrakk> 
chunhan
parents:
diff changeset
  2173
   \<Longrightarrow> co2sobj (LinkHard p oldf f # s) obj = (
chunhan
parents:
diff changeset
  2174
    case obj of
chunhan
parents:
diff changeset
  2175
      O_file f' \<Rightarrow> if (f' = f \<or> f' \<in> same_inode_files s oldf)
chunhan
parents:
diff changeset
  2176
                   then (case (cf2sfile (LinkHard p oldf f # s) f) of
chunhan
parents:
diff changeset
  2177
                           Some sf \<Rightarrow> Some (S_file (cf2sfiles s oldf \<union> {sf}) (O_file oldf \<in> tainted s))
chunhan
parents:
diff changeset
  2178
                         | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2179
                   else co2sobj s obj
chunhan
parents:
diff changeset
  2180
    | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2181
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2182
apply (simp_all add:current_files_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2183
apply (auto simp:cp2sproc_simps split:option.splits if_splits
chunhan
parents:
diff changeset
  2184
           dest!:current_proc_has_sp')[1] (* intro:info_flow_shm_tainted *)
chunhan
parents:
diff changeset
  2185
apply (frule_tac cf2sfiles_linkhard, simp+)
chunhan
parents:
diff changeset
  2186
apply (frule_tac f' = f in cf2sfile_linkhard, simp add:current_files_linkhard)
chunhan
parents:
diff changeset
  2187
apply (auto simp:is_file_simps sectxt_of_obj_simps current_files_simps is_file_in_current same_inodes_tainted
chunhan
parents:
diff changeset
  2188
  split:option.splits if_splits dest:tainted_in_current 
chunhan
parents:
diff changeset
  2189
  dest!:current_has_sec' current_file_has_sfile')[1]
chunhan
parents:
diff changeset
  2190
chunhan
parents:
diff changeset
  2191
apply (frule is_dir_in_current, simp add:current_files_linkhard is_dir_simps is_dir_in_current)
chunhan
parents:
diff changeset
  2192
apply (frule is_dir_in_current)
chunhan
parents:
diff changeset
  2193
apply (frule current_file_has_sfile, simp)
chunhan
parents:
diff changeset
  2194
apply (drule cf2sfile_linkhard1, simp+)
chunhan
parents:
diff changeset
  2195
done
chunhan
parents:
diff changeset
  2196
chunhan
parents:
diff changeset
  2197
lemma co2sobj_truncate:
chunhan
parents:
diff changeset
  2198
  "\<lbrakk>valid (Truncate p f len # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Truncate p f len # s) obj = (
chunhan
parents:
diff changeset
  2199
      case obj of
chunhan
parents:
diff changeset
  2200
        O_file f' \<Rightarrow> if (f' \<in> same_inode_files s f \<and> len > 0)
chunhan
parents:
diff changeset
  2201
                     then Some (S_file (cf2sfiles s f') (O_file f' \<in> tainted s \<or> O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  2202
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2203
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2204
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2205
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2206
chunhan
parents:
diff changeset
  2207
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2208
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2209
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2210
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2211
done
chunhan
parents:
diff changeset
  2212
chunhan
parents:
diff changeset
  2213
lemma co2sobj_kill:
chunhan
parents:
diff changeset
  2214
  "\<lbrakk>valid (Kill p p' # s); alive (Kill p p' # s) obj\<rbrakk> \<Longrightarrow> co2sobj (Kill p p' # s) obj = co2sobj s obj"
chunhan
parents:
diff changeset
  2215
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2216
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other) (* ch2sshm_other *)
chunhan
parents:
diff changeset
  2217
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2218
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps 
chunhan
parents:
diff changeset
  2219
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2220
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2221
done
chunhan
parents:
diff changeset
  2222
chunhan
parents:
diff changeset
  2223
lemma co2sobj_exit:
chunhan
parents:
diff changeset
  2224
  "\<lbrakk>valid (Exit p # s); alive (Exit p # s) obj\<rbrakk> \<Longrightarrow> co2sobj (Exit p # s) obj = co2sobj s obj"
chunhan
parents:
diff changeset
  2225
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2226
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2227
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2228
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2229
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2230
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2231
done
chunhan
parents:
diff changeset
  2232
chunhan
parents:
diff changeset
  2233
lemma co2sobj_createmsgq:
chunhan
parents:
diff changeset
  2234
  "\<lbrakk>valid (CreateMsgq p q # s); alive (CreateMsgq p q # s) obj\<rbrakk> \<Longrightarrow> co2sobj (CreateMsgq p q # s) obj = (
chunhan
parents:
diff changeset
  2235
      case obj of
chunhan
parents:
diff changeset
  2236
        O_msgq q' \<Rightarrow> if (q' = q) then (case (cq2smsgq (CreateMsgq p q # s) q) of
chunhan
parents:
diff changeset
  2237
                                         Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents:
diff changeset
  2238
                                       | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2239
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2240
      | _        \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2241
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2242
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2243
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2244
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2245
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2246
             dest!:current_has_smsgq'
chunhan
parents:
diff changeset
  2247
             dest:is_file_in_current is_dir_in_current cq2smsg_createmsgq)
chunhan
parents:
diff changeset
  2248
done
chunhan
parents:
diff changeset
  2249
chunhan
parents:
diff changeset
  2250
lemma co2sobj_sendmsg:
chunhan
parents:
diff changeset
  2251
  "\<lbrakk>valid (SendMsg p q m # s); alive (SendMsg p q m # s) obj\<rbrakk> \<Longrightarrow> co2sobj (SendMsg p q m # s) obj = (
chunhan
parents:
diff changeset
  2252
      case obj of
chunhan
parents:
diff changeset
  2253
        O_msgq q' \<Rightarrow> if (q' = q) then (case (cq2smsgq (SendMsg p q m # s) q) of
chunhan
parents:
diff changeset
  2254
                                         Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents:
diff changeset
  2255
                                       | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2256
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2257
      | _        \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2258
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2259
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2260
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2261
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2262
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2263
             dest!:current_has_smsgq'
chunhan
parents:
diff changeset
  2264
             dest:is_file_in_current is_dir_in_current cq2smsg_sendmsg)
chunhan
parents:
diff changeset
  2265
done
chunhan
parents:
diff changeset
  2266
chunhan
parents:
diff changeset
  2267
lemma co2sobj_recvmsg:
chunhan
parents:
diff changeset
  2268
  "\<lbrakk>valid (RecvMsg p q m # s); alive (RecvMsg p q m # s) obj\<rbrakk> \<Longrightarrow> co2sobj (RecvMsg p q m # s) obj = (
chunhan
parents:
diff changeset
  2269
      case obj of
chunhan
parents:
diff changeset
  2270
        O_msgq q' \<Rightarrow> if (q' = q) then (case (cq2smsgq (RecvMsg p q m # s) q) of
chunhan
parents:
diff changeset
  2271
                                         Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents:
diff changeset
  2272
                                       | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2273
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2274
      | O_proc p' \<Rightarrow> if (p' = p \<and> O_msg q m \<in> tainted s)
chunhan
parents:
diff changeset
  2275
                     then (case (cp2sproc s p') of
chunhan
parents:
diff changeset
  2276
                             Some sp \<Rightarrow> Some (S_proc sp True)
chunhan
parents:
diff changeset
  2277
                           | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2278
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2279
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2280
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2281
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2282
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2283
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2284
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2285
             dest!:current_has_smsgq'
chunhan
parents:
diff changeset
  2286
             dest:is_file_in_current is_dir_in_current cq2smsg_recvmsg)
chunhan
parents:
diff changeset
  2287
done
chunhan
parents:
diff changeset
  2288
(*
chunhan
parents:
diff changeset
  2289
lemma co2sobj_recvmsg:
chunhan
parents:
diff changeset
  2290
  "\<lbrakk>valid (RecvMsg p q m # s); alive (RecvMsg p q m # s) obj\<rbrakk> \<Longrightarrow> co2sobj (RecvMsg p q m # s) obj = (
chunhan
parents:
diff changeset
  2291
      case obj of
chunhan
parents:
diff changeset
  2292
        O_msgq q' \<Rightarrow> if (q' = q) then (case (cq2smsgq (RecvMsg p q m # s) q) of
chunhan
parents:
diff changeset
  2293
                                         Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents:
diff changeset
  2294
                                       | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2295
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2296
      | O_proc p' \<Rightarrow> if (info_flow_shm s p p' \<and> O_msg q m \<in> tainted s)
chunhan
parents:
diff changeset
  2297
                     then (case (cp2sproc s p') of
chunhan
parents:
diff changeset
  2298
                             Some sp \<Rightarrow> Some (S_proc sp True)
chunhan
parents:
diff changeset
  2299
                           | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2300
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2301
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2302
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2303
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2304
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2305
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2306
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2307
             dest!:current_has_smsgq'
chunhan
parents:
diff changeset
  2308
             dest:is_file_in_current is_dir_in_current cq2smsg_recvmsg)
chunhan
parents:
diff changeset
  2309
done
chunhan
parents:
diff changeset
  2310
*)
chunhan
parents:
diff changeset
  2311
chunhan
parents:
diff changeset
  2312
lemma co2sobj_removemsgq:
chunhan
parents:
diff changeset
  2313
  "\<lbrakk>valid (RemoveMsgq p q # s); alive (RemoveMsgq p q # s) obj\<rbrakk> 
chunhan
parents:
diff changeset
  2314
   \<Longrightarrow> co2sobj (RemoveMsgq p q # s) obj = co2sobj s obj"
chunhan
parents:
diff changeset
  2315
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2316
apply (simp_all add:current_files_simps is_dir_simps cq2smsgq_other)
chunhan
parents:
diff changeset
  2317
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2318
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps
chunhan
parents:
diff changeset
  2319
                  same_inode_files_prop6
chunhan
parents:
diff changeset
  2320
             dest!:current_has_smsgq'
chunhan
parents:
diff changeset
  2321
             dest:is_file_in_current is_dir_in_current cq2smsg_removemsgq)
chunhan
parents:
diff changeset
  2322
done
chunhan
parents:
diff changeset
  2323
chunhan
parents:
diff changeset
  2324
(*
chunhan
parents:
diff changeset
  2325
lemma co2sobj_createshm:
chunhan
parents:
diff changeset
  2326
  "\<lbrakk>valid (CreateShM p h # s); alive (CreateShM p h # s) obj\<rbrakk> \<Longrightarrow> co2sobj (CreateShM p h # s) obj = (
chunhan
parents:
diff changeset
  2327
      case obj of 
chunhan
parents:
diff changeset
  2328
        O_shm h' \<Rightarrow> if (h' = h) then (case (ch2sshm (CreateShM p h # s) h) of
chunhan
parents:
diff changeset
  2329
                                        Some sh \<Rightarrow> Some (S_shm sh)
chunhan
parents:
diff changeset
  2330
                                      | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2331
                    else co2sobj s obj
chunhan
parents:
diff changeset
  2332
      | _        \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2333
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2334
apply (simp_all add:current_files_simps is_dir_simps ch2sshm_other cq2smsgq_other)
chunhan
parents:
diff changeset
  2335
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2336
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps tainted_eq_tainted
chunhan
parents:
diff changeset
  2337
                  same_inode_files_prop6 ch2sshm_simps
chunhan
parents:
diff changeset
  2338
             dest!:current_shm_has_sh'
chunhan
parents:
diff changeset
  2339
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2340
done
chunhan
parents:
diff changeset
  2341
chunhan
parents:
diff changeset
  2342
lemma co2sobj_detach:
chunhan
parents:
diff changeset
  2343
  "\<lbrakk>valid (Detach p h # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Detach p h # s) obj = (
chunhan
parents:
diff changeset
  2344
      case obj of
chunhan
parents:
diff changeset
  2345
        O_proc p' \<Rightarrow> if (p' = p) then (case (cp2sproc (Detach p h # s) p) of
chunhan
parents:
diff changeset
  2346
                                         Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
  2347
                                       | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2348
                     else co2sobj s obj
chunhan
parents:
diff changeset
  2349
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2350
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2351
apply (simp_all add:current_files_simps is_dir_simps ch2sshm_other cq2smsgq_other)
chunhan
parents:
diff changeset
  2352
chunhan
parents:
diff changeset
  2353
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2354
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps cp2sproc_simps tainted_eq_tainted
chunhan
parents:
diff changeset
  2355
                  same_inode_files_prop6 ch2sshm_simps
chunhan
parents:
diff changeset
  2356
             dest!:current_shm_has_sh'
chunhan
parents:
diff changeset
  2357
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2358
done
chunhan
parents:
diff changeset
  2359
chunhan
parents:
diff changeset
  2360
lemma co2sobj_deleteshm:
chunhan
parents:
diff changeset
  2361
  "\<lbrakk>valid (DeleteShM p h # s); alive (DeleteShM p h # s) obj\<rbrakk> \<Longrightarrow> co2sobj (DeleteShM p h # s) obj = (
chunhan
parents:
diff changeset
  2362
      case obj of
chunhan
parents:
diff changeset
  2363
        O_proc p' \<Rightarrow> (case (cp2sproc (DeleteShM p h # s) p') of
chunhan
parents:
diff changeset
  2364
                        Some sp \<Rightarrow> Some (S_proc sp (O_proc p' \<in> tainted s))
chunhan
parents:
diff changeset
  2365
                      | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2366
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2367
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2368
apply (simp_all add:current_files_simps is_dir_simps ch2sshm_other cq2smsgq_other)
chunhan
parents:
diff changeset
  2369
chunhan
parents:
diff changeset
  2370
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' current_proc_has_sp'
chunhan
parents:
diff changeset
  2371
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps tainted_eq_tainted
chunhan
parents:
diff changeset
  2372
                  same_inode_files_prop6 ch2sshm_simps
chunhan
parents:
diff changeset
  2373
             dest!:current_shm_has_sh' 
chunhan
parents:
diff changeset
  2374
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2375
done
chunhan
parents:
diff changeset
  2376
*)
chunhan
parents:
diff changeset
  2377
chunhan
parents:
diff changeset
  2378
declare Product_Type.split_paired_Ex Product_Type.split_paired_All [simp del]
chunhan
parents:
diff changeset
  2379
chunhan
parents:
diff changeset
  2380
(*
chunhan
parents:
diff changeset
  2381
lemma info_flow_shm_prop1:
chunhan
parents:
diff changeset
  2382
  "p \<in> current_procs s \<Longrightarrow> info_flow_shm s p p"
chunhan
parents:
diff changeset
  2383
by (simp add:info_flow_shm_def)
chunhan
parents:
diff changeset
  2384
chunhan
parents:
diff changeset
  2385
lemma co2sobj_attach:
chunhan
parents:
diff changeset
  2386
  "\<lbrakk>valid (Attach p h flag # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Attach p h flag # s) obj = (
chunhan
parents:
diff changeset
  2387
      case obj of
chunhan
parents:
diff changeset
  2388
        O_proc p' \<Rightarrow> if (info_flow_shm s p p')
chunhan
parents:
diff changeset
  2389
                     then (case (cp2sproc (Attach p h flag # s) p') of
chunhan
parents:
diff changeset
  2390
                             Some sp \<Rightarrow> Some (S_proc sp (O_proc p' \<in> tainted s \<or> 
chunhan
parents:
diff changeset
  2391
              (\<exists> p''. O_proc p'' \<in> tainted s \<and> (p'', SHM_RDWR) \<in> procs_of_shm s h)))
chunhan
parents:
diff changeset
  2392
                           | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2393
                     else if (\<exists> p'' flag'. (p'', flag') \<in> procs_of_shm s h \<and> flag = SHM_RDWR \<and> O_proc p \<in> tainted s \<and>
chunhan
parents:
diff changeset
  2394
  info_flow_shm s p'' p')
chunhan
parents:
diff changeset
  2395
                          then (case (cp2sproc s p') of 
chunhan
parents:
diff changeset
  2396
                                  Some sp \<Rightarrow> Some (S_proc sp True)
chunhan
parents:
diff changeset
  2397
                                | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
  2398
                          else co2sobj s obj
chunhan
parents:
diff changeset
  2399
      | _         \<Rightarrow> co2sobj s obj)"
chunhan
parents:
diff changeset
  2400
apply (frule vt_grant_os, frule vd_cons, case_tac obj)
chunhan
parents:
diff changeset
  2401
apply (simp_all add:current_files_simps is_dir_simps ch2sshm_other cq2smsgq_other)
chunhan
parents:
diff changeset
  2402
chunhan
parents:
diff changeset
  2403
apply (rule conjI|rule impI|erule exE)+
chunhan
parents:
diff changeset
  2404
apply (simp split:option.splits del:split_paired_Ex)
chunhan
parents:
diff changeset
  2405
apply (rule impI, frule current_proc_has_sp, simp)
chunhan
parents:
diff changeset
  2406
apply ((erule exE)+, auto simp:tainted_eq_tainted intro:info_flow_shm_tainted)[1]
chunhan
parents:
diff changeset
  2407
apply (rule impI, simp add:tainted_eq_tainted split:option.splits del:split_paired_Ex)
chunhan
parents:
diff changeset
  2408
apply (auto simp:info_flow_shm_prop1 cp2sproc_attach dest!:current_proc_has_sp')[1]
chunhan
parents:
diff changeset
  2409
chunhan
parents:
diff changeset
  2410
apply (case_tac "cp2sproc (Attach p h flag # s) nat")
chunhan
parents:
diff changeset
  2411
apply (drule current_proc_has_sp', simp+)
chunhan
parents:
diff changeset
  2412
chunhan
parents:
diff changeset
  2413
apply (rule conjI|erule exE|erule conjE|rule impI)+
chunhan
parents:
diff changeset
  2414
apply (simp add:tainted_eq_tainted)
chunhan
parents:
diff changeset
  2415
apply (auto simp:info_flow_shm_prop1 cp2sproc_attach intro:info_flow_shm_tainted dest!:current_proc_has_sp')[1]
chunhan
parents:
diff changeset
  2416
apply (auto simp:info_flow_shm_prop1 cp2sproc_attach intro:info_flow_shm_tainted dest!:current_proc_has_sp'
chunhan
parents:
diff changeset
  2417
split:option.splits if_splits)[1]
chunhan
parents:
diff changeset
  2418
chunhan
parents:
diff changeset
  2419
chunhan
parents:
diff changeset
  2420
apply (auto split:if_splits option.splits dest!:current_file_has_sfile' 
chunhan
parents:
diff changeset
  2421
             simp:current_files_simps cf2sfiles_simps cf2sfile_simps tainted_eq_tainted
chunhan
parents:
diff changeset
  2422
                  same_inode_files_prop6 
chunhan
parents:
diff changeset
  2423
             dest:is_file_in_current is_dir_in_current)
chunhan
parents:
diff changeset
  2424
done
chunhan
parents:
diff changeset
  2425
*)
chunhan
parents:
diff changeset
  2426
chunhan
parents:
diff changeset
  2427
lemma co2sobj_other:
chunhan
parents:
diff changeset
  2428
  "\<lbrakk>valid (e # s); alive (e # s) obj; 
chunhan
parents:
diff changeset
  2429
    \<forall> p f fds. e \<noteq> Execve p f fds;
chunhan
parents:
diff changeset
  2430
    \<forall> p p' fds. e \<noteq> Clone p p' fds;
chunhan
parents:
diff changeset
  2431
    \<forall> p p'. e \<noteq> Ptrace p p';
chunhan
parents:
diff changeset
  2432
    \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
chunhan
parents:
diff changeset
  2433
    \<forall> p fd. e \<noteq> ReadFile p fd;
chunhan
parents:
diff changeset
  2434
    \<forall> p fd. e \<noteq> WriteFile p fd;
chunhan
parents:
diff changeset
  2435
    \<forall> p fd. e \<noteq> CloseFd p fd;
chunhan
parents:
diff changeset
  2436
    \<forall> p f. e \<noteq> UnLink p f;
chunhan
parents:
diff changeset
  2437
    \<forall> p f. e \<noteq> Rmdir p f;
chunhan
parents:
diff changeset
  2438
    \<forall> p f i. e \<noteq> Mkdir p f i;
chunhan
parents:
diff changeset
  2439
    \<forall> p f f'. e \<noteq> LinkHard p f f';
chunhan
parents:
diff changeset
  2440
    \<forall> p f len. e \<noteq> Truncate p f len;
chunhan
parents:
diff changeset
  2441
    \<forall> p q. e \<noteq> CreateMsgq p q;
chunhan
parents:
diff changeset
  2442
    \<forall> p q m. e \<noteq> SendMsg p q m;
chunhan
parents:
diff changeset
  2443
    \<forall> p q m. e \<noteq> RecvMsg p q m;
chunhan
parents:
diff changeset
  2444
    \<forall> p q. e \<noteq> RemoveMsgq p q
chunhan
parents:
diff changeset
  2445
   \<rbrakk> \<Longrightarrow> co2sobj (e # s) obj = co2sobj s obj" (*;
chunhan
parents:
diff changeset
  2446
    \<forall> p h flag. e \<noteq> Attach p h flag;
chunhan
parents:
diff changeset
  2447
    \<forall> p h. e \<noteq> Detach p h;
chunhan
parents:
diff changeset
  2448
    \<forall> p h. e \<noteq> DeleteShM p h*)
chunhan
parents:
diff changeset
  2449
apply (frule vt_grant, case_tac e)
chunhan
parents:
diff changeset
  2450
apply (auto intro:co2sobj_kill co2sobj_exit)
chunhan
parents:
diff changeset
  2451
done
chunhan
parents:
diff changeset
  2452
chunhan
parents:
diff changeset
  2453
lemmas co2sobj_simps = co2sobj_execve co2sobj_clone co2sobj_ptrace co2sobj_open co2sobj_readfile
chunhan
parents:
diff changeset
  2454
  co2sobj_writefile co2sobj_closefd co2sobj_unlink co2sobj_rmdir co2sobj_mkdir co2sobj_linkhard
chunhan
parents:
diff changeset
  2455
  co2sobj_truncate co2sobj_kill co2sobj_exit co2sobj_createmsgq co2sobj_sendmsg co2sobj_recvmsg
chunhan
parents:
diff changeset
  2456
  co2sobj_removemsgq (* co2sobj_attach co2sobj_detach co2sobj_createshm co2sobj_deleteshm *)
chunhan
parents:
diff changeset
  2457
chunhan
parents:
diff changeset
  2458
chunhan
parents:
diff changeset
  2459
chunhan
parents:
diff changeset
  2460
end
chunhan
parents:
diff changeset
  2461
chunhan
parents:
diff changeset
  2462
(*<*)
chunhan
parents:
diff changeset
  2463
end
chunhan
parents:
diff changeset
  2464
(*>*)