src/HOL/Tools/Mirabelle/mirabelle.ML
author wenzelm
Sun, 06 Jun 2021 20:29:52 +0200
changeset 73821 9ead8d9be3ab
parent 73820 745e2cd1f5f5
child 73822 1192c68ebe1c
permissions -rw-r--r--
clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47847
7cddb6c8f93c updated headers;
wenzelm
parents: 47730
diff changeset
     1
(*  Title:      HOL/Mirabelle/Tools/mirabelle.ML
32564
378528d2f7eb standard headers and text sections;
wenzelm
parents: 32551
diff changeset
     2
    Author:     Jasmin Blanchette and Sascha Boehme, TU Munich
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
     3
    Author:     Makarius
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
     4
*)
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
     5
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
     6
signature MIRABELLE =
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
     7
sig
32564
378528d2f7eb standard headers and text sections;
wenzelm
parents: 32551
diff changeset
     8
  (*core*)
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
     9
  val print_name: string -> string
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    10
  val print_properties: Properties.T -> string
73697
0e7a5c7a14c8 reactive "sledgehammer";
wenzelm
parents: 73694
diff changeset
    11
  type context =
0e7a5c7a14c8 reactive "sledgehammer";
wenzelm
parents: 73694
diff changeset
    12
    {index: int, tag: string, arguments: Properties.T, timeout: Time.time, theory: theory}
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    13
  type command = {name: string, pos: Position.T, pre: Proof.state, post: Toplevel.state}
73694
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    14
  val theory_action: binding -> (context -> command list -> XML.body) -> theory -> theory
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    15
  val log_command: command -> XML.body -> XML.tree
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    16
  val log_report: Properties.T -> XML.body -> XML.tree
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    17
  val print_exn: exn -> string
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    18
  val command_action: binding -> (context -> command -> string) -> theory -> theory
32495
6decc1ffdbed removed unused signature
boehmes
parents: 32489
diff changeset
    19
32564
378528d2f7eb standard headers and text sections;
wenzelm
parents: 32551
diff changeset
    20
  (*utility functions*)
32469
1ad7d4fc0954 Mirabelle: added preliminary documentation,
boehmes
parents: 32468
diff changeset
    21
  val can_apply : Time.time -> (Proof.context -> int -> tactic) ->
1ad7d4fc0954 Mirabelle: added preliminary documentation,
boehmes
parents: 32468
diff changeset
    22
    Proof.state -> bool
60361
88505460fde7 clarified context;
wenzelm
parents: 56161
diff changeset
    23
  val theorems_in_proof_term : theory -> thm -> thm list
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    24
  val theorems_of_sucessful_proof: Toplevel.state -> thm list
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    25
  val get_argument : (string * string) list -> string * string -> string
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    26
  val get_int_argument : (string * string) list -> string * int -> int
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    27
  val get_bool_argument : (string * string) list -> string * bool -> bool
32498
1132c7c13f36 Mirabelle: actions are responsible for handling exceptions,
boehmes
parents: 32497
diff changeset
    28
  val cpu_time : ('a -> 'b) -> 'a -> 'b * int
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
    29
end
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
    30
32497
922718ac81e4 removed errors overseen in previous changes
boehmes
parents: 32496
diff changeset
    31
structure Mirabelle : MIRABELLE =
32495
6decc1ffdbed removed unused signature
boehmes
parents: 32489
diff changeset
    32
struct
6decc1ffdbed removed unused signature
boehmes
parents: 32489
diff changeset
    33
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    34
(** Mirabelle core **)
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    35
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    36
(* concrete syntax *)
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    37
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    38
val keywords = Keyword.no_command_keywords (Thy_Header.get_keywords \<^theory>);
32495
6decc1ffdbed removed unused signature
boehmes
parents: 32489
diff changeset
    39
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    40
val print_name = Token.print_name keywords;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    41
val print_properties = Token.print_properties keywords;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    42
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    43
fun read_actions str =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    44
  Token.read_body keywords
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    45
    (Parse.enum ";" (Parse.name -- Sledgehammer_Commands.parse_params))
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    46
    (Symbol_Pos.explode0 str);
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents: 32383
diff changeset
    47
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents: 32383
diff changeset
    48
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    49
(* actions *)
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    50
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    51
type command = {name: string, pos: Position.T, pre: Proof.state, post: Toplevel.state};
73697
0e7a5c7a14c8 reactive "sledgehammer";
wenzelm
parents: 73694
diff changeset
    52
