Suppose $X$ is a completely metrizable space. Let $A$ and $B$ be closed subsets of $X$ such that $A \subseteq B.$ Let $f:X \rightarrow \mathbb{R}$ be a non-negative function such that $f(x) = h(x)$ for $x \in A$, $f(x) = g(x)$ for $x \in B \setminus A$ and $f(x)=0$ for $x \in X \setminus B.$
Note that $h$ is upper semicontinuous on $X$ while $g$ is continuous on $B \setminus A.$
$A$ and $B $ are assumed to be countable sets.
Question: Is $f$ an upper semicontinuous function?
DEFINITION: $f$ is upper semicontinuous if for all real number $c$, we have $f^{-1}[c,\infty)$ is closed.
Let $c$ be given. Note that $f^{-1}[c,\infty) =X$ if $c\leq0$ and $f^{-1}[c,\infty)=(h^{-1}[c,\infty) \cap A) \cup g^{-1}[c,\infty)$ if $c >0$.
If $c\leq 0,$ then clearly $f$ is upper semicontinuous as $X$ is closed in itself.
If $c>0,$ then $h^{-1}[c,\infty) \cap A$ is closed in $X$ as $h$ is upper semicontinuous on $X.$
Note that $g$ is continuous on $B \setminus A.$ So $g^{-1}[c,\infty) = D$ is closed in $B \setminus A.$ By definition of subspace topology, there exists a closed set $F$ in $X$ such that $D = F \cap (B \setminus A) = F \cap B \cap A^c.$ However, $A^c$ is open in $X.$ I have no idea how to proceed from here.
UPDATE: Note that $F \cap B$ is closed in $X.$ So $D$ is closed in $A^c.$ So $D^c$ is open in $A^c.$ Therefore, there exists an open set $O$ in $X$ such that $D^c = O \cap A^c.$ Hence, $D = O^c \cup A$ is closed in $X.$
I am not very confident about my last statement because complement should be taken at $A^c.$
It is not True. Take $A=\{0\}$, $B= \{ x |~ 0 \leq x \} $, $h(x) = 1$, and $g(x) = \frac{1}{x} +3$.
Therefore $ f^{-1} [2, + \infty) = (0, +\infty) $ which is not closed!