src/HOL/Tools/res_atp.ML
author quigley
Mon Jul 11 16:42:42 2005 +0200 (2005-07-11)
changeset 16767 2d4433759b8d
parent 16741 7a6c17b826c0
child 16802 6eeee59dac4c
permissions -rw-r--r--
Fixed some problems with the signal handler.
paulson@15608
     1
(*  Author: Jia Meng, Cambridge University Computer Laboratory
quigley@16520
     2
paulson@15608
     3
    ID: $Id$
quigley@16520
     4
paulson@15608
     5
    Copyright 2004 University of Cambridge
paulson@15347
     6
paulson@15347
     7
ATPs with TPTP format input.
paulson@15347
     8
*)
paulson@15452
     9
paulson@15452
    10
(*Jia: changed: isar_atp now processes entire proof context.  fetch thms from delta simpset/claset*)
quigley@15644
    11
(*Claire: changed: added actual watcher calls *)
paulson@15452
    12
quigley@15779
    13
paulson@15347
    14
signature RES_ATP = 
quigley@16478
    15
sig  
paulson@15608
    16
val trace_res : bool ref
quigley@15779
    17
val subgoals: Thm.thm list
quigley@15779
    18
val traceflag : bool ref
paulson@15608
    19
val axiom_file : Path.T
paulson@15608
    20
val hyps_file : Path.T
paulson@15608
    21
val isar_atp : ProofContext.context * Thm.thm -> unit
quigley@15657
    22
val prob_file : Path.T;
quigley@15644
    23
(*val atp_ax_tac : Thm.thm list -> int -> Tactical.tactic*)
quigley@15644
    24
(*val atp_tac : int -> Tactical.tactic*)
paulson@15608
    25
val debug: bool ref
quigley@16156
    26
val full_spass: bool ref
quigley@16478
    27
(*val spass: bool ref*)
quigley@16478
    28
val vampire: bool ref
quigley@16520
    29
val custom_spass :string list  ref
paulson@15347
    30
end;
paulson@15347
    31
paulson@15347
    32
structure ResAtp : RES_ATP =
paulson@15608
    33
paulson@15347
    34
struct
paulson@15347
    35
quigley@15779
    36
val subgoals = [];
quigley@15644
    37
quigley@15779
    38
val traceflag = ref true;
quigley@16357
    39
(* used for debug *)
quigley@16357
    40
val debug = ref false;
paulson@16172
    41
paulson@15608
    42
fun debug_tac tac = (warning "testing";tac);
quigley@16357
    43
(* default value is false *)
quigley@16478
    44
quigley@16357
    45
val full_spass = ref false;
quigley@16478
    46
quigley@16478
    47
(* use spass as default prover *)
quigley@16478
    48
(*val spass = ref true;*)
quigley@16478
    49
quigley@16520
    50
val custom_spass = ref ["Auto=0","-IORe","-IOFc","-RTaut","-RFSub","-RBSub","-DocProof","-TimeLimit=60"];
quigley@16478
    51
val vampire = ref false;
quigley@16478
    52
paulson@15608
    53
val trace_res = ref false;
paulson@15347
    54
paulson@15608
    55
val skolem_tac = skolemize_tac;
paulson@15608
    56
quigley@15644
    57
val num_of_clauses = ref 0;
quigley@15644
    58
val clause_arr = Array.array(3500, ("empty", 0));
quigley@15644
    59
paulson@15347
    60
paulson@15608
    61
val atomize_tac =
paulson@15608
    62
    SUBGOAL
paulson@15608
    63
     (fn (prop,_) =>
paulson@15608
    64
	 let val ts = Logic.strip_assums_hyp prop
paulson@15608
    65
	 in EVERY1 
paulson@15608
    66
		[METAHYPS
paulson@15608
    67
		     (fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)),
paulson@15608
    68
	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
paulson@15608
    69
     end);
paulson@15347
    70
paulson@15608
    71
(* temporarily use these files, which will be loaded by Vampire *)
quigley@15644
    72
val file_id_num =ref 0;
paulson@15608
    73
quigley@15644
    74
fun new_prob_file () =  (file_id_num := (!file_id_num) + 1;"prob"^(string_of_int (!file_id_num)));
paulson@15608
    75
paulson@15347
    76
quigley@15644
    77
val axiom_file = File.tmp_path (Path.basic "axioms");
quigley@15644
    78
val clasimp_file = File.tmp_path (Path.basic "clasimp");
quigley@15644
    79
