A function $f :\Bbb R\to\Bbb R$ is continuous on $\Bbb R$ if and only if $f^{-1}(F)$ is closed in $\Bbb R$ whenever $F$ is closed in $\Bbb R.$

A function $$f :\Bbb R\to\Bbb R$$ is continuous on $$\Bbb R$$ if and only if $$f^{-1}(F)$$ is closed in $$\Bbb R$$ whenever $$F$$ is closed in $$\Bbb R.$$

My attempt so far:

We know that,

A function $$f :\Bbb R\to\Bbb R$$ is continuous on $$\Bbb R$$ if and only if $$f^{-1}(G)$$ is open in $$\Bbb R$$ whenever $$G$$ is open in $$\Bbb R.$$

Let $$F$$ be a closed set in $$\Bbb R.$$ This means that $$F^c$$ is open. Now, using the theorem above, we have, $$f^{-1}(F^c)$$ is open. Hence, $$(f^{-1}(F^c))^c=f^{-1}(F)$$ is closed.

Conversely, if for any closed set $$F$$, if we have, $$f^{-1}(F)$$ closed then let $$F$$ be a closed set. This means $$F^c$$ is open and as $$f^{-1}(F)$$ is closed so, $$(f^{-1}(F))^c=f^{-1}(F^c)$$ is also open. We thus have, $$f^{-1}(F^c)$$ is open whenever $$F^c$$ is open. But $$F$$ is arbitrary so is, $$F^c.$$ Hence, $$f$$ is continuous on $$\Bbb R.$$

Is the above solution correct? I think the part where I asserted, $$(f^{-1}(F))^c=f^{-1}(F^c)$$ needs a justification. I really can't come up with any. Is this assertion at all valid?

About the double inclusion: If $$x\in (f^{-1}(F^c))^c$$, then $$f(x)\notin F^c$$, thus $$f(x)\in F$$, which means that $$x\in f^{-1}(F)$$. If you reverse the reasoning, you get the desired identiny.