src/HOL/Tools/Sledgehammer/sledgehammer_provers.ML
changeset 43051 d7075adac3bd
parent 43050 59284a13abc4
child 43052 8d6a4978cc65
equal deleted inserted replaced
43050:59284a13abc4 43051:d7075adac3bd
    56     {outcome: failure option,
    56     {outcome: failure option,
    57      used_facts: (string * locality) list,
    57      used_facts: (string * locality) list,
    58      run_time_in_msecs: int option,
    58      run_time_in_msecs: int option,
    59      message: string}
    59      message: string}
    60 
    60 
    61   type prover = params -> minimize_command -> prover_problem -> prover_result
    61   type prover =
       
    62     params -> (string -> minimize_command) -> prover_problem -> prover_result
    62 
    63 
    63   val smt_triggers : bool Config.T
    64   val smt_triggers : bool Config.T
    64   val smt_weights : bool Config.T
    65   val smt_weights : bool Config.T
    65   val smt_weight_min_facts : int Config.T
    66   val smt_weight_min_facts : int Config.T
    66   val smt_min_weight : int Config.T
    67   val smt_min_weight : int Config.T
   316   {outcome: failure option,
   317   {outcome: failure option,
   317    message: string,
   318    message: string,
   318    used_facts: (string * locality) list,
   319    used_facts: (string * locality) list,
   319    run_time_in_msecs: int option}
   320    run_time_in_msecs: int option}
   320 
   321 
   321 type prover = params -> minimize_command -> prover_problem -> prover_result
   322 type prover =
       
   323   params -> (string -> minimize_command) -> prover_problem -> prover_result
   322 
   324 
   323 
   325 
   324 (* configuration attributes *)
   326 (* configuration attributes *)
   325 
   327 
   326 val dest_dir =
   328 val dest_dir =
   514                    (if is_type_sys_fairly_sound type_sys then Preds else Tags)
   516                    (if is_type_sys_fairly_sound type_sys then Preds else Tags)
   515                        stuff
   517                        stuff
   516                  | _ => type_sys)
   518                  | _ => type_sys)
   517      | format => (format, type_sys))
   519      | format => (format, type_sys))
   518 
   520 
   519 fun determine_format_and_type_sys _ formats (Dumb_Type_Sys type_sys) =
   521 fun choose_format_and_type_sys _ formats (Dumb_Type_Sys type_sys) =
   520     adjust_dumb_type_sys formats type_sys
   522     adjust_dumb_type_sys formats type_sys
   521   | determine_format_and_type_sys best_type_systems formats
   523   | choose_format_and_type_sys best_type_systems formats
   522                                   (Smart_Type_Sys full_types) =
   524                                (Smart_Type_Sys full_types) =
   523     map type_sys_from_string best_type_systems @ fallback_best_type_systems
   525     map type_sys_from_string best_type_systems @ fallback_best_type_systems
   524     |> find_first (if full_types then is_type_sys_virtually_sound else K true)
   526     |> find_first (if full_types then is_type_sys_virtually_sound else K true)
   525     |> the |> adjust_dumb_type_sys formats
   527     |> the |> adjust_dumb_type_sys formats
       
   528 
       
   529 val metis_minimize_max_time = seconds 2.0
       
   530 
       
   531 fun choose_minimize_command minimize_command name preplay =
       
   532   (case preplay of
       
   533      Played (reconstructor, time) =>
       
   534      if Time.<= (time, metis_minimize_max_time) then
       
   535        reconstructor_name reconstructor
       
   536      else
       
   537        name
       
   538    | _ => name)
       
   539   |> minimize_command
   526 
   540 
   527 fun repair_smt_monomorph_context debug max_mono_iters max_mono_instances =
   541 fun repair_smt_monomorph_context debug max_mono_iters max_mono_instances =
   528   Config.put SMT_Config.verbose debug
   542   Config.put SMT_Config.verbose debug
   529   #> Config.put SMT_Config.monomorph_full false
   543   #> Config.put SMT_Config.monomorph_full false
   530   #> Config.put SMT_Config.monomorph_limit max_mono_iters
   544   #> Config.put SMT_Config.monomorph_limit max_mono_iters
   603               let
   617               let
   604                 val num_facts =
   618                 val num_facts =
   605                   length facts |> is_none max_relevant
   619                   length facts |> is_none max_relevant
   606                                   ? Integer.min best_max_relevant
   620                                   ? Integer.min best_max_relevant
   607                 val (format, type_sys) =
   621                 val (format, type_sys) =
   608                   determine_format_and_type_sys best_type_systems formats
   622                   choose_format_and_type_sys best_type_systems formats type_sys
   609                                                 type_sys
       
   610                 val fairly_sound = is_type_sys_fairly_sound type_sys
   623                 val fairly_sound = is_type_sys_fairly_sound type_sys
   611                 val facts =
   624                 val facts =
   612                   facts |> not fairly_sound
   625                   facts |> not fairly_sound
   613                            ? filter_out (is_dangerous_prop ctxt o prop_of o snd
   626                            ? filter_out (is_dangerous_prop ctxt o prop_of o snd
   614                                          o untranslated_fact)
   627                                          o untranslated_fact)
   781             (debug, full_types, isar_shrink_factor, type_sys, pool,
   794             (debug, full_types, isar_shrink_factor, type_sys, pool,
   782              conjecture_shape, facts_offset, fact_names, sym_tab, atp_proof,
   795              conjecture_shape, facts_offset, fact_names, sym_tab, atp_proof,
   783              goal)
   796              goal)
   784           val one_line_params =
   797           val one_line_params =
   785             (preplay, proof_banner mode blocking name, used_facts,
   798             (preplay, proof_banner mode blocking name, used_facts,
   786              minimize_command, subgoal, subgoal_count)
   799              choose_minimize_command minimize_command name preplay,
       
   800              subgoal, subgoal_count)
   787         in
   801         in
   788           (proof_text ctxt isar_proof isar_params one_line_params ^
   802           (proof_text ctxt isar_proof isar_params one_line_params ^
   789            (if verbose then
   803            (if verbose then
   790               "\nATP real CPU time: " ^
   804               "\nATP real CPU time: " ^
   791               string_from_time (Time.fromMilliseconds (the msecs)) ^ "."
   805               string_from_time (Time.fromMilliseconds (the msecs)) ^ "."
   968                                      subgoal [Metis, MetisFT] of
   982                                      subgoal [Metis, MetisFT] of
   969               p as Played _ => p
   983               p as Played _ => p
   970             | _ => Trust_Playable (SMT (smt_settings ()), NONE)
   984             | _ => Trust_Playable (SMT (smt_settings ()), NONE)
   971           val one_line_params =
   985           val one_line_params =
   972             (preplay, proof_banner mode blocking name, used_facts,
   986             (preplay, proof_banner mode blocking name, used_facts,
   973              minimize_command, subgoal, subgoal_count)
   987              choose_minimize_command minimize_command name preplay,
       
   988              subgoal, subgoal_count)
   974         in
   989         in
   975           one_line_proof_text one_line_params ^
   990           one_line_proof_text one_line_params ^
   976           (if verbose then
   991           (if verbose then
   977              "\nSMT solver real CPU time: " ^
   992              "\nSMT solver real CPU time: " ^
   978              string_from_time (Time.fromMilliseconds (the run_time_in_msecs)) ^
   993              string_from_time (Time.fromMilliseconds (the run_time_in_msecs)) ^
  1000                              [reconstructor] of
  1015                              [reconstructor] of
  1001       play as Played (_, time) =>
  1016       play as Played (_, time) =>
  1002       let
  1017       let
  1003         val one_line_params =
  1018         val one_line_params =
  1004           (play, proof_banner mode blocking name, used_facts,
  1019           (play, proof_banner mode blocking name, used_facts,
  1005            minimize_command, subgoal, subgoal_count)
  1020            minimize_command name, subgoal, subgoal_count)
  1006       in
  1021       in
  1007         {outcome = NONE, used_facts = used_facts,
  1022         {outcome = NONE, used_facts = used_facts,
  1008          run_time_in_msecs = SOME (Time.toMilliseconds time),
  1023          run_time_in_msecs = SOME (Time.toMilliseconds time),
  1009          message = one_line_proof_text one_line_params}
  1024          message = one_line_proof_text one_line_params}
  1010       end
  1025       end