src/HOL/Tools/ATP_Manager/atp_wrapper.ML
author blanchet
Thu, 22 Apr 2010 13:50:58 +0200
changeset 36286 fa6d03d42aab
parent 36284 0e24322474a4
child 36287 96f45c5ffb36
permissions -rw-r--r--
"remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32327
0971cc0b6a57 src/HOL/Tools/ATP_Manager as separate component, with (almost) everything in one place;
wenzelm
parents: 32257
diff changeset
     1
(*  Title:      HOL/Tools/ATP_Manager/atp_wrapper.ML
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     2
    Author:     Fabian Immler, TU Muenchen
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     3
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     4
Wrapper functions for external ATPs.
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     5
*)
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     6
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     7
signature ATP_WRAPPER =
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     8
sig
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
     9
  type prover = ATP_Manager.prover
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    10
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    11
  (* hooks for problem files *)
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    12
  val destdir : string Config.T
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    13
  val problem_prefix : string Config.T
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    14
  val measure_runtime : bool Config.T
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    15
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    16
  val refresh_systems_on_tptp : unit -> unit
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    17
  val setup : theory -> theory
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    18
end;
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    19
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    20
structure ATP_Wrapper : ATP_WRAPPER =
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    21
struct
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    22
36187
4deef08608ee added timestamp to proof
blanchet
parents: 36169
diff changeset
    23
open Sledgehammer_Util
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    24
open Sledgehammer_Fact_Preprocessor
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    25
open Sledgehammer_HOL_Clause
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    26
open Sledgehammer_Fact_Filter
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    27
open Sledgehammer_Proof_Reconstruct
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    28
open ATP_Manager
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
    29
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    30
(** generic ATP wrapper **)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    31
32944
ecc0705174c2 clarified File.platform_path vs. File.shell_path;
wenzelm
parents: 32942
diff changeset
    32
(* external problem files *)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    33
36001
992839c4be90 static defaults for configuration options;
wenzelm
parents: 35969
diff changeset
    34
