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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
     1
theory Dynamic_static
051b0ee98852 restructured
chunhan
parents:
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
65
chunhan
parents: 63
diff changeset
     3
 Temp
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
     4
begin
051b0ee98852 restructured
chunhan
parents:
diff changeset
     5
051b0ee98852 restructured
chunhan
parents:
diff changeset
     6
context tainting_s begin
051b0ee98852 restructured
chunhan
parents:
diff changeset
     7
051b0ee98852 restructured
chunhan
parents:
diff changeset
     8
051b0ee98852 restructured
chunhan
parents:
diff changeset
     9
051b0ee98852 restructured
chunhan
parents:
diff changeset
    10
051b0ee98852 restructured
chunhan
parents:
diff changeset
    11
051b0ee98852 restructured
chunhan
parents:
diff changeset
    12
definition enrich:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    13
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
    14
  "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"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    15
051b0ee98852 restructured
chunhan
parents:
diff changeset
    16
definition reserve:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    17
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
    18
  "reserve s objs s' \<equiv> \<forall> obj. alive s obj \<longrightarrow> alive s' obj \<and> co2sobj s' obj = co2sobj s obj"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    19
051b0ee98852 restructured
chunhan
parents:
diff changeset
    20
definition enrichable :: "t_state \<Rightarrow> t_object set \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    21
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
    22
  "enrichable s objs \<equiv> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enrich s objs s' \<and> reserve s objs s'"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    23
051b0ee98852 restructured
chunhan
parents:
diff changeset
    24
definition is_created :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    25
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
    26
  "is_created s obj \<equiv> init_alive obj \<longrightarrow> deleted obj s"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    27
051b0ee98852 restructured
chunhan
parents:
diff changeset
    28
definition is_inited :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    29
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
    30
  "is_inited s obj \<equiv> init_alive obj \<and> \<not> deleted obj s"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    31
051b0ee98852 restructured
chunhan
parents:
diff changeset
    32
lemma is_inited_eq_not_created:
051b0ee98852 restructured
chunhan
parents:
diff changeset
    33
  "is_inited s obj = (\<not> is_created s obj)"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    34
