Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

r""" 

Lie Algebras With Basis 

 

AUTHORS: 

 

- Travis Scrimshaw (07-15-2013): Initial implementation 

""" 

 

#***************************************************************************** 

# Copyright (C) 2013-2017 Travis Scrimshaw <tcscrims at gmail.com> 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 2 of the License, or 

# (at your option) any later version. 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

from sage.misc.abstract_method import abstract_method 

from sage.misc.cachefunc import cached_method 

from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring 

from sage.categories.lie_algebras import LieAlgebras 

 

class LieAlgebrasWithBasis(CategoryWithAxiom_over_base_ring): 

""" 

Category of Lie algebras with a basis. 

""" 

_base_category_class_and_axiom = [LieAlgebras, "WithBasis"] 

 

def example(self, gens=None): 

""" 

Return an example of a Lie algebra as per 

:meth:`Category.example <sage.categories.category.Category.example>`. 

 

EXAMPLES:: 

 

sage: LieAlgebras(QQ).WithBasis().example() 

An example of a Lie algebra: the abelian Lie algebra on the 

generators indexed by Partitions over Rational Field 

 

Another set of generators can be specified as an optional argument:: 

 

sage: LieAlgebras(QQ).WithBasis().example(Compositions()) 

An example of a Lie algebra: the abelian Lie algebra on the 

generators indexed by Compositions of non-negative integers 

over Rational Field 

""" 

if gens is None: 

from sage.combinat.partition import Partitions 

gens = Partitions() 

from sage.categories.examples.lie_algebras_with_basis import Example 

return Example(self.base_ring(), gens) 

 

class ParentMethods: 

def _basis_key(self, x): 

""" 

Return the key used to compare two basis element indices. 

 

The default is to call the element itself. 

 

TESTS:: 

 

sage: L = LieAlgebras(QQ).WithBasis().example() 

sage: L._basis_key(Partition([3,1])) 

[3, 1] 

""" 

return x 

 

@abstract_method(optional=True) 

def bracket_on_basis(self, x, y): 

""" 

Return the bracket of basis elements indexed by ``x`` and ``y`` 

where ``x < y``. If this is not implemented, then the method 

``_bracket_()`` for the elements must be overwritten. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).WithBasis().example() 

sage: L.bracket_on_basis(Partition([3,1]), Partition([2,2,1,1])) 

0 

""" 

 

def module(self): 

""" 

Return an `R`-module which is isomorphic to the 

underlying `R`-module of ``self``. 

 

See 

:meth:`sage.categories.lie_algebras.LieAlgebras.module` for 

an explanation. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).WithBasis().example() 

sage: L.module() 

Free module generated by Partitions over Rational Field 

""" 

from sage.combinat.free_module import CombinatorialFreeModule 

try: 

# Try to see if it has an indexing set 

return CombinatorialFreeModule(self.base_ring(), self.basis().keys()) 

except AttributeError: 

# Otherwise just index by the basis of ``self`` as a fallback 

return CombinatorialFreeModule(self.base_ring(), self.basis()) 

 

def from_vector(self, v): 

""" 

Return the element of ``self`` corresponding to the 

vector ``v`` in ``self.module()``. 

 

Implement this if you implement :meth:`module`; see the 

documentation of 

:meth:`sage.categories.lie_algebras.LieAlgebras.module` 

for how this is to be done. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() 

sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u 

(1, 0, 0) 

sage: parent(u) is L 

True 

""" 

B = self.basis() 

return self.sum(v[i] * B[i] for i in v.support()) 

 

# Remove once #22629 is merged 

def dimension(self): 

""" 

Return the dimension of ``self``. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() 

sage: L.dimension() 

3 

 

:: 

 

sage: L = LieAlgebra(QQ, 'x,y', {('x','y'): {'x':1}}) 

sage: L.dimension() 

2 

""" 

return self.basis().cardinality() 

 

def pbw_basis(self, basis_key=None, **kwds): 

""" 

Return the Poincare-Birkhoff-Witt basis of the universal 

enveloping algebra corresponding to ``self``. 

 

EXAMPLES:: 

 

sage: L = lie_algebras.sl(QQ, 2) 

sage: PBW = L.pbw_basis() 

""" 

from sage.algebras.lie_algebras.poincare_birkhoff_witt \ 

import PoincareBirkhoffWittBasis 

return PoincareBirkhoffWittBasis(self, basis_key, **kwds) 

 

poincare_birkhoff_witt_basis = pbw_basis 

 

_construct_UEA = pbw_basis 

 

class ElementMethods: 

def _bracket_(self, y): 

""" 

Return the Lie bracket ``[self, y]``, where ``y`` is an 

element of the same Lie algebra as ``self``. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).WithBasis().example() 

sage: G = L.lie_algebra_generators() 

sage: x = G[Partition([4,3,3,1])] 

sage: y = G[Partition([6,1])] 

sage: x.bracket(y) 

0 

""" 

P = self.parent() 

 

def term(ml, mr): 

key_ml = P._basis_key(ml) 

key_mr = P._basis_key(mr) 

if key_ml == key_mr: 

return P.zero() 

if key_ml < key_mr: 

return P.bracket_on_basis(ml, mr) 

return -P.bracket_on_basis(mr, ml) 

 

return P.sum(cl * cr * term(ml, mr) 

for ml, cl in self for mr, cr in y) 

 

def to_vector(self): 

""" 

Return the vector in ``g.module()`` corresponding to the 

element ``self`` of ``g`` (where ``g`` is the parent of 

``self``). 

 

Implement this if you implement ``g.module()``. 

See :meth:`sage.categories.lie_algebras.LieAlgebras.module` 

for how this is to be done. 

 

EXAMPLES:: 

 

sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() 

sage: L.an_element().to_vector() 

(0, 0, 0) 

 

.. TODO:: 

 

Doctest this implementation on an example not overshadowed. 

""" 

M = self.parent().module() 

B = M.basis() 

return M.sum(self[i] * B[i] for i in self.support()) 

 

def lift(self): 

""" 

Lift ``self`` to the universal enveloping algebra. 

 

EXAMPLES:: 

 

sage: S = SymmetricGroup(3).algebra(QQ) 

sage: L = LieAlgebra(associative=S) 

sage: x = L.gen(2) 

sage: y = L.gen(1) 

sage: x.lift() 

b2 

sage: y.lift() 

b1 

sage: x * y 

b1*b2 + b4 - b5 

""" 

P = self.parent() 

UEA = P.universal_enveloping_algebra() 

try: 

gen_dict = UEA.algebra_generators() 

except (TypeError, AttributeError): 

gen_dict = UEA.gens_dict() 

s = UEA.zero() 

if not self: 

return s 

# Special hook for when the index set of the parent of ``self`` 

# does not match the generators index set of the UEA. 

if hasattr(P, '_UEA_names_map'): 

names_map = P._UEA_names_map 

for t, c in self.monomial_coefficients(copy=False).items(): 

s += c * gen_dict[names_map[t]] 

else: 

for t, c in self.monomial_coefficients(copy=False).items(): 

s += c * gen_dict[t] 

return s