Difference between revisions of "Package sagbi"

From ApCoCoAWiki
m (Andraschko moved page Package SAGBI to Package sagbi)
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page is about the SAGBI package. For a function list see [[:Category:Package SAGBI]].
+
{{Version|2|[[:Category:ApCoCoA-1:Package sagbi]]}}
 +
This page is about the SAGBI package. For a complete function list, see [[:Category:Package sagbi]].
  
[[Category:Package SAGBI]]
+
== Mathematical Definitions ==
 +
Let <math>K</math> be a field and let <math>P = K[x_1,\ldots,x_n]</math> be the polynomial ring over <math>K</math> in <math>n</math> indeterminates. Most of the definitions here are taken from the book [https://staff.fim.uni-passau.de/kreuzer/cabook2/CCA2.html Computational Commutative Algebra 2] by Martin Kreuzer and Lorenzo Robbiano.
 +
 
 +
=== Subalgebras ===
 +
A subset <math>S \subseteq P</math> is called a <math>K</math>-'''subalgebra''' of <math>P</math>, if
 +
*<math>K \subseteq S</math> and
 +
*<math>S</math> is closed under addition and multiplication.
 +
For a subset <math>F = \{f_1,\ldots,f_s\} \subseteq P</math>, we write
 +
:<math>K[F] = K[f_1,\ldots,f_s] = \{p(f_1,\ldots,f_s) \mid p \in K[y_1,\ldots,y_s]\}</math>
 +
where <math>K[y_1,\ldots,y_s]</math> is a new polynomial ring in <math>s</math> indeterminates for the '''<math>K</math>-subalgebra of <math>P</math> generated by <math>F</math>'''.
 +
 
 +
=== SAGBI bases ===
 +
Let <math>\sigma</math> be a [[HowTo:Term Orderings|term ordering]] on <math>P</math> and let <math>S</math> be a <math>K</math>-subalgebra of <math>P</math>. A set <math>G \subseteq S</math> is called a <math>\sigma</math>-SAGBI basis of <math>S</math> if <math>K[{\rm LT}_\sigma(f) \mid f \in S] = K[{\rm LT}_\sigma(f) \mid f \in G]</math>.
 +
 
 +
If <math>S</math> is a [[HowTo:Gradings|graded subalgebra]] and <math>d \in \mathbb{N}</math>, then a set <math>G_{\leq d}</math> is called a '''<math>d</math>-truncated <math>\sigma</math>-SAGBI basis of <math>S</math>''', if
 +
:<math>K[{\rm LT}_\sigma(f) \mid f \in S \text{ and } \deg(f) \leq d] = K[{\rm LT}_\sigma(f) \mid f \in G_{\leq d}].</math>
 +
Equivalently, a set <math>G_{\leq d}</math> is a <math>d</math>-truncated <math>\sigma</math>-SAGBI basis of <math>S</math> if there is a <math>\sigma</math>-SAGBI basis of <math>S</math> with <math>G_{\leq d} = \{g \in G \mid \deg(g) \leq d\}</math>.
 +
 
 +
=== The Subalgebra Rewrite Relation ===
 +
Let <math>G \subseteq P</math> be a set of non-zero polynomials. Furthermore, let <math>\sigma</math> be a term ordering on <math>\mathbb{T}^n</math>.
 +
* For <math>f, g \in P \setminus \{0\}</math>, we say that <math>f</math> '''subalgebra reduces to <math>g</math> in one step''' if there are <math>f_1,\ldots,f_s \in G</math>, a term <math>t \in \mathbb{T}^s</math>, and a constant <math>c \in K</math> such that <math>g = f - c t(f_1,\ldots,f_s)</math> and <math>{\rm LT}_\sigma(t(f_1,\ldots,f_s))</math> is not anymore in <math>{\operatorname{Supp}}(g)</math>. The path from <math>f</math> to <math>g</math> is then called a '''subalgebra reduction step''' and denoted by <math>f {\xrightarrow{G}}_{\rm ss} g</math>.
 +
* The transitive closure of the relation <math>{\xrightarrow{G}}_{\rm ss}</math> is denoted by <math>{\xrightarrow{G}}_{\rm s}</math> and called the '''subalgebra rewrite relation''' defined by <math>G</math>. If there are <math>f, g \in P</math> with <math>f {\xrightarrow{G}}_{\rm s} g</math>, we say that <math>f</math> '''subalgebra reduces''' to <math>g</math>.
 +
* If <math>g \in P</math> such that there is no <math>h \in P</math> with <math>h \neq g</math> and <math>g {\xrightarrow{G}}_{\rm ss} h</math>, then <math>g</math> is called '''irreducible''' with respect to the relation <math>{\xrightarrow{G}}_{\rm s}</math>. Sometimes we may also just write that <math>g</math> is irreducible with respect to <math>G</math>.
 +
A set <math>G \subseteq P</math> is called '''interreduced''' if every element <math>g \in G</math> is monic and irreducible with respect to <math>G \setminus \{g\}</math>. If <math>G</math> is a <math>\sigma</math>-SAGBI basis of <math>K[G]</math> which is interreduced, then it is called a '''reduced <math>\sigma</math>-SAGBI basis'''. Analogously to reduced Gröbner bases, it can be shown that every <math>K</math>-subalgebra has a unique reduced <math>\sigma</math>-SAGBI basis.
 +
 
 +
=== The Subalgebra Division Algorithm ===
 +
Let <math>\sigma</math> be a term ordering on <math>\mathbb{T}^n</math>, <math>f \in P</math> and <math>G = \{f_1,\ldots,f_s\} \subseteq P</math> be a set of non-zero polynomials. Consider the following sequence of instructions.
 +
# Set <math>g := f</math>.
 +
# Write <math>g = c_1t_1 + \cdots + c_m t_m</math> with <math>t_i \in \mathbb{T}^n</math>, <math>c_i \in K</math> for <math>i = 1,\ldots,m</math>, and <math>t_1 \geq_\sigma \cdots \geq_\sigma t_m</math>. Set <math>k := 1</math>.
 +
# If <math>k = m+1</math>, stop and return <math>g</math>. Otherwise, check whether there is a term <math>t \in \mathbb{T}^s</math> such that <math>t_k = t({\rm LT}_\sigma(f_1),\ldots,{\rm LT}_\sigma(f_s))</math>. If there is one, set <math>c = t({\rm LC}_\sigma(f_1),\ldots,{\rm LC}_\sigma(f_s))</math>, replace <math>g</math> by <math>g - \frac{c_i}{c} t(f_1,\ldots,f_s)</math> and go to step~(2). If there is none, increase <math>k</math> by one and repeat this step.
 +
This is an algorithm which returns a polynomial <math>g \in P</math> such that <math>f {\xrightarrow{G}}_{\rm s} g</math> and <math>g</math> is irreducible with respect to <math>{\xrightarrow{G}}_{\rm s}</math>.
 +
This algorithm clearly computes a polynomial <math>g \in P</math> with <math>f {\xrightarrow{G}}_{\rm s} g</math> and <math>g</math> is irreducible with respect to <math>G</math>.
 +
 
 +
== Package Description ==
 +
All of the previously described definitions are implemented in the SAGBI package.
 +
 
 +
=== Basic functions ===
 +
Given a polynomial ring <code>P</code> and a list <code>F</code> of polynomials in <code>P</code>, one can compute the reduced SAGBI basis of <math>K</math>[<code>F</code>] (with respect to the term ordering given by <code>P</code>) using the function [[/SB.SAGBI/]] - as long as a finite one exists.
 +
<pre>
 +
SB.SAGBI(F);
 +
</pre>
 +
Note that this function probably runs into an infinite loop if no finite SAGBI basis exists. This can be avoided using the function [[/SB.SAGBITimeout/]]. Given a positive integer <code>s</code>, one can type in
 +
<pre>
 +
SB.SAGBITimeout(F,s);
 +
</pre>
 +
which does the same as <code>SB.SAGBI(F)</code>, but throws an error if the computation is not finished within <code>s</code> seconds.
 +
Given a polynomial <code>f</code> and a list of polynomials <code>G</code>, the function [[/SB.ReductionStep/]] can be used to compute a polynomial <code>g</code> with <code>f</code><math>{\xrightarrow{G}}_{\rm s}</math><code>g</code>.
 +
<pre>
 +
SB.ReductionStep(f,G);
 +
</pre>
 +
If no such polynomial exists, then <code>f</code> is returned. This function is then used by the function [[/SB.SDA/]], which is an implementation of the Subalgebra Division Algorithm described above.
 +
<pre>SB.SDA(f,G)</pre>
 +
Analogously to the CoCoA-5 function <code>interreduced</code>, the SAGBI package contains the function [[/SB.Interreduced/]] which takes as input a list of polynomials <code>G</code> and returns a list <code>G'</code> with <math>K[G] = K[G']</math>.
 +