val hyps_file = File.tmp_path (Path.basic "hyps");
quigley@15644
    80
val prob_file = File.tmp_path (Path.basic "prob");
quigley@15644
    81
val dummy_tac = PRIMITIVE(fn thm => thm );
quigley@15644
    82
quigley@15644
    83
 
paulson@15347
    84
(**** for Isabelle/ML interface  ****)
paulson@15347
    85
quigley@16357
    86
fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126) andalso (not ((ord ch ) = 63))) orelse (ch = " ")
paulson@15608
    87
quigley@16357
    88
fun proofstring x = let val exp = explode x 
quigley@16357
    89
                    in
quigley@16357
    90
                        List.filter (is_proof_char ) exp
quigley@16357
    91
                    end
quigley@16357
    92
paulson@15608
    93
paulson@15452
    94
quigley@15644
    95
(*
quigley@15644
    96
fun call_atp_tac thms n = (tptp_inputs thms ; dummy_tac);
paulson@15347
    97
quigley@15644
    98
*)
paulson@15347
    99
paulson@15347
   100
(**** For running in Isar ****)
paulson@15347
   101
paulson@15608
   102
(* same function as that in res_axioms.ML *)
paulson@15608
   103
fun repeat_RS thm1 thm2 =
paulson@15608
   104
    let val thm1' =  thm1 RS thm2 handle THM _ => thm1
paulson@15608
   105
    in
paulson@15608
   106
	if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2)
paulson@15608
   107
    end;
paulson@15608
   108
paulson@15608
   109
(* a special version of repeat_RS *)
paulson@15608
   110
fun repeat_someI_ex thm = repeat_RS thm someI_ex;
paulson@15608
   111
quigley@15644
   112
(*********************************************************************)
paulson@15608
   113
(* convert clauses from "assume" to conjecture. write to file "hyps" *)
quigley@15644
   114
(* hypotheses of the goal currently being proved                     *)
quigley@15644
   115
(*********************************************************************)
quigley@16767
   116
(*perhaps have 2 different versions of this, depending on whether or not SpassComm.spass is set *)
paulson@15608
   117
fun isar_atp_h thms =
quigley@15644
   118
        
paulson@15608
   119
    let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms
quigley@15644
   120
        val prems' = map repeat_someI_ex prems
quigley@15644
   121
        val prems'' = make_clauses prems'
quigley@15644
   122
        val prems''' = ResAxioms.rm_Eps [] prems''
quigley@15644
   123
        val clss = map ResClause.make_conjecture_clause prems'''
paulson@15774
   124
	val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) 
paulson@15608
   125
	val tfree_lits = ResLib.flat_noDup tfree_litss
quigley@16767
   126
        (* tfree clause is different in tptp and dfg versions *)
paulson@15608
   127
	val tfree_clss = map ResClause.tfree_clause tfree_lits 
wenzelm@16259
   128
        val hypsfile = File.platform_path hyps_file
paulson@15608
   129
	val out = TextIO.openOut(hypsfile)
paulson@15608
   130
    in
paulson@15608
   131
	((ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; if !trace_res then (warning hypsfile) else ());tfree_lits) 
paulson@15608
   132
    end;
paulson@15347
   133
quigley@15644
   134
quigley@15644
   135
(*********************************************************************)
quigley@15644
   136
(* write out a subgoal as tptp clauses to the file "probN"           *)
quigley@15644
   137
(* where N is the number of this subgoal                             *)
quigley@15644
   138
(*********************************************************************)
quigley@15644
   139
paulson@15608
   140
fun tptp_inputs_tfrees thms n tfrees = 
quigley@15657
   141
    let val _ = (warning ("in tptp_inputs_tfrees 0"))
quigley@15657
   142
        val clss = map (ResClause.make_conjecture_clause_thm) thms
quigley@15657
   143
         val _ = (warning ("in tptp_inputs_tfrees 1"))
paulson@15774
   144
	val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss)
quigley@15657
   145
        val _ = (warning ("in tptp_inputs_tfrees 2"))
paulson@15608
   146
	val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) 
quigley@15657
   147
         val _ = (warning ("in tptp_inputs_tfrees 3"))
wenzelm@16259
   148
        val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n)
paulson@15608
   149
	val out = TextIO.openOut(probfile)
paulson@15608
   150
    in
quigley@16357
   151
	(ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; (if !trace_res then (warning probfile) else ()))
paulson@15608
   152
    end;
paulson@15452
   153
paulson@15608
   154
quigley@16767
   155
