This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
augmented_valuation.py
2128 lines (1638 loc) · 74.5 KB
/
augmented_valuation.py
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
r"""
Augmented valuations on polynomial rings
Implements augmentations of valutions as defined in [ML1936].
Starting from a :class:`GaussValuation`, we can create augmented valuations on
polynomial rings::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x, 1); w
[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ]
sage: w(x)
1
This also works for polynomial rings over base rings which are not fields.
However, much of the functionality is only available over fields::
sage: R.<x> = ZZ[]
sage: v = GaussValuation(R, pAdicValuation(ZZ, 2))
sage: w = v.augmentation(x, 1); w
[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ]
sage: w(x)
1
TESTS::
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x, 1)
sage: TestSuite(w).run() # long time
sage: w = v.augmentation(x, 2)
sage: TestSuite(w).run() # long time
Run the test suite for a valuation with a residual extension::
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: TestSuite(w).run() # long time
Run the test suite for an iterated residual extension starting from a
non-prime residue field::
sage: R.<u> = Qq(4, 40)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation(x^8 + 4*x^7 + 2*x^6 + 2*x^5 + x^4 + 2*x^3 + 4*(u + 1)*x^2 + 6*(u + 1)*x + 4 + 3*u, 10)
sage: TestSuite(ww).run() # long time
Run the test suite for an augmentation of a ramified augmentation::
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x, 3/4)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation(x^4 + 8, 5)
sage: TestSuite(ww).run() # long time
Run the test suite for a ramified augmentation of an unramified augmentation::
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation(x^4 + 2*x^3 + 5*x^2 + 8*x + 3, 16/3)
sage: TestSuite(ww).run() # long time
Run the test suite for a ramified augmentation of a ramified augmentation::
sage: R.<u> = Qq(4, 20)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3)
sage: TestSuite(ww).run() # long time
Run the test suite for another augmentation with iterated residue field extensions::
sage: R.<u> = Qq(4, 10)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3)
sage: TestSuite(ww).run() # long time
Run the test suite for a rather trivial pseudo-valuation::
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x, infinity)
sage: TestSuite(w).run() # long time
Run the test suite for an infinite valuation which extends the residue field::
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, infinity)
sage: TestSuite(w).run() # long time
Run the test suite for an infinite valuation which extends a valuation which
extends the residue field::
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: TestSuite(w).run() # long time
sage: ww = w.augmentation((x^2 + x + u)^2 + 2, infinity)
sage: TestSuite(ww).run() # long time
Run the test suite if the polynomial ring is not over a field::
sage: R.<x> = ZZ[]
sage: v = GaussValuation(R, pAdicValuation(ZZ, 2))
sage: w = v.augmentation(x, 1)
sage: TestSuite(w).run() # long time
REFERENCES:
.. [ML1936] Mac Lane, S. (1936). A construction for prime ideals as absolute
values of an algebraic field. Duke Mathematical Journal, 2(3), 492-510.
.. [ML1936'] MacLane, S. (1936). A construction for absolute values in
polynomial rings. Transactions of the American Mathematical Society, 40(3),
363-395.
AUTHORS:
- Julian Rüth (2013-04-15): initial version
"""
#*****************************************************************************
# Copyright (C) 2013-2016 Julian Rüth <[email protected]>
#
# 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 inductive_valuation import _lift_to_maximal_precision
from inductive_valuation import FinalInductiveValuation, NonFinalInductiveValuation, FiniteInductiveValuation, InfiniteInductiveValuation, InductiveValuation
from valuation import InfiniteDiscretePseudoValuation, DiscreteValuation
from sage.misc.cachefunc import cached_method
from sage.rings.all import infinity, QQ, ZZ
from sage.structure.factory import UniqueFactory
class AugmentedValuationFactory(UniqueFactory):
r"""
Factory for augmented valuations.
EXAMPLES:
This factory is not meant to be called directly. Instead,
:meth:`augmentation` of a valuation should be called::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x, 1) # indirect doctest
Note that trivial parts of the augmented valuation might be dropped, so you
should not rely on ``_base_valuation`` to be the valuation you started
with::
sage: ww = w.augmentation(x, 2)
sage: ww._base_valuation is v
True
"""
def create_key(self, base_valuation, phi, mu, check=True):
r"""
Create a key which uniquely identifies the valuation over
``base_valuation`` which sends ``phi`` to ``mu``.
.. NOTE::
The uniqueness that this factory provides is not why we chose to
use a factory. However, it makes pickling and equality checks much
easier. At the same time, going through a factory makes it easier
to enforce that all instances correctly inherit methods from the
parent Hom space.
TESTS::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x, 1) # indirect doctest
sage: ww = v.augmentation(x, 1)
sage: w is ww
True
"""
if check:
is_key, reason = base_valuation.is_key(phi, explain=True)
if not is_key:
raise ValueError(reason)
if mu <= base_valuation(phi):
raise ValueError("the value of the key polynomial must strictly increase but `%s` does not exceed `%s`."%(mu, base_valuation(phi)))
if not isinstance(base_valuation, InductiveValuation):
raise TypeError("base_valuation must be inductive")
phi = base_valuation.domain().coerce(phi)
if mu is not infinity:
mu = QQ(mu)
if isinstance(base_valuation, AugmentedValuation_base):
if phi.degree() == base_valuation.phi().degree():
# drop base_valuation and extend base_valuation._base_valuation instead
return self.create_key(base_valuation._base_valuation, phi, mu, check=check)
return base_valuation, phi, mu
def create_object(self, version, key):
r"""
Create the augmented valuation represented by ``key``.
TESTS::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1) # indirect doctest
"""
base_valuation, phi, mu = key
from valuation_space import DiscretePseudoValuationSpace
parent = DiscretePseudoValuationSpace(base_valuation.domain())
if mu is not infinity:
if base_valuation.is_trivial():
return parent.__make_element_class__(FinalFiniteAugmentedValuation)(parent, base_valuation, phi, mu)
else:
return parent.__make_element_class__(NonFinalFiniteAugmentedValuation)(parent, base_valuation, phi, mu)
else:
return parent.__make_element_class__(InfiniteAugmentedValuation)(parent, base_valuation, phi, mu)
AugmentedValuation = AugmentedValuationFactory("AugmentedValuation")
class AugmentedValuation_base(InductiveValuation):
"""
An augmented valuation is a discrete valuation on a polynomial ring. It
extends another discrete valuation `v` by setting the valuation of a
polynomial `f` to the minumum of `v(f_i)i\mu` when writing `f=\sum_i
f_i\phi^i`.
INPUT:
- ``v`` -- a :class:`InductiveValuation` on a polynomial ring
- ``phi`` -- a key polynomial over ``v`` (see :meth:`is_key`)
- ``mu`` -- a rational number such that ``mu > v(phi)`` or ``infinity``
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: K.<u> = CyclotomicField(5)
sage: R.<x> = K[]
sage: v = GaussValuation(R, pAdicValuation(K, 2))
sage: w = v.augmentation(x, 1/2); w # indirect doctest
[ Gauss valuation induced by 2-adic valuation, v(x) = 1/2 ]
sage: ww = w.augmentation(x^4 + 2*x^2 + 4*u, 3); ww
[ Gauss valuation induced by 2-adic valuation, v(x) = 1/2, v(x^4 + 2*x^2 + 4*u) = 3 ]
TESTS::
sage: TestSuite(w).run() # long time
sage: TestSuite(ww).run() # long time
"""
def __init__(self, parent, v, phi, mu):
"""
TESTS::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: K.<u> = Qq(4, 5)
sage: R.<x> = K[]
sage: v = GaussValuation(R)
sage: w = AugmentedValuation(v, x, 1/2)
sage: isinstance(w, AugmentedValuation_base)
True
sage: TestSuite(w).run() # long time
"""
InductiveValuation.__init__(self, parent, phi)
self._base_valuation = v
self._mu = mu
@cached_method
def equivalence_unit(self, s, reciprocal=False):
"""
Return an equivalence unit of minimal degree and valuation ``s``.
INPUT:
- ``s`` -- a rational number
- ``reciprocal`` -- a boolean (default: ``False``); whether or not to
return the equivalence unit as the :meth:`equivalence_reciprocal` of
the equivalence unit of valuation ``-s``.
OUTPUT:
A polynomial in the domain of this valuation which
:meth:`is_equivalence_unit` for this valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1)
sage: w.equivalence_unit(0)
1 + O(2^5)
sage: w.equivalence_unit(-4)
2^-4 + O(2)
Since an equivalence unit is of effective degree zero, `\phi` must not
divide it. Therefore, its valuation is in the value group of the base
valuation::
sage: w = v.augmentation(x, 1/2)
sage: w.equivalence_unit(3/2)
Traceback (most recent call last):
...
ValueError: 3/2 is not in the value semigroup of 2-adic valuation
sage: w.equivalence_unit(1)
2 + O(2^6)
An equivalence unit might not be integral, even if ``s >= 0``::
sage: w = v.augmentation(x, 3/4)
sage: ww = w.augmentation(x^4 + 8, 5)
sage: ww.equivalence_unit(1/2)
(2^-1 + O(2^4))*x^2
"""
if reciprocal:
ret = self._base_valuation.element_with_valuation(s)
residue = self.reduce(ret*self._base_valuation.element_with_valuation(-s), check=False)
assert residue.is_constant()
ret *= self.lift(~(residue[0]))
#ret = self.equivalence_reciprocal(self.equivalence_unit(-s))
else:
ret = self._base_valuation.element_with_valuation(s)
assert self.is_equivalence_unit(ret)
assert self(ret) == s
return ret
@cached_method
def element_with_valuation(self, s):
"""
Create an element of minimal degree and of valuation ``s``.
INPUT:
- ``s`` -- a rational number in the value group of this valuation
OUTPUT:
An element in the domain of this valuation
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: w.element_with_valuation(0)
1 + O(2^5)
sage: w.element_with_valuation(1/2)
(1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)
sage: w.element_with_valuation(1)
2 + O(2^6)
sage: c = w.element_with_valuation(-1/2); c
(2^-1 + O(2^4))*x^2 + (2^-1 + O(2^4))*x + u*2^-1 + O(2^4)
sage: w(c)
-1/2
sage: w.element_with_valuation(1/3)
Traceback (most recent call last):
...
ValueError: s must be in the value group of the valuation but 1/3 is not in Additive Abelian Group generated by 1/2.
"""
if s not in self.value_group():
raise ValueError("s must be in the value group of the valuation but %r is not in %r."%(s, self.value_group()))
error = s
ret = self.domain().one()
while s not in self._base_valuation.value_group():
ret *= self._phi
s -= self._mu
ret = ret * self._base_valuation.element_with_valuation(s)
return self.simplify(ret, error=error)
def _repr_(self):
"""
Return a printable representation of this valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: w # indirect doctest
[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)) = 1/2 ]
"""
vals = self.augmentation_chain()
vals.reverse()
vals = [ "v(%s) = %s"%(v._phi, v._mu) if isinstance(v, AugmentedValuation_base) else str(v) for v in vals ]
return "[ %s ]"%", ".join(vals)
def augmentation_chain(self):
r"""
Return a list with the chain of augmentations down to the underlying
:class:`GaussValuation`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x, 1)
sage: w.augmentation_chain()
[[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ],
Gauss valuation induced by 2-adic valuation]
For performance reasons, (and to simplify the underlying
implementation,) trivial augmentations might get dropped. You should
not rely on :meth:`augmentation_chain` to contain all the steps that
you specified to create the current valuation::
sage: ww = w.augmentation(x, 2)
sage: ww.augmentation_chain()
[[ Gauss valuation induced by 2-adic valuation, v(x) = 2 ],
Gauss valuation induced by 2-adic valuation]
"""
return [self] + self._base_valuation.augmentation_chain()
@cached_method
def psi(self):
"""
Return the minimal polynomial of the residue field extension of this valuation.
OUTPUT:
A polynomial in the residue ring of the base valuation
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: w.psi()
x^2 + x + u0
sage: ww = w.augmentation((x^2 + x + u)^2 + 2, 5/3)
sage: ww.psi()
x + 1
"""
R = self._base_valuation.equivalence_unit(-self._base_valuation(self._phi))
F = self._base_valuation.reduce(self._phi*R, check=False).monic()
assert F.is_irreducible()
return F
@cached_method
def E(self):
"""
Return the ramification index of this valuation over its underlying
Gauss valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1)
sage: w.E()
1
sage: w = v.augmentation(x, 1/2)
sage: w.E()
2
"""
if self.augmentation_chain()[-1].is_trivial():
raise NotImplementedError("ramification index is not defined over a trivial Gauss valuation")
return self.value_group().index(self._base_valuation.value_group()) * self._base_valuation.E()
@cached_method
def F(self):
"""
Return the degree of the residue field extension of this valuation
over the underlying Gauss valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = Qq(4, 5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: w = v.augmentation(x^2 + x + u, 1)
sage: w.F()
2
sage: w = v.augmentation(x, 1/2)
sage: w.F()
1
"""
return self.phi().degree() // self._base_valuation.E()
def extensions(self, ring):
r"""
Return the extensions of this valuation to ``ring``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.extensions(GaussianIntegers().fraction_field()['x'])
[[ Gauss valuation induced by 2-adic valuation, v(x^2 + x + 1) = 1 ]]
"""
if ring is self.domain():
return [self]
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
if is_PolynomialRing(ring) and ring.ngens() == 1:
base_valuations = self._base_valuation.extensions(ring)
phi = self.phi().change_ring(ring.base_ring())
ret = []
for v in base_valuations:
if v.is_key(phi):
ret.append(AugmentedValuation(v, phi, self._mu))
else:
F = v.equivalence_decomposition(phi)
mu0 = v(phi)
for f,e in F:
# We construct a valuation with [v, w(phi) = mu] which should be such that
# self(phi) = self._mu, i.e., w(phi) = w(unit) + sum e_i * w(f_i) where
# the sum runs over all the factors in the equivalence decomposition of phi
# Solving for mu gives
mu = (self._mu - v(F.unit()) - sum([ee*v(ff) for ff,ee in F if ff != f])) / e
ret.append(AugmentedValuation(v, f, mu))
return ret
return super(AugmentedValuation_base, self).extensions(ring)
def restriction(self, ring):
r"""
Return the restriction of this valuation to ``ring``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: K = GaussianIntegers().fraction_field()
sage: R.<x> = K[]
sage: v = GaussValuation(R, pAdicValuation(K, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.restriction(QQ['x'])
[ Gauss valuation induced by 2-adic valuation, v(x^2 + x + 1) = 1 ]
"""
if ring.is_subring(self.domain()):
base = self._base_valuation.restriction(ring)
if ring.is_subring(self.domain().base_ring()):
return base
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
if is_PolynomialRing(ring) and ring.ngens() == 1:
return base.augmentation(self.phi().change_ring(ring.base()), self._mu)
return super(AugmentedValuation_base, self).restriction(ring)
def uniformizer(self):
r"""
Return a uniformizing element for this valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.uniformizer()
2
"""
return self.element_with_valuation(self.value_group()._generator)
def is_gauss_valuation(self):
r"""
Return whether this valuation is a Gauss valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.is_gauss_valuation()
False
"""
assert(self._mu > 0)
return False
def monic_integral_model(self, G):
r"""
Return a monic integral irreducible polynomial which defines the same
extension of the base ring of the domain as the irreducible polynomial
``G`` together with maps between the old and the new polynomial.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.monic_integral_model(5*x^2 + 1/2*x + 1/4)
(Ring endomorphism of Univariate Polynomial Ring in x over Rational Field
Defn: x |--> 1/2*x,
Ring endomorphism of Univariate Polynomial Ring in x over Rational Field
Defn: x |--> 2*x,
x^2 + 1/5*x + 1/5)
"""
return self._base_valuation.monic_integral_model(G)
def _ge_(self, other):
r"""
Return whether this valuation is greater or equal than ``other``
everywhere.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w >= v
True
sage: ww = v.augmentation(x^2 + x + 1, 2)
sage: ww >= w
True
sage: www = w.augmentation(x^4 + 2*x^3 + 5*x^2 + 8*x + 3, 16/3)
sage: www >= w
True
sage: www >= ww
False
"""
from gauss_valuation import GaussValuation_generic
if other.is_trivial():
return other.is_discrete_valuation()
if isinstance(other, GaussValuation_generic):
return self._base_valuation >= other
if isinstance(other, AugmentedValuation_base):
if self(other._phi) >= other._mu:
return self >= other._base_valuation
else:
return False
return super(AugmentedValuation_base, self)._ge_(other)
def is_trivial(self):
r"""
Return whether this valuation is trivial, i.e., zero outside of zero.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w.is_trivial()
False
"""
# We need to override the default implementation from valuation_space
# because that one uses uniformizer() which might not be implemented if
# the base ring is not a field.
return False
def scale(self, scalar):
r"""
Return this valuation scaled by ``scalar``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: 3*w # indirect doctest
[ Gauss valuation induced by 3 * 2-adic valuation, v(x^2 + x + 1) = 3 ]
"""
if scalar in QQ and scalar > 0 and scalar != 1:
return self._base_valuation.scale(scalar).augmentation(self.phi(), scalar*self._mu)
return super(AugmentedValuation_base, self).scale(scalar)
def _residue_ring_generator_name(self):
r"""
Return a name for a generator of the residue ring.
This method is used by :meth:`residue_ring` to work around name clashes
with names in subrings of the residue ring.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, 1)
sage: w._residue_ring_generator_name()
'u1'
"""
base = self._base_valuation.residue_ring().base()
# we need a name for a generator that is not present already in base
generator = 'u' + str(len(self.augmentation_chain()) - 1)
while True:
try:
base(generator)
generator = 'u' + generator
except NameError:
# use this name, it has no meaning in base
return generator
except TypeError:
# use this name, base can not handle strings, so hopefully,
# there are no variable names (such as in QQ or GF(p))
return generator
def _relative_size(self, f):
r"""
Return an estimate on the coefficient size of ``f``.
The number returned is an estimate on the factor between the number of
bits used by ``f`` and the minimal number of bits used by an element
congruent to ``f``.
This is used by :meth:`simplify` to decide whether simplification of
coefficients is going to lead to a significant shrinking of the
coefficients of ``f``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<u> = QQ[]
sage: K.<u> = QQ.extension(u^2 + u+ 1)
sage: S.<x> = K[]
sage: v = GaussValuation(S, pAdicValuation(K, 2))
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: w._relative_size(x^2 + x + 1)
1
sage: w._relative_size(1048576*x^2 + 1048576*x + 1048576)
21
"""
return self._base_valuation._relative_size(f)
def is_negative_pseudo_valuation(self):
r"""
Return whether this valuation attains `-\infty`.
EXAMPLES:
No element in the domain of an augmented valuation can have valuation
`-\infty`, so this method always returns ``False``::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: w = v.augmentation(x, infinity)
sage: w.is_negative_pseudo_valuation()
False
"""
return False
def change_domain(self, ring):
r"""
Return this valuation over ``ring``.
EXAMPLES:
We can change the domain of an augmented valuation even if there is no coercion between rings::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = GaussianIntegers()[]
sage: v = GaussValuation(R, pAdicValuation(GaussianIntegers(), 2))
sage: v = v.augmentation(x, 1)
sage: v.change_domain(QQ['x'])
[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ]
"""
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
if is_PolynomialRing(ring) and ring.ngens() == 1 and ring.variable_name() == self.domain().variable_name():
return self._base_valuation.change_domain(ring).augmentation(self.phi().change_ring(ring.base_ring()), self._mu, check=False)
return super(AugmentedValuation_base, self).change_domain(ring)
class FinalAugmentedValuation(AugmentedValuation_base, FinalInductiveValuation):
r"""
An augmented valuation which can not be augmented anymore, either because
it augments a trivial valuation or because it is infinite.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: w = v.augmentation(x, 1)
"""
def __init__(self, parent, v, phi, mu):
r"""
TESTS::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: w = v.augmentation(x, 1)
sage: isinstance(w, FinalAugmentedValuation)
True
"""
AugmentedValuation_base.__init__(self, parent, v, phi, mu)
FinalInductiveValuation.__init__(self, parent, phi)
@cached_method
def residue_ring(self):
r"""
Return the residue ring of this valuation, i.e., the elements of
non-negative valuation modulo the elements of positive valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: w = v.augmentation(x, 1)
sage: w.residue_ring()
Rational Field
sage: w = v.augmentation(x^2 + x + 1, infinity)
sage: w.residue_ring()
Number Field in u1 with defining polynomial x^2 + x + 1
An example with a non-trivial base valuation::
sage: v = GaussValuation(R, pAdicValuation(QQ, 2))
sage: w = v.augmentation(x^2 + x + 1, infinity)
sage: w.residue_ring()
Finite Field in u1 of size 2^2
Since trivial extensions of finite fields are not implemented, the
resulting ring might be identical to the residue ring of the underlying
valuation::
sage: w = v.augmentation(x, infinity)
sage: w.residue_ring()
Finite Field of size 2
TESTS:
We avoid clashes in generator names::
sage: K.<x> = FunctionField(QQ)
sage: v = FunctionFieldValuation(K, x^2 + 2)
sage: R.<y> = K[]
sage: L.<y> = K.extension(y^2 + x^2)
sage: w = v.extension(L)
sage: w.residue_field()
Number Field in uu1 with defining polynomial y^2 - 2 over its base field
sage: w.residue_field().base_field()
Number Field in u1 with defining polynomial x^2 + 2
"""
# the following is correct, even if the polynomial ring is not over a field
base = self._base_valuation.residue_ring().base()
if self.psi().degree() > 1:
generator = self._residue_ring_generator_name()
return base.extension(self.psi(), names=generator)
else:
# Do not call extension() if self.psi().degree() == 1:
# In that case the resulting field appears to be the same as the original field,
# however, it is not == to the original field (for finite fields at
# least) but a distinct copy (this is a bug in finite field's
# extension() implementation.)
return base
def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations=None):
r"""
Reduce ``f`` module this valuation.
INPUT:
- ``f`` -- an element in the domain of this valuation
- ``check`` -- whether or not to check whether ``f`` has non-negative
valuation (default: ``True``)
- ``degree_bound`` -- an a-priori known bound on the degree of the
result which can speed up the computation (default: not set)
- ``coefficients`` -- the coefficients of ``f`` as produced by
:meth:`coefficients` or ``None`` (default: ``None``); this can be
used to speed up the computation when the expansion of ``f`` is
already known from a previous computation.
- ``valuations`` -- the valuations of ``coefficients`` or ``None``
(default: ``None``); ignored
OUTPUT:
an element of the :meth:`residue_ring` of this valuation, the reduction
modulo the ideal of elements of positive valuation
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: w = v.augmentation(x, 1)
sage: w.reduce(x^2 + x + 1)
1
sage: w = v.augmentation(x^2 + x + 1, infinity)
sage: w.reduce(x)
u1
TESTS:
Cases with non-trivial base valuation::
sage: R.<u> = Qq(4, 10)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: v.reduce(x)
x
sage: v.reduce(S(u))
u0
sage: w = v.augmentation(x^2 + x + u, 1/2)
sage: w.reduce(S.one())
1
sage: w.reduce(S(2))
0
sage: w.reduce(S(u))
u0