# On the bad points of positive semidefinite polynomials

Olivier Benoist  Département de mathématiques et applications, École normale
supérieure, CNRS, 45 rue d’Ulm, 75230 Paris Cedex 05, France
<EMAIL_ADDRESS>
###### Abstract.

A bad point of a positive semidefinite real polynomial $f$ is a point at which
a pole appears in all expressions of $f$ as a sum of squares of rational
functions. We show that quartic polynomials in three variables never have bad
points. We give examples of positive semidefinite polynomials with a bad point
at the origin, that are nevertheless sums of squares of formal power series,
answering a question of Brumfiel. We also give an example of a positive
semidefinite polynomial in three variables with a complex bad point that is
not real, answering a question of Scheiderer.

## Introduction

Let $f\in\mathbb{R}[x_{1},\dots,x_{n}]$ be a polynomial with real coefficients
that is positive semidefinite, i.e., that only takes nonnegative values. Its
degree $d$ is then even. Sometimes, one may explain the positivity of $f$ by
writing it as a sum of squares of polynomials. Such is the case when $n\leq
1$, when $d\leq 2$, and, as Hilbert proved in [Hil88], when $(n,d)=(2,4)$. For
all other values of $(n,d)$, there exist positive semidefinite polynomials
that are not sums of squares of polynomials [Hil88].

Hilbert asked in his celebrated $17$th problem whether all positive
semidefinite polynomials $f$ could however be written as sums of squares of
rational functions. This was proven by him [Hil93] when $n=2$ and by Artin
[Art27, Satz 4] in general.

To understand the possible denominators in a representation of $f$ as a sum of
squares in $\mathbb{R}(x_{1},\dots,x_{n})$, it is natural to introduce the set
$B(f)\subset\mathbb{C}^{n}$ of bad points of $f$: those points at which some
denominator vanishes in all possible representations of $f$ as a sum of
squares in $\mathbb{R}(x_{1},\dots,x_{n})$. The existence of a bad point may
be thought of as an explanation why $f$ cannot be a sum of squares in
$\mathbb{R}[x_{1},\dots,x_{n}]$.

As indicated in [Del80, p. 20], that bad points may exist was first noted by
Straus in a 1956 letter to Kreisel: if $f\in\mathbb{R}[x_{1},\dots,x_{n}]$ is
not a sum of squares of polynomials, then its homogenization in
$\mathbb{R}[x_{1},\dots,x_{n+1}]$ has a bad point at the origin. Such examples
only appeared in print twenty years later (see [CL77, Theorem 4.3], [Bru79, p.
196], [CLRR80, Proposition 3.5], [BE80, Counterexample 9.1] or [Del80, pp.
59-61]).

The bad locus $B(f)\subset\mathbb{C}^{n}$ of $f$ always has codimension $\geq
3$, as was shown in increasing generality by Choi and Lam [CL77, Theorem 4.2],
by Delzell [Del80, Proposition 5.1], and by Scheiderer [Sch01, Theorem 4.8].
In particular, bad points never appear when $n=2$ (which yields examples of
polynomials $f$ with no bad points that are nevertheless not sums of squares
of polynomials).

Our first theorem shows that a similar phenomenon occurs when $(n,d)=(3,4)$.

######  Theorem 0.1 (Theorem 2.4).

Positive semidefinite real polynomials of degree four in three variables have
no bad points.

The $(n,d)=(3,4)$ case considered in this theorem is the only one for which
the question of the existence of bad points is not covered by the above-
mentioned results. It was ostensibly left open in [CL77, Theorem 4.3].

Our proof builds on the works of several authors: Hilbert’s classical theorem
on quartics in two variables [Hil88], Choi, Lam and Reznick’s detailed study
of quartics in three variables [CLR80], and Scheiderer’s general results on
sums of squares in local rings [Sch01]. The argument works over an arbitrary
real closed field.

In three variables, all known examples of bad points share striking common
features. To begin with, they are all real points. It was asked by Scheiderer
[Sch00, Remark 1.4 2] whether a positive semidefinite $f\in\mathbb{R}[x,y,z]$
could have a nonreal bad point. In our second main theorem, we construct such
an example.

######  Theorem 0.2 (Theorem 3.6).

There exists a positive semidefinite polynomial in $\mathbb{R}[x,y,z]$ with a
bad point that is not real.

The only bad points of our example are $(0,0,i)$ and $(0,0,-i)$ (see Theorem
3.6).

In $\geq 4$ variables, examples of nonreal bad points were already known since
the bad locus $B(f)$ may have dimension $\geq 1$ (see [Del80, Example 1 p.
59]). However, Theorem 0.2 is the first example in any number of variables
where the real bad points of $f$ are not Zariski-dense in $B(f)$.

Additionally, in all existing examples of positive semidefinite
$f\in\mathbb{R}[x,y,z]$ with a real bad point, assumed to be the origin, this
point is shown to be bad by an analysis of some low degree monomials of $f$.
As a consequence, the polynomial $f$ is not even a sum of squares in the ring
$\mathbb{R}[[x,y,z]]$ of formal power series. An old question of Brumfiel
appearing in [Del80, p. 62] asks whether this is a general phenomenon. In our
third main theorem, we answer this question in the negative.

######  Theorem 0.3 (Theorem 3.10).

There exists a positive semidefinite polynomial in $\mathbb{R}[x,y,z]$ that
has a bad point at the origin, but that is a sum of squares in
$\mathbb{R}[[x,y,z]]$.

Our example does not have other bad points than the origin (see Theorem 3.10).

Brumfiel asked his question in any number of variables. There are however
easier examples in $\geq 4$ variables, as it may happen that a positive
semidefinite $f\in\mathbb{R}[w,x,y,z]$ is a sum of squares in
$\mathbb{R}[[w,x,y,z]]$ but not in $\mathbb{R}[w,x,y,z]_{\langle
w,x,y,z\rangle}$ for the simple reason that it is not even a sum of squares in
some other completion of $\mathbb{R}[w,x,y,z]_{\langle w,x,y,z\rangle}$. We
give such an example in Theorem 3.14.

This last remark points to what is difficult in proving Theorems 0.2 and 0.3.
Let $\mathfrak{m}\subset\mathbb{R}[x,y,z]$ be the maximal ideal corresponding
to the bad point. Under the hypotheses of either theorem, the polynomial $f$
has to be a sum of squares in all the completions of
$\mathbb{R}[x,y,z]_{\mathfrak{m}}$ (apply [Sch01, Corollary 2.4 and Theorem
4.8]). We thus need to devise an obstruction to $f$ being a sum of squares in
the local ring $\mathbb{R}[x,y,z]_{\mathfrak{m}}$ that is sufficiently global
in nature to allow $f$ to be a sum of squares in all the completions of
$\mathbb{R}[x,y,z]_{\mathfrak{m}}$. We now briefly explain how to overcome
this difficulty (see Section 3 for more details).

Let $\Gamma\subset\mathbb{A}^{3}_{\mathbb{R}}$ be an integral curve through
$\mathfrak{m}$ such that $\Gamma(\mathbb{R})$ is Zariski-dense in $\Gamma$ and
such that $f$ vanishes on $\Gamma$. It follows from these facts that, in any
representation $f=\sum_{i}f_{i}^{2}$ of $f$ as a sum of squares in
$\mathbb{R}[x,y,z]_{\mathfrak{m}}$, the $f_{i}$ must vanish on $\Gamma$. As a
consequence, one has $f\in(I_{\Gamma}^{2})_{\mathfrak{m}}$, where $I_{\Gamma}$
is the ideal defining $\Gamma$. It thus suffices to arrange that
$f\notin(I_{\Gamma}^{2})_{\mathfrak{m}}$ to ensure that it is not a sum of
squares in $\mathbb{R}[x,y,z]_{\mathfrak{m}}$.

This is not easy to achieve. Indeed, since $f$ is positive semidefinite, it
belongs to the ideal $I_{\Gamma}^{2}$ at all smooth real points of $\Gamma$,
hence generically along $\Gamma$. In other words, it belongs to the symbolic
square $I_{\Gamma}^{(2)}$ of $I_{\Gamma}$ (see (3.1) for the definition of
$I_{\Gamma}^{(2)}$ and the survey [DDG+18] for more information on this
topic). We thus need the ideals $I_{\Gamma}^{2}$ and $I_{\Gamma}^{(2)}$ to be
distinct. The simplest example of this phenomenon, already appearing in
[Nor53, Example3 p. 29], is the ideal of the image of the morphism
$t\mapsto(t^{3},t^{4},t^{5})$.

The polynomials we use to prove Theorems 0.2 and 0.3 are both constructed by
modifying appropriately this basic example. For Theorem 0.2, this strategy
leads to a concrete polynomial of degree ten (see Theorem 3.6). The proof of
Theorem 0.3 is more involved and does not yield an explicit example.

Our strategy actually works on arbitrary smooth varieties over any base field.
We thus obtain the following result. Recall that a field is said to be
formally real if it admits a field ordering (in particular, such a field has
characteristic $0$).

######  Theorem 0.4 (Theorem 3.12).

Let $X$ be an affine variety over a field $k$. Let $A$ be a local ring of $X$
that is regular, with maximal ideal $\mathfrak{m}$. Assume that $\dim(A)\geq
3$ and that $\mathrm{Frac}(A)$ is formally real. Then there exists
$f\in\mathcal{O}(X)$ such that:

  1. (i)

The element $f$ is a sum of squares in the completion
$\widehat{A}_{\mathfrak{m}}$ of $A$ at $\mathfrak{m}$.

  2. (ii)

For all prime ideals $\mathfrak{p}\neq\mathfrak{m}$ of $A$, $f$ is a sum of
squares in the localization $A_{\mathfrak{p}}$.

  3. (iii)

But $f$ is not a sum of squares in $A$.

Notice that Theorem 0.2 (resp.Theorem 0.3) may be obtained as the particular
case of Theorem 0.4 where $k=\mathbb{R}$, $X=\mathbb{A}^{3}_{\mathbb{R}}$ and
$\mathfrak{m}$ has residue field $\mathbb{C}$ (resp.$\mathbb{R}$).

Theorem 0.4 yields the first examples of a regular local ring $A$ with $2\in
A^{*}$ and of an element $f\in A$ that is a sum of squares in all the
completions of $A$ but not in $A$. Such examples do not exist if $\dim(A)\leq
2$ by [Sch01, Theorem 4.8], or if $\mathrm{Frac}(A)$ is not formally real
[Sch01, Corollaries 1.5 and 2.4].

Thanks to Theorem 0.4, we are able to complete the proof of the following
result, which is almost entirely due to Scheiderer (the case that was still
open is explicitely mentioned in [Sch00, Remark 1.4 2]). To state it, we
recall that an element $f$ of a ring $A$ is positive semidefinite if it is
nonnegative with respect to all the orderings of the residue fields of $A$.

######  Theorem 0.5.

Let $A$ be the local ring at a regular point of a variety over a field $k$ of
characteristic not $2$. The following are equivalent:

  1. (i)

All positive semidefinite elements of $A$ are sums of squares in $A$.

  2. (ii)

Either $\dim(A)\leq 2$ or $\mathrm{Frac}(A)$ is not formally real.

###### Proof.

If $\dim(A)\leq 2$, one may apply [Sch01, Theorem 4.8], and if
$\mathrm{Frac}(A)$ is not formally real, the theorem follows from [Sch01,
Corollaries 1.5 and 2.4]. The other cases are covered by Theorem 0.4, but were
already known if either $\dim(A)\geq 4$ or if the residue field of $A$ is
formally real (see [Sch00, Propositions 1.2 and 1.5]). ∎

Understanding when assertion (i) of Theorem 0.5 holds is also interesting when
$A$ is possibly singular. We refer to [Sch01, Theorem 3.9], to [Fer02, Theorem
3.1] and to [FRS04, Theorem 1.1] for the best known results in dimensions $1$,
$2$ and $\geq 3$ respectively.

It is tempting to ask if Theorem 0.5 remains true for arbitrary regular local
rings, not necessarily of geometric origin. In our last result, we show that
this is not the case, answering a question raised in [Sch01, bottom of p.
209].

######  Theorem 0.6 (Theorem 4.2).

For all $n\geq 0$, there exists a regular local $\mathbb{R}$-algebra $A$ of
dimension $n$ with the following properties:

  1. (i)

All positive semidefinite elements of $A$ are sums of squares in $A$.

  2. (ii)

The field $\mathrm{Frac}(A)$ is formally real.

The regular local rings we consider to prove Theorem 0.6 are actually not far
from geometry: they lie between the local ring of
$\mathbb{A}^{n}_{\mathbb{R}}$ at the origin and its Henselization.

### Acknowledgements

I thank Charles N. Delzell and Claus Scheiderer for having made [Del80]
available to me.

##  1\. Generalities on real spectra and sums of squares

If $A$ is ring and $\mathfrak{p}\subset A$ is a prime ideal, we let
$A_{\mathfrak{p}}$ and $\widehat{A}_{\mathfrak{p}}$ be the localization and
the completion of $A$ at $\mathfrak{p}$, and we denote by
$I_{\mathfrak{p}}=IA_{\mathfrak{p}}\subset A_{\mathfrak{p}}$ and
$\widehat{I}_{\mathfrak{p}}=I\widehat{A}_{\mathfrak{p}}\subset\widehat{A}_{\mathfrak{p}}$
the ideals generated by an ideal $I\subset A$.

