Integral of two functions over generating sets coincide, then the functions are the same a.e Let $f,g$ be non-negative measurable in a measure space $(X,\Sigma,\mu)$ and the $\sigma$-algebra $\Sigma$ is generated by a collection of sets $\mathcal{A}$. Suppose that
\begin{equation}
\int_{E} f \, d\mu = \int_{E} g \, d\mu, \forall E \in \mathcal{A}
\end{equation}
then are $f,g$ equal almost everywhere?

I believe this statement is false without extra conditions. A counter-example would be $X = [0,\infty)$ with the Borel $\sigma-$algebra and the Lebesgue measure. And for $\mathcal{A} = \{ [0,x], x > 0 \}$ and the functions $f = \frac{1}{x}$, $g = \frac{1}{\sqrt{x}}$, then we have trivially $\infty = \infty$ on each generating set.
What if we require $f,g$ to be integrable? Or only integrable on a sequence $\{E_{n}\} \in \mathcal{A}$ such that $\cup E_n = X$? I think this is true, my idea of a proof is showing that the collection of sets in $\Sigma$ where the integrals coincide is a $\sigma-$algebra containing $\mathcal{A}$ so it must be every measurable set.
Is this a standard result that I can check in some reference?
 A: Let $(X,\mathscr{A},\mu)$ be a measure space. Let $\mathscr{G}$ be an $\cap$-stable collection of subsets of $X$, and suppose $X \in \mathscr{G}$ and $\sigma(\mathscr{G})=\mathscr{A}$. If $f,g\in L^1(\mathscr{A})$ and $\smallint_G fd\mu=\smallint_G g d\mu,\,\forall G \in \mathscr{G}$, then $f=g$ a.e. To see this, we note
$$\mathscr{G}\subseteq \mathscr{C}:=\{A \in \mathscr{A}:\smallint_Afd\mu =\smallint_Ag d\mu \}\subseteq \mathscr{A}$$
We check that $\mathscr{C}$ is a Dynkin system. Since $X \in \mathscr{G}$, then $X \in \mathscr{C}$. If $C \in \mathscr{C}$, then $\smallint_Xfd\mu=\smallint_Xg d\mu$ and $\smallint_C fd\mu=\smallint_C gd\mu$; this implies first
$$\smallint_{C}f d\mu +\smallint_{C^c}fd\mu=\smallint_X fd\mu=\smallint_X gd\mu=\smallint_{C}g d\mu +\smallint_{C^c}gd\mu$$
then we substract $\smallint_Cfd\mu=\smallint_Cgd\mu$ (which are real-valued because $f,g$ are integrable) and we obtain $C^c \in \mathscr{C}$. Finally, if $(C_n)_{n \in \mathbb{N}}\subseteq \mathscr{C}$, mutually disjoint, then by dominated convergence (note $\mathbf{1}_{\cup_{k\leq n}C_k}|f|\leq \mathbf{1}_{\cup_nC_n}|f|\leq |f|\in L^1$) and linearity of integrals,
$$\begin{aligned}\int_{\cup_nC_n}fd\mu&=\int_X \sum_{n\in \mathbb{N}}\mathbf{1}_{C_n}fd\mu=\\
&=\lim_{n \to \infty}\sum_{k\leq n}\int_{C_k}fd\mu=\\
&=\lim_{n \to \infty}\sum_{k\leq n}\int_{C_k}gd\mu=\\
&=\int_{\cup_nC_n}gd\mu\end{aligned}$$
so $\cup_nC_n\in \mathscr{C}$. Then, we conclude that $\mathscr{C}$ is Dynkin, and $\mathscr{C}=\mathscr{A}$. This then implies that $f=g$ a.e.
