(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)


Require Import List.
Require Export DistributedReferenceCounting.machine4.invariant0.
Require Export DistributedReferenceCounting.machine4.invariant1.
Require Export DistributedReferenceCounting.machine4.invariant2.

Unset Standard Proposition Elimination Names.

(* Where properties of rooted_fun are derived --> this
   should obviously be abstracted and given decent names *)


Section INVARIANT3.
Lemma sigma_rooted_fun2 :
 forall (s s1 s2 : Site) (d : Message),
 s2 <> owner -> s1 <> s -> s2 <> s -> rooted_fun s s1 s2 d = 0%Z.
Proof.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (rooted_fun s s1 owner dec) Z0 *)
  unfold rooted_fun in |- *.
(* Goal: @eq Z match d with | dec => if eq_site_dec s2 s then Zpos xH else Z0 | inc_dec s3 => if eq_site_dec s3 s then if eq_site_dec s2 owner then Zpos xH else Z0 else Z0 | copy => if eq_site_dec s1 s then Zpos xH else Z0 end Z0 *)
  elim d.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  rewrite case_ineq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (if eq_site_dec s0 s then if eq_site_dec s2 owner then Zpos xH else Z0 else Z0) Z0 *)
(* Goal: @eq Z (if eq_site_dec s1 s then Zpos xH else Z0) Z0 *)
  case (eq_site_dec s0 s).
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  intro; rewrite case_ineq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  rewrite case_ineq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.

Lemma sigma_rooted_fun3 :
 forall s1 : Site,
 sigma_but Site owner eq_site_dec LS
   (fun s : Site => rooted_fun s s1 owner dec) = 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s owner s2 copy)) Z0 *)
  apply sigma_but_null.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (rooted_fun s s1 owner dec) Z0 *)
  unfold rooted_fun in |- *.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  rewrite case_ineq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.



Lemma sigma_rooted_fun4 :
 forall (s s1 : Site) (l : list Site),
 ~ In s l ->
 sigma_but Site owner eq_site_dec l
   (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s)) = 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro; intro.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
  elim l.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) Z0 *)
  rewrite H.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : not (@In Site s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall (_ : not (@eq Site s1 a)) (_ : only_once Site eq_site_dec s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s1 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  elim H0.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H0.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
Qed.

Lemma sigma_rooted_fun6 :
 forall (s s1 : Site) (l : list Site),
 ~ In s l ->
 sigma_but Site owner eq_site_dec l
   (fun s0 : Site => rooted_fun s0 s owner copy) = 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro; intro.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
  elim l.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) Z0 *)
  rewrite H.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H0; intuition.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : not (@In Site s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall (_ : not (@eq Site s1 a)) (_ : only_once Site eq_site_dec s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s1 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  elim H0.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) Z0 *)
  rewrite H.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H0; intuition.
Qed.

Lemma sigma_rooted_fun7 :
 forall (s : Site) (l : list Site),
 only_once Site eq_site_dec s l ->
 s <> owner ->
 sigma_but Site owner eq_site_dec l
   (fun s0 : Site => rooted_fun s0 s owner copy) = 1%Z.

Proof.
(* Goal: forall (s2 : Site) (l : list Site) (_ : only_once Site eq_site_dec s2 l) (_ : not (@eq Site s2 owner)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s owner s2 dec)) (Zpos xH) *)
  simple induction l.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  simpl in |- *; intuition.
  
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H.
(* Goal: forall _ : forall (_ : only_once Site eq_site_dec s l0) (_ : not (@eq Site s owner)), @eq Z (sigma_but Site owner eq_site_dec l0 (fun s0 : Site => rooted_fun s0 s owner copy)) (Zpos xH), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l0) (fun s0 : Site => rooted_fun s0 s owner copy)) (Zpos xH) *)
  generalize (sigma_rooted_fun6 s a l0).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H0; simpl in |- *.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall (_ : @eq Site s a) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall (_ : not (@eq Site s a)) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  rewrite e.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H0; simpl in |- *.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H0.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.

