/
Makefile.sub
424 lines (366 loc) · 15.5 KB
/
Makefile.sub
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
###################################################################
#
# Eta relations
# Copyright 2015-2022, Ralf Hemmecke <ralf@hemmecke.org>
#
###################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################
# Compute the eta relations and generate also intermediate data.
#
# Note that generated files that don't count as "results" will be put
# into the subdirectory "tmp/". That directory can always be removed.
###################################################################
# Warning: Spaces in path or file names are not supported!
###################################################################
MKDIR_P=mkdir -p
STAMP=touch
# We assume that make is executed from the directory where THIS Makefile
# is located.
BIN=${ROOT}/bin
INPUT=${ROOT}/input
all: compile-spad
# Note that a modified version of FriCAS is needed that does not
# require variables in the GroebnerPackage.
# https://github.com/hemmecke/fricas/commits/poly
FRICAS=FRICAS_INITFILE='' fricas -nosman
###################################################################
# The following stuff is only relevant inside tmp/
%.compile: %.spad
echo ")compile $<" >> projectcompile.input
grep '^)abbrev' $< \
| sed -e 's/^.abbrev[ ]*domain[ \t]*[A-Z0-9]*[ \t]*/ --D /' \
-e 's/^.abbrev[ ]*category[ \t]*[A-Z0-9]*[ \t]*/ --C /' \
-e 's/^.abbrev[ ]*package[ \t]*[A-Z0-9]*[ \t]*/ --P /' \
>> projectcompile.input
${STAMP} $@
include deps.mk
projectcompile.input: ${patsubst %,%.spad, ${SPADFILES}}
rm -f projectcompile.input ${patsubst %,%.compile, ${SPADFILES}}
${MAKE} ${patsubst %,%.compile, ${SPADFILES}}
compile-project: projectcompile.input
echo ')read projectcompile.input' | ${FRICAS} | tee $@
projectlibs.input: compile-project
grep '^)compile ' projectcompile.input \
| while read c f; do \
echo "-- )compile $$f"; \
grep '^)abbrev' $$f \
| awk '{print};/category/ {print $$1, $$2, $$3"-", $$4}' \
| while read A C S L; do \
if test -d $$S.NRLIB; then echo ")lib $$S"; fi; \
done; \
done >> $@
echo >> projectlibs.input
compile-spad: projectlibs.input
###################################################################
DIR=${ROOT}/etafiles
DS=${DIR}/Somos
clean:
rm -f *.compile projectcompile.input projectlibs.input compile-spad
rm -f etarelationlevels.txt somoslevels.txt
distclean: clean
rm -f $(ALLTMP)
rm -f $(ALLOUT)
rm -f $(ALLINPUT)
###################################################################
VARIANT=HemmeckeCached
SOMOS=${ROOT}/somos/data
DV=${DIR}/${VARIANT}
LEVELS= 4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 \
32 33 34 35 36 38 39 40 42 44 45 46 48 49 50 51 52 54 55 \
56 57 58 60 62 63 64 65 66 68 69 70 72 74 75 76 77 78 80 \
81 82 84 85 86 87 88 90 91 92 93 94 95 96 98 99 100 \
121 169 289 361 529 841 961
CRASHLEVELS_etaQuotientMonoidSpecifications=
CRASHLEVELS_etaQuotientIdealGenerators=\
${CRASHLEVELS_etaQuotientMonoidSpecifications} \
# still crashing
CRASHLEVELS_etaLaurentIdealGenerator=\
${CRASHLEVELS_etaQuotientIdealGenerators} \
# still crashing
CRASHLEVELS_etaRelations= 48 52\
${CRASHLEVELS_etaLaurentIdealGenerators} \
# Takes too long (with slimgb).
LEVELS_EQMSPECS= \
${filter-out ${CRASHLEVELS_etaQuotientMonoidSpecifications}, ${LEVELS}}
LEVELS_EQIG= \
${filter-out ${CRASHLEVELS_etaQuotientIdealGenerators}, ${LEVELS_EQMSPECS}}
LEVELS_ELIG= \
${filter-out ${CRASHLEVELS_etaLaurentIdealGenerators}, ${LEVELS_EQIG}}
LEVELS_ER=${filter-out ${CRASHLEVELS_etaRelations}, ${LEVELS_ELIG}}
# The exponent vectors that generate the monoid of eta-quotients.
EQMSPECS=etaQuotientMonoidSpecifications
EQMSPECSINPUT=$(patsubst %, ${DV}/${EQMSPECS}%.input,${LEVELS_EQMSPECS})
EQMSPECSOUT= $(patsubst %, ${DV}/${EQMSPECS}%.out, ${LEVELS_EQMSPECS})
# Relations via an algebra basis in terms of eta-quotients.
EQIG=etaQuotientIdealGenerators
EQIGINPUT=$(patsubst %, ${DV}/${EQIG}%.input,${LEVELS_EQIG})
EQIGOUT= $(patsubst %, ${DV}/${EQIG}%.out, ${LEVELS_EQIG})
# Replace the variables in the etaQuotientIdealGenerators
# by the respective eta variables (E) and their inverses (Y).
ELIG=etaLaurentIdealGenerators
ELIGINPUT=$(patsubst %, ${DV}/${ELIG}%.input,${LEVELS_ELIG})
ELIGOUT= $(patsubst %, ${DV}/${ELIG}%.out, ${LEVELS_ELIG})
# Eliminate the inverses from the etaLaurentIdealGenerators.
ER=etaRelations
ERINPUT=$(patsubst %, ${DV}/${ER}%.input,${LEVELS_ER})
EROUT= $(patsubst %, ${DV}/${ER}%.out, ${LEVELS_ER})
ALLINPUT= ${EQMSPECSINPUT} ${EQIGINPUT} ${ELIGINPUT} ${ERINPUT}
ALLOUT= ${EQMSPECSOUT} ${EQIGOUT} ${ELIGOUT} ${EROUT}
ALLTMP=${patsubst %.out,%.tmp,${ALLOUT}}
compute-all: ${ALLINPUT}
eqmspecs: ${EQMSPECSINPUT}
eqig: ${EQIGINPUT}
elig: ${ELIGINPUT}
er: ${ERINPUT}
###################################################################
define COMPUTE_OUT_GENERIC
$(MKDIR_P) $$TARGET_DIR/log \
&& N=$* \
&& echo "(($$CMD))(($$N))" \
&& xterm -T "$$CMD $$N" -e "$$EXEC 2>&1 | tee $$TARGET_DIR/log/$$CMD$$N.log"
# && echo "TITLE: $$CMD $$N" && bash -c "$$EXEC 2>&1 | tee $$TARGET_DIR/log/$$CMD$$N.log"
mv $(subst .out,.tmp,$@) $@
endef
define COMPUTE_OUT
TARGET_DIR=${DV} \
&& CMD=$(subst eta,,$(subst $*.out,,$(@F))) \
&& EXEC="${BIN}/eta.sh $$CMD $* DIR=${DIR} VARIANT=${VARIANT}" \
&& ${COMPUTE_OUT_GENERIC}
endef
#.PRECIOUS: %.out
${DV}/${EQMSPECS}%.out: compile-spad
${COMPUTE_OUT}
${DV}/${EQIG}%.out: ${DV}/${EQMSPECS}%.input
${COMPUTE_OUT}
${DV}/${ELIG}%.out: ${DV}/${EQIG}%.input
${COMPUTE_OUT}
${DV}/${ER}%.out: ${DV}/${ELIG}%.input ${DV}/${EQMSPECS}%.input
${COMPUTE_OUT}
###################################################################
# express relations of Somos http://eta.math.georgetown.edu/etal/
# in terms of the eta relations that we have computed.
CHECKSOMOS_OUT=$(patsubst %, ${DS}/checksomos%.out, ${CHECKSOMOS_LEVELS})
CHECKSOMOS_INPUT=$(patsubst %, ${DS}/checksomos%.input, ${CHECKSOMOS_LEVELS})
FRICASSOMOS_INPUT=$(patsubst %, ${DS}/fricassomos%.input, ${CHECKSOMOS_LEVELS})
RUNFRICASSOMOS_OUT=$(patsubst %, ${DS}/runfricassomos%.out, ${CHECKSOMOS_LEVELS})
# Determine which levels are given through the collection of Somos.
somos-all.input: ${SOMOS}/somos-all.gp
awk '/^[qtx][0-9]*_/ {sub(/^/,"h("); sub(/ *= *\+/, ") := "); print; next} {print "--" $$0}' $< > $@
# Some levels are given in another format.
SOMOS_SQUARED_PRIMES=121 169 289 361
# We assume that CHECKSOMOS_LEVELS is already set when calling the Makefile.
SOMOS_ALL=${filter-out ${SOMOS_SQUARED_PRIMES}, ${CHECKSOMOS_LEVELS}}
# This file lists all levels provided by Somos.
somoslevels.txt: somos-all.input
( for n in ${SOMOS_SQUARED_PRIMES}; do echo $$n; done; \
grep '^h(' $< | sed 's/h([qtx]//;s/_.*//') \
| sort -n -u \
| tr '\n' ' ' \
> $@
# This file lists a subset of numbers from somoslevels.txt, namely those n,
# for whicht there is a corresponding file ${DV}/etaRelations$n.input.
etarelationlevels.txt: somoslevels.txt
for l in $$(cat $<); do \
if test -r ${DV}/etaRelations$$l.input; then printf "$$l "; fi; \
done \
> $@
###################################################################
# Create all somos$n.input files.
SOMOS_SP_LEVELS=${patsubst %, somos%.input, ${SOMOS_SQUARED_PRIMES}}
SOMOS_ALL_LEVELS=${patsubst %, somos%.input, ${SOMOS_ALL}}
${SOMOS_SP_LEVELS}: somos%.input: ${SOMOS}/somos-level%.gp
echo "=== $@ ===";
echo 'h: XHashTable(Symbol, Polynomial(Integer)) := table();' > $@
(${BIN}/somossquaredprime2input.pl $<; \
cat ${INPUT}/somossquaredprime.input) \
| fricas -nosman \
| sed ':a;N;$$!ba;s/_\n//g' \
| grep -- '-> -- h' \
| sed 's/^.*-> -- //' \
>> $@
${SOMOS_ALL_LEVELS}: somos%.input: somos-all.input
echo === $@ ===
echo 'h: XHashTable(Symbol, Polynomial(Integer)) := table();' > $@
grep "^h(.$*_" $< >> $@
echo "h$*: XHashTable(Symbol, Polynomial(Integer)) := h;" >> $@
###################################################################
# Check whether all of the relations found by Somos, really reduce to 0
# modulo our Gröbner basis of eta relations.
checksomos: etarelationlevels.txt
CHECKSOMOS_LEVELS=$$(cat $<); \
echo "==:: $$CHECKSOMOS_LEVELS"; \
${MAKE} CHECKSOMOS_LEVELS="$$CHECKSOMOS_LEVELS" checksomos_input
checksomos_input: ${FRICASSOMOS_INPUT}
${CHECKSOMOS_OUT}: ${DS}/checksomos%.out: compile-spad somos%.input
${MKDIR_P} ${@D}
${BIN}/checksomos.sh $* DIR=${DIR} VARIANT=${VARIANT} SOMOS="." > $@
${CHECKSOMOS_INPUT}: ${DS}/checksomos%.input: ${DS}/checksomos%.out
cat $< \
| awk -e '/-- eta relations --/ {p=1}' \
-e 'p==0 {next}' \
-e '/-- .* --/ {sub(/^.*-- /, "-- "); print; next}' \
-e '{sub(/^.* -> /,"")}' \
-e '/^ / || /^Void/ {next}' \
-e '{l=l$$0}' \
-e '/_$$/ {sub(/_$$/,"",l); next}' \
-e '{gsub(/\*1\*/,"*",l); if(l!=""){print l";"}; l=""}' \
> $@
${FRICASSOMOS_INPUT}: ${DS}/fricassomos%.input: ${DS}/checksomos%.input
awk -e '/-- Relation relations --/ {rr=1; print; l="relationRelations := [_"; next}' \
-e 'rr==0 {print; next}' \
-e '{sub(/;$$/,",_",l); print l; l=$$0}' \
-e 'END {sub(/;$$/,"];",l);print l}' \
$< > $@
###################################################################
# Check whether the relations in fricassomos$n.input really evaluate to 0.
runfricassomos: etarelationlevels.txt
CHECKSOMOS_LEVELS=$$(cat $<); \
echo "==:: $$CHECKSOMOS_LEVELS"; \
${MAKE} CHECKSOMOS_LEVELS="$$CHECKSOMOS_LEVELS" runfricassomos_out
runfricassomos_out: ${RUNFRICASSOMOS_OUT}
${RUNFRICASSOMOS_OUT}: ${DS}/runfricassomos%.out: ${DS}/fricassomos%.input
echo === $< ===
(echo ")r $<"; \
echo "# relationRelations"; \
echo "removeDuplicates relationRelations" \
) | fricas -nosman > $@
###################################################################
# compute Groebner basis in Q[E] of eta relations from Somos
# http://eta.math.georgetown.edu/etal/
# Then reduce the true etaRelations GB with this "Somos relations ideal"
# in order to find elements that Somos does not have.
SEG=somosEtaGroebner
SEGINPUT=$(patsubst ${DV}/${ER}%.input,${DS}/${SEG}%.input,${ERINPUT})
SEGOUT= $(patsubst ${DV}/${ER}%.out,${DS}/${SEG}%.out,${EROUT})
ALLINPUT+=${SEGINPUT}
${SEGOUT}: ${DS}/${SEG}%.out: #${DV}/${ER}%.input
TARGET_DIR="${DS}" && CMD="${SEG}" \
&& EXEC="${BIN}/somosgb.sh $* DIR=${DIR} SOMOS=${SOMOS}" \
&& ${COMPUTE_OUT_GENERIC}
seg: ${SEGINPUT}
###################################################################
# compute Groebner basis in Q[Y,E] of eta relations from Somos
# http://eta.math.georgetown.edu/etal/ and the inverse relations Y*E=1
# and intersect with Q[E].
# Then reduce the true etaRelations GB with this "Somos relations ideal"
# in order to find elements that Somos does not have.
SLG=somosLaurentGroebner
SLGINPUT=$(patsubst ${DS}/${SEG}%.input,${DS}/${SLG}%.input,${SEGINPUT})
SLGOUT= $(patsubst ${DS}/${SEG}%.out,${DS}/${SLG}%.out,${SEGOUT})
ALLINPUT+=${SLGINPUT}
${SLGOUT}: ${DS}/${SLG}%.out: ${DS}/${SEG}%.input
TARGET_DIR="${DS}" && CMD="${SLG}" \
&& EXEC="${BIN}/somosgb.sh $* DIR=${DIR} SOMOS=${SOMOS} IDEAL=Laurent" \
&& ${COMPUTE_OUT_GENERIC}
slg: ${SLGINPUT}
###################################################################
# compare the Groebner basis obtained via seg
# with the true Groebner basis of the eta relations
# in order to find elements that Somos does not have.
CEG=compareEtaGroebner
CEGOUT=$(patsubst ${DS}/${SEG}%.out,${DS}/${CEG}%.out,${SEGOUT})
${CEGOUT}: ${DS}/${CEG}%.out:
if test -r ${DS}/${SEG}$*.input -a -r ${DV}/etaRelations$*.input; then \
${BIN}/comparerelations.sh $* ${DS}/${SEG}$*.input ${DV}/etaRelations$*.input --12 --21 > $@; \
fi
ceg: ${CEGOUT}
###################################################################
# compare the (Laurent) Groebner basis obtained via slg
# with the true Groebner basis of the eta relations
# in order to find elements that Somos does not have.
CLG=compareLaurentGroebner
CLGOUT=$(patsubst ${DS}/${SLG}%.out,${DS}/${CLG}%.out,${SLGOUT})
${CLGOUT}: ${DS}/${CLG}%.out:
if test -r ${DS}/${SLG}$*.input -a -r ${DV}/etaRelations$*.input; then \
${BIN}/comparerelations.sh $* ${DS}/${SLG}$*.input ${DV}/etaRelations$*.input --12 --21 > $@; \
fi
clg: ${CLGOUT}
###################################################################
# Generic recipe to translate an .out file (sage or fricas) to a .input file.
${ALLINPUT}: %.input: %.out
perl -e 'while (<>) {' \
-e ' if ($$P) {' \
-e ' chomp;' \
-e ' s/^\(\d+\).* -> //;' \
-e ' if (! /_$$/ and ! /^ *$$/) {s/$$/;\n/};' \
-e ' s/_//g;' \
-e ' if (! /^ *$$/) {print;}' \
-e ' } elsif (/^ *Time: .* sec$$/) {' \
-e ' s/^ *Time: /--Time: /;' \
-e ' s/^--Time:.*=/--Time:/;' \
-e ' $$P=1; print;' \
-e ' }' \
-e '}' \
$< | grep -v '^-- ' > $@
###################################################################
# General and API documentation
# Create a HTML site (locally) for the API similar to fricas.github.io/api.
abbrev-lines.list: ${patsubst %,%.spad, ${SPADFILES}}
(cd ${ROOT}/src; \
grep -nH '^.*$$' $^ \
| awk '/:[)]if (LiterateDoc|false) *$$/,/:[)]endif/ {next}; /:[)]abbrev / {gsub(/[.:]/," "); print $$1, $$3, $$5, $$6, $$7}') > $@
###################################################################
# Copy the sphinx sources into the tmp directory
# The path to the source .spad files.
API_SPAD=$(HOME)/g/fricas/src/doc/api.spad
API_DIR=sphinx/source/api
stamp-sphinx: ${ROOT}/sphinx/source/conf.py
-rm -rf sphinx
cp -r ${ROOT}/sphinx .
if test -r ${API_SPAD}; then cp ${API_SPAD} sphinx/api.spad; \
else \
G="https://raw.githubusercontent.com/hemmecke/fricas"; \
A="$$G/master/src/doc/api.spad"; \
curl $$A > sphinx/api.spad; \
fi
${STAMP} $@
# Generate the API documentation into ${API_DIR}/*.rst files.
stamp-api: compile-spad abbrev-lines.list stamp-sphinx
-rm -rf sphinx/build ${API_DIR}
$(MKDIR_P) ${API_DIR}
((echo ')compile "sphinx/api.spad"'; \
echo ')read projectlibs'; \
echo ")cd ${API_DIR}"; \
echo 'documentAll("${ROOT}/tmp/abbrev-lines.list")') \
| $(FRICAS)) > $@
# Call sphinx-build to compile the .rst files into .html files.
stamp-html: stamp-api
sphinx-build --version \
|| (echo "==> sphinx-build not found. Please install it."; exit 1)
cd sphinx && ${MAKE} html
${STAMP} $@
# Copy the generated html directory into the target place and include
# book.pdf.
stamp-doc: stamp-html
-rm -rf ${ROOT}/html
cp -R sphinx/build/html ${ROOT}
${STAMP} $@
doc: stamp-doc
# The following target makes links point to the local repository.
# Might be useful for development without internet connection.
localdoc:
${MAKE} PACKAGE_SOURCE_VIEW=file://${ROOT} stamp-doc
clean-html:
-rm -rf ${ROOT}/html sphinx
-rm -rf stamp-sphinx stamp-api stamp-html stamp-doc
# Update the gh-pages branch.
GHPAGES=/tmp/qeta_gh-pages
github.io-local:
git worktree add ${GHPAGES} gh-pages
cp -r sphinx/build/html/* ${GHPAGES}
(cd ${GHPAGES} && git add -u && git add . \
&& (git diff --cached --exit-code \
|| git commit -m '${shell date +"%Y-%m-%d %H:%M:%S"}'))
git worktree remove ${GHPAGES}