4. Given that the graph of a quadratic function is tangent to the lines containing the three sides of $\triangle A B C$. If the coordinates of the vertices of the triangle are $A\left(\frac{1}{4}, \frac{3}{2}\right), B\left(\frac{1}{2}, 1\right), C\left(\frac{3}{4}, 1\right)$, then the expression of the quadratic function is
4. $y=x^{2}-2 x+2$.

Let the quadratic function be (undetermined coefficient method)
$$
y=a x^{2}+b x+c \quad(a \neq 0) .
$$

By the two-point form, the equations of the three sides of the triangle can be found as
$$
\begin{array}{l}
A B: y=-2 x+2, \\
B C: y=1, \\
C A: y=-x+\frac{7}{4} .
\end{array}
$$
(1) and (2) combined to eliminate $y$, we get the quadratic equation in $x$
$$
a x^{2}+(b+2) x+(c-2)=0 \text {. }
$$

By the tangency, the discriminant is 0, i.e.,
$$
\Delta_{1}=(b+2)^{2}-4 a(c-2)=0 \text {. }
$$

Similarly, from (1) and (3), we have
$$
\begin{array}{l}
a x^{2}+b x+(c-1)=0, \\
\Delta_{2}=b^{2}-4 a(c-1)=0 ;
\end{array}
$$

From (1) and (4), we have
$$
\begin{array}{l}
a x^{2}+(b+1) x+\left(c-\frac{7}{4}\right)=0, \\
\Delta_{3}=(b+1)^{2}-4 a\left(c-\frac{7}{4}\right)=0 .
\end{array}
$$
(5), (6), and (7) combined to eliminate $c$, we get
$$
\left\{\begin{array}{l}
b+a+1=0, \\
2 b+a+3=0 .
\end{array}\right.
$$

Solving, we get $b=$
$$
-2, a=1 \text {. }
$$

Substituting into (5), we get
$$
c=2 \text {. }
$$

Therefore, the required quadratic function is
$$
y=x^{2}-2 x
$$
+2 (Figure 9).