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

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

r""" 

Spin Crystals 

 

These are the crystals associated with the three spin 

representations: the spin representations of odd orthogonal groups 

(or rather their double covers); and the `+` and `-` spin 

representations of the even orthogonal groups. 

 

We follow Kashiwara and Nakashima (Journal of Algebra 165, 1994) in 

representing the elements of the spin crystal by sequences of signs 

`\pm`. 

""" 

#TODO: Do we want the following two representations? 

# 

#Two other representations are available as attributes 

#:meth:`Spin.internal_repn` and :meth:`Spin.signature` of the crystal element. 

# 

#- A numerical internal representation, an integer `n` such that if `n-1` 

# is written in binary and the `1`'s are replaced by ``-``, the `0`'s by 

# ``+`` 

# 

#- The signature, which is a list in which ``+`` is replaced by `+1` and 

# ``-`` by `-1`. 

 

 

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

# Copyright (C) 2007 Anne Schilling <anne at math.ucdavis.edu> 

# Nicolas Thiery <nthiery at users.sf.net> 

# Daniel Bump <bump at match.stanford.edu> 

# 

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

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

from __future__ import print_function 

 

from sage.misc.cachefunc import cached_method 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.parent import Parent 

from sage.categories.classical_crystals import ClassicalCrystals 

from sage.combinat.crystals.letters import LetterTuple 

from sage.combinat.root_system.cartan_type import CartanType 

from sage.combinat.tableau import Tableau 

 

 

######################### 

# Type B spin 

######################### 

 

def CrystalOfSpins(ct): 

r""" 

Return the spin crystal of the given type `B`. 

 

This is a combinatorial model for the crystal with highest weight 

`Lambda_n` (the `n`-th fundamental weight). It has 

`2^n` elements, here called Spins. See also 

:func:`~sage.combinat.crystals.letters.CrystalOfLetters`, 

:func:`~sage.combinat.crystals.spins.CrystalOfSpinsPlus`, 

and :func:`~sage.combinat.crystals.spins.CrystalOfSpinsMinus`. 

 

INPUT: 

 

- ``['B', n]`` - A Cartan type `B_n`. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: C.list() 

[+++, ++-, +-+, -++, +--, -+-, --+, ---] 

sage: C.cartan_type() 

['B', 3] 

 

:: 

 

sage: [x.signature() for x in C] 

['+++', '++-', '+-+', '-++', '+--', '-+-', '--+', '---'] 

 

TESTS:: 

 

sage: crystals.TensorProduct(C,C,generators=[[C.list()[0],C.list()[0]]]).cardinality() 

35 

""" 

ct = CartanType(ct) 

if ct[0] == 'B': 

return GenericCrystalOfSpins(ct, Spin_crystal_type_B_element, "spins") 

else: 

raise NotImplementedError 

 

######################### 

# Type D spins 

######################### 

 

def CrystalOfSpinsPlus(ct): 

r""" 

Return the plus spin crystal of the given type D. 

 

This is the crystal with highest weight `Lambda_n` (the 

`n`-th fundamental weight). 

 

INPUT: 

 

- ``['D', n]`` - A Cartan type `D_n`. 

 

EXAMPLES:: 

 

sage: D = crystals.SpinsPlus(['D',4]) 

sage: D.list() 

[++++, ++--, +-+-, -++-, +--+, -+-+, --++, ----] 

 

:: 

 

sage: [x.signature() for x in D] 

['++++', '++--', '+-+-', '-++-', '+--+', '-+-+', '--++', '----'] 

 

TESTS:: 

 

sage: TestSuite(D).run() 

""" 

ct = CartanType(ct) 

if ct[0] == 'D': 

return GenericCrystalOfSpins(ct, Spin_crystal_type_D_element, "plus") 

else: 

raise NotImplementedError 

 

def CrystalOfSpinsMinus(ct): 

r""" 

Return the minus spin crystal of the given type D. 

 

This is the crystal with highest weight `Lambda_{n-1}` 

(the `(n-1)`-st fundamental weight). 

 

INPUT: 

 

- ``['D', n]`` - A Cartan type `D_n`. 

 

EXAMPLES:: 

 

sage: E = crystals.SpinsMinus(['D',4]) 

sage: E.list() 

[+++-, ++-+, +-++, -+++, +---, -+--, --+-, ---+] 

sage: [x.signature() for x in E] 

['+++-', '++-+', '+-++', '-+++', '+---', '-+--', '--+-', '---+'] 

 

TESTS:: 

 

sage: len(crystals.TensorProduct(E,E,generators=[[E[0],E[0]]]).list()) 

35 

sage: D = crystals.SpinsPlus(['D',4]) 

sage: len(crystals.TensorProduct(D,E,generators=[[D.list()[0],E.list()[0]]]).list()) 

56 

""" 

ct = CartanType(ct) 

if ct[0] == 'D': 

