%%% X-Authentication-Warning: l1-hrz.uni-duisburg.de: hn212sc owned process doing -bs
%%% Date: Tue, 2 Jan 2001 12:11:01 +0100 (MEZ)
%%% From: Claus Scheiderer <hn212sc@uni-duisburg.de>
%%% To: Ulf Rehmann <rehmann@Mathematik.Uni-Bielefeld.DE>
%%% Subject: Re: erneut
%%% In-Reply-To: <200101021049.LAA00686@jcn09.Mathematik.Uni-Bielefeld.DE>
%%% Content-Type: MULTIPART/MIXED; BOUNDARY="113901587-684387517-978433861=:22081"
%%% 
%%% Content-Type: TEXT/PLAIN; charset=US-ASCII
%%% 
%%% Lieber Herr Rehmann,
%%% 
%%% Vermutlich kriegen Sie von der "claus@..." Adresse Fehlermeldungen
%%% derzeit. Auf hn212sc dagegen habe ich Ihre Antwort erhalten,
%%% vielen Dank.
%%% 
%%% Ich versuche jetzt einmal, die .tex-Quelldatei zu der Arbeit
%%% ueber lokale Ringe als attachment zu schicken. Bitte sagen Sie
%%% mir, ob das geklappt hat!
%%% 
%%% Ihr
%%% Claus Scheiderer
%%% 
%%% Content-Type: TEXT/PLAIN; charset=iso-8859-1; name="l.tex"
%%% Content-Transfer-Encoding: BASE64
%%% Content-ID: <Pine.HPX.4.21.0101021211010.22081@l1-hrz.uni-duisburg.de>
%%% Content-Description: 
%%% Content-Disposition: attachment; filename="l.tex"
%%% 
%%% % LOCAL: MODIFICATIONS AFTER FIRST SUBMISSION ON July 31, 2000
%%% %
%%% % Alonso, Andradas, Becker, Bochnak, Broecker
%%% % Colliot-Thelene, Coste, Delzell, Ducros
%%% % Gamboa, Gondard, Hoffmann, Knebusch
%%% % Lam, Leep, Mahe, Marshall, Monnier, Ojanguren
%%% % Parimala, Pfister, Powers, Prestel, Pumplun, Quarez,
%%% % Reznick, Ruiz, Schwartz, Serre, Stengle, Sujatha
%%% %
%%% %
%%% 
\documentclass{amsart}
\usepackage{amssymb}

\input xy
\xyoption{all}

\swapnumbers

\theoremstyle{plain}
\newtheorem{proposition}{Proposition}[section]
\newtheorem{theorem}[proposition]{Theorem}
\newtheorem{corollary}[proposition]{Corollary}
\newtheorem{lemma}[proposition]{Lemma}
%\newtheorem{sublemma}[proposition]{Sublemma}

\theoremstyle{definition}
\newtheorem{definition}[proposition]{Definition}
\newtheorem{remark}[proposition]{Remark}
\newtheorem{remarks}[proposition]{Remarks}
\newtheorem{example}[proposition]{Example}
\newtheorem{question}[proposition]{Question}
\newtheorem{lab}[proposition]{}

%\newcommand{\bbA}{\mathbb A}
%\newcommand{\bbG}{\mathbb G}
%\newcommand{\bbP}{\mathbb P}
\newcommand{\C}{\mathbb C}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\Z}{\mathbb Z}
\newcommand{\fra}{\mathfrak a}
%\newcommand{\frb}{\mathfrak b}
\newcommand{\m}{\mathfrak m}
\newcommand{\n}{\mathfrak n}
\newcommand{\frp}{\mathfrak p}
\newcommand{\frq}{\mathfrak q}
\newcommand{\frr}{\mathfrak r}
%\newcommand{\calH}{\mathcal H}
\newcommand{\calO}{\mathcal O}
%\newcommand{\eusL}{\mathcal L}
%\newcommand{\eusP}{{\mathscr P}}
%\newcommand{\eusS}{{\mathscr S}}
\usepackage{amscd}
\usepackage[mathscr]{eucal}

\def\onto{\mathrel{\rlap{$\mathord{\rightarrow}$}\kern1.5pt\mathord
  {\rightarrow}}}

\def\comp{\circ}
%\def\comp{\mathbin{\scriptstyle\circ}}
%\def\isomap{\mathrel{\buildrel\sim\over\to}}
\def\iff{\Leftrightarrow}
\def\rightmap#1{\mathrel{\mathop{\to}\limits^{#1}}}
\def\mal{\,.\,}
\def\ol#1{\overline{#1}}
%\def\minus{{\scriptscriptstyle-}}
\def\plus{{\scriptscriptstyle+}}
\def\lpow{[\![}
\def\rpow{]\!]}
\def\llau{(\!(}
\def\rlau{)\!)}
\def\Quot{\mathop{\rm Quot}}
\def\wh#1{\widehat{#1}}
\def\lqf{\mathopen{<}}
\def\rqf{\mathclose{>}}
%\def\biglqf{\mathopen{\langle}}
%\def\bigrqf{\mathclose{\rangle}}
%\def\lpfi{\mathopen{\ll}}
%\def\rpfi{\mathopen{\gg}}

\def\Ass{{\rm Ass}}
\def\cd{\mathop{\rm cd}}
\def\ch{\mathop{\rm char}}
%\def\Div{\mathop{\rm Div}}
\def\div{\mathop{\rm div}}
%\def\Gal{\mathop{\rm Gal}}
%\def\Gen{\mathop{\rm Gen}}
%\def\Gr{\mathop{\rm Gr}}
\def\Hom{{\rm Hom}}
\def\im{{\rm im}}
\def\Max{{\rm Max}}
\def\Nil{{\rm Nil}}
\def\ord{{\rm ord}}
\def\Pic{\mathop{\rm Pic}}
\def\PO{{\rm PO}}
%\def\pr{\mathop{\rm pr}}
\def\Rad{{\rm Rad}}
\def\red{{\rm red}}
%\def\sa{semi-algebraic}
%\def\sgn{\mathop{\rm sgn}}
\def\Spec{\mathop{\rm Spec}}
\def\Sper{\mathop{\rm Sper}}
\def\supp{\mathop{\rm supp}}
\def\vcd{\mathop{\rm vcd}}

