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