src/HOL/Tools/Sledgehammer/sledgehammer.ML
author blanchet
Thu Oct 21 14:55:09 2010 +0200 (2010-10-21 ago)
changeset 40059 6ad9081665db
parent 39494 bf7dd4902321
child 40060 5ef6747aa619
permissions -rw-r--r--
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet@38021
     1
(*  Title:      HOL/Tools/Sledgehammer/sledgehammer.ML
wenzelm@28477
     2
    Author:     Fabian Immler, TU Muenchen
wenzelm@32996
     3
    Author:     Makarius
blanchet@35969
     4
    Author:     Jasmin Blanchette, TU Muenchen
wenzelm@28477
     5
blanchet@38021
     6
Sledgehammer's heart.
wenzelm@28477
     7
*)
wenzelm@28477
     8
blanchet@38021
     9
signature SLEDGEHAMMER =
wenzelm@28477
    10
sig
blanchet@38023
    11
  type failure = ATP_Systems.failure
blanchet@38988
    12
  type locality = Sledgehammer_Filter.locality
blanchet@38988
    13
  type relevance_override = Sledgehammer_Filter.relevance_override
blanchet@39004
    14
  type fol_formula = Sledgehammer_Translate.fol_formula
blanchet@38988
    15
  type minimize_command = Sledgehammer_Reconstruct.minimize_command
blanchet@39493
    16
blanchet@35969
    17
  type params =
blanchet@38982
    18
    {blocking: bool,
blanchet@38982
    19
     debug: bool,
blanchet@35969
    20
     verbose: bool,
blanchet@36143
    21
     overlord: bool,
blanchet@40059
    22
     provers: string list,
blanchet@35969
    23
     full_types: bool,
blanchet@36235
    24
     explicit_apply: bool,
blanchet@38745
    25
     relevance_thresholds: real * real,
blanchet@38744
    26
     max_relevant: int option,
blanchet@35969
    27
     isar_proof: bool,
blanchet@36924
    28
     isar_shrink_factor: int,
blanchet@38985
    29
     timeout: Time.time,
blanchet@38985
    30
     expect: string}
blanchet@39493
    31
blanchet@40059
    32
  type atp_problem =
blanchet@39318
    33
    {state: Proof.state,
blanchet@38998
    34
     goal: thm,
blanchet@38998
    35
     subgoal: int,
blanchet@39366
    36
     axioms: (term * ((string * locality) * fol_formula) option) list,
blanchet@39366
    37
     only: bool}
blanchet@39493
    38
blanchet@40059
    39
  type atp_result =
blanchet@36370
    40
    {outcome: failure option,
blanchet@35969
    41
     message: string,
blanchet@37926
    42
     pool: string Symtab.table,
blanchet@38752
    43
     used_thm_names: (string * locality) list,
blanchet@35969
    44
     atp_run_time_in_msecs: int,
blanchet@36369
    45
     output: string,
blanchet@39452
    46
     tstplike_proof: string,
blanchet@38818
    47
     axiom_names: (string * locality) list vector,
blanchet@38083
    48
     conjecture_shape: int list list}
blanchet@39493
    49
blanchet@40059
    50
  type atp = params -> minimize_command -> atp_problem -> atp_result
blanchet@35867
    51
blanchet@38023
    52
  val dest_dir : string Config.T
blanchet@38023
    53
  val problem_prefix : string Config.T
blanchet@39003
    54
  val measure_run_time : bool Config.T
blanchet@40059
    55
  val available_provers : theory -> unit
blanchet@40059
    56
  val kill_provers : unit -> unit
blanchet@40059
    57
  val running_provers : unit -> unit
blanchet@40059
    58
  val messages : int option -> unit
blanchet@40059
    59
  val get_atp_fun : theory -> string -> atp
blanchet@38044
    60
  val run_sledgehammer :
blanchet@39318
    61
    params -> bool -> int -> relevance_override -> (string -> minimize_command)
blanchet@39318
    62
    -> Proof.state -> bool * Proof.state
blanchet@38023
    63
  val setup : theory -> theory
wenzelm@28477
    64
end;
wenzelm@28477
    65
blanchet@38021
    66
structure Sledgehammer : SLEDGEHAMMER =
wenzelm@28477
    67
struct
wenzelm@28477
    68
blanchet@38028
    69
open ATP_Problem
blanchet@39491
    70
open ATP_Proof
blanchet@38028
    71
open ATP_Systems
blanchet@39494
    72
open Metis_Translate
blanchet@38023
    73
