Dynamic_static.thy
author chunhan
Wed, 30 Oct 2013 08:18:40 +0800
changeset 65 6f9a588bcfc4
parent 63 051b0ee98852
child 66 5f86fb3ddd44
permissions -rw-r--r--
update

theory Dynamic_static
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
 Temp
begin

context tainting_s begin





definition enrich:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
where
  "enrich s objs s' \<equiv> \<forall> obj \<in> objs. \<exists> obj'. obj' \<notin> objs \<and> alive s' obj \<and> co2sobj s' obj' = co2sobj s' obj"

definition reserve:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
where
  "reserve s objs s' \<equiv> \<forall> obj. alive s obj \<longrightarrow> alive s' obj \<and> co2sobj s' obj = co2sobj s obj"

definition enrichable :: "t_state \<Rightarrow> t_object set \<Rightarrow> bool"
where
  "enrichable s objs \<equiv> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enrich s objs s' \<and> reserve s objs s'"

definition is_created :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
where
  "is_created s obj \<equiv> init_alive obj \<longrightarrow> deleted obj s"

definition is_inited :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
where
  "is_inited s obj \<equiv> init_alive obj \<and> \<not> deleted obj s"

lemma is_inited_eq_not_created:
  "is_inited s obj = (\<not> is_created s obj)"
by (auto simp:is_created_def is_inited_def)






lemma d2s_main_execve:
  "valid (Execve p f fds # s) \<Longrightarrow> s2ss (Execve p f fds # s) \<in> static"
apply (frule vd_cons, frule vt_grant_os, clarsimp simp:s2ss_execve)
sorry

lemma d2s_main:
  "valid s \<Longrightarrow> s2ss s \<propto> static"
apply (induct s, simp add:s2ss_nil_prop init_ss_in_def)
apply (rule_tac x = "init_static_state" in bexI, simp, simp add:s_init)
apply (frule vd_cons, frule vt_grant_os, simp)
apply (case_tac a) 
apply (clarsimp simp add:s2ss_execve)
apply (rule conjI, rule impI)



sorry


lemma many_sq_imp_sms:
  "\<lbrakk>S_msgq (Create, sec, sms) \<in> ss; ss \<in> static\<rbrakk> \<Longrightarrow> \<forall> sm \<in> (set sms). is_many_smsg sm"
sorry


(* recorded in our static world *)
fun recorded :: "t_object \<Rightarrow> bool"
where
  "recorded (O_proc p)     = True"
| "recorded (O_file f)     = True"
| "recorded (O_dir  f)     = True"
| "recorded (O_node n)     = False" (* cause socket is temperary not considered *)
| "recorded (O_shm  h)     = True"
| "recorded (O_msgq q)     = True"
| "recorded _              = False"

lemma enrichability: 
  "\<lbrakk>valid s; \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj\<rbrakk>
   \<Longrightarrow> enrichable s objs"
proof (induct s arbitrary:objs)
  case Nil
  hence "objs = {}" 
    apply (auto simp:is_created_def)
    apply (erule_tac x = x in ballE)
    apply (auto simp:init_alive_prop)
    done
  thus ?case using Nil unfolding enrichable_def enrich_def reserve_def
    by (rule_tac x = "[]" in exI, auto)
next
  case (Cons e s)
  hence p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj \<Longrightarrow> enrichable s objs"
    and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
    and os: "os_grant s e" and se: "grant s e" and vd: "valid s"
    by (auto dest:vt_grant_os vd_cons vt_grant)
  show ?case sorry (*
  proof (cases e)
    case (Execve p f fds)
    hence p4: "e = Execve p f fds" by simp
    from p3 have p5: "is_inited s (O_proc p) \<Longrightarrow> (O_proc p) \<notin> objs"
      by (auto simp:is_created_def is_inited_def p4 elim!:ballE[where x = "O_proc p"])
    show "enrichable (e # s) objs"
    proof (case "is_inited s (O_proc p)")
      apply (simp add:enrichable_def p4)

      
  
    apply auto
    apply (auto simp:enrichable_def)
apply (induct s)



done
*)
qed

lemma s2d_main:
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
apply (erule static.induct)
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)

apply (erule exE|erule conjE)+

apply (simp add:update_ss_def)

sorry


end

end