-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCriticalGroups.m2
368 lines (322 loc) · 10.1 KB
/
CriticalGroups.m2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
newPackage(
"CriticalGroups",
AuxiliaryFiles => false,
Version => "0.1",
Date => "",
Keywords => {"Combinatorics"},
Authors => {
{Name => "Ayah Almousa",
Email => "[email protected]",
HomePage => "http://sites.google.com/view/ayah-almousa"}
},
Headline => "functions for investigating critical groups of simplicial complexes",
PackageExports => {
"SimplicialComplexes",
"SimplicialDecomposability",
"Posets",
},
DebuggingMode => true
)
export{
-- ++ means tested
"combinatorialLaplacian", --documented ++
"listLaplacians", --documented
"invariantFactors", --docmented ++
"shiftedComplex", --documented ++
"reducedLaplacianShifted", --documented ++
"galePoset"
}
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- **CODE** --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-------------------------------------------
-- ** Part 1 : Combinatorial Laplacians **
-------------------------------------------
combinatorialLaplacian = method()
combinatorialLaplacian(SimplicialComplex,ZZ) := Matrix => (Delta,k) -> (
C := chainComplex Delta;
dk := C.dd_k;
dk*transpose(dk)
)
listLaplacians = method()
listLaplacians(SimplicialComplex) := List => D -> (
apply((dim D)+1, i-> combinatorialLaplacian(D,i))
)
invariantFactors = method()
invariantFactors SimplicialComplex := List => Delta -> (
L := combinatorialLaplacian(Delta, dim Delta);
M := (smithNormalForm(L, KeepZeroes => false))_0;
toList eigenvalues M
)
--isSpanningTree
-----------------------------------
-- ** Part 2: Shifted complexes **
-----------------------------------
cmp := (a,b) -> (
entryCompare := for i from 0 to #a-1 list (a_i <= b_i);
entryCompare == toList(#a:true)
)
galePoset = method()
galePoset(ZZ,ZZ) := Poset => (n,m) -> (
coords := subsets(m,n);
shiftedCoords := apply(coords, i-> i+toList(n:1));
poset(shiftedCoords, cmp)
)
shiftedComplex = method(
Options => {
CoefficientRing => ZZ,
Variable => getSymbol "x"
}
)
shiftedComplex List := o -> L -> (
--lazy order ideal, make efficient later
if (#(unique apply(L, i->#i)) != 1) then error("the generating facets should be the same dimension");
d := #(L_0);
maxElt := max flatten L;
P := galePoset(d,maxElt);
facetGens := orderIdeal(P,L);
--construct simplicial complex
kk := o.CoefficientRing;
x := o.Variable;
indets := apply(1..maxElt, i-> x_i);
S := kk[indets, DegreeRank => #indets];
varHash := hashTable apply(S_*, v-> last baseName v => v);
facetList := apply(facetGens, i-> product(apply(i, j-> varHash#j)));
simplicialComplex facetList
)
reducedLaplacianShifted = method()
reducedLaplacianShifted List := Matrix => L -> (
D := shiftedComplex L;
Lap := combinatorialLaplacian(D, dim D);
ridgeList := faces( (dim D)-1, D);
pos := positions(ridgeList, i-> (degree i)_0 == 1);
submatrix'(Lap,pos,pos)
);
-------------------------------------------------
-- ** Part 3: Potential statistics to study**
------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- **DOCUMENTATION** --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
beginDocumentation()
doc ///
Key
CriticalGroups
Headline
critical groups for simplicial complexes
Description
Text
This package provides functions for constructing and investigating critical groups
and combinatorial Laplacians for simplicial complexes. It contains functions
for exploring combinatorial Laplacians for shifted complexes and independence complexes of Schubert matroids.
Text
@UL {
{"[Kli18] Klivans, Caroline (2018). The mathematics of chip-firing (1st ed.). Chapman and Hall/CRC."}
}@
///
doc ///
Key
combinatorialLaplacian
(combinatorialLaplacian, SimplicialComplex, ZZ)
Headline
combinatorial Laplacian of a simplicial complex
Usage
combinatorialLaplacian(D,k)
Inputs
D:SimplicialComplex
k:ZZ
Outputs
:Matrix
Description
Text
Given a simplicial complex $\Delta$ and an integer $k$ which is less than or equal to the dimension
of $\Delta$, outputs the $k$'th combinatorial Laplacian for $\Delta$.
Example
S = ZZ[a..d];
D = simplicialComplex {a*b*c,a*b*d,a*c*d,b*c*d}
combinatorialLaplacian(D,2)
///
doc ///
Key
listLaplacians
(listLaplacians, SimplicialComplex)
Headline
list all combinatorial Laplacians of a simplicial complex
Usage
listLaplacians D
Inputs
D:SimplicialComplex
Outputs
:List
Description
Text
Given a simplicial complex $\Delta$ and an integer $k$ which is less than or equal to the dimension
of $\Delta$, outputs a list of all combinatorial Laplacians for $\Delta$.
Example
S = ZZ[a..d];
D = simplicialComplex {a*b*c,a*b*d,a*c*d,b*c*d}
listLaplacians D
///
doc ///
Key
invariantFactors
(invariantFactors, SimplicialComplex)
Headline
invariant factors of a simplicial complex
Usage
invariantFactors D
Inputs
D:SimplicialComplex
Outputs
:List
Description
Text
Given a simplicial complex $\Delta$, outputs the invariant factors for $\Delta$.
Example
S = ZZ[a..d];
D = simplicialComplex {a*b*c,a*b*d,a*c*d,b*c*d}
invariantFactors D
///
doc ///
Key
shiftedComplex
(shiftedComplex, List)
Headline
shifted complex generated by a set of facets
Usage
shiftedComplex L
Inputs
L:List
Outputs
:SimplicialComplex
Description
Text
Given a list of indices, outputs the smallest shifted simplicial complex
containing those facets.
Example
shiftedComplex {{2,3,4}}
shiftedComplex {{1,3,5},{2,3,4}}
///
doc ///
Key
reducedLaplacianShifted
(reducedLaplacianShifted, List)
Headline
reduced Laplacian for a shifted complex
Usage
reducedLaplacian L
Inputs
L:List
Outputs
:Matrix
Description
Text
Given a list of indices $L$, outputs the reduced Laplacian for the shifted complex
with generators in $L$. The spanning tree that is used to reduce the Laplacian
is the one corresponding to all codimension $1$ faces containing the vertex labeled $1$.
Example
L = {{2,4,5}};
reducedLaplacianShifted L
(smithNormalForm oo)_0
tally invariantFactors shiftedComplex L
///
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- **TESTS** --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TEST ///
--boundary of tetrahedron
S = ZZ[a..d];
D = simplicialComplex({a*b*c,a*b*d,a*c*d,b*c*d})
M = matrix{
{3,-1,-1,-1},
{-1,3,-1,-1},
{-1,-1,3,-1},
{-1,-1,-1,3}
};
assert(combinatorialLaplacian(D,1) == M)
assert(sort invariantFactors(D) == {1,1,4})
///
TEST ///
--build boundary of tetrahedron as a shifted complex
D = shiftedComplex {{2,3,4}};
S = ring D;
assert(simplicialComplex(apply(subsets(S_*,3), i-> product i)) === D)
///
TEST ///
--testing reducedLaplacianShifted
L = {{2,4,5,7}};
redLap = reducedLaplacianShifted L;
L1 = toList eigenvalues (smithNormalForm oo)_0;
L2 = invariantFactors shiftedComplex L;
assert(L1 == L2)
///
end---------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- **SCRATCH SPACE** --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--------------------------------
--------------------------------
-- **EXAMPLES / CODE DEMO** --
--------------------------------
--------------------------------
EXAMPLE \\\
--tetrahedron
D = shiftedComplex {{2,3,4}} --tetrahedron
L = listLaplacians D
invariantFactors D
--lists
printingAccuracy = 1 --for rounding the eigenvalues to integers
apply(L, i-> sort toList eigenvalues i) --list eigenvalues for all the Laplacians
--
\\\
EXAMPLE \\\
--Other example from Carly's write-up
D = shiftedComplex {{3,4,6}}
L = listLaplacians D
printingAccuracy = 1 --for rounding the eigenvalues to integers
apply(L, i-> sort toList eigenvalues i)
invariantFactors D
\\\
EXAMPLE \\\
--a shifted complex which is not a shifted matroid
D = shiftedComplex {{1,3,5},{2,3,4}}
L = listLaplacians D
printingAccuracy = 1 --for rounding the eigenvalues to integers
apply(L, i-> sort toList eigenvalues i)
invariantFactors D
\\\
EXAMPLE \\\
--using the reducedLaplacianShifted function
L = {{2,4,5}};
reducedLaplacianShifted L
(smithNormalForm oo)_0
tally invariantFactors shiftedComplex L
\\\
------------------------------
--Ayah's sandbox
------------------------------
L = apply(subsets(9,3), i-> i+{1,1,1});
IFs = apply(L, i-> tally invariantFactors shiftedComplex {i});
netList transpose{L, IFs}
apply(6, i-> reducedLaplacianShifted {toList 1..i})
reducedLaplacianShifted {{1,2}}
reducedLaplacianShifted {{2,3,4}}
------------------------------------
--Development Section
------------------------------------
restart
uninstallPackage "CriticalGroups"
restart
installPackage "CriticalGroups"
restart
needsPackage "CriticalGroups"
elapsedTime check "CriticalGroups"
viewHelp "CriticalGroups"