Section QueryPlusTPC.
(* Querying on behalf of the coordinator (it's easier this way, thanks *)
(* to cn_agreement lemma). In order to query on behald of the *)
(* participan, a different invariant-based fact should be proven. *)
(****************************************************************)
(*************         Basic definitions       ******************)
(****************************************************************)
Variables (lc lq : Label).
Variables (cn : nid) (pts : seq nid).
Hypothesis Lab_neq: lq != lc.
Hypothesis Hnin : cn \notin pts.
Hypothesis Puniq : uniq pts.
Hypothesis PtsNonEmpty : pts != [::].
(* Core protocol *)
Definition pc : protocol := TwoPhaseInductiveProof.tpc_with_inv lc [::] Hnin.
Definition Data : Type := (nat * Log).
Definition qnodes := cn :: pts.
(* Serialization of logs *)
Variable serialize : Data -> seq nat.
Variable deserialize : seq nat -> Data.
Hypothesis ds_inverse : left_inverse serialize deserialize.
(* This one is in the init state *)
Definition local_indicator (d : Data) :=
[Pred h | h = st :-> (d.1, CInit) \+ log :-> d.2].
(* Data is just a log *)
Definition core_state_to_data n h (d : Data)  :=
if n == cn
then h = st :-> (d.1, CInit) \+ log :-> d.2
else h = st :-> (d.1, PInit) \+ log :-> d.2.

Lemma core_state_to_data_inj n h d d' :
core_state_to_data n h d -> core_state_to_data n h d' -> d = d'.