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