src/HOL/Mirabelle/Tools/mirabelle_sledgehammer.ML
changeset 32936 9491bec20595
parent 32868 5f1805c6ef2a
child 32937 34f66c9dd8a2
equal deleted inserted replaced
32935:2218b970325a 32936:9491bec20595
   284 fun change_data id f = (Unsynchronized.change data (AList.map_entry (op =) id f); ())
   284 fun change_data id f = (Unsynchronized.change data (AList.map_entry (op =) id f); ())
   285 
   285 
   286 
   286 
   287 fun get_atp thy args =
   287 fun get_atp thy args =
   288   AList.lookup (op =) args proverK
   288   AList.lookup (op =) args proverK
   289   |> the_default (hd (space_explode " " (AtpManager.get_atps ())))
   289   |> the_default (hd (space_explode " " (ATP_Manager.get_atps ())))
   290   |> (fn name => (name, the (AtpManager.get_prover name thy)))
   290   |> (fn name => (name, the (ATP_Manager.get_prover name thy)))
   291 
   291 
   292 local
   292 local
   293 
   293 
   294 datatype sh_result =
   294 datatype sh_result =
   295   SH_OK of int * int * string list |
   295   SH_OK of int * int * string list |
   298 
   298 
   299 fun run_sh prover hard_timeout timeout dir st =
   299 fun run_sh prover hard_timeout timeout dir st =
   300   let
   300   let
   301     val (ctxt, goal) = Proof.get_goal st
   301     val (ctxt, goal) = Proof.get_goal st
   302     val ctxt' = if is_none dir then ctxt
   302     val ctxt' = if is_none dir then ctxt
   303       else Config.put AtpWrapper.destdir (the dir) ctxt
   303       else Config.put ATP_Wrapper.destdir (the dir) ctxt
   304     val atp = prover (AtpWrapper.atp_problem_of_goal
   304     val atp = prover (ATP_Wrapper.atp_problem_of_goal
   305       (AtpManager.get_full_types ()) 1 (ctxt', goal))
   305       (ATP_Manager.get_full_types ()) 1 (ctxt', goal))
   306 
   306 
   307     val time_limit =
   307     val time_limit =
   308       (case hard_timeout of
   308       (case hard_timeout of
   309         NONE => I
   309         NONE => I
   310       | SOME secs => TimeLimit.timeLimit (Time.fromSeconds secs))
   310       | SOME secs => TimeLimit.timeLimit (Time.fromSeconds secs))
   311     val (AtpWrapper.Prover_Result {success, message, theorem_names,
   311     val (ATP_Wrapper.Prover_Result {success, message, theorem_names,
   312       runtime=time_atp, ...}, time_isa) =
   312       runtime=time_atp, ...}, time_isa) =
   313       time_limit (Mirabelle.cpu_time atp) timeout
   313       time_limit (Mirabelle.cpu_time atp) timeout
   314   in
   314   in
   315     if success then (message, SH_OK (time_isa, time_atp, theorem_names))
   315     if success then (message, SH_OK (time_isa, time_atp, theorem_names))
   316     else (message, SH_FAIL(time_isa, time_atp))
   316     else (message, SH_FAIL(time_isa, time_atp))
   370 
   370 
   371 fun run_minimize args named_thms id ({pre=st, log, ...}: Mirabelle.run_args) =
   371 fun run_minimize args named_thms id ({pre=st, log, ...}: Mirabelle.run_args) =
   372   let
   372   let
   373     val n0 = length (these (!named_thms))
   373     val n0 = length (these (!named_thms))
   374     val (prover_name, prover) = get_atp (Proof.theory_of st) args
   374     val (prover_name, prover) = get_atp (Proof.theory_of st) args
   375     val minimize = AtpMinimal.minimalize prover prover_name
   375     val minimize = ATP_Minimal.minimalize prover prover_name
   376     val timeout =
   376     val timeout =
   377       AList.lookup (op =) args minimize_timeoutK
   377       AList.lookup (op =) args minimize_timeoutK
   378       |> Option.map (fst o read_int o explode)
   378       |> Option.map (fst o read_int o explode)
   379       |> the_default 5
   379       |> the_default 5
   380     val _ = log separator
   380     val _ = log separator
   446   end
   446   end
   447   end
   447   end
   448 
   448 
   449 fun invoke args =
   449 fun invoke args =
   450   let
   450   let
   451     val _ = AtpManager.set_full_types (AList.defined (op =) args full_typesK)
   451     val _ = ATP_Manager.set_full_types (AList.defined (op =) args full_typesK)
   452   in Mirabelle.register (init, sledgehammer_action args, done) end
   452   in Mirabelle.register (init, sledgehammer_action args, done) end
   453 
   453 
   454 end
   454 end