del_vs_del_s.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 06 Sep 2013 14:55:53 +0100
changeset 15 baa2970a9687
parent 6 4294abb1f38c
child 21 17ea9ad46257
permissions -rw-r--r--
some small changes according to the reviews
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
dcde836219bc add thy files
chunhan
parents:
diff changeset
     1
theory del_vs_del_s
dcde836219bc add thy files
chunhan
parents:
diff changeset
     2
imports Main rc_theory os_rc obj2sobj_prop all_sobj_prop 
dcde836219bc add thy files
chunhan
parents:
diff changeset
     3
begin
dcde836219bc add thy files
chunhan
parents:
diff changeset
     4
dcde836219bc add thy files
chunhan
parents:
diff changeset
     5
context tainting_s_complete begin
dcde836219bc add thy files
chunhan
parents:
diff changeset
     6
dcde836219bc add thy files
chunhan
parents:
diff changeset
     7
lemma deleted_has_del_event_proc:
dcde836219bc add thy files
chunhan
parents:
diff changeset
     8
  "\<lbrakk>deleted (Proc p) s; valid s\<rbrakk> \<Longrightarrow> \<exists> s' p'. Kill p' p # s' \<preceq> s \<and> \<not> deleted (Proc p) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
     9
apply (induct s, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    10
apply (frule valid_cons, frule valid_os)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    11
by (case_tac a, auto simp:no_junior_def)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    12
dcde836219bc add thy files
chunhan
parents:
diff changeset
    13
lemma deleted_has_del_event_ipc:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    14
  "\<lbrakk>deleted (IPC i) s; valid s\<rbrakk> \<Longrightarrow> \<exists> s' p. DeleteIPC p i # s' \<preceq> s \<and> \<not> deleted (IPC i) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    15
apply (induct s, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    16
apply (frule valid_cons, frule valid_os)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    17
by (case_tac a, auto simp:no_junior_def)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    18
dcde836219bc add thy files
chunhan
parents:
diff changeset
    19
lemma deleted_has_del_event_file:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    20
  "\<lbrakk>deleted (File f) s; valid s\<rbrakk> \<Longrightarrow> \<exists> s' p. DeleteFile p f # s' \<preceq> s \<and> \<not> deleted (File f) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    21
apply (induct s, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    22
apply (frule valid_cons, frule valid_os)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    23
by (case_tac a, auto simp:no_junior_def)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    24
dcde836219bc add thy files
chunhan
parents:
diff changeset
    25
(*
dcde836219bc add thy files
chunhan
parents:
diff changeset
    26
lemma noJ_Anc: "x \<prec> y = (x \<preceq> y \<and> x \<noteq> y)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    27
apply (simp add: no_junior_expand)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    28
by (auto simp:is_ancestor_def)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    29
dcde836219bc add thy files
chunhan
parents:
diff changeset
    30
lemma noJ_Anc': "x \<prec> y \<Longrightarrow> (x \<preceq> y \<and> x \<noteq> y)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    31
by (simp add:noJ_Anc)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    32
dcde836219bc add thy files
chunhan
parents:
diff changeset
    33
lemma noJ_Anc'': "\<lbrakk>x \<preceq> y; x \<noteq> y\<rbrakk> \<Longrightarrow> x \<prec> y"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    34
by (simp add:noJ_Anc)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    35
dcde836219bc add thy files
chunhan
parents:
diff changeset
    36
lemma deled_imp_no_childfs:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    37
  "\<lbrakk>valid (DeleteFile p f # s); f \<prec> childf\<rbrakk> \<Longrightarrow> childf \<notin> current_files s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    38
apply (frule valid_cons, drule valid_os, rule notI, clarsimp dest!:noJ_Anc')
dcde836219bc add thy files
chunhan
parents:
diff changeset
    39
apply (drule ancient_has_parent, simp, clarsimp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    40
apply (drule_tac af = sonf and f = childf in ancient_file_in_current, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    41
apply (case_tac sonf, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    42
apply (erule_tac x = a in allE, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    43
done
dcde836219bc add thy files
chunhan
parents:
diff changeset
    44
dcde836219bc add thy files
chunhan
parents:
diff changeset
    45
lemma deled_imp_childfs_deleted:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    46
  "\<lbrakk>valid (DeleteFile p f # s); f \<prec> childf; childf \<in> init_files\<rbrakk>
dcde836219bc add thy files
chunhan
parents:
diff changeset
    47
  \<Longrightarrow> deleted (File childf) s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    48
apply (drule deled_imp_no_childfs, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    49
apply (erule_tac P = "childf \<in> current_files s" in swap)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    50
by (drule not_deleted_imp_exists, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    51
dcde836219bc add thy files
chunhan
parents:
diff changeset
    52
lemma initf_deled_imp_childf_deled:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    53
  "\<lbrakk>deleted (File f) s; valid s\<rbrakk> \<Longrightarrow> \<exists> s' p. DeleteFile p f # s' \<preceq> s \<and> \<not> deleted (File f) s' \<and> (\<forall> childf \<in> init_files. f \<prec> childf \<longrightarrow> deleted (File childf) s')"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    54
apply (drule deleted_has_del_event_file, simp, clarify)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    55
apply (rule_tac x = s' in exI, rule_tac x = p in exI, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    56
apply (rule ballI, rule impI, frule vs_history, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    57
by (erule deled_imp_childfs_deleted, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    58
dcde836219bc add thy files
chunhan
parents:
diff changeset
    59
lemma initf_deled_imp_childf_deled:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    60
  "\<lbrakk>deleted (File f) s; valid s; f \<prec> childf; childf \<in> init_files\<rbrakk> 
dcde836219bc add thy files
chunhan
parents:
diff changeset
    61
  \<Longrightarrow> \<exists> s'. s' \<preceq> s \<and> valid s' \<and> deleted (File childf) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    62
apply (drule deleted_has_del_event_file, simp, clarify)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    63
apply (frule vs_history, simp, frule valid_cons)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    64
apply (drule deled_imp_childfs_deleted, simp, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    65
apply (rule_tac x = s' in exI, auto elim:no_juniorE)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    66
done
dcde836219bc add thy files
chunhan
parents:
diff changeset
    67
dcde836219bc add thy files
chunhan
parents:
diff changeset
    68
lemma deleted_has_del_event_allchildf:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    69
  "\<lbrakk>deleted (File f) s; valid s; f \<preceq> childf; childf \<in> init_files\<rbrakk>
dcde836219bc add thy files
chunhan
parents:
diff changeset
    70
  \<Longrightarrow> \<exists> s' p. DeleteFile p childf # s' \<preceq> s \<and> \<not> deleted (File childf) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    71
apply (case_tac "f = childf")
dcde836219bc add thy files
chunhan
parents:
diff changeset
    72
apply (drule deleted_has_del_event_file, simp, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    73
apply (drule noJ_Anc'', simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    74
apply (drule initf_deled_imp_childf_deled, simp+, clarify)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    75
apply (drule deleted_has_del_event_file, simp+, clarify)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    76
apply (rule_tac x = s'a in exI, rule conjI, rule_tac x = p in exI)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    77
apply (erule no_junior_trans, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    78
done
dcde836219bc add thy files
chunhan
parents:
diff changeset
    79
*)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    80
dcde836219bc add thy files
chunhan
parents:
diff changeset
    81
lemma del_imp_del_s_file:
dcde836219bc add thy files
chunhan
parents:
diff changeset
    82
  assumes initf: "f \<in> init_files"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    83
  and deled: "deleted (File f) s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    84
  and vs: "valid s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    85
  shows "file_deletable_s f"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    86
proof -
dcde836219bc add thy files
chunhan
parents:
diff changeset
    87
  from deled vs obtain s' p' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
    88
    his: "DeleteFile p' f # s' \<preceq> s" and fstdel: "\<not> deleted (File f) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    89
    by (drule_tac deleted_has_del_event_file, auto)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    90
  from his vs have "valid (DeleteFile p' f # s')" by (simp add:vs_history)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    91
  hence exp': "p' \<in> current_procs s'" and exf: "f \<in> current_files s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    92
    and rc: "rc_grant s' (DeleteFile p' f)" and vs': "valid s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    93
    by (auto dest:valid_os valid_rc valid_cons)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    94
dcde836219bc add thy files
chunhan
parents:
diff changeset
    95
  from initf obtain t where etype: "etype_of_file [] f = Some t"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    96
    by (drule_tac init_file_has_etype, simp add:etype_of_file_def, blast)
dcde836219bc add thy files
chunhan
parents:
diff changeset
    97
  from initf have sd: "source_dir [] f = Some f"
dcde836219bc add thy files
chunhan
parents:
diff changeset
    98
    by (simp add:source_dir_of_init') 
dcde836219bc add thy files
chunhan
parents:
diff changeset
    99
  hence "obj2sobj [] (File f) = SFile (t, f) (Some f)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   100
    using etype initf by (auto simp:obj2sobj.simps)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   101
  with fstdel vs' initf exf etype
dcde836219bc add thy files
chunhan
parents:
diff changeset
   102
  have SF: "obj2sobj s' (File f) = SFile (t, f) (Some f)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   103
    using obj2sobj_file_remains'''[where s = "[]" and s' = s']
dcde836219bc add thy files
chunhan
parents:
diff changeset
   104
    by (auto simp:obj2sobj.simps)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   105
dcde836219bc add thy files
chunhan
parents:
diff changeset
   106
  from exp' vs' obtain r' fr' pt' u' srp' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
   107
    SP': "obj2sobj s' (Proc p') = SProc (r',fr',pt',u') srp'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   108
    by (frule_tac current_proc_has_sobj, simp, blast)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   109
  with exp' vs' all_sobjs_I[where s = s' and obj = "Proc p'"]
dcde836219bc add thy files
chunhan
parents:
diff changeset
   110
  have SP'_in: "SProc (r',fr',pt',u') srp' \<in> all_sobjs" by simp
dcde836219bc add thy files
chunhan
parents:
diff changeset
   111
dcde836219bc add thy files
chunhan
parents:
diff changeset
   112
  show ?thesis unfolding file_deletable_s_def
dcde836219bc add thy files
chunhan
parents:
diff changeset
   113
    apply (rule_tac x = t in exI, 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   114
           rule_tac x = "(r',fr',pt',u')" in exI,
dcde836219bc add thy files
chunhan
parents:
diff changeset
   115
           rule_tac x = srp' in exI)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   116
    apply (simp add:SP'_in) 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   117
    using rc SP' SF etype
dcde836219bc add thy files
chunhan
parents:
diff changeset
   118
    by (auto simp:obj2sobj.simps cp2sproc.simps split:option.splits if_splits)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   119
qed
dcde836219bc add thy files
chunhan
parents:
diff changeset
   120
dcde836219bc add thy files
chunhan
parents:
diff changeset
   121
lemma del_imp_del_s_proc:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   122
  assumes initp: "p \<in> init_processes"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   123
  and deled: "deleted (Proc p) s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   124
  and vs: "valid s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   125
  shows "proc_deletable_s p"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   126
proof-
dcde836219bc add thy files
chunhan
parents:
diff changeset
   127
  from deled vs obtain s' p' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
   128
    his: "Kill p' p # s' \<preceq> s" and fstdel: "\<not> deleted (Proc p) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   129
    by (drule_tac deleted_has_del_event_proc, auto)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   130
  from his vs have "valid (Kill p' p # s')" by (simp add:vs_history)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   131
  hence exp': "p' \<in> current_procs s'" and exp: "p \<in> current_procs s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   132
    and rc: "rc_grant s' (Kill p' p)" and vs': "valid s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   133
    by (auto dest:valid_os valid_rc valid_cons)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   134
dcde836219bc add thy files
chunhan
parents:
diff changeset
   135
  from initp fstdel vs' have "source_proc s' p = Some p"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   136
    apply (induct s', simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   137
    apply (frule valid_cons, frule valid_os, frule not_deleted_cons_D, simp)
6
4294abb1f38c update scripts with no new_* in admissable-check
chunhan
parents: 1
diff changeset
   138
    by (case_tac a, auto dest:not_deleted_imp_exists)
1
dcde836219bc add thy files
chunhan
parents:
diff changeset
   139
  with exp initp vs' obtain r fr pt u 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   140
    where SP: "obj2sobj s' (Proc p) = SProc (r,fr,pt,u) (Some p)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   141
    apply (frule_tac current_proc_has_sobj, simp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   142
    by (simp add:obj2sobj.simps split:option.splits, blast)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   143
  with exp vs' all_sobjs_I[where s = s' and obj = "Proc p"]
dcde836219bc add thy files
chunhan
parents:
diff changeset
   144
  have SP_in: "SProc (r,fr,pt,u) (Some p) \<in> all_sobjs" by simp
dcde836219bc add thy files
chunhan
parents:
diff changeset
   145
dcde836219bc add thy files
chunhan
parents:
diff changeset
   146
  from exp' vs' obtain r' fr' pt' u' srp' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
   147
    SP': "obj2sobj s' (Proc p') = SProc (r',fr',pt',u') srp'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   148
    by (frule_tac current_proc_has_sobj, simp, blast)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   149
  with exp' vs' all_sobjs_I[where s = s' and obj = "Proc p'"]
dcde836219bc add thy files
chunhan
parents:
diff changeset
   150
  have SP'_in: "SProc (r',fr',pt',u') srp' \<in> all_sobjs" by simp
dcde836219bc add thy files
chunhan
parents:
diff changeset
   151
dcde836219bc add thy files
chunhan
parents:
diff changeset
   152
  show ?thesis unfolding proc_deletable_s_def
dcde836219bc add thy files
chunhan
parents:
diff changeset
   153
    apply (rule_tac x = r in exI, rule_tac x = fr in exI,
dcde836219bc add thy files
chunhan
parents:
diff changeset
   154
           rule_tac x = pt in exI, rule_tac x = u in exI,
dcde836219bc add thy files
chunhan
parents:
diff changeset
   155
           rule_tac x = "(r',fr',pt',u')" in exI,
dcde836219bc add thy files
chunhan
parents:
diff changeset
   156
           rule_tac x = srp' in exI)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   157
    apply (simp add:SP_in SP'_in) 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   158
    using rc SP SP'
dcde836219bc add thy files
chunhan
parents:
diff changeset
   159
    by (auto simp:obj2sobj.simps cp2sproc.simps split:option.splits)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   160
qed
dcde836219bc add thy files
chunhan
parents:
diff changeset
   161
    
dcde836219bc add thy files
chunhan
parents:
diff changeset
   162
lemma del_imp_del_s_ipc:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   163
  assumes initi: "i \<in> init_ipcs"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   164
  and deled: "deleted (IPC i) s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   165
  and vs: "valid s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   166
  shows "ipc_deletable_s i"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   167
proof-
dcde836219bc add thy files
chunhan
parents:
diff changeset
   168
  from deled vs obtain s' p' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
   169
    his: "DeleteIPC p' i # s' \<preceq> s" and fstdel: "\<not> deleted (IPC i) s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   170
    by (drule_tac deleted_has_del_event_ipc, auto)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   171
  from his vs have "valid (DeleteIPC p' i # s')" by (simp add:vs_history)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   172
  hence exp': "p' \<in> current_procs s'" and exi: "i \<in> current_ipcs s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   173
    and rc: "rc_grant s' (DeleteIPC p' i)" and vs': "valid s'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   174
    by (auto dest:valid_os valid_rc valid_cons)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   175
dcde836219bc add thy files
chunhan
parents:
diff changeset
   176
  from initi obtain t where type: "init_ipc_type i = Some t" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   177
    using init_ipc_has_type by (auto simp:bidirect_in_init_def)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   178
  with fstdel vs' initi exi have SI: "obj2sobj s' (IPC i) = SIPC t (Some i)"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   179
    using obj2sobj_ipc_remains'''[where s = "[]" and s' = s']
dcde836219bc add thy files
chunhan
parents:
diff changeset
   180
    by (auto simp:obj2sobj.simps)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   181
dcde836219bc add thy files
chunhan
parents:
diff changeset
   182
  from exp' vs' obtain r' fr' pt' u' srp' where
dcde836219bc add thy files
chunhan
parents:
diff changeset
   183
    SP': "obj2sobj s' (Proc p') = SProc (r',fr',pt',u') srp'"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   184
    by (frule_tac current_proc_has_sobj, simp, blast)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   185
  with exp' vs' all_sobjs_I[where s = s' and obj = "Proc p'"]
dcde836219bc add thy files
chunhan
parents:
diff changeset
   186
  have SP'_in: "SProc (r',fr',pt',u') srp' \<in> all_sobjs" by simp
dcde836219bc add thy files
chunhan
parents:
diff changeset
   187
dcde836219bc add thy files
chunhan
parents:
diff changeset
   188
  show ?thesis unfolding ipc_deletable_s_def
dcde836219bc add thy files
chunhan
parents:
diff changeset
   189
    apply (rule_tac x = t in exI, 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   190
           rule_tac x = "(r',fr',pt',u')" in exI,
dcde836219bc add thy files
chunhan
parents:
diff changeset
   191
           rule_tac x = srp' in exI)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   192
    apply (simp add: SP'_in) 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   193
    using rc SP' SI type
dcde836219bc add thy files
chunhan
parents:
diff changeset
   194
    by (auto simp:obj2sobj.simps cp2sproc.simps split:option.splits if_splits)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   195
qed
dcde836219bc add thy files
chunhan
parents:
diff changeset
   196
dcde836219bc add thy files
chunhan
parents:
diff changeset
   197
lemma deleted_imp_deletable_s:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   198
  "\<lbrakk>deleted obj s; exists [] obj; valid s\<rbrakk> \<Longrightarrow> deletable_s obj"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   199
apply (case_tac obj)  
dcde836219bc add thy files
chunhan
parents:
diff changeset
   200
apply (simp add:del_imp_del_s_proc)  
dcde836219bc add thy files
chunhan
parents:
diff changeset
   201
apply (simp add:del_imp_del_s_file) 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   202
apply (simp add:del_imp_del_s_ipc)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   203
done
dcde836219bc add thy files
chunhan
parents:
diff changeset
   204
dcde836219bc add thy files
chunhan
parents:
diff changeset
   205
(*
dcde836219bc add thy files
chunhan
parents:
diff changeset
   206
lemma all_sobjs_E3:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   207
  assumes prem: "sobj \<in> all_sobjs" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   208
  shows "\<exists> s obj. valid s \<and> obj2sobj s obj = sobj \<and> sobj_source_eq_obj sobj obj \<and> 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   209
                  initp_intact_but s sobj \<and> exists s obj \<and> no_del_event s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   210
proof-
dcde836219bc add thy files
chunhan
parents:
diff changeset
   211
  obtain t where "etype_of_file [] [] = Some t" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   212
    using root_in_filesystem current_file_has_etype[of "[]" "[]"] vs_nil 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   213
    by auto
dcde836219bc add thy files
chunhan
parents:
diff changeset
   214
  with root_in_filesystem
dcde836219bc add thy files
chunhan
parents:
diff changeset
   215
  have "obj2sobj [] (File []) = SFile (t,[]) (Some [])"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   216
    by (auto simp:obj2sobj.simps source_dir_of_init' 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   217
            split:option.splits if_splits)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   218
  moreover have "initp_intact []"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   219
    by (auto simp:initp_intact_def cp2sproc.simps obj2sobj.simps 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   220
            split:option.splits)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   221
  ultimately show ?thesis
dcde836219bc add thy files
chunhan
parents:
diff changeset
   222
    using prem vs_nil root_in_filesystem 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   223
    apply (drule_tac s' = "[]" and obj' = "File []" in all_sobjs_E2)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   224
    apply (simp+, (erule exE|erule conjE)+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   225
    by (rule_tac x = s in exI, simp, rule_tac x = obj in exI, simp+)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   226
qed
dcde836219bc add thy files
chunhan
parents:
diff changeset
   227
dcde836219bc add thy files
chunhan
parents:
diff changeset
   228
lemma del_s_imp_del_proc:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   229
  assumes initp: "p \<in> init_processes"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   230
  and del_s: "proc_deletable_s p"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   231
  shows "\<exists> s. valid s \<and> deleted (Proc p) s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   232
proof-
dcde836219bc add thy files
chunhan
parents:
diff changeset
   233
  from del_s obtain r fr pt u sp' srp' 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   234
    where Target: "SProc (r,fr,pt,u) (Some p) \<in> all_sobjs" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   235
    and Killer: "SProc sp' srp' \<in> all_sobjs"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   236
    and rc: "(role_of_sproc sp', Proc_type pt, DELETE) \<in> compatible"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   237
    using proc_deletable_s_def by auto
dcde836219bc add thy files
chunhan
parents:
diff changeset
   238
  
dcde836219bc add thy files
chunhan
parents:
diff changeset
   239
  from Target obtain s where vs: "valid s" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   240
    and "obj2sobj s (Proc p) = SProc (r,fr,pt,u) (Some p)" 
dcde836219bc add thy files
chunhan
parents:
diff changeset
   241
    and "exists s (Proc p)"  and "no_del_event s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   242
    and "initp_intact_but s (SProc (r,fr,pt,u) (Some p))"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   243
    apply (drule_tac all_sobjs_E3, clarsimp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   244
    by (frule obj2sobj_proc, clarsimp)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   245
  with Killer obtain s' p' where vs': "valid (s' @ s)" and
dcde836219bc add thy files
chunhan
parents:
diff changeset
   246
    SP : "obj2sobj (s' @ s) (Proc p) = SProc (r,fr,pt,u) (Some p)" and
dcde836219bc add thy files
chunhan
parents:
diff changeset
   247
    exp: "exists (s' @ s) (Proc p)"  and
dcde836219bc add thy files
chunhan
parents:
diff changeset
   248
    SP': "obj2sobj (s' @ s) (Proc p') = SProc sp' srp'" and
dcde836219bc add thy files
chunhan
parents:
diff changeset
   249
    exp': "exists (s' @ s) (Proc p')"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   250
    apply (drule_tac obj' = "Proc p" and s' = s in all_sobjs_E1, auto)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   251
    apply (frule_tac obj = obj in obj2sobj_proc, erule exE)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   252
    apply (auto intro:nodel_exists_remains)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   253
    apply blast
dcde836219bc add thy files
chunhan
parents:
diff changeset
   254
    apply (frule_tac obj = "Proc p" in nodel_exists_remains)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   255
dcde836219bc add thy files
chunhan
parents:
diff changeset
   256
dcde836219bc add thy files
chunhan
parents:
diff changeset
   257
lemma deletable_s_imp_deleted:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   258
  "deletable_s obj \<Longrightarrow> \<exists> s. valid s \<and> deleted obj s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   259
apply (case_tac obj)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   260
apply (simp add:deletable_s.simps)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   261
dcde836219bc add thy files
chunhan
parents:
diff changeset
   262
dcde836219bc add thy files
chunhan
parents:
diff changeset
   263
lemma valid_kill_imp_proc_del_s:
dcde836219bc add thy files
chunhan
parents:
diff changeset
   264
  "\<lbrakk>valid (Kill p' p # s); p \<in> init_processes; \<not> deleted (Proc p) s\<rbrakk> \<Longrightarrow> proc_deletable_s p"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   265
apply (frule valid_os, frule valid_
dcde836219bc add thy files
chunhan
parents:
diff changeset
   266
dcde836219bc add thy files
chunhan
parents:
diff changeset
   267
dcde836219bc add thy files
chunhan
parents:
diff changeset
   268
lemma build_phase: "f \<in> init_files \<and> file_deletable_s f \<longrightarrow> (\<exists> s. \<forall> childf. valids s \<and> f \<preceq> childf \<and> childf \<in> init_files \<and> etype_of_file [] f = Some t \<longrightarrow> (\<exists> p. p \<in> current_procs s \<and> currentrole s p = Some r \<and> (r, File_type t, DELETE) \<in> compatible))"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   269
 thm all_sobjs_E0
dcde836219bc add thy files
chunhan
parents:
diff changeset
   270
dcde836219bc add thy files
chunhan
parents:
diff changeset
   271
lemma del_phase: "f \<in> init_files \<and> file_deletable_s f \<and> (\<forall> childf. f \<preceq> childf \<and> childf \<notin> current_files s \<and> valid s"
dcde836219bc add thy files
chunhan
parents:
diff changeset
   272
dcde836219bc add thy files
chunhan
parents:
diff changeset
   273
*)
dcde836219bc add thy files
chunhan
parents:
diff changeset
   274
dcde836219bc add thy files
chunhan
parents:
diff changeset
   275
end
dcde836219bc add thy files
chunhan
parents:
diff changeset
   276
dcde836219bc add thy files
chunhan
parents:
diff changeset
   277
end