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

r""" 

Kodaira symbols 

 

Kodaira symbols encode the type of reduction of an elliptic curve at a 

(finite) place. 

 

The standard notation for Kodaira Symbols is as a string which is one 

of `\rm{I}_m`, `\rm{II}`, `\rm{III}`, `\rm{IV}`, `\rm{I}^*_m`, 

`\rm{II}^*`, `\rm{III}^*`, `\rm{IV}^*`, where `m` denotes a 

non-negative integer. These have been encoded by single integers by 

different people. For convenience we give here the conversion table 

between strings, the eclib coding and the PARI encoding. 

 

+----------------------+----------------+--------------------+ 

| Kodaira Symbol | Eclib coding | PARI Coding | 

+======================+================+====================+ 

| `\rm{I}_0` | `0` | `1` | 

+----------------------+----------------+--------------------+ 

| `\rm{I}^*_0` | `1` | `-1` | 

+----------------------+----------------+--------------------+ 

| `\rm{I}_m` `(m>0)` | `10m` | `m+4` | 

+----------------------+----------------+--------------------+ 

| `\rm{I}^*_m` `(m>0)` | `10m+1` | `-(m+4)` | 

+----------------------+----------------+--------------------+ 

| `\rm{II}` | `2` | `2` | 

+----------------------+----------------+--------------------+ 

| `\rm{III}` | `3` | `3` | 

+----------------------+----------------+--------------------+ 

| `\rm{IV}` | `4` | `4` | 

+----------------------+----------------+--------------------+ 

| `\rm{II}^*` | `7` | `-2` | 

+----------------------+----------------+--------------------+ 

| `\rm{III}^*` | `6` | `-3` | 

+----------------------+----------------+--------------------+ 

| `\rm{IV}^*` | `5` | `-4` | 

+----------------------+----------------+--------------------+ 

 

 

AUTHORS: 

 

- David Roe <roed@math.harvard.edu> 

 

- John Cremona 

 

""" 

 

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

# Copyright (C) 2007 David Roe <roed@math.harvard.edu> 

# William Stein <wstein@gmail.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.sage_object import SageObject 

from sage.structure.richcmp import richcmp_method, richcmp 

from sage.rings.integer import Integer 

import weakref 

 

 

@richcmp_method 

class KodairaSymbol_class(SageObject): 

r""" 

Class to hold a Kodaira symbol of an elliptic curve over a 

`p`-adic local field. 

 

Users should use the ``KodairaSymbol()`` function to construct 

Kodaira Symbols rather than use the class constructor directly. 

""" 

def __init__(self, symbol): 

r""" 

Constructor for Kodaira Symbol class. 

 

INPUT: 

 

- ``symbol`` (string or integer) -- The string should be a 

standard string representation (e.g. III*) of a Kodaira 

symbol, which will be parsed. Alternatively, use the PARI 

encoding of Kodaira symbols as integers. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol_class 

sage: KodairaSymbol_class(14) 

I10 

sage: KodairaSymbol_class('III*') 

III* 

sage: latex(KodairaSymbol_class('In')) 

I_n 

sage: KodairaSymbol_class('In') 

In 

""" 

if not isinstance(symbol, str): 

n = Integer(symbol) 

self._n = None 

if n == 0: 

raise ValueError("Kodaira Symbol code number must be nonzero.") 

if n == 1: 

self._n = 0 

self._roman = 1 

self._str = 'I0' 

self._latex = 'I_0' 

elif n == 2: 

self._roman = 2 

self._str = 'II' 

self._latex = 'II' 

elif n == 3: 

self._roman = 3 

self._str = 'III' 

self._latex = 'III' 

elif n == 4: 

self._roman = 4 

self._str = 'IV' 

self._latex = 'IV' 

elif n > 4: 

nu = n - 4 

self._n = nu 

self._roman = 1 

self._str = 'I' + nu.str() 

self._latex = 'I_{' + nu.str() + '}' 

elif n == -1: 

self._roman = 1 

self._n = 0 

self._str = 'I0*' 

self._latex = 'I_0^{*}' 

elif n == -2: 

self._roman = 2 

self._str = 'II*' 

self._latex = 'II^{*}' 

elif n == -3: 

self._roman = 3 

self._str = 'III*' 

self._latex = 'III^{*}' 

elif n == -4: 

self._roman = 4 

self._str = 'IV*' 

self._latex = 'IV^{*}' 

elif n < -4: 

nu = -n - 4 

self._roman = 1 

self._n = nu 

self._str = 'I' + nu.str() +'*' 

self._latex = 'I_' + nu.str() + '^{*}' 

self._starred = (n < 0) 

self._pari = n 

return 

elif len(symbol) == 0: 

raise TypeError("symbol must be a nonempty string") 

if symbol[0] == "I": 

symbol = symbol[1:] 

