Why 'equality almost everywhere' is transitive? Rudin RCA p.27
Let $\mu$ be a measure.
Define $f\sim g$ iff $\mu(\{x|f(x)≠g(x)\})=0$ ($f,g$ are measurable functions from $X$ to a topological space $Y$.
How come this relation $\sim$ is transitive?
Let'a assume $f\sim g$ and $g\sim h$.
By assumtion, $\{x|f(x)≠g(x)\}$ and $\{x|g(x)≠h(x)\}$ are measurable sets.
However, why this gurantees that $\{x|f(x)≠h(x)\}$ is measurable? If this is not measurable, then $\mu(\{x|f(x)≠h(x)\})$ is not defined, hence $f$ is not equivalent with $h$.
 A: If you assume $f, h$ are measurable functions (which is an acceptable assumption) then $\{x;f(x)\neq h(x)\}$ is a measurable set and we have $\{x;f(x)\neq h(x)\}\subseteq \{x;f(x)\neq g(x)\}\cup \{x;g(x)\neq h(x)\}$.
A: Since you're saying $f\sim g$ and $g\sim h$ it is implicitly given that $f,g,h$ are measurable. To show that $\mu(\{x\mid f(x)\neq h(x)\})=0$ show and use that
$$
\{x\mid f(x)=g(x)\}\cap\{x\mid g(x)=h(x)\}\subseteq\{x\mid f(x)=h(x)\}.
$$
A: I'm assuming all our functions are $\mathbb{R}^n$ valued, with $\mathbb{R}^n$ given Lesbesgue measure. In general, for any two such $f,g$, $f-g$ is measurable, and so the set of points where $f \neq g$ is simply the preimage of $\mathbb{R}^n - 0$ under $f-g$, hence measurable. 
Edit: As pointed out in other comments, for $Y$ arbitrary if the measure on $X$ is complete it follows this is an equivalence relation. I just wanted to add that if $Y$ is Hausdorff you don't need this: for any $f,g$, the set of points where $f = g$ is exactly the pullback of the diagonal of $Y \times Y$, which is closed.
A: Note that:
$$\forall x\in X[f(x)\not=h(x)\implies f(x)\not=g(x) \,or\ g(x)\not=h(x)] $$
Thus:
$$\{x|f(x)\not= h(x)\}\subseteq \{x|f(x)\not=g(x)\}\cup\{x|f(x)\not=g(x)\}$$
Now use the monotonicity of an outer measure along with the fact that the union of two null sets is a null set.
A: Concerning the measurability of $$ A = \{x| f(x) \neq h(x)\}$$
If $f$ and $g$ are measurable functions so is $$t(x)=f(x)-h(x)$$
Now note that  $$ A = t^{-1}(- \infty,0) \cup t^{-1}(0, +\infty)$$ which by definition is measurable.
On a final note, this works if the topological space you are mapping your functions into has the order topology, for example $f$ and $g$ map to $\mathbb{R}$ or the extended real line. If it is a general topological space think about what kind of set $A$ is. Is it open, closed? What happens when you take the preimage of it by a continuous function?
