src/HOL/Tools/Sledgehammer/sledgehammer_run.ML
changeset 41773 22d23da89aa5
parent 41746 e590971528b2
child 41788 adfd365c7ea4
equal deleted inserted replaced
41772:27d4c768cf20 41773:22d23da89aa5
   173   else case subgoal_count state of
   173   else case subgoal_count state of
   174     0 => (Output.urgent_message "No subgoal!"; (false, state))
   174     0 => (Output.urgent_message "No subgoal!"; (false, state))
   175   | n =>
   175   | n =>
   176     let
   176     let
   177       val _ = Proof.assert_backward state
   177       val _ = Proof.assert_backward state
       
   178       val print = if auto then K () else Output.urgent_message
   178       val state =
   179       val state =
   179         state |> Proof.map_context (Config.put SMT_Config.verbose debug)
   180         state |> Proof.map_context (Config.put SMT_Config.verbose debug)
   180       val ctxt = Proof.context_of state
   181       val ctxt = Proof.context_of state
   181       val thy = ProofContext.theory_of ctxt
   182       val thy = ProofContext.theory_of ctxt
   182       val {facts = chained_ths, goal, ...} = Proof.goal state
   183       val {facts = chained_ths, goal, ...} = Proof.goal state
   184       val no_dangerous_types = types_dangerous_types type_sys
   185       val no_dangerous_types = types_dangerous_types type_sys
   185       val _ = () |> not blocking ? kill_provers
   186       val _ = () |> not blocking ? kill_provers
   186       val _ = case find_first (not o is_prover_supported ctxt) provers of
   187       val _ = case find_first (not o is_prover_supported ctxt) provers of
   187                 SOME name => error ("No such prover: " ^ name ^ ".")
   188                 SOME name => error ("No such prover: " ^ name ^ ".")
   188               | NONE => ()
   189               | NONE => ()
   189       val _ = if auto then () else Output.urgent_message "Sledgehammering..."
   190       val _ = print "Sledgehammering..."
   190       val (smts, atps) = provers |> List.partition (is_smt_prover ctxt)
   191       val (smts, atps) = provers |> List.partition (is_smt_prover ctxt)
   191       fun launch_provers state get_facts translate maybe_smt_filter provers =
   192       fun launch_provers state get_facts translate maybe_smt_filter provers =
   192         let
   193         let
   193           val facts = get_facts ()
   194           val facts = get_facts ()
   194           val num_facts = length facts
   195           val num_facts = length facts
   232                           "Found no relevant facts."
   233                           "Found no relevant facts."
   233                         else
   234                         else
   234                           "Including (up to) " ^ string_of_int (length facts) ^
   235                           "Including (up to) " ^ string_of_int (length facts) ^
   235                           " relevant fact" ^ plural_s (length facts) ^ ":\n" ^
   236                           " relevant fact" ^ plural_s (length facts) ^ ":\n" ^
   236                           (facts |> map (fst o fst) |> space_implode " ") ^ ".")
   237                           (facts |> map (fst o fst) |> space_implode " ") ^ ".")
   237                        |> Output.urgent_message
   238                        |> print
   238                      else
   239                      else
   239                        ())
   240                        ())
   240         end
   241         end
   241       fun launch_atps accum =
   242       fun launch_atps accum =
   242         if null atps then
   243         if null atps then
   263                  |> exists fst |> rpair state
   264                  |> exists fst |> rpair state
   264           end
   265           end
   265       fun launch_atps_and_smt_solvers () =
   266       fun launch_atps_and_smt_solvers () =
   266         [launch_atps, launch_smts]
   267         [launch_atps, launch_smts]
   267         |> smart_par_list_map (fn f => f (false, state) |> K ())
   268         |> smart_par_list_map (fn f => f (false, state) |> K ())
   268         handle ERROR msg => (Output.urgent_message ("Error: " ^ msg); error msg)
   269         handle ERROR msg => (print ("Error: " ^ msg); error msg)
   269     in
   270     in
   270       (false, state)
   271       (false, state)
   271       |> (if blocking then launch_atps #> not auto ? launch_smts
   272       |> (if blocking then launch_atps #> not auto ? launch_smts
   272           else (fn p => Future.fork (tap launch_atps_and_smt_solvers) |> K p))
   273           else (fn p => Future.fork (tap launch_atps_and_smt_solvers) |> K p))
       
   274       handle TimeLimit.TimeOut =>
       
   275              (print "Sledgehammer ran out of time."; (false, state))
   273     end
   276     end
   274 
   277 
   275 end;
   278 end;