by (auto simp:is_created_def is_inited_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    35
051b0ee98852 restructured
chunhan
parents:
diff changeset
    36
051b0ee98852 restructured
chunhan
parents:
diff changeset
    37
051b0ee98852 restructured
chunhan
parents:
diff changeset
    38
051b0ee98852 restructured
chunhan
parents:
diff changeset
    39
051b0ee98852 restructured
chunhan
parents:
diff changeset
    40
051b0ee98852 restructured
chunhan
parents:
diff changeset
    41
lemma d2s_main_execve:
051b0ee98852 restructured
chunhan
parents:
diff changeset
    42
  "valid (Execve p f fds # s) \<Longrightarrow> s2ss (Execve p f fds # s) \<in> static"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    43
apply (frule vd_cons, frule vt_grant_os, clarsimp simp:s2ss_execve)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    44
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
    45
051b0ee98852 restructured
chunhan
parents:
diff changeset
    46
lemma d2s_main:
051b0ee98852 restructured
chunhan
parents:
diff changeset
    47
  "valid s \<Longrightarrow> s2ss s \<propto> static"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    48
apply (induct s, simp add:s2ss_nil_prop init_ss_in_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    49
apply (rule_tac x = "init_static_state" in bexI, simp, simp add:s_init)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    50
apply (frule vd_cons, frule vt_grant_os, simp)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    51
apply (case_tac a) 
051b0ee98852 restructured
chunhan
parents:
diff changeset
    52
apply (clarsimp simp add:s2ss_execve)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    53
apply (rule conjI, rule impI)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    54
051b0ee98852 restructured
chunhan
parents:
diff changeset
    55
051b0ee98852 restructured
chunhan
parents:
diff changeset
    56
051b0ee98852 restructured
chunhan
parents:
diff changeset
    57
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
    58
051b0ee98852 restructured
chunhan
parents:
diff changeset
    59
051b0ee98852 restructured
chunhan
parents:
diff changeset
    60
lemma many_sq_imp_sms:
051b0ee98852 restructured
chunhan
parents:
diff changeset
    61
  "\<lbrakk>S_msgq (Create, sec, sms) \<in> ss; ss \<in> static\<rbrakk> \<Longrightarrow> \<forall> sm \<in> (set sms). is_many_smsg sm"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    62
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
    63
051b0ee98852 restructured
chunhan
parents:
diff changeset
    64
65
chunhan
parents: 63
diff changeset
    65
(* recorded in our static world *)
chunhan
parents: 63
diff changeset
    66
fun recorded :: "t_object \<Rightarrow> bool"
chunhan
parents: 63
diff changeset
    67
where
chunhan
parents: 63
diff changeset
    68
  "recorded (O_proc p)     = True"
chunhan
parents: 63
diff changeset
    69
| "recorded (O_file f)     = True"
chunhan
parents: 63
diff changeset
    70
| "recorded (O_dir  f)     = True"
chunhan
parents: 63
diff changeset
    71
| "recorded (O_node n)     = False" (* cause socket is temperary not considered *)
chunhan
parents: 63
diff changeset
    72
| "recorded (O_shm  h)     = True"
chunhan
parents: 63
diff changeset
    73
| "recorded (O_msgq q)     = True"
chunhan
parents: 63
diff changeset
    74
| "recorded _              = False"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
    75
051b0ee98852 restructured
chunhan
parents:
diff changeset
    76
lemma enrichability: 
051b0ee98852 restructured
chunhan
parents:
diff changeset
    77
  "\<lbrakk>valid s; \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj\<rbrakk>
051b0ee98852 restructured
chunhan
parents:
diff changeset
    78
   \<Longrightarrow> enrichable s objs"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    79
proof (induct s arbitrary:objs)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    80
  case Nil
051b0ee98852 restructured
chunhan
parents:
diff changeset
    81
  hence "objs = {}" 
051b0ee98852 restructured
chunhan
parents:
diff changeset
    82
    apply (auto simp:is_created_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    83
    apply (erule_tac x = x in ballE)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    84
    apply (auto simp:init_alive_prop)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    85
    done
051b0ee98852 restructured
chunhan
parents:
diff changeset
    86
  thus ?case using Nil unfolding enrichable_def enrich_def reserve_def
051b0ee98852 restructured
chunhan
parents:
diff changeset
    87
    by (rule_tac x = "[]" in exI, auto)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    88
next
051b0ee98852 restructured
chunhan
parents:
diff changeset
    89
  case (Cons e s)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    90
  hence p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj \<Longrightarrow> enrichable s objs"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    91
    and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    92
    and os: "os_grant s e" and se: "grant s e" and vd: "valid s"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    93
    by (auto dest:vt_grant_os vd_cons vt_grant)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    94
  show ?case sorry (*
051b0ee98852 restructured
chunhan
parents:
diff changeset
    95
  proof (cases e)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    96
    case (Execve p f fds)
051b0ee98852 restructured
chunhan
parents:
diff changeset
    97
    hence p4: "e = Execve p f fds" by simp
051b0ee98852 restructured
chunhan
parents:
diff changeset
    98
    from p3 have p5: "is_inited s (O_proc p) \<Longrightarrow> (O_proc p) \<notin> objs"
051b0ee98852 restructured
chunhan
parents:
diff changeset
    99
      by (auto simp:is_created_def is_inited_def p4 elim!:ballE[where x = "O_proc p"])
051b0ee98852 restructured
chunhan
parents:
diff changeset
   100
    show "enrichable (e # s) objs"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   101
    proof (case "is_inited s (O_proc p)")
051b0ee98852 restructured
chunhan
parents:
diff changeset
   102
      apply (simp add:enrichable_def p4)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   103
051b0ee98852 restructured
chunhan
parents:
diff changeset
   104
      
051b0ee98852 restructured
chunhan
parents:
diff changeset
   105
  
051b0ee98852 restructured
chunhan
parents:
diff changeset
   106
    apply auto
051b0ee98852 restructured
chunhan
parents:
diff changeset
   107
    apply (auto simp:enrichable_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   108
apply (induct s)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   109
051b0ee98852 restructured
chunhan
parents:
diff changeset
   110
051b0ee98852 restructured
chunhan
parents:
diff changeset
   111
051b0ee98852 restructured
chunhan
parents:
diff changeset
   112
done
051b0ee98852 restructured
chunhan
parents:
diff changeset
   113
*)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   114
qed
051b0ee98852 restructured
chunhan
parents:
diff changeset
   115
051b0ee98852 restructured
chunhan
parents:
diff changeset
   116
lemma s2d_main:
051b0ee98852 restructured
chunhan
parents:
diff changeset
   117
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   118
apply (erule static.induct)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   119
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   120
051b0ee98852 restructured
chunhan
parents:
diff changeset
   121
apply (erule exE|erule conjE)+
051b0ee98852 restructured
chunhan
parents:
diff changeset
   122
051b0ee98852 restructured
chunhan
parents:
diff changeset
   123
apply (simp add:update_ss_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   124
051b0ee98852 restructured
chunhan
parents:
diff changeset
   125
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
   126
051b0ee98852 restructured
chunhan
parents:
diff changeset
   127
051b0ee98852 restructured
chunhan
parents:
diff changeset
   128
end
051b0ee98852 restructured
chunhan
parents:
diff changeset
   129
051b0ee98852 restructured
chunhan
parents:
diff changeset
   130
end