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