Definition pn_send_trans :=
SendTrans pn_safe_coh pn_safe_in pn_safe_def pn_step_coh.
End ParticipantGenericSendTransitions.
Section ParticipantSendTransitions.
(* Generic send-transition for the participant transition *)
Definition send_prep_resp_prec (ps : data -> PState)
(p : PStateT) (m : payload) :=
exists n d, p = (n, ps d) /\  m = [:: n].
Program Definition pn_gen_send_trans (t : ttag)
(T: t \in [:: prep_yes; prep_no; commit_ack; abort_ack])
(ps : data -> PState) c :=
@pn_send_trans t (send_prep_resp_prec ps) _ c.
Next Obligation.
case: H=>H/eqP->{to}.
rewrite /cohMsg (this_not_pts H) H eqxx/=; split=>//.
by apply/andP; split=>//=; case: H0=>[?][?][->]/eqP.
Qed.
(* Prep-Yes transition *)
Program Definition pn_send_yes_trans :=
@pn_gen_send_trans prep_yes _ PGotRequest true.
(* Prep-No transition *)
Program Definition pn_send_no_trans :=
@pn_gen_send_trans prep_no _ PGotRequest false.
(* Commit-Ack transition *)
Program Definition pn_commit_ack_trans :=
@pn_gen_send_trans commit_ack _ PCommitted true.
(* Abort-Ack transition *)
Program Definition pn_abort_ack_trans :=
@pn_gen_send_trans abort_ack _ PAborted false.
End ParticipantSendTransitions.
Section ParticipantGenericReceiveTransitions.
Notation coh := TPCCoh.
(* Send-prepare *)
Variable rp_tag : ttag.
Variable rp_wf : forall d, coh d -> nid -> nid -> pred payload.
Definition rp_step : receive_step_t coh :=
fun this (from : nid) (m : seq nat) d (pf : coh d) (pt : this \in nodes) =>
if (this \in pts)
then let s := getStP pf pt in
let l := @getStL this d pf pt in
mkLocal (pstep_recv s from rp_tag m l)
else getLocal this d.

Lemma rp_step_coh : r_step_coh_t rp_wf rp_tag rp_step.
Definition rp_recv_trans := ReceiveTrans rp_step_coh.