Attempt Define $f(x)=x_1^2+x_2^2$ and $g(x)=-x_1-x_2+4\le 0$
a) Clearly $g(\overline x)\le 0$ and $f(\overline x)=8,$ thus $\overline x$ is optimal solution.
b)
We have that the Lagrangian dual problem is given by $\max \theta (u), s.t. u\ge 0,$ where $\theta (u)= \inf \{f(x)+u^tg(x)\}$.
The dual function is given by $\theta(u)=\inf\{x_1^2+x_2^2+u(-x_1-x_2+4):x_1,x_2\in X\}=-3u$ if $u\ge 0$
if $u<0$, then $\theta(u)=3u$.
However it does not match with the expected dual function $\theta(u)=-u^2/2=4u$ :(
- If we consider this dual function $\theta(u)=-u^2/2-4u$ then $\max \theta(u)=8$ when $u=-4$. Hence does not exist duality gap.
Could someone please tell me why I get a different dual function?
What am I doing wrong? I just split the infimum and each of them gave $-u/2$. Hence the total infimum is $-u+4u=3u$

Let's consider how to minimize $x_1^2+x_2^2+u(-x_1-x_2+4)$ where $u \ge 0$ is fixed.
If we differentiate wrt $x_i$, we obtain
$$2x_i-u=0$$
Hence $$x_i=\frac{u}2 \ge 0$$
Hence the optimal value is
$$2\left( \frac{u}2\right)^2+u\left(-u+4 \right)$$
I think you left out the quadratic part and I can't tell where does $-u$ comes from.