src/HOL/Tools/res_atp.ML
author paulson
Fri Sep 02 15:25:44 2005 +0200 (2005-09-02)
changeset 17231 f42bc4f7afdf
parent 17150 ce2a1aeb42aa
child 17234 12a9393c5d77
permissions -rw-r--r--
tidying up the Isabelle/ATP interface
paulson@15608
     1
(*  Author: Jia Meng, Cambridge University Computer Laboratory
paulson@15608
     2
    ID: $Id$
paulson@15608
     3
    Copyright 2004 University of Cambridge
paulson@15347
     4
paulson@15347
     5
ATPs with TPTP format input.
paulson@15347
     6
*)
paulson@15452
     7
wenzelm@16802
     8
signature RES_ATP =
wenzelm@16802
     9
sig
wenzelm@16802
    10
  val axiom_file : Path.T
wenzelm@16802
    11
  val hyps_file : Path.T
wenzelm@16802
    12
  val prob_file : Path.T;
wenzelm@16802
    13
(*val atp_ax_tac : thm list -> int -> Tactical.tactic*)
quigley@15644
    14
(*val atp_tac : int -> Tactical.tactic*)
wenzelm@16802
    15
  val full_spass: bool ref
quigley@16478
    16
(*val spass: bool ref*)
wenzelm@16802
    17
  val vampire: bool ref
wenzelm@16802
    18
  val custom_spass: string list ref
quigley@17150
    19
  val hook_count: int ref
quigley@17150
    20
(*  val invoke_atp: Toplevel.transition -> Toplevel.transition*)
paulson@15347
    21
end;
paulson@15347
    22
wenzelm@16802
    23
structure ResAtp: RES_ATP =
paulson@15347
    24
struct
paulson@15347
    25
quigley@17150
    26
quigley@17150
    27
val call_atp = ref false;
quigley@17150
    28
val hook_count = ref 0;
quigley@17150
    29
paulson@16904
    30
fun debug_tac tac = (debug "testing"; tac);
quigley@16478
    31
quigley@16357
    32
val full_spass = ref false;
quigley@16478
    33
quigley@16478
    34
(* use spass as default prover *)
quigley@16478
    35
(*val spass = ref true;*)
quigley@16478
    36
quigley@16520
    37
val custom_spass = ref ["Auto=0","-IORe","-IOFc","-RTaut","-RFSub","-RBSub","-DocProof","-TimeLimit=60"];
quigley@16478
    38
val vampire = ref false;
quigley@16478
    39
paulson@15608
    40
val skolem_tac = skolemize_tac;
paulson@15608
    41
quigley@15644
    42
val num_of_clauses = ref 0;
wenzelm@16802
    43
val clause_arr = Array.array (3500, ("empty", 0));
quigley@15644
    44
paulson@15347
    45
paulson@15608
    46
val atomize_tac =
paulson@15608
    47
    SUBGOAL
paulson@15608
    48
     (fn (prop,_) =>
wenzelm@16802
    49
         let val ts = Logic.strip_assums_hyp prop
wenzelm@16802
    50
         in EVERY1
wenzelm@16802
    51
                [METAHYPS
wenzelm@16802
    52
                     (fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)),
wenzelm@16802
    53
          REPEAT_DETERM_N (length ts) o (etac thin_rl)]
paulson@15608
    54
     end);
paulson@15347
    55
paulson@15608
    56
(* temporarily use these files, which will be loaded by Vampire *)
wenzelm@16802
    57
val file_id_num = ref 0;
wenzelm@16802
    58
fun new_prob_file () = "prob" ^ string_of_int (inc file_id_num);
paulson@15347
    59
quigley@15644
    60
val axiom_file = File.tmp_path (Path.basic "axioms");
quigley@15644
    61
val clasimp_file = File.tmp_path (Path.basic "clasimp");
quigley@15644
    62
val hyps_file = File.tmp_path (Path.basic "hyps");
quigley@15644
    63
val prob_file = File.tmp_path (Path.basic "prob");
wenzelm@16802
    64
val dummy_tac = all_tac;
quigley@17150
    65
val _ =debug  (File.platform_path prob_file);
quigley@15644
    66
wenzelm@16802
    67
paulson@15347
    68
(**** for Isabelle/ML interface  ****)
paulson@15347
    69
paulson@16897
    70