starred = False 

if symbol[-1] == "*": 

starred = True 

symbol = symbol[:-1] 

self._starred = starred 

if symbol in ["I", "II", "V"]: # NB we have already stripped off the leading 'I' 

self._roman = ["I", "II", "V"].index(symbol) + 2 # =2, 3 or 4 

self._n = None 

if starred: 

sign = -1 

self._str = "I" + symbol + "*" 

self._latex = "I" + symbol + "^*" 

else: 

sign = 1 

self._str = "I" + symbol 

self._latex = "" + self._str + "" 

if symbol == "I": 

self._pari = 2 * sign 

elif symbol == "II": 

self._pari = 3 * sign 

elif symbol == "V": 

self._pari = 4 * sign 

elif symbol == "n": 

self._roman = 1 

self._pari = None 

self._n = "generic" 

if starred: 

self._str = "In*" 

self._latex = "I_n^*" 

else: 

self._str = "In" 

self._latex = "I_n" 

elif symbol.isdigit(): 

self._roman = 1 

self._n = Integer(symbol) 

if starred: 

if self._n == 0: 

self._pari = -1 

else: 

self._pari = -self._n - 4 

self._str = "I" + symbol + "*" 

self._latex = "I_{%s}^*"%(symbol) 

else: 

if self._n == 0: 

self._pari = 1 

else: 

self._pari = self._n + 4 

self._str = "I" + symbol 

self._latex = "I_{%s}"%(symbol) 

else: 

raise ValueError("input is not a Kodaira symbol") 

 

def __repr__(self): 

r""" 

Return the string representation of this Kodaira Symbol. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol_class 

sage: KS = KodairaSymbol_class(15) 

sage: str(KS) # indirect doctest 

'I11' 

""" 

return self._str 

 

def _latex_(self): 

r""" 

Return the string representation of this Kodaira Symbol. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol_class 

sage: KS = KodairaSymbol_class(15) 

sage: latex(KS) 

I_{11} 

""" 

return self._latex 

 

def __richcmp__(self, other, op): 

r""" 

Standard comparison function for Kodaira Symbols. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol_class 

sage: KS1 = KodairaSymbol_class(15); KS1 

I11 

sage: KS2 = KodairaSymbol_class(-34); KS2 

I30* 

sage: KS1 < KS2 

True 

sage: KS2 < KS1 

False 

 

:: 

 

sage: Klist = [KodairaSymbol_class(i) for i in [-10..10] if i!=0] 

sage: Klist.sort() 

sage: Klist 

[I0, 

I0*, 

I1, 

I1*, 

I2, 

I2*, 

I3, 

I3*, 

I4, 

I4*, 

I5, 

I5*, 

I6, 

I6*, 

II, 

II*, 

III, 

III*, 

IV, 

IV*] 

""" 

if isinstance(other, KodairaSymbol_class): 

if (self._n == "generic" and not other._n is None) or (other._n == "generic" and not self._n is None): 

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

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

else: 

return NotImplemented 

 

def _pari_code(self): 

""" 

Return the PARI encoding of this Kodaira Symbol. 

 

EXAMPLES:: 

 

sage: KodairaSymbol('I0')._pari_code() 

1 

sage: KodairaSymbol('I10')._pari_code() 

14 

sage: KodairaSymbol('I10*')._pari_code() 

-14 

sage: [KodairaSymbol(s)._pari_code() for s in ['II','III','IV']] 

[2, 3, 4] 

sage: [KodairaSymbol(s)._pari_code() for s in ['II*','III*','IV*']] 

[-2, -3, -4] 

""" 

return self._pari 

 

_ks_cache = {} 

def KodairaSymbol(symbol): 

r""" 

Returns the specified Kodaira symbol. 

 

INPUT: 

 

- ``symbol`` (string or integer) -- Either a string of the form "I0", "I1", ..., "In", "II", "III", "IV", "I0*", "I1*", ..., "In*", "II*", "III*", or "IV*", or an integer encoding a Kodaira symbol using PARI's conventions. 

 

OUTPUT: 

 

(KodairaSymbol) The corresponding Kodaira symbol. 

 

EXAMPLES:: 

 

sage: KS = KodairaSymbol 

sage: [KS(n) for n in range(1,10)] 

[I0, II, III, IV, I1, I2, I3, I4, I5] 

sage: [KS(-n) for n in range(1,10)] 

[I0*, II*, III*, IV*, I1*, I2*, I3*, I4*, I5*] 

sage: all([KS(str(KS(n)))==KS(n) for n in range(-10,10) if n!=0]) 

True 

""" 

if symbol in _ks_cache: 

ks = _ks_cache[symbol]() 

if not ks is None: 

return ks 

ks = KodairaSymbol_class(symbol) 

_ks_cache[symbol] = weakref.ref(ks) 

return ks