Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/sage/topology/all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# sage.doctest: needs sage.graphs
from sage.topology.simplicial_complex import SimplicialComplex, Simplex

from sage.topology.simplicial_complex_morphism import SimplicialComplexMorphism
Expand Down
68 changes: 30 additions & 38 deletions src/sage/topology/cell_complex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# sage.doctest: needs sage.graphs
r"""
Generic cell complexes

Expand Down Expand Up @@ -228,7 +227,6 @@ def _n_cells_sorted(self, n, subcomplex=None):
sage: Z._n_cells_sorted(2, subcomplex=K)
[(1, 2, 4), (1, 3, 4)]

sage: # needs sage.symbolic
sage: S = SimplicialComplex([[complex(i), complex(1)]])
sage: S._n_cells_sorted(0)
[((1+0j),), (1j,)]
Expand Down Expand Up @@ -508,7 +506,6 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None,

EXAMPLES::

sage: # needs sage.modules
sage: P = delta_complexes.RealProjectivePlane()
sage: P.homology()
{0: 0, 1: C2, 2: 0}
Expand All @@ -527,7 +524,7 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None,
Sage can compute generators of homology groups::

sage: S2 = simplicial_complexes.Sphere(2)
sage: S2.homology(dim=2, generators=True, base_ring=GF(2)) # needs sage.modules
sage: S2.homology(dim=2, generators=True, base_ring=GF(2))
[(Vector space of dimension 1 over Finite Field of size 2,
(0, 1, 2) + (0, 1, 3) + (0, 2, 3) + (1, 2, 3))]

Expand All @@ -538,15 +535,15 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None,
complexes, each generator is a linear combination of cubes::

sage: S2_cub = cubical_complexes.Sphere(2)
sage: S2_cub.homology(dim=2, generators=True) # needs sage.modules
sage: S2_cub.homology(dim=2, generators=True)
[(Z,
[0,0] x [0,1] x [0,1] - [0,1] x [0,0] x [0,1] + [0,1] x [0,1] x [0,0]
- [0,1] x [0,1] x [1,1] + [0,1] x [1,1] x [0,1] - [1,1] x [0,1] x [0,1])]

Similarly for simplicial sets::

sage: S = simplicial_sets.Sphere(2)
sage: S.homology(generators=True) # needs sage.modules
sage: S.homology(generators=True)
{0: [], 1: 0, 2: [(Z, sigma_2)]}
"""
from sage.homology.homology_group import HomologyGroup
Expand Down Expand Up @@ -625,14 +622,13 @@ def cohomology(self, dim=None, base_ring=ZZ, subcomplex=None,
EXAMPLES::

sage: circle = SimplicialComplex([[0,1], [1,2], [0, 2]])
sage: circle.cohomology(0) # needs sage.modules
sage: circle.cohomology(0)
0
sage: circle.cohomology(1) # needs sage.modules
sage: circle.cohomology(1)
Z

Projective plane::

sage: # needs sage.modules
sage: P2 = SimplicialComplex([[0,1,2], [0,2,3], [0,1,5], [0,4,5], [0,3,4],
....: [1,2,4], [1,3,4], [1,3,5], [2,3,5], [2,4,5]])
sage: P2.cohomology(2)
Expand All @@ -642,20 +638,20 @@ def cohomology(self, dim=None, base_ring=ZZ, subcomplex=None,
sage: P2.cohomology(2, base_ring=GF(3))
Vector space of dimension 0 over Finite Field of size 3

sage: cubical_complexes.KleinBottle().cohomology(2) # needs sage.modules
sage: cubical_complexes.KleinBottle().cohomology(2)
C2

Relative cohomology::

sage: T = SimplicialComplex([[0,1]])
sage: U = SimplicialComplex([[0], [1]])
sage: T.cohomology(1, subcomplex=U) # needs sage.modules
sage: T.cohomology(1, subcomplex=U)
Z

A `\Delta`-complex example::

sage: s5 = delta_complexes.Sphere(5)
sage: s5.cohomology(base_ring=GF(7))[5] # needs sage.modules
sage: s5.cohomology(base_ring=GF(7))[5]
Vector space of dimension 1 over Finite Field of size 7
"""
return self.homology(dim=dim, cohomology=True, base_ring=base_ring,
Expand Down Expand Up @@ -689,23 +685,23 @@ def betti(self, dim=None, subcomplex=None):
two-point space with itself::

sage: S = SimplicialComplex([[0], [1]])
sage: (S*S*S).betti() # needs sage.modules
sage: (S*S*S).betti()
{0: 1, 1: 0, 2: 1}
sage: (S*S*S).betti([1,2]) # needs sage.modules
sage: (S*S*S).betti([1,2])
{1: 0, 2: 1}
sage: (S*S*S).betti(2) # needs sage.modules
sage: (S*S*S).betti(2)
1

Or build the two-sphere as a `\Delta`-complex::

sage: S2 = delta_complexes.Sphere(2)
sage: S2.betti([1,2]) # needs sage.modules
sage: S2.betti([1,2])
{1: 0, 2: 1}

Or as a cubical complex::

sage: S2c = cubical_complexes.Sphere(2)
sage: S2c.betti(2) # needs sage.modules
sage: S2c.betti(2)
1
"""
dic = {}
Expand Down Expand Up @@ -733,9 +729,9 @@ def is_acyclic(self, base_ring=ZZ) -> bool:
EXAMPLES::

sage: RP2 = simplicial_complexes.RealProjectivePlane()
sage: RP2.is_acyclic() # needs sage.modules
sage: RP2.is_acyclic()
False
sage: RP2.is_acyclic(QQ) # needs sage.modules
sage: RP2.is_acyclic(QQ)
True

This first computes the Euler characteristic: if it is not 1,
Expand Down Expand Up @@ -779,12 +775,12 @@ def n_chains(self, n, base_ring=ZZ, cochains=False):
EXAMPLES::

sage: S2 = simplicial_complexes.Sphere(2)
sage: S2.n_chains(1, QQ) # needs sage.modules
sage: S2.n_chains(1, QQ)
Free module generated by {(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)}
over Rational Field
sage: list(S2.n_chains(1, QQ, cochains=False).basis()) # needs sage.modules
sage: list(S2.n_chains(1, QQ, cochains=False).basis())
[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]
sage: list(S2.n_chains(1, QQ, cochains=True).basis()) # needs sage.modules
sage: list(S2.n_chains(1, QQ, cochains=True).basis())
[\chi_(0, 1), \chi_(0, 2), \chi_(0, 3), \chi_(1, 2), \chi_(1, 3), \chi_(2, 3)]
"""
from sage.homology.chains import Chains, Cochains
Expand Down Expand Up @@ -847,7 +843,6 @@ def homology_with_basis(self, base_ring=QQ, cohomology=False):

EXAMPLES::

sage: # needs sage.modules
sage: K = simplicial_complexes.KleinBottle()
sage: H = K.homology_with_basis(QQ); H
Homology module of Minimal triangulation of the Klein bottle
Expand All @@ -863,12 +858,12 @@ def homology_with_basis(self, base_ring=QQ, cohomology=False):
The homology is constructed as a graded object, so for
example, you can ask for the basis in a single degree::

sage: H.basis(1) # needs sage.modules
sage: H.basis(1)
Finite family {(1, 0): h_{1,0}, (1, 1): h_{1,1}}

sage: S3 = delta_complexes.Sphere(3)
sage: H = S3.homology_with_basis(QQ, cohomology=True) # needs sage.modules
sage: list(H.basis(3)) # needs sage.modules
sage: H = S3.homology_with_basis(QQ, cohomology=True)
sage: list(H.basis(3))
[h^{3,0}]
"""
from sage.homology.homology_vector_space_with_basis import \
Expand Down Expand Up @@ -914,7 +909,6 @@ def cohomology_ring(self, base_ring=QQ):

EXAMPLES::

sage: # needs sage.modules
sage: K = simplicial_complexes.KleinBottle()
sage: H = K.cohomology_ring(QQ); H
Cohomology ring of Minimal triangulation of the Klein bottle
Expand All @@ -928,23 +922,22 @@ def cohomology_ring(self, base_ring=QQ):
[h^{0,0}, h^{1,0}, h^{1,1}, h^{2,0}]

sage: X = delta_complexes.SurfaceOfGenus(2)
sage: H = X.cohomology_ring(QQ); H # needs sage.modules
sage: H = X.cohomology_ring(QQ); H
Cohomology ring of Delta complex with 3 vertices and 29 simplices
over Rational Field
sage: sorted(H.basis(1), key=str) # needs sage.modules
sage: sorted(H.basis(1), key=str)
[h^{1,0}, h^{1,1}, h^{1,2}, h^{1,3}]

sage: H = simplicial_complexes.Torus().cohomology_ring(QQ); H # needs sage.modules
sage: H = simplicial_complexes.Torus().cohomology_ring(QQ); H
Cohomology ring of Minimal triangulation of the torus
over Rational Field
sage: x = H.basis()[1,0]; x # needs sage.modules
sage: x = H.basis()[1,0]; x
h^{1,0}
sage: y = H.basis()[1,1]; y # needs sage.modules
sage: y = H.basis()[1,1]; y
h^{1,1}

You can compute cup products of cohomology classes::

sage: # needs sage.modules
sage: x.cup_product(y)
-h^{2,0}
sage: x * y # alternate notation
Expand All @@ -956,13 +949,12 @@ def cohomology_ring(self, base_ring=QQ):

Cohomology operations::

sage: # needs sage.groups
sage: RP2 = simplicial_complexes.RealProjectivePlane()
sage: K = RP2.suspension()
sage: K.set_immutable()
sage: y = K.cohomology_ring(GF(2)).basis()[2,0]; y # needs sage.modules
sage: y = K.cohomology_ring(GF(2)).basis()[2,0]; y
h^{2,0}
sage: y.Sq(1) # needs sage.modules
sage: y.Sq(1)
h^{3,0}

To compute the cohomology ring, the complex must be
Expand All @@ -976,12 +968,12 @@ def cohomology_ring(self, base_ring=QQ):
sage: T = S1.product(S1)
sage: T.is_immutable()
False
sage: T.cohomology_ring() # needs sage.modules
sage: T.cohomology_ring()
Traceback (most recent call last):
...
ValueError: this simplicial complex must be immutable; call set_immutable()
sage: T.set_immutable()
sage: T.cohomology_ring() # needs sage.modules
sage: T.cohomology_ring()
Cohomology ring of Simplicial complex with 9 vertices and
18 facets over Rational Field
"""
Expand Down
34 changes: 15 additions & 19 deletions src/sage/topology/cubical_complex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# sage.doctest: needs sage.graphs
r"""
Finite cubical complexes

Expand Down Expand Up @@ -46,11 +45,11 @@
segment in the plane from `(0,2)` to `(0,3)`. We could form a
topologically equivalent space by inserting some degenerate simplices::

sage: S1.homology() # needs sage.modules
sage: S1.homology()
{0: 0, 1: Z}
sage: X = CubicalComplex([([0,0], [2,3], [2]), ([0,1], [3,3], [2]),
....: ([0,1], [2,2], [2]), ([1,1], [2,3], [2])])
sage: X.homology() # needs sage.modules
sage: X.homology()
{0: 0, 1: Z}

Topologically, the cubical complex ``X`` consists of four edges of a
Expand Down Expand Up @@ -797,26 +796,26 @@ class :class:`Cube`, or lists or tuples suitable for conversion to
sage: S1 = CubicalComplex([([0,0], [2,3]), ([0,1], [3,3]),
....: ([0,1], [2,2]), ([1,1], [2,3])]); S1
Cubical complex with 4 vertices and 8 cubes
sage: S1.homology() # needs sage.modules
sage: S1.homology()
{0: 0, 1: Z}

A set of five points and its product with ``S1``::

sage: pts = CubicalComplex([([0],), ([3],), ([6],), ([-12],), ([5],)])
sage: pts
Cubical complex with 5 vertices and 5 cubes
sage: pts.homology() # needs sage.modules
sage: pts.homology()
{0: Z x Z x Z x Z}
sage: X = S1.product(pts); X
Cubical complex with 20 vertices and 40 cubes
sage: X.homology() # needs sage.modules
sage: X.homology()
{0: Z x Z x Z x Z, 1: Z^5}

Converting a simplicial complex to a cubical complex::

sage: S2 = simplicial_complexes.Sphere(2)
sage: C2 = CubicalComplex(S2)
sage: all(C2.homology(n) == S2.homology(n) for n in range(3)) # needs sage.modules
sage: all(C2.homology(n) == S2.homology(n) for n in range(3))
True

You can get the set of maximal cells or a dictionary of all cells::
Expand Down Expand Up @@ -853,14 +852,14 @@ class :class:`Cube`, or lists or tuples suitable for conversion to

sage: T = S1.product(S1); T
Cubical complex with 16 vertices and 64 cubes
sage: T.chain_complex() # needs sage.modules
sage: T.chain_complex()
Chain complex with at most 3 nonzero terms over Integer Ring
sage: T.homology(base_ring=QQ) # needs sage.modules
sage: T.homology(base_ring=QQ)
{0: Vector space of dimension 0 over Rational Field,
1: Vector space of dimension 2 over Rational Field,
2: Vector space of dimension 1 over Rational Field}
sage: RP2 = cubical_complexes.RealProjectivePlane()
sage: RP2.cohomology(dim=[1, 2], base_ring=GF(2)) # needs sage.modules
sage: RP2.cohomology(dim=[1, 2], base_ring=GF(2))
{1: Vector space of dimension 1 over Finite Field of size 2,
2: Vector space of dimension 1 over Finite Field of size 2}

Expand Down Expand Up @@ -1191,7 +1190,6 @@ def chain_complex(self, subcomplex=None, augmented=False,

EXAMPLES::

sage: # needs sage.modules
sage: S2 = cubical_complexes.Sphere(2)
sage: S2.chain_complex()
Chain complex with at most 3 nonzero terms over Integer Ring
Expand All @@ -1210,7 +1208,6 @@ def chain_complex(self, subcomplex=None, augmented=False,

Check that :issue:`32203` has been fixed::

sage: # needs sage.modules
sage: Square = CubicalComplex([([0,1],[0,1])])
sage: EdgesLTR = CubicalComplex([([0,0],[0,1]),([0,1],[1,1]),([1,1],[0,1])])
sage: EdgesLBR = CubicalComplex([([0,0],[0,1]),([0,1],[0,0]),([1,1],[0,1])])
Expand Down Expand Up @@ -1507,7 +1504,7 @@ def disjoint_union(self, other):

sage: S1 = cubical_complexes.Sphere(1)
sage: S2 = cubical_complexes.Sphere(2)
sage: S1.disjoint_union(S2).homology() # needs sage.modules
sage: S1.disjoint_union(S2).homology()
{0: Z, 1: Z, 2: Z}
"""
embedded_left = len(tuple(self.maximal_cells()[0]))
Expand Down Expand Up @@ -1545,7 +1542,7 @@ def wedge(self, other):

sage: S1 = cubical_complexes.Sphere(1)
sage: S2 = cubical_complexes.Sphere(2)
sage: S1.wedge(S2).homology() # needs sage.modules
sage: S1.wedge(S2).homology()
{0: 0, 1: Z, 2: Z}
"""
embedded_left = len(tuple(self.maximal_cells()[0]))
Expand Down Expand Up @@ -1582,12 +1579,12 @@ def connected_sum(self, other):

sage: T = cubical_complexes.Torus()
sage: S2 = cubical_complexes.Sphere(2)
sage: T.connected_sum(S2).cohomology() == T.cohomology() # needs sage.modules
sage: T.connected_sum(S2).cohomology() == T.cohomology()
True
sage: RP2 = cubical_complexes.RealProjectivePlane()
sage: T.connected_sum(RP2).homology(1) # needs sage.modules
sage: T.connected_sum(RP2).homology(1)
Z x Z x C2
sage: RP2.connected_sum(RP2).connected_sum(RP2).homology(1) # needs sage.modules
sage: RP2.connected_sum(RP2).connected_sum(RP2).homology(1)
Z x Z x C2
"""
# connected_sum: first check whether the complexes are pure
Expand Down Expand Up @@ -1703,7 +1700,6 @@ def algebraic_topological_model(self, base_ring=None):

EXAMPLES::

sage: # needs sage.modules
sage: RP2 = cubical_complexes.RealProjectivePlane()
sage: phi, M = RP2.algebraic_topological_model(GF(2))
sage: M.homology()
Expand Down Expand Up @@ -1764,7 +1760,7 @@ def _simplicial_(self):

sage: Ts = T._simplicial_(); Ts
Simplicial complex with 16 vertices and 32 facets
sage: T.homology() == Ts.homology() # needs sage.modules
sage: T.homology() == Ts.homology()
True

Each `n`-dimensional cube produces `n!` `n`-simplices::
Expand Down
Loading
Loading