return GenericCrystalOfSpins(ct, Spin_crystal_type_D_element, "minus") 

else: 

raise NotImplementedError 

 

class GenericCrystalOfSpins(UniqueRepresentation, Parent): 

""" 

A generic crystal of spins. 

""" 

def __init__(self, ct, element_class, case): 

""" 

EXAMPLES:: 

 

sage: E = crystals.SpinsMinus(['D',4]) 

sage: TestSuite(E).run() 

""" 

self._cartan_type = CartanType(ct) 

if case == "spins": 

self.rename("The crystal of spins for type %s"%ct) 

elif case == "plus": 

self.rename("The plus crystal of spins for type %s"%ct) 

else: 

self.rename("The minus crystal of spins for type %s"%ct) 

 

self.Element = element_class 

Parent.__init__(self, category = ClassicalCrystals()) 

 

if case == "minus": 

generator = [1]*(ct[1]-1) 

generator.append(-1) 

else: 

generator = [1]*ct[1] 

self.module_generators = (self.element_class(self, tuple(generator)),) 

 

def _element_constructor_(self, value): 

""" 

Construct an element of ``self`` from ``value``. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: x = C((1,1,1)); x 

+++ 

sage: y = C([1,1,1]); y 

+++ 

sage: x == y 

True 

""" 

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

 

def digraph(self): 

""" 

Return the directed graph associated to ``self``. 

 

EXAMPLES:: 

 

sage: crystals.Spins(['B',3]).digraph() 

Digraph on 8 vertices 

""" 

try: 

return self._digraph 

except AttributeError: 

pass 

self._digraph = super(GenericCrystalOfSpins, self).digraph() 

self._digraph.copy(immutable=True) 

return self._digraph 

 

def lt_elements(self, x,y): 

r""" 

Return ``True`` if and only if there is a path from ``x`` to ``y`` 

in the crystal graph. 

 

Because the crystal graph is classical, it is a directed acyclic 

graph which can be interpreted as a poset. This function implements 

the comparison function of this poset. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: x = C([1,1,1]) 

sage: y = C([-1,-1,-1]) 

sage: C.lt_elements(x,y) 

True 

sage: C.lt_elements(y,x) 

False 

sage: C.lt_elements(x,x) 

False 

""" 

if x.parent() is not self or y.parent() is not self: 

raise ValueError("both elements must be in this crystal") 

try: 

GC = self._digraph_closure 

except AttributeError: 

GC = self.digraph().transitive_closure() 

self._digraph_closure = GC 

if GC.has_edge(x,y): 

return True 

return False 

 

class Spin(LetterTuple): 

""" 

A spin letter in the crystal of spins. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: c = C([1,1,1]) 

sage: TestSuite(c).run() 

 

sage: C([1,1,1]).parent() 

The crystal of spins for type ['B', 3] 

 

sage: c = C([1,1,1]) 

sage: c._repr_() 

'+++' 

 

sage: D = crystals.Spins(['B',4]) 

sage: a = C([1,1,1]) 

sage: b = C([-1,-1,-1]) 

sage: c = D([1,1,1,1]) 

sage: a == a 

True 

sage: a == b 

False 

sage: b == c 

False 

""" 

def signature(self): 

""" 

Return the signature of ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: C([1,1,1]).signature() 

'+++' 

sage: C([1,1,-1]).signature() 

'++-' 

""" 

sword = "" 

for x in range(self.parent().cartan_type().n): 

sword += "+" if self.value[x] == 1 else "-" 

return sword 

 

def _repr_(self): 

""" 

Represents the spin elements in terms of its signature. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: b = C([1,1,-1]) 

sage: b 

++- 

sage: b._repr_() 

'++-' 

""" 

return self.signature() 

 

def _repr_diagram(self): 

""" 

Return a representation of ``self`` as a diagram. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: b = C([1,1,-1]) 

sage: print(b._repr_diagram()) 

+ 

+ 

- 

""" 

return '\n'.join(self.signature()) 

 

def pp(self): 

""" 

Pretty print ``self`` as a column. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: b = C([1,1,-1]) 

sage: b.pp() 

+ 

+ 

- 

""" 

print(self._repr_diagram()) 

 

def _latex_(self): 

r""" 

Gives the latex output of a spin column. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: b = C([1,1,-1]) 

sage: print(b._latex_()) 

{\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}} 

\raisebox{-.6ex}{$\begin{array}[b]{*{1}c}\cline{1-1} 

\lr{-}\\\cline{1-1} 

\lr{+}\\\cline{1-1} 

\lr{+}\\\cline{1-1} 

\end{array}$} 

} 

""" 

return Tableau([[i] for i in reversed(self.signature())])._latex_() 

 

def epsilon(self, i): 

r""" 

Return `\varepsilon_i` of ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: [[C[m].epsilon(i) for i in range(1,4)] for m in range(8)] 

[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], 

[0, 0, 1], [1, 0, 1], [0, 1, 0], [0, 0, 1]] 

""" 

