Lemma (continuous iff taking preimage preserves open or closed sets)

Let $(X,\tau)$ and $(Y,\rho)$ be topological spaces, and $f: X\to Y$. The following are equivalent:

Proof