<pre>
 +
SB.Interreduced(G);
 +
</pre>
 +
 
 +
=== Special Functions for Graded Subalgebras ===
 +
If <code>G</code> is a set of [[HowTo:Gradings|homogeneous]] polynomials, then there are additional functions one can use. Given a positive integer<code>d</code>, a <code>d</code>-truncated SAGBI basis can be computed using [[/SB.TruncSAGBI/]].
 +
<pre>
 +
SB.TruncSAGBI(G,d);
 +
</pre>
 +
If additionally, the Hilbert series <code>HS</code> of the subalgebra <math>K[G]</math> is given, one can call
 +
<pre>
 +
SB.TruncSAGBI(G,d,HS);
 +
</pre>
 +
which does the same as above, but computes the SAGBI basis Hilbert-driven, which may be a little bit faster.
 +
The function [[/SB.SubalgebraHS/]] can be applied to compute the Hilbert series of a graded subalgebra.
 +
<pre>
 +
SB.SubalgebraHS(G);
 +
</pre>
 +
If furthermore <code>G</code> is a set of terms, then the function
 +
<pre>
 +
SB.TorRingHS(G);
 +
</pre>
 +
can be used to compute its Hilbert series much more efficient.
 +
 
 +
=== The Subalgebra Data Type ===
 +
