def sl(R, n, representation='bracket'): r""" The Lie algebra `\mathfrak{sl}_n`. The Lie algebra `\mathfrak{sl}_n` is the type `A_{n-1}` Lie algebra and is finite dimensional. As a matrix Lie algebra, it is given by the set of all `n \times n` matrices with trace 0. INPUT: - ``R`` -- the base ring - ``n`` -- the size of the matrix - ``representation`` -- (default: ``'bracket'``) can be one of the following: * ``'bracket'`` - use brackets and the Chevalley basis * ``'matrix'`` - use matrices EXAMPLES: We first construct `\mathfrak{sl}_2` using the Chevalley basis:: sage: sl2 = lie_algebras.sl(QQ, 2); sl2 Lie algebra of ['A', 1] in the Chevalley basis sage: E,F,H = sl2.gens() sage: E.bracket(F) == H True sage: H.bracket(E) == 2*E True sage: H.bracket(F) == -2*F True We now construct `\mathfrak{sl}_2` as a matrix Lie algebra:: sage: sl2 = lie_algebras.sl(QQ, 2, representation='matrix') sage: E,F,H = sl2.gens() sage: E.bracket(F) == H True sage: H.bracket(E) == 2*E True sage: H.bracket(F) == -2*F True """ if representation == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(R, ['A', n-1]) if representation == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import sl as sl_matrix return sl_matrix(R, n) raise ValueError("invalid representation")
def su(R, n, representation='matrix'): r""" The Lie algebra `\mathfrak{su}_n`. The Lie algebra `\mathfrak{su}_n` is the compact real form of the type `A_{n-1}` Lie algebra and is finite-dimensional. As a matrix Lie algebra, it is given by the set of all `n \times n` skew-Hermitian matrices with trace 0. INPUT: - ``R`` -- the base ring - ``n`` -- the size of the matrix - ``representation`` -- (default: ``'matrix'``) can be one of the following: * ``'bracket'`` - use brackets and the Chevalley basis * ``'matrix'`` - use matrices EXAMPLES: We construct `\mathfrak{su}_2`, where the default is as a matrix Lie algebra:: sage: su2 = lie_algebras.su(QQ, 2) sage: E,H,F = su2.basis() sage: E.bracket(F) == 2*H True sage: H.bracket(E) == 2*F True sage: H.bracket(F) == -2*E True Since `\mathfrak{su}_n` is the same as the type `A_{n-1}` Lie algebra, the bracket is the same as :func:`sl`:: sage: su2 = lie_algebras.su(QQ, 2, representation='bracket') sage: su2 is lie_algebras.sl(QQ, 2, representation='bracket') True """ if representation == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(R, ['A', n-1]) if representation == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import MatrixCompactRealForm from sage.combinat.root_system.cartan_type import CartanType return MatrixCompactRealForm(R, CartanType(['A', n-1])) raise ValueError("invalid representation")
def example(self, n=2): """ Return an example of a Kac-Moody algebra as per :meth:`Category.example <sage.categories.category.Category.example>`. EXAMPLES:: sage: from sage.categories.kac_moody_algebras import KacMoodyAlgebras sage: KacMoodyAlgebras(QQ).example() Lie algebra of ['A', 2] in the Chevalley basis We can specify the rank of the example:: sage: KacMoodyAlgebras(QQ).example(4) Lie algebra of ['A', 4] in the Chevalley basis """ from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(self.base_ring(), ['A', n])
def sp(R, n, representation='bracket'): r""" The Lie algebra `\mathfrak{sp}_n`. The Lie algebra `\mathfrak{sp}_n` where `n = 2k` is the type `C_k` Lie algebra and is finite dimensional. As a matrix Lie algebra, it is given by the set of all matrices `X` that satisfy the equation: .. MATH:: X^T M - M X = 0 where .. MATH:: M = \begin{pmatrix} 0 & I_k \\ -I_k & 0 \end{pmatrix}. This is the Lie algebra of type `C_k`. INPUT: - ``R`` -- the base ring - ``n`` -- the size of the matrix - ``representation`` -- (default: ``'bracket'``) can be one of the following: * ``'bracket'`` - use brackets and the Chevalley basis * ``'matrix'`` - use matrices EXAMPLES: We first construct `\mathfrak{sp}_4` using the Chevalley basis:: sage: sp4 = lie_algebras.sp(QQ, 4); sp4 Lie algebra of ['C', 2] in the Chevalley basis sage: E1,E2, F1,F2, H1,H2 = sp4.gens() sage: sp4([E2, [E2, E1]]) 0 sage: X = sp4([E1, [E1, E2]]); X 2*E[2*alpha[1] + alpha[2]] sage: H1.bracket(X) 4*E[2*alpha[1] + alpha[2]] sage: H2.bracket(X) 0 sage: sp4([H1, [E1, E2]]) 0 sage: sp4([H2, [E1, E2]]) -E[alpha[1] + alpha[2]] We now construct `\mathfrak{sp}_4` as a matrix Lie algebra:: sage: sp4 = lie_algebras.sp(QQ, 4, representation='matrix'); sp4 Symplectic Lie algebra of rank 4 over Rational Field sage: E1,E2, F1,F2, H1,H2 = sp4.gens() sage: H1.bracket(E1) [ 0 2 0 0] [ 0 0 0 0] [ 0 0 0 0] [ 0 0 -2 0] sage: sp4([E1, [E1, E2]]) [0 0 2 0] [0 0 0 0] [0 0 0 0] [0 0 0 0] """ if n % 2: raise ValueError("n must be even") if representation == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(R, ['C', n//2]) if representation == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import sp as sp_matrix return sp_matrix(R, n) raise ValueError("invalid representation")
def so(R, n, representation='bracket'): r""" The Lie algebra `\mathfrak{so}_n`. The Lie algebra `\mathfrak{so}_n` is the type `B_k` Lie algebra if `n = 2k - 1` or the type `D_k` Lie algebra if `n = 2k`, and in either case is finite dimensional. As a matrix Lie algebra, it is given by the set of all real anti-symmetric `n \times n` matrices. INPUT: - ``R`` -- the base ring - ``n`` -- the size of the matrix - ``representation`` -- (default: ``'bracket'``) can be one of the following: * ``'bracket'`` - use brackets and the Chevalley basis * ``'matrix'`` - use matrices EXAMPLES: We first construct `\mathfrak{so}_5` using the Chevalley basis:: sage: so5 = lie_algebras.so(QQ, 5); so5 Lie algebra of ['B', 2] in the Chevalley basis sage: E1,E2, F1,F2, H1,H2 = so5.gens() sage: so5([E1, [E1, E2]]) 0 sage: X = so5([E2, [E2, E1]]); X -2*E[alpha[1] + 2*alpha[2]] sage: H1.bracket(X) 0 sage: H2.bracket(X) -4*E[alpha[1] + 2*alpha[2]] sage: so5([H1, [E1, E2]]) -E[alpha[1] + alpha[2]] sage: so5([H2, [E1, E2]]) 0 We do the same construction of `\mathfrak{so}_4` using the Chevalley basis:: sage: so4 = lie_algebras.so(QQ, 4); so4 Lie algebra of ['D', 2] in the Chevalley basis sage: E1,E2, F1,F2, H1,H2 = so4.gens() sage: H1.bracket(E1) 2*E[alpha[1]] sage: H2.bracket(E1) == so4.zero() True sage: E1.bracket(E2) == so4.zero() True We now construct `\mathfrak{so}_4` as a matrix Lie algebra:: sage: sl2 = lie_algebras.sl(QQ, 2, representation='matrix') sage: E1,E2, F1,F2, H1,H2 = so4.gens() sage: H2.bracket(E1) == so4.zero() True sage: E1.bracket(E2) == so4.zero() True """ if representation == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis if n % 2 == 0: return LieAlgebraChevalleyBasis(R, ['D', n//2]) else: return LieAlgebraChevalleyBasis(R, ['B', (n-1)//2]) if representation == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import so as so_matrix return so_matrix(R, n) raise ValueError("invalid representation")
def __classcall_private__(cls, R=None, arg0=None, arg1=None, names=None, index_set=None, abelian=False, **kwds): """ Select the correct parent based upon input. TESTS:: sage: LieAlgebra(QQ, abelian=True, names='x,y,z') Abelian Lie algebra on 3 generators (x, y, z) over Rational Field sage: LieAlgebra(QQ, {('e','h'): {'e':-2}, ('f','h'): {'f':2}, ....: ('e','f'): {'h':1}}, names='e,f,h') Lie algebra on 3 generators (e, f, h) over Rational Field """ # Parse associative algebra input # ----- assoc = kwds.get("associative", None) if assoc is not None: return LieAlgebraFromAssociative(assoc, names=names, index_set=index_set) # Parse input as a Cartan type # ----- ct = kwds.get("cartan_type", None) if ct is not None: from sage.combinat.root_system.cartan_type import CartanType ct = CartanType(ct) if ct.is_affine(): from sage.algebras.lie_algebras.affine_lie_algebra import AffineLieAlgebra return AffineLieAlgebra(R, cartan_type=ct, kac_moody=kwds.get("kac_moody", True)) if not ct.is_finite(): raise NotImplementedError( "non-finite types are not implemented yet, see trac #14901 for details" ) rep = kwds.get("representation", "bracket") if rep == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(R, ct) if rep == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import ClassicalMatrixLieAlgebra return ClassicalMatrixLieAlgebra(R, ct) raise ValueError("invalid representation") # Parse the remaining arguments # ----- if R is None: raise ValueError("invalid arguments") check_assoc = lambda A: (isinstance(A, (Ring, MatrixSpace)) or A in Rings() or A in Algebras(R).Associative()) if arg0 in ZZ or check_assoc(arg1): # Check if we need to swap the arguments arg0, arg1 = arg1, arg0 # Parse the first argument # ----- if isinstance(arg0, dict): if not arg0: from sage.algebras.lie_algebras.abelian import AbelianLieAlgebra return AbelianLieAlgebra(R, names, index_set) elif isinstance(next(iter(arg0.keys())), (list, tuple)): # We assume it is some structure coefficients arg1, arg0 = arg0, arg1 if isinstance(arg0, (list, tuple)): if all(isinstance(x, str) for x in arg0): # If they are all strings, then it is a list of variables names = tuple(arg0) if isinstance(arg0, str): names = tuple(arg0.split(',')) elif isinstance(names, str): names = tuple(names.split(',')) # Parse the second argument if isinstance(arg1, dict): # Assume it is some structure coefficients from sage.algebras.lie_algebras.structure_coefficients import LieAlgebraWithStructureCoefficients return LieAlgebraWithStructureCoefficients(R, arg1, names, index_set, **kwds) # Otherwise it must be either a free or abelian Lie algebra if arg1 in ZZ: if isinstance(arg0, str): names = arg0 if names is None: index_set = list(range(arg1)) else: if isinstance(names, str): names = tuple(names.split(',')) if arg1 != 1 and len(names) == 1: names = tuple('{}{}'.format(names[0], i) for i in range(arg1)) if arg1 != len(names): raise ValueError("the number of names must equal the" " number of generators") if abelian: from sage.algebras.lie_algebras.abelian import AbelianLieAlgebra return AbelianLieAlgebra(R, names, index_set) # Otherwise it is the free Lie algebra rep = kwds.get("representation", "bracket") if rep == "polynomial": # Construct the free Lie algebra from polynomials in the # free (associative unital) algebra # TODO: Change this to accept an index set once FreeAlgebra accepts one from sage.algebras.free_algebra import FreeAlgebra F = FreeAlgebra(R, names) if index_set is None: index_set = F.variable_names() # TODO: As part of #16823, this should instead construct a # subclass with specialized methods for the free Lie algebra return LieAlgebraFromAssociative(F, F.gens(), names=names, index_set=index_set) raise NotImplementedError("the free Lie algebra has only been" " implemented using polynomials in the" " free algebra, see trac ticket #16823")