src/HOL/Tools/Sledgehammer/sledgehammer_util.ML
changeset 36062 194cb6e3c13f
parent 35963 943e2582dc87
child 36142 f5e15e9aae10
     1.1 --- a/src/HOL/Tools/Sledgehammer/sledgehammer_util.ML	Mon Mar 29 15:26:19 2010 +0200
     1.2 +++ b/src/HOL/Tools/Sledgehammer/sledgehammer_util.ML	Mon Mar 29 15:50:18 2010 +0200
     1.3 @@ -1,4 +1,4 @@
     1.4 -(*  Title:      HOL/Sledgehammer/sledgehammer_util.ML
     1.5 +(*  Title:      HOL/Tools/Sledgehammer/sledgehammer_util.ML
     1.6      Author:     Jasmin Blanchette, TU Muenchen
     1.7  
     1.8  General-purpose functions used by the Sledgehammer modules.
     1.9 @@ -9,11 +9,21 @@
    1.10    val serial_commas : string -> string list -> string list
    1.11    val parse_bool_option : bool -> string -> string -> bool option
    1.12    val parse_time_option : string -> string -> Time.time option
    1.13 +  val hashw : word * word -> word
    1.14 +  val hashw_char : Char.char * word -> word
    1.15 +  val hashw_string : string * word -> word
    1.16  end;
    1.17  
    1.18  structure Sledgehammer_Util : SLEDGEHAMMER_UTIL =
    1.19  struct
    1.20  
    1.21 +(* This hash function is recommended in Compilers: Principles, Techniques, and
    1.22 +   Tools, by Aho, Sethi and Ullman. The hashpjw function, which they
    1.23 +   particularly recommend, triggers a bug in versions of Poly/ML up to 4.2.0. *)
    1.24 +fun hashw (u, w) = Word.+ (u, Word.* (0w65599, w))
    1.25 +fun hashw_char (c, w) = hashw (Word.fromInt (Char.ord c), w)
    1.26 +fun hashw_string (s:string, w) = CharVector.foldl hashw_char w s
    1.27 +
    1.28  fun serial_commas _ [] = ["??"]
    1.29    | serial_commas _ [s] = [s]
    1.30    | serial_commas conj [s1, s2] = [s1, conj, s2]