src/HOL/Tools/Sledgehammer/sledgehammer_run.ML
changeset 54816 10d48c2a3e32
parent 54799 565f9af86d67
child 55201 1ee776da8da7
equal deleted inserted replaced
54815:4f6ec8754bf5 54816:10d48c2a3e32
    17   val someN : string
    17   val someN : string
    18   val noneN : string
    18   val noneN : string
    19   val timeoutN : string
    19   val timeoutN : string
    20   val unknownN : string
    20   val unknownN : string
    21   val string_of_factss : (string * fact list) list -> string
    21   val string_of_factss : (string * fact list) list -> string
    22   val run_sledgehammer :
    22   val run_sledgehammer : params -> mode -> (string -> unit) option -> int -> fact_override ->
    23     params -> mode -> (string -> unit) option -> int -> fact_override
    23     ((string * string list) list -> string -> minimize_command) -> Proof.state ->
    24     -> ((string * string list) list -> string -> minimize_command)
    24     bool * (string * Proof.state)
    25     -> Proof.state -> bool * (string * Proof.state)
       
    26 end;
    25 end;
    27 
    26 
    28 structure Sledgehammer_Run : SLEDGEHAMMER_RUN =
    27 structure Sledgehammer_Run : SLEDGEHAMMER_RUN =
    29 struct
    28 struct
    30 
    29 
    63       "") ^
    62       "") ^
    64    " on " ^ (if n = 1 then "goal" else "subgoal " ^ string_of_int i) ^
    63    " on " ^ (if n = 1 then "goal" else "subgoal " ^ string_of_int i) ^
    65    (if blocking then "."
    64    (if blocking then "."
    66     else "\n" ^ Syntax.string_of_term ctxt (Thm.term_of (Thm.cprem_of goal i))))
    65     else "\n" ^ Syntax.string_of_term ctxt (Thm.term_of (Thm.cprem_of goal i))))
    67 
    66 
    68 fun launch_prover (params as {debug, verbose, spy, blocking, max_facts, timeout, expect, ...})
    67 fun launch_prover (params as {debug, verbose, spy, blocking, max_facts, timeout, expect, ...}) mode
    69         mode output_result minimize_command only learn
    68     output_result minimize_command only learn
    70         {comment, state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
    69     {comment, state, goal, subgoal, subgoal_count, factss as (_, facts) :: _} name =
    71   let
    70   let
    72     val ctxt = Proof.context_of state
    71     val ctxt = Proof.context_of state
    73 
    72 
    74     val hard_timeout = time_mult 3.0 (timeout |> the_default one_day)
    73     val hard_timeout = time_mult 3.0 timeout
    75     val _ = spying spy (fn () => (state, subgoal, name, "Launched"));
    74     val _ = spying spy (fn () => (state, subgoal, name, "Launched"));
    76     val birth_time = Time.now ()
    75     val birth_time = Time.now ()
    77     val death_time = Time.+ (birth_time, hard_timeout)
    76     val death_time = Time.+ (birth_time, hard_timeout)
    78     val max_facts = max_facts |> the_default (default_max_facts_of_prover ctxt name)
    77     val max_facts = max_facts |> the_default (default_max_facts_of_prover ctxt name)
    79     val num_facts = length facts |> not only ? Integer.min max_facts
    78     val num_facts = length facts |> not only ? Integer.min max_facts
   171           else
   170           else
   172             warning ("Unexpected outcome: " ^ quote outcome_code ^ ".");
   171             warning ("Unexpected outcome: " ^ quote outcome_code ^ ".");
   173       in (outcome_code, message) end
   172       in (outcome_code, message) end
   174   in
   173   in
   175     if mode = Auto_Try then
   174     if mode = Auto_Try then
   176       let val (outcome_code, message) = time_limit timeout go () in
   175       let val (outcome_code, message) = TimeLimit.timeLimit timeout go () in
   177         (outcome_code,
   176         (outcome_code,
   178          state
   177          state
   179          |> outcome_code = someN
   178          |> outcome_code = someN
   180             ? Proof.goal_message (fn () =>
   179             ? Proof.goal_message (fn () =>
   181                   Pretty.mark Markup.information (Pretty.str (message ()))))
   180                   Pretty.mark Markup.information (Pretty.str (message ()))))