split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
2 # Author: Jasmin Blanchette and Sascha Boehme
4 # Testing tool for automated proof tools.
11 my $isabelle_home = $ENV{'ISABELLE_HOME'};
12 my $mirabelle_home = $ENV{'MIRABELLE_HOME'};
13 my $mirabelle_logic = $ENV{'MIRABELLE_LOGIC'};
14 my $mirabelle_theory = $ENV{'MIRABELLE_THEORY'};
15 my $output_path = $ENV{'MIRABELLE_OUTPUT_PATH'};
16 my $verbose = $ENV{'MIRABELLE_VERBOSE'};
17 my $timeout = $ENV{'MIRABELLE_TIMEOUT'};
19 my $mirabelle_thy = $mirabelle_home . "/Mirabelle";
24 my $actions = $ARGV[0];
26 my $thy_file = $ARGV[1];
29 if ($thy_file =~ /^(.*)\[([0-9]+)\:(~?[0-9]+)\]$/) { # FIXME
34 my ($thy_name, $path, $ext) = fileparse($thy_file, ".thy");
35 my $new_thy_name = $thy_name . "_Mirabelle";
36 my $new_thy_file = $output_path . "/" . $new_thy_name . $ext;
41 my $setup_thy_name = $thy_name . "_Setup";
42 my $setup_file = $output_path . "/" . $setup_thy_name . ".thy";
43 my $log_file = $output_path . "/" . $thy_name . ".log";
46 foreach (split(/:/, $actions)) {
48 push @action_files, "\"$mirabelle_home/Tools/mirabelle_$1.ML\"";
52 if ($#action_files >= 0) {
53 $tools = "uses " . join(" ", @action_files);
56 open(SETUP_FILE, ">$setup_file") || die "Could not create file '$setup_file'";
58 print SETUP_FILE <<END;
59 theory "$setup_thy_name"
60 imports "$mirabelle_thy" "$mirabelle_theory"
65 Mirabelle.set_logfile "$log_file" #>
66 Config.put_thy Mirabelle.timeout $timeout #>
67 Config.put_thy Mirabelle.verbose $verbose #>
68 Config.put_thy Mirabelle.start_line $start_line #>
69 Config.put_thy Mirabelle.end_line $end_line
74 foreach (split(/:/, $actions)) {
75 if (m/([^[]*)(?:\[(.*)\])?/) {
76 my ($name, $settings_str) = ($1, $2 || "");
77 $name =~ s/^([a-z])/\U$1/;
78 print SETUP_FILE "setup {* Mirabelle_$name.invoke [";
80 foreach (split(/,/, $settings_str)) {
81 if (m/\s*(.*)\s*=\s*(.*)\s*/) {
82 print SETUP_FILE "$sep(\"$1\", \"$2\")";
86 print SETUP_FILE "] *}\n";
90 print SETUP_FILE "\nend";
94 # modify target theory file
96 open(OLD_FILE, "<$thy_file") || die "Cannot open file '$thy_file'";
97 my @lines = <OLD_FILE>;
100 my $thy_text = join("", @lines);
101 my $old_len = length($thy_text);
102 $thy_text =~ s/\btheory\b[^\n]*\s*\bimports\s/theory $new_thy_name\nimports "$setup_thy_name" /gm;
103 die "No 'imports' found" if length($thy_text) == $old_len;
105 open(NEW_FILE, ">$new_thy_file") || die "Cannot create file '$new_thy_file'";
106 print NEW_FILE $thy_text;
109 my $root_file = "$output_path/ROOT_$thy_name.ML";
110 open(ROOT_FILE, ">$root_file") || die "Cannot create file '$root_file'";
111 print ROOT_FILE "use_thy \"$output_path/$new_thy_name\";\n";
117 my $r = system "$isabelle_home/bin/isabelle-process " .
118 "-e 'use \"$root_file\";' -q $mirabelle_logic" . "\n";
124 unlink $new_thy_file;