The real spectrum $\mathrm{Sper}(A)$ of a ring $A$ is the set of pairs
$\xi=(\mathfrak{p},\prec)$, where $\mathfrak{p}$ is a prime ideal of $A$ and
$\prec$ is a field ordering of $\mathrm{Frac}(A/\mathfrak{p})$. The element
$\xi\in\mathrm{Sper}(A)$ is said to be supported at $\mathfrak{p}$. We denote
by $\prec_{\xi}$ the ordering associated with $\xi$. We endow
$\mathrm{Sper}(A)$ with its spectral topology [BCR98, Definition 7.1.3],
generated by open sets of the form $\\{\xi\in\mathrm{Sper}(A)\mid
f_{i}\succ_{\xi}0\\}$ for ${(f_{i})_{1\leq i\leq m}\in A}$. If
$\xi,\zeta\in\mathrm{Sper}(A)$, one says that $\xi$ is a specialization of
$\zeta$ if $\xi$ belongs to the closure of $\zeta$. An element ${f\in A}$ is
positive semidefinite (resp.totally positive) if it is nonnegative
(resp.positive) with respect to all points of $\mathrm{Sper}(A)$. A real
polynomial $f\in\mathbb{R}[x_{1},\dots,x_{n}]$ is positive semidefinite in
this sense if and only if it is positive semidefinite in the sense considered
in the introduction (see [BCR98, Propositions 7.2.1 and 7.2.2]).

If $k$ is a field, then $\mathrm{Sper}(k)$ coincides with the set of field
orderings of $k$ endowed with the Harrison topology (see [Lam05, VIII, §6]).
The field $k$ is said to be formally real if $\mathrm{Sper}(k)$ is nonempty,
i.e., if $k$ admits a field ordering.

We now collect a few known statements that will be used repeatedly in the
sequel. We start with two lemmas.

######  Lemma 1.1 ([Sch00, Lemma 0.1]).

Let $A$ be a regular domain with fraction field $K$. Then $\mathrm{Sper}(K)$
is dense in $\mathrm{Sper}(A)$.

######  Lemma 1.2 ([Sch00, Lemma 5.1 a)]).

Let $A$ be a regular local ring with maximal ideal $\mathfrak{m}$. Let $f\in
A$ be positive semidefinite. If $f\in\mathfrak{m}^{d}$, the image of $f$ in
${\mathfrak{m}^{d}/\mathfrak{m}^{d+1}=\mathrm{Sym}^{d}(\mathfrak{m}/\mathfrak{m}^{2})}$
is a positive semidefinite polynomial function on
$(\mathfrak{m}/\mathfrak{m}^{2})^{\vee}$.

In particular, if $A/\mathfrak{m}$ is formally real and $d$ is odd, then
$f\in\mathfrak{m}^{d+1}$.

The following two theorems are due to Scheiderer.

######  Theorem 1.3 ([Sch01, Corollary 2.4]).

Let $A$ be a local ring with $2\in A^{*}$. If $f\in A$ is totally positive,
then $f$ is a sum of squares.

######  Theorem 1.4 ([Sch01, Theorem 4.8]).

Let $A$ be a regular local ring of dimension two with $2\in A^{*}$. If $f\in
A$ is positive semidefinite, then $f$ is a sum of squares.

##  2\. Quartics in three variables have no bad points

In this section, we show that positive semidefinite quartic polynomials in
three variables have no bad points (Theorem 2.4). We also study quartics in
three variables that are nonnegative in a neighbourhood of the origin (see
Theorem 2.5).

Throughout, we work over a real closed field $R$. We start with a series of
lemmas.

######  Lemma 2.1.

Let $B$ be a ring with $2\in B^{*}$. Fix $g\in B[[x_{1},\dots,x_{n}]]$ with
only terms of degree $\geq 3$. Choose $0\leq r\leq n$. Then there exist
$(a_{i})_{1\leq i\leq r}\in B[[x_{1},\dots,x_{n}]]$ with only terms of degree
$\geq 2$, and $b\in B[[x_{r+1},\dots,x_{n}]]$, such that

$\sum_{i=1}^{r}x_{i}^{2}+g=\sum_{i=1}^{r}(x_{i}+a_{i})^{2}+b.$

###### Proof.

By induction on $N\geq 1$, we will construct $(a_{i,N})_{1\leq i\leq r}\in
B[x_{1},\dots,x_{n}]$, $b_{N}\in B[x_{r+1},\dots,x_{n}]$ and $c_{N}\in
B[[x_{1},\dots,x_{n}]]$ with the following properties:

  1. (i)

One has
$\sum_{i=1}^{r}x_{i}^{2}+g=\sum_{i=1}^{r}(x_{i}+a_{i,N})^{2}+b_{N}+c_{N}$.

  2. (ii)

Only terms of degree $\geq 2$ appear in $a_{i,N}$.

  3. (iii)

Only terms of degree $\geq N+2$ appear in $c_{N}$.

  4. (iv)

Only terms of degree $\geq N+1$ appear in $a_{i,N+1}-a_{i,N}$ and in
$b_{N+1}-b_{N}$.

To do so, we set $a_{i,1}=b_{1}=0$ and $c_{1}=g$. If $a_{i,N}$, $b_{N}$ and
$c_{N}$ have been constructed, write the degree $N+2$ term of $c_{N}$ as
$\sum_{i=1}^{r}x_{i}u_{i}+v$, where $u_{i}\in B[x_{1},\dots,x_{n}]$ has degree
$N+1$ and $v\in B[x_{r+1},\dots,x_{n}]$ has degree $N+2$. It now suffices to
define $a_{i,N+1}=a_{i,N}+u_{i}/2$, $b_{N+1}=b_{N}+v$ and
$c_{N+1}=c_{N}-v-\sum_{i=1}^{r}(x_{i}u_{i}+a_{i,N}u_{i}+u_{i}^{2}/4)$.

To conclude, define $a_{i}:=\lim_{N\to\infty}a_{i,N}$ and
$b:=\lim_{N\to\infty}b_{N}$, where the limits are taken with respect to the
$\langle x_{1},\dots,x_{n}\rangle$-adic topology. ∎

######  Lemma 2.2.

Let $f\in R[[x_{1},\dots,x_{n}]]$ be positive semidefinite. Assume that the
lowest degree term of $f$ is a quadratic form of rank $r\geq n-2$. Then $f$ is
a sum of squares in $R[[x_{1},\dots,x_{n}]]$.

###### Proof.

The degree $2$ term of $f$ is positive semidefinite by Lemma 1.2. Since it may
be diagonalized after a linear change of coordinates, we may assume that
${f=\sum_{i=1}^{r}x_{i}^{2}+g}$, where all monomials in $g\in
R[[x_{1},\dots,x_{n}]]$ have degree $\geq 3$.

By Lemma 2.1 applied with $B=R$, there exist $(a_{i})_{1\leq i\leq r}\in
R[[x_{1},\dots,x_{n}]]$ with only terms of degree $\geq 2$, and $b\in
R[[x_{r+1},\dots,x_{n}]]$, such that $f=\sum_{i=1}^{r}(x_{i}+a_{i})^{2}+b$.

Since $f$ is positive semidefinite, so is its image in
$R[[x_{1},\dots,x_{n}]]/\langle x_{i}+a_{i}\rangle_{1\leq i\leq r}$, showing
that $b\in R[[x_{r+1},\dots,x_{n}]]$ is positive semidefinite. As $r\geq n-2$,
Theorem 1.4 shows that $b$ is a sum of squares in $R[[x_{r+1},\dots,x_{n}]]$.
The proof is now complete. ∎

######  Lemma 2.3.

A polynomial $f\in R[x,y,z]$ of degree $\leq 4$ which is positive semidefinite
in $R[[x,y,z]]$ is a sum of squares in $R[[x,y,z]]$.

###### Proof.

By Lemma 1.2, the lowest degree term of $f$ is positive semidefinite of degree
$0$, $2$ or $4$. If it has degree $0$, then $f$ is a square in $R[[x,y,z]]$,
and we are done. If it has degree $2$, one may apply Lemma 2.2 to conclude. If
it has degree $4$, then $f$ is a sum of three squares of quadratic polynomials
by Hilbert’s theorem [Hil88] (this result, proven over $\mathbb{R}$ in
_loc_._cit_., holds over an arbitrary real closed field by the Tarski-
Seidenberg principle [BCR98, Proposition 5.2.3]). ∎

Now comes the main theorem of Section 2.

######  Theorem 2.4.

Let $f\in R[x,y,z]$ be positive semidefinite of degree $\leq 4$. For all
maximal ideals $\mathfrak{m}\subset R[x,y,z]$, the polynomial $f$ is a sum of
squares in $R[x,y,z]_{\mathfrak{m}}$.

###### Proof.

If $f$ has at least twelve real zeros, then it is a sum of six squares of
quadratic polynomials, by a theorem of Choi, Lam and Reznick [CLR80, Theorem
5.1] (this fact, proven over the reals in _loc_._cit_., is valid over any real
closed field by the Tarski-Seidenberg principle [BCR98, Proposition 5.2.3]).

We may thus assume that $f$ has finitely many real zeros. Using [BCR98,
Theorem 7.2.3], we see that $\mathrm{Sper}((R[x,y,z]/\langle
f\rangle)_{\mathfrak{m}})$ contains exactly one point (which is supported at
$\mathfrak{m}$) if the residue field of $\mathfrak{m}$ is $R$, and is empty
otherwise. In the latter case, the element $f\in R[x,y,z]_{\mathfrak{m}}$ is
totally positive, hence a sum of squares by Theorem 1.3.

It remains to deal with the case where the residue field of $\mathfrak{m}$ is
$R$. After changing coordinates by a translation, one may suppose that
$\mathfrak{m}=\langle x,y,z\rangle$. By Lemma 2.3, the polynomial $f$ is a sum
of squares in $R[[x,y,z]]$. Since $\mathrm{Sper}((R[x,y,z]/\langle
f\rangle)_{\mathfrak{m}})$ is supported at $\mathfrak{m}$, a theorem of
Scheiderer [Sch01, Corollary 2.7 (ii)$\Rightarrow$(i)] shows that $f$ is a sum
of squares in $R[x,y,z]_{\mathfrak{m}}$, as wanted. ∎

We conclude this section with a more concrete reformulation of Lemma 2.3.

######  Theorem 2.5.

Let $f\in R[x,y,z]$ be of degree $\leq 4$. The following are equivalent:

  1. (i)

The function $f:R^{3}\to R$ takes only nonegative values in a Euclidean
neighbourhood of the origin.

  2. (ii)

The polynomial $f$ is a sum of squares in $R[[x,y,z]]$.

###### Proof.

It suffices to combine Lemma 2.3 and Lemma 2.6 below. ∎

######  Lemma 2.6.

Let $A$ be a finitely generated $R$-algebra, fix $f\in A$ and let
$\mathfrak{m}\subset A$ be a maximal ideal with residue field $R$. The
following assertions are equivalent:

  1. (i)

The element $f\in\widehat{A}_{\mathfrak{m}}$ is positive semidefinite.

  2. (ii)

The function $\mathrm{Spec}(A)(R)\to R$ induced by $f$ takes only nonnegative
values in a Euclidean neighbourhood of the point of $\mathrm{Spec}(A)(R)$
corresponding to $\mathfrak{m}$.

###### Proof.

Let $x$ (resp.$\tilde{x}$) be the point of $\mathrm{Spec}(A)(R)$ (resp.of
$\mathrm{Sper}(A)$) associated to $\mathfrak{m}$. By [Rui86, Théorème 1.1],
the image of the natural map
$\mathrm{Sper}(\widehat{A}_{\mathfrak{m}})\to\mathrm{Sper}(A)$ consists
exactly of the elements having $\tilde{x}$ as a specialization.

If (ii) holds, the semi-algebraic subset $\\{f\geq 0\\}$ of
$\mathrm{Spec}(A)(R)$ contains a neighbourhood of $x$. It follows from [BCR98,
Theorem 7.2.3] that the constructible subset $\\{f\geq 0\\}$ of
$\mathrm{Sper}(A)$ contains a neighbourhood of $\tilde{x}$, hence all points
having $\tilde{x}$ as a specialization. Consequently, $f$ is positive
semidefinite in $\widehat{A}_{\mathfrak{m}}$.

Conversely, assume that (ii) does not hold, hence that the open subset
$\\{f<0\\}$ of $\mathrm{Spec}(A)(R)$ contains $x$ in its closure. By [BCR98,
Theorem 7.2.3], the open subset $\\{f<0\\}$ of $\mathrm{Sper}(A)$ contains
$\tilde{x}$ in its closure. In view of [BCR98, Proposition 7.1.21], this
subset of $\mathrm{Sper}(A)$ contains a point specializing to $\tilde{x}$.
This shows that $f$ is not positive semidefinite as an element of
$\widehat{A}_{\mathfrak{m}}$. ∎

######  Remark 2.7.

Scheiderer has shown in [Sch16, Theorem 2.1] the existence of a homogeneous
polynomial $f\in\mathbb{Q}[x,y,z]$ of degree $4$ that is positive
semidefinite, but not a sum of squares in $\mathbb{Q}[x,y,z]$. Using the
homogeneity of $f$, one sees that $f$ is not a sum of squares in
$\mathbb{Q}[[x,y,z]]$ either. This shows that Theorems 2.4 and 2.5 cannot be
extended to general base fields that are not necessarily real closed.

##  3\. Examples of bad points

In §3.1, we state a simple criterion for an element of a ring not to be a sum
of squares. This criterion is applied in §3.3 and §3.5 to give examples of
real positive semidefinite polynomials in three variables with a nonreal bad
point, or with a real bad point that cannot be detected after completion
(Theorems 3.6 and 3.10). We apply it again in §3.6 to give examples of regular
bad points on varieties over a field that satisfy minimal hypotheses (Theorem
3.12). Another example of bad point, of a different nature, is presented in
§3.7.

In this whole section, we let $k$ be a field of characteristic $0$.

