sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.19k stars 412 forks source link

RuntimeError in universal enveloping algebra of a Lie algebra #26149

Open 97efbb86-de09-4609-9449-8bf7258d4da8 opened 5 years ago

97efbb86-de09-4609-9449-8bf7258d4da8 commented 5 years ago

For parents in the category FiniteDimensionalLieAlgebrasWithBasis over some non-fields, e.g. ZZ or Integers(n) for n non-prime, attempting to construct the universal enveloping algebra causes a runtime error:

sage: L = LieAlgebras(ZZ).FiniteDimensional().WithBasis().example(); L
An example of a finite dimensional Lie algebra with basis: the 3-dimensional abelian Lie algebra over Integer Ring
sage: L._construct_UEA()
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-ef80279ff4ee> in <module>()
----> 1 L._construct_UEA()

/home/eero/sage/local/lib/python2.7/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:13468)()
   2314         if self.cache is None:
   2315             f = self.f
-> 2316             self.cache = f(self._instance)
   2317         return self.cache
   2318 

/home/eero/sage/local/lib/python2.7/site-packages/sage/categories/finite_dimensional_lie_algebras_with_basis.pyc in _construct_UEA(self)
    114                 else:
    115                     rels[g0*g1] = g1*g0 + F.sum(val*get_var(g) for g, val in S[k])
--> 116             return F.g_algebra(rels)
    117 
    118         @lazy_attribute

/home/eero/sage/local/lib/python2.7/site-packages/sage/algebras/free_algebra.pyc in g_algebra(self, relations, names, order, check)
    874         from sage.rings.polynomial.plural import g_Algebra
    875         return g_Algebra(base_ring, cmat, dmat, names = names or self.variable_names(),
--> 876                          order=order, check=check)
    877 
    878     def poincare_birkhoff_witt_basis(self):

/home/eero/sage/local/lib/python2.7/site-packages/sage/structure/factory.pyx in sage.structure.factory.UniqueFactory.__call__ (build/cythonized/sage/structure/factory.c:2047)()
    366         key, kwds = self.create_key_and_extra_args(*args, **kwds)
    367         version = self.get_version(sage_version)
--> 368         return self.get_object(version, key, kwds)
    369 
    370     cpdef get_object(self, version, key, extra_args):

/home/eero/sage/local/lib/python2.7/site-packages/sage/structure/factory.pyx in sage.structure.factory.UniqueFactory.get_object (build/cythonized/sage/structure/factory.c:2423)()
    409         except KeyError:
    410             pass
--> 411         obj = self.create_object(version, key, **extra_args)
    412         self._cache[version, cache_key] = obj
    413         try:

/home/eero/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/plural.pyx in sage.rings.polynomial.plural.G_AlgFactory.create_object (build/cythonized/sage/rings/polynomial/plural.cpp:5201)()
    173         base_ring,names, c, d, order, category = key
    174         check = extra_args.get('check')
--> 175         return NCPolynomialRing_plural(base_ring, names, c, d, order,
    176                                        category, check)
    177 

/home/eero/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/plural.pyx in sage.rings.polynomial.plural.NCPolynomialRing_plural.__init__ (build/cythonized/sage/rings/polynomial/plural.cpp:6350)()
    331         ncalgebra = singular_function('nc_algebra')
    332 
--> 333         cdef RingWrap rw = ncalgebra(self._c, self._d, ring = P)
    334 
    335         #       rw._output()

/home/eero/sage/local/lib/python2.7/site-packages/sage/libs/singular/function.pyx in sage.libs.singular.function.SingularFunction.__call__ (build/cythonized/sage/libs/singular/function.cpp:15394)()
   1328         if not (isinstance(ring, MPolynomialRing_libsingular) or isinstance(ring, NCPolynomialRing_plural)):
   1329             raise TypeError("Cannot call Singular function '%s' with ring parameter of type '%s'"%(self._name,type(ring)))
-> 1330         return call_function(self, args, ring, interruptible, attributes)
   1331 
   1332     def _instancedoc_(self):

/home/eero/sage/local/lib/python2.7/site-packages/sage/libs/singular/function.pyx in sage.libs.singular.function.call_function (build/cythonized/sage/libs/singular/function.cpp:17499)()
   1526     if errorreported:
   1527         errorreported = 0
-> 1528         raise RuntimeError("error in Singular function call %r:\n%s" %
   1529             (self._name, "\n".join(error_messages)))
   1530 

RuntimeError: error in Singular function call 'nc_algebra':
not implemented for rings with rings as coeffients

This issue bubbles up to some seemingly unrelated contexts, e.g.

sage: L = LieAlgebras(ZZ).FiniteDimensional().WithBasis().example()
sage: L.an_element() in ZZ
Traceback (most recent call last)
...
RuntimeError: error in Singular function call 'nc_algebra':
not implemented for rings with rings as coeffients

This is caused by the element constructor ZZ(x) trying to call x.lift(), which leads to the call L._construct_UEA(), causing the above error.

CC: @tscrim

Component: categories

Keywords: Lie algebras

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

tscrim commented 5 years ago
comment:1

The calling lift for the latter check is the correct thing (trying to see if ZZ is the UEA).

However, the first part is really strange. It seems to be a bug in the g_algebra code. The correct relations are being constructed, but are not included in the UEA (I added a print(rels) statement to the code:

sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
sage: L._construct_UEA()
{b2*b1: b1*b2, b1*b0: b0*b1, b2*b0: b0*b2}
Noncommutative Multivariate Polynomial Ring in b0, b1, b2 over Rational Field, nc-relations: {}

Without going through the Lie algebra:

sage: F.<x,y,z> = FreeAlgebra(QQ)
sage: F.g_algebra({y*x: x*y, z*x: x*z, z*y: y*z})
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {}
sage: F.<x,y,z> = FreeAlgebra(ZZ)
sage: F.g_algebra({y*x: x*y, z*x: x*z, z*y: y*z})
# same traceback in the description