New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add finite topological spaces #30400
Comments
comment:2
I have added the file finite_topological_spaces.py in ~/sage/src/sage/homology. I think this is a correct place to put it because different methods dealing with homotopy types and weak homotopy types will be added in next commits, but the discussion is open and I accept other suggestions in order to put it in the correct place. New commits:
|
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:8
Thank you so much, I've learned it for next tickets. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:10
I'm getting some doctest failures. Also, it would be nice to add this to the reference manual. Here are changes to fix some of these: diff --git a/src/doc/en/reference/homology/index.rst b/src/doc/en/reference/homology/index.rst
index bf98e0841f..148dc4bae0 100644
--- a/src/doc/en/reference/homology/index.rst
+++ b/src/doc/en/reference/homology/index.rst
@@ -35,6 +35,7 @@ cell complexes.
sage/homology/algebraic_topological_model
sage/homology/homology_morphism
sage/homology/matrix_utils
+ sage/homology/finite_topological_spaces
sage/interfaces/chomp
.. include:: ../footer.txt
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 3a43eabed4..430e2a84ad 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -72,6 +72,7 @@ from sage.combinat.posets.hasse_diagram import HasseDiagram
def dict_to_matrix(ordered_eltos, dictionary):
r"""
Return a matrix from the information given by ``dictionary``.
+
INPUT:
- ``ordered_eltos`` -- a list.
@@ -79,7 +80,7 @@ def dict_to_matrix(ordered_eltos, dictionary):
- ``dictionary`` -- a dict whose key list is ``ordered_eltos`` and its values
are sets of elements in ``ordered_eltos``.
- OUTPUT::
+ OUTPUT:
- A binary matrix whose `(i,j)` entry is equal to 1 if and only if ``ordered_eltos[i]``
is in ``dictionary[ordered_eltos[j]]``.
@@ -124,7 +125,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
- ``elements`` -- it is ignored when data is of type 1, 2 or 4. When ``data``
is a topogenous matrix, this parameter gives the underlying set of the space.
- EXAMPLES::
+ EXAMPLES:
A dictionary as ``data``::
@@ -135,16 +136,16 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: type(T)
<class 'sage.homology.finite_topological_spaces.FiniteTopologicalSpace'>
sage: FiniteSpace({'a': {'a', 'b'}})
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The data does not correspond to a valid dictionary
sage: FiniteSpace({'a': {'a', 'b'}, 'b': {'a', 'b'}, 'c': {'a', 'c'}})
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The introduced data does not define a topology
When ``data`` is a tuple or a list, the elements are in ``range(n)`` where
- ``n`` is the lenght of ``data``::
+ ``n`` is the length of ``data``::
sage: from sage.homology.finite_topological_spaces import FiniteSpace
sage: T = FiniteSpace([{0, 3}, {1, 3}, {2, 3}, {3}]) ; T
@@ -155,7 +156,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: T.elements()
[3, 0, 1, 2]
sage: FiniteSpace(({0, 2}, {0, 2}))
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: This kind of data assume the elements are in range(2)
@@ -182,7 +183,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: M.elements()
[5, 'e', 'h', 0, 'c']
sage: FiniteSpace(mat, elements=[5, 'e', 'h', 0, 0])
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
AssertionError: Not valid list of elements
@@ -386,6 +387,7 @@ class FiniteTopologicalSpace(Parent):
sage: from sage.homology.finite_topological_spaces import FiniteSpace
sage: T = FiniteSpace(({0}, {1}, {2, 3}, {3}))
sage: T.underlying_set()
+ {0, 1, 2, 3}
"""
return set(self._elements)
@@ -474,7 +476,7 @@ class FiniteTopologicalSpace(Parent):
sage: T.Ux(4)
{3, 4}
sage: T.Ux(5)
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The point 5 is not an element of the space
"""
@@ -787,7 +789,7 @@ class FiniteTopologicalSpace(Parent):
True
sage: T.boundary(T.boundary(Fr)) == T.boundary(Fr)
True
- sage: X == Fr.union(T.interior(E), T.exterior(E))|||
+ sage: X == Fr.union(T.interior(E), T.exterior(E))
True
"""
X = self.underlying_set()
I get sporadic doctest failures:
The issue is that these sets may print in different orders, and I think it's more or less random. By the way, it's better to say New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
Replying to @jhpalmieri:
Thanks for the suggestions, I have changed the files in order to include the improvements.
I see... I think it depends on the implementation of sets in SageMath, do I have to impose an specific order for printing or it is not necessary? |
comment:14
Doctests have to pass, so something has to change. Here are suggestions, but if you can think of meaningful doctests that don't rely on the ordering (one example is the test diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 5c40fe26ce..548322f174 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -127,9 +127,14 @@ def FiniteSpace(data, elements=None, is_T0=False):
A dictionary as ``data``::
sage: from sage.homology.finite_topological_spaces import FiniteSpace
- sage: T = FiniteSpace({'a': {'a', 'c'}, 'b': {'b'}, 'c':{'a', 'c'}}) ; T
+ sage: T = FiniteSpace({'a': {'a', 'c'}, 'b': {'b'}, 'c':{'a', 'c'}})
+ sage: T # random
Finite topological space of 3 points with minimal basis
{'a': {'c', 'a'}, 'b': {'b'}, 'c': {'c', 'a'}}
+ sage: T._minimal_basis # random
+ {'a': {'c', 'a'}, 'b': {'b'}, 'c': {'c', 'a'}}
+ sage: T._minimal_basis['a'] == set(['a', 'c'])
+ True
sage: type(T)
<class 'sage.homology.finite_topological_spaces.FiniteTopologicalSpace'>
sage: FiniteSpace({'a': {'a', 'b'}})
@@ -174,7 +179,8 @@ def FiniteSpace(data, elements=None, is_T0=False):
{0: {0}, 1: {1, 2}, 2: {1, 2}, 3: {0, 3, 4}, 4: {0, 3, 4}}
sage: T.elements()
[0, 1, 2, 3, 4]
- sage: M = FiniteSpace(mat, elements=(5, 'e', 'h', 0, 'c')) ; M
+ sage: M = FiniteSpace(mat, elements=(5, 'e', 'h', 0, 'c'))
+ sage: M # random
Finite topological space of 5 points with minimal basis
{5: {5}, 'e': {'h', 'e'}, 'h': {'h', 'e'}, 0: {0, 'c', 5}, 'c': {0, 'c', 5}}
sage: M.elements()
@@ -313,7 +319,8 @@ class FiniteTopologicalSpace(Parent):
sage: minimal_basis = {'a': {3, 'a'}, 3: {3, 'a'}, 2: {2, 1}, 1: {1}}
sage: mat_dict = {(0, 0): 1, (0, 1): 1, (1, 1): 1, (2, 2): 1, \
....: (2, 3): 1, (3, 2): 1, (3, 3): 1}
- sage: T = FiniteTopologicalSpace(elements, minimal_basis, matrix(mat_dict)) ; T
+ sage: T = FiniteTopologicalSpace(elements, minimal_basis, matrix(mat_dict))
+ sage: T # random
Finite topological space of 4 points with minimal basis
{'a': {3, 'a'}, 3: {3, 'a'}, 2: {1, 2}, 1: {1}}
sage: T.topogenous_matrix() == matrix(mat_dict)
@@ -325,7 +332,7 @@ class FiniteTopologicalSpace(Parent):
self._minimal_basis = minimal_basis
self._topogenous = topogenous
- def __repr__(self):
+ def _repr_(self):
r"""
Print representation.
@@ -1012,7 +1019,7 @@ class FiniteTopologicalSpace_T0(FiniteTopologicalSpace):
self._poset = poset
self._T0 = True
- def __repr__(self):
+ def _repr_(self):
r"""
Print representation.
By the way, for classes which inherit from |
comment:15
More suggestions: diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst
index c58f1acbb9..96157140c4 100644
--- a/src/doc/en/reference/references/index.rst
+++ b/src/doc/en/reference/references/index.rst
@@ -181,6 +181,8 @@ REFERENCES:
of the Slovak Academy of Sciences. Mathematica Slovaca vol 30, n 4,
pages 405--417, 1980
+.. [Ale1937] \P. Alexandroff, *Diskrete Raume*, Mat. Sb. (N.S.) 2, 501--518 (1937).
+
.. [Al1947] \A. A. Albert, *A Structure Theory for Jordan
Algebras*. Annals of Mathematics, Second Series, Vol. 48,
No. 3 (Jul., 1947), pp. 546--567.
@@ -373,6 +375,10 @@ REFERENCES:
Four Russians'. Cryptography E-Print Archive
(http://eprint.iacr.org/2006/251.pdf), 2006.
+.. [Bar2011] \J. A. Barmak,
+ *Algebraic topology of finite topological spaces and applications*.
+ Lecture Notes in Mathematics Vol. 2032 (2011).
+
.. [Bat1991] \V. V. Batyrev, *On the classification of smooth projective
toric varieties*, Tohoku Math. J. **43** (1991), 569-585
@@ -4880,6 +4886,9 @@ REFERENCES:
*Generation of random chordal graphs using subtrees of a tree*,
:arxiv:`1810.13326v1`.
+.. [Shi1968] \M. Shiraki, *On finite topological spaces*,
+ Rep. Fac. Sci. Kagoshima Univ. 1, 1--8 (1968).
+
.. [Shi2002] \M. Shimozono
*Affine type A crystal structure on tensor products of rectangles,
Demazure characters, and nilpotent varieties*,
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 5c40fe26ce..c01c344ca2 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -7,11 +7,11 @@ A *finite topological space* is a topological space with finitely many points an
a *finite preordered set* is a finite set with a transitive and reflexive relation.
Finite spaces and finite preordered sets are basically the same objects considered
from different perspectives. Given a finite topological space `X`, for every point
-`x\in X` the *minimal open set* `U_x` as the intersection of all the open sets
+`x\in X`, define the *minimal open set* `U_x` as the intersection of all the open sets
which contain `x` (it is an open set since arbitrary intersections of open sets
in finite spaces are open). The minimal open sets constitute a basis for the topology
of `X`. Indeed, any open set `U` of `X` is the union of the sets `U_x` with `x\in U`.
-This basis is called the *minimal basis of `X`*. A preorder on `X` by `x\leqslant y`
+This basis is called the *minimal basis of* `X`. A preorder on `X` is given by `x\leqslant y`
if `x\in U_y`.
If `X` is now a finite preordered set, one can define a topology on `X` given by
@@ -20,21 +20,21 @@ then `y` is contained in every basic set containing `x`, and therefore `y\in U_x
Conversely, if `y\in U_x`, then `y\in\lbrace z\in X\vert z\leqslant x\rbrace`.
Therefore `y\leqslant x` if and only if `y\in U_x`. This shows that these two
applications, relating topologies and preorders on a finite set, are mutually
-inverse. This simple remark, made in first place by Alexandroff [1], allows us to study
+inverse. This simple remark, made in first place by Alexandroff [Ale1937]_, allows us to study
finite spaces by combining Algebraic Topology with the combinatorics arising from
their intrinsic preorder structures. The antisymmetry of a finite preorder
corresponds exactly to the `T_0` separation axiom. Recall that a topological space
-`X` is said to be *`T_0`* if for any pair of points in `X` there exists an open
+`X` is said to be `T_0` if for any pair of points in `X` there exists an open
set containing one and only one of them. Therefore finite `T_0`-spaces are in
-correspondence with finite partially ordered sets (posets) [2].
+correspondence with finite partially ordered sets (posets) [Bar2011]_.
Now, if `X = \lbrace x_1, x_2, \ldots , x_n\rbrace` is a finite space and for
each `i` the unique minimal open set containing `x_i` is denoted by `U_i`, a
-*topogenous matrix* of the space is a `n \times n` matrix `A = \left[a_{ij}\right]`
+*topogenous matrix* of the space is the `n \times n` matrix `A = \left[a_{ij}\right]`
defined by `a_{ij} = 1` if `x_i \in U_j` and `a_{ij} = 0` otherwise (this is the
-transposed matrix of the Definition 1 in [3]). A finite space `X` is `T_0` if and
+transposed matrix of the Definition 1 in [Shi1968]_). A finite space `X` is `T_0` if and
only if the topogenous matrix `A` defined above is similar (via a permutation matrix)
-to a certain upper triangular matrix [3]. This is the reason one can assume that
+to a certain upper triangular matrix [Shi1968]_. This is the reason one can assume that
the topogenous matrix of a finite `T_0`-space is upper triangular.
@@ -44,11 +44,9 @@ AUTHOR::
REFERENCES:
-- [1] Alexandroff P., *Diskrete Raume*, Mat. Sb. (N.S.) 2, 501--518 (1937).
-- [2] Barmak, J.A., *Algebraic topology of finite topological spaces and applications*.
- Lecture Notes in Mathematics Vol. 2032 (2011).
-- [3] Shiraki M., *On finite topological spaces*, Rep. Fac. Sci. Kagoshima Univ.
- 1, 1--8 (1968).
+- [Ale1937]_
+- [Bar2011]_
+- [Shi1968]_
"""
# ****************************************************************************
@@ -559,12 +564,12 @@ class FiniteTopologicalSpace(Parent):
...
ValueError: Parameter 'points' is not a valid set of representatives
"""
- if self._T0==True:
+ if self._T0 is True:
return self
else:
if points is None:
points = [list(A)[0] for A in self._T0]
- elif check==True:
+ elif check:
assert isinstance(points, (tuple, list, set)), \
"Parameter 'points' must be of type tuple, list or set"
assert len(points)==len(self._T0), \
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:17
I have fixed some failures shown in comments 14 and 15. I have added a method |
comment:18
maybe you could get rid of dict_to_matrix, used only once |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:57
Replying to @jhpalmieri:
The Trac query for tickets whose summary includes "kenzo"
which upgrades from Kenzo 1.1.9 to Kenzo 1.1.10 It got positive review in early April 2021, Other Kenzo sources seem more outdated, mentioning only Kenzo 1.1.7:
Thankfully,
|
comment:58
Replying to @slel:
See also comment:48 on this ticket for the upgrade that I think we need. |
comment:59
In any case, #31925 is ready for review, and this ticket could go in after it. |
Dependencies: #31925 |
Work Issues: Rework on top of #31925 |
comment:61
Setting a new milestone for this ticket based on a cursory review. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:64
It has been merged with ticket #31925. |
comment:65
I think there needs to be a ticket with the appropriate upgrade to Kenzo (comment:48), and this ticket should depend on that one. I think that we cannot really test this one without the Kenzo upgrade. |
comment:66
red branch => needs work |
This ticket provides a class for finite topological spaces and methods dealing with properties in general topology. It is expected to create a second ticket to add algebraic topology properties (see ticket #30447).
Principal reference: Algebraic topology of finite topological spaces and applications by Jonathan Barmak.
Depends on #31925
CC: @jhpalmieri
Component: algebraic topology
Keywords: Finite topological spaces
Work Issues: Rework on top of #31925
Author: Julián Cuevas-Rozo
Branch/Commit: u/gh-jcuevas-rozo/add_finite_topological_spaces @
3c2e0d4
Issue created by migration from https://trac.sagemath.org/ticket/30400
The text was updated successfully, but these errors were encountered: