The sun is visible to us before actual sunrise and after actual sunset. The refractive index of air of normal density is about 1.0003 relative to vacuum. Further, the density of air is higher near the surface of earth. When sun is just below the horizon, the rays from the sun coming from through space enter earth's atmosphere and travel from rarer to denser medium. They bend towards the normal and appear to come from a point above the horizon (apparent position od sun). Therefore, sun appears above the horizon. Hence the sun appears to rise a few minutes before the actual rise and for the same reason, it continues to be seen a few minutes after it has actually set.