Section ListDenoteMergePreds.
Context {A B : Type}.
Variables (f : A -> pred B) (b : pred B).
Variable (cmp : A -> A -> comparison).
Variable (Hcmp : forall x y, Eq = cmp x y -> x = y).
Proof with simpl; auto.
revert l2; induction l1... intros l2 _ H1.
assert (forall l, (fix merge_aux (l0 : list A) := l0) l = l)
as -> by (destruct l; auto)...
intros l2 H1 H2. induction l2... remember (cmp a a0) as b0; destruct b0...
split; auto. rewrite (Hcmp a a0) in Heqb0; subst. destruct H1 as [H1 H3]...
destruct H1, H2... destruct H1, H2... destruct H2; split... destruct H1; split...
Qed.
Proof with auto.
intros H1; split.
apply listd_In_pred. intros a H2.
apply (listd_In_inv_pred _ a) in H1...
rewrite <-merge_elems. left... auto.
apply listd_In_pred. intros a H2.
apply (listd_In_inv_pred _ a) in H1...
rewrite <-merge_elems. right... auto.
Qed.
Proof with simpl; auto.
revert l2; induction l1... intros l2; inversion 1. intros l2 H1.
induction l2... remember (cmp a a0) as b0; destruct b0...
apply (Hcmp a a0) in Heqb0; subst.
inversion H1; try solve[left; auto]. right...
right; apply IHl2... inversion H1; try solve[left; auto]. right; auto.
Qed.

Lemma listd_merge_un2 l1 l2 s :
listd f un FF l2 s -> listd f un FF (merge cmp l1 l2) s.