Given a pair of continuous functions from a topological space to an ordered set, how to prove that this set is closed?

Given that $X$ is an arbitrary topological space, $Y$ is a totally ordered set in the order topology, and $f$, $g \colon X \to Y$ are continuous functions, how to show that the subset $A$ of $X$ given by $$A := \left\{ \ x \in X \ \colon \ f(x) \leq g(x) \ \right\}$$ is closed in $X$?

Edit based on the answer by Hagen von Eitzen:

Let $U \colon= \{ u \times v \in Y \times Y \ \colon \ u < v \ \}$. We show that $U$ is open in $Y \times Y$.

Let $u \times v \in U$. Then $u < v$.

Case I. If there is some $y \in Y$ such that $u < y < v$, then $u \times v \in (-\infty, y) \times (y, +\infty) \subset U$.

Case 2. If $(u,v)$ is empty, then $u \in (-\infty, v)$ and $v \in (u, +\infty)$, and so $u \times v \in (-\infty, v) \times (u, +\infty)$.

Moreover, if $a \times b \in (-\infty, v) \times (u, +\infty)$, then we must have $a < v$ and $b> u$. So $a \leq u < v \leq b$, which implies that $a < b$ and so $a \times b \in U$.

Thus, $u \times v \in (-\infty, v) \times (u, +\infty) \subset U$.

So $U$ is open in $Y \times Y$.

Similarly, we can show that the set $$V \colon= \left\{ \ u \times v \in Y \times Y \ \colon \ u > v \ \right\}$$ is open in $Y \times Y$.

Thus, it follows that the set $A \colon= \{ \ u \times v \in Y \times Y \ \colon \ u \leq v \ \}$ is closed in $Y \times Y$.

Now since the maps $f \colon X \to Y$ and $g \colon X \to Y$ are continuous, so is the map $f \times g \colon X \to Y \times Y$ defined as $$(f \times g)(x) \colon= f(x) \times g(x) \ \mbox{ for all } \ x \in X.$$

Thus, the inverse image under $f \times g$ of the set $A$ is closed in $X$.

But $$(f \times g)^{-1} (A) = \left\{ \ x \in X \ \colon \ (f \times g)(x) \in A \ \right\} = \left\{ \ x \in X \ \colon \ f(x) \leq g(x) \ \right\}.$$

-

You can prove it directly from the definitions. Let $U=X\setminus A=\{x\in X:f(x)>g(x)\}$; we need only prove that $U$ is open. Let $x\in U$ be arbitrary; we’ll find an open nbhd of $x$ contained in $U$. Since $x\in U$, we know that $g(x)<f(x)$. There are now two cases.

1. There is some $a\in Y$ such that $g(x)<a<f(x)$. Let $$V=g^{-1}\big[(\leftarrow,a)\big]\quad\text{and}\quad W=f^{-1}\big[(a,\to)\big]\;.$$ Then $V\cap W$ is an open nbhd of $x$ (why?), and for each $y\in V\cap W$ we have $g(y)<a<f(y)$, so $V\cap W\subseteq U$.

2. The interval $\big(g(x),f(x)\big)$ in $Y$ is empty. Then let $$V=g^{-1}\big[(\leftarrow,f(x))\big]\quad\text{and}\quad W=f^{-1}\big[(g(x),\to)\big]$$ and argue almost exactly as in the first case.

-
your answers are so instructive and illuminating!! How much I've benefitted from your presence on this forum!! God bless you!! – Saaqib Mahmuud Mar 24 '15 at 6:36
@Saaqib: Thank you! – Brian M. Scott Mar 24 '15 at 6:38

The set $\{(x,y)\in Y^2\mid x\le y\}$ is closed in $Y^2$ and $X\to Y^2, x\mapsto (f(x),g(x))$ is continuous.

-
how is the set $\{ (x,y) \in Y^2 \ \vert \ x \leq y \ \}$ is closed in $Y^2$? – Saaqib Mahmuud Mar 24 '15 at 6:41
how is the set $$\left\{ \ u \times v \in Y \times Y \ \colon \ u \leq v \ \right\}$$ closed in $Y \times Y$? Can you please elaborate? – Saaqib Mahmuud Jan 27 at 14:25