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