added configurations SML_HOL and SML_makeall (even though the latter is practically infeasible)
2 Test configuration descriptions for mira.
14 # build and evaluation tools
16 def prepare_isabelle_repository(loc_isabelle, loc_contrib, loc_dependency_heaps, parallelism = True, more_settings=''):
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])
23 contributed_components = path.join(loc_isabelle, 'Admin', 'contributed_components')
24 if path.exists(contributed_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')
35 if loc_dependency_heaps:
36 isabelle_path = loc_dependency_heaps + '/$ISABELLE_IDENTIFIER:$ISABELLE_OUTPUT'
38 isabelle_path = '$ISABELLE_OUTPUT'
41 parallelism_options = '-M max'
43 parallelism_options = '-M 1 -q 0'
46 ISABELLE_HOME_USER="$ISABELLE_HOME/home_user"
47 ISABELLE_OUTPUT="$ISABELLE_HOME/heaps"
48 ISABELLE_BROWSER_INFO="$ISABELLE_HOME/browser_info"
51 ISABELLE_USEDIR_OPTIONS="$ISABELLE_USEDIR_OPTIONS %s -t true -v true -d pdf -g true -i true"
52 Z3_NON_COMMERCIAL="yes"
54 ''' % (isabelle_path, parallelism_options, more_settings)
56 writer = open(path.join(loc_isabelle, 'etc', 'settings'), 'a')
57 writer.write(extra_settings)
61 def extract_isabelle_run_timing(logdata):
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):
74 t[name]['threads'] = int(threads)
75 t[name]['elapsed_inner'] = elapsed
76 t[name]['cpu_inner'] = cpu
82 def extract_isabelle_run_summary(logdata):
84 re_error = re.compile(r'^(?:make: )?\*\*\* (.*)$', re.MULTILINE)
85 summary = '\n'.join(re_error.findall(logdata))
92 def isabelle_usedir(env, isa_path, isabelle_usedir_opts, base_image, dir_name):
94 return env.run_process('%s/bin/isabelle' % isa_path, 'usedir',
95 isabelle_usedir_opts, base_image, dir_name)
98 def isabelle_dependency_only(env, case, paths, dep_paths, playground):
100 isabelle_home = paths[0]
101 result = path.join(isabelle_home, 'heaps')
103 for dep_path in dep_paths:
104 subprocess.check_call(['cp', '-R'] + glob(dep_path + '/*') + [result])
106 return (True, 'ok', {}, {}, result)
109 def build_isabelle_image(subdir, base, img, env, case, paths, dep_paths, playground, more_settings=''):
111 isabelle_home = paths[0]
112 dep_path = dep_paths[0]
113 prepare_isabelle_repository(p, env.settings.contrib, dep_path, more_settings=more_settings)
114 os.chdir(path.join(isabelle_home, 'src', subdir))
116 (return_code, log) = isabelle_usedir(env, isabelle_home, '-b', base, img)
118 result = path.join(isabelle_home, 'heaps')
119 return (return_code == 0, extract_isabelle_run_summary(log),
120 {'timing': extract_isabelle_run_timing(log)}, {'log': log}, result)
123 def isabelle_make(subdir, env, case, paths, dep_paths, playground, more_settings='', target='all'):
125 isabelle_home = paths[0]
126 dep_path = dep_paths[0] if dep_paths else None
127 prepare_isabelle_repository(isabelle_home, env.settings.contrib, dep_path, more_settings=more_settings)
128 os.chdir(path.join(isabelle_home, subdir))
130 (return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'make', '-k', target)
132 return (return_code == 0, extract_isabelle_run_summary(log),
133 {'timing': extract_isabelle_run_timing(log)}, {'log': log}, None)
136 def isabelle_makeall(env, case, paths, dep_paths, playground, more_settings='', target='all'):
138 isabelle_home = paths[0]
139 dep_path = dep_paths[0] if dep_paths else None
140 prepare_isabelle_repository(isabelle_home, env.settings.contrib, dep_path, more_settings=more_settings)
141 os.chdir(isabelle_home)
143 (return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'makeall', '-k', target)
145 return (return_code == 0, extract_isabelle_run_summary(log),
146 {'timing': extract_isabelle_run_timing(log)}, {'log': log}, None)
149 # Isabelle configurations
151 @configuration(repos = [Isabelle], deps = [])
152 def Pure(env, case, paths, dep_paths, playground):
155 isabelle_home = paths[0]
156 prepare_isabelle_repository(isabelle_home, env.settings.contrib, '')
157 os.chdir(path.join(isabelle_home, 'src', 'Pure'))
159 (return_code, log) = env.run_process('%s/bin/isabelle' % isabelle_home, 'make', 'Pure')
161 result = path.join(isabelle_home, 'heaps')
162 return (return_code == 0, extract_isabelle_run_summary(log),
163 {'timing': extract_isabelle_run_timing(log)}, {'log': log}, result)
165 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
168 return build_isabelle_image('FOL', 'Pure', 'FOL', *args)
170 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
173 return build_isabelle_image('HOL', 'Pure', 'HOL', *args)
175 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
176 def HOL_HOLCF(*args):
177 """HOL-HOLCF image"""
178 return build_isabelle_image('HOL/HOLCF', 'HOL', 'HOLCF', *args)
180 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
181 def HOL_Nominal(*args):
182 """HOL-Nominal image"""
183 return build_isabelle_image('HOL/Nominal', 'HOL', 'HOL-Nominal', *args)
185 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
188 return build_isabelle_image('HOL/Word', 'HOL', 'HOL-Word', *args)
190 @configuration(repos = [Isabelle], deps = [
196 def AFP_images(*args):
197 """Isabelle images needed for the AFP"""
198 return isabelle_dependency_only(*args)
200 @configuration(repos = [Isabelle], deps = [
203 def Isabelle_makeall(*args):
204 """Isabelle makeall"""
205 return isabelle_makeall(*args)
208 # Mutabelle configurations
210 def invoke_mutabelle(theory, env, case, paths, dep_paths, playground):
212 """Mutant testing for counterexample generators in Isabelle"""
214 (loc_isabelle,) = paths
215 (dep_isabelle,) = dep_paths
216 prepare_isabelle_repository(loc_isabelle, env.settings.contrib, dep_isabelle)
217 os.chdir(loc_isabelle)
219 (return_code, log) = env.run_process('bin/isabelle',
220 'mutabelle', '-O', playground, theory)
223 mutabelle_log = util.readfile(path.join(playground, 'log'))
227 return (return_code == 0 and mutabelle_log != '', extract_isabelle_run_summary(log),
228 {'timing': extract_isabelle_run_timing(log)},
229 {'log': log, 'mutabelle_log': mutabelle_log}, None)
231 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
232 def Mutabelle_Relation(*args):
233 """Mutabelle regression suite on Relation theory"""
234 return invoke_mutabelle('Relation', *args)
236 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
237 def Mutabelle_List(*args):
238 """Mutabelle regression suite on List theory"""
239 return invoke_mutabelle('List', *args)
241 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
242 def Mutabelle_Set(*args):
243 """Mutabelle regression suite on Set theory"""
244 return invoke_mutabelle('Set', *args)
246 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
247 def Mutabelle_Map(*args):
248 """Mutabelle regression suite on Map theory"""
249 return invoke_mutabelle('Map', *args)
251 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
252 def Mutabelle_Divides(*args):
253 """Mutabelle regression suite on Divides theory"""
254 return invoke_mutabelle('Divides', *args)
256 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
257 def Mutabelle_MacLaurin(*args):
258 """Mutabelle regression suite on MacLaurin theory"""
259 return invoke_mutabelle('MacLaurin', *args)
261 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
262 def Mutabelle_Fun(*args):
263 """Mutabelle regression suite on Fun theory"""
264 return invoke_mutabelle('Fun', *args)
267 # Judgement Day configurations
269 judgement_day_provers = ('e', 'spass', 'vampire', 'z3', 'cvc3', 'yices')
271 def judgement_day(base_path, theory, opts, env, case, paths, dep_paths, playground):
272 """Judgement Day regression suite"""
275 dep_path = dep_paths[0]
277 os.chdir(path.join(playground, '..', base_path)) # Mirabelle requires specific cwd
278 prepare_isabelle_repository(isa, env.settings.contrib, dep_path)
284 for atp in judgement_day_provers:
286 log_dir = path.join(playground, 'mirabelle_log_' + atp)
289 cmd = ('%s/bin/isabelle mirabelle -q -O %s sledgehammer[prover=%s,%s] %s.thy'
290 % (isa, log_dir, atp, opts, theory))
293 output[atp] = util.readfile(path.join(log_dir, theory + '.log'))
295 percentages = list(re.findall(r'Success rate: (\d+)%', output[atp]))
296 if len(percentages) == 2:
297 success_rates[atp] = {
298 'sledgehammer': int(percentages[0]),
299 'metis': int(percentages[1])}
300 if success_rates[atp]['sledgehammer'] > 0:
303 success_rates[atp] = {}
306 data = {'success_rates': success_rates}
307 raw_attachments = dict((atp + "_output", output[atp]) for atp in judgement_day_provers)
309 return (some_success, '', data, raw_attachments, None)
312 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
314 """Judgement Day regression suite NS"""
315 return judgement_day('Isabelle/src/HOL/Auth', 'NS_Shared', 'prover_timeout=10', *args)
317 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
319 """Judgement Day regression suite FTA"""
320 return judgement_day('Isabelle/src/HOL/Library', 'Fundamental_Theorem_Algebra', 'prover_timeout=10', *args)
322 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
324 """Judgement Day regression suite Hoare"""
325 return judgement_day('Isabelle/src/HOL/IMPP', 'Hoare', 'prover_timeout=10', *args)
327 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
329 """Judgement Day regression suite SN"""
330 return judgement_day('Isabelle/src/HOL/Proofs/Lambda', 'StrongNorm', 'prover_timeout=10', *args)
337 ML_HOME="/home/smlnj/110.72/bin"
338 ML_OPTIONS="@SMLdebug=/dev/null @SMLalloc=256"
339 ML_PLATFORM=$(eval $("$ML_HOME/.arch-n-opsys" 2>/dev/null); echo "$HEAP_SUFFIX")
342 @configuration(repos = [Isabelle], deps = [])
344 """HOL image built with SML/NJ"""
345 return isabelle_make('src/HOL', *args, more_settings=smlnj_settings, target='HOL')
347 @configuration(repos = [Isabelle], deps = [])
348 def SML_makeall(*args):
349 """Makeall built with SML/NJ"""
350 return isabelle_makeall(*args, more_settings=smlnj_settings)