Section REDUCE.
Variable E : Set.
Variable f : E -> Z.
Fixpoint reduce (q : queue E) : Z :=
match q with
| empty => 0%Z
| input d q' => (reduce q' + f d)%Z
end.
Hypothesis positive_function : forall a : E, (f a > 0)%Z.
(* We prove the following general lemma. Then, we instantiate it to - q1=nil: this case corresponds to adding an element in a queue. - q2=nil: this case corresponds to removing an element from a queue. *)
(* And now two instantiations *)

Lemma reduce_append_nil1 :
forall (d : E) (q2 : queue E), reduce (input E d q2) = (reduce q2 + f d)%Z.