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