(* Proving that sum is equivalent to sum_tail This is a relatively easy version of a problem that requires introducing a more general lemma to solve *)
Fixpoint sum (l: list nat) : nat :=
match l with
| [] => 0
| x :: xs => x + sum xs
end.
Fixpoint sum_tail' (l: list nat) (acc: nat) : nat :=
match l with
| [] => acc
| x :: xs => sum_tail' xs (x + acc)
end.
Definition sum_tail (l: list nat) : nat :=
sum_tail' l 0.

Theorem sum_tail_correct :
forall l,
sum_tail l = sum l.