(* 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.

Lemma fib_tail'_correct_2 :
forall n k a b,
a = fib k ->
b = fib (k + 1) ->
fib_tail' n a b = fib (k + n).