src/HOL/Tools/res_atp.ML
author paulson
Thu Apr 07 18:44:45 2005 +0200 (2005-04-07)
changeset 15682 09a7b8909c4d
parent 15679 28eb0fe50533
child 15697 681bcb7f0389
permissions -rw-r--r--
removed bad code
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
paulson@15452
     8
(*Jia: changed: isar_atp now processes entire proof context.  fetch thms from delta simpset/claset*)
quigley@15644
     9
(*Claire: changed: added actual watcher calls *)
paulson@15452
    10
paulson@15347
    11
signature RES_ATP = 
paulson@15347
    12
sig
paulson@15608
    13
val trace_res : bool ref
paulson@15608
    14
val axiom_file : Path.T
paulson@15608
    15
val hyps_file : Path.T
paulson@15608
    16
val isar_atp : ProofContext.context * Thm.thm -> unit
quigley@15657
    17
val prob_file : Path.T;
quigley@15644
    18
(*val atp_ax_tac : Thm.thm list -> int -> Tactical.tactic*)
quigley@15644
    19
(*val atp_tac : int -> Tactical.tactic*)
paulson@15608
    20
val debug: bool ref
paulson@15347
    21
paulson@15347
    22
end;
paulson@15347
    23
paulson@15347
    24
structure ResAtp : RES_ATP =
paulson@15608
    25
paulson@15347
    26
struct
paulson@15347
    27
quigley@15644
    28
quigley@15644
    29
paulson@15608
    30
(* used for debug *)
paulson@15608
    31
val debug = ref false;
paulson@15452
    32
paulson@15608
    33
fun debug_tac tac = (warning "testing";tac);
paulson@15608
    34
(* default value is false *)
paulson@15347
    35
paulson@15608
    36
val trace_res = ref false;
paulson@15347
    37
paulson@15608
    38
val skolem_tac = skolemize_tac;
paulson@15608
    39
quigley@15644
    40
val num_of_clauses = ref 0;
quigley@15644
    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,_) =>
paulson@15608
    47
	 let val ts = Logic.strip_assums_hyp prop
paulson@15608
    48
	 in EVERY1 
paulson@15608
    49
		[METAHYPS
paulson@15608
    50
		     (fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)),
paulson@15608
    51
	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
paulson@15608
    52
     end);
paulson@15347
    53
paulson@15608
    54
(* temporarily use these files, which will be loaded by Vampire *)
quigley@15644
    55
val file_id_num =ref 0;
paulson@15608
    56
quigley@15644
    57
fun new_prob_file () =  (file_id_num := (!file_id_num) + 1;"prob"^(string_of_int (!file_id_num)));
paulson@15608
    58
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");
quigley@15644
    64
val dummy_tac = PRIMITIVE(fn thm => thm );
quigley@15644
    65
quigley@15644
    66
 
quigley@15644
    67
fun concat_with_and [] str = str
quigley@15644
    68
|   concat_with_and (x::[]) str = str^" ("^x^")"
quigley@15644
    69
|   concat_with_and (x::xs) str = (concat_with_and xs (str^"("^x^")"^" & "))
quigley@15644
    70
paulson@15347
    71
paulson@15347
    72
paulson@15347
    73
(**** for Isabelle/ML interface  ****)
paulson@15347
    74
quigley@15644
    75
fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126) andalso (not ((ord ch ) = 63))) orelse (ch = " ")
paulson@15608
    76
quigley@15644
    77
fun proofstring x = let val exp = explode x 
quigley@15644
    78
                    in
quigley@15644
    79
                        List.filter (is_proof_char ) exp
quigley@15644
    80
                    end
paulson@15608
    81
paulson@15608
    82
paulson@15452
    83
quigley@15644
    84
(*
quigley@15644
    85
fun call_atp_tac thms n = (tptp_inputs thms ; dummy_tac);
paulson@15347
    86
quigley@15644
    87
*)
paulson@15347
    88
paulson@15347
    89
(**** For running in Isar ****)
paulson@15347
    90
paulson@15608
    91
(* same function as that in res_axioms.ML *)
paulson@15608
    92
fun repeat_RS thm1 thm2 =
paulson@15608
    93
    let val thm1' =  thm1 RS thm2 handle THM _ => thm1
paulson@15608
    94
    in
paulson@15608
    95
	if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2)
paulson@15608
    96
    end;
paulson@15608
    97
