Today’s problem appeared as Problem 9 on the Texas A&M Real Analysis Qual:
Problem 9. Prove or disprove that there exists a continuous function such that
is rational for
irrational and
is irrational for
rational.
Solution: Suppose such an did exist. For
an enumeration of the rationals, consider the sets
which are closed in
since
is continuous. Then, by assumption,
and
Thus, the irrationals would be a countable union of closed sets, which we call an
set. But the irrationals are not an
set (and the rationals are not a
set) by a classic Baire category theorem argument. Thus, such an
cannot exist.
Proof of the claim: By DeMorgan’s laws, it suffices to show the rationals are not a countable intersection of open sets. Suppose they were, i.e. Then, each
contains
and therefore must be dense in
Clearly then,
is also open and dense. But then,
which is impossible since by the Baire category theorem, an intersection of open dense sets has to be dense (and thus cannot be empty).
Remark: In general, there are lots of powerful nonconstructive existence/non-existence arguments that rely on the Baire category theorem. For example, it can be proven that there exists a continuous nowhere differentiable function (without providing a specific example of one).