Proof using.
intros t H; red in |- *.
intros a t1 t2 H0 H1 H2; apply (H a t1 t2); auto.
inversion H0; auto.
Qed.
Hint Resolve distinct_pbleaves_pbleft distinct_pbleaves_pbright : core.
(* Transform a tree in a code *)
Fixpoint compute_pbcode (a : pbtree) : code A :=
match a with
| pbleaf b => (b, nil) :: nil
| pbleft l1 =>
map
(fun v : A * list bool =>
match v with
| (a1, b1) => (a1, false :: b1)
end) (compute_pbcode l1)
| pbright l1 =>
map
(fun v : A * list bool =>
match v with
| (a1, b1) => (a1, true :: b1)
end) (compute_pbcode l1)
| pbnode l1 l2 =>
map
(fun v : A * list bool =>
match v with
| (a1, b1) => (a1, false :: b1)
end) (compute_pbcode l1) ++
map
(fun v : A * list bool =>
match v with
| (a1, b1) => (a1, true :: b1)
end) (compute_pbcode l2)
end.

(* Computed code are not empty *)
Theorem compute_pbcode_not_null : forall p, compute_pbcode p <> nil.
Proof using.