paulson@15608
    98
(* a special version of repeat_RS *)
paulson@15608
    99
fun repeat_someI_ex thm = repeat_RS thm someI_ex;
paulson@15608
   100
quigley@15644
   101
(*********************************************************************)
paulson@15608
   102
(* convert clauses from "assume" to conjecture. write to file "hyps" *)
quigley@15644
   103
(* hypotheses of the goal currently being proved                     *)
quigley@15644
   104
(*********************************************************************)
quigley@15644
   105
paulson@15608
   106
fun isar_atp_h thms =
quigley@15644
   107
        
paulson@15608
   108
    let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms
quigley@15644
   109
        val prems' = map repeat_someI_ex prems
quigley@15644
   110
        val prems'' = make_clauses prems'
quigley@15644
   111
        val prems''' = ResAxioms.rm_Eps [] prems''
quigley@15644
   112
        val clss = map ResClause.make_conjecture_clause prems'''
paulson@15608
   113
	val (tptp_clss,tfree_litss) = ResLib.unzip (map ResClause.clause2tptp clss) 
paulson@15608
   114
	val tfree_lits = ResLib.flat_noDup tfree_litss
paulson@15608
   115
	val tfree_clss = map ResClause.tfree_clause tfree_lits 
paulson@15608
   116
        val hypsfile = File.sysify_path hyps_file
paulson@15608
   117
	val out = TextIO.openOut(hypsfile)
paulson@15608
   118
    in
paulson@15608
   119
	((ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; if !trace_res then (warning hypsfile) else ());tfree_lits) 
paulson@15608
   120
    end;
paulson@15347
   121
quigley@15644
   122
quigley@15644
   123
(*********************************************************************)
quigley@15644
   124
(* write out a subgoal as tptp clauses to the file "probN"           *)
quigley@15644
   125
(* where N is the number of this subgoal                             *)
quigley@15644
   126
(*********************************************************************)
quigley@15644
   127
paulson@15608
   128
fun tptp_inputs_tfrees thms n tfrees = 
quigley@15657
   129
    let val _ = (warning ("in tptp_inputs_tfrees 0"))
quigley@15657
   130
        val clss = map (ResClause.make_conjecture_clause_thm) thms
quigley@15657
   131
         val _ = (warning ("in tptp_inputs_tfrees 1"))
paulson@15608
   132
	val (tptp_clss,tfree_litss) = ResLib.unzip (map ResClause.clause2tptp clss)
quigley@15657
   133
        val _ = (warning ("in tptp_inputs_tfrees 2"))
paulson@15608
   134
	val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) 
quigley@15657
   135
         val _ = (warning ("in tptp_inputs_tfrees 3"))
paulson@15608
   136
        val probfile = (File.sysify_path prob_file) ^ "_" ^ (string_of_int n)
paulson@15608
   137
	val out = TextIO.openOut(probfile)
paulson@15608
   138
    in
paulson@15608
   139
	(ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; (if !trace_res then (warning probfile) else ()))
paulson@15608
   140
    end;
paulson@15452
   141
paulson@15608
   142
paulson@15608
   143
quigley@15644
   144
(*********************************************************************)
quigley@15644
   145
(* call SPASS with settings and problem file for the current subgoal *)
quigley@15644
   146
(* should be modified to allow other provers to be called            *)
quigley@15644
   147
(*********************************************************************)
paulson@15608
   148
quigley@15657
   149
fun call_resolve_tac thms sg_term (childin, childout,pid) n  = let
quigley@15644
   150
                             val thmstring = concat_with_and (map string_of_thm thms) ""
quigley@15657
   151
                             val thm_no = length thms
quigley@15657
   152
                             val _ = warning ("number of thms is : "^(string_of_int thm_no))
quigley@15657
   153
                             val _ = warning ("thmstring in call_res is: "^thmstring)
quigley@15657
   154
quigley@15657
   155
                             val goalstr = Sign.string_of_term Mainsign sg_term 
quigley@15657
   156
                             val goalproofstring = proofstring goalstr
quigley@15657
   157
                             val no_returns =List.filter not_newline ( goalproofstring)
quigley@15657
   158
                             val goalstring = implode no_returns
quigley@15657
   159
                             val _ = warning ("goalstring in call_res is: "^goalstring)
quigley@15644
   160
        
quigley@15657
   161
                             (*val prob_file =File.tmp_path (Path.basic newprobfile); *)
