But, the law of conservation of energy strictly says that the velocity of the wall must be exactly zero

Actually, **it doesn't**. Energy is conserved, yes, but nothing has to be zero for it to be conserved.

The mistake is that you *assume* the wall to be stationary also after collision. This is your own assumption, and as you clearly show with momentum conservation, that cannot be true.

You have already realized that if the whole Earth is included in the picture, the momentum conservation law makes sense in the way that the Earth is given a tiny, tiny, tiny speed after collision. Now redo the energy conservation considerations with this in mind - in other words, redo the energy calculations *without* assuming that the wall/Earth is stationary.

In fact, the acquired Earth speed is so tiny that it is negligible - that's why it is usually just assumed zero.

There are a few preliminary points worth making. It is rarely useful to talk about photons when considering wave phenomena like refraction. Light waves are not simply made up of a hail of bullet like photons. The relationship is more complicated than that. However it is perfectly reasonable to talk about the momentum of a light wave and you are quite correct that the momentum of the light ray changes when the wave is refracted.

Refraction occurs when the light interacts with electrons in the refracting material. To (over?) simplify, the oscillating electric field of the light makes the electrons oscillate and the oscillating electrons reradiate an EM wave. The interference of this reradiated wave with the original wave causes the refraction.

It is this interaction that causes the momentum change, so the refraction of the light ray causes an equal and opposite momentum change in the refracting material i.e. refraction of the light ray exerts a force on the object doing the refracting.

## Best Answer

It is a manifestation of Noether's theorem.

In short, if you have translational invariance in particular direction you have a conservation of momentum in this direction.

Use of Hamilton equations lets you prove it very easily. Suppose there is a translational invariance in $i$-th direction. Hamiltonian ${\mathcal H}$ does not depend on this coordinate and partial derivative with respect to it is zero. Then:

$$ \dot{p}_i=-\frac{\partial {\mathcal H}}{\partial q_i}=0 $$

Thus $p_i=$const.

In your case Hamiltonian has translational invariance parallel to the boundary (it doesn't matter where to refract along the boundary, since medium is uniform).