Show that for any closed subset $A\subset \Bbb R,$ there exists a continons function $f$ on $\Bbb R$ which vanishes exactly on $A.$
I thought taking the function $f:\Bbb R\to\Bbb R$ such that $f(x)=\inf\{|x-a|:a\in A\}$ (where, $A\subset \Bbb R,$) would do the job.
This is because, the for any $a_0\in A$ we have, $f(a_0)=0$ (, which follows from the definition of $f$ ). But I am having a hard time showing that $f$ defined like this, is continuous on $\Bbb R.$ The problem precisely arises because I don't have an idea on how to use, the $\epsilon-\delta$ definition of continuity to show this.
In order to show that, $f$ is continuous at $c\in \Bbb R$ it will, suffice, to show that $\lim_{x\to c}f(x)=f(c).$ This, means, we need to show that $\forall \epsilon\gt 0,$ $\exists \delta \gt 0$ such that if $|x-c|\lt\delta$ then $|f(x)-f(c)|\lt \epsilon.$
Now, I tried to work with the expression $|f(x)-f(c)|.$ I noted that $,\forall a_1,a_2\in A$ we have, $||x-a_1|-|c-a_2||\leq |(x-a_1)-(c-a_2|=|(x-c)+(a_2-a_1)|\leq |x-c|+|a_2-a_1|.$
If I could show, that, $||x-a_1|-|c-a_2||\leq |x-c|$ then, I could claim that, $|f(x)-f(c)|\leq |x-c|.$ Finally, if, $|x-c|\lt\epsilon$ then, $|f(x)-f(c)|\leq |x-c|\lt\epsilon,$ and we are done.
But the question is, can I ever claim, $||x-a_1|-|c-a_2||\leq |x-c|.$
Also, if possible, say we are able to establish the above claim then, can we say directly, that, $|f(x)-f(c)|\leq |x-c|$ ? The confusion is because of the definition of $f,$ i.e $f(x)=\inf\{|x-a|:a\in A\},$ i.e because of the infimum thing. If I could write, $\min$ in place of $\inf$ I think things would have been simpler, but then again, I don't know whether we can.
Any help regarding this, will be highly appreciated.