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.
End SoupPredicates.
(************************************************************)
(*                       List lemmas                        *)
(************************************************************)

Lemma has_all_true xs (ps : seq nid) x:
perm_eq [seq i.1 | i <- xs] ps ->
all id [seq i.2 | i <- xs] ->
x \in ps -> (x, true) \in xs.