# Set of homomorphisms between two schemes#

For schemes $$X$$ and $$Y$$, this module implements the set of morphisms $$\mathrm{Hom}(X,Y)$$. This is done by SchemeHomset_generic.

As a special case, the Hom-sets can also represent the points of a scheme. Recall that the $$K$$-rational points of a scheme $$X$$ over $$k$$ can be identified with the set of morphisms $$\mathrm{Spec}(K) \to X$$. In Sage the rational points are implemented by such scheme morphisms. This is done by SchemeHomset_points and its subclasses.

Note

You should not create the Hom-sets manually. Instead, use the Hom() method that is inherited by all schemes.

AUTHORS:

• William Stein (2006): initial version.

• Volker Braun (2011-08-11): significant improvement and refactoring.

• Ben Hutz (June 2012): added support for projective ring

class sage.schemes.generic.homset.SchemeHomsetFactory[source]#

Bases: UniqueFactory

Factory for Hom-sets of schemes.

EXAMPLES:

sage: A2 = AffineSpace(QQ, 2)
sage: A3 = AffineSpace(QQ, 3)
sage: Hom = A3.Hom(A2)

>>> from sage.all import *
>>> A2 = AffineSpace(QQ, Integer(2))
>>> A3 = AffineSpace(QQ, Integer(3))
>>> Hom = A3.Hom(A2)


The Hom-sets are uniquely determined by domain and codomain:

sage: Hom is copy(Hom)
True
sage: Hom is A3.Hom(A2)
True

>>> from sage.all import *
>>> Hom is copy(Hom)
True
>>> Hom is A3.Hom(A2)
True


The Hom-sets are identical if the domains and codomains are identical:

sage: loads(Hom.dumps()) is Hom
True
sage: A3_iso = AffineSpace(QQ, 3)
sage: A3_iso is A3
True
sage: Hom_iso = A3_iso.Hom(A2)
sage: Hom_iso is Hom
True

>>> from sage.all import *
True
>>> A3_iso = AffineSpace(QQ, Integer(3))
>>> A3_iso is A3
True
>>> Hom_iso = A3_iso.Hom(A2)
>>> Hom_iso is Hom
True

create_key_and_extra_args(X, Y, category=None, base=None, check=True, as_point_homset=False)[source]#

Create a key that uniquely determines the Hom-set.

INPUT:

• X – a scheme. The domain of the morphisms.

• Y – a scheme. The codomain of the morphisms.

• category – a category for the Hom-sets (default: schemes over given base).

• base – a scheme or a ring. The base scheme of domain and codomain schemes. If a ring is specified, the spectrum of that ring will be used as base scheme.

• check – boolean (default: True).

EXAMPLES:

sage: A2 = AffineSpace(QQ, 2)
sage: A3 = AffineSpace(QQ, 3)
sage: A3.Hom(A2)    # indirect doctest
Set of morphisms
From: Affine Space of dimension 3 over Rational Field
To:   Affine Space of dimension 2 over Rational Field
sage: from sage.schemes.generic.homset import SchemeHomsetFactory
sage: SHOMfactory = SchemeHomsetFactory('test')
sage: key, extra = SHOMfactory.create_key_and_extra_args(A3, A2, check=False)
sage: key
(..., ..., Category of schemes over Rational Field, False)
sage: extra
{'X': Affine Space of dimension 3 over Rational Field,
'Y': Affine Space of dimension 2 over Rational Field,
'base_ring': Rational Field,
'check': False}

>>> from sage.all import *
>>> A2 = AffineSpace(QQ, Integer(2))
>>> A3 = AffineSpace(QQ, Integer(3))
>>> A3.Hom(A2)    # indirect doctest
Set of morphisms
From: Affine Space of dimension 3 over Rational Field
To:   Affine Space of dimension 2 over Rational Field
>>> from sage.schemes.generic.homset import SchemeHomsetFactory
>>> SHOMfactory = SchemeHomsetFactory('test')
>>> key, extra = SHOMfactory.create_key_and_extra_args(A3, A2, check=False)
>>> key
(..., ..., Category of schemes over Rational Field, False)
>>> extra
{'X': Affine Space of dimension 3 over Rational Field,
'Y': Affine Space of dimension 2 over Rational Field,
'base_ring': Rational Field,
'check': False}

create_object(version, key, **extra_args)[source]#

Create a SchemeHomset_generic.

INPUT:

• version – object version. Currently not used.

• key – a key created by create_key_and_extra_args().

• extra_args – a dictionary of extra keyword arguments.

EXAMPLES:

