Union of Functions Theorem

Theorem
Let $X$ be a set.

Let $\left\{{X_i: i \in \N}\right\}$ be an exhausting sequence of sets on $X$.

For each $i \in \N$, let $g_i: X_i \to Y$ be a mapping such that:
 * $g_{i+1} \restriction X_i = g_i$

where $g_{i+1} \restriction X_i$ denotes the restriction of $g_{i+1}$ to $g_i$.

Then:
 * $\displaystyle \bigcup \left\{{g_i: i \in \N}\right\}$

is a mapping from $X$ to $Y$.

Proof
By definition, $\displaystyle g = \bigcup \left\{{g_i: i \in \N}\right\}$ is a relation whose domain is $X$.

$g$ is not a mapping.

Then for some $x \in X$ and $i, h \in \N$:
 * $(1): \quad x \in X_i, g_i \left({x}\right) \ne g_{i + h} \left({x}\right)$

Let $k \in \N$ be the smallest such that:
 * $g_i \left({x}\right) \ne g_{i + k}$

where $x$ and $i$ are the same as in $(1)$.

Then:
 * $g_{i + k - 1} \left({x}\right) = g_i$

But then:
 * $g_{i + k} \restriction X_{i + k - 1} = g_{i + k - 1}$

From this contradiction it follows that our supposition that $g$ is not a mapping must be false.

That is:
 * $\displaystyle \bigcup \left\{{g_i: i \in \N}\right\}$

is a mapping from $X$ to $Y$.