Definition rooted_fun (s1 s2 : Site) (m : Message) :=
  match m with
  | copy => if eq_site_dec s1 s0 then 1%Z else 0%Z
  | dec => if eq_site_dec s2 s0 then 1%Z else 0%Z
  | inc_dec s3 =>
      if eq_site_dec s3 s0
      then
       if eq_site_dec s2 owner then 1%Z else 0%Z
      else 0%Z
  end.Definition rooted (s1 s2 : Site) (q : queue Message) :=
  reduce Message (rooted_fun s1 s2) q.Definition sigma_rooted (bm : Bag_of_message) :=
  sigma2_table Site LS LS (queue Message) rooted bm.

(* Specifications: *)
Lemma sigma_rooted_post_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), s0 <> owner -> sigma_rooted s0 (Post_message Message m b s1 s2) = (sigma_rooted s0 b + rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_first_out : forall (s0 s1 s2 : Site) (q : queue Message) (m : Message), first Message q = value Message m -> rooted s0 s1 s2 (first_out Message q) = (rooted s0 s1 s2 q - rooted_fun s0 s1 s2 m)%Z.
Lemma sigma_rooted_collect_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), first Message (b s1 s2) = value Message m -> s0 <> owner -> sigma_rooted s0 (Collect_message Message b s1 s2) = (sigma_rooted s0 b - rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_fun_positive_or_null : forall (s0 x y : Site) (a : Message), (rooted_fun s0 x y a >= 0)%Z.
Lemma rooted_positive_or_null : forall (s0 x y : Site) (q : queue Message), (rooted s0 x y q >= 0)%Z.
Lemma sigma_rooted_post_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), s0 <> owner -> sigma_rooted s0 (Post_message Message m b s1 s2) = (sigma_rooted s0 b + rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_first_out : forall (s0 s1 s2 : Site) (q : queue Message) (m : Message), first Message q = value Message m -> rooted s0 s1 s2 (first_out Message q) = (rooted s0 s1 s2 q - rooted_fun s0 s1 s2 m)%Z.
Lemma sigma_rooted_collect_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), first Message (b s1 s2) = value Message m -> s0 <> owner -> sigma_rooted s0 (Collect_message Message b s1 s2) = (sigma_rooted s0 b - rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_fun_positive_or_null : forall (s0 x y : Site) (a : Message), (rooted_fun s0 x y a >= 0)%Z.
Lemma rooted_positive_or_null : forall (s0 x y : Site) (q : queue Message), (rooted s0 x y q >= 0)%Z.
Lemma sigma_rooted_post_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), s0 <> owner -> sigma_rooted s0 (Post_message Message m b s1 s2) = (sigma_rooted s0 b + rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_first_out : forall (s0 s1 s2 : Site) (q : queue Message) (m : Message), first Message q = value Message m -> rooted s0 s1 s2 (first_out Message q) = (rooted s0 s1 s2 q - rooted_fun s0 s1 s2 m)%Z.
Lemma sigma_rooted_collect_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), first Message (b s1 s2) = value Message m -> s0 <> owner -> sigma_rooted s0 (Collect_message Message b s1 s2) = (sigma_rooted s0 b - rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_fun_positive_or_null : forall (s0 x y : Site) (a : Message), (rooted_fun s0 x y a >= 0)%Z.
Lemma rooted_positive_or_null : forall (s0 x y : Site) (q : queue Message), (rooted s0 x y q >= 0)%Z.
Lemma invariant2_init : forall s0 : Site, st config_init s0 = sigma_rooted s0 (bm config_init).
Lemma invariant2_ind : forall s0 : Site, s0 <> owner -> forall (c : Config) (t : class_trans c), legal c -> st c s0 = sigma_rooted s0 (bm c) -> st (transition c t) s0 = sigma_rooted s0 (bm (transition c t)).
Lemma invariant2 : forall (c0 : Config) (s0 : Site), legal c0 -> s0 <> owner -> st c0 s0 = sigma_rooted s0 (bm c0).
Lemma positive_st : forall (c : Config) (s0 s5 : Site), s0 <> owner -> legal c -> In_queue Message (inc_dec s0) (bm c s5 owner) -> (st c s0 > 0)%Z.
Lemma sigma_rooted_post_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), s0 <> owner -> sigma_rooted s0 (Post_message Message m b s1 s2) = (sigma_rooted s0 b + rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_first_out : forall (s0 s1 s2 : Site) (q : queue Message) (m : Message), first Message q = value Message m -> rooted s0 s1 s2 (first_out Message q) = (rooted s0 s1 s2 q - rooted_fun s0 s1 s2 m)%Z.
Lemma sigma_rooted_collect_message : forall (m : Message) (s0 s1 s2 : Site) (b : Bag_of_message), first Message (b s1 s2) = value Message m -> s0 <> owner -> sigma_rooted s0 (Collect_message Message b s1 s2) = (sigma_rooted s0 b - rooted_fun s0 s1 s2 m)%Z.
Lemma rooted_fun_positive_or_null : forall (s0 x y : Site) (a : Message), (rooted_fun s0 x y a >= 0)%Z.
Lemma rooted_positive_or_null : forall (s0 x y : Site) (q : queue Message), (rooted s0 x y q >= 0)%Z.
Lemma invariant2_init : forall s0 : Site, st config_init s0 = sigma_rooted s0 (bm config_init).
Lemma invariant2_ind : forall s0 : Site, s0 <> owner -> forall (c : Config) (t : class_trans c), legal c -> st c s0 = sigma_rooted s0 (bm c) -> st (transition c t) s0 = sigma_rooted s0 (bm (transition c t)).
Lemma invariant2 : forall (c0 : Config) (s0 : Site), legal c0 -> s0 <> owner -> st c0 s0 = sigma_rooted s0 (bm c0).
Lemma positive_st : forall (c : Config) (s0 s5 : Site), s0 <> owner -> legal c -> In_queue Message (inc_dec s0) (bm c s5 owner) -> (st c s0 > 0)%Z.