If a=b, then [a,b]={x∈R:a≤x≤a}={a}, and the only value of f is f(a), so the conclusion holds. Assume from now on that a<b.
Let x∈[a,b] with a<x; we show f(x)=f(a) (for x=a there is nothing to prove). Consider the restriction f∣[a,x] of f to the closed interval [a,x], which satisfies [a,x]⊆[a,b].
By claim 1 of Restriction Stability of Continuity and of the Derivative, applied with both (X,dX) and (Y,dY) equal to the real line, A=[a,b] and B=[a,x], the restriction f∣[a,x] is continuous on [a,x].
Let u∈R with a<u<x. Then u is an interior point of [a,x], since a,x∈[a,x] and a<u<x. Moreover a<u<x≤b shows u∈(a,b), so by hypothesis f is differentiable at u with f′(u)=0. By claim 2 of Restriction Stability of Continuity and of the Derivative, applied with the interval [a,b] in the role of I and [a,x] in the role of J, the restriction f∣[a,x] is differentiable at u with (f∣[a,x])′(u)=f′(u)=0.
By Mean Value Theorem on a Closed Real Interval, applied to f∣[a,x] on [a,x] (note a<x), there exists c with a<c<x such that
(f∣[a,x])′(c)=x−af∣[a,x](x)−f∣[a,x](a)=x−af(x)−f(a).
The left-hand side is 0 by the previous paragraph, and multiplying both sides by x−a=0 gives f(x)−f(a)=0, that is, f(x)=f(a). ■