To see why this works, suppose aw is in L. Then P' will simulate, with epsilon input, whatever P does until it makes a move that reads the a. From that point, P' can only simulate P, and thus accepts w if and only if P accepts aw.
We must prove that if L does contain all these strings, then it contains every string of 0's. We could prove by induction on i that 0^{m+i} is in L for all i. However, an equivalent, and in this case easier, argument is a ``shortest counterexample'' argument.
Suppose that, although all strings of 0's of length up to m are in L, there is some string 0^k that is not. Then k > m, surely. Let k be the smallest integer with that property; i.e., all strings of 0's, from epsilon up to 0^{k-1} are in L. Consider 0^{k-n!}. Because k > n! + n, 0^{k-n!} is of length at least n. Thus, the pumping lemma applies to it, and we know that we can write 0^{k-n!} = uvwxy such that vx, of length between 1 and n, can be ``pumped.'' Since the length of vx surely divides n!, we know we can find some i, namely i = 1+n!/|vx|, such that uv^iwv^iy = 0^k. By the pumping lemma, it follows that 0^k really is in L after all. If there is no shortest string of 0's that is not in L, then there can be no string of 0's at all that is not in L; i.e., L contains all strings of 0's, if it contains all the strings up to 0^m.
The resulting program assigns to x if and only if P prints hello, world. If we could tell whether the new program assigns to x, we could tell whether the given program P was a hello, world. printer, which we know we cannot do. Thus, the hypothetical ``assign to x'' tester does not exist.
That is, q, the start state, says ``we have not yet seen a b''; state p says ``we have seen a b, but not yet reached a blank,'' and r is the accepting state, reached if we get to a blank after moving over 0 or more a's and 0 or more b's.