\(p\)-adic Extension Generic - $p$-adics

Skip to content
Back to top
View this page
Edit this page

# \(p\)-adic Extension Generic

A common superclass for all extensions of Qp and Zp.

AUTHORS:

- David Roe

class sage.rings.padics.padic_extension_generic.DefPolyConversion

  Bases: `Morphism`

  Conversion map between \(p\)-adic rings/fields with the same defining polynomial.

  INPUT:

  - `R` – a \(p\)-adic extension ring or field

  - `S` – a \(p\)-adic extension ring or field with the same defining polynomial

  EXAMPLES:

  Sage

      sage: R.<a> = Zq(125, print_mode='terse')
      sage: S = R.change(prec = 15, type='floating-point')
      sage: a - 1
      95367431640624 + a + O(5^20)
      sage: S(a - 1)
      30517578124 + a + O(5^15)

  Python

      >>> from sage.all import *
      >>> R = Zq(Integer(125), print_mode='terse', names=('a',)); (a,) = R._first_ngens(1)
      >>> S = R.change(prec = Integer(15), type='floating-point')
      >>> a - Integer(1)
      95367431640624 + a + O(5^20)
      >>> S(a - Integer(1))
      30517578124 + a + O(5^15)

  Sage

      sage: R.<a> = Zq(125, print_mode='terse')
      sage: S = R.change(prec = 15, type='floating-point')
      sage: f = S.convert_map_from(R)
      sage: TestSuite(f).run()

  [Python]

      >>> from sage.all import *
      >>> R = Zq(Integer(125), print_mode='terse', names=('a',)); (a,) = R._first_ngens(1)
      >>> S = R.change(prec = Integer(15), type='floating-point')
      >>> f = S.convert_map_from(R)
      >>> TestSuite(f).run()

class sage.rings.padics.padic_extension_generic.MapFreeModuleToOneStep

  Bases: `pAdicModuleIsomorphism`

  The isomorphism from the underlying module of a one-step \(p\)-adic extension to the extension.

  EXAMPLES:

  Sage

      sage: K.<a> = Qq(125)
      sage: V, fr, to = K.free_module()
      sage: TestSuite(fr).run(skip=['_test_nonzero_equal'])  # skipped since Qq(125) doesn't have dimension()

  Python

      >>> from sage.all import *
      >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
      >>> V, fr, to = K.free_module()
      >>> TestSuite(fr).run(skip=['_test_nonzero_equal'])  # skipped since Qq(125) doesn't have dimension()

class sage.rings.padics.padic_extension_generic.MapFreeModuleToTwoStep

  Bases: `pAdicModuleIsomorphism`

  The isomorphism from the underlying module of a two-step \(p\)-adic extension to the extension.

  EXAMPLES:

  Sage

      sage: K.<a> = Qq(125)
      sage: R.<x> = ZZ[]
      sage: L.<b> = K.extension(x^2 - 5*x + 5)
      sage: V, fr, to = L.free_module(base=Qp(5))
      sage: TestSuite(fr).run(skip=['_test_nonzero_equal'])  # skipped since L doesn't have dimension()

  Python

      >>> from sage.all import *
      >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
      >>> R = ZZ['x']; (x,) = R._first_ngens(1)
      >>> L = K.extension(x**Integer(2) - Integer(5)*x + Integer(5), names=('b',)); (b,) = L._first_ngens(1)
      >>> V, fr, to = L.free_module(base=Qp(Integer(5)))
      >>> TestSuite(fr).run(skip=['_test_nonzero_equal'])  # skipped since L doesn't have dimension()

class sage.rings.padics.padic_extension_generic.MapOneStepToFreeModule

  Bases: `pAdicModuleIsomorphism`

  The isomorphism from a one-step \(p\)-adic extension to its underlying free module.

  EXAMPLES:

  Sage

      sage: K.<a> = Qq(125)
      sage: V, fr, to = K.free_module()
      sage: TestSuite(to).run()

  Python

      >>> from sage.all import *
      >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
      >>> V, fr, to = K.free_module()
      >>> TestSuite(to).run()

