(* It's okay to have duplicating nodes in this list *)

(* World is a dependent partial map of protocols *)

Definition context := union_map Label protocol.(*

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.Definition geth (w: world) : hooks := snd w.(* 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.Definition hook_complete w := hooks_consistent (getc w) (geth w).

(* Specifications: *)
Lemma hook_complete0 c : hook_complete (c, Unit).
Lemma cohW w s : Coh w s -> valid w.
Lemma cohS w s : Coh w s -> valid s.
Lemma cohH w s : Coh w s -> hook_complete w.
Lemma cohD w s : Coh w s -> dom (getc w) =i dom s.
Lemma coh_coh w s l : Coh w s -> coh (getProtocol w l) (getStatelet s l).
Lemma unit_coh w s : Coh w s -> w = Unit <-> s = Unit.
Lemma Coh0 (w : world) (s : state) : w = Unit -> s = Unit -> Coh w s.
Lemma coh_prec w: precise (Coh w).
Lemma locE' d n x y : valid (dstate d) -> getLocal n {| dstate := upd n x (dstate d); dsoup := y |} = x.