
% Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     - Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     - Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the
%       distribution.
%
%     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES-- LOSS OF USE, DATA, OR
% PROFITS-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


The \spadtype{SquareFreeRegularTriangularSet} domain constructor implements
square-free regular triangular sets.
See the \spadtype{RegularTriangularSet} domain constructor
for general regular triangular sets.
Let {\em T} be a regular triangular set consisting of polynomials
{\em t1, ..., tm} ordered by increasing main variables.
The regular triangular set {\em T} is square-free if {\em T}
is empty or if {\em t1, ..., tm-1} is square-free  and if
the polynomial {\em tm} is square-free as
a univariate polynomial with coefficients in the tower
of simple extensions associated with {\em t1, ..., tm-1}.

The main interest of square-free regular triangular sets
is that their associated towers of simple extensions
are product of fields.
Consequently, the saturated ideal of a square-free regular triangular set
is radical.
This property simplifies some of the operations related
to regular triangular sets.
However, building square-free regular triangular sets
is generally more  expensive than building
general regular triangular sets.

As the \spadtype{RegularTriangularSet} domain constructor,
the \spadtype{SquareFreeRegularTriangularSet} domain constructor also implements
a method for solving polynomial systems by means of regular triangular sets.
This is in fact the same method with some adaptations to take into
account the fact that the computed regular chains are square-free.
Note that it is also possible to pass from a decomposition
into general regular triangular sets to a decomposition into
square-free regular triangular sets.
This conversion is used internally by the
\spadtype{LazardSetSolvingPackage} package constructor.

{\bf N.B.} When solving polynomial systems with the
\spadtype{SquareFreeRegularTriangularSet} domain constructor
or the \spadtype{LazardSetSolvingPackage} package constructor,
decompositions have no redundant components.
See also \spadtype{LexTriangularPackage} and \spadtype{ZeroDimensionalSolvePackage} for the case of
algebraic systems with a finite number of (complex) solutions.

We shall explain now how to use the constructor \spadtype{SquareFreeRegularTriangularSet}.

This constructor takes four arguments.
The first one, {\bf R}, is the coefficient ring of the polynomials;
it must belong to the category \spadtype{GcdDomain}.
The second one, {\bf E}, is the exponent monoid of the polynomials;
it must belong to the category \spadtype{OrderedAbelianMonoidSup}.
the third one, {\bf V}, is the ordered set of variables;
it must belong to the category \spadtype{OrderedSet}.
The last one is the polynomial ring;
it must belong to the category \spadtype{RecursivePolynomialCategory(R,E,V)}.
The abbreviation for \spadtype{SquareFreeRegularTriangularSet} is
\spadtype{SREGSET}.

Note that the way of understanding triangular decompositions
is detailed in the example of the \spadtype{RegularTriangularSet}
constructor.

\xtc{
Let us illustrate the use of this constructor with one example (Donati-Traverso).
Define the coefficient ring.
}{
\spadcommand{R := Integer \bound{R}}
}
\xtc{
Define the list of variables,
}{
\spadcommand{ls : List Symbol := [x,y,z,t] \bound{ls}}
}
\xtc{
and make it an ordered set;
}{
\spadcommand{V := OVAR(ls) \free{ls} \bound{V}}
}
\xtc{
then define the exponent monoid.
}{
\spadcommand{E := IndexedExponents V \free{V} \bound{E}}
}
\xtc{
Define the polynomial ring.
}{
\spadcommand{P := NSMP(R, V) \free{R} \free{V} \bound{P}}
}
\xtc{
Let the variables be polynomial.
}{
\spadcommand{x: P := 'x \free{P} \bound{x}}
}
\xtc{
}{
\spadcommand{y: P := 'y \free{P} \bound{y}}
}
\xtc{
}{
\spadcommand{z: P := 'z \free{P} \bound{z}}
}
\xtc{
}{
\spadcommand{t: P := 't \free{P} \bound{t}}
}
\xtc{
Now call the \spadtype{SquareFreeRegularTriangularSet} domain constructor.
}{
\spadcommand{ST := SREGSET(R,E,V,P) \free{R} \free{E} \free{V} \free{P} \bound{ST} }
}
\xtc{
Define a polynomial system.
}{
\spadcommand{p1 := x ^ 31 - x ^ 6 - x - y \free{x} \free{y} \bound{p1}}
}
\xtc{
}{
\spadcommand{p2 := x ^ 8  - z \free{x} \free{z} \bound{p2}}
}
\xtc{
}{
\spadcommand{p3 := x ^ 10 - t \free{x} \free{t} \bound{p3}}
}
\xtc{
}{
\spadcommand{lp := [p1, p2, p3] \free{p1} \free{p2} \free{p3} \bound{lp}}
}

\xtc{
First of all, let us solve this system in the sense of Kalkbrener.
}{
\spadcommand{zeroSetSplit(lp)$ST \free{lp} \free{ST}}
}
\xtc{
And now in the sense of Lazard (or Wu and other authors).
}{
\spadcommand{zeroSetSplit(lp,false)$ST \free{lp} \free{ST} \bound{lts}}
}

Now to see the difference with the \spadtype{RegularTriangularSet} domain constructor,
\xtc{
we define:
}{
\spadcommand{T := REGSET(R,E,V,P) \free{R} \free{E} \free{V} \free{P} \bound{T} }
}
\xtc{
and compute:
}{
\spadcommand{lts := zeroSetSplit(lp,false)$T \free{lp} \free{T} \bound{lts}}
}
If you look at the second set in both decompositions in the sense of Lazard,
you will see that the polynomial with main variable {\bf y} is not the same.

Let us understand what has happened.
\xtc{
We define:
}{
\spadcommand{ts := lts.2  \free{lts}  \bound{ts}}
}
\xtc{
}{
\spadcommand{pol := select(ts,'y)$T \free{ts} \free{y} \free{T} \bound{pol}}
}
\xtc{
}{
\spadcommand{tower := collectUnder(ts,'y)$T \free{ts} \free{y} \free{T} \bound{tower}}
}
\xtc{
}{
\spadcommand{pack := RegularTriangularSetGcdPackage(R,E,V,P,T) \free{R} \free{E} \free{V} \free{P} \free{T} \bound{pack}}
}
\xtc{
Then we compute:
}{
\spadcommand{toseSquareFreePart(pol,tower)$pack \free{pol} \free{tower} \free{pack}}
}
