# 19.2 Homsets

Module: `sage.categories.homset`

Homsets

Author Log:

• David Kohel and William Stein
• David Joyner (2005-12-17): added examples
• William Stein (2006-01-14): Changed from Homspace to Homset.

Module-level Functions

 End( X, [cat=None])
Create the set of endomorphisms of X in the category cat.

```INPUT:
X -- anything
cat -- (optional) category in which to coerce X

OUTPUT:
a set of endomorphisms in cat
```

```sage: V = VectorSpace(QQ, 3)
sage: End(V)
Set of Morphisms from Vector space of dimension 3 over Rational
Field to Vector space of dimension 3 over Rational Field in
Category of vector spaces over Rational Field
```

```sage: G = SymmetricGroup(3)
sage: S = End(G); S
Set of Morphisms from SymmetricGroup(3) to SymmetricGroup(3) in Category of
groups
sage: is_Endset(S)
True
sage: S.domain()
Symmetric group of order 3! as a permutation group
```

Homsets are not objects in their category. They are currently sets.

```sage: S.category()
Category of sets
sage: S.domain().category()
Category of groups
```

 Hom( X, Y, [cat=None])
Create the space of homomorphisms from X to Y in the category cat.

```INPUT:
X -- anything
Y -- anything
cat -- (optional) category in which the morphisms must be

OUTPUT:
a homset in cat
```

```sage: V = VectorSpace(QQ,3)
sage: Hom(V, V)
Set of Morphisms from Vector space of dimension 3 over Rational
Field to Vector space of dimension 3 over Rational Field in
Category of vector spaces over Rational Field
sage: G = SymmetricGroup(3)
sage: Hom(G, G)
Set of Morphisms from SymmetricGroup(3) to SymmetricGroup(3) in Category of
groups
sage: Hom(ZZ, QQ, Sets())
Set of Morphisms from Integer Ring to Rational Field in Category of sets
```

 end( X, f)
Return End(X)(f), where f is data that defines an element of End(X).

```sage: R, x = PolynomialRing(QQ,'x').objgen()
sage: phi = end(R, [x + 1])
sage: phi
Ring endomorphism of Univariate Polynomial Ring in x over Rational Field
Defn: x |--> x + 1
sage: phi(x^2 + 5)
x^2 + 2*x + 6
```

 hom( X, Y, f)
Return Hom(X,Y)(f), where f is data that defines an element of Hom(X,Y).

```sage: R, x = PolynomialRing(QQ,'x').objgen()
sage: phi = hom(R, QQ, [2])
sage: phi(x^2 + 3)
7
```

 is_Endset( x)
Return True if x is a set of endomorphisms in a category.

 is_Homset( x)
Return True if x is a set of homomorphisms in a category.

Class: `Homset`

class Homset
The class for collections of morphisms in a category.

```sage: H = Hom(QQ^2, QQ^3)
True
sage: E = End(AffineSpace(2, names='x,y'))
True
```
 Homset( self, X, Y, [cat=None], [check=True])

Functions: codomain, domain, identity, is_endomorphism_set, natural_map, reversed

 is_endomorphism_set( self)
Return True if the domain and codomain of self are the same object.

 reversed( self)
Return the corresponding homset, but with the domain and codomain reversed.

Special Functions: __call__, __cmp__, __contains__, _repr_

 __call__( self, x, [y=None], [check=True])
Construct a morphism in this homset from x if possible.

```sage: H = Hom(SymmetricGroup(4), SymmetricGroup(7))
sage: phi = Hom(SymmetricGroup(5), SymmetricGroup(6)).natural_map()
sage: phi
Coercion morphism:
From: SymmetricGroup(5)
To:   SymmetricGroup(6)
sage: H(phi)
Composite morphism:
From: SymmetricGroup(4)
To:   SymmetricGroup(7)
Defn:   Composite morphism:
From: SymmetricGroup(4)
To:   SymmetricGroup(6)
Defn:   Coercion morphism:
From: SymmetricGroup(4)
To:   SymmetricGroup(5)
then
Coercion morphism:
From: SymmetricGroup(5)
To:   SymmetricGroup(6)
then
Coercion morphism:
From: SymmetricGroup(6)
To:   SymmetricGroup(7)
```

Class: `HomsetWithBase`