src/HOL/Mirabelle/Tools/mirabelle_metis.ML
author nipkow
Fri, 11 Sep 2009 09:52:40 +0200
changeset 32562 b7a7b535d607
parent 32521 f20cc66b2c74
child 32564 378528d2f7eb
permissions -rw-r--r--
Made record parameter flexible to allow for extensions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     1
(* Title:  mirabelle_metis.ML
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     2
   Author: Jasmin Blanchette and Sascha Boehme
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     3
*)
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     4
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     5
structure Mirabelle_Metis : MIRABELLE_ACTION =
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     6
struct
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     7
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
     8
fun metis_tag id = "#" ^ string_of_int id ^ " metis: "
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
     9
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    10
fun init _ = I
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    11
fun done _ _ = ()
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    12
32562
b7a7b535d607 Made record parameter flexible to allow for extensions
nipkow
parents: 32521
diff changeset
    13
fun run id {pre, post, timeout, log, ...} =
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    14
  let
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    15
    val thms = Mirabelle.theorems_of_sucessful_proof post
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    16
    val names = map Thm.get_name thms
32472
7b92a8b8daaf Mirabelle: actions are responsible for their log messages, output is better readable
boehmes
parents: 32469
diff changeset
    17
    val add_info = if null names then I else suffix (":\n" ^ commas names)
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    18
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    19
    val facts = Facts.props (ProofContext.facts_of (Proof.context_of pre))
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    20
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    21
    fun metis ctxt = MetisTools.metis_tac ctxt (thms @ facts)
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    22
  in
32469
1ad7d4fc0954 Mirabelle: added preliminary documentation,
boehmes
parents: 32385
diff changeset
    23
    (if Mirabelle.can_apply timeout metis pre then "succeeded" else "failed")
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    24
    |> prefix (metis_tag id)
32472
7b92a8b8daaf Mirabelle: actions are responsible for their log messages, output is better readable
boehmes
parents: 32469
diff changeset
    25
    |> add_info
7b92a8b8daaf Mirabelle: actions are responsible for their log messages, output is better readable
boehmes
parents: 32469
diff changeset
    26
    |> log
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    27
  end
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    28
  handle TimeLimit.TimeOut => log (metis_tag id ^ "timeout")
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    29
       | ERROR msg => log (metis_tag id ^ "error: " ^ msg)
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    30
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    31
fun invoke _ = Mirabelle.register (init, Mirabelle.catch metis_tag run, done)
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    32
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    33
end