TITLE: Is there a way to phrase "continuous" in terms of "connected"?
QUESTION [26 upvotes]: This is something of a pedagogical question. Most of us have scratched our heads at some point as to why the definition of "$f$ is continuous" requires that the preimage of any open set under $f$ is open, then done a bunch of examples, then convinced ourselves. I think our confusion comes because when we first encounter "continuity" we are generally expecting a statement about what $f$ does to the images of sets, and get frustrated when we see a statement about what $f$ guarantees about the preimages of sets.
I think that we might be able to restore this by instead looking at subspaces of the topological space and whether they are connected according to their subspace topology. Let's call a subset of a topological space which is connected according to its subspace topology a "connected subset". Connectedness is inherently a negative notion ("there does not exist two open sets...") and thus one is naturally induced to look at a contrapositive -- at images rather than preimages.
So I think there might be a way to start from a more-intuitive definition, for example: "$f: X \to Y$ is continuous iff $X$ and $Y$ are topological spaces and the image of any connected subset of $X$ is a connected subset of $Y$." This would seem immediately intuitive to a student, I feel. And if we start from there, then immediately the contrapositive accomplishes the reversal: "$f: X \to Y$ is continuous iff the preimage of any disconnected subset of $Y$ is a disconnected subset of $X$."
Now it's clear that the latter is necessary for $f$ to be continuous according to the conventional definition. If $f$ is conventionally-continuous  then when we factor a disconnected subset of $Y$ into two disjoint open subsets, the preimage of each subset is open and the preimages of two disjoint sets must also be disjoint, proving that the subset of $X$ was disconnected, too. 
However I am struggling with rigorously proving sufficiency and thereby deriving the conventional definition from the intuitive one. The existential quantifiers of disconnectedness seem to really get in my way: for example even if I could somehow state "for every nonempty open set there exists some other disjoint nonempty open set" (which is false for the trivial topology but maybe that's not such an issue) the above definition seemingly does not guarantee that the corresponding preimages of the two are open -- maybe this partition of the $Y$-subset has very little to do with the partition of the $X$-subset, for example. So it's not clear to me how to push past these weird existentials and come to "the preimage of any open set is open" again.

Am I missing some obvious counterexample that shows this whole enterprise is a mistake, or clarifies some extra assumptions I'll need in my definition to make it work?
If not, what technique might I use to finish the sufficiency side of the proof?

REPLY [6 votes]: For a counterexample, consider 
$$
\begin{array}{l}
f : \mathbb R \to \mathbb R
\\
f(x) = \begin{cases} \sin(1/x) & \mbox{if } x\neq 0 \\
0 & \mbox{otherwise}
\end{cases}
\end{array}
$$
which is not continuous at $0$.
In spite of that, we can show that $f$ is connected-set-continuous, that is: if $X \subseteq \mathbb R$ is a connected set (i.e. an interval), then the image $f(X)$ is connected (an interval).
Indeed, if $0\not\in X$, then $f$ is continuous on $X$ and by the intermediate value theorem $f(X)$ is an interval.
If $X=\{0\}$ then $f(X)=\{0\}$ which is connected (a degenerate interval).
Otherwise, $X$ contains either $[0,\epsilon)$ or $(-\epsilon,0]$ for some $\epsilon>0$, hence $f(X)=[-1,+1]$.