How to derive integration-by-parts formula for functions in Sobolev spaces? Suppose $\Omega$ is a bounded open subset of $\mathbb{R}^n$, and $\partial \Omega$ is $C^1$. Suppose also $u \in C^1(\bar{\Omega})$, $v \in C^2(\bar{\Omega})$. Then there holds
\begin{equation}
\int_\Omega \nabla u \cdot \nabla v \, \mathrm{d} x = \int_{\partial \Omega} u \frac{\partial v}{\partial \mathbf{n}} \, \mathrm{d} S - \int_{\Omega} u \Delta v \, \mathrm{d} x, \quad \quad (1)
\end{equation}
which can be derived via the product rule of differentiation and Green's formula in multivariate calculus. However, if instead, $u \in W^{1,p}(\Omega)$, $v \in W^{2,p}(\Omega)$, why would the integration-by-parts formula (1) still hold? I mean, it is by definition of weak derivative that the following formula holds for $u \in W^{1,p}(\Omega)$:
\begin{equation}
\int_\Omega \nabla u \cdot \nabla \phi \, \mathrm{d} x = - \int_\Omega u \Delta \phi \, \mathrm{d} x, \quad \forall \phi \in C_0^\infty(\Omega), \quad \quad (2)
\end{equation}
but what if $\phi \neq 0$ on $\partial \Omega$ and is differentiable only in weak sense?
 A: To generalize $(1)$ to Sobolev spaces first of all you need $u \in W^{1,p}(\Omega)$ and $v \in W^{2,q}(\Omega)$ where $\frac{1}{p} + \frac{1}{q} = 1$. Moreover you have to account for the fact that the restriction of  a Sobolev function to the boundary of $\Omega$ is not well defined since $\mathcal{L}^n(\partial\Omega) = 0$. (In the following $\mathcal{L}^n$ is the Lebesgue measure and $\mathcal{H}^{n-1}$ is the Hausdorff measure)
If $u \in W^{1,p}(\Omega)$ take a sequence $\{u_h\}_h \subset C^{\infty}(\bar{\Omega})$ such that $u_h \rightarrow u$ wrt $||\cdot||_{W^{1,p}(\Omega)}$ and define
$$u|_{\partial\Omega} := \lim_{h \to \infty} u_h|_{\partial\Omega}$$ where the limit is in $L^p(\partial\Omega,\mathcal{H}^{n-1})$ (this is well defined for the "trace inequality")
If $v \in W^{2,q}(\Omega)$ take a sequence $\{v_h\}_h \subset C^{\infty}(\bar{\Omega})$ such that $v_h \rightarrow u$ wrt $||\cdot||_{W^{2,q}(\Omega)}$ and define
$$\frac{\partial v}{\partial n} := \lim_{h \to \infty} \frac{\partial v_h}{\partial n}$$ where the limit is in $L^q(\partial\Omega,\mathcal{H}^{n-1})$ (this is well defined for the "normal trace inequality")
By approximation with smooth functions you can prove that
$$\int_\Omega D u \cdot D v d\mathcal{L}^n = \int_{\partial\Omega} u|_{\partial\Omega} \frac{\partial v}{\partial n} d\mathcal{H}^{n-1} - \int_\Omega u \Delta v d\mathcal{L}^n$$
for every $u$,$v$ as above. I think that you need $\partial \Omega$ to be only Lipschitz rather that $C^1$
