Is there a TM that halts iff P = NP?
The answer to your question is formally &quot;yes&quot;. This is because one possible Turing machine that halts iff P=NP is either (i) a Turning machine that always halts or (ii) a Turing machine that never halts (regardless of its input).
However, the following argument might be closer in spirit to what you are asking:
Assume that $P=NP$ is not independent from the axioms you are (implicitly) using.
Since proofs are enumerable you could build a Turing machine $T$ that iterates over all &quot;candidate proofs&quot; that P=NP.
When a candidate proof $\pi$ is considered, $T$ checks whether $\pi$ is an anctual proof. If it is, $T$ halts immediately. If it isn't, $T$ continues with the next candidate proof.
It follows that $T$ halts iff $P=NP$.