Does Intermediate value theorem work depending on the domain Does it work when the domain and codomain are subsets of the reals? For example, any continuous function from a discrete subset of reals that satisfies the least upper bound property? Is this possible? If it breaks down, why?
 A: No. It is not true that every function from $\mathbb Z$ into $\mathbb R$ satisfies the intermediate value property (note that every function from $\mathbb Z$ into $\mathbb R$ is continuous), in spite of the fact that $\mathbb Z$ is discrete and that it satisfies the least upper bound property.
A: Let's say that a subset $\Bbb X$ of $\Bbb R$ has the IVT property if for every continuous map $f\colon X\to \Bbb R$ and every $x_1,x_2\in X$, $y\in \Bbb R$ with $f(x_1)<y<f(x_2)$, there exists $\xi\in X$ with $f(\xi)=y$.
Then $X$ has the IVT property iff $X$ is connected. 


*

*Assume $X$ has the IVT property. Let $U,V\subseteq \Bbb R$ be open sets such that $X\subseteq U\cup V$ and the sets $X\cap U$ and $X\cap V$ are disjoint. Define  $f\colon X\to\Bbb R$ as $f(x)=\begin{cases}1&x\in U\\0&\text{otherwise}\end{cases}$. Then $f$ is continuous. If there were $x_1,x_2\in X$ with $f(x_1)=0$ and $f(x_2)=1$, then the IVT property would tell us that $f(\xi)=\frac12$ for some $\xi\in X$. As this is absurd, such $x_1,x_2$ cannot exist, i.e., one of $U\cap X$, $Vcap X$ is empty. We conclude that $X$ is connected.

*Assume $X$ is connected. Let $f\colon X\to \Bbb R$ be continuous, $x_1,x_2\in X$, $y\in \Bbb R$ with $f(x_1)<y<f(x_2)$. Then the sets $f^{-1}((-\infty,y))$ and $f^{-1}((y,\infty))$ are disjoint and, by continuity of $f$, open subsets of $X$, They are also non.empty (contain $x_1$ and $x_2$, respectively). By connectedness of $X$ they thus cannot cover $X$. Hence there must exist $\xi\in X$ such that $f(\xi)\notin(-\infty,y)\cup(y,\infty)$, i.e., $f(\xi)=y$.
Quite obviously, discrete subsets of $\Bbb R$ (with at least two points) are not connected. Of course you can also see immediately that for any such discrete (or "gappy" in any other way) subset of $\Bbb R$, the continuous map $x\mapsto x$ breaks the Intermediate value prperty.
