The continuous case:
If the domain is not an interval, we can still find a counterexample. Define
$$
f(x)=\cases{2x+2 & if $x\in(0,2)$,\cr
x-3 & if $x\in(3,5)$,}
$$
then
$$
f^{-1}(x)=\cases{x/2-1 & if $x\in(2,6)$,\cr
x+3 & if $x\in(0,2)$,}
$$
and intersections are $(1,4)$, $(4,1)$.
However, if the domain is connected, it turns out to be true.
Proof of the theorem in the case of a connected domain (interval)
For contradiction, let us suppose that there is an even number of intersections and an intersection is out of diagonal.
- We assume that $f^{-1}$ exists which means that $f$ is injective. Moreover, $f$ is continuous and its domain is interval, so $f$ is increasing or decreasing.
- $f$ and $f^{-1}$ are symmetric by diagonal, therefore the set of intersections is symmetric by the diagonal.
- Let denote $(x_1, x_2)$ an intersection out of diagonal. By symmetry, there is an intersection $(x_2, x_1)$. We can therefore WLOG assume that $x_1
- $f(x_1) > x_1$ and $f(x_2) < x_2$, so by continuity, $f$ intersects the diagonal.
- There is an even number of intersections and by symmetry, there is an even number of intersections out of diagonal. So there is even number of intersections on the diagonal. So there are at least two of them: $f(x_3) = x_3$, $f(x_4) = x_4$
- $x_1 f(x_2)$, so $f$ is decreasing (on the whole, by 1).
- $x_3
Contradiction :-)