(* 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                                                     *)
(* FIFO *)
(*relatif aux files d'attente*)
Require Export bibli.
Unset Standard Proposition Elimination Names.
Section DEF_FIFO.
(* definition d'une file d'attente comme d'une liste avec un acces a chaque extremite *)
Variable data : Set.
Inductive queue : Set :=
| empty : queue
| input : data -> queue -> queue.
Inductive exc : Set :=
| value : data -> exc
| error : exc.
Definition last (q : queue) :=
match q with
| empty => error
| input d _ => value d
end.
Fixpoint first (q : queue) : exc :=
match q with
| empty => error
| input d q' =>
match q' with
| empty => value d
| input _ _ => first q'
end
end.
Fixpoint first_out (q : queue) : queue :=
match q with
| empty => empty
| input d q' =>
match q' with
| empty => empty
| input _ _ => input d (first_out q')
end
end.
Fixpoint In_queue (d : data) (q : queue) {struct q} : Prop :=
match q with
| empty => False
| input d' q' => d = d' \/ In_queue d q'
end.

(* Specifications: *)
Lemma not_in_empty : forall d : data, ~ In_queue d empty.
Hypothesis eq_data_dec : eq_dec data.