author | bulwahn |
Thu, 31 Mar 2011 17:15:13 +0200 | |
changeset 42185 | 7101712baae8 |
parent 42140 | 3a60518900e4 |
child 42186 | bb688200b949 |
permissions | -rw-r--r-- |
41542 | 1 |
""" |
2 |
Test configuration descriptions for mira. |
|
3 |
""" |
|
4 |
||
5 |
import os |
|
6 |
from os import path |
|
7 |
from glob import glob |
|
8 |
import subprocess |
|
9 |
import re |
|
10 |
||
11 |
import util |
|
12 |
||
13 |
||
14 |
# build and evaluation tools |
|
15 |
||
42113 | 16 |
def prepare_isabelle_repository(loc_isabelle, loc_contrib, loc_dependency_heaps, parallelism = True, more_settings=''): |
41542 | 17 |
|
18 |
loc_contrib = path.expanduser(loc_contrib) |
|
19 |
if not path.exists(loc_contrib): |
|
20 |
raise IOError('Bad file: %s' % loc_contrib) |
|
21 |
subprocess.check_call(['ln', '-s', loc_contrib, '%s/contrib' % loc_isabelle]) |
|
22 |
||
23 |
contributed_components = path.join(loc_isabelle, 'Admin', 'contributed_components') |
|
24 |
if path.exists(contributed_components): |
|
25 |
components = [] |
|
26 |
for component in util.readfile_lines(contributed_components): |
|
27 |
loc_component = path.join(loc_isabelle, component) |
|
28 |
if path.exists(loc_component): |
|
29 |
components.append(loc_component) |
|
30 |
writer = open(path.join(loc_isabelle, 'etc', 'components'), 'a') |
|
31 |
for component in components: |
|
32 |
writer.write(component + '\n') |
|
33 |
writer.close() |
|
34 |
||
35 |
if loc_dependency_heaps: |
|
36 |
isabelle_path = loc_dependency_heaps + '/$ISABELLE_IDENTIFIER:$ISABELLE_OUTPUT' |
|
37 |
else: |
|
38 |
isabelle_path = '$ISABELLE_OUTPUT' |
|
39 |
||
40 |
if parallelism: |
|
41 |
parallelism_options = '-M max' |
|
42 |
else: |
|
43 |
parallelism_options = '-M 1 -q 0' |
|
44 |
||
45 |
extra_settings = ''' |
|
46 |
ISABELLE_HOME_USER="$ISABELLE_HOME/home_user" |
|
47 |
ISABELLE_OUTPUT="$ISABELLE_HOME/heaps" |
|
48 |
ISABELLE_BROWSER_INFO="$ISABELLE_HOME/browser_info" |
|
49 |
ISABELLE_PATH="%s" |
|
50 |
||
51 |
ISABELLE_USEDIR_OPTIONS="$ISABELLE_USEDIR_OPTIONS %s -t true -v true -d pdf -g true -i true" |
|
42109 | 52 |
Z3_NON_COMMERCIAL="yes" |
42113 | 53 |
%s |
54 |
''' % (isabelle_path, parallelism_options, more_settings) |
|
41542 | 55 |
|
56 |
writer = open(path.join(loc_isabelle, 'etc', 'settings'), 'a') |
|
57 |
writer.write(extra_settings) |
|
58 |
writer.close() |
|
59 |
||
60 |
||
61 |
def extract_isabelle_run_timing(logdata): |
|
62 |
||
63 |
def to_secs(h, m, s): |
|
64 |
return (int(h) * 60 + int(m)) * 60 + int(s) |
|
65 |
pat = r'Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time' |
|
66 |
pat2 = r'Timing (\S+) \((\d+) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time\)' |
|
67 |
t = dict((name, {'elapsed': to_secs(eh,em,es), 'cpu': to_secs(ch,cm,cs)}) |
|
68 |
for name, eh, em, es, ch, cm, cs in re.findall(pat, logdata)) |
|
69 |
for name, threads, elapsed, cpu, gc in re.findall(pat2, logdata): |
|
70 |
||
71 |
if name not in t: |
|
72 |
t[name] = {} |
|
73 |
||
74 |
t[name]['threads'] = int(threads) |
|
75 |
t[name]['elapsed_inner'] = elapsed |
|
76 |
t[name]['cpu_inner'] = cpu |
|
77 |
t[name]['gc'] = gc |
|
78 |
||
79 |
return t |
|
80 |
||
81 |
||
82 |
def extract_isabelle_run_summary(logdata): |
|
83 |
||
41894 | 84 |
re_error = re.compile(r'^(?:make: )?\*\*\* (.*)$', re.MULTILINE) |
41542 | 85 |
summary = '\n'.join(re_error.findall(logdata)) |
86 |
if summary == '': |
|
87 |
summary = 'ok' |
|
88 |
||
89 |
return summary |
|
90 |
||
91 |
||
92 |
def isabelle_usedir(env, isa_path, isabelle_usedir_opts, base_image, dir_name): |
|
93 |
||
94 |
return env.run_process('%s/bin/isabelle' % isa_path, 'usedir', |
|
95 |
isabelle_usedir_opts, base_image, dir_name) |
|
96 |
||
97 |
||
98 |
def isabelle_dependency_only(env, case, paths, dep_paths, playground): |
|
99 |
||
42114 | 100 |
isabelle_home = paths[0] |
101 |
result = path.join(isabelle_home, 'heaps') |
|
41542 | 102 |
os.makedirs(result) |
103 |
for dep_path in dep_paths: |
|
104 |
subprocess.check_call(['cp', '-R'] + glob(dep_path + '/*') + [result]) |
|
105 |
||
106 |
return (True, 'ok', {}, {}, result) |
|
107 |
||
108 |
||
42113 | 109 |
def build_isabelle_image(subdir, base, img, env, case, paths, dep_paths, playground, more_settings=''): |
41542 | 110 |
|
42114 | 111 |
isabelle_home = paths[0] |
41542 | 112 |
dep_path = dep_paths[0] |
42120 | 113 |
prepare_isabelle_repository(isabelle_home, env.settings.contrib, dep_path, more_settings=more_settings) |
42114 | 114 |
os.chdir(path.join(isabelle_home, 'src', subdir)) |
41542 | 115 |
|
42114 | 116 |
(return_code, log) = isabelle_usedir(env, isabelle_home, '-b', base, img) |
41542 | 117 |
|
42114 | 118 |
result = path.join(isabelle_home, 'heaps') |
41542 | 119 |
return (return_code == 0, extract_isabelle_run_summary(log), |
120 |
{'timing': extract_isabelle_run_timing(log)}, {'log': log}, result) |
|
121 |
||
122 |
||
42140 | 123 |
def isabelle_make(subdir, env, case, paths, dep_paths, playground, more_settings='', target='all', keep_results=False): |
42115
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
124 |
|
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
125 |
isabelle_home = paths[0] |
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
126 |
dep_path = dep_paths[0] if dep_paths else None |
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
127 |
prepare_isabelle_repository(isabelle_home, env.settings.contrib, dep_path, more_settings=more_settings) |
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
128 |
os.chdir(path.join(isabelle_home, subdir)) |
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
129 |
|
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
130 |
(return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'make', '-k', target) |
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
131 |
|
42140 | 132 |
result = path.join(isabelle_home, 'heaps') if keep_results else None |
42115
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
133 |
return (return_code == 0, extract_isabelle_run_summary(log), |
42140 | 134 |
{'timing': extract_isabelle_run_timing(log)}, {'log': log}, result) |
42115
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
135 |
|
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
136 |
|
42121 | 137 |
def isabelle_makeall(env, case, paths, dep_paths, playground, more_settings='', target='all', make_options=()): |
41542 | 138 |
|
42114 | 139 |
isabelle_home = paths[0] |
42115
e6a1dc0aa058
mira interface to 'isabelle make' in addition to usedir and makeall;
krauss
parents:
42114
diff
changeset
|
140 |
dep_path = dep_paths[0] if dep_paths else None |
42114 | 141 |
prepare_isabelle_repository(isabelle_home, env.settings.contrib, dep_path, more_settings=more_settings) |
142 |
os.chdir(isabelle_home) |
|
41542 | 143 |
|
42121 | 144 |
(return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'makeall', '-k', *(make_options + (target,))) |
41542 | 145 |
|
146 |
return (return_code == 0, extract_isabelle_run_summary(log), |
|
147 |
{'timing': extract_isabelle_run_timing(log)}, {'log': log}, None) |
|
148 |
||
149 |
||
150 |
# Isabelle configurations |
|
151 |
||
152 |
@configuration(repos = [Isabelle], deps = []) |
|
153 |
def Pure(env, case, paths, dep_paths, playground): |
|
154 |
"""Pure image""" |
|
155 |
||
42114 | 156 |
isabelle_home = paths[0] |
157 |
prepare_isabelle_repository(isabelle_home, env.settings.contrib, '') |
|
158 |
os.chdir(path.join(isabelle_home, 'src', 'Pure')) |
|
41542 | 159 |
|
42114 | 160 |
(return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'make', 'Pure') |
41542 | 161 |
|
42114 | 162 |
result = path.join(isabelle_home, 'heaps') |
41542 | 163 |
return (return_code == 0, extract_isabelle_run_summary(log), |
164 |
{'timing': extract_isabelle_run_timing(log)}, {'log': log}, result) |
|
165 |
||
166 |
@configuration(repos = [Isabelle], deps = [(Pure, [0])]) |
|
167 |
def FOL(*args): |
|
168 |
"""FOL image""" |
|
169 |
return build_isabelle_image('FOL', 'Pure', 'FOL', *args) |
|
170 |
||
171 |
@configuration(repos = [Isabelle], deps = [(Pure, [0])]) |
|
172 |
def HOL(*args): |
|
173 |
"""HOL image""" |
|
174 |
return build_isabelle_image('HOL', 'Pure', 'HOL', *args) |
|
175 |
||
176 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
177 |
def HOL_HOLCF(*args): |
|
178 |
"""HOL-HOLCF image""" |
|
179 |
return build_isabelle_image('HOL/HOLCF', 'HOL', 'HOLCF', *args) |
|
180 |
||
181 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
182 |
def HOL_Nominal(*args): |
|
183 |
"""HOL-Nominal image""" |
|
184 |
return build_isabelle_image('HOL/Nominal', 'HOL', 'HOL-Nominal', *args) |
|
185 |
||
186 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
187 |
def HOL_Word(*args): |
|
188 |
"""HOL-Word image""" |
|
189 |
return build_isabelle_image('HOL/Word', 'HOL', 'HOL-Word', *args) |
|
190 |
||
191 |
@configuration(repos = [Isabelle], deps = [ |
|
192 |
(HOL, [0]), |
|
193 |
(HOL_HOLCF, [0]), |
|
194 |
(HOL_Nominal, [0]), |
|
195 |
(HOL_Word, [0]) |
|
196 |
]) |
|
197 |
def AFP_images(*args): |
|
198 |
"""Isabelle images needed for the AFP""" |
|
199 |
return isabelle_dependency_only(*args) |
|
200 |
||
201 |
@configuration(repos = [Isabelle], deps = [ |
|
202 |
(AFP_images, [0]) |
|
203 |
]) |
|
204 |
def Isabelle_makeall(*args): |
|
205 |
"""Isabelle makeall""" |
|
206 |
return isabelle_makeall(*args) |
|
207 |
||
208 |
||
209 |
# Mutabelle configurations |
|
210 |
||
211 |
def invoke_mutabelle(theory, env, case, paths, dep_paths, playground): |
|
212 |
||
213 |
"""Mutant testing for counterexample generators in Isabelle""" |
|
214 |
||
215 |
(loc_isabelle,) = paths |
|
216 |
(dep_isabelle,) = dep_paths |
|
217 |
prepare_isabelle_repository(loc_isabelle, env.settings.contrib, dep_isabelle) |
|
218 |
os.chdir(loc_isabelle) |
|
219 |
||
220 |
(return_code, log) = env.run_process('bin/isabelle', |
|
221 |
'mutabelle', '-O', playground, theory) |
|
222 |
||
223 |
try: |
|
224 |
mutabelle_log = util.readfile(path.join(playground, 'log')) |
|
225 |
except IOError: |
|
226 |
mutabelle_log = '' |
|
227 |
||
228 |
return (return_code == 0 and mutabelle_log != '', extract_isabelle_run_summary(log), |
|
41652 | 229 |
{'timing': extract_isabelle_run_timing(log)}, |
230 |
{'log': log, 'mutabelle_log': mutabelle_log}, None) |
|
41542 | 231 |
|
232 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
233 |
def Mutabelle_Relation(*args): |
|
234 |
"""Mutabelle regression suite on Relation theory""" |
|
235 |
return invoke_mutabelle('Relation', *args) |
|
236 |
||
237 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
238 |
def Mutabelle_List(*args): |
|
239 |
"""Mutabelle regression suite on List theory""" |
|
240 |
return invoke_mutabelle('List', *args) |
|
241 |
||
242 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
243 |
def Mutabelle_Set(*args): |
|
244 |
"""Mutabelle regression suite on Set theory""" |
|
245 |
return invoke_mutabelle('Set', *args) |
|
246 |
||
247 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
248 |
def Mutabelle_Map(*args): |
|
249 |
"""Mutabelle regression suite on Map theory""" |
|
250 |
return invoke_mutabelle('Map', *args) |
|
251 |
||
252 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
253 |
def Mutabelle_Divides(*args): |
|
254 |
"""Mutabelle regression suite on Divides theory""" |
|
255 |
return invoke_mutabelle('Divides', *args) |
|
256 |
||
257 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
258 |
def Mutabelle_MacLaurin(*args): |
|
259 |
"""Mutabelle regression suite on MacLaurin theory""" |
|
260 |
return invoke_mutabelle('MacLaurin', *args) |
|
261 |
||
262 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
263 |
def Mutabelle_Fun(*args): |
|
264 |
"""Mutabelle regression suite on Fun theory""" |
|
265 |
return invoke_mutabelle('Fun', *args) |
|
42040 | 266 |
|
267 |
||
268 |
# Judgement Day configurations |
|
269 |
||
42095 | 270 |
judgement_day_provers = ('e', 'spass', 'vampire', 'z3', 'cvc3', 'yices') |
42040 | 271 |
|
272 |
def judgement_day(base_path, theory, opts, env, case, paths, dep_paths, playground): |
|
273 |
"""Judgement Day regression suite""" |
|
274 |
||
275 |
isa = paths[0] |
|
276 |
dep_path = dep_paths[0] |
|
277 |
||
278 |
os.chdir(path.join(playground, '..', base_path)) # Mirabelle requires specific cwd |
|
279 |
prepare_isabelle_repository(isa, env.settings.contrib, dep_path) |
|
280 |
||
281 |
output = {} |
|
282 |
success_rates = {} |
|
283 |
some_success = False |
|
284 |
||
285 |
for atp in judgement_day_provers: |
|
286 |
||
287 |
log_dir = path.join(playground, 'mirabelle_log_' + atp) |
|
288 |
os.makedirs(log_dir) |
|
289 |
||
290 |
cmd = ('%s/bin/isabelle mirabelle -q -O %s sledgehammer[prover=%s,%s] %s.thy' |
|
291 |
% (isa, log_dir, atp, opts, theory)) |
|
292 |
||
293 |
os.system(cmd) |
|
294 |
output[atp] = util.readfile(path.join(log_dir, theory + '.log')) |
|
295 |
||
296 |
percentages = list(re.findall(r'Success rate: (\d+)%', output[atp])) |
|
297 |
if len(percentages) == 2: |
|
298 |
success_rates[atp] = { |
|
299 |
'sledgehammer': int(percentages[0]), |
|
300 |
'metis': int(percentages[1])} |
|
301 |
if success_rates[atp]['sledgehammer'] > 0: |
|
302 |
some_success = True |
|
303 |
else: |
|
304 |
success_rates[atp] = {} |
|
305 |
||
306 |
||
307 |
data = {'success_rates': success_rates} |
|
308 |
raw_attachments = dict((atp + "_output", output[atp]) for atp in judgement_day_provers) |
|
309 |
# FIXME: summary? |
|
310 |
return (some_success, '', data, raw_attachments, None) |
|
311 |
||
312 |
||
313 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
314 |
def JD_NS(*args): |
|
315 |
"""Judgement Day regression suite NS""" |
|
316 |
return judgement_day('Isabelle/src/HOL/Auth', 'NS_Shared', 'prover_timeout=10', *args) |
|
317 |
||
318 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
319 |
def JD_FTA(*args): |
|
320 |
"""Judgement Day regression suite FTA""" |
|
321 |
return judgement_day('Isabelle/src/HOL/Library', 'Fundamental_Theorem_Algebra', 'prover_timeout=10', *args) |
|
322 |
||
323 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
324 |
def JD_Hoare(*args): |
|
325 |
"""Judgement Day regression suite Hoare""" |
|
42058
1eda69f0b9a8
moved some configurations to AFP, and fixed others
krauss
parents:
42040
diff
changeset
|
326 |
return judgement_day('Isabelle/src/HOL/IMPP', 'Hoare', 'prover_timeout=10', *args) |
42040 | 327 |
|
328 |
@configuration(repos = [Isabelle], deps = [(HOL, [0])]) |
|
329 |
def JD_SN(*args): |
|
330 |
"""Judgement Day regression suite SN""" |
|
42058
1eda69f0b9a8
moved some configurations to AFP, and fixed others
krauss
parents:
42040
diff
changeset
|
331 |
return judgement_day('Isabelle/src/HOL/Proofs/Lambda', 'StrongNorm', 'prover_timeout=10', *args) |
42040 | 332 |
|
42116
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
333 |
|
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
334 |
# SML/NJ |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
335 |
|
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
336 |
smlnj_settings = ''' |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
337 |
ML_SYSTEM=smlnj |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
338 |
ML_HOME="/home/smlnj/110.72/bin" |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
339 |
ML_OPTIONS="@SMLdebug=/dev/null @SMLalloc=256" |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
340 |
ML_PLATFORM=$(eval $("$ML_HOME/.arch-n-opsys" 2>/dev/null); echo "$HEAP_SUFFIX") |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
341 |
''' |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
342 |
|
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
343 |
@configuration(repos = [Isabelle], deps = []) |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
344 |
def SML_HOL(*args): |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
345 |
"""HOL image built with SML/NJ""" |
42140 | 346 |
return isabelle_make('src/HOL', *args, more_settings=smlnj_settings, target='HOL', keep_results=True) |
42116
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
347 |
|
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
348 |
@configuration(repos = [Isabelle], deps = []) |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
349 |
def SML_makeall(*args): |
b9ae421fbcc7
added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
krauss
parents:
42115
diff
changeset
|
350 |
"""Makeall built with SML/NJ""" |
42138
e54a985daa61
added make target 'smlnj' to refer to what can/should be tested using smlnj -- allows the use of "isabelle makeall smlnj";
krauss
parents:
42121
diff
changeset
|
351 |
return isabelle_makeall(*args, more_settings=smlnj_settings, target='smlnj', make_options=('-j', '3')) |