Lemma sigma_rooted_fun8 :
 forall (s2 : Site) (l : list Site),
 ~ In s2 l ->
 sigma_but Site owner eq_site_dec l
   (fun s : Site => rooted_fun s owner s2 dec) = 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
  elim l.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) Z0 *)
  rewrite H.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H0; intuition.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall _ : not (@In Site s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall (_ : not (@eq Site s1 a)) (_ : only_once Site eq_site_dec s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s1 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  intro; elim H0.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) Z0 *)
  rewrite H.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H0; intuition.
Qed.



Lemma sigma_rooted_fun9 :
 forall (s2 : Site) (l : list Site),
 only_once Site eq_site_dec s2 l ->
 s2 <> owner ->
 sigma_but Site owner eq_site_dec l
   (fun s : Site => rooted_fun s owner s2 dec) = 1%Z.
Proof.
(* Goal: forall (s2 : Site) (l : list Site) (_ : only_once Site eq_site_dec s2 l) (_ : not (@eq Site s2 owner)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s owner s2 dec)) (Zpos xH) *)
  simple induction l.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  simpl in |- *; intuition.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H.
(* Goal: forall _ : forall (_ : only_once Site eq_site_dec s2 l0) (_ : not (@eq Site s2 owner)), @eq Z (sigma_but Site owner eq_site_dec l0 (fun s : Site => rooted_fun s owner s2 dec)) (Zpos xH), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l0) (fun s : Site => rooted_fun s owner s2 dec)) (Zpos xH) *)
  generalize (sigma_rooted_fun8 s2 l0).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0)) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s2 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) (Zpos xH) *)
  apply H3.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H0; simpl in |- *.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall (_ : @eq Site s a) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall (_ : not (@eq Site s a)) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  rewrite e.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H0.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  rewrite e; simpl in |- *.
(* Goal: forall _ : if eq_site_dec a a then not (@In Site a l0) else only_once Site eq_site_dec a l0, not (@In Site a l0) *)
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) (Zpos xH) *)
  case (eq_site_dec a a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H0.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.


Lemma sigma_rooted_fun10 :
 forall s2 : Site,
 sigma_but Site owner eq_site_dec LS
   (fun s : Site => rooted_fun s owner s2 copy) = 0%Z.
Proof.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s owner s2 copy)) Z0 *)
  apply sigma_but_null.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  rewrite case_ineq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.



Lemma sigma_rooted_fun11 :
 forall (s1 s2 : Site) (l : list Site),
 s2 <> owner ->
 s1 <> owner ->
 ~ In s2 l ->
 sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 dec) =
 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
  elim l.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H2; intuition.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (Zpos xH) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) Z0 *)
(* Goal: forall _ : not (@eq Site s1 a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) Z0 *)
  elim H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H2; intuition.
Qed.


Lemma sigma_rooted_fun12 :
 forall s1 s2 : Site,
 s2 <> owner ->
 s1 <> owner ->
 only_once Site eq_site_dec s2 LS ->
 sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 dec) =
 1%Z.
Proof.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 dec)) (Zpos xH) *)
  generalize H1.
(* Goal: forall (_ : not (@In Site s1 LS)) (_ : not (@In Site s2 LS)), @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  elim LS.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H3.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall (_ : @eq Site s a) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall (_ : not (@eq Site s a)) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  rewrite e.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; elim H; auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s2 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) (Zpos xH) *)
  generalize (sigma_rooted_fun11 s1 s2 l H H0).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall _ : @eq Site s2 a, @eq Z (Z.add (Zpos xH) (sigma_but Site owner eq_site_dec l (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s : Site => if eq_site_dec s2 s then Zpos xH else Z0))) (Zpos xH) *)
  intro; rewrite H4.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H3.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  elim n0; auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H3.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; elim n0; auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.


