This is a puzzling point for me, and I see it often used in some textbooks when authors switch between differential and integral forms of equations (e.g. in electrodynamics). I wish to know if there is any proven mathematical theorem or lemma that relates to this.
Given the equality between two integrals:
$$\int_{V} f(x,y,z)\, dV =\int_{V} g(x,y,z)\, dV.$$
It is often said that, if this equality holds for an arbitrary domain $V$ (e.g. a volume), then this equality implies equality of the involved integrands too, that is $f=g$.
Now, although I understand that this works because the arbitrariness of $V$ implies that one could choose an infinitesimally small $V$ where the integrands could be considered constants and taken outside the integrals, allowing for the above conclusion to be obtained, I am not sure whether it is a general rule or one that doesn't have other necessary conditions.
For example, would it work if the functions $f$ and $g$ were dependent on $V$ to start with? We could have cases or phenomena where arbitrary $V$ gives different $f$ and $g$ and the equality of integrals still holds, but would it then still imply equality of integrands?
Is there any known theorem or lemma that talk about this more rigorously?