Skip to content
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

Complexes PR #2: changes to a first set of packages #3479

Merged
merged 9 commits into from
Sep 30, 2024
28 changes: 14 additions & 14 deletions M2/Macaulay2/packages/CellularResolutions.m2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export {--types
"cellLabel",
"hullComplex",
"isCycle",
"isFree",
-- "isFree",
"isMinimal",
"isSimplex",
"newCell",
Expand All @@ -42,8 +42,8 @@ export {--types
"CellDimension",
"InferLabels",
"LabelRing",
"Reduced",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantically speaking, removing the comma here is not necessary since export silently ignores null entries.

"Prune"
"Reduced"
--"Prune"
}
protect labelRing
protect label
Expand Down Expand Up @@ -418,17 +418,17 @@ boundaryMap(ZZ,CellComplex) := opts -> (r,cellComplex) -> (
sparseBlockMap(codomain,domain,new HashTable from L)
);

chainComplex(CellComplex) := {Reduced=>true, Prune=>true} >> o -> (cellComplex) -> (
if not cellComplex.cache.?chainComplex then (
cellComplex.cache.chainComplex =
(chainComplex apply(max((dim cellComplex) + 1,1), r -> boundaryMap(r,cellComplex)))[1]
complex(CellComplex) := {Reduced=>true, Prune=>true} >> o -> (cellComplex) -> (
if not cellComplex.cache.?complex then (
cellComplex.cache.complex =
(complex apply(max((dim cellComplex) + 1,1), r -> boundaryMap(r,cellComplex)))[1]
);
ret := if not o.Reduced then (
Ccopy := chainComplex apply(max cellComplex.cache.chainComplex,
i -> cellComplex.cache.chainComplex.dd_(i+1));
Ccopy := complex apply(max cellComplex.cache.complex,
i -> cellComplex.cache.complex.dd_(i+1));
Ccopy
)
else cellComplex.cache.chainComplex;
else cellComplex.cache.complex;
if o.Prune then (
prune ret --how expensive is prune? should it be cached?
)
Expand All @@ -437,16 +437,16 @@ chainComplex(CellComplex) := {Reduced=>true, Prune=>true} >> o -> (cellComplex)

--Get homology directly from cell complex
homology(ZZ,CellComplex) := opts -> (i,cellComplex) -> (
homology_i chainComplex(cellComplex)
homology_i complex(cellComplex)
);

homology(CellComplex) := opts -> (cellComplex) -> (
homology chainComplex(cellComplex)
homology complex(cellComplex)
);

--Get cohomology directly from cell complex
cohomology(ZZ,CellComplex) := opts -> (i,cellComplex) -> (
cohomology_i Hom(chainComplex(cellComplex),cellComplex.labelRing^1)
cohomology_i Hom(complex(cellComplex),cellComplex.labelRing^1)
);

----------
Expand Down Expand Up @@ -516,7 +516,7 @@ facePoset(CellComplex) := (cellComplex) -> (
-- Minimality
-------------

isFree = method(TypicalValue => Boolean);
--isFree = method(TypicalValue => Boolean);
--check if all the labels are free modules
isFree(CellComplex) := (cellComplex) -> (
R := cellComplex.labelRing;
Expand Down
50 changes: 24 additions & 26 deletions M2/Macaulay2/packages/CellularResolutions/doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ doc ///
This class represents a single cell in a cell complex. A cell has
a boundary, a dimension, and a label. In most cases, the label should
be a monomial. But the cells in this package may be anything.
However for functions such as @TO chainComplex@ to work, the labels
However for functions such as @TO complex@ to work, the labels
should be either monomials, ideals, or modules.
In the monomial case, we can view the label as a module by taking
the submodule generated by the monomial in the ring. There should be
Expand Down Expand Up @@ -541,21 +541,20 @@ doc ///
d2 = boundaryMap_2 C
assert(d1*d2==0)
SeeAlso
(chainComplex,CellComplex)
(chainComplex,SimplicialComplex)
(complex,CellComplex)
(complex,SimplicialComplex)
///

doc ///
Key
(chainComplex,CellComplex)
(complex,CellComplex)
Reduced
[(chainComplex,CellComplex),Reduced]
Prune
[(chainComplex,CellComplex),Prune]
[(complex,CellComplex),Reduced]
[(complex,CellComplex),Prune]
Headline
compute the cellular chain complex for a cell complex
Usage
chainComplex C
complex C
Inputs
C : CellComplex
the cell complex for which to compute the chain complex
Expand All @@ -564,7 +563,7 @@ doc ///
Prune => Boolean
that controls whether the modules in the chain complex are pruned
Outputs
: ChainComplex
: Complex
the dimension of the complex
Description
Text
Expand All @@ -573,15 +572,15 @@ doc ///
cell complex will be a complex of modules over the ring
associated to the cell complex.
By default, the option "Reduced" is set to true, so
the resulting ChainComplex has a rank 1 free module in homological degree -1.
the resulting Complex has a rank 1 free module in homological degree -1.
Example
R = QQ[x]
a = newSimplexCell({},x);
b1 = newCell {a,a};
b2 = newCell {a,a};
C = cellComplex(R,{b1,b2});
chainComplex C
chainComplex(C,Reduced=>false)
complex C
complex(C,Reduced=>false)
Text
For details see Combinatorial Commutative Algebra Section 4.1.
If we restrict to the case of monomial labels, then, subject to
Expand All @@ -601,8 +600,8 @@ doc ///
eyz = newSimplexCell({vy,vz});
f = newSimplexCell({exy,exz,eyz});
C = cellComplex(R,{f});
betti chainComplex(C)[-1]
assert(betti chainComplex(C)[-1] == betti res I);
betti complex(C)[-1]
assert(betti complex(C)[-1] == betti res I);
Text
The option "Prune," also defaulted to true, controls whether the modules in the complex
are pruned before being returned. With the "Prune" option set to the default of true,
Expand All @@ -614,11 +613,11 @@ doc ///
b = newSimplexCell({},y);
e = newCell {a,b};
C = cellComplex(R,{e});
chainComplex C
chainComplex(C,Prune=>false)
complex C
complex(C,Prune=>false)
SeeAlso
(boundaryMap,ZZ,CellComplex)
(chainComplex,SimplicialComplex)
(complex,SimplicialComplex)
(homology,CellComplex)
(homology,ZZ,CellComplex)
(cohomology,ZZ,CellComplex)
Expand Down Expand Up @@ -664,7 +663,7 @@ doc ///
prune oo
SeeAlso
(homology,ZZ,CellComplex)
(chainComplex,CellComplex)
(complex,CellComplex)
///

doc ///
Expand Down Expand Up @@ -712,7 +711,7 @@ doc ///
SeeAlso
(homology,CellComplex)
(cohomology,ZZ,CellComplex)
(chainComplex,CellComplex)
(complex,CellComplex)
///

doc ///
Expand Down Expand Up @@ -756,7 +755,7 @@ doc ///
SeeAlso
(homology,CellComplex)
(homology,ZZ,CellComplex)
(chainComplex,CellComplex)
(complex,CellComplex)
///

doc ///
Expand Down Expand Up @@ -920,7 +919,6 @@ doc ///

doc ///
Key
isFree
(isFree,CellComplex)
Headline
checks if the labels of a cell complex are free modules
Expand Down Expand Up @@ -1134,7 +1132,7 @@ doc ///
Example
S = cellComplexSphere(QQ,3)
cells(S)
chainComplex S
complex S
prune homology S
SeeAlso
cellComplexRPn
Expand Down Expand Up @@ -1238,12 +1236,12 @@ doc ///
S = QQ[x,y,z];
I = monomialIdeal (x^2*z, x*y*z, y^2*z, x^3*y^5, x^4*y^4, x^5*y^3);
H = hullComplex I
chainComplex H
complex H
cells(1,H)/cellLabel
cells(2,H)/cellLabel
isMinimal H
H2 = hullComplex (3/2,I)
prune HH chainComplex H2
prune HH complex H2
SeeAlso
(taylorComplex,MonomialIdeal)
///
Expand Down Expand Up @@ -1271,7 +1269,7 @@ doc ///
S = QQ[x,y,z];
I = monomialIdeal (x^2, y^2, z^2);
T = taylorComplex I
C = chainComplex T
C = complex T
C.dd
SeeAlso
(hullComplex,MonomialIdeal)
Expand Down Expand Up @@ -1300,7 +1298,7 @@ doc ///
S = QQ[x,y,z];
I = monomialIdeal (x^2*z, x*y*z, y^2*z, x^3*y^5, x^4*y^4, x^5*y^3);
C = scarfComplex I
chainComplex C
complex C
cells(1,C)/cellLabel
cells(2,C)/cellLabel
isMinimal C
Expand Down
58 changes: 29 additions & 29 deletions M2/Macaulay2/packages/CellularResolutions/tests.m2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ assert(isWellDefined e);
assert(dim e === -infinity);
assert(#maxCells e == 0);
assert(#maxCells skeleton(0,e) == 0);
chainComplex e;
complex e;
///


Expand All @@ -27,10 +27,10 @@ assert(l1=!=l2);
assert(dim l1==1);
assert(dim l2==1);
C = cellComplex(QQ,{l1,l2});
CchainComplex = chainComplex C;
Copy link
Member

@mahrud mahrud Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point: I think some of the changed lines here aren't necessary since CchainComplex is just a variable, and since C is a (cell) complex having "chain" in the variable name doesn't hurt.

assert(HH_0(CchainComplex)==0);
assert(prune HH_1(CchainComplex)==QQ^1);
assert(HH_2(CchainComplex)==0);
Ccomplex = complex C;
assert(HH_0(Ccomplex)==0);
assert(prune HH_1(Ccomplex)==QQ^1);
assert(HH_2(Ccomplex)==0);
f1 = newCell {l1,l2};
C = cellComplex(QQ,{f1});
assert(dim C==2);
Expand All @@ -48,11 +48,11 @@ assert(rank source del2 == 1);
assert(rank target del2 == 2);
assert(rank del2 == 1);
assert(del100 == map(QQ^0,QQ^0,{}));
CchainComplex = chainComplex C;
assert(HH_0(CchainComplex)==0);
assert(HH_1(CchainComplex)==0);
assert(HH_2(CchainComplex)==0);
assert(HH C == HH CchainComplex);
Ccomplex = complex C;
assert(HH_0(Ccomplex)==0);
assert(HH_1(Ccomplex)==0);
assert(HH_2(Ccomplex)==0);
assert(HH C == HH Ccomplex);
assert(isFree(C));
///

Expand All @@ -63,11 +63,11 @@ l = newCell {v,v};
f = newCell {(l,1),(l,1)};
C = cellComplex(ZZ,{f});
assert(dim C===2);
prune HH chainComplex C
prune HH complex C
assert(HH_0 C == 0);
assert(homology(0,chainComplex(C,Reduced=>false))==ZZ^1);
assert(homology(1,chainComplex(C,Reduced=>false))==ZZ^1/(2*ZZ^1));
assert(HH_1 chainComplex C == cokernel matrix {{2}})
assert(homology(0,complex(C,Reduced=>false))==ZZ^1);
assert(homology(1,complex(C,Reduced=>false))==ZZ^1/(2*ZZ^1));
assert(HH_1 complex C == cokernel matrix {{2}})
assert(HH^2 C == cokernel matrix {{2}});
assert(HH^1 C == 0);
assert(dim skeleton_1 C == 1);
Expand All @@ -82,11 +82,11 @@ assert(dim D == 1);
assert(isSimplex a);
assert(not isSimplex b1);
assert(not isSimplex b2);
DchainComplex = chainComplex D;
assert(HH_0(DchainComplex)==0);
Dcomplex = complex D;
assert(HH_0(Dcomplex)==0);
R = ring D;
assert(prune HH_1(DchainComplex)==R^2);
assert(HH_2(DchainComplex)==0);
assert(prune HH_1(Dcomplex)==R^2);
assert(HH_2(Dcomplex)==0);
///


Expand Down Expand Up @@ -133,7 +133,7 @@ lxz = newSimplexCell({vx,vz});
fxyz = newSimplexCell({lxy,lyz,lxz});
assert(cellLabel fxyz === x*y*z);
D = cellComplex(R,{fxyz});
C = (chainComplex D);
C = (complex D);
assert(HH_(-1)(C)==cokernel matrix {{x,y,z}});
assert(C.dd^2==0);
assert(degrees C_0 == {{1}, {1}, {1}});
Expand All @@ -150,7 +150,7 @@ lyz = newSimplexCell({vy,vz});
lxz = newSimplexCell({vx,vz});
fxyz = newSimplexCell({lxy,lyz,lxz});
D = cellComplex(R,{fxyz});
C = (chainComplex D)[-1];
C = (complex D)[-1];
assert(HH_0(C)==R^1/module ideal(x,y,z))
assert(HH_1(C)==0)
assert(C.dd^2==0);
Expand All @@ -167,7 +167,7 @@ lyz = newSimplexCell {vy,vz};
lxz = newSimplexCell {vx,vz};
fxyz = newSimplexCell {lxy,lyz,lxz};
D = cellComplex(R,{fxyz});
C = (chainComplex D)[-1];
C = (complex D)[-1];
assert(C.dd^2==0);
assert(not isFree(D));
///
Expand Down Expand Up @@ -210,7 +210,7 @@ assert(# cells(3,C)==1);
assert(HH_1(C)==0);
assert(HH_2(C)==0);
assert(HH_3(C)==0);
assert((chainComplex C).dd^2==0);
assert((complex C).dd^2==0);
C1 = skeleton(1,C);
assert(dim C1 == 1);
assert(rank HH_1 C1 == 5);
Expand Down Expand Up @@ -353,7 +353,7 @@ C = cellComplex(R,P);
S = ZZ[x];
f = map(S,R,{});
D = f**C;
chainD = chainComplex D;
chainD = complex D;
assert(ring chainD === S);
assert(HH_1(D)==0);
assert(HH_2(D)==0);
Expand Down Expand Up @@ -432,7 +432,7 @@ e23 = newCell({v2,v3});
e14 = newCell({v1,v4});
f123 = newCell({e12,e13,e23});
Delta = cellComplex(S, {f123,e14});
C = chainComplex Delta;
C = complex Delta;
assert (dim Delta == 2);
assert (length C == 3);
///
Expand Down Expand Up @@ -471,7 +471,7 @@ m = product(apply(numgens S, i -> S_i));
G = apply(max X, l -> m//product(apply(l,i -> S_i)));
H = hashTable apply(#G, i -> (j := F#i#0#0;((vertices P)_j,G_i)))
C = cellComplex(S,P,Labels => H);
Cres = (chainComplex C)[-1];
Cres = (complex C)[-1];
assert(betti (res B) == betti Cres);
assert(HH_0 Cres == S^1/B);
assert(HH_1 Cres == 0);
Expand All @@ -484,12 +484,12 @@ TEST ///
R = QQ[x,y,z];
I = monomialIdeal (x^2*z, x*y*z, y^2*z, x^3*y^5, x^4*y^4, x^5*y^3);
H = hullComplex I;
chainComplex H;
complex H;
assert(isMinimal H);
assert(HH_(-1) chainComplex H == R^1/I);
assert((HH_0 chainComplex H)==0);
assert(HH_(-1) complex H == R^1/I);
assert((HH_0 complex H)==0);
H2 = hullComplex (3/2,I)
assert((HH_0 chainComplex H2)!=0);
assert((HH_0 complex H2)!=0);
///

--isWellDefined test
Expand Down
Loading
Loading