TITLE: A Pasting lemma for measurable functions
QUESTION [6 upvotes]: I have the following setting:

Let $(\Omega,\Sigma)$, $(\Gamma, \mathcal{C})$, $(X_{1},\mathcal{B}_{1})$, and $(X_{2},\mathcal{B}_{2})$ be measurable spaces such that $\Omega = X_{1}\cup X_{2}$, $X_{1}\cap X_{2} = \emptyset$, $\mathcal{B}_{1} = \{X_{1}\cap A:A\in\Sigma)$, $\mathcal{B}_{2} = \{X_{2}\cap A:A\in\Sigma)$.
Let $f_{1}:X_{1}\to\Gamma$ and $f_{2}:X_{2}\to\Gamma$ be measurable.
Then I think $f:=\begin{cases}f_{1} & \text{ on }X_{1}\\f_{2} & \text{ on }X_{2}\end{cases}$ is measurable as a function $f:\Omega\to\Gamma$.

The following seems to work, could someone confirm this is correct and that I haven't overlooked anything?

Let $A\in \mathcal{C}$, then $f^{-1}(A) = (X_{1}\cap f^{-1}(A))\cup (X_{2}\cap f^{-1}(A)) = \underbrace{f_{1}^{-1}(A)}_{\in \mathcal{B_{1}}}\cup \underbrace{f_{2}^{-1}(A)}_{\in\mathcal{B_{2}}}\in\Sigma.$

REPLY [2 votes]: Yes, your argument is correct.