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