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

r""" 

Examples of finite Coxeter groups 

""" 

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

# Copyright (C) 2008 Nicolas M. Thiery <nthiery at users.sf.net> 

# Copyright (C) 2009 Nicolas Borie <nicolas dot borie at math.u-psud.fr> 

# 

# 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.structure.parent import Parent 

from sage.structure.element_wrapper import ElementWrapper 

from sage.categories.all import FiniteCoxeterGroups 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.misc.functional import is_odd, is_even 

from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix 

 

 

class DihedralGroup(UniqueRepresentation, Parent): 

""" 

An example of finite Coxeter group: the `n`-th dihedral group of order `2n`. 

 

The purpose of this class is to provide a minimal template for 

implementing finite Coxeter groups. See 

:class:`~sage.groups.perm_gps.permgroup_named.DihedralGroup` for a 

full featured and optimized implementation. 

 

EXAMPLES:: 

 

sage: G = FiniteCoxeterGroups().example() 

 

This group is generated by two simple reflections `s_1` and `s_2` 

subject to the relation `(s_1s_2)^n = 1`:: 

 

sage: G.simple_reflections() 

Finite family {1: (1,), 2: (2,)} 

 

sage: s1, s2 = G.simple_reflections() 

sage: (s1*s2)^5 == G.one() 

True 

 

An element is represented by its reduced word (a tuple of elements 

of `self.index_set()`):: 

 

sage: G.an_element() 

(1, 2) 

 

sage: list(G) 

[(), 

(1,), 

(2,), 

(1, 2), 

(2, 1), 

(1, 2, 1), 

(2, 1, 2), 

(1, 2, 1, 2), 

(2, 1, 2, 1), 

(1, 2, 1, 2, 1)] 

 

This reduced word is unique, except for the longest element where 

the choosen reduced word is `(1,2,1,2\dots)`:: 

 

sage: G.long_element() 

(1, 2, 1, 2, 1) 

 

TESTS:: 

 

sage: TestSuite(G).run() 

 

sage: c = FiniteCoxeterGroups().example(3).cayley_graph() 

sage: sorted(c.edges()) 

[((), (1,), 1), 

((), (2,), 2), 

((1,), (), 1), 

((1,), (1, 2), 2), 

((1, 2), (1,), 2), 

((1, 2), (1, 2, 1), 1), 

((1, 2, 1), (1, 2), 1), 

((1, 2, 1), (2, 1), 2), 

((2,), (), 2), 

((2,), (2, 1), 1), 

((2, 1), (1, 2, 1), 2), 

((2, 1), (2,), 1)] 

""" 

 

def __init__(self, n = 5): 

r""" 

INPUT: 

- ``n`` - an integer with `n>=2` 

 

Construct the n-th DihedralGroup of order 2*n 

 

EXAMPLES:: 

 

sage: from sage.categories.examples.finite_coxeter_groups import DihedralGroup 

sage: DihedralGroup(3) 

The 3-th dihedral group of order 6 

 

""" 

assert n >= 2 

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

self.n = n 

 

def _repr_(self): 

r""" 

EXAMPLES:: 

 

sage: FiniteCoxeterGroups().example() 

The 5-th dihedral group of order 10 

sage: FiniteCoxeterGroups().example(6) 

The 6-th dihedral group of order 12 

""" 

return "The %s-th dihedral group of order %s"%(self.n, 2*self.n) 

 

def __contains__(self, x): 

r""" 

Check in the element x is in the mathematical parent self. 

 

EXAMPLES:: 

 

sage: D5 = FiniteCoxeterGroups().example() 

sage: D5.an_element() in D5 

True 

sage: 1 in D5 

False 

 

(also tested by :meth:`test_an_element` :meth:`test_some_elements`) 

""" 

from sage.structure.all import parent 

return parent(x) is self 

 

@cached_method 

def one(self): 

r""" 

Implements :meth:`Monoids.ParentMethods.one`. 

 

EXAMPLES:: 

 

sage: D6 = FiniteCoxeterGroups().example(6) 

sage: D6.one() 

() 

""" 

return self(()) 

 

def index_set(self): 

r""" 

Implements :meth:`CoxeterGroups.ParentMethods.index_set`. 

 

EXAMPLES:: 

 

sage: D4 = FiniteCoxeterGroups().example(4) 

sage: D4.index_set() 

(1, 2) 

""" 

return (1, 2) 

 

def degrees(self): 

""" 

Return the degrees of ``self``. 

 

EXAMPLES:: 

 

sage: FiniteCoxeterGroups().example(6).degrees() 

(2, 6) 

""" 

from sage.rings.integer_ring import ZZ 

return (ZZ(2), ZZ(self.n)) 

 

def coxeter_matrix(self): 

""" 

Return the Coxeter matrix of ``self``. 

 

EXAMPLES:: 

 

sage: FiniteCoxeterGroups().example(6).coxeter_matrix() 

[1 6] 

[6 1] 

""" 

return CoxeterMatrix([[1, self.n], [self.n, 1]]) 

 

class Element(ElementWrapper): 

wrapped_class = tuple 

__lt__ = ElementWrapper._lt_by_value 

 

def has_right_descent(self, i, positive = False, side = "right"): 

r""" 

Implements :meth:`SemiGroups.ElementMethods.has_right_descent`. 

 

EXAMPLES:: 

 

sage: D6 = FiniteCoxeterGroups().example(6) 

sage: s = D6.simple_reflections() 

sage: s[1].has_descent(1) 

True 

sage: s[1].has_descent(1) 

True 

sage: s[1].has_descent(2) 

False 

sage: D6.one().has_descent(1) 

False 

sage: D6.one().has_descent(2) 

False 

sage: D6.long_element().has_descent(1) 

True 

sage: D6.long_element().has_descent(2) 

True 

 

TESTS:: 

 

sage: D6._test_has_descent() 

""" 

reduced_word = self.value 

if len(reduced_word) == self.parent().n: 

return not positive 

elif len(reduced_word) == 0: 

return positive 

else: 

return (i == reduced_word[0 if side == "left" else -1]) == (not positive) 

 

def apply_simple_reflection_right(self, i): 

r""" 

Implements :meth:`CoxeterGroups.ElementMethods.apply_simple_reflection`. 

 

EXAMPLES:: 

 

sage: D5 = FiniteCoxeterGroups().example(5) 

sage: [i^2 for i in D5] # indirect doctest 

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

sage: [i^5 for i in D5] # indirect doctest 

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

""" 

from copy import copy 

reduced_word = copy(self.value) 

n = self.parent().n 

if len(reduced_word) == n: 

if (i == 1 and is_odd(n)) or (i == 2 and is_even(n)): 

return self.parent()(reduced_word[:-1]) 

else: 

return self.parent()(reduced_word[1:]) 

elif (len(reduced_word) == n-1 and (not self.has_descent(i))) and (reduced_word[0] == 2): 

return self.parent()((1,)+reduced_word) 

else: 

if self.has_descent(i): 

return self.parent()(reduced_word[:-1]) 

else: 

return self.parent()(reduced_word+(i,)) 

 

Example = DihedralGroup