src/HOL/Tools/Sledgehammer/sledgehammer_filter_mash.ML
changeset 48289 6b65f1ad0e4b
parent 48288 255c6e1fd505
child 48292 7fcee834c7f5
equal deleted inserted replaced
48288:255c6e1fd505 48289:6b65f1ad0e4b
    25   val isabelle_dependencies_of : string list -> thm -> string list
    25   val isabelle_dependencies_of : string list -> thm -> string list
    26   val goal_of_thm : theory -> thm -> thm
    26   val goal_of_thm : theory -> thm -> thm
    27   val iter_facts :
    27   val iter_facts :
    28     Proof.context -> params -> int -> thm
    28     Proof.context -> params -> int -> thm
    29     -> (((unit -> string) * stature) * thm) list
    29     -> (((unit -> string) * stature) * thm) list
    30     -> ((string * stature) * thm) list
    30     -> (((unit -> string) * stature) * thm) list
    31   val run_prover :
    31   val run_prover :
    32     Proof.context -> params -> ((string * stature) * thm) list -> thm
    32     Proof.context -> params -> (((unit -> string) * stature) * thm) list -> thm
    33     -> prover_result
    33     -> prover_result
    34   val generate_accessibility : theory -> bool -> string -> unit
    34   val generate_accessibility : theory -> bool -> string -> unit
    35   val generate_features : theory -> bool -> string -> unit
    35   val generate_features : theory -> bool -> string -> unit
    36   val generate_isa_dependencies : theory -> bool -> string -> unit
    36   val generate_isa_dependencies : theory -> bool -> string -> unit
    37   val generate_atp_dependencies :
    37   val generate_atp_dependencies :
    45   val learn_proof : theory -> term -> thm list -> unit
    45   val learn_proof : theory -> term -> thm list -> unit
    46 
    46 
    47   val relevant_facts :
    47   val relevant_facts :
    48     Proof.context -> params -> string -> int -> relevance_override -> thm list
    48     Proof.context -> params -> string -> int -> relevance_override -> thm list
    49     -> term list -> term -> (((unit -> string) * stature) * thm) list
    49     -> term list -> term -> (((unit -> string) * stature) * thm) list
    50     -> ((string * stature) * thm) list
    50     -> (((unit -> string) * stature) * thm) list
    51 end;
    51 end;
    52 
    52 
    53 structure Sledgehammer_Filter_MaSh : SLEDGEHAMMER_FILTER_MASH =
    53 structure Sledgehammer_Filter_MaSh : SLEDGEHAMMER_FILTER_MASH =
    54 struct
    54 struct
    55 
    55 
   263 
   263 
   264 fun run_prover ctxt (params as {provers, ...}) facts goal =
   264 fun run_prover ctxt (params as {provers, ...}) facts goal =
   265   let
   265   let
   266     val problem =
   266     val problem =
   267       {state = Proof.init ctxt, goal = goal, subgoal = 1, subgoal_count = 1,
   267       {state = Proof.init ctxt, goal = goal, subgoal = 1, subgoal_count = 1,
   268        facts = facts |> map Sledgehammer_Provers.Untranslated_Fact}
   268        facts = facts |> map (apfst (apfst (fn name => name ())))
       
   269                      |> map Sledgehammer_Provers.Untranslated_Fact}
   269     val prover =
   270     val prover =
   270       Sledgehammer_Minimize.get_minimizing_prover ctxt
   271       Sledgehammer_Minimize.get_minimizing_prover ctxt
   271           Sledgehammer_Provers.Normal (hd provers)
   272           Sledgehammer_Provers.Normal (hd provers)
   272   in prover params (K (K (K ""))) problem end
   273   in prover params (K (K (K ""))) problem end
   273 
   274 
   337     fun is_dep dep (_, th) = fact_name_of (Thm.get_name_hint th) = dep
   338     fun is_dep dep (_, th) = fact_name_of (Thm.get_name_hint th) = dep
   338     fun add_isa_dep facts dep accum =
   339     fun add_isa_dep facts dep accum =
   339       if exists (is_dep dep) accum then
   340       if exists (is_dep dep) accum then
   340         accum
   341         accum
   341       else case find_first (is_dep dep) facts of
   342       else case find_first (is_dep dep) facts of
   342         SOME ((name, status), th) => accum @ [((name (), status), th)]
   343         SOME ((name, status), th) => accum @ [((name, status), th)]
   343       | NONE => accum (* shouldn't happen *)
   344       | NONE => accum (* shouldn't happen *)
   344     fun fix_name ((_, stature), th) =
   345     fun fix_name ((_, stature), th) =
   345       ((th |> Thm.get_name_hint |> fact_name_of, stature), th)
   346       ((fn () => th |> Thm.get_name_hint |> fact_name_of, stature), th)
   346     fun do_thm th =
   347     fun do_thm th =
   347       let
   348       let
   348         val name = Thm.get_name_hint th
   349         val name = Thm.get_name_hint th
   349         val goal = goal_of_thm thy th
   350         val goal = goal_of_thm thy th
   350         val deps =
   351         val deps =
   389 
   390 
   390 fun relevant_facts ctxt params prover max_relevant
   391 fun relevant_facts ctxt params prover max_relevant
   391                    (override as {add, only, ...}) chained_ths hyp_ts concl_t
   392                    (override as {add, only, ...}) chained_ths hyp_ts concl_t
   392                    facts =
   393                    facts =
   393   if only then
   394   if only then
   394     facts |> map (apfst (apfst (fn f => f ()))) (* ###*)
   395     facts
   395   else if max_relevant <= 0 then
   396   else if max_relevant <= 0 then
   396     []
   397     []
   397   else
   398   else
   398     let
   399     let
   399       val add_ths = Attrib.eval_thms ctxt add
   400       val add_ths = Attrib.eval_thms ctxt add