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

r""" 

Fast Rank Two Crystals 

""" 

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

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

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

# Ben Brubaker <brubaker at math.mit.edu> 

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

# Justin Walker <justin at mac.com> 

# 

# 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 sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.parent import Parent 

from sage.categories.classical_crystals import ClassicalCrystals 

from sage.structure.element import Element, parent 

from sage.combinat.root_system.cartan_type import CartanType 

from sage.structure.richcmp import richcmp 

 

 

class FastCrystal(UniqueRepresentation, Parent): 

r""" 

An alternative implementation of rank 2 crystals. The root 

operators are implemented in memory by table lookup. This means 

that in comparison with the 

:class:`~sage.combinat.crystals.tensor_product.CrystalsOfTableaux`, these 

crystals are slow to instantiate but faster for computation. Implemented 

for types `A_2`, `B_2`, and `C_2`. 

 

INPUT: 

 

- ``cartan_type`` -- the Cartan type and must be either type `A_2`, `B_2`, or `C_2` 

 

- ``shape`` -- A shape is of the form ``[l1,l2]`` where ``l1`` and ``l2`` 

are either integers or (in type `B_2`) half integers such that 

``l1 - l2`` is integral. It is assumed that ``l1 >= l2 >= 0``. If 

``l1`` and ``l2` are integers, this will produce the a crystal 

isomorphic to the one obtained by 

``crystals.Tableaux(type, shape=[l1,l2])``. Furthermore 

``crystals.FastRankTwo(['B', 2], l1+1/2, l2+1/2)`` produces a crystal 

isomorphic to the following crystal ``T``:: 

 

sage: C = crystals.Tableaux(['B',2], shape=[l1,l2]) # not tested 

sage: D = crystals.Spins(['B',2]) # not tested 

sage: T = crystals.TensorProduct(C, D, C.list()[0], D.list()[0]) # not tested 

 

- ``format`` -- (default: ``'string'``) the default representation of 

elements is in term of theBerenstein-Zelevinsky-Littelmann (BZL) 

strings ``[a1, a2, ...]`` described under metapost in 

:mod:`~sage.categories.crystals`. Alternative representations may be 

obtained by the options ``'dual_string'`` or ``'simple'``. 

In the ``'simple'`` format, the element is represented by and integer, 

and in the ``'dual_string'`` format, it is represented by the 

BZL string, but the underlying decomposition of the long Weyl group 

element into simple reflections is changed. 

 

TESTS:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[4,1]) 

sage: C.cardinality() 

24 

sage: C.cartan_type() 

['A', 2] 

sage: TestSuite(C).run() 

sage: C = crystals.FastRankTwo(['B',2],shape=[4,1]) 

sage: C.cardinality() 

154 

sage: TestSuite(C).run() 

sage: C = crystals.FastRankTwo(['B',2],shape=[3/2,1/2]) 

sage: C.cardinality() 

16 

sage: TestSuite(C).run() 

sage: C = crystals.FastRankTwo(['C',2],shape=[2,1]) 

sage: C.cardinality() 

16 

sage: C = crystals.FastRankTwo(['C',2],shape=[3,1]) 

sage: C.cardinality() 

35 

sage: TestSuite(C).run() 

""" 

@staticmethod 

def __classcall__(cls, cartan_type, shape, format = "string"): 

""" 

Normalizes the input arguments to ensure unique representation 

 

EXAMPLES:: 

 

sage: C1 = crystals.FastRankTwo(['A',2], shape=(4,1)) 

sage: C2 = crystals.FastRankTwo(CartanType(['A',2]),shape=[4,1]) 

sage: C1 is C2 

True 

""" 

cartan_type = CartanType(cartan_type) 

shape = tuple(shape) 

if len(shape) > 2: 

raise ValueError("The shape must have length <=2") 

shape = shape + (0,)*(2-len(shape)) 

return super(FastCrystal, cls).__classcall__(cls, cartan_type, shape, format) 

 

def __init__(self, ct, shape, format): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[4,1]); C 

The fast crystal for A2 with shape [4,1] 

sage: TestSuite(C).run() 

