Is topology just the minimal mathematical structure you need to define on a set just to define continuous functions?

I think the answer to your question is a qualified "Yes!". A topology is indeed in many ways secondary to the continuous functions that are defined on it and it often convenient to make the continuous functions primary and induce the topology using that.

A great example of this is the Zariski topology on, say, $\mathbb C^n$. The topology is defined in the following way: It is the weakest topology that makes all polynomial functions $f: \mathbb C^n \to \mathbb C$ continuous where we give the target the cofinite topology which corresponds to the intuition that we can tell when the polynomial takes a particular value. So closed sets are precisely generated by zero sets of polynomials.

This idea can be made more sophisticated by talking about sheaves and such things but the fundamental point always is that we care about the functions first, topology second.

In case of the standard topology on Euclidean space, it is perhaps not so clear what the continuous functions should be a priori which is why the answer to your question is a qualified yes. The other way of thinking about closed and open sets is that closed sets are the "answers to questions you can ask about the space".

That is, in the Euclidean topology, we can always know if a particular number lies in say $[0,1]$. We just compute the first few significant digits and check. On the other hand, we can never be sure that a particular number lies in $(0,1)$. Even if the number looks like $0.00000\dots$ with a million leading zeros, the next digit might be non zero. Of course this is superficially related to the representation of the number we are using but any "computable" representation will have this property.

This is related to the continuous functions point of view because the function "n-th digit of a number" is a function we would very much like to be continuous.


I like Asvin's answer a lot, but I would like to add an answer of a slightly different flavor.

I see the answer as "yes," because a topology is the minimum amount of structural information about a space that is generally used in mathematics to decide whether a function is continuous.

The definition of "continuous" was probably first given with respect to functions from $\mathbb{R}$ to $\mathbb{R}$ (or subsets thereof), and defined with respect to $\mathbb{R}$'s metric structure, although the definition predated the idea of "$\mathbb{R}$'s metric structure" so nobody would have described it that way. A function $f:\mathbb{R}\rightarrow \mathbb{R}$ is continuous at a point $c\in \mathbb{R}$ if for all $\varepsilon >0$, there exists a $\delta >0$ such that $|x-c|<\delta\Rightarrow |f(x)-f(c)|<\varepsilon$. (Notice that the metric structure of $\mathbb{R}$ is playing the key role here, as $|x-c|$ and $|f(x)-f(c)|$ are both measurements given by the metric.) A function $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous (no reference to a specific point) if it is continuous at each point $c\in \mathbb{R}$.

In this context, at some point it was noticed (and proven as a theorem) that $f$ being continuous on all of $\mathbb{R}$ is actually equivalent to the property that for any open set $U\subset\mathbb{R}$, the inverse image $f^{-1}(U)$ is also open. Working out this equivalence (for functions $\mathbb{R}\rightarrow \mathbb{R}$) is a very satisfying exercise.

Once this theorem was articulated and proven, it became possible to make the following profound observation: While the original definition of continuity made explicit use of distances like $|x-c|$ and $|f(x)-f(c)|$, actually it would be possible to determine whether $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous without being able to access these distances, as long as we still have access to whether or not any given set is open. In other words, the knowledge of which sets are open is enough information to determine continuity. Furthermore, if we changed how distances are measured but in such a way that it didn't change which sets are the open ones (for example by replacing $|x-y|$ with $2|x-y|$ as the distance between $x$ and $y$), it would not change which functions are the continuous ones. To summarize, while it initially appeared that the metric was intrinsically involved in determining if a function was continuous, the above theorem means that really it's just that the metric determines which sets are open, and the collection of open sets is really what determines continuity.

This is what paved the way for the definition of a topology. If knowing which sets are open is really what determines whether functions are continuous, then we can drop the metric from the definition completely and use the conclusion of the above theorem as a definition: if $X,Y$ are any spaces such that I know how to determine whether their subsets are open, then $f:X\rightarrow Y$ is defined to be continuous if for each open $U\subset Y$, the inverse image $f^{-1}(U)$ is open in $X$. Thus the information about which sets are open (i.e., the topology) is really the only info you need to determine continuity.

(I see this as analogous to the progression in learning trigonometry from (a) originally defining $\sin \theta$ as the ratio of certain sides in a right triangle, which only makes sense when $0<\theta<\pi/2$, but then (b) learning as a theorem that this definition of $\sin \theta$ coincides with the $y$-coordinate of a certain point on the unit circle, to finally (c) replacing the ratio of sides definition with this $y$-coordinate of the unit circle point as the definition, so that $\sin\theta$ can be defined even when $\theta$ is not in the interval $(0,\pi/2)$. Similarly, continuity is (a) first defined with respect to a metric, but then (b) it is proven as a theorem that the definition coincides with a criterion based only on open sets, and finally (c) the criterion based on open sets replaces the metric-based definition as the definition, allowing continuity to be defined even when there is no metric, as long as you know which sets are open.)

Let me add a comment relating this train of thought to William Elliot's answer, because it pulls in a somewhat different direction. William Elliot's answer foregrounds limits as the key idea of a topology, whereas this answer, and Asvin's, foreground continuity. I see this difference as essentially one of taste. Limits and continuity are deeply interlinked concepts. Indeed, the classical $\varepsilon$-$\delta$ definitions of the two notions (for functions $\mathbb{R}\rightarrow \mathbb{R}$) look almost identical. One can define either in terms of the other. So while my tendency (per the above) is to view continuity as the fundamental property that a topology abstracts from a metric space, I'm not really arguing against William Elliot's decision to view limits as the key thing being abstracted. It seems to me one can choose which way one prefers to look at it, and develop a complete theory from either starting point.