Section GreeterCoh.
(* All nodes are welcome to participate in the protocol *)
Definition nodes (d : dstatelet) : pred nid := mem fixed_nodes.
(* Defining coherence predicate for the greeter statelet *)
Definition hello := [:: 3; 1; 1; 0].
Definition counter := ptr_nat 1.
(* All messages have fixed shape *)
Definition soupCoh : Pred soup :=
[Pred s | valid s /\
forall m msg,
find m s = Some msg ->
let: from := from msg in
let: tag := tag (content msg) in
let: val := tms_cont (content msg) in
[/\ from \in fixed_nodes,
tag == 0 & behead val == hello]].
(* Coherence for the local state ensures that is has just one counter, which we will later use to count incoming messages  *)
Definition localCoh : Pred heap :=
[Pred h | exists n : nat, h = counter :-> n].
(* Overall coherence *)
Definition greeter_coh d : Prop :=
let: dl := dstate d in
let: ds := dsoup d in
[/\ soupCoh ds, dom dl =i fixed_nodes,
valid dl &
forall n, n \in fixed_nodes -> localCoh (getLocal n d)].
End GreetAux.

Lemma this_in_pf this to d msg :
greet_safe this to d msg -> this \in fixed_nodes.