5832
|
1 |
(* Title: Pure/Isar/isar_syn.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Muenchen
|
|
4 |
|
6353
|
5 |
Isar/Pure outer syntax.
|
5832
|
6 |
*)
|
|
7 |
|
|
8 |
signature ISAR_SYN =
|
|
9 |
sig
|
|
10 |
val keywords: string list
|
|
11 |
val parsers: OuterSyntax.parser list
|
|
12 |
end;
|
|
13 |
|
|
14 |
structure IsarSyn: ISAR_SYN =
|
|
15 |
struct
|
|
16 |
|
|
17 |
open OuterParse;
|
|
18 |
|
|
19 |
|
|
20 |
(** init and exit **)
|
|
21 |
|
|
22 |
val theoryP =
|
6370
|
23 |
OuterSyntax.command "theory" "begin theory"
|
6245
|
24 |
(OuterSyntax.theory_header >> (Toplevel.print oo IsarThy.theory));
|
5832
|
25 |
|
6687
|
26 |
val end_excursionP =
|
|
27 |
OuterSyntax.command "end" "end current excursion"
|
|
28 |
(Scan.succeed (Toplevel.print o Toplevel.exit));
|
|
29 |
|
|
30 |
val kill_excursionP =
|
|
31 |
OuterSyntax.command "kill" "kill current excursion"
|
|
32 |
(Scan.succeed (Toplevel.print o Toplevel.kill));
|
5832
|
33 |
|
6245
|
34 |
val contextP =
|
6370
|
35 |
OuterSyntax.improper_command "context" "switch theory context"
|
6245
|
36 |
(name >> (Toplevel.print oo IsarThy.context));
|
|
37 |
|
|
38 |
val update_contextP =
|
6370
|
39 |
OuterSyntax.improper_command "update_context" "switch theory context, forcing update"
|
6245
|
40 |
(name >> (Toplevel.print oo IsarThy.update_context));
|
|
41 |
|
5832
|
42 |
|
|
43 |
|
|
44 |
(** theory sections **)
|
|
45 |
|
|
46 |
(* formal comments *)
|
|
47 |
|
6370
|
48 |
val textP = OuterSyntax.command "text" "formal comments"
|
6551
|
49 |
(comment >> (Toplevel.theory o IsarThy.add_text));
|
5958
|
50 |
|
6370
|
51 |
val titleP = OuterSyntax.command "title" "document title"
|
6551
|
52 |
((comment -- Scan.optional comment Comment.empty -- Scan.optional comment Comment.empty)
|
6353
|
53 |
>> (fn ((x, y), z) => Toplevel.theory (IsarThy.add_title x y z)));
|
|
54 |
|
6370
|
55 |
val chapterP = OuterSyntax.command "chapter" "chapter heading"
|
6551
|
56 |
(comment >> (Toplevel.theory o IsarThy.add_chapter));
|
5958
|
57 |
|
6370
|
58 |
val sectionP = OuterSyntax.command "section" "section heading"
|
6551
|
59 |
(comment >> (Toplevel.theory o IsarThy.add_section));
|
5958
|
60 |
|
6370
|
61 |
val subsectionP = OuterSyntax.command "subsection" "subsection heading"
|
6551
|
62 |
(comment >> (Toplevel.theory o IsarThy.add_subsection));
|
5958
|
63 |
|
6370
|
64 |
val subsubsectionP = OuterSyntax.command "subsubsection" "subsubsection heading"
|
6551
|
65 |
(comment >> (Toplevel.theory o IsarThy.add_subsubsection));
|
5832
|
66 |
|
|
67 |
|
|
68 |
(* classes and sorts *)
|
|
69 |
|
|
70 |
val classesP =
|
6370
|
71 |
OuterSyntax.command "classes" "declare type classes"
|
5832
|
72 |
(Scan.repeat1 (name -- Scan.optional ($$$ "<" |-- !!! (list1 xname)) [])
|
|
73 |
>> (Toplevel.theory o Theory.add_classes));
|
|
74 |
|
|
75 |
val classrelP =
|
6370
|
76 |
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)"
|
5832
|
77 |
(xname -- ($$$ "<" |-- !!! xname) >> (Toplevel.theory o Theory.add_classrel o single));
|
|
78 |
|
|
79 |
val defaultsortP =
|
6370
|
80 |
OuterSyntax.command "defaultsort" "declare default sort"
|
5832
|
81 |
(sort >> (Toplevel.theory o Theory.add_defsort));
|
|
82 |
|
|
83 |
|
|
84 |
(* types *)
|
|
85 |
|
|
86 |
val typedeclP =
|
6370
|
87 |
OuterSyntax.command "typedecl" "Pure type declaration"
|
5832
|
88 |
(type_args -- name -- opt_infix
|
|
89 |
>> (fn ((args, a), mx) => Toplevel.theory (PureThy.add_typedecls [(a, args, mx)])));
|
|
90 |
|
|
91 |
val typeabbrP =
|
6370
|
92 |
OuterSyntax.command "types" "declare type abbreviations"
|
5832
|
93 |
(Scan.repeat1 (type_args -- name -- ($$$ "=" |-- !!! (typ -- opt_infix)))
|
|
94 |
>> (Toplevel.theory o Theory.add_tyabbrs o
|
|
95 |
map (fn ((args, a), (T, mx)) => (a, args, T, mx))));
|
|
96 |
|
|
97 |
val nontermP =
|
6370
|
98 |
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols"
|
5832
|
99 |
(Scan.repeat1 name >> (Toplevel.theory o Theory.add_nonterminals));
|
|
100 |
|
|
101 |
val aritiesP =
|
6370
|
102 |
OuterSyntax.command "arities" "state type arities (axiomatic!)"
|
5832
|
103 |
(Scan.repeat1 (xname -- ($$$ "::" |-- !!! arity) >> triple2)
|
|
104 |
>> (Toplevel.theory o Theory.add_arities));
|
|
105 |
|
|
106 |
|
|
107 |
(* consts and syntax *)
|
|
108 |
|
|
109 |
val constsP =
|
6370
|
110 |
OuterSyntax.command "consts" "declare constants"
|
5832
|
111 |
(Scan.repeat1 const >> (Toplevel.theory o Theory.add_consts));
|
|
112 |
|
|
113 |
val opt_mode =
|
|
114 |
Scan.optional
|
|
115 |
($$$ "(" |-- !!! (name -- Scan.optional ($$$ "output" >> K false) true --| $$$ ")"))
|
|
116 |
("", true);
|
|
117 |
|
|
118 |
val syntaxP =
|
6370
|
119 |
OuterSyntax.command "syntax" "declare syntactic constants"
|
5832
|
120 |
(opt_mode -- Scan.repeat1 const >> (Toplevel.theory o uncurry Theory.add_modesyntax));
|
|
121 |
|
|
122 |
|
|
123 |
(* translations *)
|
|
124 |
|
|
125 |
val trans_pat =
|
|
126 |
Scan.optional ($$$ "(" |-- !!! (xname --| $$$ ")")) "logic" -- string;
|
|
127 |
|
|
128 |
fun trans_arrow toks =
|
|
129 |
($$$ "=>" >> K Syntax.ParseRule ||
|
|
130 |
$$$ "<=" >> K Syntax.PrintRule ||
|
|
131 |
$$$ "==" >> K Syntax.ParsePrintRule) toks;
|
|
132 |
|
|
133 |
val trans_line =
|
|
134 |
trans_pat -- !!! (trans_arrow -- trans_pat)
|
|
135 |
>> (fn (left, (arr, right)) => arr (left, right));
|
|
136 |
|
|
137 |
val translationsP =
|
6370
|
138 |
OuterSyntax.command "translations" "declare syntax translation rules"
|
5832
|
139 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Theory.add_trrules));
|
|
140 |
|
|
141 |
|
|
142 |
(* axioms and definitions *)
|
|
143 |
|
|
144 |
val axiomsP =
|
6370
|
145 |
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)"
|
|
146 |
(Scan.repeat1 spec_name >> (Toplevel.theory o IsarThy.add_axioms));
|
5832
|
147 |
|
|
148 |
val defsP =
|
6370
|
149 |
OuterSyntax.command "defs" "define constants"
|
|
150 |
(Scan.repeat1 spec_opt_name >> (Toplevel.theory o IsarThy.add_defs));
|
|
151 |
|
|
152 |
val constdefsP =
|
|
153 |
OuterSyntax.command "constdefs" "declare and define constants"
|
|
154 |
(Scan.repeat1 (const -- term) >> (Toplevel.theory o IsarThy.add_constdefs));
|
5832
|
155 |
|
|
156 |
|
5914
|
157 |
(* theorems *)
|
|
158 |
|
|
159 |
val facts = opt_thm_name "=" -- xthms1;
|
|
160 |
|
|
161 |
val theoremsP =
|
6370
|
162 |
OuterSyntax.command "theorems" "define theorems"
|
5914
|
163 |
(facts >> (Toplevel.theory o IsarThy.have_theorems));
|
|
164 |
|
|
165 |
val lemmasP =
|
6370
|
166 |
OuterSyntax.command "lemmas" "define lemmas"
|
5914
|
167 |
(facts >> (Toplevel.theory o IsarThy.have_lemmas));
|
|
168 |
|
|
169 |
|
5832
|
170 |
(* name space entry path *)
|
|
171 |
|
|
172 |
val globalP =
|
6370
|
173 |
OuterSyntax.command "global" "disable prefixing of theory name"
|
5832
|
174 |
(Scan.succeed (Toplevel.theory PureThy.global_path));
|
|
175 |
|
|
176 |
val localP =
|
6370
|
177 |
OuterSyntax.command "local" "enable prefixing of theory name"
|
5832
|
178 |
(Scan.succeed (Toplevel.theory PureThy.local_path));
|
|
179 |
|
|
180 |
val pathP =
|
6370
|
181 |
OuterSyntax.command "path" "modify name-space entry path"
|
5832
|
182 |
(xname >> (Toplevel.theory o Theory.add_path));
|
|
183 |
|
|
184 |
|
|
185 |
(* use ML text *)
|
|
186 |
|
|
187 |
val useP =
|
6370
|
188 |
OuterSyntax.command "use" "eval ML text from file"
|
5958
|
189 |
(name >> IsarCmd.use);
|
5832
|
190 |
|
|
191 |
val mlP =
|
6370
|
192 |
OuterSyntax.command "ML" "eval ML text"
|
5832
|
193 |
(text >> (fn txt => IsarCmd.use_mltext txt o IsarCmd.use_mltext_theory txt));
|
|
194 |
|
|
195 |
val setupP =
|
6370
|
196 |
OuterSyntax.command "setup" "apply ML theory transformer"
|
5832
|
197 |
(text >> (Toplevel.theory o IsarThy.use_setup));
|
|
198 |
|
|
199 |
|
|
200 |
(* translation functions *)
|
|
201 |
|
|
202 |
val parse_ast_translationP =
|
6370
|
203 |
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions"
|
5832
|
204 |
(text >> (Toplevel.theory o IsarThy.parse_ast_translation));
|
|
205 |
|
|
206 |
val parse_translationP =
|
6370
|
207 |
OuterSyntax.command "parse_translation" "install parse translation functions"
|
5832
|
208 |
(text >> (Toplevel.theory o IsarThy.parse_translation));
|
|
209 |
|
|
210 |
val print_translationP =
|
6370
|
211 |
OuterSyntax.command "print_translation" "install print translation functions"
|
5832
|
212 |
(text >> (Toplevel.theory o IsarThy.print_translation));
|
|
213 |
|
|
214 |
val typed_print_translationP =
|
6370
|
215 |
OuterSyntax.command "typed_print_translation" "install typed print translation functions"
|
5832
|
216 |
(text >> (Toplevel.theory o IsarThy.typed_print_translation));
|
|
217 |
|
|
218 |
val print_ast_translationP =
|
6370
|
219 |
OuterSyntax.command "print_ast_translation" "install print ast translation functions"
|
5832
|
220 |
(text >> (Toplevel.theory o IsarThy.print_ast_translation));
|
|
221 |
|
|
222 |
val token_translationP =
|
6370
|
223 |
OuterSyntax.command "token_translation" "install token translation functions"
|
5832
|
224 |
(text >> (Toplevel.theory o IsarThy.token_translation));
|
|
225 |
|
|
226 |
|
|
227 |
(* oracles *)
|
|
228 |
|
|
229 |
val oracleP =
|
6370
|
230 |
OuterSyntax.command "oracle" "install oracle"
|
5832
|
231 |
(name -- text >> (Toplevel.theory o IsarThy.add_oracle));
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
(** proof commands **)
|
|
236 |
|
|
237 |
(* statements *)
|
|
238 |
|
5937
|
239 |
val is_props = $$$ "(" |-- !!! (Scan.repeat1 ($$$ "is" |-- prop) --| $$$ ")");
|
|
240 |
val propp = prop -- Scan.optional is_props [];
|
|
241 |
fun statement f = opt_thm_name ":" -- propp >> (fn ((x, y), z) => f x y z);
|
5832
|
242 |
|
|
243 |
val theoremP =
|
6370
|
244 |
OuterSyntax.command "theorem" "state theorem"
|
5832
|
245 |
(statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
|
|
246 |
|
|
247 |
val lemmaP =
|
6370
|
248 |
OuterSyntax.command "lemma" "state lemma"
|
5832
|
249 |
(statement IsarThy.lemma >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
|
|
250 |
|
|
251 |
val showP =
|
6370
|
252 |
OuterSyntax.command "show" "state local goal, solving current obligation"
|
5832
|
253 |
(statement IsarThy.show >> (fn f => Toplevel.print o Toplevel.proof f));
|
|
254 |
|
|
255 |
val haveP =
|
6370
|
256 |
OuterSyntax.command "have" "state local goal"
|
5832
|
257 |
(statement IsarThy.have >> (fn f => Toplevel.print o Toplevel.proof f));
|
|
258 |
|
6501
|
259 |
val thusP =
|
|
260 |
OuterSyntax.command "thus" "abbreviates \"then show\""
|
|
261 |
(statement IsarThy.thus >> (fn f => Toplevel.print o Toplevel.proof f));
|
|
262 |
|
|
263 |
val henceP =
|
|
264 |
OuterSyntax.command "hence" "abbreviates \"then have\""
|
|
265 |
(statement IsarThy.hence >> (fn f => Toplevel.print o Toplevel.proof f));
|
|
266 |
|
5832
|
267 |
|
5914
|
268 |
(* facts *)
|
5832
|
269 |
|
|
270 |
val thenP =
|
6370
|
271 |
OuterSyntax.command "then" "forward chaining"
|
5832
|
272 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.chain));
|
|
273 |
|
|
274 |
val fromP =
|
6370
|
275 |
OuterSyntax.command "from" "forward chaining from given facts"
|
5914
|
276 |
(xthms1 >> (fn x => Toplevel.print o Toplevel.proof (IsarThy.from_facts x)));
|
|
277 |
|
|
278 |
val factsP =
|
6370
|
279 |
OuterSyntax.command "note" "define facts"
|
5914
|
280 |
(facts >> (Toplevel.proof o IsarThy.have_facts));
|
5832
|
281 |
|
|
282 |
|
|
283 |
(* proof context *)
|
|
284 |
|
|
285 |
val assumeP =
|
6370
|
286 |
OuterSyntax.command "assume" "assume propositions"
|
|
287 |
(opt_thm_name ":" -- Scan.repeat1 propp >>
|
5832
|
288 |
(fn ((x, y), z) => Toplevel.print o Toplevel.proof (IsarThy.assume x y z)));
|
|
289 |
|
|
290 |
val fixP =
|
6370
|
291 |
OuterSyntax.command "fix" "fix variables (Skolem constants)"
|
|
292 |
(Scan.repeat1 (name -- Scan.option ($$$ "::" |-- typ))
|
5832
|
293 |
>> (fn xs => Toplevel.print o Toplevel.proof (IsarThy.fix xs)));
|
|
294 |
|
|
295 |
val letP =
|
6370
|
296 |
OuterSyntax.command "let" "bind text variables"
|
6013
|
297 |
(and_list1 (enum1 "as" term -- ($$$ "=" |-- term))
|
5832
|
298 |
>> (fn bs => Toplevel.print o Toplevel.proof (IsarThy.match_bind bs)));
|
|
299 |
|
|
300 |
|
|
301 |
(* proof structure *)
|
|
302 |
|
|
303 |
val beginP =
|
6687
|
304 |
OuterSyntax.command "{{" "begin explicit proof block"
|
5832
|
305 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.begin_block));
|
|
306 |
|
6687
|
307 |
val endP =
|
|
308 |
OuterSyntax.command "}}" "end explicit proof block"
|
|
309 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.end_block));
|
|
310 |
|
5832
|
311 |
val nextP =
|
6687
|
312 |
OuterSyntax.command "next" "enter next proof block"
|
5832
|
313 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.next_block));
|
|
314 |
|
|
315 |
|
|
316 |
(* end proof *)
|
|
317 |
|
6404
|
318 |
val kill_proofP =
|
6687
|
319 |
OuterSyntax.improper_command "kill_proof" "abort current proof"
|
6404
|
320 |
(Scan.succeed (Toplevel.print o Toplevel.proof_to_theory IsarThy.kill_proof));
|
5832
|
321 |
|
|
322 |
val qed_withP =
|
6370
|
323 |
OuterSyntax.improper_command "qed_with" "conclude proof, may patch name and attributes"
|
6404
|
324 |
(Scan.option name -- Scan.option attribs -- Scan.option method
|
|
325 |
>> (uncurry IsarThy.global_qed_with));
|
|
326 |
|
|
327 |
val qedP =
|
|
328 |
OuterSyntax.command "qed" "conclude (sub-)proof"
|
|
329 |
(Scan.option method >> IsarThy.qed);
|
5832
|
330 |
|
6404
|
331 |
val terminal_proofP =
|
|
332 |
OuterSyntax.command "by" "terminal backward proof"
|
6530
|
333 |
(method >> IsarThy.terminal_proof)
|
6404
|
334 |
|
|
335 |
val immediate_proofP =
|
|
336 |
OuterSyntax.command "." "immediate proof"
|
6530
|
337 |
(Scan.succeed IsarThy.immediate_proof);
|
6404
|
338 |
|
|
339 |
val default_proofP =
|
|
340 |
OuterSyntax.command ".." "default proof"
|
6530
|
341 |
(Scan.succeed IsarThy.default_proof);
|
5832
|
342 |
|
|
343 |
|
|
344 |
(* proof steps *)
|
|
345 |
|
6404
|
346 |
val refineP =
|
|
347 |
OuterSyntax.improper_command "refine" "unstructured backward proof step, ignoring facts"
|
|
348 |
(method >> (Toplevel.print oo (Toplevel.proof o IsarThy.tac)));
|
5832
|
349 |
|
6404
|
350 |
val then_refineP =
|
|
351 |
OuterSyntax.improper_command "then_refine" "unstructured backward proof step, using facts"
|
|
352 |
(method >> (Toplevel.print oo (Toplevel.proof o IsarThy.then_tac)));
|
5832
|
353 |
|
6404
|
354 |
val proofP =
|
|
355 |
OuterSyntax.command "proof" "backward proof"
|
|
356 |
(Scan.option method >> (Toplevel.print oo (Toplevel.proof o IsarThy.proof)));
|
5832
|
357 |
|
|
358 |
|
|
359 |
(* proof history *)
|
|
360 |
|
|
361 |
val clear_undoP =
|
6687
|
362 |
OuterSyntax.improper_command "clear_undo" "clear undo information"
|
|
363 |
(Scan.succeed (Toplevel.print o IsarCmd.clear_undo));
|
5832
|
364 |
|
|
365 |
val undoP =
|
6687
|
366 |
OuterSyntax.improper_command "undo" "undo last command"
|
|
367 |
(Scan.succeed (Toplevel.print o IsarCmd.undo));
|
5832
|
368 |
|
|
369 |
val redoP =
|
6687
|
370 |
OuterSyntax.improper_command "redo" "redo last command"
|
|
371 |
(Scan.succeed (Toplevel.print o IsarCmd.redo));
|
5832
|
372 |
|
5944
|
373 |
val undosP =
|
6687
|
374 |
OuterSyntax.improper_command "undos" "undo last commands"
|
|
375 |
(nat >> (fn n => Toplevel.print o IsarCmd.undos n));
|
5944
|
376 |
|
5832
|
377 |
val backP =
|
6370
|
378 |
OuterSyntax.improper_command "back" "backtracking of proof command"
|
5832
|
379 |
(Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.back));
|
|
380 |
|
|
381 |
val prevP =
|
6370
|
382 |
OuterSyntax.improper_command "prev" "previous proof state"
|
5832
|
383 |
(Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.prev));
|
|
384 |
|
|
385 |
val upP =
|
6370
|
386 |
OuterSyntax.improper_command "up" "upper proof state"
|
5832
|
387 |
(Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.up));
|
|
388 |
|
|
389 |
val topP =
|
6370
|
390 |
OuterSyntax.improper_command "top" "to initial proof state"
|
5832
|
391 |
(Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.top));
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
(** diagnostic commands (for interactive mode only) **)
|
|
396 |
|
|
397 |
val print_commandsP =
|
6370
|
398 |
OuterSyntax.improper_command "help" "print outer syntax (global)"
|
5832
|
399 |
(Scan.succeed (Toplevel.imperative OuterSyntax.print_outer_syntax));
|
|
400 |
|
|
401 |
val print_theoryP =
|
6370
|
402 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)"
|
5832
|
403 |
(Scan.succeed IsarCmd.print_theory);
|
|
404 |
|
|
405 |
val print_syntaxP =
|
6370
|
406 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)"
|
5832
|
407 |
(Scan.succeed IsarCmd.print_syntax);
|
|
408 |
|
5881
|
409 |
val print_theoremsP =
|
6370
|
410 |
OuterSyntax.improper_command "print_theorems" "print theorems known in this theory"
|
5881
|
411 |
(Scan.succeed IsarCmd.print_theorems);
|
|
412 |
|
5832
|
413 |
val print_attributesP =
|
6370
|
414 |
OuterSyntax.improper_command "print_attributes" "print attributes known in this theory"
|
5832
|
415 |
(Scan.succeed IsarCmd.print_attributes);
|
|
416 |
|
|
417 |
val print_methodsP =
|
6370
|
418 |
OuterSyntax.improper_command "print_methods" "print methods known in this theory"
|
5832
|
419 |
(Scan.succeed IsarCmd.print_methods);
|
|
420 |
|
|
421 |
val print_bindsP =
|
6370
|
422 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context"
|
5832
|
423 |
(Scan.succeed IsarCmd.print_binds);
|
|
424 |
|
|
425 |
val print_lthmsP =
|
6370
|
426 |
OuterSyntax.improper_command "print_facts" "print local theorems of proof context"
|
5832
|
427 |
(Scan.succeed IsarCmd.print_lthms);
|
|
428 |
|
5896
|
429 |
val print_thmsP =
|
6370
|
430 |
OuterSyntax.improper_command "thm" "print theorems" (xthm >> IsarCmd.print_thms);
|
5832
|
431 |
|
|
432 |
val print_propP =
|
6370
|
433 |
OuterSyntax.improper_command "prop" "read and print proposition"
|
5832
|
434 |
(term >> IsarCmd.print_prop);
|
|
435 |
|
|
436 |
val print_termP =
|
6370
|
437 |
OuterSyntax.improper_command "term" "read and print term"
|
5832
|
438 |
(term >> IsarCmd.print_term);
|
|
439 |
|
|
440 |
val print_typeP =
|
6687
|
441 |
OuterSyntax.improper_command "typ" "read and print type"
|
5832
|
442 |
(typ >> IsarCmd.print_type);
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
(** system commands (for interactive mode only) **)
|
|
447 |
|
|
448 |
val cdP =
|
6370
|
449 |
OuterSyntax.improper_command "cd" "change current working directory"
|
5958
|
450 |
(name >> IsarCmd.cd);
|
5832
|
451 |
|
|
452 |
val pwdP =
|
6370
|
453 |
OuterSyntax.improper_command "pwd" "print current working directory"
|
5832
|
454 |
(Scan.succeed IsarCmd.pwd);
|
|
455 |
|
|
456 |
val use_thyP =
|
6370
|
457 |
OuterSyntax.improper_command "use_thy" "use theory file"
|
5958
|
458 |
(name >> IsarCmd.use_thy);
|
5832
|
459 |
|
6694
|
460 |
val use_thy_onlyP =
|
|
461 |
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML"
|
|
462 |
(name >> IsarCmd.use_thy_only);
|
|
463 |
|
6196
|
464 |
val update_thyP =
|
6370
|
465 |
OuterSyntax.improper_command "update_thy" "update theory file"
|
6197
|
466 |
(name >> IsarCmd.update_thy);
|
5832
|
467 |
|
|
468 |
val prP =
|
6370
|
469 |
OuterSyntax.improper_command "pr" "print current toplevel state"
|
5832
|
470 |
(Scan.succeed (Toplevel.print o Toplevel.imperative (K ())));
|
|
471 |
|
|
472 |
|
|
473 |
val opt_unit = Scan.optional ($$$ "(" -- $$$ ")" >> (K ())) ();
|
|
474 |
|
|
475 |
val commitP =
|
6370
|
476 |
OuterSyntax.improper_command "commit" "commit current session to ML database"
|
5832
|
477 |
(opt_unit >> (K IsarCmd.use_commit));
|
|
478 |
|
|
479 |
val quitP =
|
6370
|
480 |
OuterSyntax.improper_command "quit" "quit Isabelle"
|
5832
|
481 |
(opt_unit >> (K IsarCmd.quit));
|
|
482 |
|
|
483 |
val exitP =
|
6370
|
484 |
OuterSyntax.improper_command "exit" "exit Isar loop"
|
5832
|
485 |
(Scan.succeed IsarCmd.exit);
|
|
486 |
|
5991
|
487 |
val restartP =
|
6370
|
488 |
OuterSyntax.improper_command "restart" "restart Isar loop"
|
5991
|
489 |
(Scan.succeed IsarCmd.restart);
|
|
490 |
|
5832
|
491 |
val breakP =
|
6370
|
492 |
OuterSyntax.improper_command "break" "discontinue excursion (keep current state)"
|
5832
|
493 |
(Scan.succeed IsarCmd.break);
|
|
494 |
|
|
495 |
|
|
496 |
|
|
497 |
(** the Pure outer syntax **)
|
|
498 |
|
|
499 |
(*keep keywords consistent with the parsers, including those in
|
|
500 |
outer_parse.ML, otherwise be prepared for unexpected errors*)
|
|
501 |
|
|
502 |
val keywords =
|
6551
|
503 |
["!", "%", "(", ")", "*", "+", ",", "--", ":", "::", ";", "<", "<=",
|
|
504 |
"=", "==", "=>", "?", "[", "]", "and", "as", "binder", "files",
|
|
505 |
"infixl", "infixr", "is", "output", "{", "|", "}"];
|
5832
|
506 |
|
|
507 |
val parsers = [
|
|
508 |
(*theory structure*)
|
6687
|
509 |
theoryP, end_excursionP, kill_excursionP, contextP, update_contextP,
|
5832
|
510 |
(*theory sections*)
|
6370
|
511 |
textP, titleP, chapterP, sectionP, subsectionP, subsubsectionP,
|
|
512 |
classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP,
|
|
513 |
aritiesP, constsP, syntaxP, translationsP, axiomsP, defsP,
|
|
514 |
constdefsP, theoremsP, lemmasP, globalP, localP, pathP, useP, mlP,
|
|
515 |
setupP, parse_ast_translationP, parse_translationP,
|
|
516 |
print_translationP, typed_print_translationP,
|
|
517 |
print_ast_translationP, token_translationP, oracleP,
|
5832
|
518 |
(*proof commands*)
|
6501
|
519 |
theoremP, lemmaP, showP, haveP, thusP, henceP, assumeP, fixP, letP,
|
6687
|
520 |
thenP, fromP, factsP, beginP, endP, nextP, kill_proofP, qed_withP,
|
|
521 |
qedP, terminal_proofP, immediate_proofP, default_proofP, refineP,
|
|
522 |
then_refineP, proofP, clear_undoP, undoP, redoP, undosP, backP,
|
|
523 |
prevP, upP, topP,
|
5832
|
524 |
(*diagnostic commands*)
|
|
525 |
print_commandsP, print_theoryP, print_syntaxP, print_attributesP,
|
5881
|
526 |
print_methodsP, print_theoremsP, print_bindsP, print_lthmsP,
|
5914
|
527 |
print_thmsP, print_propP, print_termP, print_typeP,
|
5832
|
528 |
(*system commands*)
|
6694
|
529 |
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, prP, commitP,
|
|
530 |
quitP, exitP, restartP, breakP];
|
5832
|
531 |
|
|
532 |
|
|
533 |
end;
|
|
534 |
|
|
535 |
|
6196
|
536 |
(*install the Pure outer syntax*)
|
5832
|
537 |
OuterSyntax.add_keywords IsarSyn.keywords;
|
|
538 |
OuterSyntax.add_parsers IsarSyn.parsers;
|