(* 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                                                     *)
(* COPY *)
(*definit la transition copy et ses consequences*)
Require Export init.
Require Export table_act.
Require Export mess_act.
Unset Standard Proposition Elimination Names.
Section DEF_COPY.
Definition copy_trans (c : Config) (s1 s2 : Site) :=
mkconfig (S (time c)) (dt c) (Inc_send_table (st c) s1)
(rt c) (Post_message copy (bm c) s1 s2).
End DEF_COPY.
Section COPY_EFFECT.
(* invariants *)
Variable c0 : Config.
Variable s1 s2 : Site.
Hypothesis diff_s1_s2 : s1 <> s2.

(* Specifications: *)
Lemma copy_trans_le_dt_time :
forall s0 : Site,
dt c0 s0 <= time c0 ->
dt (copy_trans c0 s1 s2) s0 <= time (copy_trans c0 s1 s2).
Lemma copy_trans_diff_site :
forall s3 s4 : Site,
(In_queue Message copy (bm c0 s3 s4) -> s3 <> s4) ->
In_queue Message copy (bm (copy_trans c0 s1 s2) s3 s4) -> s3 <> s4.
Lemma copy_trans_st :
forall s0 : Site,
st (copy_trans c0 s1 s2) s0 =
(if eq_site_dec s0 s1 then  (st c0 s0 + 1)%Z else  st c0 s0).
Lemma copy_trans_in_queue :
forall s0 s3 s4 : Site,
In_queue Message (inc_dec s0) (bm (copy_trans c0 s1 s2) s3 s4) ->
In_queue Message (inc_dec s0) (bm c0 s3 s4).
Lemma copy_trans_st_rt :
forall s0 : Site,
s0 <> owner ->
access s1 (rt c0) ->
((st c0 s0 > 0)%Z -> rt c0 s0 = true) ->
(st (copy_trans c0 s1 s2) s0 > 0)%Z -> rt (copy_trans c0 s1 s2) s0 = true.