(* 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.

Theorem inpb_compute_ex : forall a p, inpb (pbleaf a) p -> exists l : _, In (a, l) (compute_pbcode p).