src/HOL/Tools/Sledgehammer/sledgehammer_run.ML
changeset 53815 e8aa538e959e
parent 53814 255a2929c137
child 54057 a2c4e0b7b1e2
equal deleted inserted replaced
53814:255a2929c137 53815:e8aa538e959e
    71         {state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
    71         {state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
    72   let
    72   let
    73     val ctxt = Proof.context_of state
    73     val ctxt = Proof.context_of state
    74 
    74 
    75     val hard_timeout = time_mult 3.0 (timeout |> the_default one_day)
    75     val hard_timeout = time_mult 3.0 (timeout |> the_default one_day)
    76     val _ = spying spy (fn () => (name, "launched"));
    76     val _ = spying spy (fn () => (state, subgoal, name, "launched"));
    77     val birth_time = Time.now ()
    77     val birth_time = Time.now ()
    78     val death_time = Time.+ (birth_time, hard_timeout)
    78     val death_time = Time.+ (birth_time, hard_timeout)
    79     val max_facts = max_facts |> the_default (default_max_facts_of_prover ctxt slice name)
    79     val max_facts = max_facts |> the_default (default_max_facts_of_prover ctxt slice name)
    80     val num_facts = length facts |> not only ? Integer.min max_facts
    80     val num_facts = length facts |> not only ? Integer.min max_facts
    81 
    81 
   114       |> verbose
   114       |> verbose
   115          ? tap (fn {outcome = NONE, used_facts as _ :: _, used_from, ...} =>
   115          ? tap (fn {outcome = NONE, used_facts as _ :: _, used_from, ...} =>
   116                    print_used_facts used_facts used_from
   116                    print_used_facts used_facts used_from
   117                  | _ => ())
   117                  | _ => ())
   118       |> spy
   118       |> spy
   119          ? tap (fn res => spying spy (fn () => (name, spying_str_of_res res)))
   119          ? tap (fn res => spying spy (fn () => (state, subgoal, name, spying_str_of_res res)))
   120       |> (fn {outcome, preplay, message, message_tail, ...} =>
   120       |> (fn {outcome, preplay, message, message_tail, ...} =>
   121              (if outcome = SOME ATP_Proof.TimedOut then timeoutN
   121              (if outcome = SOME ATP_Proof.TimedOut then timeoutN
   122               else if is_some outcome then noneN
   122               else if is_some outcome then noneN
   123               else someN, fn () => message (Lazy.force preplay) ^ message_tail))
   123               else someN, fn () => message (Lazy.force preplay) ^ message_tail))
   124 
   124 
   223       val _ = () |> not blocking ? kill_provers
   223       val _ = () |> not blocking ? kill_provers
   224       val _ = case find_first (not o is_prover_supported ctxt) provers of
   224       val _ = case find_first (not o is_prover_supported ctxt) provers of
   225                 SOME name => error ("No such prover: " ^ name ^ ".")
   225                 SOME name => error ("No such prover: " ^ name ^ ".")
   226               | NONE => ()
   226               | NONE => ()
   227       val _ = print "Sledgehammering..."
   227       val _ = print "Sledgehammering..."
   228       val _ = spying spy (fn () => ("***", "starting " ^ @{make_string} mode ^ " mode"))
   228       val _ =
       
   229         spying spy (fn () => (state, i, "***", "starting " ^ @{make_string} mode ^ " mode"))
   229       val (smts, (ueq_atps, full_atps)) =
   230       val (smts, (ueq_atps, full_atps)) =
   230         provers |> List.partition (is_smt_prover ctxt)
   231         provers |> List.partition (is_smt_prover ctxt)
   231                 ||> List.partition (is_unit_equational_atp ctxt)
   232                 ||> List.partition (is_unit_equational_atp ctxt)
   232 
   233 
   233       val spying_str_of_factss =
   234       val spying_str_of_factss =
   240               SOME n => n
   241               SOME n => n
   241             | NONE =>
   242             | NONE =>
   242               0 |> fold (Integer.max o default_max_facts_of_prover ctxt slice)
   243               0 |> fold (Integer.max o default_max_facts_of_prover ctxt slice)
   243                         provers
   244                         provers
   244                 |> mode = Auto_Try ? (fn n => n div auto_try_max_facts_divisor)
   245                 |> mode = Auto_Try ? (fn n => n div auto_try_max_facts_divisor)
   245           val _ = spying spy (fn () =>
   246           val _ = spying spy (fn () => (state, i, label ^ "s",
   246             (label ^ "s", "filtering " ^ string_of_int (length all_facts) ^ " facts"));
   247             "filtering " ^ string_of_int (length all_facts) ^ " facts"));
   247         in
   248         in
   248           all_facts
   249           all_facts
   249           |> (case is_appropriate_prop of
   250           |> (case is_appropriate_prop of
   250                 SOME is_app => filter (is_app o prop_of o snd)
   251                 SOME is_app => filter (is_app o prop_of o snd)
   251               | NONE => I)
   252               | NONE => I)
   257                        string_of_factss factss
   258                        string_of_factss factss
   258                        |> print
   259                        |> print
   259                      else
   260                      else
   260                        ())
   261                        ())
   261           |> spy ? tap (fn factss =>
   262           |> spy ? tap (fn factss =>
   262             spying spy (fn () => (label ^ "s", "selected facts: " ^ spying_str_of_factss factss)))
   263             spying spy (fn () =>
       
   264               (state, i, label ^ "s", "selected facts: " ^ spying_str_of_factss factss)))
   263         end
   265         end
   264 
   266 
   265       fun launch_provers state label is_appropriate_prop provers =
   267       fun launch_provers state label is_appropriate_prop provers =
   266         let
   268         let
   267           val factss = get_factss label is_appropriate_prop provers
   269           val factss = get_factss label is_appropriate_prop provers