class sage.rings.padics.padic_extension_generic.MapTwoStepToFreeModule

  Bases: `pAdicModuleIsomorphism`

  The isomorphism from a two-step \(p\)-adic extension to its underlying free module.

  EXAMPLES:

  Sage

      sage: K.<a> = Qq(125)
      sage: R.<x> = ZZ[]
      sage: L.<b> = K.extension(x^2 - 5*x + 5)
      sage: V, fr, to = L.free_module(base=Qp(5))
      sage: TestSuite(to).run()

  Python

      >>> from sage.all import *
      >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
      >>> R = ZZ['x']; (x,) = R._first_ngens(1)
      >>> L = K.extension(x**Integer(2) - Integer(5)*x + Integer(5), names=('b',)); (b,) = L._first_ngens(1)
      >>> V, fr, to = L.free_module(base=Qp(Integer(5)))
      >>> TestSuite(to).run()

class sage.rings.padics.padic_extension_generic.pAdicExtensionGeneric(poly, prec, print_mode, names, element_class)

  Bases: `pAdicGeneric`

  Initialization.

  EXAMPLES:

  Sage

      sage: R = Zp(5,5)
      sage: S.<x> = R[]
      sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5
      sage: W.<w> = R.ext(f)  # indirect doctest

  Python

      >>> from sage.all import *
      >>> R = Zp(Integer(5),Integer(5))
      >>> S = R['x']; (x,) = S._first_ngens(1)
      >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) +Integer(125)*x - Integer(5)
      >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)# indirect doctest

  construction(forbid_frac_field=False)

    Return the functorial construction of this ring, namely, the algebraic extension of the base ring defined by the given polynomial.

    Also preserves other information that makes this ring unique (e.g. precision, rounding, print mode).

    INPUT:

    - `forbid_frac_field` – require a completion functor rather than a fraction field functor. This is used in the `sage.rings.padics.local_generic.LocalGeneric.change()` method.

    EXAMPLES:

    Sage

        sage: R.<a> = Zq(25, 8, print_mode='val-unit')
        sage: c, R0 = R.construction(); R0
        5-adic Ring with capped relative precision 8
        sage: c(R0)
        5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2
        sage: c(R0) == R
        True

    Python

        >>> from sage.all import *
        >>> R = Zq(Integer(25), Integer(8), print_mode='val-unit', names=('a',)); (a,) = R._first_ngens(1)
        >>> c, R0 = R.construction(); R0
        5-adic Ring with capped relative precision 8
        >>> c(R0)
        5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2
        >>> c(R0) == R
        True

    For a field, by default we return a fraction field functor.

    Sage

        sage: K.<a> = Qq(25, 8)
        sage: c, R = K.construction(); R
        5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2
        sage: c
        FractionField

    [Python]

        >>> from sage.all import *
        >>> K = Qq(Integer(25), Integer(8), names=('a',)); (a,) = K._first_ngens(1)
        >>> c, R = K.construction(); R
        5-adic Unramified Extension Ring in a defined by x^2 + 4*x + 2
        >>> c
        FractionField

    If you prefer an extension functor, you can use the `forbit_frac_field` keyword:

    Sage

        sage: c, R = K.construction(forbid_frac_field=True); R
        5-adic Field with capped relative precision 8
        sage: c
        AlgebraicExtensionFunctor
        sage: c(R) is K
        True

    Python

        >>> from sage.all import *
        >>> c, R = K.construction(forbid_frac_field=True); R
        5-adic Field with capped relative precision 8
        >>> c
        AlgebraicExtensionFunctor
        >>> c(R) is K
        True

  defining_polynomial(var=None, exact=False)

    Return the polynomial defining this extension.

    INPUT:

    - `var` – string (default: `'x'`); the name of the variable

    - `exact` – boolean (default: `False`); whether to return the underlying exact

        defining polynomial rather than the one with coefficients in the base ring

    EXAMPLES:

    Sage

        sage: R = Zp(5,5)
        sage: S.<x> = R[]
        sage: f = x^5 + 75*x^3 - 15*x^2 + 125*x - 5
        sage: W.<w> = R.ext(f)
        sage: W.defining_polynomial()
        (1 + O(5^5))*x^5 + O(5^6)*x^4 + (3*5^2 + O(5^6))*x^3 + (2*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6))*x^2 + (5^3 + O(5^6))*x + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6)
        sage: W.defining_polynomial(exact=True)
        x^5 + 75*x^3 - 15*x^2 + 125*x - 5

        sage: W.defining_polynomial(var='y', exact=True)
        y^5 + 75*y^3 - 15*y^2 + 125*y - 5

    Python

        >>> from sage.all import *
        >>> R = Zp(Integer(5),Integer(5))
        >>> S = R['x']; (x,) = S._first_ngens(1)
        >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) + Integer(125)*x - Integer(5)
        >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.defining_polynomial()
        (1 + O(5^5))*x^5 + O(5^6)*x^4 + (3*5^2 + O(5^6))*x^3 + (2*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6))*x^2 + (5^3 + O(5^6))*x + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6)
        >>> W.defining_polynomial(exact=True)
        x^5 + 75*x^3 - 15*x^2 + 125*x - 5

        >>> W.defining_polynomial(var='y', exact=True)
        y^5 + 75*y^3 - 15*y^2 + 125*y - 5

    See also

    `modulus()` `exact_field()`

  exact_field()

    Return a number field with the same defining polynomial.

    Note that this method always returns a field, even for a \(p\)-adic ring.

    EXAMPLES:

    Sage

        sage: R = Zp(5,5)
        sage: S.<x> = R[]
        sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5
        sage: W.<w> = R.ext(f)
        sage: W.exact_field()
        Number Field in w with defining polynomial x^5 + 75*x^3 - 15*x^2 + 125*x - 5

    Python

        >>> from sage.all import *
        >>> R = Zp(Integer(5),Integer(5))
        >>> S = R['x']; (x,) = S._first_ngens(1)
        >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) +Integer(125)*x - Integer(5)
        >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.exact_field()
        Number Field in w with defining polynomial x^5 + 75*x^3 - 15*x^2 + 125*x - 5

    See also

    `defining_polynomial()` `modulus()`

  exact_ring()

    Return the order with the same defining polynomial.

    Will raise a `ValueError` if the coefficients of the defining polynomial are not integral.

    EXAMPLES:

    Sage

        sage: R = Zp(5,5)
        sage: S.<x> = R[]
        sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5
        sage: W.<w> = R.ext(f)
        sage: W.exact_ring()
        Order generated by w in Number Field in w with defining polynomial x^5 + 75*x^3 - 15*x^2 + 125*x - 5

        sage: T = Zp(5,5)
        sage: U.<z> = T[]
        sage: g = 2*z^4 + 1
        sage: V.<v> = T.ext(g)
        sage: V.exact_ring()
        Traceback (most recent call last):
        ...
        ValueError: each generator must be integral

    Python

        >>> from sage.all import *
        >>> R = Zp(Integer(5),Integer(5))
        >>> S = R['x']; (x,) = S._first_ngens(1)
        >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) +Integer(125)*x - Integer(5)
        >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.exact_ring()
        Order generated by w in Number Field in w with defining polynomial x^5 + 75*x^3 - 15*x^2 + 125*x - 5

        >>> T = Zp(Integer(5),Integer(5))
        >>> U = T['z']; (z,) = U._first_ngens(1)
        >>> g = Integer(2)*z**Integer(4) + Integer(1)
        >>> V = T.ext(g, names=('v',)); (v,) = V._first_ngens(1)
        >>> V.exact_ring()
        Traceback (most recent call last):
        ...
        ValueError: each generator must be integral

  free_module(base=None, basis=None, map=True)

    Return a free module \(V\) over a specified base ring together with maps to and from \(V\).

    INPUT:

    - `base` – a subring \(R\) so that this ring/field is isomorphic to a finite-rank free \(R\)-module \(V\)

    - `basis` – a basis for this ring/field over the base

    - `map` – boolean (default: `True`); whether to return \(R\)-linear maps to and from \(V\)

    OUTPUT:

    - A finite-rank free \(R\)-module \(V\)

    - An \(R\)-module isomorphism from \(V\) to this ring/field (only included if `map` is `True`)

    - An \(R\)-module isomorphism from this ring/field to \(V\) (only included if `map` is `True`)

    EXAMPLES:

    Sage

        sage: R.<x> = ZZ[]
        sage: K.<a> = Qq(125)
        sage: L.<pi> = K.extension(x^2-5)
        sage: V, from_V, to_V = K.free_module()
        sage: W, from_W, to_W = L.free_module()
        sage: W0, from_W0, to_W0 = L.free_module(base=Qp(5))
        sage: to_V(a + O(5^7))
        (O(5^7), 1 + O(5^7), O(5^7))
        sage: to_W(a)
        (a + O(5^20), O(5^20))
        sage: to_W0(a + O(5^7))
        (O(5^7), 1 + O(5^7), O(5^7), O(5^7), O(5^7), O(5^7))
        sage: to_W(pi)
        (O(5^21), 1 + O(5^20))
        sage: to_W0(pi + O(pi^11))
        (O(5^6), O(5^6), O(5^6), 1 + O(5^5), O(5^5), O(5^5))

        sage: X, from_X, to_X = K.free_module(K)
        sage: to_X(a)
        (a + O(5^20))

    Python

        >>> from sage.all import *
        >>> R = ZZ['x']; (x,) = R._first_ngens(1)
        >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
        >>> L = K.extension(x**Integer(2)-Integer(5), names=('pi',)); (pi,) = L._first_ngens(1)
        >>> V, from_V, to_V = K.free_module()
        >>> W, from_W, to_W = L.free_module()
        >>> W0, from_W0, to_W0 = L.free_module(base=Qp(Integer(5)))
        >>> to_V(a + O(Integer(5)**Integer(7)))
        (O(5^7), 1 + O(5^7), O(5^7))
        >>> to_W(a)
        (a + O(5^20), O(5^20))
        >>> to_W0(a + O(Integer(5)**Integer(7)))
        (O(5^7), 1 + O(5^7), O(5^7), O(5^7), O(5^7), O(5^7))
        >>> to_W(pi)
        (O(5^21), 1 + O(5^20))
        >>> to_W0(pi + O(pi**Integer(11)))
        (O(5^6), O(5^6), O(5^6), 1 + O(5^5), O(5^5), O(5^5))

        >>> X, from_X, to_X = K.free_module(K)
        >>> to_X(a)
        (a + O(5^20))

  ground_ring()

    Return the ring of which this ring is an extension.

    EXAMPLES:

    Sage

        sage: R = Zp(5,5)
        sage: S.<x> = R[]
        sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5
        sage: W.<w> = R.ext(f)
        sage: W.ground_ring()
        5-adic Ring with capped relative precision 5

    Python

        >>> from sage.all import *
        >>> R = Zp(Integer(5),Integer(5))
        >>> S = R['x']; (x,) = S._first_ngens(1)
        >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) +Integer(125)*x - Integer(5)
        >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.ground_ring()
        5-adic Ring with capped relative precision 5

  ground_ring_of_tower()

    Return the \(p\)-adic base ring of which this is ultimately an extension.

    Currently this function is identical to `ground_ring()`, since relative extensions have not yet been implemented.

    EXAMPLES:

    Sage

        sage: Qq(27,30,names='a').ground_ring_of_tower()
        3-adic Field with capped relative precision 30

    Python

        >>> from sage.all import *
        >>> Qq(Integer(27),Integer(30),names='a').ground_ring_of_tower()
        3-adic Field with capped relative precision 30

  modulus(exact=False)

    Return the polynomial defining this extension.

    INPUT:

    - `exact` – boolean (default: `False`); whether to return the underlying exact defining polynomial rather than the one with coefficients in the base ring

    EXAMPLES:

    Sage

        sage: R = Zp(5,5)
        sage: S.<x> = R[]
        sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5
        sage: W.<w> = R.ext(f)
        sage: W.modulus()
        (1 + O(5^5))*x^5 + O(5^6)*x^4 + (3*5^2 + O(5^6))*x^3 + (2*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6))*x^2 + (5^3 + O(5^6))*x + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6)
        sage: W.modulus(exact=True)
        x^5 + 75*x^3 - 15*x^2 + 125*x - 5

    Python

        >>> from sage.all import *
        >>> R = Zp(Integer(5),Integer(5))
        >>> S = R['x']; (x,) = S._first_ngens(1)
        >>> f = x**Integer(5) + Integer(75)*x**Integer(3) - Integer(15)*x**Integer(2) +Integer(125)*x - Integer(5)
        >>> W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.modulus()
        (1 + O(5^5))*x^5 + O(5^6)*x^4 + (3*5^2 + O(5^6))*x^3 + (2*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6))*x^2 + (5^3 + O(5^6))*x + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + O(5^6)
        >>> W.modulus(exact=True)
        x^5 + 75*x^3 - 15*x^2 + 125*x - 5

    See also

    `defining_polynomial()` `exact_field()`

  polynomial_ring()

    Return the polynomial ring of which this is a quotient.

    EXAMPLES:

    Sage

        sage: Qq(27,30,names='a').polynomial_ring()
        Univariate Polynomial Ring in x over 3-adic Field with capped relative precision 30

    Python

        >>> from sage.all import *
        >>> Qq(Integer(27),Integer(30),names='a').polynomial_ring()
        Univariate Polynomial Ring in x over 3-adic Field with capped relative precision 30

  random_element()

    Return a random element of `self`.

    This is done by picking a random element of the ground ring self.degree() times, then treating those elements as coefficients of a polynomial in self.gen().

    EXAMPLES:

    Sage

        sage: R.<a> = Zq(125, 5)
        sage: R.random_element().parent() is R
        True
        sage: R = Zp(5,3); S.<x> = ZZ[]; f = x^5 + 25*x^2 - 5; W.<w> = R.ext(f)
        sage: W.random_element().parent() is W
        True

    Python

        >>> from sage.all import *
        >>> R = Zq(Integer(125), Integer(5), names=('a',)); (a,) = R._first_ngens(1)
        >>> R.random_element().parent() is R
        True
        >>> R = Zp(Integer(5),Integer(3)); S = ZZ['x']; (x,) = S._first_ngens(1); f = x**Integer(5) + Integer(25)*x**Integer(2) - Integer(5); W = R.ext(f, names=('w',)); (w,) = W._first_ngens(1)
        >>> W.random_element().parent() is W
        True

