-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
591 lines (483 loc) · 17.1 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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
SHELL := /bin/bash
##############################################################################
# Paths
# Tests paths.
errors_path = test/Fail/Errors
errors_shelltestrunner_path = test/Fail/errors-shelltestrunner
fol_theorems_path = test/Succeed/fol-theorems
non_conjectures_path = test/Succeed/NonConjectures
non_fol_theorems_path = test/Succeed/non-fol-theorems
non_theorems_path = test/Fail/non-theorems
# Output directory for the TPTP files.
output_dir = /tmp/apia
# Notes path.
notes_path = notes
##############################################################################
# Variables
haskell_files = $(shell find src/ -name '*.hs')
AGDA = agda -v 0
APIA = dist/build/apia/apia --check
# Supported ATPs.
ATPs = cvc4 e equinox metis vampire z3
# ATPs = cvc4 e equinox ileancop metis spass vampire z3
##############################################################################
# Auxiliary functions
my_pathsubst = $(patsubst %.agda, %.$(1), \
$(shell find $(2) -name '*.agda' \
| xargs grep -l 'ATP prove' \
| sort))
##############################################################################
# Files
# Tests
generated_fol_theorems_files = \
$(call my_pathsubst,generated-fol-theorems,$(fol_theorems_path))
generated_non_fol_theorems_files = \
$(call my_pathsubst,generated-non-fol-theorems,\
$(non_fol_theorems_path))
generated_non_theorems_files = \
$(call my_pathsubst,generated-non-theorems,$(non_theorems_path))
non_conjectures_files = \
$(patsubst %.agda, %.non-conjectures,\
$(shell find $(non_conjectures_path) -name '*.agda' | sort))
only_fol_theorems_files = \
$(call my_pathsubst,only-fol-theorems,$(fol_theorems_path))
only_non_fol_theorems_files = \
$(call my_pathsubst,only-non-fol-theorems,\
$(non_fol_theorems_path))
prove_fol_theorems_files = \
$(call my_pathsubst,prove-fol-theorems,$(fol_theorems_path))
prove_non_fol_theorems_files = \
$(call my_pathsubst,prove-non-fol-theorems,\
$(non_fol_theorems_path))
refute_theorems_files = \
$(call my_pathsubst,refute-theorems,$(non_theorems_path))
errors_files = \
$(patsubst %.agda, %.errors,\
$(shell find $(errors_path) -name '*.agda' | sort))
errors_shelltestrunner_files = \
$(patsubst %.agda, %.errors-shelltestrunner,\
$(shell find $(errors_shelltestrunner_path) -name '*.agda' | sort))
# Notes
type_check_notes_files = \
$(patsubst %.agda, %.type-check-notes, \
$(shell find $(notes_path) -name '*.agda' | sort))
prove_notes_files = $(call my_pathsubst,prove-notes,$(notes_path))
##############################################################################
# Test suite variables
APIA_TEST_BIN = dist/build/apia-tests/apia-tests
TESTS_OPTIONS =-i
##############################################################################
# Test suite: Generated FOL theorems
GENERATED_FOL_THEOREMS_FLAGS = \
-v 0\
-i$(fol_theorems_path) --only-files \
--output-dir=$(output_dir)
%.generated-fol-theorems :
@echo "Comparing $*.agda"
@$(AGDA) -i$(fol_theorems_path) $*.agda
@case $*.agda in \
"${fol_theorems_path}/NonInternalEquality.agda") \
$(APIA) $(GENERATED_FOL_THEOREMS_FLAGS) \
--no-internal-equality \
$*.agda \
;; \
*) $(APIA) $(GENERATED_FOL_THEOREMS_FLAGS) \
$*.agda \
;; \
esac
@diff -r $* $(output_dir)/$*
.PHONY : generated-fol-theorems-aux
generated-fol-theorems-aux : $(generated_fol_theorems_files)
.PHONY : generated-fol-theorems
generated-fol-theorems :
rm -r -f $(output_dir)
make generated-fol-theorems-aux
@echo "$@ succeeded!"
##############################################################################
# Test suite: Generated non-FOL theorems
GENERATED_NON_FOL_THEOREMS_FLAGS = \
-v 0 \
-i$(non_fol_theorems_path) \
--only-files \
--output-dir=$(output_dir)
%.generated-non-fol-theorems :
@echo "Comparing $*.agda"
@$(AGDA) -i$(non_fol_theorems_path) $*.agda
@case $*.agda in \
"${non_fol_theorems_path}/AgdaInternalTerms/VarEmptyArgumentsTerm.agda" | \
"${non_fol_theorems_path}/Eta-Issue8.agda" | \
"${non_fol_theorems_path}/Existential.agda" | \
"${non_fol_theorems_path}/Instance.agda" | \
"${non_fol_theorems_path}/Issue12.agda" | \
"${non_fol_theorems_path}/OptionsLList.agda" | \
"${non_fol_theorems_path}/P11.agda" | \
"${non_fol_theorems_path}/PropositionalFunction.agda") \
$(APIA) $(GENERATED_NON_FOL_THEOREMS_FLAGS) \
--schematic-propositional-functions \
$*.agda \
;; \
"${non_fol_theorems_path}/PropositionalSymbol.agda") \
$(APIA) $(GENERATED_NON_FOL_THEOREMS_FLAGS) \
--schematic-propositional-symbols \
$*.agda \
;; \
*) exit 1 \
;; \
esac
@diff -r $* $(output_dir)/$*
.PHONY : generated-non-fol-theorems-aux
generated-non-fol-theorems-aux : \
$(generated_non_fol_theorems_files)
.PHONY : generated-non-fol-theorems
generated-non-fol-theorems :
rm -r -f $(output_dir)
make generated-non-fol-theorems-aux
@echo "$@ succeeded!"
##############################################################################
# Test suite: Generated non-theorems
GENERATED_NON_THEOREMS_FLAGS = \
-v 0 \
-i$(non_theorems_path) \
--only-files \
--output-dir=$(output_dir)
%.generated-non-theorems :
@echo "Comparing $*.agda"
@$(AGDA) -i$(non_theorems_path) $*.agda
@$(APIA) $(GENERATED_NON_THEOREMS_FLAGS) $*.agda
@diff -r $* $(output_dir)/$*
.PHONY : generated-non-theorems-aux
generated-non-theorems-aux : $(generated_non_theorems_files)
.PHONY : generated-non-theorems
generated-non-theorems : $(generated_non_theorems_files)
rm -r -f $(output_dir)
make generated-non-theorems-aux
@echo "$@ succeeded!"
##############################################################################
# Test suite: Generated TPTP files
.PHONY : generated-all
generated-all :
make generated-fol-theorems
make generated-non-fol-theorems
make generated-non-theorems
@echo "$@ succeeded!"
##############################################################################
# Test suite: Only FOL theorems files
ONLY_FOL_THEOREMS_FLAGS = \
-i$(fol_theorems_path) \
--only-files \
--output-dir=$(output_dir)
%.only-fol-theorems :
$(AGDA) -i$(fol_theorems_path) $*.agda
@case $*.agda in \
"${fol_theorems_path}/NonInternalEquality.agda") \
$(APIA) ${ONLY_FOL_THEOREMS_FLAGS} \
--no-internal-equality \
$*.agda \
;; \
*) $(APIA) ${ONLY_FOL_THEOREMS_FLAGS} \
$*.agda \
;; \
esac
.PHONY : only-fol-theorems
only-fol-theorems : $(only_fol_theorems_files)
@echo "$@ succeeded!"
##############################################################################
# Test suite: Only non-FOL theorems files
ONLY_NON_FOL_THEOREMS_FLAGS = \
-i$(non_fol_theorems_path) \
--only-files \
--output-dir=$(output_dir)
%.only-non-fol-theorems :
$(AGDA) -i$(non_fol_theorems_path) $*.agda
@case $*.agda in \
"${non_fol_theorems_path}/AgdaInternalTerms/VarEmptyArgumentsTerm.agda" | \
"${non_fol_theorems_path}/Eta-Issue8.agda" | \
"${non_fol_theorems_path}/Existential.agda" | \
"${non_fol_theorems_path}/Instance.agda" | \
"${non_fol_theorems_path}/Issue12.agda" | \
"${non_fol_theorems_path}/OptionsLList.agda" | \
"${non_fol_theorems_path}/P11.agda" | \
"${non_fol_theorems_path}/PropositionalFunction.agda") \
$(APIA) ${ONLY_NON_FOL_THEOREMS_FLAGS} \
--schematic-propositional-functions \
$*.agda \
;; \
"${non_fol_theorems_path}/PropositionalSymbol.agda") \
$(APIA) ${ONLY_NON_FOL_THEOREMS_FLAGS} \
--schematic-propositional-symbols \
$*.agda \
;; \
*) exit 1 \
;; \
esac
.PHONY : only-non-fol-theorems
only-non-fol-theorems : \
$(only_non_fol_theorems_files)
@echo "$@ succeeded!"
##############################################################################
# Test suite: Prove FOL theorems
PROVE_FOL_THEOREMS_FLAGS = \
-i$(fol_theorems_path) \
--output-dir=$(output_dir) \
--time=10 \
%.prove-fol-theorems :
$(AGDA) -i$(fol_theorems_path) $*.agda
@for atp in ${ATPs} ; do \
set -e ; \
case $*.agda in \
"${fol_theorems_path}/Definition10.agda") \
if [[ $$atp != ileancop ]]; then \
$(APIA) ${PROVE_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
$*.agda ; \
fi \
;; \
"${fol_theorems_path}/LogicalConstants.agda") \
if [[ $$atp != ileancop ]]; then \
$(APIA) ${PROVE_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
$*.agda ; \
fi \
;; \
"${fol_theorems_path}/NonInternalEquality.agda") \
$(APIA) ${PROVE_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
--no-internal-equality \
$*.agda ; \
;; \
*) $(APIA) ${PROVE_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
$*.agda ; \
;; \
esac ; \
done
.PHONY : prove-fol-theorems
prove-fol-theorems : $(prove_fol_theorems_files)
@echo "$@ succeeded!"
##############################################################################
# Test suite: Prove non-FOL theorems
PROVE_NON_FOL_THEOREMS_FLAGS = \
-i$(non_fol_theorems_path) \
--output-dir=$(output_dir) \
--time=10
%.prove-non-fol-theorems :
$(AGDA) -i$(non_fol_theorems_path) $*.agda
@for atp in ${ATPs} ; do \
set -e ; \
case $*.agda in \
"${non_fol_theorems_path}/AgdaInternalTerms/VarEmptyArgumentsTerm.agda" | \
"${non_fol_theorems_path}/Eta-Issue8.agda" | \
"${non_fol_theorems_path}/Existential.agda" | \
"${non_fol_theorems_path}/Instance.agda" | \
"${non_fol_theorems_path}/Issue12.agda" | \
"${non_fol_theorems_path}/OptionsLList.agda" | \
"${non_fol_theorems_path}/P11.agda" | \
"${non_fol_theorems_path}/PropositionalFunction.agda") \
$(APIA) ${PROVE_NON_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
--schematic-propositional-functions \
$*.agda ; \
;; \
"${non_fol_theorems_path}/PropositionalSymbol.agda") \
$(APIA) ${PROVE_NON_FOL_THEOREMS_FLAGS} \
--atp=$$atp \
--schematic-propositional-symbols \
$*.agda ; \
;; \
*) exit 1 \
;; \
esac ; \
done
.PHONY : prove-non-fol-theorems
prove-non-fol-theorems : \
$(prove_non_fol_theorems_files)
@echo "$@ succeeded!"
##############################################################################
# Test suite: Prove all theorems
.PHONY : prove-all-theorems
prove-all-theorems :
make prove-fol-theorems
make prove-non-fol-theorems
@echo "$@ succeeded!"
##############################################################################
# Test suite: Refute theorems
%.refute-theorems :
@echo "Processing $*.agda"
@$(AGDA) -i$(non_theorems_path) $*.agda
@if ( $(APIA) -i$(non_theorems_path) \
--output-dir=$(output_dir) --time=5 $*.agda ); then \
exit 1; \
fi
.PHONY : refute-theorems
refute-theorems : $(refute_theorems_files)
@echo "$@ succeeded!"
##############################################################################
# Test suite: Non-conjectures
%.non-conjectures :
@$(AGDA) -i$(non_conjectures_path) $*.agda
.PHONY : non-conjectures
non-conjectures : $(non_conjectures_files)
$(APIA_TEST_BIN) $(TESTS_OPTIONS) --regex-include test/Succeed/NonConjectures
@echo "$@ succeeded"
# Tested with shelltestrunner 1.9.
.PHONY : non-conjectures-shelltestrunner
non-conjectures-shelltestrunner : $(non_conjectures_files)
shelltest --color \
--execdir \
--precise \
$(non_conjectures_path)/non-conjectures.test
@echo "$@ succeeded!"
##############################################################################
# Test suite: Errors
%.errors :
@$(AGDA) -v 0 -i$(errors_path) $*.agda
.PHONY : errors
errors : $(errors_files)
$(APIA_TEST_BIN) $(TESTS_OPTIONS) --regex-include test/Fail/Errors
@echo "$@ succeeded"
%.errors-shelltestrunner :
@$(AGDA) -v 0 -i$(errors_shelltestrunner_path) $*.agda
# Tested with shelltestrunner 1.3.5.
.PHONY : errors-shelltestrunner
errors-shelltestrunner : $(errors_shelltestrunner_files)
shelltest --color --execdir --precise $(errors_shelltestrunner_path)/errors.test
@echo "$@ succeeded!"
##############################################################################
# Test suite: Haddock test
#
# Tested with cabal-install version 1.20.0.3 using version 1.20.0.2 of
# the Cabal library.
.PHONY : haddock
haddock :
cabal configure
cabal haddock --executables \
--haddock-option=--use-unicode \
--hyperlink-source
@echo "$@ succeeded!"
##############################################################################
# Notes: Type-checking
type_check_notes_path = -i$(notes_path) \
-i$(notes_path)/agda-interface \
-i$(notes_path)/README
%.type-check-notes :
$(AGDA) $(type_check_notes_path) $*.agda
.PHONY : type-check-notes
type-check-notes : $(type_check_notes_files)
@echo "$@ succeeded!"
##############################################################################
# Notes: Prove theorems
prove_notes_path = -i$(notes_path) \
-i$(notes_path)/README
%.prove-notes :
echo $(prove_notes_files)
$(AGDA) $(prove_notes_path) $*.agda
@for atp in ${ATPs} ; do \
set -e ; \
$(APIA) $(prove_notes_path) \
--atp=$$atp \
--output-dir=$(output_dir) \
--time=10 \
$*.agda ; \
done
.PHONY : prove-notes
prove-notes : $(prove_notes_files)
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to Apia
.PHONY : tests
tests :
make generated-all
make non-conjectures
make non-conjectures-shelltestrunner
make errors
make errors-shelltestrunner
make type-check-notes
make prove-notes
make haddock
@echo "$@ succeeded!"
##############################################################################
# Test used when there is a modification to Agda
.PHONY : agda-changed
agda-changed : clean
cabal clean
make install-bin
make tests
@echo "$@ succeeded!"
##############################################################################
# Hlint test
# Requires HLint >= 1.9.36 and run `cabal build` or `cabal install`
# before.
.PHONY : hlint
hlint :
hlint --color=never Setup.hs
hlint --color=never \
--cpp-file=dist/build/apia/autogen/cabal_macros.h \
--cpp-include=src/Apia/ \
src/ test/
@echo "$@ succeeded!"
##############################################################################
# Git : pre-commit test
.PHONY : git-pre-commit
git-pre-commit :
fix-whitespace --check
make hlint
@echo "$@ succeeded!"
##############################################################################
# Apia install
.PHONY : install-bin
install-bin :
cabal install --enable-tests --disable-documentation
##############################################################################
# Haskell program coverage
# TODO: Fix
hpc_html_dir = $(apia_path)/hpc
.PHONY : hpc
hpc : hpc-clean
cd $(apia_path) && cabal clean && cabal install --ghc-option=-fhpc
make prove_all_theorem
make refute-theorems
make errors
make errors-shelltestrunner
make non-conjectures
make non-conjectures-shelltestrunner
hpc markup --exclude=Paths_apia \
--destdir=$(hpc_html_dir) \
--srcdir=$(apia_path) \
apia.tix
hpc report --exclude=Paths_apia \
--decl-list \
--srcdir=$(apia_path) \
apia.tix
rm -f *.tix
.PHONY : hpc-clean
hpc-clean :
rm -f *.tix
rm -f -r $(hpc_html_dir)
##############################################################################
# White-spaces stuff
.PHONY : install-fix-whitespace
install-fix-whitespace :
cd src/fix-whitespace && cabal install
.PHONY : check-whitespace
check-whitespace :
fix-whitespace --check
##############################################################################
# Others
.PHONY : TAGS
TAGS :
hTags -I src/Apia/ \
-i dist/build/autogen/cabal_macros.h \
-e $(haskell_files)
.PHONY : TODO
TODO :
find . -type d \( -path './.git' -o -path './dist' \) -prune -o -print \
| xargs grep -I 'TODO' \
| sort
.PHONY : clean
clean :
find . -type f -name '*.agdai' -delete
find . -type f -name '*.hi' -delete
find . -type f -name '*.o' -delete
find . -type f -name 'apia.tix' -delete
find . -type f -name 'model' -delete
rm -f -r $(output_dir)