Intuition that $A=\{x\in M|\space f(x)\neq g(x)\}$ is open given $f,g$ continuous Let $M,N$ be two metric spaces and $f,g:M\rightarrow N$ continuous functions. Show that the set $A=\{x\in M|\space f(x)\neq g(x)\}$ is open in $M$.
Well, I understand that if $h(x)=d_{N}(f(x),g(x))$ it is only left to prove, that $h$ is continuous and then the set $A=\{x\in M|\space h(x)>0\}$ is open. My question is, what was the 'mind process' to get to the conclusion that I should use $h$ instead of something else to prove that proposition. What was the intuition behind creating that function. 
I hope you guys understand what Im trying to ask, thanks so much in advance.
 A: This proof is what is often called a follow your nose proof --- at each step you do the only thing that you can with the given information, and you end up at the result. For this problem, it goes as follows:


*

*I observe that the goal is to prove that $A$ is open. So what am I given? All I am given is information about continuous functions from $M$ to $N$. This suggests that I will need to show that $A$ is the pre-image of an open set in under some continuous function.

*I need to actually find a continuous function $h$ and an open set $B$ such that $A = h^{-1}(B)$. Clearly, that function must be in terms of $f$ and $g$, since they are all I have to work with, and also clearly it can't be just one of them, since $A$ is defined in terms of both.

*So what combination of $f$ and $g$ could produce a function that has to do with $A$? Well, we haven't actually used either of the metrics $d_M$ or $d_N$ yet, so let's look there. I go back to my definition of metric space and notice that $d(a,b) > 0 \iff a \ne b$. I notice that $a \ne b$ looks like $f(x) \ne g(x)$. That is, our metric space definition says that $f(x) \ne g(x) \iff d_N(f(x),g(x)) > 0$. Hence, $h : M \to \mathbb{R}_{\ge 0}$ defined as $h(x) = d_N(f(x),g(x))$ looks like it may be a good candidate for $h$.

*There's really no more work to do --- just verify that we followed our nose to the correct place: letting $h(x) = d_N(f(x), g(x))$, and observe that this forces $B = (0,\infty)$, which we can confirm is open. And $h$ is clearly continuous. So $A$ is open!

A: If the spaces were Euclidean spaces, then you could define $h(x)=f(x)-g(x)$. Then $h$ would be continuous, its zero set would be closed, and the complement would be open. Done.
You cannot subtract functions on general metric spaces. But since we want the zero set, then the next best thing is to use the distance in the codomain.
A: IMO, this is sort of thing is a "basic trick" — you try it out simply because it's one of the standard things you check to see if it applies to your problem.
Actually, there are two basic tricks here:


*

*the idea of encoding "equal / not equal" via the metric 

*identifying inequality constraints between real numbers as open sets (or equality constraints as closed sets) so you can use general topological properties of such things

