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

""" 

Divisor groups 

 

AUTHORS: 

 

- David Kohel (2006): Initial version 

 

- Volker Braun (2010-07-16): Documentation, doctests, coercion fixes, bugfixes. 

""" 

 

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

# Copyright (C) 2010 Volker Braun <vbraun.name@gmail.com> 

# Copyright (C) 2006 David Kohel <kohel@maths.usyd.edu.au> 

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

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

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

 

from sage.schemes.generic.divisor import Divisor_generic, Divisor_curve 

from sage.structure.formal_sum import FormalSums 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.rings.integer_ring import ZZ 

from sage.rings.rational_field import QQ 

 

 

def DivisorGroup(scheme, base_ring=None): 

r""" 

Return the group of divisors on the scheme. 

 

INPUT: 

 

- ``scheme`` -- a scheme. 

 

- ``base_ring`` -- usually either `\ZZ` (default) or `\QQ`. The 

coefficient ring of the divisors. Not to be confused with the 

base ring of the scheme! 

 

OUTPUT: 

 

An instance of ``DivisorGroup_generic``. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: DivisorGroup(Spec(ZZ)) 

Group of ZZ-Divisors on Spectrum of Integer Ring 

sage: DivisorGroup(Spec(ZZ), base_ring=QQ) 

Group of QQ-Divisors on Spectrum of Integer Ring 

""" 

if base_ring is None: 

base_ring = ZZ 

 

from sage.schemes.curves.curve import Curve_generic 

if isinstance(scheme, Curve_generic): 

DG = DivisorGroup_curve(scheme, base_ring) 

else: 

DG = DivisorGroup_generic(scheme, base_ring) 

 

return DG 

 

 

def is_DivisorGroup(x): 

r""" 

Return whether ``x`` is a :class:`DivisorGroup_generic`. 

 

INPUT: 

 

- ``x`` -- anything. 

 

OUTPUT: 

 

``True`` or ``False``. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import is_DivisorGroup, DivisorGroup 

sage: Div = DivisorGroup(Spec(ZZ), base_ring=QQ) 

sage: is_DivisorGroup(Div) 

True 

sage: is_DivisorGroup('not a divisor') 

False 

""" 

return isinstance(x, DivisorGroup_generic) 

 

 

class DivisorGroup_generic(FormalSums): 

r""" 

The divisor group on a variety. 

""" 

 

@staticmethod 

def __classcall__(cls, scheme, base_ring=ZZ): 

""" 

Set the default value for the base ring. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup_generic 

sage: DivisorGroup_generic(Spec(ZZ),ZZ) == DivisorGroup_generic(Spec(ZZ)) # indirect test 

True 

""" 

# Must not call super().__classcall__()! 

return UniqueRepresentation.__classcall__(cls, scheme, base_ring) 

 

def __init__(self, scheme, base_ring): 

r""" 

Construct a :class:`DivisorGroup_generic`. 

 

INPUT: 

 

- ``scheme`` -- a scheme. 

 

- ``base_ring`` -- the coefficient ring of the divisor 

group. 

 

Implementation note: :meth:`__classcall__` sets default value 

for ``base_ring``. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup_generic 

sage: DivisorGroup_generic(Spec(ZZ), QQ) 

Group of QQ-Divisors on Spectrum of Integer Ring 

 

TESTS:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: D1 = DivisorGroup(Spec(ZZ)) 

sage: D2 = DivisorGroup(Spec(ZZ), base_ring=QQ) 

sage: D3 = DivisorGroup(Spec(QQ)) 

sage: D1 == D1 

True 

sage: D1 == D2 

False 

sage: D1 != D3 

True 

sage: D2 == D2 

True 

sage: D2 == D3 

False 

sage: D3 != D3 

False 

sage: D1 == 'something' 

False 

""" 

super(DivisorGroup_generic,self).__init__(base_ring) 

self._scheme = scheme 

 

def _repr_(self): 

