Rudin's definition of continuity in terms of pre-images (inverse images). Is this simple function continuous or not? I am reading W. Rudins book ``Principles of Mathematical Analysis''.
I find it hard to exactly understand the definition of continuity
in terms of pre-images. Rudins definition of a continuous function
is: 
A mapping $f$ of a metric space $X$ into a metric space $Y$ is
continuous on $X$ if and only $f^{-1}\left(V\right)$ is open in
$X$ for every open set $V$ in $Y$.
So lets say I define the simple linear function $f(x)=x$ as a function
$f:\left[0,1\right]\rightarrow\mathbb{R}$. Personally I believe this
function to be continuous, but I cannot make it fit with the definition.
If I choose the open set as, say, $V=\left(-1,2\right)$, I find the
pre-image to be $f^{-1}\left(V\right)=\left\{ \left.x\in X\right|f\left(x\right)\in V\right\} =\left[0,1\right]$,
hence a closed set. The definition then tells me the function is not
continuous.
What is wrong?
 A: The topology on a subspace $(Y, \mathfrak{N})$ of a metric space $(X, \mathfrak{M})$ is formed by all the intersections of each open sets of $(X, \mathfrak{M})$ with $Y$ as subset. 
I'll prove that the restriction of a continuous function to a subspace is still continuous (it may happen the converse, that the restriction of a non-continuous function happens to be continuous - it's always the case when the subspace is discrete for instance).
Take $f:X\to Z$ a continuous function, and $Y$ a subspace of $X$. The preimage by $f$ of an open set $B\subseteq Z$ is an open $A\subseteq X$. Let $f'$ be the restriction of $f$ on $Y$ (sometimes indicated by $f|_Y$). The preimage of $B$ by $f'$ is by definition the set of points $y\in Y$ for which $f(y)\in B$, which is exactly $A\cap Y$, which by the definition of the subspace topology is open. $\qed$
Your example function is clearly continuous from $ℝ$ to $ℝ$ — the identity is always continuous — so all restrictions of it on any subspace are continuous too.
As @PrahladVaidyanathan correctly says, the confusion comes from forgetting that a space is always open in itself.
A: The whole space is always both closed and open in itself. It is the entire universe as far as this problem is concerned. –  Prahlad Vaidyanathan
Prahlad gives the correct understanding and note here whole space is restricted to [0,1] so [0,1] is always closed and open with respect to itself [0,1]. And you could find this result at the chapter of set topology in baby rudin.
