ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 30 Nov 2012 11:41:50 +0100Dual Cells and Face Posethttps://ask.sagemath.org/question/9578/dual-cells-and-face-poset/Hello.
I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.
My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.
Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.
How can I correct this?
Thanks,
Chris .Wed, 28 Nov 2012 08:49:45 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/Comment by John Palmieri for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?comment=18630#post-id-18630What if you define the poset using 'facade=True'?Wed, 28 Nov 2012 20:01:33 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?comment=18630#post-id-18630Answer by John Palmieri for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14328#post-id-14328If I use your code with K being a 2-simplex, it seems to work (unless I misunderstand what the dual cell is):
sage: X = simplicial_complexes.Simplex(2)
sage: find_dual_cell(X, Simplex(X.vertices()[0]))
Simplicial complex with 4 vertices and 2 facets
sage: Y = find_dual_cell(X, Simplex(X.vertices()[0]))
sage: Y.facets()
{((0,), (0, 1, 2), (0, 2)), ((0,), (0, 1), (0, 1, 2))}
or
sage: Y = find_dual_cell(X, Simplex([0]))
sage: Y.facets()
{((0,), (0, 1, 2), (0, 2)), ((0,), (0, 1), (0, 1, 2))}
It also seems to work if K is $S^1$ or $S^2$. If I try it with a 3-sphere, I get this:
sage: X = simplicial_complexes.Sphere(3)
sage: Y = find_dual_cell(X, Simplex(X.vertices()[0]))
sage: Y
Simplicial complex with 15 vertices and 24 facets
Is this wrong? What sort of answer are you expecting?Fri, 30 Nov 2012 00:45:38 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14328#post-id-14328Answer by DG44 for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14323#post-id-14323Thank you for your suggestion.
I only actually want to find the dual cells of vertices. I added the code "facade = True" to the existing algorithm which finds the face poset of a simplicial complex K (a warning for below- I have not done much programming before)
def find_face_poset(K):
from sage.combinat.posets.posets import Poset
from sage.misc.flatten import flatten
covers = {}
all_cells = flatten([list(f) for f in K.cells().values()])
for C in all_cells:
if C.dimension() >= 0:
covers[tuple(C)] = []
for C in all_cells:
for face in C.faces():
if face.dimension() >= 0:
covers[tuple(face)].append(tuple(C))
return Poset(covers, facade = True)
I also created an algorithm to find the cofaces of a simplex $\sigma \in K$:
def find_cofaces(K, sigma):
m = sigma.dimension()
cofaces = []
cofaces.append(sigma)
for i in range(m+1, K.dimension()+1):
i_faces = K.n_faces(i)
for tau in i_faces:
if sigma.is_face(tau):
if tau.dimension() == i :
cofaces.append(tau)
else:
pass
else:
pass
return cofaces
and also an algorithm to find the dual cell of a vertex $\sigma$:
def find_dual_cell(K, sigma):
face_poset = find_face_poset(K)
maximal_chains = face_poset.maximal_chains()
dual_cell_vertices = find_cofaces(K, sigma)
dual_cell_facets = []
for tau in maximal_chains:
if sigma.tuple() == tau[0]:
dual_cell_facets.append(tau)
else:
pass
return SimplicialComplex(dual_cell_vertices, dual_cell_facets)
I played around with the example
K = simplicial_complexes.Sphere(3)
for sigma in K.n_faces(0):
find_dual_cell(K, sigma)
When I get Sage to print dual_cell_vertices and dual_cell_facets (instead of returning SimplicialComplex(dual_cell_vertices, dual_cell_facets)), it seems to produce a correct result. But it never produces the correct simplicial complex! It gives me
Simplicial complex with vertex set (0, 1, 2, 3, 4) and 4 facets
Any help would be very much appreciated!
Thu, 29 Nov 2012 05:55:37 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14323#post-id-14323Answer by DG44 for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14330#post-id-14330This is completely the correct answer! How frustrating for me! When I try to run the example (on my Macbook Pro with Sage 5.4.1 and OS X 10.8.2)
sage: X = simplicial_complexes.Simplex(2)
sage: find_dual_cell(X, Simplex(X.vertices()[0]))
I get the error
sage: Traceback (click to the left of this block for traceback)...
sage: ValueError: The face ((0,), (0, 2), (0, 1, 2)) is not a subset of the vertex set.
I have created a worksheet at http://www.sagenb.org/home/pub/5038 that contains all of the above code (edit: public worksheets are currently disabled) . It still produces the same error!Fri, 30 Nov 2012 05:40:37 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14330#post-id-14330Answer by John Palmieri for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14331#post-id-14331Okay, try this: change the last line of `find_dual_cell` to
return SimplicialComplex(dual_cell_facets)
It's always an option to create a simplicial complex without specifying the vertex set it is then deduced from the list of facets and in fact this will become the preferred way of doing things some time soon (after the patches [here](http://trac.sagemath.org/sage_trac/ticket/12587) are merged). Anyway, with your original code, I get an error with Sage 5.4 (but not with a prerelease of Sage 5.5, which includes the relevant patches). By modifying that one line, it seems to work in Sage 5.4 as well.
- I guess then you can delete the function `find_cofaces` and the one call to it in `find_dual_cell`.
- I don't have the time to figure out why your original code fails, but at least I think we have a fix.
- Would it help to be able to do `sage: K.face_poset(options...)` with `options` including `facade=True`? That would be an easy thing to add to Sage.Fri, 30 Nov 2012 10:53:47 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14331#post-id-14331Answer by DG44 for <p>Hello.</p>
<p>I would like to create a procedure in Sage to find the dual cell of a simplex $\sigma$ in a simplicial complex $K$. The dual cell $D(\sigma, K)$ of $\sigma$ is a subcomplex of the first barycentric subdivision of $K$. The vertex set is given by the barycentres of all cofaces of $\sigma$, and the simplices are joins of barycentres of the form $\widehat{\sigma_0} \widehat{\sigma_1} ... \widehat{\sigma_s}$ with $\sigma \leq \sigma_0 \leq ... \leq \sigma_s$.</p>
<p>My plan of attack is to view K as a poset, then find the maximal increasing chains $[\sigma_0,..., \sigma_s]$ in K which satisfy $\sigma_0 = \sigma$ . These chains would then be the maximal faces of the dual cell $D(\sigma, K)$.</p>
<p>Creating the poset and finding the maximal chains of simplices is fine. However, if I have a maximal chain $[\sigma_0,..., \sigma_s]$ a problem occurs when checking if $\sigma_0 = \sigma$ - Sage sees $\sigma_0$ as just an element of the poset and not as simplex and $\sigma$ as a simplex but not an element of the poset so the equality is never satisfied.</p>
<p>How can I correct this?</p>
<p>Thanks,
Chris .</p>
https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14332#post-id-14332Thank you! Problem solved :). I think it would be helpful to do
sage: K.face_poset(options...)
with options including facade=True in Sage.Fri, 30 Nov 2012 11:41:50 +0100https://ask.sagemath.org/question/9578/dual-cells-and-face-poset/?answer=14332#post-id-14332