quigley@15653
   162
                             (*val _ =( warning ("calling make_clauses "))
quigley@15644
   163
                             val clauses = make_clauses thms
quigley@15653
   164
                             val _ =( warning ("called make_clauses "))*)
quigley@15657
   165
                             (*val _ = tptp_inputs clauses prob_file*)
quigley@15657
   166
                             val thmstring = concat_with_and (map string_of_thm thms) ""
quigley@15644
   167
                           
quigley@15657
   168
                             val goalstr = Sign.string_of_term Mainsign sg_term 
quigley@15657
   169
                             val goalproofstring = proofstring goalstr
quigley@15644
   170
                             val no_returns =List.filter not_newline ( goalproofstring)
quigley@15657
   171
                             val goalstring = implode no_returns
paulson@15608
   172
quigley@15657
   173
                             val thmproofstring = proofstring ( thmstring)
quigley@15657
   174
                             val no_returns =List.filter   not_newline ( thmproofstring)
quigley@15657
   175
                             val thmstr = implode no_returns
quigley@15644
   176
                            
quigley@15657
   177
                             val probfile = (File.sysify_path prob_file) ^ "_" ^ (string_of_int n)
quigley@15679
   178
                             val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "hellofile")))
quigley@15657
   179
                             val _ = TextIO.output(outfile, "prob file path is "^probfile^" thmstring is "^thmstr^" goalstring is "^goalstring);
quigley@15657
   180
                             val _ = TextIO.flushOut outfile;
quigley@15657
   181
                             val _ =  TextIO.closeOut outfile
quigley@15644
   182
                          in
quigley@15644
   183
                           (* without paramodulation *)
quigley@15657
   184
                           (warning ("goalstring in call_res_tac is: "^goalstring));
quigley@15657
   185
                           (warning ("prob file in cal_res_tac is: "^probfile));
quigley@15644
   186
                            Watcher.callResProvers(childout,
quigley@15644
   187
                            [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS",  
quigley@15644
   188
                             "-FullRed=0%-Auto=0%-ISRe%-ISFc%-RTaut%-RFSub%-RBSub%-DocProof", 
quigley@15657
   189
                             probfile)]);
quigley@15657
   190
quigley@15644
   191
                           (* with paramodulation *)
quigley@15644
   192
                           (*Watcher.callResProvers(childout,
quigley@15644
   193
                                  [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS",
quigley@15644
   194
                                  "-FullRed=0%-ISPm=1%-Split=0%-PObv=0%-DocProof", 
quigley@15644
   195
                                    prob_path)]); *)
quigley@15657
   196
                          (* Watcher.callResProvers(childout,
quigley@15644
   197
                           [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS", 
quigley@15657
   198
                           "-DocProof",  prob_path)]);*)
quigley@15644
   199
                           dummy_tac
quigley@15644
   200
                         end
paulson@15452
   201
quigley@15644
   202
(************************************************)
quigley@15644
   203
(* pass in subgoal as a term and watcher info   *)
quigley@15644
   204
(* process subgoal into skolemized, negated form*)
quigley@15644
   205
(* then call call_resolve_tac to send to ATP    *)
quigley@15644
   206
(************************************************)
quigley@15657
   207
(*
quigley@15644
   208
fun resolve_tac sg_term  (childin, childout,pid) = 
quigley@15644
   209
   let val _ = warning ("in resolve_tac ")
quigley@15644
   210
   in
quigley@15644
   211
   SELECT_GOAL
quigley@15653
   212
  (EVERY1 [rtac ccontr,atomize_tac,skolemize_tac,  METAHYPS(fn negs => (warning ("calling call_resolve_tac next ");dummy_tac (*call_resolve_tac negs sg_term (childin, childout,pid)*)))])
quigley@15644
   213
   end;
paulson@15452
   214
quigley@15657
   215
*)
paulson@15608
   216
paulson@15452
   217
quigley@15644
   218
