Skip to content

Commit

Permalink
Fixing some issues; corrected primary_decomposition(); misc improveme…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
tscrim committed Apr 12, 2024
1 parent f32e5dc commit fa10d66
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
cpdef bracket(self, right)
cpdef _bracket_(self, right)
cpdef _vector_(self, bint sparse=*)
cpdef to_vector(self, bint sparse=*)
cpdef _vector_(self, bint sparse=*, order=*)
cpdef to_vector(self, bint sparse=*, order=*)
cpdef dict monomial_coefficients(self, bint copy=*)
# cpdef lift(self)

Expand Down
10 changes: 5 additions & 5 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
"""
return self._parent.module()(self.value.to_vector(sparse=sparse))

to_vector = _vector_
to_vector = _vector_

cpdef dict monomial_coefficients(self, bint copy=True):
r"""
Expand Down Expand Up @@ -835,8 +835,8 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
if v != zero:
yield (I[i], v)

cpdef _vector_(self, bint sparse=False):
"""
cpdef _vector_(self, bint sparse=False, order=None):
r"""
Return ``self`` as a vector.
EXAMPLES::
Expand All @@ -850,7 +850,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
return self.value.sparse_vector()
return self.value

cpdef to_vector(self, bint sparse=False):
cpdef to_vector(self, bint sparse=False, order=None):
"""
Return ``self`` as a vector.
Expand All @@ -861,7 +861,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
sage: a.to_vector()
(1, 3, -1/2)
"""
return self._vector_(sparse=sparse)
return self._vector_(sparse=sparse, order=order)

