
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given the function $f(x)=2\cos^2x+2\sqrt{3}\sin x\cos x+a$, and when $x\in\left[0, \frac{\pi}{2}\right]$, the minimum value of $f(x)$ is $2$,

$(1)$ Find the value of $a$, and determine the intervals where $f(x)$ is monotonically increasing;

$(2)$ First, transform the graph of the function $y=f(x)$ by keeping the y-coordinates unchanged and reducing the x-coordinates to half of their original values, then shift the resulting graph to the right by $\frac{\pi}{12}$ units to obtain the graph of the function $y=g(x)$. Find the sum of all roots of the equation $g(x)=4$ in the interval $\left[0,\frac{\pi}{2}\right]$.

Present the answer in LaTex format: \boxed{Your answer}
user