Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Implement _im_gens_ and _is_valid_homomorphism_
Browse files Browse the repository at this point in the history
  • Loading branch information
roed314 committed Sep 13, 2019
1 parent 1738aa9 commit 45da59b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/sage/rings/padics/padic_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,50 @@ def extension(self, modulus, prec = None, names = None, print_mode = None, imple
print_mode[option] = self._printer.dict()[option]
return ExtensionFactory(base=self, modulus=modulus, prec=prec, names=names, check = True, implementation=implementation, **print_mode)

def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None):
"""
Check whether the given images and map on the base ring determine a
valid homomorphism to the codomain.
EXAMPLES::
sage: R.<x> = ZZ[]
sage: K.<a> = Qq(25, modulus=x^2-2)
sage: L.<b> = Qq(625, modulus=x^4-2)
sage: K._is_valid_homomorphism_(L, [b^2])
True
sage: L._is_valid_homomorphism_(L, [b^3])
False
sage: z = L(-1).sqrt()
sage: L._is_valid_homomorphism_(L, [z*b])
True
sage: L._is_valid_homomorphism_(L, [-b])
True
sage: W.<w> = K.extension(x^2 - 5)
sage: cc = K.hom([-a])
sage: W._is_valid_homomorphism_(W, [w], base_map=cc)
True
sage: W._is_valid_homomorphism_(W, [-w], base_map=cc)
True
sage: W._is_valid_homomorphism_(W, [w+1])
False
"""
K = self.base_ring()
if base_map is None and not codomain.has_coerce_map_from(K):
return False
if len(im_gens) != 1:
raise ValueError("Wrong number of generators")
if self is K:
# Qp or Zp, so either base_map is not None or there's a coercion to the codomain
# We check that the im_gens has the right length and value
return im_gens[0] == codomain(self.prime())
# Now we're an extension. We check that the defining polynomial maps to zero
f = self.modulus()
if base_map is not None:
f = f.change_ring(base_map)
return f(im_gens[0]) == 0

def _test_add(self, **options):
"""
Test addition of elements of this ring.
Expand Down
44 changes: 44 additions & 0 deletions src/sage/rings/padics/padic_generic_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,50 @@ cdef class pAdicGenericElement(LocalGenericElement):
L += [Kbase(0)] * (K.relative_degree() - len(L))
return K(L)
def _im_gens_(self, codomain, im_gens, base_map=None):
"""
Return the image of this element under the morphism defined by
``im_gens`` in ``codomain``, where elements of the
base ring are mapped by ``base_map``.
EXAMPLES::
sage: R.<x> = ZZ[]
sage: K.<a> = Qq(25, modulus=x^2-2)
sage: L.<b> = Qq(625, modulus=x^4-2)
sage: phi = K.hom([b^2]); phi(a+1)
(b^2 + 1) + O(5^20)
sage: z = L(-1).sqrt()
sage: psi = L.hom([z*b]); psi(phi(a) + 5*b) == psi(phi(a)) + 5*psi(b)
True
sage: z = (1+5*b).log()
sage: w = (5 - 5*b).exp()
sage: psi(z*w) == psi(z) * psi(w)
True
sage: P.<pi> = K.extension(x^2 - 5)
sage: cc = K.hom([-a])
sage: alpha = P.hom([pi], base_map=cc); alpha(a) + a
O(pi^40)
sage: zz = (1 + a*pi).log()
sage: ww = pi.exp()
sage: beta = P.hom([-pi], base_map=cc)
sage: beta(ww*zz) == beta(ww)*beta(zz)
True
"""
L = self.parent()
K = L.base_ring()
if L is K:
# Qp or Zp, so there is a unique map
if base_map is None:
return codomain.coerce(self)
else:
return base_map(self)
f = self.polynomial()
if base_map is not None:
f = f.change_ring(base_map)
return f(im_gens[0])
def _log_generic(self, aprec, mina=0):
r"""
Return ``\log(self)`` for ``self`` equal to 1 in the residue field
Expand Down

0 comments on commit 45da59b

Please sign in to comment.