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