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