sage: A2 = AffineSpace(QQ, 2)
sage: A3 = AffineSpace(QQ, 3)
sage: A3.Hom(A2) is A3.Hom(A2)   # indirect doctest
True
sage: from sage.schemes.generic.homset import SchemeHomsetFactory
sage: SHOMfactory = SchemeHomsetFactory('test')
sage: SHOMfactory.create_object(0, [id(A3), id(A2), A3.category(), False],
....:                           check=True, X=A3, Y=A2, base_ring=QQ)
Set of morphisms
From: Affine Space of dimension 3 over Rational Field
To:   Affine Space of dimension 2 over Rational Field

>>> from sage.all import *
>>> A2 = AffineSpace(QQ, Integer(2))
>>> A3 = AffineSpace(QQ, Integer(3))
>>> A3.Hom(A2) is A3.Hom(A2)   # indirect doctest
True
>>> from sage.schemes.generic.homset import SchemeHomsetFactory
>>> SHOMfactory = SchemeHomsetFactory('test')
>>> SHOMfactory.create_object(Integer(0), [id(A3), id(A2), A3.category(), False],
...                           check=True, X=A3, Y=A2, base_ring=QQ)
Set of morphisms
From: Affine Space of dimension 3 over Rational Field
To:   Affine Space of dimension 2 over Rational Field

class sage.schemes.generic.homset.SchemeHomset_generic(X, Y, category=None, check=True, base=None)[source]#

Bases: HomsetWithBase

The base class for Hom-sets of schemes.

INPUT:

• X – a scheme. The domain of the Hom-set.

• Y – a scheme. The codomain of the Hom-set.

• category – a category (optional). The category of the Hom-set.

• check – boolean (default: True). Whether to check the defining data for consistency.

EXAMPLES:

sage: from sage.schemes.generic.homset import SchemeHomset_generic
sage: A2 = AffineSpace(QQ,2)
sage: Hom = SchemeHomset_generic(A2, A2); Hom
Set of morphisms
From: Affine Space of dimension 2 over Rational Field
To:   Affine Space of dimension 2 over Rational Field
sage: Hom.category()
Category of endsets of schemes over Rational Field

>>> from sage.all import *
>>> from sage.schemes.generic.homset import SchemeHomset_generic
>>> A2 = AffineSpace(QQ,Integer(2))
>>> Hom = SchemeHomset_generic(A2, A2); Hom
Set of morphisms
From: Affine Space of dimension 2 over Rational Field
To:   Affine Space of dimension 2 over Rational Field
>>> Hom.category()
Category of endsets of schemes over Rational Field

Element[source]#

alias of SchemeMorphism

natural_map()[source]#

Return a natural map in the Hom space.

OUTPUT:

A SchemeMorphism if there is a natural map from domain to codomain. Otherwise, a NotImplementedError is raised.

EXAMPLES:

sage: A = AffineSpace(4, QQ)
sage: A.structure_morphism()   # indirect doctest
Scheme morphism:
From: Affine Space of dimension 4 over Rational Field
To:   Spectrum of Rational Field
Defn: Structure map

>>> from sage.all import *
>>> A = AffineSpace(Integer(4), QQ)
>>> A.structure_morphism()   # indirect doctest
Scheme morphism:
From: Affine Space of dimension 4 over Rational Field
To:   Spectrum of Rational Field
Defn: Structure map

class sage.schemes.generic.homset.SchemeHomset_points(X, Y, category=None, check=True, base=Integer Ring)[source]#

Set of rational points of the scheme.

Recall that the $$K$$-rational points of a scheme $$X$$ over $$k$$ can be identified with the set of morphisms $$\mathrm{Spec}(K) \to X$$. In Sage, the rational points are implemented by such scheme morphisms.

If a scheme has a finite number of points, then the homset is supposed to implement the Python iterator interface. See SchemeHomset_points_toric_field for example.

INPUT:

EXAMPLES:

sage: from sage.schemes.generic.homset import SchemeHomset_points
sage: SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,2))
Set of rational points of Affine Space of dimension 2 over Rational Field

>>> from sage.all import *
>>> from sage.schemes.generic.homset import SchemeHomset_points
>>> SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,Integer(2)))
Set of rational points of Affine Space of dimension 2 over Rational Field

cardinality()[source]#

Return the number of points.

OUTPUT:

An integer or infinity.

EXAMPLES:

sage: toric_varieties.P2().point_set().cardinality()                        # needs sage.geometry.polyhedron sage.graphs
+Infinity

