The ring of bounded polynomials on a semi-algebraic set

Let V be a normal affine variety over the real numbers R, and let S be a semi-algebraic subset of V(R). We study the subring B(S) of the coordinate ring of V consisting of the polynomials that are bounded on S. We introduce the notion of S-compatible completions of V, and we prove the existence of such completions when V is of dimension at most 2 or S=V(R). An S-compatible completion X of V yields an isomorphism of B(S) with the ring of regular functions on some (concretely specified) open subvariety of X. We prove that B(S) is a finitely generated R-algebra if S is open and of dimension at most 2, and we show that this result becomes false in higher dimensions.


Introduction
The general question studied in this paper can be stated as follows: Let S be a semi-algebraic subset of R n (i.e. a subset described by polynomial inequalities). How can we describe (conceptually or explicitly) the ring of polynomials that are bounded on S?
To address this question we will work in the following setup. Let V be an affine variety defined over R, and let S be a semi-algebraic subset of V (R). We write R[V ] for the ring of real polynomial functions on V (the coordinate ring of V ) and consider its subring The first systematic study of B V (S), in the case S = V (R), was undertaken in 1996 by Becker and Powers [2]. Their results have been generalized substantially by Monnier [12] and Schweighofer [20]. The emphasis there is on iterating the B V construction (which requires a more abstract definition via the real spectrum), and on relations to sums of squares, sums of higher powers, and certificates for positivity; see also Marshall [11]. Motivation came in part from earlier work on the so-called holomorphy ring in the theory of real rings and fields (see [1] and [2] and references given there). In particular, rings A were studied in which all elements of the form 1 + i a 2 i with a i ∈ A are invertible. Of course, this condition is hardly ever satisfied for A = R[V ].
A principal difficulty in studying B V (S) is that these rings need not be of finite type over R. For example, this is so for elementary reasons when S is neither relatively compact nor Zariski dense in V (Cor. 5.8). We will show, however, that there exist other and more genuine examples as well (Cor. 5.14). In [2], [12] and [20], this difficulty was overcome, to a certain extent, by working in the real spectrum and using sophisticated arguments from real algebra.
Our investigations go in a somewhat different direction. We seek to understand the structure of B V (S) in terms of the geometry of S, in particular by constructing algebraic compactifications of V that are suitably adapted to S. To describe the main results of this paper, let us make the simplifying assumption that the affine variety V is non-singular and connected. Using resolution of singularities, we construct a quasi-projective variety U containing V as an open dense subset such that O U (U ) restricts isomorphically onto B V (V (R)) (Thm. 3.8 and Thm. 4.1). We also generalize this construction from S = V (R) to more general semi-algebraic sets S ⊂ V (R). However we have been able to prove a satisfactory general result only for dim(V ) ≤ 2 (Thm. 4.5). Combining this with a theorem of Zariski, we prove that the R-algebra B V (S) is finitely generated when dim(V ) ≤ 2 and the semi-algebraic set S satisfies a weak regularity condition (Thm. 5.12).
Here is a brief survey of the contents of this paper. After introducing the necessary terminology, we fix a connected normal affine R-variety V and a closed semialgebraic set S ⊂ V (R), and we study morphisms V → W into affine R-varieties W which are bounded on S. From this we obtain a characterization of the field of fractions of B V (S) in geometric terms (Prop. 2.2). In particular, we show that B V (S) has full transcendence degree dim(V ) over R if, and only if, there exists a non-constant f ∈ B V (S) such that the set f −1 (c) ∩ S is compact for almost all real numbers c (Thm. 2.5).
In Sect. 3 we introduce the notion of compatible completions. Given a normal affine variety V and a semi-algebraic set S ⊂ V (R), a complete variety X containing V as an open dense set is said to be compatible with S if S touches every irreducible component of X V in a Zariski dense subset, provided it touches that component at all. Removing those components from X that are not touched by S, we obtain an open subvariety U ⊂ X containing V , and we show O U (U ) ∼ → B V (S) (Thm. 3.8). The existence of compatible completions is studied in Sect. 4. Relative to S = V (R), every non-singular affine variety V has a compatible completion (Thm. 4.1). Relative to more general semi-algebraic subsets of V (R), we can prove such a result for dim(V ) ≤ 2 (Thm. 4.5). Turning things around, we prove in Thm. 4.11 that for every normal real quasi-projective variety U there is an open affine subset V ⊂ U and a semi-algebraic set S ⊂ V (R) with O U (U ) ∼ → B V (S). In Sect. 5 we finally study finite generation of the R-algebra B V (S). After showing that B V (S) is not noetherian when S is not Zariski dense in V , we prove finite generation of B V (S) for dim(V ) ≤ 2 (Thm. 5.12), using Zariski's theorem. We also show that this result becomes false when dim(V ) ≥ 3.
Acknowledgements: Concerning the final section of this paper, we greatly profitted from a correspondence with Sebastian Krug, who provided us with examples and constructions in the context of Hilbert's fourteenth problem, going beyond what went into this paper. We are also grateful to Fabrizio Catanese for suggesting the connection to Zariski's work.
1. Notations and conventions 1.1. By an R-variety we mean a separated and reduced R-scheme V of finite type, not necessarily irreducible. The structural sheaf of V is written O V . If V is affine, The set V (R) of R-rational points is endowed with the euclidean topology. The notion of semi-algebraic subsets of V (R) is well-known when V is affine, and is easily transferred to the general case, a subset S ⊂ V (R) being semi-algebraic if and only if S ∩ U (R) is semi-algebraic in U (R) for every open affine subset U of V .
An irreducible R-variety V is said to be real if it has a non-singular R-point, or equivalently, if the function field R(V ) is (formally) real. It is also equivalent that V (R) is Zariski dense in V .