The package also introduces a new ''Data type'', i.e. a record tagged with <code>"$apcocoa/sagbi.Subalgebra"</code>. Given a polynomial ring <code>P</code> and a list of polynomials <code>G</code> from <code>P</code>, one can create the subalgebra <math>K[G]</math> using the function [[/SB.Subalgebra/]].
 +
<pre>
 +
Use P ::= QQ[x,y,z];
 +
G := [x^2+y*z,z];
 +
S := SB.Subalgebra(P,G);
 +
</pre>
 +
For details about the structure of this data type, see the function page.
 +
While nearly all functionalities of the SAGBI package can be used without touching this data type, it has many advantages to do so because it stores informations of previous computations, see the example below. This is also the reason why many of the getter functions need the subalgebra to be called by reference.
 +
The following getter function can be used to get informations about the subalgebra:
 +
[[/SB.GetCoeffRing/]](S); -- returns the coefficient ring
 +
[[/SB.GetGens/]](S); -- returns the set G
 +
[[/SB.GetID/]](S); -- returns the unique ID of S
 +
[[/SB.GetLTSA/]](ref S); -- returns the subalgebra K[LT(f) | f in S]
 +
[[/SB.GetRing/]](S); -- returns P
 +
[[/SB.GetSAGBI/]](ref S); -- returns the reduced SAGBI basis of S (if a finite one exists)
 +
 
 +
If additionally, <code>G</code> is a set of homogeneous polynomials, one can call the following getter functions:
 +
[[/SB.GetHS/]](ref S); -- returns the Hilbert Series of S
 +
[[/SB.GetTruncSAGBI/]](ref S,d); -- returns a d-truncated SAGBI basis of S
 +
[[/SB.GetTruncDeg/]](S); -- returns the truncation degree of the currently stored SAGBI basis
 +
To optain a <math>K</math>-vector space basis of the set <math>K[G]_d</math> of all homogeneous polynomials of degree <math>d</math> in <math>K[G]</math>, the function [[/SB.GetInDeg/]] can be used:
 +
[[/SB.GetInDeg/]](S);
 +
 
 +
=== Testing Subalgebra Membership ===
 +
Let <code>f</code> be a polynomial in the polynomial ring <code>P</code>, let <code>G</code> be a list of polynomials in <code>P</code> and let <code>S</code> be a subalgebra generated by <code>G</code>. Then the SAGBI package provides four functions to check whether <code>f</code> is an element of the subalgebra <code>S</code>:
 +
[[/SB.IsInSubalgebra/]](f,G);
 +
[[/SB.IsInSA/]](f,S);
 +
If <code>G</code> is a list of homogeneous polynomials, the following functions can also be used:
 +
[[/SB.IsInSubalgebra_SAGBI/]](f,G);
 +
[[/SB.IsInSA_SAGBI/]](f,ref S);
 +
