Paragraph added after reading the OP’s previous question about renaming:
It’s really helpful for (aspiring) mathematicians to understand a couple of things that are more often taught in computer science than mathematics: a) the difference between bound and free variables in mathematical expressions, and b) the fact that the logical statements mathematicians write (especially if-then statements) often have hidden quantifiers. The following two statements mean the same thing:
If $n^2$ is even, then $n$ is even.
If $r^2$ is even, then $r$ is even.
This is because the variable in each is bound by a hidden/unwritten for all quantifier. On the other hand, the statements $n$ is even and $r$ is even do not mean the same thing, because in those, the variables are free — there is no for all or there exists quantifier (hidden or not). They are statements about a specific variable, $n$ or $r$. When combining statements that use the same letter, it’s often convenient to rename bound variables (where the particular letter is essentially meaningless) to avoid confusion.
My original answer:
Halmos is not saying that you should change letters when it changes the meaning.
The context for this is here, where Halmos describes what a sentence is so that he can discuss the axiom of specification. He gives his description with a set of grammatical productions. Formalizing it with Backus-Narr, it goes like this:
<letter> ::= a|b|c|...|A|B|C|... (Halmos doesn't list the <letter>s.)
(<letter> ∈ <letter>)
| (<letter> = <letter>)
| (<sentence> and <sentence>)
| (<sentence> or <sentence>)
| (not <sentence>)
| (if <sentence> then sentence)
| (<sentence> if and only if <sentence>)
| (for some <letter>, <sentence>)
| (for all <letter>, <sentence>)
Halmos assumes the reader pretty much knows what the possible sentences mean, but he takes a moment to point out (in different words than mine, and rather incompletely for modern readers, I think) that changing letters might be useful to clarify things. Consider these two sentences:
for some x, (x ∈ B)
(x ∈ A)
The first one doesn’t “depend on
x is bound by the quantifier. The second one does “depend on
x is free. No problem so far, but it becomes confusing if you combine the two into this compound sentence:
((for some x, (x ∈ B)) and (x ∈ A))
The meaning is unambiguous (
x is in
B is not empty), but why not write it this way, which is clearer?
((x ∈ A) and (for some y, (y ∈ B)))
(Note that you can’t change the first
y instead, because then the result depends on
x.) For another context where this renaming of bound variables is useful read about $\alpha$-conversion in the lambda calculus.