1.2.
Let f : V → W be a morphism of R-varieties, and let S be a subset of V (R).
We say that f is bounded on S if the closure of f (S) in W (R) is compact.
In particular, this applies in the case W = A 1 , i.e., when f is a regular function on V . The main object of this paper is to study the subring , for V an affine R-variety. Here are some immediate observations: Proof. For (e), observe that a relation f n + a 1 f n−1 + · · · + a n = 0 with f ∈ R[V ] and a 1 , . . . , a n ∈ B V (S) implies that |f | ≤ 1 + max i |a i | holds (pointwise) on V (R), hence f is bounded on S.
1.4. For the entire paper, our base field will be the field R of real numbers. All results remain true when R is replaced by an arbitrary real closed field and bounded is replaced by bounded over R, compact by semi-algebraically compact etc.

Fibres of bounded morphisms
Throughout this section we assume that V is an irreducible affine R-variety and that S is a fixed semi-algebraic subset of V (R).
This is a semi-algebraic subset of W (R) which is contained in ϕ(S).
, the following are equivalent: (i) f ∈ Quot(B); (ii) there exists a dominant morphism ϕ : Let C be any finitely generated subalgebra of B containing h and f h, write W = Spec(C), and let ϕ : V → W be the morphism induced by the inclusion C ⊂ R[V ]. Then ϕ is bounded on S. Let y ∈ Ω ϕ (f ), so f is unbounded on S y = S ∩ ϕ −1 (y). On the other hand, h and f h lie in C = R[W ], so they are constant on S y . Together, this implies h(y) = 0. So Ω ϕ (f ) is contained in Z(h), and is therefore not Zariski dense in W .
Conversely assume that there is a dominant morphism ϕ : (y ∈ ϕ(S)), where we put 1 ∞ := 0. The mapf has semi-algebraic graph, and f −1 (0) = Ω. Let D be the set of points in ϕ(S) wheref fails to be continuous. Then D is not Zariski dense in W . This can, for instance, easily be deduced from a cylindrical algebraic decomposition of the graph off (see [3] Thm. 2.3.1). Hence D ∪ Ω is not Zariski dense in W either.
Since Z(h) is not Zariski dense in W , there exists h = 0 in R[W ] with Z(h) ⊂ Z(h). Since ϕ(S) is compact, the Lojasiewicz inequality (see [3], Cor. 2.6.7) implies that there are 0 < c ∈ R and a positive integer N such that |h N | ≤ c · |h| on ϕ(S). We conclude for all x ∈ S. This shows that f h n is bounded on S, and so f = (f h n )/h n lies in Quot(B).
The following easy fact was used in the last proof: Proof. Upon replacing f by min{f, 1} we may assume f ≤ 1 on M . The distance function d D : R n → R, d D (x) = inf{|x − y| : y ∈ D} is continuous with semialgebraic graph, and it vanishes precisely on D. The function has the desired properties. Indeed, f is continuous outside of D, and hence so is g. Fix x ∈ M ∩ D. Then g(x) = 0, and for all y ∈ M we have d D (y) ≤ |y − x|. This implies 0 ≤ g(y) ≤ |y − x| 1 + |y − x| for all y ∈ M . In particular, g is continuous in x.

