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

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

r""" 

Examples of a Lie algebra 

""" 

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

# Copyright (C) 2014 Travis Scrimshaw <tscrim at ucdavis.edu> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

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

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

 

#from sage.misc.cachefunc import cached_method 

from sage.sets.family import Family 

from sage.categories.all import LieAlgebras 

from sage.structure.parent import Parent 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.element_wrapper import ElementWrapper 

 

class LieAlgebraFromAssociative(Parent, UniqueRepresentation): 

r""" 

An example of a Lie algebra: a Lie algebra generated by 

a set of elements of an associative algebra. 

 

This class illustrates a minimal implementation of a Lie algebra. 

 

Let `R` be a commutative ring, and `A` an associative 

`R`-algebra. The Lie algebra `A` (sometimes denoted `A^-`) 

is defined to be the `R`-module `A` with Lie bracket given by 

the commutator in `A`: that is, `[a, b] := ab - ba` for all 

`a, b \in A`. 

 

What this class implements is not precisely `A^-`, however; 

it is the Lie subalgebra of `A^-` generated by the elements 

of the iterable ``gens``. This specific implementation does not 

provide a reasonable containment test (i.e., it does not allow 

you to check if a given element `a` of `A^-` belongs to this 

Lie subalgebra); it, however, allows computing inside it. 

 

INPUT: 

 

- ``gens`` -- a nonempty iterable consisting of elements of an 

associative algebra `A` 

 

OUTPUT: 

 

The Lie subalgebra of `A^-` generated by the elements of 

``gens`` 

 

EXAMPLES: 

 

We create a model of `\mathfrak{sl}_2` using matrices:: 

 

sage: gens = [matrix([[0,1],[0,0]]), matrix([[0,0],[1,0]]), matrix([[1,0],[0,-1]])] 

sage: for g in gens: 

....: g.set_immutable() 

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

sage: e,f,h = L.lie_algebra_generators() 

sage: e.bracket(f) == h 

True 

sage: h.bracket(e) == 2*e 

True 

sage: h.bracket(f) == -2*f 

True 

""" 

@staticmethod 

def __classcall_private__(cls, gens): 

""" 

Normalize input to ensure a unique representation. 

 

EXAMPLES:: 

 

sage: S3 = SymmetricGroupAlgebra(QQ, 3) 

sage: L1 = LieAlgebras(QQ).example() 

sage: gens = list(S3.algebra_generators()) 

sage: L2 = LieAlgebras(QQ).example(gens) 

sage: L1 is L2 

True 

""" 

return super(LieAlgebraFromAssociative, cls).__classcall__(cls, tuple(gens)) 

 

def __init__(self, gens): 

""" 

EXAMPLES:: 

 

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

sage: TestSuite(L).run() 

""" 

if not gens: 

raise ValueError("need at least one generator") 

self._gens = gens 

self._A = gens[0].parent() 

R = self._A.base_ring() 

Parent.__init__(self, base=R, category=LieAlgebras(R)) 

 

def _repr_(self): 

""" 

EXAMPLES:: 

 

sage: LieAlgebras(QQ).example() 

An example of a Lie algebra: the Lie algebra from the associative algebra 

Symmetric group algebra of order 3 over Rational Field 

generated by ([2, 1, 3], [2, 3, 1]) 

""" 

return "An example of a Lie algebra: the Lie algebra from the" \ 

" associative algebra {} generated by {}".format( 

self._A, self._gens) 

 

def _element_constructor_(self, value): 

""" 

Return an element of ``self``. 

 

EXAMPLES:: 

 

sage: S3 = SymmetricGroupAlgebra(ZZ, 3) 

sage: gens = S3.algebra_generators() 

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

sage: L(3*gens[0] + gens[1]) 

3*[2, 1, 3] + [2, 3, 1] 

""" 

return self.element_class(self, self._A(value)) 

 

def zero(self): 

""" 

Return the element 0. 

 

EXAMPLES:: 

 

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

sage: L.zero() 

0 

""" 

return self.element_class(self, self._A.zero()) 

 

def lie_algebra_generators(self): 

""" 

Return the generators of ``self`` as a Lie algebra. 

 

EXAMPLES:: 

 

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

sage: L.lie_algebra_generators() 

Family ([2, 1, 3], [2, 3, 1]) 

""" 

return Family([self.element_class(self, g) for g in self._gens]) 

 

