diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index d3a701decfe..2004f295d20 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -975,10 +975,10 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, 2. The modulus can also be given as a **symbolic expression**. :: - sage: x = var('x') - sage: X. = Qq(27, modulus = x^3 + 2*x + 1); X.modulus() + sage: x = var('x') # needs sage.symbolic + sage: X. = Qq(27, modulus = x^3 + 2*x + 1); X.modulus() # needs sage.symbolic (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) - sage: X == R + sage: X == R # needs sage.symbolic True By default, the polynomial chosen is the standard lift of the @@ -2225,10 +2225,10 @@ def Zq(q, prec=None, type='capped-rel', modulus=None, names=None, 2. The modulus can also be given as a **symbolic expression**. :: - sage: x = var('x') - sage: X. = Zq(27, modulus = x^3 + 2*x + 1); X.modulus() + sage: x = var('x') # needs sage.symbolic + sage: X. = Zq(27, modulus = x^3 + 2*x + 1); X.modulus() # needs sage.symbolic (1 + O(3^20))*x^3 + O(3^20)*x^2 + (2 + O(3^20))*x + 1 + O(3^20) - sage: X == R + sage: X == R # needs sage.symbolic True By default, the polynomial chosen is the standard lift of the diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 21f3e458255..6dbebfb5347 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.padics +# sage.doctest: needs sage.rings.padics r""" Local Generic diff --git a/src/sage/rings/padics/local_generic_element.pyx b/src/sage/rings/padics/local_generic_element.pyx index 5a757de50bb..6c78114f395 100644 --- a/src/sage/rings/padics/local_generic_element.pyx +++ b/src/sage/rings/padics/local_generic_element.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.padics +# sage.doctest: needs sage.rings.padics """ Local Generic Element diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index d3c3a72083d..46b261c95dc 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -91,25 +91,25 @@ def gauss_sum(a, p, f, prec=20, factored=False, algorithm='pari', parent=None): In this example, we verify that `g_3(0) = -1`:: sage: from sage.rings.padics.misc import gauss_sum - sage: -gauss_sum(0, 3, 1) # optional - sage.rings.padics + sage: -gauss_sum(0, 3, 1) # needs sage.rings.padics 1 + O(pi^40) Next, we verify that `g_5(a) g_5(-a) = 5 (-1)^a`:: sage: from sage.rings.padics.misc import gauss_sum - sage: gauss_sum(2,5,1)^2 - 5 # optional - sage.rings.padics + sage: gauss_sum(2,5,1)^2 - 5 # needs sage.rings.padics O(pi^84) - sage: gauss_sum(1,5,1)*gauss_sum(3,5,1) + 5 # optional - sage.rings.padics + sage: gauss_sum(1,5,1)*gauss_sum(3,5,1) + 5 # needs sage.rings.padics O(pi^84) Finally, we compute a non-trivial value:: sage: from sage.rings.padics.misc import gauss_sum - sage: gauss_sum(2,13,2) # optional - sage.rings.padics + sage: gauss_sum(2,13,2) # needs sage.rings.padics 6*pi^2 + 7*pi^14 + 11*pi^26 + 3*pi^62 + 6*pi^74 + 3*pi^86 + 5*pi^98 + pi^110 + 7*pi^134 + 9*pi^146 + 4*pi^158 + 6*pi^170 + 4*pi^194 + pi^206 + 6*pi^218 + 9*pi^230 + O(pi^242) - sage: gauss_sum(2,13,2, prec=5, factored=True) # optional - sage.rings.padics + sage: gauss_sum(2,13,2, prec=5, factored=True) # needs sage.rings.padics (2, 6 + 6*13 + 10*13^2 + O(13^5)) .. SEEALSO:: diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index 6be6bceec0a..56f241fd777 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -433,11 +433,11 @@ def plot(self, max_points=2500, **args): EXAMPLES:: - sage: Zp(3).plot() + sage: Zp(3).plot() # needs sage.plot Graphics object consisting of 1 graphics primitive - sage: Zp(5).plot(max_points=625) + sage: Zp(5).plot(max_points=625) # needs sage.plot Graphics object consisting of 1 graphics primitive - sage: Zp(23).plot(rgbcolor=(1,0,0)) + sage: Zp(23).plot(rgbcolor=(1,0,0)) # needs sage.plot Graphics object consisting of 1 graphics primitive """ if 'pointsize' not in args: diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index a4596240d57..34e92135b55 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.padics +# sage.doctest: needs sage.rings.padics r""" `p`-adic Generic @@ -36,7 +36,6 @@ from sage.rings.ring import PrincipalIdealDomain from sage.rings.integer import Integer from sage.rings.infinity import Infinity -from sage.rings.padics.padic_printing import pAdicPrinter from sage.rings.padics.precision_error import PrecisionError from sage.misc.cachefunc import cached_method from sage.structure.richcmp import richcmp_not_equal @@ -59,6 +58,8 @@ def __init__(self, base, p, prec, print_mode, names, element_class, category=Non sage: R = Zp(17) # indirect doctest """ + from sage.rings.padics.padic_printing import pAdicPrinter + if category is None: if self.is_field(): category = Fields() @@ -1896,6 +1897,8 @@ def local_print_mode(obj, print_options, pos=None, ram_name=None): For more documentation see :class:`sage.structure.parent_gens.localvars`. """ + from sage.rings.padics.padic_printing import pAdicPrinter + if isinstance(print_options, str): print_options = {'mode': print_options} elif not isinstance(print_options, dict): diff --git a/src/sage/rings/padics/padic_lattice_element.py b/src/sage/rings/padics/padic_lattice_element.py index 141af863ef5..a8d9e507b90 100644 --- a/src/sage/rings/padics/padic_lattice_element.py +++ b/src/sage/rings/padics/padic_lattice_element.py @@ -17,10 +17,11 @@ sage: R3 = QpLC(2) sage: R4 = QpLF(2) - sage: TestSuite(R1).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time - sage: TestSuite(R2).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time - sage: TestSuite(R3).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time - sage: TestSuite(R4).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time + sage: # long time + sage: TestSuite(R1).run(skip=['_test_teichmuller', '_test_matrix_smith']) + sage: TestSuite(R2).run(skip=['_test_teichmuller', '_test_matrix_smith']) + sage: TestSuite(R3).run(skip=['_test_teichmuller', '_test_matrix_smith']) + sage: TestSuite(R4).run(skip=['_test_teichmuller', '_test_matrix_smith']) """ # **************************************************************************** diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index 40425b3dbe8..ed820abc78c 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -12,6 +12,7 @@ Discrete valuations can be created on a variety of rings:: + sage: # needs sage.rings.padics sage: ZZ.valuation(2) 2-adic valuation sage: GaussianIntegers().valuation(3) @@ -34,15 +35,15 @@ :: sage: R. = QQ[] - sage: v = QQ.valuation(2) - sage: w = GaussValuation(R, v) - sage: w.augmentation(x, 3) + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: w = GaussValuation(R, v) # needs sage.rings.padics + sage: w.augmentation(x, 3) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x) = 3 ] We can also define discrete pseudo-valuations, i.e., discrete valuations that send more than just zero to infinity:: - sage: w.augmentation(x, infinity) + sage: w.augmentation(x, infinity) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x) = +Infinity ] """ # **************************************************************************** @@ -71,12 +72,12 @@ class DiscretePseudoValuation(Morphism): EXAMPLES:: - sage: v = ZZ.valuation(2); v # indirect doctest + sage: v = ZZ.valuation(2); v # indirect doctest 2-adic valuation TESTS:: - sage: TestSuite(v).run() # long time + sage: TestSuite(v).run() # long time """ def __init__(self, parent): @@ -84,7 +85,7 @@ def __init__(self, parent): TESTS:: sage: from sage.rings.valuation.valuation import DiscretePseudoValuation - sage: isinstance(ZZ.valuation(2), DiscretePseudoValuation) + sage: isinstance(ZZ.valuation(2), DiscretePseudoValuation) # needs sage.rings.padics True """ @@ -96,6 +97,7 @@ def is_equivalent(self, f, g): EXAMPLES:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: v.is_equivalent(2, 1) False @@ -124,8 +126,8 @@ def __hash__(self): EXAMPLES:: - sage: v = QQ.valuation(2) - sage: hash(v) == hash(v) # indirect doctest + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: hash(v) == hash(v) # indirect doctest # needs sage.rings.padics True """ @@ -145,8 +147,8 @@ def _hash_(self): EXAMPLES:: - sage: v = QQ.valuation(2) - sage: hash(v) == hash(v) # indirect doctest + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: hash(v) == hash(v) # indirect doctest # needs sage.rings.padics True """ @@ -167,6 +169,7 @@ def _richcmp_(self, other, op): EXAMPLES:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: v == v True @@ -227,8 +230,8 @@ def _le_(self, other): EXAMPLES:: sage: v = valuations.TrivialValuation(QQ) - sage: w = QQ.valuation(2) - sage: v <= w + sage: w = QQ.valuation(2) # needs sage.rings.padics + sage: v <= w # needs sage.rings.padics True """ return other >= self @@ -244,8 +247,8 @@ def _ge_(self, other): EXAMPLES:: sage: v = valuations.TrivialValuation(QQ) - sage: w = QQ.valuation(2) - sage: v >= w + sage: w = QQ.valuation(2) # needs sage.rings.padics + sage: v >= w # needs sage.rings.padics False """ if self == other: @@ -269,7 +272,7 @@ def _test_valuation_inheritance(self, **options): EXAMPLES:: - sage: QQ.valuation(2)._test_valuation_inheritance() + sage: QQ.valuation(2)._test_valuation_inheritance() # needs sage.rings.padics """ tester = self._tester(**options) tester.assertNotEqual(isinstance(self, InfiniteDiscretePseudoValuation), @@ -283,18 +286,18 @@ class InfiniteDiscretePseudoValuation(DiscretePseudoValuation): EXAMPLES:: - sage: v = QQ.valuation(2) + sage: v = QQ.valuation(2) # needs sage.rings.padics sage: R. = QQ[] - sage: v = GaussValuation(R, v) - sage: w = v.augmentation(x, infinity); w # indirect doctest + sage: v = GaussValuation(R, v) # needs sage.rings.padics + sage: w = v.augmentation(x, infinity); w # indirect doctest # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x) = +Infinity ] TESTS:: sage: from sage.rings.valuation.valuation import InfiniteDiscretePseudoValuation - sage: isinstance(w, InfiniteDiscretePseudoValuation) + sage: isinstance(w, InfiniteDiscretePseudoValuation) # needs sage.rings.padics True - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.rings.padics """ def is_discrete_valuation(self): @@ -303,6 +306,7 @@ def is_discrete_valuation(self): EXAMPLES:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: R. = QQ[] sage: v = GaussValuation(R, v) @@ -341,7 +345,8 @@ def is_negative_pseudo_valuation(self): EXAMPLES:: sage: R. = QQ[] - sage: v = GaussValuation(R, valuations.TrivialValuation(QQ)).augmentation(x, infinity) + sage: u = GaussValuation(R, valuations.TrivialValuation(QQ)) + sage: v = u.augmentation(x, infinity) sage: v.is_negative_pseudo_valuation() False sage: K. = FunctionField(QQ) @@ -359,18 +364,18 @@ class DiscreteValuation(DiscretePseudoValuation): EXAMPLES:: - sage: v = QQ.valuation(2) + sage: v = QQ.valuation(2) # needs sage.rings.padics sage: R. = QQ[] - sage: v = GaussValuation(R, v) - sage: w = v.augmentation(x, 1337); w # indirect doctest + sage: v = GaussValuation(R, v) # needs sage.rings.padics + sage: w = v.augmentation(x, 1337); w # indirect doctest # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x) = 1337 ] TESTS:: sage: from sage.rings.valuation.valuation import DiscreteValuation - sage: isinstance(w, DiscreteValuation) + sage: isinstance(w, DiscreteValuation) # needs sage.rings.padics True - sage: TestSuite(w).run() # long time + sage: TestSuite(w).run() # long time # needs sage.rings.padics """ def is_discrete_valuation(self): @@ -431,12 +436,14 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru EXAMPLES:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(2) sage: R. = QQ[] sage: v.mac_lane_approximants(x^2 + 1) [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ]] sage: v.mac_lane_approximants(x^2 + 1, required_precision=infinity) - [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2, v(x^2 + 1) = +Infinity ]] + [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2, + v(x^2 + 1) = +Infinity ]] sage: v.mac_lane_approximants(x^2 + x + 1) [[ Gauss valuation induced by 2-adic valuation, v(x^2 + x + 1) = +Infinity ]] @@ -444,13 +451,13 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru factor `x + 1` and an approximate factor `x + 1` (which is an approximation to `x - 1`):: - sage: v.mac_lane_approximants(x^2 - 1) + sage: v.mac_lane_approximants(x^2 - 1) # needs sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = +Infinity ], [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ]] However, it needs to be squarefree:: - sage: v.mac_lane_approximants(x^2) + sage: v.mac_lane_approximants(x^2) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: G must be squarefree @@ -459,19 +466,20 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Some difficult cases provided by Mark van Hoeij:: + sage: # needs sage.rings.finite_rings sage: k = GF(2) sage: K. = FunctionField(k) sage: R. = K[] sage: F = y^21 + x*y^20 + (x^3 + x + 1)*y^18 + (x^3 + 1)*y^17 + (x^4 + x)*y^16 + (x^7 + x^6 + x^3 + x + 1)*y^15 + x^7*y^14 + (x^8 + x^7 + x^6 + x^4 + x^3 + 1)*y^13 + (x^9 + x^8 + x^4 + 1)*y^12 + (x^11 + x^9 + x^8 + x^5 + x^4 + x^3 + x^2)*y^11 + (x^12 + x^9 + x^8 + x^7 + x^5 + x^3 + x + 1)*y^10 + (x^14 + x^13 + x^10 + x^9 + x^8 + x^7 + x^6 + x^3 + x^2 + 1)*y^9 + (x^13 + x^9 + x^8 + x^6 + x^4 + x^3 + x)*y^8 + (x^16 + x^15 + x^13 + x^12 + x^11 + x^7 + x^3 + x)*y^7 + (x^17 + x^16 + x^13 + x^9 + x^8 + x)*y^6 + (x^17 + x^16 + x^12 + x^7 + x^5 + x^2 + x + 1)*y^5 + (x^19 + x^16 + x^15 + x^12 + x^6 + x^5 + x^3 + 1)*y^4 + (x^18 + x^15 + x^12 + x^10 + x^9 + x^7 + x^4 + x)*y^3 + (x^22 + x^21 + x^20 + x^18 + x^13 + x^12 + x^9 + x^8 + x^7 + x^5 + x^4 + x^3)*y^2 + (x^23 + x^22 + x^20 + x^17 + x^15 + x^14 + x^12 + x^9)*y + x^25 + x^23 + x^19 + x^17 + x^15 + x^13 + x^11 + x^5 sage: x = K._ring.gen() sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed [[ Gauss valuation induced by (x)-adic valuation, v(y + x + 1) = 3/2 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 1 ], [ Gauss valuation induced by (x)-adic valuation, v(y) = 4/3 ], [ Gauss valuation induced by (x)-adic valuation, v(y^15 + y^13 + y^12 + y^10 + y^9 + y^8 + y^4 + y^3 + y^2 + y + 1) = 1 ]] sage: v0 = K.valuation(GaussValuation(K._ring, valuations.TrivialValuation(k)).augmentation(x+1,1)) - sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed + sage: v0.mac_lane_approximants(F, assume_squarefree=True) # assumes squarefree for speed [[ Gauss valuation induced by (x + 1)-adic valuation, v(y + x^2 + 1) = 7/2 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 3/4 ], [ Gauss valuation induced by (x + 1)-adic valuation, v(y) = 7/2 ], @@ -487,6 +495,7 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Cases with trivial residue field extensions:: + sage: # needs sage.rings.padics sage: K. = FunctionField(QQ) sage: S. = K[] sage: F = y^2 - x^2 - x^3 - 3 @@ -499,46 +508,49 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Over a complete base field:: - sage: k=Qp(2,10) - sage: v = k.valuation() + sage: k = Qp(2,10) # needs sage.rings.padics + sage: v = k.valuation() # needs sage.rings.padics - sage: R.=k[] + sage: # needs sage.rings.padics + sage: R. = k[] sage: G = x sage: v.mac_lane_approximants(G) [Gauss valuation induced by 2-adic valuation] - sage: v.mac_lane_approximants(G, required_precision = infinity) + sage: v.mac_lane_approximants(G, required_precision=infinity) [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = +Infinity ]] - sage: G = x^2 + 1 - sage: v.mac_lane_approximants(G) + sage: G = x^2 + 1 # needs sage.rings.padics + sage: v.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x + 1 + O(2^10)) = 1/2 ]] - sage: v.mac_lane_approximants(G, required_precision = infinity) - [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x + 1 + O(2^10)) = 1/2, v((1 + O(2^10))*x^2 + 1 + O(2^10)) = +Infinity ]] + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics + [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x + 1 + O(2^10)) = 1/2, + v((1 + O(2^10))*x^2 + 1 + O(2^10)) = +Infinity ]] - sage: G = x^4 + 2*x^3 + 2*x^2 - 2*x + 2 - sage: v.mac_lane_approximants(G) + sage: G = x^4 + 2*x^3 + 2*x^2 - 2*x + 2 # needs sage.rings.padics + sage: v.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = 1/4 ]] - sage: v.mac_lane_approximants(G, required_precision=infinity) - [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = 1/4, v((1 + O(2^10))*x^4 + (2 + O(2^11))*x^3 + (2 + O(2^11))*x^2 + (2 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + 2^10 + O(2^11))*x + 2 + O(2^11)) = +Infinity ]] + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics + [[ Gauss valuation induced by 2-adic valuation, v((1 + O(2^10))*x) = 1/4, + v((1 + O(2^10))*x^4 + (2 + O(2^11))*x^3 + (2 + O(2^11))*x^2 + (2 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + 2^10 + O(2^11))*x + 2 + O(2^11)) = +Infinity ]] The factorization of primes in the Gaussian integers can be read off the Mac Lane approximants:: - sage: v0 = QQ.valuation(2) + sage: v0 = QQ.valuation(2) # needs sage.rings.padics sage: R. = QQ[] sage: G = x^2 + 1 - sage: v0.mac_lane_approximants(G) + sage: v0.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ]] - sage: v0 = QQ.valuation(3) - sage: v0.mac_lane_approximants(G) + sage: v0 = QQ.valuation(3) # needs sage.rings.padics + sage: v0.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 3-adic valuation, v(x^2 + 1) = +Infinity ]] - sage: v0 = QQ.valuation(5) - sage: v0.mac_lane_approximants(G) + sage: v0 = QQ.valuation(5) # needs sage.rings.padics + sage: v0.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v(x + 2) = 1 ], [ Gauss valuation induced by 5-adic valuation, v(x + 3) = 1 ]] - sage: v0.mac_lane_approximants(G, required_precision = 10) + sage: v0.mac_lane_approximants(G, required_precision=10) # needs sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v(x + 3116/237) = 10 ], [ Gauss valuation induced by 5-adic valuation, v(x - 3116/237) = 10 ]] @@ -546,9 +558,10 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru `\QQ[x]/(x^2+1)`, 5 factors `-(x - 2)(x + 2)`, this behaviour can be read off the Mac Lane approximants:: - sage: k=Qp(5,4) + sage: # needs sage.rings.padics + sage: k = Qp(5,4) sage: v = k.valuation() - sage: R.=k[] + sage: R. = k[] sage: G = x^2 + 1 sage: v1,v2 = v.mac_lane_approximants(G); v1,v2 ([ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + O(5^4)) = 1 ], @@ -559,22 +572,23 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Note how the latter give a better approximation to the factors of `x^2 + 1`:: - sage: v1.phi() * v2.phi() - G + sage: v1.phi() * v2.phi() - G # needs sage.rings.padics O(5^4)*x^2 + (5 + O(5^4))*x + 5 + O(5^4) - sage: w1.phi() * w2.phi() - G + sage: w1.phi() * w2.phi() - G # needs sage.rings.padics O(5^4)*x^2 + (5^2 + O(5^4))*x + 5^3 + O(5^4) In this example, the process stops with a factorization of `x^2 + 1`:: - sage: v.mac_lane_approximants(G, required_precision=infinity) + sage: v.mac_lane_approximants(G, required_precision=infinity) # needs sage.rings.padics [[ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) = +Infinity ], [ Gauss valuation induced by 5-adic valuation, v((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) = +Infinity ]] This obviously cannot happen over the rationals where we only get an approximate factorization:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(5) - sage: R.=QQ[] + sage: R. = QQ[] sage: G = x^2 + 1 sage: v.mac_lane_approximants(G) [[ Gauss valuation induced by 5-adic valuation, v(x + 2) = 1 ], @@ -586,9 +600,10 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru Initial versions ran into problems with the trivial residue field extensions in this case:: - sage: K = Qp(3, 20, print_mode='digits') - sage: R. = K[] + sage: K = Qp(3, 20, print_mode='digits') # needs sage.rings.padics + sage: R. = K[] # needs sage.rings.padics + sage: # needs sage.rings.padics sage: alpha = T^3/4 sage: G = 3^3*T^3*(alpha^4 - alpha)^2 - (4*alpha^3 - 1)^3 sage: G = G/G.leading_coefficient() @@ -598,13 +613,14 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru A similar example:: sage: R. = QQ[] - sage: v = QQ.valuation(3) - sage: G = (x^3 + 3)^3 - 81 - sage: v.mac_lane_approximants(G) + sage: v = QQ.valuation(3) # needs sage.rings.padics + sage: G = (x^3 + 3)^3 - 81 # needs sage.rings.padics + sage: v.mac_lane_approximants(G) # needs sage.rings.padics [[ Gauss valuation induced by 3-adic valuation, v(x) = 1/3, v(x^3 + 3*x + 3) = 13/9 ]] Another problematic case:: + sage: # needs sage.rings.number_field sage.rings.padics sage: R. = QQ[] sage: Delta = x^12 + 20*x^11 + 154*x^10 + 664*x^9 + 1873*x^8 + 3808*x^7 + 5980*x^6 + 7560*x^5 + 7799*x^4 + 6508*x^3 + 4290*x^2 + 2224*x + 887 sage: K. = NumberField(x^6 + 108) @@ -615,7 +631,7 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru 1 sage: vK(theta) 1/3 - sage: G=Delta.change_ring(K) + sage: G = Delta.change_ring(K) sage: vK.mac_lane_approximants(G) [[ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + 3*theta + 1) = 3/2 ], [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/4, v(x^4 + 1/2*theta^4 + theta + 1) = 3/2 ], @@ -624,8 +640,8 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru An easy case that produced the wrong error at some point:: sage: R. = QQ[] - sage: v = QQ.valuation(2) - sage: v.mac_lane_approximants(x^2 - 1/2) + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: v.mac_lane_approximants(x^2 - 1/2) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: G must be integral @@ -634,24 +650,29 @@ def mac_lane_approximants(self, G, assume_squarefree=False, require_final_EF=Tru :: + sage: # needs sage.rings.padics sage: R = ZpFM(3, 7, print_mode='terse') sage: S. = R[] sage: v = R.valuation() sage: f = x^4 + 234 - sage: len(v.mac_lane_approximants(f, assume_squarefree=True)) # is_squarefree() is not properly implemented yet + sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet + ....: assume_squarefree=True)) 2 :: + sage: # needs sage.rings.padics sage: R = ZpFM(2, 50, print_mode='terse') sage: S. = R[] sage: f = (x^32 + 16)*(x^32 + 16 + 2^16*x^2) + 2^34 sage: v = R.valuation() - sage: len(v.mac_lane_approximants(f, assume_squarefree=True)) # is_squarefree() is not properly implemented yet + sage: len(v.mac_lane_approximants(f, # is_squarefree() is not properly implemented yet + ....: assume_squarefree=True)) 2 A case that triggered an assertion at some point:: + sage: # needs sage.rings.padics sage: v = QQ.valuation(3) sage: R. = QQ[] sage: f = x^36 + 60552000*x^33 + 268157412*x^30 + 173881701*x^27 + 266324841*x^24 + 83125683*x^21 + 111803814*x^18 + 31925826*x^15 + 205726716*x^12 +17990262*x^9 + 351459648*x^6 + 127014399*x^3 + 359254116 @@ -784,10 +805,10 @@ def _pow(self, x, e, error): EXAMPLES:: - sage: v = QQ.valuation(2) - sage: v._pow(2, 2, error=4) + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: v._pow(2, 2, error=4) # needs sage.rings.padics 4 - sage: v._pow(2, 1000, error=4) + sage: v._pow(2, 1000, error=4) # needs sage.rings.padics 0 """ @@ -817,58 +838,66 @@ def mac_lane_approximant(self, G, valuation, approximants=None): EXAMPLES:: - sage: v = QQ.valuation(2) - sage: R. = QQ[] - sage: G = x^2 + 1 + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: R. = QQ[] # needs sage.rings.padics + sage: G = x^2 + 1 # needs sage.rings.padics We can select an approximant by approximating it:: - sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] As long as this is the only matching approximant, the approximation can be very coarse:: - sage: w = GaussValuation(R, v) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] Or it can be very specific:: - sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2).augmentation(G, infinity) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x + 1, 1/2).augmentation(G, infinity) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1/2 ] But it must be an approximation of an approximant:: - sage: w = GaussValuation(R, v).augmentation(x, 1/2) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x, 1/2) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics Traceback (most recent call last): ... - ValueError: The valuation [ Gauss valuation induced by 2-adic valuation, v(x) = 1/2 ] is not an approximant for a valuation which extends 2-adic valuation with respect to x^2 + 1 since the valuation of x^2 + 1 does not increase in every step + ValueError: The valuation + [ Gauss valuation induced by 2-adic valuation, v(x) = 1/2 ] is + not an approximant for a valuation which extends 2-adic valuation + with respect to x^2 + 1 since the valuation of x^2 + 1 + does not increase in every step The ``valuation`` must single out one approximant:: - sage: G = x^2 - 1 - sage: w = GaussValuation(R, v) - sage: v.mac_lane_approximant(G, w) + sage: G = x^2 - 1 # needs sage.rings.padics + sage: w = GaussValuation(R, v) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics Traceback (most recent call last): ... - ValueError: The valuation Gauss valuation induced by 2-adic valuation does not approximate a unique extension of 2-adic valuation with respect to x^2 - 1 + ValueError: The valuation Gauss valuation induced by 2-adic valuation + does not approximate a unique extension of 2-adic valuation + with respect to x^2 - 1 - sage: w = GaussValuation(R, v).augmentation(x + 1, 1) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x + 1, 1) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics Traceback (most recent call last): ... - ValueError: The valuation [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ] does not approximate a unique extension of 2-adic valuation with respect to x^2 - 1 + ValueError: The valuation + [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ] does not + approximate a unique extension of 2-adic valuation with respect to x^2 - 1 - sage: w = GaussValuation(R, v).augmentation(x + 1, 2) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x + 1, 2) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = +Infinity ] - sage: w = GaussValuation(R, v).augmentation(x + 3, 2) - sage: v.mac_lane_approximant(G, w) + sage: w = GaussValuation(R, v).augmentation(x + 3, 2) # needs sage.rings.padics + sage: v.mac_lane_approximant(G, w) # needs sage.rings.padics [ Gauss valuation induced by 2-adic valuation, v(x + 1) = 1 ] """ @@ -928,24 +957,26 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No EXAMPLES:: - sage: k=Qp(5,4) + sage: # needs sage.rings.padics + sage: k = Qp(5,4) sage: v = k.valuation() - sage: R.=k[] + sage: R. = k[] sage: G = x^2 + 1 sage: v.montes_factorization(G) - ((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) * ((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) + ((1 + O(5^4))*x + 2 + 5 + 2*5^2 + 5^3 + O(5^4)) + * ((1 + O(5^4))*x + 3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4)) The computation might not terminate over incomplete fields (in particular because the factors can not be represented there):: sage: R. = QQ[] - sage: v = QQ.valuation(2) - sage: v.montes_factorization(x^6 - 1) + sage: v = QQ.valuation(2) # needs sage.rings.padics + sage: v.montes_factorization(x^6 - 1) # needs sage.rings.padics (x - 1) * (x + 1) * (x^2 - x + 1) * (x^2 + x + 1) - sage: v.montes_factorization(x^7 - 1) # not tested, does not terminate + sage: v.montes_factorization(x^7 - 1) # not tested # needs sage.rings.padics - sage: v.montes_factorization(x^7 - 1, required_precision=5) + sage: v.montes_factorization(x^7 - 1, required_precision=5) # needs sage.rings.padics (x - 1) * (x^3 - 5*x^2 - 6*x - 1) * (x^3 + 6*x^2 + 5*x - 1) TESTS: @@ -955,6 +986,7 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No In this example, ``f`` factors as three factors of degree 50 over an unramified extension:: + sage: # needs sage.rings.padics sage: R. = ZqFM(125) sage: S. = R[] sage: f = (x^6+2)^25 + 5 @@ -964,6 +996,7 @@ def montes_factorization(self, G, assume_squarefree=False, required_precision=No In this case, ``f`` factors into degrees 1, 2, and 5 over a totally ramified extension:: + sage: # needs sage.rings.padics sage: R = Zp(5) sage: S. = R[] sage: R. = R.extension(w^3 + 5) @@ -1033,8 +1066,8 @@ class MacLaneApproximantNode(): TESTS:: - sage: v = ZZ.valuation(3) - sage: v.extension(GaussianIntegers()) # indirect doctest + sage: v = ZZ.valuation(3) # needs sage.rings.padics + sage: v.extension(GaussianIntegers()) # indirect doctest # needs sage.rings.padics 3-adic valuation """ @@ -1043,8 +1076,8 @@ def __init__(self, valuation, parent, ef, principal_part_bound, coefficients, va TESTS:: sage: from sage.rings.valuation.valuation import MacLaneApproximantNode - sage: node = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) - sage: TestSuite(node).run() + sage: node = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) # needs sage.rings.padics + sage: TestSuite(node).run() # needs sage.rings.padics """ self.valuation = valuation @@ -1061,6 +1094,7 @@ def __eq__(self, other): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.rings.valuation.valuation import MacLaneApproximantNode sage: n = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) sage: m = MacLaneApproximantNode(QQ.valuation(3), None, 1, None, None, None) @@ -1080,6 +1114,7 @@ def __ne__(self, other): EXAMPLES:: + sage: # needs sage.rings.padics sage: from sage.rings.valuation.valuation import MacLaneApproximantNode sage: n = MacLaneApproximantNode(QQ.valuation(2), None, 1, None, None, None) sage: m = MacLaneApproximantNode(QQ.valuation(3), None, 1, None, None, None) diff --git a/src/sage/rings/valuation/valuations_catalog.py b/src/sage/rings/valuation/valuations_catalog.py index 69e064a10c1..64effaf13a6 100644 --- a/src/sage/rings/valuation/valuations_catalog.py +++ b/src/sage/rings/valuation/valuations_catalog.py @@ -1,5 +1,9 @@ -from sage.rings.padics.padic_valuation import pAdicValuation -from sage.rings.function_field.valuation import FunctionFieldValuation -from .gauss_valuation import GaussValuation -from .trivial_valuation import TrivialDiscretePseudoValuation, TrivialPseudoValuation, TrivialValuation -from .limit_valuation import LimitValuation +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.rings.padics.padic_valuation', 'pAdicValuation') +lazy_import('sage.rings.function_field.valuation', 'FunctionFieldValuation') +lazy_import('sage.rings.valuation.gauss_valuation', 'GaussValuation') +lazy_import('sage.rings.valuation.trivial_valuation', ['TrivialDiscretePseudoValuation', 'TrivialPseudoValuation', 'TrivialValuation']) +lazy_import('sage.rings.valuation.limit_valuation', 'LimitValuation') + +del lazy_import