# Obtaining a simplicial complex associated to a poset with the help of Sage

I want to associate to a finite poset a simplicial complex $\Delta(P)$ and study the homology(with coefficients in the rational numbers or a finite field) and the topological type of this simplicial complex using Sage. I have not yet used sage for this and wanted to ask whether there is an easy method to do this.

Let $P$ be a a finite poset with at least two elements and for $p \in P$ define two subsets as follows:

$J(p):=$ { $g \in P | p \nleq g$ } and $I(p):=$ { $g \in P | g \leq p$ }.

For a subset $S$ of $P$ (we view $P$ also as set of its vertices) we then define

$J(S):= \bigcap\limits_{p \in S}^{}{J(p)}$ and $I(S):= \bigcup\limits_{p \in S}^{}{I(p)}$.

We set $J( \emptyset)=P, J(P)=\emptyset$ and $I(\emptyset)=\emptyset$, $I(P)=P$.

Then the simplicial complex $\Delta(P)$ is defined as the set of all subsets $S \subseteq P$ with $J(S^c) \subseteq I(S^c)$, where fore a subset $S \subseteq P$ we denote by $S^c$ the complement of $S$ in $P$.

For example when the poset $P$ is a chain with $n$-elements then $\Delta(P)$ should have topological type of the $(n-2)$-sphere.

I can obtain the sets $J(p)$ and $I(p)$ for elements but not for subsets in Sage, but I would think there is an easy trick.

Here is an example in Sage for a given poset $P$ :

P=posets.BooleanLattice(2)

display(P)

p=P[2]

I=[u for u in P if P.is_lequal(u,p)]

J=[u for u in P if not P.is_lequal(p,u)]

display(I)

display(J)


Thanks for any help.

edit retag close merge delete

Please add the code you have so far, with an example $P$.

( 2020-10-07 09:57:31 +0200 )edit

I added a small example for the Boolean lattice on how to obtain $J(p)$ and $I(p)$.

( 2020-10-07 10:09:56 +0200 )edit

Sort by » oldest newest most voted

something like this maybe (not tested)

def test_subset(P, S):
Sc = set(g for g in P if g not in S)
in_ISc = lambda g: any(s in Sc for s in P.principal_order_filter(g))
JSc = (g for g in P if not any(s in Sc
for s in P.principal_order_ideal(g)))
return all(in_ISc(g) for g in JSc)

more

Thank you very much, but it seems to not work for every subset. For example here it works:

def test_subset(P, S):
Sc = set(g for g in P if g not in S)
in_ISc = lambda g: any(s in Sc for s in P.principal_order_filter(g))
Jsc = (g for g in P if not any(s in Sc
for s in P.principal_order_ideal(g)))
return all(in_Isc(g) for g in Jsc)

P=posets.BooleanLattice(2)
U = Subsets(P)
T=U[2]
display(T)
test_subset(P, T)


but for the same poset P with another subset it does not work and gives an error (see next comment)

( 2020-10-07 13:32:19 +0200 )edit

Here it gives an error:

def test_subset(P, S):
Sc = set(g for g in P if g not in S)
in_ISc = lambda g: any(s in Sc for s in P.principal_order_filter(g))
Jsc = (g for g in P if not any(s in Sc
for s in P.principal_order_ideal(g)))
return all(in_Isc(g) for g in Jsc)

P=posets.BooleanLattice(2)
U = Subsets(P)
T=U[1]
display(T)
test_subset(P, T)

( 2020-10-07 13:32:31 +0200 )edit

There was a typo "Isc" versus ISc.

( 2020-10-07 15:26:56 +0200 )edit

Thank you very much again. It seems to work now. I combined it and obtained the simplicial complex as follows:

def test_subset(P, S):
Sc = set(g for g in P if g not in S)
in_ISc = lambda g: any(s in Sc for s in P.principal_order_filter(g))
JSc = (g for g in P if not any(s in Sc
for s in P.principal_order_ideal(g)))
return all(in_ISc(g) for g in JSc)

P=posets.ChainPoset(4)
P=P.relabel()
U = Subsets(P)
G=[t for t in U if test_subset(P, t)==true]
GG=[list(r) for r in G]
display(GG)
S=SimplicialComplex(GG)
display(S)
phi, M = S.algebraic_topological_model(QQ)
M.homology()

( 2020-10-07 16:40:38 +0200 )edit

Do you know whether I calcuate the homology the right way over the rational numbers QQ? It seems I have to use the strange command

phi, M = S.algebraic_topological_model(QQ)


and I do not quite know why I need to write the phi before the M.

Also do you know whether there is a command to check whether the simplicial complex is topologically homeomorphic to a sphere?

( 2020-10-07 16:41:55 +0200 )edit