Oops...I meant REFRACTION. Actually, it is a combination of refraction and dispersion. You can think of the Sun's image as a superposition of images at red, orange, yellow, green and blue wavelengths. With no atmosphere, all coincide with each other and you see a yellow sun. With the atmosphere at the horizon, the atmosphere refracts the light rays forming each disk at different amounts so that the 'red' disk is less refracted and sets first, followed by the orange, yellow and green disks. Blue light is most heavily refracted and absorbed by the atmosphere so it isn't seen, leaving the 'green disk' the last to set, and producing the flash. If you look at the article in the February, 1992 issue of Sky and Telescope page 200, you will read more about this, and also get the basic code for a simple program that models this phenomenon.