(*Remove unwanted characters such as ? and newline from the textural 
paulson@16897
    71
  representation of a theorem (surely they don't need to be produced in 
paulson@16897
    72
  the first place?) *)
paulson@15608
    73
paulson@16897
    74
fun is_proof_char ch = (#" " <= ch andalso ch <= #"~" andalso ch <> #"?");
paulson@16897
    75
paulson@16897
    76
val proofstring =
paulson@16897
    77
    String.translate (fn c => if is_proof_char c then str c else "");
paulson@15608
    78
paulson@15452
    79
paulson@15347
    80
(**** For running in Isar ****)
paulson@15347
    81
paulson@15608
    82
(* same function as that in res_axioms.ML *)
paulson@15608
    83
fun repeat_RS thm1 thm2 =
paulson@15608
    84
    let val thm1' =  thm1 RS thm2 handle THM _ => thm1
paulson@15608
    85
    in
wenzelm@16802
    86
        if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2)
paulson@15608
    87
    end;
paulson@15608
    88
paulson@15608
    89
(* a special version of repeat_RS *)
paulson@15608
    90
fun repeat_someI_ex thm = repeat_RS thm someI_ex;
paulson@15608
    91
paulson@16925
    92
paulson@16925
    93
(*FIXME: is function isar_atp_h used? If not, delete!*)
quigley@15644
    94
(*********************************************************************)
paulson@15608
    95
(* convert clauses from "assume" to conjecture. write to file "hyps" *)
quigley@15644
    96
(* hypotheses of the goal currently being proved                     *)
quigley@15644
    97
(*********************************************************************)
quigley@16767
    98
(*perhaps have 2 different versions of this, depending on whether or not SpassComm.spass is set *)
paulson@15608
    99
fun isar_atp_h thms =
paulson@15608
   100
    let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms
quigley@15644
   101
        val prems' = map repeat_someI_ex prems
quigley@15644
   102
        val prems'' = make_clauses prems'
quigley@15644
   103
        val prems''' = ResAxioms.rm_Eps [] prems''
quigley@15644
   104
        val clss = map ResClause.make_conjecture_clause prems'''
paulson@15774
   105
	val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) 
paulson@15608
   106
	val tfree_lits = ResLib.flat_noDup tfree_litss
quigley@16767
   107
        (* tfree clause is different in tptp and dfg versions *)
paulson@15608
   108
	val tfree_clss = map ResClause.tfree_clause tfree_lits 
wenzelm@16259
   109
        val hypsfile = File.platform_path hyps_file
wenzelm@16802
   110
        val out = TextIO.openOut(hypsfile)
paulson@15608
   111
    in
paulson@16904
   112
        ResLib.writeln_strs out (tfree_clss @ tptp_clss);
paulson@16904
   113
        TextIO.closeOut out; debug hypsfile;
paulson@16904
   114
        tfree_lits
paulson@15608
   115
    end;
paulson@15347
   116
quigley@15644
   117
quigley@15644
   118
(*********************************************************************)
quigley@15644
   119
(* write out a subgoal as tptp clauses to the file "probN"           *)
quigley@15644
   120
(* where N is the number of this subgoal                             *)
quigley@15644
   121
(*********************************************************************)
quigley@15644
   122
wenzelm@16802
   123
fun tptp_inputs_tfrees thms n tfrees =
wenzelm@16802
   124
    let
paulson@16904
   125
      val _ = debug ("in tptp_inputs_tfrees 0")
wenzelm@16802
   126
      val clss = map (ResClause.make_conjecture_clause_thm) thms
paulson@16904
   127
      val _ = debug ("in tptp_inputs_tfrees 1")
wenzelm@16802
   128
      val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss)
paulson@16904
   129
      val _ = debug ("in tptp_inputs_tfrees 2")
wenzelm@16802
   130
      val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees)
paulson@16904
   131
      val _ = debug ("in tptp_inputs_tfrees 3")
wenzelm@16802
   132
      val probfile = File.platform_path prob_file ^ "_" ^ string_of_int n
wenzelm@16802
   133
      val out = TextIO.openOut(probfile)
paulson@15608
   134
    in
wenzelm@16802
   135
      ResLib.writeln_strs out (tfree_clss @ tptp_clss);
wenzelm@16802
   136
      TextIO.closeOut out;
