  We study definable sets, groups, and fields in the theory $T_\infty$ of
infinite-dimensional vector spaces over an algebraically closed field equipped
with a nondegenerate symmetric (or alternating) bilinear form. First, we define
an ($\mathbb{N}\times \mathbb{Z},\leq_{lex}$)-valued dimension on definable
sets in $T_\infty$ enjoying many properties of Morley rank in strongly minimal
theories. Then, using this dimension notion as the main tool, we prove that all
groups definable in $T_\infty$ are (algebraic-by-abelian)-by-algebraic, which,
in particular, answers a question of Granger. We conclude that every infinite
field definable in $T_\infty$ is definably isomorphic to the field of scalars
of the vector space. We derive some other consequences of good behaviour of the
dimension in $T_\infty$, e.g. every generic type in any definable set is a
definable type; every set is an extension base; every definable group has a
definable connected component.
  We also consider the theory $T^{RCF}_\infty$ of vector spaces over a real
closed field equipped with a nondegenerate alternating bilinear form or a
nondegenerate symmetric positive-definite bilinear form. Using the same
construction as in the case of $T_\infty$, we define a dimension on sets
definable in $T^{RCF}_\infty$, and using it we prove analogous results about
definable groups and fields: every group definable in $T^{RCF}_{\infty}$ is
(semialgebraic-by-abelian)-by-semialgebraic (in particular, it is
(Lie-by-abelian)-by-Lie), and every field definable in $T^{RCF}_{\infty}$ is
definable in the field of scalars, hence it is either real closed or
algebraically closed.