val (destdir, destdir_setup) = Attrib.config_string "atp_destdir" (K "");
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    35
  (*Empty string means create files in Isabelle's temporary files directory.*)
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    36
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    37
val (problem_prefix, problem_prefix_setup) =
36001
992839c4be90 static defaults for configuration options;
wenzelm
parents: 35969
diff changeset
    38
  Attrib.config_string "atp_problem_prefix" (K "prob");
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    39
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    40
val (measure_runtime, measure_runtime_setup) =
36001
992839c4be90 static defaults for configuration options;
wenzelm
parents: 35969
diff changeset
    41
  Attrib.config_bool "atp_measure_runtime" (K false);
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    42
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    43
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
    44
(* prover configuration *)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    45
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    46
type prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    47
 {command: Path.T,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    48
  arguments: Time.time -> string,
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    49
  known_failures: (string list * string) list,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    50
  max_new_clauses: int,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
    51
  prefers_theory_relevant: bool,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    52
  supports_isar_proofs: bool};
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    53
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    54
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    55
(* basic template *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    56
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
    57
fun with_path cleanup after f path =
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
    58
  Exn.capture f path
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
    59
  |> tap (fn _ => cleanup path)
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
    60
  |> Exn.release
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    61
  |> tap (after path);
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
    62
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    63
fun find_known_failure known_failures proof =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    64
  case map_filter (fn (patterns, message) =>
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    65
                      if exists (fn pattern => String.isSubstring pattern proof)
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    66
                                patterns then
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    67
                        SOME message
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    68
                      else
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    69
                        NONE) known_failures of
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    70
    [] => if is_proof_well_formed proof then ""
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    71
          else "Error: The ATP output is ill-formed."
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    72
  | (message :: _) => message
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    73
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
    74
fun generic_prover overlord get_facts prepare write_file cmd args known_failures
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36231
diff changeset
    75
        proof_text name ({debug, full_types, explicit_apply, ...} : params)
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
    76
        minimize_command
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    77
        ({subgoal, goal, relevance_override, axiom_clauses, filtered_clauses}
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    78
         : problem) =
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    79
  let
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
    80
    (* get clauses and prepare them for writing *)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    81
    val (ctxt, (chain_ths, th)) = goal;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    82
    val thy = ProofContext.theory_of ctxt;
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    83
    val chain_ths = map (Thm.put_name_hint chained_hint) chain_ths;
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    84
    val goal_cls = #1 (neg_conjecture_clauses ctxt th subgoal);
31752
19a5f1c8a844 use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents: 31751
diff changeset
    85
    val the_filtered_clauses =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    86
      (case filtered_clauses of
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    87
        NONE => get_facts relevance_override goal goal_cls
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    88
      | SOME fcls => fcls);
31409
d8537ba165b5 split preparing clauses and writing problemfile;
immler@in.tum.de
parents: 31368
diff changeset
    89
    val the_axiom_clauses =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    90
      (case axiom_clauses of
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    91
        NONE => the_filtered_clauses
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    92
      | SOME axcls => axcls);
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
    93
    val (internal_thm_names, clauses) =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    94
      prepare goal_cls chain_ths the_axiom_clauses the_filtered_clauses thy;
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
    95
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    96
    (* path to unique problem file *)
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
    97
    val destdir' = if overlord then getenv "ISABELLE_HOME_USER"
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
    98
                   else Config.get ctxt destdir;
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
    99
    val problem_prefix' = Config.get ctxt problem_prefix;
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   100
    fun prob_pathname nr =
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   101
      let
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   102
        val probfile =
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   103
          Path.basic (problem_prefix' ^
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   104
                      (if overlord then "_" ^ name else serial_string ())
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   105
                      ^ "_" ^ string_of_int nr)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   106
      in
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   107
        if destdir' = "" then File.tmp_path probfile
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   108
        else if File.exists (Path.explode destdir')
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   109
        then Path.append (Path.explode destdir') probfile
36169
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36167
diff changeset
   110
        else error ("No such directory: " ^ destdir' ^ ".")
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   111
      end;
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   112
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
   113
    (* write out problem file and call prover *)
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   114
    fun cmd_line probfile =
36284
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   115
      (if Config.get ctxt measure_runtime then
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   116
         "TIMEFORMAT='%3U'; { time " ^ space_implode " " [File.shell_path cmd,
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   117
         args, File.shell_path probfile] ^ " ; } 2>&1"
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   118
       else
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   119
         space_implode " " ["exec", File.shell_path cmd, args,
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   120
         File.shell_path probfile, "2>&1"]) ^
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   121
      (if overlord then
36286
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   122
         " | sed 's/,/, /g' \
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   123
         \| sed 's/\\([^!=]\\)\\([=|]\\)\\([^=]\\)/\\1 \\2 \\3/g' \
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   124
         \| sed 's/! =/ !=/g' \
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   125
         \| sed 's/  / /g' | sed 's/| |/||/g' \
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   126
         \| sed 's/ = = =/===/g' \
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   127
         \| sed 's/= = /== /g'"
36284
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   128
       else
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   129
         "")
32510
1b56f8b1e5cc added runtime information to sledgehammer
boehmes
parents: 32458
diff changeset
   130
    fun split_time s =
1b56f8b1e5cc added runtime information to sledgehammer
boehmes
parents: 32458
diff changeset
   131
      let
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   132
        val split = String.tokens (fn c => str c = "\n");
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   133
        val (proof, t) = s |> split |> split_last |> apfst cat_lines;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   134
        fun as_num f = f >> (fst o read_int);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   135
        val num = as_num (Scan.many1 Symbol.is_ascii_digit);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   136
        val digit = Scan.one Symbol.is_ascii_digit;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   137
        val num3 = as_num (digit ::: digit ::: (digit >> single));
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   138
        val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   139
        val as_time = the_default 0 o Scan.read Symbol.stopper time o explode;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   140
      in (proof, as_time t) end;
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   141
    fun split_time' s =
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   142
      if Config.get ctxt measure_runtime then split_time s else (s, 0)
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   143
    fun run_on probfile =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   144
      if File.exists cmd then
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36231
diff changeset
   145
        write_file full_types explicit_apply probfile clauses
35010
d6e492cea6e4 renamed system/system_out to bash/bash_output -- to emphasized that this is really GNU bash, not some undefined POSIX sh;
wenzelm
parents: 33316
diff changeset
   146
        |> pair (apfst split_time' (bash_output (cmd_line probfile)))
36167
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 36143
diff changeset
   147
      else error ("Bad executable: " ^ Path.implode cmd ^ ".");
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   148
36167
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 36143
diff changeset
   149
    (* If the problem file has not been exported, remove it; otherwise, export
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 36143
diff changeset
   150
       the proof file too. *)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   151
    fun cleanup probfile = if destdir' = "" then try File.rm probfile else NONE;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   152
    fun export probfile (((proof, _), _), _) =
36187
4deef08608ee added timestamp to proof
blanchet
parents: 36169
diff changeset
   153
      if destdir' = "" then
4deef08608ee added timestamp to proof
blanchet
parents: 36169
diff changeset
   154
        ()
4deef08608ee added timestamp to proof
blanchet
parents: 36169
diff changeset
   155
      else
4deef08608ee added timestamp to proof
blanchet
parents: 36169
diff changeset
   156
        File.write (Path.explode (Path.implode probfile ^ "_proof"))
36282
9a7c5b86a105 generate command-line in addition to timestamp in ATP output file, for debugging purposes
blanchet
parents: 36281
diff changeset
   157
                   ((if overlord then
9a7c5b86a105 generate command-line in addition to timestamp in ATP output file, for debugging purposes
blanchet
parents: 36281
diff changeset
   158
                       "% " ^ cmd_line probfile ^ "\n% " ^ timestamp () ^ "\n"
9a7c5b86a105 generate command-line in addition to timestamp in ATP output file, for debugging purposes
blanchet
parents: 36281
diff changeset
   159
                     else
9a7c5b86a105 generate command-line in addition to timestamp in ATP output file, for debugging purposes
blanchet
parents: 36281
diff changeset
   160
                        "") ^ proof)
32257
bad5a99c16d8 neg_conjecture_clauses, neg_clausify_tac: proper context, eliminated METAHYPS;
wenzelm
parents: 32091
diff changeset
   161
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36223
diff changeset
   162
    val (((proof, atp_run_time_in_msecs), rc), _) =
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   163
      with_path cleanup export run_on (prob_pathname subgoal);
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   164
36167
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 36143
diff changeset
   165
    (* Check for success and print out some information on failure. *)
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   166
    val failure = find_known_failure known_failures proof;
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   167
    val success = rc = 0 andalso failure = "";
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   168
    val (message, relevant_thm_names) =
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   169
      if success then
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   170
        proof_text ctxt minimize_command proof internal_thm_names th subgoal
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   171
      else if failure <> "" then
36284
0e24322474a4 postprocess ATP output in "overlord" mode to make it more readable
blanchet
parents: 36283
diff changeset
   172
        (failure ^ "\n", [])
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   173
      else
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   174
        ("Unknown ATP error: " ^ proof ^ ".\n", [])
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   175
  in
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36223
diff changeset
   176
    {success = success, message = message,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   177
     relevant_thm_names = relevant_thm_names,
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   178
     atp_run_time_in_msecs = atp_run_time_in_msecs, proof = proof,
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   179
     internal_thm_names = internal_thm_names,
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   180
     filtered_clauses = the_filtered_clauses}
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   181
  end;
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   182
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   183
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   184
(* generic TPTP-based provers *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   185
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   186
fun generic_tptp_prover
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   187
        (name, {command, arguments, known_failures, max_new_clauses,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   188
                prefers_theory_relevant, supports_isar_proofs})
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   189
        (params as {debug, overlord, respect_no_atp, relevance_threshold,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   190
                    convergence, theory_relevant, higher_order, follow_defs,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   191
                    isar_proof, modulus, sorts, ...})
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   192
        minimize_command timeout =
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   193
  generic_prover overlord
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36001
diff changeset
   194
      (get_relevant_facts respect_no_atp relevance_threshold convergence
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36001
diff changeset
   195
                          higher_order follow_defs max_new_clauses
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   196
                          (the_default prefers_theory_relevant theory_relevant))
36222
0e3e49bd658d don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents: 36220
diff changeset
   197
      (prepare_clauses higher_order false)
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   198
      (write_tptp_file (debug andalso overlord andalso not isar_proof)) command
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   199
      (arguments timeout) known_failures
36283
25e69e93954d failure of reconstructing the Isar proof (e.g., exception) should not prevent Sledgehammer from showing the short one-liner proof -- but in "debug" mode we do want to know what the exception is
blanchet
parents: 36282
diff changeset
   200
      (proof_text (supports_isar_proofs andalso isar_proof) debug modulus sorts)
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   201
      name params minimize_command
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   202
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   203
fun tptp_prover name p = (name, generic_tptp_prover (name, p));
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   204
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   205
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   206
(** common provers **)
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   207
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   208
fun generous_to_secs time = (Time.toMilliseconds time + 999) div 1000
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   209
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   210
(* Vampire *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   211
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   212
(* NB: Vampire does not work without explicit time limit. *)
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   213
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   214
val vampire_config : prover_config =
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   215
  {command = Path.explode "$VAMPIRE_HOME/vampire",
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   216
   arguments = (fn timeout => "--output_syntax tptp --mode casc -t " ^
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   217
                              string_of_int (generous_to_secs timeout)),
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   218
   known_failures =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   219
     [(["Satisfiability detected", "CANNOT PROVE"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   220
       "The ATP problem is unprovable."),
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   221
      (["Refutation not found"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   222
       "The ATP failed to determine the problem's status.")],
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   223
   max_new_clauses = 60,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   224
   prefers_theory_relevant = false,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   225
   supports_isar_proofs = true}
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   226
val vampire = tptp_prover "vampire" vampire_config
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   227
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   228
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   229
(* E prover *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   230
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   231
val e_config : prover_config =
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   232
  {command = Path.explode "$E_HOME/eproof",
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   233
   arguments = (fn timeout => "--tstp-in --tstp-out -l5 -xAutoDev \
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   234
                              \-tAutoDev --silent --cpu-limit=" ^
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   235
                              string_of_int (generous_to_secs timeout)),
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   236
   known_failures =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   237
       [(["SZS status: Satisfiable", "SZS status Satisfiable"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   238
         "The ATP problem is unprovable."),
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   239
        (["SZS status: ResourceOut", "SZS status ResourceOut"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   240
         "The ATP ran out of resources."),
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   241
        (["# Cannot determine problem status"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   242
         "The ATP failed to determine the problem's status.")],
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   243
   max_new_clauses = 100,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   244
   prefers_theory_relevant = false,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   245
   supports_isar_proofs = true}
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   246
val e = tptp_prover "e" e_config
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   247
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   248
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   249
(* SPASS *)
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   250
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   251
fun generic_dfg_prover
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   252
        (name, ({command, arguments, known_failures, max_new_clauses,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   253
                 prefers_theory_relevant, ...} : prover_config))
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   254
        (params as {overlord, respect_no_atp, relevance_threshold, convergence,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   255
                    theory_relevant, higher_order, follow_defs, ...})
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   256
        minimize_command timeout =
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   257
  generic_prover overlord
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36001
diff changeset
   258
      (get_relevant_facts respect_no_atp relevance_threshold convergence
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36001
diff changeset
   259
                          higher_order follow_defs max_new_clauses
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   260
                          (the_default prefers_theory_relevant theory_relevant))
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   261
      (prepare_clauses higher_order true) write_dfg_file command
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   262
      (arguments timeout) known_failures (K metis_proof_text)
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36265
diff changeset
   263
      name params minimize_command
32869
159309603edc recovered support for Spass: re-enabled writing problems in DFG format
boehmes
parents: 32864
diff changeset
   264
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   265
fun dfg_prover name p = (name, generic_dfg_prover (name, p))
32869
159309603edc recovered support for Spass: re-enabled writing problems in DFG format
boehmes
parents: 32864
diff changeset
   266
36219
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36190
diff changeset
   267
(* The "-VarWeight=3" option helps the higher-order problems, probably by
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36190
diff changeset
   268
   counteracting the presence of "hAPP". *)
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   269
val spass_config : prover_config =
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   270
 {command = Path.explode "$SPASS_HOME/SPASS",
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   271
  arguments = (fn timeout => "-Auto -SOS=1 -PGiven=0 -PProblem=0 -Splits=0" ^
36219
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36190
diff changeset
   272
    " -FullRed=0 -DocProof -VarWeight=3 -TimeLimit=" ^
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   273
    string_of_int (generous_to_secs timeout)),
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   274
  known_failures =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   275
    [(["SPASS beiseite: Completion found."], "The ATP problem is unprovable."),
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   276
     (["SPASS beiseite: Ran out of time."], "The ATP timed out."),
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   277
     (["SPASS beiseite: Maximal number of loops exceeded."],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   278
      "The ATP hit its loop limit.")],
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   279
  max_new_clauses = 40,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   280
  prefers_theory_relevant = true,
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   281
  supports_isar_proofs = false}
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   282
val spass = dfg_prover "spass" spass_config
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   283
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   284
(* SPASS 3.7 supports both the DFG and the TPTP syntax, whereas SPASS 3.0
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   285
   supports only the DFG syntax. As soon as all Isabelle repository/snapshot
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   286
   users have upgraded to 3.7, we can kill "spass" (and all DFG support in
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   287
   Sledgehammer) and rename "spass_tptp" "spass". *)
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   288
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   289
(* FIXME: Change the error message below to point to the Isabelle download
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   290
   page once the package is there (around the Isabelle2010 release). *)
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   291
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   292
val spass_tptp_config =
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   293
  {command = #command spass_config,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   294
   arguments = prefix "-TPTP " o #arguments spass_config,
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   295
   known_failures =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   296
     #known_failures spass_config @
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   297
     [(["unrecognized option `-TPTP'", "Unrecognized option TPTP"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   298
       "Warning: Sledgehammer requires a more recent version of SPASS with \
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   299
       \support for the TPTP syntax. To install it, download and untar the \
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   300
       \package \"http://isabelle.in.tum.de/~blanchet/spass-3.7.tgz\" and add \
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   301
       \the \"spass-3.7\" directory's full path to \"" ^
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   302
       Path.implode (Path.expand (Path.appends
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   303
           (Path.variable "ISABELLE_HOME_USER" ::
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   304
            map Path.basic ["etc", "components"]))) ^
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   305
       "\" on a line of its own.")],
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   306
   max_new_clauses = #max_new_clauses spass_config,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   307
   prefers_theory_relevant = #prefers_theory_relevant spass_config,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   308
   supports_isar_proofs = #supports_isar_proofs spass_config}
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   309
val spass_tptp = tptp_prover "spass_tptp" spass_tptp_config
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   310
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   311
(* remote prover invocation via SystemOnTPTP *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   312
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   313
val systems = Synchronized.var "atp_wrapper_systems" ([]: string list);
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   314
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   315
fun get_systems () =
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   316
  let
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   317
    val (answer, rc) = bash_output "\"$ISABELLE_ATP_MANAGER/SystemOnTPTP\" -w"
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   318
  in
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   319
    if rc <> 0 then
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   320
      error ("Failed to get available systems at SystemOnTPTP:\n" ^ answer)
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   321
    else
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   322
      split_lines answer
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   323
  end;
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   324
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   325
fun refresh_systems_on_tptp () =
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   326
  Synchronized.change systems (fn _ => get_systems ());
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   327
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   328
fun get_system prefix = Synchronized.change_result systems (fn systems =>
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   329
  (if null systems then get_systems () else systems)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   330
  |> `(find_first (String.isPrefix prefix)));
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   331
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
   332
fun the_system prefix =
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   333
  (case get_system prefix of
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
   334
    NONE => error ("System " ^ quote prefix ^ " not available at SystemOnTPTP")
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   335
  | SOME sys => sys);
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   336
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   337
val remote_known_failures =
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   338
  [(["Remote-script could not extract proof"],
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   339
    "Error: The remote ATP proof is ill-formed.")]
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   340
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   341
fun remote_prover_config prover_prefix args
36286
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   342
        ({known_failures, max_new_clauses, prefers_theory_relevant,
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   343
          supports_isar_proofs, ...}
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   344
         : prover_config) : prover_config =
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   345
  {command = Path.explode "$ISABELLE_ATP_MANAGER/SystemOnTPTP",
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   346
   arguments = (fn timeout =>
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36064
diff changeset
   347
     args ^ " -t " ^ string_of_int (generous_to_secs timeout) ^ " -s " ^
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   348
     the_system prover_prefix),
36265
41c9e755e552 distinguish between the different ATP errors in the user interface;
blanchet
parents: 36264
diff changeset
   349
   known_failures = remote_known_failures @ known_failures,
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   350
   max_new_clauses = max_new_clauses,
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36219
diff changeset
   351
   prefers_theory_relevant = prefers_theory_relevant,
36286
fa6d03d42aab "remote_e" and "remote_vampire" support TSTP proof output + fix "overlord" mode ATP output postprocessing
blanchet
parents: 36284
diff changeset
   352
   supports_isar_proofs = supports_isar_proofs}
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   353
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   354
val remote_vampire =
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   355
  tptp_prover "remote_vampire"
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   356
              (remote_prover_config "Vampire---9" "" vampire_config)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   357
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   358
val remote_e =
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   359
  tptp_prover "remote_e" (remote_prover_config "EP---" "" e_config)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   360
35969
c9565298df9e added support for Sledgehammer parameters;
blanchet
parents: 35869
diff changeset
   361
val remote_spass =
36059
ab3dfdeb9603 made "theory_const" a Sledgehammer option;
blanchet
parents: 36058
diff changeset
   362
  tptp_prover "remote_spass" (remote_prover_config "SPASS---" "-x" spass_config)
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   363
36264
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   364
val provers = [spass, spass_tptp, vampire, e, remote_vampire, remote_spass,
3c2490917710 added "spass_tptp" prover, which requires SPASS x.y > 3.0;
blanchet
parents: 36235
diff changeset
   365
               remote_e]
35867
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   366
val prover_setup = fold add_prover provers
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   367
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   368
val setup =
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   369
  destdir_setup
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   370
  #> problem_prefix_setup
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   371
  #> measure_runtime_setup
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   372
  #> prover_setup;
16279c4c7a33 move all ATP setup code into ATP_Wrapper
blanchet
parents: 35865
diff changeset
   373
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   374
end;