src/HOL/Tools/Sledgehammer/sledgehammer_mash.ML
changeset 57384 085e85cc6eea
parent 57383 ba0fe0639bc8
child 57385 0eb0c7b93676
equal deleted inserted replaced
57383:ba0fe0639bc8 57384:085e85cc6eea
  1712     [("", map fact_of_raw_fact facts)]
  1712     [("", map fact_of_raw_fact facts)]
  1713   else if max_facts <= 0 orelse null facts then
  1713   else if max_facts <= 0 orelse null facts then
  1714     [("", [])]
  1714     [("", [])]
  1715   else
  1715   else
  1716     let
  1716     let
  1717       fun maybe_launch_thread () =
  1717       fun maybe_launch_thread min_num_facts_to_learn =
  1718         if not (Async_Manager.has_running_threads MaShN) andalso
  1718         if not (Async_Manager.has_running_threads MaShN) andalso
  1719            Time.toSeconds timeout >= min_secs_for_learning then
  1719            Time.toSeconds timeout >= min_secs_for_learning then
  1720           let val timeout = time_mult learn_timeout_slack timeout in
  1720           let val timeout = time_mult learn_timeout_slack timeout in
       
  1721             Output.urgent_message ("Started MaShing through at least " ^
       
  1722               string_of_int min_num_facts_to_learn ^ " fact" ^ plural_s min_num_facts_to_learn ^
       
  1723               " in the background");
  1721             launch_thread timeout
  1724             launch_thread timeout
  1722               (fn () => (true, mash_learn_facts ctxt params prover true 2 false timeout facts))
  1725               (fn () => (true, mash_learn_facts ctxt params prover true 2 false timeout facts))
  1723           end
  1726           end
  1724         else
  1727         else
  1725           ()
  1728           ()
  1727       fun maybe_learn () =
  1730       fun maybe_learn () =
  1728         if is_mash_enabled () andalso learn then
  1731         if is_mash_enabled () andalso learn then
  1729           let
  1732           let
  1730             val {access_G, xtabs = ((num_facts0, _), _), ...} = peek_state ctxt overlord I
  1733             val {access_G, xtabs = ((num_facts0, _), _), ...} = peek_state ctxt overlord I
  1731             val is_in_access_G = is_fact_in_graph access_G o snd
  1734             val is_in_access_G = is_fact_in_graph access_G o snd
       
  1735             val min_num_facts_to_learn = length facts - num_facts0
  1732           in
  1736           in
  1733             if length facts - num_facts0 <= max_facts_to_learn_before_query then
  1737             if min_num_facts_to_learn <= max_facts_to_learn_before_query then
  1734               (case length (filter_out is_in_access_G facts) of
  1738               (case length (filter_out is_in_access_G facts) of
  1735                 0 => false
  1739                 0 => false
  1736               | num_facts_to_learn =>
  1740               | num_facts_to_learn =>
  1737                 if num_facts_to_learn <= max_facts_to_learn_before_query then
  1741                 if num_facts_to_learn <= max_facts_to_learn_before_query then
  1738                   (mash_learn_facts ctxt params prover false 2 false timeout facts
  1742                   (mash_learn_facts ctxt params prover false 2 false timeout facts
  1739                    |> (fn "" => () | s => Output.urgent_message (MaShN ^ ": " ^ s));
  1743                    |> (fn "" => () | s => Output.urgent_message (MaShN ^ ": " ^ s));
  1740                    true)
  1744                    true)
  1741                 else
  1745                 else
  1742                   (maybe_launch_thread (); false))
  1746                   (maybe_launch_thread num_facts_to_learn; false))
  1743             else
  1747             else
  1744               (maybe_launch_thread (); false)
  1748               (maybe_launch_thread min_num_facts_to_learn; false)
  1745           end
  1749           end
  1746         else
  1750         else
  1747           false
  1751           false
  1748 
  1752 
  1749       val (save, effective_fact_filter) =
  1753       val (save, effective_fact_filter) =