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

I want to associate to a finite poset ~~$P$ ~~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.