theory Dpolicy

lemma thread_bound_ntfn_cap_transform_tcb:
  "\<lbrakk> opt_cap ptr (transform s) = Some cap; is_bound_ntfn_cap cap \<rbrakk> \<Longrightarrow>
     \<exists>tcb. get_tcb (fst ptr) s = Some tcb" apply (case_tac ptr) apply (simp add:opt_cap_def slots_of_def transform_def transform_objects_def) apply (rule_tac P="a = idle_thread s" in case_split) apply (clarsimp simp: map_add_def object_slots_def) apply (case_tac "kheap s (fst ptr)") apply (clarsimp simp: map_add_def object_slots_def) apply (simp add:get_tcb_def object_slots_def) apply (case_tac aa, simp_all) apply (case_tac x11; simp) apply (clarsimp simp:transform_cnode_contents_def) apply (clarsimp simp:transform_cnode_contents_def) apply (rename_tac arch_obj) apply (case_tac arch_obj;clarsimp simp:transform_asid_pool_contents_def unat_map_def split:if_split_asm) apply (clarsimp simp:transform_asid_pool_entry_def is_bound_ntfn_cap_def split:option.splits) apply (clarsimp simp:transform_page_table_contents_def unat_map_def transform_pte_def is_bound_ntfn_cap_def
                   split:if_split_asm ARM_A.pte.splits) apply (clarsimp simp:transform_page_directory_contents_def unat_map_def transform_pde_def is_bound_ntfn_cap_def
                   split:if_split_asm ARM_A.pde.splits) done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>opt_cap ptr (transform s) = Some cap; is_bound_ntfn_cap cap\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb (fst ptr) s = Some tcb proof (prove)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>opt_cap ptr (transform s) = Some cap; is_bound_ntfn_cap cap; ptr = (a, b)\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb (fst ptr) s = Some tcb proof (prove)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b)\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb proof (prove)
goal (2 subgoals):
 1. \<And>a b. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a = idle_thread s\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb
 2. \<And>a b. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb proof (prove)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb proof (prove)
goal (2 subgoals):
 1. \<And>a b. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s (fst ptr) = None\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb
 2. \<And>a b aa. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s (fst ptr) = Some aa\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb proof (prove)
goal (1 subgoal):
 1. \<And>a b aa. \<lbrakk>(case ((\<lambda>ptr. Some cdl_object.Untyped) |` (- {idle_thread s}) ++ (\<lambda>ptr. map_option (transform_object (machine_state s) ptr ((ekheap s |` (- {idle_thread s})) ptr)) ((kheap s |` (- {idle_thread s})) ptr))) a of None \<Rightarrow> \<lambda>x. None | Some x2 \<Rightarrow> object_slots x2) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s (fst ptr) = Some aa\<rbrakk> \<Longrightarrow> \<exists>tcb. get_tcb a s = Some tcb proof (prove)
goal (1 subgoal):
 1. \<And>a b aa. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) aa of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some aa\<rbrakk> \<Longrightarrow> \<exists>tcb. (case aa of TCB x \<Rightarrow> Some x | _ \<Rightarrow> None) = Some tcb proof (prove)
goal (2 subgoals):
 1. \<And>a b aa x11 x12. \<lbrakk>(case case x11 of 0 \<Rightarrow> IRQNode \<lparr>cdl_irq_node_caps = transform_cnode_contents 0 x12\<rparr> | Suc nat \<Rightarrow> cdl_object.CNode \<lparr>cdl_cnode_caps = transform_cnode_contents (Suc nat) x12, cdl_cnode_size_bits = Suc nat\<rparr> of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (kernel_object.CNode x11 x12); aa = kernel_object.CNode x11 x12\<rbrakk> \<Longrightarrow> False
 2. \<And>a b aa x5. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) (ArchObj x5) of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj x5); aa = ArchObj x5\<rbrakk> \<Longrightarrow> False proof (prove)
goal (3 subgoals):
 1. \<And>a b aa x11 x12. \<lbrakk>transform_cnode_contents 0 x12 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (kernel_object.CNode 0 x12); aa = kernel_object.CNode 0 x12; x11 = 0\<rbrakk> \<Longrightarrow> False
 2. \<And>a b aa x11 x12 nat. \<lbrakk>transform_cnode_contents (Suc nat) x12 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (kernel_object.CNode (Suc nat) x12); aa = kernel_object.CNode (Suc nat) x12; x11 = Suc nat\<rbrakk> \<Longrightarrow> False
 3. \<And>a b aa x5. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) (ArchObj x5) of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj x5); aa = ArchObj x5\<rbrakk> \<Longrightarrow> False proof (prove)
goal (2 subgoals):
 1. \<And>a b aa x11 x12 nat. \<lbrakk>transform_cnode_contents (Suc nat) x12 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (kernel_object.CNode (Suc nat) x12); aa = kernel_object.CNode (Suc nat) x12; x11 = Suc nat\<rbrakk> \<Longrightarrow> False
 2. \<And>a b aa x5. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) (ArchObj x5) of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj x5); aa = ArchObj x5\<rbrakk> \<Longrightarrow> False proof (prove)
goal (1 subgoal):
 1. \<And>a b aa x5. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) (ArchObj x5) of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj x5); aa = ArchObj x5\<rbrakk> \<Longrightarrow> False proof (prove)
goal (1 subgoal):
 1. \<And>a b aa arch_obj. \<lbrakk>(case transform_object (machine_state s) a (ekheap s a) (ArchObj arch_obj) of Tcb x \<Rightarrow> cdl_tcb_caps x | cdl_object.CNode x \<Rightarrow> cdl_cnode_caps x | AsidPool x \<Rightarrow> cdl_asid_pool_caps x | cdl_object.PageTable x \<Rightarrow> cdl_page_table_caps x | cdl_object.PageDirectory x \<Rightarrow> cdl_page_directory_caps x | IRQNode x \<Rightarrow> cdl_irq_node_caps x | _ \<Rightarrow> \<lambda>x. None) b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj arch_obj); aa = ArchObj arch_obj\<rbrakk> \<Longrightarrow> False proof (prove)
goal (3 subgoals):
 1. \<And>a b x1. \<lbrakk>is_bound_ntfn_cap (transform_asid_pool_entry (x1 (word_of_nat b))); ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (ASIDPool x1)); b < 1024; cap = transform_asid_pool_entry (x1 (word_of_nat b))\<rbrakk> \<Longrightarrow> False
 2. \<And>a b x2. \<lbrakk>transform_page_table_contents x2 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (arch_kernel_obj.PageTable x2))\<rbrakk> \<Longrightarrow> False
 3. \<And>a b x3. \<lbrakk>transform_page_directory_contents x3 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (arch_kernel_obj.PageDirectory x3))\<rbrakk> \<Longrightarrow> False proof (prove)
goal (2 subgoals):
 1. \<And>a b x2. \<lbrakk>transform_page_table_contents x2 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (arch_kernel_obj.PageTable x2))\<rbrakk> \<Longrightarrow> False
 2. \<And>a b x3. \<lbrakk>transform_page_directory_contents x3 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (arch_kernel_obj.PageDirectory x3))\<rbrakk> \<Longrightarrow> False proof (prove)
goal (1 subgoal):
 1. \<And>a b x3. \<lbrakk>transform_page_directory_contents x3 b = Some cap; is_bound_ntfn_cap cap; ptr = (a, b); a \<noteq> idle_thread s; kheap s a = Some (ArchObj (arch_kernel_obj.PageDirectory x3))\<rbrakk> \<Longrightarrow> False proof (prove)
goal:
No subgoals!