###  3.1. A criterion to be a bad point

We will rely on the following easy lemma.

######  Lemma 3.1.

Let $I$ be a radical ideal in a ring $A$ such that the image of
$\mathrm{Sper}(A/I)$ in $\mathrm{Spec}(A/I)$ is Zariski-dense. If $f\in
I\setminus I^{2}$, then $f$ is not a sum of squares in $A$.

###### Proof.

Assume for contradiction that $f=\sum_{i}f_{i}^{2}$ is a sum of squares in
$A$. Then $\sum_{i}f_{i}^{2}$ vanishes in $A/I$. It follows that the $f_{i}$
vanish at all formally real residue fields of $A/I$. As $\mathrm{Sper}(A/I)$
is Zariski-dense in $\mathrm{Spec}(A/I)$ and as $A/I$ is reduced, the $f_{i}$
vanish in $A/I$. The $f_{i}$ thus belong to $I$, so that $f\in I^{2}$, which
is absurd. ∎

Recall that the symbolic square of an ideal $I$ in a Noetherian ring $A$ is

(3.1) $I^{(2)}:=\\{f\in A\mid f\in I^{2}_{\mathfrak{p}}\textrm{ for all
associated primes }\mathfrak{p}\textrm{ of }A/I\\}.$

The following lemma will not be used in the sequel, but explains why it may be
difficult to apply Lemma 3.1 in practice.

######  Lemma 3.2.

Under the hypotheses of Lemma 3.1, if the ring $A$ is regular and the element
$f\in A$ is positive semidefinite, then $f\in I^{(2)}$.

###### Proof.

Let $\mathfrak{p}$ be an associated prime ideal of $A/I$. One has
$\mathfrak{p}A_{\mathfrak{p}}=I_{\mathfrak{p}}$ because $I$ is radical. As
$\mathrm{Sper}(A/I)$ is Zariski-dense in $\mathrm{Spec}(A/I)$, one cannot
write $-1$ as a sum of squares in $\kappa:=\mathrm{Frac}(A/\mathfrak{p})$, so
that $\kappa$ is formally real by [BCR98, Theorem 1.1.8]. Since
$f\in\mathfrak{p}A_{\mathfrak{p}}$ is positive semidefinite and $\kappa$ is
formally real, Lemma 1.2 shows that
$f\in\mathfrak{p}^{2}A_{\mathfrak{p}}=I_{\mathfrak{p}}^{2}$. ∎

Consequently, to apply Lemma 3.1 to give an example of a positive semidefinite
element in a regular ring that is not a sum of squares, we must ensure that
$I^{(2)}\neq I^{2}$. A basic example of an ideal in a regular ring whose
square and symbolic square are distinct will be given later, in Lemma 3.5.

###  3.2. A criterion to be a sum of squares

In our proofs of Theorems 3.6 and 3.10, we also need a way to check that a
regular function on a variety over $k$ is a sum of squares in a neighbourhood
of a point. This is the role of Proposition 3.3.

######  Proposition 3.3.

Let $X$ be a smooth affine variety of dimension $n$ over $k$. Let
$f\in\mathcal{O}(X)$ be positive semidefinite, and let $p\in X$ be a closed
point. Let $Y\subset X$ be the Zariski closure of
$\mathrm{Sper}(\mathcal{O}(X)/\langle f\rangle)$. If $p\in Y$, then the
differential of $f$ at $p$ vanishes. If moreover $Y$ is smooth of dimension
$n-c$ at $p$ and the Hessian of $f$ at $p$ has rank $\geq c$, then $f$ is a
sum of squares in $\mathcal{O}_{X,p}$.

###### Proof.

By Lemma 1.2, the differential of $f$ vanishes at all points $x\in X$ with
formally real residue field such that $f(x)=0$. It follows that the
differential of $f$ vanishes on $Y$, hence at $p$.

Set $A:=\mathcal{O}_{X,p}$ and let $I\subset A$ be the ideal of functions
vanishing on $\mathrm{Sper}(A/\langle f\rangle)$. As the generic points of $Y$
are formally real by Lemma 1.1, we see that $I$ is the ideal of the subscheme
$Y\times_{X}\mathrm{Spec}(A)$ of $\mathrm{Spec}(A)$.

Since $Y$ is smooth of dimension $n-c$ at $p$, the local ring $B:=A/I$ is
regular of dimension $n-c$. We have seen above that the fraction field of $B$
is formally real. As $f$ is positive semidefinite, it follows from Lemma 1.2
that the image of $f$ in the localization $A_{I}$ belongs to $I^{2}A_{I}$. We
deduce from [ZS60, Appendix 6, Lemma 5] applied with $\mathfrak{a}=I$ (or from
[Hoc73, (2.1)]) that $f\in I^{2}$.

As $Y$ is smooth at $p$, [Mat89, Theorem 30.3 (1)$\Rightarrow$(2)] shows that
$B$ is $0$-smooth over $k$ in the sense of [Mat89, p. 193], hence that the
natural surjections $A/I^{n}\to B$ admit compatible sections for $n\geq 1$.
This yields a section $s:B\to\widehat{A}_{I}$ of the quotient map
$\widehat{A}_{I}\to\widehat{A}_{I}/I=B$. Let $x_{1},\dots,x_{c}$ be generators
of $I$. By [Eis95, Theorem 7.16], the section $s$ induces a surjective
morphism of $B$-algebras $B[[x_{1},\dots,x_{c}]]\to\widehat{A}_{I}$. As
$\widehat{A}_{I}$ is faithfully flat over $A$ by [Mat89, Theorem 8.14], one
may apply [Mat89, Theorem 15.1 (ii)] to show that
$\dim(\widehat{A}_{I})\geq\dim(A)=n$. Since $B[[x_{1},\dots,x_{c}]]$ is
integral of dimension $n$, the surjection
$B[[x_{1},\dots,x_{c}]]\to\widehat{A}_{I}$ is then necessarily an isomorphism.

We now argue as in the proof of [Sch01, Corollary 2.7]. By a theorem of
Scheiderer [Sch01, Theorem 2.5], there exists an ideal $J$ of $A$ with radical
$I$ such that $f$ is a sum of squares in $A$ if it is a sum of squares in
$A/J$. Since $I^{m}\subset J$ for some $m$, the proposition will be proven if
we check that $f$ is a sum of squares in $A/I^{m}$ for all $m$. We will show
the stronger fact that $f$ is a sum of squares in
$\widehat{A}_{I}=B[[x_{1},\dots,x_{c}]]$. We have seen above that $f\in
I^{2}=\langle x_{1},\dots,x_{c}\rangle^{2}$. Let $\kappa$ be the residue field
of $B$. Since the Hessian of $f$ has rank $\geq c$, the image in
$\kappa[x_{1},\dots,x_{c}]$ of the quadratic term of $f$ is a nondegenerate
quadratic form. Applying Lemma 3.4 below concludes. ∎

######  Lemma 3.4.

Let $B$ be a local ring whose residue field $\kappa$ is not of characteristic
$2$. Let ${f\in B[[x_{1},\dots,x_{n}]]}$ be positive semidefinite. If the
lowest degree term of $f$ is quadratic with nondegenerate image in
$\kappa[x_{1},\dots,x_{n}]$, then $f$ is a sum of squares.

###### Proof.

Let $h\in B[x_{1},\dots,x_{n}]$ be the quadratic term of $f$. By [Bae78,
Chapter I, Proposition 3.4], we may assume after a suitable linear change of
coordinates that $h=\sum_{i=1}^{n}\alpha_{i}x_{i}^{2}$ for some invertible
elements $\alpha_{i}\in B$. Since $f$ is positive semidefinite, the
$\alpha_{i}$ are positive semidefinite, and Theorem 1.3 allows us to write
$\alpha_{i}=\sum_{j}(\alpha_{i}^{(j)})^{2}$ for some $\alpha_{i}^{(j)}\in B$.
After maybe permuting the $\alpha_{i}^{(j)}$, we may ensure that
$\alpha_{i}^{(1)}$ is invertible in $B$. Choosing the $\alpha_{i}^{(1)}x_{i}$
as new variables, we may finally assume that $h-\sum_{i=1}^{n}x_{i}^{2}$ is a
sum of squares in $B[x_{1},\dots,x_{n}]$. By Lemma 2.1 applied with ${g=f-h}$,
there exist $a_{1},\dots,a_{n}$ in $B[[x_{1},\dots,x_{n}]]$ with

$\sum_{i=1}^{n}x_{i}^{2}+f-h=\sum_{i=1}^{n}(x_{i}+a_{i})^{2}.$

Combining these two facts shows that $f$ is a sum of squares in
$B[[x_{1},\dots,x_{n}]]$. ∎

###  3.3. A nonreal bad point

As explained in §3.1, we are in need of an ideal whose square and symbolic
square differ. Lemma 3.5 contains a simple example.

######  Lemma 3.5.

Let $C\subset\mathbb{A}^{3}_{k}$ be the image of the morphism
$\nu:\mathbb{A}^{1}_{k}\to\mathbb{A}^{3}_{k}$ given by
$\nu(t)=(t^{3},t^{4},t^{5})$. Define $I_{C}:=\langle
u^{3}-vw,v^{2}-uw,w^{2}-u^{2}v\rangle\subset k[u,v,w]$ and consider the
polynomial $f_{1}:=u^{5}+uv^{3}+w^{3}-3u^{2}vw$. The following properties
hold:

  1. (i)

The zero locus of $I_{C}$ is the geometrically integral curve
$C\subset\mathbb{A}^{3}_{k}$.

  2. (ii)

One has $f_{1}\in I_{C}$, $f_{1}\notin I_{C,\langle u,v,w\rangle}^{2}$ and
$vf_{1}\in I_{C}^{2}$.

###### Proof.

Since the morphism $\nu$ is finite, its image is a closed subvariety
$C\subset\mathbb{A}^{3}_{k}$, which is geometrically integral because so is
$\mathbb{A}^{1}_{k}$. That its ideal is exactly $I_{C}$ is explained in
[Nor53, Example 3 p. 29]. This proves (i). As $f_{1}(t^{3},t^{4},t^{5})=0$, we
see that $f_{1}\in I_{C}$. To show that $f_{1}\notin I_{C,\langle
u,v,w\rangle}^{2}$, notice that in the development of an element of
$I_{C,\langle u,v,w\rangle}^{2}$ as a power series in $u$, $v$ and $w$, no
term of degree $\leq 3$ may appear (this argument may be found in [Nor53,
Example 3 p. 29]). The last assertion of (ii) follows from the identity

(3.2) $vf_{1}=u(v^{2}-uw)^{2}+(w^{2}-u^{2}v)(wv-u^{3}).\qed$

Now comes our first application of Lemma 3.1.

######  Theorem 3.6.

Consider the ideal $\mathfrak{m}:=\langle
x,y,z^{2}+1\rangle\subset\mathbb{R}[x,y,z]$. The polynomial

$f:=x^{10}+x^{2}y^{6}+(z^{2}+1)^{3}-3x^{4}y^{2}(z^{2}+1)$

is positive semidefinite. It is a sum of squares in
$\mathbb{R}[x,y,z]_{\mathfrak{p}}$ for all prime ideals
$\mathfrak{p}\subset\mathbb{R}[x,y,z]$ distinct from $\mathfrak{m}$, but it is
not a sum of squares in $\mathbb{R}[x,y,z]_{\mathfrak{m}}$.

###### Proof.

That $f$ is positive semidefinite stems from the inequality between the
arithmetic and the geometric means of $x^{10}$, $x^{2}y^{6}$ and
$(z^{2}+1)^{3}$.

Let $\psi:\mathbb{A}^{3}_{\mathbb{R}}\to\mathbb{A}^{3}_{\mathbb{R}}$ be the
morphism defined by $\psi(x,y,z)=(x^{2},y^{2},z^{2}+1)$. Since the pull-back
morphism $\psi^{*}:\mathbb{R}[u,v,w]\to\mathbb{R}[x,y,z]$ endows
$\mathbb{R}[x,y,z]$ with a structure of free $\mathbb{R}[u,v,w]$-module, the
morphism $\psi$ is finite flat. Let $C$, $I_{C}$ and $f_{1}$ be as in Lemma
3.5 applied with $k=\mathbb{R}$. One has $f=\psi^{*}f_{1}$. Let
$\Gamma:=\psi^{-1}(C)\subset\mathbb{A}^{3}_{\mathbb{R}}$ be the curve defined
by the ideal

$I_{\Gamma}:=\langle\psi^{*}I_{C}\rangle=\langle
x^{6}-y^{2}(z^{2}+1),y^{4}-x^{2}(z^{2}+1),(z^{2}+1)^{2}-x^{4}y^{2}\rangle\subset\mathbb{R}[x,y,z].$

Remark first that $f\in I_{\Gamma}$ by Lemma 3.5 (ii). By flatness of $\psi$
and [Mat89, Theorem 7.5 (ii)], that $f_{1}\notin I_{C,\langle
u,v,w\rangle}^{2}$ as proven in Lemma 3.5 (ii) implies that $f\notin
I_{\Gamma,\mathfrak{m}}^{2}$. Since $\psi$ is finite flat and since $C$ is
geometrically integral by Lemma 3.5 (i), the irreducible components of the
curve $\Gamma$ surject to $C$. For $t\in\mathbb{R}_{>1}$, the curve $C$ is
smooth at $(t^{3},t^{4},t^{5})$ and the morphism $\psi$ is étale with only
real points above $(t^{3},t^{4},t^{5})$. We deduce that all the irreducible
components of $\Gamma$ contain a smooth real point. It follows that
$\Gamma(\mathbb{R})$ is Zariski-dense in $\Gamma$ and, in view of Lemma 1.1,
that the residue fields of the generic points of $\Gamma$ are formally real.
Moreover, as the curve $\Gamma$ has no embedded point by flatness of $\psi$
(see [Mat89, Theorem 23.2]), it is reduced. Applying Lemma 3.1 with
$I=I_{\Gamma,\mathfrak{m}}$ now shows that $f$ is not a sum of squares in
$\mathbb{R}[x,y,z]_{\mathfrak{m}}$.