open Sledgehammer_Util
blanchet@38988
    74
open Sledgehammer_Filter
blanchet@38282
    75
open Sledgehammer_Translate
blanchet@38988
    76
open Sledgehammer_Reconstruct
blanchet@37583
    77
blanchet@38023
    78
blanchet@37583
    79
(** The Sledgehammer **)
blanchet@37583
    80
blanchet@38102
    81
(* Identifier to distinguish Sledgehammer from other tools using
blanchet@38102
    82
   "Async_Manager". *)
blanchet@37585
    83
val das_Tool = "Sledgehammer"
blanchet@37585
    84
blanchet@40059
    85
fun available_provers thy =
blanchet@40059
    86
  priority ("Available provers: " ^
blanchet@40059
    87
             commas (sort_strings (available_atps thy)) ^ ".")
blanchet@35969
    88
blanchet@40059
    89
fun kill_provers () = Async_Manager.kill_threads das_Tool "provers"
blanchet@40059
    90
fun running_provers () = Async_Manager.running_threads das_Tool "provers"
blanchet@40059
    91
val messages = Async_Manager.thread_messages das_Tool "prover"
blanchet@40059
    92
blanchet@40059
    93
(** problems, results, ATPs, etc. **)
blanchet@35969
    94
blanchet@35969
    95
type params =
blanchet@38982
    96
  {blocking: bool,
blanchet@38982
    97
   debug: bool,
blanchet@35969
    98
   verbose: bool,
blanchet@36143
    99
   overlord: bool,
blanchet@40059
   100
   provers: string list,
blanchet@35969
   101
   full_types: bool,
blanchet@36235
   102
   explicit_apply: bool,
blanchet@38745
   103
   relevance_thresholds: real * real,
blanchet@38744
   104
   max_relevant: int option,
blanchet@35969
   105
   isar_proof: bool,
blanchet@36924
   106
   isar_shrink_factor: int,
blanchet@38985
   107
   timeout: Time.time,
blanchet@38985
   108
   expect: string}
blanchet@35867
   109
blanchet@40059
   110
type atp_problem =
blanchet@39318
   111
  {state: Proof.state,
blanchet@38998
   112
   goal: thm,
blanchet@38998
   113
   subgoal: int,
blanchet@39366
   114
   axioms: (term * ((string * locality) * fol_formula) option) list,
blanchet@39366
   115
   only: bool}
blanchet@35867
   116
blanchet@40059
   117
type atp_result =
blanchet@36370
   118
  {outcome: failure option,
blanchet@35969
   119
   message: string,
blanchet@37926
   120
   pool: string Symtab.table,
blanchet@38752
   121
   used_thm_names: (string * locality) list,
blanchet@35969
   122
   atp_run_time_in_msecs: int,
blanchet@36369
   123
   output: string,
blanchet@39452
   124
   tstplike_proof: string,
blanchet@38818
   125
   axiom_names: (string * locality) list vector,
blanchet@38083
   126
   conjecture_shape: int list list}
blanchet@35867
   127
blanchet@40059
   128
type atp = params -> minimize_command -> atp_problem -> atp_result
blanchet@35867
   129
blanchet@38023
   130
(* configuration attributes *)
blanchet@38023
   131
blanchet@38991
   132
val (dest_dir, dest_dir_setup) =
blanchet@39003
   133
  Attrib.config_string "sledgehammer_dest_dir" (K "")
