Let $V$ be an infinite-dimensional vector space over $\mathbb{R}$. Let $B:V\times V\rightarrow \mathbb{R}$ be a nondegenerate bilinear form, i.e., a bilinear form satisfying
$$ B(x,y)=0,\;\forall y\in V \Rightarrow x=0.$$
Suppose $\phi:V\rightarrow V$ is a self-map satisfying $B(x,y)=B(\phi x, \phi y)$ for all $x,y\in V$. My question is this:
Is $\phi$ necessarily linear? If "no", what's an example?
The answer is yes if $\phi$ is surjective, by an argument I will share momentarily. What I want to know is if there exists a non-surjective nonlinear $\phi$ and a $B$ satisfying the above. The question is motivated by a passage in Peter Lax's book Functional Analysis, which gives a proof that relies on this assumption. On p. 59, Lax writes the following. (Hopefully the meaning of Lax's notation can be inferred from context, but just in case: $H$ is a Hilbert space and there is a fixed self-map of $H$ for which the image of $x\in H$ is denoted by $x'$, and similarly for other variables.)
"We stated in chapter 5 that every isometry of a Banach space onto itself that maps $0$ into $0$ is linear. We give now a new proof of this in Hilbert space:
[... here Lax verifies that an isometry fixing the origin preserves the Hilbert space inner product...]
Now denote $x+y$ by $z$, and let $u$ be any vector in $H$. Using [the preservation of the inner product] we have $$ (z',u')=(z,u) = (x+y,u) = (x,u) + (y,u) = (x', u') + (y',u') = (x'+y',u'). $$ Thus $$(z'-x'-y',u')=0$$ for all $u'$. This can be only if $z'=x'+y'$.
The virtue of this proof is that it applies even when the scalar product is not positive, as long as it is nondegenerate, meaning that no $u$ is orthogonal to all points.
My question arose from making sense of Lax's final comment here. If the scalar product is not positive, then it doesn't induce a metric, so it becomes unclear to me what it should mean for the metric to be complete, and therefore unclear to me how to interpret the notion of "Hilbert space" in this broader context. On the other hand, the argument makes no use of completeness, and the metric structure only enters through the inner product, so presumably the scope of Lax's final comment above is really just spaces equipped with a nondegenerate bilinear form (as in the question above). This led me to a question about what Lax wants to replace the isometry with in this broader context. He defines an isometry as (distance-preserving and) surjective, and implicitly uses this in the argument above because prima facie, "for all $u'$" means "for all $\phi u$ with $u\in H$"; this only ranges across all of $H$ if $\phi$ surjects. So the claim that results from a straightforward generalization of the above argument is that if $\phi$ preserves $B$ and is surjective onto $V$, then $\phi$ is linear. So this made me curious: what happens if $\phi$ is not surjective?