if self.e(i) is None: 

return 0 

return 1 

 

def phi(self, i): 

r""" 

Return `\varphi_i` of ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: [[C[m].phi(i) for i in range(1,4)] for m in range(8)] 

[[0, 0, 1], [0, 1, 0], [1, 0, 1], [0, 0, 1], 

[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0]] 

""" 

if self.f(i) is None: 

return 0 

return 1 

 

class Spin_crystal_type_B_element(Spin): 

r""" 

Type B spin representation crystal element 

""" 

def e(self, i): 

r""" 

Returns the action of `e_i` on self. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: [[C[m].e(i) for i in range(1,4)] for m in range(8)] 

[[None, None, None], [None, None, +++], [None, ++-, None], [+-+, None, None], 

[None, None, +-+], [+--, None, -++], [None, -+-, None], [None, None, --+]] 

""" 

assert i in self.index_set() 

rank = self.parent().cartan_type().n 

if i < rank: 

if self.value[i-1] == -1 and self.value[i] == 1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = 1 

ret[i] = -1 

return self.__class__(self.parent(), tuple(ret)) 

elif i == rank: 

if self.value[i-1] == -1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = 1 

return self.__class__(self.parent(), tuple(ret)) 

 

return None 

 

def f(self, i): 

r""" 

Returns the action of `f_i` on self. 

 

EXAMPLES:: 

 

sage: C = crystals.Spins(['B',3]) 

sage: [[C[m].f(i) for i in range(1,4)] for m in range(8)] 

[[None, None, ++-], [None, +-+, None], [-++, None, +--], [None, None, -+-], 

[-+-, None, None], [None, --+, None], [None, None, ---], [None, None, None]] 

""" 

assert i in self.index_set() 

rank = self.parent().cartan_type().n 

if i < rank: 

if self.value[i-1] == 1 and self.value[i] == -1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = -1 

ret[i] = 1 

return self.__class__(self.parent(), tuple(ret)) 

elif i == rank: 

if self.value[i-1] == 1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = -1 

return self.__class__(self.parent(), tuple(ret)) 

 

return None 

 

class Spin_crystal_type_D_element(Spin): 

r""" 

Type D spin representation crystal element 

""" 

def e(self, i): 

r""" 

Returns the action of `e_i` on self. 

 

EXAMPLES:: 

 

sage: D = crystals.SpinsPlus(['D',4]) 

sage: [[D.list()[m].e(i) for i in range(1,4)] for m in range(8)] 

[[None, None, None], [None, None, None], [None, ++--, None], [+-+-, None, None], 

[None, None, +-+-], [+--+, None, -++-], [None, -+-+, None], [None, None, None]] 

 

:: 

 

sage: E = crystals.SpinsMinus(['D',4]) 

sage: [[E[m].e(i) for i in range(1,4)] for m in range(8)] 

[[None, None, None], [None, None, +++-], [None, ++-+, None], [+-++, None, None], 

[None, None, None], [+---, None, None], [None, -+--, None], [None, None, --+-]] 

""" 

assert i in self.index_set() 

rank = self.parent().cartan_type().n 

if i < rank: 

if self.value[i-1] == -1 and self.value[i] == 1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = 1 

ret[i] = -1 

return self.__class__(self.parent(), tuple(ret)) 

elif i == rank: 

if self.value[i-2] == -1 and self.value[i-1] == -1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-2] = 1 

ret[i-1] = 1 

return self.__class__(self.parent(), tuple(ret)) 

 

return None 

 

def f(self, i): 

r""" 

Returns the action of `f_i` on self. 

 

EXAMPLES:: 

 

sage: D = crystals.SpinsPlus(['D',4]) 

sage: [[D.list()[m].f(i) for i in range(1,4)] for m in range(8)] 

[[None, None, None], [None, +-+-, None], [-++-, None, +--+], [None, None, -+-+], 

[-+-+, None, None], [None, --++, None], [None, None, None], [None, None, None]] 

 

:: 

 

sage: E = crystals.SpinsMinus(['D',4]) 

sage: [[E[m].f(i) for i in range(1,4)] for m in range(8)] 

[[None, None, ++-+], [None, +-++, None], [-+++, None, None], [None, None, None], 

[-+--, None, None], [None, --+-, None], [None, None, ---+], [None, None, None]] 

""" 

assert i in self.index_set() 

rank = self.parent().cartan_type().n 

if i < rank: 

if self.value[i-1] == 1 and self.value[i] == -1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-1] = -1 

ret[i] = 1 

return self.__class__(self.parent(), tuple(ret)) 

elif i == rank: 

if self.value[i-2] == 1 and self.value[i-1] == 1: 

ret = [self.value[x] for x in range(rank)] 

ret[i-2] = -1 

ret[i-1] = -1 

return self.__class__(self.parent(), tuple(ret)) 

 

return None