Fixpoint rev {A} (l : list A) : list A :=
match l with
| [] => []
| x :: xs => rev xs ++ [x]
end.
Fixpoint rev_tail' {A} (l : list A) (acc : list A) : list A :=
match l with
| [] => acc
| x :: l' => rev_tail' l' (x :: acc)
end.
Definition rev_tail {A} (l : list A) : list A := rev_tail' l [].

Theorem rev_tail_correct :
forall A (l : list A),
rev_tail l = rev l.