2.4.
We fix an affine irreducible R-variety V and a semi-algebraic set S ⊂ V (R). Given a morphism ϕ : V → W of R-varieties, we put Ω ϕ (f ).
If R[V ] is generated by x 1 , . . . , x n as an R-algebra then Ω ϕ = n i=1 Ω ϕ (x i ). This shows that Ω ϕ is a semi-algebraic subset of W (R). Clearly, Given an R-algebra B, we define the transcendence degree trdeg R (B) of B as the maximum number of elements of B which are algebraically independent over R.
, bounded on S, such that the set f −1 (c)∩S is compact for every 0 = c ∈ R.
Note that condition (v) implies that there exists ϕ : V → W as in (iv) with W = A 1 .
Proof. (iii) ⇒ (v): For ϕ : V → W as in (iii), let D be a proper closed subvariety of W such that the restriction ϕ −1 (W D) → W D of ϕ is an isomorphism. Choose a non-constant function g ∈ R[W ] which vanishes on D and on the boundary of ϕ(S) in W (R). Let 0 = c ∈ R. Then g −1 (c) ∩ ϕ(S) = g −1 (c) ∩ ϕ(S) by the choice of g, and this set is compact since ϕ(S) is compact. Moreover, g −1 (c) ∩ ϕ(S) is contained in (W D)(R), and so the preimage is compact as well. In particular, (g • ϕ) −1 (c) ∩ S is compact, and so it suffices to take f := g • ϕ.
(v) ⇒ (iv) is trivial (we can take W = A 1 and ϕ := f ). Under suitable conditions, we know a priori that the R-algebra B is finitely generated (see Thm. 5.12 below). In these cases we can formulate Proposition 2.2 and Theorem 2.5 more succinctly: Remark 2.7. Even if B = B V (S) fails to be finitely generated, we can characterize trdeg R (B) as the maximum dimension of an affine R-variety W for which there exists a dominant morphism V → W which is bounded on S.
From Theorem 2.5 it follows that there exists a non-constant polynomial h ∈ B(S) such that all fibres h −1 (c) ∩ S are compact for c = 0. Depending on the choice of f and g, it may not be a priori clear how to find such h. For a concrete example, take f = x 2 y and g = y 2 . Here, neither f nor f g have any compact fibres, but (for example) h = xy will do. 3. The same example also shows another phenomenon. If trdeg B(S) = 2, there exists a birational morphism ϕ : A 2 → W of affine varieties that is bounded on S. In many instances, the map A 2 → A 2 , (x, y) → ((f (x), f (y)g(y)) will not have this property, implying in particular that B(S) is strictly larger than R[f, f g]. Finding a birational morphism ϕ as above can be seen as a first step towards determining B(S). (For f and g as in the previous example, it is easy to see that B(S) = R[xy, x 2 y, x 2 y 3 ], while the map (x, y) → (f (x), f (y)g(y)) has generically degree four.) There does not seem to be any general procedure that will produce such ϕ. See however Remark 3.7.3.

2.9.
Throughout this paper, we shall assume for the most part that varieties are irreducible. Here are a few remarks on the reducible case. Let V be an affine R-variety with irreducible components V 1 , . . . , V r , let S be a semi-algebraic subset of V (R), and write S i := S ∩ V i (R). The relation between B V (S) and the rings B Vi (S i ) (i = 1, . . . , r) depends largely on the way the components need not be surjective, as the following example shows. Let V be the plane affine curve x(x 2 + y 2 − 1) = 0, which is the union of a circle V 1 and a line V 2 , and take S = V (R). Then B V (S) consists of those polynomials which are constant on the line, and so the restriction map B V (S) → B V1 (S 1 ) to the circle does not contain y| V1 in its image.
Nevertheless, in the case when V is a curve, the relation between B V (S) and the B Vi (S i ) is understood farily well, see [15] for details. Things become considerably more difficult in dimension at least two. For instance, while Lemma 1.12 (5)), this is false in higher dimensions. For an example, let V be the union of two planes in 3-space, and let S be the union of the first plane

Bounded polynomials and completions of varieties
3.1. Let X be a normal R-variety. A prime divisor on X will be a closed irreducible subset of codimension one in X. By a divisor on X we always mean a Weil divisor, that is, an element of the free abelian group generated by the prime divisors on X.
Given a rational map f : V W between irreducible varieties, we denote by dom(f ) the largest open subset of V on which f is defined.

