theory CSpaceInv_AI

lemma set_cap_pspace:
  assumes x: "\<And>s f'. f (kheap_update f' s) = f s"
  shows      "\<lbrace>\<lambda>s. P (f s)\<rbrace> set_cap p cap \<lbrace>\<lambda>rv s. P (f s)\<rbrace>" apply (simp add: set_cap_def split_def) apply (rule hoare_seq_ext [OF _ get_object_sp]) apply (case_tac obj, simp_all split del: if_split cong: if_cong) apply (wpsimp wp: set_object_wp simp: x)+ done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. P (f s)\<rbrace> set_cap p cap \<lbrace>\<lambda>rv s. P (f s)\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. P (f s)\<rbrace> do obj <- get_object (fst cap);
(case obj of CNode sz cn \<Rightarrow> if snd cap \<in> dom cn \<and> well_formed_cnode_n sz cn then return $ CNode sz $ cn(snd cap \<mapsto> p) else fail | TCB tcb \<Rightarrow> if snd cap = tcb_cnode_index 0 then return $ TCB $ tcb\<lparr>tcb_ctable := p\<rparr> else if snd cap = tcb_cnode_index 1 then return $ TCB $ tcb\<lparr>tcb_vtable := p\<rparr> else if snd cap = tcb_cnode_index 2 then return $ TCB $ tcb\<lparr>tcb_reply := p\<rparr> else if snd cap = tcb_cnode_index 3 then return $ TCB $ tcb\<lparr>tcb_caller := p\<rparr> else if snd cap = tcb_cnode_index 4 then return $ TCB $ tcb\<lparr>tcb_ipcframe := p\<rparr> else fail | _ \<Rightarrow> fail) >>= set_object (fst cap)
od \<lbrace>\<lambda>rv s. P (f s)\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<And>obj. \<lbrace>(\<lambda>s. P (f s)) and ko_at obj (fst cap)\<rbrace> (case obj of CNode sz cn \<Rightarrow> if snd cap \<in> dom cn \<and> well_formed_cnode_n sz cn then return $ CNode sz $ cn(snd cap \<mapsto> p) else fail | TCB tcb \<Rightarrow> if snd cap = tcb_cnode_index 0 then return $ TCB $ tcb\<lparr>tcb_ctable := p\<rparr> else if snd cap = tcb_cnode_index 1 then return $ TCB $ tcb\<lparr>tcb_vtable := p\<rparr> else if snd cap = tcb_cnode_index 2 then return $ TCB $ tcb\<lparr>tcb_reply := p\<rparr> else if snd cap = tcb_cnode_index 3 then return $ TCB $ tcb\<lparr>tcb_caller := p\<rparr> else if snd cap = tcb_cnode_index 4 then return $ TCB $ tcb\<lparr>tcb_ipcframe := p\<rparr> else fail | _ \<Rightarrow> fail) >>= set_object (fst cap) \<lbrace>\<lambda>rv s. P (f s)\<rbrace> proof (prove)
goal (2 subgoals):
 1. \<And>obj x11 x12. obj = CNode x11 x12 \<Longrightarrow> \<lbrace>(\<lambda>s. P (f s)) and ko_at (CNode x11 x12) (fst cap)\<rbrace> (if snd cap \<in> dom x12 \<and> well_formed_cnode_n x11 x12 then return (CNode x11 (x12(snd cap \<mapsto> p))) else fail) >>= set_object (fst cap) \<lbrace>\<lambda>rv s. P (f s)\<rbrace>
 2. \<And>obj x2. obj = TCB x2 \<Longrightarrow> \<lbrace>(\<lambda>s. P (f s)) and ko_at (TCB x2) (fst cap)\<rbrace> (if snd cap = tcb_cnode_index 0 then return (TCB (x2\<lparr>tcb_ctable := p\<rparr>)) else if snd cap = tcb_cnode_index (Suc 0) then return (TCB (x2\<lparr>tcb_vtable := p\<rparr>)) else if snd cap = tcb_cnode_index 2 then return (TCB (x2\<lparr>tcb_reply := p\<rparr>)) else if snd cap = tcb_cnode_index 3 then return (TCB (x2\<lparr>tcb_caller := p\<rparr>)) else if snd cap = tcb_cnode_index 4 then return (TCB (x2\<lparr>tcb_ipcframe := p\<rparr>)) else fail) >>= set_object (fst cap) \<lbrace>\<lambda>rv s. P (f s)\<rbrace> proof (prove)
goal:
No subgoals!