  We derive a new criterion for a real-valued function $u$ to be in the Sobolev
space $W^{1,2}(\R^n)$. This criterion consists of comparing the value of a
functional $\int f(u)$ with the values of the same functional applied to
convolutions of $u$ with a Dirac sequence. The difference of these values
converges to zero as the convolutions approach $u$, and we prove that the rate
of convergence to zero is connected to regularity: $u\in W^{1,2}$ if and only
if the convergence is sufficiently fast. We finally apply our criterium to a
minimization problem with constraints, where regularity of minimizers cannot be
deduced from the Euler-Lagrange equation.

Functional Analysis;Optimization and Control