Section tree_ind.
Variable P : tree -> Prop.
Hypothesis P_atom : forall a, P (atom a).
Hypothesis P_node : forall l, List.Forall P l -> P (node l).
Definition tree_ind (t : tree) : P t :=
tree_rect P (List.Forall P)
(List.Forall_nil _)
(fun t l Pt Pl => List.Forall_cons _ Pt Pl) P_atom P_node t.
End tree_ind.
End tree.
Fixpoint rev_rec {A} (l : list A) (acc : list A) :=
match l with
| [] => acc
| a :: l => rev_rec l (a :: acc)
end.
Definition rev' {A} (l : list A) :=
rev_rec l [].
Fixpoint map_rec {A B} (f : A -> B) (l : list A) (acc : list B) :=
match l with
| [] => rev' acc
| a :: l => map_rec f l (f a :: acc)
end.
Definition list_map' {A B} (f : A -> B) (l : list A) :=
map_rec f l [].

Theorem map'_spec : forall {A B} (f : A -> B) (l : list A),
List.map f l = list_map' f l.