While the first two functions test the membership using implicitization, these two functions use truncated SAGBI bases for the membership test, which ''may'' be more efficient. It depends on the application which of these two possibilities is the fastest one.
 +
 
 +
=== Example for the Subalgebra Data Type ===
 +
So what advantages does the Subalgebra data type have? Consider the following example.
 +
<pre>
 +
Use P ::= QQ[x,y,z];
 +
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
 +
L := SB.SAGBI(G);
 +
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
 +
b := SB.IsInSubalgebra(f,G);
 +
h := SB.SubalgebraHS(G);
 +
</pre>
 +
Here, first a SAGBI basis is computed, then the subalgebra membership is tested using implicitization and at the end, the Hilbert series of <code>K[G]</code> is computed. But after computing a SAGBI basis, one could also test the Subalgebra membership using the Subalgebra Division Algorithm and compute the Hilbert Series of . The Subalgebra data type does this automatically. Instead of the code above, we can write the following:
 +
<pre>
 +
Use P ::= QQ[x,y,z];
 +
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
 +
S := SB.Subalgebra(P,G);
 +
L := SB.GetSAGBI(ref S);
 +
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
 +
b := SB.IsInSA(f,ref S);
 +
h := SB.GetHS(ref S);
 +
</pre>
 +
While this is only a simple example, the second code is much faster. At the time this is written, the second computation is approximately two times as fast as the first one.
 +
 
 +
[[Category:Package sagbi]]
 +
[[Category:ApCoCoA Packages]]

Latest revision as of 20:21, 8 November 2020

This article is about a function from ApCoCoA-2. If you are looking for the ApCoCoA-1 version of it, see Category:ApCoCoA-1:Package sagbi.

This page is about the SAGBI package. For a complete function list, see Category:Package sagbi.

Mathematical Definitions

Let Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle K} be a field and let be the polynomial ring over Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle K} in indeterminates. Most of the definitions here are taken from the book Computational Commutative Algebra 2 by Martin Kreuzer and Lorenzo Robbiano.

Subalgebras

A subset is called a -subalgebra of , if

  • and
  • is closed under addition and multiplication.

For a subset , we write

where is a new polynomial ring in indeterminates for the -subalgebra of generated by .

SAGBI bases

Let be a term ordering on and let be a -subalgebra of . A set is called a -SAGBI basis of if .

If is a graded subalgebra and , then a set is called a -truncated -SAGBI basis of , if

Equivalently, a set is a -truncated -SAGBI basis of if there is a -SAGBI basis of with .

The Subalgebra Rewrite Relation

Let be a set of non-zero polynomials. Furthermore, let be a term ordering on .

  • For , we say that subalgebra reduces to in one step if there are , a term , and a constant such that and is not anymore in . The path from to is then called a subalgebra reduction step and denoted by .
  • The transitive closure of the relation is denoted by and called the subalgebra rewrite relation defined by . If there are with , we say that subalgebra reduces to .
  • If such that there is no with and , then is called irreducible with respect to the relation . Sometimes we may also just write that is irreducible with respect to .

A set is called interreduced if every element is monic and irreducible with respect to . If is a -SAGBI basis of which is interreduced, then it is called a reduced -SAGBI basis. Analogously to reduced Gröbner bases, it can be shown that every -subalgebra has a unique reduced -SAGBI basis.

The Subalgebra Division Algorithm

Let be a term ordering on , and be a set of non-zero polynomials. Consider the following sequence of instructions.

  1. Set .
  2. Write with , for , and . Set .
  3. If , stop and return . Otherwise, check whether there is a term such that . If there is one, set , replace by and go to step~(2). If there is none, increase by one and repeat this step.

This is an algorithm which returns a polynomial such that and is irreducible with respect to . This algorithm clearly computes a polynomial with and is irreducible with respect to .

Package Description

All of the previously described definitions are implemented in the SAGBI package.

Basic functions

Given a polynomial ring P and a list F of polynomials in P, one can compute the reduced SAGBI basis of [F] (with respect to the term ordering given by P) using the function SB.SAGBI - as long as a finite one exists.

SB.SAGBI(F);

Note that this function probably runs into an infinite loop if no finite SAGBI basis exists. This can be avoided using the function SB.SAGBITimeout. Given a positive integer s, one can type in

SB.SAGBITimeout(F,s);

which does the same as SB.SAGBI(F), but throws an error if the computation is not finished within s seconds. Given a polynomial f and a list of polynomials G, the function SB.ReductionStep can be used to compute a polynomial g with fg.

