TITLE: Function is continuous if and only if preimages of elements of a subbase are open.
QUESTION [10 upvotes]: I recently started studying Topology, and functions defined from one topological space to another.
I found on Wikipedia, where I was reading about subbase, that 'continuity of a function need only be checked on a subbase of the range.'
That is, if $\mathcal B$ is a subbase for $Y$, a function  $f  : X \to Y$ is continuous if and only if  $f^{−1}(U)$ is open in $X$ for each $U \in\mathcal B$.
I tried to prove it by taking an open set in $Y$ and showing that its inverse is also open if $f$ is continuous, after that I studied the structure of $O$ and found that each $O$ is in fact union of finite intersections of elements of $\mathcal B$, and I got stuck, how to show that the inverse of unions of finite intersections of elements of $\mathcal B$ to be open?
May be it's very easy,but it's not striking my head, hope to get a help.
Thank you.

REPLY [5 votes]: You can check it directly using the fact that the open sets are unions of finite intersections of the subbasis, but here is an approach which is also useful for other contexts (like measure theory, where measurable sets are not so easily described).
Firstly, we let the definition of topology generated by a subbasis be the natural one: it is the smallest topology containing the elements of the subbasis. It should be an easy exercise to check that this is equivalent to whatever definition you have.
Let $f: (X,\tau) \to (Y,\tau')$ be such that $f^{-1}(S)$ is open for every $S$ an element of the subbasis $\mathcal{S}$ of $(Y,\tau')$. Note now that it suffices to show that the set $$\mathcal{O}:=\{A \subset Y \mid f^{-1}(A) \in \tau\}$$
is a topology on $Y$. Since it contains the elements of $\mathcal{S}$ by hypothesis, we will have that $\tau' \subset \mathcal{O}$ by definition of subbasis. Consequently, $f$ is continuous.
But that $\mathcal{O}$ is a topology follows readily from the equations involving $f^{-1}$ and intersections/unions, and the fact that $\tau$ is a topology.