Let $S\subset\mathbb R$ be a $G\_\delta$ set. A variation on the construction of the Thomae function (which is discontinuous on the rationals and continuous elsewhere) shows that there is a function $\mathbb R\to\mathbb R$ that is continuous exactly on $S$. 


I'm trying to find a published reference for this result. Note: the wikipedia page on Thomae's function mentions an equivalent result, phrased in terms of $F\_\sigma$'s, without giving a reference.
So it's clear the result is well-known; but I'd like a reference in an article or book (even as an exercise) rather than just the wikipedia page.



If $S\subset\mathbb R$ is a $G_\delta$, is there a function $\mathbb R\to\mathbb R$ continuous exactly on $S$?
The result you are looking for can be found in most advanced references in topology or analysis. Since I am away from my office at the time of this writing, I will provide you with a source readily available on the internet: Theorem 7.2 (p.30) in [Oxtoby's Measure and Category](http://math.rice.edu/%7Emichael/teaching/426_Spr14/Banach_Mazur.pdf).


Note that Theorem 7.2 shows that any $F\_{\sigma}$ set is precisely the set of *discontinuities* of some real valued function on $\Bbb{R}$; the result you want the reference for is equivalent to Theorem 7.2 thanks to De Morgan Laws. This theorem, I suspect, is due to Lebesgue, but at the moment I do not have a reference at hand to corroborate my suspicion.


**Addendum:** [According to this source](https://groups.google.com/g/sci.math/c/JSZiDgWxlPk/m/jolpTO7A2wUJ) (see history of Theorem 2') the above result was first proved by William H. Young in 1903, and perhaps independently by Lebesgue in 1904.


