This situation is best described as a catch-22, or a logical paradox which can be escaped only by denying its premise. The eponymous novel by Joseph Heller, Catch-22, contains the following illustration:
One must seek a declaration of insanity to be exempt from combat duty.
Those who go into combat duty are insane.
Therefore, to seek exemption from combat duty is tacit proof of one's own sanity. Under these circumstances, no declaration of insanity can ever be granted, but there is no recourse but to seek one.
The situation you set up between John and Mary is not exactly the same, because in reality Mary has a valid rebuttal available to her. She could respond with silence, and thereby disprove John's statement. Assuming you had constrained the situation so that only verbal rebuttals were acceptable, however, then I believe the word/idiom you're looking for is catch-22.