equal
deleted
inserted
replaced
51 open Sledgehammer_Util |
51 open Sledgehammer_Util |
52 |
52 |
53 val trace = Unsynchronized.ref false |
53 val trace = Unsynchronized.ref false |
54 fun trace_msg msg = if !trace then tracing (msg ()) else () |
54 fun trace_msg msg = if !trace then tracing (msg ()) else () |
55 |
55 |
56 (* experimental feature *) |
56 (* experimental features *) |
57 val respect_no_atp = true |
57 val respect_no_atp = true |
|
58 val instantiate_inducts = false |
58 |
59 |
59 datatype locality = General | Intro | Elim | Simp | Local | Assum | Chained |
60 datatype locality = General | Intro | Elim | Simp | Local | Assum | Chained |
60 |
61 |
61 type relevance_fudge = |
62 type relevance_fudge = |
62 {allow_ext : bool, |
63 {allow_ext : bool, |
253 (* Add a pconstant to the table, but a [] entry means a standard |
254 (* Add a pconstant to the table, but a [] entry means a standard |
254 connective, which we ignore.*) |
255 connective, which we ignore.*) |
255 fun add_pconst_to_table also_skolem (s, p) = |
256 fun add_pconst_to_table also_skolem (s, p) = |
256 if (not also_skolem andalso String.isPrefix skolem_prefix s) then I |
257 if (not also_skolem andalso String.isPrefix skolem_prefix s) then I |
257 else Symtab.map_default (s, [p]) (insert (op =) p) |
258 else Symtab.map_default (s, [p]) (insert (op =) p) |
258 |
|
259 fun is_formula_type T = (T = HOLogic.boolT orelse T = propT) |
|
260 |
259 |
261 fun pconsts_in_terms thy is_built_in_const also_skolems pos ts = |
260 fun pconsts_in_terms thy is_built_in_const also_skolems pos ts = |
262 let |
261 let |
263 val flip = Option.map not |
262 val flip = Option.map not |
264 (* We include free variables, as well as constants, to handle locales. For |
263 (* We include free variables, as well as constants, to handle locales. For |
284 add_pconst_to_table true |
283 add_pconst_to_table true |
285 (gensym skolem_prefix, PType (order_of_type abs_T, [])) |
284 (gensym skolem_prefix, PType (order_of_type abs_T, [])) |
286 else |
285 else |
287 I) |
286 I) |
288 and do_term_or_formula T = |
287 and do_term_or_formula T = |
289 if is_formula_type T then do_formula NONE else do_term |
288 if T = HOLogic.boolT then do_formula NONE else do_term |
290 and do_formula pos t = |
289 and do_formula pos t = |
291 case t of |
290 case t of |
292 Const (@{const_name all}, _) $ Abs (_, T, t') => |
291 Const (@{const_name all}, _) $ Abs (_, T, t') => |
293 do_quantifier (pos = SOME false) T t' |
292 do_quantifier (pos = SOME false) T t' |
294 | @{const "==>"} $ t1 $ t2 => |
293 | @{const "==>"} $ t1 $ t2 => |
634 (* FIXME: put other record thms here, or declare as "no_atp" *) |
633 (* FIXME: put other record thms here, or declare as "no_atp" *) |
635 val multi_base_blacklist = |
634 val multi_base_blacklist = |
636 ["defs", "select_defs", "update_defs", "split", "splits", "split_asm", |
635 ["defs", "select_defs", "update_defs", "split", "splits", "split_asm", |
637 "cases", "ext_cases", "eq.simps", "eq.refl", "nchotomy", "case_cong", |
636 "cases", "ext_cases", "eq.simps", "eq.refl", "nchotomy", "case_cong", |
638 "weak_case_cong"] |
637 "weak_case_cong"] |
|
638 |> not instantiate_inducts ? append ["induct", "inducts"] |
639 |> map (prefix ".") |
639 |> map (prefix ".") |
640 |
640 |
641 val max_lambda_nesting = 3 |
641 val max_lambda_nesting = 3 |
642 |
642 |
643 fun term_has_too_many_lambdas max (t1 $ t2) = |
643 fun term_has_too_many_lambdas max (t1 $ t2) = |
649 (* Don't count nested lambdas at the level of formulas, since they are |
649 (* Don't count nested lambdas at the level of formulas, since they are |
650 quantifiers. *) |
650 quantifiers. *) |
651 fun formula_has_too_many_lambdas Ts (Abs (_, T, t)) = |
651 fun formula_has_too_many_lambdas Ts (Abs (_, T, t)) = |
652 formula_has_too_many_lambdas (T :: Ts) t |
652 formula_has_too_many_lambdas (T :: Ts) t |
653 | formula_has_too_many_lambdas Ts t = |
653 | formula_has_too_many_lambdas Ts t = |
654 if is_formula_type (fastype_of1 (Ts, t)) then |
654 if member (op =) [HOLogic.boolT, propT] (fastype_of1 (Ts, t)) then |
655 exists (formula_has_too_many_lambdas Ts) (#2 (strip_comb t)) |
655 exists (formula_has_too_many_lambdas Ts) (#2 (strip_comb t)) |
656 else |
656 else |
657 term_has_too_many_lambdas max_lambda_nesting t |
657 term_has_too_many_lambdas max_lambda_nesting t |
658 |
658 |
659 (* The max apply depth of any "metis" call in "Metis_Examples" (on 2007-10-31) |
659 (* The max apply depth of any "metis" call in "Metis_Examples" (on 2007-10-31) |
875 (if only then |
875 (if only then |
876 maps (map (fn ((name, loc), th) => ((K name, loc), (true, th))) |
876 maps (map (fn ((name, loc), th) => ((K name, loc), (true, th))) |
877 o fact_from_ref ctxt reserved chained_ths) add |
877 o fact_from_ref ctxt reserved chained_ths) add |
878 else |
878 else |
879 all_facts ctxt reserved no_dangerous_types fudge add_ths chained_ths) |
879 all_facts ctxt reserved no_dangerous_types fudge add_ths chained_ths) |
880 |> maps (instantiate_if_induct_rule ctxt ind_stmt ind_stmt_xs) |
880 |> instantiate_inducts |
|
881 ? maps (instantiate_if_induct_rule ctxt ind_stmt ind_stmt_xs) |
881 |> rearrange_facts ctxt (respect_no_atp andalso not only) |
882 |> rearrange_facts ctxt (respect_no_atp andalso not only) |
882 |> uniquify |
883 |> uniquify |
883 in |
884 in |
884 trace_msg (fn () => "Considering " ^ Int.toString (length facts) ^ |
885 trace_msg (fn () => "Considering " ^ Int.toString (length facts) ^ |
885 " facts"); |
886 " facts"); |