$f: \mathbb R^2 \to \mathbb R$ be a function whose restriction on the graph of any continuous function on open set is continuous , is $f$ continuous? Let $f: \mathbb R^2 \to \mathbb R$ be a function such that for every open set $U \subseteq \mathbb R$ and continuous function $h:U \to \mathbb R$ , $f|_{G(h)} : G(h) \to \mathbb R$ is continuous ($G(h):=\{(x,h(x))|x \in U\}$) , then is it true that $f$ is continuous ? 
 A: Suppose $f$ is discontinuous at some $(x_0,y_0).$ Then there exists $\epsilon>0$ and a sequence $(x_n,y_n) \to (x_0,y_0)$ such that 
$$\tag 1 |f(x_n,y_n) -f(x_0,y_0)| > \epsilon \text { for all } n.$$
By passing to a subsequence if necessary, we can assume $(x_n)$ is monotonic. WLOG, we can assume the sequence is decreasing, so that $x_1\ge x_2 \ge \cdots \ge x_0$ for all $n.$
Claim: We can choose a sequence $x_n'$ in $\mathbb R$ such that $x_1' > x_2' > \cdots \to x_0$ such $f(x_n',y_n) - f(x_n,y_n) \to 0.$
Suppose the claim is true. We then define a continuous $h$ on $\mathbb R$ as follows: $h$ is linear on each $[x_{n+1}',x_n'],$ with values $y_{n+1}, y_n$ at the endpoints. Then define $h(x) = y_0$ for $x\le x_0$ and $h(x) = y_1$ for $x\ge x_1.$ (Good to draw a picture here.)
By hypothesis, $f\circ h$ is continuous on $\mathbb R.$ Thus $f(x_n',h(x_n')) = f(x_n',y_n) \to f(x_0,y_0).$ The claim then forces $f(x_n,y_n) \to f(x_0,y_0)$ as well, contradiction.
Proof of the claim: The hypotheses imply that $f$ is continuous on every horizontal line. Thus
$$\lim_{x\to x_1^+} f(x,y_1) = f(x_1,y_1).$$
Therefore we can choose $x_1'>x_1$ such that
$$|x_1'-x_1| < 1, \text { and } |f(x_1',y_1) - f(x_1,y_1)| <1.$$
Because $x_2\le x_1$ and $\lim_{x\to x_2^+} f(x,y_2) = f(x_2,y_2),$ we can choose $x_2'\in (x_2,x_1')$ such that
$$|x_2'-x_2| < 1/2, \text { and } |f(x_2',y_2) - f(x_2,y_2)| <1/2.$$
Continiung by induction produces a sequence $x_n'$ such that $x_1' > x_2' > \cdots \to x_0$ and such that
$$|x_n'-x_n| < 1/n, |f(x_n',y_n) - f(x_n,y_n)| <1/n$$
for all $n.$ This proves the claim, and finishes the proof.
A: Suppose it's not continuous at $(x,y)\in\mathbb R^2$. Then, $$\exists \varepsilon>0:\forall n\in\mathbb N, \exists (x_n,y_n)\in\mathbb R^2: \|(x_n,y_n)-(x,y)\|<\frac{1}{n}\quad \text{and}\quad |f(x_n,y_n)-f(x,y)|>\varepsilon.$$
Let $h$ a continuous function s.t. $y_n=h(x_n)$. In particular, by continuity of $h$, we have $y=h(x)$. Using the fact that $G(h)$ is closed, $(x,h(x))\in G(h)$, what contradict $f$ continuous on $G(h)$.
