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

r""" 

Knots 

 

AUTHORS: 

 

- Miguel Angel Marco Buzunariz 

- Amit Jamadagni 

""" 

 

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

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

# 

# 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.knots.link import Link 

from sage.rings.integer import Integer 

from sage.rings.finite_rings.integer_mod import Mod 

 

 

class Knot(Link): 

""" 

A knot. 

 

A knot is defined as embedding of the circle `\mathbb{S}^1` in the 

3-dimensional sphere `\mathbb{S}^3`, considered up to ambient isotopy. 

They represent the physical idea of a knotted rope, but with the 

particularity that the rope is closed. That is, the ends of the rope 

are joined. 

 

.. SEEALSO:: 

 

:class:`Link` 

 

INPUT: 

 

- ``data`` -- see :class:`Link` for the allowable inputs 

- ``check`` -- optional, default ``True``. If ``True``, make sure 

that the data define a knot, not a link 

 

EXAMPLES: 

 

We construct the knot `8_{14}` and compute some invariants:: 

 

sage: B = BraidGroup(4) 

sage: K = Knot(B([1,1,1,2,-1,2,-3,2,-3])) 

 

.. PLOT:: 

:width: 300 px 

 

B = BraidGroup(4) 

K = Knot(B([1,1,1,2,-1,2,-3,2,-3])) 

sphinx_plot(K.plot()) 

 

:: 

 

sage: K.alexander_polynomial() 

-2*t^-2 + 8*t^-1 - 11 + 8*t - 2*t^2 

sage: K.jones_polynomial() 

t^7 - 3*t^6 + 4*t^5 - 5*t^4 + 6*t^3 - 5*t^2 + 4*t + 1/t - 2 

sage: K.determinant() 

31 

sage: K.signature() 

-2 

 

REFERENCES: 

 

- :wikipedia:`Knot_(mathematics)` 

 

.. TODO:: 

 

- Make a class Knots for the monoid of all knots and have this be an 

element in that monoid. 

""" 

def __init__(self, data, check=True): 

""" 

Initialize ``self``. 

 

TESTS:: 

 

sage: B = BraidGroup(8) 

sage: K = Knot(B([-1, -1, -1, 2, 1, -2, 3, -2, 3])) 

sage: TestSuite(K).run() 

sage: K = Knot(B([1, -2, 1, -2])) 

sage: TestSuite(K).run() 

sage: K = Knot([[1, 1, 2, 2]]) 

sage: TestSuite(K).run() 

 

The following is not a knot: it has two components. :: 

 

sage: Knot([[[1, 2], [-2, -1]], [1, -1]]) 

Traceback (most recent call last): 

... 

ValueError: the input has more than 1 connected component 

 

sage: Knot([[[1, 2], [-2, -1]], [1, -1]], check=False) 

Knot represented by 2 crossings 

""" 

Link.__init__(self, data) 

if check: 

if self.number_of_components() != 1: 

raise ValueError("the input has more than 1 connected component") 

 

def __repr__(self): 

""" 

Return a string representation. 

 

EXAMPLES:: 

 

sage: B = BraidGroup(8) 

sage: K = Knot(B([1, 2, 1, 2])) 

sage: K 

Knot represented by 4 crossings 

sage: K = Knot([[1, 7, 2, 6], [7, 3, 8, 2], [3, 11, 4, 10], [11, 5, 12, 4], [14, 5, 1, 6], [13, 9, 14, 8], [12, 9, 13, 10]]) 

sage: K 

Knot represented by 7 crossings 

""" 

pd_len = len(self.pd_code()) 

return 'Knot represented by {} crossings'.format(pd_len) 

 

def dt_code(self): 

""" 

Return the DT code of ``self``. 

 

ALGORITHM: 

 

The DT code is generated by the following way: 

 

Start moving along the knot, as we encounter the crossings we 

start numbering them, so every crossing has two numbers assigned to 

it once we have traced the entire knot. Now we take the even number 

associated with every crossing. 

 

The following sign convention is to be followed: 

 

Take the even number with a negative sign if it is an overcrossing 

that we are encountering. 

 

OUTPUT: DT code representation of the knot 

 

EXAMPLES:: 

 

sage: K = Knot([[1,5,2,4],[5,3,6,2],[3,1,4,6]]) 

sage: K.dt_code() 

[4, 6, 2] 

sage: B = BraidGroup(4) 

sage: K = Knot(B([1, 2, 1, 2])) 

sage: K.dt_code() 

[4, -6, 8, -2] 

sage: K = Knot([[[1, -2, 3, -4, 5, -1, 2, -3, 4, -5]], [1, 1, 1, 1, 1]]) 

sage: K.dt_code() 

[6, 8, 10, 2, 4] 

""" 

