src/HOL/Tools/Sledgehammer/sledgehammer_prover_atp.ML
changeset 75035 ed510a3693e2
parent 75026 b61949cba32a
child 75060 789e0e1a9e33
equal deleted inserted replaced
75034:890b70f96fe4 75035:ed510a3693e2
    45 (* In addition to being easier to read, readable names are often much shorter, especially if types
    45 (* In addition to being easier to read, readable names are often much shorter, especially if types
    46    are mangled in names. This makes a difference for some provers (e.g., E). For these reason, short
    46    are mangled in names. This makes a difference for some provers (e.g., E). For these reason, short
    47    names are enabled by default. *)
    47    names are enabled by default. *)
    48 val atp_full_names = Attrib.setup_config_bool \<^binding>\<open>sledgehammer_atp_full_names\<close> (K false)
    48 val atp_full_names = Attrib.setup_config_bool \<^binding>\<open>sledgehammer_atp_full_names\<close> (K false)
    49 
    49 
    50 fun choose_type_enc strictness best_type_enc format =
    50 fun choose_type_enc strictness format good_type_enc =
    51   the_default best_type_enc
    51   type_enc_of_string strictness good_type_enc
    52   #> type_enc_of_string strictness
    52   |> adjust_type_enc format
    53   #> adjust_type_enc format
       
    54 
    53 
    55 fun has_bound_or_var_of_type pred =
    54 fun has_bound_or_var_of_type pred =
    56   exists_subterm (fn Var (_, T as Type _) => pred T
    55   exists_subterm (fn Var (_, T as Type _) => pred T
    57                    | Abs (_, T as Type _, _) => pred T
    56                    | Abs (_, T as Type _, _) => pred T
    58                    | _ => false)
    57                    | _ => false)
   101 
   100 
   102 (* Important messages are important but not so important that users want to see them each time. *)
   101 (* Important messages are important but not so important that users want to see them each time. *)
   103 val atp_important_message_keep_quotient = 25
   102 val atp_important_message_keep_quotient = 25
   104 
   103 
   105 fun run_atp mode name
   104 fun run_atp mode name
   106     ({debug, verbose, overlord, type_enc, strict, lam_trans, uncurried_aliases, fact_filter,
   105     ({debug, verbose, overlord, strict, fact_filter, max_facts, max_mono_iters,
   107       max_facts, max_mono_iters, max_new_mono_instances, isar_proofs, compress, try0, smt_proofs,
   106       max_new_mono_instances, isar_proofs, compress, try0, smt_proofs, minimize, slices, timeout,
   108       minimize, slices, timeout, preplay_timeout, spy, ...} : params)
   107       preplay_timeout, spy, ...} : params)
   109     ({comment, state, goal, subgoal, subgoal_count, factss, found_proof} : prover_problem)
   108     ({comment, state, goal, subgoal, subgoal_count, factss, found_proof} : prover_problem)
   110     slice =
   109     slice =
   111   let
   110   let
   112     val thy = Proof.theory_of state
   111     val thy = Proof.theory_of state
   113     val ctxt = Proof.context_of state
   112     val ctxt = Proof.context_of state
   189           (case max_facts of
   188           (case max_facts of
   190             NONE => good_max_facts
   189             NONE => good_max_facts
   191           | SOME max_facts => max_facts)
   190           | SOME max_facts => max_facts)
   192           |> Integer.min (length facts)
   191           |> Integer.min (length facts)
   193         val strictness = if strict then Strict else Non_Strict
   192         val strictness = if strict then Strict else Non_Strict
   194         val type_enc = type_enc |> choose_type_enc strictness good_type_enc good_format
   193         val type_enc = choose_type_enc strictness good_format good_type_enc
   195         val run_timeout = slice_timeout slices timeout
   194         val run_timeout = slice_timeout slices timeout
   196         val generous_run_timeout = if mode = MaSh then one_day else run_timeout
   195         val generous_run_timeout = if mode = MaSh then one_day else run_timeout
   197         val ({elapsed, ...}, atp_problem_data as (atp_problem, _, _, _)) = Timing.timing (fn () =>
   196         val ({elapsed, ...}, atp_problem_data as (atp_problem, _, _, _)) = Timing.timing (fn () =>
   198           let
   197           let
   199             val sound = is_type_enc_sound type_enc
   198             val sound = is_type_enc_sound type_enc
   200             val generate_info = (case good_format of DFG _ => true | _ => false)
   199             val generate_info = (case good_format of DFG _ => true | _ => false)
   201             val readable_names = not (Config.get ctxt atp_full_names)
   200             val readable_names = not (Config.get ctxt atp_full_names)
   202             val lam_trans = lam_trans |> the_default good_lam_trans
       
   203             val uncurried_aliases = uncurried_aliases |> the_default good_uncurried_aliases
       
   204           in
   201           in
   205             facts
   202             facts
   206             |> not sound ? filter_out (is_dangerous_prop ctxt o Thm.prop_of o snd)
   203             |> not sound ? filter_out (is_dangerous_prop ctxt o Thm.prop_of o snd)
   207             |> take num_facts
   204             |> take num_facts
   208             |> not (is_type_enc_polymorphic type_enc) ? monomorphize_facts
   205             |> not (is_type_enc_polymorphic type_enc) ? monomorphize_facts
   209             |> map (apsnd Thm.prop_of)
   206             |> map (apsnd Thm.prop_of)
   210             |> generate_atp_problem ctxt generate_info good_format prem_role type_enc atp_mode
   207             |> generate_atp_problem ctxt generate_info good_format prem_role type_enc atp_mode
   211               lam_trans uncurried_aliases readable_names true hyp_ts concl_t
   208               good_lam_trans good_uncurried_aliases readable_names true hyp_ts concl_t
   212           end) ()
   209           end) ()
   213 
   210 
   214         val () = spying spy (fn () =>
   211         val () = spying spy (fn () =>
   215           (state, subgoal, name, "Generating ATP problem in " ^
   212           (state, subgoal, name, "Generating ATP problem in " ^
   216              string_of_int (Time.toMilliseconds elapsed) ^ " ms"))
   213              string_of_int (Time.toMilliseconds elapsed) ^ " ms"))