69 val smt_slice_time_frac : real Config.T |
69 val smt_slice_time_frac : real Config.T |
70 val smt_slice_min_secs : int Config.T |
70 val smt_slice_min_secs : int Config.T |
71 val das_Tool : string |
71 val das_Tool : string |
72 val select_smt_solver : string -> Proof.context -> Proof.context |
72 val select_smt_solver : string -> Proof.context -> Proof.context |
73 val is_smt_prover : Proof.context -> string -> bool |
73 val is_smt_prover : Proof.context -> string -> bool |
|
74 val is_unit_equational_atp : Proof.context -> string -> bool |
74 val is_prover_supported : Proof.context -> string -> bool |
75 val is_prover_supported : Proof.context -> string -> bool |
75 val is_prover_installed : Proof.context -> string -> bool |
76 val is_prover_installed : Proof.context -> string -> bool |
76 val default_max_relevant_for_prover : Proof.context -> bool -> string -> int |
77 val default_max_relevant_for_prover : Proof.context -> bool -> string -> int |
|
78 val is_unit_equality : term -> bool |
|
79 val is_good_prop_for_prover : Proof.context -> string -> term -> bool |
77 val is_built_in_const_for_prover : |
80 val is_built_in_const_for_prover : |
78 Proof.context -> string -> string * typ -> term list -> bool * term list |
81 Proof.context -> string -> string * typ -> term list -> bool * term list |
79 val atp_relevance_fudge : relevance_fudge |
82 val atp_relevance_fudge : relevance_fudge |
80 val smt_relevance_fudge : relevance_fudge |
83 val smt_relevance_fudge : relevance_fudge |
81 val relevance_fudge_for_prover : Proof.context -> string -> relevance_fudge |
84 val relevance_fudge_for_prover : Proof.context -> string -> relevance_fudge |
118 Context.proof_map o SMT_Config.select_solver |
121 Context.proof_map o SMT_Config.select_solver |
119 |
122 |
120 fun is_smt_prover ctxt name = |
123 fun is_smt_prover ctxt name = |
121 member (op =) (SMT_Solver.available_solvers_of ctxt) name |
124 member (op =) (SMT_Solver.available_solvers_of ctxt) name |
122 |
125 |
|
126 fun is_unit_equational_atp ctxt name = |
|
127 let val thy = Proof_Context.theory_of ctxt in |
|
128 case try (get_atp thy) name of |
|
129 SOME {formats, ...} => member (op =) formats CNF_UEQ |
|
130 | NONE => false |
|
131 end |
|
132 |
123 fun is_prover_supported ctxt name = |
133 fun is_prover_supported ctxt name = |
124 let val thy = Proof_Context.theory_of ctxt in |
134 let val thy = Proof_Context.theory_of ctxt in |
125 is_smt_prover ctxt name orelse member (op =) (supported_atps thy) name |
135 is_smt_prover ctxt name orelse member (op =) (supported_atps thy) name |
126 end |
136 end |
127 |
137 |
144 handled specially via "fFalse", "fTrue", ..., "fequal". *) |
154 handled specially via "fFalse", "fTrue", ..., "fequal". *) |
145 val atp_irrelevant_consts = |
155 val atp_irrelevant_consts = |
146 [@{const_name False}, @{const_name True}, @{const_name Not}, |
156 [@{const_name False}, @{const_name True}, @{const_name Not}, |
147 @{const_name conj}, @{const_name disj}, @{const_name implies}, |
157 @{const_name conj}, @{const_name disj}, @{const_name implies}, |
148 @{const_name HOL.eq}, @{const_name If}, @{const_name Let}] |
158 @{const_name HOL.eq}, @{const_name If}, @{const_name Let}] |
|
159 |
|
160 fun is_unit_equality (@{const Trueprop} $ t) = is_unit_equality t |
|
161 | is_unit_equality (Const (@{const_name all}, _) $ Abs (_, _, t)) = |
|
162 is_unit_equality t |
|
163 | is_unit_equality (Const (@{const_name All}, _) $ Abs (_, _, t)) = |
|
164 is_unit_equality t |
|
165 | is_unit_equality (Const (@{const_name "=="}, Type (_, [T, _])) $ _ $ _) = |
|
166 T <> @{typ bool} |
|
167 | is_unit_equality (Const (@{const_name HOL.eq}, Type (_ , [T, _])) $ _ $ _) = |
|
168 T <> @{typ bool} |
|
169 | is_unit_equality _ = false |
|
170 |
|
171 fun is_good_prop_for_prover ctxt name = |
|
172 if is_unit_equational_atp ctxt name then is_unit_equality else K true |
149 |
173 |
150 fun is_built_in_const_for_prover ctxt name = |
174 fun is_built_in_const_for_prover ctxt name = |
151 if is_smt_prover ctxt name then |
175 if is_smt_prover ctxt name then |
152 let val ctxt = ctxt |> select_smt_solver name in |
176 let val ctxt = ctxt |> select_smt_solver name in |
153 fn x => fn ts => |
177 fn x => fn ts => |
388 for higher-order problems. *) |
412 for higher-order problems. *) |
389 |
413 |
390 (* Facts containing variables of type "unit" or "bool" or of the form |
414 (* Facts containing variables of type "unit" or "bool" or of the form |
391 "ALL x. x = A | x = B | x = C" are likely to lead to unsound proofs if types |
415 "ALL x. x = A | x = B | x = C" are likely to lead to unsound proofs if types |
392 are omitted. *) |
416 are omitted. *) |
393 fun is_dangerous_term ctxt = |
417 fun is_dangerous_prop ctxt = |
394 transform_elim_term |
418 transform_elim_prop |
395 #> (has_bound_or_var_of_type (is_type_surely_finite ctxt) orf |
419 #> (has_bound_or_var_of_type (is_type_surely_finite ctxt) orf |
396 is_exhaustive_finite) |
420 is_exhaustive_finite) |
397 |
421 |
398 fun int_opt_add (SOME m) (SOME n) = SOME (m + n) |
422 fun int_opt_add (SOME m) (SOME n) = SOME (m + n) |
399 | int_opt_add _ _ = NONE |
423 | int_opt_add _ _ = NONE |
411 else (FOF, Preds (Mangled_Monomorphic, level, Heavy)) |
435 else (FOF, Preds (Mangled_Monomorphic, level, Heavy)) |
412 | adjust_dumb_type_sys formats type_sys = |
436 | adjust_dumb_type_sys formats type_sys = |
413 (* We could return (TFF, type_sys) in all cases but this would require the |
437 (* We could return (TFF, type_sys) in all cases but this would require the |
414 TFF provers to accept problems in which constants are implicitly |
438 TFF provers to accept problems in which constants are implicitly |
415 declared. Today neither SNARK nor ToFoF-E satisfy this criterion. *) |
439 declared. Today neither SNARK nor ToFoF-E satisfy this criterion. *) |
416 if member (op =) formats FOF then |
440 if member (op =) formats CNF_UEQ then |
417 (FOF, type_sys) |
|
418 else if member (op =) formats CNF_UEQ then |
|
419 (CNF_UEQ, case type_sys of |
441 (CNF_UEQ, case type_sys of |
420 Tags _ => type_sys |
442 Tags _ => type_sys |
421 | _ => Preds (polymorphism_of_type_sys type_sys, |
443 | _ => Preds (polymorphism_of_type_sys type_sys, |
422 Const_Arg_Types, Light)) |
444 Const_Arg_Types, Light)) |
|
445 else if member (op =) formats FOF then |
|
446 (FOF, type_sys) |
423 else |
447 else |
424 (TFF, Simple_Types All_Types) |
448 (TFF, Simple_Types All_Types) |
425 fun determine_format_and_type_sys _ formats (Dumb_Type_Sys type_sys) = |
449 fun determine_format_and_type_sys _ formats (Dumb_Type_Sys type_sys) = |
426 adjust_dumb_type_sys formats type_sys |
450 adjust_dumb_type_sys formats type_sys |
427 | determine_format_and_type_sys best_type_systems formats |
451 | determine_format_and_type_sys best_type_systems formats |
512 val (format, type_sys) = |
536 val (format, type_sys) = |
513 determine_format_and_type_sys best_type_systems formats type_sys |
537 determine_format_and_type_sys best_type_systems formats type_sys |
514 val fairly_sound = is_type_sys_fairly_sound type_sys |
538 val fairly_sound = is_type_sys_fairly_sound type_sys |
515 val facts = |
539 val facts = |
516 facts |> not fairly_sound |
540 facts |> not fairly_sound |
517 ? filter_out (is_dangerous_term ctxt o prop_of o snd |
541 ? filter_out (is_dangerous_prop ctxt o prop_of o snd |
518 o untranslated_fact) |
542 o untranslated_fact) |
519 |> take num_facts |
543 |> take num_facts |
520 |> not (null blacklist) |
544 |> not (null blacklist) |
521 ? filter_out (member (op =) blacklist o fst |
545 ? filter_out (member (op =) blacklist o fst |
522 o untranslated_fact) |
546 o untranslated_fact) |