(* Need to replace call_atp_tac_tfrees with call res_provers as it's the dummy one *)
quigley@15644
   219
quigley@15644
   220
(**********************************************************)
quigley@15644
   221
(* write out the current subgoal as a tptp file, probN,   *)
quigley@15644
   222
(* then call dummy_tac - should be call_res_tac           *)
quigley@15644
   223
(**********************************************************)
quigley@15653
   224
(* should call call_res_tac here, not resolve_tac *)
quigley@15653
   225
(* if we take tptpinputs out it gets into call_res_tac then falls over as usual after printing out goalstring. but if we leave it in it falls over here *)
quigley@15679
   226
quigley@15679
   227
(* dummy tac vs.  Doesn't call resolve_tac *)
quigley@15657
   228
quigley@15679
   229
fun call_atp_tac_tfrees thms n tfrees sg_term (childin, childout,pid) = 
quigley@15679
   230
                                         ( (warning("ths for tptp: "^(concat_with_and (map string_of_thm thms) "")));
quigley@15679
   231
                                           (warning("in call_atp_tac_tfrees"));
quigley@15679
   232
                                           
quigley@15657
   233
                                           tptp_inputs_tfrees (make_clauses thms) n tfrees;
quigley@15679
   234
                                           call_resolve_tac thms sg_term (childin, childout, pid) n;
quigley@15679
   235
  					   dummy_tac);
quigley@15644
   236
quigley@15679
   237
quigley@15679
   238
(*
quigley@15644
   239
fun atp_tac_tfrees tfrees sg_term (childin, childout,pid)  n  = 
quigley@15644
   240
let val _ = (warning ("in atp_tac_tfrees "))
quigley@15644
   241
   in
quigley@15679
   242
SELECT_GOAL (EVERY1 [rtac ccontr,atomize_tac,(*skolemize_tac,*) METAHYPS(fn negs => ((warning("calling  call_atp_tac_tfrees with negs"^(concat_with_and (map  string_of_thm negs) "")));(*make_clauses negs;*)dummy_tac)) ])1
quigley@15644
   243
end;
quigley@15644
   244
quigley@15644
   245
quigley@15679
   246
quigley@15679
   247
METAHYPS(fn negs => ((warning("calling  call_atp_tac_tfrees with negs"^(concat_with_and (map  string_of_thm negs) ""))));make_clauses negs;dummy_tac)) 1;
quigley@15679
   248
*)
quigley@15679
   249
quigley@15679
   250
quigley@15679
   251
fun atp_tac_tfrees tfrees sg_term (childin, childout,pid)  n  = 
quigley@15679
   252
let val _ = (warning ("in atp_tac_tfrees "))
quigley@15679
   253
    val _ = (warning ("sg_term :"^((Sign.string_of_term Mainsign) sg_term)))
quigley@15679
   254
   
quigley@15679
   255
   in
quigley@15679
   256
SELECT_GOAL
paulson@15682
   257
  (EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, 
quigley@15679
   258
  METAHYPS(fn negs => ((warning("calling  call_atp_tac_tfrees with negs"^(concat_with_and (map  string_of_thm negs) "")));call_atp_tac_tfrees (negs) n tfrees sg_term (childin, childout,pid) ))]) n
quigley@15679
   259
end;
quigley@15679
   260
quigley@15679
   261
quigley@15679
   262
fun isar_atp_g tfrees sg_term (childin, childout, pid) n = 
quigley@15644
   263
                                        
quigley@15679
   264
((warning("in isar_atp_g"));atp_tac_tfrees tfrees sg_term (childin, childout, pid) n);
quigley@15644
   265
quigley@15644
   266
quigley@15644
   267
quigley@15644
   268
(**********************************************)
quigley@15644
   269
(* recursively call atp_tac_g on all subgoals *)
quigley@15644
   270
(* sg_term is the nth subgoal as a term - used*)
quigley@15644
   271
(* in proof reconstruction                    *)
quigley@15644
   272
(**********************************************)
quigley@15644
   273
quigley@15644
   274
fun isar_atp_goal' thm k n tfree_lits  (childin, childout, pid) = 
quigley@15644
   275
                  	if (k > n) 
quigley@15644
   276
                        then () 
quigley@15644
   277
	  		else 
quigley@15644
   278
                           (let val  prems = prems_of thm 
quigley@15644
   279
                                val sg_term = get_nth n prems
quigley@15679
   280
                                val thmstring = string_of_thm thm
quigley@15644
   281
                            in   
quigley@15644
   282
                                 
quigley@15644
   283
                		(warning("in isar_atp_goal'"));
quigley@15679
   284
                                (warning("thmstring in isar_atp_goal: "^thmstring));
quigley@15644
   285
 				 isar_atp_g tfree_lits  sg_term (childin, childout, pid) k thm; 
quigley@15644
   286
                                 isar_atp_goal' thm (k+1) n tfree_lits  (childin, childout, pid) 
quigley@15644
   287
                            end);
