For any closed set $A$ of $\mathbb R$ , does there exists a function $f:\mathbb R \to \mathbb R$ such that, $f$ is discontinuous exactly on $A$?

For any closed set $A$ of $\mathbb R$ , does there exists a function $f:\mathbb R \to \mathbb R$ such that, $f$ is discontinuous at every point in $A$ but, is continuous at all other points ?

• What about $f(x)=0$ for $x\in\mathbb{R}\setminus A$ and $f(x)=1$ if $x\in\mathbb{Q}\cap{A}$ and $f(x)=2$ if $x\in\mathbb{I}\cap{A}$. It will be continuous at each point $x_0$ outside of $A$ as it will be $0$ at an environment of $x_0$ (As $\mathbb{R}\setminus A$ is open), and obviously not continuous at $A$. – Nescio Jun 17 '15 at 13:55
• In my humble opinion that's worth an answer instead of a comment. – Alberto Debernardi Jun 17 '15 at 14:32
• Sorry if I wind up stealing your thunder, Nescio, because that is a really nice, clean example. – Ian Jun 17 '15 at 14:55
• For the opposite - continuous on a closed set $A$ - let $d_A(x)=\min\{\vert x-a\vert: a\in A\}$, and let $f(x)=0$ of $x\in A$ or $x\in\mathbb{I}$ and $d_A(x)$ if $x\in\mathbb{Q}\cap\overline{A}$. – Noah Schweber Jun 17 '15 at 16:46
• @NoahSchweber I'm skeptical, because the minimum needn't be attained if $A$ is not compact. (But I think that does indeed work if $A$ is compact.) – Ian Jun 17 '15 at 17:02

In general, if $X$ is a topological space, $Y$ is a metric space, and $f : X \to Y$ is a function, then the set of continuity points of $f$ must be a $G_\delta$ set in $X$, meaning a countable intersection of open sets. If $Y=\mathbb{R}$ and $X$ is a metric space with no isolated points (for instance, $\mathbb{R}$) then the converse is true, i.e. for any $G_\delta$ set $A \subset X$, there exists $f : X \to \mathbb{R}$ such that the set of continuity points of $X$ is $A$. A proof of this converse is given here: http://math.uga.edu/~pete/Kim99.pdf The construction is very similar to Nescio's comment; it is based on the construction of a dense set whose complement is dense, which in $\mathbb{R}$ is naturally given by $\mathbb{Q}$.

Your result follows from this, because an open set is certainly a $G_\delta$ set.

The proof of the first result is not difficult, but it is a little bit tricky. You first introduce the set $A_n$ of "$1/n$-continuity points", i.e. the points $x$ where there exists a neighborhood $U_x$ such that if $y \in U_x$ then $d(f(x),f(y))<1/n$. Then you prove that $A_n$ is open, and that the set of continuity points of $f$ is $\bigcap_{n=1}^\infty A_n$. In a somewhat less general context, this is an exercise in Royden and Fitzpatrick.

The "dual" problem, asking whether there is a function continuous on any given closed set, has the same answer. This follows from the second result above in concert with this: A closed set in a metric space is $G_\delta$ But the trend ends here, because there are $F_\sigma$ sets such as $\mathbb{Q}$ which cannot be a set of continuity points. You can prove this by assuming that $\mathbb{Q}$ is a $G_\delta$ and then using the Baire category theorem to conclude that $\mathbb{Q} \cap \mathbb{I} = \emptyset$ is dense in $\mathbb{R}$, which is an obvious contradiction.

It seemed to be popular enough in the comments so, You can consider a function defined as $f(x)=0$ for $x\in\mathbb{R}\setminus A$ and $f(x)=1$ if $x\in\mathbb{Q}\cap{A}$ and $f(x)=2$ if $x\in\mathbb{I}\cap{A}$. It will be continuous at each point $x_0$ outside of $A$ as it will be $0$ at an environment of $x_0$ (As $\mathbb{R}\setminus A$ is open), and obviously not continuous at $A$.

• Your last remark might be true, but its justification is not (at least not as is). Because a function can be continuous exactly on the irrationals (indeed Thomae's "popcorn function" is the classic example). – Ian Jun 17 '15 at 17:10
• In fact your last remark is simply not true at all. Cf. math.stackexchange.com/questions/317479/… and my answer. – Ian Jun 17 '15 at 17:15
• That what happens when I don't think... Removed – Nescio Jun 17 '15 at 17:23

If we take the Cantor's set C and and take its complement E and take the characteristic function f of E then f is continuous on E(being a countable disjoint union of intervals) and it is discontinuous on C since it is perfect and nowhere dense in R and since f is 0 on C.

• To clarify a little bit, a convergent sequence in $C$ converges to a point in $C$. This does no harm to continuity. A convergent sequence in $E$ could converge to a point in $E$ or to a point in $C$. If it converges to a point in $E$, again no harm is done to continuity. The harm occurs when a sequence in $E$ converges to a point in $C$; since this is possible, the characteristic function of $E$ (or of $C$, of course) is discontinuous on $C$. – Ian Jun 18 '15 at 0:16