# TODO: refactor to use LieAlgebraElementWrapper once more of #14901 is added in 

class Element(ElementWrapper): 

""" 

Wrap an element as a Lie algebra element. 

""" 

def __eq__(self, rhs): 

""" 

Check equality. 

 

This check is rather restrictive: ``self`` and ``rhs`` are only 

revealed as equal if they are equal *and* have the same parent 

(or both are zero). 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: x == x 

True 

sage: x.bracket(y) == -y.bracket(x) 

True 

sage: x == y 

False 

sage: x.bracket(x) == L.zero() 

True 

sage: x.bracket(x) == 0 

True 

""" 

if not isinstance(rhs, LieAlgebraFromAssociative.Element): 

return self.value == 0 and rhs == 0 

return self.parent() == rhs.parent() and self.value == rhs.value 

 

def __ne__(self, rhs): 

""" 

Check not-equals. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: x != y 

True 

sage: x != 0 

True 

sage: x != x 

False 

sage: x.bracket(y) != -y.bracket(x) 

False 

""" 

return not self.__eq__(rhs) 

 

def __bool__(self): 

""" 

Check non-zero. 

 

EXAMPLES:: 

 

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

sage: bool(sum(L.lie_algebra_generators())) 

True 

sage: bool(L.zero()) 

False 

""" 

return bool(self.value) 

 

__nonzero__ = __bool__ 

 

def _add_(self, rhs): 

""" 

Add ``self`` and ``rhs``. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: x + y 

[2, 1, 3] + [2, 3, 1] 

""" 

return self.__class__(self.parent(), self.value + rhs.value) 

 

def _sub_(self, rhs): 

""" 

Subtract ``self`` and ``rhs``. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: x - y 

[2, 1, 3] - [2, 3, 1] 

""" 

return self.__class__(self.parent(), self.value - rhs.value) 

 

def _acted_upon_(self, scalar, self_on_left=False): 

""" 

Return the action of a scalar on ``self``. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: 3 * x 

3*[2, 1, 3] 

""" 

# This was copied, but IDK if it still applies: 

# With the current design, the coercion model does not have 

# enough information to detect apriori that this method only 

# accepts scalars; so it tries on some elements(), and we need 

# to make sure to report an error. 

if hasattr( scalar, 'parent' ) and scalar.parent() != self.base_ring(): 

# Temporary needed by coercion (see Polynomial/FractionField tests). 

if self.base_ring().has_coerce_map_from(scalar.parent()): 

scalar = self.base_ring()( scalar ) 

else: 

return None 

if self_on_left: 

return self.__class__(self.parent(), self.value * scalar) 

return self.__class__(self.parent(), scalar * self.value) 

 

def __div__(self, x, self_on_left=False): 

""" 

Division by coefficients. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: y / 4 

1/4*[2, 3, 1] 

""" 

if self_on_left: 

return self * (~x) 

return (~x) * self 

 

def __neg__(self): 

""" 

Return the negation of ``self``. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: -x 

-[2, 1, 3] 

""" 

return self.__class__(self.parent(), -self.value) 

 

def __getitem__(self, i): 

""" 

Redirect the ``__getitem__()`` to the wrapped element. 

 

EXAMPLES:: 

 

sage: gens = [matrix([[0,1],[0,0]]), matrix([[0,0],[1,0]]), matrix([[1,0],[0,-1]])] 

sage: for g in gens: 

....: g.set_immutable() 

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

sage: e,f,h = L.lie_algebra_generators() 

sage: h[0,0] 

1 

sage: h[1,1] 

-1 

sage: h[0,1] 

0 

""" 

return self.value.__getitem__(i) 

 

def _bracket_(self, rhs): 

""" 

Return the Lie bracket ``[self, rhs]``. 

 

EXAMPLES:: 

 

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

sage: x,y = L.lie_algebra_generators() 

sage: elt = 2*x - y 

sage: elt.bracket(elt) 

0 

sage: elt.bracket(x) 

-[1, 3, 2] + [3, 2, 1] 

sage: elt2 = x.bracket(y) + x 

sage: elt.bracket(elt2) 

-2*[2, 1, 3] + 4*[2, 3, 1] - 4*[3, 1, 2] + 2*[3, 2, 1] 

""" 

return self.__class__(self.parent(), self.value * rhs.value - rhs.value * self.value) 

 

Example = LieAlgebraFromAssociative