7 signature SLEDGEHAMMER_FILTER_MASH = |
7 signature SLEDGEHAMMER_FILTER_MASH = |
8 sig |
8 sig |
9 type status = ATP_Problem_Generate.status |
9 type status = ATP_Problem_Generate.status |
10 type stature = ATP_Problem_Generate.stature |
10 type stature = ATP_Problem_Generate.stature |
11 type params = Sledgehammer_Provers.params |
11 type params = Sledgehammer_Provers.params |
|
12 type relevance_override = Sledgehammer_Fact.relevance_override |
|
13 type relevance_fudge = Sledgehammer_Provers.relevance_fudge |
12 type prover_result = Sledgehammer_Provers.prover_result |
14 type prover_result = Sledgehammer_Provers.prover_result |
13 |
15 |
14 val fact_name_of : string -> string |
16 val fact_name_of : string -> string |
15 val all_non_tautological_facts_of : |
17 val all_non_tautological_facts_of : |
16 theory -> (((unit -> string) * stature) * thm) list |
18 theory -> (((unit -> string) * stature) * thm) list |
34 val generate_isa_dependencies : theory -> bool -> string -> unit |
36 val generate_isa_dependencies : theory -> bool -> string -> unit |
35 val generate_atp_dependencies : |
37 val generate_atp_dependencies : |
36 Proof.context -> params -> theory -> bool -> string -> unit |
38 Proof.context -> params -> theory -> bool -> string -> unit |
37 |
39 |
38 val reset : unit -> unit |
40 val reset : unit -> unit |
39 val can_suggest : unit -> bool |
41 val can_suggest_facts : unit -> bool |
|
42 (* ### val suggest_facts : ... *) |
40 val can_learn_thy : theory -> bool |
43 val can_learn_thy : theory -> bool |
41 val learn_thy : theory -> real -> unit |
44 val learn_thy : theory -> real -> unit |
42 val learn_proof : theory -> term -> thm list -> unit |
45 val learn_proof : theory -> term -> thm list -> unit |
|
46 |
|
47 val relevant_facts : |
|
48 Proof.context -> params -> string -> int -> relevance_override -> thm list |
|
49 -> term list -> term -> (((unit -> string) * stature) * thm) list |
|
50 -> ((string * stature) * thm) list |
43 end; |
51 end; |
44 |
52 |
45 structure Sledgehammer_Filter_MaSh : SLEDGEHAMMER_FILTER_MASH = |
53 structure Sledgehammer_Filter_MaSh : SLEDGEHAMMER_FILTER_MASH = |
46 struct |
54 struct |
47 |
55 |
245 | freeze (Free (s, T)) = Free (s, freezeT T) |
253 | freeze (Free (s, T)) = Free (s, freezeT T) |
246 | freeze t = t |
254 | freeze t = t |
247 |
255 |
248 fun goal_of_thm thy = prop_of #> freeze #> cterm_of thy #> Goal.init |
256 fun goal_of_thm thy = prop_of #> freeze #> cterm_of thy #> Goal.init |
249 |
257 |
250 fun iter_facts ctxt ({provers, relevance_thresholds, ...} : params) max_relevant |
258 fun iter_facts ctxt (params as {provers, ...}) max_relevant goal = |
251 goal = |
259 let val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal 1 in |
252 let |
260 iterative_relevant_facts ctxt params (hd provers) max_relevant NONE |
253 val prover_name = hd provers |
261 no_relevance_override [] hyp_ts concl_t |
254 val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal 1 |
|
255 val is_built_in_const = |
|
256 Sledgehammer_Provers.is_built_in_const_for_prover ctxt prover_name |
|
257 val relevance_fudge = |
|
258 Sledgehammer_Provers.relevance_fudge_for_prover ctxt prover_name |
|
259 val relevance_override = {add = [], del = [], only = false} |
|
260 in |
|
261 iterative_relevant_facts ctxt relevance_thresholds max_relevant |
|
262 is_built_in_const relevance_fudge |
|
263 relevance_override [] hyp_ts concl_t |
|
264 end |
262 end |
265 |
263 |
266 fun run_prover ctxt (params as {provers, ...}) facts goal = |
264 fun run_prover ctxt (params as {provers, ...}) facts goal = |
267 let |
265 let |
268 val problem = |
266 val problem = |
375 (*** High-level communication with MaSh ***) |
373 (*** High-level communication with MaSh ***) |
376 |
374 |
377 fun reset () = |
375 fun reset () = |
378 () |
376 () |
379 |
377 |
380 fun can_suggest () = |
378 fun can_suggest_facts () = |
381 true |
379 true |
382 |
380 |
383 fun can_learn_thy thy = |
381 fun can_learn_thy thy = |
384 true |
382 true |
385 |
383 |
386 fun learn_thy thy timeout = |
384 fun learn_thy thy timeout = |
387 () |
385 () |
388 |
386 |
389 fun learn_proof theory t thms = |
387 fun learn_proof thy t thms = |
390 () |
388 () |
391 |
389 |
|
390 fun relevant_facts ctxt params prover max_relevant |
|
391 (override as {add, only, ...}) chained_ths hyp_ts concl_t |
|
392 facts = |
|
393 if only then |
|
394 facts |> map (apfst (apfst (fn f => f ()))) (* ###*) |
|
395 else if max_relevant <= 0 then |
|
396 [] |
|
397 else |
|
398 let |
|
399 val add_ths = Attrib.eval_thms ctxt add |
|
400 fun prepend_facts ths facts = |
|
401 ((facts |> filter (member Thm.eq_thm_prop ths o snd)) @ |
|
402 (facts |> filter_out (member Thm.eq_thm_prop ths o snd))) |
|
403 |> take max_relevant |
|
404 in |
|
405 iterative_relevant_facts ctxt params prover max_relevant NONE override |
|
406 chained_ths hyp_ts concl_t facts |
|
407 |> not (null add_ths) ? prepend_facts add_ths |
|
408 end |
|
409 |
392 end; |
410 end; |