Problem with proving the undecidability of REGULAR$_{TM}$ Sipser in his book provided the following proof for undecidability of  REGULAR$_{TM}$:


  S = “On input $&lt;M,w&gt;$, where $M$ is a TM and w is a string:
  
  
  Construct the following TM $M_2$.
  
  $M_2$= “On input $x$:
  
  
  If $x$ has the form $0^n1^n$, accept .
  If $x $ does not have this form, run $M$ on input $w$ and
  accept if $M$ accepts $w$.”
  
  Run $R$ on input $&lt;M_2&gt;$.
  If $R$ accepts, accept; if $R$ rejects, reject .”
  


and it also states:


  Note that the TM $M_2$ is not constructed for the purposes of actually running it on some input. We construct $M_2$ only for the purpose of
  feeding its description into the decider for REGULAR$_{TM}$ that we have assumed to exist.


So it means we don't run the $M$ on $w$ at all. I would like to know why when the $M_2$ accepts regular languages we conclude that the $M$ accepts $w$ while we never run $M$ on $w$? The reduction must have a meaningful relationship between the problems. I can't understand this relation in this problem.

thanks
Note $M_2$ is constructed based on $\langle M,w\rangle$. That is to say, different $\langle M,w\rangle$ may result in different $M_2$.

If $M$ accepts $w$, then $M_2$ will accept any string (if the input has the form $0^n1^n$, $M_2$ accepts it at the first step, otherwise $M_2$ accepts it at the second step), thus $M_2$ accepts a regular language.

If $M$ does not accept $w$, then $M_2$ will only accept string of the form $0^n1^n$ (if the input has the form $0^n1^n$, $M_2$ accepts it at the first step, otherwise $M_2$ skips the first step, and will not accept it at the second step), thus $M_2$ accepts a non-regular language.

So we can conclude $M$ accepts $w$ iff $M_2$ accepts a regular language.