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

r""" 

Discrete Valuation Rings (DVR) and Fields (DVF) 

""" 

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

# Copyright (C) 2013 Xavier Caruso <xavier.caruso@normalesup.org> 

# 

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

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

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

 

 

from sage.misc.abstract_method import abstract_method 

from sage.categories.category_singleton import Category_singleton 

from sage.categories.euclidean_domains import EuclideanDomains 

from sage.categories.fields import Fields 

 

class DiscreteValuationRings(Category_singleton): 

""" 

The category of discrete valuation rings 

 

EXAMPLES:: 

 

sage: GF(7)[['x']] in DiscreteValuationRings() 

True 

sage: TestSuite(DiscreteValuationRings()).run() 

""" 

def super_categories(self): 

""" 

EXAMPLES:: 

 

sage: DiscreteValuationRings().super_categories() 

[Category of euclidean domains] 

""" 

return [EuclideanDomains()] 

 

class ParentMethods: 

@abstract_method 

def uniformizer(self): 

""" 

Return a uniformizer of this ring. 

 

EXAMPLES:: 

 

sage: Zp(5).uniformizer() 

5 + O(5^21) 

 

sage: K.<u> = QQ[[]] 

sage: K.uniformizer() 

u 

""" 

 

@abstract_method 

def residue_field(self): 

""" 

Return the residue field of this ring. 

 

EXAMPLES:: 

 

sage: Zp(5).residue_field() 

Finite Field of size 5 

 

sage: K.<u> = QQ[[]] 

sage: K.residue_field() 

Rational Field 

""" 

 

class ElementMethods: 

@abstract_method 

def valuation(self): 

""" 

Return the valuation of this element. 

 

EXAMPLES:: 

 

sage: x = Zp(5)(50) 

sage: x.valuation() 

2 

""" 

 

def euclidean_degree(self): 

""" 

Return the Euclidean degree of this element. 

 

TESTS:: 

 

sage: R.<q> = GF(5)[[]] 

sage: (q^3).euclidean_degree() 

3 

sage: R(0).euclidean_degree() 

Traceback (most recent call last): 

... 

ValueError: Euclidean degree of the zero element not defined 

 

""" 

if not self: 

raise ValueError("Euclidean degree of the zero element not defined") 

return self.valuation() 

 

def quo_rem(self, other): 

""" 

Return the quotient and remainder for Euclidean division 

of ``self`` by ``other``. 

 

TESTS:: 

 

sage: R.<q> = GF(5)[[]] 

sage: (q^2 + q).quo_rem(q) 

(1 + q, 0) 

sage: (q + 1).quo_rem(q^2) 

(0, 1 + q) 

sage: q.quo_rem(0) 

Traceback (most recent call last): 

... 

ZeroDivisionError: Euclidean division by the zero element not defined 

 

""" 

if not other: 

raise ZeroDivisionError("Euclidean division by the zero element not defined") 

P = self.parent() 

if self.valuation() >= other.valuation(): 

return P(self / other), P.zero() 

else: 

return P.zero(), self 

 

def is_unit(self): 

""" 

Return True if self is invertible. 

 

EXAMPLES:: 

 

sage: x = Zp(5)(50) 

sage: x.is_unit() 

False 

 

sage: x = Zp(7)(50) 

sage: x.is_unit() 

True 

""" 

return self.valuation() == 0 

 

def gcd(self,other): 

""" 

Return the greatest common divisor of self and other, 

normalized so that it is a power of the distinguished 

uniformizer. 

""" 

from sage.rings.infinity import Infinity 

val = min(self.valuation(), other.valuation()) 

if val is Infinity: 

return self.parent()(0) 

else: 

return self.parent().uniformizer() ** val 

 

def lcm(self,other): 

""" 

Return the least common multiple of self and other, 

normalized so that it is a power of the distinguished 

uniformizer. 

""" 

from sage.rings.infinity import Infinity 

val = max(self.valuation(), other.valuation()) 

if val is Infinity: 

return self.parent()(0) 

else: 

return self.parent().uniformizer() ** val 

 

 

class DiscreteValuationFields(Category_singleton): 

""" 

The category of discrete valuation fields 

 

EXAMPLES:: 

 

sage: Qp(7) in DiscreteValuationFields() 

True 

sage: TestSuite(DiscreteValuationFields()).run() 

""" 

 

def super_categories(self): 

""" 

EXAMPLES:: 

 

sage: DiscreteValuationFields().super_categories() 

[Category of fields] 

""" 

return [Fields()] 

 

class ParentMethods: 

@abstract_method 

def uniformizer(self): 

""" 

Return a uniformizer of this ring. 

 

EXAMPLES:: 

 

sage: Qp(5).uniformizer() 

5 + O(5^21) 

""" 

 

@abstract_method 

def residue_field(self): 

""" 

Return the residue field of the ring of integers of  

this discrete valuation field. 

 

EXAMPLES:: 

 

sage: Qp(5).residue_field() 

Finite Field of size 5 

 

sage: K.<u> = LaurentSeriesRing(QQ) 

sage: K.residue_field() 

Rational Field 

""" 

 

class ElementMethods: 

@abstract_method 

def valuation(self): 

""" 

Return the valuation of this element. 

 

EXAMPLES:: 

 

sage: x = Qp(5)(50) 

sage: x.valuation() 

2 

"""