Q:

Which of the following condition ensure that the function $f:R^n\to R$ is continuous?

I encountered an interesting problem in my Economics class about continuity.
Which of the following conditions on the function $f:\mathbb R^n\to \mathbb R$ ensures that the function $f$ is continuous?

For all $y$ the sets $\{x:x\in \mathbb R^n, f(x) < y\}$ and $\{x:x\in \mathbb R^n, f(x) > y\}$ are open;
For all $y$ the sets $\{x:x\in \mathbb R^n, f(x) \le y\}$ and $\{x:x\in \mathbb R^n, f(x) \ge y\}$ are open;
For all $y$ the sets $\{x:x\in \mathbb R^n, f(x) < y\}$ and $\{x:x\in \mathbb R^n, f(x)> y\}$ are closed;
For all $y$ the sets $\{x:x\in \mathbb R^n, f(x) \le y\}$ and $\{x:x\in \mathbb R^n, f(x)\ge y\}$ are closed;

I have proved using contradiction that 3, 4 implies continuity.

The proof follows as below:
Suppose we assume 3, and suppose to the contrary that $f$ is not continuous. Then there exists sequence $x_n\to x_0$ such that $f(x_n) \not\to f(x_0)$. So given $\epsilon>0$, there exists some $N\in \mathbb{N}$ such that for all $n > N$, $|f(x_n)-f(x_0)|>\epsilon$. The last inequality is equivalent to $f(x_n)<f(x_0)-\epsilon$ or $f(x_n)>f(x_0)+\epsilon$.
Now from the assumption 3, the sets $\{x:x\in R^n, f(x) < f(x_0)\}$ and $\{x:x\in R^n, f(x)> f(x_0)\}$ are closed. Hence, it contains all its limit points. Without loss of generality, let us consider just left case. Since $f(x_n)<f(x_0)-\epsilon<f(x_0)$ for all $n>N$, the limit point of $x_n$ which is $x_0\in \{x:x\in R^n, f(x) < f(x_0)\}$. This implies $f(x_0)<f(x_0)-\epsilon$, a contradiction.

But I was not quite sure how to prove/disprove 1, 2 implies continuity. Number 1 seems close to topological definition of continuity, but it is weak (I think). Any helps, hints, or counter examples will be appreciated.

A:

Hint: 
Claim 1: Let $M,N$ be metric spaces. $f: M \to N$ is continuous if, and only if, the inverse image $f^{-1}(A')$ of every open subset $A' \subseteq N$, is open in $M$.
Claim 2: A subset $A \subset M$ is open, if, and only if, is a union of open balls. 
Now in (1), assume $\{x ; f(x) < y\}$ and  $\{x ; f(x) > y\}$ for all $y$ in $\mathbb R$. By Claim 2 we have that for anay open set $U$ in $\mathbb R$, $U = \bigcup_{\alpha \in I} (a_{\alpha}, b_{\alpha})$ and also 
$$(a_{\alpha}, b_{\alpha}) = (a_{\alpha}, \infty) \cap (-\infty, b_{\alpha}) \implies \begin{align}f^{-1}((a_{\alpha}, b_{\alpha})) &= f^{-1} ((a_{\alpha}, \infty)) \cap f^{-1}((-\infty, b_{\alpha})) \\&= \{x ; f(x) < a_{\alpha}\} \cap \{x ; f(x) > \alpha\}\end{align}$$
the intersection of any two open sets is open. Then $f^{-1} (a_{\alpha}, b_{\alpha}) $ is open. It follows that $$f^{-1}(U) = \bigcup_{\alpha \in I} f^{-1} ((a_{\alpha}, b_{\alpha}))$$
is open. Finally by Claim 1 $f$ is continuous. 
For (4) remember that if $A$ is closed in $M$ then $M - A$ is open. 

