author | paulson |
Fri, 02 Sep 2005 17:55:24 +0200 | |
changeset 17234 | 12a9393c5d77 |
parent 17231 | f42bc4f7afdf |
child 17235 | 8e55ad29b690 |
permissions | -rw-r--r-- |
15608 | 1 |
(* Author: Jia Meng, Cambridge University Computer Laboratory |
2 |
ID: $Id$ |
|
3 |
Copyright 2004 University of Cambridge |
|
15347 | 4 |
|
5 |
ATPs with TPTP format input. |
|
6 |
*) |
|
15452 | 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 |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
10 |
val axiom_file : Path.T |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
11 |
(*val atp_ax_tac : thm list -> int -> Tactical.tactic*) |
15644 | 12 |
(*val atp_tac : int -> Tactical.tactic*) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
13 |
val full_spass: bool ref |
16478 | 14 |
(*val spass: bool ref*) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
15 |
val vampire: bool ref |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
16 |
val custom_spass: string list ref |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
17 |
val hook_count: int ref |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
18 |
(* val invoke_atp: Toplevel.transition -> Toplevel.transition*) |
15347 | 19 |
end; |
20 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
21 |
structure ResAtp: RES_ATP = |
15347 | 22 |
struct |
23 |
||
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
24 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
25 |
val call_atp = ref false; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
26 |
val hook_count = ref 0; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
27 |
|
16904 | 28 |
fun debug_tac tac = (debug "testing"; tac); |
16478 | 29 |
|
16357 | 30 |
val full_spass = ref false; |
16478 | 31 |
|
32 |
(* use spass as default prover *) |
|
33 |
(*val spass = ref true;*) |
|
34 |
||
16520 | 35 |
val custom_spass = ref ["Auto=0","-IORe","-IOFc","-RTaut","-RFSub","-RBSub","-DocProof","-TimeLimit=60"]; |
16478 | 36 |
val vampire = ref false; |
37 |
||
15608 | 38 |
val skolem_tac = skolemize_tac; |
39 |
||
15644 | 40 |
val num_of_clauses = ref 0; |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
41 |
val clause_arr = Array.array (3500, ("empty", 0)); |
15644 | 42 |
|
15347 | 43 |
|
15608 | 44 |
val atomize_tac = |
45 |
SUBGOAL |
|
46 |
(fn (prop,_) => |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
47 |
let val ts = Logic.strip_assums_hyp prop |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
48 |
in EVERY1 |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
49 |
[METAHYPS |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
50 |
(fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)), |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
51 |
REPEAT_DETERM_N (length ts) o (etac thin_rl)] |
15608 | 52 |
end); |
15347 | 53 |
|
15644 | 54 |
val axiom_file = File.tmp_path (Path.basic "axioms"); |
55 |
val clasimp_file = File.tmp_path (Path.basic "clasimp"); |
|
56 |
val hyps_file = File.tmp_path (Path.basic "hyps"); |
|
57 |
val prob_file = File.tmp_path (Path.basic "prob"); |
|
58 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
59 |
|
15347 | 60 |
(**** for Isabelle/ML interface ****) |
61 |
||
16897 | 62 |
(*Remove unwanted characters such as ? and newline from the textural |
63 |
representation of a theorem (surely they don't need to be produced in |
|
64 |
the first place?) *) |
|
15608 | 65 |
|
16897 | 66 |
fun is_proof_char ch = (#" " <= ch andalso ch <= #"~" andalso ch <> #"?"); |
67 |
||
68 |
val proofstring = |
|
69 |
String.translate (fn c => if is_proof_char c then str c else ""); |
|
15608 | 70 |
|
15452 | 71 |
|
15347 | 72 |
(**** For running in Isar ****) |
73 |
||
15608 | 74 |
(* same function as that in res_axioms.ML *) |
75 |
fun repeat_RS thm1 thm2 = |
|
76 |
let val thm1' = thm1 RS thm2 handle THM _ => thm1 |
|
77 |
in |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
78 |
if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2) |
15608 | 79 |
end; |
80 |
||
81 |
(* a special version of repeat_RS *) |
|
82 |
fun repeat_someI_ex thm = repeat_RS thm someI_ex; |
|
83 |
||
16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset
|
84 |
|
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset
|
85 |
(*FIXME: is function isar_atp_h used? If not, delete!*) |
15644 | 86 |
(*********************************************************************) |
15608 | 87 |
(* convert clauses from "assume" to conjecture. write to file "hyps" *) |
15644 | 88 |
(* hypotheses of the goal currently being proved *) |
89 |
(*********************************************************************) |
|
16767 | 90 |
(*perhaps have 2 different versions of this, depending on whether or not SpassComm.spass is set *) |
15608 | 91 |
fun isar_atp_h thms = |
92 |
let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms |
|
15644 | 93 |
val prems' = map repeat_someI_ex prems |
94 |
val prems'' = make_clauses prems' |
|
95 |
val prems''' = ResAxioms.rm_Eps [] prems'' |
|
96 |
val clss = map ResClause.make_conjecture_clause prems''' |
|
15774 | 97 |
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) |
15608 | 98 |
val tfree_lits = ResLib.flat_noDup tfree_litss |
16767 | 99 |
(* tfree clause is different in tptp and dfg versions *) |
15608 | 100 |
val tfree_clss = map ResClause.tfree_clause tfree_lits |
16259 | 101 |
val hypsfile = File.platform_path hyps_file |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
102 |
val out = TextIO.openOut(hypsfile) |
15608 | 103 |
in |
16904 | 104 |
ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
105 |
TextIO.closeOut out; debug hypsfile; |
|
106 |
tfree_lits |
|
15608 | 107 |
end; |
15347 | 108 |
|
15644 | 109 |
|
110 |
(*********************************************************************) |
|
111 |
(* write out a subgoal as tptp clauses to the file "probN" *) |
|
112 |
(* where N is the number of this subgoal *) |
|
113 |
(*********************************************************************) |
|
114 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
115 |
fun tptp_inputs_tfrees thms n tfrees = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
116 |
let |
16904 | 117 |
val _ = debug ("in tptp_inputs_tfrees 0") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
118 |
val clss = map (ResClause.make_conjecture_clause_thm) thms |
16904 | 119 |
val _ = debug ("in tptp_inputs_tfrees 1") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
120 |
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) |
16904 | 121 |
val _ = debug ("in tptp_inputs_tfrees 2") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
122 |
val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) |
16904 | 123 |
val _ = debug ("in tptp_inputs_tfrees 3") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
124 |
val probfile = File.platform_path prob_file ^ "_" ^ string_of_int n |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
125 |
val out = TextIO.openOut(probfile) |
15608 | 126 |
in |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
127 |
ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
128 |
TextIO.closeOut out; |
16904 | 129 |
debug probfile |
15608 | 130 |
end; |
15452 | 131 |
|
15608 | 132 |
|
16767 | 133 |
(*********************************************************************) |
134 |
(* write out a subgoal as DFG clauses to the file "probN" *) |
|
135 |
(* where N is the number of this subgoal *) |
|
136 |
(*********************************************************************) |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
137 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
138 |
fun dfg_inputs_tfrees thms n tfrees axclauses = |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
139 |
let val clss = map (ResClause.make_conjecture_clause_thm) thms |
16767 | 140 |
val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n) |
17231 | 141 |
val _ = debug ("about to write out dfg prob file " ^ probfile) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
142 |
(*val (dfg_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2dfg clss) |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
143 |
val tfree_clss = map ResClause.tfree_dfg_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) *) |
17234 | 144 |
val probN = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) |
17231 | 145 |
axclauses [] [] [] tfrees |
16767 | 146 |
val out = TextIO.openOut(probfile) |
147 |
in |
|
17234 | 148 |
(ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) |
17231 | 149 |
(* (ResLib.writeln_strs out (tfree_clss @ dfg_clss); *) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
150 |
end; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
151 |
|
16357 | 152 |
|
15644 | 153 |
(*********************************************************************) |
154 |
(* call SPASS with settings and problem file for the current subgoal *) |
|
155 |
(* should be modified to allow other provers to be called *) |
|
156 |
(*********************************************************************) |
|
16357 | 157 |
(* now passing in list of skolemized thms and list of sgterms to go with them *) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
158 |
fun call_resolve_tac (thms: thm list list) sign (sg_terms: term list) (childin, childout,pid) n = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
159 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
160 |
val axfile = (File.platform_path axiom_file) |
16520 | 161 |
|
162 |
val hypsfile = (File.platform_path hyps_file) |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
163 |
val clasimpfile = (File.platform_path clasimp_file) |
16520 | 164 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
165 |
fun make_atp_list [] sign n = [] |
16897 | 166 |
| make_atp_list ((sko_thm, sg_term)::xs) sign n = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
167 |
let |
16897 | 168 |
val thmstr = proofstring (Meson.concat_with_and (map string_of_thm sko_thm)) |
16904 | 169 |
val _ = debug ("thmstring in make_atp_lists is " ^ thmstr) |
15608 | 170 |
|
16897 | 171 |
val goalstring = proofstring (Sign.string_of_term sign sg_term) |
16904 | 172 |
val _ = debug ("goalstring in make_atp_lists is " ^ goalstring) |
16357 | 173 |
|
16897 | 174 |
val probfile = File.platform_path prob_file ^ "_" ^ (string_of_int n) |
16904 | 175 |
val _ = debug ("prob file in call_resolve_tac is " ^ probfile) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
176 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
177 |
if !SpassComm.spass |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
178 |
then |
16897 | 179 |
let val optionline = (*Custom SPASS options, or default?*) |
180 |
if !full_spass (*Auto mode: all SPASS inference rules*) |
|
181 |
then "-DocProof%-TimeLimit=60%-SOS" |
|
182 |
else "-" ^ space_implode "%-" (!custom_spass) |
|
16904 | 183 |
val _ = debug ("SPASS option string is " ^ optionline) |
16897 | 184 |
val _ = ResLib.helper_path "SPASS_HOME" "SPASS" |
185 |
(*We've checked that SPASS is there for ATP/spassshell to run.*) |
|
186 |
in |
|
187 |
([("spass", thmstr, goalstring, |
|
188 |
getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell", |
|
189 |
optionline, clasimpfile, axfile, hypsfile, probfile)] @ |
|
190 |
(make_atp_list xs sign (n+1))) |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
191 |
end |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
192 |
else |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
193 |
let val vampire = ResLib.helper_path "VAMPIRE_HOME" "vkernel" |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
194 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
195 |
([("vampire", thmstr, goalstring, vampire, "-t 60%-m 100000", |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
196 |
clasimpfile, axfile, hypsfile, probfile)] @ |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
197 |
(make_atp_list xs sign (n+1))) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
198 |
end |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
199 |
end |
15452 | 200 |
|
16897 | 201 |
val atp_list = make_atp_list (ListPair.zip (thms, sg_terms)) sign 1 |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
202 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
203 |
Watcher.callResProvers(childout,atp_list); |
16904 | 204 |
debug "Sent commands to watcher!"; |
17234 | 205 |
all_tac |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
206 |
end |
16357 | 207 |
|
15644 | 208 |
(**********************************************************) |
209 |
(* write out the current subgoal as a tptp file, probN, *) |
|
17234 | 210 |
(* then call all_tac - should be call_res_tac *) |
15644 | 211 |
(**********************************************************) |
15679
28eb0fe50533
Integrating the reconstruction files into the building of HOL
quigley
parents:
15657
diff
changeset
|
212 |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
213 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
214 |
fun get_sko_thms tfrees sign sg_terms (childin, childout,pid) thm n sko_thms axclauses = |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
215 |
if n=0 then |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
216 |
(call_resolve_tac (rev sko_thms) |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
217 |
sign sg_terms (childin, childout, pid) (List.length sg_terms); |
17234 | 218 |
all_tac thm) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
219 |
else |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
220 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
221 |
( SELECT_GOAL |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
222 |
(EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, |
17231 | 223 |
METAHYPS(fn negs => |
224 |
(if !SpassComm.spass |
|
225 |
then dfg_inputs_tfrees (make_clauses negs) n tfrees axclauses |
|
226 |
else tptp_inputs_tfrees (make_clauses negs) n tfrees; |
|
227 |
get_sko_thms tfrees sign sg_terms (childin, childout, pid) |
|
228 |
thm (n -1) (negs::sko_thms) axclauses; |
|
17234 | 229 |
all_tac))]) n thm ) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
230 |
|
15644 | 231 |
|
232 |
||
233 |
(**********************************************) |
|
234 |
(* recursively call atp_tac_g on all subgoals *) |
|
235 |
(* sg_term is the nth subgoal as a term - used*) |
|
236 |
(* in proof reconstruction *) |
|
237 |
(**********************************************) |
|
238 |
||
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
239 |
fun isar_atp_goal' thm n tfree_lits (childin, childout, pid) axclauses = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
240 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
241 |
val prems = Thm.prems_of thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
242 |
(*val sg_term = get_nth k prems*) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
243 |
val sign = sign_of_thm thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
244 |
val thmstring = string_of_thm thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
245 |
in |
16904 | 246 |
debug("in isar_atp_goal'"); |
247 |
debug("thmstring in isar_atp_goal': " ^ thmstring); |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
248 |
(* go and call callResProvers with this subgoal *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
249 |
(* isar_atp_g tfree_lits sg_term (childin, childout, pid) k thm; *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
250 |
(* recursive call to pick up the remaining subgoals *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
251 |
(* isar_atp_goal' thm (k+1) n tfree_lits (childin, childout, pid) *) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
252 |
get_sko_thms tfree_lits sign prems (childin, childout, pid) thm n [] axclauses |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
253 |
end; |
16520 | 254 |
|
15644 | 255 |
|
256 |
(**************************************************) |
|
257 |
(* convert clauses from "assume" to conjecture. *) |
|
258 |
(* 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
|
259 |
(* any hypotheses in the goal produced by assume *) |
28eb0fe50533
Integrating the reconstruction files into the building of HOL
quigley
parents:
15657
diff
changeset
|
260 |
(* statements; *) |
15644 | 261 |
(* write to file "hyps" *) |
262 |
(**************************************************) |
|
263 |
||
17231 | 264 |
fun isar_atp_aux thms thm n_subgoals (childin, childout, pid) axclauses = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
265 |
let val tfree_lits = isar_atp_h thms |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
266 |
in |
16904 | 267 |
debug ("in isar_atp_aux"); |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
268 |
isar_atp_goal' thm n_subgoals tfree_lits (childin, childout, pid) axclauses |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
269 |
end; |
15644 | 270 |
|
271 |
(******************************************************************) |
|
272 |
(* called in Isar automatically *) |
|
273 |
(* writes out the current clasimpset to a tptp file *) |
|
274 |
(* passes all subgoals on to isar_atp_aux for further processing *) |
|
275 |
(* turns off xsymbol at start of function, restoring it at end *) |
|
276 |
(******************************************************************) |
|
15779
aed221aff642
Removed remaining references to Main.thy in reconstruction code.
quigley
parents:
15774
diff
changeset
|
277 |
(*FIX changed to clasimp_file *) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
278 |
val isar_atp' = setmp print_mode [] (fn (ctxt, thms, thm) => |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
279 |
if Thm.no_prems thm then () |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
280 |
else |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
281 |
let |
16904 | 282 |
val _= debug ("in isar_atp'") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
283 |
val thy = ProofContext.theory_of ctxt |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
284 |
val prems = Thm.prems_of thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
285 |
val thms_string = Meson.concat_with_and (map string_of_thm thms) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
286 |
val thm_string = string_of_thm thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
287 |
val prems_string = Meson.concat_with_and (map (Sign.string_of_term thy) prems) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
288 |
|
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
289 |
(*set up variables for writing out the clasimps to a tptp file*) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
290 |
val (clause_arr, num_of_clauses, axclauses) = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
291 |
ResClasimp.write_out_clasimp (File.platform_path clasimp_file) thy |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
292 |
(hd prems) (*FIXME: hack!! need to do all prems*) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
293 |
val _ = debug ("clasimp_file is " ^ File.platform_path clasimp_file ^ " with " ^ (string_of_int num_of_clauses)^ " clauses") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
294 |
val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr, num_of_clauses) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
295 |
val pid_string = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
296 |
string_of_int (Word.toInt (Word.fromLargeWord (Posix.Process.pidToWord pid))) |
15608 | 297 |
in |
16904 | 298 |
debug ("initial thms: " ^ thms_string); |
299 |
debug ("initial thm: " ^ thm_string); |
|
300 |
debug ("subgoals: " ^ prems_string); |
|
301 |
debug ("pid: "^ pid_string); |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
302 |
isar_atp_aux thms thm (length prems) (childin, childout, pid) axclauses; |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
303 |
() |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
304 |
end); |
15608 | 305 |
|
15452 | 306 |
|
15608 | 307 |
fun get_thms_cs claset = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
308 |
let val {safeEs, safeIs, hazEs, hazIs, ...} = rep_cs claset |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
309 |
in safeEs @ safeIs @ hazEs @ hazIs end; |
16357 | 310 |
|
15608 | 311 |
fun append_name name [] _ = [] |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
312 |
| append_name name (thm :: thms) k = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
313 |
Thm.name_thm ((name ^ "_" ^ string_of_int k), thm) :: append_name name thms (k + 1); |
15608 | 314 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
315 |
fun append_names (name :: names) (thms :: thmss) = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
316 |
append_name name thms 0 :: append_names names thmss; |
16357 | 317 |
|
15608 | 318 |
fun get_thms_ss [] = [] |
319 |
| get_thms_ss thms = |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
320 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
321 |
val names = map Thm.name_of_thm thms |
15608 | 322 |
val thms' = map (mksimps mksimps_pairs) thms |
323 |
val thms'' = append_names names thms' |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
324 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
325 |
ResLib.flat_noDup thms'' |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
326 |
end; |
15608 | 327 |
|
15452 | 328 |
|
15608 | 329 |
(* convert locally declared rules to axiom clauses *) |
330 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
331 |
fun subtract_simpset thy ctxt = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
332 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
333 |
val rules1 = #rules (#1 (rep_ss (simpset_of thy))); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
334 |
val rules2 = #rules (#1 (rep_ss (local_simpset_of ctxt))); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
335 |
in map #thm (Net.subtract MetaSimplifier.eq_rrule rules1 rules2) end; |
15679
28eb0fe50533
Integrating the reconstruction files into the building of HOL
quigley
parents:
15657
diff
changeset
|
336 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
337 |
fun subtract_claset thy ctxt = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
338 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
339 |
val (netI1, netE1) = #xtra_netpair (rep_cs (claset_of thy)); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
340 |
val (netI2, netE2) = #xtra_netpair (rep_cs (local_claset_of ctxt)); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
341 |
val subtract = map (#2 o #2) oo Net.subtract Tactic.eq_kbrl; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
342 |
in subtract netI1 netI2 @ subtract netE1 netE2 end; |
15608 | 343 |
|
344 |
||
16357 | 345 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
346 |
(** the Isar toplevel hook **) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
347 |
|
17091 | 348 |
val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state => |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
349 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
350 |
let |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
351 |
|
17091 | 352 |
val proof = Toplevel.proof_of state |
353 |
val (ctxt, (_, goal)) = Proof.get_goal proof |
|
354 |
handle Proof.STATE _ => error "No goal present"; |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
355 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
356 |
val thy = ProofContext.theory_of ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
357 |
|
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
358 |
(* FIXME presently unused *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
359 |
val ss_thms = subtract_simpset thy ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
360 |
val cs_thms = subtract_claset thy ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
361 |
in |
17091 | 362 |
debug ("initial thm in isar_atp: " ^ |
363 |
Pretty.string_of (ProofContext.pretty_thm ctxt goal)); |
|
364 |
debug ("subgoals in isar_atp: " ^ |
|
365 |
Pretty.string_of (ProofContext.pretty_term ctxt |
|
366 |
(Logic.mk_conjunction_list (Thm.prems_of goal)))); |
|
16904 | 367 |
debug ("number of subgoals in isar_atp: " ^ string_of_int (Thm.nprems_of goal)); |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
368 |
hook_count := !hook_count +1; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
369 |
debug ("in hook for time: " ^(string_of_int (!hook_count)) ); |
16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset
|
370 |
ResClause.init thy; |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
371 |
isar_atp' (ctxt, ProofContext.prems_of ctxt, goal) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
372 |
end); |
16357 | 373 |
|
17091 | 374 |
val call_atpP = |
375 |
OuterSyntax.improper_command |
|
376 |
"ProofGeneral.call_atp" |
|
377 |
"call automatic theorem provers" |
|
378 |
OuterKeyword.diag |
|
379 |
(Scan.succeed (Toplevel.no_timing o invoke_atp)); |
|
380 |
||
381 |
val _ = OuterSyntax.add_parsers [call_atpP]; |
|
382 |
||
15347 | 383 |
end; |