(*********************************************************************)
quigley@16767
   156
(* write out a subgoal as DFG clauses to the file "probN"           *)
quigley@16767
   157
(* where N is the number of this subgoal                             *)
quigley@16767
   158
(*********************************************************************)
quigley@16767
   159
(*
quigley@16767
   160
fun dfg_inputs_tfrees thms n tfrees = 
quigley@16767
   161
    let val _ = (warning ("in dfg_inputs_tfrees 0"))
quigley@16767
   162
        val clss = map (ResClause.make_conjecture_clause_thm) thms
quigley@16767
   163
         val _ = (warning ("in dfg_inputs_tfrees 1"))
quigley@16767
   164
	val (dfg_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2dfg clss)
quigley@16767
   165
        val _ = (warning ("in dfg_inputs_tfrees 2"))
quigley@16767
   166
	val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) 
quigley@16767
   167
         val _ = (warning ("in dfg_inputs_tfrees 3"))
quigley@16767
   168
        val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n)
quigley@16767
   169
	val out = TextIO.openOut(probfile)
quigley@16767
   170
    in
quigley@16767
   171
	(ResLib.writeln_strs out (tfree_clss @ dfg_clss); TextIO.closeOut out; (if !trace_res then (warning probfile) else ()))
quigley@16767
   172
    end;*)
quigley@16357
   173
quigley@15644
   174
(*********************************************************************)
quigley@15644
   175
(* call SPASS with settings and problem file for the current subgoal *)
quigley@15644
   176
(* should be modified to allow other provers to be called            *)
quigley@15644
   177
(*********************************************************************)
quigley@16357
   178
(* now passing in list of skolemized thms and list of sgterms to go with them *)
paulson@16515
   179
fun call_resolve_tac  (thms: Thm.thm list list)  sign (sg_terms:  Term.term list) (childin, childout,pid) n  = 
paulson@16515
   180
 let
quigley@16357
   181
   val axfile = (File.platform_path axiom_file)
quigley@16520
   182
quigley@16520
   183
    val hypsfile = (File.platform_path hyps_file)
quigley@16520
   184
     val clasimpfile = (File.platform_path clasimp_file)
quigley@16520
   185
    val spass_home = getenv "SPASS_HOME"
quigley@16520
   186
quigley@16520
   187
paulson@16475
   188
   fun make_atp_list [] sign n = []
paulson@16475
   189
   |   make_atp_list ((sko_thm, sg_term)::xs) sign  n = 
paulson@16515
   190
     let 
quigley@16520
   191
quigley@16357
   192
	val skothmstr = Meson.concat_with_and (map string_of_thm sko_thm) 
quigley@16357
   193
	val thmproofstr = proofstring ( skothmstr)
quigley@16357
   194
	val no_returns =List.filter   not_newline ( thmproofstr)
quigley@16357
   195
	val thmstr = implode no_returns
quigley@16357
   196
	val _ = warning ("thmstring in make_atp_lists is: "^thmstr)
paulson@15608
   197
quigley@16357
   198
	val sgstr = Sign.string_of_term sign sg_term 
quigley@16357
   199
	val goalproofstring = proofstring sgstr
paulson@16089
   200
	val no_returns =List.filter not_newline ( goalproofstring)
paulson@16089
   201
	val goalstring = implode no_returns
quigley@16357
   202
	val _ = warning ("goalstring in make_atp_lists is: "^goalstring)
quigley@16357
   203
wenzelm@16259
   204
	val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n)
quigley@16520
   205
paulson@16515
   206
	val _ = (warning ("prob file in cal_res_tac is: "^probfile))      
paulson@16515
   207
     in
paulson@16515
   208
       if !SpassComm.spass 
paulson@16515
   209
       then 
paulson@16515
   210
         let val _ = ResLib.helper_path "SPASS_HOME" "SPASS"