type context =
0e7a5c7a14c8 reactive "sledgehammer";
wenzelm
parents: 73694
diff changeset
    53
  {index: int, tag: string, arguments: Properties.T, timeout: Time.time, theory: theory};
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    54
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    55
structure Data = Theory_Data
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    56
(
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    57
  type T = (context -> command list -> XML.body) Name_Space.table;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    58
  val empty = Name_Space.empty_table "mirabelle_action";
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    59
  val extend = I;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    60
  val merge = Name_Space.merge_tables;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    61
);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
    62
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    63
fun theory_action binding action thy =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    64
  let val context = Context.Theory thy |> Name_Space.map_naming (K Name_Space.global_naming);
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    65
  in thy |> Data.map (#2 o Name_Space.define context true (binding, action)) end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
    66
73694
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    67
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    68
(* log content *)
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    69
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    70
fun log_action name arguments =
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    71
  XML.Elem (("action", (Markup.nameN, name) :: arguments),
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    72
    [XML.Text (print_name name ^ (if null arguments then "" else " " ^ print_properties arguments))]);
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    73
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    74
fun log_command ({name, pos, ...}: command) body =
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    75
  XML.Elem (("command", (Markup.nameN, name) :: Position.properties_of pos), body);
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    76
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    77
fun log_report props body =
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    78
  XML.Elem (("report", props), body);
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    79
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    80
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    81
(* apply actions *)
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    82
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    83
fun apply_action index name arguments timeout commands thy =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    84
  let
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    85
    val action = #2 (Name_Space.check (Context.Theory thy) (Data.get thy) (name, Position.none));
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    86
    val tag = "#" ^ Value.print_int index ^ " " ^ name ^ ": ";
73697
0e7a5c7a14c8 reactive "sledgehammer";
wenzelm
parents: 73694
diff changeset
    87
    val context = {index = index, tag = tag, arguments = arguments, timeout = timeout, theory = thy};
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    88
    val export_body = action context commands;
73694
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    89
    val export_head = log_action name arguments;
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    90
    val export_name = Path.binding0 (Path.basic "mirabelle" + Path.basic (Value.print_int index));
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    91
  in
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    92
    if null export_body then ()
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    93
    else Export.export thy export_name (export_head :: export_body)
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
    94
  end;
34035
08d34921b7dd also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents: 33522
diff changeset
    95
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    96
fun print_exn exn =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    97
  (case exn of
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    98
    Timeout.TIMEOUT _ => "timeout"
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
    99
  | ERROR msg => "error: " ^ msg
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   100
  | exn => "exception:\n" ^ General.exnMessage exn);
34035
08d34921b7dd also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents: 33522
diff changeset
   101
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   102
fun command_action binding action =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   103
  let
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   104
    fun apply context command =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   105
      let val s =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   106
        action context command handle exn =>
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   107
          if Exn.is_interrupt exn then Exn.reraise exn
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   108
          else #tag context ^ print_exn exn;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   109
      in
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   110
        if s = "" then NONE
73694
60519a7bfc53 clarified signature;
wenzelm
parents: 73691
diff changeset
   111
        else SOME (log_command command [XML.Text s]) end;
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   112
  in theory_action binding (map_filter o apply) end;
32515
e7c0d3c0494a Mirabelle: actions are responsible for catching exceptions and producing suitable log messages (makes log message uniform),
boehmes
parents: 32504
diff changeset
   113
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   114
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   115
(* theory line range *)
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   116
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   117
local
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   118
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   119
val theory_name =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   120
  Scan.many1 (Symbol_Pos.symbol #> (fn s => Symbol.not_eof s andalso s <> "["))
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   121
    >> Symbol_Pos.content;
32498
1132c7c13f36 Mirabelle: actions are responsible for handling exceptions,
boehmes
parents: 32497
diff changeset
   122
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   123
val line = Symbol_Pos.scan_nat >> (Symbol_Pos.content #> Value.parse_nat);
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   124
val end_line = Symbol_Pos.$$ ":" |-- line;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   125
val range = Symbol_Pos.$$ "[" |-- line -- Scan.option end_line --| Symbol_Pos.$$ "]";
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   126
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   127
in
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   128
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   129
fun read_theory_range str =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   130
  (case Scan.read Symbol_Pos.stopper (theory_name -- Scan.option range) (Symbol_Pos.explode0 str) of
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   131
    SOME res => res
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   132
  | NONE => error ("Malformed specification of theory line range: " ^ quote str));
32472
7b92a8b8daaf Mirabelle: actions are responsible for their log messages, output is better readable
boehmes
parents: 32469
diff changeset
   133
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   134
end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   135
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   136
fun check_theories strs =
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32515
diff changeset
   137
  let
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   138
    val theories = map read_theory_range strs;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   139
    fun get_theory name =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   140
      if null theories then SOME NONE
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   141
      else get_first (fn (a, b) => if a = name then SOME b else NONE) theories;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   142
    fun check_line NONE _ = false
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   143
      | check_line _ NONE = true
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   144
      | check_line (SOME NONE) _ = true
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   145
      | check_line (SOME (SOME (line, NONE))) (SOME i) = line <= i
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   146
      | check_line (SOME (SOME (line, SOME end_line))) (SOME i) = line <= i andalso i <= end_line;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   147
    fun check_pos range = check_line range o Position.line_of;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   148
  in check_pos o get_theory end;
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32515
diff changeset
   149
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   150
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   151
(* presentation hook *)
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   152
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   153
val whitelist = ["apply", "by", "proof"];
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   154
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   155
val _ =
73821
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   156
  Build.add_hook (fn loaded_theories =>
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   157
    let
73820
745e2cd1f5f5 refer to theory "segments" only, according to global Build.build_theories and Thy_Info.use_theories;
wenzelm
parents: 73808
diff changeset
   158
      val mirabelle_timeout = Options.default_seconds \<^system_option>\<open>mirabelle_timeout\<close>;
745e2cd1f5f5 refer to theory "segments" only, according to global Build.build_theories and Thy_Info.use_theories;
wenzelm
parents: 73808
diff changeset
   159
      val mirabelle_stride = Options.default_int \<^system_option>\<open>mirabelle_stride\<close>;
745e2cd1f5f5 refer to theory "segments" only, according to global Build.build_theories and Thy_Info.use_theories;
wenzelm
parents: 73808
diff changeset
   160
      val mirabelle_actions = Options.default_string \<^system_option>\<open>mirabelle_actions\<close>;
745e2cd1f5f5 refer to theory "segments" only, according to global Build.build_theories and Thy_Info.use_theories;
wenzelm
parents: 73808
diff changeset
   161
      val mirabelle_theories = Options.default_string \<^system_option>\<open>mirabelle_theories\<close>;
32468
3e6f5365971e Mirabelle: explicit command blacklist, preliminary documentation
boehmes
parents: 32396
diff changeset
   162
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   163
      val actions =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   164
        (case read_actions mirabelle_actions of
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   165
          SOME actions => actions
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   166
        | NONE => error ("Failed to parse mirabelle_actions: " ^ quote mirabelle_actions));
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   167
      val check = check_theories (space_explode "," mirabelle_theories);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   168
73821
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   169
      fun theory_commands (thy, segments) =
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   170
        let
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   171
          val commands = segments
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   172
            |> map_index (fn (n, {command = tr, prev_state = st, state = st', ...}) =>
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   173
              if n mod mirabelle_stride = 0 then
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   174
                let
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   175
                  val name = Toplevel.name_of tr;
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   176
                  val pos = Toplevel.pos_of tr;
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   177
                in
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   178
                  if can (Proof.assert_backward o Toplevel.proof_of) st andalso
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   179
                    member (op =) whitelist name andalso
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   180
                    check (Context.theory_long_name thy) pos
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   181
                  then SOME {name = name, pos = pos, pre = Toplevel.proof_of st, post = st'}
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   182
                  else NONE
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   183
                end
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   184
              else NONE)
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   185
            |> map_filter I;
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   186
        in if null commands then NONE else SOME (thy, commands) end;
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   187
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   188
      fun app_actions (thy, commands) =
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   189
        (actions, ()) |-> fold_index (fn (index, (name, arguments)) => fn () =>
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   190
          apply_action (index + 1) name arguments mirabelle_timeout commands thy);
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   191
    in
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   192
      if null actions then ()
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   193
      else List.app app_actions (map_filter theory_commands loaded_theories)
9ead8d9be3ab clarified hook for Mirabelle: provide all loaded theories at once (for each 'theories' section within the session ROOT);
wenzelm
parents: 73820
diff changeset
   194
    end);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   195
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   196
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   197
(* Mirabelle utility functions *)
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   198
32472
7b92a8b8daaf Mirabelle: actions are responsible for their log messages, output is better readable
boehmes
parents: 32469
diff changeset
   199
fun can_apply time tac st =
32469
1ad7d4fc0954 Mirabelle: added preliminary documentation,
boehmes
parents: 32468
diff changeset
   200
  let
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   201
    val {context = ctxt, facts, goal} = Proof.goal st;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   202
    val full_tac = HEADGOAL (Method.insert_tac ctxt facts THEN' tac ctxt);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   203
  in
62519
a564458f94db tuned signature -- clarified modules;
wenzelm
parents: 62505
diff changeset
   204
    (case try (Timeout.apply time (Seq.pull o full_tac)) goal of
39451
8893562a954b prevent exception when calling "Mirabelle.can_apply" on empty proof sequence;
blanchet
parents: 39377
diff changeset
   205
      SOME (SOME _) => true
8893562a954b prevent exception when calling "Mirabelle.can_apply" on empty proof sequence;
blanchet
parents: 39377
diff changeset
   206
    | _ => false)
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   207
  end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   208
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   209
local
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   210
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   211
fun fold_body_thms f =
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   212
  let
64573
e6aee01da22d tuned signature -- more abstract type thm_node;
wenzelm
parents: 62519
diff changeset
   213
    fun app n (PBody {thms, ...}) = thms |> fold (fn (i, thm_node) =>
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   214
      fn (x, seen) =>
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   215
        if Inttab.defined seen i then (x, seen)
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   216
        else
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   217
          let
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   218
            val name = Proofterm.thm_node_name thm_node;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   219
            val prop = Proofterm.thm_node_prop thm_node;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   220
            val body = Future.join (Proofterm.thm_node_body thm_node);
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   221
            val (x', seen') =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   222
              app (n + (if name = "" then 0 else 1)) body
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   223
                (x, Inttab.update (i, ()) seen);
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   224
        in (x' |> n = 0 ? f (name, prop, body), seen') end);
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   225
  in fn bodies => fn x => #1 (fold (app 0) bodies (x, Inttab.empty)) end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   226
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   227
in
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   228
60361
88505460fde7 clarified context;
wenzelm
parents: 56161
diff changeset
   229
fun theorems_in_proof_term thy thm =
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   230
  let
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   231
    val all_thms = Global_Theory.all_thms_of thy true;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   232
    fun collect (s, _, _) = if s <> "" then insert (op =) s else I;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   233
    fun member_of xs (x, y) = if member (op =) xs x then SOME y else NONE;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   234
    fun resolve_thms names = map_filter (member_of names) all_thms;
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   235
  in resolve_thms (fold_body_thms collect [Thm.proof_body_of thm] []) end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   236
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   237
end;
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   238
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   239
fun theorems_of_sucessful_proof st =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   240
  (case try Toplevel.proof_of st of
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   241
    NONE => []
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   242
  | SOME prf => theorems_in_proof_term (Proof.theory_of prf) (#goal (Proof.goal prf)));
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   243
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   244
fun get_argument arguments (key, default) =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   245
  the_default default (AList.lookup (op =) arguments key);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   246
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   247
fun get_int_argument arguments (key, default) =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   248
  (case Option.map Int.fromString (AList.lookup (op =) arguments key) of
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   249
    SOME (SOME i) => i
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   250
  | SOME NONE => error ("bad option: " ^ key)
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   251
  | NONE => default);
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   252
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   253
fun get_bool_argument arguments (key, default) =
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   254
  (case Option.map Bool.fromString (AList.lookup (op =) arguments key) of
73292
f84a93f1de2f tuned Mirabelle to parse option check_trivial only once
desharna
parents: 69597
diff changeset
   255
    SOME (SOME i) => i
f84a93f1de2f tuned Mirabelle to parse option check_trivial only once
desharna
parents: 69597
diff changeset
   256
  | SOME NONE => error ("bad option: " ^ key)
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   257
  | NONE => default);
73292
f84a93f1de2f tuned Mirabelle to parse option check_trivial only once
desharna
parents: 69597
diff changeset
   258
42014
75417ef605ba simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
wenzelm
parents: 42012
diff changeset
   259
fun cpu_time f x =
75417ef605ba simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
wenzelm
parents: 42012
diff changeset
   260
  let val ({cpu, ...}, y) = Timing.timing f x
73691
2f9877db82a1 reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents: 73685
diff changeset
   261
  in (y, Time.toMilliseconds cpu) end;
32498
1132c7c13f36 Mirabelle: actions are responsible for handling exceptions,
boehmes
parents: 32497
diff changeset
   262
32381
11542bebe4d4 made Mirabelle a component
boehmes
parents:
diff changeset
   263
end