Does there exist $A\subseteq \mathbb{R}$ such that $d(x,A) = |\sin x|$ , $d(x,A) = \inf\{d(x,y)|y\in A\}$? I process it like this:
If $A$ exists, then we must have $0\in A$ and $\pi\in A$.
When $x = \frac{\pi}{2}$, $d(x,A) = |\sin \frac{\pi}{2}| = 1$, so $\frac{\pi}{2} - 1\in A$ or $\frac{\pi}{2} + 1\in A$.
If $\frac{\pi}{2} - 1\in A$, let $x = \frac{\pi}{4}$. Then $d(x,A) = \frac{\sqrt{2}}{2}\approx 0.7071\gt 0.2146\approx1-\frac{\pi}{4} = \frac{\pi}{4} - (\frac{\pi}{2}-1)$, the distance from $\frac{\pi}{4}$ to $\frac{\pi}{2}-1$.
And this contradicts the definition of $d(x,A)$. 
But it suddenly occurs to me that there is no need $0\in A$, $\pi\in A$ ..., then how can I prove or disprove the existence of A?
Thanks~
 A: Such a set can not exist. Otherwise
$$
 A \subset \{ x \in \Bbb R \mid d(x, A) = 0 \}  = \{ k \pi \mid k \in \Bbb Z \} 
$$
and that implies that $d(\frac \pi 2, A)\ge \frac \pi 2$,
contradicting the assumption that $d(\frac \pi 2, A) = |\sin \frac \pi 2| = 1$.

More generally, assume that $f(x) = d(x, A)$ for some set $A \subset
\Bbb R$. Then $f(x) = 0$ for $x \in \overline A$.
The complement $(\overline A)^C$ is a (finite or countable infinite) union of
disjoint open intervals, and on each interval $(x_i, y_i)$ we have
$$
 f(x) = \min(x-x_i, y_i - x) \, .
$$
It follows that $f$ is a sum of “non overlapping triangle functions”
$$
 f(x) = \sum_i f_i(x)
$$
where
$$
 f_i(x) = \begin{cases}
  0 & \text{ if } x \le x_i \\
  \min(x-x_i, y_i - x) & \text{ if } x_i < x < y_i \\
  0 & \text{ if } x \ge y_i \\
 \end{cases}
$$
and $(x_i, y_i)$ are (finite or countably infinite) disjoint intervals.
On the other hand, if $f$ is of this form, the set
$$
 A = \{ x \in \Bbb R \mid f(x) = 0 \}
$$
satisfies $d(x, A) = f(x)$ for all $x \in \Bbb R$.
A: Without loss of generality $A$ is closed, since $d(x, A) = d(x, \overline{A})$ for every $A \subseteq \mathbb{R}$. Now your argument works.
