author | clasohm |
Fri, 01 Sep 1995 13:28:54 +0200 | |
changeset 1242 | b3f68a644380 |
parent 1236 | b54d51df9065 |
child 1244 | 3d408455d69f |
permissions | -rw-r--r-- |
391 | 1 |
(* Title: Pure/Thy/thy_read.ML |
2 |
ID: $Id$ |
|
559 | 3 |
Author: Carsten Clasohm and Markus Wenzel and Sonia Mahjoub and |
4 |
Tobias Nipkow and L C Paulson |
|
5 |
Copyright 1994 TU Muenchen |
|
391 | 6 |
|
1242 | 7 |
Functions for reading theory files, and storing and retrieving theories, |
8 |
theorems and the global simplifier set. |
|
391 | 9 |
*) |
10 |
||
1157 | 11 |
(*Type for theory storage*) |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
12 |
datatype thy_info = ThyInfo of {path: string, |
391 | 13 |
children: string list, |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
14 |
thy_time: string option, |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
15 |
ml_time: string option, |
559 | 16 |
theory: theory option, |
1242 | 17 |
thms: thm Symtab.table, |
18 |
thy_simps: thm list, ml_simps: thm list}; |
|
1157 | 19 |
(*meaning of special values: |
20 |
thy_time, ml_time = None theory file has not been read yet |
|
21 |
= Some "" theory was read but has either been marked |
|
22 |
as outdated or there is no such file for |
|
23 |
this theory (see e.g. 'virtual' theories |
|
24 |
like Pure or theories without a ML file) |
|
25 |
theory = None theory has not been read yet |
|
26 |
*) |
|
391 | 27 |
|
412 | 28 |
signature READTHY = |
391 | 29 |
sig |
30 |
datatype basetype = Thy of string |
|
31 |
| File of string |
|
32 |
||
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
33 |
val loaded_thys : thy_info Symtab.table ref |
391 | 34 |
val loadpath : string list ref |
35 |
val delete_tmpfiles: bool ref |
|
36 |
||
37 |
val use_thy : string -> unit |
|
38 |
val update : unit -> unit |
|
39 |
val time_use_thy : string -> unit |
|
40 |
val unlink_thy : string -> unit |
|
586
201e115d8031
renamed base_on into mk_base and moved it to the beginning of the generated
clasohm
parents:
559
diff
changeset
|
41 |
val mk_base : basetype list -> string -> bool -> theory |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
42 |
val store_theory : theory * string -> unit |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
43 |
|
559 | 44 |
val theory_of_sign: Sign.sg -> theory |
45 |
val theory_of_thm: thm -> theory |
|
46 |
val store_thm: string * thm -> thm |
|
758 | 47 |
val bind_thm: string * thm -> unit |
559 | 48 |
val qed: string -> unit |
758 | 49 |
val qed_thm: thm ref |
746 | 50 |
val qed_goal: string -> theory -> string -> (thm list -> tactic list) -> unit |
51 |
val qed_goalw: string -> theory->thm list->string->(thm list->tactic list) |
|
52 |
-> unit |
|
559 | 53 |
val get_thm: theory -> string -> thm |
54 |
val thms_of: theory -> (string * thm) list |
|
778 | 55 |
val print_theory: theory -> unit |
391 | 56 |
end; |
57 |
||
58 |
||
1242 | 59 |
functor ReadthyFUN(structure ThySyn: THY_SYN and ThmDB: THMDB |
60 |
and Simplifier: SIMPLIFIER): READTHY = |
|
391 | 61 |
struct |
1242 | 62 |
|
63 |
open ThmDB Simplifier; |
|
391 | 64 |
|
65 |
datatype basetype = Thy of string |
|
66 |
| File of string; |
|
67 |
||
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
68 |
val loaded_thys = ref (Symtab.make [("ProtoPure", |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
69 |
ThyInfo {path = "", |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
70 |
children = ["Pure", "CPure"], |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
71 |
thy_time = Some "", ml_time = Some "", |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
72 |
theory = Some proto_pure_thy, |
1242 | 73 |
thms = Symtab.null, |
74 |
thy_simps = [], ml_simps = []}), |
|
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
75 |
("Pure", ThyInfo {path = "", children = [], |
559 | 76 |
thy_time = Some "", ml_time = Some "", |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
77 |
theory = Some pure_thy, |
1242 | 78 |
thms = Symtab.null, |
79 |
thy_simps = [], ml_simps = []}), |
|
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
80 |
("CPure", ThyInfo {path = "", |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
81 |
children = [], |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
82 |
thy_time = Some "", ml_time = Some "", |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
83 |
theory = Some cpure_thy, |
1242 | 84 |
thms = Symtab.null, |
85 |
thy_simps = [], ml_simps = []})]); |
|
391 | 86 |
|
87 |
val loadpath = ref ["."]; (*default search path for theory files *) |
|
88 |
||
89 |
val delete_tmpfiles = ref true; (*remove temporary files after use *) |
|
90 |
||
91 |
(*Make name of the output ML file for a theory *) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
92 |
fun out_name tname = "." ^ tname ^ ".thy.ML"; |
391 | 93 |
|
94 |
(*Read a file specified by thy_file containing theory thy *) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
95 |
fun read_thy tname thy_file = |
559 | 96 |
let |
391 | 97 |
val instream = open_in thy_file; |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
98 |
val outstream = open_out (out_name tname); |
559 | 99 |
in |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
100 |
output (outstream, ThySyn.parse tname (input (instream, 999999))); |
391 | 101 |
close_out outstream; |
102 |
close_in instream |
|
103 |
end; |
|
104 |
||
105 |
fun file_exists file = |
|
106 |
let val instream = open_in file in close_in instream; true end |
|
107 |
handle Io _ => false; |
|
108 |
||
109 |
(*Get thy_info for a loaded theory *) |
|
559 | 110 |
fun get_thyinfo tname = Symtab.lookup (!loaded_thys, tname); |
391 | 111 |
|
971
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
112 |
(*Check if a theory was completly loaded *) |
391 | 113 |
fun already_loaded thy = |
114 |
let val t = get_thyinfo thy |
|
115 |
in if is_none t then false |
|
971
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
116 |
else let val ThyInfo {thy_time, ml_time, ...} = the t |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
117 |
in is_some thy_time andalso is_some ml_time end |
391 | 118 |
end; |
119 |
||
120 |
(*Check if a theory file has changed since its last use. |
|
121 |
Return a pair of boolean values for .thy and for .ML *) |
|
559 | 122 |
fun thy_unchanged thy thy_file ml_file = |
1098
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
123 |
case get_thyinfo thy of |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
124 |
Some (ThyInfo {thy_time, ml_time, ...}) => |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
125 |
let val tn = is_none thy_time; |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
126 |
val mn = is_none ml_time |
391 | 127 |
in if not tn andalso not mn then |
1098
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
128 |
((file_info thy_file = the thy_time), |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
129 |
(file_info ml_file = the ml_time)) |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
130 |
else if not tn andalso mn then |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
131 |
(file_info thy_file = the thy_time, false) |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
132 |
else |
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
133 |
(false, false) |
391 | 134 |
end |
1098
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
135 |
| None => (false, false) |
391 | 136 |
|
1242 | 137 |
(*Get list of simplifiers defined in .thy and .ML file*) |
138 |
fun get_simps tname = |
|
139 |
case get_thyinfo tname of |
|
140 |
Some (ThyInfo {thy_simps, ml_simps, ...}) => (thy_simps, ml_simps) |
|
141 |
| None => ([], []); |
|
142 |
||
143 |
(*Get all direct ancestors of a theory*) |
|
144 |
fun get_parents child = |
|
145 |
let fun has_child (tname, ThyInfo {children, theory, ...}) = |
|
146 |
if child mem children then Some tname else None; |
|
147 |
in mapfilter has_child (Symtab.dest (!loaded_thys)) end; |
|
148 |
||
149 |
(*Get theory object for a loaded theory *) |
|
150 |
fun get_theory name = |
|
151 |
let val ThyInfo {theory, ...} = the (get_thyinfo name) |
|
152 |
in the theory end; |
|
153 |
||
391 | 154 |
exception FILE_NOT_FOUND; (*raised by find_file *) |
155 |
||
156 |
(*Find a file using a list of paths if no absolute or relative path is |
|
157 |
specified.*) |
|
158 |
fun find_file "" name = |
|
159 |
let fun find_it (curr :: paths) = |
|
160 |
if file_exists (tack_on curr name) then |
|
161 |
tack_on curr name |
|
559 | 162 |
else |
391 | 163 |
find_it paths |
164 |
| find_it [] = "" |
|
165 |
in find_it (!loadpath) end |
|
166 |
| find_file path name = |
|
167 |
if file_exists (tack_on path name) then tack_on path name |
|
168 |
else ""; |
|
169 |
||
170 |
(*Get absolute pathnames for a new or already loaded theory *) |
|
171 |
fun get_filenames path name = |
|
172 |
let fun make_absolute file = |
|
559 | 173 |
if file = "" then "" else |
391 | 174 |
if hd (explode file) = "/" then file else tack_on (pwd ()) file; |
175 |
||
176 |
fun new_filename () = |
|
177 |
let val found = find_file path (name ^ ".thy") |
|
178 |
handle FILE_NOT_FOUND => ""; |
|
179 |
val thy_file = make_absolute found; |
|
180 |
val (thy_path, _) = split_filename thy_file; |
|
181 |
val found = find_file path (name ^ ".ML"); |
|
182 |
val ml_file = if thy_file = "" then make_absolute found |
|
183 |
else if file_exists (tack_on thy_path (name ^ ".ML")) |
|
184 |
then tack_on thy_path (name ^ ".ML") |
|
185 |
else ""; |
|
186 |
val searched_dirs = if path = "" then (!loadpath) else [path] |
|
187 |
in if thy_file = "" andalso ml_file = "" then |
|
188 |
error ("Could not find file \"" ^ name ^ ".thy\" or \"" |
|
189 |
^ name ^ ".ML\" for theory \"" ^ name ^ "\"\n" |
|
190 |
^ "in the following directories: \"" ^ |
|
191 |
(space_implode "\", \"" searched_dirs) ^ "\"") |
|
192 |
else (); |
|
559 | 193 |
(thy_file, ml_file) |
391 | 194 |
end; |
195 |
||
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
196 |
val tinfo = get_thyinfo name; |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
197 |
in if is_some tinfo andalso path = "" then |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
198 |
let val ThyInfo {path = abs_path, ...} = the tinfo; |
391 | 199 |
val (thy_file, ml_file) = if abs_path = "" then new_filename () |
200 |
else (find_file abs_path (name ^ ".thy"), |
|
201 |
find_file abs_path (name ^ ".ML")) |
|
202 |
in if thy_file = "" andalso ml_file = "" then |
|
203 |
(writeln ("Warning: File \"" ^ (tack_on path name) |
|
204 |
^ ".thy\"\ncontaining theory \"" ^ name |
|
205 |
^ "\" no longer exists."); |
|
206 |
new_filename () |
|
207 |
) |
|
208 |
else (thy_file, ml_file) |
|
209 |
end |
|
210 |
else new_filename () |
|
211 |
end; |
|
212 |
||
213 |
(*Remove theory from all child lists in loaded_thys *) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
214 |
fun unlink_thy tname = |
1242 | 215 |
let fun remove (ThyInfo {path, children, thy_time, ml_time, theory, thms, |
216 |
thy_simps, ml_simps}) = |
|
559 | 217 |
ThyInfo {path = path, children = children \ tname, |
1242 | 218 |
thy_time = thy_time, ml_time = ml_time, theory = theory, |
219 |
thms = thms, thy_simps = thy_simps, ml_simps = ml_simps} |
|
559 | 220 |
in loaded_thys := Symtab.map remove (!loaded_thys) end; |
391 | 221 |
|
222 |
(*Remove a theory from loaded_thys *) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
223 |
fun remove_thy tname = |
559 | 224 |
loaded_thys := Symtab.make (filter_out (fn (id, _) => id = tname) |
225 |
(Symtab.dest (!loaded_thys))); |
|
391 | 226 |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
227 |
(*Change thy_time and ml_time for an existent item *) |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
228 |
fun set_info thy_time ml_time tname = |
1242 | 229 |
let val ThyInfo {path, children, theory, thms, thy_simps, ml_simps, ...} = |
559 | 230 |
the (Symtab.lookup (!loaded_thys, tname)); |
1242 | 231 |
in loaded_thys := Symtab.update |
232 |
((tname, |
|
233 |
ThyInfo {path = path, children = children, thy_time = thy_time, |
|
234 |
ml_time = ml_time, theory = theory, thms = thms, |
|
235 |
thy_simps = thy_simps, ml_simps = ml_simps}), |
|
236 |
!loaded_thys) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
237 |
end; |
391 | 238 |
|
239 |
(*Mark theory as changed since last read if it has been completly read *) |
|
559 | 240 |
fun mark_outdated tname = |
971
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
241 |
let val t = get_thyinfo tname; |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
242 |
in if is_none t then () |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
243 |
else let val ThyInfo {thy_time, ml_time, ...} = the t |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
244 |
in set_info (if is_none thy_time then None else Some "") |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
245 |
(if is_none ml_time then None else Some "") |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
246 |
tname |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
247 |
end |
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
248 |
end; |
391 | 249 |
|
559 | 250 |
(*Read .thy and .ML files that haven't been read yet or have changed since |
391 | 251 |
they were last read; |
559 | 252 |
loaded_thys is a thy_info list ref containing all theories that have |
391 | 253 |
completly been read by this and preceeding use_thy calls. |
254 |
If a theory changed since its last use its children are marked as changed *) |
|
255 |
fun use_thy name = |
|
1242 | 256 |
let |
257 |
val (path, tname) = split_filename name; |
|
258 |
val (thy_file, ml_file) = get_filenames path tname; |
|
259 |
val (abs_path, _) = if thy_file = "" then split_filename ml_file |
|
260 |
else split_filename thy_file; |
|
261 |
val (thy_uptodate, ml_uptodate) = thy_unchanged tname thy_file ml_file; |
|
262 |
val (thy_simps, ml_simps) = get_simps tname; |
|
263 |
val old_simps = ref []; |
|
391 | 264 |
|
1242 | 265 |
(*Set absolute path for loaded theory *) |
266 |
fun set_path () = |
|
267 |
let val ThyInfo {children, thy_time, ml_time, theory, thms, |
|
268 |
thy_simps, ml_simps, ...} = |
|
269 |
the (Symtab.lookup (!loaded_thys, tname)); |
|
270 |
in loaded_thys := Symtab.update ((tname, |
|
271 |
ThyInfo {path = abs_path, children = children, |
|
272 |
thy_time = thy_time, ml_time = ml_time, |
|
273 |
theory = theory, thms = thms, |
|
274 |
thy_simps = thy_simps, |
|
275 |
ml_simps = ml_simps}), |
|
276 |
!loaded_thys) |
|
277 |
end; |
|
278 |
||
279 |
(*Mark all direct descendants of a theory as changed *) |
|
280 |
fun mark_children thy = |
|
281 |
let val ThyInfo {children, ...} = the (get_thyinfo thy); |
|
282 |
val present = filter (is_some o get_thyinfo) children; |
|
283 |
val loaded = filter already_loaded present; |
|
284 |
in if loaded <> [] then |
|
285 |
writeln ("The following children of theory " ^ (quote thy) |
|
286 |
^ " are now out-of-date: " |
|
287 |
^ (quote (space_implode "\",\"" loaded))) |
|
288 |
else (); |
|
289 |
seq mark_outdated present |
|
290 |
end; |
|
391 | 291 |
|
1242 | 292 |
(*Remove theorems associated with a theory*) |
293 |
fun delete_thms () = |
|
294 |
let |
|
295 |
val tinfo = case get_thyinfo tname of |
|
296 |
Some (ThyInfo {path, children, thy_time, ml_time, theory, |
|
297 |
thy_simps, ml_simps, ...}) => |
|
298 |
ThyInfo {path = path, children = children, |
|
299 |
thy_time = thy_time, ml_time = ml_time, |
|
300 |
theory = theory, thms = Symtab.null, |
|
301 |
thy_simps = thy_simps, ml_simps = ml_simps} |
|
302 |
| None => ThyInfo {path = "", children = [], |
|
303 |
thy_time = None, ml_time = None, |
|
304 |
theory = None, thms = Symtab.null, |
|
305 |
thy_simps = [], ml_simps = []}; |
|
306 |
in loaded_thys := Symtab.update ((tname, tinfo), !loaded_thys) end; |
|
307 |
||
308 |
fun update_simps (new_thy_simps, new_ml_simps) = |
|
309 |
let val ThyInfo {path, children, thy_time, ml_time, theory, thms, |
|
310 |
thy_simps, ml_simps} = the (get_thyinfo tname); |
|
391 | 311 |
|
1242 | 312 |
val (thy_simps', ml_simps') = |
313 |
(if is_none new_thy_simps then thy_simps else the new_thy_simps, |
|
314 |
if is_none new_ml_simps then ml_simps else the new_ml_simps); |
|
315 |
in loaded_thys := Symtab.update ((tname, |
|
316 |
ThyInfo {path = path, children = children, |
|
317 |
thy_time = thy_time, ml_time = ml_time, theory = theory, |
|
318 |
thms = thms, thy_simps = thy_simps', |
|
319 |
ml_simps = ml_simps'}), !loaded_thys) |
|
320 |
end; |
|
321 |
||
322 |
in if thy_uptodate andalso ml_uptodate then () |
|
323 |
else |
|
324 |
( |
|
325 |
delete_thms (); |
|
326 |
||
327 |
if thy_uptodate orelse thy_file = "" then |
|
328 |
(Delsimps ml_simps; |
|
329 |
old_simps := #simps(rep_ss (!simpset)); |
|
330 |
update_simps (None, Some [])) |
|
391 | 331 |
else |
1242 | 332 |
(writeln ("Reading \"" ^ name ^ ".thy\""); |
333 |
Delsimps (thy_simps @ ml_simps); |
|
334 |
old_simps := #simps(rep_ss (!simpset)); |
|
335 |
update_simps (Some [], Some []); (*clear simp lists in case use_thy |
|
336 |
encounters an EROR exception*) |
|
337 |
read_thy tname thy_file; |
|
338 |
use (out_name tname); |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
339 |
|
1242 | 340 |
if not (!delete_tmpfiles) then () |
341 |
else delete_file (out_name tname); |
|
1098
487089cb173e
fixed bug in thy_unchanged that occurred when the .thy file was changed
clasohm
parents:
971
diff
changeset
|
342 |
|
1242 | 343 |
update_simps |
344 |
(Some (gen_rems same_thm (#simps(rep_ss (!simpset)), !old_simps)), |
|
345 |
None); |
|
346 |
old_simps := #simps(rep_ss (!simpset)) |
|
347 |
); |
|
348 |
||
349 |
set_info (Some (file_info thy_file)) None tname; |
|
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
350 |
(*mark thy_file as successfully loaded*) |
391 | 351 |
|
1242 | 352 |
if ml_file = "" then () |
353 |
else |
|
354 |
(writeln ("Reading \"" ^ name ^ ".ML\""); |
|
355 |
use ml_file; |
|
391 | 356 |
|
1242 | 357 |
update_simps (None, |
358 |
Some (gen_rems same_thm (#simps(rep_ss (!simpset)), !old_simps))) |
|
359 |
); |
|
360 |
||
361 |
(*Store theory again because it could have been redefined*) |
|
362 |
use_string |
|
363 |
["val _ = (store_theory (" ^ tname ^ ".thy, " ^ quote tname ^ "); " ^ |
|
391 | 364 |
|
1242 | 365 |
(*Store new axioms in theorem database; ignore theories which are just |
366 |
copies of existing ones*) |
|
367 |
let val parents = get_parents tname; |
|
368 |
val fst_thy = get_theory (hd parents); |
|
369 |
val this_thy = get_theory tname; |
|
370 |
in if length parents = 1 |
|
371 |
andalso Sign.eq_sg (sign_of fst_thy, sign_of this_thy) then "" |
|
372 |
else |
|
373 |
"map store_thm_db (axioms_of " ^ tname ^ ".thy));" |
|
374 |
end]; |
|
391 | 375 |
|
1242 | 376 |
(*Now set the correct info*) |
377 |
set_info (Some (file_info thy_file)) (Some (file_info ml_file)) tname; |
|
378 |
set_path (); |
|
379 |
||
380 |
(*Mark theories that have to be reloaded*) |
|
381 |
mark_children tname |
|
382 |
) |
|
383 |
end; |
|
391 | 384 |
|
385 |
fun time_use_thy tname = timeit(fn()=> |
|
559 | 386 |
(writeln("\n**** Starting Theory " ^ tname ^ " ****"); |
391 | 387 |
use_thy tname; |
388 |
writeln("\n**** Finished Theory " ^ tname ^ " ****")) |
|
389 |
); |
|
390 |
||
391 |
(*Load all thy or ML files that have been changed and also |
|
392 |
all theories that depend on them *) |
|
393 |
fun update () = |
|
394 |
let (*List theories in the order they have to be loaded *) |
|
395 |
fun load_order [] result = result |
|
396 |
| load_order thys result = |
|
397 |
let fun next_level (t :: ts) = |
|
398 |
let val thy = get_thyinfo t |
|
399 |
in if is_some thy then |
|
400 |
let val ThyInfo {children, ...} = the thy |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
401 |
in children union (next_level ts) end |
391 | 402 |
else next_level ts |
403 |
end |
|
404 |
| next_level [] = []; |
|
559 | 405 |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
406 |
val children = next_level thys; |
391 | 407 |
in load_order children ((result \\ children) @ children) end; |
408 |
||
409 |
fun reload_changed (t :: ts) = |
|
410 |
let val thy = get_thyinfo t; |
|
411 |
||
412 |
fun abspath () = |
|
413 |
if is_some thy then |
|
414 |
let val ThyInfo {path, ...} = the thy in path end |
|
415 |
else ""; |
|
416 |
||
417 |
val (thy_file, ml_file) = get_filenames (abspath ()) t; |
|
418 |
val (thy_uptodate, ml_uptodate) = |
|
419 |
thy_unchanged t thy_file ml_file; |
|
420 |
in if thy_uptodate andalso ml_uptodate then () |
|
421 |
else use_thy t; |
|
422 |
reload_changed ts |
|
423 |
end |
|
424 |
| reload_changed [] = (); |
|
425 |
||
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
426 |
(*Remove all theories that are no descendants of ProtoPure. |
391 | 427 |
If there are still children in the deleted theory's list |
428 |
schedule them for reloading *) |
|
429 |
fun collect_garbage not_garbage = |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
430 |
let fun collect ((tname, ThyInfo {children, ...}) :: ts) = |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
431 |
if tname mem not_garbage then collect ts |
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
432 |
else (writeln ("Theory \"" ^ tname ^ |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
433 |
"\" is no longer linked with ProtoPure - removing it."); |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
434 |
remove_thy tname; |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
435 |
seq mark_outdated children) |
391 | 436 |
| collect [] = () |
437 |
||
559 | 438 |
in collect (Symtab.dest (!loaded_thys)) end; |
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
439 |
in collect_garbage ("ProtoPure" :: (load_order ["ProtoPure"] [])); |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
440 |
reload_changed (load_order ["Pure", "CPure"] []) |
391 | 441 |
end; |
442 |
||
443 |
(*Merge theories to build a base for a new theory. |
|
444 |
Base members are only loaded if they are missing. *) |
|
586
201e115d8031
renamed base_on into mk_base and moved it to the beginning of the generated
clasohm
parents:
559
diff
changeset
|
445 |
fun mk_base bases child mk_draft = |
391 | 446 |
let (*List all descendants of a theory list *) |
447 |
fun list_descendants (t :: ts) = |
|
448 |
let val tinfo = get_thyinfo t |
|
449 |
in if is_some tinfo then |
|
450 |
let val ThyInfo {children, ...} = the tinfo |
|
451 |
in children union (list_descendants (ts union children)) |
|
452 |
end |
|
453 |
else [] |
|
454 |
end |
|
455 |
| list_descendants [] = []; |
|
456 |
||
457 |
(*Show the cycle that would be created by add_child *) |
|
458 |
fun show_cycle base = |
|
459 |
let fun find_it result curr = |
|
460 |
let val tinfo = get_thyinfo curr |
|
559 | 461 |
in if base = curr then |
391 | 462 |
error ("Cyclic dependency of theories: " |
463 |
^ child ^ "->" ^ base ^ result) |
|
464 |
else if is_some tinfo then |
|
465 |
let val ThyInfo {children, ...} = the tinfo |
|
466 |
in seq (find_it ("->" ^ curr ^ result)) children |
|
467 |
end |
|
468 |
else () |
|
469 |
end |
|
470 |
in find_it "" child end; |
|
559 | 471 |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
472 |
(*Check if a cycle would be created by add_child *) |
391 | 473 |
fun find_cycle base = |
474 |
if base mem (list_descendants [child]) then show_cycle base |
|
475 |
else (); |
|
559 | 476 |
|
391 | 477 |
(*Add child to child list of base *) |
478 |
fun add_child base = |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
479 |
let val tinfo = |
559 | 480 |
case Symtab.lookup (!loaded_thys, base) of |
481 |
Some (ThyInfo {path, children, thy_time, ml_time, |
|
1242 | 482 |
theory, thms, thy_simps, ml_simps}) => |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
483 |
ThyInfo {path = path, children = child ins children, |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
484 |
thy_time = thy_time, ml_time = ml_time, |
1242 | 485 |
theory = theory, thms = thms, |
486 |
thy_simps = thy_simps, ml_simps = ml_simps} |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
487 |
| None => ThyInfo {path = "", children = [child], |
559 | 488 |
thy_time = None, ml_time = None, |
1242 | 489 |
theory = None, thms = Symtab.null, |
490 |
thy_simps = [], ml_simps = []}; |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
491 |
in loaded_thys := Symtab.update ((base, tinfo), !loaded_thys) end; |
391 | 492 |
|
493 |
(*Load a base theory if not already done |
|
494 |
and no cycle would be created *) |
|
495 |
fun load base = |
|
971
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
496 |
let val thy_loaded = already_loaded base |
426
767367131b47
replaced "foldl merge_theories" by "merge_thy_list" in base_on
clasohm
parents:
424
diff
changeset
|
497 |
(*test this before child is added *) |
391 | 498 |
in |
499 |
if child = base then |
|
500 |
error ("Cyclic dependency of theories: " ^ child |
|
501 |
^ "->" ^ child) |
|
559 | 502 |
else |
391 | 503 |
(find_cycle base; |
504 |
add_child base; |
|
971
f4815812665b
fixed bug: parent theory wasn't loaded if .thy file was completly read before
clasohm
parents:
922
diff
changeset
|
505 |
if thy_loaded then () |
391 | 506 |
else (writeln ("Autoloading theory " ^ (quote base) |
507 |
^ " (used by " ^ (quote child) ^ ")"); |
|
508 |
use_thy base) |
|
509 |
) |
|
559 | 510 |
end; |
391 | 511 |
|
512 |
(*Load all needed files and make a list of all real theories *) |
|
513 |
fun load_base (Thy b :: bs) = |
|
514 |
(load b; |
|
515 |
b :: (load_base bs)) |
|
516 |
| load_base (File b :: bs) = |
|
517 |
(load b; |
|
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
518 |
load_base bs) (*don't add it to mergelist *) |
391 | 519 |
| load_base [] = []; |
520 |
||
521 |
val mergelist = (unlink_thy child; |
|
522 |
load_base bases); |
|
523 |
in writeln ("Loading theory " ^ (quote child)); |
|
426
767367131b47
replaced "foldl merge_theories" by "merge_thy_list" in base_on
clasohm
parents:
424
diff
changeset
|
524 |
merge_thy_list mk_draft (map get_theory mergelist) end; |
391 | 525 |
|
559 | 526 |
(*Change theory object for an existent item of loaded_thys |
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
1098
diff
changeset
|
527 |
or create a new item; also store axioms in Thm database*) |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
528 |
fun store_theory (thy, tname) = |
559 | 529 |
let val tinfo = case Symtab.lookup (!loaded_thys, tname) of |
1242 | 530 |
Some (ThyInfo {path, children, thy_time, ml_time, thms, |
531 |
thy_simps, ml_simps, ...}) => |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
532 |
ThyInfo {path = path, children = children, |
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
533 |
thy_time = thy_time, ml_time = ml_time, |
1242 | 534 |
theory = Some thy, thms = thms, |
535 |
thy_simps = thy_simps, ml_simps = ml_simps} |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
536 |
| None => ThyInfo {path = "", children = [], |
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
871
diff
changeset
|
537 |
thy_time = None, ml_time = None, |
1242 | 538 |
theory = Some thy, thms = Symtab.null, |
539 |
thy_simps = [], ml_simps = []}; |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
1098
diff
changeset
|
540 |
in loaded_thys := Symtab.update ((tname, tinfo), !loaded_thys) |
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
1098
diff
changeset
|
541 |
end; |
559 | 542 |
|
543 |
||
544 |
(** store and retrieve theorems **) |
|
545 |
||
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
546 |
(*Guess to which theory a signature belongs and return it's thy_info*) |
559 | 547 |
fun thyinfo_of_sign sg = |
548 |
let |
|
549 |
val ref xname = hd (#stamps (Sign.rep_sg sg)); |
|
550 |
val opt_info = get_thyinfo xname; |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
551 |
|
559 | 552 |
fun eq_sg (ThyInfo {theory = None, ...}) = false |
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
553 |
| eq_sg (ThyInfo {theory = Some thy, ...}) = Sign.eq_sg (sg,sign_of thy); |
559 | 554 |
|
555 |
val show_sg = Pretty.str_of o Sign.pretty_sg; |
|
556 |
in |
|
557 |
if is_some opt_info andalso eq_sg (the opt_info) then |
|
558 |
(xname, the opt_info) |
|
559 |
else |
|
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
560 |
(case Symtab.find_first (eq_sg o snd) (!loaded_thys) of |
559 | 561 |
Some name_info => name_info |
562 |
| None => error ("Theory " ^ show_sg sg ^ " not stored by loader")) |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
563 |
end; |
391 | 564 |
|
559 | 565 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
566 |
(*Try to get the theory object corresponding to a given signature*) |
559 | 567 |
fun theory_of_sign sg = |
568 |
(case thyinfo_of_sign sg of |
|
569 |
(_, ThyInfo {theory = Some thy, ...}) => thy |
|
570 |
| _ => sys_error "theory_of_sign"); |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
571 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
572 |
(*Try to get the theory object corresponding to a given theorem*) |
559 | 573 |
val theory_of_thm = theory_of_sign o #sign o rep_thm; |
574 |
||
575 |
||
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
576 |
(* Store theorems *) |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
577 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
578 |
(*Store a theorem in the thy_info of its theory*) |
559 | 579 |
fun store_thm (name, thm) = |
580 |
let |
|
1242 | 581 |
val (thy_name, ThyInfo {path, children, thy_time, ml_time, theory, thms, |
582 |
thy_simps, ml_simps}) = |
|
559 | 583 |
thyinfo_of_sign (#sign (rep_thm thm)); |
1236
b54d51df9065
added check for duplicate theorems in theorem database;
clasohm
parents:
1223
diff
changeset
|
584 |
|
559 | 585 |
val thms' = Symtab.update_new ((name, thm), thms) |
774
ea19f22ed23c
added warning for already stored theorem to store_thm
clasohm
parents:
759
diff
changeset
|
586 |
handle Symtab.DUPLICATE s => |
1242 | 587 |
(if same_thm (the (Symtab.lookup (thms, name)), thm) then |
1236
b54d51df9065
added check for duplicate theorems in theorem database;
clasohm
parents:
1223
diff
changeset
|
588 |
(writeln ("Warning: Theory database already contains copy of\ |
774
ea19f22ed23c
added warning for already stored theorem to store_thm
clasohm
parents:
759
diff
changeset
|
589 |
\ theorem " ^ quote name); |
ea19f22ed23c
added warning for already stored theorem to store_thm
clasohm
parents:
759
diff
changeset
|
590 |
thms) |
1236
b54d51df9065
added check for duplicate theorems in theorem database;
clasohm
parents:
1223
diff
changeset
|
591 |
else error ("Duplicate theorem name " ^ quote s |
b54d51df9065
added check for duplicate theorems in theorem database;
clasohm
parents:
1223
diff
changeset
|
592 |
^ " used in theory database")); |
559 | 593 |
in |
594 |
loaded_thys := Symtab.update |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
595 |
((thy_name, ThyInfo {path = path, children = children, |
1242 | 596 |
thy_time = thy_time, ml_time = ml_time, |
597 |
theory = theory, thms = thms', |
|
598 |
thy_simps = thy_simps, ml_simps = ml_simps}), |
|
599 |
!loaded_thys); |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
1098
diff
changeset
|
600 |
store_thm_db (name, thm) |
559 | 601 |
end; |
602 |
||
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
603 |
(*Store result of proof in loaded_thys and as ML value*) |
758 | 604 |
|
605 |
val qed_thm = ref flexpair_def(*dummy*); |
|
606 |
||
607 |
fun bind_thm (name, thm) = |
|
1223
53e4b22aa1f2
corrected bind_thm: now applies "standard" uniformly.
nipkow
parents:
1157
diff
changeset
|
608 |
(qed_thm := standard thm; |
53e4b22aa1f2
corrected bind_thm: now applies "standard" uniformly.
nipkow
parents:
1157
diff
changeset
|
609 |
use_string ["val " ^name^ " = store_thm (" ^quote name^", !qed_thm);"]); |
758 | 610 |
|
559 | 611 |
fun qed name = |
612 |
use_string ["val " ^ name ^ " = store_thm (" ^ quote name ^ ", result ());"]; |
|
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
613 |
|
746 | 614 |
fun qed_goal name thy agoal tacsf = |
758 | 615 |
(qed_thm := prove_goal thy agoal tacsf; |
616 |
use_string ["val " ^ name ^ " = store_thm (" ^ quote name ^", !qed_thm);"]); |
|
746 | 617 |
|
618 |
fun qed_goalw name thy rths agoal tacsf = |
|
758 | 619 |
(qed_thm := prove_goalw thy rths agoal tacsf; |
620 |
use_string ["val " ^ name ^ " = store_thm (" ^ quote name ^", !qed_thm);"]); |
|
559 | 621 |
|
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
622 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
623 |
(* Retrieve theorems *) |
559 | 624 |
|
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
625 |
(*Get all theorems belonging to a given theory*) |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
626 |
fun thmtab_ofthy thy = |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
627 |
let val (_, ThyInfo {thms, ...}) = thyinfo_of_sign (sign_of thy); |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
628 |
in thms end; |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
629 |
|
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
630 |
fun thmtab_ofname name = |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
631 |
let val ThyInfo {thms, ...} = the (get_thyinfo name); |
559 | 632 |
in thms end; |
476
836cad329311
added check for concistency of filename and theory name;
clasohm
parents:
426
diff
changeset
|
633 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
634 |
(*Get a stored theorem specified by theory and name*) |
559 | 635 |
fun get_thm thy name = |
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
636 |
let fun get [] [] searched = |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
637 |
raise THEORY ("get_thm: no theorem " ^ quote name, [thy]) |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
638 |
| get [] ng searched = |
871 | 639 |
get (ng \\ searched) [] searched |
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
640 |
| get (t::ts) ng searched = |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
641 |
(case Symtab.lookup (thmtab_ofname t, name) of |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
642 |
Some thm => thm |
871 | 643 |
| None => get ts (ng union (get_parents t)) (t::searched)); |
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
644 |
|
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
645 |
val (tname, _) = thyinfo_of_sign (sign_of thy); |
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
646 |
in get [tname] [] [] end; |
559 | 647 |
|
715
f76ad10f5802
added call of store_theory after thy file has been read
clasohm
parents:
586
diff
changeset
|
648 |
(*Get stored theorems of a theory*) |
783
08f1785a4384
changed get_thm to search all parent theories if the theorem is not found
clasohm
parents:
778
diff
changeset
|
649 |
val thms_of = Symtab.dest o thmtab_ofthy; |
559 | 650 |
|
651 |
||
778 | 652 |
(* print theory *) |
653 |
||
654 |
fun print_thms thy = |
|
655 |
let |
|
656 |
val thms = thms_of thy; |
|
657 |
fun prt_thm (s, th) = Pretty.block [Pretty.str (s ^ ":"), Pretty.brk 1, |
|
658 |
Pretty.quote (pretty_thm th)]; |
|
659 |
in |
|
660 |
Pretty.writeln (Pretty.big_list "stored theorems:" (map prt_thm thms)) |
|
661 |
end; |
|
662 |
||
663 |
fun print_theory thy = (Drule.print_theory thy; print_thms thy); |
|
664 |
||
391 | 665 |
end; |