Section SoupPredicates.
(*****************************************************)
(* Message predicates  [Valid messages in soup]  The following generic definition "msg_in_souop" specifies which messages are considered valid in the specific state and the soup.  The derived definition come next.  *)
Definition msg_in_soup (from to : nid) (criterion : nat -> seq nat -> bool)
(d : soup) : Prop :=
(exists! i, exists t c,
find i d = Some (Msg (TMsg t c) from to true)) /\
forall i t c,
find i d = Some (Msg (TMsg t c) from to true) ->
criterion t c.
(* Fix specific tag and content *)
Definition msg_spec from to tg cnt :=
msg_in_soup from to (fun x y => (x == tg) && (y == cnt)).
Definition no_msg_from (from : nid) (d : soup) : Prop :=
forall i to tms b, find i d = Some (Msg tms from to b) -> b = false.
Definition no_msg_to (to : nid) (d : soup) : Prop :=
forall i from tms b, find i d = Some (Msg tms from to b) -> b = false.
Definition no_msg_from_to from to (d : soup) :=
forall i tms b,
find i d = Some (Msg tms from to b) -> b = false.
Definition no_msg_from_imp from to d :
no_msg_from from d -> no_msg_from_to from to d.

Lemma msg_specE s from to tg cnt :
valid s ->
no_msg_from_to from to s ->
msg_spec from to tg cnt (post_msg s (Msg (TMsg tg cnt) from to true)).1.