3.2.
Let X be an R-variety. Sometimes it will be convenient to work in the real spectrum X r of X. When X is affine, . When X is not necessarily affine, the topological space X r is defined by glueing the real spectra (U i ) r (i = 1, . . . , r) of an open affine cover X = U 1 ∪ · · · ∪ U r , see [17] 0.4 for more details. Thus a point α ∈ X r corresponds to a pair (x α , P α ) where x α is a (scheme-theoretic) point of X and P α is an ordering of the residue class field of X in x α . The support of α is supp(α) = {x α }. In particular, X(R) is a topological subspace of X r in the obvious way. Similarly, when X is irreducible, the space Sper R(X) of all orderings of the function field of X is identified with the subspace {α ∈ X r : supp(α) = X} of X r .
The topological space X r is spectral, and hence there is a well-defined notion of constructible subsets of X r (see [17] 0.4). For every semi-algebraic subset S of X(R), there exists a unique constructible subset S of X r such that S = S ∩ X(R). If X is affine, then S is the subset of X r defined by the same system of inequalities as S. It is well-known that S is open (resp. closed) in X r if and only if the same is true of S in X(R). For two points α, β ∈ X r , we say that α specializes to β, denoted α β, if β is contained in the closure of α.
Recall that a valuation v of a field K is called compatible with an ordering ≤ of The usefulness of the real spectrum in our context comes from the following lemma: Lemma and Definition 3.3. Let X be a normal R-variety, let Z be a prime divisor on X, and let S be a semi-algebraic subset of X(R). The following conditions are equivalent: Sper R(X). If these conditions hold we say that Z and S are compatible.
Note that every prime divisor which is compatible with S has a real residue field.
Proof. Let T := Z(R) ∩ (S ∩ U (R)), a closed semi-algebraic subset of Z(R). The set T is Zariski dense in Z if and only if T contains a point with support Z. The latter condition is equivalent to (ii), and (iii) is merely a reformulation of (ii).
The following lemma is obvious (see [18] Lemma 0.2) and will be used frequently: Definition 3.6. Let V be an irreducible R-variety and let S be a semi-algebraic subset of V (R). By a completion of V we mean an open dense embedding V ֒→ X into a complete R-variety. The completion X will be said to be compatible with S (or S-compatible) if for every irreducible component Z of X V the following conditions hold: (1) The local ring O X,Z is a discrete valuation ring; (2) the set Z(R) ∩ S is either empty or Zariski dense in Z. (Here, of course, S denotes the closure of S in X(R).) Note that (1) is saying that Z has codimension one in X and is not contained in the singular locus of X. Condition (2) says (for normal X) that every irreducible Examples 3.7.
1. Given a semi-algebraic subset S of R n , the natural completion A n ⊂ P n of affine n-space is compatible with S if and only if S contains an open cone in R n (not necessarily centered at the origin).
2. The case of curves is simple: Given a (possibly singular) irreducible curve C, there is a unique projective completion C ֒→ X for which X sing ⊂ C sing (see [19] 4.6). The completion X is compatible with any semi-algebraic subset S of C(R). The points of X C are called the points of C at infinity.
3. There are interesting classes of semi-algebraic sets S (in R n , say) for which S-compatible completions (of V = A n , in this case) can be constructed as toric varieties. For example, when S is defined by (finitely many) binomial inequalities ax α < bx β , this always is the case. For such S, the ring B(S) can be identified explicitly in terms of the defining inequalities, and B(S) is always finitely generated as an R-algebra. We plan to expand on this remark in a future publication.
Our interest in compatible completions arises from the next result. It shows that such a completion calculates the ring of bounded polynomials on a semi-algebraic set: To improve this we consider the blowing-up π 1 : X 1 → P 2 at P . Then A 2 ֒→ X 1 is a completion of A 2 for which X 1 A 2 has two irreducible components, namely L ′ (the strict transform of L) and E 1 = π −1 1 (P ). In X 1 (R) we have S ∩L ′ (R) = ∅, and S ∩E 1 (R) is Zariski dense in E 1 . Therefore the completion X 1 is compatible with S, and by 3.
3.10. For another example let now T = {(x, y) ∈ R 2 : |x| ≤ 1, |xy| ≤ 1}. As before we use the blowing-up π 1 : X 1 → P 2 of the plane in P = (0 : 0 : 1). Again we have T ∩ L ′ (R) = ∅ in X 1 (R), but this time T ∩ E 1 (R) = {P 1 } is a singleton. Therefore we blow up X 1 in P 1 to get π 2 : In general, if we want to apply Theorem 3.8 to calculate B V (S), we can start with some (normal) completion V ֒→ X 0 of V . By making suitable iterated blowing-ups with centers over X 0 V , we try to "straighten out" the set S at infinity more and more. When V is a surface and the set S is sufficiently regular at infinity, this procedure will always lead, after finitely many steps, to a completion of V which is compatible with S, see Theorem 4.5 below.

Existence of compatible completions
In view of Theorem 3.8, we are now discussing the existence question for Scompatible completions. We start with the case S = V (R).
Theorem 4.1. Every connected non-singular R-variety V has a completion X which is compatible with the set S = V (R), and such that the irreducible components of X V are non-singular. If V is quasi-projective then X can be chosen to be projective.

