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