These are the human proofs of Fibonacci search, at full length.
Fibonacci search returns the first index of x, or NIL, in at most K - 2 steps full
This proof shows: correctness, termination, complexity.
Let A[0…n−1] be sorted in non-decreasing order, n≥0, and let x be a key. Extend A by A[j]=+∞ for j≥n; the algorithm never reads these items, because line L6 tests mid<n first and then acts as if A[mid]≥x. Let ℓ=∣{j<n:A[j]<x}∣ be the lower bound of x, so 0≤ℓ≤n and, for every j≥0, A[j]<x exactly when j<ℓ. The answer is ℓ when ℓ<n and A[ℓ]=x, and NIL otherwise. Write F0=0, F1=1, Fk=Fk−1+Fk−2.
Line L2. Before each test of line L2, (g,f)=(Fk−1,Fk) for some k≥1: this holds for (0,1)=(F0,F1), and the step gives (Fk,Fk+Fk−1)=(Fk,Fk+1). Since Fk grows without bound, the loop stops, at the smallest K≥1 with FK−1≥n (for n≥1, the values F1=F2=1 both fail and the first success has K≥3).
The invariant. Before each test of line L4:
(g,f)=(Fk−1,Fk) for some k≥1;
lo≤ℓ≤lo+f−1.
At the start lo=0 and f−1≥n≥ℓ, so both hold with k=K.
Step. The loop runs when f>1, that is Fk≥2, so k≥3 and g=Fk−1≥1. Line L5 gives lo≤mid=lo+Fk−1−1≤lo+f−1.
If mid<n and A[mid]<x, then mid<ℓ, so the new lo′=mid+1≤ℓ. The new end is lo′+Fk−2−1=lo+Fk−1+Fk−2−1=lo+f−1≥ℓ. The new pair is (f−g,2g−f)=(Fk−2,Fk−1−Fk−2)=(Fk−2,Fk−3), and k−2≥1.
Otherwise A[mid]≥x (when mid≥n the extended item is +∞), so ℓ≤mid=lo+Fk−1−1, which is the new end with the pair (g,f−g)=(Fk−1,Fk−2), and k−1≥2.
In both cases statements 1 and 2 hold for the new values.
Termination. Each step lowers k by 1 or 2 and keeps k≥1, and the loop runs only while k≥3. So it stops after at most K−2 steps (none when K≤2, that is, n=0). It stops with f≤1, so f=Fk=1 and statement 2 gives lo≤ℓ≤lo, so lo=ℓ.
Result. Line L9 runs with lo=ℓ. It returns ℓ exactly when ℓ<n and A[ℓ]=x, the answer, and otherwise line L10 returns NIL, the answer. ■
The number of comparisons. There are at most K−2 steps, each with at most one comparison, and one more at line L9: at most K−1. For n≥1, by the choice of K, FK−1−1<n, so FK−1≤n. The bound Fj≥φj−2 for j≥1, with φ=(1+5)/2, follows by induction from φ2=φ+1. So φK−3≤n, and the number of steps is K−2≤logφn+1.