theory Orphanage

lemma sendFaultIPC_valid_queues' [wp]:
  "\<lbrace> \<lambda>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s \<rbrace>
   sendFaultIPC tptr fault
   \<lbrace> \<lambda>rv s. valid_queues' s \<rbrace>" unfolding sendFaultIPC_def apply (rule hoare_pre) apply (wp threadSet_valid_queues' threadSet_valid_objs' threadSet_sch_act
          | wpc | clarsimp)+ apply (rule_tac Q'="\<lambda>handlerCap s. valid_queues' s \<and> valid_objs' s
                                         \<and> sch_act_wf (ksSchedulerAction s) s"
             in hoare_post_imp_R) apply (wp | clarsimp simp: inQ_def valid_tcb'_def tcb_cte_cases_def)+ done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s\<rbrace> sendFaultIPC tptr fault \<lbrace>\<lambda>rv. valid_queues'\<rbrace> proof (prove)
goal (1 subgoal):
 1. \<lbrace>\<lambda>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s\<rbrace> doE handlerCPtr <- withoutFailure $ threadGet tcbFaultHandler tptr;
handlerCap <- capFaultOnFailure handlerCPtr False $ lookupCap tptr handlerCPtr;
case handlerCap of capability.EndpointCap epptr x True xa canGrant canGrantReply \<Rightarrow> if canGrant \<or> canGrantReply then withoutFailure $ do threadSet (tcbFault_update (\<lambda>_. Just fault)) tptr;
sendIPC True True (capEPBadge handlerCap) canGrant True tptr (capEPPtr handlerCap)
od else throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0 | capability.EndpointCap epptr x False xa canGrant canGrantReply \<Rightarrow> throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0 | _ \<Rightarrow> throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0
odE \<lbrace>\<lambda>rv. valid_queues'\<rbrace> proof (prove)
goal (2 subgoals):
 1. \<lbrace>?Q\<rbrace> doE handlerCPtr <- withoutFailure $ threadGet tcbFaultHandler tptr;
handlerCap <- capFaultOnFailure handlerCPtr False $ lookupCap tptr handlerCPtr;
case handlerCap of capability.EndpointCap epptr x True xa canGrant canGrantReply \<Rightarrow> if canGrant \<or> canGrantReply then withoutFailure $ do threadSet (tcbFault_update (\<lambda>_. Just fault)) tptr;
sendIPC True True (capEPBadge handlerCap) canGrant True tptr (capEPPtr handlerCap)
od else throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0 | capability.EndpointCap epptr x False xa canGrant canGrantReply \<Rightarrow> throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0 | _ \<Rightarrow> throw $ Fault_H.fault.CapFault handlerCPtr False $ Fault_H.lookup_failure.MissingCapability 0
odE \<lbrace>\<lambda>rv. valid_queues'\<rbrace>
 2. \<And>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s \<Longrightarrow> ?Q s proof (prove)
goal (3 subgoals):
 1. \<And>handlerCPtr. \<lbrace>?P'356 handlerCPtr\<rbrace> lookupCap tptr handlerCPtr \<lbrace>\<lambda>handlerCap s. ((\<exists>x. handlerCap = capability.ThreadCap x) \<longrightarrow> valid_queues' s) \<and> (handlerCap = capability.NullCap \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. handlerCap = capability.NotificationCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x. handlerCap = capability.IRQHandlerCap x) \<longrightarrow> valid_queues' s) \<and> (\<forall>x xa xb xc xd xe. handlerCap = capability.EndpointCap x xa xb xc xd xe \<longrightarrow> (xb \<longrightarrow> (xd \<longrightarrow> (\<forall>ko qdom prio. ko_at' ko tptr s \<and> inQ qdom prio (tcbFault_update (\<lambda>_. Some fault) ko) \<and> \<not> inQ qdom prio ko \<longrightarrow> tptr \<in> set (ksReadyQueues s (qdom, prio))) \<and> valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s) \<and> (xe \<longrightarrow> (\<forall>ko qdom prio. ko_at' ko tptr s \<and> inQ qdom prio (tcbFault_update (\<lambda>_. Some fault) ko) \<and> \<not> inQ qdom prio ko \<longrightarrow> tptr \<in> set (ksReadyQueues s (qdom, prio))) \<and> valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s) \<and> (\<not> xd \<and> \<not> xe \<longrightarrow> valid_queues' s)) \<and> (\<not> xb \<longrightarrow> valid_queues' s)) \<and> (handlerCap = capability.DomainCap \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb. handlerCap = capability.Zombie x xa xb) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x. handlerCap = capability.ArchObjectCap x) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb. handlerCap = capability.ReplyCap x xa xb) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. handlerCap = capability.UntypedCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. handlerCap = capability.CNodeCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> (handlerCap = capability.IRQControlCap \<longrightarrow> valid_queues' s)\<rbrace>, -
 2. \<lbrace>?Q\<rbrace> withoutFailure $ threadGet tcbFaultHandler tptr \<lbrace>\<lambda>handlerCPtr s. (valid_queues' s \<and> True) \<and> ?P'356 handlerCPtr s\<rbrace>, \<lbrace>\<lambda>rv. valid_queues'\<rbrace>
 3. \<And>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s \<Longrightarrow> ?Q s proof (prove)
goal (4 subgoals):
 1. \<And>handlerCPtr. \<lbrace>?P'356 handlerCPtr\<rbrace> lookupCap tptr handlerCPtr \<lbrace>\<lambda>handlerCap s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s\<rbrace>, -
 2. \<And>handlerCPtr rv s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s \<Longrightarrow> ((\<exists>x. rv = capability.ThreadCap x) \<longrightarrow> valid_queues' s) \<and> (rv = capability.NullCap \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. rv = capability.NotificationCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x. rv = capability.IRQHandlerCap x) \<longrightarrow> valid_queues' s) \<and> (\<forall>x xa xb xc xd xe. rv = capability.EndpointCap x xa xb xc xd xe \<longrightarrow> (xb \<longrightarrow> (xd \<longrightarrow> (\<forall>ko qdom prio. ko_at' ko tptr s \<and> inQ qdom prio (tcbFault_update (\<lambda>_. Some fault) ko) \<and> \<not> inQ qdom prio ko \<longrightarrow> tptr \<in> set (ksReadyQueues s (qdom, prio))) \<and> valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s) \<and> (xe \<longrightarrow> (\<forall>ko qdom prio. ko_at' ko tptr s \<and> inQ qdom prio (tcbFault_update (\<lambda>_. Some fault) ko) \<and> \<not> inQ qdom prio ko \<longrightarrow> tptr \<in> set (ksReadyQueues s (qdom, prio))) \<and> valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s) \<and> (\<not> xd \<and> \<not> xe \<longrightarrow> valid_queues' s)) \<and> (\<not> xb \<longrightarrow> valid_queues' s)) \<and> (rv = capability.DomainCap \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb. rv = capability.Zombie x xa xb) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x. rv = capability.ArchObjectCap x) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb. rv = capability.ReplyCap x xa xb) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. rv = capability.UntypedCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> ((\<exists>x xa xb xc. rv = capability.CNodeCap x xa xb xc) \<longrightarrow> valid_queues' s) \<and> (rv = capability.IRQControlCap \<longrightarrow> valid_queues' s)
 3. \<lbrace>?Q\<rbrace> withoutFailure $ threadGet tcbFaultHandler tptr \<lbrace>\<lambda>handlerCPtr s. (valid_queues' s \<and> True) \<and> ?P'356 handlerCPtr s\<rbrace>, \<lbrace>\<lambda>rv. valid_queues'\<rbrace>
 4. \<And>s. valid_queues' s \<and> valid_objs' s \<and> sch_act_wf (ksSchedulerAction s) s \<Longrightarrow> ?Q s proof (prove)
goal:
No subgoals!