Proof.
Start with any open dense embedding V ֒→ X into a complete R-variety X (which we can take projective if V is quasi-projective). The singularities of X are contained in X V , and by resolving them we get X non-singular. Some irreducible components of X V may have codimension ≥ 2. This can be remedied by blowing up X in these centers. So we can assume that every irreducible component of X V has codimension one in X. Finally, by embedded resolution of singularities, we can achieve that the irreducible components of X V are non-singular.
We claim that the completion V ⊂ X is compatible with V (R). To see this, fix an irreducible component Z of X V for which Z(R) = ∅. Since Z is non-singular, the function field R(Z) is real. By the Baer-Krull theorem, R(X) has an ordering α which is compatible with the discrete valuation v Z . In particular, Z is compatible with the set V (R) (Definition 3.3).
We now turn to compatible completions for more general semi-algebraic subsets S of V (R). We shall denote the interior of a set M ⊂ V (R) by int(M ). Remark 4.3. If S is regular at infinity and S is not compact, then S is Zariski dense at infinity. Indeed, otherwise there would be a proper Zariski closed subset Z of V and a compact set K ⊂ V (R) with S ⊂ K ∪ Z(R). This would imply int(S ∩ V reg (R)) ⊂ K, and by regularity at infinity we would get S compact, a contradiction.
We will need the following version of embedded resolution of singularities on a surface. By a curve on X we mean a reduced effective divisor on X.
Theorem 4.4. Let k be an infinite field, X a normal quasi-projective surface over k, C a curve in X and T a finite set of closed points in C sing ∩ X reg . Then there exists a birational morphism ϕ : X → X of k-varieties with the following properties: (1) ϕ induces an isomorphism X ϕ −1 (T ) ∼ → X T ; (2) X is quasi-projective and X sing = ϕ −1 (X sing ) (in particular, X is normal); (3) in all points of ϕ −1 (T ), the divisor ϕ −1 (C) on X has normal crossings and non-singular components.
Proof. If X is non-singular and T = C sing , our statement becomes the usual one for embedded resolution of curves in surfaces (see for example [6] Thm. V.3.7, or [4] Sect. 3.5 for the case of an arbitrary infinite base field). This implies the above version, since T is contained in X reg . In more detail, let S = X sing ∪ (C sing T ) and put X 0 = X S, a non-singular quasi-projective surface. Applying usual embedded resolution of singularities to the divisor C ∩ X 0 on X 0 and glueing it with the identity of X T yields the above version.
The following result proves the existence of compatible completions for surfaces, when the semi-algebraic set is regular at infinity (Definition 4.2): Theorem 4.5. Let V be a connected normal quasi-projective surface over R, and let S be a semi-algebraic subset of V (R) that is regular at infinity. Then V has a projective completion which is compatible with S. If V is non-singular then the completion can be chosen to be non-singular as well.
Proof. We may assume that the function field R(V ) is real. For otherwise, V (R) consists of finitely many singular points of V . In that case, any normal completion of V will be compatible with any subset of V (R).
We can also assume that S is closed in V (R). Start with any completion V ֒→ X 1 of V . Since V is a normal surface, the singular set V sing is finite. By resolving singularities of X 1 V sing and gluing the resulting surface to V we can assume X 1,sing ⊂ V . Let S be the closure of S in X 1 (R), let ∂S be its boundary in X 1 (R), and denote by C 1 the Zariski closure of ∂S in X 1 , a curve on X 1 . Further write D 1 = X 1 V . Now apply embedded resolution, as stated in Theorem 4.4, to the surface X 1 , the curve C 1 ∪D 1 on X and the set T := (C 1 ∪D 1 ) sing ∩D 1 . We obtain a birational morphism π : X → X 1 whose restriction π −1 (V ) → V is an isomorphism. Via π we can regard X as a completion of V . Let D = X V = π −1 (D 1 ) and C = π −1 (C). The completion V ֒→ X has the following properties: (1) X is projective and normal (non-singular if V is non-singular); (2) the irreducible components of the divisor C ∪ D are non-singular in all points of D, and if two components of C ∪ D meet in a point of D, then that point is a normal crossing singularity. We show that V ֒→ X is compatible with S. Let Z be an irreducible component of D = X V for which the set S ∩ Z(R) is non-empty. We have to show that this set is Zariski dense in Z. Let x ∈ S ∩ Z(R), and let u ∈ O X,x be a local equation for Z. There can be at most one more irreducible component Z ′ = Z of C ∪ D which passes through x, by property (2). If such Z ′ exists, let v ∈ O X,x be a local equation for Z ′ . Then u, v is a regular system of parameters for O X,x . If no such Z ′ exist we put Z ′ = Z and let v ∈ O X,x be any element for which u, v is a regular system of parameters for O X,x .
Let U be an open neighbourhood of x in X(R) such that U ∩ (C ∪ D)(R) ⊂ (Z ∪ Z ′ )(R). By shrinking U we can assume that u and v are regular functions on U . Shrinking U further if necessary, there are precisely four connected components of {y ∈ U : (uv)(y) = 0}. Since S is regular at infinity, it follows that S contains at least one of these four components. In particular, S ∩ Z(R) contains a nonempty open subset of Z(R) and is therefore Zariski dense in Z. This completes the proof.
1. We do not know whether Theorem 4.5 extends to dim(V ) > 2. See however Theorem 4.1.
2. In Theorem 4.5, the regularity of S at infinity is not necessary in order that a compatible completion exists. This is demonstrated by simple examples like the following: Let V = A 2 and consider the set S is the union of the right half plane with the x-axis. Clearly P 2 is a completion of A 2 which is compatible with S, even though S is not regular at infinity. On the other hand, when S ⊂ V (R) is unbounded but contained in the union of a compact set and a proper subvariety of V (so S fails to be Zariski dense at infinity), there cannot be any completion of V compatible with S (see Prop. 5.7.) 3. If C is a possibly singular (irreducible) affine curve, it is still true that C has a unique projective completion X which is non-singular in the added points (c.f. also [19] Lemma 4.5). The completion X is compatible with every semi-algebraic subset S of C(R), and Theorem 3.8 holds in this case as well. 4. Let X be a non-singular connected projective surface over R, and let D be a curve on X with irreducible components Z 1 , . . . , Z r . Then it is sometimes possible to calculate the transcendence degree of the ring B = O X (X D) from the intersection matrix M D = (Z i . Z j ) i,j=1,...,r of the divisor D: (1) If M D is negative definite, then trdeg R (B) = 0, hence B = R. For instance, consider T = {(x, y) ∈ R 2 : |x| ≤ 1, |xy| ≤ 1} as in Example 3.10. There we found B(T ) = O(X 2 D) with D = L ′′ ∪ E ′ 1 (using the notation from 3.10). The intersection matrix of D is which has a positive eigenvalue. Thus we conclude trdeg B(T ) = 2 without actually calculating the ring B(T ) as in 3.10. In this example, the transcendence degree can also be read off using Thm. 2.5, since the birational map Let V be an affine normal R-variety and let S ⊂ V (R) be a semi-algebraic subset. We have seen that the ring B V (S) is isomorphic to a ring O U (U ) for some quasiprojective R-variety U , provided that V has a completion which is compatible with S. We are now going to prove a converse (Thm. 4.11 below). It roughly states, for every quasiprojective U which is real, that the ring O U (U ) can be realized as B V (S) for some open affine subset V of U and some semi-algebraic subset S of V (R).
Lemma 4.7. Let V be an irreducible affine R-variety, and let X be a projective completion of V which is normal. Let Y 1 , . . . , Y r be irreducible components of X V which are real, and let Z 1 , . . . , Z s be the remaining components (real or not) of X V . There exists a regular and basic closed semi-algebraic subset S of V (R) that is compatible with Y 1 , . . . , Y r and whose closure in X(R) is disjoint from Z 1 (R), . . . , Z s (R). In particular, the completion X of V is compatible with S.
Proof. Fix an index i ∈ {1, . . . , r}. Since X is normal and Y i is real, we find a point p i ∈ Y i (R) which is non-singular on X and on X V . By this last fact, p i has a generalisation β i in Sper R(Y i ). Since X is normal, β i has a generalization α i in Sper R(X). Every semi-algebraic subset S of X(R) with α i ∈ S is compatible with Y i . There is an open affine subset U of X such that U (R) = X(R). Let x 1 , . . . , x n be a system of generators for the R-algebra R[U ]. If c i ∈ R is positive and sufficiently small, the closed semi-algebraic set will be contained in V reg (R) and regular, and moreover S i will be compatible with Y i and disjoint from Z 1 (R) ∪ · · · ∪ Z s (R). This being done for i = 1, . . . , r, we may further assume that S 1 , . . . , S r are pairwise disjoint, by making c 1 , . . . , c r even smaller if necessary.
We claim that S := S 1 ∪ · · · ∪ S r is a basic closed semi-algebraic subset of V (R), which will complete the proof. For i = 1, . . . , r put and let V 0 be the maximal Zariski open subset of V for which g i | V0 ∈ O V (V 0 ) for i = 1, . . . , r. Since V is normal, the closed subset Z = V V 0 has pure codimension one in V . Clearly Z(R) = ∅ since U (R) = X(R) and the g i are regular on U . Choose h 1 , . . . , h k ∈ R[V ] which generate the vanishing ideal of Z in R[V ], and put h := h 2 1 + · · · + h 2 k . Then h has no real zeros on V , and since V is normal, there exists N ≥ 1 such that f i := h N g i ∈ R[V ] for i = 1, . . . , r. Thus S i = {p ∈ V (R) : f i (p) ≥ 0} for every i, and hence S 1 ∪ · · · ∪ S r = p ∈ V (R) : (−1) r+1 f 1 (p) · · · f r (p) ≥ 0 , since the S i are pairwise disjoint.
An effective Weil divisor D on a normal R-variety X will be called totally real if every irreducible component of D is a real variety. By Cl(X) we denote the class group of Weil divisors modulo linear equivalence on X. We will use the following theorem: Theorem 4.8 (Roggero [16]). Let V be a normal affine real R-variety of dimension at least 2. Then every divisor on V is linearly equivalent to a totally real effective divisor on V .  Let U be a connected normal quasi-projective R-variety which is real. There exist real prime divisors Y 1 , . . . , Y r on U such that the variety U (Y 1 ∪· · ·∪Y r ) is affine.
Proof. If U is a curve, we can take r = 1 and Y 1 any real point on U . So we may assume dim(U ) ≥ 2. Assume furthermore that U is projective. Fix a non-singular point p ∈ U (R) and an ample divisor H on U , and let L ⊂ |H| consist of those D ∈ |H| that pass through p. The linear system L has no fixed components, so by Bertini's theorem (see for example Jouanolou [8], Cor. 6.11), the set of all Z ∈ L for which Z is irreducible and satisfies Z sing ⊂ U sing has non-empty interior inside L. In particular, it is non-empty. Any such Z is real since it contains p as a regular real point. Moreover U Z is affine since Z is ample.
When U is only quasi-projective, fix an open dense embedding U ֒→ X with X normal and projective and such that X U has pure codimension one in X (the latter can be achieved by blowing up if necessary). Let E be the divisor X U . By the projective case above we find an ample prime divisor H on X that is totally real. By Cor. 4.9, there exist n ∈ Z and a totally real effective divisor D on X such that −E ∼ D + nH. For m > max{0, n} the divisor E + D + mH is effective and ample. It follows that the irreducible components Y 1 , . . . , Y r of (D + mH) ∩ U are real and U (Y 1 ∪ · · · ∪ Y r ) is affine, as desired.
Theorem 4.11. Let U be a connected normal quasi-projective R-variety which is real. There exists an open affine subset V of U and a regular and basic closed subset Proof. Let U ֒→ X be a normal projective completion of U , and let Z 1 , . . . , Z s be the irreducible components of X U . By Lemma 4.10 there exist further prime divisors Y 1 , . . . , Y r on X which are real and such that the open subset V := X i Y i ∪ j Z j of U is affine. By Lemma 4.7 we find a regular and basic closed semi-algebraic set S in V (R) which is compatible with Y 1 , . . . , Y r and which satisfies S ∩ Z j (R) = ∅ for j = 1, . . . , s. In particular, the completion X of V is compatible with S. Therefore O U (U ) ∼ → B V (S) by Theorem 3.8.
Under certain conditions we know that the R-algebra B V (S) is finitely generated, see e.g. Thm. 5.12 below. Writing W := Spec B V (S) for the affine R-variety defined by this ring, the canonical morphism ϕ S : V → W is universal for morphisms that are bounded on S from V to affine varieties, i.e., every morphism V → W ′ into an affine R-variety W ′ which is bounded on S factors uniquely through ϕ S . Note that the variety W is normal, provided V is normal (Lemma 1.3(e)). We are wondering how to characterize all morphisms V → W of normal affine R-varieties which are of the form ϕ S : V → Spec B V (S) for some semi-algebraic subset S of V (R) (with B V (S) finitely generated).
Although we do not know a general answer to this question, we can present the following sufficient condition for birational morphisms: For the proof we need the following lemma: Lemma 4.13. Let V be an affine normal R-variety, and let Z be a given effective divisor on V which is totally real. There exists a compact semi-algebraic set S in V (R) which is compatible with every irreducible component of Z, and such that S (S ∩ Z(R)) is dense in S.
Proof. Let Z 1 , . . . , Z r be the irreducible components of Z, and fix i ∈ {1, . . . , r}. Since Z i is real and not contained in V sing , we find a point p i ∈ Z i (R) which is nonsingular on Z i and on V . So p i has a generalization β i in Sper R(Z i ), and in turn, β i has a generalization α i in Sper R(V ). Every semi-algebraic subset S of V (R) with α i ∈ S is compatible with Z i . If x 1 , . . . , x n is a system of generators of the R-algebra R[V ], we may therefore define S to be the closure of the set {p ∈ V (R) : p / ∈ Z(R), x 1 (p) 2 + · · · + x n (p) 2 < c}, where c ∈ R is positive and sufficiently large.
). Considering f as a rational function on W , it follows that f has a pole along one of the irreducible components of Z, since W is normal. Since T is compatible with that component, it follows from Lemma 3.5 that f is unbounded on T ∩ dom W (f ). In particular, f is unbounded on T (T ∩ Z(R)), and so f is unbounded on S.

