81 ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
77 ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
82 TextIO.closeOut out; |
78 TextIO.closeOut out; |
83 debug probfile |
79 debug probfile |
84 end; |
80 end; |
85 |
81 |
86 |
82 (* write out a subgoal in DFG format to the file "xxxx_N"*) |
87 (*********************************************************************) |
|
88 (* write out a subgoal as DFG clauses to the file "probN" *) |
|
89 (* where N is the number of this subgoal *) |
|
90 (*********************************************************************) |
|
91 |
|
92 fun dfg_inputs_tfrees thms n axclauses = |
83 fun dfg_inputs_tfrees thms n axclauses = |
93 let val clss = map (ResClause.make_conjecture_clause_thm) thms |
84 let val clss = map (ResClause.make_conjecture_clause_thm) thms |
94 val probfile = prob_pathname() ^ "_" ^ (string_of_int n) |
85 val probfile = prob_pathname() ^ "_" ^ (string_of_int n) |
95 val _ = debug ("about to write out dfg prob file " ^ probfile) |
86 val _ = debug ("about to write out dfg prob file " ^ probfile) |
96 val probN = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) |
87 val probN = ResClause.clauses2dfg clss (!problem_name ^ "_" ^ string_of_int n) |
97 axclauses [] [] [] |
88 axclauses [] [] [] |
98 val out = TextIO.openOut(probfile) |
89 val out = TextIO.openOut(probfile) |
99 in |
90 in |
100 (ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) |
91 (ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) |
101 (* (ResLib.writeln_strs out (tfree_clss @ dfg_clss); *) |
|
102 end; |
92 end; |
103 |
93 |
104 |
94 |
105 (*********************************************************************) |
95 (*********************************************************************) |
106 (* call prover with settings and problem file for the current subgoal *) |
96 (* call prover with settings and problem file for the current subgoal *) |
173 else tptp_inputs_tfrees (make_clauses negs) n axclauses; |
163 else tptp_inputs_tfrees (make_clauses negs) n axclauses; |
174 write_problem_files axclauses thm (n-1); |
164 write_problem_files axclauses thm (n-1); |
175 all_tac))]) n thm; |
165 all_tac))]) n thm; |
176 ()); |
166 ()); |
177 |
167 |
178 |
168 val last_watcher_pid = ref (NONE : Posix.Process.pid option); |
179 (*FIXME: WHAT IS THMS FOR????*) |
|
180 |
169 |
181 (******************************************************************) |
170 (******************************************************************) |
182 (* called in Isar automatically *) |
171 (* called in Isar automatically *) |
183 (* writes out the current clasimpset to a tptp file *) |
172 (* writes out the current clasimpset to a tptp file *) |
184 (* turns off xsymbol at start of function, restoring it at end *) |
173 (* turns off xsymbol at start of function, restoring it at end *) |
185 (******************************************************************) |
174 (******************************************************************) |
186 (*FIX changed to clasimp_file *) |
175 (*FIX changed to clasimp_file *) |
187 val isar_atp = setmp print_mode [] |
176 val isar_atp = setmp print_mode [] |
188 (fn (ctxt, thms, thm) => |
177 (fn (ctxt, thm) => |
189 if Thm.no_prems thm then () |
178 if Thm.no_prems thm then () |
190 else |
179 else |
191 let |
180 let |
192 val _= debug ("in isar_atp") |
181 val _= debug ("in isar_atp") |
193 val thy = ProofContext.theory_of ctxt |
182 val thy = ProofContext.theory_of ctxt |
194 val prems = Thm.prems_of thm |
183 val prems = Thm.prems_of thm |
195 val thms_string = Meson.concat_with_and (map string_of_thm thms) |
|
196 val prems_string = Meson.concat_with_and (map (Sign.string_of_term thy) prems) |
184 val prems_string = Meson.concat_with_and (map (Sign.string_of_term thy) prems) |
197 |
185 |
|
186 val _ = (case !last_watcher_pid of NONE => () |
|
187 | SOME pid => (*FIXME: should kill ATP processes too; at least they time out*) |
|
188 (debug ("Killing old watcher, pid = " ^ |
|
189 Int.toString (ResLib.intOfPid pid)); |
|
190 Watcher.killWatcher pid)) |
|
191 handle OS.SysErr _ => debug "Attempt to kill watcher failed"; |
198 (*set up variables for writing out the clasimps to a tptp file*) |
192 (*set up variables for writing out the clasimps to a tptp file*) |
199 val (clause_arr, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) |
193 val (clause_arr, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) |
200 (*FIXME: hack!! need to consider relevance for all prems*) |
194 (*FIXME: hack!! need to consider relevance for all prems*) |
201 val _ = debug ("claset and simprules total clauses = " ^ |
195 val _ = debug ("claset and simprules total clauses = " ^ |
202 string_of_int (Array.length clause_arr)) |
196 string_of_int (Array.length clause_arr)) |
203 val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr) |
197 val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr) |
204 in |
198 in |
205 debug ("initial thms: " ^ thms_string); |
199 last_watcher_pid := SOME pid; |
206 debug ("subgoals: " ^ prems_string); |
200 debug ("subgoals: " ^ prems_string); |
207 debug ("pid: " ^ Int.toString (ResLib.intOfPid pid)); |
201 debug ("pid: " ^ Int.toString (ResLib.intOfPid pid)); |
208 write_problem_files axclauses thm (length prems); |
202 write_problem_files axclauses thm (length prems); |
209 watcher_call_provers (sign_of_thm thm) (Thm.prems_of thm) (childin, childout, pid) |
203 watcher_call_provers (sign_of_thm thm) (Thm.prems_of thm) (childin, childout, pid) |
210 end); |
204 end); |
211 |
205 |
212 val isar_atp_writeonly = setmp print_mode [] |
206 val isar_atp_writeonly = setmp print_mode [] |
213 (fn (ctxt, thms: thm list, thm) => |
207 (fn (ctxt, thm) => |
214 if Thm.no_prems thm then () |
208 if Thm.no_prems thm then () |
215 else |
209 else |
216 let val prems = Thm.prems_of thm |
210 let val prems = Thm.prems_of thm |
217 val (_, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) |
211 val (_, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) |
218 in |
212 in |
219 write_problem_files axclauses thm (length prems) |
213 write_problem_files axclauses thm (length prems) |
220 end); |
214 end); |
221 |
|
222 |
|
223 (* convert locally declared rules to axiom clauses: UNUSED *) |
|
224 |
|
225 fun subtract_simpset thy ctxt = |
|
226 let |
|
227 val rules1 = #rules (#1 (rep_ss (simpset_of thy))); |
|
228 val rules2 = #rules (#1 (rep_ss (local_simpset_of ctxt))); |
|
229 in map #thm (Net.subtract MetaSimplifier.eq_rrule rules1 rules2) end; |
|
230 |
|
231 fun subtract_claset thy ctxt = |
|
232 let |
|
233 val (netI1, netE1) = #xtra_netpair (rep_cs (claset_of thy)); |
|
234 val (netI2, netE2) = #xtra_netpair (rep_cs (local_claset_of ctxt)); |
|
235 val subtract = map (#2 o #2) oo Net.subtract Tactic.eq_kbrl; |
|
236 in subtract netI1 netI2 @ subtract netE1 netE2 end; |
|
237 |
|
238 |
215 |
239 |
216 |
240 (** the Isar toplevel hook **) |
217 (** the Isar toplevel hook **) |
241 |
218 |
242 val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state => |
219 val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state => |