From mathcomp.ssreflect
From mathcomp
From fcsl
From DiSeL
From DiSeL
Set Implicit Arguments.
Unset Strict Implicit.
(* The Hello World example - a distributed protocol, allowing anyone send anyone a greeting message. *)
Module GreeterProtocol.
Section GreeterProtocol.
Variable fixed_nodes : seq nid.
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)].

(* Specifications: *)
(* Axioms of the coherence predicate *)
Lemma l1 d: greeter_coh d -> valid (dstate d).
End GreetAux.
Lemma this_in_pf this to d msg :
greet_safe this to d msg -> this \in fixed_nodes.