src/HOL/Tools/res_atp.ML
author paulson
Tue, 31 Jan 2006 10:39:13 +0100
changeset 18863 a113b6839df1
parent 18798 ca02a2077955
child 18986 5060ca625e02
permissions -rw-r--r--
reorganization of code to support DFG otuput
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     1
(*  Author: Jia Meng, Cambridge University Computer Laboratory
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     2
    ID: $Id$
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     3
    Copyright 2004 University of Cambridge
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     4
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     5
ATPs with TPTP format input.
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     6
*)
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
     7
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
     8
signature RES_ATP =
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
     9
sig
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    10
  val prover: string ref
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    11
  val custom_spass: string list ref
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    12
  val destdir: string ref
17849
d7619ccf22e6 signature changes
paulson
parents: 17845
diff changeset
    13
  val helper_path: string -> string -> string
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    14
  val problem_name: string ref
17690
8ba7c3cd24a8 time limit option; fixed bug concerning first line of ATP output
paulson
parents: 17525
diff changeset
    15
  val time_limit: int ref
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    16
end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    17
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    18
structure ResAtp: RES_ATP =
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    19
struct
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    20
17150
ce2a1aeb42aa DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents: 17091
diff changeset
    21
val call_atp = ref false;
ce2a1aeb42aa DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents: 17091
diff changeset
    22
val hook_count = ref 0;
18675
333a73034023 more practical time limit
paulson
parents: 18404
diff changeset
    23
val time_limit = ref 30;
17150
ce2a1aeb42aa DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents: 17091
diff changeset
    24
17404
d16c3a62c396 the experimental tagging system, and the usual tidying
paulson
parents: 17317
diff changeset
    25
val prover = ref "E";   (* use E as the default prover *)
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    26
val custom_spass =   (*specialized options for SPASS*)
17690
8ba7c3cd24a8 time limit option; fixed bug concerning first line of ATP output
paulson
parents: 17525
diff changeset
    27
      ref ["-Auto=0","-FullRed=0","-IORe","-IOFc","-RTaut","-RFSub","-RBSub"];
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    28
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    29
val destdir = ref "";   (*Empty means write files to /tmp*)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    30
val problem_name = ref "prob";
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    31
17819
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    32
(*Return the path to a "helper" like SPASS or tptp2X, first checking that
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    33
  it exists.  FIXME: modify to use Path primitives and move to some central place.*)  
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    34
fun helper_path evar base =
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    35
  case getenv evar of
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    36
      "" => error  ("Isabelle environment variable " ^ evar ^ " not defined")
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    37
    | home => 
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    38
        let val path = home ^ "/" ^ base
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    39
        in  if File.exists (File.unpack_platform_path path) then path 
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    40
	    else error ("Could not find the file " ^ path)
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    41
	end;  
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    42
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
    43
fun probfile_nosuffix _ = 
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    44
  if !destdir = "" then File.platform_path (File.tmp_path (Path.basic (!problem_name)))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    45
  else if File.exists (File.unpack_platform_path (!destdir))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    46
  then !destdir ^ "/" ^ !problem_name
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    47
  else error ("No such directory: " ^ !destdir);
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    48
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
    49
fun prob_pathname n = probfile_nosuffix n ^ "_" ^ Int.toString n;
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
    50
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    51
(* call prover with settings and problem file for the current subgoal *)
17764
fde495b9e24b improved process handling. tidied
paulson
parents: 17746
diff changeset
    52
fun watcher_call_provers sign sg_terms (childin, childout, pid) =
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    53
  let
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17404
diff changeset
    54
    fun make_atp_list [] n = []
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
    55
      | make_atp_list (sg_term::xs) n =
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    56
          let
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
    57
            val probfile = prob_pathname n
17690
8ba7c3cd24a8 time limit option; fixed bug concerning first line of ATP output
paulson
parents: 17525
diff changeset
    58
            val time = Int.toString (!time_limit)
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    59
          in
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
    60
            Output.debug ("problem file in watcher_call_provers is " ^ probfile);
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17306
diff changeset
    61
            (*Avoid command arguments containing spaces: Poly/ML and SML/NJ
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17306
diff changeset
    62
              versions of Unix.execute treat them differently!*)
