gap> ######################### BEGIN COPYRIGHT MESSAGE #########################
GBNP - computing Gröbner bases of noncommutative polynomials
Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem
Knopper, Chris Krook. Address: Discrete Algebra and Geometry (DAM) group
at the Department of Mathematics and Computer Science of Eindhoven
University of Technology.

For acknowledgements see the manual. The manual can be found in several
formats in the doc subdirectory of the GBNP distribution. The
acknowledgements formatted as text can be found in the file chap0.txt.

GBNP is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by the
Free Software Foundation (FSF); either version 2.1 of the License, or
(at your option) any later version. For details, see the file 'LGPL' in
the doc subdirectory of the GBNP distribution or see the FSF's own site:
http://www.gnu.org/licenses/lgpl.html
gap> ########################## END COPYRIGHT MESSAGE ##########################

gap> ### filename = "example11.g" 
gap> ### authors Cohen & Gijsbers
gap> ### $Id: example11.g,v 1.5 2004/04/16 14:37:37 jwk Exp $

gap> ### THIS IS A GAP PACKAGE FOR COMPUTING NON-COMMUTATIVE GROBNER BASES 
gap>  
<#GAPDoc Label="Example11">
<Section Label="Example11"><Heading>The truncated variant on two weighted homogeneous polynomials</Heading>
Here we exhibit a truncated non-commutative homogeneous weighted Gröbner
basis computation. This example uses the functions from Section <Ref
Sect="truncfun"/>, the truncation variants (see also Section <Ref
Sect="trunc"/>).
<P/>
The input is a set of polynomials in <M>x</M> and <M>y</M>, which
are homogeneous when the weight of <M>x</M> is 2 and of <M>y</M> is 3.
The input is <M>\{x^3y^2-x^6+y^4,y^2x^3+xyxyx+x^2yxy\}</M>.
We truncate the computation at degree 16.
The truncated Gröbner basis is 
<M>\{y^2x^3+xyxyx+x^2yxy,x^6-x^3y^2-y^4,x^3y^2x-x^4y^2-xy^4\}</M>
and the dimension of the quotient algebra is 134.
<P/>
First load the package and set the standard infolevel <Ref
InfoClass="InfoGBNP" Style="Text"/> to 1 and the time infolevel <Ref
Func="InfoGBNPTime" Style="Text"/> to 1 (for more information about the info
level, see Chapter <Ref Chap="Info"/>).


<Listing><![CDATA[
gap> LoadPackage("GBNP","0",false);;
gap> SetInfoLevel(InfoGBNP,1);
gap> SetInfoLevel(InfoGBNPTime,1);
]]></Listing>

The variables will be printed as <M>x</M> and <M>y</M>.
<Listing><![CDATA[
gap> GBNP.ConfigPrint("x","y");
]]></Listing>

The level to truncate at is assigned to <M>n</M>.

<Listing><![CDATA[
gap> n := 16;;
]]></Listing>

Now enter the relations in NP form (see Section <Ref Sect="NP"/>) and the
weights.

<Listing><![CDATA[
gap> s1 :=[[[1,1,1,2,2],[1,1,1,1,1,1],[2,2,2,2]],[1,-1,1]];;
gap> s2 :=[[[2,2,1,1,1],[1,2,1,2,1],[1,1,2,1,2]],[1,1,1]];;
gap> K := [s1,s2];;
gap> weights:=[2,3];;
]]></Listing>

The input can be printed with <Ref Func="PrintNPList" Style="Text"/>

<Listing><![CDATA[
gap> PrintNPList(K);
 x^3y^2 - x^6 + y^4 
 y^2x^3 + xyxyx + x^2yxy 
]]></Listing>

Verify whether the list <C>K</C> consists only of polynomials that are
homogeneous with respect to <C>weights</C>
by means of  <Ref Func="CheckHomogeneousNPs" Style="Text"/>.

<Listing><![CDATA[
gap> CheckHomogeneousNPs(K,weights);
#I  Input is homogeneous
[ 12, 12 ]
]]></Listing>


Now calculate the truncated Gröbner basis with <Ref Func="SGrobnerTrunc"
Style="Text"/>. The output will only contain homogeneous polynomials
of degree at most <C>n</C>.

<Listing><![CDATA[
gap> G := SGrobnerTrunc(K,n,weights);;
#I  number of entered polynomials is 2
#I  number of polynomials after reduction is 2
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 4 msecs.
]]></Listing>

The Gröbner basis of the truncated quotient algebra can be printed with <Ref
Func="PrintNPList" Style="Text"/>:

<Listing><![CDATA[
gap> PrintNPList(G);
 y^2x^3 + xyxyx + x^2yxy 
 x^6 - x^3y^2 - y^4 
 x^3y^2x - x^4y^2 + y^4x - xy^4 
]]></Listing>

