(* 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                                                     *)
(* DELETE *)
(*definit la transition delete et ses consequences*)
Require Export init.
Require Export table_act.
Require Export mess_act.
Unset Standard Proposition Elimination Names.
Section DEF_DEL.
Definition delete_trans (c : Config) (s : Site) :=
mkconfig (S (time c)) (dt c) (st c) (Reset_rec_table (rt c) s)
(Post_message dec (bm c) s owner).
End DEF_DEL.
Section DEL_EFFECT.
(* invariants *)
Variable c0 : Config.
Variable s0 : Site.
Hypothesis rt_true : rt c0 s0 = true.

(* Specifications: *)
Lemma del_trans_le_dt_time :
forall s1 : Site,
dt c0 s1 <= time c0 ->
dt (delete_trans c0 s0) s1 <= time (delete_trans c0 s0).
Lemma del_trans_diff_site :
forall s3 s4 : Site,
(In_queue Message copy (bm c0 s3 s4) -> s3 <> s4) ->
In_queue Message copy (bm (delete_trans c0 s0) s3 s4) -> s3 <> s4.
Lemma del_trans_rt :
forall s1 : Site,
Int (rt (delete_trans c0 s0) s1) =
(if eq_site_dec s1 s0
then  (Int (rt c0 s1) - 1)%Z
else  Int (rt c0 s1)).
Lemma del_trans_in_queue :
forall s1 s3 s4 : Site,
In_queue Message (inc_dec s0) (bm (delete_trans c0 s1) s3 s4) ->
In_queue Message (inc_dec s0) (bm c0 s3 s4).
Lemma del_trans_st_rt :
forall s1 : Site,
st c0 s1 = 0%Z ->
rt c0 s1 = true ->
((st c0 s0 > 0)%Z -> rt c0 s0 = true) ->
(st (delete_trans c0 s1) s0 > 0)%Z -> rt (delete_trans c0 s1) s0 = true.