b = self.braid().Tietze() 

N = len(b) 

label = [0 for i in range(2 * N)] 

string = 1 

next_label = 1 

type1 = 0 

crossing = 0 

while next_label <= 2 * N: 

string_found = False 

for i in range(crossing, N): 

if abs(b[i]) == string or abs(b[i]) == string - 1: 

string_found = True 

crossing = i 

break 

if not string_found: 

for i in range(0, crossing): 

if abs(b[i]) == string or abs(b[i]) == string - 1: 

string_found = True 

crossing = i 

break 

assert label[2 * crossing + next_label % 2] != 1, "invalid knot" 

 

label[2 * crossing + next_label % 2] = next_label 

next_label = next_label + 1 

if type1 == 0: 

if b[crossing] < 0: 

type1 = 1 

else: 

type1 = -1 

else: 

type1 = -1 * type1 

if ((abs(b[crossing]) == string and b[crossing] * type1 > 0) 

or (abs(b[crossing]) != string and b[crossing] * type1 < 0)): 

if next_label % 2 == 1: 

label[2 * crossing] = label[2 * crossing] * -1 

if abs(b[crossing]) == string: 

string = string + 1 

else: 

string = string - 1 

crossing = crossing + 1 

code = [0 for i in range(N)] 

for i in range(N): 

for j in range(N): 

if label[2 * j + 1] == 2 * i + 1: 

code[i] = label[2 * j] 

break 

return code 

 

def arf_invariant(self): 

""" 

Return the Arf invariant. 

 

EXAMPLES:: 

 

sage: B = BraidGroup(4) 

sage: K = Knot(B([-1, 2, 1, 2])) 

sage: K.arf_invariant() 

0 

sage: B = BraidGroup(8) 

sage: K = Knot(B([-2, 3, 1, 2, 1, 4])) 

sage: K.arf_invariant() 

0 

sage: K = Knot(B([1, 2, 1, 2])) 

sage: K.arf_invariant() 

1 

""" 

a = self.alexander_polynomial() 

if Mod(a(-1), 8) == 1 or Mod(a(-1), 8) == 7: 

return 0 

 

return 1 

 

def connected_sum(self, other): 

r""" 

Return the oriented connected sum of ``self`` and ``other``. 

 

.. NOTE:: 

 

We give the knots an orientation based upon the braid 

representation. 

 

INPUT: 

 

- ``other`` -- a knot 

 

OUTPUT: 

 

A knot equivalent to the connected sum of ``self`` and ``other``. 

 

EXAMPLES:: 

 

sage: B = BraidGroup(2) 

sage: trefoil = Knot(B([1,1,1])) 

sage: K = trefoil.connected_sum(trefoil); K 

Knot represented by 7 crossings 

sage: K.braid() 

s0^3*s2^3*s1 

 

.. PLOT:: 

:width: 300 px 

 

B = BraidGroup(2) 

trefoil = Knot(B([1,1,1])) 

K = trefoil.connected_sum(trefoil) 

sphinx_plot(K.plot()) 

 

:: 

 

sage: rev_trefoil = Knot(B([-1,-1,-1])) 

sage: K = trefoil.connected_sum(rev_trefoil); K 

Knot represented by 7 crossings 

sage: K.braid() 

s0^3*s2^-3*s1 

 

.. PLOT:: 

:width: 300 px 

 

B = BraidGroup(2) 

t = Knot(B([1,1,1])) 

tr = Knot(B([-1,-1,-1])) 

K = t.connected_sum(tr) 

sphinx_plot(K.plot()) 

 

REFERENCES: 

 

- :wikipedia:`Connected_sum` 

""" 

from sage.groups.braid import BraidGroup 

b1 = self.braid() 

b2 = other.braid() 

 

b1s = b1.strands() 

b2s = b2.strands() 

 

B = BraidGroup(b1s + b2s) 

 

return Knot(B(list(b1.Tietze()) 

+ [(abs(i) + b2s) * Integer(i).sign() for i in b2.Tietze()] 

+ [b1s]))