Show that $g(x)=\text{mid}\{f_1,f_1,f_3\}$ is measurable. Background
A family $\textbf{X}$ of subsets of $X$ is a $\sigma$ algebra in case:


*

*$\phi, \mathbb{R} \in \textbf{X}$

*$X \setminus A \in \textbf{X}$ if $A \in \textbf{X}$

*If $(A_n) \in \textbf{X}$, then the union $\bigcup_{n=1}^{\infty} A_n \in \textbf{X}$
Any set in $\textbf{X}$ is called $\textbf{X}-$ measurable.
A function is $\textbf{X}-$ measurable if for every real $\alpha$, the set $\{x \in X : f(x)>\alpha\}$ belongs to $\textbf{X}$
Question
Let mid$(a,b,c)$ be the middle number of $a,b,c$. Then it is known that $\text{mid}(a,b,c)=\text{inf}\{\text{sup} \ \{a,b\},\text{sup} \ \{a,c\},\text{sup} \{b,c\}\}$. 
If $f_1,f_2,f_3$ are $\textbf{X}-$ measurable then show that 
$$g(x)=\text{mid}(f_1(x),f_2(x), f_3(x))$$ is $\textbf{X}-$ measurable.
Attempt
(I will use the word measurable in place of $\textbf{X}-$ measurable)
I will show that if $f_1,f_2$ are measurable, then $m(x)=\text{sup}\{f_1(x),f_2(x)\}$ and $n(x)=\text{inf}\{f_1(x),f_2(x)\}$ are measurable. It seems to me that for any real $\alpha$,
\begin{align*}
\{x:m(x)>\alpha\}&=\{\text{sup}(f_1(x),f_2(x))>\alpha\} \\
&=\{f_1(x)>\alpha\}\cup \{f_2(x)>\alpha\}
\end{align*}
and 
\begin{align*}
\{x:n(x)>\alpha\}&=\{\text{inf}(f_1(x),f_2(x))>\alpha\} \\
&=\{f_1(x)>\alpha\}\cap \{f_2(x)>\alpha\}.
\end{align*}
But I cannot seem to give a rigorous proof of these two statements.
Next, unions and intersection of measurable sets are measurable so $m(x),n(x)$ are both measurable. The proof that $\text{mid}(f_1,f_2,f_3)$ is measurable is repeated application of these two facts.
 A: Here is a rigorous proof for the first one (you should try the second one on your own; the proof is very similar in method):
Prove $\{x : m(x) > \alpha \} = \{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(a) > \alpha \}$.
We will prove this by proving set inclusion both ways.
First, to prove $\{x : m(x) > \alpha \} \subseteq \{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \}$:

Let $x \in \{x : m(x) > \alpha \}$.  Then $\sup\{f_{1}(x), f_{2}(x)\} > \alpha$.  But since the set $\{f_{1}(x), f_{2}(x)\}$ is finite, its sup is its maximum.  So either the sup is $f_{1}(x)$ if $f_{1}(x) \geq f_{2}(x)$ or it is $f_{2}(x)$ if $f_{2}(x) \geq f_{1}(x)$.  If it is $f_{1}(x)$, then we get $f_{1}(x) > \alpha$.  If the sup is $f_{2}(x)$, then we get $f_{2}(x) > \alpha$.  So in every case, either $x \in \{ x : f_{1}(x) > \alpha \}$ or $x \in \{ x : f_{2}(x) > \alpha \}$.
But that means $x \in \{ x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \}$, which is what we wanted to show.  Thus, $\{x : m(x) > \alpha \} \subseteq \{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \}$, as desired.

Now to prove $\{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \} \subseteq \{x : m(x) > \alpha \}$:

Let $x \in \{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \}$.  Then either $x \in \{x : f_{1}(x) > \alpha \}$ or $x \in \{ x : f_{2}(x) > \alpha \}$.  If $x \in \{ x : f_{1}(x) > \alpha \}$, then since the sup is $\geq f_{1}(x)$, then the sup is $\geq \alpha$, so $x \in \{x : m(x) > \alpha \}$.
Otherwise if $x \in \{ x : f_{2}(x) > \alpha \}$, then since the sup is $\geq f_{2}(x)$, it follows that the sum is $\geq \alpha$, so $x \in \{x :m(x) > \alpha \}$.  So in every case, $x \in \{x : m(x) > \alpha \}$, which means $\{x : f_{1}(x) > \alpha \} \cup \{ x : f_{2}(x) > \alpha \} \subseteq \{x : m(x) > \alpha \}$, as desired.

