author | wenzelm |
Fri, 13 May 2011 23:58:40 +0200 | |
changeset 42795 | 66fcc9882784 |
parent 42697 | 9bc5dc48f1a5 |
child 43029 | 3e060b1c844b |
permissions | -rw-r--r-- |
33982 | 1 |
(* Title: HOL/Tools/Nitpick/nitpick_util.ML |
33192 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
34982
7b8c366e34a2
added support for nonstandard models to Nitpick (based on an idea by Koen Claessen) and did other fixes to Nitpick
blanchet
parents:
34936
diff
changeset
|
3 |
Copyright 2008, 2009, 2010 |
33192 | 4 |
|
5 |
General-purpose functions used by the Nitpick modules. |
|
6 |
*) |
|
7 |
||
33705
947184dc75c9
removed a few global names in Nitpick (styp, nat_less, pairf)
blanchet
parents:
33232
diff
changeset
|
8 |
signature NITPICK_UTIL = |
33192 | 9 |
sig |
10 |
type styp = string * typ |
|
11 |
datatype polarity = Pos | Neg | Neut |
|
12 |
||
13 |
exception ARG of string * string |
|
14 |
exception BAD of string * string |
|
34124
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
15 |
exception TOO_SMALL of string * string |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
16 |
exception TOO_LARGE of string * string |
33192 | 17 |
exception NOT_SUPPORTED of string |
18 |
exception SAME of unit |
|
19 |
||
20 |
val nitpick_prefix : string |
|
21 |
val curry3 : ('a * 'b * 'c -> 'd) -> 'a -> 'b -> 'c -> 'd |
|
33705
947184dc75c9
removed a few global names in Nitpick (styp, nat_less, pairf)
blanchet
parents:
33232
diff
changeset
|
22 |
val pairf : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c |
35385
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
23 |
val pair_from_fun : (bool -> 'a) -> 'a * 'a |
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
24 |
val fun_from_pair : 'a * 'a -> bool -> 'a |
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
25 |
val int_from_bool : bool -> int |
33705
947184dc75c9
removed a few global names in Nitpick (styp, nat_less, pairf)
blanchet
parents:
33232
diff
changeset
|
26 |
val nat_minus : int -> int -> int |
33192 | 27 |
val reasonable_power : int -> int -> int |
28 |
val exact_log : int -> int -> int |
|
29 |
val exact_root : int -> int -> int |
|
30 |
val offset_list : int list -> int list |
|
31 |
val index_seq : int -> int -> int list |
|
32 |
val filter_indices : int list -> 'a list -> 'a list |
|
33 |
val filter_out_indices : int list -> 'a list -> 'a list |
|
34 |
val fold1 : ('a -> 'a -> 'a) -> 'a list -> 'a |
|
35 |
val replicate_list : int -> 'a list -> 'a list |
|
36 |
val n_fold_cartesian_product : 'a list list -> 'a list list |
|
37 |
val all_distinct_unordered_pairs_of : ''a list -> (''a * ''a) list |
|
38 |
val nth_combination : (int * int) list -> int -> int list |
|
39 |
val all_combinations : (int * int) list -> int list list |
|
40 |
val all_permutations : 'a list -> 'a list list |
|
41 |
val batch_list : int -> 'a list -> 'a list list |
|
42 |
val chunk_list_unevenly : int list -> 'a list -> 'a list list |
|
43 |
val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list |
|
44 |
val double_lookup : |
|
45 |
('a * 'a -> bool) -> ('a option * 'b) list -> 'a -> 'b option |
|
46 |
val triple_lookup : |
|
47 |
(''a * ''a -> bool) -> (''a option * 'b) list -> ''a -> 'b option |
|
48 |
val is_substring_of : string -> string -> bool |
|
49 |
val plural_s : int -> string |
|
50 |
val plural_s_for_list : 'a list -> string |
|
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
51 |
val serial_commas : string -> string list -> string list |
38188 | 52 |
val pretty_serial_commas : string -> Pretty.T list -> Pretty.T list |
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
53 |
val parse_bool_option : bool -> string -> string -> bool option |
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
54 |
val parse_time_option : string -> string -> Time.time option |
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
39134
diff
changeset
|
55 |
val string_from_time : Time.time -> string |
38652
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
56 |
val nat_subscript : int -> string |
33192 | 57 |
val flip_polarity : polarity -> polarity |
58 |
val prop_T : typ |
|
59 |
val bool_T : typ |
|
60 |
val nat_T : typ |
|
61 |
val int_T : typ |
|
37260
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
62 |
val simple_string_of_typ : typ -> string |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
63 |
val is_real_constr : theory -> string * typ -> bool |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
64 |
val typ_of_dtyp : |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
65 |
Datatype_Aux.descr -> (Datatype_Aux.dtyp * typ) list -> Datatype_Aux.dtyp |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
66 |
-> typ |
42697 | 67 |
val varify_type : Proof.context -> typ -> typ |
68 |
val instantiate_type : theory -> typ -> typ -> typ -> typ |
|
69 |
val varify_and_instantiate_type : Proof.context -> typ -> typ -> typ -> typ |
|
37260
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
70 |
val is_of_class_const : theory -> string * typ -> bool |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
71 |
val get_class_def : theory -> string -> (string * term) option |
36555
8ff45c2076da
expand combinators in Isar proofs constructed by Sledgehammer;
blanchet
parents:
36483
diff
changeset
|
72 |
val monomorphic_term : Type.tyenv -> term -> term |
37260
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
73 |
val specialize_type : theory -> string * typ -> term -> term |
38652
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
74 |
val eta_expand : typ list -> term -> int -> term |
33192 | 75 |
val time_limit : Time.time option -> ('a -> 'b) -> 'a -> 'b |
76 |
val DETERM_TIMEOUT : Time.time option -> tactic -> tactic |
|
39118
12f3788be67b
turned show_all_types into proper configuration option;
wenzelm
parents:
38652
diff
changeset
|
77 |
val set_show_all_types : Proof.context -> Proof.context |
33192 | 78 |
val indent_size : int |
79 |
val pstrs : string -> Pretty.T list |
|
34982
7b8c366e34a2
added support for nonstandard models to Nitpick (based on an idea by Koen Claessen) and did other fixes to Nitpick
blanchet
parents:
34936
diff
changeset
|
80 |
val unyxml : string -> string |
38188 | 81 |
val pretty_maybe_quote : Pretty.T -> Pretty.T |
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
82 |
val hashw : word * word -> word |
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
83 |
val hashw_string : string * word -> word |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35807
diff
changeset
|
84 |
end; |
33192 | 85 |
|
33232
f93390060bbe
internal renaming in Nitpick and fixed Kodkodi invokation on Linux;
blanchet
parents:
33192
diff
changeset
|
86 |
structure Nitpick_Util : NITPICK_UTIL = |
33192 | 87 |
struct |
88 |
||
89 |
type styp = string * typ |
|
90 |
||
91 |
datatype polarity = Pos | Neg | Neut |
|
92 |
||
93 |
exception ARG of string * string |
|
94 |
exception BAD of string * string |
|
34124
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
95 |
exception TOO_SMALL of string * string |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
96 |
exception TOO_LARGE of string * string |
33192 | 97 |
exception NOT_SUPPORTED of string |
98 |
exception SAME of unit |
|
99 |
||
100 |
val nitpick_prefix = "Nitpick." |
|
101 |
||
102 |
fun curry3 f = fn x => fn y => fn z => f (x, y, z) |
|
103 |
||
33705
947184dc75c9
removed a few global names in Nitpick (styp, nat_less, pairf)
blanchet
parents:
33232
diff
changeset
|
104 |
fun pairf f g x = (f x, g x) |
33192 | 105 |
|
35385
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
106 |
fun pair_from_fun f = (f false, f true) |
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
107 |
fun fun_from_pair (f, t) b = if b then t else f |
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
108 |
|
29f81babefd7
improved precision of infinite "shallow" datatypes in Nitpick;
blanchet
parents:
35280
diff
changeset
|
109 |
fun int_from_bool b = if b then 1 else 0 |
33705
947184dc75c9
removed a few global names in Nitpick (styp, nat_less, pairf)
blanchet
parents:
33232
diff
changeset
|
110 |
fun nat_minus i j = if i > j then i - j else 0 |
33192 | 111 |
|
112 |
val max_exponent = 16384 |
|
113 |
||
35280
54ab4921f826
fixed a few bugs in Nitpick and removed unreferenced variables
blanchet
parents:
35220
diff
changeset
|
114 |
fun reasonable_power _ 0 = 1 |
33192 | 115 |
| reasonable_power a 1 = a |
116 |
| reasonable_power 0 _ = 0 |
|
117 |
| reasonable_power 1 _ = 1 |
|
118 |
| reasonable_power a b = |
|
34124
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
119 |
if b < 0 then |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
120 |
raise ARG ("Nitpick_Util.reasonable_power", |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
121 |
"negative exponent (" ^ signed_string_of_int b ^ ")") |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
122 |
else if b > max_exponent then |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
123 |
raise TOO_LARGE ("Nitpick_Util.reasonable_power", |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
124 |
"too large exponent (" ^ signed_string_of_int b ^ ")") |
33192 | 125 |
else |
34124
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
126 |
let val c = reasonable_power a (b div 2) in |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
127 |
c * c * reasonable_power a (b mod 2) |
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
34039
diff
changeset
|
128 |
end |
33192 | 129 |
|
130 |
fun exact_log m n = |
|
131 |
let |
|
132 |
val r = Math.ln (Real.fromInt n) / Math.ln (Real.fromInt m) |> Real.round |
|
133 |
in |
|
134 |
if reasonable_power m r = n then |
|
135 |
r |
|
136 |
else |
|
33232
f93390060bbe
internal renaming in Nitpick and fixed Kodkodi invokation on Linux;
blanchet
parents:
33192
diff
changeset
|
137 |
raise ARG ("Nitpick_Util.exact_log", |
33192 | 138 |
commas (map signed_string_of_int [m, n])) |
139 |
end |
|
140 |
||
141 |
fun exact_root m n = |
|
142 |
let val r = Math.pow (Real.fromInt n, 1.0 / (Real.fromInt m)) |> Real.round in |
|
143 |
if reasonable_power r m = n then |
|
144 |
r |
|
145 |
else |
|
33232
f93390060bbe
internal renaming in Nitpick and fixed Kodkodi invokation on Linux;
blanchet
parents:
33192
diff
changeset
|
146 |
raise ARG ("Nitpick_Util.exact_root", |
33192 | 147 |
commas (map signed_string_of_int [m, n])) |
148 |
end |
|
149 |
||
150 |
fun fold1 f = foldl1 (uncurry f) |
|
151 |
||
152 |
fun replicate_list 0 _ = [] |
|
153 |
| replicate_list n xs = xs @ replicate_list (n - 1) xs |
|
154 |
||
155 |
fun offset_list ns = rev (tl (fold (fn x => fn xs => (x + hd xs) :: xs) ns [0])) |
|
156 |
fun index_seq j0 n = if j0 < 0 then j0 downto j0 - n + 1 else j0 upto j0 + n - 1 |
|
157 |
||
158 |
fun filter_indices js xs = |
|
159 |
let |
|
160 |
fun aux _ [] _ = [] |
|
161 |
| aux i (j :: js) (x :: xs) = |
|
162 |
if i = j then x :: aux (i + 1) js xs else aux (i + 1) (j :: js) xs |
|
33232
f93390060bbe
internal renaming in Nitpick and fixed Kodkodi invokation on Linux;
blanchet
parents:
33192
diff
changeset
|
163 |
| aux _ _ _ = raise ARG ("Nitpick_Util.filter_indices", |
33192 | 164 |
"indices unordered or out of range") |
165 |
in aux 0 js xs end |
|
166 |
fun filter_out_indices js xs = |
|
167 |
let |
|
168 |
fun aux _ [] xs = xs |
|
169 |
| aux i (j :: js) (x :: xs) = |
|
170 |
if i = j then aux (i + 1) js xs else x :: aux (i + 1) (j :: js) xs |
|
33232
f93390060bbe
internal renaming in Nitpick and fixed Kodkodi invokation on Linux;
blanchet
parents:
33192
diff
changeset
|
171 |
| aux _ _ _ = raise ARG ("Nitpick_Util.filter_out_indices", |
33192 | 172 |
"indices unordered or out of range") |
173 |
in aux 0 js xs end |
|
174 |
||
175 |
fun cartesian_product [] _ = [] |
|
176 |
| cartesian_product (x :: xs) yss = |
|
177 |
map (cons x) yss @ cartesian_product xs yss |
|
178 |
fun n_fold_cartesian_product xss = fold_rev cartesian_product xss [[]] |
|
179 |
fun all_distinct_unordered_pairs_of [] = [] |
|
180 |
| all_distinct_unordered_pairs_of (x :: xs) = |
|
181 |
map (pair x) xs @ all_distinct_unordered_pairs_of xs |
|
182 |
||
183 |
val nth_combination = |
|
184 |
let |
|
185 |
fun aux [] n = ([], n) |
|
186 |
| aux ((k, j0) :: xs) n = |
|
187 |
let val (js, n) = aux xs n in ((n mod k) + j0 :: js, n div k) end |
|
188 |
in fst oo aux end |
|
189 |
||
190 |
val all_combinations = n_fold_cartesian_product o map (uncurry index_seq o swap) |
|
191 |
||
192 |
fun all_permutations [] = [[]] |
|
193 |
| all_permutations xs = |
|
194 |
maps (fn j => map (cons (nth xs j)) (all_permutations (nth_drop j xs))) |
|
195 |
(index_seq 0 (length xs)) |
|
196 |
||
197 |
fun batch_list _ [] = [] |
|
198 |
| batch_list k xs = |
|
199 |
if length xs <= k then [xs] |
|
200 |
else List.take (xs, k) :: batch_list k (List.drop (xs, k)) |
|
201 |
||
202 |
fun chunk_list_unevenly _ [] = [] |
|
203 |
| chunk_list_unevenly [] ys = map single ys |
|
204 |
| chunk_list_unevenly (k :: ks) ys = |
|
205 |
let val (ys1, ys2) = chop k ys in ys1 :: chunk_list_unevenly ks ys2 end |
|
206 |
||
207 |
fun map3 _ [] [] [] = [] |
|
208 |
| map3 f (x :: xs) (y :: ys) (z :: zs) = f x y z :: map3 f xs ys zs |
|
40722
441260986b63
make two copies (!) of Library.UnequalLengths coincide with ListPair.UnequalLengths;
wenzelm
parents:
40627
diff
changeset
|
209 |
| map3 _ _ _ _ = raise ListPair.UnequalLengths |
33192 | 210 |
|
211 |
fun double_lookup eq ps key = |
|
212 |
case AList.lookup (fn (SOME x, SOME y) => eq (x, y) | _ => false) ps |
|
213 |
(SOME key) of |
|
214 |
SOME z => SOME z |
|
215 |
| NONE => ps |> find_first (is_none o fst) |> Option.map snd |
|
35220
2bcdae5f4fdb
added support for nonstandard "nat"s to Nitpick and fixed bugs in binary "nat"s and "int"s
blanchet
parents:
34982
diff
changeset
|
216 |
fun triple_lookup _ [(NONE, z)] _ = SOME z |
2bcdae5f4fdb
added support for nonstandard "nat"s to Nitpick and fixed bugs in binary "nat"s and "int"s
blanchet
parents:
34982
diff
changeset
|
217 |
| triple_lookup eq ps key = |
2bcdae5f4fdb
added support for nonstandard "nat"s to Nitpick and fixed bugs in binary "nat"s and "int"s
blanchet
parents:
34982
diff
changeset
|
218 |
case AList.lookup (op =) ps (SOME key) of |
2bcdae5f4fdb
added support for nonstandard "nat"s to Nitpick and fixed bugs in binary "nat"s and "int"s
blanchet
parents:
34982
diff
changeset
|
219 |
SOME z => SOME z |
2bcdae5f4fdb
added support for nonstandard "nat"s to Nitpick and fixed bugs in binary "nat"s and "int"s
blanchet
parents:
34982
diff
changeset
|
220 |
| NONE => double_lookup eq ps key |
33192 | 221 |
|
222 |
fun is_substring_of needle stack = |
|
223 |
not (Substring.isEmpty (snd (Substring.position needle |
|
224 |
(Substring.full stack)))) |
|
225 |
||
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
226 |
val plural_s = Sledgehammer_Util.plural_s |
33192 | 227 |
fun plural_s_for_list xs = plural_s (length xs) |
228 |
||
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
229 |
val serial_commas = Sledgehammer_Util.serial_commas |
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
230 |
|
38188 | 231 |
fun pretty_serial_commas _ [] = [] |
232 |
| pretty_serial_commas _ [p] = [p] |
|
233 |
| pretty_serial_commas conj [p1, p2] = |
|
234 |
[p1, Pretty.brk 1, Pretty.str conj, Pretty.brk 1, p2] |
|
235 |
| pretty_serial_commas conj [p1, p2, p3] = |
|
236 |
[p1, Pretty.str ",", Pretty.brk 1, p2, Pretty.str ",", Pretty.brk 1, |
|
237 |
Pretty.str conj, Pretty.brk 1, p3] |
|
238 |
| pretty_serial_commas conj (p :: ps) = |
|
239 |
p :: Pretty.str "," :: Pretty.brk 1 :: pretty_serial_commas conj ps |
|
240 |
||
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
241 |
val parse_bool_option = Sledgehammer_Util.parse_bool_option |
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
242 |
val parse_time_option = Sledgehammer_Util.parse_time_option |
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
39134
diff
changeset
|
243 |
val string_from_time = Sledgehammer_Util.string_from_time |
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
244 |
|
40627
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
wenzelm
parents:
40341
diff
changeset
|
245 |
val i_subscript = implode o map (prefix "\<^isub>") o raw_explode (* FIXME Symbol.explode (?) *) |
38652
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
246 |
fun be_subscript s = "\<^bsub>" ^ s ^ "\<^esub>" |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
247 |
fun nat_subscript n = |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
248 |
let val s = signed_string_of_int n in |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
249 |
if print_mode_active Symbol.xsymbolsN then |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
250 |
(* cheap trick to ensure proper alphanumeric ordering for one- and |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
251 |
two-digit numbers *) |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
252 |
(if n <= 9 then be_subscript else i_subscript) s |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
253 |
else |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
254 |
s |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
255 |
end |
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
256 |
|
33192 | 257 |
fun flip_polarity Pos = Neg |
258 |
| flip_polarity Neg = Pos |
|
259 |
| flip_polarity Neut = Neut |
|
260 |
||
261 |
val prop_T = @{typ prop} |
|
262 |
val bool_T = @{typ bool} |
|
263 |
val nat_T = @{typ nat} |
|
264 |
val int_T = @{typ int} |
|
265 |
||
37260
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
266 |
val simple_string_of_typ = Refute.string_of_typ |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
267 |
val is_real_constr = Refute.is_IDT_constructor |
42680 | 268 |
val typ_of_dtyp = Sledgehammer_Util.typ_of_dtyp |
42697 | 269 |
val varify_type = Sledgehammer_Util.varify_type |
270 |
val instantiate_type = Sledgehammer_Util.instantiate_type |
|
271 |
val varify_and_instantiate_type = Sledgehammer_Util.varify_and_instantiate_type |
|
37260
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
272 |
val is_of_class_const = Refute.is_const_of_class |
dde817e6dfb1
added "atoms" option to Nitpick (request from Karlsruhe) + wrap Refute. functions to "nitpick_util.ML"
blanchet
parents:
36555
diff
changeset
|
273 |
val get_class_def = Refute.get_classdef |
36555
8ff45c2076da
expand combinators in Isar proofs constructed by Sledgehammer;
blanchet
parents:
36483
diff
changeset
|
274 |
val monomorphic_term = Sledgehammer_Util.monomorphic_term |
8ff45c2076da
expand combinators in Isar proofs constructed by Sledgehammer;
blanchet
parents:
36483
diff
changeset
|
275 |
val specialize_type = Sledgehammer_Util.specialize_type |
38652
e063be321438
perform eta-expansion of quantifier bodies in Sledgehammer translation when needed + transform elim rules later;
blanchet
parents:
38240
diff
changeset
|
276 |
val eta_expand = Sledgehammer_Util.eta_expand |
33192 | 277 |
|
34039
1fba360b5443
made Nitpick work also for people who import "Plain" instead of "Main"
blanchet
parents:
33982
diff
changeset
|
278 |
fun time_limit NONE = I |
1fba360b5443
made Nitpick work also for people who import "Plain" instead of "Main"
blanchet
parents:
33982
diff
changeset
|
279 |
| time_limit (SOME delay) = TimeLimit.timeLimit delay |
33192 | 280 |
|
281 |
fun DETERM_TIMEOUT delay tac st = |
|
282 |
Seq.of_list (the_list (time_limit delay (fn () => SINGLE tac st) ())) |
|
283 |
||
39118
12f3788be67b
turned show_all_types into proper configuration option;
wenzelm
parents:
38652
diff
changeset
|
284 |
fun set_show_all_types ctxt = |
12f3788be67b
turned show_all_types into proper configuration option;
wenzelm
parents:
38652
diff
changeset
|
285 |
Config.put show_all_types |
39134
917b4b6ba3d2
turned show_sorts/show_types into proper configuration options;
wenzelm
parents:
39118
diff
changeset
|
286 |
(Config.get ctxt show_types orelse Config.get ctxt show_sorts |
917b4b6ba3d2
turned show_sorts/show_types into proper configuration options;
wenzelm
parents:
39118
diff
changeset
|
287 |
orelse Config.get ctxt show_all_types) ctxt |
33192 | 288 |
|
289 |
val indent_size = 2 |
|
290 |
||
291 |
val pstrs = Pretty.breaks o map Pretty.str o space_explode " " |
|
292 |
||
36483
db71041b596b
remove Nitpick functions that are now implemented in Sledgehammer
blanchet
parents:
36385
diff
changeset
|
293 |
val unyxml = Sledgehammer_Util.unyxml |
38188 | 294 |
|
36483
db71041b596b
remove Nitpick functions that are now implemented in Sledgehammer
blanchet
parents:
36385
diff
changeset
|
295 |
val maybe_quote = Sledgehammer_Util.maybe_quote |
38188 | 296 |
fun pretty_maybe_quote pretty = |
297 |
let val s = Pretty.str_of pretty in |
|
298 |
if maybe_quote s = s then pretty else Pretty.enum "" "\"" "\"" [pretty] |
|
299 |
end |
|
33192 | 300 |
|
42567
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
40722
diff
changeset
|
301 |
val hashw = ATP_Problem.hashw |
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
40722
diff
changeset
|
302 |
val hashw_string = ATP_Problem.hashw_string |
36380
1e8fcaccb3e8
stop referring to Sledgehammer_Util stuff all over Nitpick code; instead, redeclare any needed function in Nitpick_Util as synonym for the Sledgehammer_Util function of the same name
blanchet
parents:
35964
diff
changeset
|
303 |
|
33192 | 304 |
end; |