sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

Full interface to letterplace from singular #7797

Closed burcin closed 11 years ago

burcin commented 14 years ago

The new aim of this ticket is to add an interface to the letterplace component of Singular, that actually goes beyond what Singular offers.

The patch provides

(Note that the original purpose was merely to compute Groebner bases up to a degree bound of two-sided ideals of free algebras, but without normal form computation etc.)

Examples are below, in the comments.

Apply

attachment: trac7797-full_letterplace_wrapper_combined.patch and attachment: trac_7797-ref.patch

Depends on #11068 #11268 #12641 #12749

Depends on #4539 Depends on #11268 Depends on #12461 Depends on #12749 Depends on #12988 Depends on #13237

Upstream: None of the above - read trac for reasoning.

CC: @sagetrac-PolyBoRi @saliola @malb @jhpalmieri @sagetrac-sage-combinat @sagetrac-OleksandrMotsak

Component: algebra

Keywords: singular, free algebra, letterplace

Author: Simon King, Michael Brickenstein, Burcin Erocal

Reviewer: Alexander Dreyer

Merged: sage-5.5.beta2

Issue created by migration from https://trac.sagemath.org/ticket/7797

burcin commented 14 years ago

hack to create an MPolynomialRing as a parent for letterplace polynomials

burcin commented 14 years ago

Attachment: trac_7797-letterplace_ring_hack.patch.gz

basic interface to compute groebner bases with letterplace

burcin commented 14 years ago
comment:1

Attachment: trac_7797-letterplace.patch.gz