blanchet@38991
   134
  (* Empty string means create files in Isabelle's temporary files directory. *)
blanchet@38023
   135
blanchet@38023
   136
val (problem_prefix, problem_prefix_setup) =
blanchet@39003
   137
  Attrib.config_string "sledgehammer_problem_prefix" (K "prob")
blanchet@38023
   138
blanchet@39003
   139
val (measure_run_time, measure_run_time_setup) =
blanchet@39003
   140
  Attrib.config_bool "sledgehammer_measure_run_time" (K false)
wenzelm@28484
   141
blanchet@38023
   142
fun with_path cleanup after f path =
blanchet@38023
   143
  Exn.capture f path
blanchet@38023
   144
  |> tap (fn _ => cleanup path)
blanchet@38023
   145
  |> Exn.release
blanchet@38023
   146
  |> tap (after path)
blanchet@38023
   147
blanchet@40059
   148
(* generic TPTP-based ATPs *)
blanchet@38023
   149
blanchet@39492
   150
(* Important messages are important but not so important that users want to see
blanchet@39492
   151
   them each time. *)
blanchet@39493
   152
val important_message_keep_factor = 0.1
blanchet@39492
   153
blanchet@40059
   154
fun atp_fun auto atp_name
blanchet@38645
   155
        {exec, required_execs, arguments, has_incomplete_mode, proof_delims,
blanchet@38997
   156
         known_failures, default_max_relevant, explicit_forall,
blanchet@38997
   157
         use_conjecture_for_hypotheses}
blanchet@38455
   158
        ({debug, verbose, overlord, full_types, explicit_apply,
blanchet@38998
   159
          max_relevant, isar_proof, isar_shrink_factor, timeout, ...} : params)
blanchet@40059
   160
        minimize_command ({state, goal, subgoal, axioms, only} : atp_problem) =
blanchet@38023
   161
  let
blanchet@39318
   162
    val ctxt = Proof.context_of state
blanchet@38998
   163
    val (_, hyp_ts, concl_t) = strip_subgoal goal subgoal
blanchet@39366
   164
    val axioms = axioms |> not only
blanchet@39366
   165
                          ? take (the_default default_max_relevant max_relevant)
blanchet@40059
   166
    val dest_dir = if overlord then getenv "ISABELLE_HOME_USER"
blanchet@40059
   167
                   else Config.get ctxt dest_dir
blanchet@40059
   168
    val problem_prefix = Config.get ctxt problem_prefix
blanchet@40059
   169
    val atp_problem_file_name =
blanchet@39003
   170
      Path.basic ((if overlord then "prob_" ^ atp_name
blanchet@40059
   171
                   else problem_prefix ^ serial_string ())
blanchet@39003
   172
                  ^ "_" ^ string_of_int subgoal)
blanchet@40059
   173
    val atp_problem_path_name =
blanchet@40059
   174
      if dest_dir = "" then
blanchet@40059
   175
        File.tmp_path atp_problem_file_name
blanchet@40059
   176
      else if File.exists (Path.explode dest_dir) then
blanchet@40059
   177
        Path.append (Path.explode dest_dir) atp_problem_file_name
blanchet@39003
   178
      else
blanchet@40059
   179
        error ("No such directory: " ^ quote dest_dir ^ ".")
blanchet@39003
   180
    val measure_run_time = verbose orelse Config.get ctxt measure_run_time
blanchet@38092
   181
    val command = Path.explode (getenv (fst exec) ^ "/" ^ snd exec)
blanchet@40059
   182
    (* write out problem file and call ATP *)
blanchet@38645
   183
    fun command_line complete timeout probfile =
blanchet@38023
   184
      let
blanchet@38023
   185
        val core = File.shell_path command ^ " " ^ arguments complete timeout ^
blanchet@38023
   186
                   " " ^ File.shell_path probfile
blanchet@38023
   187
      in
blanchet@39010
   188
        (if measure_run_time then "TIMEFORMAT='%3R'; { time " ^ core ^ " ; }"
blanchet@38744
   189
         else "exec " ^ core) ^ " 2>&1"
blanchet@38023
   190
      end
blanchet@38023
   191
    fun split_time s =
blanchet@38023
   192
      let
blanchet@38023
   193
        val split = String.tokens (fn c => str c = "\n");
blanchet@38023
   194
        val (output, t) = s |> split |> split_last |> apfst cat_lines;
blanchet@38023
   195
        fun as_num f = f >> (fst o read_int);
blanchet@38023
   196
        val num = as_num (Scan.many1 Symbol.is_ascii_digit);
blanchet@38023
   197
        val digit = Scan.one Symbol.is_ascii_digit;
blanchet@38023
   198
        val num3 = as_num (digit ::: digit ::: (digit >> single));
blanchet@38023
   199
        val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b);
blanchet@38023
   200
        val as_time = the_default 0 o Scan.read Symbol.stopper time o explode;
blanchet@38023
   201
      in (output, as_time t) end;
blanchet@38023
   202
    fun run_on probfile =
blanchet@38092
   203
      case filter (curry (op =) "" o getenv o fst) (exec :: required_execs) of
blanchet@38032
   204
        (home_var, _) :: _ =>
blanchet@38023
   205
        error ("The environment variable " ^ quote home_var ^ " is not set.")
blanchet@38032
   206
      | [] =>
blanchet@38032
   207
        if File.exists command then
blanchet@38032
   208
          let
blanchet@39318
   209
            fun run complete timeout =
blanchet@38032
   210
              let
blanchet@38645
   211
                val command = command_line complete timeout probfile
