3 Functions
The language of functions is used throughout without pause. We record the definitions and the key asymmetry between images and preimages — the latter behaves well under all set operations, the former does not. This asymmetry is not a technicality; it is the reason continuity is defined the way it is.
3.1 Basic definitions
Definition 3.1 (Function) Let \(X\) and \(Y\) be sets. A function \(f : X \to Y\) is a rule assigning to each \(x \in X\) a unique element \(f(x) \in Y\).
The set \(X\) is the domain and \(Y\) is the codomain. Two functions are equal iff they have the same domain, the same codomain, and agree at every point. The codomain is part of the data: \(f : \mathbb{R} \to \mathbb{R}\) and \(f : \mathbb{R} \to [0,\infty)\) defined by \(f(x) = x^2\) are different functions — one is surjective, the other is not.
Definition 3.2 (Injectivity, surjectivity, bijectivity) Let \(f : X \to Y\).
- \(f\) is injective if \(f(x_1) = f(x_2) \Rightarrow x_1 = x_2\).
- \(f\) is surjective if for every \(y \in Y\) there exists \(x \in X\) with \(f(x) = y\).
- \(f\) is bijective if it is both injective and surjective.
The contrapositive of injectivity is often the more useful form: \(x_1 \neq x_2 \Rightarrow f(x_1) \neq f(x_2)\). For surjectivity, quantifier order matters — \(\forall y\, \exists x\) is surjectivity; \(\exists x\, \forall y\) would require a single element to map everywhere, which essentially never holds.
A bijective map is the only kind admitting a two-sided inverse \(f^{-1} : Y \to X\) satisfying \(f^{-1} \circ f = \mathrm{id}_X\) and \(f \circ f^{-1} = \mathrm{id}_Y\).
Exercise. Let \(f : X \to Y\) and \(g : Y \to Z\).
- Show that if \(g \circ f\) is injective then \(f\) is injective, but \(g\) need not be.
- Show that if \(g \circ f\) is surjective then \(g\) is surjective, but \(f\) need not be.
Suppose \(f(x_1) = f(x_2)\). Then \(g(f(x_1)) = g(f(x_2))\), and injectivity of \(g \circ f\) gives \(x_1 = x_2\). For the second claim, let \(X = \{1\}\), \(Y = \{1,2\}\), \(Z = \{1\}\), \(f(1) = 1\), and \(g \equiv 1\). Then \(g \circ f\) is injective, but \(g\) is not.
Given \(z \in Z\), surjectivity of \(g \circ f\) gives \(x\) with \(g(f(x)) = z\), so \(y = f(x)\) satisfies \(g(y) = z\). For the second claim, let \(X = \{1,2\}\), \(Y = \{1\}\), \(Z = \{1\}\), \(f\) constant, \(g = \mathrm{id}\). Then \(g \circ f\) is surjective, but \(f\) is not injective and has no reason to be surjective in general. \(\square\)
The asymmetry here — injectivity passes to \(f\), surjectivity to \(g\) — reflects the fact that injectivity is a condition on inputs and surjectivity on outputs. Composition only “sees” \(f\)’s inputs and \(g\)’s outputs directly.
3.2 Image and preimage
Definition 3.3 (Image and preimage) Let \(f : X \to Y\), \(A \subset X\), \(B \subset Y\).
- The image of \(A\) is \(f(A) := \{f(x) : x \in A\}\).
- The preimage of \(B\) is \(f^{-1}(B) := \{x \in X : f(x) \in B\}\).
The image of \(X\) itself, \(f(X) \subset Y\), is the range of \(f\).
\(f^{-1}(B)\) is defined for any function \(f\), with no assumption of bijectivity. When \(f\) is bijective, the two meanings of \(f^{-1}\) coincide, but the preimage is primary and the more general notion.
Notice in the right panel that two distinct points map to the same element of \(B\). The preimage does not care — it recovers everything responsible for \(B\), however tangled the map.
3.3 Preimages and set operations
The preimage commutes with every Boolean operation on \(Y\). The image does not.
Proposition 3.1 (Preimage commutes with set operations) Let \(f : X \to Y\), let \(\{B_\alpha\}_{\alpha \in \Lambda}\) be a family of subsets of \(Y\), and let \(B \subset Y\). Then
- \(f^{-1}\!\left(\bigcup_\alpha B_\alpha\right) = \bigcup_\alpha f^{-1}(B_\alpha)\),
- \(f^{-1}\!\left(\bigcap_\alpha B_\alpha\right) = \bigcap_\alpha f^{-1}(B_\alpha)\),
- \(f^{-1}(Y \setminus B) = X \setminus f^{-1}(B)\).
Proof.
\(x \in f^{-1}(\bigcup_\alpha B_\alpha)\) iff \(f(x) \in B_\alpha\) for some \(\alpha\), iff \(x \in f^{-1}(B_\alpha)\) for some \(\alpha\).
Replace “some” with “every.”
\(x \in f^{-1}(Y \setminus B)\) iff \(f(x) \notin B\), iff \(x \notin f^{-1}(B)\), iff \(x \in X \setminus f^{-1}(B)\). \(\square\)
For images, one always has \(f(A \cup B) = f(A) \cup f(B)\), but only \[ f(A \cap B) \subset f(A) \cap f(B), \] with equality iff \(f\) is injective. The failure: \(x_1 \in A \setminus B\) and \(x_2 \in B \setminus A\) can satisfy \(f(x_1) = f(x_2)\), placing that value in \(f(A) \cap f(B)\) but not \(f(A \cap B)\).
This failure is not a curiosity — it is why continuity is defined via preimages rather than images. The preimage formulation is stable under all set operations; the image formulation is not, and building a theory on an unstable foundation requires constant additional hypotheses.
Exercise. Prove or disprove: \(f(A \cup B) = f(A) \cup f(B)\) for all \(A, B \subset X\).
True. \(y \in f(A \cup B)\) iff \(y = f(x)\) for some \(x \in A \cup B\), iff \(y \in f(A)\) or \(y \in f(B)\), iff \(y \in f(A) \cup f(B)\). \(\square\)
This holds for arbitrary unions: \(f(\bigcup_\alpha A_\alpha) = \bigcup_\alpha f(A_\alpha)\). The same argument works with “some \(\alpha\)” throughout.
Exercise. Give an explicit example showing \(f(A \cap B) \subsetneq f(A) \cap f(B)\) is possible, and characterise when equality holds.
Let \(f : \{1,2\} \to \{0\}\) be the constant map, \(A = \{1\}\), \(B = \{2\}\). Then \(A \cap B = \varnothing\), so \(f(A \cap B) = \varnothing\), but \(f(A) = f(B) = \{0\}\), so \(f(A) \cap f(B) = \{0\}\).
Equality \(f(A \cap B) = f(A) \cap f(B)\) holds for all \(A, B\) iff \(f\) is injective. The forward direction: if \(y \in f(A) \cap f(B)\) then \(y = f(a) = f(b)\) for some \(a \in A\), \(b \in B\); injectivity gives \(a = b \in A \cap B\), so \(y \in f(A \cap B)\). The converse: if \(f\) is not injective there exist \(a \neq b\) with \(f(a) = f(b)\); take \(A = \{a\}\), \(B = \{b\}\). \(\square\)
3.4 Composition
Definition 3.4 (Composition) Let \(f : X \to Y\) and \(g : Y \to Z\). The composition \(g \circ f : X \to Z\) is defined by \((g \circ f)(x) := g(f(x))\).
<Figure size 672x480 with 0 Axes>
Composition is associative — \((h \circ g) \circ f = h \circ (g \circ f)\), a direct check from the definition — and not in general commutative; \(g \circ f\) and \(f \circ g\) need not even have the same domain.
Proposition 3.2 (Composition preserves injectivity and surjectivity) Let \(f : X \to Y\) and \(g : Y \to Z\).
- If \(f\) and \(g\) are injective, so is \(g \circ f\).
- If \(f\) and \(g\) are surjective, so is \(g \circ f\).
- If \(f\) and \(g\) are bijective, so is \(g \circ f\), and \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\).
Proof.
If \(g(f(x_1)) = g(f(x_2))\), injectivity of \(g\) gives \(f(x_1) = f(x_2)\), then injectivity of \(f\) gives \(x_1 = x_2\).
Given \(z \in Z\), surjectivity of \(g\) gives \(y\) with \(g(y) = z\); surjectivity of \(f\) gives \(x\) with \(f(x) = y\).
From (a) and (b). The formula \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\) is verified by checking both compositions yield the identity — the order reverses. \(\square\)
Exercise. Show that the preimage of a composition satisfies \((g \circ f)^{-1}(C) = f^{-1}(g^{-1}(C))\) for any \(C \subset Z\).
\(x \in (g \circ f)^{-1}(C)\) iff \(g(f(x)) \in C\), iff \(f(x) \in g^{-1}(C)\), iff \(x \in f^{-1}(g^{-1}(C))\). \(\square\)
This says preimage reverses composition, exactly as \((g \circ f)^{-1} = f^{-1} \circ g^{-1}\) does for invertible maps — but here no invertibility is assumed. It is used repeatedly in topology: the preimage of an open set under \(g \circ f\) is the preimage under \(f\) of an open set (since \(g^{-1}(C)\) is open when \(g\) is continuous and \(C\) is open), which is how continuity of compositions is proved.