def lift(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/lie_algebras/subalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def _an_element_(self):
gens = self.lie_algebra_generators()
if not gens:
return self.zero()
return self.element_class(self, gens[0])
return next(iter(gens))

def _element_constructor_(self, x):
"""
Expand Down
16 changes: 12 additions & 4 deletions src/sage/categories/finite_dimensional_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,19 @@ def subalgebra(self, gens, category=None, *args, **opts):
sage: A = MS.subalgebra(gens)
sage: A.dimension()
5
sage: sl3 = LieAlgebra(GF(3), cartan_type=['A',2])
sage: MS = MatrixSpace(sl3.base_ring(), sl3.dimension())
sage: gens = [b.adjoint_matrix() for b in sl3.basis()]
sage: A = MS.subalgebra(gens)
sage: A.dimension()
57
"""
# add the unit to make sure it is unital
basis = []
new_elts = [self(g) for g in gens] + [self.one()]
while new_elts:
basis = self.echelon_form(basis + new_elts)
basis = self.echelon_form([self(g) for g in gens] + [self.one()])
dim = 0
while dim != len(basis):
dim = len(basis)
leadsupp = {b.leading_support(): b for b in basis}
sortsupp = sorted(leadsupp)
new_elts = []
Expand All @@ -456,6 +463,7 @@ def subalgebra(self, gens, category=None, *args, **opts):
elt -= c * leadsupp[s]
if elt:
new_elts.append(elt)
basis = self.echelon_form(basis + new_elts)
C = FiniteDimensionalAlgebrasWithBasis(self.category().base_ring())
category = C.Subobjects().or_subcategory(category)
return self.submodule(basis, check=False, already_echelonized=True,
Expand Down
77 changes: 33 additions & 44 deletions src/sage/categories/finite_dimensional_lie_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1652,17 +1652,16 @@ def fitting_one(self, gens):
....: ('c','d'): {'a':1}, ('c','e'): {'c':1}}
sage: L.<a,b,c,d,e> = LieAlgebra(QQ, scoeffs)
sage: FO = L.fitting_one([a]); FO
Ideal () of Lie algebra on 5 generators (a, b, c, d, e)
over Rational Field
Free module generated by {} over Rational Field
sage: FO.basis()
Family ()
sage: L.fitting_one([e]).basis()
Family (a, b, c)
Finite family {}
sage: [elt.lift() for elt in L.fitting_one([e]).basis()]
[a, b, c]
sage: L.fitting_one([a, c]).basis()
Family ()
sage: L.fitting_one([d, e]).basis()
Family (a, b, c)
Finite family {}
sage: [elt.lift() for elt in L.fitting_one([d, e]).basis()]
[a, b, c]
sage: L.fitting_one([a, e])
Traceback (most recent call last):
Expand All @@ -1676,8 +1675,8 @@ def fitting_one(self, gens):
cur = self.product_space(K)
while cur.dimension() < dim:
dim = cur.dimension()
cur = cur.product_space(K)
return cur
cur = K.product_space(cur)
return self.submodule(cur.gens())

@cached_method
def non_nilpotent_element(self):
Expand Down Expand Up @@ -1929,29 +1928,21 @@ def primary_decomposition(self, H=None):
EXAMPLES::
sage: sl3 = LieAlgebra(QQ, cartan_type=['A',2])
sage: sl3.primary_decomposition()
[Subalgebra generated by (h1, h2) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[alpha[1]]) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[-alpha[2]]) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[alpha[1] + alpha[2]]) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[-alpha[1] - alpha[2]]) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[alpha[2]]) of Lie algebra of ['A', 2] in the Chevalley basis,
Subalgebra generated by (E[-alpha[1]]) of Lie algebra of ['A', 2] in the Chevalley basis]
sage: [[sl3(b) for b in D.basis()] for D in sl3.primary_decomposition()]
[[h1, h2], [E[alpha[1]]], [E[-alpha[2]]], [E[alpha[1] + alpha[2]]],
[E[-alpha[1] - alpha[2]]], [E[alpha[2]]], [E[-alpha[1]]]]
sage: scoeffs = {('h1','x1'): {'x1':2}, ('h2','x1'): {'x1':2},
....: ('h1','y1'): {'y1':-2}, ('h2','y1'): {'y1':-2},
....: ('h1','x2'): {'x2':2}, ('h2','x2'): {'x2':-2},
....: ('h1','y2'): {'y2':-2}, ('h2','y2'): {'y2':2},
....: ('x1','y1'): {'h1':1/2, 'h2':1/2}, ('x2','y2'): {'h1':1/2, 'h2':-1/2}}
sage: L.<x1,x2,y1,y2,h1,h2> = LieAlgebra(QQ, scoeffs)
sage: L.primary_decomposition()
[Subalgebra generated by (h1, h2) of Lie algebra on 6 generators (x1, x2, y1, y2, h1, h2) over Rational Field,
Subalgebra generated by (x1) of Lie algebra on 6 generators (x1, x2, y1, y2, h1, h2) over Rational Field,
Subalgebra generated by (x2) of Lie algebra on 6 generators (x1, x2, y1, y2, h1, h2) over Rational Field,
Subalgebra generated by (y2) of Lie algebra on 6 generators (x1, x2, y1, y2, h1, h2) over Rational Field,
Subalgebra generated by (y1) of Lie algebra on 6 generators (x1, x2, y1, y2, h1, h2) over Rational Field]
sage: L.<x1,x2,y1,y2,h1,h2> = LieAlgebra(GF(5), scoeffs)
sage: L.primary_decomposition()
sage: [[L(b) for b in D.basis()] for D in L.primary_decomposition()]
[[h1, h2], [x1], [x2], [y2], [y1]]
sage: L5.<x1,x2,y1,y2,h1,h2> = LieAlgebra(GF(5), scoeffs)
sage: sorted([[L5(b) for b in D.basis()] for D in L5.primary_decomposition()], key=str)
[[h1, h2], [x1], [x2], [y1], [y2]]
"""
if self.killing_form_matrix().is_singular():
raise ValueError("the Lie algebra must have a nondegenerate Killing form")
Expand All @@ -1963,16 +1954,14 @@ def primary_decomposition(self, H=None):
H = self.cartan_subalgebra()
ret = [H]
rank = H.dimension()
HM = H.module()

M = self.module()
todo = [self.fitting_one(H)]

while todo:
V = todo.pop()
VM = V.module()
VM = M.submodule([v.lift()._vector_() for v in V.basis()])
MS = MatrixSpace(self.base_ring(), V.dimension())
TV = MS.subalgebra([MS([VM.coordinate_vector(h.bracket(b).to_vector())
for b in V.basis]).transpose()
TV = MS.subalgebra([MS([VM.coordinate_vector(self.bracket(h, b.lift())._vector_())
for b in V.basis()]).transpose()
for h in H.basis()])
processing = True
while processing:
Expand All @@ -1988,20 +1977,22 @@ def primary_decomposition(self, H=None):
for f, _ in factors:
# Compute the Fitting null in V of gen
K = f(x).right_kernel()
Vi = self.subalgebra([self(V.from_vector(v)) for v in K.basis()])
Vi = self.submodule([self(V.from_vector(v)) for v in K.basis()])
todo.append(Vi)
processing = False
return tuple(ret)

L0 = None
ret = []
for f, mult in minpoly.factor():
assert mult == 1
K = f(A).right_kernel()
Li = self.subalgebra([self.from_vector(v) for v in K.basis()])
Li = self.submodule([self.from_vector(v) for v in K.basis()])
if f.is_monomial():
L0 = Li
else:
ret.append(Li)
return [L0] + ret
return tuple([L0] + ret)

@cached_method
def direct_sum_decomposition(self):
Expand Down Expand Up @@ -2049,18 +2040,16 @@ def direct_sum_decomposition(self):
sage: TestSuite(L).run(elements=list(L.basis()))
sage: L.cartan_subalgebra().basis()
Family (a, b)
sage: [PD.basis() for PD in L.primary_decomposition()]
[Family (a, b), Family (c, d), Family (e, f)]
sage: [[L(b) for b in D.basis()] for D in L.primary_decomposition()]
[[a, b], [c, d], [e, f]]
sage: [DS.basis() for DS in L.direct_sum_decomposition()]
[Family (a, b, c, d, e, f)]
sage: L.<a,b,c,d,e,f> = LieAlgebra(CyclotomicField(4), scoeffs)
sage: L.cartan_subalgebra().basis()
Family (a, b)
sage: [PD.basis() for PD in L.primary_decomposition()]
[Family (a, b),
Family (zeta4*c + d,), Family (-zeta4*c + d,),
Family (-zeta4*e + f,), Family (zeta4*e + f,)]
sage: [[L(b) for b in D.basis()] for D in L.primary_decomposition()]
[[a, b], [c - zeta4*d], [c + zeta4*d], [e + zeta4*f], [e - zeta4*f]]
sage: [DS.basis() for DS in L.direct_sum_decomposition()]
[Family (-zeta4*a + b, zeta4*c + d, zeta4*e + f),
Family (zeta4*a + b, -zeta4*c + d, -zeta4*e + f)]
Expand All @@ -2070,7 +2059,7 @@ def direct_sum_decomposition(self):
cur_dim = 0
dim = self.dimension()
for L in D[1:]:
LI = self.ideal(L)
LI = self.ideal([b.lift() for b in L.basis()])
b = LI.lift(next(iter(LI.basis())))
if any(b in simple for simple in ret):
continue
Expand All @@ -2093,15 +2082,15 @@ def weight_basis(self):
sage: L = lie_algebras.cross_product(CyclotomicField(4))
sage: L.weight_basis()
{X: (0), zeta4*Y + Z: (zeta4), -zeta4*Y + Z: (-zeta4)}
{X: (0), Y - zeta4*Z: (zeta4), Y + zeta4*Z: (-zeta4)}
"""
PD = self.primary_decomposition()
H = [self(b) for b in PD[0].basis()]
if any(D.dimension() > 1 for D in PD[1:]):
raise ValueError(f"the Cartan subalgebra is not split for {self}")
from sage.modules.free_module import FreeModule
M = FreeModule(self.base_ring(), len(H))
wt_basis = {self(next(iter(D.basis()))): None for D in PD}
wt_basis = {next(iter(D.basis())).lift(): None for D in PD}
for r in wt_basis:
wt_basis[r] = M([bracket.leading_coefficient() / r.leading_coefficient()
if (bracket := h.bracket(r)) else 0
Expand Down

0 comments on commit fa10d66

Please sign in to comment.