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