SB.ReductionStep(f,G);

If no such polynomial exists, then f is returned. This function is then used by the function SB.SDA, which is an implementation of the Subalgebra Division Algorithm described above.

SB.SDA(f,G)

Analogously to the CoCoA-5 function interreduced, the SAGBI package contains the function SB.Interreduced which takes as input a list of polynomials G and returns a list G' with .

SB.Interreduced(G);

Special Functions for Graded Subalgebras

If G is a set of homogeneous polynomials, then there are additional functions one can use. Given a positive integerd, a d-truncated SAGBI basis can be computed using SB.TruncSAGBI.

SB.TruncSAGBI(G,d);

If additionally, the Hilbert series HS of the subalgebra is given, one can call

SB.TruncSAGBI(G,d,HS);

which does the same as above, but computes the SAGBI basis Hilbert-driven, which may be a little bit faster. The function SB.SubalgebraHS can be applied to compute the Hilbert series of a graded subalgebra.

SB.SubalgebraHS(G);

If furthermore G is a set of terms, then the function

SB.TorRingHS(G);

can be used to compute its Hilbert series much more efficient.

The Subalgebra Data Type

The package also introduces a new Data type, i.e. a record tagged with "$apcocoa/sagbi.Subalgebra". Given a polynomial ring P and a list of polynomials G from P, one can create the subalgebra using the function SB.Subalgebra.

Use P ::= QQ[x,y,z];
G := [x^2+y*z,z];
S := SB.Subalgebra(P,G);

For details about the structure of this data type, see the function page. While nearly all functionalities of the SAGBI package can be used without touching this data type, it has many advantages to do so because it stores informations of previous computations, see the example below. This is also the reason why many of the getter functions need the subalgebra to be called by reference. The following getter function can be used to get informations about the subalgebra:

SB.GetCoeffRing(S); -- returns the coefficient ring
SB.GetGens(S); -- returns the set G
SB.GetID(S); -- returns the unique ID of S
SB.GetLTSA(ref S); -- returns the subalgebra K[LT(f) | f in S]
SB.GetRing(S); -- returns P
SB.GetSAGBI(ref S); -- returns the reduced SAGBI basis of S (if a finite one exists)

If additionally, G is a set of homogeneous polynomials, one can call the following getter functions:

SB.GetHS(ref S); -- returns the Hilbert Series of S
SB.GetTruncSAGBI(ref S,d); -- returns a d-truncated SAGBI basis of S
SB.GetTruncDeg(S); -- returns the truncation degree of the currently stored SAGBI basis

To optain a -vector space basis of the set of all homogeneous polynomials of degree in , the function SB.GetInDeg can be used:

SB.GetInDeg(S);

Testing Subalgebra Membership

Let f be a polynomial in the polynomial ring P, let G be a list of polynomials in P and let S be a subalgebra generated by G. Then the SAGBI package provides four functions to check whether f is an element of the subalgebra S:

SB.IsInSubalgebra(f,G);
SB.IsInSA(f,S);

If G is a list of homogeneous polynomials, the following functions can also be used:

SB.IsInSubalgebra_SAGBI(f,G);
SB.IsInSA_SAGBI(f,ref S);

While the first two functions test the membership using implicitization, these two functions use truncated SAGBI bases for the membership test, which may be more efficient. It depends on the application which of these two possibilities is the fastest one.

Example for the Subalgebra Data Type

So what advantages does the Subalgebra data type have? Consider the following example.

Use P ::= QQ[x,y,z];
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
L := SB.SAGBI(G);
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
b := SB.IsInSubalgebra(f,G);
h := SB.SubalgebraHS(G);

Here, first a SAGBI basis is computed, then the subalgebra membership is tested using implicitization and at the end, the Hilbert series of K[G] is computed. But after computing a SAGBI basis, one could also test the Subalgebra membership using the Subalgebra Division Algorithm and compute the Hilbert Series of . The Subalgebra data type does this automatically. Instead of the code above, we can write the following:

Use P ::= QQ[x,y,z];
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
S := SB.Subalgebra(P,G);
L := SB.GetSAGBI(ref S);
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
b := SB.IsInSA(f,ref S);
h := SB.GetHS(ref S);

While this is only a simple example, the second code is much faster. At the time this is written, the second computation is approximately two times as fast as the first one.