Showing existence of an extension for a measurable function on the whole set $X$ Let $ \mathcal U $ be a $\sigma$-Algebra on a set $X$ and $M \subseteq X$.
Let $f:M\longrightarrow \mathbb R$ be measurable in respect of the Trace-$\sigma$-Algebra $\quad \mathcal U|_M : =\{ U \cap M\mid U\in \mathcal U\}$.
Show: There exists an extension on whole $X$ which is also measurable
I tried to write $X = \bigcup M_i$ for $M_i \subseteq X.$  
Since $f$ is measurable  for each $M_i$ then it follows that $f$ is measurable for $\bigcup M_i$ in respect to $\mathcal U|_{\bigcup M_i}.$
Therefore I can define a function $h:X \longrightarrow \mathbb R$  with $h|_M = f$ which is measurable since $f|_{M_i} $ is measurable $\forall M_i$.
I am not really sure if this is the right way so i appreciate any help on this one . Thanks
 A: First, note you can assume that $f\ge0$, since in general $f=f_1-f_2$ with $f_j\ge0$.
Assume first that $f=\chi_E$, where $E$ is a measurable subset of $M$. Then the definition of "measurable subset of $M$" more or less gives you the extension.
So you're done if $f\ge0$ is simple. Now any positive measurable function is the limit of an increasing sequence of simple functions...
Edit: When I posted that I thought it was more or less a solution. On reflection maybe it's more just a suggestion of a possible approach. The detail I overlooked is this: Say $\phi_n$ is a sequence of simple funtions increasing to $f$. Say $\psi_n$ is a simple function on $X$ extending $\phi_n$. We need at least a little care to ensure that the sequence $\psi_n$ is increasing...
No problem, actually. Extend $\phi_1$ to a simple function $\psi_1$. Now $\phi_{n+1}-\phi_n$ is a non-negative simple function on $M$; the obvious method for extending simple functions extends it to a non-negative simple function $h_1$; let $\psi_2=\psi_1+h_1$. Etc.
