Fermat's principle states that that the path taken between two points by a ray of light is the path that can be traversed in the least time. This can be used to describe the properties of light rays such as reflection of mirrors, refraction through different media and total internal reflection.
Fermat's Principle leads to the principle of geometrical reversibility which states that any actual ray of light in an optical system, if reversed in direction, will retrace the same path backward.