paulson@16515
   211
         in  (*We've checked that SPASS is there for ATP/spassshell to run.*)
paulson@16515
   212
           if !full_spass 
paulson@16515
   213
            then (*Allow SPASS to run in Auto mode, using all its inference rules*)
quigley@16520
   214
quigley@16357
   215
   		([("spass", thmstr, goalstring (*,spass_home*), 
quigley@16520
   216
quigley@16520
   217
	    	 getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell"(*( getenv "SPASS_HOME")^"/SPASS"*),  
quigley@16520
   218
	     	"-DocProof%-TimeLimit=60%-SOS", 
quigley@16520
   219
quigley@16357
   220
	     	clasimpfile, axfile, hypsfile, probfile)]@(make_atp_list xs sign (n+1)))
paulson@16515
   221
  	    else (*Restrict SPASS to a small set of rules that we can parse*)
quigley@16357
   222
   		([("spass", thmstr, goalstring (*,spass_home*), 
quigley@16357
   223
	     	getenv "ISABELLE_HOME" ^"/src/HOL/Tools/ATP/spassshell"(* (getenv "SPASS_HOME")^"/SPASS"*),  
quigley@16520
   224
	     	("-" ^ space_implode "%-" (!custom_spass)), 
quigley@16478
   225
	     	clasimpfile, axfile, hypsfile, probfile)]@(make_atp_list xs sign (n+1)))
paulson@16515
   226
	 end
quigley@16478
   227
     else
paulson@16515
   228
       let val vampire = ResLib.helper_path "VAMPIRE_HOME" "vkernel"
paulson@16515
   229
       in  
quigley@16675
   230
	   ([("vampire", thmstr, goalstring, vampire, "-t 60%-m 100000", 
paulson@16515
   231
	      clasimpfile, axfile, hypsfile, probfile)] @ 
paulson@16515
   232
	    (make_atp_list xs sign (n+1)))
paulson@16515
   233
       end
paulson@16515
   234
     end
paulson@15452
   235
quigley@16357
   236
val thms_goals = ListPair.zip( thms, sg_terms) 
quigley@16357
   237
val atp_list = make_atp_list  thms_goals sign 1
quigley@16357
   238
in
quigley@16357
   239
	Watcher.callResProvers(childout,atp_list);
quigley@16357
   240
        warning("Sent commands to watcher!");
quigley@16357
   241
  	dummy_tac
quigley@16357
   242
 end
quigley@16357
   243
quigley@15644
   244
(**********************************************************)
quigley@15644
   245
(* write out the current subgoal as a tptp file, probN,   *)
quigley@15644
   246
(* then call dummy_tac - should be call_res_tac           *)
quigley@15644
   247
(**********************************************************)
quigley@15679
   248
quigley@15657
   249
quigley@16357
   250
fun get_sko_thms tfrees sign sg_terms (childin, childout,pid)  thm n sko_thms  =
paulson@16515
   251
    if n=0 then 
paulson@16515
   252
	     (call_resolve_tac  (rev sko_thms) sign  sg_terms (childin, childout, pid) (List.length sg_terms);dummy_tac thm)
paulson@16515
   253
     else
paulson@16515
   254
	
paulson@16515
   255
     ( SELECT_GOAL
paulson@16515
   256
	     (EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, 
paulson@16515
   257
	      METAHYPS(fn negs => (tptp_inputs_tfrees (make_clauses negs) n tfrees;
paulson@16515
   258
				 get_sko_thms  tfrees sign sg_terms (childin, childout, pid) thm  (n -1) (negs::sko_thms);dummy_tac))]) n thm )
quigley@15644
   259
quigley@15644
   260
quigley@15644
   261
quigley@15644
   262
(**********************************************)
quigley@15644
   263
(* recursively call atp_tac_g on all subgoals *)
quigley@15644
   264
(* sg_term is the nth subgoal as a term - used*)
quigley@15644
   265
(* in proof reconstruction                    *)
quigley@15644
   266
(**********************************************)
quigley@15644
   267
quigley@16357
   268
fun isar_atp_goal' thm n tfree_lits  (childin, childout, pid) = 
paulson@16515
   269
    let val  prems = prems_of thm 
paulson@16515
   270
      (*val sg_term = get_nth k prems*)
paulson@16515
   271
	val sign = sign_of_thm thm
paulson@16515
   272
	val thmstring = string_of_thm thm
paulson@16515
   273
    in   
paulson@16515
   274
	warning("in isar_atp_goal'");
paulson@16515
   275
	warning("thmstring in isar_atp_goal': "^thmstring);
paulson@16515
   276
	(* go and call callResProvers with this subgoal *)
paulson@16515
   277
	(* isar_atp_g tfree_lits  sg_term (childin, childout, pid) k thm; *)
paulson@16515
   278
	(* recursive call to pick up the remaining subgoals *)