It remains to show that, if $\mathfrak{p}\subset\mathbb{R}[x,y,z]$ is a prime
ideal distinct from $\mathfrak{m}$, then $f$ is a sum of squares in
$\mathbb{R}[x,y,z]_{\mathfrak{p}}$. If $\mathfrak{p}$ is not maximal, this
follows from Theorem 1.4. From now on, we assume that $\mathfrak{p}$ is
maximal, and we let $p\in\mathbb{A}^{3}_{\mathbb{R}}$ be the closed point
associated with $\mathfrak{p}$.

We claim that $\Gamma$ is the Zariski closure of
$\\{(x_{0},y_{0},z_{0})\in\mathbb{R}^{3}\mid f(x_{0},y_{0},z_{0})=0\\}$. We
have already seen that $f$ vanishes on $\Gamma$ and that $\Gamma(\mathbb{R})$
is Zariski-dense in $\Gamma$. Conversely, if
$(x_{0},y_{0},z_{0})\in\mathbb{R}^{3}$ is such that $f(x_{0},y_{0},z_{0})=0$,
we deduce from the case of equality in the inequality between the arithmetic
and the geometric means that
$x_{0}^{10}=x_{0}^{2}y_{0}^{6}=(z_{0}^{2}+1)^{3}$. These equations imply that
$x_{0}\neq 0$ hence that $x_{0}^{8}=y_{0}^{6}$. One then easily verifies that
$(x_{0},y_{0},z_{0})$ satisfies the defining equations of $\Gamma$, which
proves the claim. By [BCR98, Theorem 7.2.3], the Zariski closure of the image
of $\mathrm{Sper}(\mathbb{R}[x,y,z]/\langle
f\rangle)\to\mathrm{Spec}(\mathbb{R}[x,y,z]/\langle f\rangle)$ is also equal
to $\Gamma$. If $p$ does not belong to $\Gamma$, we deduce from Theorem 1.3
that $f$ is a sum of squares in $\mathbb{R}[x,y,z]_{\mathfrak{p}}$.

Assume from now on that $p$ belongs to $\Gamma$. In this case, we show that
$f$ is a sum of squares in $\mathbb{R}[x,y,z]_{\mathfrak{p}}$ by applying
Proposition 3.3 with $X=\mathbb{A}^{3}_{\mathbb{R}}$, $Y=\Gamma$, $n=3$ and
$c=2$. Let us verify its hypotheses. Let $q\in\mathbb{A}^{3}_{\mathbb{R}}$ be
the point associated with $\mathfrak{m}$. Note that $p\neq q$ by hypothesis.
The polynomials $x^{8}-y^{6}$ and $x^{10}-(z^{2}+1)^{3}$ vanish on $\Gamma$
and have independent differentials along $\Gamma\setminus\\{q\\}$. We deduce
that $\Gamma$ is smooth at $p$. Suppose for contradiction that the Hessian of
$f$ at $p$ has rank $\leq 1$. Then

$\begin{pmatrix}\frac{\partial^{2}f}{\partial x\partial
y}&\frac{\partial^{2}f}{\partial y^{2}}\\\ \frac{\partial^{2}f}{\partial
x\partial z}&\frac{\partial^{2}f}{\partial y\partial
z}\end{pmatrix}=144x^{5}y^{2}z(4y^{4}+x^{2}(z^{2}+1))$

vanishes at $p$. As the polynomials $x$, $y$ and $4y^{4}+x^{2}(z^{2}+1)$ do
not vanish on $\Gamma\setminus\\{q\\}$, we see that $z$ vanishes at $p$. It
follows that, at the point $p$, one has

(3.3) $\begin{pmatrix}\frac{\partial^{2}f}{\partial
x^{2}}&\frac{\partial^{2}f}{\partial x\partial y}\\\
\frac{\partial^{2}f}{\partial x\partial y}&\frac{\partial^{2}f}{\partial
y^{2}}\end{pmatrix}=\begin{pmatrix}90x^{8}+2y^{6}-36x^{2}y^{2}&12xy^{5}-24x^{3}y\\\
12xy^{5}-24x^{3}y&30x^{2}y^{4}-6x^{4}\end{pmatrix},$

and this quantity must vanish at $p$ by the hypothesis on the Hessian. Since
$z$ vanishes at $p$, the equations of $\Gamma$ show that $x^{6}=y^{2}$ and
$y^{4}=x^{2}$ at the point $p$. Combining this with (3.3) shows that
$\begin{pmatrix}56x^{2}y^{2}&-12x^{3}y\\\
-12x^{3}y&24x^{4}\end{pmatrix}=1200x^{6}y^{2}$ vanishes at $p$. As neither $x$
nor $y$ vanish on $\Gamma\setminus\\{q\\}$, this is a contradiction. We may
thus apply Proposition 3.3 to complete the proof of the theorem. ∎

###  3.4. Sums of squares in the completion

In §§3.4-3.5, we use Lemma 3.1 to prove Theorem 3.10. To do so, we construct
an example of $(A,I,f)$ as in Lemma 3.1, where $A$ is local regular with
maximal ideal $\mathfrak{m}$ and $f$ is positive semidefinite, such that $f$
is moreover a sum of squares in $\widehat{A}_{\mathfrak{m}}$. If one requires
the residue field of $A$ to be formally real, this is not easy to achieve.
This is the goal of Proposition 3.7 in §3.4 and of Proposition 3.8 in §3.5.
Let us first explain the principle of the argument of Proposition 3.7, where
we ensure that $f$ is a sum of squares in $\widehat{A}_{\mathfrak{m}}$.

Starting from the example of $(A,I,f)$ with $f\in I^{(2)}\setminus I^{2}$
given by Lemma 3.5, we add to $f$ a lot of squares of elements of $I$ so as to
improve the chances that it is a sum of squares in
$\widehat{A}_{\mathfrak{m}}$. This works well only if the multiplicities of
the squares of the generators of $I$ are low compared to the multiplicity of
$f$, and we can only arrange this after a change of variables of relatively
high degree. Making sure that $\mathrm{Sper}(A/I)$ remains Zariski-dense in
$\mathrm{Spec}(A/I)$ only complicates the change of variables that we need to
use. The verification that the resulting element $f$ is indeed a sum of
squares in $\widehat{A}_{\mathfrak{m}}$ is computational since we do not know
of a conceptual way to check it.

######  Proposition 3.7.

There exist ${f_{2}\in k[x,y,z]}$ and an ideal $I_{D}\subset k[x,y,z]$ such
that:

  1. (i)

The ideal $I_{D}$ defines a geometrically integral curve
$D\subset\mathbb{A}^{3}_{k}$.

  2. (ii)

One has $(0,0,0)\in D(k)$. The curve $D\setminus\\{(0,0,0)\\}$ has a smooth
$k$-point.

  3. (iii)

There exists $h\in k[x,y,z]$ with $f_{2}\in I_{D}$, $f_{2}\notin I_{D,\langle
x,y,z\rangle}^{2}$, $h\notin I_{D}$ and $hf_{2}\in I_{D}^{2}$.

  4. (iv)

The polynomial $f_{2}$ is a sum of squares in $k[[x,y,z]]$.

###### Proof.

Let $\phi:\mathbb{A}^{3}_{k}\to\mathbb{A}^{3}_{k}$ be defined by
$\phi(x,y,z)=(x^{2},y^{8}-y^{10}+y^{11},-z^{2}+2z^{3})$. Since the pull-back
morphism $\phi^{*}:k[u,v,w]\to k[x,y,z]$ endows $k[x,y,z]$ with a structure of
free $k[u,v,w]$-module, the morphism $\phi$ is finite flat.

Let $I_{C}$, $C$ and $f_{1}$ be as in Lemma 3.5. Let
$D:=\phi^{-1}(C)\subset\mathbb{A}^{3}_{k}$ be defined by the ideal
$I_{D}:=\langle\phi^{*}I_{C}\rangle\subset k[x,y,z]$. Let $\overline{k}$ be an
algebraic closure of $k$. Since $\phi$ is flat, the curve $D$ has no embedded
point (see [Mat89, Theorem 23.2]). To prove (i), it thus suffices to show that
$D_{\overline{k}}$ is irreducible and generically reduced, i.e., that its
total ring of fractions

$F:=\overline{k}(t)[x,y,z]/\langle
x^{2}-t^{3},y^{11}-y^{10}+y^{8}-t^{4},2z^{3}-z^{2}-t^{5}\rangle$

is a field. One has $F=\overline{k}(s)[y,z]/\langle
y^{11}-y^{10}+y^{8}-s^{8},2z^{3}-z^{2}-s^{10}\rangle$, where $s:=x/t$. Since
$2z^{3}-z^{2}$ is not a nontrivial power in $\overline{k}(z)$, we see that
$2z^{3}-z^{2}-s^{10}$ is irreducible in $\overline{k}(z)[s]$, hence in
$\overline{k}(s)[z]$ by Gauss’s lemma. The same reasoning shows that
$y^{11}-y^{10}+y^{8}-s^{8}$ is irreducible in $\overline{k}(s)[y]$. The two
field extensions $K:=\overline{k}(s)[z]/\langle 2z^{3}-z^{2}-s^{10}\rangle$
and $L:=\overline{k}(s)[y]/\langle y^{11}-y^{10}+y^{8}-s^{8}\rangle$ of
$\overline{k}(s)$ have coprime degree. Their tensor product
$F=K\otimes_{\overline{k}(s)}L$ is thus a field. This proves (i).

One checks that $(0,0,0)$ and $(1,1,1)$ belong to $D(k)$. Since
$\phi(1,1,1)=(1,1,1)$ is a smooth point of $C$, and since $\phi$ is étale at
$(1,1,1)$, we see that $(1,1,1)$ is a smooth $k$-point of $D$. We have checked
(ii).

Let $\hat{y}\in k[[y]]$ be the element such that
$\hat{y}^{8}=y^{8}-y^{10}+y^{11}$ and $\hat{y}-y\in\langle y^{2}\rangle$.
Similarly, let $\hat{z}\in k[[z]]$ be such that $\hat{z}^{2}=z^{2}-2z^{3}$ and
$\hat{z}-z\in\langle z^{2}\rangle$. For esthetic purposes, we also set
$\hat{x}:=x$. With this notation, one can write

(3.4)
$I_{D}=\langle\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2},\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2},\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8}\rangle,$

where the generators indeed belong to $k[x,y,z]$ since they only depend on
$\hat{y}$ and $\hat{z}$ through $\hat{y}^{8}$ and $\hat{z}^{2}$. For the same
reason, the element defined as

$f_{2}:=-y^{6}\phi^{*}f_{1}+2(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2})^{2}+y^{4}(\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2})^{2}+(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8})^{2},$

belongs to $k[x,y,z]$ (we note that
$\phi^{*}f_{1}=\hat{x}^{10}+\hat{x}^{2}\hat{y}^{24}+\hat{z}^{6}-3\hat{x}^{4}\hat{y}^{8}\hat{z}^{2}$).

To see that $f_{2}\in I_{D}$, combine Lemma 3.5 (ii) and (3.4). Assume for
contradiction that $f_{2}\in I^{2}_{D,\langle x,y,z\rangle}$. Then, in view of
(3.4), one has $y^{6}\phi^{*}f_{1}\in I^{2}_{D,\langle x,y,z\rangle}$. This is
absurd, because the monomial $\hat{y}^{6}\hat{z}^{6}$ appears in the
development of $y^{6}\phi^{*}f_{1}$ as a power series in $\hat{x}$, $\hat{y}$
and $\hat{z}$, but not in the development of any element of $I^{2}_{D,\langle
x,y,z\rangle}$ as a power series in $\hat{x}$, $\hat{y}$ and $\hat{z}$ (as
(3.4) shows). Choose ${h:=y^{8}-y^{10}+y^{11}}$. One has $h\notin I_{D}$ since
$h(1,1,1)=1\neq 0$. But $h\phi^{*}f_{1}=\phi^{*}(vf_{1})\in I_{D}^{2}$ by
Lemma 3.5 (ii), so that $hf_{2}\in I_{D}^{2}$ in view of (3.4). We have
verified assertion (iii).

To prove assertion (iv), we use a decomposition
$f_{2}=g+g^{\prime}+g^{\prime\prime}$ in the ring
$k[[x,y,z]]=k[[\hat{x},\hat{y},\hat{z}]]$. We choose

$g:=-\hat{y}^{6}\phi^{*}f_{1}+(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2})^{2}+\hat{y}^{4}(\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2})^{2},$

which is a sum of squares in $k[[\hat{x},\hat{y},\hat{z}]]$ in view of the
identity:

$g=(\hat{x}^{2}-\hat{y}^{6})^{2}(\hat{x}^{8}+\hat{x}^{6}\hat{y}^{6}+\hat{x}^{4}\hat{y}^{12}+\hat{x}^{2}\hat{y}^{18}+\hat{y}^{24}+2\hat{x}^{2}\hat{y}^{8}\hat{z}^{2})+\hat{z}^{2}\hat{y}^{4}(\hat{x}^{4}+\hat{y}^{2}\hat{z}^{2})(\hat{y}^{10}+\hat{z}^{2}).$

We also set

$g^{\prime}:=(y^{4}-\hat{y}^{4})(\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2})^{2},$