quigley@15644
   288
quigley@15644
   289
quigley@15644
   290
fun isar_atp_goal thm n_subgoals tfree_lits   (childin, childout, pid) = (if (!debug) then warning (string_of_thm thm) else (isar_atp_goal' thm 1 n_subgoals tfree_lits  (childin, childout, pid) ));
quigley@15644
   291
quigley@15644
   292
(**************************************************)
quigley@15644
   293
(* convert clauses from "assume" to conjecture.   *)
quigley@15644
   294
(* i.e. apply make_clauses and then get tptp for  *)
quigley@15679
   295
(* any hypotheses in the goal produced by assume  *)
quigley@15679
   296
(* statements;                                    *)
quigley@15644
   297
(* write to file "hyps"                           *)
quigley@15644
   298
(**************************************************)
quigley@15644
   299
quigley@15644
   300
quigley@15644
   301
fun isar_atp_aux thms thm n_subgoals  (childin, childout, pid) = 
paulson@15608
   302
    let val tfree_lits = isar_atp_h thms 
paulson@15608
   303
    in
quigley@15644
   304
	(warning("in isar_atp_aux"));isar_atp_goal thm n_subgoals tfree_lits   (childin, childout, pid)
paulson@15608
   305
    end;
quigley@15644
   306
quigley@15644
   307
(******************************************************************)
quigley@15644
   308
(* called in Isar automatically                                   *)
quigley@15644
   309
(* writes out the current clasimpset to a tptp file               *)
quigley@15644
   310
(* passes all subgoals on to isar_atp_aux for further processing  *)
quigley@15644
   311
(* turns off xsymbol at start of function, restoring it at end    *)
quigley@15644
   312
(******************************************************************)
paulson@15452
   313
paulson@15608
   314
fun isar_atp' (thms, thm) =
quigley@15644
   315
    let val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
quigley@15644
   316
        val _= (warning ("in isar_atp'"))
quigley@15644
   317
        val prems = prems_of thm
quigley@15644
   318
        val thms_string =concat_with_and (map  string_of_thm thms) ""
quigley@15644
   319
        val thmstring = string_of_thm thm
quigley@15644
   320
        val prems_string = concat_with_and (map (Sign.string_of_term Mainsign) prems) ""
quigley@15644
   321
        (* set up variables for writing out the clasimps to a tptp file *)
quigley@15644
   322
        (* val _ = write_out_clasimp (File.sysify_path axiom_file)*)
quigley@15644
   323
        (* cq: add write out clasimps to file *)
quigley@15644
   324
        (* cq:create watcher and pass to isar_atp_aux *)                    
quigley@15657
   325
        val (childin,childout,pid) = Watcher.createWatcher()
quigley@15644
   326
        val pidstring = string_of_int(Word.toInt (Word.fromLargeWord ( Posix.Process.pidToWord pid )))
paulson@15608
   327
    in
quigley@15644
   328
	case prems of [] => () 
quigley@15644
   329
		    | _ => ((warning ("initial thms: "^thms_string)); 
quigley@15644
   330
                           (warning ("initial thm: "^thmstring));
quigley@15644
   331
                           (warning ("subgoals: "^prems_string));
quigley@15644
   332
                           (warning ("pid: "^ pidstring))); 
quigley@15644
   333
                            isar_atp_aux thms thm (length prems) (childin, childout, pid) ;
quigley@15644
   334
                           
quigley@15644
   335
                           print_mode := (["xsymbols", "symbols"] @ ! print_mode)
paulson@15608
   336
    end;
paulson@15608
   337
paulson@15452
   338
paulson@15608
   339
paulson@15608
   340
paulson@15608
   341
local
paulson@15608
   342
paulson@15608
   343
fun get_thms_cs claset =
paulson@15608
   344
    let val clsset = rep_cs claset
paulson@15608
   345
	val safeEs = #safeEs clsset
paulson@15608
   346
	val safeIs = #safeIs clsset
paulson@15608
   347
	val hazEs = #hazEs clsset
paulson@15608
   348
	val hazIs = #hazIs clsset
paulson@15608
   349
    in
paulson@15608
   350
	safeEs @ safeIs @ hazEs @ hazIs
paulson@15608
   351
    end;
paulson@15608
   352
paulson@15608
   353
paulson@15452
   354
paulson@15608
   355
fun append_name name [] _ = []
paulson@15608
   356
  | append_name name (thm::thms) k = (Thm.name_thm ((name ^ "_" ^ (string_of_int k)),thm)) :: (append_name name thms (k+1));
paulson@15608
   357
paulson@15608
   358
fun append_names (name::names) (thms::thmss) =
paulson@15608
   359
    let val thms' = append_name name thms 0
paulson@15608
   360
    in
paulson@15608
   361
	thms'::(append_names names thmss)
paulson@15608
   362
    end;
paulson@15608
   363
paulson@15452
   364
paulson@15608
   365
fun get_thms_ss [] = []
paulson@15608
   366
  | get_thms_ss thms =
paulson@15608
   367
    let val names = map Thm.name_of_thm thms 
paulson@15608
   368
        val thms' = map (mksimps mksimps_pairs) thms
paulson@15608
   369
        val thms'' = append_names names thms'
paulson@15608
   370
    in
paulson@15608
   371
	ResLib.flat_noDup thms''
paulson@15608
   372
    end;
paulson@15608
   373
paulson@15452
   374
paulson@15608
   375
paulson@15608
   376
paulson@15608
   377
in
paulson@15608
   378
paulson@15452
   379
paulson@15608
   380
(* convert locally declared rules to axiom clauses *)
paulson@15608
   381
(* write axiom clauses to ax_file *)
quigley@15644
   382
(* what about clasimpset - it should already be in the ax file - perhaps append to ax file rather than just *)
quigley@15644
   383
(* write out ? Or keep as a separate file and then cat them all together in the watcher, like we do with the *)
quigley@15644
   384
(*claset file and prob file*)
paulson@15608
   385
fun isar_local_thms (delta_cs, delta_ss_thms) =
paulson@15608
   386
    let val thms_cs = get_thms_cs delta_cs
paulson@15608
   387
	val thms_ss = get_thms_ss delta_ss_thms
paulson@15608
   388
	val thms_clauses = ResLib.flat_noDup (map ResAxioms.clausify_axiom (thms_cs @ thms_ss))
paulson@15608
   389
	val clauses_strs = ResLib.flat_noDup (map ResClause.tptp_clause thms_clauses) (*string list*)
paulson@15608
   390
	val ax_file = File.sysify_path axiom_file
paulson@15608
   391
	val out = TextIO.openOut ax_file
paulson@15608
   392
    in
quigley@15644
   393
	(ResLib.writeln_strs out clauses_strs; (warning ("axiom file is: "^ax_file));TextIO.closeOut out)
paulson@15608
   394
    end;
paulson@15347
   395
paulson@15608
   396
paulson@15608
   397
paulson@15608
   398
paulson@15347
   399
paulson@15608
   400
(* called in Isar automatically *)
quigley@15679
   401
paulson@15608
   402
fun isar_atp (ctxt,thm) =
paulson@15608
   403
    let val prems = ProofContext.prems_of ctxt
quigley@15644
   404
        val d_cs = Classical.get_delta_claset ctxt 
quigley@15644
   405
        val d_ss_thms = Simplifier.get_delta_simpset ctxt
quigley@15644
   406
        val thmstring = string_of_thm thm
quigley@15679
   407
        val sg_prems = prems_of thm
quigley@15679
   408
        val prem_no = length sg_prems
quigley@15679
   409
        val prems_string =  concat_with_and (map (Sign.string_of_term Mainsign) sg_prems) ""
paulson@15608
   410
    in
quigley@15644
   411
         
quigley@15644
   412
          (warning ("initial thm in isar_atp: "^thmstring));
quigley@15644
   413
          (warning ("subgoals in isar_atp: "^prems_string));
quigley@15644
   414
    	   (warning ("number of subgoals in isar_atp: "^(string_of_int prem_no)));
quigley@15644
   415
          (isar_local_thms (d_cs,d_ss_thms); (warning("about to call isar_atp'"));
quigley@15644
   416
           isar_atp' (prems, thm))
paulson@15608
   417
    end;
paulson@15347
   418
paulson@15608
   419
end
paulson@15608
   420
paulson@15608
   421
paulson@15608
   422
paulson@15452
   423
paulson@15347
   424
end;
paulson@15347
   425
paulson@15347
   426
Proof.atp_hook := ResAtp.isar_atp;