From mathcomp.ssreflect
From mathcomp
From fcsl
From DiSeL
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Module WorldGetters.
Section WorldGetters.
(* It's okay to have duplicating nodes in this list *)
(* World is a dependent partial map of protocols *)
Definition context := union_map Label protocol.
(* The hooks are dependencies between:  1. a hook's unique id 2. a core protocol 3. a client protocol 4. a send-transition (represented by its tag) of a client protocol  *)
Definition hook_domain := [ordType of ((nat * Label) * (Label * nat))%type].
(*  A hook is a constraint from the local state wrt. core protocol (1st heap argument), relating the local state wrt. the client protocol (2ns heap argument), message to be sent, and the destination node id.  *)
Definition hook_type := heap -> heap -> seq nat -> nid -> Prop.
Definition hooks := union_map hook_domain hook_type.
Definition world := (context * hooks)%type.
Definition getc (w: world) : context := fst w.
Coercion getc : world >-> context.
Definition geth (w: world) : hooks := snd w.
Coercion geth : world >-> hooks.
Variable w : world.
Variables (p : protocol).
(* The function is, in fact, partially defined and returns Empty Protocol for a non-present label. *)
Definition getProtocol i : protocol:=
match find i (getc w) with
| Some p => p
| None => EmptyProt i
end.
End WorldGetters.
End WorldGetters.
Export WorldGetters.
(* Defining coherence of a state with respect to the world *)
Module Worlds.
Module Core.
Section Core.
(* The following definition ties together worlds and states *)
Definition hooks_consistent (c : context) (h : hooks) : Prop :=
forall z lc ls t, ((z, lc), (ls, t)) \in dom h ->
(lc \in dom c) && (ls \in dom c).
Definition hook_complete w := hooks_consistent (getc w) (geth w).

Lemma locE i n k x y :
k \in dom i -> valid i -> valid (dstate (getStatelet i k)) ->
getLocal n (getStatelet (upd k
{| dstate := upd n x (dstate (getStatelet i k));
dsoup := y |} i) k) = x.