In p.339 of Real and functional analysis (S. Lang) the Lemma 3.3 states
Lemma 3.3: If $f$ is a differentiable map on an interval $[a,b]$ whose derivative is $0$, then $f$ is constant.
Lang gives the following proof
Proof: Suppose that $f(t)\neq f(a)$ for some $t\in [a,b]$. By the Hahn-Banach theorem, let $\lambda$ be a functional such that $\lambda(f(t))\neq \lambda (f(a))$. The map $\lambda \circ f$ is differentiable and its derivative is $0$. Hence $\lambda \circ f$ is constant on $[a,b]$, contradiction.
Here I get everything up to the last sentence, I cannot help thinking that this proof is wrong. Since there is no presented argument in why should the map $\lambda \circ f$ be constant. It seems as if there was some kind of mistake, here. Or is there something else here that I am not aware of?
The issue is to reduce the problem to a function $\mathbb{R} \to \mathbb{R}$, the author is taking for granted that the mean value theorem applies here.
Since you have $f: \mathbb{B} \to \mathbb{R}$, you cannot apply the usual mean value theorem. However, if you can show that $\phi(f(x)-f(y)) = 0$ for all $\phi \in \mathbb{B}^*$, then you know that $f(x)=f(y)$.
Since the well known mean value theorem applies to $\phi \circ f$, we are finished.