src/HOL/Tools/Sledgehammer/sledgehammer.ML
changeset 61223 dfccf6c06201
parent 60612 79d71bfea310
child 61311 150aa3015c47
equal deleted inserted replaced
61222:05d28dc76e5c 61223:dfccf6c06201
   116         try_methss [] methss
   116         try_methss [] methss
   117       end
   117       end
   118   end
   118   end
   119 
   119 
   120 fun launch_prover (params as {debug, verbose, spy, blocking, max_facts, minimize, timeout,
   120 fun launch_prover (params as {debug, verbose, spy, blocking, max_facts, minimize, timeout,
   121       preplay_timeout, expect, ...}) mode output_result only learn
   121       preplay_timeout, expect, ...}) mode writeln_result only learn
   122     {comment, state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
   122     {comment, state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
   123   let
   123   let
   124     val ctxt = Proof.context_of state
   124     val ctxt = Proof.context_of state
   125 
   125 
   126     val hard_timeout = time_mult 3.0 timeout
   126     val hard_timeout = time_mult 3.0 timeout
   228       let
   228       let
   229         val (outcome_code, message) = TimeLimit.timeLimit hard_timeout go ()
   229         val (outcome_code, message) = TimeLimit.timeLimit hard_timeout go ()
   230         val outcome =
   230         val outcome =
   231           if outcome_code = someN orelse mode = Normal then quote name ^ ": " ^ message () else ""
   231           if outcome_code = someN orelse mode = Normal then quote name ^ ": " ^ message () else ""
   232         val _ =
   232         val _ =
   233           if outcome <> "" andalso is_some output_result then
   233           if outcome <> "" andalso is_some writeln_result then
   234             the output_result outcome
   234             the writeln_result outcome
   235           else
   235           else
   236             outcome
   236             outcome
   237             |> Async_Manager_Legacy.break_into_chunks
   237             |> Async_Manager_Legacy.break_into_chunks
   238             |> List.app writeln
   238             |> List.app writeln
   239       in (outcome_code, []) end
   239       in (outcome_code, []) end
   256   else
   256   else
   257     cat_lines (map (fn (filter, facts) =>
   257     cat_lines (map (fn (filter, facts) =>
   258       (if filter = "" then "" else quote filter ^ ": ") ^ string_of_facts facts) factss)
   258       (if filter = "" then "" else quote filter ^ ": ") ^ string_of_facts facts) factss)
   259 
   259 
   260 fun run_sledgehammer (params as {verbose, spy, blocking, provers, max_facts, ...}) mode
   260 fun run_sledgehammer (params as {verbose, spy, blocking, provers, max_facts, ...}) mode
   261     output_result i (fact_override as {only, ...}) state =
   261     writeln_result i (fact_override as {only, ...}) state =
   262   if null provers then
   262   if null provers then
   263     error "No prover is set."
   263     error "No prover is set."
   264   else
   264   else
   265     (case subgoal_count state of
   265     (case subgoal_count state of
   266       0 =>
   266       0 =>
   267       ((if blocking then error else writeln) "No subgoal!"; (false, (noneN, [])))
   267       ((if blocking then error else writeln) "No subgoal!"; (false, (noneN, [])))
   268     | n =>
   268     | n =>
   269       let
   269       let
   270         val _ = Proof.assert_backward state
   270         val _ = Proof.assert_backward state
   271         val print =
   271         val print =
   272           if mode = Normal andalso is_none output_result then writeln else K ()
   272           if mode = Normal andalso is_none writeln_result then writeln else K ()
   273         val ctxt = Proof.context_of state
   273         val ctxt = Proof.context_of state
   274         val keywords = Thy_Header.get_keywords' ctxt
   274         val keywords = Thy_Header.get_keywords' ctxt
   275         val {facts = chained, goal, ...} = Proof.goal state
   275         val {facts = chained, goal, ...} = Proof.goal state
   276         val (_, hyp_ts, concl_t) = strip_subgoal goal i ctxt
   276         val (_, hyp_ts, concl_t) = strip_subgoal goal i ctxt
   277         val ho_atp = exists (is_ho_atp ctxt) provers
   277         val ho_atp = exists (is_ho_atp ctxt) provers
   313             val factss = get_factss provers
   313             val factss = get_factss provers
   314             val problem =
   314             val problem =
   315               {comment = "", state = state, goal = goal, subgoal = i, subgoal_count = n,
   315               {comment = "", state = state, goal = goal, subgoal = i, subgoal_count = n,
   316                factss = factss}
   316                factss = factss}
   317             val learn = mash_learn_proof ctxt params (Thm.prop_of goal) all_facts
   317             val learn = mash_learn_proof ctxt params (Thm.prop_of goal) all_facts
   318             val launch = launch_prover params mode output_result only learn
   318             val launch = launch_prover params mode writeln_result only learn
   319           in
   319           in
   320             if mode = Auto_Try then
   320             if mode = Auto_Try then
   321               (unknownN, [])
   321               (unknownN, [])
   322               |> fold (fn prover => fn accum as (outcome_code, _) =>
   322               |> fold (fn prover => fn accum as (outcome_code, _) =>
   323                   if outcome_code = someN then accum else launch problem prover)
   323                   if outcome_code = someN then accum else launch problem prover)