Is the set $S=\left\{ \left(x+k,\left(-1\right)^{k}y,x,y\right):x,y\in\mathbb{R},k\in\mathbb{Z}\right\}$ closed? Define a subset of $\mathbb{R}^{4}$
  as follows: $S=\left\{ \left(x+k,\left(-1\right)^{k}y,x,y\right):x,y\in\mathbb{R},k\in\mathbb{Z}\right\}$
Is $S$ closed? I suspect it is, but can not find a way to show this. 
 A: $S$ is the preimage of the set $\mathbb{Z}\times \{0\}$ under the continuous function $f(a, b, c, d) = (a-c, b-(-1)^{a-c}d)$ from $\mathbb{R}^4$ to $\mathbb{C}^2$. As $\mathbb{Z}\times \{0\}$ is closed as a subset of $\mathbb{C}^2$, $S$ is closed in $\mathbb{R}^4$.
A: If $p_n=(x_n+k_n, (-1)^{k_n}y_n, x_n,y_n)\in S$ with $k_n\in \mathbb Z$ and if $p_n$ converges to $(a,b,c,d)$ as $n\to \infty$ then $x_n$ converges to $c$  and $y_n$ converges to $d.$
Now $c+k_n$ converges to $a,$ so $k_n$ converges to $a-c.$ A sequence of integers converges iff it is eventually constant so $k_n=a-c=k\in \mathbb Z$ for all but finitely many $n.$ So $x_n+k_n$ converges to $c+k$ and  $(-1)^{k_n}y_n$ converges to $(-1)^kd.$ So $$(a,b,c,d)=(c+k,(-1)^{k}d,c,d)\in S.$$
A: HINT
Take the usual metric in $\mathbb{R}^4$ namely:
$$d_2(x,y)=\sqrt{(x_1-y_1)^2 +(x_2-y_2)^2+(x_3-y_3)^2 +(x_4-y_4)^2}$$
Then take a sequence $x_n \in S$ such that $x_n \rightarrow x$ and prove that $x \in  S$
Also note that  in $\mathbb{R}^4$ (and in $\mathbb{R}^n$ in general): $$x_n=(x_n^{(1)},x_n^{(2)},x_n^{(3)},x_n^{(4)}) \rightarrow x=(x_1,x_2,x_3,x_4) \Leftrightarrow x_n^{(i)} \rightarrow x_i  , \forall i \in \{1,2,3,4\}$$
If you need more help ,let me know.