burcin commented 14 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,4 @@
-Attached patches add a basic interface to the letterplace [1] component of Singular, which allows computation of Groebner bases (up to a degree bound) of (two-sided) ideals of free algebras.
-
-[1] http://www.singular.uni-kl.de/Manual/latest/sing_425.htm#SEC478
+Attached patches add a basic interface to the [letterplace](http://www.singular.uni-kl.de/Manual/latest/sing_427.htm#SEC480) component of Singular, which allows computation of Groebner bases (up to a degree bound) of (two-sided) ideals of free algebras.

 These patches depend on #7198.
malb commented 14 years ago
comment:3

Doctest failure on sage.math:

File "/mnt/usb1/scratch/malb/sage-4.4/devel/sage-main/sage/libs/singular/letterplace.py", line 32:
    sage: freegb(l, 10)
Exception raised:
    Traceback (most recent call last):
      File "/mnt/usb1/scratch/malb/sage-4.4/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/mnt/usb1/scratch/malb/sage-4.4/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/mnt/usb1/scratch/malb/sage-4.4/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_1[5]>", line 1, in <module>
        freegb(l, Integer(10))###line 32:
    sage: freegb(l, 10)
      File "/mnt/usb1/scratch/malb/sage-4.4/local/lib/python/site-packages/sage/libs/singular/letterplace.py", line 70, in freegb
        libsingular_options(bck)
    TypeError: 'sage.libs.singular.option.LibSingularOptions' object is not callable

I think we used to allow calling libsingular option objects earlier, however load() replaces it.

malb commented 14 years ago
comment:4

Actually, this doesn't make sense to me:

bck = int(libsingular_options)  
#letter place needs these options
libsingular_options['redTail'] = True
libsingular_options['redSB'] = True
libsingular_options(bck)

First bck is stored and then options are changed. So far fine. However, then bck is loaded and thus overwrites the options just set.

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago

letter place singular interface

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago
comment:5

Attachment: trac_7797-letterplace.2.patch.gz

Hi!

I have corrected that using the new context interface.

Cheers, Michael

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago

Attachment: trac_7797-letterplace.3.patch.gz

malb commented 14 years ago
comment:7
malb commented 14 years ago
comment:8
File "/mnt/usb1/scratch/malb/sage-4.4/devel/sage-main/sage/libs/singular/letterplace.py", line 32:

sage: freegb(l, 10)

Expected:

[3*y*x*z^7*y + y*x*z^8, 3*y*x*z^6*y + y*x*z^7, y*x*z^6*x*z + 314928*y^2*x*z^2*x^5, 3*y*x*z^5*y + y*x*z^6, y*x*z^5*x*z - 17496*y^2*x*z^2*x^4, 3*y*x*z^4*y + y*x*z^5, y*x*z^4*x*z + 972*y^2*x*z^2*x^3, 3*y*x*z^4*x^2*z*y + y*x*z^4*x^2*z^2, 3*y*x*z^3*y + y*x*z^4, y*x*z^3*x*z - 54*y^2*x*z^2*x^2, 3*y*x*z^3*x^2*z^2*y + y*x*z^3*x^2*z^3, 3*y*x*z^3*x^2*z*y + y*x*z^3*x^2*z^2, 3*y*x*z^3*x^3*z*y + y*x*z^3*x^3*z^2, 3*y*x*z^2*y + y*x*z^3, y*x*z^2*x*z + 3*y^2*x*z^2*x, 3*y*x*z^2*x^2*z^3*y + y*x*z^2*x^2*z^4, 3*y*x*z^2*x^2*z^2*y + y*x*z^2*x^2*z^3, y*x*z^2*x^2*z^2*x*z + 3*y^2*x*z^2*x^2*z^2*x, 3*y*x*z^2*x^2*z*y + y*x*z^2*x^2*z^2, 3*y*x*z^2*x^3*z^2*y + y*x*z^2*x^3*z^3, 3*y*x*z^2*x^3*z*y + y*x*z^2*x^3*z^2, 3*y*x*z^2*x^4*z*y + y*x*z^2*x^4*z^2, 3*y*x*z*y + y*x*z^2, x*z*y^6*x*z - 7776*y*x*z^2*x^6, x*z*y^5*x*z - 1296*y*x*z^2*x^5, x*z*y^4*x*z - 216*y*x*z^2*x^4, x*z*y^3*x*z - 36*y*x*z^2*x^3, x*z*y^2*x*z - 6*y*x*z^2*x^2, x*z*y*x*z - y*x*z^2*x, 6*x*z*x - y*x*z, 3*x*y + x*z]

Got
[3*x*y + x*z, 6*x*z*x - y*x*z, 3*y*x*z*y + y*x*z^2, 3*y*x*z^2*y + y*x*z^3, x*z*y*x*z - y*x*z^2*x, 3*y*x*z^3*y + y*x*z^4, y*x*z^2*x*z + 3*y^2*x*z^2*x, x*z*y^2*x*z - 6*y*x*z^2*x^2, 3*y*x*z^4*y + y*x*z^5, y*x*z^3*x*z - 54*y^2*x*z^2*x^2, x*z*y^3*x*z - 36*y*x*z^2*x^3, 3*y*x*z^5*y + y*x*z^6, y*x*z^4*x*z + 972*y^2*x*z^2*x^3, 3*y*x*z^2*x^2*z*y + y*x*z^2*x^2*z^2, x*z*y^4*x*z - 216*y*x*z^2*x^4, 3*y*x*z^6*y + y*x*z^7, y*x*z^5*x*z - 17496*y^2*x*z^2*x^4, 3*y*x*z^3*x^2*z*y + y*x*z^3*x^2*z^2, 3*y*x*z^2*x^2*z^2*y + y*x*z^2*x^2*z^3, 3*y*x*z^2*x^3*z*y + y*x*z^2*x^3*z^2, x*z*y^5*x*z - 1296*y*x*z^2*x^5, 3*y*x*z^7*y + y*x*z^8, y*x*z^6*x*z + 314928*y^2*x*z^2*x^5, 3*y*x*z^4*x^2*z*y + y*x*z^4*x^2*z^2, 3*y*x*z^3*x^2*z^2*y + y*x*z^3*x^2*z^3, 3*y*x*z^3*x^3*z*y + y*x*z^3*x^3*z^2, 3*y*x*z^2*x^2*z^3*y + y*x*z^2*x^2*z^4, y*x*z^2*x^2*z^2*x*z + 3*y^2*x*z^2*x^2*z^2*x, 3*y*x*z^2*x^3*z^2*y + y*x*z^2*x^3*z^3, 3*y*x*z^2*x^4*z*y + y*x*z^2*x^4*z^2, x*z*y^6*x*z - 7776*y*x*z^2*x^6]

This is with Singular 3-1-1-3 though.

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago
comment:9

Aufruf von System ist offiziell, heißt aber nur, dass es nicht als extra Kommando eingebaut ist.

http://www.singular.uni-kl.de/Manual/latest/sing_433.htm

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago
comment:10

sorry, for the language: calling system is official. Using singular system was easier for the authors of freegb.

http://www.singular.uni-kl.de/Manual/latest/sing_433.htm

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago
comment:11

the result seem to differ just in order.

What Ideal class is used for free algebras?

1998e663-c3b5-4cf6-92c3-7f1771ca5185 commented 14 years ago

Attachment: plural_functions.patch.gz

some improvements to plural interface, still not much working

malb commented 14 years ago
comment:12

Replying to @sagetrac-PolyBoRi:

the result seem to differ just in order. What Ideal class is used for free algebras?

Apparently, we don't have one which works yet

sage: P.<a,b,c> = FreeAlgebra(QQ,3)
sage: P
Free Algebra on 3 generators (a, b, c) over Rational Field
sage: P.ideal([a*b+c,a+1])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/malb/<ipython console> in <module>()

/usr/local/sage-4.3/local/lib/python2.6/site-packages/sage/rings/ring.so in sage.rings.ring.Ring.ideal (sage/rings/ring.c:3426)()

/usr/local/sage-4.3/local/lib/python2.6/site-packages/sage/rings/ideal.pyc in Ideal(*args, **kwds)
    187 
    188     if not commutative_ring.is_CommutativeRing(R):
--> 189         raise TypeError, "R must be a commutative ring"
    190 
    191     if len(gens) == 0:

TypeError: R must be a commutative ring
simon-king-jena commented 13 years ago
comment:13

Do I understand correctly that in this ticket it is not attempted to replace FreeAlgebra by a more efficient implementation based on Singular's Letterplace Algebra? This ticket is only about wrapping free Groebner bases, but not about wrapping the basic arithmetic?

What Sage currently does in free algebras is generic and slow. As pointed out on sage-devel, bot Singular and Gap are faster in basic arithmetic than the current implementation in Sage.

But this should be on a different ticket, right?

Best regards, Simon

d46d2cb1-860f-484d-8329-8ebfc9f5d004 commented 13 years ago
comment:14

As I understand, this makes the Singular's letterplace functionality accessible to Sage (in addition to the Plural functionality of #4539).

burcin commented 13 years ago
comment:15

This ticket is only about exposing the Groebner basis computation. We didn't think arithmetic was usable since

If you think the arithmetic should be wrapped as well, that should be on a different ticket. I don't know how much the Plural wrapper (#4539) will help with that.

simon-king-jena commented 13 years ago
comment:16

Replying to @alexanderdreyer:

As I understand, this makes the Singular's letterplace functionality accessible to Sage (in addition to the Plural functionality of #4539).

What is meant by "Letterplace functionality"? Is it "simply" computing Gröbner basis with degree bound in free associative algebras?

Something that irritates me (and I already asked in the Singular forum) is that I could not find a way to apply such Groebner basis, e.g., in order to compute a normal form of an element of the free associative algebra w.r.t. this Gröbner basis. Also I tend to call basic arithmetic a funtionality.

Replying to @burcin:

This ticket is only about exposing the Groebner basis computation. We didn't think arithmetic was usable since

  • there is a degree bound, and
  • it is a hack in Singular.

If you think the arithmetic should be wrapped as well, that should be on a different ticket. I don't know how much the Plural wrapper (#4539) will help with that.

OK. If I find the time, I'll finish the wrappers that I hacked together yesterday. The new ticket will then provide two alternative implementations of free (associative) algebras. One will be based on Gap, the other on Letterplace. The latter will be a hack as well: While doing arithmetic, the degree bound will be dynamically adapted. Currently I use Expect interfaces, but I guess using the Plural wrapper will improve things further.

Cheers, Simon

simon-king-jena commented 13 years ago
comment:17

I tried to apply the patches - apparently it is

Apply trac_7797-letterplace_ring_hack.patch trac_7797-letterplace.3.patch plural_functions.patch

Correct?

Unfortunately, plural_functions.patch fails. Can you rebase it, please?

simon-king-jena commented 13 years ago
comment:18

In addition, one doc test has a different result:

sage: from sage.libs.singular.letterplace import freegb 
sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F 
Free Algebra on 3 generators (x, y, z) over Rational Field
sage: l=[2*x*z*x+y*x*y, 3*x*y+x*z] 
sage: freegb(l, 10) 
[3*x*y + x*z, 6*x*z*x - y*x*z, 3*y*x*z*y + y*x*z^2, 3*y*x*z^2*y + y*x*z^3, x*z*y*x*z - y*x*z^2*x, 3*y*x*z^3*y + y*x*z^4, y*x*z^2*x*z + 3*y^2*x*z^2*x, x*z*y^2*x*z - 6*y*x*z^2*x^2, 3*y*x*z^4*y + y*x*z^5, y*x*z^3*x*z - 54*y^2*x*z^2*x^2, x*z*y^3*x*z - 36*y*x*z^2*x^3, 3*y*x*z^5*y + y*x*z^6, y*x*z^4*x*z + 972*y^2*x*z^2*x^3, 3*y*x*z^2*x^2*z*y + y*x*z^2*x^2*z^2, x*z*y^4*x*z - 216*y*x*z^2*x^4, 3*y*x*z^6*y + y*x*z^7, y*x*z^5*x*z - 17496*y^2*x*z^2*x^4, 3*y*x*z^3*x^2*z*y + y*x*z^3*x^2*z^2, 3*y*x*z^2*x^2*z^2*y + y*x*z^2*x^2*z^3, 3*y*x*z^2*x^3*z*y + y*x*z^2*x^3*z^2, x*z*y^5*x*z - 1296*y*x*z^2*x^5, 3*y*x*z^7*y + y*x*z^8, y*x*z^6*x*z + 314928*y^2*x*z^2*x^5, 3*y*x*z^4*x^2*z*y + y*x*z^4*x^2*z^2, 3*y*x*z^3*x^2*z^2*y + y*x*z^3*x^2*z^3, 3*y*x*z^3*x^3*z*y + y*x*z^3*x^3*z^2, 3*y*x*z^2*x^2*z^3*y + y*x*z^2*x^2*z^4, y*x*z^2*x^2*z^2*x*z + 3*y^2*x*z^2*x^2*z^2*x, 3*y*x*z^2*x^3*z^2*y + y*x*z^2*x^3*z^3, 3*y*x*z^2*x^4*z*y + y*x*z^2*x^4*z^2, x*z*y^6*x*z - 7776*y*x*z^2*x^6]

Which one is correct?

simon-king-jena commented 13 years ago

Work Issues: rebase, doctests

simon-king-jena commented 13 years ago
comment:19

FYI: As I mentioned in an earlier post, just having a two-sided Gröbner basis is not enough for my envisioned applications. I also need a competitive arithmetic for free associative algebras, normal form computation, and, if possible, ideals in non-commutative rings, and ring quotients.

So, I implemented something from scratch, not based on the previous patches. I already got an implementation of free associative algebras based on letterplace (with a dynamic degree bound). For example, computing (x+y)**20 is 84 times faster than with the old implementation of free algebras.

I also have a base class for left, right and twosided ideals: If R is any ring and L a list of elements, then RL is a left ideal, LR a right ideal, and RLR a twosided ideal.

Using freegb for the computation of a two-sided Gröbner basis will be straight forward. In addition, Grischa Studzinski and Viktor Levandoskyy provided me with some code for computing normal forms in free algebras, that is supposed to be in a future Singular release. My plan is to back-port it.

And then there's documentation to write...

simon-king-jena commented 13 years ago

Description changed:

--- 
+++ 
@@ -1,5 +1,16 @@
-Attached patches add a basic interface to the [letterplace](http://www.singular.uni-kl.de/Manual/latest/sing_427.htm#SEC480) component of Singular, which allows computation of Groebner bases (up to a degree bound) of (two-sided) ideals of free algebras.
+The new aim of this ticket is to add an interface to the [letterplace](http://www.singular.uni-kl.de/Manual/latest/sing_427.htm#SEC480) component of Singular, namely providing

-These patches depend on #7198.
+* A new implementation of free algebras with fast arithmetic.
+* Degree-wise Gröbner basis computation for twosided homogeneous ideals of free algebras.
+* Normal form computation with respect to such ideals.

-Since Sage only supports ideals over commutative rings for now, writing a better interface to this would take considerably more work. I suggest we review & merge these patches, and hook it up to the right place when it exists.
+and in addition
+
+* One- and twosided ideals of noncommutative rings.
+* Quotient rings of such ideals
+
+(Note that the original purpose was merely to compute Groebner bases up to a degree bound of two-sided ideals of free algebras, but without normal form computation etc.)
+
+Examples are below, in the comments.
+
+Apply trac7797-full_letterplace_wrapper.patch
simon-king-jena commented 13 years ago

Changed author from Michael Brickenstein, Burcin Erocal to Simon King, Michael Brickenstein, Burcin Erocal

simon-king-jena commented 13 years ago

Changed work issues from rebase, doctests to none

simon-king-jena commented 13 years ago
comment:21

I have attached a new patch that replaces all previous patches and provides a lot more functionality.

Since I learned much from the previous patches, I hesitate to remove Michael and Burcin from the author list. But perhaps you like to be referee? Then you should move your name into the reviewer field.

Technical Remarks

singular_function is very useful! However, it was impossible to simply call the freegb.lib library functions of Singular, since they rely on ring attributes -- but ring attributes have not been wrapped in libSingular.

Moreover, it is not a good idea to call the makeLetterplaceRing function from Singular and then transform the resulting RingWrap into a polynomial ring. It is possible -- but the result can not be pickled, since its variable names look like x(1),y(1),x(2),y(2) and are thus no valid identifiers.

But it is no problem to create another ring with more sober variable names, and apply the letterplace functions to it. One just needs to work around the attribute tests that these functions do. In fact, these functions do only one thing after the checking, namely a system call. So, I simply did this system calls as well.

In the current release, Singular does provide the Gröbner basis computations in free algebras, but it does not provide normal form computations. Grischa Studzinski has send me some code that is supposed to become part of freegb.lib -- again, I can not call it directly, but it was fairly straight forward to implement along the lines of Grischa's code.

New Features

Free Algebra constructor as UniqueFactory

Up to now, the FreeAlgebra constructor was based on an incomplete way of caching: When you pickle and unpickle a free algebra, you would not get the same object.

# old behaviour
sage: F.<a,b,c> = FreeAlgebra(QQ,3)
sage: loads(dumps(F)) is F
False

This is now resolved. Moreover, it is not needed to explicitly provide the number of generators, when it is obvious from the list of names:

sage: F.<x,y,z> = FreeAlgebra(QQ)
sage: loads(dumps(F)) is F
True

I did one change that may be subject to criticism, and I wouldn't oppose to revert it. A free algebra in one generator is a polynomial ring. So, I return a polynomial ring:

sage: FreeAlgebra(QQ,'x')
Univariate Polynomial Ring in x over Rational Field

The constructor can now also be asked for a different implementation, as in all examples below.

Free Algebra via Letterplace

I provide a new implementation of free algebras. It can be constructed as follows:

sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
sage: F
Free Associative Unital Algebra on 3 generators ('x', 'y', 'z') over Rational Field

Due to some shortcomings of Singular's letterplace implementation, unfortunately we need to restrict to homogeneous elements:

sage: (x+2*y)^2
x*x + 2*x*y + 2*y*x + 4*y*y
sage: x+0
x
Traceback (most recent call last):
...
ArithmeticError: Can only add elements of the same degree

This is why the new implementation can not yet become the default.

However, the arithmetic in the new implementation is much faster than the old:

sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
sage: F_old.<a,b,c> = FreeAlgebra(QQ)
sage: timeit('t=(x+y)^15')
5 loops, best of 3: 27.7 ms per loop
sage: timeit('t=(a+b)^15')
sage: %time t=(a+b)^15
CPU times: user 4.51 s, sys: 0.09 s, total: 4.60 s
Wall time: 6.46 s
sage: 4510/27.7
162.815884476534
sage: timeit('t=(x+y)^15')
25 loops, best of 3: 19.7 ms per loop
sage: %time t=(a+b)^15
CPU times: user 2.70 s, sys: 0.02 s, total: 2.72 s
Wall time: 2.73 s
sage: 2700/19.7
137.055837563452

One- and Twosided Ideals of Noncommutative Rings

I implemented it in a fairly general way, ideals can be created for any ring:

sage: A = SteenrodAlgebra(2)
sage: IL = A*[A.1+A.2,A.1^2]; IL
Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra
sage: IR = [A.1+A.2,A.1^2]*A; IR
Right Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra
sage: IT = A*[A.1+A.2,A.1^2]*A; IT
Twosided Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra

Note some nastyness: The parent of an ideal still is the "monoid of ideals of a ring". But we actually have no multiplication in the non-commutative setting:

sage: IL*IR
Traceback (most recent call last):
...
NotImplementedError: Can not multiply non-commutative ideals.

Of course, in general, we have no way to solve the ideal containment problem. But in free algebras, we have letterplace:

sage: I.groebner_basis(degbound=3)
Twosided Ideal (y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators ('x', 'y', 'z') over Rational Field
sage: (x*y*z*y*x).normal_form(I)
y*z*z*y*z + y*z*z*z*x + y*z*z*z*z
sage: x*y*z*y*x - (x*y*z*y*x).normal_form(I) in I
True
sage: x*I.0-I.1*y+I.0*y in I
True
sage: 1 in I
False

Quotient Rings

Previously, quotient rings have only been available for rings that inherit from the base class of commutative rings. My patch makes them available for all rings, and actually it should work to some extent even for objects that belong to the category Rings() but do not inherit from sage.rings.ring.Ring.

The requirement is that we mod by an ideal I that is twosided and that has a method I.reduce(x) that returns a normal form of an element x with respect to I. That requirement holds for ideals of polynomial rings, and also for homogeneous ideals of free associative algebras. In particular:

sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F
sage: Q.<a,b,c> = F.quo(I); Q
Quotient of Free Associative Unital Algebra on 3 generators ('x', 'y', 'z') over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y)
sage: a*b
-b*c
sage: a^3
-b*c*a - b*c*b - b*c*c
sage: J = Q*[a^3-b^3]*Q
sage: R.<i,j,k> = Q.quo(J); R
Quotient of Free Associative Unital Algebra on 3 generators ('x', 'y', 'z') over Rational Field by the ideal (-y*y*z - y*z*x - 2*y*z*z, x*y + y*z, x*x + x*y - y*x - y*y)
sage: i^3
-j*k*i - j*k*j - j*k*k
sage: j^3
-j*k*i - j*k*j - j*k*k

One can also test if the quotient is commutative:

sage: Q.is_commutative()
False
sage: J = F*[x*y-y*x,x*z-z*x,y*z-z*y,x^3-y^3]*F
sage: R = F.quo(J)
sage: R.is_commutative()
True

Miscellaneous

I inserted the documentation of the new modules into the reference manual - I think it looks nice, but I guess a referee should double check.

Doc tests pass for me. Thus: Ready for review!!

simon-king-jena commented 13 years ago
comment:23

I forgot one technical detail:

Not all rings inherit from the base class of rings. Examples are matrix algebras. In order to support non-commutative ideals for such rings, I provide the relevant methods as ParentMethods in the category of Rings(). Perhaps this duplication of code is considered a code smell.

At least, it enables the following:

sage: MS = MatrixSpace(QQ,2,2)
sage: MS*[MS.1,2]
Left Ideal 
(
  [0 1]
  [0 0],

  [2 0]
  [0 2]
)
 of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
simon-king-jena commented 13 years ago
comment:24

Apparently the patchbot does not read the ticket description.

Apply trac7797-full_letterplace_wrapper.patch

simon-king-jena commented 13 years ago
comment:25

I realise that I made at least two copy-and-paste errors in the examples above: One of the "timeit" commands should be removed, and the ideals I always is the same, namely I = F*[x*y+y*z,x<sup>2+x*y-y*x-y</sup>2]*F.

Sorry, Simon

simon-king-jena commented 13 years ago
comment:27

Anne Schilling reported a problem on sage-combinat-devel: The patch did apply, but "sage -br" did not work. I think I found the reason: The patch did not contain the empty __init__.py file in sage/algebras/letterplace/. Simply I forgot to add it.

I updated the patch, and now I hope it works. By the way, is the patchbot not working? I miss the coloured stamp on the ticket!

Apply trac7797-full_letterplace_wrapper.patch

simon-king-jena commented 13 years ago
comment:28

Currently, the Letterplace Gröbner bases can only be computed if the ring of coefficients is a field. I don't know whether this condition can be lifted and whether the Singular team is working on it.

That restriction was mentioned in the doc, but not very clearly, and the error message was obscure (namely, it came from the failing call to a Singular system function). There is now additional documentation of that restriction, and the error message is nicer.

Apply trac7797-full_letterplace_wrapper.patch

nthiery commented 13 years ago
comment:30

Version rebased on top of #10961 available from:

http://combinat.sagemath.org/patches/file/tip/trac7797-full_letterplace_wrapper.patch

simon-king-jena commented 13 years ago
comment:31

Replying to @nthiery:

Version rebased on top of #10961 available from:

http://combinat.sagemath.org/patches/file/tip/trac7797-full_letterplace_wrapper.patch

Thank you!

What is the procedure? Shall I replace my patch with the rebased one and state the dependency (to the patchbot), or shall the rebased version remain on the combinat patch server?

Best regards, Simon

anneschilling commented 13 years ago
comment:32

This patch provides an interface to Singular, which gives a faster implementation of free algebras and adds new features such as for example quotients of free algebras (for terms of homogeneous degree). I have tested the quotient algebra features extensively and they seem to work great!

I do not feel qualified to do a technical review, but I am happy to give a positive review for the new features added.

Anne

anneschilling commented 13 years ago
comment:33

Replying to @simon-king-jena:

Replying to @nthiery:

Version rebased on top of #10961 available from:

http://combinat.sagemath.org/patches/file/tip/trac7797-full_letterplace_wrapper.patch

Thank you!

What is the procedure? Shall I replace my patch with the rebased one and state the dependency (to the patchbot), or shall the rebased version remain on the combinat patch server?

Best regards, Simon

Since #10961 hopefully gets merged soon, you should probably upload the rebased version on trac and add `Dependencies: #10961' to the description. Then patchbot should in principle know!

simon-king-jena commented 13 years ago
comment:34

For the patchbot:

Apply trac7797-full_letterplace_wrapper.patch Depends on #10961

simon-king-jena commented 13 years ago

Description changed:

--- 
+++ 
@@ -14,3 +14,4 @@
 Examples are below, in the comments.

 Apply trac7797-full_letterplace_wrapper.patch
+Depends on #10961
simon-king-jena commented 13 years ago
comment:35

Replying to @anneschilling:

This patch provides an interface to Singular, which gives a faster implementation of free algebras and adds new features such as for example quotients of free algebras (for terms of homogeneous degree). I have tested the quotient algebra features extensively and they seem to work great!

Good! I'll give that feedback to the Singular team as well.

I do not feel qualified to do a technical review, but I am happy to give a positive review for the new features added.

Thank you! There is at least one point that should probably be raised on sage-algebra: Is it acceptable that (with my patch) the FreeAlgebra constructor returns a polynomial ring when asked for a free algebra with only one generator?

Mathematically it is correct, but I wonder if that is acceptable in a CAS.

Simon

simon-king-jena commented 13 years ago
comment:36

The new patch differs from the old one only in the comments.

Again for the patchbot:

Apply trac7797-full_letterplace_wrapper.patch

Depends on #10961

simon-king-jena commented 13 years ago

Description changed:

--- 
+++ 
@@ -14,4 +14,5 @@
 Examples are below, in the comments.

 Apply trac7797-full_letterplace_wrapper.patch
+
 Depends on #10961
simon-king-jena commented 13 years ago

Attachment: trac7797-full_letterplace_wrapper.patch.gz

A full wrapper for Singular's letterplace functionality, plus non-commutative ideals and ring quotients; rebased on top of 10961

simon-king-jena commented 13 years ago
comment:37

I added an __iter__ method for FreeAlgebraElement_letterplace, returning the list of pairs "exponent tuple, coefficient", and a method of FreeAlgebra_letterplace that returns an element, such that F(dict(p))==p for any element p of F. That has been requested by Nicolas.

For the patchbot:

Apply trac7797-full_letterplace_wrapper.patch

Depends on #10961

simon-king-jena commented 13 years ago
comment:38

Replying to @simon-king-jena:

...such that F(dict(p))==p for any element p of F.

Sorry, I meant to write p == F._from_dict_(dict(p)).

simon-king-jena commented 13 years ago
comment:39

It was suggested to split this ticket, and also it was suggested that the FreeAlgebra constructor always returns a free algebra, not a polynomial ring.

simon-king-jena commented 13 years ago

Reviewer: split the ticket

simon-king-jena commented 13 years ago

Changed reviewer from split the ticket to none

simon-king-jena commented 13 years ago
comment:40

I managed to split my patch. The part concerning "basic implementation of ideals in non-commutative rings" is now at #11068. The new patch is based on top of that.

TODO

Let the FreeAlgebra constructor always return a free algebra, not a polynomial ring.

New Feature

In addition to what was described in previous comments, my letterplace wrapper can compute complete twosided Gröbnerbases by an adaptive algorithm. The idea is simple: If the Gröbner basis is known out to degree 2*d-1, but the highest degree of its generators is d, then the Gröbner basis is complete.

Example:

sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
sage: I = F*[x*y-y*x,x*z-z*x,y*z-z*y,x^2*y-z^3,x*y^2+z*x^2]*F
sage: I.groebner_basis(Infinity)
Twosided Ideal (z*z*z*y*y + z*z*z*z*x, z*x*x*x + z*z*z*y, y*z - z*y, y*y*x + z*x*x, y*x*x - z*z*z, x*z - z*x, x*y - y*x) of Free Associative Unital Algebra on 3 generators ('x', 'y', 'z') over Rational Field

Since the commutators are contained in the ideal, we can verify that result with a commutative Gröbner basis, as follows:

sage: P.<c,b,a> = PolynomialRing(QQ,order='neglex')
sage: J = P*[a^2*b-c^3,a*b^2+c*a^2]
sage: J.groebner_basis()
[b*a^2 - c^3, b^2*a + c*a^2, c*a^3 + c^3*b, c^3*b^2 + c^4*a]

So, that's a good consistency test.

Apply trac7797-full_letterplace_wrapper_rel11068.patch

Depends on #11068

simon-king-jena commented 13 years ago

Work Issues: Unigenerated free algebra vs. univariate polynomial ring