Dynamic2static.thy
author chunhan
Thu, 06 Jun 2013 14:50:52 +0800
changeset 21 de8733706a06
parent 20 e2c6af3ccb0d
child 31 aa1375b6c0eb
permissions -rw-r--r--
update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Dynamic2static
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     3
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
context tainting_s begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
lemma d2s_main:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
  "valid s \<Longrightarrow> s2ss s \<in> static"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
apply (induct s, simp add:s2ss_nil_prop s_init)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
apply (frule vd_cons, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
apply (case_tac a, simp_all) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
apply 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
induct s, case tac e, every event analysis
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    16
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    17
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    18
lemma d2s_main':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
  "\<lbrakk>alive s obj; co2sobj s obj= Some sobj\<rbrakk> \<Longrightarrow> sobj \<in> (s2ss s)"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    20
by (simp add:s2ss_def, rule_tac x = obj in exI, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
lemma alive_has_sobj:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    23
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sobj. co2sobj s obj = Some sobj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
lemma t2ts:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
  "obj \<in> tainted s \<Longrightarrow> co2sobj s obj = Some sobj \<Longrightarrow> tainted_s (s2ss s) sobj"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    28
apply (frule tainted_in_current, frule tainted_is_valid)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
apply (simp add:s2ss_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
apply (case_tac sobj, simp_all)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    31
apply (case_tac [!] obj, simp_all split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
apply (rule_tac x = "O_proc nat" in exI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
apply (rule_tac x = "O_file list" in exI, simp)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    34
apply (drule dir_not_tainted, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    35
apply (drule msgq_not_tainted, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    36
apply (drule shm_not_tainted, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    37
apply (case_tac prod1, simp, case_tac prod2, clarsimp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
apply (rule conjI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
apply (rule_tac x = "O_msgq nat1" in exI, simp)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    40
apply (rule conjI) defer
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    41
apply (simp add:cm2smsg_def split:option.splits) 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    42
sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
lemma delq_imp_delqm:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
  "deleted (O_msgq q) s \<Longrightarrow> deleted (O_msg q m) s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
apply (induct s, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
by (case_tac a, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
theorem static_complete: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
  assumes undel: "undeletable obj" and tbl: "taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
  shows "taintable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
  from tbl obtain s where tainted: "obj \<in> tainted s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
    by (auto simp:taintable_def)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    55
  hence vs: "valid s" by (simp add:tainted_is_valid)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
  hence static: "s2ss s \<in> static" using d2s_main by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
  from tainted have alive: "alive s obj" 
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    58
    using tainted_in_current by auto
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
  then obtain sobj where sobj: "co2sobj s obj = Some sobj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
    using vs alive_has_sobj by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    61
  from undel vs have "\<not> deleted obj s" and init_alive: "init_alive obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
    by (auto simp:undeletable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
  with vs sobj have "init_obj_related sobj obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
    apply (case_tac obj, case_tac [!] sobj)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    65
    apply (auto split:option.splits if_splits simp:cp2sproc_def ch2sshm_def cq2smsgq_def cm2smsg_def delq_imp_delqm)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    66
    apply (frule not_deleted_init_file, simp+) (*
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    67
apply (drule is_file_has_sfile, erule exE)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
    apply (rule_tac x = sf in bexI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
    apply (case_tac list, auto split:option.splits simp:is_init_file_props)[1]
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    70
    apply (simp add:same_inode_files_def cfs2sfiles_def) *)  
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    71
    sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
  with tainted t2ts init_alive sobj static
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
  show ?thesis unfolding taintable_s_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
    apply (rule_tac x = "s2ss s" in bexI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
    apply (rule_tac x = "sobj" in exI, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
    done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    79
lemma cp2sproc_pi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    80
  "\<lbrakk>cp2sproc s p = Some (Init p', sec, fds, shms); valid s\<rbrakk> \<Longrightarrow> p = p' \<and> \<not> deleted (O_proc p) s \<and> p \<in> init_procs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    81
by (simp add:cp2sproc_def split:option.splits if_splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    82
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    83
lemma cq2smsgq_qi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    84
  "\<lbrakk>cq2smsgq s q = Some (Init q', sec, sms); valid s\<rbrakk> \<Longrightarrow> q = q' \<and> \<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    85
by (simp add:cq2smsgq_def split:option.splits if_splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    86
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    87
lemma cm2smsg_mi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    88
  "\<lbrakk>cm2smsg s q m = Some (Init m', sec, ttag); q \<in> init_msgqs; valid s\<rbrakk> 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    89
   \<Longrightarrow> m = m' \<and> \<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    90
by (clarsimp simp add:cm2smsg_def split:if_splits option.splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    91
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    92
lemma ch2sshm_hi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    93
  "\<lbrakk>ch2sshm s h = Some (Init h', sec); valid s\<rbrakk> \<Longrightarrow> h = h' \<and> \<not> deleted (O_shm h) s \<and> h \<in> init_shms"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    94
by (clarsimp simp:ch2sshm_def split:if_splits option.splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    95
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    96
lemma root_not_deleted:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    97
  "\<lbrakk>deleted (O_dir []) s; valid s\<rbrakk> \<Longrightarrow> False"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    98
apply (induct s, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    99
apply (frule vd_cons, frule vt_grant_os, case_tac a, auto)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   100
done
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   101
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   102
lemma cf2sfile_fi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   103
  "\<lbrakk>cf2sfile s f = Some (Init f', sec, psecopt, asecs); valid s\<rbrakk> \<Longrightarrow> f = f' \<and> 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   104
     (if (is_file s f) then \<not> deleted (O_file f) s \<and> is_init_file f 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   105
      else \<not> deleted (O_dir f) s \<and> is_init_dir f)"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   106
apply (case_tac f)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   107
by (auto simp:sroot_def cf2sfile_def root_is_init_dir dest!:root_is_dir' root_not_deleted
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   108
        split:if_splits option.splits) 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   109
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
lemma init_deled_imp_deled_s: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
  "\<lbrakk>deleted obj s; init_alive obj; sobj \<in> (s2ss s); valid s\<rbrakk> \<Longrightarrow> \<not> init_obj_related sobj obj"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   112
apply (rule notI)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   113
apply (clarsimp simp:s2ss_def)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   114
apply (case_tac obj, case_tac [!] obja, case_tac sobj)
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   115
apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   116
apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_prop1' is_file_def is_dir_def
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   117
           split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   118
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   119
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   120
lemma deleted_imp_deletable_s:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   121
  "\<lbrakk>deleted obj s; init_alive obj; valid s\<rbrakk> \<Longrightarrow> deletable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
apply (simp add:deletable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   123
apply (rule_tac x = "s2ss s" in bexI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
apply (clarify, simp add:init_deled_imp_deled_s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   125
apply (erule d2s_main)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   126
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
theorem undeletable_s_complete:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   129
  assumes undel_s: "undeletable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   130
  shows "undeletable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   131
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   132
  from undel_s have init_alive: "init_alive obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   133
    and alive_s: "\<forall> ss \<in> static. \<exists> sobj \<in> ss. init_obj_related sobj obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   134
    using undeletable_s_def by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   135
  have "\<not> (\<exists> s. valid s \<and> deleted obj s)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   136
  proof
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   137
    assume "\<exists> s. valid s \<and> deleted obj s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   138
    then obtain s where vs: "valid s" and del: "deleted obj s" by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
    from vs have vss: "s2ss s \<in> static" by (rule d2s_main) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   140
    with alive_s obtain sobj where in_ss: "sobj \<in> (s2ss s)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   141
      and related: "init_obj_related sobj obj" by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
    from init_alive del vs have "deletable_s obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
      by (auto elim:deleted_imp_deletable_s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   144
    with alive_s
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
    show False by (auto simp:deletable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   147
  with init_alive show ?thesis 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
    by (simp add:undeletable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   151
theorem final_offer:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
  "\<lbrakk>undeletable_s obj; \<not> taintable_s obj; init_alive obj\<rbrakk> \<Longrightarrow> \<not> taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   153
apply (erule swap)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   154
by (simp add:static_complete undeletable_s_complete)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   155
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   156
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   157
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   158
(************** static \<rightarrow> dynamic ***************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   159
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   160
lemma created_can_have_many:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   161
  "\<lbrakk>valid s; alive s obj; \<not> init_alive obj\<rbrakk> \<Longrightarrow> \<exists> s'. valid s' \<and> alive s' obj \<and> alive s' obj' \<and> s2ss s = s2ss s'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   162
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   163
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   164
lemma s2d_main:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   165
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   166
apply (erule static.induct)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   167
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   168
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   169
apply (erule exE|erule conjE)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   170
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   171
sorry
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   172
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   173
lemma tainted_s_in_ss:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   174
  "tainted_s ss sobj \<Longrightarrow> sobj \<in> ss"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   175
apply (case_tac sobj, simp_all)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   176
apply (case_tac bool, simp+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   177
apply (case_tac bool, simp+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   178
apply (case_tac prod1, case_tac prod2, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   179
thm tainted_s.simps
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   180
oops
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   181
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   182
lemma set_eq_D:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   183
  "\<lbrakk>x \<in> S; {x. P x} = S\<rbrakk> \<Longrightarrow> P x"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   184
by auto
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   185
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   186
lemma cqm2sms_prop1:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   187
  "\<lbrakk>cqm2sms s q queue = Some sms; sm \<in> set sms\<rbrakk> \<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   188
apply (induct queue arbitrary:sms)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   189
apply (auto split:option.splits)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   190
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   191
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   192
lemma sq_sm_prop:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   193
  "\<lbrakk>sm \<in> set sms; cq2smsgq s q = Some (qi, qsec, sms); valid s\<rbrakk>
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   194
   \<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   195
by (auto simp:cq2smsgq_def split: option.splits intro:cqm2sms_prop1)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   196
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   197
lemma tainted_s_imp_tainted:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   198
  "\<lbrakk>tainted_s ss sobj; ss \<in> static\<rbrakk> \<Longrightarrow> \<exists> s obj. valid s \<and> co2sobj s obj = Some sobj \<and> obj \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   199
apply (drule s2d_main)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   200
apply (erule exE, erule conjE, simp add:s2ss_def)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   201
apply (rule_tac x = s in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   202
apply (case_tac sobj, simp_all)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   203
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   204
apply (rule_tac x = obj in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   205
apply (case_tac obj, (simp split:option.splits if_splits)+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   206
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   207
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   208
apply (rule_tac x = obj in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   209
apply (case_tac obj, (simp split:option.splits if_splits)+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   210
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   211
apply (case_tac prod1, case_tac prod2, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   212
apply ((erule conjE)+, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   213
apply (case_tac obj, simp_all split:option.splits if_splits)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   214
apply (drule_tac sm = "(aa, ba, True)" in sq_sm_prop, simp+, erule exE)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   215
apply (rule_tac x = "O_msg nat m" in exI)
21
chunhan
parents: 20
diff changeset
   216
apply (simp add:cm2smsg_def split:option.splits)
chunhan
parents: 20
diff changeset
   217
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   218
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   219
lemma has_inode_tainted_aux:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   220
  "O_file f \<in> tainted s \<Longrightarrow> \<forall> f'. has_same_inode s f f' \<longrightarrow> O_file f' \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   221
apply (erule tainted.induct)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   222
apply (auto intro:tainted.intros simp:has_same_inode_def)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   223
(*?? need simpset for tainted *)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   224
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   225
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   226
lemma has_same_inode_tainted:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   227
  "\<lbrakk>has_same_inode s f f'; O_file f' \<in> tainted s\<rbrakk> \<Longrightarrow> O_file f \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   228
by (drule has_inode_tainted_aux, auto simp:has_same_inode_def)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   229
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   230
theorem static_sound:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   231
  assumes tbl_s: "taintable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   232
  shows "taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   233
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   234
  from tbl_s obtain ss sobj where static: "ss \<in> static"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   235
    and sobj: "tainted_s ss sobj" and related: "init_obj_related sobj obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
    and init_alive: "init_alive obj" by (auto simp:taintable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   237
  from static sobj tainted_s_imp_tainted 
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   238
  obtain s obj' where co2sobj: "co2sobj s obj' = Some sobj"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   239
    and tainted': "obj' \<in> tainted s" and vs: "valid s" by blast
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
  
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   241
  from co2sobj related vs
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   242
  have eq:"obj = obj' \<or> (\<exists> f f'. obj = O_file f \<and> obj' = O_file f' \<and> has_same_inode s f f')"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   243
    apply (case_tac obj', case_tac [!] obj)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   244
    apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   245
    apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_def is_file_def is_dir_def
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   246
               split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   247
    done
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   248
  with tainted' have tainted: "obj \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   249
    by (auto intro:has_same_inode_tainted)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   250
  with vs init_alive
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
  show ?thesis by (auto simp:taintable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
lemma ts2t:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
  "obj \<in> tainted_s ss \<Longrightarrow> \<exists> s. obj \<in> tainted s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
  "obj \<in> tainted_s ss \<Longrightarrow> \<exists> so. so True \<in> ss \<Longrightarrow> so True \<in> ss \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss \<Longrightarrow> so True \<in> s2ss s \<Longrightarrow> tainted s obj. "
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
end