paulson@16515
   279
	(* isar_atp_goal' thm (k+1) n tfree_lits  (childin, childout, pid) *)
paulson@16515
   280
	get_sko_thms tfree_lits sign  prems (childin, childout, pid) thm n []
paulson@16515
   281
    end ;
quigley@15644
   282
quigley@16520
   283
quigley@15644
   284
quigley@15644
   285
(**************************************************)
quigley@15644
   286
(* convert clauses from "assume" to conjecture.   *)
quigley@15644
   287
(* i.e. apply make_clauses and then get tptp for  *)
quigley@15679
   288
(* any hypotheses in the goal produced by assume  *)
quigley@15679
   289
(* statements;                                    *)
quigley@15644
   290
(* write to file "hyps"                           *)
quigley@15644
   291
(**************************************************)
quigley@15644
   292
quigley@15644
   293
quigley@15644
   294
fun isar_atp_aux thms thm n_subgoals  (childin, childout, pid) = 
paulson@15608
   295
    let val tfree_lits = isar_atp_h thms 
quigley@16357
   296
    in
quigley@16357
   297
	(warning("in isar_atp_aux"));
quigley@16357
   298
         isar_atp_goal' thm n_subgoals tfree_lits   (childin, childout, pid)
paulson@15608
   299
    end;
quigley@15644
   300
quigley@15644
   301
(******************************************************************)
quigley@15644
   302
(* called in Isar automatically                                   *)
quigley@15644
   303
(* writes out the current clasimpset to a tptp file               *)
quigley@15644
   304
(* passes all subgoals on to isar_atp_aux for further processing  *)
quigley@15644
   305
(* turns off xsymbol at start of function, restoring it at end    *)
quigley@15644
   306
(******************************************************************)
quigley@15779
   307
(*FIX changed to clasimp_file *)
quigley@16357
   308
fun isar_atp' (ctxt,thms, thm) =
paulson@16741
   309
 if null (prems_of thm) then () 
paulson@16741
   310
 else
quigley@16357
   311
    let 
paulson@16741
   312
	val _= (print_mode := (Library.gen_rems (op =) 
paulson@16741
   313
	                       (! print_mode, ["xsymbols", "symbols"])))
quigley@15644
   314
        val _= (warning ("in isar_atp'"))
paulson@16741
   315
        val prems = prems_of thm
paulson@15697
   316
        val sign = sign_of_thm thm
quigley@15779
   317
        val thms_string = Meson.concat_with_and (map string_of_thm thms) 
quigley@15644
   318
        val thmstring = string_of_thm thm
quigley@15779
   319
        val prems_string = Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
quigley@15919
   320
        
quigley@15919
   321
	(* set up variables for writing out the clasimps to a tptp file *)
paulson@16172
   322
	val (clause_arr, num_of_clauses) =
paulson@16741
   323
	    ResClasimp.write_out_clasimp (File.platform_path clasimp_file) 
paulson@16172
   324
	                                 (ProofContext.theory_of ctxt)
paulson@16741
   325
	                                 (hd prems) (*FIXME: hack!! need to do all prems*)
paulson@16741
   326
        val _ = warning ("clasimp_file is " ^ File.platform_path clasimp_file) 
quigley@15919
   327
        val (childin,childout,pid) = Watcher.createWatcher(thm,clause_arr, num_of_clauses)
paulson@16741
   328
        val pidstring = string_of_int(Word.toInt
paulson@16741
   329
                           (Word.fromLargeWord ( Posix.Process.pidToWord pid )))
paulson@15608
   330
    in
paulson@16741
   331
       warning ("initial thms: "^thms_string); 
paulson@16741
   332
       warning ("initial thm: "^thmstring);
paulson@16741
   333
       warning ("subgoals: "^prems_string);
paulson@16741
   334
       warning ("pid: "^ pidstring); 
paulson@16741
   335
       isar_atp_aux thms thm (length prems) (childin, childout, pid);
paulson@16741
   336
       warning("turning xsymbol back on!");
paulson@16741
   337
       print_mode := (["xsymbols", "symbols"] @ ! print_mode)
paulson@15608
   338
    end;
paulson@15608
   339
paulson@15452
   340
paulson@15608
   341
paulson@15608
   342
paulson@15608
   343
local
paulson@15608
   344
paulson@15608
   345
fun get_thms_cs claset =
paulson@15608
   346
    let val clsset = rep_cs claset
paulson@15608
   347
	val safeEs = #safeEs clsset
paulson@15608
   348
	val safeIs = #safeIs clsset
paulson@15608
   349
	val hazEs = #hazEs clsset
paulson@15608
   350
	val hazIs = #hazIs clsset
paulson@15608
   351
    in
paulson@15608
   352
	safeEs @ safeIs @ hazEs @ hazIs
paulson@15608
   353
    end;
paulson@15608
   354
quigley@16357
   355
quigley@16357
   356
paulson@15608
   357
fun append_name name [] _ = []
paulson@15608
   358
  | append_name name (thm::thms) k = (Thm.name_thm ((name ^ "_" ^ (string_of_int k)),thm)) :: (append_name name thms (k+1));
paulson@15608
   359
paulson@15608
   360
fun append_names (name::names) (thms::thmss) =
paulson@15608
   361
    let val thms' = append_name name thms 0
paulson@15608
   362
    in
paulson@15608
   363
	thms'::(append_names names thmss)
paulson@15608
   364
    end;
paulson@15608
   365
quigley@16357
   366
paulson@15608
   367
fun get_thms_ss [] = []
paulson@15608
   368
  | get_thms_ss thms =
paulson@15608
   369
    let val names = map Thm.name_of_thm thms 
paulson@15608
   370
        val thms' = map (mksimps mksimps_pairs) thms
paulson@15608
   371
        val thms'' = append_names names thms'
paulson@15608
   372
    in
paulson@15608
   373
	ResLib.flat_noDup thms''
paulson@15608
   374
    end;
paulson@15608
   375
quigley@16357
   376
quigley@16357
   377
quigley@16357
   378
paulson@15608
   379
in
paulson@15608
   380
paulson@15452
   381
paulson@15608
   382
(* convert locally declared rules to axiom clauses *)
paulson@15608
   383
(* write axiom clauses to ax_file *)
quigley@15644
   384
(* what about clasimpset - it should already be in the ax file - perhaps append to ax file rather than just *)
quigley@15644
   385
(* write out ? Or keep as a separate file and then cat them all together in the watcher, like we do with the *)
quigley@15644
   386
(*claset file and prob file*)
quigley@16357
   387
(* FIX*)
quigley@16039
   388
(*fun isar_local_thms (delta_cs, delta_ss_thms) =
paulson@15608
   389
    let val thms_cs = get_thms_cs delta_cs
paulson@15608
   390
	val thms_ss = get_thms_ss delta_ss_thms
paulson@15608
   391
	val thms_clauses = ResLib.flat_noDup (map ResAxioms.clausify_axiom (thms_cs @ thms_ss))
paulson@15608
   392
	val clauses_strs = ResLib.flat_noDup (map ResClause.tptp_clause thms_clauses) (*string list*)
wenzelm@16259
   393
	val ax_file = File.platform_path axiom_file
paulson@15608
   394
	val out = TextIO.openOut ax_file
paulson@15608
   395
    in
quigley@15644
   396
	(ResLib.writeln_strs out clauses_strs; (warning ("axiom file is: "^ax_file));TextIO.closeOut out)
paulson@15608
   397
    end;
quigley@16039
   398
*)
paulson@15608
   399
paulson@15608
   400
quigley@16357
   401
quigley@16357
   402
paulson@15608
   403
(* called in Isar automatically *)
quigley@15679
   404
paulson@15608
   405
fun isar_atp (ctxt,thm) =
paulson@15608
   406
    let val prems = ProofContext.prems_of ctxt
quigley@15644
   407
        val d_cs = Classical.get_delta_claset ctxt 
quigley@15644
   408
        val d_ss_thms = Simplifier.get_delta_simpset ctxt
quigley@15644
   409
        val thmstring = string_of_thm thm
quigley@15679
   410
        val sg_prems = prems_of thm
paulson@15697
   411
        val sign = sign_of_thm thm
quigley@15679
   412
        val prem_no = length sg_prems
quigley@15779
   413
        val prems_string = Meson.concat_with_and (map (Sign.string_of_term sign) sg_prems) 
paulson@15608
   414
    in
quigley@15644
   415
          (warning ("initial thm in isar_atp: "^thmstring));
quigley@15644
   416
          (warning ("subgoals in isar_atp: "^prems_string));
quigley@15779
   417
    	  (warning ("number of subgoals in isar_atp: "^(string_of_int prem_no)));
quigley@16357
   418
          (*isar_local_thms (d_cs,d_ss_thms);*)
quigley@16357
   419
           isar_atp' (ctxt,prems, thm)
paulson@15608
   420
    end;
paulson@15347
   421
paulson@15608
   422
end
paulson@15608
   423
paulson@15608
   424
quigley@16357
   425
quigley@16357
   426
paulson@15347
   427
end;
paulson@15347
   428
paulson@15347
   429
Proof.atp_hook := ResAtp.isar_atp;