I was going through the Palatini formalism in order to obtain the Einstein equations and the fact that the connection $\nabla$ is the Levi-Civita one. Using the variational approach, I vary the action integral
$$S=\int \sqrt{-g} g^{ab}R_{ab}d^4x.$$
After some calculations, one obtains that
$$\delta S = \int\sqrt{-g}\big[ \nabla_cW^c-\nabla_cg^{ab}\delta\Gamma^c_{ab} +\nabla_bg^{ab}\delta\Gamma^c_{ac} \big]d^4x,$$
where $W^c = g^{ab}\delta\Gamma^{c}_{ab} - g^{ac}\delta\Gamma^{b}_{ab}.$
The last two terms between the square brackets indeed could be brought to the form $F(g)\delta\Gamma^c_{ab}$ such that $F(g)=0$ implies $\nabla$ is Levi-Civita, but I am struggling to find a trick to make $\sqrt{-g}\nabla_cW^c$ vanish (most probably as a boundary term).
Any help more than welcome!
Thanks!
You're right, it is a boundary term.
By Gauss' theorem $$ \int_U\sqrt{-g}\nabla_a W^a\ d^4x=\int_{\partial U}\sqrt{|h|}n_a W^a\ d^3\xi, $$ where $\xi$ are coordinates on the boundary, $h$ is the determinant on the induced metric on the boundary and $n_a$ is the unit normal vector pointing outwards from the boundary.
In the Palatini-formalism, the metric and the connection are both configuration variables, so boundary conditions can be prescribed for both of them. Thus, if $\delta\Gamma|_{\partial U}=0$ is prescribed, then $W|_{\partial U}=0$, thus the term vanishes.
EDIT: I have a bit of a hard time adapting to your derivation, so I'll do it my way. This may or may not directly answer your question, but will most likely solve your problem.
The difference between two connections is a tensor field. Let $\nabla$ denote the dynamical connection, and $\hat{\nabla}$ the Levi-Civita connection. Then $$ \nabla_XY=\hat{\nabla}_XY+C(X,Y). $$
We will use $C$ to represent the connection $\nabla$. It is clear that the variation of $\nabla$ is the same as the variation of $C$. It is less clear, but even if the LC connection is used as the reference connection, it doesn't get varied when the metric is. Why? Because an arbitrary connection can be used as a reference connection, we can always use the LC connection belonging to the unperturbed metric.
For arbitrary auxiliary vector field $X$, we have $\delta\nabla_a X^b=\delta A^b_{\ ac}X^c$, where $A$ are the connection coefficients of $\nabla$, but we also have $\delta\nabla_a X^b=\delta(\hat{\nabla}_aX^b+C^b_{\ ac}X^c)=\delta C^b_{\ ac}X^c$, so we can simply take $C$ as the connection variable.
The curvature tensor of $\nabla$ (which I'll denote with $F$ instead of $R$) can be expresse with the curvature tensor of the LC connection as $$ F^c_{\ dab}=R^c_{\ dab}+\hat\nabla_aC^c_{\ bd}-\hat\nabla_bC^c_{\ ad}+C^c_{\ ae}C^e_{\ bd}-C^c_{\ be}C^e_{\ ad}.$$ Variation passes through the LC connection unimpeded, so $$ \delta F^c_{\ dab}=\hat\nabla_a\delta C^c_{\ bd}-\hat\nabla_b\delta C^c_{\ ad}+\delta C^c_{\ ae}C^e_{\ bd}+C^c_{\ ae}\delta C^e_{\ bd}-(a\leftrightarrow b), $$
$$ \delta F_{ab}=\hat\nabla_c\delta C^c_{\ ab}-\hat\nabla_b\delta C^c_{\ ca}+\delta C^c_{\ ce}C^e_{\ ab}+C^c_{\ ce}\delta C^e_{\ ab}-\delta C^c_{\ be}C^e_{\ ca}-C^c_{\ be}\delta C^e_{\ ca} $$ $$ g^{ab}\delta F_{ab}= ... $$
I don't want to go on from here on because this is getting too long, but 1) I think if you expand your $\nabla_c g_{ab}$s in terms of $\hat\nabla$, you'll get the same terms as I do (except for the parts containing the covariant derivatives), 2) I'll do the part involving the covariants: $$ g^{ab}(\hat\nabla_c\delta C^c_{\ ab}-\hat\nabla_b\delta C^c_{\ ca})=\hat\nabla_c\delta C^c_{ab}g^{ab}-\hat\nabla_c\delta C^b_{\ ba}g^{ac}=\hat\nabla_c W^c. $$ But here now it is the LC connection that appears, and Gauss' theorem can be utilized.