4. If the equation $a=\left|\sqrt{1-x^{2}}-x-1\right|$ has real solutions, then the range of real number $a$ is $\qquad$
Let $x=\sin \theta, \theta \in\left[-\frac{\pi}{2}, \frac{\pi}{2}\right]$, then $a=|\cos \theta-\sin \theta-1|=\left|\sqrt{2} \cos \left(\theta+\frac{\pi}{4}\right)-1\right|$,
and $\theta+\frac{\pi}{4} \in\left[-\frac{\pi}{4}, \frac{3 \pi}{4}\right] \Rightarrow \cos \left(\theta+\frac{\pi}{4}\right) \in\left[-\frac{\sqrt{2}}{2}, 1\right]$
$\Rightarrow \sqrt{2} \cos \left(\theta+\frac{\pi}{4}\right)-1 \in[-2, \sqrt{2}-1] \Rightarrow a \in[0,2]$.