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

335

336

337

# -*- coding: utf-8 -*- 

r""" 

Valuations which are scaled versions of another valuation 

 

EXAMPLES:: 

 

sage: 3*ZZ.valuation(3) 

3 * 3-adic valuation 

 

AUTHORS: 

 

- Julian Rüth (2016-11-10): initial version 

 

""" 

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

# Copyright (C) 2016-2017 Julian Rüth <julian.rueth@fsfe.org> 

# 

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

# 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 __future__ import absolute_import 

 

from sage.structure.factory import UniqueFactory 

 

from .valuation import DiscreteValuation 

 

 

class ScaledValuationFactory(UniqueFactory): 

r""" 

Return a valuation which scales the valuation ``base`` by the factor ``s``. 

 

EXAMPLES:: 

 

sage: 3*ZZ.valuation(2) # indirect doctest 

3 * 2-adic valuation 

 

""" 

def create_key(self, base, s): 

r""" 

Create a key which uniquely identifies a valuation. 

 

TESTS:: 

 

sage: 3*ZZ.valuation(2) is 2*(3/2*ZZ.valuation(2)) # indirect doctest 

True 

 

""" 

from sage.rings.all import infinity, QQ 

if s is infinity or s not in QQ or s <= 0: 

# for these values we can not return a TrivialValuation() in 

# create_object() because that would override that instance's 

# _factory_data and lead to pickling errors 

raise ValueError("s must be a positive rational") 

if base.is_trivial(): 

# for the same reason we can not accept trivial valuations here 

raise ValueError("base must not be trivial") 

s = QQ.coerce(s) 

if s == 1: 

# we would override the _factory_data of base if we just returned 

# it in create_object() so we just refuse to do so 

raise ValueError("s must not be 1") 

 

if isinstance(base, ScaledValuation_generic): 

return self.create_key(base._base_valuation, s*base._scale) 

 

return base, s 

 

def create_object(self, version, key): 

r""" 

Create a valuation from ``key``. 

 

TESTS:: 

 

sage: 3*ZZ.valuation(2) # indirect doctest 

3 * 2-adic valuation 

 

""" 

base, s = key 

 

assert not isinstance(base, ScaledValuation_generic) 

 

from .valuation_space import DiscretePseudoValuationSpace 

parent = DiscretePseudoValuationSpace(base.domain()) 

return parent.__make_element_class__(ScaledValuation_generic)(parent, base, s) 

 

 

ScaledValuation = ScaledValuationFactory("sage.rings.valuation.scaled_valuation.ScaledValuation") 

 

class ScaledValuation_generic(DiscreteValuation): 

r""" 

A valuation which scales another ``base_valuation`` by a finite positive factor ``s``. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(3); v 

3 * 3-adic valuation 

 

TESTS:: 

 

sage: TestSuite(v).run() # long time 

 

""" 

def __init__(self, parent, base_valuation, s): 

r""" 

.. TODO:: 

 

It is annoying that we have to wrap any possible method on 

``base_valuation`` in this class. It would be nice if this would 

somehow be done automagically, e.g., by adding annotations to the 

methods in ``base_valuation`` that explain which parameters and 

return values need to be scaled. 

 

TESTS:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: from sage.rings.valuation.scaled_valuation import ScaledValuation_generic 

sage: isinstance(v, ScaledValuation_generic) 

True 

 

""" 

DiscreteValuation.__init__(self, parent) 

 

self._base_valuation = base_valuation 

self._scale = s 

 

def _repr_(self): 

r""" 

Return a printable representation of this valuation. 

 

EXAMPLES:: 

 

sage: 3*ZZ.valuation(2) # indirect doctest 

3 * 2-adic valuation 

 

""" 

return "%r * %r"%(self._scale, self._base_valuation) 

 

def residue_ring(self): 

r""" 

Return the residue field of this valuation. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: v.residue_ring() 

Finite Field of size 2 

 

""" 

return self._base_valuation.residue_ring() 

 

def uniformizer(self): 

r""" 

Return a uniformizing element of this valuation. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: v.uniformizer() 

2 

 

""" 

return self._base_valuation.uniformizer() 

 

def _call_(self, f): 

r""" 

Evaluate this valuation at ``f``. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: v(2) 

3 

 

""" 

return self._scale * self._base_valuation(f) 

 

