src/HOL/Mirabelle/Tools/mirabelle.ML
changeset 32551 421323205efd
parent 32521 f20cc66b2c74
child 32564 378528d2f7eb
equal deleted inserted replaced
32550:d57c7a2d927c 32551:421323205efd
    52 
    52 
    53 
    53 
    54 type init_action = int -> theory -> theory
    54 type init_action = int -> theory -> theory
    55 type done_action = int -> {last: Toplevel.state, log: string -> unit} -> unit
    55 type done_action = int -> {last: Toplevel.state, log: string -> unit} -> unit
    56 type run_action = int -> {pre: Proof.state, post: Toplevel.state option,
    56 type run_action = int -> {pre: Proof.state, post: Toplevel.state option,
    57   timeout: Time.time, log: string -> unit} -> unit
    57   timeout: Time.time, log: string -> unit, pos: Position.T} -> unit
    58 type action = init_action * run_action * done_action
    58 type action = init_action * run_action * done_action
    59 
    59 
    60 structure Actions = TheoryDataFun
    60 structure Actions = TheoryDataFun
    61 (
    61 (
    62   type T = (int * run_action * done_action) list
    62   type T = (int * run_action * done_action) list
    90   (* FIXME: with multithreading and parallel proofs enabled, we might need to
    90   (* FIXME: with multithreading and parallel proofs enabled, we might need to
    91      encapsulate this inside a critical section *)
    91      encapsulate this inside a critical section *)
    92 
    92 
    93 fun log_sep thy = log thy "------------------"
    93 fun log_sep thy = log thy "------------------"
    94 
    94 
    95 fun apply_actions thy info (pre, post, time) actions =
    95 fun apply_actions thy pos info (pre, post, time) actions =
    96   let
    96   let
    97     fun apply f = f {pre=pre, post=post, timeout=time, log=log thy}
    97     fun apply f = f {pre=pre, post=post, timeout=time, log=log thy, pos=pos}
    98     fun run (id, run, _) = (apply (run id); log_sep thy)
    98     fun run (id, run, _) = (apply (run id); log_sep thy)
    99   in (log thy info; log_sep thy; List.app run actions) end
    99   in (log thy info; log_sep thy; List.app run actions) end
   100 
   100 
   101 fun in_range _ _ NONE = true
   101 fun in_range _ _ NONE = true
   102   | in_range l r (SOME i) = (l <= i andalso (r < 0 orelse i <= r))
   102   | in_range l r (SOME i) = (l <= i andalso (r < 0 orelse i <= r))
   116 
   116 
   117     val str0 = string_of_int o the_default 0
   117     val str0 = string_of_int o the_default 0
   118     val loc = str0 (Position.line_of pos) ^ ":" ^ str0 (Position.column_of pos)
   118     val loc = str0 (Position.line_of pos) ^ ":" ^ str0 (Position.column_of pos)
   119     val info = "\n\nat " ^ loc ^ " (" ^ name ^ "):"
   119     val info = "\n\nat " ^ loc ^ " (" ^ name ^ "):"
   120   in
   120   in
   121     only_within_range thy pos (apply_actions thy info st) (Actions.get thy)
   121     only_within_range thy pos (apply_actions thy pos info st) (Actions.get thy)
   122   end
   122   end
   123 
   123 
   124 fun done_actions st =
   124 fun done_actions st =
   125   let
   125   let
   126     val thy = Toplevel.theory_of st
   126     val thy = Toplevel.theory_of st