src/HOL/Tools/Sledgehammer/sledgehammer_fact.ML
changeset 53511 3ea6b9461c55
parent 53510 c0982ad1281d
child 53512 b9bc867e49f6
equal deleted inserted replaced
53510:c0982ad1281d 53511:3ea6b9461c55
    16   type fact_override =
    16   type fact_override =
    17     {add : (Facts.ref * Attrib.src list) list,
    17     {add : (Facts.ref * Attrib.src list) list,
    18      del : (Facts.ref * Attrib.src list) list,
    18      del : (Facts.ref * Attrib.src list) list,
    19      only : bool}
    19      only : bool}
    20 
    20 
    21   val ignore_no_atp : bool Config.T
       
    22   val instantiate_inducts : bool Config.T
    21   val instantiate_inducts : bool Config.T
    23   val no_fact_override : fact_override
    22   val no_fact_override : fact_override
    24   val fact_of_ref :
    23   val fact_of_ref :
    25     Proof.context -> unit Symtab.table -> thm list -> status Termtab.table
    24     Proof.context -> unit Symtab.table -> thm list -> status Termtab.table
    26     -> Facts.ref * Attrib.src list -> ((string * stature) * thm) list
    25     -> Facts.ref * Attrib.src list -> ((string * stature) * thm) list
    31     (thm -> string) -> ('a * thm) list
    30     (thm -> string) -> ('a * thm) list
    32     -> string Symtab.table * string Symtab.table
    31     -> string Symtab.table * string Symtab.table
    33   val maybe_instantiate_inducts :
    32   val maybe_instantiate_inducts :
    34     Proof.context -> term list -> term -> (((unit -> string) * 'a) * thm) list
    33     Proof.context -> term list -> term -> (((unit -> string) * 'a) * thm) list
    35     -> (((unit -> string) * 'a) * thm) list
    34     -> (((unit -> string) * 'a) * thm) list
    36   val maybe_filter_no_atps : Proof.context -> ('a * thm) list -> ('a * thm) list
       
    37   val fact_of_raw_fact : raw_fact -> fact
    35   val fact_of_raw_fact : raw_fact -> fact
    38   val all_facts :
    36   val all_facts :
    39     Proof.context -> bool -> bool -> unit Symtab.table -> thm list -> thm list
    37     Proof.context -> bool -> bool -> unit Symtab.table -> thm list -> thm list
    40     -> status Termtab.table -> raw_fact list
    38     -> status Termtab.table -> raw_fact list
    41   val nearly_all_facts :
    39   val nearly_all_facts :
    57 type fact_override =
    55 type fact_override =
    58   {add : (Facts.ref * Attrib.src list) list,
    56   {add : (Facts.ref * Attrib.src list) list,
    59    del : (Facts.ref * Attrib.src list) list,
    57    del : (Facts.ref * Attrib.src list) list,
    60    only : bool}
    58    only : bool}
    61 
    59 
    62 (* experimental features *)
    60 (* experimental feature *)
    63 val ignore_no_atp =
       
    64   Attrib.setup_config_bool @{binding sledgehammer_ignore_no_atp} (K false)
       
    65 val instantiate_inducts =
    61 val instantiate_inducts =
    66   Attrib.setup_config_bool @{binding sledgehammer_instantiate_inducts} (K false)
    62   Attrib.setup_config_bool @{binding sledgehammer_instantiate_inducts} (K false)
    67 
    63 
    68 val no_fact_override = {add = [], del = [], only = false}
    64 val no_fact_override = {add = [], del = [], only = false}
    69 
    65 
   243     exists_Const (is_technical_const orf is_low_level_class_const) t orelse
   239     exists_Const (is_technical_const orf is_low_level_class_const) t orelse
   244     is_that_fact th
   240     is_that_fact th
   245   end
   241   end
   246 
   242 
   247 fun is_blacklisted_or_something ctxt ho_atp name =
   243 fun is_blacklisted_or_something ctxt ho_atp name =
   248   (not (Config.get ctxt ignore_no_atp) andalso is_package_def name) orelse
   244   is_package_def name orelse
   249   exists (fn s => String.isSuffix s name) (multi_base_blacklist ctxt ho_atp)
   245   exists (fn s => String.isSuffix s name) (multi_base_blacklist ctxt ho_atp)
   250 
   246 
   251 fun hackish_string_of_term ctxt =
   247 fun hackish_string_of_term ctxt =
   252   with_vanilla_print_mode (Syntax.string_of_term ctxt) #> simplify_spaces
   248   with_vanilla_print_mode (Syntax.string_of_term ctxt) #> simplify_spaces
   253 
   249 
   420         |> Logic.list_implies |> Object_Logic.atomize_term thy
   416         |> Logic.list_implies |> Object_Logic.atomize_term thy
   421       val ind_stmt_xs = external_frees ind_stmt
   417       val ind_stmt_xs = external_frees ind_stmt
   422     in maps (instantiate_if_induct_rule ctxt ind_stmt ind_stmt_xs) end
   418     in maps (instantiate_if_induct_rule ctxt ind_stmt ind_stmt_xs) end
   423   else
   419   else
   424     I
   420     I
   425 
       
   426 fun maybe_filter_no_atps ctxt =
       
   427   not (Config.get ctxt ignore_no_atp) ? filter_out (No_ATPs.member ctxt o snd)
       
   428 
   421 
   429 fun fact_of_raw_fact ((name, stature), th) = ((name (), stature), th)
   422 fun fact_of_raw_fact ((name, stature), th) = ((name (), stature), th)
   430 
   423 
   431 fun all_facts ctxt generous ho_atp reserved add_ths chained css =
   424 fun all_facts ctxt generous ho_atp reserved add_ths chained css =
   432   let
   425   let
   509          maps (map (fn ((name, stature), th) => ((K name, stature), th))
   502          maps (map (fn ((name, stature), th) => ((K name, stature), th))
   510                o fact_of_ref ctxt reserved chained css) add
   503                o fact_of_ref ctxt reserved chained css) add
   511        else
   504        else
   512          let val (add, del) = pairself (Attrib.eval_thms ctxt) (add, del) in
   505          let val (add, del) = pairself (Attrib.eval_thms ctxt) (add, del) in
   513            all_facts ctxt false ho_atp reserved add chained css
   506            all_facts ctxt false ho_atp reserved add chained css
   514            |> filter_out (member Thm.eq_thm_prop del o snd)
   507            |> filter_out
   515            |> maybe_filter_no_atps ctxt
   508                   ((member Thm.eq_thm_prop del orf No_ATPs.member ctxt) o snd)
   516            |> hashed_keyed_distinct (size_of_term o prop_of o snd)
   509            |> hashed_keyed_distinct (size_of_term o prop_of o snd)
   517                   (normalize_eq_vars o prop_of o snd)
   510                   (normalize_eq_vars o prop_of o snd)
   518          end)
   511          end)
   519       |> maybe_instantiate_inducts ctxt hyp_ts concl_t
   512       |> maybe_instantiate_inducts ctxt hyp_ts concl_t
   520     end
   513     end