paulson@16904
   137
      debug probfile
paulson@15608
   138
    end;
paulson@15452
   139
paulson@15608
   140
quigley@16767
   141
(*********************************************************************)
quigley@16767
   142
(* write out a subgoal as DFG clauses to the file "probN"           *)
quigley@16767
   143
(* where N is the number of this subgoal                             *)
quigley@16767
   144
(*********************************************************************)
quigley@17150
   145
quigley@17150
   146
fun dfg_inputs_tfrees thms n tfrees axclauses = 
quigley@17150
   147
    let val clss = map (ResClause.make_conjecture_clause_thm) thms
quigley@16767
   148
        val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n)
paulson@17231
   149
        val _ = debug ("about to write out dfg prob file " ^ probfile)
quigley@17150
   150
       	(*val (dfg_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2dfg clss)
quigley@17150
   151
        val tfree_clss = map ResClause.tfree_dfg_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) *)   
paulson@17231
   152
        val filestr = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) 
paulson@17231
   153
                        axclauses [] [] [] tfrees   
quigley@16767
   154
	val out = TextIO.openOut(probfile)
quigley@16767
   155
    in
quigley@17150
   156
	(ResLib.writeln_strs out [filestr]; TextIO.closeOut out; debug probfile )
paulson@17231
   157
