src/HOL/Tools/Sledgehammer/sledgehammer_util.ML
changeset 52615 1e930ee99b0c
parent 52556 c8357085217c
child 52628 94fbc50a6757
equal deleted inserted replaced
52614:3046da935eae 52615:1e930ee99b0c
     1 (*  Title:      HOL/Tools/Sledgehammer/sledgehammer_util.ML
     1 (*  Title:      HOL/Tools/Sledgehammer/sledgehammer_util.ML
     2     Author:     Jasmin Blanchette, TU Muenchen
     2     Author:     Jasmin Blanchette, TU Muenchen
     3 
     3 
     4 General-purpose functions used by the Sledgehammer modules.
     4 General-purpose functions used by the Sledgehammer modules.
     5 *)
     5 *)
       
     6 
       
     7 infix 1 |>! #>!
     6 
     8 
     7 signature SLEDGEHAMMER_UTIL =
     9 signature SLEDGEHAMMER_UTIL =
     8 sig
    10 sig
     9   val sledgehammerN : string
    11   val sledgehammerN : string
    10   val log2 : real -> real
    12   val log2 : real -> real
    29 
    31 
    30   (** extrema **)
    32   (** extrema **)
    31   val max : ('a * 'a -> order) -> 'a -> 'a -> 'a
    33   val max : ('a * 'a -> order) -> 'a -> 'a -> 'a
    32   val max_option : ('a * 'a -> order) -> 'a option -> 'a option -> 'a option
    34   val max_option : ('a * 'a -> order) -> 'a option -> 'a option -> 'a option
    33   val max_list : ('a * 'a -> order) -> 'a list -> 'a option
    35   val max_list : ('a * 'a -> order) -> 'a list -> 'a option
       
    36 
       
    37   (** debugging **)
       
    38   val print_timing : ('a -> 'b) -> 'a -> 'b
       
    39   (* infix versions of print_timing; meant to replace '|>' and '#>' *)
       
    40   val |>! : 'a * ('a -> 'b) -> 'b
       
    41   val #>! : ('a -> 'b) * ('b -> 'c) -> 'a -> 'c
    34 end;
    42 end;
    35 
    43 
    36 structure Sledgehammer_Util : SLEDGEHAMMER_UTIL =
    44 structure Sledgehammer_Util : SLEDGEHAMMER_UTIL =
    37 struct
    45 struct
    38 
    46 
   163 
   171 
   164 fun max_option ord = max (option_ord ord)
   172 fun max_option ord = max (option_ord ord)
   165 
   173 
   166 fun max_list ord xs = fold (SOME #> max_option ord) xs NONE
   174 fun max_list ord xs = fold (SOME #> max_option ord) xs NONE
   167 
   175 
       
   176 (** debugging **)
       
   177 fun print_timing f x =
       
   178   Timing.timing f x
       
   179   |>> Timing.message
       
   180   |>> warning
       
   181   |> snd
       
   182 
       
   183 fun x |>! f = print_timing f x
       
   184 fun (f #>! g) x = x |> f |>! g
       
   185 
   168 end;
   186 end;