theory Finalise_R

lemma m_badged:
  "m p = Some (CTE cap node) \<Longrightarrow>
  \<exists>cap' node'. n p = Some (CTE cap' node') \<and>
              (if p = slot
               then \<not> mdbFirstBadged node'
               else if p = mdbNext s_node
               then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node)
               else mdbFirstBadged node' = mdbFirstBadged node)" apply (subgoal_tac "p \<noteq> 0") prefer 2 apply (insert no_0_n)[1] apply clarsimp apply (cases "p = slot") apply (clarsimp simp: n_def modify_map_if nullMDBNode_def split: if_split_asm) apply (cases "p = mdbNext s_node") apply (clarsimp simp: n_def modify_map_if nullMDBNode_def split: if_split_asm) apply clarsimp apply (cases "p = mdbPrev s_node") apply (auto simp: n_def modify_map_if initMDBNode_def  split: if_split_asm) done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. m p = Some (CTE cap node) \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node)
 2. m p = Some (CTE cap node) \<Longrightarrow> p \<noteq> 0 proof (prove)
goal (2 subgoals):
 1. m p = Some (CTE cap node) \<Longrightarrow> p \<noteq> 0
 2. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m p = Some (CTE cap node); no_0 n\<rbrakk> \<Longrightarrow> p \<noteq> 0
 2. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p = slot\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node)
 2. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p = mdbNext s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node)
 2. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p \<noteq> mdbNext s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p \<noteq> mdbNext s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> (if p = slot then \<not> mdbFirstBadged node' else if p = mdbNext s_node then mdbFirstBadged node' = (mdbFirstBadged node \<or> mdbFirstBadged s_node) else mdbFirstBadged node' = mdbFirstBadged node) proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p \<noteq> mdbNext s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> mdbFirstBadged node' = mdbFirstBadged node proof (prove)
goal (2 subgoals):
 1. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p \<noteq> mdbNext s_node; p = mdbPrev s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> mdbFirstBadged node' = mdbFirstBadged node
 2. \<lbrakk>m p = Some (CTE cap node); p \<noteq> 0; p \<noteq> slot; p \<noteq> mdbNext s_node; p \<noteq> mdbPrev s_node\<rbrakk> \<Longrightarrow> \<exists>cap' node'. n p = Some (CTE cap' node') \<and> mdbFirstBadged node' = mdbFirstBadged node proof (prove)
goal:
No subgoals!