Definition tpc := TwoPhaseCommitProtocol others Hnin l.(* Take the transitions *)
Notation sts := (snd_trans tpc).Notation rts := (rcv_trans tpc).Notation loc z d := (getLocal z d).Definition PhaseOne (d : dstatelet) (round : nat) (next_data : data) (l : Log) :=
  (exists sent, cn_PhaseOneSend d round next_data l sent) \/
  (exists recvd, cn_PhaseOneReceive d round next_data l recvd).(***********************************************************)
(* Elimination lemmas for the invariant to deal with cases *)
(***********************************************************)

Notation coh d := (coh tpc d).Notation PI := pf_irr.

(* Specifications: *)
Lemma inv_init d e (C : coh d): Inv d -> getStC C = (e, CInit) -> exists lg, EverythingInit d e lg.
Lemma inv_prep_send d e dt ps (C : coh d): Inv d -> getStC C = (e, CSentPrep dt ps) -> exists lg sent, cn_PhaseOneSend d e dt lg sent.
Lemma inv_waitprep d r (C : coh d) next_data recvd: Inv d -> getStC C = (r, CWaitPrepResponse next_data recvd) -> exists lg, cn_PhaseOneReceive d r next_data lg recvd.
Lemma inv_sentcommit d r (C : coh d) next_data sent: Inv d -> getStC C = (r, CSentCommit next_data sent) -> exists lg, cn_PhaseTwoSendCommits d r next_data lg sent.
Lemma inv_sentabort d r (C : coh d) next_data sent: Inv d -> getStC C = (r, CSentAbort next_data sent) -> exists lg, cn_PhaseTwoSendAborts d r next_data lg sent.
Lemma inv_waitcommit d r (C : coh d) next_data sent: Inv d -> getStC C = (r, CWaitAckCommit next_data sent) -> exists lg, cn_PhaseTwoReceiveCommits d r next_data lg sent.
Lemma inv_waitabort d r (C : coh d) next_data sent: Inv d -> getStC C = (r, CWaitAckAbort next_data sent) -> exists lg, cn_PhaseTwoReceiveAborts d r next_data lg sent.
Lemma PhaseTwoAbort_round_cn d round lg next_data : PhaseTwoAbort d round next_data lg -> exists cs, cn_state d (round, cs) lg.
Lemma PhaseTwoCommit_round_cn d round lg next_data : PhaseTwoCommit d round next_data lg -> exists cs, cn_state d (round, cs) lg.
Lemma PhaseOne_round_cn d round lg next_data : PhaseOne d round next_data lg -> exists cs, cn_state d (round, cs) lg.
Lemma c_matches_tag_prep_yes_inv cs : c_matches_tag cs prep_yes -> exists next_data recvd, cs = CWaitPrepResponse next_data recvd.
Lemma c_matches_tag_prep_no_inv cs : c_matches_tag cs prep_no -> exists next_data recvd, cs = CWaitPrepResponse next_data recvd.
Lemma c_matches_tag_commit_ack_inv cs : c_matches_tag cs commit_ack -> exists next_data recvd, cs = CWaitAckCommit next_data recvd.
Lemma c_matches_tag_abort_ack_inv cs : c_matches_tag cs abort_ack -> exists next_data recvd, cs = CWaitAckAbort next_data recvd.
Lemma pt_state_functional d pt ps1 lg1 ps2 lg2 : valid (loc pt d) -> pt_state d ps1 lg1 pt -> pt_state d ps2 lg2 pt -> ps1 = ps2 /\ lg1 = lg2.