author | wenzelm |
Tue, 27 Jul 1999 21:57:58 +0200 | |
changeset 7102 | ead5c234b28c |
parent 7023 | 5d1eafaff50c |
child 7124 | 78c01842d3b5 |
permissions | -rw-r--r-- |
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 = |
7102 | 35 |
OuterSyntax.improper_command "context" "switch theory context" K.thy_switch |
6723 | 36 |
(P.name >> (Toplevel.print oo IsarThy.context)); |
6245 | 37 |
|
5832 | 38 |
|
39 |
||
6886 | 40 |
(** formal comments **) |
5832 | 41 |
|
6886 | 42 |
val txtP = OuterSyntax.command "txt" "formal comment (proof)" K.prf_decl |
6890 | 43 |
(P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_txt))); |
5832 | 44 |
|
6886 | 45 |
val textP = OuterSyntax.command "text" "formal comment (theory)" K.thy_decl |
6723 | 46 |
(P.comment >> (Toplevel.theory o IsarThy.add_text)); |
5958 | 47 |
|
6723 | 48 |
val titleP = OuterSyntax.command "title" "document title" K.thy_heading |
6727 | 49 |
((P.comment -- Scan.optional P.comment Comment.none -- Scan.optional P.comment Comment.none) |
6353 | 50 |
>> (fn ((x, y), z) => Toplevel.theory (IsarThy.add_title x y z))); |
51 |
||
6723 | 52 |
val chapterP = OuterSyntax.command "chapter" "chapter heading" K.thy_heading |
53 |
(P.comment >> (Toplevel.theory o IsarThy.add_chapter)); |
|
5958 | 54 |
|
6723 | 55 |
val sectionP = OuterSyntax.command "section" "section heading" K.thy_heading |
56 |
(P.comment >> (Toplevel.theory o IsarThy.add_section)); |
|
5958 | 57 |
|
6723 | 58 |
val subsectionP = OuterSyntax.command "subsection" "subsection heading" K.thy_heading |
59 |
(P.comment >> (Toplevel.theory o IsarThy.add_subsection)); |
|
5958 | 60 |
|
6723 | 61 |
val subsubsectionP = OuterSyntax.command "subsubsection" "subsubsection heading" K.thy_heading |
62 |
(P.comment >> (Toplevel.theory o IsarThy.add_subsubsection)); |
|
5832 | 63 |
|
64 |
||
6886 | 65 |
|
66 |
(** theory sections **) |
|
67 |
||
5832 | 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 |
||
6936 | 244 |
fun statement f = (P.opt_thm_name ":" -- P.propp >> P.triple1) -- P.marg_comment >> f; |
5832 | 245 |
|
246 |
val theoremP = |
|
6723 | 247 |
OuterSyntax.command "theorem" "state theorem" K.thy_goal |
5832 | 248 |
(statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f)); |
249 |
||
250 |
val lemmaP = |
|
6723 | 251 |
OuterSyntax.command "lemma" "state lemma" K.thy_goal |
5832 | 252 |
(statement IsarThy.lemma >> (fn f => Toplevel.print o Toplevel.theory_to_proof f)); |
253 |
||
254 |
val showP = |
|
6723 | 255 |
OuterSyntax.command "show" "state local goal, solving current obligation" K.prf_goal |
5832 | 256 |
(statement IsarThy.show >> (fn f => Toplevel.print o Toplevel.proof f)); |
257 |
||
258 |
val haveP = |
|
6723 | 259 |
OuterSyntax.command "have" "state local goal" K.prf_goal |
5832 | 260 |
(statement IsarThy.have >> (fn f => Toplevel.print o Toplevel.proof f)); |
261 |
||
6501 | 262 |
val thusP = |
6723 | 263 |
OuterSyntax.command "thus" "abbreviates \"then show\"" K.prf_goal |
6501 | 264 |
(statement IsarThy.thus >> (fn f => Toplevel.print o Toplevel.proof f)); |
265 |
||
266 |
val henceP = |
|
6723 | 267 |
OuterSyntax.command "hence" "abbreviates \"then have\"" K.prf_goal |
6501 | 268 |
(statement IsarThy.hence >> (fn f => Toplevel.print o Toplevel.proof f)); |
269 |
||
5832 | 270 |
|
5914 | 271 |
(* facts *) |
5832 | 272 |
|
273 |
val thenP = |
|
6723 | 274 |
OuterSyntax.command "then" "forward chaining" K.prf_chain |
6727 | 275 |
(P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.chain))); |
5832 | 276 |
|
6936 | 277 |
val thenceP = |
278 |
OuterSyntax.command "thence" "forward chaining, including full export" K.prf_chain |
|
279 |
(P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.export_chain))); |
|
280 |
||
5832 | 281 |
val fromP = |
6723 | 282 |
OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain |
6727 | 283 |
(P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts))); |
5914 | 284 |
|
6878 | 285 |
val withP = |
286 |
OuterSyntax.command "with" "forward chaining from given and current facts" K.prf_chain |
|
287 |
(P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.with_facts))); |
|
288 |
||
6773 | 289 |
val noteP = |
6723 | 290 |
OuterSyntax.command "note" "define facts" K.prf_decl |
6755 | 291 |
(facts -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.have_facts))); |
5832 | 292 |
|
293 |
||
294 |
(* proof context *) |
|
295 |
||
296 |
val assumeP = |
|
6869 | 297 |
OuterSyntax.command "assume" "assume propositions" K.prf_asm |
6936 | 298 |
((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment |
6727 | 299 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.assume))); |
5832 | 300 |
|
6850 | 301 |
val presumeP = |
6869 | 302 |
OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm |
6936 | 303 |
((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment |
6850 | 304 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.presume))); |
305 |
||
6953 | 306 |
val defP = |
307 |
OuterSyntax.command "def" "local definition" K.prf_asm |
|
308 |
((P.opt_thm_name ":" -- (P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- |
|
6972 | 309 |
(P.$$$ "==" |-- P.termp)) >> P.triple1) -- P.marg_comment |
6953 | 310 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.local_def))); |
311 |
||
5832 | 312 |
val fixP = |
6869 | 313 |
OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm |
6727 | 314 |
(Scan.repeat1 (P.name -- Scan.option (P.$$$ "::" |-- P.typ)) -- P.marg_comment |
315 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.fix))); |
|
5832 | 316 |
|
317 |
val letP = |
|
6723 | 318 |
OuterSyntax.command "let" "bind text variables" K.prf_decl |
6727 | 319 |
(P.and_list1 (P.enum1 "as" P.term -- (P.$$$ "=" |-- P.term) -- P.marg_comment) |
320 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.match_bind))); |
|
5832 | 321 |
|
322 |
||
323 |
(* proof structure *) |
|
324 |
||
325 |
val beginP = |
|
6723 | 326 |
OuterSyntax.command "{{" "begin explicit proof block" K.prf_block |
5832 | 327 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.begin_block)); |
328 |
||
6687 | 329 |
val endP = |
6723 | 330 |
OuterSyntax.command "}}" "end explicit proof block" K.prf_block |
6687 | 331 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.end_block)); |
332 |
||
5832 | 333 |
val nextP = |
6723 | 334 |
OuterSyntax.command "next" "enter next proof block" K.prf_block |
5832 | 335 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.next_block)); |
336 |
||
337 |
||
338 |
(* end proof *) |
|
339 |
||
6404 | 340 |
val qedP = |
6735 | 341 |
OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block |
7002 | 342 |
(Scan.option (P.method -- P.interest) -- P.marg_comment >> IsarThy.qed); |
5832 | 343 |
|
6404 | 344 |
val terminal_proofP = |
6723 | 345 |
OuterSyntax.command "by" "terminal backward proof" K.qed |
7002 | 346 |
(P.method -- P.interest -- Scan.option (P.method -- P.interest) |
347 |
-- P.marg_comment >> IsarThy.terminal_proof); |
|
6404 | 348 |
|
349 |
val immediate_proofP = |
|
6723 | 350 |
OuterSyntax.command "." "immediate proof" K.qed |
7002 | 351 |
(P.marg_comment >> IsarThy.immediate_proof); |
6404 | 352 |
|
353 |
val default_proofP = |
|
6723 | 354 |
OuterSyntax.command ".." "default proof" K.qed |
7002 | 355 |
(P.marg_comment >> IsarThy.default_proof); |
5832 | 356 |
|
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
357 |
val skip_proofP = |
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
358 |
OuterSyntax.command "sorry" "skip proof (quick-and-dirty mode only!)" K.qed |
7002 | 359 |
(P.marg_comment >> IsarThy.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
360 |
|
5832 | 361 |
|
362 |
(* proof steps *) |
|
363 |
||
6850 | 364 |
val applyP = |
365 |
OuterSyntax.improper_command "apply" "unstructured backward proof step, ignoring facts" |
|
6723 | 366 |
K.prf_script (P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.tac))); |
5832 | 367 |
|
6850 | 368 |
val then_applyP = |
369 |
OuterSyntax.improper_command "then_apply" "unstructured backward proof step, using facts" |
|
6723 | 370 |
K.prf_script (P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.then_tac))); |
5832 | 371 |
|
6404 | 372 |
val proofP = |
6723 | 373 |
OuterSyntax.command "proof" "backward proof" K.prf_block |
7002 | 374 |
(P.interest -- Scan.option (P.method -- P.interest) -- P.marg_comment |
6727 | 375 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.proof))); |
5832 | 376 |
|
377 |
||
6773 | 378 |
(* calculational proof commands *) |
379 |
||
6878 | 380 |
val calc_args = |
381 |
Scan.option (P.$$$ "(" |-- P.!!! ((P.xthms1 --| P.$$$ ")") -- P.interest)); |
|
382 |
||
6773 | 383 |
val alsoP = |
384 |
OuterSyntax.command "also" "intermediate calculational proof step" K.prf_decl |
|
6878 | 385 |
(calc_args -- P.marg_comment >> IsarThy.also); |
6773 | 386 |
|
387 |
val finallyP = |
|
388 |
OuterSyntax.command "finally" "terminal calculational proof step" K.prf_chain |
|
6878 | 389 |
(calc_args -- P.marg_comment >> IsarThy.finally); |
6773 | 390 |
|
391 |
||
6742 | 392 |
(* proof navigation *) |
5944 | 393 |
|
5832 | 394 |
val backP = |
6723 | 395 |
OuterSyntax.improper_command "back" "backtracking of proof command" K.prf_script |
5832 | 396 |
(Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.back)); |
397 |
||
398 |
||
6742 | 399 |
(* history *) |
400 |
||
401 |
val cannot_undoP = |
|
402 |
OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control |
|
403 |
(P.name >> (Toplevel.print oo IsarCmd.cannot_undo)); |
|
404 |
||
405 |
val clear_undoP = |
|
406 |
OuterSyntax.improper_command "clear_undo" "clear undo information" K.control |
|
407 |
(Scan.succeed (Toplevel.print o IsarCmd.clear_undo)); |
|
408 |
||
409 |
val redoP = |
|
410 |
OuterSyntax.improper_command "redo" "redo last command" K.control |
|
411 |
(Scan.succeed (Toplevel.print o IsarCmd.redo)); |
|
412 |
||
413 |
val undos_proofP = |
|
414 |
OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control |
|
415 |
(P.nat >> (Toplevel.print oo IsarCmd.undos_proof)); |
|
416 |
||
417 |
val kill_proofP = |
|
418 |
OuterSyntax.improper_command "kill_proof" "undo current proof" K.control |
|
419 |
(Scan.succeed (Toplevel.print o IsarCmd.kill_proof)); |
|
420 |
||
421 |
val undoP = |
|
422 |
OuterSyntax.improper_command "undo" "undo last command" K.control |
|
423 |
(Scan.succeed (Toplevel.print o IsarCmd.undo)); |
|
424 |
||
425 |
||
5832 | 426 |
|
427 |
(** diagnostic commands (for interactive mode only) **) |
|
428 |
||
429 |
val print_commandsP = |
|
6723 | 430 |
OuterSyntax.improper_command "help" "print outer syntax (global)" K.diag |
5832 | 431 |
(Scan.succeed (Toplevel.imperative OuterSyntax.print_outer_syntax)); |
432 |
||
433 |
val print_theoryP = |
|
6723 | 434 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag |
5832 | 435 |
(Scan.succeed IsarCmd.print_theory); |
436 |
||
437 |
val print_syntaxP = |
|
6723 | 438 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag |
5832 | 439 |
(Scan.succeed IsarCmd.print_syntax); |
440 |
||
5881 | 441 |
val print_theoremsP = |
6723 | 442 |
OuterSyntax.improper_command "print_theorems" "print theorems known in this theory" K.diag |
5881 | 443 |
(Scan.succeed IsarCmd.print_theorems); |
444 |
||
5832 | 445 |
val print_attributesP = |
6723 | 446 |
OuterSyntax.improper_command "print_attributes" "print attributes known in this theory" K.diag |
5832 | 447 |
(Scan.succeed IsarCmd.print_attributes); |
448 |
||
449 |
val print_methodsP = |
|
6723 | 450 |
OuterSyntax.improper_command "print_methods" "print methods known in this theory" K.diag |
5832 | 451 |
(Scan.succeed IsarCmd.print_methods); |
452 |
||
453 |
val print_bindsP = |
|
6723 | 454 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag |
5832 | 455 |
(Scan.succeed IsarCmd.print_binds); |
456 |
||
457 |
val print_lthmsP = |
|
6723 | 458 |
OuterSyntax.improper_command "print_facts" "print local theorems of proof context" K.diag |
5832 | 459 |
(Scan.succeed IsarCmd.print_lthms); |
460 |
||
5896 | 461 |
val print_thmsP = |
7012 | 462 |
OuterSyntax.improper_command "thm" "print theorems" K.diag (P.xthms1 >> IsarCmd.print_thms); |
5832 | 463 |
|
464 |
val print_propP = |
|
6723 | 465 |
OuterSyntax.improper_command "prop" "read and print proposition" K.diag |
466 |
(P.term >> IsarCmd.print_prop); |
|
5832 | 467 |
|
468 |
val print_termP = |
|
6723 | 469 |
OuterSyntax.improper_command "term" "read and print term" K.diag |
470 |
(P.term >> IsarCmd.print_term); |
|
5832 | 471 |
|
472 |
val print_typeP = |
|
6723 | 473 |
OuterSyntax.improper_command "typ" "read and print type" K.diag |
474 |
(P.typ >> IsarCmd.print_type); |
|
5832 | 475 |
|
476 |
||
477 |
||
478 |
(** system commands (for interactive mode only) **) |
|
479 |
||
480 |
val cdP = |
|
6723 | 481 |
OuterSyntax.improper_command "cd" "change current working directory" K.control |
482 |
(P.name >> IsarCmd.cd); |
|
5832 | 483 |
|
484 |
val pwdP = |
|
6723 | 485 |
OuterSyntax.improper_command "pwd" "print current working directory" K.diag |
5832 | 486 |
(Scan.succeed IsarCmd.pwd); |
487 |
||
488 |
val use_thyP = |
|
6723 | 489 |
OuterSyntax.improper_command "use_thy" "use theory file" K.diag |
490 |
(P.name >> IsarCmd.use_thy); |
|
5832 | 491 |
|
6694 | 492 |
val use_thy_onlyP = |
7102 | 493 |
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML" |
494 |
K.diag (P.name >> IsarCmd.use_thy_only); |
|
6694 | 495 |
|
6196 | 496 |
val update_thyP = |
6723 | 497 |
OuterSyntax.improper_command "update_thy" "update theory file" K.diag |
498 |
(P.name >> IsarCmd.update_thy); |
|
5832 | 499 |
|
7102 | 500 |
val update_thy_onlyP = |
501 |
OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML" |
|
502 |
K.diag (P.name >> IsarCmd.update_thy); |
|
503 |
||
504 |
val touch_thyP = |
|
505 |
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag |
|
506 |
(P.name >> IsarCmd.touch_thy); |
|
507 |
||
508 |
val touch_all_thysP = |
|
509 |
OuterSyntax.improper_command "touch_all_thys" "outdate all non-finished theories" K.diag |
|
510 |
(Scan.succeed IsarCmd.touch_all_thys); |
|
511 |
||
512 |
val remove_thyP = |
|
513 |
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag |
|
514 |
(P.name >> IsarCmd.remove_thy); |
|
515 |
||
5832 | 516 |
val prP = |
6723 | 517 |
OuterSyntax.improper_command "pr" "print current toplevel state" K.diag |
5832 | 518 |
(Scan.succeed (Toplevel.print o Toplevel.imperative (K ()))); |
519 |
||
520 |
||
6723 | 521 |
val opt_unit = Scan.optional (P.$$$ "(" -- P.$$$ ")" >> (K ())) (); |
5832 | 522 |
|
523 |
val commitP = |
|
6723 | 524 |
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag |
5832 | 525 |
(opt_unit >> (K IsarCmd.use_commit)); |
526 |
||
527 |
val quitP = |
|
6723 | 528 |
OuterSyntax.improper_command "quit" "quit Isabelle" K.control |
5832 | 529 |
(opt_unit >> (K IsarCmd.quit)); |
530 |
||
531 |
val exitP = |
|
6723 | 532 |
OuterSyntax.improper_command "exit" "exit Isar loop" K.control |
5832 | 533 |
(Scan.succeed IsarCmd.exit); |
534 |
||
7102 | 535 |
val init_toplevelP = |
536 |
OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control |
|
537 |
(Scan.succeed IsarCmd.init_toplevel); |
|
5991 | 538 |
|
5832 | 539 |
|
540 |
||
541 |
(** the Pure outer syntax **) |
|
542 |
||
543 |
(*keep keywords consistent with the parsers, including those in |
|
544 |
outer_parse.ML, otherwise be prepared for unexpected errors*) |
|
545 |
||
546 |
val keywords = |
|
6953 | 547 |
["!", "!!", "%", "(", ")", "*", "+", ",", "--", ":", "::", ";", "<", |
548 |
"<=", "=", "==", "=>", "?", "[", "]", "and", "as", "binder", |
|
549 |
"concl", "files", "infixl", "infixr", "is", "output", "{", "|", |
|
550 |
"}"]; |
|
5832 | 551 |
|
552 |
val parsers = [ |
|
553 |
(*theory structure*) |
|
7102 | 554 |
theoryP, end_excursionP, kill_excursionP, contextP, |
5832 | 555 |
(*theory sections*) |
6886 | 556 |
txtP, textP, titleP, chapterP, sectionP, subsectionP, |
557 |
subsubsectionP, classesP, classrelP, defaultsortP, typedeclP, |
|
558 |
typeabbrP, nontermP, aritiesP, constsP, syntaxP, translationsP, |
|
559 |
axiomsP, defsP, constdefsP, theoremsP, lemmasP, globalP, localP, |
|
560 |
pathP, useP, mlP, setupP, parse_ast_translationP, |
|
561 |
parse_translationP, print_translationP, typed_print_translationP, |
|
6370 | 562 |
print_ast_translationP, token_translationP, oracleP, |
5832 | 563 |
(*proof commands*) |
6850 | 564 |
theoremP, lemmaP, showP, haveP, thusP, henceP, assumeP, presumeP, |
6953 | 565 |
defP, fixP, letP, thenP, thenceP, fromP, withP, noteP, beginP, endP, |
566 |
nextP, qedP, terminal_proofP, immediate_proofP, default_proofP, |
|
567 |
skip_proofP, applyP, then_applyP, proofP, alsoP, finallyP, backP, |
|
568 |
cannot_undoP, clear_undoP, redoP, undos_proofP, kill_proofP, undoP, |
|
5832 | 569 |
(*diagnostic commands*) |
570 |
print_commandsP, print_theoryP, print_syntaxP, print_attributesP, |
|
5881 | 571 |
print_methodsP, print_theoremsP, print_bindsP, print_lthmsP, |
5914 | 572 |
print_thmsP, print_propP, print_termP, print_typeP, |
5832 | 573 |
(*system commands*) |
7102 | 574 |
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP, |
575 |
touch_thyP, touch_all_thysP, remove_thyP, prP, commitP, quitP, |
|
576 |
exitP, init_toplevelP]; |
|
5832 | 577 |
|
578 |
||
579 |
end; |
|
580 |
||
581 |
||
6196 | 582 |
(*install the Pure outer syntax*) |
5832 | 583 |
OuterSyntax.add_keywords IsarSyn.keywords; |
584 |
OuterSyntax.add_parsers IsarSyn.parsers; |