This repository has been archived by the owner on Aug 1, 2018. It is now read-only.
forked from MCLF/mac_lane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinductive_valuation.py
1561 lines (1227 loc) · 60.2 KB
/
inductive_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"""
Inductive valuations on polynomial rings
This module provides functionality for inductive valuations, i.e., finite
chains of :class:`AugmentedValuation`s on top of a :class:`GaussValuation`.
AUTHORS:
- Julian Rüth (2016-11-01): initial version
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.
"""
#*****************************************************************************
# Copyright (C) 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 valuation import DiscreteValuation, InfiniteDiscretePseudoValuation
from developing_valuation import DevelopingValuation
from sage.misc.cachefunc import cached_method
from sage.misc.abstract_method import abstract_method
class InductiveValuation(DevelopingValuation):
r"""
Abstract base class for iterated :class:`AugmentedValuation` on top of a
: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, 5))
TESTS::
sage: TestSuite(v).run() # long time
"""
def is_equivalence_unit(self, f, valuations=None):
r"""
Return whether ``f`` is an equivalence unit, i.e., an element of
:meth:`effective_degree` zero (see [ML1936'] p.497.)
INPUT:
- ``f`` -- a polynomial in the domain of this valuation
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R = Zp(2,5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: v.is_equivalence_unit(x)
False
sage: v.is_equivalence_unit(S.zero())
False
sage: v.is_equivalence_unit(2*x + 1)
True
"""
f = self.domain().coerce(f)
if f.is_zero():
return False
return self.effective_degree(f, valuations=valuations) == 0
def equivalence_reciprocal(self, f, coefficients=None, valuations=None, check=True):
r"""
Return an equivalence reciprocal of ``f``.
An equivalence reciprocal of `f` is a polynomial `h` such that `f\cdot
h` is equivalent to 1 modulo this valuation (see [ML1936'] p.497.)
INPUT:
- ``f`` -- a polynomial in the domain of this valuation which is an
:meth:`equivalence_unit`
- ``coefficients`` -- the coefficients of ``f`` in the :meth:`phi`-adic
expansion if known (default: ``None``)
- ``valuations`` -- the valuations of ``coefficients`` if known
(default: ``None``)
- ``check`` -- whether or not to check the validity of ``f`` (default:
``True``)
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R = Zp(3,5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: f = 3*x + 2
sage: h = v.equivalence_reciprocal(f); h # optional: integrated (needs xgcd for polynomials with p-adic coefficients)
2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)
sage: v.is_equivalent(f*h, 1) # optional: integrated
True
In an extended valuation over an extension field::
sage: R.<u> = Qq(4,5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: v = v.augmentation(x^2 + x + u, 1)
sage: f = 2*x + u
sage: h = v.equivalence_reciprocal(f); h
(u + 1) + O(2^5)
sage: v.is_equivalent(f*h, 1)
True
Extending the valuation once more::
sage: v = v.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3)
sage: h = v.equivalence_reciprocal(f); h
(u + 1) + O(2^5)
sage: v.is_equivalent(f*h, 1)
True
TESTS:
A case that caused problems at some point::
sage: K = Qp(2, 4)
sage: R.<x> = K[]
sage: L.<a> = K.extension(x^4 + 4*x^3 + 6*x^2 + 4*x + 2)
sage: R.<t> = L[]
sage: v = GaussValuation(R)
sage: w = v.augmentation(t + 1, 5/16)
sage: w = w.augmentation(t^4 + (a^8 + a^12 + a^14 + a^16 + a^17 + a^19 + a^20 + a^23)*t^3 + (a^6 + a^9 + a^13 + a^15 + a^18 + a^19 + a^21)*t^2 + a^10*t + 1 + a^4 + a^5 + a^8 + a^13 + a^14 + a^15, 17/8)
sage: f = a^-15*t^2 + (a^-11 + a^-9 + a^-6 + a^-5 + a^-3 + a^-2)*t + a^-15
sage: f_ = w.equivalence_reciprocal(f)
sage: w.reduce(f*f_)
1
sage: f = f.parent()([f[0], f[1].add_bigoh(1), f[2]])
sage: f_ = w.equivalence_reciprocal(f)
sage: w.reduce(f*f_)
1
"""
f = self.domain().coerce(f)
from sage.categories.fields import Fields
if not self.domain().base_ring() in Fields():
# the xgcd does in general not work, i.e., return 1, unless over a field
raise NotImplementedError("only implemented for polynomial rings over fields")
if check:
if coefficients is None:
coefficients = list(self.coefficients(f))
if valuations is None:
valuations = list(self.valuations(f, coefficients=coefficients))
if not self.is_equivalence_unit(f, valuations=valuations):
raise ValueError("f must be an equivalence unit but %r is not"%(f,))
if coefficients is None:
e0 = self.coefficients(f).next()
else:
e0 = coefficients[0]
# f is an equivalence unit, its valuation is given by the constant coefficient
if valuations is None:
vf = self(e0)
else:
vf = valuations[0]
e0 = self.simplify(e0, error=vf)
s_ = self.equivalence_unit(-vf)
residue = self.reduce(e0 * s_)
if not isinstance(self, FinalInductiveValuation):
assert residue.is_constant()
residue = residue[0]
h = self.lift(~residue) * s_
h = self.simplify(h, -vf)
# it might be the case that f*h has non-zero valuation because h has
# insufficient precision, so we must not assert that here but only
# until we lifted to higher precision
# We do not actually need g*phi + h*e0 = 1, it is only important that
# the RHS is 1 in reduction.
# This allows us to do two things:
# - we may lift h to arbitrary precision
# - we can add anything which times e0 has positive valuation, e.g., we
# may drop coefficients of positive valuation
h = h.map_coefficients(lambda c:_lift_to_maximal_precision(c))
return h
@cached_method
def mu(self):
r"""
Return the valuation of :meth:`phi`.
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: v.mu()
0
"""
return self(self.phi())
@abstract_method
def equivalence_unit(self, s, reciprocal=False):
"""
Return an equivalence unit of valuation ``s``.
INPUT:
- ``s`` -- an element of the :meth:`value_group`
- ``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``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: S.<x> = Qp(3,5)[]
sage: v = GaussValuation(S)
sage: v.equivalence_unit(2)
(3^2 + O(3^7))
sage: v.equivalence_unit(-2)
(3^-2 + O(3^3))
Note that this might fail for negative ``s`` if the domain is not
defined over a field::
sage: v = pAdicValuation(ZZ, 2)
sage: R.<x> = ZZ[]
sage: w = GaussValuation(R, v)
sage: w.equivalence_unit(1)
2
sage: w.equivalence_unit(-1)
Traceback (most recent call last):
...
ValueError: s must be in the value semigroup of this valuation but -1 is not in Additive Abelian Semigroup generated by 1
"""
@abstract_method
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.<u> = Qq(4,5)
sage: S.<x> = R[]
sage: v = GaussValuation(S)
sage: v.augmentation_chain()
[Gauss valuation induced by 2-adic valuation]
"""
@abstract_method
def is_gauss_valuation(self):
r"""
Return whether this valuation is a Gauss valuation over the domain.
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: v.is_gauss_valuation()
True
"""
@abstract_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: v.E()
1
"""
@abstract_method
def F(self):
"""
Return the residual degree of this valuation over its Gauss extension.
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: v.F()
1
"""
@abstract_method
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: v.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)
"""
@abstract_method
def element_with_valuation(self, s):
r"""
Return a polynomial of minimal degree with valuation ``s``.
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: v.element_with_valuation(-2)
1/4
Depending on the base ring, an element of valuation ``s`` might not
exist::
sage: R.<x> = ZZ[]
sage: v = GaussValuation(R, pAdicValuation(ZZ, 2))
sage: v.element_with_valuation(-2)
Traceback (most recent call last):
...
ValueError: s must be in the value semigroup of this valuation but -2 is not in Additive Abelian Semigroup generated by 1
"""
def _test_element_with_valuation_inductive_valuation(self, **options):
r"""
Test the correctness of :meth:`element_with_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: v._test_element_with_valuation_inductive_valuation()
"""
tester = self._tester(**options)
chain = self.augmentation_chain()
for s in tester.some_elements(self.value_group().some_elements()):
try:
R = self.element_with_valuation(s)
except (ValueError, NotImplementedError):
# this is often not possible unless the underlying ring of
# constants is a field
from sage.categories.fields import Fields
if self.domain().base() not in Fields():
continue
raise
tester.assertEqual(self(R), s)
if chain != [self]:
base = chain[1]
if s in base.value_group():
S = base.element_with_valuation(s)
tester.assertEqual(self(S), s)
tester.assertGreaterEqual(S.degree(), R.degree())
def _test_EF(self, **options):
r"""
Test the correctness of :meth:`E` and :meth:`F`.
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: v._test_EF()
"""
tester = self._tester(**options)
chain = self.augmentation_chain()
for w,v in zip(chain, chain[1:]):
from sage.rings.all import infinity, ZZ
if w(w.phi()) is infinity:
tester.assertEqual(w.E(), v.E())
tester.assertIn(w.E(), ZZ)
tester.assertIn(w.F(), ZZ)
tester.assertGreaterEqual(w.E(), v.E())
tester.assertGreaterEqual(w.F(), v.F())
def _test_augmentation_chain(self, **options):
r"""
Test the correctness of :meth:`augmentation_chain`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: v._test_augmentation_chain()
"""
tester = self._tester(**options)
chain = self.augmentation_chain()
tester.assertIs(chain[0], self)
tester.assertTrue(chain[-1].is_gauss_valuation())
for w,v in zip(chain, chain[1:]):
tester.assertGreaterEqual(w, v)
def _test_equivalence_unit(self, **options):
r"""
Test the correctness of :meth:`lift_to_key`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: v._test_equivalence_unit()
"""
tester = self._tester(**options)
if self.is_gauss_valuation():
value_group = self.value_group()
else:
value_group = self.augmentation_chain()[1].value_group()
for s in tester.some_elements(value_group.some_elements()):
try:
R = self.equivalence_unit(s)
except (ValueError, NotImplementedError):
# this is often not possible unless the underlying ring of
# constants is a field
from sage.categories.fields import Fields
if self.domain().base() not in Fields():
continue
raise
tester.assertIs(R.parent(), self.domain())
tester.assertEqual(self(R), s)
tester.assertTrue(self.is_equivalence_unit(R))
def _test_is_equivalence_unit(self, **options):
r"""
Test the correctness of :meth:`is_equivalence_unit`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: v._test_is_equivalence_unit()
"""
tester = self._tester(**options)
tester.assertFalse(self.is_equivalence_unit(self.phi()))
def _test_equivalence_reciprocal(self, **options):
r"""
Test the correctness of :meth:`equivalence_reciprocal`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: v._test_equivalence_reciprocal()
"""
tester = self._tester(**options)
S = tester.some_elements(self.domain().some_elements())
for f in S:
if self.is_equivalence_unit(f):
try:
g = self.equivalence_reciprocal(f)
except (ValueError, NotImplementedError):
# this is often not possible unless the underlying ring of
# constants is a field
from sage.categories.fields import Fields
if self.domain().base() not in Fields():
continue
raise
tester.assertEqual(self.reduce(f*g), 1)
def _test_inductive_valuation_inheritance(self, **options):
r"""
Test that every instance that is a :class:`InductiveValuation` is
either a :class:`FiniteInductiveValuation` or a
:class:`InfiniteInductiveValuation`. Same for
:class:`FinalInductiveValuation` and
:class:`NonFinalInductiveValuation`.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
sage: v._test_inductive_valuation_inheritance()
"""
tester = self._tester(**options)
tester.assertTrue(isinstance(self, InfiniteInductiveValuation) != isinstance(self, FiniteInductiveValuation))
tester.assertTrue(isinstance(self, FinalInductiveValuation) != isinstance(self, NonFinalInductiveValuation))
class FiniteInductiveValuation(InductiveValuation, DiscreteValuation):
r"""
Abstract base class for iterated :class:`AugmentedValuation` on top of a
:class:`GaussValuation` which is a discrete valuation, i.e., the last key
polynomial has finite valuation.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, TrivialValuation(QQ))
"""
def __init__(self, parent, phi):
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: isinstance(v, FiniteInductiveValuation)
True
"""
InductiveValuation.__init__(self, parent, phi)
DiscreteValuation.__init__(self, parent)
def extensions(self, other):
r"""
Return the extensions of this valuation to ``other``.
EXAMPLES::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: R.<x> = ZZ[]
sage: v = GaussValuation(R, TrivialValuation(ZZ))
sage: K.<x> = FunctionField(QQ)
sage: v.extensions(K)
[Trivial valuation on Rational Field]
"""
from sage.categories.function_fields import FunctionFields
if other in FunctionFields() and other.ngens() == 1:
# extend to K[x] and from there to K(x)
v = self.extension(self.domain().change_ring(self.domain().base().fraction_field()))
from function_field_valuation import FunctionFieldValuation
return [FunctionFieldValuation(other, v)]
return super(FiniteInductiveValuation, self).extensions(other)
class NonFinalInductiveValuation(FiniteInductiveValuation, DiscreteValuation):
r"""
Abstract base class for iterated :class:`AugmentedValuation` on top of a
:class:`GaussValuation` which can be extended further through
:meth:`augmentation`.
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: v = v.augmentation(x^2 + x + u, 1)
"""
def __init__(self, parent, phi):
r"""
TESTS::
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: v = v.augmentation(x^2 + x + u, 1)
sage: isinstance(v, NonFinalInductiveValuation)
True
"""
FiniteInductiveValuation.__init__(self, parent, phi)
DiscreteValuation.__init__(self, parent)
def augmentation(self, phi, mu, check=True):
r"""
Return the inductive valuation which extends this valuation by mapping
``phi`` to ``mu``.
INPUT:
- ``phi`` -- a polynomial in the domain of this valuation; this must be
a key polynomial, see :meth:`is_key` for properties of key
polynomials.
- ``mu`` -- a rational number or infinity, the valuation of ``phi`` in
the extended valuation
- ``check`` -- a boolean (default: ``True``), whether or not to check
the correctness of the parameters
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: v = v.augmentation(x^2 + x + u, 1)
sage: v = v.augmentation((x^2 + x + u)^2 + 2*x*(x^2 + x + u) + 4*x, 3)
sage: v
[ Gauss valuation induced by 2-adic valuation,
v((1 + O(2^5))*x^2 + (1 + O(2^5))*x + u + O(2^5)) = 1,
v((1 + O(2^5))*x^4 + (2^2 + O(2^6))*x^3 + (1 + (u + 1)*2 + O(2^5))*x^2 + ((u + 1)*2^2 + O(2^6))*x + (u + 1) + (u + 1)*2 + (u + 1)*2^2 + (u + 1)*2^3 + (u + 1)*2^4 + O(2^5)) = 3 ]
TESTS:
Make sure that we do not make the assumption that the degrees of the
key polynomials are strictly increasing::
sage: v_K = pAdicValuation(QQ,3)
sage: A.<t> = QQ[]
sage: v0 = GaussValuation(A,v_K)
sage: v1 = v0.augmentation(t, 1/12)
sage: v2 = v1.augmentation(t^12 + 3, 7/6)
sage: v3 = v2.augmentation(t^12 + 3*t^2 + 3, 9/4)
sage: v4 = v1.augmentation(t^12 + 3*t^2 + 3, 9/4)
sage: v3 <= v4 and v3 >= v4
True
.. SEEALSO::
:meth:`AugmentedValuation`
"""
from augmented_valuation import AugmentedValuation
return AugmentedValuation(self, phi, mu, check)
def mac_lane_step(self, G, principal_part_bound=None, assume_squarefree=False, assume_equivalence_irreducible=False, report_degree_bounds_and_caches=False, coefficients=None, valuations=None, check=True):
r"""
Perform an approximation step towards the squarefree monic non-constant
integral polynomial ``G`` which is not an :meth:`equivalence_unit`.
This performs the individual steps that are used in
:meth:`mac_lane_approximants`.
INPUT:
- ``G`` -- a sqaurefree monic non-constant integral polynomial ``G``
which is not an :meth:`equivalence_unit`
- ``principal_part_bound`` -- an integer or ``None`` (default:
``None``), a bound on the length of the principal part, i.e., the
section of negative slope, of the Newton polygon of ``G``
- ``assume_squarefree`` -- whether or not to assume that ``G`` is
squarefree (default: ``False``)
- ``assume_equivalence_irreducible`` -- whether or not to assume that
``G`` is equivalence irreducible (default: ``False``)
- ``report_degree_bounds_and_caches`` -- whether or not to include internal state with the returned value (used by :meth:`mac_lane_approximants` to speed up sequential calls)
- ``coefficients`` -- the coefficients of ``G`` in the
:meth:`phi`-adic expansion if known (default: ``None``)
- ``valauations`` -- the valuations of ``coefficients`` if known
(default: ``None``)
- ``check`` -- whether to check that ``G`` is a squarefree monic
non-constant integral polynomial and not an :meth:`equivalence_unit`
(default: ``True``)
TESTS::
sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone
sage: K.<x> = FunctionField(QQ)
sage: S.<y> = K[]
sage: F = y^2 - x^2 - x^3 - 3
sage: v0 = GaussValuation(K._ring,pAdicValuation(QQ, 3))
sage: v1 = v0.augmentation(K._ring.gen(), 1/3)
sage: mu0 = FunctionFieldValuation(K, v1)
sage: eta0 = GaussValuation(S, mu0)
sage: eta1 = eta0.mac_lane_step(F)[0]
sage: eta2 = eta1.mac_lane_step(F)[0]
sage: eta2
[ Gauss valuation induced by Valuation on rational function field induced by [ Gauss valuation induced by 3-adic valuation, v(x) = 1/3 ], v(y + x) = 2/3 ]
"""
G = self.domain().coerce(G)
if G.is_constant():
raise ValueError("G must not be constant")
from itertools import islice
from sage.misc.misc import verbose
verbose("Augmenting %s towards %s"%(self, G), level=10)
if not G.is_monic():
raise ValueError("G must be monic")
if coefficients is None:
coefficients = self.coefficients(G)
if principal_part_bound:
coefficients = islice(coefficients, 0, principal_part_bound + 1, 1)
coefficients = list(coefficients)
if valuations is None:
valuations = self.valuations(G, coefficients=coefficients)
if principal_part_bound:
valuations = islice(valuations, 0, principal_part_bound + 1, 1)
valuations = list(valuations)
if check and min(valuations) < 0:
raise ValueError("G must be integral")
if check and self.is_equivalence_unit(G, valuations=valuations):
raise ValueError("G must not be an equivalence-unit")
if check and not assume_squarefree and not G.is_squarefree():
raise ValueError("G must be squarefree")
from sage.rings.all import infinity
assert self(G) is not infinity # this is a valuation and G is non-zero
ret = []
F = self.equivalence_decomposition(G, assume_not_equivalence_unit=True, coefficients=coefficients, valuations=valuations, compute_unit=False, degree_bound=principal_part_bound)
assert len(F), "%s equivalence-decomposes as an equivalence-unit %s"%(G, F)
if len(F) == 1 and F[0][1] == 1 and F[0][0].degree() == G.degree():
assert self.is_key(G, assume_equivalence_irreducible=assume_equivalence_irreducible)
ret.append((self.augmentation(G, infinity, check=False), G.degree(), principal_part_bound, None, None))
else:
for phi,e in F:
if G == phi:
# Something strange happened here:
# G is not a key (we checked that before) but phi==G is; so phi must have less precision than G
# this can happen if not all coefficients of G have the same precision
# if we drop some precision of G then it will be a key (but is
# that really what we should do?)
assert not G.base_ring().is_exact()
prec = min([c.precision_absolute() for c in phi.list()])
g = G.map_coefficients(lambda c:c.add_bigoh(prec))
assert self.is_key(g)
ret.append((self.augmentation(g, infinity, check=False), g.degree(), principal_part_bound, None, None))
assert len(F) == 1
break
if phi == self.phi():
# a factor phi in the equivalence decomposition means that we
# found an actual factor of G, i.e., we can set
# v(phi)=infinity
# However, this should already have happened in the last step
# (when this polynomial had -infinite slope in the Newton
# polygon.)
if self.is_gauss_valuation(): # unless in the first step
pass
else:
continue
verbose("Determining the augmentation of %s for %s"%(self, phi), level=11)
old_mu = self(phi)
w = self.augmentation(phi, old_mu, check=False)
# we made some experiments here: instead of computing the
# coefficients again from scratch, update the coefficients when
# phi - self.phi() is a constant.
# It turned out to be slightly slower than just recomputing the
# coefficients. The main issue with the approach was that we
# needed to keep track of all the coefficients and not just of
# the coefficients up to principal_part_bound.
w_coefficients = w.coefficients(G)
if principal_part_bound:
w_coefficients = islice(w_coefficients, 0, principal_part_bound + 1, 1)
w_coefficients = list(w_coefficients)
w_valuations = w.valuations(G, coefficients=w_coefficients)
if principal_part_bound:
w_valuations = islice(w_valuations, 0, principal_part_bound + 1, 1)
w_valuations = list(w_valuations)
NP = w.newton_polygon(G, valuations=w_valuations).principal_part()
verbose("Newton-Polygon for v(phi)=%s : %s"%(self(phi), NP), level=11)
slopes = NP.slopes(repetition=True)
multiplicities = {slope : len([s for s in slopes if s == slope]) for slope in slopes}
slopes = multiplicities.keys()
if NP.vertices()[0][0] != 0:
slopes = [-infinity] + slopes
multiplicities[-infinity] = 1
if not slopes:
q,r = G.quo_rem(phi)
assert not r.is_zero()
phi = phi.coefficients(sparse=False)
for i,c in enumerate(r.coefficients(sparse=False)):
if not c.is_zero():
v = w(c)
# for a correct result we need to add O(pi^v) in degree i
# we try to find the coefficient of phi where such an
# error can be introduced without losing much absolute
# precision on phi
best = i
for j in range(i):
if w(q[j]) < w(q[best]):
best = j
# now add the right O() to phi in degree i - best
phi[i-best] = phi[i-best].add_bigoh(w(c)-w(q[best]))
phi = G.parent()(phi)
w = self._base_valuation.augmentation(phi, infinity, check=False)
ret.append((w, phi.degree(), principal_part_bound, None, None))
continue
for i, slope in enumerate(slopes):
slope = slopes[i]
verbose("Slope = %s"%slope, level=12)
new_mu = old_mu - slope
new_valuations = [val - (j*slope if slope is not -infinity else (0 if j == 0 else -infinity)) for j,val in enumerate(w_valuations)]
base = self
if phi.degree() == base.phi().degree():
assert new_mu > self(phi)
if not base.is_gauss_valuation():
base = base._base_valuation
w = base.augmentation(phi, new_mu, check=False)
assert slope is -infinity or 0 in w.newton_polygon(G).slopes(repetition=False)
from sage.rings.all import ZZ
assert (phi.degree() / self.phi().degree()) in ZZ
degree_bound = multiplicities[slope] * phi.degree()
assert degree_bound <= G.degree()
assert degree_bound >= phi.degree()
ret.append((w, degree_bound, multiplicities[slope], w_coefficients, new_valuations))
assert ret
if not report_degree_bounds_and_caches:
ret = [v for v,_,_,_,_ in ret]
return ret
def is_key(self, phi, explain=False, assume_equivalence_irreducible=False):
r"""
Return whether ``phi`` is a key polynomial for this valuation, i.e.,
whether it is monic, whether it :meth:`is_equivalence_irreducible`, and
whether it is :meth:`is_minimal`.
INPUT:
- ``phi`` -- a polynomial in the domain of this valuation
- ``explain`` -- a boolean (default: ``False``), if ``True``, return a
string explaining why ``phi`` is not a key polynomial
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: v.is_key(x)
True
sage: v.is_key(2*x, explain = True)
(False, 'phi must be monic')
sage: v.is_key(x^2, explain = True)
(False, 'phi must be equivalence irreducible')
sage: w = v.augmentation(x, 1)
sage: w.is_key(x + 1, explain = True)
(False, 'phi must be minimal')
"""
phi = self.domain().coerce(phi)
reason = None
if not phi.is_monic():
reason = "phi must be monic"
elif not assume_equivalence_irreducible and not self.is_equivalence_irreducible(phi):
reason = "phi must be equivalence irreducible"
elif not self.is_minimal(phi, assume_equivalence_irreducible=True):
reason = "phi must be minimal"
if explain:
return reason is None, reason
else:
return reason is None
def is_minimal(self, f, assume_equivalence_irreducible=False):
r"""
Return whether the polynomial ``f`` is minimal with respect to this
valuation, i.e., whether ``f`` is not constant any non-constant
polynomial `h` has at least the degree of ``f`` or ``f`` is not
divisible by `h` with respect to this valuation, i.e., there is no `c`
such that `c h` :meth:`is_equivalent` to `f`.
ALGORITHM:
Based on Theorem 9.4 of [ML1936'].
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: v.is_minimal(x + 1)
True
sage: w = v.augmentation(x, 1)
sage: w.is_minimal(x + 1)
False
TESTS::
sage: K = Qp(2, 10)
sage: R.<x> = K[]
sage: vp = pAdicValuation(K)
sage: v0 = GaussValuation(R, vp)
sage: v1 = v0.augmentation(x, 1/4)
sage: v2 = v1.augmentation(x^4 + 2, 5/4)
sage: v2.is_minimal(x^5 + x^4 + 2)
False
Polynomials which are equivalent to the key polynomial are minimal if
and only if they have the same degree as the key polynomial::
sage: v2.is_minimal(x^4 + 2)
True
sage: v2.is_minimal(x^4 + 4)
False
"""
f = self.domain().coerce(f)
if f.is_constant():
return False
if not assume_equivalence_irreducible and not self.is_equivalence_irreducible(f):
# any factor divides f with respect to this valuation
return False
if not f.is_monic():
# divide out the leading factor, it does not change minimality
v = self
if not self.domain().base_ring().is_field():
domain = self.domain().change_ring(self.domain().base_ring().fraction_field())
v = self.extension(domain)
f = domain(f)
return v.is_minimal(f / f.leading_coefficient())
if self.is_gauss_valuation():
if self(f) == 0:
F = self.reduce(f, check=False)
assert not F.is_constant()
return F.is_irreducible()
else:
assert(self(f) <= 0) # f is monic
# f is not minimal:
# Let g be f stripped of its leading term, i.e., g = f - x^n.
# Then g and f are equivalent with respect to this valuation
# and in particular g divides f with respect to this valuation
return False
if self.is_equivalent(self.phi(), f):