""" 

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

# super(FastCrystal, self).__init__(category = FiniteEnumeratedSets()) 

self._cartan_type = ct 

if ct[1] != 2: 

raise NotImplementedError 

 

l1 = shape[0] 

l2 = shape[1] 

 

# For safety, delpat and gampat should be immutable 

 

self.delpat = [] 

self.gampat = [] 

 

if ct[0] == 'A': 

self._type_a_init(l1, l2) 

elif ct[0] == 'B' or ct[0] == 'C': 

self._type_bc_init(l1, l2) 

else: 

raise NotImplementedError 

 

self.format = format 

self.size = len(self.delpat) 

self._rootoperators = [] 

self.shape = shape 

 

for i in range(self.size): 

target = [x for x in self.delpat[i]] 

 

target[0] = target[0]-1 

e1 = None if target not in self.delpat else self.delpat.index(target) 

target[0] = target[0]+1+1 

f1 = None if target not in self.delpat else self.delpat.index(target) 

 

target = [x for x in self.gampat[i]] 

target[0] = target[0]-1 

e2 = None if target not in self.gampat else self.gampat.index(target) 

target[0] = target[0]+1+1 

f2 = None if target not in self.gampat else self.gampat.index(target) 

 

self._rootoperators.append([e1,f1,e2,f2]) 

 

if int(2*l1)%2 == 0: 

l1_str = "%d"%l1 

l2_str = "%d"%l2 

else: 

assert self._cartan_type[0] == 'B' and int(2*l2)%2 == 1 

l1_str = "%d/2"%int(2*l1) 

l2_str = "%d/2"%int(2*l2) 

self.rename("The fast crystal for %s2 with shape [%s,%s]"%(ct[0],l1_str,l2_str)) 

self.module_generators = [self(0)] 

# self._list = ClassicalCrystal.list(self) 

self._list = super(FastCrystal, self).list() 

# self._digraph = ClassicalCrystal.digraph(self) 

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

self._digraph_closure = self.digraph().transitive_closure() 

 

def _type_a_init(self, l1, l2): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[1,1]) 

sage: C.delpat # indirect doctest 

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

sage: C.gampat 

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

""" 

for b in range(l2,-1,-1): 

for a in range(l1,l2-1,-1): 

for c in range(a,b-1,-1): 

a3 = l1-a 

a2 = l1+l2-a-b 

a1 = a-c 

b1 = max(a3,a2-a1) 

b2 = a1+a3 

b3 = min(a2-a3,a1) 

self.delpat.append([a1,a2,a3]) 

self.gampat.append([b1,b2,b3]) 

 

def _type_bc_init(self, l1, l2): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['B',2],shape=[1]) 

sage: len(C.delpat) # indirect doctest 

5 

sage: len(C.gampat) 

5 

sage: C = crystals.FastRankTwo(['C',2],shape=[1]) 

sage: len(C.delpat) 

4 

sage: len(C.gampat) 

4 

""" 

if self._cartan_type[0] == 'B': 

[m1, m2] = [l1+l2, l1-l2] 

else: 

[m1, m2] = [l1, l2] 

for b in range(m2,-1,-1): 

for a in range(m1,m2-1,-1): 

for c in range(b,a+1): 

for d in range(c,-1,-1): 

a1 = c-d 

a2 = m1+m2+c-a-2*b 

a3 = m1+m2-a-b 

a4 = m1-a 

b1 = max(a4,2*a3-a2,a2-2*a1) 

b2 = max(a3, a1+a4, a1+2*a3-a2) 

b3 = min(a2, 2*a2-2*a3+a4, 2*a1+a4) 

b4 = min(a1, a2-a3, a3-a4) 

if self._cartan_type[0] == 'B': 

self.delpat.append([a1,a2,a3,a4]) 

self.gampat.append([b1,b2,b3,b4]) 

else: 

self.gampat.append([a1,a2,a3,a4]) 

self.delpat.append([b1,b2,b3,b4]) 

 

def __call__(self, value): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C(0) 

[0, 0, 0] 

sage: C(1) 

[1, 0, 0] 

sage: x = C(0) 

sage: C(x) is x 

True 

""" 

if parent(value) is self: return value 

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

 

def list(self): 

""" 

Returns a list of the elements of self. 

 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C.list() 

[[0, 0, 0], 

[1, 0, 0], 

[0, 1, 1], 

[0, 2, 1], 

[1, 2, 1], 

[0, 1, 0], 

[1, 1, 0], 

[2, 1, 0]] 

""" 

return self._list 

 

def digraph(self): 

""" 

Returns the digraph associated to self. 

 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C.digraph() 

Digraph on 8 vertices 

""" 

return self._digraph 

 

def cmp_elements(self, x,y): 

