Constancy on large subsets Let $X$ be a smooth proper variety of dimension greater than one defined over a number field. Let $A_i$ be a sequence of pairwise disjoint finite closed subsets of $X$ indexed by natural numbers defined over number fields such that $|A_{i}| \rightarrow \infty$ as $i \rightarrow \infty$. Suppose that any closed subvariety $W \subset X$ with $\dim(W) < \dim(X)$ contains at most finitely many $A_i$'s. Is it possible to have a non-constant a rational function $f$ such that $f=c_{i}$ on $A_i$ for all $i$? Here $c_{i}$'s are constants. 
It seems tempting to expect that the answer is no. If not, can we put some additional hypotheses on the density of these large subsets (or something relevant) to guarantee that $f$ is constant?
 A: If $X$ is proper then $f$ is locally constant so it's possible to have non-constant $f$ iff $X$=$Y\cup Z$ such that $Y$ and $Z$ are each non-empty unions of connected components of $X$, $Y$ and $Z$ are disjoint, and each $A$$i$ is contained in $Y$ or is contained in $Z$.
I give 2 examples with $X$ = affine plane over ℚ such that $f$ exists in the first example and not in the second.
Let {$t$$i$: $i=1,2,3,...$} be a set of algebraic numbers such that degree ℚ($t$$i$)/ℚ($t$$j$:$j$ ≠ $i$) $\rightarrow \infty$ as $i\rightarrow \infty$.  (For example, take $t$$i$ = $p$$i$$1/p$$i$ where $p$$i$ is the $i$th prime.)  Set $P$1=($t$1, $t$2), $P$2=($t$3, $t$4),..., points of $X$.
First example: $A$1={$P$1}, $A$2={$P$2}, ... Any curve {$g(x,y)=0$} contains only finitely many $A$$i$ because the degree of each coordinate over the other coordinate is bounded by a function of the degree of $g$ and the degrees of the coefficients of $g$.  And, $f(x,y)=x$ is constant on each $A$$i$.
Second example: $A$1={$P$1,$P$2}, $A$2={$P$3,$P$4},... Any curve {$g(x,y)=0$} contains only finitely many $A$$i$, as in the first example.  There is no $f$ which is constant on each $A$$i$ because $f(P$$2i-1$) = $f(P$$2i$) bounds the degree of each coordinate of $P$$2i$ (resp. $P$$2i-1$) over the compositum of the other coordinate and the coordinates of $P$$2i-1$ (resp. $P$$2i$) by a function of the degree of $f$ and the degrees of the coefficients of $f$.
