4. $\sin ^{2} 18^{\circ}+\cos ^{2} 63^{\circ}+\sqrt{2} \sin 18^{\circ} \cdot \cos 63^{\circ}=$ ().
(A) $\frac{1}{2}$
(B) $\frac{\sqrt{2}}{2}$
(C) $\frac{\sqrt{2}}{4}$
(D) $\frac{3}{4}$
4. A.

By the cosine rule, we have
$$
a^{2}+b^{2}-2 a b \cos C=c^{2} \text {. }
$$

By the sine rule, we have
$$
\begin{array}{l}
\sin ^{2} A+\sin ^{2} B-2 \sin A \cdot \sin B \cdot \cos C \\
=\sin ^{2} C .
\end{array}
$$

Let $\angle C=135^{\circ}, \angle A=18^{\circ}$, then $\angle B=27^{\circ}$.
Thus, $\sin ^{2} 18^{\circ}+\cos ^{2} 63^{\circ}+\sqrt{2} \sin 18^{\circ} \cdot \cos 63^{\circ}$ $=\sin ^{2} 18^{\circ}+\sin ^{2} 27^{\circ}-$
$$
2 \sin 18^{\circ} \cdot \sin 27^{\circ} \cdot \cos 135^{\circ}
$$
$$
=\sin ^{2} 135^{\circ}=\frac{1}{2}
$$