which is a sum of squares in $k[[\hat{x},\hat{y},\hat{z}]]$, because
$y^{4}-\hat{y}^{4}-\hat{y}^{6}/4$ is a square in $k[[\hat{y}]]$ as its lowest
degree term is $\hat{y}^{6}/4$. We finally define:

(3.5)
$g^{\prime\prime}:=(\hat{y}^{6}-y^{6})\phi^{*}f_{1}+(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2})^{2}+(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8})^{2}.$

To see that $g^{\prime\prime}$ is a sum of squares in
$k[[\hat{x},\hat{y},\hat{z}]]$, we note that
$\hat{y}^{6}-y^{6}=-\alpha\hat{y}^{8}$ for some $\alpha\in k[[\hat{y}]]$ whose
constant term is equal to $3/4$. Pulling back equation (3.2) by the morphism
$\phi$ and combining it with (3.5) yields the identity

$g^{\prime\prime}=\alpha\big{(}\hat{x}^{2}(\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2})^{2}-(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8})(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2})\big{)}+(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2})^{2}+(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8})^{2},$

which we rewrite as

$g^{\prime\prime}=\alpha\hat{x}^{2}(\hat{y}^{16}+\hat{x}^{2}\hat{z}^{2})^{2}+(\hat{x}^{6}+\hat{y}^{8}\hat{z}^{2}-\alpha/2(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8}))^{2}+(1-\alpha^{2}/4)(\hat{z}^{4}-\hat{x}^{4}\hat{y}^{8})^{2}.$

In the latter expression, all terms are sums of squares in
$k[[\hat{x},\hat{y},\hat{z}]]$. Indeed, the power series $\alpha$ and
$(1-\alpha^{2}/4)$ are sums of squares in $k[[\hat{y}]]$ since their constant
terms $3/4$ and $55/64$ are sums of squares in $\mathbb{Q}$, hence in $k$. ∎

###  3.5. Bad points cannot be tested formally

In Proposition 3.8, we modify the polynomial constructed in Proposition 3.7 so
as to make it positive semidefinite. We argue geometrically, on a well-chosen
affine birational model of $\mathbb{A}^{3}_{k}$.

######  Proposition 3.8.

There exist $f_{3}\in k[x,y,z]$ and an ideal $I_{D}\subset k[x_{,}y,z]$ such
that:

  1. (i)

The ideal $I_{D}$ defines a geometrically integral curve
$D\subset\mathbb{A}^{3}_{k}$.

  2. (ii)

One has $(0,0,0)\in D(k)$. The curve $D\setminus\\{(0,0,0)\\}$ has a smooth
$k$-point.

  3. (iii)

The polynomial $f_{3}$ is positive semidefinite and totally positive on
$\mathbb{A}^{3}_{k}\setminus D$.

  4. (iv)

One has $f_{3}\in I_{D}$ and $f_{3}\notin I_{D,\langle x,y,z\rangle}^{2}$.

  5. (v)

The polynomial $f_{3}$ is a sum of squares in $k[[x,y,z]]$.

  6. (vi)

The polynomial $f_{3}$ is a sum of squares in
$\mathcal{O}_{\mathbb{A}^{3}_{k},p}$ for all
$p\in\mathbb{A}^{3}_{k}\setminus\\{(0,0,0)\\}$.

###### Proof.

We may assume that $k=\mathbb{Q}$ since the general case follows by extending
the scalars (use [Mat89, Theorem 7.5 (ii)] to check that the second part of
(iv) remains valid). Let $f_{2}$, $I_{D}$ and $D$ be as in Proposition 3.7
applied with $k=\mathbb{Q}$. Define ${o:=(0,0,0)\in D(\mathbb{Q})}$.
Assertions (i) and (ii) are exactly Proposition 3.7 (i) and (ii). We fix a
smooth $\mathbb{Q}$-point $q$ of $D\setminus\\{o\\}$.

Let $\overline{D}$ be the closure of $D$ in $\mathbb{P}^{3}_{\mathbb{Q}}$.
Resolving the singularities of $\overline{D}\setminus\\{o\\}$ as in [Liu02,
Chapter 8, Proposition 1.26] shows the existence of a composition of blow-ups
at closed points $\widetilde{\mathbb{P}}^{3}\to\mathbb{P}^{3}_{\mathbb{Q}}$
that is an isomorphism above $\mathbb{A}^{3}_{\mathbb{Q}}$ and such that $o$
is the only singular point of the strict transform
$\widetilde{D}\subset\widetilde{\mathbb{P}}^{3}$ of $\overline{D}$. Choose a
very ample line bundle $\mathcal{L}$ on $\widetilde{\mathbb{P}}^{3}$ and a
basis $(\sigma_{i})$ of $H^{0}(\widetilde{\mathbb{P}}^{3},\mathcal{L})$, and
define $U$ to be the complement in $\widetilde{\mathbb{P}}^{3}$ of the ample
divisor $\\{\sum_{i}\sigma_{i}^{2}=0\\}$. Then
$U\subset\widetilde{\mathbb{P}}^{3}$ is an affine open subset such that
$U(\mathbb{R})=\widetilde{\mathbb{P}}^{3}(\mathbb{R})$. Define
$Z:=\widetilde{D}\cap U\subset U$ and let $I_{Z}\subset\mathcal{O}(U)$ be the
ideal of $Z$.

Notice that $o\in Z(\mathbb{Q})$. View $f_{2}$ as a rational function on $U$
that is well-defined at $o\in U(\mathbb{Q})$. Hence, there exists
$a\in\mathcal{O}(U)$ nonzero at $o$ such that $af_{2}\in\mathcal{O}(U)$. Let
$b_{1},\dots,b_{m}\in\mathcal{O}(U)$ be generators of $I_{Z}$, and define:

(3.6)
$g:=a^{2}f_{2}+\lambda^{2}\cdot\sum_{i=1}^{m}b_{i}^{2}\in\mathcal{O}(U),$

where $\lambda\in\mathbb{Q}$ is to be chosen later.

We claim that, for all $p\in U(\mathbb{R})$, and for all
$\lambda\in\mathbb{Q}$ big enough, there exists a neighbourhood $\Omega_{p}$
of $p$ in $U(\mathbb{R})$ such that $g$ is nonnegative on $\Omega_{p}$ . We
distinguish three cases. If $p\notin Z(\mathbb{R})$, then $g$ is nonnegative
at $p$ for $\lambda\gg 0$ since one of the $b_{i}$ does not vanish at $p$. If
$p=o$, then $f_{2}$ is nonnegative in a neighbourhood of $p\in U(\mathbb{R})$
by Proposition 3.7 (iv) and Lemma 2.6, so that any $\lambda\geq 0$ works. If
$p\in Z(\mathbb{R})$ is distinct from $o$, then it is a smooth point of
$Z_{\mathbb{R}}$. Consequently, after maybe permuting the $b_{i}$, we may
assume that there exists $b^{\prime}\in\mathcal{O}(U)$ such that
$(b_{1},b_{2},b^{\prime})$ forms a regular system of parameters in
$\widehat{\mathcal{O}}_{U_{\mathbb{R}},p}\simeq\mathbb{R}[[b_{1},b_{2},b^{\prime}]]$
and such that the ideal
$J:=I_{Z}\cdot\widehat{\mathcal{O}}_{U_{\mathbb{R}},p}\subset\widehat{\mathcal{O}}_{U_{\mathbb{R}},p}$
is generated by $b_{1}$ and $b_{2}$. The last two assertions of Proposition
3.7 (iii) imply that $f_{2}$, hence also $g$, vanish at the generic point of
the spectrum of the ring $\widehat{\mathcal{O}}_{U_{\mathbb{R}},p}/J^{2}$,
hence vanish in $\widehat{\mathcal{O}}_{U_{\mathbb{R}},p}/J^{2}$ by [ZS60,
Appendix 6, Lemma 5] (or by [Hoc73, (2.1)]). As a consequence, there exist
${\alpha,\beta,\gamma\in\mathbb{R}[[b_{1},b_{2},b^{\prime}]]}$ with $g=\alpha
b_{1}^{2}+\beta b_{1}b_{2}+\gamma b_{2}^{2}$ in
$\mathbb{R}[[b_{1},b_{2},b^{\prime}]]$. If $\lambda\gg 0$, the constant terms
of both $\alpha$ and $\gamma-\beta^{2}/(4\alpha)$ are positive, so that there
exist ${\delta,\varepsilon\in\mathbb{R}[[b_{1},b_{2},b^{\prime}]]}$ such that
$\delta^{2}=\alpha$ and $\varepsilon^{2}=\gamma-\beta^{2}/(4\alpha)$. We may
then write ${g=(\delta b_{1}+\beta b_{2}/(2\delta))^{2}+(\varepsilon
b_{2})^{2}}$ in $\mathbb{R}[[b_{1},b_{2},b^{\prime}]]$. Lemma 2.6 thus shows
that $g$ is nonnegative in a neighbourhood $\Omega_{p}$ of $p$ in
$U(\mathbb{R})$. The claim is proved.

Since $U(\mathbb{R})=\widetilde{\mathbb{P}}^{3}(\mathbb{R})$ is compact, it is
covered by finitely many of the $\Omega_{p}$. Consequently, for $\lambda\gg
0$, the function $g$ is nonnegative on $U(\mathbb{R})$. We fix such a
$\lambda$. In view of [BCR98, Theorem 7.2.3], the element
$g\in\mathcal{O}(U_{\mathbb{R}})$ is positive semidefinite. As $\mathbb{R}$ is
the only real closure of $\mathbb{Q}$, we deduce that $g\in\mathcal{O}(U)$ is
positive semidefinite.

View (3.6) as an identity in $\mathcal{O}_{U,o}=\mathbb{Q}[x,y,z]_{\langle
x,y,z\rangle}$. Choose ${a^{\prime}\in\mathbb{Q}[x,y,z]}$ that does not vanish
at $o$ such that $a^{\prime}a$ and the $a^{\prime}b_{i}$ all belong to
$\mathbb{Q}[x,y,z]$. Let
$b^{\prime}_{1},\dots,b^{\prime}_{m^{\prime}}\in\mathbb{Q}[x,y,z]$ be
generators of $I_{D}$. Define

(3.7)
$f_{3}:=(a^{\prime})^{2}g+\sum_{i=1}^{m^{\prime}}(b_{i}^{\prime})^{2}\in\mathbb{Q}[x,y,z].$

Since $g\in\mathcal{O}(U)$ is positive semidefinite, we see that
$(a^{\prime})^{2}g$ is positive semidefinite as an element of
$\mathbb{Q}(x,y,z)$, hence as an element of $\mathbb{Q}[x,y,z]$ by Lemma 1.1.
Assertion (iii) follows at once from (3.7).

Assertions (iv) and (v) are consequences of Proposition 3.7 (iii) and (iv) and
of the formulas (3.6) and (3.7) since $a$ and $a^{\prime}$ do not vanish at
$o$.

If $p\in\mathbb{A}^{3}_{\mathbb{Q}}$ is not a closed point, then $f_{3}$ is a
sum of squares in $\mathcal{O}_{\mathbb{A}^{3}_{\mathbb{Q}},p}$ by Theorem 1.4
and (iii). Let us check that $f_{3}$ is a sum of squares in
$\mathcal{O}_{\mathbb{A}^{3}_{\mathbb{Q}},q}$. To do so, we apply Proposition
3.3 with $X=\mathbb{A}^{3}_{\mathbb{R}}$, $Y=D$, $n=3$ and $c=2$. Let us
verify its hypotheses. As $q$ is a smooth $\mathbb{Q}$-point of $D$, the
function field of $D$ is formally real by Lemma 1.1. Since $f$ vanishes on $D$
by (iv) and is totally positive on $\mathbb{A}^{3}_{\mathbb{Q}}\setminus D$ by
(iii), we see that $D$ is the Zariski closure of
$\mathrm{Sper}(\mathbb{Q}[x,y,z]/\langle f\rangle)$. As $(a^{\prime})^{2}g$ is
positive semidefinite and vanishes at $q$, its differential at $q$ vanishes
and its Hessian at $q$ is positive semidefinite (see Lemma 1.2). Hence, by
(3.7) and smoothness of $D$ at $q$, the Hessian of $f_{3}$ at $q$ is positive
semidefinite of rank $\geq 2$.

By the above, there are only finitely many closed points $p_{1},\dots,p_{r}$
in $\mathbb{A}^{3}_{\mathbb{Q}}\setminus\\{o\\}$, all distinct from $q$, such
that $f_{3}$ is not a sum of squares in
$\mathcal{O}_{\mathbb{A}^{3}_{\mathbb{Q}},p}$. By Lemma 3.9 below, there
exists a birational morphism
$\pi:\mathbb{A}^{3}_{\mathbb{Q}}\to\mathbb{A}^{3}_{\mathbb{Q}}$ such that $o$
and $q$ are in the open subset over which $\pi$ is an isomorphism, and such
that none of the $p_{i}$ are in the image of $\pi$. After a change of
coordinates, we may assume that $\pi(o)=(o)$. After replacing $f_{3}$, $q$ and
$D$ with $\pi^{*}f_{3}$, $\pi^{-1}(q)$ and the strict transform of $D$ by
$\pi$, properties (i), (ii), (iii), (iv) and (v) are still verified, and (vi)
now holds. ∎

######  Lemma 3.9.

Fix $n\geq 2$. Let $p_{1},\dots,p_{r},q_{1},\dots,q_{s}\in\mathbb{A}^{n}_{k}$
be distinct closed points. Then there exists a birational morphism
$\pi:\mathbb{A}^{n}_{k}\to\mathbb{A}^{n}_{k}$ such that the $p_{i}$ are not in
the image of $\pi$ and the $q_{j}$ are in the open subset above which $\pi$ is
an isomorphism.

