Definition E_consume_external d i this tag m from P :=
let: d' := {| dstate := upd this (loc this d) (dstate d);
dsoup := consume_msg (dsoup d) i |} in
coh d ->
find i (dsoup d) =
Some {| content := {| tag := tag; tms_cont := m |};
from := from;
to := this;
active := true |} ->
~~ internal_msg tag from this ->
P d ->
P d'.

(* Specifications: *)
Lemma cn_stateE_consume_external d i this tag m from cs log :
E_consume_external d i this tag m from (fun d => cn_state d cs log).
Lemma pt_stateE_consume_external d i this tag m from ps lg pt :
E_consume_external d i this tag m from (fun d => pt_state d ps lg pt).
Lemma msg_specE_consume_external d i this tag m from from' to' tag' m' :
internal_msg tag' from' to' ->
E_consume_external d i this tag m from (fun d => msg_spec from' to' tag' m' (dsoup d)).
Lemma pt_PhaseOneE_consume_external d i this tag m from round next_data lg pt :
pt \in pts ->
E_consume_external d i this tag m from (fun d => pt_PhaseOne d round next_data lg pt).
Lemma pt_InitE_consume_external d i this tag m from round lg pt :
E_consume_external d i this tag m from (fun d => pt_Init d round lg pt).
Lemma pt_PhaseOneRespondedE_consume_external d i this tag m from round next_data lg b pt :
E_consume_external d i this tag m from (fun d => pt_PhaseOneResponded d round next_data lg b pt).
Lemma pt_PhaseTwoRespondedE_consume_external d i this tag m from round next_data lg b pt :
E_consume_external d i this tag m from (fun d => pt_PhaseTwoResponded d round next_data lg b pt).
Lemma pt_PhaseTwoCommitE_consume_external d i this tag m from round next_data lg pt :
pt \in pts ->
E_consume_external d i this tag m from (fun d => pt_PhaseTwoCommit d round next_data lg pt).
Lemma pt_PhaseTwoAbortE_consume_external d i this tag m from round next_data lg pt :
pt \in pts ->
E_consume_external d i this tag m from (fun d => pt_PhaseTwoAbort d round next_data lg pt).
Lemma invE_consume_external d i this tag m from :
E_consume_external d i this tag m from Inv.
Lemma rc_step_external d (C : coh d) this (Hthis : this \in nodes cn pts others) tag from m i :
~~ internal_msg tag from this ->
find i (dsoup d) =
Some {| content := {| tag := tag; tms_cont := m |};
from := from;
to := this;
active := true |} ->
rc_step tag from m C Hthis = loc this d.
Lemma rp_step_external d (C : coh d) this (Hthis : this \in nodes cn pts others) tag from m i :
~~ internal_msg tag from this ->
find i (dsoup d) =
Some {| content := {| tag := tag; tms_cont := m |};
from := from;
to := this;
active := true |} ->
rp_step Hnin tag from m C Hthis = loc this d.
Lemma internal_msg_from_cn tag to :
internal_msg tag cn to ->
coord_msg tag cn to.
Lemma p_matches_tag_internal_inv d i t m pt r ps lg :
coh d ->
pt \in pts ->
find i (dsoup d) =
Some {| content := {| tag := t; tms_cont := m |};
from := cn;
to := pt;
active := true |} ->
internal_msg t cn pt ->
pt_state d (r, ps) lg pt ->
Inv d ->
p_matches_tag ps t.
Lemma PhaseOne_msg_next_data d (C : coh d) i m pt round next_data lg  :
find i (dsoup d) =
Some {| content := {| tag := prep_req; tms_cont := m |};
from := cn;
to := pt;
active := true |} ->
internal_msg prep_req cn pt ->
PhaseOne d round next_data lg ->
behead m == next_data.
Lemma cn_state_functional d cs1 lg1 cs2 lg2 :
valid (loc cn d) ->
cn_state d cs1 lg1 ->
cn_state d cs2 lg2 ->
cs1 = cs2 /\ lg1 = lg2.
Lemma pt_log_agreement d r lg pt :
coh d ->
pt \in pts ->
pt_state d (r, PInit) lg pt ->
Inv d ->
forall pt' ps' r' lg',
pt' \in pts ->
pt_state d (r', ps') lg' pt' ->
r' = r ->
lg' = lg.
Lemma cn_log_agreement d r lg pt :
coh d ->
cn_state d (r, CInit) lg ->
Inv d ->
pt \in pts ->
pt_state d (r, PInit) lg pt.