theory Ipc_IF

lemma send_fault_ipc_valid_global_objs:
  "send_fault_ipc tptr fault \<lbrace>valid_global_objs\<rbrace>" unfolding send_fault_ipc_def apply (wp) apply (simp add: Let_def) apply (wp send_ipc_valid_global_objs | wpc)+ apply (rule_tac Q'="\<lambda>_. valid_global_objs" in hoare_post_imp_R) apply (wp | simp)+ done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrace>valid_global_objs\<rbrace> send_fault_ipc tptr fault \<lbrace>\<lambda>_. valid_global_objs\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<lbrace>valid_global_objs\<rbrace> doE handler_cptr <- liftE $ thread_get tcb_fault_handler tptr;
handler_cap <- cap_fault_on_failure (of_bl handler_cptr) False $ lookup_cap tptr handler_cptr;
let f = CapFault (of_bl handler_cptr) False (MissingCapability 0) in case handler_cap of EndpointCap ref badge rights \<Rightarrow> if AllowSend \<in> rights \<and> (AllowGrant \<in> rights \<or> AllowGrantReply \<in> rights) then liftE $ do thread_set (tcb_fault_update (\<lambda>_. Some fault)) tptr;
send_ipc True True (cap_ep_badge handler_cap) (AllowGrant \<in> rights) True tptr (cap_ep_ptr handler_cap)
od else throwError f | _ \<Rightarrow> throwError f
odE \<lbrace>\<lambda>_. valid_global_objs\<rbrace> proof (prove)
goal (4 subgoals):
 1. \<And>handler_cptr handler_cap. \<lbrace>?B3 handler_cptr handler_cap\<rbrace> let f = CapFault (of_bl handler_cptr) False (MissingCapability 0) in case handler_cap of EndpointCap ref badge rights \<Rightarrow> if AllowSend \<in> rights \<and> (AllowGrant \<in> rights \<or> AllowGrantReply \<in> rights) then liftE $ do thread_set (tcb_fault_update (\<lambda>_. Some fault)) tptr;
send_ipc True True (cap_ep_badge handler_cap) (AllowGrant \<in> rights) True tptr (cap_ep_ptr handler_cap)
od else throwError f | _ \<Rightarrow> throwError f \<lbrace>\<lambda>_. valid_global_objs\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 2. \<And>handler_cptr. \<lbrace>?B2 handler_cptr\<rbrace> cap_fault_on_failure (of_bl handler_cptr) False $ lookup_cap tptr handler_cptr \<lbrace>?B3 handler_cptr\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 3. \<lbrace>?Q\<rbrace> liftE $ thread_get tcb_fault_handler tptr \<lbrace>?B2\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 4. \<And>s. valid_global_objs s \<Longrightarrow> ?Q s proof (prove)
goal (4 subgoals):
 1. \<And>handler_cptr handler_cap. \<lbrace>?B3 handler_cptr handler_cap\<rbrace> case handler_cap of EndpointCap ref badge rights \<Rightarrow> if AllowSend \<in> rights \<and> (AllowGrant \<in> rights \<or> AllowGrantReply \<in> rights) then liftE $ do thread_set (tcb_fault_update (\<lambda>_. Some fault)) tptr;
send_ipc True True (cap_ep_badge handler_cap) (AllowGrant \<in> rights) True tptr (cap_ep_ptr handler_cap)
od else throwError (CapFault (of_bl handler_cptr) False (MissingCapability 0)) | _ \<Rightarrow> throwError (CapFault (of_bl handler_cptr) False (MissingCapability 0)) \<lbrace>\<lambda>_. valid_global_objs\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 2. \<And>handler_cptr. \<lbrace>?B2 handler_cptr\<rbrace> cap_fault_on_failure (of_bl handler_cptr) False $ lookup_cap tptr handler_cptr \<lbrace>?B3 handler_cptr\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 3. \<lbrace>?Q\<rbrace> liftE $ thread_get tcb_fault_handler tptr \<lbrace>?B2\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 4. \<And>s. valid_global_objs s \<Longrightarrow> ?Q s proof (prove)
goal (3 subgoals):
 1. \<And>handler_cptr. \<lbrace>?P'164 handler_cptr\<rbrace> lookup_cap tptr handler_cptr \<lbrace>\<lambda>handler_cap s. (handler_cap = NullCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb xc. handler_cap = UntypedCap x xa xb xc \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. handler_cap = EndpointCap x xa xb \<longrightarrow> (AllowSend \<in> xb \<and> (AllowGrant \<in> xb \<or> AllowGrantReply \<in> xb) \<longrightarrow> True \<and> valid_global_objs s) \<and> (\<not> (AllowSend \<in> xb \<and> (AllowGrant \<in> xb \<or> AllowGrantReply \<in> xb)) \<longrightarrow> valid_global_objs s \<and> True)) \<and> (\<forall>x xa xb. handler_cap = NotificationCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. handler_cap = ReplyCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. handler_cap = CNodeCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. handler_cap = ThreadCap x \<longrightarrow> valid_global_objs s \<and> True) \<and> (handler_cap = DomainCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (handler_cap = IRQControlCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. handler_cap = IRQHandlerCap x \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. handler_cap = Zombie x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. handler_cap = ArchObjectCap x \<longrightarrow> valid_global_objs s \<and> True)\<rbrace>, -
 2. \<lbrace>?Q\<rbrace> liftE $ thread_get tcb_fault_handler tptr \<lbrace>\<lambda>handler_cptr s. (valid_global_objs s \<and> True) \<and> ?P'164 handler_cptr s\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 3. \<And>s. valid_global_objs s \<Longrightarrow> ?Q s proof (prove)
goal (4 subgoals):
 1. \<And>handler_cptr. \<lbrace>?P'164 handler_cptr\<rbrace> lookup_cap tptr handler_cptr \<lbrace>\<lambda>_. valid_global_objs\<rbrace>, -
 2. \<And>handler_cptr rv s. valid_global_objs s \<Longrightarrow> (rv = NullCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb xc. rv = UntypedCap x xa xb xc \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. rv = EndpointCap x xa xb \<longrightarrow> (AllowSend \<in> xb \<and> (AllowGrant \<in> xb \<or> AllowGrantReply \<in> xb) \<longrightarrow> True \<and> valid_global_objs s) \<and> (\<not> (AllowSend \<in> xb \<and> (AllowGrant \<in> xb \<or> AllowGrantReply \<in> xb)) \<longrightarrow> valid_global_objs s \<and> True)) \<and> (\<forall>x xa xb. rv = NotificationCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. rv = ReplyCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. rv = CNodeCap x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. rv = ThreadCap x \<longrightarrow> valid_global_objs s \<and> True) \<and> (rv = DomainCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (rv = IRQControlCap \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. rv = IRQHandlerCap x \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x xa xb. rv = Zombie x xa xb \<longrightarrow> valid_global_objs s \<and> True) \<and> (\<forall>x. rv = ArchObjectCap x \<longrightarrow> valid_global_objs s \<and> True)
 3. \<lbrace>?Q\<rbrace> liftE $ thread_get tcb_fault_handler tptr \<lbrace>\<lambda>handler_cptr s. (valid_global_objs s \<and> True) \<and> ?P'164 handler_cptr s\<rbrace>, \<lbrace>\<lambda>_. valid_global_objs\<rbrace>
 4. \<And>s. valid_global_objs s \<Longrightarrow> ?Q s proof (prove)
goal:
No subgoals!