def reduce(self, f): 

r""" 

Return the reduction of ``f`` in the :meth:`~sage.rings.valuation.valuation_space.DiscretePseudoValuationSpace.ElementMethods.residue_field` of this valuation. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: v.reduce(1) 

1 

 

""" 

return self._base_valuation.reduce(f) 

 

def lift(self, F): 

r""" 

Lift ``F`` from the :meth:`~sage.rings.valuation.valuation_space.DiscretePseudoValuationSpace.ElementMethods.residue_field` 

of this valuation into its 

domain. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(2) 

sage: v.lift(1) 

1 

 

""" 

return self._base_valuation.lift(F) 

 

def extensions(self, ring): 

r""" 

Return the extensions of this valuation to ``ring``. 

 

EXAMPLES:: 

 

sage: v = 3*ZZ.valuation(5) 

sage: v.extensions(GaussianIntegers().fraction_field()) 

[3 * [ 5-adic valuation, v(x + 2) = 1 ]-adic valuation, 

3 * [ 5-adic valuation, v(x + 3) = 1 ]-adic valuation] 

 

""" 

return [ScaledValuation(w, self._scale) for w in self._base_valuation.extensions(ring)] 

 

def restriction(self, ring): 

r""" 

Return the restriction of this valuation to ``ring``. 

 

EXAMPLES:: 

 

sage: v = 3*QQ.valuation(5) 

sage: v.restriction(ZZ) 

3 * 5-adic valuation 

 

""" 

return ScaledValuation(self._base_valuation.restriction(ring), self._scale) 

 

def _strictly_separating_element(self, other): 

r""" 

Return an element in the domain of this valuation which has positive 

valuation with respect to this valuation but negative valuation with 

respect to ``other``. 

 

EXAMPLES:: 

 

sage: v2 = QQ.valuation(2) 

sage: v3 = 12 * QQ.valuation(3) 

sage: v2._strictly_separating_element(v3) 

2/3 

 

""" 

return self._base_valuation._strictly_separating_element(other) 

 

def _weakly_separating_element(self, other): 

r""" 

Return an element in the domain of this valuation which has 

positive valuation with respect to this valuation and higher 

valuation with respect to this valuation than with respect to 

``other``. 

 

EXAMPLES:: 

 

sage: v2 = QQ.valuation(2) 

sage: v3 = 12 * QQ.valuation(3) 

sage: v2._weakly_separating_element(v3) 

2 

 

""" 

return self._base_valuation._weakly_separating_element(other) 

 

def _ge_(self, other): 

r""" 

Return whether this valuation is greater or equal to ``other``, a 

valuation on the same domain. 

 

EXAMPLES:: 

 

sage: v2 = QQ.valuation(2) 

sage: 2*v2 >= v2 

True 

sage: v2/2 >= 2*v2 

False 

sage: 3*v2 > 2*v2 

True 

 

Test that non-scaled valuations call through to this method to resolve 

the scaling:: 

 

sage: v2 > v2/2 

True 

 

""" 

if self == other: 

return True 

if isinstance(other, ScaledValuation_generic): 

return (self._scale / other._scale) * self._base_valuation >= other._base_valuation 

if self._scale >= 1: 

if self._base_valuation >= other: 

return True 

else: 

assert not self.is_trivial() 

if self._base_valuation <= other: 

return False 

return super(ScaledValuation_generic, self)._ge_(other) 

 

def _le_(self, other): 

r""" 

Return whether this valuation is smaller or equal to ``other``, a 

valuation on the same domain. 

 

EXAMPLES:: 

 

sage: v2 = QQ.valuation(2) 

sage: 2*v2 <= v2 

False 

sage: v2/2 <= 2*v2 

True 

sage: 3*v2 < 2*v2 

False 

 

Test that non-scaled valuations call through to this method to resolve 

the scaling:: 

 

sage: v2 < v2/2 

False 

 

""" 

return other / self._scale >= self._base_valuation 

 

def value_semigroup(self): 

r""" 

Return the value semigroup of this valuation. 

 

EXAMPLES:: 

 

sage: v2 = QQ.valuation(2) 

sage: (2*v2).value_semigroup() 

Additive Abelian Semigroup generated by -2, 2 

 

""" 

return self._scale * self._base_valuation.value_semigroup()