author | wenzelm |
Mon, 17 Apr 2000 14:27:10 +0200 | |
changeset 8731 | 085f0e32b9d6 |
parent 8724 | ef7efded8fdc |
child 8804 | de0e9f689c6e |
permissions | -rw-r--r-- |
5830 | 1 |
(* Title: Pure/Isar/isar_thy.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
6371 | 5 |
Pure/Isar derived theory operations. |
5830 | 6 |
*) |
7 |
||
8 |
signature ISAR_THY = |
|
9 |
sig |
|
7734 | 10 |
val add_header: Comment.text -> Toplevel.transition -> Toplevel.transition |
6552 | 11 |
val add_chapter: Comment.text -> theory -> theory |
12 |
val add_section: Comment.text -> theory -> theory |
|
13 |
val add_subsection: Comment.text -> theory -> theory |
|
14 |
val add_subsubsection: Comment.text -> theory -> theory |
|
7172 | 15 |
val add_text: Comment.text -> theory -> theory |
7862 | 16 |
val add_text_raw: Comment.text -> theory -> theory |
7172 | 17 |
val add_sect: Comment.text -> ProofHistory.T -> ProofHistory.T |
18 |
val add_subsect: Comment.text -> ProofHistory.T -> ProofHistory.T |
|
19 |
val add_subsubsect: Comment.text -> ProofHistory.T -> ProofHistory.T |
|
20 |
val add_txt: Comment.text -> ProofHistory.T -> ProofHistory.T |
|
7862 | 21 |
val add_txt_raw: Comment.text -> ProofHistory.T -> ProofHistory.T |
8724 | 22 |
val global_path: Comment.text -> theory -> theory |
23 |
val local_path: Comment.text -> theory -> theory |
|
24 |
val hide_space: (string * xstring list) * Comment.text -> theory -> theory |
|
25 |
val hide_space_i: (string * string list) * Comment.text -> theory -> theory |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
26 |
val add_classes: (bclass * xclass list) list * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
27 |
val add_classes_i: (bclass * class list) list * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
28 |
val add_classrel: (xclass * xclass) * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
29 |
val add_classrel_i: (class * class) * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
30 |
val add_defsort: xsort * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
31 |
val add_defsort_i: sort * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
32 |
val add_nonterminals: (bstring * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
33 |
val add_tyabbrs: ((bstring * string list * string * mixfix) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
34 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
35 |
val add_tyabbrs_i: ((bstring * string list * typ * mixfix) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
36 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
37 |
val add_arities: ((xstring * xsort list * xsort) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
38 |
val add_arities_i: ((string * sort list * sort) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
39 |
val add_typedecl: (bstring * string list * mixfix) * Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
40 |
val add_consts: ((bstring * string * mixfix) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
41 |
val add_consts_i: ((bstring * typ * mixfix) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
42 |
val add_modesyntax: string * bool -> ((bstring * string * mixfix) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
43 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
44 |
val add_modesyntax_i: string * bool -> ((bstring * typ * mixfix) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
45 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
46 |
val add_trrules: ((xstring * string) Syntax.trrule * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
47 |
val add_trrules_i: (Syntax.ast Syntax.trrule * Comment.text) list -> theory -> theory |
8227 | 48 |
val add_judgment: (bstring * string * mixfix) * Comment.text -> theory -> theory |
49 |
val add_judgment_i: (bstring * typ * mixfix) * Comment.text -> theory -> theory |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
50 |
val add_axioms: (((bstring * string) * Args.src list) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
51 |
val add_axioms_i: (((bstring * term) * theory attribute list) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
52 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
53 |
val add_defs: (((bstring * string) * Args.src list) * Comment.text) list -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
54 |
val add_defs_i: (((bstring * term) * theory attribute list) * Comment.text) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
55 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
56 |
val add_constdefs: (((bstring * string * mixfix) * Comment.text) * (string * Comment.text)) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
57 |
-> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
58 |
val add_constdefs_i: (((bstring * typ * mixfix) * Comment.text) * (term * Comment.text)) list |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
59 |
-> theory -> theory |
6371 | 60 |
val apply_theorems: (xstring * Args.src list) list -> theory -> theory * thm list |
61 |
val apply_theorems_i: (thm * theory attribute list) list -> theory -> theory * thm list |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
62 |
val have_theorems: ((bstring * Args.src list) * (xstring * Args.src list) list) * Comment.text |
6371 | 63 |
-> theory -> theory |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
64 |
val have_theorems_i: ((bstring * theory attribute list) * (thm * theory attribute list) list) |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
65 |
* Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
66 |
val have_lemmas: ((bstring * Args.src list) * (xstring * Args.src list) list) * Comment.text |
5915 | 67 |
-> theory -> theory |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
68 |
val have_lemmas_i: ((bstring * theory attribute list) * (thm * theory attribute list) list) |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
69 |
* Comment.text -> theory -> theory |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
70 |
val have_facts: ((string * Args.src list) * (string * Args.src list) list) * Comment.text |
5915 | 71 |
-> ProofHistory.T -> ProofHistory.T |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
72 |
val have_facts_i: ((string * Proof.context attribute list) * |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
73 |
(thm * Proof.context attribute list) list) * Comment.text -> ProofHistory.T -> ProofHistory.T |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
74 |
val from_facts: (string * Args.src list) list * Comment.text -> ProofHistory.T -> ProofHistory.T |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
75 |
val from_facts_i: (thm * Proof.context attribute list) list * Comment.text |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
76 |
-> ProofHistory.T -> ProofHistory.T |
6879 | 77 |
val with_facts: (string * Args.src list) list * Comment.text -> ProofHistory.T -> ProofHistory.T |
78 |
val with_facts_i: (thm * Proof.context attribute list) list * Comment.text |
|
79 |
-> ProofHistory.T -> ProofHistory.T |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
80 |
val chain: Comment.text -> ProofHistory.T -> ProofHistory.T |
7417 | 81 |
val fix: ((string list * string option) * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
7666 | 82 |
val fix_i: ((string list * typ option) * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
8615 | 83 |
val let_bind: ((string list * string) * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
84 |
val let_bind_i: ((term list * term) * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
|
8450 | 85 |
val invoke_case: (string * Args.src list) * Comment.text -> ProofHistory.T -> ProofHistory.T |
86 |
val invoke_case_i: (string * Proof.context attribute list) * Comment.text |
|
87 |
-> ProofHistory.T -> ProofHistory.T |
|
6937 | 88 |
val theorem: (bstring * Args.src list * (string * (string list * string list))) |
89 |
* Comment.text -> bool -> theory -> ProofHistory.T |
|
90 |
val theorem_i: (bstring * theory attribute list * (term * (term list * term list))) |
|
91 |
* Comment.text -> bool -> theory -> ProofHistory.T |
|
92 |
val lemma: (bstring * Args.src list * (string * (string list * string list))) |
|
93 |
* Comment.text -> bool -> theory -> ProofHistory.T |
|
94 |
val lemma_i: (bstring * theory attribute list * (term * (term list * term list))) |
|
95 |
* Comment.text -> bool -> theory -> ProofHistory.T |
|
7271 | 96 |
val assume: ((string * Args.src list * (string * (string list * string list)) list) |
97 |
* Comment.text) list -> ProofHistory.T -> ProofHistory.T |
|
98 |
val assume_i: ((string * Proof.context attribute list * (term * (term list * term list)) list) |
|
99 |
* Comment.text) list -> ProofHistory.T -> ProofHistory.T |
|
100 |
val presume: ((string * Args.src list * (string * (string list * string list)) list) |
|
101 |
* Comment.text) list -> ProofHistory.T -> ProofHistory.T |
|
102 |
val presume_i: ((string * Proof.context attribute list * (term * (term list * term list)) list) |
|
103 |
* Comment.text) list -> ProofHistory.T -> ProofHistory.T |
|
6952 | 104 |
val local_def: (string * Args.src list * ((string * string option) * (string * string list))) |
105 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
7666 | 106 |
val local_def_i: (string * Args.src list * ((string * typ option) * (term * term list))) |
6952 | 107 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
6937 | 108 |
val show: (string * Args.src list * (string * (string list * string list))) |
109 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
110 |
val show_i: (string * Proof.context attribute list * (term * (term list * term list))) |
|
111 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
112 |
val have: (string * Args.src list * (string * (string list * string list))) |
|
113 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
114 |
val have_i: (string * Proof.context attribute list * (term * (term list * term list))) |
|
115 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
116 |
val thus: (string * Args.src list * (string * (string list * string list))) |
|
117 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
118 |
val thus_i: (string * Proof.context attribute list * (term * (term list * term list))) |
|
119 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
120 |
val hence: (string * Args.src list * (string * (string list * string list))) |
|
121 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
122 |
val hence_i: (string * Proof.context attribute list * (term * (term list * term list))) |
|
123 |
* Comment.text -> ProofHistory.T -> ProofHistory.T |
|
5830 | 124 |
val begin_block: ProofHistory.T -> ProofHistory.T |
125 |
val next_block: ProofHistory.T -> ProofHistory.T |
|
126 |
val end_block: ProofHistory.T -> ProofHistory.T |
|
8681 | 127 |
val defer: int option * Comment.text -> ProofHistory.T -> ProofHistory.T |
128 |
val prefer: int * Comment.text -> ProofHistory.T -> ProofHistory.T |
|
129 |
val apply: Method.text * Comment.text -> ProofHistory.T -> ProofHistory.T |
|
130 |
val apply_end: Method.text * Comment.text -> ProofHistory.T -> ProofHistory.T |
|
7002 | 131 |
val proof: (Comment.interest * (Method.text * Comment.interest) option) * Comment.text |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
132 |
-> ProofHistory.T -> ProofHistory.T |
7002 | 133 |
val qed: (Method.text * Comment.interest) option * Comment.text |
6937 | 134 |
-> Toplevel.transition -> Toplevel.transition |
7002 | 135 |
val terminal_proof: ((Method.text * Comment.interest) * (Method.text * Comment.interest) option) |
136 |
* Comment.text -> Toplevel.transition -> Toplevel.transition |
|
137 |
val immediate_proof: Comment.text -> Toplevel.transition -> Toplevel.transition |
|
138 |
val default_proof: Comment.text -> Toplevel.transition -> Toplevel.transition |
|
139 |
val skip_proof: Comment.text -> Toplevel.transition -> Toplevel.transition |
|
8210 | 140 |
val forget_proof: Comment.text -> Toplevel.transition -> Toplevel.transition |
7012 | 141 |
val get_thmss: (string * Args.src list) list -> Proof.state -> thm list |
6879 | 142 |
val also: ((string * Args.src list) list * Comment.interest) option * Comment.text |
143 |
-> Toplevel.transition -> Toplevel.transition |
|
144 |
val also_i: (thm list * Comment.interest) option * Comment.text |
|
145 |
-> Toplevel.transition -> Toplevel.transition |
|
146 |
val finally: ((string * Args.src list) list * Comment.interest) option * Comment.text |
|
147 |
-> Toplevel.transition -> Toplevel.transition |
|
148 |
val finally_i: (thm list * Comment.interest) option * Comment.text |
|
149 |
-> Toplevel.transition -> Toplevel.transition |
|
8562 | 150 |
val moreover: Comment.text -> Toplevel.transition -> Toplevel.transition |
8588 | 151 |
val ultimately: Comment.text -> Toplevel.transition -> Toplevel.transition |
5830 | 152 |
val parse_ast_translation: string -> theory -> theory |
153 |
val parse_translation: string -> theory -> theory |
|
154 |
val print_translation: string -> theory -> theory |
|
155 |
val typed_print_translation: string -> theory -> theory |
|
156 |
val print_ast_translation: string -> theory -> theory |
|
157 |
val token_translation: string -> theory -> theory |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
158 |
val add_oracle: (bstring * string) * Comment.text -> theory -> theory |
6331 | 159 |
val begin_theory: string -> string list -> (string * bool) list -> theory |
160 |
val end_theory: theory -> theory |
|
7932 | 161 |
val kill_theory: string -> unit |
6246 | 162 |
val theory: string * string list * (string * bool) list |
163 |
-> Toplevel.transition -> Toplevel.transition |
|
7960 | 164 |
val init_context: ('a -> unit) -> 'a -> Toplevel.transition -> Toplevel.transition |
6246 | 165 |
val context: string -> Toplevel.transition -> Toplevel.transition |
5830 | 166 |
end; |
167 |
||
168 |
structure IsarThy: ISAR_THY = |
|
169 |
struct |
|
170 |
||
171 |
||
172 |
(** derived theory and proof operations **) |
|
173 |
||
8090 | 174 |
(* markup commands *) |
5959 | 175 |
|
7734 | 176 |
fun add_header comment = |
177 |
Toplevel.keep (fn state => if Toplevel.is_toplevel state then () else raise Toplevel.UNDEF); |
|
178 |
||
8090 | 179 |
fun add_text _ x = x; |
8079 | 180 |
fun add_text_raw _ x = x; |
7633 | 181 |
|
8090 | 182 |
fun add_heading add present txt thy = |
7633 | 183 |
(Context.setmp (Some thy) present (Comment.string_of txt); add txt thy); |
184 |
||
8090 | 185 |
val add_chapter = add_heading add_text Present.section; |
186 |
val add_section = add_heading add_text Present.section; |
|
187 |
val add_subsection = add_heading add_text Present.subsection; |
|
188 |
val add_subsubsection = add_heading add_text Present.subsubsection; |
|
5959 | 189 |
|
8090 | 190 |
fun add_txt (_: Comment.text) = ProofHistory.apply I; |
191 |
val add_txt_raw = add_txt; |
|
7332 | 192 |
val add_sect = add_txt; |
193 |
val add_subsect = add_txt; |
|
194 |
val add_subsubsect = add_txt; |
|
7172 | 195 |
|
5959 | 196 |
|
8724 | 197 |
(* name spaces *) |
198 |
||
199 |
fun global_path comment_ignore = PureThy.global_path; |
|
200 |
fun local_path comment_ignore = PureThy.local_path; |
|
201 |
||
202 |
fun gen_hide f ((kind, names), comment_ignore) thy = |
|
203 |
if kind mem_string [Sign.classK, Sign.typeK, Sign.constK] then f (kind, names) thy |
|
204 |
else error ("Bad name space specification: " ^ quote kind); |
|
205 |
||
8731 | 206 |
fun hide_space x = gen_hide Theory.hide_space x; |
207 |
fun hide_space_i x = gen_hide Theory.hide_space_i x; |
|
8724 | 208 |
|
209 |
||
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
210 |
(* signature and syntax *) |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
211 |
|
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
212 |
val add_classes = Theory.add_classes o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
213 |
val add_classes_i = Theory.add_classes_i o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
214 |
val add_classrel = Theory.add_classrel o single o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
215 |
val add_classrel_i = Theory.add_classrel_i o single o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
216 |
val add_defsort = Theory.add_defsort o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
217 |
val add_defsort_i = Theory.add_defsort_i o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
218 |
val add_nonterminals = Theory.add_nonterminals o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
219 |
val add_tyabbrs = Theory.add_tyabbrs o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
220 |
val add_tyabbrs_i = Theory.add_tyabbrs_i o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
221 |
val add_arities = Theory.add_arities o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
222 |
val add_arities_i = Theory.add_arities_i o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
223 |
val add_typedecl = PureThy.add_typedecls o single o Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
224 |
val add_consts = Theory.add_consts o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
225 |
val add_consts_i = Theory.add_consts_i o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
226 |
fun add_modesyntax mode = Theory.add_modesyntax mode o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
227 |
fun add_modesyntax_i mode = Theory.add_modesyntax_i mode o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
228 |
val add_trrules = Theory.add_trrules o map Comment.ignore; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
229 |
val add_trrules_i = Theory.add_trrules_i o map Comment.ignore; |
8227 | 230 |
val add_judgment = AutoBind.add_judgment o Comment.ignore; |
231 |
val add_judgment_i = AutoBind.add_judgment_i o Comment.ignore; |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
232 |
|
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
233 |
|
5830 | 234 |
(* axioms and defs *) |
235 |
||
5915 | 236 |
fun add_axms f args thy = |
237 |
f (map (fn (x, srcs) => (x, map (Attrib.global_attribute thy) srcs)) args) thy; |
|
238 |
||
8428 | 239 |
val add_axioms = add_axms (#1 oo PureThy.add_axioms) o map Comment.ignore; |
240 |
val add_axioms_i = (#1 oo PureThy.add_axioms_i) o map Comment.ignore; |
|
241 |
val add_defs = add_axms (#1 oo PureThy.add_defs) o map Comment.ignore; |
|
242 |
val add_defs_i = (#1 oo PureThy.add_defs_i) o map Comment.ignore; |
|
6371 | 243 |
|
244 |
||
245 |
(* constdefs *) |
|
246 |
||
247 |
fun gen_add_constdefs consts defs args thy = |
|
248 |
thy |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
249 |
|> consts (map (Comment.ignore o fst) args) |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
250 |
|> defs (map (fn (((c, _, mx), _), (s, _)) => |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
251 |
(((Thm.def_name (Syntax.const_name c mx), s), []), Comment.none)) args); |
6371 | 252 |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
253 |
fun add_constdefs args = gen_add_constdefs Theory.add_consts add_defs args; |
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
254 |
fun add_constdefs_i args = gen_add_constdefs Theory.add_consts_i add_defs_i args; |
5915 | 255 |
|
256 |
||
257 |
(* theorems *) |
|
258 |
||
259 |
fun gen_have_thmss get attrib f ((name, more_srcs), th_srcs) x = |
|
260 |
f name (map (attrib x) more_srcs) |
|
261 |
(map (fn (s, srcs) => (get x s, map (attrib x) srcs)) th_srcs) x; |
|
262 |
||
7572 | 263 |
fun global_have_thmss kind f (x as ((name, _), _)) thy = |
264 |
let val (thy', thms) = gen_have_thmss PureThy.get_thms Attrib.global_attribute f x thy in |
|
265 |
if kind <> "" then Context.setmp (Some thy') (Present.results kind name) thms else (); |
|
266 |
(thy', thms) |
|
267 |
end; |
|
5915 | 268 |
|
6371 | 269 |
fun local_have_thmss x = |
270 |
gen_have_thmss (ProofContext.get_thms o Proof.context_of) |
|
271 |
(Attrib.local_attribute o Proof.theory_of) x; |
|
272 |
||
7012 | 273 |
fun gen_have_thmss_i f ((name, more_atts), th_atts) = |
6371 | 274 |
f name more_atts (map (apfst single) th_atts); |
275 |
||
276 |
fun have_lemss name atts = PureThy.have_thmss name (atts @ [Drule.tag_lemma]); |
|
5915 | 277 |
|
278 |
||
7572 | 279 |
fun apply_theorems th_srcs = global_have_thmss "" PureThy.have_thmss (("", []), th_srcs); |
7476 | 280 |
fun apply_theorems_i th_srcs = gen_have_thmss_i PureThy.have_thmss (("", []), th_srcs); |
7572 | 281 |
val have_theorems = #1 oo (global_have_thmss "theorems" PureThy.have_thmss o Comment.ignore); |
7476 | 282 |
val have_theorems_i = #1 oo (gen_have_thmss_i PureThy.have_thmss o Comment.ignore); |
7572 | 283 |
val have_lemmas = #1 oo (global_have_thmss "lemmas" have_lemss o Comment.ignore); |
7476 | 284 |
val have_lemmas_i = #1 oo (gen_have_thmss_i have_lemss o Comment.ignore); |
6879 | 285 |
val have_facts = ProofHistory.apply o local_have_thmss (Proof.have_thmss []) o Comment.ignore; |
7012 | 286 |
val have_facts_i = ProofHistory.apply o gen_have_thmss_i (Proof.have_thmss []) o Comment.ignore; |
6371 | 287 |
|
5915 | 288 |
|
6371 | 289 |
(* forward chaining *) |
290 |
||
6879 | 291 |
fun gen_from_facts f = ProofHistory.apply o (Proof.chain oo curry f ("", [])); |
292 |
||
293 |
fun add_thmss name atts ths_atts state = |
|
294 |
Proof.have_thmss (Proof.the_facts state) name atts ths_atts state; |
|
6371 | 295 |
|
6879 | 296 |
val from_facts = gen_from_facts (local_have_thmss (Proof.have_thmss [])) o Comment.ignore; |
7012 | 297 |
val from_facts_i = gen_from_facts (gen_have_thmss_i (Proof.have_thmss [])) o Comment.ignore; |
6879 | 298 |
val with_facts = gen_from_facts (local_have_thmss add_thmss) o Comment.ignore; |
7012 | 299 |
val with_facts_i = gen_from_facts (gen_have_thmss_i add_thmss) o Comment.ignore; |
6879 | 300 |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
301 |
fun chain comment_ignore = ProofHistory.apply Proof.chain; |
5830 | 302 |
|
303 |
||
304 |
(* context *) |
|
305 |
||
7417 | 306 |
val fix = ProofHistory.apply o Proof.fix o map Comment.ignore; |
307 |
val fix_i = ProofHistory.apply o Proof.fix_i o map Comment.ignore; |
|
8615 | 308 |
val let_bind = ProofHistory.apply o Proof.let_bind o map Comment.ignore; |
309 |
val let_bind_i = ProofHistory.apply o Proof.let_bind_i o map Comment.ignore; |
|
8450 | 310 |
|
311 |
fun invoke_case ((name, src), comment_ignore) = ProofHistory.apply (fn state => |
|
312 |
Proof.invoke_case (name, map (Attrib.local_attribute (Proof.theory_of state)) src) state); |
|
313 |
val invoke_case_i = ProofHistory.apply o Proof.invoke_case o Comment.ignore; |
|
5830 | 314 |
|
315 |
||
316 |
(* statements *) |
|
317 |
||
7271 | 318 |
local |
319 |
||
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
320 |
fun global_statement f (name, src, s) int thy = |
6688 | 321 |
ProofHistory.init (Toplevel.undo_limit int) |
322 |
(f name (map (Attrib.global_attribute thy) src) s thy); |
|
5830 | 323 |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
324 |
fun global_statement_i f (name, atts, t) int thy = |
6688 | 325 |
ProofHistory.init (Toplevel.undo_limit int) (f name atts t thy); |
6501 | 326 |
|
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
327 |
fun local_statement f g (name, src, s) = ProofHistory.apply (fn state => |
6501 | 328 |
f name (map (Attrib.local_attribute (Proof.theory_of state)) src) s (g state)); |
6371 | 329 |
|
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
330 |
fun local_statement_i f g (name, atts, t) = ProofHistory.apply (f name atts t o g); |
5830 | 331 |
|
8090 | 332 |
fun multi_local_attribute state (name, src, s) = |
333 |
(name, map (Attrib.local_attribute (Proof.theory_of state)) src, s); |
|
334 |
||
7271 | 335 |
fun multi_statement f args = ProofHistory.apply (fn state => |
7678 | 336 |
f (map (multi_local_attribute state) args) state); |
7271 | 337 |
|
338 |
fun multi_statement_i f args = ProofHistory.apply (f args); |
|
339 |
||
340 |
in |
|
341 |
||
6952 | 342 |
val theorem = global_statement Proof.theorem o Comment.ignore; |
343 |
val theorem_i = global_statement_i Proof.theorem_i o Comment.ignore; |
|
344 |
val lemma = global_statement Proof.lemma o Comment.ignore; |
|
345 |
val lemma_i = global_statement_i Proof.lemma_i o Comment.ignore; |
|
7271 | 346 |
val assume = multi_statement Proof.assume o map Comment.ignore; |
347 |
val assume_i = multi_statement_i Proof.assume_i o map Comment.ignore; |
|
348 |
val presume = multi_statement Proof.presume o map Comment.ignore; |
|
349 |
val presume_i = multi_statement_i Proof.presume_i o map Comment.ignore; |
|
6952 | 350 |
val local_def = local_statement LocalDefs.def I o Comment.ignore; |
351 |
val local_def_i = local_statement LocalDefs.def_i I o Comment.ignore; |
|
7176 | 352 |
val show = local_statement (Proof.show Seq.single) I o Comment.ignore; |
353 |
val show_i = local_statement_i (Proof.show_i Seq.single) I o Comment.ignore; |
|
354 |
val have = local_statement (Proof.have Seq.single) I o Comment.ignore; |
|
355 |
val have_i = local_statement_i (Proof.have_i Seq.single) I o Comment.ignore; |
|
356 |
val thus = local_statement (Proof.show Seq.single) Proof.chain o Comment.ignore; |
|
357 |
val thus_i = local_statement_i (Proof.show_i Seq.single) Proof.chain o Comment.ignore; |
|
358 |
val hence = local_statement (Proof.have Seq.single) Proof.chain o Comment.ignore; |
|
359 |
val hence_i = local_statement_i (Proof.have_i Seq.single) Proof.chain o Comment.ignore; |
|
5830 | 360 |
|
7271 | 361 |
end; |
362 |
||
5830 | 363 |
|
364 |
(* blocks *) |
|
365 |
||
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
366 |
val begin_block = ProofHistory.apply Proof.begin_block; |
5830 | 367 |
val next_block = ProofHistory.apply Proof.next_block; |
6937 | 368 |
val end_block = ProofHistory.applys Proof.end_block; |
5830 | 369 |
|
370 |
||
8165 | 371 |
(* shuffle state *) |
372 |
||
8236 | 373 |
fun shuffle meth i = Method.refine (Method.Basic (K (meth i))) o Proof.assert_no_chain; |
8204 | 374 |
|
8681 | 375 |
fun defer (i, comment_ignore) = ProofHistory.applys (shuffle Method.defer i); |
376 |
fun prefer (i, comment_ignore) = ProofHistory.applys (shuffle Method.prefer i); |
|
8165 | 377 |
|
378 |
||
5830 | 379 |
(* backward steps *) |
380 |
||
8681 | 381 |
fun apply (m, comment_ignore) = ProofHistory.applys (Method.refine m o Proof.assert_backward); |
382 |
fun apply_end (m, comment_ignore) = |
|
383 |
ProofHistory.applys (Method.refine_end m o Proof.assert_forward); |
|
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
384 |
|
7002 | 385 |
val proof = ProofHistory.applys o Method.proof o |
386 |
apsome Comment.ignore_interest o Comment.ignore_interest' o Comment.ignore; |
|
6404 | 387 |
|
388 |
||
6732 | 389 |
(* print result *) |
390 |
||
7572 | 391 |
local |
392 |
||
6732 | 393 |
fun pretty_result {kind, name, thm} = |
7590 | 394 |
Pretty.block [Pretty.str (kind ^ (if name = "" then "" else " " ^ name) ^ ":"), |
7572 | 395 |
Pretty.fbrk, Proof.pretty_thm thm]; |
6986 | 396 |
|
397 |
fun pretty_rule thm = |
|
7353 | 398 |
Pretty.block [Pretty.str "trying to solve goal by rule:", Pretty.fbrk, Proof.pretty_thm thm]; |
6732 | 399 |
|
7572 | 400 |
in |
401 |
||
6732 | 402 |
val print_result = Pretty.writeln o pretty_result; |
403 |
||
6986 | 404 |
fun cond_print_result_rule int = |
405 |
if int then (print_result, Pretty.writeln o pretty_rule) |
|
406 |
else (K (), K ()); |
|
407 |
||
408 |
fun proof'' f = Toplevel.proof' (f o cond_print_result_rule); |
|
6732 | 409 |
|
7572 | 410 |
end; |
411 |
||
6732 | 412 |
|
6404 | 413 |
(* local endings *) |
414 |
||
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
415 |
val local_qed = |
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
416 |
proof'' o (ProofHistory.applys oo Method.local_qed) o apsome Comment.ignore_interest; |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
417 |
|
6937 | 418 |
fun ignore_interests (x, y) = (Comment.ignore_interest x, apsome Comment.ignore_interest y); |
419 |
||
6688 | 420 |
val local_terminal_proof = |
6937 | 421 |
proof'' o (ProofHistory.applys oo Method.local_terminal_proof) o ignore_interests; |
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
422 |
|
6904
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
423 |
val local_immediate_proof = proof'' (ProofHistory.applys o Method.local_immediate_proof); |
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
424 |
val local_default_proof = proof'' (ProofHistory.applys o Method.local_default_proof); |
4125d6b6d8f9
removed proof history nesting commands (not useful);
wenzelm
parents:
6890
diff
changeset
|
425 |
val local_skip_proof = proof'' (ProofHistory.applys o SkipProof.local_skip_proof); |
6404 | 426 |
|
427 |
||
428 |
(* global endings *) |
|
429 |
||
430 |
fun global_result finish = Toplevel.proof_to_theory (fn prf => |
|
431 |
let |
|
432 |
val state = ProofHistory.current prf; |
|
433 |
val _ = if Proof.at_bottom state then () else raise Toplevel.UNDEF; |
|
7572 | 434 |
val (thy, res as {kind, name, thm}) = finish state; |
435 |
in print_result res; Context.setmp (Some thy) (Present.result kind name) thm; thy end); |
|
6404 | 436 |
|
6952 | 437 |
val global_qed = global_result o Method.global_qed o apsome Comment.ignore_interest; |
6937 | 438 |
val global_terminal_proof = global_result o Method.global_terminal_proof o ignore_interests; |
6404 | 439 |
val global_immediate_proof = global_result Method.global_immediate_proof; |
440 |
val global_default_proof = global_result Method.global_default_proof; |
|
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6885
diff
changeset
|
441 |
val global_skip_proof = global_result SkipProof.global_skip_proof; |
6404 | 442 |
|
443 |
||
444 |
(* common endings *) |
|
445 |
||
7002 | 446 |
fun qed (meth, comment) = local_qed meth o global_qed meth; |
447 |
fun terminal_proof (meths, comment) = local_terminal_proof meths o global_terminal_proof meths; |
|
448 |
fun immediate_proof comment = local_immediate_proof o global_immediate_proof; |
|
449 |
fun default_proof comment = local_default_proof o global_default_proof; |
|
450 |
fun skip_proof comment = local_skip_proof o global_skip_proof; |
|
5830 | 451 |
|
8210 | 452 |
fun forget_proof comment = Toplevel.proof_to_theory (Proof.theory_of o ProofHistory.current); |
453 |
||
5830 | 454 |
|
6774 | 455 |
(* calculational proof commands *) |
456 |
||
6879 | 457 |
local |
458 |
||
7417 | 459 |
fun cond_print_calc int thms = |
460 |
if int then Pretty.writeln (Pretty.big_list "calculation:" (map Proof.pretty_thm thms)) |
|
6774 | 461 |
else (); |
462 |
||
463 |
fun proof''' f = Toplevel.proof' (f o cond_print_calc); |
|
464 |
||
6879 | 465 |
fun gen_calc get f (args, _) prt state = |
466 |
f (apsome (fn (srcs, _) => get srcs state) args) prt state; |
|
467 |
||
468 |
in |
|
469 |
||
7012 | 470 |
fun get_thmss srcs = Proof.the_facts o local_have_thmss (Proof.have_thmss []) (("", []), srcs); |
471 |
fun get_thmss_i thms _ = thms; |
|
472 |
||
6879 | 473 |
fun also x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.also x); |
474 |
fun also_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.also x); |
|
475 |
fun finally x = proof''' (ProofHistory.applys o gen_calc get_thmss Calculation.finally x); |
|
476 |
fun finally_i x = proof''' (ProofHistory.applys o gen_calc get_thmss_i Calculation.finally x); |
|
8562 | 477 |
fun moreover comment = proof''' (ProofHistory.apply o Calculation.moreover); |
8588 | 478 |
fun ultimately comment = proof''' (ProofHistory.apply o Calculation.ultimately); |
6879 | 479 |
|
480 |
end; |
|
6774 | 481 |
|
482 |
||
5830 | 483 |
(* translation functions *) |
484 |
||
485 |
val parse_ast_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
486 |
Context.use_let "parse_ast_translation: (string * (Syntax.ast list -> Syntax.ast)) list" |
5830 | 487 |
"Theory.add_trfuns (parse_ast_translation, [], [], [])"; |
488 |
||
489 |
val parse_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
490 |
Context.use_let "parse_translation: (string * (term list -> term)) list" |
5830 | 491 |
"Theory.add_trfuns ([], parse_translation, [], [])"; |
492 |
||
493 |
val print_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
494 |
Context.use_let "print_translation: (string * (term list -> term)) list" |
5830 | 495 |
"Theory.add_trfuns ([], [], print_translation, [])"; |
496 |
||
497 |
val print_ast_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
498 |
Context.use_let "print_ast_translation: (string * (Syntax.ast list -> Syntax.ast)) list" |
5830 | 499 |
"Theory.add_trfuns ([], [], [], print_ast_translation)"; |
500 |
||
501 |
val typed_print_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
502 |
Context.use_let "typed_print_translation: (string * (bool -> typ -> term list -> term)) list" |
5830 | 503 |
"Theory.add_trfunsT typed_print_translation"; |
504 |
||
505 |
val token_translation = |
|
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
506 |
Context.use_let "token_translation: (string * string * (string -> string * int)) list" |
5830 | 507 |
"Theory.add_tokentrfuns token_translation"; |
508 |
||
509 |
||
510 |
(* add_oracle *) |
|
511 |
||
6728
b51b25db7bc6
added formal comment arguments almost everywhere (still ignored);
wenzelm
parents:
6688
diff
changeset
|
512 |
fun add_oracle ((name, txt), comment_ignore) = |
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8236
diff
changeset
|
513 |
Context.use_let |
5830 | 514 |
"oracle: bstring * (Sign.sg * Object.T -> term)" |
515 |
"Theory.add_oracle oracle" |
|
516 |
("(" ^ quote name ^ ", " ^ txt ^ ")"); |
|
517 |
||
518 |
||
6688 | 519 |
(* theory init and exit *) |
5830 | 520 |
|
7242 | 521 |
fun gen_begin_theory bg name parents files = |
6266 | 522 |
let |
6331 | 523 |
val paths = map (apfst Path.unpack) files; |
7242 | 524 |
val thy = bg name parents paths; |
6650
808a3d9e2404
Present.begin_theory now needs an additional argument of type
berghofe
parents:
6552
diff
changeset
|
525 |
in Present.begin_theory name parents paths thy end; |
5830 | 526 |
|
7242 | 527 |
val begin_theory = gen_begin_theory ThyInfo.begin_theory; |
528 |
val begin_update_theory = gen_begin_theory ThyInfo.begin_update_theory; |
|
7909 | 529 |
|
530 |
fun end_theory thy = |
|
7932 | 531 |
if ThyInfo.check_known_thy (PureThy.get_name thy) then ThyInfo.end_theory thy |
7909 | 532 |
else thy; |
533 |
||
7932 | 534 |
val kill_theory = ThyInfo.if_known_thy ThyInfo.remove_thy; |
6688 | 535 |
|
7103 | 536 |
|
537 |
fun bg_theory (name, parents, files) int = |
|
7242 | 538 |
(if int then begin_update_theory else begin_theory) name parents files; |
7103 | 539 |
|
6331 | 540 |
fun en_theory thy = (end_theory thy; ()); |
541 |
||
7932 | 542 |
fun theory spec = Toplevel.init_theory (bg_theory spec) en_theory (kill_theory o PureThy.get_name); |
6246 | 543 |
|
544 |
||
545 |
(* context switch *) |
|
546 |
||
7960 | 547 |
fun fetch_context f x = |
548 |
(case Context.pass None f x of |
|
549 |
((), None) => raise Toplevel.UNDEF |
|
550 |
| ((), Some thy) => thy); |
|
551 |
||
552 |
fun init_context f x = Toplevel.init_theory (fn _ => fetch_context f x) (K ()) (K ()); |
|
7953 | 553 |
|
554 |
val context = init_context (ThyInfo.quiet_update_thy true); |
|
6246 | 555 |
|
5830 | 556 |
|
557 |
end; |