class sage.rings.padics.padic_extension_generic.pAdicModuleIsomorphism

  Bases: `Map`

  A base class for various isomorphisms between \(p\)-adic rings/fields and free modules.

  EXAMPLES:

  Sage

      sage: K.<a> = Qq(125)
      sage: V, fr, to = K.free_module()
      sage: from sage.rings.padics.padic_extension_generic import pAdicModuleIsomorphism
      sage: isinstance(fr, pAdicModuleIsomorphism)
      True

  Python

      >>> from sage.all import *
      >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
      >>> V, fr, to = K.free_module()
      >>> from sage.rings.padics.padic_extension_generic import pAdicModuleIsomorphism
      >>> isinstance(fr, pAdicModuleIsomorphism)
      True

  is_injective()

    EXAMPLES:

    Sage

        sage: K.<a> = Qq(125)
        sage: V, fr, to = K.free_module()
        sage: fr.is_injective()
        True

    Python

        >>> from sage.all import *
        >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
        >>> V, fr, to = K.free_module()
        >>> fr.is_injective()
        True

  is_surjective()

    EXAMPLES:

    Sage

        sage: K.<a> = Qq(125)
        sage: V, fr, to = K.free_module()
        sage: fr.is_surjective()
        True

    Python

        >>> from sage.all import *
        >>> K = Qq(Integer(125), names=('a',)); (a,) = K._first_ngens(1)
        >>> V, fr, to = K.free_module()
        >>> fr.is_surjective()
        True