-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
459 lines (358 loc) · 12.9 KB
/
Makefile
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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
SHELL := /bin/bash
##############################################################################
# Paths
fot_path = src/fot
# Notes path.
notes_path = notes
# Output directory for snapshot.
snapshot_dir = snapshot-fot
# Output directory for prove-fot.
prove_fot_dir = /tmp/prove-fot
# Output directory for consistency-fot.
consistency_fot_dir = /tmp/consistency-fot
# Output directory for prove-notes.
prove_notes_dir = /tmp/prove-notes
##############################################################################
# Variables
AGDA = agda -v 0
APIA = apia --check --atp=e --atp=equinox --atp=vampire
# APIA = apia --atp=e
# APIA = apia --atp=equinox
# APIA = apia --atp=ileancop
# APIA = apia --atp=metis
# APIA = apia --atp=spass
# APIA = apia --atp=vampire
APIA_FOT = ${APIA} -i$(fot_path)
##############################################################################
# Auxiliary functions
my_pathsubst = \
$(patsubst %.agda, %.$(1), \
$(shell find $(2) \( ! -path '*/Consistency/*' \) \
\( -name '*.agda' -and ! -name 'UnprovedATP.agda' \) \
| xargs grep -l 'ATP prove' \
| sort))
##############################################################################
# Files
# FOT
type_check_fot_files = \
$(patsubst %.agda, %.type-check-fot, \
$(shell find $(fot_path) -name 'Everything.agda' | sort))
type_check_agsy_fot_files = \
$(patsubst %.agda, %.type-check-agsy-fot, \
$(shell find $(fot_path)/Agsy/ -name '*.agda' | sort))
create_snapshot_fot_files = \
$(call my_pathsubst,create-snapshot-fot,$(fot_path))
compare_snapshot_fot_files = \
$(call my_pathsubst,compare-snapshot-fot,$(fot_path))
only_fot_files = $(call my_pathsubst,only-fot,$(fot_path))
prove_fot_files = $(call my_pathsubst,prove-fot,$(fot_path))
consistency_fot_files = \
$(patsubst %.agda, %.consistency-fot, \
$(shell find $(fot_path) -path '*/Consistency/*' -name '*.agda' | sort))
# Notes
type_check_notes_files = \
$(patsubst %.agda, %.type-check-notes, \
$(shell find $(notes_path) -name '*.agda' | sort))
stdlib_changed_files = \
$(patsubst %.agda, %.stdlib-changed, \
$(shell find $(notes_path) -name '*SL.agda' | sort))
prove_notes_files = $(call my_pathsubst,prove-notes,$(notes_path))
# Others
coq_type_check_files = \
$(patsubst %.v, %.coq-type-check, \
$(shell find -name '*.v' | sort))
ghc_files = \
$(patsubst %.hs, %.ghc, \
$(shell find -name '*.hs' | sort))
peano_files = \
$(patsubst %.hs, %.peano, \
$(shell find -name '*.hs' | xargs grep -l 'import Data.\Peano' | sort))
benchmark_files = \
$(fot_path)/FOTC/Base/PropertiesATP.benchmark \
$(fot_path)/FOTC/Program/GCD/Partial/ProofSpecificationATP.benchmark \
$(fot_path)/FOTC/Program/SortList/ProofSpecificationATP.benchmark
##############################################################################
# FOT: Type-checking
%.type-check-fot :
$(AGDA) $*.agda
%.type-check-agsy-fot :
$(AGDA) $*.agda
type-check-agsy-fot : $(type_check_agsy_fot_files)
@echo "$@ succeeded!"
type-check-fot : $(type_check_fot_files)
make type-check-agsy-fot
$(AGDA) $(fot_path)/README.agda
@echo "$@ succeeded!"
##############################################################################
# FOT: Generated conjectures
# In FOT we use the create-snapshot-fot rule.
##############################################################################
# FOT: Snapshot
%.create-snapshot-fot :
$(AGDA) $*.agda
@case $*.agda in \
"${fot_path}/FOL/NonIntuitionistic/TheoremsATP.agda" | \
"${fot_path}/FOL/SchemataATP.agda") \
$(APIA_FOT) --only-files \
--output-dir=$(snapshot_dir) \
--schematic-propositional-functions \
--schematic-propositional-symbols \
$*.agda \
;; \
*) \
$(APIA_FOT) --only-files --output-dir=$(snapshot_dir) $*.agda \
;; \
esac
%.compare-snapshot-fot :
@echo "Comparing $*.agda..."
@$(AGDA) $*.agda
@case $*.agda in \
"${fot_path}/FOL/NonIntuitionistic/TheoremsATP.agda" | \
"${fot_path}/FOL/SchemataATP.agda") \
$(APIA_FOT) -v 0 \
--snapshot-test \
--snapshot-dir=$(snapshot_dir) \
--schematic-propositional-functions \
--schematic-propositional-symbols \
$*.agda \
;; \
*) \
$(APIA_FOT) -v 0 \
--snapshot-test \
--snapshot-dir=$(snapshot_dir) \
$*.agda \
;; \
esac
create-snapshot-fot-aux : $(create_snapshot_fot_files)
create-snapshot-fot :
rm -r -f $(snapshot_dir)
make create-snapshot-fot-aux
@echo "$@ succeeded!"
compare-snapshot-fot : $(compare_snapshot_fot_files)
@echo "$@ succeeded!"
##############################################################################
# FOT: Only files
%.only-fot :
$(AGDA) $*.agda
case $*.agda in \
"${fot_path}/FOL/NonIntuitionistic/TheoremsATP.agda" | \
"${fot_path}/FOL/SchemataATP.agda") \
$(APIA_FOT) --only-files \
--output-dir=$(prove_fot_dir) \
--schematic-propositional-functions \
--schematic-propositional-symbols \
$*.agda \
;; \
*) \
$(APIA_FOT) --only-files --output-dir=$(prove_fot_dir) $*.agda \
;; \
esac
only-fot : $(only_fot_files)
@echo "$@ succeeded!"
##############################################################################
# FOT: Prove theorems
%.prove-fot :
$(AGDA) $*.agda
case $*.agda in \
"${fot_path}/FOL/NonIntuitionistic/TheoremsATP.agda" | \
"${fot_path}/FOL/SchemataATP.agda") \
$(APIA_FOT) --output-dir=$(prove_fot_dir) \
--time=300 \
--schematic-propositional-functions \
--schematic-propositional-symbols \
$*.agda \
;; \
*) \
$(APIA_FOT) --output-dir=$(prove_fot_dir) --time=300 $*.agda \
;; \
esac
prove-fot : $(prove_fot_files)
@echo "$@ succeeded!"
##############################################################################
# FOT: Consistency
%.consistency-fot :
$(AGDA) $*.agda
if ( $(APIA_FOT) --output-dir=$(consistency_fot_dir) \
--time=10 $*.agda ); then \
exit 1;\
fi
consistency-fot : $(consistency_fot_files)
@echo "$@ succeeded!"
##############################################################################
# Notes: Type-checking
type_check_notes_path = \
-i$(notes_path)/discrimination-rules \
-i$(notes_path)/fixed-points \
-i$(notes_path)/hip \
-i$(notes_path)/k-axiom \
-i$(notes_path)/papers/fossacs-2012 \
-i$(notes_path)/papers/paper-2011/ \
-i$(notes_path)/README \
-i$(notes_path)/setoids \
-i$(notes_path)/strict-evaluation \
-i$(notes_path)/strictly-positive-inductive-types \
-i$(notes_path)/thesis/report \
-i$(notes_path)/type-classes
%.type-check-notes :
$(AGDA) $(type_check_notes_path) $*.agda
type-check-notes : $(type_check_notes_files)
@echo "$@ succeeded!"
##############################################################################
# Notes: Prove theorems
prove_notes_path = -i$(notes_path)/hip \
-i$(notes_path)/papers/fossacs-2012 \
-i$(notes_path)/thesis/report \
-i$(notes_path)/README
%.prove-notes :
$(AGDA) $(prove_notes_path) $*.agda
case $*.agda in \
"${notes_path}/FOT/FOL/MendelsonSubstATP.agda" | \
"${notes_path}/FOT/FOL/SchemataATP.agda" | \
"${notes_path}/FOT/FOL/SchemataInstances/TestATP.agda" | \
"${notes_path}/FOT/FOTC/Data/Bool/AndTotality.agda" | \
"${notes_path}/thesis/report/CombiningProofs/ForallExistSchema.agda") \
$(APIA_FOT) $(prove_notes_path) \
--output-dir=$(prove_notes_dir) \
--time=300 \
--schematic-propositional-functions \
$*.agda \
;; \
"${notes_path}/papers/fossacs-2012/Examples.agda" | \
"${notes_path}/thesis/report/CombiningProofs/CommDisjunctionSchema.agda") \
$(APIA_FOT) $(prove_notes_path) \
--output-dir=$(prove_notes_dir) \
--time=300 \
--schematic-propositional-symbols \
$*.agda \
;; \
*) \
$(APIA) $(prove_notes_path) \
--output-dir=$(prove_notes_dir) \
--time=300 \
$*.agda \
;; \
esac
prove-notes : $(prove_notes_files)
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to Agda
agda-changed : clean
if [ ! -d $(snapshot_dir) ]; then \
echo "Error: The directory $(snapshot_dir) does not exist"; \
exit 1; \
fi
make type-check-fot
make compare-snapshot-fot
make type-check-notes
make prove-notes
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to the Agda standard library
stdlib_changed_path = -i$(notes_path)/k-axiom
%.stdlib-changed :
$(AGDA) $(stdlib_changed_path) $*.agda
stdlib-changed-aux : $(stdlib_changed_files)
stdlib-changed :
make type-check-agsy-fot
make stdlib-changed-aux
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to Apia
apia-changed :
if [ ! -d $(snapshot_dir) ]; then \
echo "Error: The directory $(snapshot_dir) does not exist"; \
exit 1; \
fi
make compare-snapshot-fot
make prove-notes
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a new ATP or a new version of an ATP
atp-changed :
@make prove-notes
@make prove-fot
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a new version of Coq.
%.coq-type-check :
coqc -w all $*.v
coq-changed : coq-clean $(coq_type_check_files)
@echo "$@ succeeded!"
coq-clean :
rm -f *.glob *.vo
##############################################################################
# Test used when there is a modification to FOT.
fot-changed :
make type-check-fot
make type-check-notes
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a new version of GHC.
%.ghc :
@rm -f $*.hi
@rm -f $*.o
ghc -Wall -Werror $*.hs
ghc-changed : $(ghc_files)
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to the Peano library.
%.peano :
@rm -f $*.hi
@rm -f $*.o
ghc -Wall -Werror $*.hs
peano-changed : $(peano_files)
@echo "$@ succeeded!"
##############################################################################
# Git : pre-commit test
git-pre-commit :
fix-whitespace --check
make type-check-fot
make type-check-notes
@echo "$@ succeeded!"
##############################################################################
# Benchmark
benchmark_tag = \
$(shell echo `date +"%Y%m%d-%H.%M"`-ghc-`ghc --numeric-version`-`hostname -s`)
# TODO (19 June 2015): Pragmas/options were removed/added from/to
# Agda/Apia.
%.benchmark :
$(AGDA_FOT) $*.agda
$(APIA_FOT) -v 0 $*.agda \
+RTS -s/tmp/benchmark/$(subst /,.,$*)
benchmark-aux : $(benchmark_files)
.PHONY : benchmark
benchmark :
mkdir --parents /tmp/benchmark
make benchmark-aux
mkdir --parents $(apia_path)/benchmark/$(benchmark_tag)
mv /tmp/benchmark/* $(apia_path)/benchmark/$(benchmark_tag)/
@echo "$@ succeeded!"
##############################################################################
# Hlint test
hlint :
find -name '*.hs' | xargs hlint --color=never
@echo "$@ succeeded!"
##############################################################################
# ATP stuff
add-ATP-stuff :
src/utils/sed/add-ATP-stuff.bash
remove-ATP-stuff :
src/utils/sed/remove-ATP-stuff.bash
##############################################################################
# Others
dependency-graph :
$(AGDA_FOT) --dependency-graph=/tmp/dependency-graph.gv \
$(fot_path)/FOTC/Program/ABP/ProofSpecificationATP.agda
dot -Tpdf /tmp/dependency-graph.gv > /tmp/dependency-graph.pdf
TODO :
find . -type d \( -path './.git' -o -path './dist' \) -prune -o -print \
| xargs grep -I 'TODO' \
| sort
clean :
find . -type f -name '*.agdai' -delete
find . -type f -name '*.glob' -delete
find . -type f -name '*.hi' -delete
find . -type f -name '*.o' -delete
find . -type f -name '*.vo' -delete
find . -type f -name 'apia.tix' -delete
find . -type f -name 'model' -delete