Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Refactored nilpotent Lie algebra constructor into Lie algebra constru…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
ehaka committed Aug 21, 2018
1 parent 8b3c585 commit a1e1ace
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 86 deletions.
38 changes: 34 additions & 4 deletions src/sage/algebras/lie_algebras/lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,31 @@ class LieAlgebra(Parent, UniqueRepresentation): # IndexedGenerators):
sage: P.bracket(a, b) + P.bracket(a - c, b + 3*c)
2*a*b + 3*a*c - 2*b*a + b*c - 3*c*a - c*b
**6.** Nilpotent Lie algebras are Lie algebras such that there exists an
integer `s` such that all iterated brackets of length longer than `s`
are zero. They can be constructed from structural coefficients using the
``nilpotent`` keyword::
sage: L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
sage: L.category()
Category of finite dimensional nilpotent lie algebras with basis over Rational Field
A second example defining the Engel Lie algebra::
sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
sage: E.<X,Y,Z,W> = LieAlgebra(QQ, sc, nilpotent=True); E
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
sage: E.step()
3
sage: E[X, Y + Z]
Z + W
sage: E[X, [X, Y + Z]]
W
sage: E[X, [X, [X, Y + Z]]]
0
REFERENCES:
- [deG2000]_ Willem A. de Graaf. *Lie Algebras: Theory and Algorithms*.
Expand All @@ -297,7 +322,8 @@ class LieAlgebra(Parent, UniqueRepresentation): # IndexedGenerators):
# __classcall_private__ will only be called when calling LieAlgebra
@staticmethod
def __classcall_private__(cls, R=None, arg0=None, arg1=None, names=None,
index_set=None, abelian=False, **kwds):
index_set=None, abelian=False,
nilpotent=False, **kwds):
"""
Select the correct parent based upon input.
Expand Down Expand Up @@ -376,6 +402,10 @@ def __classcall_private__(cls, R=None, arg0=None, arg1=None, names=None,

if isinstance(arg1, dict):
# Assume it is some structure coefficients
if nilpotent:
from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra_dense
return NilpotentLieAlgebra_dense(R, arg1, names, index_set, **kwds)

from sage.algebras.lie_algebras.structure_coefficients import LieAlgebraWithStructureCoefficients
return LieAlgebraWithStructureCoefficients(R, arg1, names, index_set, **kwds)

Expand Down Expand Up @@ -434,7 +464,7 @@ def __init__(self, R, names=None, category=None):
sage: L.<x,y> = LieAlgebra(QQ, abelian=True)
sage: L.category()
Category of finite dimensional lie algebras with basis over Rational Field
Category of finite dimensional nilpotent lie algebras with basis over Rational Field
"""
category = LieAlgebras(R).or_subcategory(category)
Parent.__init__(self, base=R, names=names, category=category)
Expand Down Expand Up @@ -671,7 +701,7 @@ def __init__(self, R, names=None, index_set=None, category=None, prefix='L', **k
sage: L.<x,y> = LieAlgebra(QQ, abelian=True)
sage: L.category()
Category of finite dimensional lie algebras with basis over Rational Field
Category of finite dimensional nilpotent lie algebras with basis over Rational Field
"""
self._indices = index_set
LieAlgebra.__init__(self, R, names, category)
Expand Down Expand Up @@ -755,7 +785,7 @@ def __init__(self, R, names=None, index_set=None, category=None):
sage: L.<x,y> = LieAlgebra(QQ, abelian=True)
sage: L.category()
Category of finite dimensional lie algebras with basis over Rational Field
Category of finite dimensional nilpotent lie algebras with basis over Rational Field
"""
LieAlgebraWithGenerators.__init__(self, R, names, index_set, category)
self.__ngens = len(self._indices)
Expand Down
67 changes: 7 additions & 60 deletions src/sage/algebras/lie_algebras/nilpotent_lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class NilpotentLieAlgebra_dense(LieAlgebraWithStructureCoefficients):
same form as to a
:class:`~sage.algebras.lie_algebras.structure_coefficients.LieAlgebraWithStructureCoefficients`::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L.<X,Y,Z,W> = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}})
sage: L.<X,Y,Z,W> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
sage: L[X, Y]
Expand All @@ -56,14 +55,14 @@ class NilpotentLieAlgebra_dense(LieAlgebraWithStructureCoefficients):
If the parameter ``names`` is omitted, then the terms appearing in the
structural coefficients are used as names::
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}}); L
sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True); L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
TESTS::
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1},
....: ('X','Z'): {'W': 1},
....: ('Y','Z'): {'T': 1}})
sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1},
....: ('X','Z'): {'W': 1},
....: ('Y','Z'): {'T': 1}}, nilpotent=True)
sage: TestSuite(L).run()
"""
@staticmethod
Expand Down Expand Up @@ -120,8 +119,7 @@ def __init__(self, R, s_coeff, names, index_set, step=None,
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L.<X,Y,Z,W> = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}})
sage: L.<X,Y,Z,W> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: TestSuite(L).run()
"""
if step:
Expand All @@ -139,59 +137,8 @@ def _repr_(self):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L.<X,Y,Z,W> = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}})
sage: L.<X,Y,Z,W> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
"""
return "Nilpotent %s" % (super(NilpotentLieAlgebra_dense, self)._repr_())

def NilpotentLieAlgebra(R, arg, step=None, names=None,
free=False, category=None, **kwds):
r"""
Construct a nilpotent Lie algebra.
INPUT:
- ``R`` -- the base ring
- ``arg`` -- if the argument ``free`` is ``False``, then ``arg`` should be
a dictionary of structural coefficients; otherwise ``arg`` should be
the number of generators of the free nilpotent Lie algebra
- ``step`` -- (optional) an integer; the nilpotency step of the
Lie algebra if known; otherwise it will be computed when needed;
the ``step`` must be specified if ``free`` is ``True``
- ``names`` -- (default:``None``) a list of strings to use as names of
basis elements; if ``None`` and ``free`` is ``False``, the names will
be extracted from the structural coefficients; otherwise the names
will be autogenerated
- ``category`` -- (optional) a subcategory of nilpotent Lie algebras
with basis
EXAMPLES:
The Heisenberg algebra from its structural coefficients::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}}); L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
sage: L.category()
Category of finite dimensional nilpotent lie algebras with basis over Rational Field
Defining the Engel Lie algebra and binding its basis::
sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
sage: E.<X,Y,Z,W> = NilpotentLieAlgebra(QQ, sc); E
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
sage: E[X, Y + Z]
Z + W
sage: E[X, [X, Y + Z]]
W
sage: E[X, [X, [X, Y + Z]]]
0
"""
if free:
raise NotImplementedError("free nilpotent Lie algebras not yet implemented")

return NilpotentLieAlgebra_dense(R, arg, names, step=step,
category=category, **kwds)

Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ def _test_grading(self, **options):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: L = NilpotentLieAlgebra(QQ, {('x','y'): {'z': 1}},
....: category=C)
sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}},
....: nilpotent=True, category=C)
sage: L._test_grading()
sage: L = NilpotentLieAlgebra(QQ, {('x','y'): {'x': 1}},
....: category=C)
sage: L = LieAlgebra(QQ, {('x','y'): {'x': 1}},
....: nilpotent=True, category=C)
sage: L._test_grading()
Traceback (most recent call last):
...
Expand Down Expand Up @@ -93,11 +92,10 @@ def homogeneous_component_as_submodule(self, d):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: L = NilpotentLieAlgebra(QQ, {('x','y'): {'z': 1}},
....: category=C)
sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}},
....: nilpotent=True, category=C)
sage: L.homogeneous_component_as_submodule(2)
Sparse vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
Expand Down Expand Up @@ -133,15 +131,14 @@ def _test_generated_by_degree_one(self, **options):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: sc = {('x','y'): {'z': 1}}
sage: L.<x,y,z> = NilpotentLieAlgebra(QQ, sc, category=C)
sage: L.<x,y,z> = LieAlgebra(QQ, sc, nilpotent=True, category=C)
sage: L._test_generated_by_degree_one()
sage: sc = {('x','y'): {'z': 1}, ('a','b'): {'c':1}, ('z','c'): {'m':1}}
sage: L.<a,b,c,m,x,y,z> = NilpotentLieAlgebra(QQ, sc, category=C)
sage: L.<a,b,c,m,x,y,z> = LieAlgebra(QQ, sc, nilpotent=True, category=C)
sage: L._test_generated_by_degree_one()
Traceback (most recent call last):
...
Expand Down Expand Up @@ -186,11 +183,10 @@ def degree_on_basis(self, m):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: sc = {('X','Y'): {'Z': 1}}
sage: L.<X,Y,Z> = NilpotentLieAlgebra(QQ, sc, category=C)
sage: L.<X,Y,Z> = LieAlgebra(QQ, sc, nilpotent=True, category=C)
sage: L.degree_on_basis(X.leading_support())
1
sage: X.degree()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def _test_nilpotency(self, **options):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}})
sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L._test_nilpotency()
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}}, step = 3)
sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}},
....: nilpotent=True, step = 3)
sage: L._test_nilpotency()
Traceback (most recent call last):
...
AssertionError: claimed nilpotency step 3 does not match the actual nilpotency step 2
sage: L = NilpotentLieAlgebra(QQ, {('X','Y'): {'X': 1}})
sage: L = LieAlgebra(QQ, {('X','Y'): {'X': 1}}, nilpotent=True)
sage: L._test_nilpotency()
Traceback (most recent call last):
...
Expand All @@ -93,11 +93,11 @@ def step(self):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: NilpotentLieAlgebra(QQ, {('X','Y'): {'Z': 1}}).step()
sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L.step()
2
sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
sage: NilpotentLieAlgebra(QQ, sc).step()
sage: LieAlgebra(QQ, sc, nilpotent=True).step()
3
"""
if not hasattr(self, '_step'):
Expand All @@ -110,8 +110,7 @@ def is_nilpotent(self):
EXAMPLES::
sage: from sage.algebras.lie_algebras.nilpotent_lie_algebra import NilpotentLieAlgebra
sage: L = NilpotentLieAlgebra(QQ, {('x','y'): {'z': 1}})
sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}}, nilpotent=True)
sage: L.is_nilpotent()
True
"""
Expand Down

0 comments on commit a1e1ace

Please sign in to comment.