Definition server_send_trans :=
SendTrans server_send_safe_coh server_send_safe_in server_step_def server_step_coh.
End ServerGenericSendTransitions.
Section ServerSendTransitions.
Definition server_send_update_response_prec (ss : server_state) to m :=
exists e v b e0 v0 outstanding,
m = [:: e; v; b] /\
let: r := Update (to, e, v)
in r \in outstanding /\
ss = ServerState e0 v0 outstanding /\
b = if e0 <= e then 1 else 0.
Program Definition server_send_update_response_trans : send_trans ResourceCoh :=
@server_send_trans update_response_tag server_send_update_response_prec _.
Next Obligation.
case: H=>/eqP->H; rewrite /coh_msg eqxx; split=>//=.
case: H0=>[e][v][b][e0][v0][out][]->[U][_]->.
rewrite /msg_from_server /= eqxx. left. split=>//. by eexists _, _, _.
Qed.
Definition server_send_read_response_prec (ss : server_state) to m :=
exists e e0 v0 outstanding,
ss = ServerState e0 v0 outstanding /\
let: r := Read (to, e)
in r \in outstanding /\
m = if e0 <= e
then [:: e; v0 ]
else [:: e].
Program Definition server_send_read_response_trans : send_trans ResourceCoh :=
@server_send_trans read_response_tag server_send_read_response_prec _.
Next Obligation.
case: H=>/eqP->H; rewrite /coh_msg eqxx; split=>//=.
case: H0=>[e][e0][v0][out][_][R]->.
rewrite /msg_from_server /= eqxx. right. split=>//.
by case: ifP=>_; [left; eexists _,_|right; eexists].
Qed.
End ServerSendTransitions.
Section ServerGenericReceiveTransitions.
Notation coh := ResourceCoh.
Variable the_tag : nat.
Variable server_recv_wf : forall d, coh d -> nid -> nid -> TaggedMessage -> bool.
Definition rs_step : receive_step_t coh :=
fun this (from : nid) (m : seq nat) d (pf : coh d) (pt : this \in nodes) =>
if (this == server)
then let s := getSt_server pf in
st :-> server_recv_step s from the_tag m
else getLocal this d.

Lemma rs_step_coh : r_step_coh_t server_recv_wf the_tag rs_step.
Definition rs_recv_trans := ReceiveTrans rs_step_coh.