blanchet@38032
   212
                val ((output, msecs), res_code) =
blanchet@38032
   213
                  bash_output command
blanchet@38032
   214
                  |>> (if overlord then
blanchet@38032
   215
                         prefix ("% " ^ command ^ "\n% " ^ timestamp () ^ "\n")
blanchet@38032
   216
                       else
blanchet@38032
   217
                         I)
blanchet@38744
   218
                  |>> (if measure_run_time then split_time else rpair 0)
blanchet@39452
   219
                val (tstplike_proof, outcome) =
blanchet@39452
   220
                  extract_tstplike_proof_and_outcome complete res_code
blanchet@39452
   221
                      proof_delims known_failures output
blanchet@39452
   222
              in (output, msecs, tstplike_proof, outcome) end
blanchet@38032
   223
            val readable_names = debug andalso overlord
blanchet@40059
   224
            val (atp_problem, pool, conjecture_offset, axiom_names) =
blanchet@40059
   225
              prepare_atp_problem ctxt readable_names explicit_forall full_types
blanchet@40059
   226
                                  explicit_apply hyp_ts concl_t axioms
blanchet@39452
   227
            val ss = tptp_strings_for_atp_problem use_conjecture_for_hypotheses
blanchet@40059
   228
                                                  atp_problem
blanchet@38631
   229
            val _ = File.write_list probfile ss
blanchet@38032
   230
            val conjecture_shape =
blanchet@38032
   231
              conjecture_offset + 1 upto conjecture_offset + length hyp_ts + 1
blanchet@38040
   232
              |> map single
blanchet@39318
   233
            val run_twice = has_incomplete_mode andalso not auto
blanchet@38645
   234
            val timer = Timer.startRealTimer ()
blanchet@38032
   235
            val result =
blanchet@39318
   236
              run false (if run_twice then
blanchet@39318
   237
                           Time.fromMilliseconds
blanchet@38645
   238
                                         (2 * Time.toMilliseconds timeout div 3)
blanchet@39318
   239
                         else
blanchet@39318
   240
                           timeout)
blanchet@39318
   241
              |> run_twice
blanchet@38645
   242
                 ? (fn (_, msecs0, _, SOME _) =>
blanchet@39318
   243
                       run true (Time.- (timeout, Timer.checkRealTimer timer))
blanchet@39452
   244
                       |> (fn (output, msecs, tstplike_proof, outcome) =>
blanchet@39452
   245
                              (output, msecs0 + msecs, tstplike_proof, outcome))
blanchet@38645
   246
                     | result => result)
blanchet@38282
   247
          in ((pool, conjecture_shape, axiom_names), result) end
blanchet@38032
   248
        else
blanchet@38032
   249
          error ("Bad executable: " ^ Path.implode command ^ ".")
blanchet@38023
   250
blanchet@38023
   251
    (* If the problem file has not been exported, remove it; otherwise, export
blanchet@38023
   252
       the proof file too. *)
blanchet@38023
   253
    fun cleanup probfile =
blanchet@40059
   254
      if dest_dir = "" then try File.rm probfile else NONE
blanchet@38023
   255
    fun export probfile (_, (output, _, _, _)) =
blanchet@40059
   256
      if dest_dir = "" then
blanchet@38023
   257
        ()
blanchet@38023
   258
      else
blanchet@38023
   259
        File.write (Path.explode (Path.implode probfile ^ "_proof")) output
blanchet@38282
   260
    val ((pool, conjecture_shape, axiom_names),
blanchet@39452
   261
         (output, msecs, tstplike_proof, outcome)) =
blanchet@40059
   262
      with_path cleanup export run_on atp_problem_path_name
blanchet@38282
   263
    val (conjecture_shape, axiom_names) =
blanchet@39493
   264
      repair_conjecture_shape_and_axiom_names output conjecture_shape
blanchet@39493
   265
                                              axiom_names
blanchet@39492
   266
    val important_message =
blanchet@39493
   267
      if random () <= important_message_keep_factor then
blanchet@39492
   268
        extract_important_message output
blanchet@39492
   269
      else
blanchet@39492
   270
        ""
blanchet@39327
   271
    val banner = if auto then "Sledgehammer found a proof"
blanchet@39327
   272
                 else "Try this command"
blanchet@38023
   273
    val (message, used_thm_names) =
blanchet@38023
   274
      case outcome of
blanchet@38023
   275
        NONE =>
blanchet@38023
   276
        proof_text isar_proof
blanchet@38023
   277
            (pool, debug, isar_shrink_factor, ctxt, conjecture_shape)
