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