| author | steckerm | 
| Tue, 02 Sep 2014 16:38:26 +0200 | |
| changeset 58142 | d6a2e3567f95 | 
| parent 58028 | e4250d370657 | 
| child 58634 | 9f10d82e8188 | 
| permissions | -rw-r--r-- | 
| 36062 | 1 | (* Title: HOL/Tools/Sledgehammer/sledgehammer_util.ML | 
| 35963 | 2 | Author: Jasmin Blanchette, TU Muenchen | 
| 3 | ||
| 4 | General-purpose functions used by the Sledgehammer modules. | |
| 5 | *) | |
| 6 | ||
| 7 | signature SLEDGEHAMMER_UTIL = | |
| 8 | sig | |
| 48392 
ca998fa08cd9
added "learn_from_atp" command to MaSh, for patient users
 blanchet parents: 
48383diff
changeset | 9 | val sledgehammerN : string | 
| 50608 | 10 | val log2 : real -> real | 
| 55223 
3c593bad6b31
generalized preplaying infrastructure to store various results for various methods
 blanchet parents: 
55212diff
changeset | 11 |   val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
 | 
| 51181 
d0fa18638478
implement (more) accurate computation of parents
 blanchet parents: 
51010diff
changeset | 12 |   val app_hd : ('a -> 'a) -> 'a list -> 'a list
 | 
| 36142 
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
 blanchet parents: 
36062diff
changeset | 13 | val plural_s : int -> string | 
| 35963 | 14 | val serial_commas : string -> string list -> string list | 
| 38738 
0ce517c1970f
make sure that "undo_ascii_of" is the inverse of "ascii_of", also for non-printable characters -- and avoid those in ``-style facts
 blanchet parents: 
