[proofplan]
We prove measurability of $g$ directly from the definition by checking preimages of arbitrary Borel sets. For a Borel set $B\subset\mathbb{R}$, the preimages $f^{-1}(B)$ and $g^{-1}(B)$ can differ only at points where $f$ and $g$ differ, hence only inside the null set $N$. Completeness makes these discrepancy sets measurable, and then $g^{-1}(B)$ is obtained from measurable sets by finite set operations.
[/proofplan]
[step:Compare the Borel preimages of $f$ and $g$ outside the null set]
Let $B\in\mathcal{B}(\mathbb{R})$ be arbitrary. Define the sets $A_B:=f^{-1}(B)=\{x\in X:f(x)\in B\}$ and $G_B:=g^{-1}(B)=\{x\in X:g(x)\in B\}$.
Since $f$ is $\mathcal{M}/\mathcal{B}(\mathbb{R})$-measurable and $B$ is Borel, we have $A_B\in\mathcal{M}$.
Define the discrepancy sets $C_B:=G_B\setminus A_B$ and $D_B:=A_B\setminus G_B$.
If $x\in C_B$, then $g(x)\in B$ and $f(x)\notin B$, so $f(x)\ne g(x)$ and therefore $x\in N$. Thus $C_B\subset N$. If $x\in D_B$, then $f(x)\in B$ and $g(x)\notin B$, so again $f(x)\ne g(x)$ and $x\in N$. Thus $D_B\subset N$.
Because $(X,\mathcal{M},\mu)$ is complete, every subset of the measurable null set $N$ belongs to $\mathcal{M}$. Hence $C_B,D_B\in\mathcal{M}$.
[guided]
Fix an arbitrary Borel set $B\in\mathcal{B}(\mathbb{R})$. To prove that $g$ is measurable, we need to prove that its Borel preimage belongs to $\mathcal{M}$. We compare that preimage with the corresponding preimage under $f$, since $f$ is already known to be measurable.
Define $A_B:=f^{-1}(B)=\{x\in X:f(x)\in B\}$ and $G_B:=g^{-1}(B)=\{x\in X:g(x)\in B\}$.
The set $A_B$ is measurable because $f$ is $\mathcal{M}/\mathcal{B}(\mathbb{R})$-measurable and $B$ is a Borel subset of $\mathbb{R}$. The set $G_B$ is the set whose measurability we must prove.
The only possible obstruction is that $f$ and $g$ may differ on $N$. We isolate exactly where the two preimages disagree by defining $C_B:=G_B\setminus A_B$ and $D_B:=A_B\setminus G_B$.
If $x\in C_B$, then $x\in G_B$ and $x\notin A_B$. Therefore $g(x)\in B$ while $f(x)\notin B$, so the two [real numbers](/page/Real%20Numbers) $f(x)$ and $g(x)$ are unequal. Hence $x\in N$, and $C_B\subset N$.
Similarly, if $x\in D_B$, then $x\in A_B$ and $x\notin G_B$. Therefore $f(x)\in B$ while $g(x)\notin B$, so $f(x)\ne g(x)$ and $x\in N$. Hence $D_B\subset N$.
This is the exact point where completeness is used. The set $N$ belongs to $\mathcal{M}$ and satisfies $\mu(N)=0$ by hypothesis. Since $(X,\mathcal{M},\mu)$ is complete, every subset of $N$ is measurable. Because $C_B\subset N$ and $D_B\subset N$, we conclude that $C_B\in\mathcal{M}$ and $D_B\in\mathcal{M}$.
[/guided]
[/step]
[step:Reconstruct $g^{-1}(B)$ from measurable pieces]
We claim that $G_B=(A_B\setminus D_B)\cup C_B$. Indeed, $A_B\setminus D_B=A_B\cap G_B$, because $D_B=A_B\setminus G_B$. Therefore $(A_B\setminus D_B)\cup C_B=(A_B\cap G_B)\cup(G_B\setminus A_B)=G_B$.
Since $A_B,D_B,C_B\in\mathcal{M}$ and $\mathcal{M}$ is a $\sigma$-algebra, the set $(A_B\setminus D_B)\cup C_B$ belongs to $\mathcal{M}$. Hence $G_B\in\mathcal{M}$.
[/step]
[step:Conclude measurability of $g$ from arbitrary Borel preimages]
The Borel set $B\in\mathcal{B}(\mathbb{R})$ was arbitrary, and we have proved that $g^{-1}(B)=G_B\in\mathcal{M}$. Therefore $g$ is $\mathcal{M}/\mathcal{B}(\mathbb{R})$-measurable.
[/step]