###### Proof.

Arguing by induction on $r$, we may assume that $r=1$. After a general linear
change of coordinates, we may assume that the first coordinate of $p_{1}$ is
distinct from the first coordinates of each of the $q_{i}$, and that the
$n$-th coordinate of $p_{1}$ is nonzero. Let $P$ be the minimal polynomial of
the first coordinate of $p_{1}$. Then one may define $\pi$ by setting
$\pi(x_{1},\dots,x_{n})=(x_{1},\dots,x_{n-1},P(x_{1})x_{n})$. ∎

We may now give our second application of Lemma 3.1.

######  Theorem 3.10.

There exists a positive semidefinite polynomial $f\in\mathbb{R}[x,y,z]$ that
is a sum of squares in $\mathbb{R}[[x,y,z]]$ and in
$\mathbb{R}[x,y,z]_{\mathfrak{p}}$ for all prime ideals
$\mathfrak{p}\subset\mathbb{R}[x,y,z]$ distinct from $\langle x,y,z\rangle$,
but that is not a sum of squares in $\mathbb{R}[x,y,z]_{\langle
x,y,z\rangle}$.

###### Proof.

Let $f_{3}$, $I_{D}$ and $D$ be as in Proposition 3.8 applied with
$k=\mathbb{R}$. Set $f:=f_{3}$. In view of Proposition 3.8 (iii), (v) and
(vi), we only need to show that $f$ is not a sum of squares in
$\mathbb{R}[x,y,z]_{\langle x,y,z\rangle}$.

Proposition 3.8 (i) and (ii) and Lemma 1.1 imply that the function field of
$D$ is formally real. In view of Proposition 3.8 (i) and (iv), one may apply
Lemma 3.1 with $I=I_{D}$ to show that $f$ is not a sum of squares in
$\mathbb{R}[x,y,z]_{\langle x,y,z\rangle}$. ∎

###  3.6. Bad points on varieties

We extend the example of Proposition 3.8 first to higher dimensions in
Proposition 3.11, then to arbitrary varieties in Theorem 3.12.

######  Proposition 3.11.

For all $n\geq c\geq 3$, there exist $f_{4}\in k[x_{1},\dots,x_{n}]$ and an
ideal ${I_{Z}\subset k[x_{1},\dots,x_{n}]}$ such that, setting
$W:=\\{(0,\dots,0)\\}\times\mathbb{A}^{n-c}_{k}\subset\mathbb{A}^{n}_{k}$, one
has:

  1. (i)

The variety $Z\subset\mathbb{A}^{n}_{k}$ defined by $I_{Z}$ is geometrically
integral of dimension $n-c+1$ and contains $W$. The variety $Z\setminus W$ has
a smooth $k$-point.

  2. (ii)

Let $\eta$ be the generic point of $W$. One has $f_{4}\in I_{Z}$ and
$f_{4}\notin I_{Z,\eta}^{2}$.

  3. (iii)

The polynomial $f_{4}$ is positive semidefinite and totally positive on
$\mathbb{A}^{n}_{k}\setminus Z$.

  4. (iv)

The polynomial $f_{4}$ is a sum of squares in
$\widehat{\mathcal{O}}_{\mathbb{A}^{n}_{k},\eta}$.

  5. (v)

The polynomial $f_{4}$ is a sum of squares in
$\mathcal{O}_{\mathbb{A}^{n}_{k},p}$ for all $p\in\mathbb{A}^{n}_{k}\setminus
W$.

###### Proof.

Let $f_{3}$, $I_{D}$ and $D$ be as in Proposition 3.8. We consider the
subvariety $Z:=\\{(0,\dots,0)\\}\times D\times\mathbb{A}^{n-c}_{k}$ of
$\mathbb{A}^{c-3}_{k}\times\mathbb{A}^{3}_{k}\times\mathbb{A}^{n-c}_{k}=\mathbb{A}^{n}_{k}$,
and we let $I_{Z}$ be the ideal of $Z$. View $f_{3}$ as a function on
$\mathbb{A}^{c-3}_{k}\times\mathbb{A}^{3}_{k}\times\mathbb{A}^{n-c}_{k}=\mathbb{A}^{n}_{k}$
by pull-back from the second factor, and define
$f_{4}:=f_{3}+\sum_{j=1}^{c-3}x_{j}^{2}$. Assertions (i), (ii), (iii) and (iv)
are consequences of Proposition 3.8. Assertion (v) follows from Proposition
3.8 (vi) if
$p\notin\mathbb{A}^{c-3}_{k}\times\\{(0,\dots,0)\\}\times\mathbb{A}^{n-c}_{k}$
and from (iii) and Theorem 1.3 if $p\notin Z$. ∎

Now comes the main theorem of this section.

######  Theorem 3.12.

Let $X$ be an affine variety over $k$ and let $x\in X$ be a regular point.
Define $A:=\mathcal{O}_{X,x}$, with maximal ideal $\mathfrak{m}$. Assume that
$\dim(A)\geq 3$ and that $\mathrm{Frac}(A)$ is formally real. Then there
exists $f\in\mathcal{O}(X)$ such that:

  1. (i)

The regular function $f$ is a sum of squares in $\widehat{A}_{\mathfrak{m}}$.

  2. (ii)

For all prime ideals $\mathfrak{p}\neq\mathfrak{m}$ of $A$, the function $f$
is a sum of squares in $A_{\mathfrak{p}}$.

  3. (iii)

But $f$ is not a sum of squares in $A$.

###### Proof.

At any point of the proof, we may replace $X$ by an affine open neighbourhood
$V\subset X$ of $x$. To see it, suppose that $f\in\mathcal{O}(V)$ satisfies
(i), (ii) and (iii). Choose $f^{\prime}\in\mathcal{O}(X)$ that does not vanish
at $x$ with the property that $f^{\prime}f\in\mathcal{O}(V)$ lifts to an
element $f^{\prime\prime}\in\mathcal{O}(X)$. Then
$f^{\prime}f^{\prime\prime}\in\mathcal{O}(X)$ also satisfies (i), (ii) and
(iii) since $(f^{\prime}f^{\prime\prime})|_{V}=(f^{\prime}|_{V})^{2}f$. As a
consequence, we may assume $X$ to be smooth and irreducible. Replacing $k$
with its algebraic closure in $k(X)$, we may assume that $X$ is geometrically
irreducible. We set $n:=\dim(X)$ and $c:=\dim(A)$.

Let $f_{4}$, $Z$ and $W$ be as in Proposition 3.11 and let $q\in(Z\setminus
W)(k)$ be a smooth $k$-point (see Proposition 3.11 (i)). Let $\overline{X}$ be
a smooth projective compactification of $X$, let $Y\subset\overline{X}$ be the
closed integral subvariety whose generic point is $x$, and let $\overline{Z}$
and $\overline{W}$ be the closures of $Z$ and $W$ in $\mathbb{P}^{n}_{k}$.
Choose homogeneous coordinates $[y_{1}:\dots:y_{n+1}]$ of $\mathbb{P}^{n}_{k}$
with $\overline{W}=\\{y_{1}=\dots=y_{c}=0\\}$ and
$q=\\{y_{2}=\dots=y_{n+1}=0\\}$.

By the Artin-Lang homomorphism theorem [BCR98, Theorem 4.1.2] applied over the
real closure of $k$ associated with the restriction of an ordering of
$\mathrm{Frac}(A)$, one may choose a closed point $p\in X\setminus(Y\cap X)$
whose residue field is formally real.

Let $\mathcal{L}$ be a very ample line bundle on $\overline{X}$. Choose $e\gg
0$, and let $\sigma_{1},\dots,\sigma_{n+1}$ be sections in
$H^{0}(\overline{X},\mathcal{L}^{\otimes e})$ such that
$\sigma_{1},\dots,\sigma_{c}$ vanish on $Y$, such that
$\sigma_{2},\dots,\sigma_{n+1}$ vanish on $p$, and that are general among the
sections satisfying these properties.

######  Lemma 3.13.

The following holds:

  1. (a)

The formula $t\mapsto[\sigma_{1}(t):\dots:\sigma_{n+1}(t)]$ defines a morphism
${\sigma:\overline{X}\to\mathbb{P}^{n}_{k}}$.

  2. (b)

The morphism $\sigma$ is finite flat, and étale at $p\in\overline{X}$.

  3. (c)

One has $\sigma(Y)=\overline{W}$ and $\sigma(p)=q$. The point $p$ is a smooth
point of $\sigma^{-1}(\overline{Z})$.

  4. (d)

The subvariety $\sigma^{-1}(\overline{Z})\subset\overline{X}$ is geometrically
integral.

###### Proof.

