Let $f:[0, 1]\to\mathbb{R}$ be a function such that $$|f(x)-f(y)|<|x-y|\ \forall\ \ x, y\in [0, 1].$$ Then how can we show the following?
(i) There exists a $x_0\in [0, 1]$ such that the function $$g:[0, 1]\to \mathbb{R}: g(x)=|f(x)-x|,$$ attains its minimum value.
(ii) Let $x_0$ be such that $$g(x_0)=\min_{x\in [0, 1]}g(x).$$ Then $f(x_0)\in [0, 1].$
I know that $g$ is a non-negative function. But how to ensure that minimum exists.