Regular maps between quasi-projective varieties defined over a global field Let $K$ be a global field, and $f: V \to W$ be a regular map,
 where $V,W$ are quasi-projective varieties, and everything is defined
over $K$. Is it true that $f(V(O_v)) \subset W(O_v)$ for all but finitely many $v$? If yes, what is the idea of proof? 
The way I understand V(O_v) is as follows. Let $V\subset\mathbb P^N$ be the the variety
\begin{equation}\label{qvar}
\left(\cap_{i=1}^r\{f_i=0\}
\right)\setminus\left(\cap_{j=1}^s\{g_j=0\}
\right)
\end{equation}
where $f_1,\ldots,f_r$ and $g_1,\ldots,g_s$ are homogeneous polynomials in $K[X_0,\ldots,X_N]$. Assume each polynomials is in $O_v[X_0,\ldots,X_N]$ with some coefficient lying in $O_v^*$. Then
\begin{equation}
V(O_v)=\left\{[x_0:\ldots:x_N]
\in\mathbb P^N(K_v): 
\begin{array}{l}
x_i\in O_v \text{ for all } i\\
x_{i_0}\in O_v^* \text{ for some } i_0\\
f_i(x_0,\ldots,x_N)=0 \text{ for all } i\\
g_j(x_0,\ldots,x_N)\in O_v^* \text{ for all } j
\end{array}
\right\},
\end{equation}   
Although  $f$ can be locally given by polynomial maps, I don't know how the condtions such as $g_j(x_0,\ldots,x_N)\in O_v^*$ can be preseved?
 A: Let 
$V = \{x \in \mathbb{P}^n |\forall i \in I, f_i(x) = 0, \exists j \in J,g_j(x) \ne 0\}$
and $W = \{y \in \mathbb{P}^m |\forall i \in I', f'_i(x) = 0, \exists j \in J', g'_j(x) \ne 0 \} $
be quasi-projective varieties over a global field $K$ and 
$\phi: V \to W$ be a regular map defined over $K$. 
We show that, for all but finitely many places $v$ of $K$, 
$\phi(V(O_v)) \subset W(O_v)$. 
Here, $O_v$ is the ring of integers of
the completion $K_v$ of $K$ at $v$ (assumed without loss of generality 
to be non-archimedian), 
$V(O_v) = \{x = (x_0:\ldots:x_n) \in V(K_v) | \forall i, x_i \in O_v,  
\exists i, x_i \in O_v^*, \exists j \in J, g_j(x) \in O_v^*\}$,
and likewise for $W$.
We begin by covering $V$ by open subsets 
$U_{\ell} =\{x \in V | r_{\ell}(x) \ne 0\}$ such that, on $U_{\ell}$,
$\phi(x) = (p_0^{(\ell)}(x):\ldots:p_m^{(\ell)}(x))$, where the $p_i^{(\ell)}$
are homogeneous polynomials with coefficients in $K$. The fact that the
$U_{\ell}$ cover $V$ means that whenever $x \in \mathbb{P}^n$ is such that
$f_i(x) = r_{\ell}(x) = 0 \forall i,\ell$, then we must have
$g_j(x) = 0$ for all $j$. Thus, by the
Nullstellensatz, $g_j^N = \sum u_{ij}f_i + \sum v_{\ell j}r_{\ell}$
for some polynomials $u_{ij},v_{\ell j}$ and integer $N >0$. 
Now we use that, on $U_{\ell}$, 
$\phi(x) = (p_0^{(\ell)}(x):\ldots:p_m^{(\ell)}(x)) \in W$, so
$g'_j(p_0^{\ell}(x):\ldots:p_m^{\ell}(x)) \ne 0$ for some $j \in J'$.
So, for any $x \in P^n$ satisfying
$f_i(x)=0, \forall i \in I, 
g'_j(p_0^{(\ell)}(x),\ldots,p_m^{(\ell)}(x)) = 0 \forall j \in J'$
we must have $g_j(x)r_{\ell}(x) = 0$ for all $j \in J$. 
Again, by the Nullstellensatz, for all $j \in J$
$(r_{\ell}g_j)^M = \sum z_{ij}^{(\ell)}f_i + 
\sum_{j \in J'} w_j^{(\ell)}g'_j(p_0^{(\ell)},\ldots,
p_m^{(\ell)})$, for some polynomials $z_{ij}^{(\ell)},w_j^{(\ell)}$ and 
integer $M > 0$.
We now take the finite set of places $S$ of $K$ including all archimedian
places and all places where some coefficient of one of the polynomials
considered above is non-integral. Let $v \notin S$ be a place of $K$.
Let $a \in V(O_v)$, then $g_j(a)^N = \sum v_{\ell}(a)r_{\ell}(a)$.
By assumption, for some $j$, $g_j(a)^N \in O_v^*$ and that implies that
$r_{\ell}(a) \in O_v^*$ for some $\ell$. Using these $j,\ell$, we get
$(r_{\ell}(a)g_j(a))^M \in O_v^*$ and therefore, for some $j\in J'$
$g'_j(p_0^{(\ell)}(a),\ldots,p_m^{(\ell)}(a)) \in O_v^*$.
This implies that $g'_j(\phi(a)) \in O_v^*$ for some $j$ and that
$p_i^{(\ell)}(a) \in O_v^*$ for some $i=0,\ldots,m$ and finally that
$\phi(a) \in W(O_v)$, as desired.
