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                        *)
(************************************************************)
(********************************************************)
(*** More elaborated versions of the same predicates  ***)
(********************************************************)
Definition no_msg_from_to' from to
(criterion : nat -> seq nat -> bool) (d : soup) :=
forall i t c,
find i d = Some (Msg (TMsg t c) from to true) ->
~~criterion t c.

Lemma no_msg_from_to_consume' from to cond s i:
valid s ->
no_msg_from_to' from to cond s ->
no_msg_from_to' from to cond (consume_msg s i).