Original question:
Suppose $f$ is a real, continuous function defined on the closed set $E \subset \mathbb{R}^1$. Prove that there exists real, continuous function $g$ on $\mathbb{R}^1$ such that $g(x) = f(x) \forall x \in E$.
Proof:
Suppose $f$ is a real, continuous function defined on the closed set $E \subset \mathbb{R}^1$. Then, $E^c$ is open in $\mathbb{R}^1$. Then $E^c$ can be expressed as a union of an at most countable collection of pairwise disjoint open intervals and we can write $$E^c = \cup_{i = 1}^{n} (a_i, b_i) \cup (-\infty, a_0) \cup (b_0, +\infty).$$ where either $n$ is finite or $n \in \mathbb{N}$ and $a_i < b_i$. Next, define $g$ as
$g(x) = \begin{cases} f(x) & \text{if $x \in E$} \\ f(a_i)+(x-a_i)\frac{f(b_i)-f(a_i)}{b_i-a_i} & \text{if $x \in (a_i, b_i)$} \\ f(b_0) & \text{if $x \in (b_0, +\infty)$} \\ f(a_0) & \text{if $x \in (-\infty, a_0)$} \end{cases}$
Clearly, $g$ is an extension of $f$ on $\mathbb{R}^1$ and it remains to show that $g$ is continuous on $\mathbb{R}^1$.
Now, to show that $g$ is continuous if $x\in E$, I found a proof that begins with:
Given $x\in E$ and $\epsilon>0$, by the continuity of $f$ on $E, \exists \delta_0>0$ such that $$y\in E \textrm{ and } |y-x|<\delta_0 \implies |f(y)-f(x)|<\epsilon/2.$$ If there exists a $z\in E$ with $x-\delta_0<z<x$, set $\delta_1=x-z$ and note that
\begin{equation*} \sup_{x-\delta_1<y<x} |g(y)-g(x)| = \sup \{|f(y)-f(x)|:y\in E, x-\delta_1<y<x\} \le \epsilon/2 < \epsilon \end{equation*}
My question: Why is it true that $\sup_{x-\delta_1<y<x} |g(y)-g(x)| = \sup \{|f(y)-f(x)|:y\in E, x-\delta_1<y<x\}$? I think that this is true because $g$ is a linear extension of $f$. Why can the $\sup$ be restricted to the $y$-values $x-\delta_1<y<x$?