Definition dec_predicate (m : Message) :=
  match m with
  | dec => true
  | _ => false
  end.Definition inc_predicate (m : Message) :=
  match m with
  | inc_dec _ => true
  | _ => false
  end.Definition site_inc_predicate (m : Message) :=
  match m with
  | inc_dec s => if eq_site_dec s s0 then true else false
  | _ => false
  end.Definition copy_predicate (m : Message) :=
  match m with
  | copy => true
  | _ => false
  end.Definition dec_count (m : Message) :=
  match m with
  | dec => 1%Z
  | _ => 0%Z
  end.Definition inc_count (m : Message) := 0%Z.Definition copy_count (m : Message) :=
  match m with
  | copy => 1%Z
  | _ => 0%Z
  end.Definition cardinal_count :=
  fun_sum Message dec_count (fun_sum Message inc_count copy_count).Definition cardinal := reduce Message cardinal_count.

Lemma cardinal_first_out : forall (q : queue Message) (m : Message), first Message q = value Message m -> cardinal (first_out Message q) = (cardinal q - cardinal_count m)%Z.