Lemma sigma_rooted_fun13 :
 forall (s1 s2 : Site) (l : list Site),
 s2 <> owner ->
 s1 <> owner ->
 ~ In s1 l ->
 sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy) =
 0%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro; intro.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro; intro.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
   elim l.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   simpl in |- *; auto.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
   simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
   intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
   case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
   rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
   generalize H2; intuition.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   case (eq_site_dec s1 a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro.
(* Goal: @eq Z (Z.add (Zpos xH) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) Z0 *)
(* Goal: forall _ : not (@eq Site s1 a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) Z0 *)
   elim H2.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
   rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
   auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
   generalize H2; intuition.
Qed.

Lemma sigma_rooted_fun14 :
 forall (s1 s2 : Site) (l : list Site),
 s2 <> owner ->
 s1 <> owner ->
 only_once Site eq_site_dec s1 l ->
 sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy) =
 1%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro; intro; intro; intro.
(* Goal: forall _ : only_once Site eq_site_dec s1 l, @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 copy)) (Zpos xH) *)
  elim l.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s1 l0 *)
  generalize H2.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s1 a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : not (@In Site s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall (_ : not (@eq Site s1 a)) (_ : only_once Site eq_site_dec s1 l0), only_once Site eq_site_dec s1 l0 *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (if eq_site_dec s1 a then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  elim H0.
(* Goal: forall (_ : @eq Site s a) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall (_ : not (@eq Site s a)) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  rewrite e0; rewrite e.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s1 a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (Zpos xH) (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s1 a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  generalize (sigma_rooted_fun13 s1 s2 l0 H H0).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s1 l0 *)
  generalize H2.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s1 a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  elim n0; auto.
  
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l0 (fun s : Site => if eq_site_dec s1 s then Zpos xH else Z0))) (Zpos xH) *)
  rewrite H1.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: only_once Site eq_site_dec s1 l0 *)
  generalize H2.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s1 a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; elim n0; auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.



Lemma sigma_rooted_fun5 :
 forall s s1 : Site,
 only_once Site eq_site_dec s LS ->
 s <> owner ->
 sigma_but Site owner eq_site_dec LS
   (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s)) = 1%Z.
Proof.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro; intro.
(* Goal: forall (_ : not (@In Site s1 LS)) (_ : not (@In Site s2 LS)), @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  elim LS.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H0.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall (_ : @eq Site s a) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall (_ : not (@eq Site s a)) (_ : only_once Site eq_site_dec s (@cons Site a l)), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  rewrite e.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H3.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize H.
(* Goal: forall _ : forall (_ : only_once Site eq_site_dec s l) (_ : not (@eq Site s owner)), @eq Z (sigma_but Site owner eq_site_dec l (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s0 : Site => rooted_fun s0 s1 owner (inc_dec s))) (Zpos xH) *)
  generalize (sigma_rooted_fun4 s s1 l).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) else Z.add (if eq_site_dec s a then if eq_site_dec owner owner then Zpos xH else Z0 else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
  rewrite case_ineq.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H2.
(* Goal: @eq Z (Z.add (if eq_site_dec owner owner then Zpos xH else Z0) Z0) (Zpos xH) *)
(* Goal: not (@In Site s l) *)
(* Goal: forall _ : not (@eq Site s a), @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite case_eq.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H0; simpl in |- *.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (Z.add Z0 (sigma_but Site owner eq_site_dec l (fun s0 : Site => if eq_site_dec s s0 then if eq_site_dec owner owner then Zpos xH else Z0 else Z0))) (Zpos xH) *)
(* Goal: not (@eq Site a owner) *)
  rewrite H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H0; simpl in |- *.
(* Goal: forall _ : if eq_site_dec s a then not (@In Site s l) else only_once Site eq_site_dec s l, only_once Site eq_site_dec s l *)
(* Goal: not (@eq Site s owner) *)
(* Goal: not (@eq Site a owner) *)
  case (eq_site_dec s a).
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
  
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
Qed.




Lemma sigma_rooted_fun1 :
 forall (s s1 s2 : Site) (d : Message),
 s2 <> owner ->
 ~ In s1 LS ->
 ~ In s2 LS ->
 sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 d) =
 0%Z.
