forked from Deducteam/hol2dk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpart.mk
More file actions
190 lines (130 loc) · 4.22 KB
/
part.mk
File metadata and controls
190 lines (130 loc) · 4.22 KB
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
# auxiliary Makefile used by in Makefile generated by the hol2dk command mkfile
BASE := $(shell if test -f BASE; then cat BASE; fi)
ROOT_PATH := $(shell if test -f ROOT_PATH; then cat ROOT_PATH; fi)
MAPPING := $(shell if test -f MAPPING; then cat MAPPING; fi)
REQUIRING := $(shell if test -f REQUIRING; then cat REQUIRING; fi)
VOFILES := $(shell if test -f VOFILES; then cat VOFILES; fi)
.SUFFIXES:
.PHONY: default
default:
@echo "usage: make TARGET [VAR=VAL ...]"
@echo "targets: lp lpo v vo opam clean-<target> clean-all"
.PHONY: part
part $(BASE).dg &:
hol2dk mk $(NB_PARTS) $(BASE)
$(BASE).mk: $(BASE).dg
hol2dk mkfile $(BASE)
.PHONY: rm-mk
rm-mk:
-rm -f lpo.mk vo.mk
.PHONY: rm-dk
rm-dk:
-find . -maxdepth 1 -name '*.dk' -a ! -name theory_hol.dk -delete
.PHONY: rm-dko
rm-dko:
-find . -maxdepth 1 -name '*.dko' -delete
.PHONY: rm-typ
rm-typ:
-find . -maxdepth 1 -name '*.typ' -delete
.PHONY: rm-sed
rm-sed:
-find . -maxdepth 1 -name '*.sed' -delete
.PHONY: rm-lp
rm-lp:
-find . -maxdepth 1 -name '*.lp' -a ! -name theory_hol.lp -delete
.PHONY: rm-lpo
rm-lpo:
-find . -maxdepth 1 -name '*.lpo' -delete
.PHONY: rm-lpo-mk
rm-lpo-mk:
-find . -maxdepth 1 -name '*.lpo.mk' -delete
.PHONY: rm-v
rm-v:
-find . -maxdepth 1 -name '*.v' -a -type f -delete
.PHONY: rm-vo
rm-vo:
-find . -maxdepth 1 -name '*.vo*' -delete
.PHONY: rm-glob
rm-glob:
-find . -maxdepth 1 -name '*.glob' -delete
.PHONY: rm-aux
rm-aux:
-find . -maxdepth 1 -name '.*.aux' -delete
.PHONY: rm-cache
rm-cache:
-rm -f .lia.cache .nia.cache
.PHONY: clean-lp
clean-lp: rm-lp rm-lpo-mk rm-mk rm-typ rm-sed rm-lpo clean-lpo clean-v
-rm -f lpo.mk
.PHONY: clean-dk
clean-dk: rm-dk rm-dko
.PHONY: clean-lpo
clean-lpo: rm-lpo
.PHONY: clean-v
clean-v: rm-v clean-vo
-rm -f vo.mk
.PHONY: clean-vo
clean-vo: rm-vo rm-glob rm-aux rm-cache
.PHONY: clean-all
clean-all: clean-lp clean-dk
# lp type abbrevs replacement
SED_FILES := $(wildcard *.sed)
.PHONY: rename-abbrevs
rename-abbrevs: $(SED_FILES:%_term_abbrevs.sed=%.lp.rename-abbrevs)
%.lp.rename-abbrevs: %_term_abbrevs.sed
sed -i -f $*_term_abbrevs.sed $*.lp $*_term_abbrevs.lp
# lpo file generation
LP_FILES := $(wildcard *.lp)
.PHONY: lpo
lpo: $(LP_FILES:%.lp=%.lpo)
%.lpo: %.lp
lambdapi check -v0 -w -c $<
include lpo.mk
LPO_MK_FILES := theory_hol.lpo.mk $(wildcard *.lpo.mk)
lpo.mk: $(LPO_MK_FILES)
find . -maxdepth 1 -name '*.lpo.mk' | xargs cat > $@
theory_hol.lpo.mk: theory_hol.lp
echo 'theory_hol.lpo:' > $@
# v file generation
.PHONY: v
v: $(LP_FILES:%.lp=%.v)
%.v: %.lp
lambdapi export -o stt_coq --encoding $(HOL2DK_DIR)/encoding.lp --renaming $(HOL2DK_DIR)/renaming.lp --mapping $(MAPPING) --use-notations --requiring "$(REQUIRING)" $< > $@
# vo file generation
.PHONY: vo
vo: $(LP_FILES:%.lp=%.vo)
ROCQ_OPTIONS = -no-glob # -w -coercions
%.vo: %.v
@echo rocq compile $<
@rocq compile $(ROCQ_OPTIONS) -R . $(ROOT_PATH) $<
include vo.mk
vo.mk: lpo.mk
sed -e 's/\.lp/.v/g' -e "s/^theory_hol.vo:/theory_hol.vo: $(VOFILES) /" lpo.mk > $@
theory_hol.vo: $(VOFILES)
# include Makefile generated by hol2dk config
include deps.mk
# dk file generation
# the order is important for generating hol.dk
DK_FILES_TO_GEN := $(shell echo theory_hol $(BASE)_types $(BASE)_terms $(BASE)_axioms; for k in `seq 1 $(NB_PARTS)`; do echo $(BASE)_part_$${k}_type_abbrevs $(BASE)_part_$${k}_term_abbrevs $(BASE)_part_$${k}; done)
.PHONY: dk
dk: $(BASE).dk
$(BASE).dk: $(DK_FILES_TO_GEN:%=%.dk) $(BASE)_theorems.dk
cat $+ > $@
$(BASE)_types.dk $(BASE)_terms.dk $(BASE)_axioms.dk &: $(BASE).sig
hol2dk sig $(BASE).dk
$(BASE)_theorems.dk: $(BASE).sig $(BASE).thm $(BASE).pos $(BASE).prf
hol2dk thm $(BASE).dk
# lp file generation
LP_FILES_TO_GEN := $(shell echo theory_hol $(BASE) $(BASE)_opam $(BASE)_types $(BASE)_terms $(BASE)_axioms; for k in `seq 1 $(NB_PARTS)`; do echo $(BASE)_part_$${k}; done)
.PHONY: lp
lp: $(LP_FILES_TO_GEN:%=%.lp)
$(MAKE) -f $(BASE).mk $(BASE)_type_abbrevs.lp
$(MAKE) -f $(BASE).mk rename-abbrevs
$(BASE)_types.lp $(BASE)_terms.lp $(BASE)_axioms.lp &: $(BASE).sig
hol2dk sig $(BASE).lp
$(BASE).lp: $(BASE).sig $(BASE).thm $(BASE).pos $(BASE).prf
hol2dk thm $(BASE).lp
$(BASE)_opam.lp: $(BASE).sig $(BASE).thm $(BASE).pos $(BASE).prf
hol2dk axm $(BASE).lp
$(BASE)_type_abbrevs.lp:
hol2dk type_abbrevs $(BASE)