Proof with auto.
intros Q e f.
induction l.
simpl.
intros.
inversion_clear H.
exists t.
split...
simpl.
intros.
inversion_clear H.
exists t.
split...
destruct (IHl H0).
destruct H.
exists x.
split...
Qed.
End contents.
Hint Constructors In.
Hint Resolve InLeaf.
Hint Resolve InNode.
Hint Resolve InOne.
Hint Resolve InHead.
Hint Resolve InTail.
(* todo: why don't the ctor hints remove the need for these? *)
Definition map (A B: Set) (f: A -> B): T A -> T B := fold (@Leaf _ ∘ f) (@Node _).
Add Parametric Morphism (A B: Set): (@map A B)
with signature (@ext_eq A B) ==> (@ext_eq (T A) (T B))
as map_ext_morph.
Proof with try reflexivity.
unfold ext_eq.
intros.
induction x0; simpl.
unfold compose.
rewrite H...
rewrite IHx0...
rewrite IHx0...
simpl in IHx1.
inversion_clear IHx1...
Qed.

Lemma In_map_inv (A B: Set) (e: B) (f: A -> B) (t: T A):
In e (map f t) -> exists e', e = f e' /\ In e' t.