Finite generation of the ring of bounded polynomials
We first recall that B C (S) is always finitely generated when C ist a curve: Proposition 5.1. Let C be an irreducible affine curve over R, possibly singular, and let S ⊂ C(R) be a semi-algebraic subset. Assume that C is real.
(a) B C (S) is finitely generated as an R-algebra.
(b) If every point of C at infinity is real and lies in the closure of S, then B C (S) = R. (c) Otherwise B C (S) has transcendence degree one over R.
Proof. Let C ֒→ X be the completion of C for which X sing ⊂ C sing (3.7.2), and let C ′ ⊂ X be the open subset which is the union of C and all R-points of X C which lie in the closure of S. Then O X (C ′ ) ∼ → B C (S). Indeed, even though Thm. 3.8 is not directly applicable here when C is singular, an inspection of the proof shows that it applies nevertheless. When C ′ = X then the curve C ′ is affine, and so B C (S) is a finitely generated R-algebra of transcendence degree one. When C ′ = X (which means that the hypothesis of (b) is satisfied) then B C (S) = R.
Before proceeding to our main result on finite generation, we study some consequences for the ring B V (S) that arise from the existence of an S-compatible completion.
Lemma and Definition 5.2. Let V be an irreducible R-variety, and let S be a semi-algebraic subset of V (R). There is a unique smallest Zariski closed subset Z of V such that S ⊂ Z(R) ∪ K for some compact subset K of V (R). We shall call Z the Zariski closure of S at infinity.
Proof. If Zariski closed subsets Z 1 , Z 2 of V and compact subsets K 1 , K 2 of V (R) are given with S ⊂ Z i (R) ∪ K i (i = 1, 2), then S is contained in Z 1 (R) ∩ Z 2 (R) ∪ (K 1 ∪ K 2 ). This implies the assertion.
Clearly, S is Zariski dense at infinity (Definition 4.2) if and only if its Zariski closure at infinity is V .
Proof. Since S ⊂ Z(R) ∪ K for some compact set K, it is clear that For if its closure K were compact, we would have S ⊂ K ∪ {b = 0}, contradicting the definition of Z. Hence there exists a semi-algebraic curve γ : [0, ∞[ → S, t → γ t such that b(γ t ) = 0 for all t ≥ 0 and such that Γ := {γ t : t ≥ 0} is unbounded in V (R). This last condition means that there exists f ∈ R[V ] for which f (γ t ), t ≥ 0, is unbounded. Since b = 0 on Γ, it follows from Lemma 5.4 below that the product f n b is unbounded on Γ for sufficiently large n ≥ 1. So bf n / ∈ B V (S).
The following well-known fact was used in the last proof: be two continuous semi-algebraic functions such that f is unbounded and g > 0 everywhere. Then f n g is unbounded for sufficiently large n ≥ 1.
Lemma 5.5. Let B ⊂ A be a ring extension, and let J be an ideal of A which is contained in B. If J contains an element which is not a zero divisor of A, and if J is finitely generated as an ideal of B, then the extension B ⊂ A is integral.
Proof. This is a special case of [5,Cor. 4.6].
Lemma 5.6. Let Y be a connected normal R-variety, and let V ⊂ Y be an affine open subset.
Since Y is normal this means that there exists a prime divisor Z of Y with v Z (f ) ≤ −1. Unless b = 0 we therefore get v Z (bf n ) ≤ −1 for large n > 0, and so bf n / ∈ O(Y ). This proves the assertion.
Proposition 5.7. Let V be a connected normal affine R-variety, and let S be an unbounded semi-algebraic subset of V (R). Consider the following conditions: The equivalence of (iii) and (iv) follows from Prop. 5.3.

holds.
Assume that S is unbounded and (for simplicity) closed, and that B V (S) is noetherian. Then conclusion (5.1) implies for any compact subset T of S that S T is Zariski dense in V (R). This means that S is Zariski dense at infinity, and shows that the implication (ii) ⇒ (iv) of 5.7 is contained in Prop. 5.10. We now consider algebraic surfaces. Theorem 5.12 below is one of our main results. It is based on the results of Sections 3 and 4 and on the following theorem: Theorem 5.11 (Zariski). Let W be a normal quasi-projective surface over a field k of characteristic zero. Then the ring O W (W ) is finitely generated as a k-algebra.
See Zariski [22], remarks on Theorem 1 at the end of the article. An alternative proof in modern language was given in [9], based on ideas of Nagata.
Theorem 5.12. Let V be a connected normal affine surface over R. For every semi-algebraic subset S of V (R) which is regular at infinity, the R-algebra B V (S) is finitely generated.
Proof. By Theorem 4.5, V has a projective completion V ֒→ X which is compatible with S. If Y is the union of all irreducible components of X V without a real point, then O X (X Y ) ∼ → B V (S) by Theorem 3.8. This implies the assertion, since O X (X Y ) is finitely generated by Zariski's theorem 5.11.

5.13.
It is folklore knowledge that Zariski's theorem 5.11 ceases to be true in dimensions larger than two. However, it seems not so easy to localize a reference for this fact in the published literature.
A construction of a quasi-projective non-singular threefold whose ring of global sections is not finitely generated was given by Vakil [21]: Take an elliptic curve E over a field k, and let L, L ′ be invertible sheaves on E such that deg(L ′ ) > 0, deg(L) = 0 and L is not torsion in Pic(E). Let W be the total space of the vector bundle L ⊕ L ′ on E. Then the ring O W (W ) is not noetherian. By a variation of this construction one can also obtain another example which is even quasi-affine (see [21]).
Using this construction for k = R in a case where the elliptic curve E is real, we can apply Theorem 4.11 and conclude: Corollary 5.14. There exists a non-singular affine R-variety V of dimension three and a regular and basic closed semi-algebraic subset S of V (R) for which the ring B V (S) is not noetherian.

5.15.
From results of Kuroda [10], it is possible to conclude the existence of rational, normal, quasi-affine threefolds whose ring of regular functions is not finitely generated. This was pointed out to us by Sebastian Krug, answering a question in an earlier version of this paper. The details of the construction, which he communicated to us, are not presented here. 5.16. By Zariski's theorem, an example as in 5.13 cannot exist in dimension two. However, there are examples of (non-normal) irreducible quasi-projective surfaces W for which O W (W ) is not finitely generated. One such construction of a quasiaffine example is due to Nagata ([13], [14], see also [9] for a detailed account).
The construction of two-dimensional varieties whose ring of global sections is not finitely generated becomes much easier when we allow the variety to be reducible. Here is an example (again see [9] for details): In affine 3-space with coordinates (x, y, z) let U := V (xy) (the transversal union of two planes) and L := V (y, z) (a line in one of the planes which intersects the other plane transversely). Then W := U L is a reducible quasi-affine variety of dimension two for which the ring O W (W ) is not noetherian.
To interpret this example in terms of bounded functions, let an open affine subvariety of W , and write L ′ = V (x, z). Let S 0 be a regular, compact and basic closed semi-algebraic subset of U (R) which is disjoint from L and compatible with L ′ . For example, S 0 = {(0, y, z) : (y − 2) 2 + z 2 ≤ 1} will do. Then S = S 0 ∩ V (R) is basic closed in V (R), and B V (S) = O W (W ) is not noetherian.