Definition new_inc_count (m : Message) :=
  match m with
  | inc_dec s => 1%Z
  | _ => 0%Z
  end.(* Below five remarks aux1, aux2, aux3, aux4, aux5 ... followed by
  the real meat the invariant 4. *)

Remark aux1 :
 forall c : Config,
 legal c ->
 st c owner =
 (sigma_receive_table (rt c) + sigma_weight (bm c) -
  sigma_table_but_owner Z (fun (_ : Site) (x : Z) => x) (st c))%Z.Remark aux2 :
 forall c : Config,
 legal c ->
 sigma_table_but_owner Z (fun (_ : Site) (x : Z) => x) (st c) =
 sigma_but Site owner eq_site_dec LS (fun s : Site => sigma_rooted s (bm c)).Remark aux3 :
 forall (s1 s2 : Site) (q : queue Message),
 (cardinal q -
  sigma_but Site owner eq_site_dec LS (fun s : Site => rooted s s1 s2 q))%Z =
 reduce Message
   (fun a : Message =>
    (cardinal_count a -
     sigma_but Site owner eq_site_dec LS
       (fun s : Site => rooted_fun s s1 s2 a))%Z) q.Remark aux4 :
 forall t : Site -> Site -> queue Message,
 sigma2_table Site LS LS (queue Message)
   (fun (s1 s2 : Site) (q : queue Message) =>
    (cardinal q -
     sigma_but Site owner eq_site_dec LS (fun s : Site => rooted s s1 s2 q))%Z)
   t =
 sigma2_table Site LS LS (queue Message)
   (fun (s1 s2 : Site) (q : queue Message) =>
    reduce Message
      (fun a : Message =>
       (cardinal_count a -
        sigma_but Site owner eq_site_dec LS
          (fun s : Site => rooted_fun s s1 s2 a))%Z) q) t.Remark aux5 :
 forall c : Config,
 legal c ->
 sigma2_table Site LS LS (queue Message)
   (fun (s1 s2 : Site) (q : queue Message) =>
    reduce Message
      (fun a : Message =>
       (cardinal_count a -
        sigma_but Site owner eq_site_dec LS
          (fun s : Site => rooted_fun s s1 s2 a))%Z) q) 
   (bm c) =
 (sigma2_table Site LS LS (queue Message)
    (fun (s1 s2 : Site) (q : queue Message) =>
     if eq_site_dec s2 owner
     then reduce Message dec_count q
     else 0) (bm c) +
  sigma2_table Site LS LS (queue Message)
    (fun (s1 s2 : Site) (q : queue Message) =>
     if eq_site_dec s1 owner
     then reduce Message copy_count q
     else 0) (bm c) -
  sigma2_table Site LS LS (queue Message)
    (fun (s1 s2 : Site) (q : queue Message) => reduce Message new_inc_count q)
    (bm c))%Z.

Lemma simpl_copy_sum : forall c : Config, legal c -> sigma2_table Site LS LS (queue Message) (fun (s1 _ : Site) (q : queue Message) => match eq_site_dec s1 owner with | left _ => reduce Message copy_count q | right _ => 0%Z end) (bm c) = sigma_table Site LS Z (Z_id Site) (fun s2 : Site => reduce Message copy_count (bm c owner s2)).