Morphisms

AUTHORS:

  • William Stein: initial version
  • David Joyner (12-17-2005): added examples
  • Robert Bradshaw (2007-06-25) Pyrexification
class sage.categories.morphism.CallMorphism

Bases: sage.categories.morphism.Morphism

class sage.categories.morphism.FormalCoercionMorphism

Bases: sage.categories.morphism.Morphism

class sage.categories.morphism.IdentityMorphism

Bases: sage.categories.morphism.Morphism

is_identity()

Return True if this morphism is the identity morphism.

EXAMPLES:

sage: E = End(Partitions(5))
sage: E.identity().is_identity()
True

Check that trac ticket #15478 is fixed:

sage: K.<z> = GF(4)
sage: phi = End(K)([z^2])
sage: R.<t> = K[]
sage: psi = End(R)(phi)
sage: psi.is_identity()
False
is_injective()

Return whether this morphism is injective.

EXAMPLES:

sage: Hom(ZZ, ZZ).identity().is_injective()
True
is_surjective()

Return whether this morphism is surjective.

EXAMPLES:

sage: Hom(ZZ, ZZ).identity().is_surjective()
True
section()

Return a section of this morphism.

EXAMPLES:

sage: T = Hom(ZZ, ZZ).identity()
sage: T.section() is T
True
class sage.categories.morphism.Morphism

Bases: sage.categories.map.Map

category()

Return the category of the parent of this morphism.

EXAMPLES:

sage: R.<t> = ZZ[]
sage: f = R.hom([t**2])
sage: f.category()
Category of endsets of unital magmas and right modules over
 (euclidean domains and infinite enumerated sets and metric spaces)
 and left modules over (euclidean domains
 and infinite enumerated sets and metric spaces)

sage: K = CyclotomicField(12)
sage: L = CyclotomicField(132)
sage: phi = L._internal_coerce_map_from(K)
sage: phi.category()
Category of homsets of number fields
is_endomorphism()

Return True if this morphism is an endomorphism.

EXAMPLES:

sage: R.<t> = ZZ[]
sage: f = R.hom([t])
sage: f.is_endomorphism()
True

sage: K = CyclotomicField(12)
sage: L = CyclotomicField(132)
sage: phi = L._internal_coerce_map_from(K)
sage: phi.is_endomorphism()
False
is_identity()

Return True if this morphism is the identity morphism.

Note

Implemented only when the domain has a method gens()

EXAMPLES:

sage: R.<t> = ZZ[]
sage: f = R.hom([t])
sage: f.is_identity()
True
sage: g = R.hom([t+1])
sage: g.is_identity()
False

A morphism between two different spaces cannot be the identity:

sage: R2.<t2> = QQ[]
sage: h = R.hom([t2])
sage: h.is_identity()
False
pushforward(I)
register_as_coercion()

Register this morphism as a coercion to Sage’s coercion model (see sage.structure.coerce).

EXAMPLES:

By default, adding polynomials over different variables triggers an error:

sage: X.<x> = ZZ[]
sage: Y.<y> = ZZ[]
sage: x^2 + y
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for +: 'Univariate Polynomial Ring in x over Integer Ring' and 'Univariate Polynomial Ring in y over Integer Ring'

Let us declare a coercion from \(\ZZ[x]\) to \(\ZZ[z]\):

sage: Z.<z> = ZZ[]
sage: phi = Hom(X, Z)(z)
sage: phi(x^2+1)
z^2 + 1
sage: phi.register_as_coercion()

Now we can add elements from \(\ZZ[x]\) and \(\ZZ[z]\), because the elements of the former are allowed to be implicitly coerced into the later:

sage: x^2 + z
z^2 + z

Caveat: the registration of the coercion must be done before any other coercion is registered or discovered:

sage: phi = Hom(X, Y)(y)
sage: phi.register_as_coercion()
Traceback (most recent call last):
...
AssertionError: coercion from Univariate Polynomial Ring in x over Integer Ring to Univariate Polynomial Ring in y over Integer Ring already registered or discovered
register_as_conversion()

Register this morphism as a conversion to Sage’s coercion model

(see sage.structure.coerce).

EXAMPLES:

Let us declare a conversion from the symmetric group to \(\ZZ\) through the sign map:

sage: S = SymmetricGroup(4)
sage: phi = Hom(S, ZZ)(lambda x: ZZ(x.sign()))
sage: x = S.an_element(); x
(2,3,4)
sage: phi(x)
1
sage: phi.register_as_conversion()
sage: ZZ(x)
1
class sage.categories.morphism.SetMorphism

Bases: sage.categories.morphism.Morphism

INPUT:

  • parent – a Homset
  • function – a Python function that takes elements of the domain as input and returns elements of the domain.

EXAMPLES:

sage: from sage.categories.morphism import SetMorphism
sage: f = SetMorphism(Hom(QQ, ZZ, Sets()), numerator)
sage: f.parent()
Set of Morphisms from Rational Field to Integer Ring in Category of sets
sage: f.domain()
Rational Field
sage: f.codomain()
Integer Ring
sage: TestSuite(f).run()
sage.categories.morphism.is_Morphism(x)