theory Untyped_R

lemma updateFreeIndex_caps_no_overlap'':
  "\<lbrace>\<lambda>s. caps_no_overlap'' ptr sz s \<and>
        cte_wp_at' (isUntypedCap o cteCap) src s\<rbrace>
   updateFreeIndex src index
   \<lbrace>\<lambda>r s. caps_no_overlap'' ptr sz s\<rbrace>" apply (simp add: updateFreeIndex_def updateTrackedFreeIndex_def getSlotCap_def) apply (wp updateFreeIndex_updateCap_caps_no_overlap'' getCTE_wp') apply (clarsimp simp: cte_wp_at_ctes_of) apply (clarsimp simp: caps_no_overlap''_def split: option.split) done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. caps_no_overlap'' ptr sz s \<and> cte_wp_at' (isUntypedCap \<circ> cteCap) src s\<rbrace> updateFreeIndex src index \<lbrace>\<lambda>r. caps_no_overlap'' ptr sz\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. caps_no_overlap'' ptr sz s \<and> cte_wp_at' (isUntypedCap \<circ> cteCap) src s\<rbrace> do y <- do cte <- getCTE src;
y <- modify (\<lambda>ks. ks\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges ks | Some r \<Rightarrow> gsUntypedZeroRanges ks - {r}\<rparr>);
modify (\<lambda>ks. ks\<lparr>gsUntypedZeroRanges := case untypedZeroRange (capFreeIndex_update (\<lambda>_. index) (cteCap cte)) of None \<Rightarrow> gsUntypedZeroRanges ks | Some r \<Rightarrow> insert r (gsUntypedZeroRanges ks)\<rparr>)
od;
cte <- getCTE src;
updateCap src (capFreeIndex_update (\<lambda>_. index) (cteCap cte))
od \<lbrace>\<lambda>r. caps_no_overlap'' ptr sz\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<And>s. caps_no_overlap'' ptr sz s \<and> cte_wp_at' (isUntypedCap \<circ> cteCap) src s \<Longrightarrow> \<forall>cte. cte_wp_at' ((=) cte) src s \<longrightarrow> (\<forall>ctea. cte_wp_at' ((=) ctea) src (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}, gsUntypedZeroRanges := case untypedZeroRange (capFreeIndex_update (\<lambda>_. index) (cteCap cte)) of None \<Rightarrow> gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>) | Some r \<Rightarrow> insert r (gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>))\<rparr>) \<longrightarrow> isUntypedCap (cteCap ctea) \<and> caps_no_overlap'' ptr sz (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}, gsUntypedZeroRanges := case untypedZeroRange (capFreeIndex_update (\<lambda>_. index) (cteCap cte)) of None \<Rightarrow> gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>) | Some r \<Rightarrow> insert r (gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>))\<rparr>) \<and> cte_wp_at' (\<lambda>c. cteCap c = cteCap ctea) src (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}, gsUntypedZeroRanges := case untypedZeroRange (capFreeIndex_update (\<lambda>_. index) (cteCap cte)) of None \<Rightarrow> gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>) | Some r \<Rightarrow> insert r (gsUntypedZeroRanges (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (cteCap cte) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r}\<rparr>))\<rparr>)) proof (prove)
goal (1 subgoal):
 1. \<And>s ctea. \<lbrakk>caps_no_overlap'' ptr sz s; isUntypedCap (cteCap ctea); ctes_of s src = Some ctea\<rbrakk> \<Longrightarrow> caps_no_overlap'' ptr sz (s\<lparr>gsUntypedZeroRanges := case untypedZeroRange (capFreeIndex_update (\<lambda>_. index) (cteCap ctea)) of None \<Rightarrow> case untypedZeroRange (cteCap ctea) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r} | Some r \<Rightarrow> insert r (case untypedZeroRange (cteCap ctea) of None \<Rightarrow> gsUntypedZeroRanges s | Some r \<Rightarrow> gsUntypedZeroRanges s - {r})\<rparr>) proof (prove)
goal:
No subgoals!