[Math] Are functions that map dense sets to dense sets continuous

general-topologymeasure-theoryreal-analysis

Suppose $X$ and $Y$ are separable metric spaces, and that $f:X\rightarrow Y$ is a bijective function that maps every countable dense set of $X$ to a dense set of $Y$.

Are functions with this property necessarily continuous?

If not, if $g:X\rightarrow Y$ is bijective and Borel do we obtain that property (dense sets map to dense sets)?

Thanks for any information.

Best Answer

Consider the function $f: \mathbb R \rightarrow \mathbb R$ defined by

$$f(x)=\begin{cases}x & x\neq 1,2 \\ 2 &x=1\\ 1 &x=2\end{cases}.$$

That is $f$ is the identity except it swaps $1$ and $2$. Then $f$ is Borel and bijective and maps countable dense sets to countable dense sets, since if $D \subset \mathbb R$ is a dense subset and $x \in D$ then $D\setminus \{x\}$ is also dense.

Edit: I misread your second question. I think we can make a map that messes with the rationals and is still Borel. Let $g: \mathbb R \rightarrow \mathbb R$ be the identity on the irrationals. Let $g$ map the negative rationals to themselves and let $g$ send $\mathbb N$ to the positive non-integer rationals and send the positive non-integer rationals to $\mathbb N$. Then $g$ should still be Borel, but $\mathbb Q \setminus \mathbb N$ is a countable dense subset whose image is not dense under $g$.