38698diff
changeset | 15 | val simplify_spaces : string -> string | 
| 48656 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 16 |   val with_cleanup : ('a -> unit) -> ('a -> 'b) -> 'a -> 'b
 | 
| 48318 | 17 | val time_mult : real -> Time.time -> Time.time | 
| 35963 | 18 | val parse_bool_option : bool -> string -> string -> bool option | 
| 54816 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 19 | val parse_time : string -> string -> Time.time | 
| 38044 | 20 | val subgoal_count : Proof.state -> int | 
| 38696 
4c6b65d6a135
quote facts whose names collide with a keyword or command name (cf. "subclass" in "Jinja/J/TypeSafe.thy")
 blanchet parents: 
38652diff
changeset | 21 | val reserved_isar_keyword_table : unit -> unit Symtab.table | 
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 22 | val thms_in_proof : int -> (string Symtab.table * string Symtab.table) option -> thm -> | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 23 | string list option | 
| 50267 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 24 | val thms_of_name : Proof.context -> string -> thm list | 
| 50557 | 25 | val one_day : Time.time | 
| 26 | val one_year : Time.time | |
| 50048 | 27 |   val with_vanilla_print_mode : ('a -> 'b) -> 'a -> 'b
 | 
| 53815 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 28 | val hackish_string_of_term : Proof.context -> term -> string | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 29 | val spying : bool -> (unit -> Proof.state * int * string * string) -> unit | 
| 35963 | 30 | end; | 
| 39318 | 31 | |
| 35963 | 32 | structure Sledgehammer_Util : SLEDGEHAMMER_UTIL = | 
| 33 | struct | |
| 34 | ||
| 43085 
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
 blanchet parents: 
43043diff
changeset | 35 | open ATP_Util | 
| 
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
 blanchet parents: 
43043diff
changeset | 36 | |
| 48392 
ca998fa08cd9
added "learn_from_atp" command to MaSh, for patient users
 blanchet parents: 
48383diff
changeset | 37 | val sledgehammerN = "sledgehammer" | 
| 
ca998fa08cd9
added "learn_from_atp" command to MaSh, for patient users
 blanchet parents: 
48383diff
changeset | 38 | |
| 50608 | 39 | val log10_2 = Math.log10 2.0 | 
| 40 | fun log2 n = Math.log10 n / log10_2 | |
| 41 | ||
| 55223 
3c593bad6b31
generalized preplaying infrastructure to store various results for various methods
 blanchet parents: 
55212diff
changeset | 42 | fun map3 xs = Ctr_Sugar_Util.map3 xs | 
| 
3c593bad6b31
generalized preplaying infrastructure to store various results for various methods
 blanchet parents: 
55212diff
changeset | 43 | |
| 51181 
d0fa18638478
implement (more) accurate computation of parents
 blanchet parents: 
51010diff
changeset | 44 | fun app_hd f (x :: xs) = f x :: xs | 
| 
d0fa18638478
implement (more) accurate computation of parents
 blanchet parents: 
51010diff
changeset | 45 | |
| 36142 
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
 blanchet parents: 
36062diff
changeset | 46 | fun plural_s n = if n = 1 then "" else "s" | 
| 36062 | 47 | |
| 43029 
3e060b1c844b
use helpers and tweak Quickcheck's priority to it comes second (to give Solve Direct slightly more time before another prover runs)
 blanchet parents: 
43005diff
changeset | 48 | val serial_commas = Try.serial_commas | 
| 43085 
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
 blanchet parents: 
43043diff
changeset | 49 | val simplify_spaces = strip_spaces false (K true) | 
| 37962 
d7dbe01f48d7
keep track of clause numbers for SPASS now that we generate FOF rather than CNF problems;
 blanchet parents: 
37575diff
changeset | 50 | |
| 48656 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 51 | fun with_cleanup clean_up f x = | 
| 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 52 | Exn.capture f x | 
| 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 53 | |> tap (fn _ => clean_up x) | 
| 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 54 | |> Exn.release | 
| 
5caa414ce9a2
cleaner temporary file cleanup for MaSh, based on tried-and-trusted code
 blanchet parents: 
48392diff
changeset | 55 | |
| 55212 | 56 | fun time_mult k t = Time.fromMilliseconds (Real.ceil (k * Real.fromInt (Time.toMilliseconds t))) | 
| 48318 | 57 | |
| 35963 | 58 | fun parse_bool_option option name s = | 
| 59 | (case s of | |
| 51930 
52fd62618631
prefer explicitly qualified exceptions, which is particular important for robust handlers;
 wenzelm parents: 
51181diff
changeset | 60 | "smart" => if option then NONE else raise Option.Option | 
| 35963 | 61 | | "false" => SOME false | 
| 62 | | "true" => SOME true | |
| 63 | | "" => SOME true | |
| 51930 
52fd62618631
prefer explicitly qualified exceptions, which is particular important for robust handlers;
 wenzelm parents: 
51181diff
changeset | 64 | | _ => raise Option.Option) | 
| 35963 | 65 | handle Option.Option => | 
| 55285 | 66 | let val ss = map quote ((option ? cons "smart") ["true", "false"]) in | 
| 67 |       error ("Parameter " ^ quote name ^ " must be assigned " ^
 | |
| 68 | space_implode " " (serial_commas "or" ss) ^ ".") | |
| 69 | end | |
| 35963 | 70 | |
| 40341 
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
 blanchet parents: 
39890diff
changeset | 71 | val has_junk = | 
| 40627 
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
 wenzelm parents: 
40341diff
changeset | 72 | exists (fn s => not (Symbol.is_digit s) andalso s <> ".") o raw_explode (* FIXME Symbol.explode (?) *) | 
| 40341 
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
 blanchet parents: 
39890diff
changeset | 73 | |
| 54816 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 74 | fun parse_time name s = | 
| 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 75 | let val secs = if has_junk s then NONE else Real.fromString s in | 
| 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 76 | if is_none secs orelse Real.< (the secs, 0.0) then | 
| 55285 | 77 |       error ("Parameter " ^ quote name ^ " must be assigned a nonnegative \number of seconds \
 | 
| 78 | \(e.g., \"60\", \"0.5\") or \"none\".") | |
| 54816 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 79 | else | 
| 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 80 | seconds (the secs) | 
| 
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
 blanchet parents: 
54695diff
changeset | 81 | end | 
| 35963 | 82 | |
| 43029 
3e060b1c844b
use helpers and tweak Quickcheck's priority to it comes second (to give Solve Direct slightly more time before another prover runs)
 blanchet parents: 
43005diff
changeset | 83 | val subgoal_count = Try.subgoal_count | 
| 38044 | 84 | |
| 38696 
4c6b65d6a135
quote facts whose names collide with a keyword or command name (cf. "subclass" in "Jinja/J/TypeSafe.thy")
 blanchet parents: 
38652diff
changeset | 85 | fun reserved_isar_keyword_table () = | 
| 48292 | 86 | Keyword.dest () |-> union (op =) |> map (rpair ()) |> Symtab.make | 
| 38696 
4c6b65d6a135
quote facts whose names collide with a keyword or command name (cf. "subclass" in "Jinja/J/TypeSafe.thy")
 blanchet parents: 
38652diff
changeset | 87 | |
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 88 | exception TOO_MANY of unit | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 89 | |
| 57108 
dc0b4f50e288
more generous max number of suggestions, for more safety
 blanchet parents: 
57055diff
changeset | 90 | (* FIXME: Similar yet different code in "mirabelle.ML". The code here has a few fixes that seem to | 
| 
dc0b4f50e288
more generous max number of suggestions, for more safety
 blanchet parents: 
57055diff
changeset | 91 | be missing over there; or maybe the two code portions are not doing the same? *) | 
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 92 | fun fold_body_thm max_thms outer_name (map_plain_name, map_inclass_name) body = | 
| 48251 
6cdcfbddc077
moved most of MaSh exporter code to Sledgehammer
 blanchet parents: 
46957diff
changeset | 93 | let | 
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 94 | fun app_thm map_name (_, (name, _, body)) (accum as (num_thms, names)) = | 
| 54116 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 95 | let | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 96 | val (anonymous, enter_class) = | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 97 | (* The "name = outer_name" case caters for the uncommon case where the proved theorem | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 98 | occurs in its own proof (e.g., "Transitive_Closure.trancl_into_trancl"). *) | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 99 | if name = "" orelse name = outer_name then (true, false) | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 100 | else if map_inclass_name name = SOME outer_name then (true, true) | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 101 | else (false, false) | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 102 | in | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 103 | if anonymous then | 
| 57756 
92fe49c7ab3b
peek instead of joining -- is perhaps less risky
 blanchet parents: 
57727diff
changeset | 104 | (case Future.peek body of | 
| 
92fe49c7ab3b
peek instead of joining -- is perhaps less risky
 blanchet parents: 
57727diff
changeset | 105 | SOME (Exn.Res the_body) => | 
| 
92fe49c7ab3b
peek instead of joining -- is perhaps less risky
 blanchet parents: 
57727diff
changeset | 106 | app_body (if enter_class then map_inclass_name else map_name) the_body accum | 
| 
92fe49c7ab3b
peek instead of joining -- is perhaps less risky
 blanchet parents: 
57727diff
changeset | 107 | | NONE => accum) | 
| 54116 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 108 | else | 
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 109 | (case map_name name of | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 110 | SOME name' => | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 111 | if member (op =) names name' then accum | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 112 | else if num_thms = max_thms then raise TOO_MANY () | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 113 | else (num_thms + 1, name' :: names) | 
| 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 114 | | NONE => accum) | 
| 54116 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 115 | end | 
| 
ba709c934470
made theorem extraction code not delve too far when looking at local fact, by relying on 'strip_thm' instead of (wrongly) reverse-engineering proof terms
 blanchet parents: 
54062diff
changeset | 116 |     and app_body map_name (PBody {thms, ...}) = fold (app_thm map_name) thms
 | 
| 57108 
dc0b4f50e288
more generous max number of suggestions, for more safety
 blanchet parents: 
57055diff
changeset | 117 | in | 
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 118 | snd (app_body map_plain_name body (0, [])) | 
| 57108 
dc0b4f50e288
more generous max number of suggestions, for more safety
 blanchet parents: 
57055diff
changeset | 119 | end | 
| 48251 
6cdcfbddc077
moved most of MaSh exporter code to Sledgehammer
 blanchet parents: 
46957diff
changeset | 120 | |
| 57306 
ff10067b2248
optimized traversal of proof terms by skipping bad apples (e.g. full_exhaustive_int'.pinduct)
 blanchet parents: 
57108diff
changeset | 121 | fun thms_in_proof max_thms name_tabs th = | 
| 57838 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 122 | (case try Thm.proof_body_of th of | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 123 | NONE => NONE | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 124 | | SOME body => | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 125 | let val map_names = (case name_tabs of SOME p => pairself Symtab.lookup p | NONE => `I SOME) in | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 126 | SOME (fold_body_thm max_thms (Thm.get_name_hint th) map_names (Proofterm.strip_thm body)) | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 127 | handle TOO_MANY () => NONE | 
| 
c21f2c52f54b
careful when calling 'Thm.proof_body_of' -- it can throw exceptions
 blanchet parents: 
57306diff
changeset | 128 | end) | 
| 48251 
6cdcfbddc077
moved most of MaSh exporter code to Sledgehammer
 blanchet parents: 
46957diff
changeset | 129 | |
| 50267 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 130 | fun thms_of_name ctxt name = | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 131 | let | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 132 | val lex = Keyword.get_lexicons | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 133 | val get = maps (Proof_Context.get_fact ctxt o fst) | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 134 | in | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 135 | Source.of_string name | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 136 | |> Symbol.source | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 137 |     |> Token.source {do_recover = SOME false} lex Position.start
 | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 138 | |> Token.source_proper | 
| 58028 
e4250d370657
tuned signature -- define some elementary operations earlier;
 wenzelm parents: 
57882diff
changeset | 139 | |> Source.source Token.stopper (Parse.xthms1 >> get) NONE | 
| 50267 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 140 | |> Source.exhaust | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 141 | end | 
| 
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
 smolkas parents: 
50049diff
changeset | 142 | |
| 50557 | 143 | val one_day = seconds (24.0 * 60.0 * 60.0) | 
| 144 | val one_year = seconds (365.0 * 24.0 * 60.0 * 60.0) | |
| 145 | ||
| 50048 | 146 | fun with_vanilla_print_mode f x = | 
| 54821 | 147 | Print_Mode.setmp (filter (curry (op =) Symbol.xsymbolsN) (print_mode_value ())) f x | 
| 50048 | 148 | |
| 53815 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 149 | fun hackish_string_of_term ctxt = | 
| 57727 
02a53c1bbb6c
generate backquotes without markup, since this confuses preplay; bump up spying version identifier;
 blanchet parents: 
57306diff
changeset | 150 | with_vanilla_print_mode (Syntax.string_of_term ctxt) #> unyxml #> simplify_spaces | 
| 53815 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 151 | |
| 57727 
02a53c1bbb6c
generate backquotes without markup, since this confuses preplay; bump up spying version identifier;
 blanchet parents: 
57306diff
changeset | 152 | val spying_version = "d" | 
| 53815 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 153 | |
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 154 | fun spying false _ = () | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 155 | | spying true f = | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 156 | let | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 157 | val (state, i, tool, message) = f () | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 158 | val ctxt = Proof.context_of state | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 159 | val goal = Logic.get_goal (prop_of (#goal (Proof.goal state))) i | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 160 | val hash = String.substring (SHA1.rep (SHA1.digest (hackish_string_of_term ctxt goal)), 0, 12) | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 161 | in | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 162 | File.append (Path.explode "$ISABELLE_HOME_USER/spy_sledgehammer") | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 163 | (spying_version ^ " " ^ timestamp () ^ ": " ^ hash ^ ": " ^ tool ^ ": " ^ message ^ "\n") | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 164 | end | 
| 
e8aa538e959e
encode goal digest in spying log (to detect duplicates)
 blanchet parents: 
53800diff
changeset | 165 | |
| 35963 | 166 | end; |