(* (ResLib.writeln_strs out (tfree_clss @ dfg_clss); *)
quigley@17150
   158
    end;
quigley@17150
   159
quigley@16357
   160
quigley@15644
   161
(*********************************************************************)
quigley@15644
   162
(* call SPASS with settings and problem file for the current subgoal *)
quigley@15644
   163
(* should be modified to allow other provers to be called            *)
quigley@15644
   164
(*********************************************************************)
quigley@16357
   165
(* now passing in list of skolemized thms and list of sgterms to go with them *)
wenzelm@16802
   166
fun call_resolve_tac  (thms: thm list list)  sign (sg_terms:  term list) (childin, childout,pid) n  =
wenzelm@16802
   167
  let
wenzelm@16802
   168
    val axfile = (File.platform_path axiom_file)
quigley@16520
   169
quigley@16520
   170
    val hypsfile = (File.platform_path hyps_file)
wenzelm@16802
   171
    val clasimpfile = (File.platform_path clasimp_file)
quigley@16520
   172
wenzelm@16802
   173
    fun make_atp_list [] sign n = []
paulson@16897
   174
      | make_atp_list ((sko_thm, sg_term)::xs) sign n =
wenzelm@16802
   175
          let
paulson@16897
   176
            val thmstr = proofstring (Meson.concat_with_and (map string_of_thm sko_thm))
paulson@16904
   177
            val _ = debug ("thmstring in make_atp_lists is " ^ thmstr)
paulson@15608
   178
paulson@16897
   179
            val goalstring = proofstring (Sign.string_of_term sign sg_term)
paulson@16904
   180
            val _ = debug ("goalstring in make_atp_lists is " ^ goalstring)
quigley@16357
   181
paulson@16897
   182
            val probfile = File.platform_path prob_file ^ "_" ^ (string_of_int n)
paulson@16904
   183
            val _ = debug ("prob file in call_resolve_tac is " ^ probfile)
wenzelm@16802
   184
          in
wenzelm@16802
   185
            if !SpassComm.spass
wenzelm@16802
   186
            then
paulson@16897
   187
              let val optionline = (*Custom SPASS options, or default?*)
paulson@16897
   188
		      if !full_spass (*Auto mode: all SPASS inference rules*)
paulson@16897
   189
                      then "-DocProof%-TimeLimit=60%-SOS"
paulson@16897
   190
                      else "-" ^ space_implode "%-" (!custom_spass)
paulson@16904
   191
                  val _ = debug ("SPASS option string is " ^ optionline)
paulson@16897
   192
                  val _ = ResLib.helper_path "SPASS_HOME" "SPASS"
paulson@16897
   193
                    (*We've checked that SPASS is there for ATP/spassshell to run.*)
paulson@16897
   194
              in 
paulson@16897
   195
                  ([("spass", thmstr, goalstring,
paulson@16897
   196
                     getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell",
paulson@16897
   197
                     optionline, clasimpfile, axfile, hypsfile, probfile)] @ 
paulson@16897
   198
                  (make_atp_list xs sign (n+1)))
wenzelm@16802
   199
              end
wenzelm@16802
   200
            else
wenzelm@16802
   201
              let val vampire = ResLib.helper_path "VAMPIRE_HOME" "vkernel"
wenzelm@16802
   202
              in
wenzelm@16802
   203
                ([("vampire", thmstr, goalstring, vampire, "-t 60%-m 100000",
wenzelm@16802
   204
                   clasimpfile, axfile, hypsfile, probfile)] @
wenzelm@16802
   205
                 (make_atp_list xs sign (n+1)))
wenzelm@16802
   206
              end
wenzelm@16802
   207
          end
paulson@15452
   208
paulson@16897
   209
    val atp_list = make_atp_list (ListPair.zip (thms, sg_terms)) sign 1
wenzelm@16802
   210
  in
wenzelm@16802
   211
    Watcher.callResProvers(childout,atp_list);
paulson@16904
   212
    debug "Sent commands to watcher!";
wenzelm@16802
   213
    dummy_tac
wenzelm@16802
   214
  end
quigley@16357
   215
quigley@15644
   216
(**********************************************************)
quigley@15644
   217
(* write out the current subgoal as a tptp file, probN,   *)
quigley@15644
   218
(* then call dummy_tac - should be call_res_tac           *)
quigley@15644
   219
(**********************************************************)
quigley@15679
   220
quigley@17150
   221
quigley@17150
   222
fun get_sko_thms tfrees sign sg_terms (childin, childout,pid) thm n sko_thms axclauses =
quigley@17150
   223
    if n=0 then 
quigley@17150
   224
       (call_resolve_tac  (rev sko_thms)
quigley@17150
   225
        sign  sg_terms (childin, childout, pid) (List.length sg_terms);
quigley@17150
   226
        dummy_tac thm)
quigley@17150
   227
     else
quigley@17150
   228
	
quigley@17150
   229
     ( SELECT_GOAL
quigley@17150
   230
        (EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, 
paulson@17231
   231
          METAHYPS(fn negs => 
paulson@17231
   232
            (if !SpassComm.spass 
paulson@17231
   233
             then dfg_inputs_tfrees (make_clauses negs) n tfrees axclauses
paulson@17231
   234
             else tptp_inputs_tfrees (make_clauses negs) n tfrees;
paulson@17231
   235
             get_sko_thms tfrees sign sg_terms (childin, childout, pid) 
paulson@17231
   236
                          thm  (n -1) (negs::sko_thms) axclauses; 
paulson@17231
   237
             dummy_tac))]) n thm )
quigley@17150
   238
quigley@15644
   239
quigley@15644
   240
quigley@15644
   241
(**********************************************)
quigley@15644
   242
(* recursively call atp_tac_g on all subgoals *)
quigley@15644
   243
(* sg_term is the nth subgoal as a term - used*)
quigley@15644
   244
(* in proof reconstruction                    *)
quigley@15644
   245
(**********************************************)
quigley@15644
   246
quigley@17150
   247
fun isar_atp_goal' thm n tfree_lits (childin, childout, pid)  axclauses =
wenzelm@16802
   248
  let
wenzelm@16802
   249
    val prems = Thm.prems_of thm
wenzelm@16802
   250
    (*val sg_term = get_nth k prems*)
wenzelm@16802
   251
    val sign = sign_of_thm thm
wenzelm@16802
   252
    val thmstring = string_of_thm thm
wenzelm@16802
   253
  in
paulson@16904
   254
    debug("in isar_atp_goal'");
paulson@16904
   255
    debug("thmstring in isar_atp_goal': " ^ thmstring);
wenzelm@16802
   256
    (* go and call callResProvers with this subgoal *)
wenzelm@16802
   257
    (* isar_atp_g tfree_lits  sg_term (childin, childout, pid) k thm; *)
wenzelm@16802
   258
    (* recursive call to pick up the remaining subgoals *)
wenzelm@16802
   259
    (* isar_atp_goal' thm (k+1) n tfree_lits  (childin, childout, pid) *)
quigley@17150
   260
    get_sko_thms tfree_lits sign prems (childin, childout, pid) thm n []  axclauses
wenzelm@16802
   261
  end;
quigley@16520
   262
quigley@15644
   263
quigley@15644
   264
(**************************************************)
quigley@15644
   265
(* convert clauses from "assume" to conjecture.   *)
quigley@15644
   266
(* i.e. apply make_clauses and then get tptp for  *)
quigley@15679
   267
(* any hypotheses in the goal produced by assume  *)
quigley@15679
   268
(* statements;                                    *)
quigley@15644
   269
(* write to file "hyps"                           *)
quigley@15644
   270
(**************************************************)
quigley@15644
   271
paulson@17231
   272
fun isar_atp_aux thms thm n_subgoals  (childin, childout, pid) axclauses =
wenzelm@16802
   273
  let val tfree_lits = isar_atp_h thms
wenzelm@16802
   274
  in
paulson@16904
   275
    debug ("in isar_atp_aux");
quigley@17150
   276
    isar_atp_goal' thm n_subgoals tfree_lits (childin, childout, pid)  axclauses
wenzelm@16802
   277
  end;
quigley@15644
   278
quigley@15644
   279
(******************************************************************)
quigley@15644
   280
(* called in Isar automatically                                   *)
quigley@15644
   281
(* writes out the current clasimpset to a tptp file               *)
quigley@15644
   282
(* passes all subgoals on to isar_atp_aux for further processing  *)
quigley@15644
   283
(* turns off xsymbol at start of function, restoring it at end    *)
quigley@15644
   284
(******************************************************************)
quigley@15779
   285
(*FIX changed to clasimp_file *)
wenzelm@16802
   286
val isar_atp' = setmp print_mode [] (fn (ctxt, thms, thm) =>
wenzelm@16802
   287
  if Thm.no_prems thm then ()
wenzelm@16802
   288
  else
wenzelm@16802
   289
    let
paulson@16904
   290
      val _= debug ("in isar_atp'")
wenzelm@16802
   291
      val thy = ProofContext.theory_of ctxt
wenzelm@16802
   292
      val prems = Thm.prems_of thm
wenzelm@16802
   293
      val thms_string = Meson.concat_with_and (map string_of_thm thms)
wenzelm@16802
   294
      val thm_string = string_of_thm thm
wenzelm@16802
   295
      val prems_string = Meson.concat_with_and (map (Sign.string_of_term thy) prems)
wenzelm@16802
   296
wenzelm@16802
   297
      (*set up variables for writing out the clasimps to a tptp file*)
quigley@17150
   298
      val (clause_arr, num_of_clauses, axclauses) =
wenzelm@16802
   299
        ResClasimp.write_out_clasimp (File.platform_path clasimp_file) thy
wenzelm@16802
   300
          (hd prems) (*FIXME: hack!! need to do all prems*)
quigley@17150
   301
      val _ = debug ("clasimp_file is " ^ File.platform_path clasimp_file ^ " with " ^ (string_of_int num_of_clauses)^ " clauses")
wenzelm@16802
   302
      val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr, num_of_clauses)
wenzelm@16802
   303
      val pid_string =
wenzelm@16802
   304
        string_of_int (Word.toInt (Word.fromLargeWord (Posix.Process.pidToWord pid)))
paulson@15608
   305
    in
paulson@16904
   306
      debug ("initial thms: " ^ thms_string);
paulson@16904
   307
      debug ("initial thm: " ^ thm_string);
paulson@16904
   308
      debug ("subgoals: " ^ prems_string);
paulson@16904
   309
      debug ("pid: "^ pid_string);
quigley@17150
   310
      isar_atp_aux thms thm (length prems) (childin, childout, pid) axclauses;
wenzelm@16802
   311
      ()
wenzelm@16802
   312
    end);
