  The images of many distant galaxies are displaced, distorted and often
multiplied by the presence of foreground massive galaxies near the line of
sight; the foreground galaxies act as gravitational lenses. Commonly, the lens
equation, which relates the placement and distortion of the images to the real
source position in the thin-lens scenario, is obtained by extremizing the time
of arrival among all the null paths from the source to the observer (Fermat's
principle). We show that the construction of envelopes of certain families of
null surfaces consitutes an alternative variational principle or version of
Fermat's principle that leads naturally to a lens equation in a generic
spacetime with any given metric. We illustrate the construction by deriving the
lens equation for static asymptotically flat thin lens spacetimes. As an
application of the approach, we find the bending angle for moving thin lenses
in terms of the bending angle for the same deflector at rest. Finally we apply
this construction to cosmological spacetimes (FRW) by using the fact they are
all conformally related to Minkowski space.
