(* 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                                                     *)
(* COUNTING *)
(* decomptes des parametres de la machine*)
Require Export DistributedReferenceCounting.machine0.machine.
Section CONTROL.
(* decompte des messages dans une file d'attente, puis sommation sur toutes les files d'attente issues ou arrivant sur un site *)
Variable s0 : Site.
Definition ctrl_copy (s1 : Site) (bom : Bag_of_message) :=
card_mess copy (bom s0 s1).
Definition ctrl_dec (s1 : Site) (bom : Bag_of_message) :=
card_mess dec (bom s1 s0).
Definition ctrl_inc (s1 : Site) (bom : Bag_of_message) :=
card_mess (inc_dec s0) (bom s1 owner).
Definition sigma_ctrl_copy (bom : Bag_of_message) :=
sigma Site LS (fun si : Site => ctrl_copy si bom).
Definition sigma_ctrl_dec (bom : Bag_of_message) :=
sigma Site LS (fun si : Site => ctrl_dec si bom).
Definition sigma_ctrl_inc (bom : Bag_of_message) :=
sigma Site LS (fun si : Site => ctrl_inc si bom).
Definition sigma_ctrl (bom : Bag_of_message) :=
(sigma_ctrl_copy bom + sigma_ctrl_dec bom + sigma_ctrl_inc bom)%Z.
End CONTROL.
Section CONTROL_POS.
(* preuves que ces decomptes sont positifs (ils sont fait dans Z) *)
Variable bom : Bag_of_message.

Lemma ctrl_dec_pos : forall s0 s1 : Site, (ctrl_dec s0 s1 bom >= 0)%Z.
Remark ctrl_inc_pos : forall s0 s1 : Site, (ctrl_inc s0 s1 bom >= 0)%Z.