%\def\et{{\hbox{$\scriptstyle\rm\mathaccent"7013et$}}}
\let\noi\noindent

\def\endproof{\unskip\nobreak\kern4pt\nobreak\hfill\discretionary
  {}{\hbox to\hsize{\hfill$\square$}}{\vbox{\hbox{$\square$}}}}%
%  \bigbreak} % (!)

%%% framing a piece of text (copied from LaTeX)
\def\aheight{height}
\def\awidth{width}
\newbox\atempboxa
\newdimen\atempdima
\newdimen\fboxrule
\newdimen\fboxsep
\fboxrule=0.5pt
\fboxsep=3pt
\long\def\fbox#1{\leavevmode\setbox\atempboxa\hbox{#1}\atempdima
     \fboxrule\advance\atempdima\fboxsep\advance\atempdima\dp
     \atempboxa\hbox{\lower\atempdima\hbox{\vbox{\hrule\aheight
     \fboxrule\hbox{\vrule\awidth\fboxrule\hskip\fboxsep\vbox{
     \vskip\fboxsep\box\atempboxa\vskip\fboxsep}\hskip\fboxsep
     \vrule\awidth\fboxrule}\hrule\aheight\fboxrule}}}}

%\def\Label#1{\label{#1}\marginnote{\fbox{\rm\tiny #1}}}
\def\Label#1{\label{#1}}
\def\marginnote #1{\vrule width0pt height0pt depth0pt
    \vadjust{\vbox to0pt{\vss\hbox to\hsize{\hskip\hsize\quad
    #1\hss}\vskip1.5pt}}}
%\def\marginnote #1{\vadjust{\vbox to0pt{\vss\hbox to\hsize{\hskip
%  \hsize\quad #1\hss}\vskip3.5pt}}}

\def\emph#1{\bgroup\it #1\/\egroup}

%====================================================================


\begin{document}

\title
[On sums of squares in local rings]
{On sums of squares in local rings}

\author{Claus Scheiderer}

\address{Fachbereich Mathematik, Universit\"at Duisburg, 47048
Duisburg, Germany}

\email{claus@math.uni-duisburg.de}

\date\today

%\dedicatory{Dedicated to Manfred Knebusch on the occasion of his
%60th birthday}

\subjclass{Primary 11E25; Secondary 13H, 14P}

\keywords{Sums of squares, semilocal rings, Pythagoras number,
quadratic forms, orderings, real spectrum}

\begin{abstract}
% with a little help of V.
Let $A$ be a semilocal ring. We compare the set of positive
semidefinite (psd) elements of $A$ and the set of sums of squares
in $A$. For psd $f\in A$, whether $f$ is a sum of squares or not 
depends only on the behavior of $f$ in an infinitesimal neighborhood
of the real zeros of $f$ in $\Spec A$. We apply this observation,
first to $1$-dimensional local rings, then to $2$-dimensional regular
semilocal rings. For the latter, we show that every psd element is a
sum of squares. On the quantitative side, we obtain explicit (finite)
upper bounds for the Pythagoras number, for various classes of local
rings for which finiteness of this invariant has been an open question
so far. For example, a regular $2$-dimensional local ring has finite
Pythagoras number if and only if its quotient field does.
\end{abstract}

%\commby{}

\maketitle

%====================================================================


\section*{Introduction}

Let $A$ be a local ring, or more generally, a semilocal ring. The
aim of this paper is a study of the set $\Sigma A^2$ of all sums of
squares of elements of $A$, both from a qualitative and from a
quantitative point of view. Briefly, we try to characterize the set
$\Sigma A^2$ inside $A$, and we try to study the number of squares
needed for sums of squares representations.

Sums of squares are, of course, a subject with an extremely rich
and beautiful history. Having always been a traditional topic of
classical number theory (Fermat, Legendre, Gau\ss), it received an
additional momentum in the last century from Hilbert's 17th problem
and the developments that emerged from it. Sums of squares have
become a central topic in the algebraic theory of quadratic forms
over fields, much due to Pfister's elegant theorems, and they lie at
the very basis of real algebra, ever since Artin solved Hilbert's
17th problem and established the connection with the concept of
orderings.

In the 1970's, much of the algebraic theory of quadratic forms has
been successfully transfered
% transferred?
from fields to the broader context of local and semilocal rings.
% Namen? Knebusch Rosenberg Ware
Still, there is a drawback in the local situation, since quadratic
form theory does often not provide much insight about non-units.
For example, results on representations of elements as sums of
squares (or as values of more general quadratic forms) are
typically restricted to units. The reason is simply that a non-unit
does not give rise to a non-degenerate quadratic form.

Therefore, although our subject belongs to the intersection of
quadratic form theory and real algebra, the presence of the second
will be felt stronger than the presence of the first. The questions
we take up are mostly well-established for units, but are much less
clear for non-units.

For much information on sums of squares, in particular in the more
general context of rings rather than fields, we refer to Ch.~7 of
Pfister's book \cite{Pf2}, and to the important papers by Choi, Dai,
Lam, Reznick \cite{CDLR} and by Mah\'e \cite{M}.
% weitere?
\smallbreak

One of our main concerns will be to characterize the sums of squares
inside $A$. If $K$ is the total ring of quotients of $A$, then for
$f\in A$ to be a sum of squares in $A$, it is obviously necessary
that $f$ is a sum of squares in $K$. However, there is another
necessary condition, stronger if $A$ is reduced and noetherian, and
often strictly stronger. Namely, a sum of squares in $A$ has
non-negative sign with respect to any ordering of any residue field
of $A$. An element with this latter property will be called positive
semi-definite (or \emph{psd}, for short). We will try to understand
in which (semi-) local rings it is true that, conversely, every psd
element is a sum of squares (or \emph{sos}, for short).

For example, this is known to be the case if $A$ is a field (Artin)
or a valuation ring (Kneser, Colliot-Th\'el\`ene, see \cite{CLRR}).
On the other hand, one cannot usually expect it to be true if
$\dim A\ge3$, for quite elementary reasons  (see \ref{dimge3}).
Therefore, the emphasis will be on semilocal rings of dimension one
or~two.

Our starting point is an observation (Thm.\ \ref{reallynice}) which,
although elementary, seems to have escaped earlier notice. It lies
at the basis of most of our results. Given any semilocal ring $A$
and a psd element $f$ in $A$, assume that $f$ is a sum of squares
modulo the ideal $(f^2)$. Then $f$ is a sum of squares altogether.
Therefore, the behavior of $f$ in an infinitesimal algebraic
neighborhood of its zero locus decides (for psd $f$), whether or not
$f$ is a sum of squares in $A$. It is interesting that, in this way,
rings with nilpotent elements become useful for the study of sums of
squares in very ``well-behaved'' (semi-) local rings, like regular
domains.

There is a refinement of this result, to the effect that it suffices
even that $f$ is a sum of squares in a suitable infinitesimal
neighborhood of its \emph{real} zero locus in $\Spec A$ (Thm.\ \ref
{modrealrad}). A consequence is the following: If $A$ is a
noetherian semilocal ring, and $f$ is a psd element in $A$ whose real
zero locus has dimension $\le0$, then $f$ is a sum of squares in $A$
if(f) it is a sum of squares in the completion $\wh A$ (Cor.~\ref
{reducetocompl}). This is a fact that is much exploited in the rest
of the paper.

In Sect.\ \ref{onedim}, we study one-dimensional local noetherian
rings $A$, and try to determine those in which every psd element
is a sum of squares (or briefly, in which $\rm psd=sos$ holds).
The main result (Thm.\ \ref{main}) says, under a mild restriction
($A$ has to be a Nagata ring), that $\rm psd=sos$ holds in $A$ iff
it holds in the completion $\wh A$. Moreover, under the condition
that the residue field of $A$ is real closed, we succeed in giving
a complete classification of these rings.

In Sect.\ \ref{twodim}, we turn to the case of dimension two. Here
the main result is that $\rm psd=sos$ holds in any two-dimensional
regular semilocal ring (Thm.\ \ref{2dimlocreg}). This answers an
open question from \cite{S}. With the help of Cor.\ \ref
{reducetocompl}, the proof gets reduced to the case of a power series
ring $k\lpow x,y\rpow$, which in turn is treated using Weierstra\ss\
preparation and again \ref{reducetocompl}. If the field $k$ is real
closed, it has long been known that every psd element in $k\lpow x,y
\rpow$ is a sum of squares (of two squares, in fact), but already the
case of $k\lpow x,y\rpow$ for general $k$ seems to be new.

It turns out that our methods, aiming originally at qualitative
information on sums of squares, provide a lot of quantitative
information as well. This is exploited in the final Sect.\ \ref
{quant}. Recall that the Pythagoras number $p(A)$ of a ring $A$ is
the least integer $n$ such that every sum of squares in $A$ is a sum
of $n$ squares. This is an invariant which has received much
attention, and which is often hard to get a hold on, even in the case
of fields. For simplicity, we restrict to local (instead of
semilocal) rings. Our methods lead to significant progress on the
Pythagoras numbers of such rings. Briefly, we establish not only
finiteness, but also (reasonable) upper bounds for $p(A)$, for
several classes of rings for which not even finiteness of $p(A)$ was
known before.

Here is a brief summary of the main results. We show that the square
lengths of totally positive elements in semilocal rings of geometric
type over a real closed field are bounded, and in fact, bounded in
terms of the transcendence degree (\ref{mahe}). This answers a
question of Mah\'e. Another application is to local rings $A$ of
algebraic curves over a real closed field, where we compare $p(A)$ to
$p(\wh A)$ (\ref{onedimquant}). We then turn to local rings of
dimension two. First, we estimate the Pythagoras number of power
series rings $k\lpow x,y\rpow$ (\ref{pythpowser}), and then produce a
general upper bound for $p(A)$, for factorial $A$, in terms of its
units Pythagoras number and its completion (\ref{upperbound}).

The use of this bound is illustrated by several concrete
applications. Let $A$ be a regular two-dimensional local ring of an
algebraic variety $V$ over a real closed field. If $\dim V=d$, we
show that $p(A)\le2^d$, which is the best bound one can reasonably
expect (\ref{2dimlocringvar}). Even the finiteness of $p(A)$ was not
known before. Similarly, we give a bound on the Pythagoras number of
two-dimensional local rings of regular arithmetic schemes (\ref
{arithlocrings}). Finally, we solve a general open problem posed by
Choi, Dai, Lam and Reznick, by showing that a two-dimensional regular
local ring $A$ has finite Pythagoras number if (and only if) its
quotient field $K$ has finite Pythagoras number. In fact, $p(A)$ can
be bounded in terms of $p(K)$, and in particular, the bound $p(A)\le
4p(K)-4$ is valid (Thm.\ \ref{cdlrquest}).

%This paper can be seen as a sequel to \cite{S}, in which we
%concentrate entirely on the local situation.

Our results for local rings have consequences for rings of global
nature as well, like coordinate rings of algebraic curves or
surfaces. These applications will be contained in a future paper.

% Acknowledgements:
% V. for help with the language
% ...

%====================================================================


\section{Notations and generalities}

All rings are commutative with unit, and contain $\frac12$. The total
ring of quotients of $A$ is $\Quot(A)=A_S$, where $S$ is the monoid
of non-zero divisors of $A$. By $A^*$ we denote the group of units
in~$A$. 

If $A$ is a semilocal ring, the radical $\Rad(A)$ of $A$ is the
intersection of the maximal ideals of $A$. We write $\wh A$ for the
$\Rad(A)$-adic completion of $A$. If $A$ is a local ring, $\Rad(A)$
is often written $\m_A$, or simply $\m$, if there is no danger of
confusion; and $\wh\m$ is the maximal ideal of $\wh A$.


\begin{lab}
If $A$ is a ring, then $\Sper A$ is the \emph{real spectrum} of $A$,
i.e., the topological space consisting of all pairs $\alpha=
(\frp,\omega)$ with $\frp\in\Spec A$ and $\omega$ an ordering of the
residue field $k(\frp)$ of~$\frp$ \cite{CR}, \cite{BCR}, \cite{KS}.
The prime ideal $\frp$ is called the \emph{support} of $\alpha$,
written $\frp=\supp(\alpha)$. A prime ideal is called \emph{real} if
it supports an element of $\Sper A$, i.e., if its residue field can
be ordered. Accordingly, a prime element $\pi$ of $A$ is called real
if the prime ideal $\pi A$ is real.
\end{lab}

\begin{lab}
Recall that for $f\in A$, the notation ``$f(\alpha)\ge0$'' (resp.,
``$f(\alpha)>0$'') indicates that the residue class $f$~mod~$\frp$ is
non-negative (resp., positive) with respect to~$\omega$. For every
$f$, the set of all $\alpha$ with $f(\alpha)>0$ is open in $\Sper A$,
and these sets constitute a subbasis of open sets for the topology
of $\Sper A$.

The support map is continuous as a map from $\Sper A$ to $\Spec A$.
If $\alpha$, $\beta\in\Sper A$, one says that $\beta$ is a \emph
{specialization} of $\alpha$ if $\beta\in\ol{\{\alpha\}}$.

An element $f\in A$ is said to be \emph{positive semidefinite} (or
\emph{psd}, for short), if $f(\alpha)\ge0$ for every $\alpha\in
\Sper A$. We write $A_\plus$ for the set of all psd elements of $A$.
An element $f\in A$ is said to be a \emph{sum of squares} (or \emph
{sos}, for short), if it is a sum of squares of elements of $A$. The
set of sums of squares in $A$ is written $\Sigma A^2$.

One always has $\Sigma A^2\subset A_\plus$. For brevity, we will say
that $\rm psd=sos$ holds in $A$ if this inclusion is an equality.

An element $f\in A$ is called \emph{totally positive} if $f(\alpha)
>0$ for every $\alpha\in\Sper A$.
\end{lab}

Let $A$ be a ring, and let $K=\Quot(A)$ be its total ring of
quotients. In the literature, the question when equality $\Sigma A^2
=A\cap\Sigma K^2$ holds has been discussed for certain classes of
rings (e.g., \cite{CLRR}). We first clarify the relation between this
condition and the condition that $\rm psd=sos$ holds in $A$, for $A$
a reduced noetherian ring:

\begin{lemma}\Label{sosinquot}
Let $A$ be a reduced noetherian ring, let $K=\Quot(A)$ be its total
ring of quotients.
\begin{itemize}
\item[\rm(a)]
$A_\plus\subset A\cap\Sigma K^2$, and equality holds if\/ $\Sper K$
is dense in\/ $\Sper A$.
% dachte erst: iff, aber das glaube ich fast nicht mehr
\item[\rm(b)]
$A\cap\Sigma K^2=\Sigma A^2$ implies that $\rm psd=sos$ holds in $A$.
The converse is true if\/ $\Sper K$ is dense in\/ $\Sper A$.
\end{itemize}
\end{lemma}

\begin{proof}
Of course, $\Sper K$ is considered as a subspace of $\Sper A$ here.
It is obvious that $A_\plus\subset K_\plus$, and $K_\plus=\Sigma
K^2$ is true since $K$ is a direct product of fields. Clearly, if
$\Sper K$ is dense in $\Sper A$, then $A\cap K_\plus\subset A_\plus$.
%Conversely, assume that there is $\alpha\in\Sper A$ which does not 
%lie in the closure of $\Sper K$. Then there is $f\in A$ with
%$f(\alpha)<0$ and $f\ge0$ on $\Sper K$.
%IST NICHT SO KLAR!
%Kann man zeigen, dass der Abschlu\ss\ von $\Sper K$ probasisch ist?
%F\"acherkriterium: $A$ lokal, $F$ ein $4$-F\"acher in $\Sper k$,
%kann es sein, dass genau drei davon im Abschlu\ss\ von $\Sper K$
%liegen? Siehe ABR?!
% glaube es beinahe nicht mehr! Stimmt es fuer $A$ integer?
(b) follows immediately from (a).
% $\Sigma A^2 \subset A_\plus \subset A\cap\Sigma K^2$
\end{proof}

\begin{example}
Here are a few standard examples where $A\cap\Sigma K^2$ is not
contained in $A_\plus$. This happens if $K$ nonreal, but $\Sper A\ne
\emptyset$, like for the local ring of the singular plane real curve
$y^2+x^2+x^4=0$ at the origin. But it can also happen when $K$ is
real, as shown by the local ring at the origin of the singular plane
curve $y^2=x^2(x-1)$ (take $f=x-1$), or of the Whitney umbrella
$y^2=x^2z$ (take $f=z$). However, it cannot happen in a regular ring:
\end{example}

%The following characterization is meant as an illustration, and will
%not be used. Therefore we skip over its proof, which is an exercise
%on the real spectrum:
%
%If $V$ is an algebraic variety over a real closed field $R$, if $Z$
%is an irreducible Zariski-closed subset of $V$ and $A$ is the local
%ring of $V$ in $Z$, and if $K=\Quot(A)$, then $\Sper K$ fails to be
%dense in $\Sper A$ if and only if there is an open subset $U$ of
%$V(R)$ whose Zariski closure contains $Z$, but does not contain any
%irreducible component of $V$.
%
%\begin{proof}
%Assume that there is an open subset $U$ of $V(R)$ as advertised, let
%$W$ be an irreducible component of the Zariski closure of $U$ which
%contains $Z$, and let $\frq$ be the prime ideal of $R[V]$
%corresponding to $W$. There is an element $\alpha\in\Sper R[V]$ with
%$\alpha\in\tilde U$ and $\supp(\alpha)=\frq$. Then $\alpha$,
%considered as a point in $\Sper A$, does not lie in the closure of
%$\Sper K$, since it is a minimal point of $\Sper A$ and $\frq$ is
%not a minimal prime ideal of $A$.
%Conversely, if $\Sper A$ contains a point $\alpha$ not in the
%closure of $\Sper K$, we may assume that $\alpha$ has no proper
%generalization in $\Sper A$. Consider $\alpha$ as a point in $\Sper
%R[V]$, and let $W$ be its support variety. Then $W$ is not an
%irreducible component of $V$, but there is a \sa\ subset $U$ of
%$W(R)$ which is open in $V(R)$, and for which $\tilde U$ contains
%$\alpha$. The Zariski closure of $U$ is just $W$. 
%\end{proof}

\begin{corollary}
If $A$ is a regular noetherian domain, and $K=\Quot(A)$, then
$A_\plus=A\cap\Sigma K^2$, and therefore $\rm psd=sos$ holds in $A$
iff\/ $\Sigma A^2=A\cap\Sigma K^2$.
\end{corollary}

\begin{proof}
$\Sper K$ is dense in $\Sper A$ (\cite{S} Lemma 0.1), so the
corollary follows from \ref{sosinquot}.
\end{proof}

% Remark: If $A$ is noetherian, but not reduced, then $A_\plus$ may
% not be contained in $\Sigma K^2$. For example, take $A=K$ (i.e.,
% every non-unit is a $0$-disivor): Elements in the real nilradical
% are not sos in $K$, in general


%\begin{lab}\Label{evenorder}
%If $v$ is a valuation of a field $K$ with real residue field, then
%$v(f)$ is even for every $f\in\Sigma K^2$. In particular, if $A$ is
%a UFD and $0\ne f\in A_\plus$, then for every real prime element
%$\pi$ of $A$ there is $n\ge0$ such that $\pi^{2n}$, but not
%$\pi^{2n+1}$, divides $f$.
%\end{lab}

\begin{lab}\Label{realradical}
If $A$ is a ring and $I$ is an ideal in $A$, the \emph{real radical}
of $I$ is denoted $\root{re}\of I$, and is by definition the
intersection of all real prime ideals of $A$ which contain $I$. The
ideal $\root{re}\of{(0)}$ is called the \emph{real nilradical} of
$A$. The ring $A$ will be said to be \emph{real reduced} if its real
nilradical is zero. One can show that $A$ is real reduced if and only
if $A$ is reduced and every minimal prime ideal of $A$ is real (\cite
{KS} p.~104).

The real nilradical is described by the weak real Nullstellensatz
(e.g.\ \cite {BCR} p.~85, \cite{KS} p.~105):
% some version of it is due to Krivine, which one? cite him if
% possible:
% naja... siehe die bibliographic notes in BCR p. 95
\end{lab}

\begin{proposition}\Label{weakrealnss}
Let $A$ be a ring. Then the real nilradical of $A$ consists of all
elements $a\in A$ for which $-a^{2m}$ is sos in $A$ for some $m\ge1$.
\endproof
\end{proposition}

In particular, the following equivalences hold:
$$\hbox{$s(A)<\infty$ \ $\iff$ \ $A_\plus=A$ \ $\iff$ \ $\Sigma
A^2=A$ \ $\iff$ \ $\root^{re}\of{(0)}=(1)$ \ $\iff$ \ $\Sper A=
\emptyset$.}$$
The study of the set $\Sigma A^2$ is therefore interesting only
when $\Sper A$ is non-empty.

We will often use the following basic fact:

\begin{lemma}\Label{realval}
If $k$ is a field and $v$ is a (Krull) valuation on $k$ with real
residue field, then $v(x_1^2+\cdots+x_n^2)=2\min_iv(x_i)$ for any
$x_1,\dots,x_n\in K$.
\end{lemma}

\begin{corollary}\Label{sqfreepsd}
Let $A$ be a factorial ring, $K=\Quot(A)$, and let $f$ be a
square-free element in $A\cap\Sigma K^2$. Then $f$ is not divisible
by any real prime element of~$A$.
\endproof
\end{corollary}

We will try to understand better what it means for a semilocal ring
$A$ that every psd element is a sum of squares. Here are two
necessary conditions:

\begin{lemma}\Label{notrealreduced}
(\cite{S}, Lemma 6.3)
Let $A$ be a connected noetherian ring with $\Sper A\ne\emptyset$,
and suppose that $A$ is not real reduced. Then there is an element
in the real nilradical of $A$ which is not a sum of squares in $A$.
\end{lemma}

\begin{proposition}\Label{dimge3}
(\cite{S}, Cor.\ 1.3)
If $A$ is a noetherian ring which has a prime ideal $\frp$ of
height $\ge3$ with real residue field for which the local ring
$A_\frp$ is regular, then there exists a psd element in $A$ which
is not a sum of squares.
\end{proposition}

However, it does not seem to be known whether there exists a
local noetherian ring with non-empty real spectrum of dimension
$\ge3$ in which $\rm psd=sos$ holds.

%====================================================================


\section{Basic Constructions}\Label{basic}

We start by recalling a well-known fact:

\begin{proposition}\Label{psdunits}
{\rm(\cite{KRW}, p.~231)} Let $A$ be a semilocal ring. Then any
positive semidefinite unit in $A$ is a sum of squares.
\end{proposition}

This can be proved by establishing for the Witt ring of $A$ the
``same'' properties as for the Witt ring of a field, and in
particular, the characterization of its prime ideals and Pfister's
local-global principle.
% encapsulated in the notion of "abstract Witt ring"

The following theorem is basic for most results of this paper. Its
proof is completely elementary, at least modulo the use of \ref
{psdunits}. We first give the strongest form, and then supply two
weaker versions which are less technical:

\begin{theorem}\Label{reallynice}
Let $A$ be a semilocal ring, and let $f\in A$ be a psd element. Let
$\m_1,\dots,\m_r$ be the maximal ideals of $A$ which contain $f$,
% and whose residue field is nonreal,
and put $I=\root^{re}\of{(f)}\cap\m_1\cap\cdots\cap\m_r$. If $f$ is
a sum of squares in $A/fI$, then $f$ is a sum of squares in $A$.
\end{theorem}

\begin{proof}
By assumption, we have an identity $f=s+fg$ in which $g\in I$ and
$s$ is a sum of squares in $A$. Rewriting it as $s=f(1-g)$, we see
that $1-g$ is a psd element since $g\in\root^{re}\of{(f)}$.
% auf $\{f>0\}$ ist das klar; auf $\{f=0\}$ ist auch $g=0$
Moreover, if $\m$ is a maximal ideal of $A$ with $1-g\in\m$, then
$f\notin\m$.
% $I$ ist in jedem maximalen Ideal enthalten, welches $f$ enthaelt

We would like $1-g$ to be a unit. To achieve this, we modify the
original identity. Let $\n_1,\dots,\n_m$ be those maximal ideals
of $A$ which contain $1-g$, and $\n'_1,\dots,\n'_n$ those which
don't. Choose $h\in A$ with $h\notin\n_i$ ($i=1,\dots,m$) and
$h\in\n'_j$ ($j=1,\dots,n$). The element $s':=s+(fh)^2$ is a sum
of squares, and we have the new identity $f=s'+fg'$ with $g'=
g-fh^2$. Note that $g'\in I$. Now $1-g'$ is a unit, since it is not
contained in any of the $\n_i$ or $\n'_j$. Since $1-g'$ is psd,
$(1-g')^{-1}$ is a sum of squares by \ref{psdunits}, and so $f=
(1-g')^{-1}s'$ is a sum of squares in $A$.
\end{proof}
\medbreak

For most applications, one of the following slightly weaker versions
will suffice:

\begin{corollary}\Label{cor2reallynice}
Let $A$ be a semilocal ring, and let $f\in A$ be a psd element.
\begin{itemize}
\item[\rm(a)]
If $f$ is sos in $A/f\sqrt{(f)}$, then $f$ is sos in $A$.
\item[\rm(b)]
If $f$ is sos in $A/(f^2)$, then $f$ is sos in $A$.
\end{itemize}
\end{corollary}

\noi
Indeed, $(f^2)\subset f\sqrt{(f)}\subset fI$, with $I$ as in Thm.\
\ref{reallynice}.
\endproof
\medbreak

Speaking very informally, one can say that if a psd element $f$ is
a sum of squares modulo $(f^{1+\epsilon})$, for some $\epsilon>0$,
then it is a sum of squares altogether.

Here is a first application:

\begin{corollary}\Label{totpos}
Let $A$ be a semilocal ring. Then every totally positive element of
$A$ is a sum of squares.
\end{corollary}

\begin{proof}
Let $f\in A$ be totally positive. By Cor.\ \ref{cor2reallynice}, it
suffices to show that $f$ is sos in $A/(f^2)$. But this is obvious
since $\Sper A/(f^2)=\emptyset$.
\end{proof}

\medbreak
Note that if $A/\m$ is real for every maximal ideal $\m$, the last
corollary is just a particular case of Prop.\ \ref{psdunits}. But the
general case seems to be new.
\smallbreak

Theorem \ref{reallynice} reduces the question of whether a psd
element $f$ in $A$ is sos from $A$ to $A/fI$, which is
%the ring of
a non-reduced version of the ``zero locus'' of $f$. The following
result reduces the question to (a non-reduced version of) an even
smaller locus, namely the ``real zero locus'' of $f$:

\begin{theorem}\Label{modrealrad}
Let $A$ be a semilocal ring, and let $f\in A$ be a psd element. Then
there is an ideal $J$ of $A$ with $\sqrt J=\root{re}\of{(f)}$, such
that the following is true: If $f$ is sos in $A/J$, then $f$ is sos
in~$A$.
\end{theorem}

\begin{lemma}\Label{trick}
Let $A$ be a semilocal ring, let $f$ be a psd element in $A$, and let
$s\in A$ be such that $\pm s$ are sos in $A$. If $f$ is sos in
$A/(f+s)^2$, then $f$ is sos in $A$.
\end{lemma}

\begin{proof}
If $f$ is sos in $A/(f+s)^2$, then also $f+s$ is sos in $A/(f+s)^2$.
Since $s$ vanishes identically on $\Sper A$, the element $f+s$ is psd
in $A$. So Cor.\ \ref{cor2reallynice} implies that $f+s$ is sos in
$A$. A~fortiori, $f=(f+s)-s$ is sos in $A$.
\end{proof}

\medbreak
\noi\emph{Proof} of Thm.\ \ref{modrealrad}.
There is a family of elements $g_\lambda\in\root^{re}\of{(f)}$
($\lambda\in\Lambda$) such that $-g_\lambda^2$ is sos in $A/(f^2)$
for every $\lambda$, and $\root^{re}\of{(f)}=\sqrt{(f)+(g_\lambda)_
\lambda}$. (This follows from the weak real Nullstellensatz \ref
{weakrealnss}.) Put $J:=(f^2)+\bigl((f+g_\lambda^2)^2\colon$
$\lambda\in\Lambda\bigr)$. Assume that $f$ is sos in $A/J$. Then
there are finitely many among the $g_\lambda$, say $g_1,\dots,g_r$,
such that $f$ is sos modulo $(f^2$, $(f+g_1^2)^2,\dots,
(f+g_r^2)^2)$. Now a repeated application of Lemma \ref{trick} shows
that $f$ is sos in $A/(f^2)$. Hence $f$ is sos in $A$ by Cor.\ \ref
{cor2reallynice}.
\endproof

\begin{corollary}\Label{reducetocompl}
Let $A$ be a noetherian semilocal ring, and let $f\in A$ be a psd
element with\/ $\Rad(A)\subset\root{re}\of{(f)}$. The following
conditions are equivalent:
\begin{itemize}
\item[\rm(i)]
$f$ is sos in $A$;
\item[\rm(ii)]
$f$ is sos in $\wh A$ ($:=$ the $\Rad(A)$-adic completion of $A$);
\item[\rm(iii)]
$f$ is sos in $A/\m^n$ for every real maximal ideal\/ $\m$ of $A$
and every $n\ge1$.
\end{itemize}
\end{corollary}

\begin{proof}
(i) $\Rightarrow$ (ii) $\Rightarrow$ (iii) are trivial. Assuming
(iii), $f$ is sos in $A/\Rad(A)^n$ for every $n\ge1$, since $A/\Rad
(A)^n=A/\m_1^n\times\cdots\times A/\m_r^n$ if $\m_1,\dots,\m_r$ are
the maximal ideals of $A$.
% Chinese remainder theorem
% One can skip the non-real maximal ideals
So $f$ is sos in $A$ by \ref{modrealrad}.
% wegen $A$ noethersch gibt es $n\ge1$ mit $\Rad(A)^n\subset J$.
\end{proof}
\medbreak

Geometrically speaking, the hypothesis $\Rad(A)\subset\root^{re}\of
{(f)}$ means that the locus of real zeros of $f$ in $\Spec A$ has
dimension~$\le0$.

%====================================================================



\section{One-dimensional local rings}\Label{onedim}

In this section, we try determine the one-dimensional local
noetherian rings in which every psd element is a sum of squares. The
main result is Thm.\ \ref{main} below. Before we can give its proof,
we need a series of preparatory steps.

Let $A$ be a ring. To have a convenient way of speaking, we will
often say that an element of $A$ is a \emph{regular element} if it is
not a zero divisor in $A$.
% zB in Zariski-Samuel I, p. 8

Accordingly, we say that \emph{$\rm psd=sos$ holds for regular
elements} in $A$, if every psd element of $A$ which is regular is a
sum of squares of elements of $A$.

\begin{lemma}\Label{sosareopen}
Let $A$ be a noetherian complete local ring, $\dim A=1$. If $f\in A$
is not a zero divisor, then there is $n\ge1$ such that every element
in $f+\m^n$ has the form $u^2f$ with $u\in A^*$.
%either every or no element in $f+\m^n$ is sos. Similarly for
%``psd'' instead of ``sos''.
\end{lemma}

\begin{proof}
We have $\m\subset\sqrt{(f)}$, since $f$ is not a zero divisor.
% Elemente in minimalen Primidealen sind stets Nullteiler
So there is $r\ge1$ with $\m^r\subset(f)$, and hence with $\m^{r+1}
\subset f\m$. If $g\in f+\m^{r+1}$, then $g=f(1+a)$ with $a\in\m$,
and $1+a$ is a unit square in $A$.
\end{proof}
\medbreak

\begin{proposition}\Label{vscompletion}
Let $A$ be a noetherian local ring of dimension one. Then $\rm psd=
sos$ for regular elements holds in $A$ if and only if it holds in
$\wh A$.
\end{proposition}

\begin{proof}
Assume that $\rm psd=sos$ for regular elements holds in $\wh A$. Let
$f$ be a psd element in $A$, not a zero divisor in $A$. Then $f$ is
not a zero divisor in $\wh A$ either, since $A\to\wh A$ is flat.
% \cite{Mat} p.~60
% 0 -> A -a-> A exakt gibt 0 -> B -a-> B exakt
So $f$ is sos in $\wh A$ by hypothesis, and therefore is sos in $A$
by Cor.\ \ref{reducetocompl}.

Conversely, assume that there is a psd element $g$ in $\wh A$, not a
zero divisor, which is not sos in $\wh A$. By \ref{sosareopen}, there
is $n\ge1$ such that every element in $g+\wh\m^n$ is psd and regular,
but no element in $g+\wh\m^n$ is sos in $\wh A$. Choose $f\in A$ with
$f\equiv g$ mod~$\wh{\m}^n$. From Lemma\ \ref{extendtowh} below, it
follows that $f(\alpha)\ge0$ for every $\alpha\in\Sper A$ which has a
specialization with support $\m$. By \cite{S} Cor.\ 5.4, this implies
that there is $h\in\m^n$ for which $f+h$ is psd in $A$. By
construction, $f+h$ is neither sos nor a zero divisor in $\wh A$, and
hence is neither sos nor a zero divisor in $A$.
\end{proof}
\medbreak

The following lemma was used in the last proof:

\begin{lemma}\Label{extendtowh}
Let $A$ be a one-dimensional noetherian local ring, with completion
$\wh A$, and let $\psi\colon\Sper\wh A\to\Sper A$ be the canonical
map. Then\/ $\im(\psi)$ consists of all $\alpha\in\Sper A$ which have
a specialization with support\/~$\m$.
\end{lemma}

If the local ring $A$ is excellent, of any dimension, this has been
proved by Ruiz (\cite{Rz} Thm.\ 1.1). The case of a one-dimensional
local ring is so special that it can be proved without the excellence
hypothesis.
% The reader may skip over the following proof if (s)he is willing to
% assume that $A$ is excellent and apply Ruiz's theorem.

\begin{proof}
One inclusion is clear, since every closed point in $\Sper\wh A$ has
support $\wh\m$. Conversely, let $\alpha\in\Sper A$ have a
specialization with support $\m$, and let $\frp=\supp(\alpha)$. We
can assume $\frp\ne\m$. Let $K=\Quot(A/\frp)$, and let $B$ be the
convex hull of $A/\frp$ in $K$ with respect to the ordering $\alpha$.
The valuation ring $B$ dominates the local ring $A/\frp$. The integral
closure
% $\tilde A$
of $A/\frp$ in $K$ is a (semilocal) Dedekind domain, by the
Krull-Akizuki theorem,
% Bourbaki ch. 7 \S2 no. 5 p. 224f
% neuer Matsumura p. 85, Cor.
and is contained in $B$. It follows that
% $B=\tilde A_\n$ for some maximal ideal $\n$ of $\tilde A$, and
% hence
$B$ is a discrete valuation ring. The homomorphism $A\to B$ is a
homomorphism of local rings, and hence it induces a homomorphism
$\wh A\to\wh B$ between the completions. Since $\alpha$ has in
$\Sper B$ a specialization whose support is the maximal ideal $\m_B$,
it follows that $\alpha$ lies in the image of $\Sper\wh B\to\Sper B$.
The assertion follows therefore from the commutative diagram
$$\xymatrix{
A \ar[r] \ar[d] & B \ar[d] \\
\wh A \ar[r] & \wh B}$$
\end{proof}

\begin{lemma}\Label{realideals}
Let $A$ be a noetherian local one-dimensional integral domain, and
assume that the completion $\wh A$ has at least one minimal prime
ideal which is real. Then for every ideal $I\ne(0)$ in $A$, there
exists an ideal $J\subset I$ in $A$, $J\ne(0)$, such that the
following property holds:
\begin{itemize}
\item[$(*)$]
If $x_1,\dots,x_n\in A$ and $\sum_ix_i^2\in J^2$, then $x_1,\dots,
x_n\in J$.
\end{itemize}
\end{lemma}
% Bemerkung: Aus den Voraussetzungen des Lemmas folgt insbesondere,
% dass der Restklassenkoerper von $A$ reell ist - schon a priori:
% denn $\wh A$ hat reellen Restklassenkoerper

\begin{proof}
Let $\frq$ be a minimal prime ideal of $\wh A$ which is real, and let
$B$ be the integral closure of $\wh A/\frq$ in its quotient field.
Then $B$ is a complete DVR with real residue field.
% da der Quotientenkoerper reell ist; also $B=F[[t]]$, $F$ reell
Let $\n$ be the maximal ideal of $B$. We consider $A\subset B$ as an
extension of local rings.
% A -> \wh A -> \wh A/\frq -> B
For every $n\ge0$, the ideal $J=A\cap\n^n$ of $A$ (is non-zero and)
satisfies condition $(*)$ (\ref{realval}).
% $J^2$ ist enthalten in $A\cap\n^{2n}$
On the other hand, every non-zero ideal of $A$ contains $A\cap\n^n$
for some $n\ge0$.
% denn $\m\subset\sqrt I$, also $\m^n\subset I$ fuer ein $n$, und
% $\m^n\subset A\cap\n^n$
The lemma is proved.
% $A\cap\n^n\ne(0)$, denn es enthaelt $\m^n$.
\end{proof}

% ALTE VERSION, VIEL ZU UMSTAENDLICH!!
%
%
%\begin{lemma}\Label{realideals}
%Let $A$ be a noetherian local $1$-dimensional integral domain, and
%assume that the completion $\wh A$ is real reduced. Then for every
%ideal $I\ne(0)$ in $A$, there exists an ideal $J\subset I$ in $A$,
%$J\ne(0)$, such that the following property holds:
%\begin{itemize}
%\item[$(*)$]
%If $x_1,\dots,x_n\in A$ and $\sum_ix_i^2\in J^2$, then $x_1,\dots,
%x_n\in J$.
%\end{itemize}
%\end{lemma}
%
%\begin{proof}
%See \ref{realradical} for the notion of a real reduced ring. Let $A'$
%be the integral closure of $A$ in its quotient field. Then $A'$ is
%finite as an $A$-module, since $\wh A$ is reduced (\cite{Bou} ch.~IX
%\S4 no.~2, Cor.\ \`a Thm.~2).
%% p. AC IX.33
%% Tats\"achlich gilt: Die Endlichkeit von $A'$ als $A$-Modul ist
%% \"aquivalent zur Reduziertheit von $\wh A$ (wegen $\dim A=1$):
%% Bourbaki AC IX, \S4, exerc. 1a), p. IX.78
%% oder besser: neuer Matsumura p. 264
%Therefore, $A'$ is a semilocal Dedekind domain.
%% $A'$ is a noetherian, semilocal, integral domain, $\dim A'=1$
%% das w\"urde auch noch ohne $\wh A$ stimmen, Matsumura neu
%% p. 264 unten/265 oben
%Let $\n_1,\dots,\n_r$ be the maximal ideals of $A'$. We first show
%that each $\n_i$ is real.
%
%Let $\frq_1,\dots,\frq_s$ be the minimal prime ideals of $\wh A$.
%Let $B_j=\wh A/\frq_j$, let $B'_j$ be the integral closure of $B_j$,
%and write $B'=B'_1\times\cdots\times B'_s$. So $B'$ is the integral
%closure of $\wh A$ in $L=\Quot(\wh A)$.
%% klar da $\wh A$ reduziert, s. auch BAC V \S1 no. 2, Cor. 1
%Let $C=A'\otimes_A\wh A$. Then $\wh A\to C$ is finite, and is
%injective since $A\to\wh A$ is flat. Moreover, $C\subset L$, since
%every non-zero element of $A$ is regular in $\wh A$,
%% since $A\to\wh A$ is flat
%so $L$ is also the total ring of quotients of $C$. Therefore,
%$\wh A\subset C\subset B'$, and $B'$ is the integral closure of $C$.
%So $\Max(B')\to\Max(C)$ is surjective.
%% $\Spec B'\to\Spec C$ is closed, and each minimal prime ideal
%% of $C$ is in the image since $C\to B'$ is injective! (KS p.14)
%On the other hand, $\Max(C)\to\Max(A')$ is surjective, since $A'\to
%C$ is faithfully flat.
%% is extension of $A\to\wh A$, which is f.f. (Mat neu, p. 63 oben)
%In summary, each $A'/\n_i$ is a subfield of the residue field of
%some $B'_j$. But the quotient field of $B'_j$ is real by assumption,
%% it is the quotient field of $\wh A/\frp_j$
%and $B'_j$ is a complete local ring,
%% a DVR, in fact: it is finite over $B_j$, hence complete, normal,
%% and also integral and local
%% hence isomorphic to a power series ring $k_j\lpow x\rpow$ over a
%% real field $k_j$
%hence has a real residue field. Thus $A'/\n_i$ is real for each $i$.
%
%Now, if $e_1,\dots,e_r$ are arbitrary non-negative integers, then
%$(*)$ holds for $J=A\cap\n_1^{e_1}\cdots\n_r^{e_r}$,
%% $=A\cap\n_1^{e_1}\cap\cdots\cap\n_r^{e_r}$
%since the $(A')_{\n_i}$ are discrete valuation rings with real
%residue field (c.f.\ \ref{realval}). Since every ideal $I\ne(0)$ of
%$A$ contains an ideal $J$ of the above form,
%% $\m_A^n\subset I$ for some $n$, hence $J=A\cap\n_1^n\cdots\n_r^n$
%% is contained in $I$
%and $J\ne(0)$,
%% $J$ contains $\m_A^n$ for $n\ge\max n_i$
%the lemma is proved.
%\end{proof}

\begin{lemma}\Label{realreduced}
Let $A$ be a one-dimensional complete local noetherian ring with real
residue field $k$. If $A$ is reduced and $\rm psd=sos$ for regular
elements holds in $A$, then $A$ is real reduced.
\end{lemma}

\begin{proof}
Let $\frp_1,\dots,\frp_r$ be the minimal prime ideals of $A$. For
each $i$, write $A_i=A/\frp_i$ and $K_i=\Quot(A_i)$. Let $A'_i$ be
the integral closure of $A_i$ in $K_i$, and let $A'=A'_1\times\cdots
\times A'_r$, the integral closure of $A$ in its total ring of
quotients $K:=K_1\times\cdots\times K_r$.
% vgl. auch Beweisbeginn von Bourbaki AC IX \S4 no.3 Cor, p. IX.33
We consider $A$ as a subring of $A'$, and hence, of $K$. Let $\pi_i
\colon K\to K_i$ denote the $i$-th projection.

The ring $A'_i$ is a complete DVR,
% it is finite over $A$, hence is semilocal, and complete, hence 
% direct product of local rings (Bou III.2.13, Cor.), hence local
% since it is a domain
and we denote by $v_i$ the associated discrete valuation of $K_i$.
By abuse of notation, we also write $v_i(x):=v_i(\pi_i(x))$ for
$x\in K$. Since $A'$ is finite over $A$ (\cite{Bou} ch.~IX \S4
no.~2, Cor.\ \`a Thm.~2), there exists a regular element $f\in A$
with $fA'\subset A$.
% conductor: Ist $A'$ erzeugt von $x_1,...,x_n$ als $A$-Modul, so
% gibt es regul\"are $f_i\in A$ mit $f_ix_i\in A$, und es folgt
% $f_1\cdots f_nA'\subset A$.
In particular, there are integers $m_i\ge0$ such that every $x\in K$
with $v_i(x)\ge m_i$ for all $i$ lies in $A$.
% $m_i=v_i(f)$ 

Let $\frp_1,\dots,\frp_s$ be the real ones and $\frp_{s+1},\dots,
\frp_r$ the non-real ones among the minimal prime ideals of $A$. Let
$N$ be the real nilradical of $A$. So $N=\frp_1\cap\cdots\cap\frp_s$
if $s\ge1$, and $N=\m$ if $s=0$.
% letzteres ist die (einzige) Stelle, wo eingeht, dass $k$ reell ist
Assume that
% $s<r$, or equivalently, that
$N\ne(0)$. Then $N\ne N^2$. Since $N\not\subset\frp_j$ for $j=s+1,
\dots,r$, there exists $a\in N\smallsetminus N^2$ with $a\notin
\frp_{s+1}\cup\cdots\cup\frp_r$ (\cite{Bou1} ch.~II \S1 Prop.~2).
% p. 70f. Die Aussage dort ist (insbes.): Sind $I$, $J_1,\dots,J_n$
% Ideale mit $I\subset J_1\cup\cdots\cup J_n$, und sind h\"ochstens
% zwei der $J_i$ nicht prim, so ist $I\subset J_i$ f\"ur ein $i$.
There is $x\in\frp_{s+1}\cap\cdots\cap\frp_r$ with $v_i(x)=m_i$ for
$i=1,\dots,s$. The element $x^2+a$ is psd in $A$, and is not a zero
divisor in $A$.
% denn es liegt in keinem der $\frp_i$
Hence, by hypothesis on $A$, $x^2+a=\sum_\nu y_\nu^2$ with $y_\nu\in
A$. For $i=1,\dots,s$, we have $v_i(y_\nu)\ge v_i(x)=m_i$ since the
valuation $v_i$ has real residue field (\ref{realval}). Let $e$ be
the idempotent element in $A'$ with $\pi_i(e)=0$ for $i=1,\dots,s$
and $\pi_i(e)=1$ for $i=s+1,\dots,r$. Then $ey_\nu\in A$ for all
$\nu$. From $a=e(x^2+a)=\sum_\nu(ey_\nu)^2$ and $a\in N$, it follows
that $ey_\nu\in N$ for each $\nu$. But then $a\in N^2$, in
contradiction to the choice of~$a$.
\end{proof}
\medbreak

\begin{remark}\Label{nagatarings}
Recall that a noetherian ring $A$ is called a \emph{Nagata ring} if,
for every $\frp\in\Spec A$ and every finite field extension $L$ of
the residue field $k(\frp)$ of $\frp$, the integral closure of $A$ in
$L$ is a finite $A$-module (\cite{Bou} ch.~IX \S4).
% Es gibt $1$-dimensionale lokale integre noethersche Ringe, deren
% ganzer Abschlu\ss\ nicht endlich ist. Beispiel in Nagata, Ex. 3,
% p. 205f. (der Ring ist noethersch)

Here are some important facts about Nagata rings (see loc.~cit.\ for
references):
% siehe auch: alter Matsumura, \S31, pp 231 ff,
% sowie neuer Matsumura, remarks on p 264
\begin{itemize}
\item[\rm(a)]
If $k$ is a field, every localization $A_S$ of a finitely generated
$k$-algebra $A$ is a Nagata ring.
% IX.35, oben 4) und Prop. 4b)
\item[\rm(b)]
Every complete local noetherian ring is a Nagata ring (Nagata's
theorem).
% IX.35, oben 2)
\item[\rm(c)]
If $A$ is a local noetherian ring with $\ch(A/\m)=0$, then $A$ is a
Nagata ring if and only if, for every $\frp\in\Spec A$, the
completion $\wh{A/\frp}$ is reduced (no.~4, Cor.~3).
% IX.36, Cor. 3
\item[\rm(d)]
If $A$ is a reduced local Nagata ring, then its completion $\wh A$ is
again reduced (no.~4, Cor.~1), and the integral closure $A'$ of $A$
is a finite $A$-module (no.~2, Cor.\ \`a Thm.~2).
% p. AC IX.36
\end{itemize}
\end{remark}

\begin{lemma}\Label{regelssuffice}
Let $A$ be a one-dimensional reduced local Nagata ring, with real
residue field $k$. If\/ $\rm psd=sos$ for regular elements holds in
$A$, then $\rm psd=sos$ holds in $A$ for arbitrary elements.
\end{lemma}

\begin{proof}
Let $\frp_1,\dots,\frp_r$ be the minimal prime ideals of $A$.
%Observe that $\frp_1\cup\cdots\cup\frp_r$ is the set of zero
%divisors in $A$.
% since $A$ is reduced
For each $i$, write $A_i=A/\frp_i$ and $K_i=\Quot(A_i)$. Let $A'_i$
be the integral closure of $A_i$ in $K_i$, and let $A'=A'_1\times
\cdots\times A'_r$, the integral closure of $A$ in its total ring of
quotients $K_1\times\cdots\times K_r$.
% vgl. auch Beweisbeginn von Bourbaki AC IX \S4 no.3 Cor, p. IX.33
We consider $A$ as a subring of $A'$. Let $\pi_i\colon A'\to A'_i$ be
the $i$-th projection.

By \ref{vscompletion}, $\rm psd=sos$ for regular elements holds in
$\wh A$. Since $\wh A$ is reduced (\ref{nagatarings}(d)), we can
apply Lemma \ref{realreduced} and conclude
that every minimal prime ideal of $\wh A$ is real.

%Fix an index $i\in\{1,\dots,r\}$. The completion $\wh A_i$ of $A_i$
%is real reduced. Indeed, $\wh A_i=\wh A/\frp_i\wh A$,
%% klar, siehe auch Mat neu p. 255 unten
%and the minimal prime ideals of $\wh A_i$ have the form $\frq/\frp_i
%\wh A$, where $\frq$ is a minimal prime ideal of $\wh A$ containing
%$\frp_i$.
%% das Radikal von $\frp_i\wh A$ in $\wh A$ kann nicht $\wh\m$ sein,
%% da sonst $\wh A_i$ artinsch w\"are
%Hence they are real; and $\wh A_i$ is reduced since $A$ is a Nagata
%ring.

Since $A'$ is a finite $A$-module (\ref{nagatarings}(d)), there
exists a regular element $f$ in $A$ with $fA'\subset A$.
% wie im Beweis von \ref{realreduced}:
% Sei $A'=Ax_1+...+Ax_n$. Gen\"ugt: F\"ur jedes $i$ gibt es $s\in A$,
% NNT, mit $sx_i\in A$. Aber das ist klar.
For each $i$, write $I_i=\pi_i(A'f)=A'_i\pi_i(f)$, an ideal of $A'_i$
which is contained in $A_i$. Every minimal prime ideal of $\wh A_i$
is real.
% the minimal prime ideals of $\wh A_i$ have the form $\frq/\frp_i
% \wh A$, where $\frq$ is a minimal prime ideal of $\wh A$ containing
% $\frp_i$.
%% das Radikal von $\frp_i\wh A$ in $\wh A$ kann nicht $\wh\m$ sein,
%% da sonst $\wh A_i$ artinsch w\"are
By Lemma \ref{realideals}, there exists an ideal $(0)\ne J_i\subset
I_i$ of $A_i$ such that
\begin{itemize}
\item[$(*)$]
$x_\nu\in A_i$ and $\sum_\nu x_\nu^2\in J_i^2$ imply $x_\nu\in J_i$
for all $\nu$.
\end{itemize}
Define $J:=J_1\times\cdots\times J_r$, an ideal of $A'$ which is
contained in $A$.

Let $a$ be a psd element in $A$. Choose an element $b$ in $J$ with
$ab=0$ and with $\pi_i(b)\ne0$ for every $i$ with $\pi_i(a)=0$. The
element $a+b^2$ is psd in $A$, and is not a zero divisor. By
hypothesis, there are $x_\nu\in A$ with $a+b^2=\sum_\nu x_\nu^2$. For
each $i$ with $\pi_i(a)=0$, we have $\pi_i(x_\nu)\in J_i$ for every
$\nu$, by $(*)$. Let $e$ be the idempotent element in $A'$ with $ea=
a$ and $eb=0$. Then $ex_\nu\in A$ for each $\nu$. Since $a=e(a+b^2)=
\sum_\nu(ex_\nu)^2$, it follows that $a$ is sos in $A$.
\end{proof}

\begin{example}\Label{multiplepoint}
If $k$ is a field and $A=k\lpow x_1,\dots,x_n\rpow/(x_ix_j\colon$
$i<j)$, then every psd element in $A$ is a sum of squares. Indeed,
$A$ is isomorphic to the subring of the direct product ring
$k\lpow x_1\rpow\times\cdots\times k\lpow x_n\rpow$ which consists of
all tuples $(f_1,\dots,f_n)$ with $f_1(0)=\cdots=f_n(0)$.
% der iso ist:  f(x_1,...,x_n) |--> 
% ( f(x_1,0,...,0) , f(0,x_2,0,...,0) , ... , f(0,...,0,x_n) )
From this description, it is obvious that $\rm psd=sos$ holds in $A$.
\end{example}


Let $A$ be a one-dimensional local noetherian ring. The condition
$\m\notin\Ass(A)$ is equivalent to the existence of a regular element
in $A$ which is not a unit; or also, to the condition that the set of
zero divisors in $A$ is the union of the minimal prime ideals of $A$.
In particular, it is satisfied if $A$ is reduced.

\begin{theorem}\Label{main}
Let $A$ be a one-dimensional local Nagata ring with real residue
field $k$, and assume $\m\notin\Ass(A)$. Consider the following five
conditions:
\begin{itemize}
\item[$(1)$]
$\rm psd=sos$ holds in $A$;
\item[$(2)$]
$\rm psd=sos$ holds in $\wh A$;
\item[$(3)$]
$\rm psd=sos$ for regular elements holds in $A$;
\item[$(4)$]
$\rm psd=sos$ for regular elements holds in $\wh A$;
\item[$(5)$]
there is $n\ge1$ such that $\wh A\cong k\lpow x_1,\dots,x_n\rpow/
(x_ix_j\colon i<j)$.
\end{itemize}
Then the following are true:
\begin{itemize}
\item[\rm(a)]
Each of these conditions implies that $A$ is reduced.
\item[\rm(b)]
Conditions $(1)$--$(4)$ are equivalent, and are all implied by $(5)$.
\item[\rm(c)]
If $k$ is real closed, then all five conditions are equivalent.
\end{itemize}
\end{theorem}

\begin{proof}
$(1)$ $\Rightarrow$ $(3)$ and $(2)$ $\Rightarrow$ $(4)$ are trivial.
The equivalence of $(3)$ and $(4)$ has been shown in \ref
{vscompletion}. We prove $(3)$ $\Rightarrow$ $(1)$. So assume that
$\rm psd=sos$ for regular elements holds in $A$. By \ref
{regelssuffice}, it suffices to show that $A$ is reduced.

Let $N=\sqrt{(0)}$, let $A_\red=A/N$, and denote residue classes
mod~$N$ by a bar. If $f\in A$ is such that $\ol f$ is regular in
$A_\red$, then $f$ is regular in $A$, since $\m\notin\Ass(A)$.
Therefore, $\rm psd=sos$ for regular elements holds in $A_\red$ as
well, and so $A_\red$ satisfies the conditions of Lemma \ref
{regelssuffice}. From the proof of this lemma, we see that there is
an element $x\in\m$ for which $\ol x$ is regular and has the property
that for all $y_1,\dots,y_r\in A$, $\ol x^2\mid\sum_i\ol y_i^2$ (in
$A_\red$) implies $\ol x\mid\ol y_i$ for each $i$. Assume $N\ne(0)$,
and choose $a\in N$ with $a\notin\m N$ (Nakayama lemma). The element
$x^2+a$ is psd in $A$ and regular, hence is sos by hypothesis. By the
choice of $x$, there are elements $b_i\in A$ and $c_i\in N$ with
$x^2+a=\sum_i(b_ix+c_i)^2$, and hence with
$$\Bigl(\sum_i b_i^2-1\Bigr)x^2=a-2x\sum_ib_ic_i-\sum_ic_i^2.$$
The right hand side lies in $N$. Since $\ol x$ is regular, it follows
that $1-\sum_ib_i^2\in N$. But this implies $a\in\m N$. This
contradicts the choice of $a$, and proves that $A$ is reduced.

Since $\wh m\notin\Ass(\wh A)$, the last implication can be applied
to $\wh A$, which shows $(4)$ $\Rightarrow$ $(2)$.
% $\wh A$ is Nagata
For $(5)$ $\Rightarrow$ $(2)$, see Example \ref{multiplepoint}. It
remains to prove $(2)$ $\Rightarrow$ $(5)$ under the hypothesis that
$k$ is real closed.

We assume that $A$ is complete. Note that $A$ is reduced. Let
$\frp_1,\dots,\frp_r$ be the minimal prime ideals of $A$. By \ref
{realreduced}, each $\frp_i$ is real. Fix an index~$i$. The integral
closure $A'_i$ of $A_i=A/\frp_i$ is isomorphic to a power series ring
$k_i\lpow x\rpow$, where $k_i$ is a finite real extension of $k$.
Since $k$ is real closed, $k_i=k$. We use the notation $v_i(f)$ as in
the proof of \ref{realreduced}. Choose $f\in A$ with $v_i(f)=2^n$ for
some $n\ge1$ and with $f\in\bigcap_{j\ne i}\frp_j$ (this is possible,
c.f.\ the proof of \ref{realreduced}). Replacing $f$ by $-f$, if
necessary, we can assume that $f$ is psd.
% Auch hier wird nochmal benutzt, dass $k$ reell abgeschlossen ist:
%
% $f$ psd in $A$ <==> $f$ positiv in den $K_i$ <==> der
% Leitkoeffizient von $f$ in $A'_i$ ($=$ Potenzreihenring \"uber
% $k_i:=$ Restklassenk\"orper von $A'_i$) ist positiv. Nun ist
% $k_i$ eine endliche Erweiterung von $k$, also $k$ oder $k(i)$
% Beachte: Es gen\"ugt nicht, da\ss\ $k$ nur eine Anordnung hat, denn
% dasselbe mu\ss\ f\"ur jede endliche (reelle) Erweiterung von $k$
% gelten.
Therefore, $f$ is a sum of squares in $A$ by hypothesis $(2)$. Since
the $\frp_j$ are real, this implies that there is $g\in\bigcap_
{j\ne i}\frp_j$ with $v_i(g)=2^{n-1}$ (\ref{realval}). Iterating this
step, we see that $A$ contains an element $x_i\in\bigcap_{j\ne i}
\frp_j$ with $v_i(x_i)=1$, for each $i=1,\dots,r$.

If $\m'_i$ is the maximal ideal of $A'_i$, this shows $\m'_1\times
\cdots\times\m'_r\subset A$ (again, we consider $A$ as a subring of
$\prod_iA_i$, and hence of $\prod_iA'_i$). But this means that $A$ is
isomorphic to the ring in $(5)$.
% Sei $B=k+\m'_1\times\cdots\times\m'_r$, das ist der Ring aus (v).
% Dann also $B\subset A\subset A'$. W\"are $B\ne A$, so g\"abe es
% ein Element in $A$ welches in manchen der $m'_i$ liegt, und in
% manchen nicht. Es g\"abe also mindestens 2 verschiedene
% Durchschnitte von maximalen Idealen von $A'$ mit $A$. Das ist
% Widerspruch zu $A$ lokal; der Durchschnitt $\n\cap A$ muss gleich
% $\m_A$ sein fuer jedes maximale Ideal $\n$ von $A'$.
\end{proof}


% ALTE VERSION, SCHWAECHER:
%
%
%\begin{theorem}\Label{main}
%Let $A$ be a reduced $1$-dimensional local Nagata ring with real
%residue field $k$. Consider the following five conditions:
%\begin{itemize}
%\item[\rm(i)]
%$\rm psd=sos$ holds in $A$;
%\item[\rm(ii)]
%$\rm psd=sos$ holds in $\wh A$;
%\item[\rm(iii)]
%$\rm psd=sos$ for regular elements holds in $A$;
%\item[\rm(iv)]
%$\rm psd=sos$ for regular elements holds in $\wh A$;
%\item[\rm(v)]
%there is $n\ge1$ such that $\wh A\cong k\lpow x_1,\dots,x_n\rpow/
%(x_ix_j\colon i<j)$.
%\end{itemize}
%Conditions (i), (ii), (iii) and (iv) are equivalent, and are all
%implied by (v). If $k$ is real closed, then all five conditions are
%equivalent.
%\end{theorem}
%
%\begin{proof}
%We first remark that in any case, $\wh A$ is a reduced ring (\ref
%{nagatarings}(d)).
%
%(i) $\Rightarrow$ (iii) and (ii) $\Rightarrow$ (iv) are trivial. The
%equivalence of (iii) and (iv) has been shown in \ref{vscompletion},
%and (iii) $\Rightarrow$ (i) is the content of \ref{regelssuffice}.
%Applying it to $\wh A$ instead of $A$ gives the  implication (iv)
%$\Rightarrow$ (ii) as well.
%% $\wh A$ is again a reduced Nagata ring
%For (v) $\Rightarrow$ (ii), see Example \ref{multiplepoint}. It
%remains to prove (ii) $\Rightarrow$ (v) under the hypothesis that
%$k$ is real closed.
%
%We assume that $A$ is complete. Let $\frp_1,\dots,\frp_r$ be the
%minimal prime ideals of $A$. By \ref{realreduced}, each $\frp_i$
%is real. Hence the integral closure $A'_i$ of $A_i=A/\frp_i$ is
%isomorphic to the power series ring $k\lpow x\rpow$, for every $i$.
%We use the notation $v_i(f)$ as in the proof of \ref{realreduced}.
%Fix an index $i$, and choose $f\in A$ with $v_i(f)=2^n$ for some
%$n\ge1$ and with $f\in\bigcap_{j\ne i}\frp_j$ (this is possible,
%c.f.\ the proof of \ref{realreduced}). Replacing $f$ by $-f$, if
%necessary, we can assume that $f$ is psd. (It is here that we use
%that $k$ is real closed!)
%% $f$ psd in $A$ <==> $f$ positiv in den $K_i$ <==> der
%% Leitkoeffizient von $f$ in $A'_i$ ($=$ Potenzreihenring \"uber
%% $k_i:=$ % Restklassenk\"orper von $A'_i$) ist positiv. Nun ist
%% $k_i$ eine % endliche Erweiterung von $k$, also $k$ oder $k(i)$
%% Beachte: Es gen\"ugt nicht, da\ss\ $k$ nur eine Anordnung hat,
%% denn dasselbe mu\ss\ f\"ur jede endliche (reelle) Erweiterung von
%% $k$ gelten.
%Therefore, $f$ is a sum of squares in $A$, by hypothesis (ii). Since
%the $\frp_j$ are real, this implies that there is $g\in\bigcap_
%{j\ne i}\frp_j$ with $v_i(g)=2^{n-1}$ (\ref{realval}). Iterating
%this step, we see that $A$ contains an element $x_i\in\bigcap_
%{j\ne i}\frp_j$ with $v_i(x_i)=1$, for each $i=1,\dots,r$.
%
%If $\m'_i$ is the maximal ideal of $A'_i$, this shows $\m'_1\times
%\cdots\times\m'_r\subset A$ (again, we consider $A$ as a subring of
%$\prod_iA_i$, and hence of $\prod_iA'_i$). But this means that $A$
%is isomorphic to the ring in (v).
%% Sei $B=k+\m'_1\times\cdots\times\m'_r$, das ist der Ring aus (v).
%% Dann also $B\subset A\subset A'$. W\"are $B\ne A$, so g\"abe es
%% ein Element in $A$ welches in manchen der $m'_i$ liegt, und in
%% manchen nicht. Es g\"abe also mindestens 2 verschiedene
%% Durchschnitte von maximalen Idealen von $A'$ mit $A$. Das ist
%% Widerspruch zu $A$ lokal; der Durchschnitt $\n\cap A$ muss gleich
%% $\m_A$ sein fuer jedes maximale Ideal $\n$ von $A'$.
%\end{proof}
\medbreak

\begin{remark}
In the theorem, the condition $\m\notin\Ass(A)$ is necessary for the
equivalence of $(1)$--$(4)$. Indeed, if $\m\in\Ass(A)$, then $A$ has
nilpotent elements, and so $(1)$ and $(2)$ do not hold (\ref
{notrealreduced}); but $(3)$ holds by \ref{psdunits} since every
regular element in $A$ is a unit. An example is given by the ring $A=
k\lpow x,y\rpow/(xy,y^2)$.
\end{remark}

\begin{remark}
If $k$ is not real closed, then conditions $(1)$--$(4)$ do not imply
condition $(5)$: Let $k'/k$ be a finite field extension which is
real, $k'\ne k$, let $A'=k'\lpow x\rpow$, and put $A=k+xA'$. Then $A$
satisfies $(1)$--$(4)$, but not $(5)$.
\end{remark}
% Andere Konstruktion:
% Sei $L/k$ endlich, reell, seien $V_0,V_1,V_2,\dots$ $k$-Teilraeume
% von $L$ mit $V_0=k$, $V_n=L$ fuer $n>>0$, und mit $V_iV_j\subset
% V_{i+j}$. Sei $A$ der Teilring von $L[[x]]$ aus allen Potenzreihen
% $\sum_ia_ix^i$ mit $a_i\in V_i$. Die folgende Bedingung bedeutet,
% dass psd=sos in $A$ gilt:
% fuer alle $i\ge0$ ist jedes Element in $V_{2i}\cap\Sigma L^2$ eine
% Summe von Quadraten von Elementen aus $V_i$.
%
% FRAGE: Beispiele??? Das obige ist $V_0=k$, $V_i=L$ fuer $i\ge1$.
% Anderes: Sei $U$ ein echter $k$-Teilraum von $L$, so dass jede
% Summe von Quadraten in $L$ eine Summe von Quadraten von Elementen
% aus $U$ ist. Dann Beispiel $V_0=k$, $V_1=U$, $V_i=L$ fuer $i\ge2$.
% Freilich weiss ich kein konkretes Beispiel fuer solches $U$!!!
% (Koennte es sein, dass es solches $U$ nie gibt? Das gaebe ein
% Theorem im Fall $k$ nicht reell abgeschlossen, aber ich kann es
% nicht glauben.)
%
% Seltsame Fragen sind das!!!!

\begin{remark}
We briefly discuss what happens when the residue field $k$ is
non-real. Then $\Sper\wh A=\emptyset$, so $(2)$ and $(4)$ hold
trivially. Also $(3)$ holds, by \ref{totpos}, since every regular psd
element in $A$ is totally positive. On the other hand, $(1)$ may
fail, i.e., there may be psd zero divisors in $A$ which are not sums
of squares. Here is an example:

Let $C$ be the reduced curve over $\R$ which is the union of the
circle $C_1=\{x^2+y^2=1\}$ and the line $C_2=\{x=2\}$ in the affine
plane. Let $A$ be the local ring of $C$ at the intersection point
$(2,\sqrt{-3})$ of $C_1$ and $C_2$, an ordinary double point with
residue field $\C$.
% d.h., die Komplettierung ist isomorph zu $\C[[x,y]]/(xy)$??
The function $f=2-x$ vanishes identically on $C_2$ and is strictly
positive on $C_1$. In particular, $f$ is psd, and is a zero divisor
in $A$. But $f$ is not sos in $A$: If we had $f=\sum_if_i^2$ with
$f_i\in A$, then the $f_i$ would have to vanish identically on $C_2$,
and hence lie in the maximal ideal $\m$ of $A$. This would imply
$f\in\m^2$, which however is not the case.
% the vanishing order of $f|C_1$ in $Q$ is one
\end{remark}

%\begin{question}
%When does one call a one-dimensional local ring $A$ an \emph
%{ordinary $n$-fold point}? (Is this an established terminology??) Is
%there a name for the rings classified by the Theorem? Or can one
%otherwise express what (iii) means in terms of $A$ (instead of
%$\wh A$)? Like, $n={\rm edim}(A)$, $A$ has precisely $n$ minimal
%prime ideals, and ....
%
%A plane complex singularity $f(x,y)=0$ of degree $n$ is called an
%{\it ordinary $n$-fold point\/} if the leading form of $f$ is a
%product of $n$ distinct linear factors. Up to isomorphism, the
%completion of such a singularity $f=0$ is determined by the leading
%form. The formal isomorphism classes of such singularities are in
%bijection with the moduli of $n$ points on the projective line (cf.\
%Hartshorne, p.~38).
%\end{question}
%
%\begin{definition}
%A one-dimensional local ring $A$ with residue field $\kappa$ is
%called a {\it plane ordinary $n$-fold point\/} if $\wh A\cong\kappa
%\lpow x,y\rpow/(f)$ where $f=(y-c_1x)\cdots(y-c_nx)$ with $c_1,
%\dots,c_n\in k$ pairwise different.
%\end{definition}
%
%\medbreak
%Ist das eine gute Bezeichnung??? Example: The local ring of the
%plane curve $x^2+y^2=0$ at the origin is an ordinary double point
%only if the base field contains $\sqrt{-1}$!!

%====================================================================


\section{Two-dimensional semilocal rings}\Label{twodim}

We now apply our methods from Sect.\ \ref{basic} to (semi-) local
rings $A$ of dimension two. We always need the hypothesis that $A$ is
factorial, since it is this condition which permits us to restrict to
square-free elements, c.f.\ \ref{sqfreepsd}.

Our first main result is:

\begin{theorem}\Label{powser2var}
Let $k$ be a field. Then every psd element in the power series ring
$k\lpow x,y\rpow$ is a sum of squares.
\end{theorem}

In the proof, we use the following lemma:

\begin{lemma}\Label{$A[[t]]$}
If $A$ is a complete local noetherian ring, then the image of the
canonical map $\psi\colon\Sper A\lpow t\rpow\to\Sper A[t]$ consists
of those $\alpha\in\Sper A[t]$ which have a specialization whose
support contains~$t$.
\end{lemma}

\begin{proof}
Let $\n$ be the ideal in $A[t]$ generated by $\m_A$ and by $t$.
% so $\n=\{f\in A[t]\colon$ $f(0)\in\m_A\}$
Then $\n$ is a maximal ideal, and $A\lpow t\rpow$ is the completion
of the local ring $A[t]_\n$.
% welche der projlim der $A[t]/\n^r$ ist. Nun besteht $\n^r$ aus
% allen Polynomen $a_0+a_1t+a_2t^2+...$ mit $a_0\in\m^r$, $a_1\in
% \m^{r-1}$,..., $a_{r-1}\in\m$. Der projektive Limes ist also
% $\wh A[[t]]=A[[t]]$.
The ring $A$, and therefore also $A[t]_\n$, is excellent.
% $A$: alter Matsumura p. 260 oben;
% $A[t]_\n$: dito, p. 259
By Ruiz's theorem \cite{Rz}, the image of $\Sper A\lpow t\rpow\to
\Sper A[t]$ consists of those $\alpha\in\Sper A[t]$ which have a
specialization with support $\n$. But these are the same as the
$\alpha$ which have a specialization whose support contains $t$.
% by another application of Ruiz's theorem:
% nein, eigentlich viel einfacher: weil in dem vollstaendigen
% lokalen ring $A$ jedes Element aus $\Sper A$ eine Spezialisierung
% mit Traeger $\m_A$ hat.
This proves the lemma.
\end{proof}

%\begin{remark}
%The lemma does not hold for arbitrary local rings. For example, it is
%false for $A$ a convex subring of a real closed field $R$, with rank
%of $A$ at least $2$. [Let $(0)\subsetneqq\frq\subsetneqq\m$ be a
%proper prime ideal of $A$, and let $a\in\m$, $a\notin\frq$. Let
%$\alpha\in\Sper A[t]$ be represented by $A[t]\to A\subset R$, $t\mapsto
%a$. Then $\alpha$ has a specialization with $t$ in its support
%(represented by $A[t]\to A/\m$, $t\mapsto0$). But $\alpha$ is not in
%the image of $\Sper A\lpow t\rpow\to\Sper A[t]$. Indeed, $\frp:=\supp
%(\alpha)=(t-a)A[t]$ is not even in the image of $\Spec A\lpow t\rpow\to
%\Spec A[t]$, since $A[t]/\frp\to A\lpow t\rpow/\frp A\lpow t\rpow=
%A\lpow t\rpow/(t-a)$ is identified with the canonical map $A\to
%\projlim_nA/(a^n)$, whose kernel is $\bigcap_n(a^n)$ and hence
%contains $\frq$, in the above situation. (Going-down does not hold
%for $A[t]\to A\lpow t\rpow$.)]
%\end{remark}

\begin{lab}\Label{proof}
Now we prove Thm.\ \ref{powser2var}. We can assume that the field $k$
is real. Given a psd power series $0\ne f\in k\lpow x,y\rpow$, we can
assume that $f$ is square-free, not a unit. Then $\root{re}\of{(f)}=
\m$, the maximal ideal of $k\lpow x,y\rpow$ (\ref{sqfreepsd}). After a
linear change of coordinates,
% $k$ is infinite!
we may assume $f=ug$, where $u$ is a unit in $k\lpow x,y\rpow$ and
$g\in k\lpow x\rpow\,[y]$ (Weierstra\ss\ Preparation Theorem). Put $c=
u(0,0)$, and replace $u$ by $c^{-1}u$ and $g$ by $cg$. Then $u$ is a
square, and $g$ is psd and square-free in $k\lpow x,y\rpow$. By \ref
{reducetocompl}, it suffices to prove that $g$ is sos in $k\lpow x,y
\rpow/\m^n$, for every $n\ge1$.

Fix $n\ge1$. By Lemma \ref{$A[[t]]$}, $g(\alpha)\ge0$ for every
$\alpha\in\Sper k\lpow x\rpow\,[y]$ which has a specialization whose
support contains $y$. By \cite{S} 5.4, this implies that there exists
$h\in k\lpow x\rpow\,[y]$ such that $g+y^nh$ is psd in $k\lpow x\rpow
\,[y]$.
%\footnote
% {Of course, this also follows from \ref{psdpowmodnpoly} above
% without going through lemma above, but \ref{psdpowmodnpoly} was more
% awkward to prove!}
Now $\rm psd=sos$ holds in this ring (\cite{S} 1.8).
% or more generally: \ref{prufer} above
Therefore, $g$ is a sum of squares in $k\lpow x\rpow\,[y]/(y^n)=
k\lpow x,y\rpow/(y^n)$. A fortiori, $g$ is sos in $k\lpow x,y\rpow/
\m^n$. This completes the proof of Thm.\ \ref{powser2var}.
\endproof
\end{lab}

\begin{remark}
In the case $k=\R$, Thm.\ \ref{powser2var} was proved by Bochnak and
Risler in 1975 \cite{BR}. The authors worked with the ring of
convergent power series, but their proof works for formal power series
as well. They proved in fact that every positive semidefinite power
series is a sum of two squares of power series.
% See also Ruizbuch, pp 85f.
% The same result (for the ring $\R\lpow x,y\rpow$ of formal power
% series) was re-proved later in \cite{CDLR}, \S5: Die formulieren
% allerdings nur die Pytharogaszahl, und nicht psd=sos; aber vermultich
% laesst sich psd=sos herausmelken
\end{remark}

\begin{remark}
In their paper \cite{CDLR} (p.~69), Choi, Dai, Lam and Reznick ask
for a characterization of the sums of squares in $k\lpow x,y\rpow$,
and in particular, for the polynomials which are a sum of squares in
$k\lpow x,y\rpow$.
% They say they have been unable to give one.
% Here is one: $f\in k\lpow x,y\rpow$ is a sum of squares iff $f$ is
% psd (in $k\lpow x,y\rpow$, or equivalently, in $k\llau x,y\rlau$).
% Of course, this is not very satisfactory.
Using Thm.\ \ref{powser2var}, we can describe the latter as follows:
\end{remark}

\begin{corollary}
Let $k$ be a field, and let $f\in k[x,y]$. Then $f$ is a sum of
squares in the power series ring $k\lpow x,y\rpow$ if, and only if,
for every real closure $R$ of $k$, the polynomial $f$ has
non-negative values in a neighborhood of the origin in $R^2$.
\end{corollary}

\begin{proof}
The image of the natural map $\Sper k[x,y]\to\Sper k\lpow x,y\rpow$
is equal to the set $G$ of all $\alpha\in\Sper k[x,y]$ which have a
specialization whose support is the maximal ideal $(x,y)$ \cite{Rz}.
Write $X=\Sper k[x,y]$ and $K=\{\alpha\in X\colon$ $f(\alpha)\ge0\}$.
By \ref{powser2var}, $f$ is sos in $k\lpow x,y\rpow$ iff $G\subset
K$. Now $G\subset K$ is equivalent to $G_\xi\subset K_\xi$
for every $\xi\in\Sper k$, where for every subset $M$ of $X$, $M_\xi$
denotes the set of $\alpha\in M$ which restrict to $\xi$ in $k$. Fix
$\xi\in\Sper k$, and let $k_\xi$ be the corresponding real closure of
$k$. Then $X_\xi$ is identified with $\Sper k_\xi[x,y]$, and under
this identification, the condition $G_\xi\subset K_\xi$ is equivalent
to the condition that $f$ is non-negative on a neighborhood of the
origin in $k_\xi^2$.
\end{proof}

\medbreak
If $A$ is a semilocal ring, we denote the $\Rad(A)$-adic completion
of $A$ by $\wh A$. If $\m_1,\dots,\m_r$ are the maximal ideals
of $A$, then $\wh A=\wh{A_{\m_1}}\times\cdots\times\wh{A_{\m_r}}$
(\cite{Mat} p.~62).

The second main result of this section is:

\begin{theorem}\Label{2dimufd}
Let $A$ be a two-dimensional semilocal noetherian domain, with
quotient field $K$. Suppose, for each maximal ideal\/ $\m$ of $A$,
that $\wh{A_\m}$ is a factorial ring in which $\rm psd=sos$ holds.
% and if every $\alpha\in\Sper A$ with $\supp(\alpha)$ a maximal
% ideal has a proper generalization],
Then $\Sigma A^2=A\cap\Sigma K^2$. In particular, $\rm psd=sos$ holds
in~$A$.
\end{theorem}

Remark: The hypothesis implies that $A$ itself is factorial (\cite
{Mat}, exerc.\ 20.4 and 20.5).
% p. 169; better reference?
% The converse is not true in general.
% failure of converse is remarked in Mat, loc.cit.

%Remark: I would think that the hypothesis on generalizations follows
%from $\rm psd=sos$ in $\wh A$. In other words, let $A$ be a complete
%local ring, $\dim A=2$, such that there is $\alpha\in\Sper A$ with
%$\supp(\alpha)=\m$ and $\alpha$ has no proper generalization. Does
%it follow that $\rm psd\ne sos$ in $A$?

%FRAGE:
%Let $A$ be a noetherian integral domain. Suppose there are a
%non-empty open subset $W$ of $\Sper A$ and an ideal $I\ne(0)$ of $A$
%such that $I\subset\supp(\xi)$ for every $\xi\in W$. Then $\rm psd
%\ne sos$ in $A$?????

\begin{proof}
We first show that $A\cap\Sigma K^2\subset A_\plus$ (c.f.\ \ref
{sosinquot}). Assume false. Then there are $f\in A\cap\Sigma K^2$ and
$\alpha\in\Sper A$ with $f(\alpha)<0$. The prime ideal $\supp
(\alpha)$ cannot have height one, since this would imply that
$A_{\supp(\alpha)}$ is a DVR,
% it is a $1$-dimensional local UFD
and hence that there is $\beta\in\Sper K$ with $f(\beta)<0$. So
$\supp(\alpha)=:\m$, a maximal ideal of $A$. Let $B:=\wh{A_\m}$. By
hypothesis, $B$ is a local factorial ring in which $\rm psd=sos$
holds. In particular, the quotient field of $B$ is real (\ref
{notrealreduced}). By \cite{Rz} Thm.\ 1.3,
% theoreme de dimension reelle
$B$ contains a real prime element $\pi$.
% since the residue field of $B$ is real; $B$ ist exzellent, da
% vollstaendig
The element $f$
% a unit in $B$ (but not necessarily in $A$)
is positive in every point of $\Sper B$ whose support is not the
maximal ideal of $B$.
% denn das gilt nach Zurueckziehen nach $A$
Therefore, the element $f\pi^2$ is psd in $B$, and hence is a sum of
squares in $B$ by assumption. But $f\pi^2=\sum_ih_i^2$ implies $\pi
\mid h_i$ for every $i$ (\ref{realval}), and so $f$ is sos in $B$,
which is absurd in view of $f(\alpha)<0$. This proves $A\cap\Sigma
K^2=A_\plus$.
% weiss nicht, ob $\Sper K$ dicht in $\Sper A$ ist, oder?

Let now $f\ne0$ be an element in $A\cap\Sigma K^2$. Since $A$ is
factorial, we can write $f=gh^2$ with $g,h\in A$, where $g$ is
square-free. Clearly, $g\in\Sigma K^2$, and therefore $g$ is psd in
$A$ by the first step. Moreover, $\root{re}\of{(g)}\supset\Rad(A)$
(\ref{sqfreepsd}). By the hypothesis, $g$ is sos in $\wh A$, and
hence is sos in $A$ by Cor.\ \ref{reducetocompl}. In particular, $f$
is sos in~$A$.
\end{proof}
\medbreak

In particular, we have the following result, which solves an open
problem from \cite{S} (Problem~1, p.~1067):

\begin{theorem}\Label{2dimlocreg}
If $A$ is a two-dimensional regular semilocal ring, and $K=\Quot(A)$,
then $\Sigma A^2=A\cap\Sigma K^2$: Every psd element in $A$ is a sum
of squares.
\end{theorem}

\begin{proof}
We may assume, by Thm.\ \ref{2dimufd}, that $A$ is local and
complete. If the residue field $k$ of $A$ has characteristic $0$,
then $A\cong k\lpow x,y\rpow$, and we are done by Thm.\ \ref
{powser2var}. If $\ch(k)>0$ (or more generally, if $k$ is non-real),
then $\Sper A=\emptyset$. Alternatively, one can use Cor.\ \ref
{2dimlocregnonrealres} (below) in this case.
\end{proof}

\begin{corollary}\Label{2dimlocregnonrealres}
If $A$ is a two-dimensional semilocal factorial ring such that $A/\m$
is non-real for every maximal ideal\/ $\m$, then\/ $\rm psd=sos$
in~$A$.
\end{corollary}

\begin{proof}
Given a psd element $f$, write $f$ as $f=gh^2$ where $g$ is not
divisible by any real prime element. It follows that $g$ is totally
positive in $A$, and hence is a sum of squares (\ref{totpos}).
\end{proof}

\begin{remark}
There do exist singular two-dimensional local rings $A$ with real
residue field in which $\rm psd=sos$ holds. This follows from the
results proved by Ruiz in \cite{Rz2}. He shows in fact that every psd
element is a sum of two squares, for each of the following real
analytic surface singularities: The Brieskorn singularity ($x^2+y^3+
z^5=0$), the union of two planes ($xy=0$)
% das ist leicht! A[[z]] mit A = k[[x,y]]/(xy)
and the Whitney umbrella
($x^2+y^2z=0$).
% Question: There seems no doubt that the same holds for the
% completed rings. Proof?
% Ist OK, denn bei der Reduktion ging nie die Komplettierung selbst
% ein, nur die Quotienten $\wh A/\wh m^n$
The Brieskorn singularity is factorial,
% says Ruiz; reference??!
the other two are not.
% the second is not even a domain, and the Whitney umbrella is not
% normal
\end{remark}


%\begin{question}
%Let $X$ be a smooth $3$-dimensional variety over $\R$, let $Q\in X$
%be a complex closed point. Does one have $\rm psd=sos$ in $A=\calO_
%{X,Q}$? Wlog.\ $f$ is psd with $1$-dimensional $Z(f)$. It would
%suffice to show that $f$ is sos in $B:=A/\fra^n$ for every $n$, where
%$\fra=\root{re}\of{(f)}$. Note that $B$ is a $1$-dimensional local
%ring, with residue field $\C$ and with all its minimal prime ideals
%real; however $B$ is non-reduced, and $f$ is nilpotent in $B$. (I~tend
%to expect that the answer is no? well, I don't know...)
%\end{question}

%====================================================================


\section{Pythagoras numbers of local rings}\Label{quant}

In this final section, we collect the quantitative information on
sums of squares that are implied by the techniques of the previous
sections. We usually concentrate on the case of local rings, but it
should be clear that most results can be generalized to semilocal
rings.

\begin{lab}
First, here are some reminders and remarks of general nature. Let $A$
be any ring, and let $f\in A$. By $\ell(f)=\ell_A(f)$, we denote the
``sums of squares length'' of $f$, i.e., the least integer $n$ such
that $f$ is a sum of $n$ squares in $A$. If $f$ is not a sum of
squares, we put $\ell(f)=\infty$. The \emph{level} of $A$ is defined
as $s(A):=\ell(-1)$.
% The level $s(A)$ is finite iff $\Sper A$ is empty (...).
If $A$ is a field, or more generally, a semilocal ring, then $s(A)$,
if finite, is a power of $2$, but for more general rings it can be an
arbitrary positive integer.

The \emph{Pythagoras number} $p(A)$ of $A$ is defined as $p(A)=\sup
\{\ell(f)\colon$ $f\in\Sigma A^2\}$. It is obvious that $p(A)\ge
p(A/I)$ for any ideal $I$ of $A$, and that $p(A)\ge p(A_S)$ for any
multiplicative subset $S$ of $A$.
% where $A_S$ denotes the ring of fractions with denominators in $S$
In particular, $p(A)\ge p(k(\frp))$ for any prime ideal $\frp$
of~$A$.

If $s(A)<\infty$ (and $2$ is invertible in $A$, as always in this
paper), then $p(A)$ is either $s(A)$ or $1+s(A)$, as follows from the
identity $x=(\frac{x+1}2)^2-(\frac{x-1}2)^2$.
\end{lab}

\begin{lab}
We introduce a few more invariants which are related to the
Pythagoras number:
\begin{itemize}
\item
$p^*(A):=\sup\{\ell(u)\colon$ $u\in A^*\cap\Sigma A^2\}$, the \emph
{units Pythagoras number} of $A$;
\item
$p^\plus(A):=\sup\{\ell(f)\colon$ $f\in\Sigma A^2$ and $f$ is totally
positive$\}$, the \emph{totally positive Pythagoras number}; and
\item
if $A$ is a semilocal ring, with radical $\Rad(A)$, we write $p^1
(A):=\sup\{\ell(u)\colon$ $u\in\Sigma A^2$, $u\equiv1$
mod~$\Rad(A)\}$,
the \emph{principal units Pythagoras number} of $A$.
\end{itemize}
It is obvious that $p^1(A)\le p^*(A)\le p^\plus(A)\le p(A)$ (for
semilocal $A$).
\end{lab}

%Schei\ss e: The notation $p^\plus(A)$ has also been used by Pfister
%in \cite{Pf2}, but in a different meaning. Our notation coincides
%with Mah\'e's, immerhin!!

\begin{lab}
If $m$, $n$ are positive integers, the integer $m\comp n$ is defined
by the following rules:
\begin{itemize}
\item[$(1)$]
$m\comp n=n\comp m$;
\item[$(2)$]
If $m\le n$, and $2^r$ is the smallest power of~$2$ which is $\ge m$,
then $m\comp n$ is the smallest multiple of $2^r$ which is $\ge n$.
\end{itemize}
We complete this definition by setting $\infty\comp n=n\comp\infty=
\infty\comp\infty=\infty$.

So $1\comp n=n$, $2\comp n=2\lceil\frac n2\rceil$, $3\comp n=4\comp n
=4\lceil\frac n4\rceil$ for $n>1$, etc. The following estimates are
obvious:
\end{lab}

\begin{lemma}\Label{obvious}
$\max\{m,n\}\le m\comp n<2\max\{m,n\}$ (if $m$, $n<\infty$).
\end{lemma}

The reason for introducing this notation is the following well-known
fact:

\begin{lemma}\Label{basicquant}
Let $A$ be a semilocal ring, let $a\in A$ be a sum of $m$ squares and
$b\in A$ a sum of $n$ squares. If one of $a$, $b$ is a unit, then
$ab$ is a sum of $m\comp n$ squares.
%\begin{itemize}
%\item[(a)]
%If $a$ is a unit, then $ab$ is a sum of $m\comp n$ squares.
%\item[(b)]
%If $a$ and $b$ are units, then $ab$ is a sum of $m*n$ squares.
%\end{itemize}
\end{lemma}

\begin{proof}
Assume $m\le n$. Let $2^r\ge m$, and let $k\ge1$ be such that $2^rk
\ge n$. Then $a$ is a sum of $2^r$ squares, and $b=b_1+\cdots+b_k$
where each $b_i$ is a sum of $2^r$ squares. If $b$ is a unit, one can
furthermore achieve that each $b_i$ is a unit as well (\cite{Ba}
Thm.\ III.5.2(ii), p.~85).
% die Voraussetzung (ii) greift, ausser wenn $2^r=1$. Aber dann
% ist $m=1$, und es ist eh nix zu zeigen.
For each $i$, $ab_i$ is a sum of $2^r$ squares, by the following

% Auf folgendes Lemma (in der umstîndlichen Version von [M]!) hat
% mich Mahe im Mai 99 in Oberwolfach aufmerksam gemacht:

\begin{lemma}\Label{mahelemma}
Let $A$ be a semilocal ring and $\varphi$ a Pfister form over $A$. If
$a$, $b\in A$ are represented by $\varphi$ over $A$, and if $a$ is a
unit, then also $ab$ is represented by $\varphi$ over $A$.
\end{lemma}

\begin{proof}
If $M$ is the (free) $A$-module on which $\varphi$ is defined, then
by ``$a\in A$ is represented by $\varphi$ over $A$'', we mean that
there is $x\in M$ with $\varphi(x)=a$. The lemma follows immediately
from $a\varphi\cong\varphi$ \cite{Ba}.
% Compare also \cite{M}, Lemma 3.4, for a special case, and an
% awkward proof!
\unskip\nobreak\hfill\phantom{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
\end{proof}
\end{proof}

% Question: Is there a better bound if both $a$, $b$ are units? Don't
% think so!
\medbreak

We start by recording the quantitative side of Thm.\ \ref
{reallynice}:

\begin{proposition}\Label{reallynicequant}
Let $A$ be a semilocal ring, and let $f$ be a psd element in $A$.
Assume that $f$ is a sum of $n$ squares in $A/fI$, where $I=\root^
{re}\of{(f)}\cap\m_1\cap\cdots\cap\m_r$ and\/ $\m_1,\dots,\m_r$ are
the maximal ideals of $A$ which contain $f$.
\begin{itemize}
\item[\rm(a)]
$f$ is a sum of $p^*(A)\comp(1+n)$ squares in $A$.
\item[\rm(b)]
If $f\in\Rad(A)$, then $f$ is a sum of $p^1(A)\comp n$ squares in
$A$.
\item[\rm(c)]
If $f\in\Rad(A)$, and $A$ is henselian with respect to its radical,
then $f$ is a sum of $n$ squares in $A$.
\end{itemize}
\end{proposition}

\begin{proof}
(a) There is an identity $f=s+fg$ with $s$ a sum of $n$ squares and
$g\in I$. The proof of Thm.\ \ref{reallynice} has shown how to modify
it, in order to make $1-g$ a unit sum of squares, at the cost of
adding one square to $s$. By \ref{basicquant}, this proves~(a). If
$f\in\Rad(A)$, we need not modify the original identity since $1-g
\equiv1$ mod~$\Rad(A)$. This proves (b), and (c) is a particular case
of (b) since here $p^1(A)=1$.
% Jedes $u\in1+\frr$ ist ein Quadrat modulo $\frr$, also auch
% ein Quadrat in $A$.
\end{proof}
\medbreak

%Sometimes the following version is more advantageous:
%% im Beweis von \ref{mahe}(b)!
%
%\begin{proposition}\Label{reallynicequant2}
%Let $A$ be a semilocal ring, with radical $\frr$, and let $f$ be a
%psd element in $A$ which is a sum of $m$ squares in $A/f\frr$. Then
%$f$ is a sum of $p^1(A)\comp m$ squares in $A$.
%\end{proposition}
%
%\begin{proof}
%We have $f=s+fg$ with $g\in\frr$ and $s\in A$ a sum of $m$ squares.
%The claim follows since $1-g$ is a principal unit in $A$.
%\end{proof}

Recall that in a semilocal ring, every totally positive element is a
sum of squares (\ref{totpos}). For its length, we can give the
following bound, which sometimes results in better estimates than
\ref{reallynicequant}:

\begin{proposition}\Label{totposquant}
Let $A$ be a semilocal ring, with radical\/ $\Rad(A)=\frr$, and let
$f$ be a totally positive element in $A$. Then $f$ is a sum of $p^1
(A)\comp(1+p^*(A/f\frr))$ squares in $A$. In particular,
$$p^\plus(A)\le p^1(A)\comp(1+p^*(A)).$$
\end{proposition}

\begin{proof}
For every ideal $I$ of $A$, the map $A^*\to(A/I)^*$ is surjective.
% ist $f\in A$ mit $f+I\in(A/I)^*$, so seien $\m_1,...,\m_r$ die
% maximalen Ideale, die $f$ enthalten, und $\n_1,...,\n_s$ die
% anderen. Es gibt $g\in I\cap\n_1\cap...\cap\n_s$ mit $g\notin
% \m_1\cup...\cup\m_r$. (Genugt, $I\cap\n_1\cap...\cap\n_s\not
% \subset\m_i$; das folgt aus $I\not\subset\m_i$.) Es ist $f+g$
% Einheit in $A$.
Therefore, $p^*(A)\ge p^*(A/I)$, and so the second assertion follows
from the first. To prove the first, it suffices to show that $f$ is a
sum of $m:=1+p^*(A/f\frr)$ squares in $A/f\frr$. Indeed, this gives
an identity $f=s+fg$ in $A$ where $s$ is a sum of $m$ squares and
$g\in\frr$. Since $1-g$ is a principal unit, the first assertion
follows from this.

Let $\m_1,\dots,\m_r$ be those maximal ideals of $A$ which contain
$f$, and $\n_1,\dots,\n_s$ those which don't. Choose $a\in\bigcap_j
\n_j$ with $a\notin\bigcup_i\m_i$. Then $f-a^2$ is a unit. Every real
prime ideal which contains $f\frr$ is one of $\n_1,\dots,\n_s$,
since $f$ is totally positive.
% it must contain either $f$ or $\frr$, hence $\frr$, hence be
% maximal; and it cannot contain $f$
So $f-a^2$ is psd in $A/f\frr$, and being a unit, is a sum of $p^*
(A/f\frr)$ squares in this ring. Hence $f$ is a sum of $1+p^*
(A/f\frr)=m$ squares in $A/f\frr$.
% nice trick!
\end{proof}

\begin{corollary}\Label{cor2totposqu}
Let $A$ be a semilocal ring. Then $p^\plus(A)\le p^*(A)\comp
(1+p^*(A))$. In particular, $p^\plus(A)$ is finite iff $p^*(A)$ is
finite.
\endproof
\end{corollary}

\medbreak
As a first application, we address a question of Mah\'e.  Let $R$ be
a real closed field, and let $A$ be a semilocal $R$-algebra of finite
transcendence degree $d$. Having proved $p^*(A)\le2^d$ for such $A$
(\cite{M} Thm.\ 6.1), Mah\'e asked whether also the totally positive
Pythagoras number $p^\plus(A)$ is finite, and if so, whether it can
be bounded in terms of $d$ (loc.~cit., p.~628, Question~2). We show
that this is indeed the case:
% Mah\'e, on p.~628, defined $p^\plus(A)$ --- for semilocal $A$???
% --- as the supremum of the $\ell(a)$ where $a\in A$ is totally
% positive. But he did not discuss the question whether every such
% $a$ is a sum of squares. That this is indeed the case was shown in
% Cor.~\ref{totpos} above.

\begin{theorem}\Label{mahe}
Let $R$ be a real closed field, and let $A$ be a semilocal
$R$-algebra of transcendence degree $d<\infty$. Let $f$ be a totally
positive element of $A$.
\begin{itemize}
\item[\rm(a)]
$f$ is a sum of\/ $2^{d+1}$ squares in $A$.
\item[\rm(b)]
If $f$ is not a zero divisor, $f$ is a sum of\/ $2^d$ squares in $A$.
\end{itemize}
\end{theorem}

\begin{proof}
If $d=0$, then $A$ is a direct product of local artinian rings with
residue fields $R$ or $R(\sqrt{-1})$, and the assertions are easily
checked directly. Otherwise, both statements follow immediately from
Mah\'e's bound for $p^*$, together with \ref{totposquant} (in
case~(b), the transcendence degree of $A/f\frr$ is $d-1$).
% letzteres ist falsch fuer $d=0$
% $2^d\comp(1+2^d)=2^{d+1}$, $2^d\comp(1+2^{d-1})=2^d$
\end{proof}

% ALTER BEWEIS:
%\begin{proof}
%We can assume that $A$ is essentially of finite type over $R$.
%Indeed, $A$ is the directed union of semilocal $R$-subalgebras $A_i$
%which are essentially of finite type over $R$.
%% Let $\m_1,\dots,\m_r$ be the maximal ideals of $A$. Let $B$ be
%% a f.g. $R$-subalgebra of $A$, let $\n_i=B\cap\m_i$. Let $B'$ be
%% the semilocalization of $B$ in $\n_1,\dots,\n_r$. Let $B''$ be
%% the image of $B'$ in $A$. Then $B''$ is a semilocal $R$-subalgebra
%% of $A$ which is essentially of finite type over $R$.
%If $f\in A_i$ for some $i$, then by an easy compactness argument in
%the real spectrum, there is $A_j\supset A_i$ such that $f$ is
%totally positive in $A_j$. Moreover, if $f$ is not a zero divisor in
%$A$, it is not a zero divisor in $A_j$. So assume that $A$ is
%essentially of %finite type over $R$, of transcendence degree $\le
%d$, and let $f\in A$ be totally positive. Note $\dim A\le d$.
%%Since $\dim A/(f^2)\le d$ (resp., $\dim A/(f^2)\le d-1$ if
%%$f$ is not a zero divisor), we have $p^*(A/(f^2))\le2^d$ (resp.,
%%$p^*(A/(f^2))\le2^{d-1}$) according to Mah\'e's theorem (\cite{M}
%%Thm.~6.1). Also, $p^*(A)\le2^d$ by the same token.
%%
%% Or: argue via level, since $s(A/(f^2))\le2^d$, resp.\ $\le
%% 2^{d-1}$, by \cite{M}. OK?
%% Well - die Aussage ueber das Level ist bei Mahe ein Korollar zu
%% jener ueber $p^*$
%% Aussage ist auch richtig f\"ur $d=0$: $f$ ist ein Quadrat falls
%% Einheit. Falls nicht, ist $s=1$, also $p\le2$.
%
%If $d=0$, then $A$ is a direct product of local artinian rings with
%residue fields $R$ or $R(\sqrt{-1})$, and the assertions can be
%checked directly.
%% ist der Restklassenk\"orper $R$, so ist darin $f$ ein Quadrat;
%% ist er $C$, so ist $s=1$, also $p\le2$; ist $f$ NNT, so ist $f$
%% auch darin ein Quadrat.
%So assume $d\ge1$, and let $\frr$ be the radical of $A$. By \cite{M}
%Thm.~6.1, $p^*(A)\le2^d$, and so \ref{totposquant} gives $p^\plus(A)
%\le2^d\comp(1+2^d)=2^{d+1}$. Assume now that $f$ is not a zero
%divisor. Then $A/f\frr$ has transcendence degree $d-1$, and so $p^*
%(A/f\frr)\le2^{d-1}$, again by \cite{M}. Therefore, Prop.\ \ref
%{totposquant} shows that $f$ is a sum of $2^d\comp(1+2^{d-1})=2^d$
%squares in $A$.
%% der vorige Beweis, welcher mit den leveln der $A/(f^2)$ und mit
%% \ref{reallynicequant}(a) argumentierte, gab f\"ur $d=1$ eine
%% schlechtere Schranke bei NNT, n\"amlich nur $4$ statt $2$. Das war
%% der Grund, warum ich \ref{totposquant} aufnahm...
%\end{proof}
\medbreak

Next, we give an application to the Pythagoras numbers of local rings
of real curves:

\begin{proposition}\Label{onedimquant}
Let $R$ be a real closed field, let $B$ be an integral
one-dimensional $R$-algebra of finite type, and let $A=B_\m$ where
$\m$ is a maximal ideal of $B$. Let $q$ be the ``regular'' Pythagoras
number of $\wh A$, i.e., $q=\sup\{\ell_{\wh A}(f)\colon$ $f$ sos, not
a zero divisor$\}$.
\begin{itemize}
\item[\rm(a)]
$p(A)\in\{q,q+1\}$, and $p(A)=q$ if $q$ is even;
\item[\rm(b)]
$p(A)=2$ if $q\le2$.
\end{itemize}
\end{proposition}

Note that $q=p(\wh A)$ if $\wh A$ is a domain, i.e., if $A$ is
unibranch. In this case, much information on the Pythagoras number
$p(\wh A)$ is available, see \cite{Rz0}, \cite{CRz} and \cite{Or}.
% If $\wh A$ is not a domain, I do not know if $p(\wh A)$ can be
% larger than $q$...

\begin{proof}
We first show $p(A)\ge q$. Let $g\in\wh A$ be a regular element
which is a sum of $r$, but not of $r-1$, squares in $\wh A$.
% is $q<\infty$???
By Lemma \ref{sosareopen}, there is $n\ge1$ such that every element
in $g+\wh m^n$ is a sum of $r$, but not of $r-1$, squares in $\wh A$.
It is clear that one can find $f\in A$ with $f\equiv g$ mod~$\wh
m^n$, such that $f$ is a sum of squares in $A$.
% of $r$ squares, in fact, but this doesn't play a role here.
% write $g=g_1^2+\cdots+g_r^2$ in $\wh A$, approximate the $g_i$ by
% elements $f_i\in A$, and put $f=f_1^2+\cdots+f_r^2$
Clearly, $f$ is not a sum of less than $r$ squares in $A$.

According to Mah\'e, we have $p^*(A)\le2$ (\cite{M}, Thm.\ 6.1). If
$f\ne0$ is a sum of squares in $A$, then $A/(f^2)$ is an epimorphic
image of $\wh A$, and $f$ is a regular element in $\wh A$. So $f$ is
a sum of $q$ squares in $A/(f^2)$, and is therefore a sum of $2\comp
q$ squares in $A$ by Prop.\ \ref{reallynicequant}(b). This proves
(a); and (b) follows from $p(A)\ge p(\Quot(A))=2$.
% klar falls $K$ nicht reell; sonst ebenfalls.
\end{proof}
\medbreak

Finally, we study the Pythagoras numbers of two-dimensional local
rings which are regular (and sometimes factorial). We start with
complete rings, since the general case gets partially reduced to the
complete case. First, here are a few preparations.

% GLAUBE, DAS WIRD NIRGENDS VERWENDET:
%
%\begin{lemma}\Label{easy}
%Let $k$ be a real field. The rings $k$, $k\llau t\rlau$, $k\lpow t
%\rpow$ and $k[t]/(t^n)$ (for $n\ge0$) have all the same Pythagoras
%number.
%\end{lemma}
%
%\begin{proof}
%It is clear that $p\bigl(k\llau t\rlau\bigr)=p\bigl(k\lpow t\rpow
%\bigr)\ge p\bigl(k[t]/(t^n)\bigr)\ge p(k)$. Conversely, every sum of
%squares in $k\lpow t\rpow$ has the form $at^{2r}(1+tg)$, where $r\ge0$,
%$a\in\Sigma k^2$ and $g\in k\lpow t\rpow$; and $1+tg$ is a square in
%$k\lpow t\rpow$.
%\end{proof}

\begin{lemma}\Label{$p(k(t))$}
If $k$ is a field, we put
$$\hbox{$\tau(k):=\sup\{s(F)\colon$ $F/k$ finite, non-real$\}$.}$$
Then $p(k[t])=p(k(t))$, and $1+\tau(k)\le p(k(t))\le2\tau(k)$.
\end{lemma}

\begin{proof}
$p(k(t))=p(k[t])$ is due to Cassels \cite{C},
% siehe auch zB. Scharlau 4.3.1 p. 148
% Lam p. 256
and $p(k(t))\le2\tau(k)$ is due to Pfister (\cite{Pf1} Satz~2).
% p. 233. (fuer $k$ reell). Ist $k$ nicht reell, so $\tau(k)=s(k)$,
% und die Ungleichung ist trivial.
% Pfister verweist auch auf Ax, aber Ax' Arbeit
% J.~Ax: On ternary definite rational functions. ??Proc.\ LMS??
% ist nicht erschienen.
The inequality $1+\tau(k)\le p(k(t))$ is elementary. (See also \cite
{L}, p.~305.)
% Sei $F/k$ eine endliche, nicht reelle Erweiterung mit maximalem
% $s=s(F)$. Dann ist $F/k$ eine einfache Erweiterung (nur relevant in
% Char. $p$), etwa $F\cong k[t]/(f)$ f\"ur ein irreduzibles
% normiertes Polynom $f$. Es gibt also $s+1$ Polynome $f_0,f_1,...,
% f_s$, nicht durch $f$ teilbar, so dass $g:=f_0^2+f_1^2+...+f_s^2$
% durch $f$ teilbar ist. Falls dabei $g$ durch $f^2$ teilbar, so
% ersetze $f_0$ durch $f_0+f$, dann wird $g$ ersetzt durch $g+f^2+
% 2ff_0$, ist also nicht mehr durch $f^2$ teilbar.
% Behaupte, $g$ ist nicht Summe von weniger als $s+1$ Quadraten
% (und somit $p(k[t])\ge s+1=\tau(k)+1$):
% Waere $g=g_1^2+...+g_s^2$, so wuerde $f$ nicht alle $g_j$ teilen
% wegen $f^2$ teilt nicht $g$, und Reduktion modulo $(f)$ gaebe
% $s(F)<s$, Widerspruch.
%
% If $k$ is not real, then $\tau(k)=s(k)$, and $p(k(t))=1+s(k)=
% p(k[t])$ (!),  Scharlau 3.4 p. 150
% so this case is ok. Assume now that $k$ is real. Then $p(k[t])=
% p(k(t))$ is due to Cassels (source?). The two inequalities follow
% immediately from the following fact, due to Pfister (source? see
% \cite{L} p.~305): If $F=k(\alpha)$ is a non-real simple algebraic
% extension of $k$, and if $f$ is the minimal polynomial of $\alpha$,
% then $s(F)<\ell_{k[t]}(f)\le2s(F)$.
\end{proof}

\begin{lemma}\Label{tau}
For any field $k$, $\tau(k\llau t\rlau)=\tau(k)$.
\end{lemma}

\begin{proof}
% if $k$ is not real, this says $s(k)=s(k((t)))$
If $L$ is a finite field extension of $k\llau t\rlau$, then $L$ is
isomorphic to $F\llau u\rlau$ for some finite field extension $F$ of
$k$.
% $L$ ist ebenfalls vollstaendig diskret bewertet (Local Fields p.28)
% equal characteristic, also Cohen Struktursatz...
This implies the lemma, since $F\llau u\rlau$ and $F$ have the same
level.
\end{proof}

\begin{remark}\Label{milnor}
If $k$ is a field (of characteristic $\ne2$), the virtual
cohomological $2$-dimension $\vcd_2(k)$ of $k$ is defined as the
cohomological $2$-dimension $\cd_2(k(\sqrt{-1}))$ of $k(\sqrt{-1})$.
From the Milnor conjecture, as proved by Voevodsky, it follows
immediately that $\vcd_2(k)\le d$ implies $\tau(k)\le2^d$. Indeed, if
$F/k$ is a finite non-real extension, then $(-1)^{d+1}=0$ in $H^{d+1}
(F,\Z/2)$, and by the Milnor conjecture, this implies that the
$(d+1)$-fold Pfister form $\lqf1,1\rqf\otimes\cdots\otimes\lqf1,1
\rqf$ is hyperbolic.
\end{remark}

\begin{definition}
If $A$ is a local ring with maximal ideal $\m$, we write $\ol p(A)
:=\sup_np(A/\m^n)$.
\end{definition}

Obviously, $\ol p(A)=\ol p(\wh A)\le p(\wh A)$.

\begin{lemma}\Label{lowerbound}
Let $A$ be a two-dimensional regular local ring, with residue field
$k$ and quotient field $K$.
\begin{itemize}
\item[\rm(a)]
$\ol p(A)\ge p(k(t))$.
\item[\rm(b)]
$p(K)\ge p(k(t))$.
\end{itemize}
\end{lemma}

% Es waere eleganter, einen direkten Vergleich zwischen $\ol p(A)$
% und $p(K)$ zu haben, aber ich kenne keinen!
% Vielleicht gibt es den auch nicht (sicher schon wenn $A$
% vollstaendig ist, aber sonst ist gar nicht klar, wieso $p(K)\le
% \ol p(A)$ sein sollte...
% Was natuerlich stimmt, ist $p(k(t)) \le p(K) \le p(A)$.

\begin{proof}
(a) Let $K=\Quot(A)$, and let $\mu$ be the discrete valuation on $K$
which is defined by $\mu(f)=\sup\{n\colon$ $f\in\m^n\}$ for $f\in A$.
($\mu$ comes from the exceptional divisor on the blowing-up of
$\Spec A$ in its closed point.) Let $B$ be the valuation ring of
$\mu$, and $\n$ its maximal ideal. The local ring $B$ dominates $A$,
and $B/\n\cong k(t)$.

Let $u\in B^*$ be a sum of squares in $B$, and assume that $\ol u=
u+\n$ is not a sum of less than $n$ squares in $B/\n$. Write $u=a/b$
with $0\ne a,b\in A$. Since $ab\in A$ is a sum of squares in $K$, it
is a sum of squares in $A$ (\ref{2dimlocreg}).
% ich braeuchte hier eigentlich nur ein Argument, dass $ab$ in
% A/\m^{2r+1}$ sos ist!
Let $r=\mu(a)=\mu(b)$, and let $x_1,\dots,x_m\in A$ such that $ab
\equiv\sum_ix_i^2$ mod~$\m^{2r+1}$. If $\mu(x_i)\ge r$ for each $i$,
then $x_i/b\in B$ for each $i$, and $u\equiv\sum_i(x_i/b)^2$
mod~$\n$,
% schreibe $ab=c+\sum_ix_i^2$. Dann ist $\mu(c)\ge2r+1$. Also hat
% $u-\sum_i(x_i/b)^2=c/b^2$ $\mu\ge2r+1-2r=1$.
which implies $m\ge n$. If $\mu(x_i)<r$ for some $i$, then $k$ is
non-real (\ref{realval}),
% denn $\mu(\sum_ix_i^2)=\mu(ab-c)=2r$
and $\mu(x_i)<r$ for at least $1+s(B/\n)$ different indices $i$. In
particular, then, $m\ge1+s(B/\n)\ge p(B/\n)$.
% tatsaechlich ist das letzte $\ge$ ein $=$, natuerlich.

(b)~follows from the following general fact: If $B$ is a valuation
ring with residue field $\kappa$ and quotient field $K$, then $p(K)
\ge p(\kappa)$. The argument is essentially the same as for (a), but
somewhat simpler: If $u\in B^*$ is a sum of squares in $B$, let $u=
a_1^2+\cdots+a_r^2$ with $a_i\in K$; we show $r\ge\ell_\kappa
(\ol u)$. This is clear if each $a_i$ lies in $B$. If not, then
$\kappa$ is non-real, and at least $1+s(\kappa)$ of the $a_i$ have
the same (negative) valuation, whence $r\ge1+s(\kappa)\ge p(\kappa)$.
% folgt auch aus \cite{CLRR} 4.5, aber obiges ist viel elementarer
\end{proof}

%\begin{lemma}\Label{lowerbound}
%If $A$ is a regular local ring, with quotient field $K$ and residue
%field $k$, then $p(A)\ge p(K)\ge p(k(t_1,\dots,t_{d-1}))$, where $d=
%\dim A$.
%\end{lemma}
%
%\begin{proof}
%The first inequality is obvious. Let $v$ be the discrete valuation
%on $K$ which is defined by $v(f)=\sup\{n\colon$ $f\in\m^n\}$ for $f
%\in A$. ($v$ comes from the exceptional divisor on the blowing-up of
%$\Spec A$ in its closed point.) The residue field of $v$ is
%isomorphic to $k(t_1,\dots,t_{d-1})$, so the lemma follows from
%\ref{dvr}.
%\end{proof}

%\begin{proposition}\Label{Quant}
%Let $k$ be a field, and let $m:=\sup_np\bigl(k\lpow x\rpow\,[y]/
%(y^n)\bigr)$. Then $p(k\lpow x,y\rpow)$ is either $m$ or $m+1$. In
%particular, $p(k\lpow x,y\rpow)\le1+p\bigl(k\lpow x\rpow\,[y]\bigr)
%=1+p\bigl(k\llau x\rlau\,(y)\bigr)$.
%\end{proposition}
%
%\begin{proof}
%Write $A:=k\lpow x,y\rpow$. The inequality $p(A)\ge m$ is clear,
%since $k\lpow x\rpow\,[y]/(y^n)$ is an epimorphic image of $A$. On
%the other hand, $p(A)\le1+\sup_np(A/\m^n)$ by \ref{upperbound}, and
%this last number is $\le m$. The last equality is a particular case
%of the following fact: If $B$ is a DVR with real residue field and
%with quotient field $K$, then $p(B[t])=p(K(t))$. (Elementary, using
%$p(K[t])=p(K(t))$ \cite{C}.)
%% epimorphism $A/(y^n) \onto A/\m^n$
%%ALT:
%%To show $p(A)\le m+1$, we can assume that $f$ is a sum of squares
%%in $A$, not a unit, and that $f$ is square-free. In particular,
%%$\root^{re}\of{(f)}\supset\m$. By \ref{reallynicequant}(c), it
%%suffices to show that $f$ is a sum of $m+1$ squares in $B:=
%%A/(f^2)$. Denote residue classes in $B$ by a bar. Choose $g\in\m$
%%such that $\sqrt{(f,g)}=\m$. There is $r\ge1$ such that $-\ol g^
%%{2r}$ is sos in $B$ (\ref{weakrealnss}). Let $h=f-g^{2r}$. Then
%%$\ol h$ is sos in $B$. Since $\ol B:=B/(\ol h^2)$ is an epimorphic
%%image of $A/\m^n$, $\ol B=A/(f^2,h^2)$, und $\sqrt(f^2,h^2)=\sqrt
%%(f,h)=\sqrt(f,g)=\m$ and hence of $k\lpow x\rpow\,[y]/(y^n)$, for
%%some $n$, it follows that the class of $\ol h$ in $\ol B$ is a sum
%%of $m$ squares. By \ref{reallynicequant}(c), $\ol h$ is a sum of
%%$m$ squares in $B$, which implies that $\ol f$ is a sum of $m+1$
%%squares in $B$, as desired.
%\end{proof}

\begin{proposition}\Label{pythpowser}
Let $A$ be a two-dimensional regular local ring, with residue
field~$k$. Then
$$1+\tau(k)\le p(k(t))\le\ol p(A)\le p\Bigl(k\llau x\rlau\,(y)\Bigr)
\le2\tau(k)\le2p(k(t))-2.$$
\end{proposition}

\begin{proof}
The first, fourth and fifth inequality follow from \ref{$p(k(t))$}
and \ref{tau}, while the second was shown in \ref{lowerbound}. For
the remaining inequality, we can assume that $A$ is complete. First
let $k$ be non-real. Then we have the chain of inequalities
$$\ol p(A)\le p(A)\le1+s(A)\le1+s(k)=p(k(t))\le\ol p(A),$$
from which $\ol p(A)=p(A)=1+s(k)=p\bigl(k\llau x\rlau\,(y)\bigr)$
follows. Now let $k$ be real, so we can assume $A=k\lpow x,y\rpow$.
From the series of ring epimorphisms
$$k\lpow x\rpow\,[y]\onto k\lpow x\rpow\,[y]/(y^n)=A/(y^n)\onto A/
\m^n,$$
it follows that $\ol p(A)\le p\bigl(k\lpow x\rpow\,[y]\bigr)$.
Moreover, $p(k\lpow x\rpow\,[y])=p\bigl(k\llau x\rlau\,(y)\bigr)$,
since $p(B[t])=p(K(t))$ holds for every DVR $B$ with real residue
field and with quotient field $K$. (This is elementary, using
$p(K[t])=p(K(t))$ \cite{C}.)
\end{proof}
\medbreak

Now here is the basic estimate for the Pythagoras number of a
two-dimensional factorial local ring:

\begin{proposition}\Label{upperbound}
Let $A$ be a two-dimensional factorial local ring.
\begin{itemize}
\item[\rm(a)]
If $f$ is a sum of squares in $A$, then $f$ is a sum of
$$p^1(A)\comp\bigl(1+p^1(A/f)\comp\ol p(A)\bigr)$$
squares.
\item[\rm(b)]
In particular, $p(A)\le p^1(A)\comp\bigl(1+p^1(A)\comp\ol p(A)
\bigr)\le p^1(A)\comp\bigl(1+p^1(A)\comp p(\wh A)\bigr)$.
\end{itemize}
\end{proposition}

Before we give the proof, here are two simple lemmas:

\begin{lemma}\Label{quitetriv}
If $A$ is a local ring with residue field $k$, then $p^*(A)\le p(k)
\comp p^1(A)$.
\end{lemma}

\begin{proof}
Any unit sum of squares $u$ can be written $u=vw$, where $v$ is a sum
of at most $p(k)$ squares and $w$ is a principal unit.
\end{proof}

\begin{lemma}\Label{modnilpot}
Let $A$ be a ring, let $I$ be an ideal of $A$ contained in the
nilradical of $A$, and let $u$ be a unit in $A$ which is a sum of $n$
squares in $A/I$. Then $u$ is a sum of $n$ squares in $A$. In
particular, $p^*(A)=p^*(A_\red)$.
\end{lemma}

\begin{proof}
We can assume that $I$ is nilpotent, and then, by induction, that
$I^2=0$.
% $I$ nilpotent: $u=\sum_ix_i^2+a$ mit $a\in I$, dann ersetze $I$
% durch $(a)$
Let $u=x_1^2+\cdots+x_n^2+a$ with $x_i\in A$ and $a\in I$. Since
$u\in A^*$, there are $y_1,\dots,y_n\in I$ with $a=2\sum_ix_iy_i$.
% denn $(x_1,...,x_n)=(1)$
It follows that $u=\sum_i(x_i+y_i)^2$.
\end{proof}
\medbreak

\noi\emph
{Proof} of Prop.\ \ref{upperbound}.
It is clear that (b) follows from (a). Let $f$ be a sum of squares in
$A$. Since $p^*(A)\le p^1(A)\comp p(k)$, where $k=A/\m$ (\ref
{quitetriv}), and since $p(k)\le\ol p(A)$, we can assume that $f$ is
not a unit. Write $f=gh^2$ where $h$ is a product of real prime
elements and $g$ is not divisible by any real prime element. Then $g$
is a sum of squares in $A$, and we can replace $f$ by $g$ since $p^1
(A/f\ge p^1(A/g)$.
% denn $(f) \subset (g)$
So assume $f\in\m$ and $\m\subset\root^{re}\of{(f)}$.
% if $A/\m$ is non-real, then $\root^{re}\of{(f)}=(1)$
Put $B=A/(f^2)$. By \ref{weakrealnss}, there is $g\in\m$ such that
$\sqrt{(f,g)}=\m$ and such that $-\bar g^2$ is sos in $B$. Put $\ol B
=B/(\bar f-\bar g^2)^2$. Then $\ol B$ is artinian, i.e., is an
epimorphic image of $A/\m^n$, for some $n$. So $\bar f-\bar g^2$ is a
sum of $\ol p(A)$ squares in $\ol B$. From \ref{reallynicequant}(b),
it follows that $\bar f-\bar g^2$ is a sum of $p^1(B)\comp\ol p(A)$
squares in $B$. Hence $\bar f$ is a sum of $1+p^1(B)\comp\ol p(A)$
squares in $B$. Again by \ref{reallynicequant}(b), $f$ is a sum of
$p^1(A)\comp\Bigl(1+p^1(B)\comp\ol p(A)\Bigr)$ squares in~$A$. By
\ref{modnilpot}, $p^1(B)=p^1(A/f)$.
\endproof

\begin{corollary}\Label{pbarcomplete}
Let $A$ be a two-dimensional complete regular local ring, with
residue field $k$.
\begin{itemize}
\item[\rm(a)]
$p(A)$ is either $\ol p(A)$ or $\ol p(A)+1$.
\item[\rm(b)]
If $k$ is non-real, then $p(A)=\ol p(A)=s(k)+1$.
\end{itemize}
\end{corollary}

\begin{proof}
$\ol p(A)\le p(A)$ is trivial, and $p(A)\le\ol p(A)+1$ follows from
\ref{upperbound}. Part (b) has already been shown in the proof of
\ref{pythpowser}.
\end{proof}

\begin{remark}\Label{h.p.}
In particular,
$$1+\tau(k)\le p(k(t))\le p(k\lpow x,y\rpow)\le1+p\bigl(k\llau x
\rlau\,(t)\bigr)\le1+2\tau(k)$$
for every field $k$. We wonder whether the inequality $p(k(t))\le
p\bigl(k\llau x\rlau\,(t)\bigr)$ can be strict.

A series of results on sums of squares in power series rings $B
\lpow x\rpow$, for suitable one-dimensional rings $B$, is contained
in \S5 of the paper \cite{CDLR} by Choi, Dai, Lam and Reznick.
Typically, $B$ is a discrete valuation ring, or a principal ideal
domain of finite type over a real closed field. Under various
conditions, the authors are able to show $p(B\lpow x\rpow)=2$.

In particular, they prove $p(k\lpow x,y\rpow)=2$ for any
hereditarily pythagorean field $k$ (Cor.\ 5.14). In the case $k=\R$,
this had been shown before by Bochnak and Risler \cite{BR}.
\end{remark}

We illustrate the use of Prop.\ \ref{upperbound} by three
applications. First, we consider two-dimensional regular local rings
of real algebraic varieties. So far, it was not known whether the
Pythagoras number of such a ring is finite
% in any case, ask Mah\'e!
(see \cite{CDLR} p.~64, where the finiteness question was raised).
We get the following result:

\begin{theorem}\Label{2dimlocringvar}
Let $R$ be a real closed field, and let $B$ be an integral, finitely
generated $R$-algebra of dimension~$d$. Let\/ $\frp$ be a prime ideal
in $B$ of height two, and put $A=B_\frp$. If $A$ is regular, of if
$A$ is factorial and the residue field of\/ $\frp$ is non-real, then
$p(A)\le2^d$.
\end{theorem}

\begin{proof}
Let $k(\frp)$ be the residue field of $\frp$. If $A$ is factorial
and $k(\frp)$ is non-real, then every sum of squares $f$ in $A$ can
be written $f=gh^2$ with $g,h\in A$ and $g$ totally positive, and
so the bound follows from Prop.\ \ref{mahe} in this case.

Assume that $A$ is regular. We know $p^*(A)\le2^d$ \cite{M}, and
$p^*(A/f)\le2^{d-1}$ for every $0\ne f\in A$ (same reference).
According to Pfister, $\tau(k(\frp))\le2^{d-2}$, and hence $\ol p
(A)\le2^{d-1}$ (\ref{pythpowser}c). From \ref{upperbound}(a), it
follows therefore that $p(A)\le2^d\comp(1+2^{d-1}\comp2^{d-1})=
2^d$.
\end{proof}

\begin{remark}
In the situation of the last theorem, it is known that $p(K)\le2^d$
for $K=\Quot(A)$ (Pfister), and no smaller bound is known. Therefore,
the bound in our theorem is the best one can reasonably expect. Since
$p(R(x,y))=4$ is known \cite{CEP}, it follows in particular that for
every maximal ideal $\m$ of $R[x,y]$, the local ring $R[x,y]_\m$ has
Pythagoras number equal to~$4$.
\end{remark}

%obsolete now!!
%emph{Question:}
%In the situation of (a) in the theorem, can it happen that $p(A)>
%2^d$? For example, if $V$ is a regular algebraic surface over $R$
%and $M$ is a real point on $V$, can $p(\calO_{V,M})$ be larger
%than~$4$?
%\medbreak

As a second application, we consider two-dimensional local rings of
arithmetic nature:

\begin{corollary}\Label{arithlocrings}
Let $A$ be a regular local ring of dimension two (containing $\frac
12$) whose quotient field is an $n$-dimensional function field over a
number field. If $n\ge3$, assume that Kato's cohomological Hasse
principle holds (see comment below). Then $p(A)\le2^{n+2}$.
\end{corollary}
% $A$ faktoriell (mit nichtreellem Restklassenkoerper) klappt deshalb
% nicht, weil ich, anders als bei den lokalen Ringen reeller
% Varietaeten, keine Schranke fuer $p^*(A)$ weiss!
%
% $n=0$ kommt naturlich nicht vor

\noi\emph
{Comment and proof.}
Let $F/\Q$ be a field extension of transcendence degree~$d$. It is
known that $p(F)\le4$ if $d=0$, $p(F)\le7$ if $d=1$ (see
Colliot-Th\'el\`ene's appendix to \cite{Ka}; the sharper bound $p(F)
\le6$ is contained in an unpublished preprint of Pop, according to
\cite{Pf2} p.~100), $p(F)\le8$ if $d=2$ \cite{CTJ} and $p(F)\le2^
{d+2}$ for any $d$. The last is an easy consequence of the Milnor
conjecture and of Pfister's classical theorems, see \cite{Pf3} pp.\
37--38. It is conjectured that the better bound $p(F)\le2^{d+1}$
holds for all $d\ge2$. This conjecture is known to be a consequence
of the Milnor conjecture and of Kato's (conjectural) Hasse principle
for Galois cohomology of degree $d+2$ of $F$ with coefficients
$\Z/2$; see \cite{CTJ}. The Milnor conjecture has been proved by
Voevodsky. Kato's Hasse principle was proved by Kato for $d=1$
\cite{Ka} and by Jannsen for $d=2$ \cite{J}. There is rumor that
Jannsen has proved it for all values of $d$, but this could not be
verified.
% We are still (!) optimistic that Jannsen will finally write up his
% stuff, and therefore assume Kato's local-global principle, as
% signaled in the formulation of the theorem.

Note that, in particular, $\tau(F)\le4$ if $d\le1$, and $\tau(F)\le
2^{d+1}$ if $d\ge1$ (if one assumes Kato's Hasse principle).
% H^{d+2}(F,Z/2) -->  \prod_v H^{d+2}(F_v,Z/2)  ist injektiv.
% Sei $F$ nicht reell. Die Klasse (-1)^{d+2} ist lokal Null, fuer
% d >= 1, denn an p-adischen Stellen ist schon {-1}^3=0, an reellen
% Stellen ist (-1)^{d+1}=0.
% Also folgt (-1)^{d+2}=0, was besagt: s(F) <= 2^{d+1}.
%
% Using the above bounds on $p(F)$, this can also be deduced from
% \ref{$p(k(t))$}; aber das waere aeusserst indirekt, denn genau
% obiges Argument wird ja schon benutzt, wenn man $p(F)$ mittels
% Katos HP abschaetzt.
\smallbreak

In the situation of the theorem, let $K=\Quot(A)$. Since $p^*(A)\le
p(K)$ (Ojanguren \cite{O}), we get (using Kato's Hasse principle)
$p^*(A)\le7$ if $n=1$ and $p^*(A)\le2^{n+1}$ if $n\ge2$. On the other
hand, if the residue field $k$ of $A$ has characteristic~$0$, it has
transcendence degree $n-2$ over $\Q$. From $\ol p(A)\le2\tau(k)$
(\ref{pythpowser}), it follows therefore that $\ol p(A)\le8$ if $n=2$
and $\ol p(A)\le2^n$ if $n\ge3$. If $\ch(k)>0$ (this will always be
the case for $n=1$), then $\ol p(A)=1+s(k)\le3$ (\ref{pbarcomplete}).
In any case, $\ol p(A)\le2^{n+1}$ for $n\ge2$.

For $n\ge2$, the assertion follows now from Prop.\ \ref{upperbound}:
$p(A)\le2^{n+1}\comp(1+2^{n+1}\comp2^{n+1})=2^{n+2}$. If $n=1$, then
$\ch(k)>0$, and therefore $p(A)=p^\plus(A)\le p^*(A)\comp(1+p^*(A))$
(\ref{totposquant}), which gives $p(A)\le7\comp(1+7)=8$.
\endproof
\medbreak

If we do not assume Kato's Hasse principle for $n\ge3$, we get the
weaker bound $p(A)\le2^{n+3}$ for $n\ge3$.
\smallbreak

Our final main result gives, in particular, a complete answer to
Problem~5 from the list of open problems in \cite{CDLR} (\S9, p.~80).
This problem asked whether part~(a) of the following theorem is true:

\begin{theorem}\Label{cdlrquest}
Let $A$ be a regular local two-dimensional domain, and let $K$ be its
quotient field.
\begin{itemize}
\item[\rm(a)]
If $p(K)$ is finite, then also $p(A)$ is finite.
\item[\rm(b)]
More precisely, if\/ $2^r$ is the smallest $2$-power $\ge p(K)$, then
% $r\ge1$, nach \ref{lowerbound}
$p(A)\le2^{r+1}$. In particular, we always have $p(A)\le4p(K)-4$.
\end{itemize}
\end{theorem}

\begin{proof}
$p^*(A)\le p(K)\le2^r$, according to Ojanguren \cite{O}.
% Thm.~1, p.~292
%
% Then $u$ is a sum of $2^r$ squares in $K$. Since the homomorphism
% $W(A)\to W(K)$ is injective (Ojanguren \cite{O} if $A$ is
% essentially of finite type over a field; Ojanguren and Pardon
% independently for the general case? see Knus p.~472; clear it up!),
% $u$ is also a sum of $2^r$ squares in $A$. So $p^*(A)\le2^r$.
On the other hand, let $k$ be the residue field of $A$. Then $p(k(t))
\le p(K)\le2^r$ (\ref{lowerbound}), so $\tau(k)\le2^{r-1}$ (\ref
{$p(k(t))$}), and so $\ol p(A)\le2\tau(k)\le2^r$ (\ref{pythpowser}).
By \ref{upperbound}, therefore, $p(A)\le2^r\comp(1+2^r\comp2^r)=2^
{r+1}$.
\end{proof}

In the situation of Cor.\ \ref{arithlocrings}, note that the bound
obtained there is just a particular case of the general bound in the
last theorem, if $n\ge2$ (but not if $n=1$).

\vfill\break

%====================================================================


\begin{thebibliography}{28}

\bibitem{Ba}
R.~Baeza: \emph{Quadratic Forms over Semilocal Rings}. Lect.\ Notes
Math.\ {\bf655}, Springer, Berlin 1978.

\bibitem{BCR}
J.~Bochnak, M.~Coste, M.-F.~Roy: \emph{Real Algebraic Geometry}.
Erg.\ Math.\ Grenzgeb.\ (3) {\bf36}, Springer, Berlin, 1998.

\bibitem{BR}
J.~Bochnak, J.-J.~Risler: Le th\'eor\`eme des z\'eros pour les
vari\'et\'es analytiques r\'eelles de dimension~$2$. Ann.\ sci.\
\'Ec.\ Norm.\ Sup.\ (4) {\bf8}, 353--364 (1975).

\bibitem{Bou1}
M.~Bourbaki: \emph{Alg\`ebre Commutative}. Chapitres 1 \`a 4. Masson,
Paris, 1985.

\bibitem{Bou}
M.~Bourbaki: \emph{Alg\`ebre Commutative}. Chapitres 8 et 9. Masson,
Paris, 1983.

\bibitem{CRz}
A.~Campillo, J.~M.~Ruiz: Some remarks on pythagorean real curve
germs. J.~Algebra {\bf128}, 271--275 (1990).

\bibitem C
J.~W.~S.\ Cassels: On the representation of rational functions as
sums of squares. Acta arith.\ {\bf9}, 79--82 (1964).

\bibitem{CEP}
J.~W.~S. Cassels, W.~J. Ellison, A. Pfister: On sums of squares
and on elliptic curves over function fields. J.~Number Theory {\bf3},
125--149 (1971).

\bibitem{CDLR}
M.~D.~Choi, Z.~D.~Dai, T.~Y.~Lam, B.~Reznick: The Pythagoras number
of some affine algebras and local algebras. J.~reine angew.\ Math.\
{\bf336}, 45--82 (1982).

%\bibitem{CLR}
%M.~D.~Choi, T.~Y.~Lam, B.~Reznick: Even symmetric sextics. Math.\ Z.
%{\bf195}, 559-580 (1987).

\bibitem{CLRR}
M.~D.~Choi, T.~Y.~Lam, B.~Reznick, A.~Rosenberg: Sums of squares in
some integral domains. J.~Algebra {\bf65}, 234--256 (1980).

\bibitem{CTJ}
J.-L.~Colliot-Th\'el\`ene, U.~Jannsen: Sommes de carr\'es dans les
corps des fonctions. C.~R. Acad.\ Sci.\ Paris {\bf312}, S\'er.~I,
759--762 (1991).

\bibitem{CR}
M.~Coste, M.-F.~Roy: La topologie du spectre r\'eel. In: \emph
{Ordered Fields and Real Algebraic Geometry} (San Francisco 1981),
D.~W.\ Dubois, T.~Recio (eds.), Contemp.\ Math.\ {\bf8}, Providence,
RI, 1982, pp.\ 27--59.

\bibitem J
U.~Jannsen: Principe de Hasse cohomologique. In: S\'eminaire de
Th\'eorie des Nombres, Paris, 1989-1990, ed.\ S.~David, Progress
in Mathematics {\bf102}, Birkh\"auser, Boston, 1992, pp.\ 121--140.

\bibitem{Ka}
K.~Kato: A Hasse principle for two-dimensional global fields.
J.~reine angew.\ Math.\ {\bf366}, 142--183 (1986).

\bibitem{KRW}
M.~Knebusch, A.~Rosenberg, R.~Ware: Signatures on semilocal rings.
J.~Algebra {\bf1973}, 208--250 (1973).

\bibitem{KS}
M.~Knebusch, C.~Scheiderer: \emph{Einf\"uhrung in die reelle
Algebra}. Vieweg, Wiesbaden, 1989.

\bibitem L
T.~Y.~Lam: \emph{The Algebraic Theory of Quadratic Forms}. Benjamin,
Reading, Mass., 1973.

\bibitem M
L.~Mah\'e: Level and Pythagoras number of some geometric rings.
Math.~Z. {\bf204}, 615-629 (1990); Erratum, ibid.\ {\bf209}, 481--483
(1992).

\bibitem{Mat}
H.~Matsumura: \emph{Commutative ring theory}. Cambridge University
Press, Cambridge, 1986.

\bibitem O
M.~Ojanguren: Unit\'es represent\'ees par des formes quadratiques ou
par des normes r\'eduites. In: \emph{Algebraic $K$-Theory}, Part~II,
K.~R. Dennis (ed.), Proc.\ Oberwolfach 1980, Lect.\ Notes Math.\
{\bf967}, Springer, Berlin, 1987, pp.\ 291--299.

%Quadratic forms over regular rings. J.~Indian Math.\
%Soc.\ {\bf44}, 109-116 (1980).

\bibitem{Or}
J.~J. Ortega: On the Pythagoras number of a real irreducible
algebroid curve. Math.\ Ann.\ {\bf289}, 111--123 (1991).

\bibitem{Pf1}
A.~Pfister: Zur Darstellung definiter Funktionen als Summe von
Quadraten. Invent.\ math.\ {\bf4}, 229--237 (1967).

\bibitem{Pf2}
A.~Pfister: \emph{Quadratic Forms with Applications to Algebraic
Geometry and Topology}. London Math.\ Soc.\ Lect.\ Notes {\bf217},
Cambridge University Press, Cambridge, 1995.

\bibitem{Pf3}
A.~Pfister: On the Milnor conjectures: History, influence,
applications. Jber.\ Dt.\ Math.-Verein.\ {\bf102}, 15--41 (2000).

%\bibitem{PC}
%S.~Prie\ss-Crampe: Angeordnete Strukturen

%\bibitem R
%M.~Raynaud: \emph{Anneaux Locaux Hens\'eliens}. Lect.\ Notes Math.\
%{\bf169}, Springer, Berlin, 1970.

\bibitem{Rz0}
J.~M.~Ruiz: Pythagorean real curve germs. J.~Algebra {\bf94},
126--144 (1985).

\bibitem{Rz}
J.~M.~Ruiz: C\^ones locaux et compl\'etions. C.~R. Acad.\ Sc.\ Paris
{\bf302}, s\'er.~I, 67--69 (1986).

%\bibitem{Rz1}
%J.~M.~Ruiz: On Hilbert's 17th problem and real Nullstellensatz for
%global analytic functions. Math.\ Z. {\bf190}, 447--454 (1985).

\bibitem{Rz2}
J.~M.~Ruiz: Sums of two squares in analytic rings. Math.\ Z. {\bf
230}, 317--328 (1999).

\bibitem S
C.~Scheiderer: Sums of squares of regular functions on real algebraic
varieties. Trans.\ Am.\ Math.\ Soc.\ {\bf352}, 1039--1069 (1999).

\end{thebibliography}
\end{document}
