-- Macaulay 2 code for some computations in "Critical Groups of Simplicial Complexes"
-- Macaulay2 is available at
-- http://www.math.uiuc.edu/Macaulay2/
-- This code uses the Simplicial Complexes package; see
-- http://www.math.uiuc.edu/Macaulay2/doc/Macaulay2-1.4/share/doc/Macaulay2/SimplicialComplexes/html/index.html
load"SimplicialComplexes.m2";
R=ZZ[a..f];
-- 1. Example 3.6 (critical groups of bipyramid)
Bipyramid = simplicialComplex {a*b*c, a*b*d, a*c*d, b*c*d, a*b*e, a*c*e, b*c*e};
C = chainComplex Bipyramid;
D = C.dd_1 -- boundary map from edges to vertices
L0 = C.dd_1*transpose C.dd_1 -- full updown 0-dimensional Laplacian
L0reduced = submatrix(L0, 0..3, 0..3) -- reduced Laplacian obtained by deleting vertex e
prune coker L0reduced -- this computes the critical group K_0; result is Z/15 + Z/5
-- 2. Example 4.8 (two 2-spheres with same f-vector but different K_0)
Octahedron = simplicialComplex {a*c*e,a*c*f,a*d*e,a*d*f,b*c*e,b*c*f,b*d*e,b*d*f}
C = chainComplex Octahedron
L0 = C.dd_1*transpose C.dd_1
L0reduced = submatrix(L0, 0..4, 0..4) -- reduced Laplacian obtained by deleting vertex f
prune coker L0reduced -- this computes the critical group K_0; result is Z/24 + Z/8 + Z/2
OtherSphere = simplicialComplex {a*c*e,a*c*f,a*d*e,a*d*f,b*c*e,b*c*f,b*e*f,d*e*f}
-- obtained from octahedron by bistellar flip replacing bde,bdf with bef,def
C = chainComplex OtherSphere
L0 = C.dd_1*transpose C.dd_1 -- updown Laplacian
L0reduced = submatrix(L0, 0..4, 0..4) -- reduced Laplacian
prune coker L0reduced -- this computes the critical group K_0; result is Z/336
-- 3. An example of Thm. 4.9 (critical groups of skeletons of simplices)
X = simplicialComplex{a*b*c*d*e*f}; -- simplex on 6 vertices
C = chainComplex X;
L1 = C.dd_2 * transpose C.dd_2;
prune coker L1 -- this computes K_1(X) = (Z/6Z)^6
L2 = C.dd_3 * transpose C.dd_3;
prune coker L2 -- this computes K_2(X) = (Z/6Z)^4
-- 4. Demonstration that the "torsion-free" condition is necessary in the main Thm. 3.4
-- Let Upsilon1 = star of vertex 1; this is a torsion-free spanning tree.
-- Macaulay orders the facets of X lexicographically, so Upsilon1 consists
-- of the first ten facets
Remove1 = 10..19; -- indices of non-faces of Upsilon1
LStar = submatrix(L2, Remove1, Remove1) -- reduced Laplacian \tilde{L}
prune coker LStar -- this produces (Z/6Z)^4 = K_2(X) (see above)
-- Let Upsilon2 = subcomplex generated by facets abc,abe,acd,adf,aef,bcf,bde,bdf,cde,cef
-- This is a triangulation of RP^2, hence a non-torsion-free spanning tree of X.
Remove2 = (1,3,5,6,7,10,11,15,17,19); -- faces not containing vertex 1
LRP2 = submatrix(L2, Remove2, Remove2) -- reduced Laplacian \tilde{L}
prune coker LRP2 -- this produces Z/12 + (Z/6Z)^3 + (Z/2Z) <> K_2(X).