The standard basis of the quotient of the free noncommutative algebra
on <M>n</M> variables, where 
<M>n</M> is the length of the vector <C>weights</C>,
by the homogeneous ideal generated by <C>K</C> 
up to degree <M>n</M>
is obtained by means of the function
<Ref Func="BaseQATrunc" Style="Text"/>
applied to <C>K</C>, <C>n</C>, and <C>weights</C>.

<Listing><![CDATA[
gap> B := BaseQATrunc(K,n,weights);;
#I  number of entered polynomials is 2
#I  number of polynomials after reduction is 2
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 0 msecs.
gap> i := Length(B);
17
gap> Print("at level ",i-1," the standard monomials are:\n");
at level 16 the standard monomials are:
gap> PrintNPList(List(B[i], qq -> [[qq],[1]]));
 yxyx^4 
 yx^2yx^3 
 xyxyx^3 
 yx^3yx^2 
 xyx^2yx^2 
 x^2yxyx^2 
 y^4x^2 
 yx^4yx 
 xyx^3yx 
 x^2yx^2yx 
 x^3yxyx 
 y^3xyx 
 y^2xy^2x 
 yxy^3x 
 xy^4x 
 yx^5y 
 xyx^4y 
 x^2yx^3y 
 x^3yx^2y 
 y^3x^2y 
 x^4yxy 
 y^2xyxy 
 yxy^2xy 
 xy^3xy 
 x^5y^2 
 y^2x^2y^2 
 yxyxy^2 
 xy^2xy^2 
 yx^2y^3 
 xyxy^3 
 x^2y^4 
]]></Listing>


The same result can be obtained by using the truncated Gröbner basis
found for <C>G</C> instead of <C>K</C>.

<Listing><![CDATA[
gap> B2 := BaseQATrunc(G,n,weights);;
#I  number of entered polynomials is 3
#I  number of polynomials after reduction is 3
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 0 msecs.
gap> B = B2;
true
]]></Listing>

Also, the same result can be obtained by using the
leading terms of the truncated Gröbner basis
found for <C>G</C> instead of <C>K</C>.

<Listing><![CDATA[
gap> B3 := BaseQATrunc(List( LMonsNP(G), qq -> [[qq],[1]]),n,weights);;
#I  number of entered polynomials is 3
#I  number of polynomials after reduction is 3
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 0 msecs.
gap> B = B3;
true
]]></Listing>



A list of dimensions of the homogeneous parts of the quotient algebra
up to degree <M>n</M> is obtained by means of
<Ref Func="DimsQATrunc" Style="Text"/>
with arguments <C>G</C>, <C>n</C>, and <C>weights</C>.

<Listing><![CDATA[
gap> DimsQATrunc(G,n,weights);
#I  number of entered polynomials is 3
#I  number of polynomials after reduction is 3
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 4 msecs.
[ 1, 0, 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 10, 16, 17, 24, 31 ]
]]></Listing>



Even more detailed information is given by the list of
frequences up to degree <C>n</C>. 
This is obtained by means of
<Ref Func="FreqsQATrunc" Style="Text"/>
with arguments <C>G</C>, <C>n</C>, and <C>weights</C>.

<Listing><![CDATA[
gap> FreqsQATrunc(G,n,weights);
#I  number of entered polynomials is 3
#I  number of polynomials after reduction is 3
#I  End of phase I
#I  Input is homogeneous
#I  Reached level 16
#I  end of the algorithm
#I  The computation took 0 msecs.
[ [ [ [  ], 1 ] ], [ [ [ 1, 0 ], 1 ] ], [ [ [ 0, 1 ], 1 ] ], 
  [ [ [ 2, 0 ], 1 ] ], [ [ [ 1, 1 ], 2 ] ], 
  [ [ [ 3, 0 ], 1 ], [ [ 0, 2 ], 1 ] ], [ [ [ 2, 1 ], 3 ] ], 
  [ [ [ 4, 0 ], 1 ], [ [ 1, 2 ], 3 ] ], [ [ [ 3, 1 ], 4 ], [ [ 0, 3 ], 1 ] ], 
  [ [ [ 5, 0 ], 1 ], [ [ 2, 2 ], 6 ] ], [ [ [ 4, 1 ], 5 ], [ [ 1, 3 ], 4 ] ], 
  [ [ [ 3, 2 ], 9 ], [ [ 0, 4 ], 1 ] ], [ [ [ 5, 1 ], 6 ], [ [ 2, 3 ], 10 ] ],
  [ [ [ 4, 2 ], 12 ], [ [ 1, 4 ], 5 ] ], 
  [ [ [ 6, 1 ], 5 ], [ [ 3, 3 ], 18 ], [ [ 0, 5 ], 1 ] ], 
  [ [ [ 5, 2 ], 16 ], [ [ 2, 4 ], 15 ] ] ]
]]></Listing>


</Section>
<#/GAPDoc>