Proof.
(* Goal: forall (_ : Site) (s1 s2 : Site) (d : Message) (_ : not (@eq Site s2 owner)) (_ : not (@In Site s1 LS)) (_ : not (@In Site s2 LS)), @eq Z (sigma_but Site owner eq_site_dec LS (fun s0 : Site => rooted_fun s0 s1 s2 d)) Z0 *)
  intros s s1 s2 d H.
(* Goal: forall (_ : not (@In Site s1 LS)) (_ : not (@In Site s2 LS)), @eq Z (sigma_but Site owner eq_site_dec LS (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  elim LS.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall (a : Site) (l : list Site) (_ : forall (_ : not (@In Site s1 l)) (_ : not (@In Site s2 l)), @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0) (_ : not (@In Site s1 (@cons Site a l))) (_ : not (@In Site s2 (@cons Site a l))), @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  intros.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  simpl in |- *.
(* Goal: @eq Z (if eq_site_dec a owner then sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d) else Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  case (eq_site_dec a owner).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  apply H0.
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H1; simpl in |- *.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  intuition.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H2; simpl in |- *; intuition.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  rewrite H0.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s1 a).
(* Goal: @eq Z (sigma_but Site owner eq_site_dec (@cons Site a l) (fun s : Site => rooted_fun s s1 s2 d)) Z0 *)
  generalize H1; simpl in |- *.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  elim H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  case (eq_site_dec s2 a).
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  generalize H2; simpl in |- *; intro; intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  elim H3.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  left; auto.
(* Goal: forall _ : not (@eq Site s2 a), @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  intro.
(* Goal: @eq Z (Z.add (rooted_fun a s1 s2 d) Z0) Z0 *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  rewrite sigma_rooted_fun2.
(* Goal: @eq Z (Z.add Z0 Z0) Z0 *)
(* Goal: not (@eq Site s2 owner) *)
(* Goal: not (@eq Site s1 a) *)
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  omega.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
  auto.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H1; simpl in |- *; intuition.
(* Goal: forall _ : not (or (@eq Site a s1) (@In Site s1 l)), not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
(* Goal: forall _ : not (@eq Site a owner), @eq Z (Z.add (rooted_fun a s1 s2 d) (sigma_but Site owner eq_site_dec l (fun s : Site => rooted_fun s s1 s2 d))) Z0 *)
  generalize H2; simpl in |- *; intuition.
Qed.

Lemma add_reduce4 :
 forall x y z a : Z, (x + y)%Z = (z + a)%Z -> (x - a)%Z = (z - y)%Z.
Proof.
(* Goal: @eq Z (Z.add Z0 Z0) Z0 *)
(* Goal: not (@eq Site s2 owner) *)
(* Goal: not (@eq Site s1 a) *)
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
intros; omega.
Qed.

Lemma add_reduce5 :
 forall x y z a : Z, (x - a)%Z = (z - y)%Z -> x = (a + z - y)%Z.
Proof.
(* Goal: @eq Z (Z.add Z0 Z0) Z0 *)
(* Goal: not (@eq Site s2 owner) *)
(* Goal: not (@eq Site s1 a) *)
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
intros; omega.
Qed.

Lemma add_reduce6 : forall x y z : Z, x = (z + y)%Z -> (x - z)%Z = y.
Proof.
(* Goal: @eq Z (Z.add Z0 Z0) Z0 *)
(* Goal: not (@eq Site s2 owner) *)
(* Goal: not (@eq Site s1 a) *)
(* Goal: not (@eq Site s2 a) *)
(* Goal: not (@In Site s1 l) *)
(* Goal: not (@In Site s2 l) *)
intros; omega.
Qed.



End INVARIANT3.
