(* Proving that fib is equivalent to fib_tail This is a difficult version of a problem that requires introducing a more general lemma to solve *)
Fixpoint fib (n: nat) : nat :=
match n with
| 0 => 1
| S n' => match n' with
| 0 => 1
| S n'' => fib n' + fib n''
end
end.
Fixpoint fib_tail' (n a b: nat) : nat :=
match n with
| 0 => a
| S n' => fib_tail' n' b (a + b)
end.
Definition fib_tail (n: nat) : nat :=
fib_tail' n 1 1.

Theorem fib_correct_2 :
forall n,
fib_tail n = fib n.