src/HOL/Tools/res_atp.ML
changeset 20870 992bcbff055a
parent 20868 724ab9896068
child 20954 3bbe7cab8037
equal deleted inserted replaced
20869:5abf3cd34a35 20870:992bcbff055a
    28   val eproverLimit: unit -> int
    28   val eproverLimit: unit -> int
    29   val spassLimit: unit -> int
    29   val spassLimit: unit -> int
    30   val atp_method: (Proof.context -> thm list -> int -> tactic) ->
    30   val atp_method: (Proof.context -> thm list -> int -> tactic) ->
    31     Method.src -> Proof.context -> Proof.method
    31     Method.src -> Proof.context -> Proof.method
    32   val cond_rm_tmp: string -> unit
    32   val cond_rm_tmp: string -> unit
    33   val keep_atp_input: bool ref
       
    34   val fol_keep_types: bool ref
    33   val fol_keep_types: bool ref
    35   val hol_full_types: unit -> unit
    34   val hol_full_types: unit -> unit
    36   val hol_partial_types: unit -> unit
    35   val hol_partial_types: unit -> unit
    37   val hol_const_types_only: unit -> unit
    36   val hol_const_types_only: unit -> unit
    38   val hol_no_types: unit -> unit
    37   val hol_no_types: unit -> unit
   111 
   110 
   112 fun vampireLimit () = !vampire_time;
   111 fun vampireLimit () = !vampire_time;
   113 fun eproverLimit () = !eprover_time;
   112 fun eproverLimit () = !eprover_time;
   114 fun spassLimit () = !spass_time;
   113 fun spassLimit () = !spass_time;
   115 
   114 
   116 val keep_atp_input = ref false;
       
   117 val fol_keep_types = ResClause.keep_types;
   115 val fol_keep_types = ResClause.keep_types;
   118 val hol_full_types = ResHolClause.full_types;
   116 val hol_full_types = ResHolClause.full_types;
   119 val hol_partial_types = ResHolClause.partial_types;
   117 val hol_partial_types = ResHolClause.partial_types;
   120 val hol_const_types_only = ResHolClause.const_types_only;
   118 val hol_const_types_only = ResHolClause.const_types_only;
   121 val hol_no_types = ResHolClause.no_types;
   119 val hol_no_types = ResHolClause.no_types;
   688     end;
   686     end;
   689 
   687 
   690 
   688 
   691 (**** remove tmp files ****)
   689 (**** remove tmp files ****)
   692 fun cond_rm_tmp file = 
   690 fun cond_rm_tmp file = 
   693     if !keep_atp_input then Output.debug "ATP input kept..." 
   691     if !Output.show_debug_msgs orelse !destdir <> "" then Output.debug "ATP input kept..." 
   694     else if !destdir <> "" then Output.debug ("ATP input kept in directory " ^ (!destdir))
   692     else OS.FileSys.remove file;
   695     else (Output.debug "deleting ATP inputs..."; OS.FileSys.remove file);
       
   696 
   693 
   697 
   694 
   698 (****** setup ATPs as Isabelle methods ******)
   695 (****** setup ATPs as Isabelle methods ******)
   699 fun atp_meth' tac ths ctxt = 
   696 fun atp_meth' tac ths ctxt = 
   700     Method.SIMPLE_METHOD' HEADGOAL
   697     Method.SIMPLE_METHOD' HEADGOAL
   807 	| write_all (ccls::ccls_list) (axcls::axcls_list) k =
   804 	| write_all (ccls::ccls_list) (axcls::axcls_list) k =
   808             let val fname = probfile k
   805             let val fname = probfile k
   809                 val axcls = make_unique axcls
   806                 val axcls = make_unique axcls
   810                 val ccls = subtract_cls ccls axcls
   807                 val ccls = subtract_cls ccls axcls
   811                 val clnames = writer logic ccls fname (axcls,classrel_clauses,arity_clauses) []
   808                 val clnames = writer logic ccls fname (axcls,classrel_clauses,arity_clauses) []
   812             in  (clnames,fname) :: write_all ccls_list axcls_list (k+1)  end
   809                 val thm_names = Array.fromList clnames
   813       val (clnames::_, filenames) = ListPair.unzip (write_all goal_cls axcls_list 1)
   810                 val _ = if !Output.show_debug_msgs 
   814       val thm_names = Array.fromList clnames
   811                         then trace_array (fname ^ "_thm_names") thm_names else ()
   815       val _ = if !Output.show_debug_msgs 
   812             in  (thm_names,fname) :: write_all ccls_list axcls_list (k+1)  end
   816               then trace_array "thm_names" thm_names else ()
   813       val (thm_names_list, filenames) = ListPair.unzip (write_all goal_cls axcls_list 1)
   817   in
   814   in
   818       (filenames, thm_names)
   815       (filenames, thm_names_list)
   819   end;
   816   end;
   820 
   817 
   821 val last_watcher_pid = ref (NONE : (TextIO.instream * TextIO.outstream * 
   818 val last_watcher_pid = ref (NONE : (TextIO.instream * TextIO.outstream * 
   822                                     Posix.Process.pid * string list) option);
   819                                     Posix.Process.pid * string list) option);
   823 
   820 
   825     (case !last_watcher_pid of 
   822     (case !last_watcher_pid of 
   826          NONE => ()
   823          NONE => ()
   827        | SOME (_, _, pid, files) => 
   824        | SOME (_, _, pid, files) => 
   828 	  (Output.debug ("Killing old watcher, pid = " ^ string_of_pid pid);
   825 	  (Output.debug ("Killing old watcher, pid = " ^ string_of_pid pid);
   829 	   Watcher.killWatcher pid;  
   826 	   Watcher.killWatcher pid;  
   830 	   ignore (map (try OS.FileSys.remove) files)))
   827 	   ignore (map (try cond_rm_tmp) files)))
   831      handle OS.SysErr _ => Output.debug "Attempt to kill watcher failed";
   828      handle OS.SysErr _ => Output.debug "Attempt to kill watcher failed";
   832 
   829 
   833 (*writes out the current clasimpset to a tptp file;
   830 (*writes out the current clasimpset to a tptp file;
   834   turns off xsymbol at start of function, restoring it at end    *)
   831   turns off xsymbol at start of function, restoring it at end    *)
   835 val isar_atp = setmp print_mode [] 
   832 val isar_atp = setmp print_mode [] 
   836  (fn (ctxt, th) =>
   833  (fn (ctxt, th) =>
   837   if Thm.no_prems th then ()
   834   if Thm.no_prems th then ()
   838   else
   835   else
   839     let
   836     let
   840       val _ = kill_last_watcher()
   837       val _ = kill_last_watcher()
   841       val (files,thm_names) = write_problem_files prob_pathname (ctxt,th)
   838       val (files,thm_names_list) = write_problem_files prob_pathname (ctxt,th)
   842       val (childin, childout, pid) = Watcher.createWatcher (th, thm_names)
   839       val (childin, childout, pid) = Watcher.createWatcher (th, thm_names_list)
   843     in
   840     in
   844       last_watcher_pid := SOME (childin, childout, pid, files);
   841       last_watcher_pid := SOME (childin, childout, pid, files);
   845       Output.debug ("problem files: " ^ space_implode ", " files); 
   842       Output.debug ("problem files: " ^ space_implode ", " files); 
   846       Output.debug ("pid: " ^ string_of_pid pid);
   843       Output.debug ("pid: " ^ string_of_pid pid);
   847       watcher_call_provers (sign_of_thm th) (Thm.prems_of th) (childin, childout, pid)
   844       watcher_call_provers (sign_of_thm th) (Thm.prems_of th) (childin, childout, pid)