sage: P2 = toric_varieties.P2(base_ring=GF(3))                              # needs sage.geometry.polyhedron sage.graphs
sage: P2.point_set().cardinality()                                          # needs sage.geometry.polyhedron sage.graphs
13

>>> from sage.all import *
>>> toric_varieties.P2().point_set().cardinality()                        # needs sage.geometry.polyhedron sage.graphs
+Infinity

>>> P2 = toric_varieties.P2(base_ring=GF(Integer(3)))                              # needs sage.geometry.polyhedron sage.graphs
>>> P2.point_set().cardinality()                                          # needs sage.geometry.polyhedron sage.graphs
13

extended_codomain()[source]#

Return the codomain with extended base, if necessary.

OUTPUT:

The codomain scheme, with its base ring extended to the codomain. That is, the codomain is of the form $$\mathrm{Spec}(R)$$ and the base ring of the domain is extended to $$R$$.

EXAMPLES:

sage: # needs sage.rings.number_field
sage: P2 = ProjectiveSpace(QQ, 2)
sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + x - (3^3-3))
sage: K_points = P2(K);  K_points
Set of rational points of Projective Space of dimension 2
over Number Field in a with defining polynomial x^2 + x - 24
sage: K_points.codomain()
Projective Space of dimension 2 over Rational Field
sage: K_points.extended_codomain()
Projective Space of dimension 2
over Number Field in a with defining polynomial x^2 + x - 24

>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> P2 = ProjectiveSpace(QQ, Integer(2))
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + x - (Integer(3)**Integer(3)-Integer(3)), names=('a',)); (a,) = K._first_ngens(1)
>>> K_points = P2(K);  K_points
Set of rational points of Projective Space of dimension 2
over Number Field in a with defining polynomial x^2 + x - 24
>>> K_points.codomain()
Projective Space of dimension 2 over Rational Field
>>> K_points.extended_codomain()
Projective Space of dimension 2
over Number Field in a with defining polynomial x^2 + x - 24

list()[source]#

Return a tuple containing all points.

OUTPUT:

A tuple containing all points of the toric variety.

EXAMPLES:

sage: P1 = toric_varieties.P1(base_ring=GF(3))                              # needs sage.geometry.polyhedron sage.graphs
sage: P1.point_set().list()                                                 # needs sage.geometry.polyhedron sage.graphs
([0 : 1], [1 : 0], [1 : 1], [1 : 2])

>>> from sage.all import *
>>> P1 = toric_varieties.P1(base_ring=GF(Integer(3)))                              # needs sage.geometry.polyhedron sage.graphs
>>> P1.point_set().list()                                                 # needs sage.geometry.polyhedron sage.graphs
([0 : 1], [1 : 0], [1 : 1], [1 : 2])

value_ring()[source]#

Return $$R$$ for a point Hom-set $$X(\mathrm{Spec}(R))$$.

OUTPUT:

A commutative ring.

EXAMPLES:

sage: P2 = ProjectiveSpace(ZZ, 2)
sage: P2(QQ).value_ring()
Rational Field

>>> from sage.all import *
>>> P2 = ProjectiveSpace(ZZ, Integer(2))
>>> P2(QQ).value_ring()
Rational Field

zero()[source]#

Return the identity of the codomain with extended base, if necessary.

sage.schemes.generic.homset.is_SchemeHomset(H)[source]#

Test whether H is a scheme Hom-set.

EXAMPLES:

sage: f = Spec(QQ).identity_morphism();  f
Scheme endomorphism of Spectrum of Rational Field
Defn: Identity map
sage: from sage.schemes.generic.homset import is_SchemeHomset
sage: is_SchemeHomset(f)
doctest:warning...
DeprecationWarning: The function is_SchemeHomset is deprecated; use 'isinstance(..., SchemeHomset_generic)' instead.
See https://github.com/sagemath/sage/issues/38022 for details.
False
sage: is_SchemeHomset(f.parent())
True
sage: is_SchemeHomset('a string')
False

>>> from sage.all import *
>>> f = Spec(QQ).identity_morphism();  f
Scheme endomorphism of Spectrum of Rational Field
Defn: Identity map
>>> from sage.schemes.generic.homset import is_SchemeHomset
>>> is_SchemeHomset(f)
doctest:warning...
DeprecationWarning: The function is_SchemeHomset is deprecated; use 'isinstance(..., SchemeHomset_generic)' instead.
See https://github.com/sagemath/sage/issues/38022 for details.
False
>>> is_SchemeHomset(f.parent())
True
>>> is_SchemeHomset('a string')
False