Let $\mathcal{I}_{Y}$, $\mathcal{I}_{\\{p\\}}$ and
$\mathcal{I}_{Y\cup\\{p\\}}$ be the ideal sheaves of $Y$, of $\\{p\\}$ and of
$Y\cup\\{p\\}$ in $\overline{X}$. Since $e\gg 0$, the sheaves
$\mathcal{I}_{Y}\otimes\mathcal{L}^{\otimes e}$,
$\mathcal{I}_{\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ and
$\mathcal{I}_{Y\cup\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ are all globally
generated. It follows that $\\{\sigma_{1}=0\\}$ does not contain $p$. It then
also follows, by induction on $1\leq i\leq n+1$, that $\sigma_{i}$ does not
vanish identically on any irreducible component of
$\\{\sigma_{1}=\dots=\sigma_{i-1}=0\\}$, and hence that
$\\{\sigma_{1}=\dots=\sigma_{i}=0\\}$ has dimension $n-i$. When $i=n+1$, this
means that the $\sigma_{i}$ have no common zero. This proves (a).

Each fiber of $\sigma$ has the property that one of the $\sigma_{i}$ does not
vanish at all on it. Since $\mathcal{L}$ is ample and $\overline{X}$ is
proper, this shows that no fiber of $\sigma$ may be positive-dimensional. The
morphism $\sigma$ is thus quasi-finite, hence finite since it is proper. That
$\sigma$ is flat now follows from [Mat89, Theorem 23.1]. As the sheaves
$\mathcal{I}_{\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ and
$\mathcal{I}_{Y\cup\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ are globally
generated and the $\sigma_{i}$ are general, the differentials of
$\sigma_{2},\dots,\sigma_{n+1}$ at $p$ are linearly independent. The fiber
$\\{\sigma_{2}=\dots=\sigma_{n+1}=0\\}$ of $\sigma$ through $p$ is thus smooth
of dimension $0$ at $p$. This completes the verification that $\sigma$ is
étale at $p$ and the proof of assertion (b).

One has $\sigma(Y)\subset\overline{W}$ by our choice of
$\sigma_{1},\dots,\sigma_{c}$. Since $\sigma$ is finite by (b), a dimension
count shows that $\sigma(Y)=\overline{W}$. Our choice of
$\sigma_{2},\dots,\sigma_{n+1}$ implies that $\sigma(p)=q$. Since $q$ is a
smooth point of $\overline{Z}$, we deduce from (b) that $p$ is a smooth point
of $\sigma^{-1}(\overline{Z})$. We have verified (c) and we now turn to (d).

The subvariety $\sigma^{-1}(\overline{Z})$ of $\overline{X}$ has no embedded
point by [Mat89, Theorem 23.2] which applies by flatness of $\sigma$, and has
$p$ as a smooth closed point by (c). To prove (d), it thus suffices to verify
that $\sigma^{-1}(\overline{Z})$ is geometrically irreducible. Define
${\Omega:=\\{\sigma_{1}\neq 0\\}\subset\overline{X}}$. By finiteness of
$\sigma$, none of the irreducible components of $\sigma^{-1}(\overline{Z})$
lie over the hyperplane ${\\{y_{1}=0\\}}$, so we only need to show that
$\sigma^{-1}(\overline{Z})\cap\Omega$ is geometrically irreducible.

Consider the open subset $\Theta:=\\{y_{1}\neq 0\\}\subset\overline{Z}$. For
$2\leq i\leq n+1$, define $z_{i}:=y_{i}/y_{1}\in\mathcal{O}(\Theta)$ and
$g_{i}:=\sigma_{i}/\sigma_{1}\in\mathcal{O}(\Omega)$. The variety
$\sigma^{-1}(\overline{Z})\cap\Omega$ may be naturally identified with the
zero locus in $\Omega\times\Theta$ of the $n$ equations $(z_{i}-g_{i})_{2\leq
i\leq n+1}$. Define
$\Sigma_{i}:=\\{z_{2}-g_{2}=\dots=z_{i}-g_{i}=0\\}\subset\Omega\times\Theta$,
so that $\sigma^{-1}(\overline{Z})\cap\Omega=\Sigma_{n+1}$. As
$\mathcal{I}_{\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ and
$\mathcal{I}_{Y\cup\\{p\\}}\otimes\mathcal{L}^{\otimes e}$ are globally
generated and the $\sigma_{i}$ are general, the differentials of the $g_{i}$
at $p$ are general. It follows that $\Sigma_{i}$ is smooth of dimension
$2n-c-i+2$ at $p$ and that the differential at $p$ of the first projection
$\pi_{i}:\Sigma_{i}\to\Omega$ has maximal rank.

We will prove by induction on $1\leq i\leq n+1$ that $\Sigma_{i}$ is
geometrically irreducible. Assertion (d) will follow by taking $i=n+1$. In
view of Proposition 3.11 (i), both $X$ and $\overline{Z}$ are geometrically
irreducible, hence so is $\Sigma_{1}=\Omega\times\Theta$. This shows that the
base case of the induction is valid.

As for the induction step, assume that $\Sigma_{i-1}$ is geometrically
irreducible. Let $(\tau^{(i)}_{j})_{1\leq j\leq m_{i}}$ be a basis of
$H^{0}(\overline{X},\mathcal{I}_{Y\cup\\{p\\}}\otimes\mathcal{L}^{\otimes e})$
if $2\leq i\leq c$ (resp.a basis of
$H^{0}(\overline{X},\mathcal{I}_{\\{p\\}}\otimes\mathcal{L}^{\otimes e})$ if
$c+1\leq i\leq n+1$). Set
$h^{(i)}_{j}:=\tau^{(i)}_{j}/\sigma_{1}\in\mathcal{O}(\Omega)$. Consider the
morphism $\rho_{i}:\Sigma_{i-1}\to\mathbb{A}^{m_{i}+1}_{k}$ given by
$t\mapsto(h^{(i)}_{1}(t),\dots,h^{(i)}_{m_{i}}(t),z_{i}(t))$. Since
$\sigma_{i}$ was chosen general, the subvariety
$\Sigma_{i}\subset\Sigma_{i-1}$ identifies with the inverse image by
$\rho_{i}$ of a general affine hyperplane of $\mathbb{A}^{m_{i}+1}_{k}$. The
facts verified above that $\Sigma_{i-1}$ is smooth of dimension $2n-c-i+3$ at
$p$ and that the differential of $\pi_{i-1}$ at $p$ has maximal rank imply
that the image of $\pi_{i-1}$ has dimension $\min(n,2n-c-i+3)$. In particular,
this image cannot be included in $Y\cup\\{p\\}$. Since $e\gg 0$, the linear
system generated by the $\tau^{(i)}_{j}$ induces an embedding of
$\overline{X}\setminus(Y\cup\\{p\\})$. It follows that the transcendence
degree of the subfield of $k(\Sigma_{i-1})$ generated by the $h_{j}^{(i)}$ is
equal to the dimension $\min(n,2n-c-i+3)$ of the image of $\pi_{i-1}$, hence
is $\geq 2$. We deduce that the image of $\rho_{i}$ has dimension $\geq 2$.
Bertini’s irreducibility theorem as stated in [Jou83, Théorème 6.3 4)] shows
that $\Sigma_{i}$ is geometrically irreducible. This concludes the induction
and the proof of the lemma. ∎

We resume the proof of Theorem 3.12. Let $U\subset\mathbb{P}^{n}_{k}$ be an
open affine subset containing $q$ and the generic point of $\overline{W}$, and
such that $f_{4}$ is regular on $U$. Set $V:=\sigma^{-1}(U)\cap
X\subset\overline{X}$. It is an open affine subset (note that $\sigma$ is
affine by Lemma 3.13 (b)) containing $q$ and the generic point $x$ of $Y$ by
Lemma 3.13 (c).

We now define $f:=\sigma^{*}(f_{4}|_{U})\in\mathcal{O}(V)$ and check one by
one the claims of Theorem 3.12. Assertions (i) and (ii) follow from
Proposition 3.11 (iv) and (v). To prove assertion (iii), we consider the ideal
$I\subset A$ of functions vanishing on the subscheme
$\sigma^{-1}(\overline{Z})\times_{\overline{X}}\mathrm{Spec}(A)$ of
$\mathrm{Spec}(A)$, and we apply Lemma 3.1. Let us check its hypotheses. That
$I$ is radical stems from Lemma 3.13 (d). Since $p$ is a smooth point of
$\sigma^{-1}(\overline{Z})$ with formally real residue field by Lemma 3.13
(c), and since $\sigma^{-1}(\overline{Z})$ is integral by Lemma 3.13 (d), we
deduce from Lemma 1.1 that the function field of $\sigma^{-1}(\overline{Z})$
is formally real, hence that $\mathrm{Sper}(A/I)$ is Zariski-dense in
$\mathrm{Spec}(A/I)$. That $f\in I$ follows from the first statement of
Proposition 3.11 (ii). Finally, since $\sigma$ is flat by Lemma 3.13 (b), that
$f\notin I^{2}$ may be deduced from the second statement of Proposition 3.11
(ii) by applying [Mat89, Theorem 7.5 (ii)]. Lemma 3.1 now applies and shows
that $f$ is not a sum of squares in $A$. ∎

###  3.7. An additional example

It is not straightforward to extract a concrete polynomial from the proof of
Theorem 3.10. Giving an example in $\geq 4$ variables is much easier, as the
next theorem shows.

We use a variation on Motzkin’s famous polynomial [Mot67, p. 217]: we have
only modified its coefficients to be elements of $\mathbb{R}[w]$ instead of
real numbers.

######  Theorem 3.14.

The polynomial $f=x^{6}+w^{2}y^{2}z^{4}+w^{2}y^{4}z^{2}+(1-w)x^{2}y^{2}z^{2}$
is positive semidefinite and a sum of squares in $\mathbb{R}[[w,x,y,z]]$, but
it is not a sum of squares in $\mathbb{R}(w)[[x,y,z]]$, hence not in
$\mathbb{R}[w,x,y,z]_{\langle w,x,y,z\rangle}$ either.

###### Proof.

The inequality between the arithmetic and geometric means of $x_{0}^{6}$,
$w_{0}^{2}y_{0}^{2}z_{0}^{4}$ and $w_{0}^{2}y_{0}^{4}z_{0}^{2}$ implies that
$f(w_{0},x_{0},y_{0},z_{0})\geq(3w_{0}^{4/3}-w_{0}+1)x_{0}^{2}y_{0}^{2}z_{0}^{2}\geq
0$ for all $(w_{0},x_{0},y_{0},z_{0})\in\mathbb{R}^{4}$. This shows that $f$
is positive semidefinite. The polynomial $f$ is a sum of squares in
$\mathbb{R}[[w,x,y,z]]$ because $1-w$ is a square in this ring.

Assume for contradiction that $f$ is a sum of squares in
$\mathbb{R}(w)[[x,y,z]]$. Then, for all but countably many
$w_{0}\in\mathbb{R}$ the polynomial $f(w_{0},x,y,z)\in\mathbb{R}[x,y,z]$ is a
sum of squares in $\mathbb{R}[[x,y,z]]$. Fix such a $w_{0}$ with $w_{0}>1$ and
define the polynomial $g(y,z):=f(w_{0},1,y,z)\in\mathbb{R}[y,z]$. One can then
write $g(y,z)=\sum_{i}h_{i}^{2}$ for some $h_{i}\in\mathbb{R}[y,z]$. Setting
$y=0$ shows that no monomial of the form $z^{a}$ can appear in the $h_{i}$. By
symmetry, no monomial of the form $y^{a}$ can appear in the $h_{i}$. The
identity $g(y,z)=\sum_{i}h_{i}^{2}$ now shows that the coefficient of
$y^{2}z^{2}$ in $g$ is nonnegative, which contradicts our choice of $w_{0}>1$.

That $f$ is not a sum of squares in $\mathbb{R}[w,x,y,z]_{\langle
w,x,y,z\rangle}$ follows, since $\mathbb{R}(w)[[x,y,z]]$ is the completion of
the localization of $\mathbb{R}[w,x,y,z]_{\langle w,x,y,z\rangle}$ at the
ideal $\langle x,y,z\rangle$. ∎

##  4\. Regular local rings without bad points

In this last section, we construct interesting examples of regular local rings
in which all positive semidefinite elements are sums of squares.

The regular local rings $A$ that we consider have the peculiar feature that
their function field may be ordered in a unique way. The idea of the
construction is to start with a regular local ring $B$ and with an ordering
$\xi$ of $\mathrm{Frac}(B)$, and to choose $A$ to be a maximal sub-$B$-algebra
of the Henselization $B^{\mathrm{h}}$ of $B$ to which $\xi$ lifts.

######  Theorem 4.1.

For all $n\geq 0$, there exists a regular local $\mathbb{R}$-algebra $A$ of
dimension $n$ such that $\mathrm{Sper}(A)$ consists of exactly one point,
which is a field ordering of $\mathrm{Frac}(A)$.

###### Proof.

If $n=0$, take $A:=\mathbb{R}$. We now assume that $n\geq 1$.

Let $y\in\mathbb{P}^{n}_{\mathbb{R}}$ be a closed point with complex residue
field, define $B:=\mathcal{O}_{\mathbb{P}^{n}_{\mathbb{R}},y}$, let
$\mathfrak{m}$ be the maximal ideal of $B$ and set
$L:=\mathbb{R}(x_{1},\dots,x_{n})=\mathrm{Frac}(B)$. We recall the definition
of the Henselization $B^{\mathrm{h}}$ of $B$ (see [Gro67, Définition 18.6.5]).
Let $(B_{i})_{i\in I}$ be a set of representatives of all isomorphism classes
of local essentially étale $B$-algebras $u_{i}:B\to B_{i}$ such that $u_{i}$
induces an isomorphism of residue fields. Say that $i\leq i^{\prime}$ if there
exists a (necessarily unique) morphism of $B$-algebras $B_{i}\to
B_{i^{\prime}}$. The set $I$ is partially ordered and filtered. One defines
$B^{\mathrm{h}}:=\varinjlim_{i\in I}B_{i}$.

Let $\alpha_{1},\dots,\alpha_{n}$ be $n$ elements of $\mathbb{R}[[t]]$ that
are algebraically independent over $\mathbb{R}$ (see [MLS39, Lemma 1]). They
give rise to a morphism
$\alpha:\mathrm{Spec}(\mathbb{R}[[t]])\to\mathbb{A}^{n}_{\mathbb{R}}$. Since
the $\alpha_{i}$ are algebraically independent, the morphism $\alpha$ induces
an inclusion $\alpha^{*}:L\hookrightarrow\mathbb{R}((t))$. The field ordering
of $\mathbb{R}((t))$ for which $t$ is a positive infinitesimal restricts, by
the inclusion $\alpha^{*}$, to an ordering $\xi$ of $L$.

Define $L_{i}:=\mathrm{Frac}(B_{i})$. Consider all the subsets $J\subset I$
such that:

  1. (i)

For all $i\in J$, the ordering $\xi$ may be extended to an ordering of
$L_{i}$.

  2. (ii)

For all $i,i^{\prime}\in J$, there exists $i^{\prime\prime}\in J$ with
$i^{\prime\prime}\geq i$ and $i^{\prime\prime}\geq i^{\prime}$.

Since an increasing union of such subsets again has these two properties, we
may use Zorn’s lemma to choose one that is maximal with respect to the
inclusion. Call it $J$. It is partially ordered and filtered, and we consider
the $B$-algebra $A:=\varinjlim_{i\in J}B_{i}$. The arguments used in [Gro67,
Théorème 18.6.6, Corollaire 18.6.10] to show that $B^{\mathrm{h}}$ is a flat
local regular $B$-algebra with maximal ideal $\mathfrak{m}B^{\mathrm{h}}$ and
residue field $\mathbb{C}$ show, mutatis mutandis, that $A$ is a flat local
regular $B$-algebra with maximal ideal $\mathfrak{m}A$ and residue field
$\mathbb{C}$. Its dimension is $n$ by [Gro65, Proposition 6.1.1].

Define $K:=\mathrm{Frac}(A)$. Consider the set
$Z_{i}\subset\mathrm{Sper}(L_{i})$ of orderings whose image in
$\mathrm{Sper}(L)$ is $\xi$. Since $\mathrm{Sper}(L)$ is Hausdorff [Lam05,
VIII, Theorem 6.3], its point $\xi$ is closed. It follows from [Lam05,
Corollary p. 272] that $Z_{i}\subset\mathrm{Sper}(L_{i})$ is closed, hence
compact by [Lam05, VIII, Theorem 6.3]. Since the $Z_{i}$ are nonempty for
$i\in J$ by property (i) above, the subset $Z:=\varprojlim_{i\in J}Z_{i}$ of
$\mathrm{Sper}(K)=\varprojlim_{i\in J}\mathrm{Sper}(L_{i})$ is nonempty by
Tychonoff’s theorem. This shows that the field $K$ is formally real. We choose
a point $\zeta\in Z$.

Assume for contradiction that $\mathrm{Sper}(A)$ contains a point $\chi$
distinct from $\zeta$. It corresponds to an ordering of
$\kappa:=\mathrm{Frac}(A/\mathfrak{p})$ for some prime ideal
$\mathfrak{p}\subset A$. Set $c:=\dim(A_{\mathfrak{p}})$ and let
$(t_{1},\dots,t_{c})$ be a regular system of parameters in $A_{\mathfrak{p}}$.
By Cohen’s structure theorem [Mat89, Theorem 29.7], there exists an
isomorphism $\widehat{A}_{\mathfrak{p}}\simeq\kappa[[t_{1},\dots,t_{c}]]$,
which induces inclusions
$K\subset\kappa((t_{1},\dots,t_{c}))\subset\kappa((t_{1}))\dots((t_{c}))$. Any
ordering of a field $k$ extends in two ways to an ordering of $k((t))$, one
for which $t$ is a positive infinitesimal and one for which $t$ is a negative
infinitesimal. If $c\geq 1$, it follows that $K$ admits at least two
orderings, one for which $t_{1}$ is positive and one for which $t_{1}$ is
negative. Replacing $\chi$ by one of these, we may assume that $c=0$, i.e.,
that $\zeta$ and $\chi$ are two distinct orderings of $K$.

Let $f\in K$ be such that $f\succ_{\zeta}0$ but $f\prec_{\chi}0$. There exists
$j\in J$ such that $f\in L_{j}$, and we fix such an element $j$. Since $B_{j}$
is a local essentially étale $B$-algebra, there exist a projective variety $X$
over $\mathbb{R}$, a closed point $x\in X$, a morphism
$\pi:X\to\mathbb{P}^{n}_{\mathbb{R}}$ étale at $x$ such that $\pi(x)=y$, and
an isomorphism of $B$-algebras $B_{j}\simeq\mathcal{O}_{X,x}$. In particular,
$L_{j}\simeq\mathbb{R}(X)$. By resolution of singularities, we may assume that
$X$ is smooth over $\mathbb{R}$. After multiplying $f$ by a square, we may
assume that $f\in B_{j}$. Let $D\subset X$ be the effective Cartier divisor
obtained by taking the Zariski closure in $X$ of the subscheme
$\\{f=0\\}\subset\mathrm{Spec}(B_{j})$.

Let ${V_{\prec}:=\\{g\in L_{j}\mid-r\prec g\prec r\textrm{ for some
}r\in\mathbb{R}\\}}$ be the valuation ring associated with an ordering $\prec$
of $L_{j}$ (see [BCR98, Proposition 10.1.13]). Its maximal ideal is
$\mathfrak{m}_{\prec}:=\\{g\in L_{j}\mid-r\prec g\prec r\textrm{ for all
}r\in\mathbb{R}_{>0}\\}$ and its residue field is isomorphic to $\mathbb{R}$.
We let $v_{\prec}$ be the corresponding valuation of $L_{j}$ and $c_{\prec}\in
X(\mathbb{R})$ be its center. Since $\zeta$ restricts to $\xi$ on $L$, the
restriction of $v_{\zeta}$ to $L$ is induced by the $t$-adic valuation on
$\mathbb{R}((t))$ and the inclusion
${\alpha^{*}:L\hookrightarrow\mathbb{R}((t))}$. As $L_{j}$ is a finite
extension of $L$, we deduce that $v_{\zeta}$ is a discrete valuation. If
$c_{\zeta}\in D$, replace $X$ with its blow-up at $c_{\zeta}$, and $D$ with
its strict transform in the blow-up. This has the effect of decreasing the
image by the valuation $v_{\zeta}$ of a local equation of $D$ at $c_{\zeta}$.
As $v_{\zeta}$ is discrete, repeating this procedure finitely many times
ensures that $c_{\zeta}\notin D$.

Let $S$ be the spectrum of the semilocal ring of $X$ at the points $x$,
$c_{\zeta}$ and $c_{\chi}$. We note that $x$ is distinct from either
$c_{\zeta}$ or $c_{\chi}$ since its residue field is $\mathbb{C}$ (but
$c_{\zeta}$ and $c_{\chi}$ might coincide). As $\mathcal{O}_{X}(-D)$ is
invertible and as any locally free module of constant rank over the spectrum
of a semilocal ring is free, the ideal sheaf $\mathcal{O}_{X}(-D)|_{S}$ is
principal, generated by some $g\in H^{0}(S,\mathcal{O}_{X}(-D)|_{S})$. Since
$c_{\zeta}\notin D$, one has $g(c_{\zeta})\neq 0$ and we may assume, after
maybe replacing $g$ with $-g$, that $g(c_{\zeta})>0$. In particular,
$g\succ_{\zeta}0$. If $c_{\zeta}=c_{\chi}$ or if $g\succ_{\chi}0$, define
$h=1$. If $c_{\zeta}\neq c_{\chi}$ and $g\prec_{\chi}0$, let
$h\in\mathcal{O}(S)^{*}$ be such that $h(x)=h(c_{\zeta})=1$ and
$h(c_{\chi})=-1$, so that $h\succ_{\zeta}0$ and $h\prec_{\chi}0$. Then the
element $e:=fh/g\in L_{j}$ has the property that $e\succ_{\zeta}0$ and
$e\prec_{\chi}0$. Moreover, $e\in(B_{j})^{*}$ because both $f$ and $g$
generate the invertible sheaf $\mathcal{O}_{X}(-D)$ at the point $x$.

Consider the ring $A^{\prime}$ obtained by localizing $A[z]/\langle
z^{2}-e\rangle$ at one of its maximal ideals. Let $J^{\prime}\subset I$ be the
set of $i\in I$ such that there exists a morphism of $B$-algebras $B_{i}\to
A^{\prime}$. We claim that $J^{\prime}$ contradicts the maximality of $J$,
which will conclude the proof of the theorem. It is clear that $J\subset
J^{\prime}$ since for all $i\in J$, there exist morphisms of $B$-algebras
$B_{i}\to A\to A^{\prime}$. We now check that $J^{\prime}$ satisfies the two
properties (i) and (ii) that were required of $J$.

Since $e\prec_{\chi}0$, the element $e\in K$ is not a square, and it follows
that $A^{\prime}$ is integral with fraction field $K^{\prime}:=K[z]/\langle
z^{2}-e\rangle$. Since $e\succ_{\zeta}0$, the element $e$ has a square root in
the real closure of $K$ associated with $\zeta$. This shows that $\zeta$ may
be extended to an ordering $\zeta^{\prime}$ of $K^{\prime}$. If $i\in
J^{\prime}$, the restriction of $\zeta^{\prime}$ to $L_{i}$ is an ordering of
$L_{i}$ that extends $\xi$. The shows (i).

Choose $i,i^{\prime}\in J^{\prime}$. The two morphism $B_{i}\to A^{\prime}$
and $B_{i^{\prime}}\to A^{\prime}$ induce a morphism
$B_{i}\otimes_{B}B_{i^{\prime}}\to A^{\prime}$. The localization of
$B_{i}\otimes_{B}B_{i^{\prime}}$ at its maximal ideal induced by the maximal
ideal of $A^{\prime}$ is a local essentially étale $B$-algebra with residue
field $\mathbb{C}$ that admits a morphism to $A^{\prime}$. It is thus of the
form $B_{i^{\prime\prime}}$ for some $i^{\prime\prime}\in J^{\prime}$, and the
element $i^{\prime\prime}\in J^{\prime}$ satisfies $i^{\prime\prime}\geq i$
and $i^{\prime\prime}\geq i^{\prime}$. We have verified the property (ii).

It remains to show that $J^{\prime}\neq J$. Consider the ring $B_{j}^{\prime}$
obtained by localizing $B_{j}[z]/\langle z^{2}-e\rangle$ at its maximal ideal
induced by the maximal ideal of $A^{\prime}$. The ring $B^{\prime}_{j}$ is a
local $B$-algebra with residue field $\mathbb{C}$ that is essentially étale
because $e\in(B_{j})^{*}$. It is therefore of the form $B_{j^{\prime}}$ for
some $j^{\prime}\in I$. Since there exists a morphism $B^{\prime}_{j}\to
A^{\prime}$ by construction, we see that $j^{\prime}\in J^{\prime}$. However
$j^{\prime}$ cannot belong to $J$. Indeed, if it were the case, there would
exist a morphism of $B$-algebras $B^{\prime}_{j}\to A$. This is impossible
since $e$ is a square in $B^{\prime}_{j}$ but $e\prec_{\chi}0$. ∎

That the positive semidefinite elements in the regular local rings constructed
in Theorem 4.1 are sums of squares is a straightforward application of
Scheiderer’s results on sums of squares in local rings.

######  Theorem 4.2.

For all $n\geq 0$, there exists a regular local $\mathbb{R}$-algebra $A$ of
dimension $n$ with the following properties:

  1. (i)

All positive semidefinite elements of $A$ are sums of squares in $A$.

  2. (ii)

The field $\mathrm{Frac}(A)$ is formally real.

###### Proof.

Let $A$ be the $\mathbb{R}$-algebra constructed in Theorem 4.1. It satisfies
(ii). To verify (i), choose a nonzero positive semidefinite element $f\in A$.
Since the only point of $\mathrm{Sper}(A)$ is supported on the ideal $(0)$ of
$A$, the space $\mathrm{Sper}(A/\langle f^{2}\rangle)$ is empty. It follows
from the real Nullstellensatz that $-1$ is a sum of squares in $A/\langle
f^{2}\rangle$ (see [BCR98, Theorem 4.3.7]). As a consequence,
$f=((f+1)/2)^{2}-((f-1)/2)^{2}$ is a sum of squares in $A/\langle
f^{2}\rangle$, hence a sum of squares in $A$ by [Sch01, Corollary 2.3 (b)]. ∎

## References

  * [Art27] E. Artin, _Über die Zerlegung definiter Funktionen in Quadrate_ , Abh. Math. Sem. Univ. Hamburg 5 (1927), no. 1, 100–115.
  * [Bae78] R. Baeza, _Quadratic forms over semilocal rings_ , Lecture Notes in Mathematics, vol. 655, Springer-Verlag, Berlin-New York, 1978.
  * [BCR98] J. Bochnak, M. Coste and M.-F. Roy, _Real algebraic geometry_ , Ergeb. Math. Grenzgeb. (3), vol. 36, Springer-Verlag, Berlin, 1998.
  * [BE80] J. Bochnak and G. Efroymson, _Real algebraic geometry and the 17th Hilbert problem_ , Math. Ann. 251 (1980), no. 3, 213–241.
  * [Bru79] G. W. Brumfiel, _Partially ordered rings and semi-algebraic geometry_ , London Math. Soc. Lecture Note Series, vol. 37, Cambridge University Press, Cambridge-New York, 1979.
  * [CL77] M. D. Choi and T. Y. Lam, _An old question of Hilbert_ , Conference on Quadratic Forms—1976, Queen’s Papers in Pure and Appl. Math., vol. 46, 1977, pp. 385–405.
  * [CLR80] M. D. Choi, T. Y. Lam and B. Reznick, _Real zeros of positive semidefinite forms. I_ , Math. Z. 171 (1980), no. 1, 1–26.
  * [CLRR80] M. D. Choi, T. Y. Lam, B. Reznick and A. Rosenberg, _Sums of squares in some integral domains_ , J. Algebra 65 (1980), no. 1, 234–256.
  * [DDG+18] H. Dao, A. De Stefani, E. Grifo, C. Huneke and L. Núñez-Betancourt, _Symbolic powers of ideals_ , Singularities and foliations. Geometry, topology and applications, Springer Proceedings in Mathematics & Statistics, vol. 222, Springer, Cham, 2018, pp. 387–432.
  * [Del80] C. N. Delzell, _A constructive, continuous solution to Hilbert’s 17th problem, and other results in semi-algebraic geometry_ , 1980, Ph.D. Thesis, Stanford University.
  * [Eis95] D. Eisenbud, _Commutative algebra_ , Graduate Texts in Mathematics, vol. 150, Springer-Verlag, New York, 1995.
  * [Fer02] J. F. Fernando, _Positive semidefinite germs in real analytic surfaces_ , Math. Ann. 322 (2002), no. 1, 49–67.
  * [FRS04] J. F. Fernando, J. M. Ruiz and C. Scheiderer, _Sums of squares in real rings_ , Trans. Amer. Math. Soc. 356 (2004), no. 7, 2663–2684.
  * [Gro65] A. Grothendieck, _Éléments de géométrie algébrique: IV. Étude locale des schémas et des morphismes de schémas, II_ , Publ. Math. IHES (1965), no. 24.
  * [Gro67] by same author, _Éléments de géométrie algébrique: IV. Étude locale des schémas et des morphismes de schémas, IV_ , Publ. Math. IHES (1967), no. 32.
  * [Hil88] D. Hilbert, _Ueber die Darstellung definiter Formen als Summe von Formenquadraten_ , Math. Ann. 32 (1888), no. 3, 342–350.
  * [Hil93] by same author, _Über ternäre definite Formen_ , Acta Math. 17 (1893), no. 1, 169–197.
  * [Hoc73] M. Hochster, _Criteria for equality of ordinary and symbolic powers of primes_ , Math. Z. 133 (1973), 53–65.
  * [Jou83] J.-P. Jouanolou, _Théorèmes de Bertini et applications_ , Progress in Mathematics, vol. 42, Birkhäuser Boston, Inc., Boston, MA, 1983.
  * [Lam05] T. Y. Lam, _Introduction to quadratic forms over fields_ , Graduate Studies in Mathematics, vol. 67, American Mathematical Society, Providence, RI, 2005.
  * [Liu02] Q. Liu, _Algebraic geometry and arithmetic curves_ , Oxford Graduate Texts in Mathematics, vol. 6, Oxford University Press, Oxford, 2002.
  * [Mat89] H. Matsumura, _Commutative ring theory_ , second ed., Cambridge Studies in Advanced Mathematics, vol. 8, Cambridge University Press, Cambridge, 1989.
  * [MLS39] S. Mac Lane and O. F. G. Schilling, _Zero-dimensional branches of rank one on algebraic varieties_ , Ann. of Math. (2) 40 (1939), 507–520.
  * [Mot67] T. S. Motzkin, _The arithmetic-geometric inequality_ , Inequalities (Proc. Sympos. Wright-Patterson Air Force Base, Ohio, 1965), Academic Press, New York, 1967, pp. 205–224.
  * [Nor53] D. G. Northcott, _Ideal theory_ , Cambridge Tracts in Mathematics and Mathematical Physics, vol. 42, Cambridge University Press, 1953.
  * [Rui86] J. M. Ruiz, _Cônes locaux et complétions_ , C. R. Acad. Sci. Paris Sér. I Math. 302 (1986), no. 2, 67–69.
  * [Sch00] C. Scheiderer, _Sums of squares of regular functions on real algebraic varieties_ , Trans. Amer. Math. Soc. 352 (2000), no. 3, 1039–1069.
  * [Sch01] by same author, _On sums of squares in local rings_ , J. Reine Angew. Math. 540 (2001), 205–227.
  * [Sch16] by same author, _Sums of squares of polynomials with rational coefficients_ , J. Eur. Math. Soc. 18 (2016), no. 7, 1495–1513.
  * [ZS60] O. Zariski and P. Samuel, _Commutative algebra. Vol. II_ , D. Van Nostrand Co., 1960.