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