r""" 

Return a string representation of the divisor group. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: DivisorGroup(Spec(ZZ), base_ring=QQ) 

Group of QQ-Divisors on Spectrum of Integer Ring 

""" 

ring = self.base_ring() 

if ring == ZZ: 

base_ring_str = 'ZZ' 

elif ring == QQ: 

base_ring_str = 'QQ' 

else: 

base_ring_str = '('+str(ring)+')' 

return 'Group of '+base_ring_str+'-Divisors on '+str(self._scheme) 

 

def _element_constructor_(self, x, check=True, reduce=True): 

r""" 

Construct an element of the divisor group. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: DivZZ=DivisorGroup(Spec(ZZ)) 

sage: DivZZ([(2,5)]) 

2*V(5) 

""" 

if isinstance(x, Divisor_generic): 

P = x.parent() 

if P is self: 

return x 

elif P == self: 

return Divisor_generic(x._data, check=False, reduce=False, parent=self) 

else: 

x = x._data 

if isinstance(x, list): 

return Divisor_generic(x, check=check, reduce=reduce, parent=self) 

if x == 0: 

return Divisor_generic([], check=False, reduce=False, parent=self) 

else: 

return Divisor_generic([(self.base_ring()(1), x)], check=False, reduce=False, parent=self) 

 

def scheme(self): 

r""" 

Return the scheme supporting the divisors. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: Div = DivisorGroup(Spec(ZZ)) # indirect test 

sage: Div.scheme() 

Spectrum of Integer Ring 

""" 

return self._scheme 

 

def _an_element_(self): 

r""" 

Return an element of the divisor group. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, CC) 

sage: C = Curve(y^2 - x^9 - x) 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: DivisorGroup(C).an_element() # indirect test 

0 

""" 

return self._scheme.divisor([], base_ring=self.base_ring(), check=False, reduce=False) 

 

def base_extend(self, R): 

""" 

EXAMPLES:: 

 

sage: from sage.schemes.generic.divisor_group import DivisorGroup 

sage: DivisorGroup(Spec(ZZ),ZZ).base_extend(QQ) 

Group of QQ-Divisors on Spectrum of Integer Ring 

sage: DivisorGroup(Spec(ZZ),ZZ).base_extend(GF(7)) 

Group of (Finite Field of size 7)-Divisors on Spectrum of Integer Ring 

 

Divisor groups are unique:: 

 

sage: A.<x, y> = AffineSpace(2, CC) 

sage: C = Curve(y^2 - x^9 - x) 

sage: DivisorGroup(C,ZZ).base_extend(QQ) is DivisorGroup(C,QQ) 

True 

""" 

if self.base_ring().has_coerce_map_from(R): 

return self 

elif R.has_coerce_map_from(self.base_ring()): 

return DivisorGroup(self.scheme(), base_ring=R) 

 

 

class DivisorGroup_curve(DivisorGroup_generic): 

r""" 

Special case of the group of divisors on a curve. 

""" 

 

def _element_constructor_(self, x, check=True, reduce=True): 

r""" 

Construct an element of the divisor group. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, CC) 

sage: C = Curve(y^2 - x^9 - x) 

sage: DivZZ=C.divisor_group(ZZ) 

sage: DivQQ=C.divisor_group(QQ) 

sage: DivQQ( DivQQ.an_element() ) # indirect test 

0 

sage: DivZZ( DivZZ.an_element() ) # indirect test 

0 

sage: DivQQ( DivZZ.an_element() ) # indirect test 

0 

""" 

if isinstance(x, Divisor_curve): 

P = x.parent() 

if P is self: 

return x 

elif P == self: 

return Divisor_curve(x._data, check=False, reduce=False, parent=self) 

else: 

x = x._data 

if isinstance(x, list): 

return Divisor_curve(x, check=check, reduce=reduce, parent=self) 

if x == 0: 

return Divisor_curve([], check=False, reduce=False, parent=self) 

else: 

return Divisor_curve([(self.base_ring()(1), x)], check=False, reduce=False, parent=self)