In Sipser, there is a proof I don't understand.
First he established the undecidability of $A_\mathrm{TM}$, the problem of determining whether a Turing machine accepts a given input.
$$A_\mathrm{TM}=\left\{\left \langle M,w \right \rangle\mid M \text{ is a TM and }M \text{ accepts }w\right\}\,.$$
Then defined $\mathrm{HALT_{TM}} = \left\{\left \langle M,w \right \rangle\mid M \text{ is a TM and }M \text{ halts on input }w\right\}$, he assume that $\mathrm{HALT_{TM}}$ is decidable and use that assumption to show that $A_\mathrm{TM}$ is decidable, contradicting.
He assume that we have a TM $R$ that decides $\mathrm{HALT_{TM}}$. Then he uses $R$ to construct $S$:
$S$ = "On input $\left \langle M,w \right \rangle$, an encoding of a TM $M$ and a string $w$:
- Run TM $R$ on input $\left \langle M,w \right \rangle$.
- If $R$ rejects, reject
- If $R$ accepts, simulate $M$ on $w$ until it halts.
- If $M$ has accepted, accept; if $M$ has rejected, reject."
He says "Clearly, if $R$ decides $\mathrm{HALT_{TM}}$, then $S$ decides $A_\mathrm{TM}$. Because $A_\mathrm{TM}$is undecidable, $\mathrm{HALT_{TM}}$ also must be undecidable."
I don't understand why is so obvious the problem is $R$. I mean, I don't understand why if $R$ exists, then inevitably we can simulate $M$. We know that the step number 4 is not possible because $H(\left \langle M,w \right \rangle)$ = "accept if $M$ accepts $w$ OR reject if $M$ rejects $w$" is not possible, so why is $R$ guilty?