In "Electrodynamics of Continuous Media" Landau writes the following:
The total charge in the volume of the dielectric is zero; even if it is placed in an electric field we have $\int\bar{\rho}dV=0$. This integral equation, which must be valid for a body of any shape, means that the average density can be written as the divergence of a certain vector, which is usually denoted by $-\mathbf{P}$: $$\bar{\rho}=-\nabla \cdot \mathbf{P}$$ while outside the body $\mathbf{P}=0$. For, on integrating over the volume bounded by a surface which encloses the body but nowhere enters it, we find $$\int\bar{\rho}dV=-\int\nabla \cdot \mathbf{P}dV=-\oint \mathbf{P} \cdot d\mathbf{f}=0$$
However I don't quite understand how the vanishing of $\int\bar{\rho}dV=0$ for every volume guarantees that $\bar{\rho}$ can be written as the divergence of some vector field. In fact, it seems like a convenient ad hoc assumption used to employ the divergence theorem. I wasn't able to find any mathematical theorem that states that "if $\int_V f dV=0$ for every $V$ then $f=\nabla \cdot \mathbf{F}$ where $\mathbf{F}$ is some vector field".
He later uses a similar argument to derive the magnetization vector. He states that because the surface integral $\int \mathbf{j} \cdot d\mathbf{f} = 0$ for all cross-sectional areas in a dielectric it means that $\mathbf{j}$ can be written as a rotor of some vector field $\mathbf{M}$.
So is this a physical argument or a mathematical trick? And if it's the latter, how can it be justified?