(* 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                                                     *)
(* New variant where the function receives the coordonates *)
Require Export fifo.
Require Export table.
Require Export reduce.
Unset Standard Proposition Elimination Names.
Section TABLE.
Variable Site : Set.
Hypothesis eq_site_dec : eq_dec Site.
Variable LS : list Site.
Variable Data : Set.
Let Table := Site -> Data.
Variable t : Table.
Variable s0 : Site.
Variable d0 : Data.
Variable f : Site -> Data -> Z.
Definition sigma_table (st : Table) :=
sigma Site LS (fun s : Site => f s (st s)).
Definition update_table := change_x0 Site Data eq_site_dec t s0 d0.
Definition sigma_but_table (st : Table) :=
sigma_but Site s0 eq_site_dec LS (fun s : Site => f s (st s)).
End TABLE.
Section SIGMA_TABLE.
Variable Site : Set.
Hypothesis eq_site_dec : eq_dec Site.
Variable LS : list Site.
(* This is generic code for any kind of tables hopefully *)
Variable Data : Set.
Let Table := Site -> Data.
Variable t : Table.
Variable s0 : Site.
Variable d0 : Data.
Variable f : Site -> Data -> Z.

(* Specifications: *)
Lemma sigma_table_change :
only_once Site eq_site_dec s0 LS ->
sigma_table Site LS Data f (update_table Site eq_site_dec Data t s0 d0) =
(sigma_table Site LS Data f t - f s0 (t s0) + f s0 d0)%Z.