Neighbourhoods of the only preimage of a point under a map from a compact space

See it in Lean

Axioms
ZFC only
Concerns
Compact

Statement

Let \(f : X \to Y\) be a continuous map from a compact space \(X\) to a Hausdorff space \(Y\), and let \(x \in X\) and \(y \in Y\) be such that \(f^{-1}(\{y\}) = \{x\}\). Then a set \(N \subseteq X\) is a neighbourhood of \(x\) if and only if \(N \supseteq f^{-1}(M)\) for some neighbourhood \(M\) of \(y\).

Proof

If \(N \supseteq f^{-1}(M)\). Since \(f(x) = y\) and \(f\) is continuous, \(f^{-1}(M)\) is a neighbourhood of \(x\), and so is \(N\).

If \(N\) is a neighbourhood of \(x\). Let \(U \subseteq N\) be open with \(x \in U\). The set \(X \setminus U\) is closed in the compact space \(X\), so it is compact, and so is its image \(f(X \setminus U)\), which is therefore closed in the Hausdorff space \(Y\). It does not contain \(y\), since the only point mapped to \(y\) is \(x \in U\). So \(M = Y \setminus f(X \setminus U)\) is an open neighbourhood of \(y\), and \(f^{-1}(M) \subseteq U \subseteq N\), since a point outside \(U\) is mapped into \(f(X \setminus U)\). \(\blacksquare\)