author | wenzelm |
Tue, 14 Mar 2000 11:33:14 +0100 | |
changeset 8450 | dc44d6533f0f |
parent 8370 | 6b45749d37d6 |
child 8454 | fff900f59153 |
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 |
7415 | 32 |
(Scan.succeed (Toplevel.print o Toplevel.kill)); |
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 |
||
7749 | 40 |
(** markup commands **) |
5832 | 41 |
|
7749 | 42 |
val headerP = OuterSyntax.markup_command "header" "theory header" K.diag |
7733 | 43 |
(P.comment >> IsarThy.add_header); |
6353 | 44 |
|
7749 | 45 |
val chapterP = OuterSyntax.markup_command "chapter" "chapter heading" K.thy_heading |
6723 | 46 |
(P.comment >> (Toplevel.theory o IsarThy.add_chapter)); |
5958 | 47 |
|
7749 | 48 |
val sectionP = OuterSyntax.markup_command "section" "section heading" K.thy_heading |
6723 | 49 |
(P.comment >> (Toplevel.theory o IsarThy.add_section)); |
5958 | 50 |
|
7749 | 51 |
val subsectionP = OuterSyntax.markup_command "subsection" "subsection heading" K.thy_heading |
6723 | 52 |
(P.comment >> (Toplevel.theory o IsarThy.add_subsection)); |
5958 | 53 |
|
7749 | 54 |
val subsubsectionP = |
55 |
OuterSyntax.markup_command "subsubsection" "subsubsection heading" K.thy_heading |
|
56 |
(P.comment >> (Toplevel.theory o IsarThy.add_subsubsection)); |
|
5832 | 57 |
|
7749 | 58 |
val textP = OuterSyntax.markup_command "text" "formal comment (theory)" K.thy_decl |
7172 | 59 |
(P.comment >> (Toplevel.theory o IsarThy.add_text)); |
60 |
||
7862 | 61 |
val text_rawP = OuterSyntax.verbatim_command "text_raw" "raw document preparation text" |
62 |
K.thy_decl (P.comment >> (Toplevel.theory o IsarThy.add_text_raw)); |
|
7775 | 63 |
|
7172 | 64 |
|
7749 | 65 |
val sectP = OuterSyntax.markup_command "sect" "formal comment (proof)" K.prf_decl |
7172 | 66 |
(P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_sect))); |
67 |
||
7749 | 68 |
val subsectP = OuterSyntax.markup_command "subsect" "formal comment (proof)" K.prf_decl |
7172 | 69 |
(P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_subsect))); |
70 |
||
7749 | 71 |
val subsubsectP = OuterSyntax.markup_command "subsubsect" "formal comment (proof)" K.prf_decl |
7172 | 72 |
(P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_subsubsect))); |
73 |
||
7749 | 74 |
val txtP = OuterSyntax.markup_command "txt" "formal comment (proof)" K.prf_decl |
7172 | 75 |
(P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_txt))); |
76 |
||
7862 | 77 |
val txt_rawP = OuterSyntax.verbatim_command "txt_raw" "raw document preparation text (proof)" |
78 |
K.prf_decl (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_txt_raw))); |
|
7775 | 79 |
|
5832 | 80 |
|
6886 | 81 |
|
82 |
(** theory sections **) |
|
83 |
||
5832 | 84 |
(* classes and sorts *) |
85 |
||
86 |
val classesP = |
|
6723 | 87 |
OuterSyntax.command "classes" "declare type classes" K.thy_decl |
88 |
(Scan.repeat1 (P.name -- Scan.optional (P.$$$ "<" |-- P.!!! (P.list1 P.xname)) []) |
|
6727 | 89 |
-- P.marg_comment >> (Toplevel.theory o IsarThy.add_classes)); |
5832 | 90 |
|
91 |
val classrelP = |
|
6723 | 92 |
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl |
6727 | 93 |
(P.xname -- (P.$$$ "<" |-- P.!!! P.xname) -- P.marg_comment |
94 |
>> (Toplevel.theory o IsarThy.add_classrel)); |
|
5832 | 95 |
|
96 |
val defaultsortP = |
|
6723 | 97 |
OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl |
6727 | 98 |
(P.sort -- P.marg_comment >> (Toplevel.theory o IsarThy.add_defsort)); |
5832 | 99 |
|
100 |
||
101 |
(* types *) |
|
102 |
||
103 |
val typedeclP = |
|
6723 | 104 |
OuterSyntax.command "typedecl" "Pure type declaration" K.thy_decl |
6727 | 105 |
(P.type_args -- P.name -- P.opt_infix -- P.marg_comment >> (fn (((args, a), mx), cmt) => |
106 |
Toplevel.theory (IsarThy.add_typedecl ((a, args, mx), cmt)))); |
|
5832 | 107 |
|
108 |
val typeabbrP = |
|
6723 | 109 |
OuterSyntax.command "types" "declare type abbreviations" K.thy_decl |
6727 | 110 |
(Scan.repeat1 |
111 |
(P.type_args -- P.name -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_infix)) -- P.marg_comment) |
|
112 |
>> (Toplevel.theory o IsarThy.add_tyabbrs o |
|
113 |
map (fn (((args, a), (T, mx)), cmt) => ((a, args, T, mx), cmt)))); |
|
5832 | 114 |
|
115 |
val nontermP = |
|
6370 | 116 |
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" |
6727 | 117 |
K.thy_decl (Scan.repeat1 (P.name -- P.marg_comment) |
118 |
>> (Toplevel.theory o IsarThy.add_nonterminals)); |
|
5832 | 119 |
|
120 |
val aritiesP = |
|
6723 | 121 |
OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl |
6727 | 122 |
(Scan.repeat1 ((P.xname -- (P.$$$ "::" |-- P.!!! P.arity) >> P.triple2) -- P.marg_comment) |
123 |
>> (Toplevel.theory o IsarThy.add_arities)); |
|
5832 | 124 |
|
125 |
||
126 |
(* consts and syntax *) |
|
127 |
||
8227 | 128 |
val judgmentP = |
129 |
OuterSyntax.command "judgment" "declare object-logic judgment" K.thy_decl |
|
130 |
(P.const -- P.marg_comment >> (Toplevel.theory o IsarThy.add_judgment)); |
|
131 |
||
5832 | 132 |
val constsP = |
6723 | 133 |
OuterSyntax.command "consts" "declare constants" K.thy_decl |
6727 | 134 |
(Scan.repeat1 (P.const -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_consts)); |
5832 | 135 |
|
136 |
val opt_mode = |
|
137 |
Scan.optional |
|
6723 | 138 |
(P.$$$ "(" |-- P.!!! (P.name -- Scan.optional (P.$$$ "output" >> K false) true --| P.$$$ ")")) |
5832 | 139 |
("", true); |
140 |
||
141 |
val syntaxP = |
|
6723 | 142 |
OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl |
6727 | 143 |
(opt_mode -- Scan.repeat1 (P.const -- P.marg_comment) |
144 |
>> (Toplevel.theory o uncurry IsarThy.add_modesyntax)); |
|
5832 | 145 |
|
146 |
||
147 |
(* translations *) |
|
148 |
||
149 |
val trans_pat = |
|
6723 | 150 |
Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string; |
5832 | 151 |
|
152 |
fun trans_arrow toks = |
|
6723 | 153 |
(P.$$$ "=>" >> K Syntax.ParseRule || |
154 |
P.$$$ "<=" >> K Syntax.PrintRule || |
|
155 |
P.$$$ "==" >> K Syntax.ParsePrintRule) toks; |
|
5832 | 156 |
|
157 |
val trans_line = |
|
6723 | 158 |
trans_pat -- P.!!! (trans_arrow -- trans_pat) |
5832 | 159 |
>> (fn (left, (arr, right)) => arr (left, right)); |
160 |
||
161 |
val translationsP = |
|
6723 | 162 |
OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl |
6727 | 163 |
(Scan.repeat1 (trans_line -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_trrules)); |
5832 | 164 |
|
165 |
||
166 |
(* axioms and definitions *) |
|
167 |
||
168 |
val axiomsP = |
|
6723 | 169 |
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl |
6727 | 170 |
(Scan.repeat1 (P.spec_name -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_axioms)); |
5832 | 171 |
|
172 |
val defsP = |
|
6723 | 173 |
OuterSyntax.command "defs" "define constants" K.thy_decl |
7603 | 174 |
(Scan.repeat1 (P.spec_name -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_defs)); |
6370 | 175 |
|
176 |
val constdefsP = |
|
6723 | 177 |
OuterSyntax.command "constdefs" "declare and define constants" K.thy_decl |
6727 | 178 |
(Scan.repeat1 ((P.const -- P.marg_comment) -- (P.term -- P.marg_comment)) |
179 |
>> (Toplevel.theory o IsarThy.add_constdefs)); |
|
5832 | 180 |
|
181 |
||
5914 | 182 |
(* theorems *) |
183 |
||
6723 | 184 |
val facts = P.opt_thm_name "=" -- P.xthms1; |
5914 | 185 |
|
186 |
val theoremsP = |
|
6723 | 187 |
OuterSyntax.command "theorems" "define theorems" K.thy_decl |
6727 | 188 |
(facts -- P.marg_comment >> (Toplevel.theory o IsarThy.have_theorems)); |
5914 | 189 |
|
190 |
val lemmasP = |
|
6723 | 191 |
OuterSyntax.command "lemmas" "define lemmas" K.thy_decl |
6727 | 192 |
(facts -- P.marg_comment >> (Toplevel.theory o IsarThy.have_lemmas)); |
5914 | 193 |
|
194 |
||
5832 | 195 |
(* name space entry path *) |
196 |
||
197 |
val globalP = |
|
6723 | 198 |
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl |
5832 | 199 |
(Scan.succeed (Toplevel.theory PureThy.global_path)); |
200 |
||
201 |
val localP = |
|
6723 | 202 |
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl |
5832 | 203 |
(Scan.succeed (Toplevel.theory PureThy.local_path)); |
204 |
||
205 |
||
206 |
(* use ML text *) |
|
207 |
||
208 |
val useP = |
|
6723 | 209 |
OuterSyntax.command "use" "eval ML text from file" K.diag |
210 |
(P.name >> IsarCmd.use); |
|
5832 | 211 |
|
212 |
val mlP = |
|
7616 | 213 |
OuterSyntax.command "ML" "eval ML text (diagnostic)" K.diag |
7891 | 214 |
(P.text >> IsarCmd.use_mltext true); |
215 |
||
216 |
val ml_commandP = |
|
217 |
OuterSyntax.command "ML_command" "eval ML text" K.diag |
|
218 |
(P.text >> IsarCmd.use_mltext false); |
|
7616 | 219 |
|
220 |
val ml_setupP = |
|
221 |
OuterSyntax.command "ML_setup" "eval ML text (may change theory)" K.thy_decl |
|
222 |
(P.text >> IsarCmd.use_mltext_theory); |
|
5832 | 223 |
|
224 |
val setupP = |
|
7616 | 225 |
OuterSyntax.command "setup" "apply ML theory setup" K.thy_decl |
8349
611342539639
moved use_mltext, use_mltext_theory, use_let, use_setup to context.ML;
wenzelm
parents:
8235
diff
changeset
|
226 |
(P.text >> (Toplevel.theory o Context.use_setup)); |
5832 | 227 |
|
228 |
||
229 |
(* translation functions *) |
|
230 |
||
231 |
val parse_ast_translationP = |
|
6723 | 232 |
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" K.thy_decl |
233 |
(P.text >> (Toplevel.theory o IsarThy.parse_ast_translation)); |
|
5832 | 234 |
|
235 |
val parse_translationP = |
|
6723 | 236 |
OuterSyntax.command "parse_translation" "install parse translation functions" K.thy_decl |
237 |
(P.text >> (Toplevel.theory o IsarThy.parse_translation)); |
|
5832 | 238 |
|
239 |
val print_translationP = |
|
6723 | 240 |
OuterSyntax.command "print_translation" "install print translation functions" K.thy_decl |
241 |
(P.text >> (Toplevel.theory o IsarThy.print_translation)); |
|
5832 | 242 |
|
243 |
val typed_print_translationP = |
|
6370 | 244 |
OuterSyntax.command "typed_print_translation" "install typed print translation functions" |
6723 | 245 |
K.thy_decl (P.text >> (Toplevel.theory o IsarThy.typed_print_translation)); |
5832 | 246 |
|
247 |
val print_ast_translationP = |
|
6723 | 248 |
OuterSyntax.command "print_ast_translation" "install print ast translation functions" K.thy_decl |
249 |
(P.text >> (Toplevel.theory o IsarThy.print_ast_translation)); |
|
5832 | 250 |
|
251 |
val token_translationP = |
|
6723 | 252 |
OuterSyntax.command "token_translation" "install token translation functions" K.thy_decl |
253 |
(P.text >> (Toplevel.theory o IsarThy.token_translation)); |
|
5832 | 254 |
|
255 |
||
256 |
(* oracles *) |
|
257 |
||
258 |
val oracleP = |
|
6723 | 259 |
OuterSyntax.command "oracle" "install oracle" K.thy_decl |
7140 | 260 |
((P.name --| P.$$$ "=") -- P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.add_oracle)); |
5832 | 261 |
|
262 |
||
263 |
||
264 |
(** proof commands **) |
|
265 |
||
266 |
(* statements *) |
|
267 |
||
6936 | 268 |
fun statement f = (P.opt_thm_name ":" -- P.propp >> P.triple1) -- P.marg_comment >> f; |
5832 | 269 |
|
270 |
val theoremP = |
|
6723 | 271 |
OuterSyntax.command "theorem" "state theorem" K.thy_goal |
5832 | 272 |
(statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f)); |
273 |
||
274 |
val lemmaP = |
|
6723 | 275 |
OuterSyntax.command "lemma" "state lemma" K.thy_goal |
5832 | 276 |
(statement IsarThy.lemma >> (fn f => Toplevel.print o Toplevel.theory_to_proof f)); |
277 |
||
278 |
val showP = |
|
6723 | 279 |
OuterSyntax.command "show" "state local goal, solving current obligation" K.prf_goal |
5832 | 280 |
(statement IsarThy.show >> (fn f => Toplevel.print o Toplevel.proof f)); |
281 |
||
282 |
val haveP = |
|
6723 | 283 |
OuterSyntax.command "have" "state local goal" K.prf_goal |
5832 | 284 |
(statement IsarThy.have >> (fn f => Toplevel.print o Toplevel.proof f)); |
285 |
||
6501 | 286 |
val thusP = |
6723 | 287 |
OuterSyntax.command "thus" "abbreviates \"then show\"" K.prf_goal |
6501 | 288 |
(statement IsarThy.thus >> (fn f => Toplevel.print o Toplevel.proof f)); |
289 |
||
290 |
val henceP = |
|
6723 | 291 |
OuterSyntax.command "hence" "abbreviates \"then have\"" K.prf_goal |
6501 | 292 |
(statement IsarThy.hence >> (fn f => Toplevel.print o Toplevel.proof f)); |
293 |
||
5832 | 294 |
|
5914 | 295 |
(* facts *) |
5832 | 296 |
|
297 |
val thenP = |
|
6723 | 298 |
OuterSyntax.command "then" "forward chaining" K.prf_chain |
6727 | 299 |
(P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.chain))); |
5832 | 300 |
|
6936 | 301 |
val thenceP = |
7678 | 302 |
OuterSyntax.command "thence" "forward chaining, including full export (EXPERIMENTAL!)" K.prf_chain |
6936 | 303 |
(P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.export_chain))); |
304 |
||
5832 | 305 |
val fromP = |
6723 | 306 |
OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain |
6727 | 307 |
(P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts))); |
5914 | 308 |
|
6878 | 309 |
val withP = |
310 |
OuterSyntax.command "with" "forward chaining from given and current facts" K.prf_chain |
|
311 |
(P.xthms1 -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.with_facts))); |
|
312 |
||
6773 | 313 |
val noteP = |
6723 | 314 |
OuterSyntax.command "note" "define facts" K.prf_decl |
6755 | 315 |
(facts -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.have_facts))); |
5832 | 316 |
|
317 |
||
318 |
(* proof context *) |
|
319 |
||
320 |
val assumeP = |
|
6869 | 321 |
OuterSyntax.command "assume" "assume propositions" K.prf_asm |
7269 | 322 |
(P.and_list1 ((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment) |
6727 | 323 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.assume))); |
5832 | 324 |
|
6850 | 325 |
val presumeP = |
6869 | 326 |
OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm |
7269 | 327 |
(P.and_list1 ((P.opt_thm_name ":" -- Scan.repeat1 P.propp >> P.triple1) -- P.marg_comment) |
6850 | 328 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.presume))); |
329 |
||
6953 | 330 |
val defP = |
331 |
OuterSyntax.command "def" "local definition" K.prf_asm |
|
332 |
((P.opt_thm_name ":" -- (P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- |
|
6972 | 333 |
(P.$$$ "==" |-- P.termp)) >> P.triple1) -- P.marg_comment |
6953 | 334 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.local_def))); |
335 |
||
5832 | 336 |
val fixP = |
6869 | 337 |
OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm |
7415 | 338 |
(P.and_list1 (Scan.repeat1 P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- P.marg_comment) |
6727 | 339 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.fix))); |
5832 | 340 |
|
341 |
val letP = |
|
6723 | 342 |
OuterSyntax.command "let" "bind text variables" K.prf_decl |
6727 | 343 |
(P.and_list1 (P.enum1 "as" P.term -- (P.$$$ "=" |-- P.term) -- P.marg_comment) |
344 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.match_bind))); |
|
5832 | 345 |
|
8370 | 346 |
val caseP = |
347 |
OuterSyntax.command "case" "invoke local context" K.prf_asm |
|
8450 | 348 |
(P.xthm -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.invoke_case))); |
8370 | 349 |
|
5832 | 350 |
|
351 |
(* proof structure *) |
|
352 |
||
353 |
val beginP = |
|
6723 | 354 |
OuterSyntax.command "{{" "begin explicit proof block" K.prf_block |
5832 | 355 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.begin_block)); |
356 |
||
6687 | 357 |
val endP = |
6723 | 358 |
OuterSyntax.command "}}" "end explicit proof block" K.prf_block |
6687 | 359 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.end_block)); |
360 |
||
5832 | 361 |
val nextP = |
6723 | 362 |
OuterSyntax.command "next" "enter next proof block" K.prf_block |
5832 | 363 |
(Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.next_block)); |
364 |
||
365 |
||
366 |
(* end proof *) |
|
367 |
||
6404 | 368 |
val qedP = |
6735 | 369 |
OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block |
7002 | 370 |
(Scan.option (P.method -- P.interest) -- P.marg_comment >> IsarThy.qed); |
5832 | 371 |
|
6404 | 372 |
val terminal_proofP = |
6723 | 373 |
OuterSyntax.command "by" "terminal backward proof" K.qed |
7002 | 374 |
(P.method -- P.interest -- Scan.option (P.method -- P.interest) |
375 |
-- P.marg_comment >> IsarThy.terminal_proof); |
|
6404 | 376 |
|
377 |
val immediate_proofP = |
|
6723 | 378 |
OuterSyntax.command "." "immediate proof" K.qed |
7002 | 379 |
(P.marg_comment >> IsarThy.immediate_proof); |
6404 | 380 |
|
381 |
val default_proofP = |
|
6723 | 382 |
OuterSyntax.command ".." "default proof" K.qed |
7002 | 383 |
(P.marg_comment >> IsarThy.default_proof); |
5832 | 384 |
|
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
385 |
val skip_proofP = |
7172 | 386 |
OuterSyntax.improper_command "sorry" "skip proof (quick-and-dirty mode only!)" K.qed |
7002 | 387 |
(P.marg_comment >> IsarThy.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
388 |
|
8210 | 389 |
val forget_proofP = |
390 |
OuterSyntax.improper_command "oops" "forget proof" K.qed_global |
|
391 |
(P.marg_comment >> IsarThy.forget_proof); |
|
392 |
||
393 |
||
5832 | 394 |
|
395 |
(* proof steps *) |
|
396 |
||
8165 | 397 |
val deferP = |
8235 | 398 |
OuterSyntax.command "defer" "shuffle internal proof state" |
8165 | 399 |
K.prf_script (Scan.option P.nat >> (Toplevel.print oo (Toplevel.proof o IsarThy.defer))); |
400 |
||
401 |
val preferP = |
|
8235 | 402 |
OuterSyntax.command "prefer" "shuffle internal proof state" |
8165 | 403 |
K.prf_script (P.nat >> (Toplevel.print oo (Toplevel.proof o IsarThy.prefer))); |
404 |
||
6850 | 405 |
val applyP = |
8235 | 406 |
OuterSyntax.command "apply" "initial refinement step (unstructured)" |
407 |
K.prf_script (P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply))); |
|
5832 | 408 |
|
8235 | 409 |
val apply_endP = |
410 |
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" |
|
411 |
K.prf_script (P.method >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply_end))); |
|
5832 | 412 |
|
6404 | 413 |
val proofP = |
6723 | 414 |
OuterSyntax.command "proof" "backward proof" K.prf_block |
7002 | 415 |
(P.interest -- Scan.option (P.method -- P.interest) -- P.marg_comment |
6727 | 416 |
>> (Toplevel.print oo (Toplevel.proof o IsarThy.proof))); |
5832 | 417 |
|
418 |
||
6773 | 419 |
(* calculational proof commands *) |
420 |
||
6878 | 421 |
val calc_args = |
422 |
Scan.option (P.$$$ "(" |-- P.!!! ((P.xthms1 --| P.$$$ ")") -- P.interest)); |
|
423 |
||
6773 | 424 |
val alsoP = |
425 |
OuterSyntax.command "also" "intermediate calculational proof step" K.prf_decl |
|
6878 | 426 |
(calc_args -- P.marg_comment >> IsarThy.also); |
6773 | 427 |
|
428 |
val finallyP = |
|
429 |
OuterSyntax.command "finally" "terminal calculational proof step" K.prf_chain |
|
6878 | 430 |
(calc_args -- P.marg_comment >> IsarThy.finally); |
6773 | 431 |
|
432 |
||
6742 | 433 |
(* proof navigation *) |
5944 | 434 |
|
5832 | 435 |
val backP = |
8235 | 436 |
OuterSyntax.command "back" "backtracking of proof command" K.prf_script |
7368 | 437 |
(Scan.optional (P.$$$ "!" >> K true) false >> |
438 |
(Toplevel.print oo (Toplevel.proof o ProofHistory.back))); |
|
5832 | 439 |
|
440 |
||
6742 | 441 |
(* history *) |
442 |
||
443 |
val cannot_undoP = |
|
444 |
OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control |
|
7269 | 445 |
(P.name >> IsarCmd.cannot_undo); |
6742 | 446 |
|
7733 | 447 |
val clear_undosP = |
448 |
OuterSyntax.improper_command "clear_undos" "clear theory-level undo information" K.control |
|
449 |
(P.nat >> IsarCmd.clear_undos_theory); |
|
6742 | 450 |
|
451 |
val redoP = |
|
452 |
OuterSyntax.improper_command "redo" "redo last command" K.control |
|
453 |
(Scan.succeed (Toplevel.print o IsarCmd.redo)); |
|
454 |
||
455 |
val undos_proofP = |
|
456 |
OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control |
|
457 |
(P.nat >> (Toplevel.print oo IsarCmd.undos_proof)); |
|
458 |
||
459 |
val kill_proofP = |
|
460 |
OuterSyntax.improper_command "kill_proof" "undo current proof" K.control |
|
7269 | 461 |
(Scan.succeed IsarCmd.kill_proof); |
6742 | 462 |
|
463 |
val undoP = |
|
464 |
OuterSyntax.improper_command "undo" "undo last command" K.control |
|
7269 | 465 |
(Scan.succeed IsarCmd.undo); |
6742 | 466 |
|
467 |
||
5832 | 468 |
|
469 |
(** diagnostic commands (for interactive mode only) **) |
|
470 |
||
7124 | 471 |
val pretty_setmarginP = |
472 |
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
|
473 |
K.diag (P.nat >> IsarCmd.pretty_setmargin); |
|
474 |
||
5832 | 475 |
val print_commandsP = |
6723 | 476 |
OuterSyntax.improper_command "help" "print outer syntax (global)" K.diag |
7368 | 477 |
(Scan.succeed OuterSyntax.print_help); |
5832 | 478 |
|
7308 | 479 |
val print_contextP = |
480 |
OuterSyntax.improper_command "print_context" "print theory context name" K.diag |
|
481 |
(Scan.succeed IsarCmd.print_context); |
|
482 |
||
5832 | 483 |
val print_theoryP = |
6723 | 484 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag |
5832 | 485 |
(Scan.succeed IsarCmd.print_theory); |
486 |
||
487 |
val print_syntaxP = |
|
6723 | 488 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag |
5832 | 489 |
(Scan.succeed IsarCmd.print_syntax); |
490 |
||
5881 | 491 |
val print_theoremsP = |
6723 | 492 |
OuterSyntax.improper_command "print_theorems" "print theorems known in this theory" K.diag |
5881 | 493 |
(Scan.succeed IsarCmd.print_theorems); |
494 |
||
5832 | 495 |
val print_attributesP = |
6723 | 496 |
OuterSyntax.improper_command "print_attributes" "print attributes known in this theory" K.diag |
5832 | 497 |
(Scan.succeed IsarCmd.print_attributes); |
498 |
||
499 |
val print_methodsP = |
|
6723 | 500 |
OuterSyntax.improper_command "print_methods" "print methods known in this theory" K.diag |
5832 | 501 |
(Scan.succeed IsarCmd.print_methods); |
502 |
||
7616 | 503 |
val thms_containingP = |
504 |
OuterSyntax.improper_command "thms_containing" "print theorems containing all given constants" |
|
505 |
K.diag (Scan.repeat P.xname >> IsarCmd.print_thms_containing); |
|
506 |
||
5832 | 507 |
val print_bindsP = |
6723 | 508 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag |
5832 | 509 |
(Scan.succeed IsarCmd.print_binds); |
510 |
||
511 |
val print_lthmsP = |
|
8370 | 512 |
OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag |
5832 | 513 |
(Scan.succeed IsarCmd.print_lthms); |
514 |
||
8370 | 515 |
val print_casesP = |
516 |
OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag |
|
517 |
(Scan.succeed IsarCmd.print_cases); |
|
518 |
||
5896 | 519 |
val print_thmsP = |
7012 | 520 |
OuterSyntax.improper_command "thm" "print theorems" K.diag (P.xthms1 >> IsarCmd.print_thms); |
5832 | 521 |
|
522 |
val print_propP = |
|
6723 | 523 |
OuterSyntax.improper_command "prop" "read and print proposition" K.diag |
524 |
(P.term >> IsarCmd.print_prop); |
|
5832 | 525 |
|
526 |
val print_termP = |
|
6723 | 527 |
OuterSyntax.improper_command "term" "read and print term" K.diag |
528 |
(P.term >> IsarCmd.print_term); |
|
5832 | 529 |
|
530 |
val print_typeP = |
|
6723 | 531 |
OuterSyntax.improper_command "typ" "read and print type" K.diag |
532 |
(P.typ >> IsarCmd.print_type); |
|
5832 | 533 |
|
534 |
||
535 |
||
536 |
(** system commands (for interactive mode only) **) |
|
537 |
||
538 |
val cdP = |
|
6723 | 539 |
OuterSyntax.improper_command "cd" "change current working directory" K.control |
540 |
(P.name >> IsarCmd.cd); |
|
5832 | 541 |
|
542 |
val pwdP = |
|
6723 | 543 |
OuterSyntax.improper_command "pwd" "print current working directory" K.diag |
5832 | 544 |
(Scan.succeed IsarCmd.pwd); |
545 |
||
546 |
val use_thyP = |
|
6723 | 547 |
OuterSyntax.improper_command "use_thy" "use theory file" K.diag |
548 |
(P.name >> IsarCmd.use_thy); |
|
5832 | 549 |
|
6694 | 550 |
val use_thy_onlyP = |
7102 | 551 |
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML" |
552 |
K.diag (P.name >> IsarCmd.use_thy_only); |
|
6694 | 553 |
|
6196 | 554 |
val update_thyP = |
6723 | 555 |
OuterSyntax.improper_command "update_thy" "update theory file" K.diag |
556 |
(P.name >> IsarCmd.update_thy); |
|
5832 | 557 |
|
7102 | 558 |
val update_thy_onlyP = |
559 |
OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML" |
|
7885 | 560 |
K.diag (P.name >> IsarCmd.update_thy_only); |
7102 | 561 |
|
562 |
val touch_thyP = |
|
563 |
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag |
|
564 |
(P.name >> IsarCmd.touch_thy); |
|
565 |
||
566 |
val touch_all_thysP = |
|
567 |
OuterSyntax.improper_command "touch_all_thys" "outdate all non-finished theories" K.diag |
|
568 |
(Scan.succeed IsarCmd.touch_all_thys); |
|
569 |
||
7908 | 570 |
val touch_child_thysP = |
571 |
OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag |
|
572 |
(P.name >> IsarCmd.touch_child_thys); |
|
573 |
||
7102 | 574 |
val remove_thyP = |
575 |
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag |
|
576 |
(P.name >> IsarCmd.remove_thy); |
|
577 |
||
7931 | 578 |
val kill_thyP = |
579 |
OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
|
580 |
K.diag (P.name >> IsarCmd.kill_thy); |
|
581 |
||
5832 | 582 |
val prP = |
6723 | 583 |
OuterSyntax.improper_command "pr" "print current toplevel state" K.diag |
7199 | 584 |
(Scan.succeed (Toplevel.print o Toplevel.imperative (fn () => Toplevel.quiet := false))); |
585 |
||
7222 | 586 |
val disable_prP = |
587 |
OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag |
|
7199 | 588 |
(Scan.succeed (Toplevel.imperative (fn () => Toplevel.quiet := true))); |
5832 | 589 |
|
7222 | 590 |
val enable_prP = |
591 |
OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag |
|
592 |
(Scan.succeed (Toplevel.imperative (fn () => Toplevel.quiet := false))); |
|
593 |
||
5832 | 594 |
val commitP = |
6723 | 595 |
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag |
7931 | 596 |
(P.opt_unit >> (K IsarCmd.use_commit)); |
5832 | 597 |
|
598 |
val quitP = |
|
6723 | 599 |
OuterSyntax.improper_command "quit" "quit Isabelle" K.control |
7931 | 600 |
(P.opt_unit >> (K IsarCmd.quit)); |
5832 | 601 |
|
602 |
val exitP = |
|
6723 | 603 |
OuterSyntax.improper_command "exit" "exit Isar loop" K.control |
5832 | 604 |
(Scan.succeed IsarCmd.exit); |
605 |
||
7102 | 606 |
val init_toplevelP = |
607 |
OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control |
|
608 |
(Scan.succeed IsarCmd.init_toplevel); |
|
5991 | 609 |
|
7462 | 610 |
val welcomeP = |
611 |
OuterSyntax.improper_command "welcome" "print welcome message" K.control |
|
612 |
(Scan.succeed IsarCmd.welcome); |
|
613 |
||
5832 | 614 |
|
615 |
||
616 |
(** the Pure outer syntax **) |
|
617 |
||
618 |
(*keep keywords consistent with the parsers, including those in |
|
619 |
outer_parse.ML, otherwise be prepared for unexpected errors*) |
|
620 |
||
621 |
val keywords = |
|
7415 | 622 |
["!", "!!", "%", "%%", "(", ")", "+", ",", "--", ":", "::", ";", "<", |
623 |
"<=", "=", "==", "=>", "?", "[", "]", "and", "as", "binder", |
|
7678 | 624 |
"concl", "files", "in", "infixl", "infixr", "is", "output", "{", |
625 |
"|", "}"]; |
|
5832 | 626 |
|
627 |
val parsers = [ |
|
628 |
(*theory structure*) |
|
7102 | 629 |
theoryP, end_excursionP, kill_excursionP, contextP, |
7775 | 630 |
(*markup commands*) |
7733 | 631 |
headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP, |
7862 | 632 |
text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP, |
5832 | 633 |
(*theory sections*) |
7172 | 634 |
classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP, |
8227 | 635 |
aritiesP, judgmentP, constsP, syntaxP, translationsP, axiomsP, |
636 |
defsP, constdefsP, theoremsP, lemmasP, globalP, localP, useP, mlP, |
|
7891 | 637 |
ml_commandP, ml_setupP, setupP, parse_ast_translationP, |
638 |
parse_translationP, print_translationP, typed_print_translationP, |
|
7616 | 639 |
print_ast_translationP, token_translationP, oracleP, |
5832 | 640 |
(*proof commands*) |
6850 | 641 |
theoremP, lemmaP, showP, haveP, thusP, henceP, assumeP, presumeP, |
8370 | 642 |
defP, fixP, letP, caseP, thenP, thenceP, fromP, withP, noteP, |
643 |
beginP, endP, nextP, qedP, terminal_proofP, immediate_proofP, |
|
644 |
default_proofP, skip_proofP, forget_proofP, deferP, preferP, applyP, |
|
645 |
apply_endP, proofP, alsoP, finallyP, backP, cannot_undoP, |
|
646 |
clear_undosP, redoP, undos_proofP, kill_proofP, undoP, |
|
5832 | 647 |
(*diagnostic commands*) |
7308 | 648 |
pretty_setmarginP, print_commandsP, print_contextP, print_theoryP, |
7616 | 649 |
print_syntaxP, print_theoremsP, print_attributesP, print_methodsP, |
8370 | 650 |
thms_containingP, print_bindsP, print_lthmsP, print_casesP, |
651 |
print_thmsP, print_propP, print_termP, print_typeP, |
|
5832 | 652 |
(*system commands*) |
7102 | 653 |
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP, |
7931 | 654 |
touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP, |
655 |
kill_thyP, prP, disable_prP, enable_prP, commitP, quitP, exitP, |
|
656 |
init_toplevelP, welcomeP]; |
|
5832 | 657 |
|
658 |
||
659 |
end; |
|
660 |
||
661 |
||
6196 | 662 |
(*install the Pure outer syntax*) |
5832 | 663 |
OuterSyntax.add_keywords IsarSyn.keywords; |
664 |
OuterSyntax.add_parsers IsarSyn.parsers; |