| author | berghofe |
| Mon, 12 May 2003 13:51:50 +0200 | |
| changeset 14008 | f843528b9f3c |
| parent 13279 | 8a722689a1c9 |
| child 14680 | 6029e76841fd |
| permissions | -rw-r--r-- |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
1 |
(* Title: Pure/Thy/thm_database.ML |
|
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
2 |
ID: $Id$ |
| 11895 | 3 |
Author: Markus Wenzel, TU Muenchen |
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
5 |
|
|
13279
8a722689a1c9
removed thms_containing (see pure_thy.ML and proof_context.ML);
wenzelm
parents:
11895
diff
changeset
|
6 |
Interface to thm database. |
| 4023 | 7 |
*) |
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
8 |
|
| 6204 | 9 |
signature BASIC_THM_DATABASE = |
| 4023 | 10 |
sig |
11 |
val store_thm: string * thm -> thm |
|
| 7410 | 12 |
val store_thms: string * thm list -> thm list |
| 4023 | 13 |
end; |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
14 |
|
| 6204 | 15 |
signature THM_DATABASE = |
16 |
sig |
|
17 |
include BASIC_THM_DATABASE |
|
| 7410 | 18 |
val qed_thms: thm list ref |
| 6204 | 19 |
val ml_store_thm: string * thm -> unit |
| 7410 | 20 |
val ml_store_thms: string * thm list -> unit |
| 6204 | 21 |
val is_ml_identifier: string -> bool |
| 11529 | 22 |
val ml_reserved: string list |
| 6204 | 23 |
end; |
24 |
||
| 3627 | 25 |
structure ThmDatabase: THM_DATABASE = |
| 1221 | 26 |
struct |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
27 |
|
| 4023 | 28 |
(** store theorems **) |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
29 |
|
|
13279
8a722689a1c9
removed thms_containing (see pure_thy.ML and proof_context.ML);
wenzelm
parents:
11895
diff
changeset
|
30 |
(* store in theory and perform presentation *) |
|
1136
3910c96551d1
fixed bug in thms_containing; changed error/warning messages;
clasohm
parents:
1134
diff
changeset
|
31 |
|
| 4023 | 32 |
fun store_thm (name, thm) = |
| 7410 | 33 |
let val thm' = hd (PureThy.smart_store_thms (name, [thm])) |
| 6327 | 34 |
in Present.theorem name thm'; thm' end; |
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
35 |
|
| 7410 | 36 |
fun store_thms (name, thms) = |
37 |
let val thms' = PureThy.smart_store_thms (name, thms) |
|
38 |
in Present.theorems name thms'; thms' end; |
|
39 |
||
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
40 |
|
| 4023 | 41 |
(* store on ML toplevel *) |
42 |
||
| 7410 | 43 |
val qed_thms: thm list ref = ref []; |
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
44 |
|
| 4023 | 45 |
val ml_reserved = |
46 |
["abstype", "and", "andalso", "as", "case", "do", "datatype", "else", |
|
47 |
"end", "exception", "fn", "fun", "handle", "if", "in", "infix", |
|
48 |
"infixr", "let", "local", "nonfix", "of", "op", "open", "orelse", |
|
49 |
"raise", "rec", "then", "type", "val", "with", "withtype", "while", |
|
50 |
"eqtype", "functor", "include", "sharing", "sig", "signature", |
|
51 |
"struct", "structure", "where"]; |
|
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
52 |
|
| 4023 | 53 |
fun is_ml_identifier name = |
54 |
Syntax.is_identifier name andalso not (name mem ml_reserved); |
|
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
55 |
|
| 7410 | 56 |
fun warn_ml name = |
57 |
if is_ml_identifier name then false |
|
| 7573 | 58 |
else if name = "" then true |
| 7410 | 59 |
else (warning ("Cannot bind theorem(s) " ^ quote name ^ " as ML value"); true);
|
60 |
||
| 10914 | 61 |
val use_text_verbose = use_text Context.ml_output true; |
| 7854 | 62 |
|
| 4023 | 63 |
fun ml_store_thm (name, thm) = |
64 |
let val thm' = store_thm (name, thm) in |
|
| 7410 | 65 |
if warn_ml name then () |
|
13279
8a722689a1c9
removed thms_containing (see pure_thy.ML and proof_context.ML);
wenzelm
parents:
11895
diff
changeset
|
66 |
else (qed_thms := [thm']; |
|
8a722689a1c9
removed thms_containing (see pure_thy.ML and proof_context.ML);
wenzelm
parents:
11895
diff
changeset
|
67 |
use_text_verbose ("val " ^ name ^ " = hd (! ThmDatabase.qed_thms);"))
|
| 7410 | 68 |
end; |
69 |
||
70 |
fun ml_store_thms (name, thms) = |
|
71 |
let val thms' = store_thms (name, thms) in |
|
72 |
if warn_ml name then () |
|
| 7854 | 73 |
else (qed_thms := thms'; use_text_verbose ("val " ^ name ^ " = ! ThmDatabase.qed_thms;"))
|
|
1262
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
74 |
end; |
|
8f40ff1299d8
added removal of theorems if theory is to be reloaded; changed functions for
clasohm
parents:
1245
diff
changeset
|
75 |
|
| 4023 | 76 |
|
|
1132
dfb29abcf3c2
added theorem database which contains axioms and theorems indexed by the
clasohm
parents:
diff
changeset
|
77 |
end; |
| 6204 | 78 |
|
79 |
structure BasicThmDatabase: BASIC_THM_DATABASE = ThmDatabase; |
|
80 |
open BasicThmDatabase; |