paulson@15608
   313
paulson@15452
   314
paulson@15608
   315
fun get_thms_cs claset =
wenzelm@16802
   316
  let val {safeEs, safeIs, hazEs, hazIs, ...} = rep_cs claset
wenzelm@16802
   317
  in safeEs @ safeIs @ hazEs @ hazIs end;
quigley@16357
   318
paulson@15608
   319
fun append_name name [] _ = []
wenzelm@16802
   320
  | append_name name (thm :: thms) k =
wenzelm@16802
   321
      Thm.name_thm ((name ^ "_" ^ string_of_int k), thm) :: append_name name thms (k + 1);
paulson@15608
   322
wenzelm@16802
   323
fun append_names (name :: names) (thms :: thmss) =
wenzelm@16802
   324
  append_name name thms 0 :: append_names names thmss;
quigley@16357
   325
paulson@15608
   326
fun get_thms_ss [] = []
paulson@15608
   327
  | get_thms_ss thms =
wenzelm@16802
   328
      let
wenzelm@16802
   329
        val names = map Thm.name_of_thm thms
paulson@15608
   330
        val thms' = map (mksimps mksimps_pairs) thms
paulson@15608
   331
        val thms'' = append_names names thms'
wenzelm@16802
   332
      in
wenzelm@16802
   333
        ResLib.flat_noDup thms''
