Connection between sets and functions Let $A$ be a convex closed subset of $\mathbb  R^n$. Is there a convex  function 
$g: \mathbb R^n \rightarrow \mathbb R$ such that 
$ A=\{x: g(x) \leq 0\}  ?
$ 

Assume without loss of generality that $A\neq\varnothing$.
Since $A$ is closed and non-empty $\min_{y\in A}\|x-y\|$ exists for any $x\in\mathbb{R}^n$ and we define $g(x) = \min_{y\in A}\|x-y\|$. Clearly $g(x) = 0$ for $x\in A$ and $g(x)>0$ for $x\notin A$ and it remains to show that $g$ is convex.
Let $x,y\in\mathbb{R}^n$ and let $t\in[0,1]$ then there exist $x^\prime,y^\prime\in A$ such that $\|x-x^\prime\|=g(x)$ and such that $\|y-y^\prime\|=g(y)$.
Since $A$ is convex, $tx^\prime+(1-t)y^\prime\in A$ and $g(tx+(1-t)y)$ is less than $$\|[tx+(1-t)y] - [tx^\prime+(1-t)y^\prime]\| = \|t(x-x^\prime) + (1-t)(y-y^\prime)\|,$$
which by the triangle inequality
$$\leq t\|x-x^\prime\| + (1-t)\|y-y^\prime\| = tg(x)+(1-t)g(y).$$
Hence $g$ is indeed convex.
