Jas Project

Users Guide

This document contains some (first) how to and usage information for the JAS project. JAS can be used as any other Java library by adding jas.jar to the classpath and creating and using objects from it. JAS can also be used interactively via the Python Java interpreter jython.

Getting started

As first example we will discus how to compute a Groebner base with jython. The jython script will be placed into a file, e.g. getstart.py. This script file is executed by calling

  jython getstart.py

The script file first imports the desired mathematical classes from the jas.py script which does all interfacing to the Java library.

  from jas import Ring
  from jas import Ideal

In our case we need Ring to define an appropriate polynomial ring and Ideal to define sets of polynomials and have methods to compute Groebner bases. Ring takes a string argument which contains required definitions of the polynomial ring: the type of the coefficient ring, the names of the used variables and the desired term order.

  r = Ring( "Rat(B,S,T,Z,P,W) L" );

The ring definition is stored in the variable r for later use. The string "Rat(B,S,T,Z,P,W) L" defines the coefficient ring to be the rational numbers Rat, the polynomial ring consists of the variables B, S, T, Z, P, W and the term order L means a lexicographic term order. For some historical reason the term order orders the variables as B < S < T < Z < P < W and not the other way. I.e. the highest or largest variable is always on the left of the list of variables not on the right as in some other algebra systems. With

  print "Ring: " + str(r);

you can print out the ring definition. str(r) is the usual python way of producing string representations of objects, which in our case calls the respective Java method toString() of the JAS ring object. It produces

Ring: BigRational(B, S, T, Z, P, W) INVLEX

i.e. the coefficients are from the jas class BigRational and the term order is INVLEX (INV because the largest variable is on the left). Next we need to enter the generating polynomials for the ideal. We do this in two steps, first define a python string with the polynomials and then the creation of the ideal using the ring definition from before and the polynomial string.

ps = """
( 
 ( 45 P + 35 S - 165 B - 36 ), 
 ( 35 P + 40 Z + 25 T - 27 S ), 
 ( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ), 
 ( - 9 W + 15 T P + 20 S Z ), 
 ( P W + 2 T Z - 11 B**3 ), 
 ( 99 W - 11 B S + 3 B**2 ),
 ( B**2 + 33/50 B + 2673/10000 )
) 
""";

The polynomial string can be generated by any means python allows for string manipulation. In our example we use python multiline strings, which are delimited by triple quotes """ ... """. The list of polynomials is delimited by parenthesis ( ... ), as well as every polynomial is delimited by parenthesis, e.g. ( B**2 + 33/50 B + 2673/10000 ). The polynomials are separated by commas. The syntax for polynomials is a sequence of monimals consisting of coefficients and terms (as products of powers of variables). The terms can optionally be written with multiplication sign, i.e. 25 S P can be written 25*S*P. Variable names must be delimited by white space or some operator, i.e. you can not write 25 SP because SP is not a listed variable name in the polynomial ring definition. Coefficients may not contain white space, i.e. the / separating the nominator from the denominator may not be surrounded by spaces, i.e. writing 33 / 50 is not allowed. Powers of variables can be written with ** or ^, i.e. the square of B is written as B**2 or B^2. The ideal is the defined with

  f = Ideal( r, ps );

The ideal is contained the the polynomial ring r and consists of the polynomials from the string ps. Ideals can be printed with

  print "Ideal: " + str(f);

In this example it produces the following output.

Ideal: BigRational(B, S, T, Z, P, W) INVLEX
(
( B^2 + 33/50 B + 2673/10000  ),
( 45 P + 35 S - 165 B - 36  ),
( 35 P + 40 Z + 25 T - 27 S ),
( 15 W + 25 S * P + 30 Z - 18 T - 165 B^2 ),
( -9 W + 15 T * P + 20 S * Z ),
( 99 W - 11 B * S + 3 B^2 ),
( P * W + 2 T * Z - 11 B^3 )
)

The polynomial terms are now sorted with respect to the lexicographical term order. The highest term is first in a polynomial. Also the polynomials are sorted with respect to the term order, but with smallest polynomial first in the list. Finaly we can go to the computation of the Groebner basis of this ideal.

  g = f.GB();

The ideal f has a method GB() which computes the Groebner base. The computed Groebner base is stored in the variable g which is also an ideal. It can be printed as the ideal f

  print "Groebner base:", g;

The output first shows the output from calling the GB() method and the the ideal basis.

sequential executed in 136 ms

Groebner base: BigRational(B, S, T, Z, P, W) INVLEX
(
( B^2 + 33/50 B + 2673/10000  ),
( S - 5/2 B - 9/200  ),
( T - 37/15 B + 27/250  ),
( Z + 49/36 B + 1143/2000  ),
( P - 31/18 B - 153/200  ),
( W + 19/120 B + 1323/20000  )
)

I.e. the Groebner base was computed in 135 ms and consists of six polynomials. The polynomials are now monic, i.e. the leading coefficient is 1 and omitted during print out. This concludes the getting started section.

Overview of jas.py classes and methods

The jython interface to the JAS library consists of the following jython classes.

Solvable polynomial rings

Solvable polynomial rings are non commutative polynomial rings where the non commutativity is expressed by commutator relations. Commutator relations are stored in a data structure called relation table. In the definition of a solvable polynomial ring this relation table must be defined. E.g the definition for the ring of a Weyl algebra is

Rat(a,b,e1,e2,e3) L
RelationTable
(
 ( e3 ), ( e1 ), ( e1 e3 - e1 ),
 ( e3 ), ( e2 ), ( e2 e3 - e2 )
)

The relation table must be build from triples of (commutative) polynomials. A triple p1, p2, p3 is interpreted as non commutative multiplication relation p1 .*. p2 = p3. Currently p1 and p2 must be single term, single variable polynomials. The term order must be choosen such that leadingTerm(p1 p2) equals leadingTerm(p3) and p1 > p2 for each triple. Polynomial p3 must be in commutative form, i.e. multiplication operators occuring in it are commutative. Variables for which there are no commutator relations are assumed to commute with each other and with all other variables, e.g. the variables a, b in the example. Polynomials in the generating set of an ideal are also assumed to be in commutative form. This will be changed in the future to allow the multiplication operator to mean non-commutative multiplication.

A complete example is contained in the python script solvable.py. Running the script computes a left, right and twosided Groebner base for the following ideal

(
 ( e1 e3^3 + e2^10 - a ),
 ( e1^3 e2^2 + e3 ),
 ( e3^3 + e3^2 - b )
)

The left Groebner base is

(
 ( a ), ( b ),
 ( e1^3 * e2^2 ), ( e2^10 ), ( e3 )
)

the twosided Groebner base is

(
 ( a ), ( b ), ( e1 ), ( e2 ), ( e3 )
)

and the right Groebner base is

(
 ( a ), ( b ), ( e1 ), ( e2^10 ), ( e3 )
)

A module example is in armbruster.py and a solvable module example is in solvablemodule.py.


Heinz Kredel

Last modified: Mon Mar 20 21:55:34 CET 2006

$Id: guide.html 799 2006-03-20 20:56:55Z kredel $