Suppose that $preim_{f}(C)$ is compact for every $C \subset N$. Show that if $E$ is a closed subset of $M$, then $f(E)$ is closed in $N$. I stumbled across this question, of two parts while studying for my second exam for my class on metric spaces. Note: I denote the preimage of a subset $C \subset N$ (under the map $f$) as $preim_{f}(C)$, which is of course a subset of the domain. This is simply to avoid using the notation $f^{-1}(C)$ so its clear I'm not referring to the inverse of $f$.
Let $(M,d_M)$ and $(N,d_N)$ be metric spaces and let $f : M \to N$ be continuous.

$a)$ Suppose that $preim_{f}(C)$ is compact for every $C \subset N$. Show that if $E$ is a closed subset of $M$, then $f(E)$ is closed in $N$.


$b)$ Show that if $M$ is not compact, there is a continuous function $f : M \to N$ such that $f(E)$ is closed for every subset $E$ of $M$, but $preim_{f}(C)$ is not compact for some compact subset $C$ of $N$.

I included both parts as I believe $a)$ compliments $b)$ nicely; they are also relatively short arguments.

$a)$ We have that $f$ is continuous and $preim_{f}(C)$ is compact $\forall C \subset N$. Therefore since $E \subset M$ is closed, without loss of generality since $f$ is continuous, suppose $E = preim_{f}(C)$ assuming $C$ is closed in $N$. However, we know that $preim_{f}(C)$ is compact for every $C$ of $N$, so $E$ is compact. So $f(E)$ is compact and since $f(E) \subset E$, $f(E)$ is closed. So $f$ is a closed map. $\blacksquare$
$b)$ If $M$ is not compact and $preim_{f}(C)$ is not compact for some $C \subset N$, then every subset $E$ of $M$ must be compact in order for $f(E)$ to be closed (again, using the idea that the continuous image of a compact set is compact). Therefore $f(E)$ is closed for every subset of $M$.
Is my work for these two parts correct? Any criticism is welcome and if there is a more efficient way to do any of this, please share.
 A: In your argument for (a) you assume that $C$ is closed in $N$, but you don’t justify this assumption. You also don’t justify the assumption that $E$ is the preimage of some subset of $N$, which may well be false if $f$ is not injective. Finally, $M$ and $N$ need not be the same space, so you definitely can’t say that $f[E]\subseteq E$. I would argue as follows:

$M=f^{-1}[N]$, so by hypothesis $M$ is compact. If $E$ is a closed subset of $M$, then $E$ is compact, so $f[E]$ is compact. Finally, $N$ is a metric space and therefore Hausdorff, so its compact subsets are closed, and in particular $f[E]$ is closed.

For (b) you seem to have misunderstood the question: on the assumption that $M$ is not compact you have to find a function $f:M\to N$ such that $f[E]$ is closed for each closed $E\subseteq M$, but there is a compact $C\subseteq N$ such that $f^{-1}[C]$ is not compact. The only non-compact subset of $M$ that you know for sure is $M$ itself, so it would be reasonable to try to find a function $f:M\to N$ and a compact subset $C$ of $N$ such that $f^{-1}[C]=M$. We don’t really know anything about $N$ beyond the fact that it’s a metric space, so the only subsets of $N$ that are guaranteed to be compact are the finite ones. What about picking a point $p$ in $N$ and letting $f(x)=p$ for each $x\in M$? That’s certainly continuous, and $\{p\}$ is a compact subset of $N$ whose preimage under $f$ is not compact. Is $f[E]$ closed for each closed $E\subseteq M$? Absolutely: $f[E]$ is closed for every $E\subseteq M$.
A: I'm afraid I would have constructed the arguments differently. Sorry!
Part (1). I don't think we can suppose that $E = f^{-1}(C)$ for some closed $C \subset N$. In fact, $E$ might not even be a preimage of any subset of $N$, closed or otherwise.
Instead, define $C := f(E)$. The best we can say is that $E \subseteq f^{-1}(C)$; this inclusion could either be a proper inclusion or it could be an equality, we don't know which. By assumption, $f^{-1}(C)$ is compact in $M$. And closed subsets of compact metric spaces are compact. Can you finish off from here?
Part (2). It looks like you're starting your argument assuming that there exists a (compact) $C \subset N$ such that $f^{-1}(C)$ is not compact. But that is actually the thing we'd like to prove.
Why not construct a simple map $f: M \to N$ that fits the bill? How about the constant map?
