Assume
.
Then either
or not...
If it does, then the the
and we are good. If not, there is a better path. Since we check all
neighbours, (which is all the possible paths we can consider using one
more step than before) we know that
is at least as good as the optimal solution. Since it can't be better, we
are sure that
.