What is a topological space?

It is a mathematical device to define what a continuous function is, in a general setting.

1. A topological space is a set X together with a collection of subsets of X, called open, such that finite intersections of open sets are open, and arbitrary unions of open sets are open.

2. A function of topological spaces is continuous if inverse images of open sets are open.

What is the intuition behind (1) and (2)?

I claim that it is better to ask, instead, how mathematicians came up with (1) and (2).

1/

At the beginning, people considered continuous functions ℝ → ℝ.

One of the wrong intuitions, at that time, was that such a function is continuous if "you can draw it without lifting the pen".

A counter-example is Cantor's devil's staircase. This continuous function you can't draw, with or without lifting the pen.

https://en.wikipedia.org/wiki/Cantor_function

Mathematicians spoke of continuous functions for a long time before there was a precise definition of continuous function. This was a vague idea, which, nevertheless, was useful.

At some point the definition of continuity for a function f : ℝ → ℝ was elucidated.

∀ x ∈ ℝ , ∀ ε > o, ∃ δ > 0 , ∀ x' ∈ ℝ, ∣ x - x' | < δ → | f(x) - f(x') | < ε.

This definition allowed a lot of theorems to be proved rigorously. This is why it was useful.
A lot of theorems that were claimed, could now be proved.
2/

Cantor function - Wikipedia

This definition *does* have an intuition.

Suppose you want to calculate f(x₀), for example because you are an engineer and want to build a bridge, where x₀ is a physical quantity. Unfortunately, we can't measure x₀ exactly.

But you still want to know what y₀ = f (x₀) is, at least approximately.

But "approximately" doesn't mean anything. You want to know y₀, say, with two correct decimal digits. This will do to build a robust bridge.

Then the question is, how many correct digits of x₀ do you need to know, in order to get the desired two decimal digits of y₀?

More generally, we want the following to be the case. In order to know n digits of output of the function, it is enough to know m digits of the input, where m depends on the input and on n.

This is possible if and only if the function is continuous.

So one intuition about continuity is that "finite amounts of output depend on only finite amounts of input".

3/

@MartinEscardo

> In order to know n digits of output of the function, it is enough to know m digits of the input, where m depends on the input and on n.

if we demand that this dependency be computable (that from a desired output precision n I can compute the necessary input precision m), does this change the meaning of continuity?

@rntz @MartinEscardo Yes, it changes the notion of continuity. There are classically continuous functions that don't have any computable modulus of continuity (a function that tells you how much delta you need for a given epsilon).

(EDIT: This example is bad, see replies.) E.g. constant function that returns Chaitin's constant, because Chaitin's constant does not have a computable fast Cauchy sequence. (It has a computable Cauchy sequence that does not converge at a computable rate.)

@typeswitch @MartinEscardo interesting! Do you have any other examples? I think technically the Chaitin's constant constant function does not qualify as an example, because I didn't insist on the function itself being computable, only the "modulus" (I guess? not familiar with how to use that word correctly); so for any constant function (even non-computable), we require 0 bits of input to determine (but not compute) the entire output. Am I mistaken?
@rntz Yes, I think my first example was just bad actually. I tried to simplify the construction I had in mind (see the other reply) and then later realized i had simplified it too much.