Proof using.
intros l; elim l.
intros a H; elim H; simpl in |- *; auto.
simpl in |- *; intros (a1, l1) l0; case l0.
case l1; simpl in |- *; auto.
intros p l2 H a H0.
rewrite H; auto.
red in |- *; intros H1; discriminate.
Qed.

(* Specifications: *)
(* Adding always on the right  creates a right tree *)
Theorem fold_pbadd_prop_right :
forall l a,
l <> nil ->
fold_right (fun a (c : pbtree) => pbadd (fst a) c (snd a))
(pbleaf a)
(map (fun v => match v with
| (a1, b1) => (a1, true :: b1)
end) l) =
pbright
(fold_right (fun a (c : pbtree) => pbadd (fst a) c (snd a)) (pbleaf a) l).
(* Adding always on the right on a left tree  creates a node tree *)
Theorem fold_pbadd_prop_node :
forall l a,
l <> nil ->
fold_right (fun a (c : pbtree) => pbadd (fst a) c (snd a))
(pbright a)
(map (fun v => match v with
| (a1, b1) => (a1, false :: b1)
end) l) =
pbnode
(fold_right (fun a (c : pbtree) => pbadd (fst a) c (snd a))
(pbleaf empty) l) a.