blanchet@39452
   278
            (banner, full_types, minimize_command, tstplike_proof, axiom_names,
blanchet@39452
   279
             goal, subgoal)
blanchet@38744
   280
        |>> (fn message =>
blanchet@38744
   281
                message ^ (if verbose then
blanchet@39371
   282
                             "\nATP real CPU time: " ^ string_of_int msecs ^
blanchet@39371
   283
                             " ms."
blanchet@38744
   284
                           else
blanchet@39107
   285
                             "") ^
blanchet@39107
   286
                (if important_message <> "" then
blanchet@39107
   287
                   "\n\nImportant message from Dr. Geoff Sutcliffe:\n" ^
blanchet@39107
   288
                   important_message
blanchet@39107
   289
                 else
blanchet@39107
   290
                   ""))
blanchet@38597
   291
      | SOME failure => (string_for_failure failure, [])
blanchet@38023
   292
  in
blanchet@38023
   293
    {outcome = outcome, message = message, pool = pool,
blanchet@38023
   294
     used_thm_names = used_thm_names, atp_run_time_in_msecs = msecs,
blanchet@39452
   295
     output = output, tstplike_proof = tstplike_proof,
blanchet@39452
   296
     axiom_names = axiom_names, conjecture_shape = conjecture_shape}
blanchet@38023
   297
  end
blanchet@38023
   298
blanchet@40059
   299
fun get_atp_fun thy name = atp_fun false name (get_atp thy name)
blanchet@38023
   300
blanchet@40059
   301
fun run_atp (params as {blocking, debug, verbose, max_relevant, timeout, expect,
blanchet@40059
   302
                        ...})
blanchet@40059
   303
            auto i n minimize_command
blanchet@40059
   304
            (atp_problem as {state, goal, axioms, ...})
blanchet@40059
   305
            (atp as {default_max_relevant, ...}, atp_name) =
blanchet@36379
   306
  let
blanchet@39318
   307
    val ctxt = Proof.context_of state
blanchet@37584
   308
    val birth_time = Time.now ()
blanchet@37584
   309
    val death_time = Time.+ (birth_time, timeout)
blanchet@39110
   310
    val max_relevant = the_default default_max_relevant max_relevant
blanchet@39110
   311
    val num_axioms = Int.min (length axioms, max_relevant)
blanchet@36379
   312
    val desc =
blanchet@39110
   313
      "ATP " ^ quote atp_name ^
blanchet@39110
   314
      (if verbose then
blanchet@39110
   315
         " with " ^ string_of_int num_axioms ^ " fact" ^ plural_s num_axioms
blanchet@39110
   316
       else
blanchet@39110
   317
         "") ^
blanchet@39110
   318
      " on " ^ (if n = 1 then "goal" else "subgoal " ^ string_of_int i) ^ ":" ^
blanchet@38985
   319
      (if blocking then
blanchet@38985
   320
         ""
blanchet@38985
   321
       else
blanchet@38985
   322
         "\n" ^ Syntax.string_of_term ctxt (Thm.term_of (Thm.cprem_of goal i)))
blanchet@39318
   323
    fun go () =
blanchet@38982
   324
      let
blanchet@39453
   325
        fun really_go () =
blanchet@40059
   326
          atp_fun auto atp_name atp params (minimize_command atp_name)
blanchet@40059
   327
                  atp_problem
blanchet@38985
   328
          |> (fn {outcome, message, ...} =>
blanchet@38985
   329
                 (if is_some outcome then "none" else "some", message))
blanchet@39453
   330
        val (outcome_code, message) =
blanchet@39453
   331
          if debug then
blanchet@39453
   332
            really_go ()
blanchet@39453
   333
          else
blanchet@39453
   334
            (really_go ()
blanchet@39453
   335
             handle ERROR message => ("unknown", "Error: " ^ message ^ "\n")
blanchet@39453
   336
                  | exn => ("unknown", "Internal error:\n" ^
blanchet@39453
   337
                                       ML_Compiler.exn_message exn ^ "\n"))
blanchet@39318
   338
        val _ =
blanchet@39318
   339
          if expect = "" orelse outcome_code = expect then
blanchet@39318
   340
            ()
blanchet@39318
   341
          else if blocking then
blanchet@39318
   342
            error ("Unexpected outcome: " ^ quote outcome_code ^ ".")
blanchet@39318
   343
          else
blanchet@39318
   344
            warning ("Unexpected outcome: " ^ quote outcome_code ^ ".");
