Section SimpleTpcApp.
(*  A simple application to run on the shim implementation.  Check for [Run] tags to find the initial state and the code for the coordinator and the participants.  *)
Definition l := 0.
(* Coordinator node *)
Definition cn := 0.
(* Participant node *)
Definition p1 := 1.
Definition p2 := 2.
Definition p3 := 3.
Definition pts := [::p1; p2; p3].
Definition others : seq nid := [::].
(* Necessary coherence facts *)
Fact Hnin : cn \notin pts. Proof. by []. Qed.
Fact PtsNonEmpty : pts != [::]. Proof. by []. Qed.
Fact Puniq : uniq pts. Proof. by []. Qed.
(* Coordinator *)
Variable data_stream : seq data.
Definition coordinator :=
coordinator_loop_zero l cn pts others Hnin Puniq PtsNonEmpty data_stream.
(* Participants *)
Program Definition participant p (pf : p \in pts) choices :=
participant_with_choices l cn pts others Hnin p pf choices.
Variables (choices1 choices2 choices3 : seq bool).
(* Initial distributed state *)
Definition st_ptr := TPCProtocol.States.st.
Definition log_ptr := TPCProtocol.States.log.
Definition init_heap_c := st_ptr :-> (0, CInit) \+ log_ptr :-> ([::] : seq (bool * data)).
Definition init_heap_p := st_ptr :-> (0, PInit) \+ log_ptr :-> ([::] : seq (bool * data)).
Definition init_dstate :=
cn \\-> init_heap_c \+
p1 \\-> init_heap_p \+
p2 \\-> init_heap_p \+
p3 \\-> init_heap_p.
Notation init_dstatelet := (DStatelet init_dstate Unit).
(* [Run] Initial state to run *)
Definition init_state : state := l \\-> init_dstatelet.
(* Final Safety Facts *)
Notation W := (mkWorld (TwoPhaseCoordinator.tpc l cn pts others Hnin)).

Lemma hook_complete_unit (c : context) : hook_complete (c, Unit).