I'm taking an introduction to computation theory class and we went over the chapter on undecidable problems and proving undecidability through reductions. I can't seem to grasp some of the simplest problems when it comes to reduction however.
For example there is the problem
$\mbox{REGULAR}_{TM} = \{ \langle M \rangle \mid M\mbox{ is a Turing Machine and }L(M)\mbox{ is a regular language}\}$
Most of the time the answers involve creating your own auxiliary Turing Machine. For this example, my book decides to reduce from $A_{TM}$ my book uses $M_{aux}$. I show what $M_{aux}$ looks like within the decider $S$ for $A_{TM}$ they formulated ($R$ is the decider for $\mbox{REGULAR}_{TM}$):
$S = $ "On input $\langle M , w \rangle$, where $M$ is a TM and $w$ is a string:
Construct the following TM $M_{aux}$:
$M_{aux}$: "On input $x$:
- If $x$ has the form $0^n1^n$, then accept.
- If $x$ does not have this form, run $M$ on input $w$ and accept if $M$ accepts $w$."
Run $R$ to on $\langle M_{aux} \rangle$.
- If $R$ accepts, accept. If $R$ rejects, reject."
I don't really understand where $x$ comes from and how $M_{aux}$ uses $x$. According to the book, $M_{aux}$ works by automatically accepting all strings in $\{0^n1^n\mid n \ge 0\}$. If $M$ accepts $w$, $M_{aux}$ accepts all other strings. But what if $M$ doesn't accept $w$ in the second step? In that case it looks like $M_{aux}$ would reject. What happens then?
My main problem is just that I don't understand how $M_{aux}$ runs and how the decider for $R$ uses it. I've looked over many other examples and I understand how to actually create proofs like this, but what I don't understand is the subroutine machine that they create, like $S$ does.