  We consider a continuous path of bounded symmetric Fredholm bilinear forms
with arbitrary endpoints on a real Hilbert space, and we prove a formula that
gives the spectral flow of the path in terms of the spectral flow of the
restriction to a finite codimensional closed subspace. We also discuss the case
of restrictions to a continuous path of finite codimensional closed subspaces.
As an application of the formula, we introduce the notion of spectral flow for
a periodic semi-Riemannian geodesic, and we compute its value in terms of the
Maslov index.
