# Homsets between simplicial complexes¶

AUTHORS:

• Travis Scrimshaw (2012-08-18): Made all simplicial complexes immutable to work with the homset cache.

EXAMPLES:

sage: S = simplicial_complexes.Sphere(1)
sage: T = simplicial_complexes.Sphere(2)
sage: H = Hom(S,T)
sage: f = {0:0,1:1,2:3}
sage: x = H(f)
sage: x
Simplicial complex morphism {0: 0, 1: 1, 2: 3} from Simplicial complex with vertex set (0, 1, 2) and facets {(1, 2), (0, 2), (0, 1)} to Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 2, 3), (0, 1, 2), (1, 2, 3), (0, 1, 3)}
sage: x.is_injective()
True
sage: x.is_surjective()
False
sage: x.image()
Simplicial complex with vertex set (0, 1, 3) and facets {(1, 3), (0, 3), (0, 1)}
sage: from sage.homology.simplicial_complex import Simplex
sage: s = Simplex([1,2])
sage: x(s)
(1, 3)


TESTS:

sage: S = simplicial_complexes.Sphere(1)
sage: T = simplicial_complexes.Sphere(2)
sage: H = Hom(S,T)
True

class sage.homology.simplicial_complex_homset.SimplicialComplexHomset(X, Y, category=None, base=None, check=True)

TESTS:

sage: X = ZZ['x']; X.rename("X")
sage: Y = ZZ['y']; Y.rename("Y")
sage: class MyHomset(Homset):
...       def my_function(self, x):
...           return Y(x[0])
...       def _an_element_(self):
...           return sage.categories.morphism.SetMorphism(self, self.my_function)
...
sage: import __main__; __main__.MyHomset = MyHomset # fakes MyHomset being defined in a Python module
sage: H = MyHomset(X, Y, category=Monoids(), base = ZZ)
sage: H
Set of Morphisms from X to Y in Category of monoids
sage: TestSuite(H).run()

sage: H = MyHomset(X, Y, category=1, base = ZZ)
Traceback (most recent call last):
...
TypeError: category (=1) must be a category

sage: H
Set of Morphisms from X to Y in Category of monoids
sage: TestSuite(H).run()
sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
Traceback (most recent call last):
...
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'hom_category'
sage: P.<t> = ZZ[]
sage: f = P.hom([1/2*t])
sage: f.parent().domain()
Univariate Polynomial Ring in t over Integer Ring
sage: f.domain() is f.parent().domain()
True


Test that base_ring is initialized properly:

sage: R = QQ['x']
sage: Hom(R, R).base_ring()
Rational Field
sage: Hom(R, R, category=Sets()).base_ring()
sage: Hom(R, R, category=Modules(QQ)).base_ring()
Rational Field
sage: Hom(QQ^3, QQ^3, category=Modules(QQ)).base_ring()
Rational Field


For whatever it’s worth, the base arguments takes precedence:

sage: MyHomset(ZZ^3, ZZ^3, base = QQ).base_ring()
Rational Field

an_element()

Returns a (non-random) element of self.

EXAMPLES:

sage: S = simplicial_complexes.KleinBottle()
sage: T = simplicial_complexes.Sphere(5)
sage: H = Hom(S,T)
sage: x = H.an_element()
sage: x
Simplicial complex morphism {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0} from Simplicial complex with vertex set (0, 1, 2, 3, 4, 5, 6, 7) and 16 facets to Simplicial complex with vertex set (0, 1, 2, 3, 4, 5, 6) and 7 facets

diagonal_morphism(rename_vertices=True)

Returns the diagonal morphism in $$Hom(S, S \times S)$$.

EXAMPLES:

sage: S = simplicial_complexes.Sphere(2)
sage: H = Hom(S,S.product(S, is_mutable=False))
sage: d = H.diagonal_morphism()
sage: d
Simplicial complex morphism {0: 'L0R0', 1: 'L1R1', 2: 'L2R2', 3: 'L3R3'} from
Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 2, 3), (0, 1, 2), (1, 2, 3), (0, 1, 3)}
to Simplicial complex with 16 vertices and 96 facets

sage: T = SimplicialComplex([[0], [1]], is_mutable=False)
sage: U = T.product(T,rename_vertices = False, is_mutable=False)
sage: G = Hom(T,U)
sage: e = G.diagonal_morphism(rename_vertices = False)
sage: e
Simplicial complex morphism {0: (0, 0), 1: (1, 1)} from
Simplicial complex with vertex set (0, 1) and facets {(0,), (1,)}
to Simplicial complex with 4 vertices and facets {((1, 1),), ((1, 0),), ((0, 0),), ((0, 1),)}

identity()

Returns the identity morphism of $$Hom(S,S)$$.

EXAMPLES:

sage: S = simplicial_complexes.Sphere(2)
sage: H = Hom(S,S)
sage: i = H.identity()
sage: i.is_identity()
True

sage: T = SimplicialComplex([[0,1]], is_mutable=False)
sage: G = Hom(T,T)
sage: G.identity()
Simplicial complex morphism {0: 0, 1: 1} from
Simplicial complex with vertex set (0, 1) and facets {(0, 1)} to
Simplicial complex with vertex set (0, 1) and facets {(0, 1)}

sage.homology.simplicial_complex_homset.is_SimplicialComplexHomset(x)

Return True if and only if x is a simplicial complex homspace.

EXAMPLES:

sage: S = SimplicialComplex(is_mutable=False)
sage: T = SimplicialComplex(is_mutable=False)
sage: H = Hom(S, T)
sage: H
Set of Morphisms from Simplicial complex with vertex set () and facets {()} to Simplicial complex with vertex set () and facets {()} in Category of simplicial complexes
sage: from sage.homology.simplicial_complex_homset import is_SimplicialComplexHomset
sage: is_SimplicialComplexHomset(H)
True


#### Previous topic

Morphisms of simplicial complexes

#### Next topic

Examples of simplicial complexes