src/HOL/Mirabelle/Tools/mirabelle_metis.ML
author wenzelm
Tue, 21 Jun 2016 14:42:47 +0200
changeset 63337 ae9330fdbc16
parent 62519 a564458f94db
permissions -rw-r--r--
position information for literal facts; Markup.entry may have empty kind/name;

(*  Title:      HOL/Mirabelle/Tools/mirabelle_metis.ML
    Author:     Jasmin Blanchette and Sascha Boehme, TU Munich
*)

structure Mirabelle_Metis : MIRABELLE_ACTION =
struct

fun metis_tag id = "#" ^ string_of_int id ^ " metis: "

fun init _ = I
fun done _ _ = ()

fun run id ({pre, post, timeout, log, ...}: Mirabelle.run_args) =
  let
    val thms = Mirabelle.theorems_of_sucessful_proof post
    val names = map Thm.get_name_hint thms
    val add_info = if null names then I else suffix (":\n" ^ commas names)

    val facts = map #1 (Facts.props (Proof_Context.facts_of (Proof.context_of pre)))

    fun metis ctxt =
      Metis_Tactic.metis_tac [] ATP_Problem_Generate.liftingN ctxt
                             (thms @ facts)
  in
    (if Mirabelle.can_apply timeout metis pre then "succeeded" else "failed")
    |> prefix (metis_tag id)
    |> add_info
    |> log
  end
  handle Timeout.TIMEOUT _ => log (metis_tag id ^ "timeout")
       | ERROR msg => log (metis_tag id ^ "error: " ^ msg)

fun invoke _ = Mirabelle.register (init, Mirabelle.catch metis_tag run, done)

end