17764
fde495b9e24b improved process handling. tidied
paulson
parents: 17746
diff changeset
    63
            (*options are separated by Watcher.setting_sep, currently #"%"*)
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    64
            if !prover = "spass"
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    65
            then
18700
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    66
              let val baseopts = "%-PGiven=0%-PProblem=0%-Splits=0%-FullRed=0%-DocProof%-TimeLimit=" ^ time
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    67
              val infopts = 
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    68
		      if !AtpCommunication.reconstruct 
18700
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    69
		          (*Proof reconstruction needs a limited set of inf rules*)
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    70
                      then space_implode "%" (!custom_spass)                           
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    71
                      else "-Auto%-SOS=1"
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    72
                  val spass = helper_path "SPASS_HOME" "SPASS"
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    73
            in 
f04a8755d6ca improved SPASS support
paulson
parents: 18680
diff changeset
    74
                ([("spass", spass, infopts ^ baseopts, probfile)] @ 
18798
ca02a2077955 tidying up SPASS output
paulson
parents: 18753
diff changeset
    75
                  make_atp_list xs (n+1))
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    76
              end
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    77
            else if !prover = "vampire"
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17234
diff changeset
    78
	    then 
17819
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    79
              let val vampire = helper_path "VAMPIRE_HOME" "vampire"
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    80
              in
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
    81
                ([("vampire", vampire, "-m 100000%-t " ^ time, probfile)] @
18798
ca02a2077955 tidying up SPASS output
paulson
parents: 18753
diff changeset
    82
                 make_atp_list xs (n+1))       (*BEWARE! spaces in options!*)
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    83
              end
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    84
      	     else if !prover = "E"
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    85
      	     then
17819
1241e5d31d5b small tidy-up of utility functions
paulson
parents: 17775
diff changeset
    86
	       let val Eprover = helper_path "E_HOME" "eproof"
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    87
	       in
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
    88
		  ([("E", Eprover, 
17690
8ba7c3cd24a8 time limit option; fixed bug concerning first line of ATP output
paulson
parents: 17525
diff changeset
    89
		     "--tptp-in%-l5%-xAuto%-tAuto%--cpu-limit=" ^ time,
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17404
diff changeset
    90
		     probfile)] @
18798
ca02a2077955 tidying up SPASS output
paulson
parents: 18753
diff changeset
    91
		   make_atp_list xs (n+1))
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    92
	       end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
    93
	     else error ("Invalid prover name: " ^ !prover)
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    94
          end
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    95
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17404
diff changeset
    96
    val atp_list = make_atp_list sg_terms 1
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    97
  in
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
    98
    Watcher.callResProvers(childout,atp_list);
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
    99
    Output.debug "Sent commands to watcher!"
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   100
  end
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   101
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   102
(*We write out problem files for each subgoal. Argument pf generates filenames,
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   103
  and allows the suppression of the suffix "_1" in problem-generation mode.*)
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   104
fun write_problem_files pf (ctxt,th)  =
18753
aa82bd41555d ResClasimp.get_clasimp_lemmas now takes all subgoals rather than only the first
paulson
parents: 18700
diff changeset
   105
  let val goals = Thm.prems_of th
aa82bd41555d ResClasimp.get_clasimp_lemmas now takes all subgoals rather than only the first
paulson
parents: 18700
diff changeset
   106
      val (clause_arr, axclauses) = ResClasimp.get_clasimp_lemmas ctxt goals 
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   107
      val _ = Output.debug ("claset and simprules total clauses = " ^ 
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   108
                     Int.toString (Array.length clause_arr))
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   109
      val thy = ProofContext.theory_of ctxt
18270
27227433cb42 Only output arities and class relations if !ResClause.keep_types is true.
mengj
parents: 18003
diff changeset
   110
      val classrel_clauses = if !ResClause.keep_types then ResClause.classrel_clauses_thy thy else []
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   111
      val _ = Output.debug ("classrel clauses = " ^ Int.toString (length classrel_clauses))
18270
27227433cb42 Only output arities and class relations if !ResClause.keep_types is true.
mengj
parents: 18003
diff changeset
   112
      val arity_clauses = if !ResClause.keep_types then ResClause.arity_clause_thy thy else []
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   113
      val _ = Output.debug ("arity clauses = " ^ Int.toString (length arity_clauses))
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18798
diff changeset
   114
      val write = if !prover = "spass" then ResClause.dfg_write_file 
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18798
diff changeset
   115
                                       else ResClause.tptp_write_file
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   116
      fun writenext n =
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
   117
	if n=0 then []
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   118
	 else
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   119
	   (SELECT_GOAL
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   120
	    (EVERY1 [rtac ccontr, ObjectLogic.atomize_tac, skolemize_tac, 
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   121
	      METAHYPS(fn negs => 
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18798
diff changeset
   122
		(write (make_clauses negs) (pf n) 
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   123
		       (axclauses,classrel_clauses,arity_clauses);
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   124
		 all_tac))]) n th;
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
   125
	    pf n :: writenext (n-1))
18753
aa82bd41555d ResClasimp.get_clasimp_lemmas now takes all subgoals rather than only the first
paulson
parents: 18700
diff changeset
   126
      in (writenext (length goals), clause_arr) end;
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   127
17775
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   128
val last_watcher_pid = ref (NONE : (TextIO.instream * TextIO.outstream * 
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   129
                                    Posix.Process.pid * string list) option);
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   130
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   131
fun kill_last_watcher () =
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   132
    (case !last_watcher_pid of 
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   133
         NONE => ()
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   134
       | SOME (_, childout, pid, files) => 
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   135
	  (Output.debug ("Killing old watcher, pid = " ^ string_of_pid pid);
17775
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   136
	   Watcher.killWatcher pid;  
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   137
	   ignore (map (try OS.FileSys.remove) files)))
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   138
     handle OS.SysErr _ => Output.debug "Attempt to kill watcher failed";
17525
ae5bb6001afb tidying, and support for axclass/classrel clauses
paulson
parents: 17502
diff changeset
   139
ae5bb6001afb tidying, and support for axclass/classrel clauses
paulson
parents: 17502
diff changeset
   140
(*writes out the current clasimpset to a tptp file;
ae5bb6001afb tidying, and support for axclass/classrel clauses
paulson
parents: 17502
diff changeset
   141
  turns off xsymbol at start of function, restoring it at end    *)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   142
val isar_atp = setmp print_mode [] 
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   143
 (fn (ctxt, th) =>
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   144
  if Thm.no_prems th then ()
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   145
  else
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   146
    let
17775
2679ba74411f minor code tidyig
paulson
parents: 17773
diff changeset
   147
      val _ = kill_last_watcher()
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
   148
      val (files,clause_arr) = write_problem_files prob_pathname (ctxt,th)
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   149
      val (childin, childout, pid) = Watcher.createWatcher (th, clause_arr)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   150
    in
17772
818cec5f82a4 major simplification: removal of the goalstring argument
paulson
parents: 17764
diff changeset
   151
      last_watcher_pid := SOME (childin, childout, pid, files);
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   152
      Output.debug ("problem files: " ^ space_implode ", " files); 
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   153
      Output.debug ("pid: " ^ string_of_pid pid);
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   154
      watcher_call_provers (sign_of_thm th) (Thm.prems_of th) (childin, childout, pid)
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   155
    end);
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   156
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17404
diff changeset
   157
val isar_atp_writeonly = setmp print_mode [] 
17717
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   158
      (fn (ctxt,th) =>
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   159
       if Thm.no_prems th then ()
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   160
       else 
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   161
         let val pf = if Thm.nprems_of th = 1 then probfile_nosuffix 
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   162
         	      else prob_pathname
7c6a96cbc966 improvements for problem generation
paulson
parents: 17690
diff changeset
   163
         in ignore (write_problem_files pf (ctxt,th)) end);
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   164
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   165
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   166
(** the Isar toplevel hook **)
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   167
17091
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   168
val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state =>
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   169
  let
17091
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   170
    val proof = Toplevel.proof_of state
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   171
    val (ctxt, (_, goal)) = Proof.get_goal proof;
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   172
    val thy = ProofContext.theory_of ctxt;
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   173
  in
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   174
    Output.debug ("subgoals in isar_atp:\n" ^ 
17091
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   175
           Pretty.string_of (ProofContext.pretty_term ctxt
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   176
             (Logic.mk_conjunction_list (Thm.prems_of goal))));
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   177
    Output.debug ("number of subgoals in isar_atp: " ^ Int.toString (Thm.nprems_of goal));
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   178
    Output.debug ("current theory: " ^ Context.theory_name thy);
17150
ce2a1aeb42aa DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents: 17091
diff changeset
   179
    hook_count := !hook_count +1;
18680
677e2bdd75f0 Output.debug;
wenzelm
parents: 18675
diff changeset
   180
    Output.debug ("in hook for time: " ^ Int.toString (!hook_count));
16925
0fd7b1438d28 simpler variable names, and no types for monomorphic constants
paulson
parents: 16904
diff changeset
   181
    ResClause.init thy;
17690
8ba7c3cd24a8 time limit option; fixed bug concerning first line of ATP output
paulson
parents: 17525
diff changeset
   182
    if !destdir = "" andalso !time_limit > 0 then isar_atp (ctxt, goal)
17502
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   183
    else isar_atp_writeonly (ctxt, goal)
16802
6eeee59dac4c use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents: 16767
diff changeset
   184
  end);
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   185
17091
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   186
val call_atpP =
17746
af59c748371d fixed the ascii-armouring of goalstring
paulson
parents: 17717
diff changeset
   187
  OuterSyntax.command 
17091
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   188
    "ProofGeneral.call_atp" 
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   189
    "call automatic theorem provers" 
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   190
    OuterKeyword.diag
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   191
    (Scan.succeed (Toplevel.no_timing o invoke_atp));
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   192
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   193
val _ = OuterSyntax.add_parsers [call_atpP];
13593aa6a546 new command to invoke ATPs
paulson
parents: 16955
diff changeset
   194
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   195
end;