Let $Z=(X,Y) : \Omega\rightarrow\mathbb{R}^2$ be a Borel-measurable random vector and $U\subset\mathbb{R}$ be open. Suppose that $Z$ is absolutely continuous with Lebesgue density $\zeta$.
I was wondering about the following question: If we assume that $\zeta$ factorizes on the square $U\times U$, i.e. that the restriction
$$\tag{1}q:=\left.\zeta\right|_{U\times U} \quad\text{is such that}\quad q\equiv q(x,y)=q_1(x)q_2(y) \quad\text{for some } \ q_1, q_2 : U\rightarrow\mathbb{R},$$ does this imply that $X$ and $Y$ are independent on $U$ in the sense that
$$\tag{2}\mathbb{P}(X^{-1}(A)\cap Y^{-1}(B)) = \mathbb{P}_X(A)\cdot\mathbb{P}_Y(B)\quad\forall\, A, B\subseteq U \ (\mathrm{Borel})?$$
Clearly this holds for both the special cases $U=\mathbb{R}$ and $q_i = \zeta_i$ ($i=1,2$, with $\zeta_i$ the marginal densities of $\zeta$), however I couldn't show it in the above generality; do you have a counterexample? (Apologies if this question is too basic.)