blanchet@39318
   345
      in (outcome_code = "some", message) end
blanchet@39318
   346
  in
blanchet@39318
   347
    if auto then
blanchet@39318
   348
      let val (success, message) = TimeLimit.timeLimit timeout go () in
blanchet@39318
   349
        (success, state |> success ? Proof.goal_message (fn () =>
blanchet@39318
   350
             Pretty.chunks [Pretty.str "", Pretty.mark Markup.hilite
blanchet@39327
   351
                 (Pretty.str message)]))
blanchet@38982
   352
      end
blanchet@39318
   353
    else if blocking then
blanchet@39318
   354
      let val (success, message) = TimeLimit.timeLimit timeout go () in
blanchet@39370
   355
        List.app priority
blanchet@39370
   356
                 (Async_Manager.break_into_chunks [desc ^ "\n" ^ message]);
blanchet@39370
   357
        (success, state)
blanchet@39318
   358
      end
blanchet@39318
   359
    else
blanchet@39318
   360
      (Async_Manager.launch das_Tool birth_time death_time desc (snd o go);
blanchet@39318
   361
       (false, state))
blanchet@37584
   362
  end
wenzelm@28582
   363
blanchet@39318
   364
val auto_max_relevant_divisor = 2
blanchet@39318
   365
blanchet@40059
   366
fun run_sledgehammer (params as {blocking, provers, full_types,
blanchet@38998
   367
                                 relevance_thresholds, max_relevant, ...})
blanchet@39366
   368
                     auto i (relevance_override as {only, ...}) minimize_command
blanchet@39366
   369
                     state =
blanchet@40059
   370
  if null provers then
blanchet@40059
   371
    error "No prover is set."
blanchet@39318
   372
  else case subgoal_count state of
blanchet@39318
   373
    0 => (priority "No subgoal!"; (false, state))
blanchet@39318
   374
  | n =>
blanchet@39318
   375
    let
blanchet@39364
   376
      val _ = Proof.assert_backward state
blanchet@39318
   377
      val thy = Proof.theory_of state
blanchet@40059
   378
      val _ = () |> not blocking ? kill_provers
blanchet@39318
   379
      val _ = if auto then () else priority "Sledgehammering..."
blanchet@40059
   380
      val atps = map (`(get_atp thy)) provers
blanchet@39318
   381
      fun go () =
blanchet@39318
   382
        let
blanchet@39318
   383
          val {context = ctxt, facts = chained_ths, goal} = Proof.goal state
blanchet@39318
   384
          val (_, hyp_ts, concl_t) = strip_subgoal goal i
blanchet@39318
   385
          val max_max_relevant =
blanchet@39318
   386
            case max_relevant of
blanchet@39318
   387
              SOME n => n
blanchet@39318
   388
            | NONE =>
blanchet@40059
   389
              0 |> fold (Integer.max o #default_max_relevant o fst) atps
blanchet@39318
   390
                |> auto ? (fn n => n div auto_max_relevant_divisor)
blanchet@39318
   391
          val axioms =
blanchet@39318
   392
            relevant_facts ctxt full_types relevance_thresholds
blanchet@39318
   393
                           max_max_relevant relevance_override chained_ths
blanchet@39318
   394
                           hyp_ts concl_t
blanchet@40059
   395
          val atp_problem =
blanchet@39318
   396
            {state = state, goal = goal, subgoal = i,
blanchet@39366
   397
             axioms = map (prepare_axiom ctxt) axioms, only = only}
blanchet@40059
   398
          val run_atp = run_atp params auto i n minimize_command atp_problem
blanchet@39318
   399
        in
blanchet@39318
   400
          if auto then
blanchet@40059
   401
            fold (fn atp => fn (true, state) => (true, state)
blanchet@40059
   402
                             | (false, _) => run_atp atp)
blanchet@40059
   403
                 atps (false, state)
blanchet@39318
   404
          else
blanchet@40059
   405
            (if blocking then Par_List.map else map) run_atp atps
blanchet@39318
   406
            |> exists fst |> rpair state
blanchet@39318
   407
        end
blanchet@39318
   408
    in if blocking then go () else Future.fork (tap go) |> K (false, state) end
blanchet@38044
   409
blanchet@38023
   410
val setup =
blanchet@38023
   411
  dest_dir_setup
blanchet@38023
   412
  #> problem_prefix_setup
blanchet@39003
   413
  #> measure_run_time_setup
blanchet@38023
   414
wenzelm@28582
   415
end;