wenzelm@16802
   334
      end;
paulson@15608
   335
paulson@15452
   336
paulson@15608
   337
(* convert locally declared rules to axiom clauses *)
paulson@15608
   338
wenzelm@16802
   339
fun subtract_simpset thy ctxt =
wenzelm@16802
   340
  let
wenzelm@16802
   341
    val rules1 = #rules (#1 (rep_ss (simpset_of thy)));
wenzelm@16802
   342
    val rules2 = #rules (#1 (rep_ss (local_simpset_of ctxt)));
wenzelm@16802
   343
  in map #thm (Net.subtract MetaSimplifier.eq_rrule rules1 rules2) end;
quigley@15679
   344
wenzelm@16802
   345
fun subtract_claset thy ctxt =
wenzelm@16802
   346
  let
wenzelm@16802
   347
    val (netI1, netE1) = #xtra_netpair (rep_cs (claset_of thy));
wenzelm@16802
   348
    val (netI2, netE2) = #xtra_netpair (rep_cs (local_claset_of ctxt));
wenzelm@16802
   349
    val subtract = map (#2 o #2) oo Net.subtract Tactic.eq_kbrl;
wenzelm@16802
   350
  in subtract netI1 netI2 @ subtract netE1 netE2 end;
paulson@15608
   351
paulson@15608
   352
quigley@16357
   353
wenzelm@16802
   354
(** the Isar toplevel hook **)
wenzelm@16802
   355
paulson@17091
   356
val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state =>
quigley@17150
   357
wenzelm@16802
   358
  let
quigley@17150
   359
paulson@17091
   360
    val proof = Toplevel.proof_of state
paulson@17091
   361
    val (ctxt, (_, goal)) = Proof.get_goal proof
paulson@17091
   362
        handle Proof.STATE _ => error "No goal present";
quigley@17150
   363
wenzelm@16802
   364
    val thy = ProofContext.theory_of ctxt;
wenzelm@16802
   365
wenzelm@16802
   366
    (* FIXME presently unused *)
wenzelm@16802
   367
    val ss_thms = subtract_simpset thy ctxt;
wenzelm@16802
   368
    val cs_thms = subtract_claset thy ctxt;
wenzelm@16802
   369
  in
paulson@17091
   370
    debug ("initial thm in isar_atp: " ^ 
paulson@17091
   371
           Pretty.string_of (ProofContext.pretty_thm ctxt goal));
paulson@17091
   372
    debug ("subgoals in isar_atp: " ^ 
paulson@17091
   373
           Pretty.string_of (ProofContext.pretty_term ctxt
paulson@17091
   374
             (Logic.mk_conjunction_list (Thm.prems_of goal))));
paulson@16904
   375
    debug ("number of subgoals in isar_atp: " ^ string_of_int (Thm.nprems_of goal));
quigley@17150
   376
    hook_count := !hook_count +1;
quigley@17150
   377
    debug ("in hook for time: " ^(string_of_int (!hook_count)) );
paulson@16925
   378
    ResClause.init thy;
wenzelm@16802
   379
    isar_atp' (ctxt, ProofContext.prems_of ctxt, goal)
wenzelm@16802
   380
  end);
quigley@16357
   381
paulson@17091
   382
val call_atpP =
paulson@17091
   383
  OuterSyntax.improper_command 
paulson@17091
   384
    "ProofGeneral.call_atp" 
paulson@17091
   385
    "call automatic theorem provers" 
paulson@17091
   386
    OuterKeyword.diag
paulson@17091
   387
    (Scan.succeed (Toplevel.no_timing o invoke_atp));
paulson@17091
   388
paulson@17091
   389
val _ = OuterSyntax.add_parsers [call_atpP];
paulson@17091
   390
paulson@15347
   391
end;