r""" 

Returns 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.FastRankTwo(['A',2],shape=[2,1]) 

sage: x = C(0) 

sage: y = C(1) 

sage: C.cmp_elements(x,y) 

-1 

sage: C.cmp_elements(y,x) 

1 

sage: C.cmp_elements(x,x) 

0 

""" 

assert x.parent() == self and y.parent() == self 

if self._digraph_closure.has_edge(x,y): 

return -1 

elif self._digraph_closure.has_edge(y,x): 

return 1 

else: 

return 0 

 

class Element(Element): 

def __init__(self, parent, value, format): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: c = C(0); c 

[0, 0, 0] 

sage: C[0].parent() 

The fast crystal for A2 with shape [2,1] 

sage: TestSuite(c).run() 

""" 

Element.__init__(self, parent) 

self.value = value 

self.format = format 

 

def weight(self): 

""" 

Returns the weight of self. 

 

EXAMPLES:: 

 

sage: [v.weight() for v in crystals.FastRankTwo(['A',2], shape=[2,1])] 

[(2, 1, 0), (1, 2, 0), (1, 1, 1), (1, 0, 2), (0, 1, 2), (2, 0, 1), (1, 1, 1), (0, 2, 1)] 

sage: [v.weight() for v in crystals.FastRankTwo(['B',2], shape=[1,0])] 

[(1, 0), (0, 1), (0, 0), (0, -1), (-1, 0)] 

sage: [v.weight() for v in crystals.FastRankTwo(['B',2], shape=[1/2,1/2])] 

[(1/2, 1/2), (1/2, -1/2), (-1/2, 1/2), (-1/2, -1/2)] 

sage: [v.weight() for v in crystals.FastRankTwo(['C',2], shape=[1,0])] 

[(1, 0), (0, 1), (0, -1), (-1, 0)] 

sage: [v.weight() for v in crystals.FastRankTwo(['C',2], shape=[1,1])] 

[(1, 1), (1, -1), (0, 0), (-1, 1), (-1, -1)] 

""" 

delpat = self.parent().delpat[self.value] 

if self.parent()._cartan_type[0] == 'A': 

delpat = delpat + [0,] 

[alpha1, alpha2] = self.parent().weight_lattice_realization().simple_roots() 

hwv = sum(self.parent().shape[i]*self.parent().weight_lattice_realization().monomial(i) for i in range(2)) 

return hwv - (delpat[0]+delpat[2])*alpha1 - (delpat[1]+delpat[3])*alpha2 

 

def _repr_(self): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C[0]._repr_() 

'[0, 0, 0]' 

""" 

if self.format == "string": 

return repr(self.parent().delpat[self.value]) 

elif self.format == "dual_string": 

return repr(self.parent().gampat[self.value]) 

elif self.format == "simple": 

return repr(self.value) 

else: 

raise NotImplementedError 

 

def __hash__(self): 

r""" 

TESTS:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: hash(C(0)) 

0 

""" 

return hash(self.value) 

 

def _richcmp_(self, other, op): 

""" 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: D = crystals.FastRankTwo(['B',2],shape=[2,1]) 

sage: C(0) == C(0) 

True 

sage: C(1) == C(0) 

False 

sage: C(0) == D(0) 

False 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: D = crystals.FastRankTwo(['B',2],shape=[2,1]) 

sage: C(0) != C(0) 

False 

sage: C(1) != C(0) 

True 

sage: C(0) != D(0) 

True 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C(1) < C(2) 

True 

sage: C(2) < C(1) 

False 

sage: C(2) > C(1) 

True 

sage: C(1) <= C(1) 

True 

""" 

return richcmp(self.value, other.value, op) 

 

def e(self, i): 

""" 

Returns the action of `e_i` on self. 

 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C(1).e(1) 

[0, 0, 0] 

sage: C(0).e(1) is None 

True 

""" 

assert i in self.index_set() 

if i == 1: 

r = self.parent()._rootoperators[self.value][0] 

else: 

r = self.parent()._rootoperators[self.value][2] 

return self.parent()(r) if r is not None else None 

 

def f(self, i): 

""" 

Returns the action of `f_i` on self. 

 

EXAMPLES:: 

 

sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) 

sage: C(6).f(1) 

[1, 2, 1] 

sage: C(7).f(1) is None 

True 

""" 

assert i in self.index_set() 

if i == 1: 

r = self.parent()._rootoperators[self.value][1] 

else: 

r = self.parent()._rootoperators[self.value][3] 

return self.parent()(r) if r is not None else None 

 

 

#FastCrystal.Element = FastCrystalElement