src/Pure/Isar/isar_syn.ML
author wenzelm
Mon Apr 26 21:45:08 2010 +0200 (2010-04-26 ago)
changeset 36356 5ab0f8859f9f
parent 36323 655e2d74de3a
child 36449 78721f3adb13
permissions -rw-r--r--
command 'example_proof' opens an empty proof body;
     1 (*  Title:      Pure/Isar/isar_syn.ML
     2     Author:     Markus Wenzel, TU Muenchen
     3 
     4 Isar/Pure outer syntax.
     5 *)
     6 
     7 structure IsarSyn: sig end =
     8 struct
     9 
    10 structure P = OuterParse and K = OuterKeyword;
    11 
    12 
    13 (** keywords **)
    14 
    15 (*keep keywords consistent with the parsers, otherwise be prepared for
    16   unexpected errors*)
    17 
    18 val _ = List.app OuterKeyword.keyword
    19  ["!!", "!", "%", "(", ")", "+", ",", "--", ":", "::", ";", "<", "<=",
    20   "=", "==", "=>", "?", "[", "\\<equiv>", "\\<leftharpoondown>",
    21   "\\<rightharpoonup>", "\\<rightleftharpoons>", "\\<subseteq>", "]",
    22   "advanced", "and", "assumes", "attach", "begin", "binder",
    23   "constrains", "defines", "fixes", "for", "identifier", "if",
    24   "imports", "in", "infix", "infixl", "infixr", "is",
    25   "notes", "obtains", "open", "output", "overloaded", "pervasive",
    26   "shows", "structure", "unchecked", "uses", "where", "|"];
    27 
    28 
    29 
    30 (** init and exit **)
    31 
    32 val _ =
    33   OuterSyntax.command "theory" "begin theory" (K.tag_theory K.thy_begin)
    34     (Thy_Header.args >> (Toplevel.print oo IsarCmd.init_theory));
    35 
    36 val _ =
    37   OuterSyntax.command "end" "end (local) theory" (K.tag_theory K.thy_end)
    38     (Scan.succeed (Toplevel.exit o Toplevel.end_local_theory));
    39 
    40 
    41 
    42 (** markup commands **)
    43 
    44 val _ = OuterSyntax.markup_command ThyOutput.Markup "header" "theory header" K.diag
    45   (P.doc_source >> IsarCmd.header_markup);
    46 
    47 val _ = OuterSyntax.markup_command ThyOutput.Markup "chapter" "chapter heading"
    48   K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    49 
    50 val _ = OuterSyntax.markup_command ThyOutput.Markup "section" "section heading"
    51   K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    52 
    53 val _ = OuterSyntax.markup_command ThyOutput.Markup "subsection" "subsection heading"
    54   K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    55 
    56 val _ =
    57   OuterSyntax.markup_command ThyOutput.Markup "subsubsection" "subsubsection heading"
    58   K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    59 
    60 val _ = OuterSyntax.markup_command ThyOutput.MarkupEnv "text" "formal comment (theory)"
    61   K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    62 
    63 val _ = OuterSyntax.markup_command ThyOutput.Verbatim "text_raw" "raw document preparation text"
    64   K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup);
    65 
    66 val _ = OuterSyntax.markup_command ThyOutput.Markup "sect" "formal comment (proof)"
    67   (K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup);
    68 
    69 val _ = OuterSyntax.markup_command ThyOutput.Markup "subsect" "formal comment (proof)"
    70   (K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup);
    71 
    72 val _ = OuterSyntax.markup_command ThyOutput.Markup "subsubsect" "formal comment (proof)"
    73   (K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup);
    74 
    75 val _ = OuterSyntax.markup_command ThyOutput.MarkupEnv "txt" "formal comment (proof)"
    76   (K.tag_proof K.prf_decl) (P.doc_source >> IsarCmd.proof_markup);
    77 
    78 val _ = OuterSyntax.markup_command ThyOutput.Verbatim "txt_raw"
    79   "raw document preparation text (proof)" (K.tag_proof K.prf_decl)
    80   (P.doc_source >> IsarCmd.proof_markup);
    81 
    82 
    83 
    84 (** theory commands **)
    85 
    86 (* classes and sorts *)
    87 
    88 val _ =
    89   OuterSyntax.command "classes" "declare type classes" K.thy_decl
    90     (Scan.repeat1 (P.binding -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |--
    91         P.!!! (P.list1 P.xname)) []) >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd));
    92 
    93 val _ =
    94   OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl
    95     (P.and_list1 (P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname))
    96     >> (Toplevel.theory o AxClass.axiomatize_classrel_cmd));
    97 
    98 val _ =
    99   OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl
   100     (P.sort >> (Toplevel.theory o Sign.add_defsort));
   101 
   102 
   103 (* types *)
   104 
   105 val _ =
   106   OuterSyntax.local_theory "typedecl" "type declaration" K.thy_decl
   107     (P.type_args -- P.binding -- P.opt_mixfix
   108       >> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd));
   109 
   110 val _ =
   111   OuterSyntax.local_theory "types" "declare type abbreviations" K.thy_decl
   112     (Scan.repeat1
   113       (P.type_args -- P.binding -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_mixfix')))
   114       >> (fold (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)));
   115 
   116 val _ =
   117   OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols"
   118     K.thy_decl (Scan.repeat1 P.binding >> (Toplevel.theory o Sign.add_nonterminals));
   119 
   120 val _ =
   121   OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl
   122     (Scan.repeat1 P.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd));
   123 
   124 
   125 (* consts and syntax *)
   126 
   127 val _ =
   128   OuterSyntax.command "judgment" "declare object-logic judgment" K.thy_decl
   129     (P.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd));
   130 
   131 val _ =
   132   OuterSyntax.command "consts" "declare constants" K.thy_decl
   133     (Scan.repeat1 P.const_binding >> (Toplevel.theory o Sign.add_consts));
   134 
   135 val opt_overloaded = P.opt_keyword "overloaded";
   136 
   137 val _ =
   138   OuterSyntax.command "finalconsts" "declare constants as final" K.thy_decl
   139     (opt_overloaded -- Scan.repeat1 P.term >> (uncurry (Toplevel.theory oo Theory.add_finals)));
   140 
   141 val mode_spec =
   142   (P.$$$ "output" >> K ("", false)) || P.name -- Scan.optional (P.$$$ "output" >> K false) true;
   143 
   144 val opt_mode =
   145   Scan.optional (P.$$$ "(" |-- P.!!! (mode_spec --| P.$$$ ")")) Syntax.mode_default;
   146 
   147 val _ =
   148   OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl
   149     (opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.add_modesyntax));
   150 
   151 val _ =
   152   OuterSyntax.command "no_syntax" "delete syntax declarations" K.thy_decl
   153     (opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.del_modesyntax));
   154 
   155 
   156 (* translations *)
   157 
   158 val trans_pat =
   159   Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string;
   160 
   161 fun trans_arrow toks =
   162   ((P.$$$ "\\<rightharpoonup>" || P.$$$ "=>") >> K Syntax.ParseRule ||
   163     (P.$$$ "\\<leftharpoondown>" || P.$$$ "<=") >> K Syntax.PrintRule ||
   164     (P.$$$ "\\<rightleftharpoons>" || P.$$$ "==") >> K Syntax.ParsePrintRule) toks;
   165 
   166 val trans_line =
   167   trans_pat -- P.!!! (trans_arrow -- trans_pat)
   168     >> (fn (left, (arr, right)) => arr (left, right));
   169 
   170 val _ =
   171   OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl
   172     (Scan.repeat1 trans_line >> (Toplevel.theory o Sign.add_trrules));
   173 
   174 val _ =
   175   OuterSyntax.command "no_translations" "remove syntax translation rules" K.thy_decl
   176     (Scan.repeat1 trans_line >> (Toplevel.theory o Sign.del_trrules));
   177 
   178 
   179 (* axioms and definitions *)
   180 
   181 val _ =
   182   OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl
   183     (Scan.repeat1 SpecParse.spec >> (Toplevel.theory o IsarCmd.add_axioms));
   184 
   185 val opt_unchecked_overloaded =
   186   Scan.optional (P.$$$ "(" |-- P.!!!
   187     (((P.$$$ "unchecked" >> K true) -- Scan.optional (P.$$$ "overloaded" >> K true) false ||
   188       P.$$$ "overloaded" >> K (false, true)) --| P.$$$ ")")) (false, false);
   189 
   190 val _ =
   191   OuterSyntax.command "defs" "define constants" K.thy_decl
   192     (opt_unchecked_overloaded --
   193       Scan.repeat1 (SpecParse.thm_name ":" -- P.prop >> (fn ((x, y), z) => ((x, z), y)))
   194       >> (Toplevel.theory o IsarCmd.add_defs));
   195 
   196 
   197 (* old constdefs *)
   198 
   199 val old_constdecl =
   200   P.binding --| P.where_ >> (fn x => (x, NONE, NoSyn)) ||
   201   P.binding -- (P.$$$ "::" |-- P.!!! P.typ >> SOME) -- P.opt_mixfix'
   202     --| Scan.option P.where_ >> P.triple1 ||
   203   P.binding -- (P.mixfix >> pair NONE) --| Scan.option P.where_ >> P.triple2;
   204 
   205 val old_constdef = Scan.option old_constdecl -- (SpecParse.opt_thm_name ":" -- P.prop);
   206 
   207 val structs =
   208   Scan.optional ((P.$$$ "(" -- P.$$$ "structure") |-- P.!!! (P.simple_fixes --| P.$$$ ")")) [];
   209 
   210 val _ =
   211   OuterSyntax.command "constdefs" "old-style constant definition" K.thy_decl
   212     (structs -- Scan.repeat1 old_constdef >> (Toplevel.theory o Constdefs.add_constdefs));
   213 
   214 
   215 (* constant definitions and abbreviations *)
   216 
   217 val _ =
   218   OuterSyntax.local_theory "definition" "constant definition" K.thy_decl
   219     (SpecParse.constdef >> (fn args => #2 o Specification.definition_cmd args));
   220 
   221 val _ =
   222   OuterSyntax.local_theory "abbreviation" "constant abbreviation" K.thy_decl
   223     (opt_mode -- (Scan.option SpecParse.constdecl -- P.prop)
   224     >> (fn (mode, args) => Specification.abbreviation_cmd mode args));
   225 
   226 val _ =
   227   OuterSyntax.local_theory "type_notation" "add notation for type constructors" K.thy_decl
   228     (opt_mode -- P.and_list1 (P.xname -- P.mixfix)
   229     >> (fn (mode, args) => Specification.type_notation_cmd true mode args));
   230 
   231 val _ =
   232   OuterSyntax.local_theory "no_type_notation" "delete notation for type constructors" K.thy_decl
   233     (opt_mode -- P.and_list1 (P.xname -- P.mixfix)
   234     >> (fn (mode, args) => Specification.type_notation_cmd false mode args));
   235 
   236 val _ =
   237   OuterSyntax.local_theory "notation" "add notation for constants / fixed variables" K.thy_decl
   238     (opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix)
   239     >> (fn (mode, args) => Specification.notation_cmd true mode args));
   240 
   241 val _ =
   242   OuterSyntax.local_theory "no_notation" "delete notation for constants / fixed variables" K.thy_decl
   243     (opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix)
   244     >> (fn (mode, args) => Specification.notation_cmd false mode args));
   245 
   246 
   247 (* constant specifications *)
   248 
   249 val _ =
   250   OuterSyntax.command "axiomatization" "axiomatic constant specification" K.thy_decl
   251     (Scan.optional P.fixes [] --
   252       Scan.optional (P.where_ |-- P.!!! (P.and_list1 SpecParse.specs)) []
   253     >> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y)));
   254 
   255 
   256 (* theorems *)
   257 
   258 fun theorems kind =
   259   SpecParse.name_facts >> (fn args => #2 o Specification.theorems_cmd kind args);
   260 
   261 val _ =
   262   OuterSyntax.local_theory "theorems" "define theorems" K.thy_decl (theorems Thm.theoremK);
   263 
   264 val _ =
   265   OuterSyntax.local_theory "lemmas" "define lemmas" K.thy_decl (theorems Thm.lemmaK);
   266 
   267 val _ =
   268   OuterSyntax.local_theory "declare" "declare theorems" K.thy_decl
   269     (P.and_list1 SpecParse.xthms1
   270       >> (fn args => #2 o Specification.theorems_cmd "" [(Attrib.empty_binding, flat args)]));
   271 
   272 
   273 (* name space entry path *)
   274 
   275 val _ =
   276   OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl
   277     (Scan.succeed (Toplevel.theory Sign.root_path));
   278 
   279 val _ =
   280   OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl
   281     (Scan.succeed (Toplevel.theory Sign.local_path));
   282 
   283 fun hide_names name hide what =
   284   OuterSyntax.command name ("hide " ^ what ^ " from name space") K.thy_decl
   285     ((P.opt_keyword "open" >> not) -- Scan.repeat1 P.xname >>
   286       (Toplevel.theory o uncurry hide));
   287 
   288 val _ = hide_names "hide_class" IsarCmd.hide_class "classes";
   289 val _ = hide_names "hide_type" IsarCmd.hide_type "types";
   290 val _ = hide_names "hide_const" IsarCmd.hide_const "constants";
   291 val _ = hide_names "hide_fact" IsarCmd.hide_fact "facts";
   292 
   293 
   294 (* use ML text *)
   295 
   296 fun propagate_env (context as Context.Proof lthy) =
   297       Context.Proof (Local_Theory.map_contexts (ML_Env.inherit context) lthy)
   298   | propagate_env context = context;
   299 
   300 fun propagate_env_prf prf = Proof.map_contexts
   301   (Context.proof_map (ML_Env.inherit (Context.Proof (Proof.context_of prf)))) prf;
   302 
   303 val _ =
   304   OuterSyntax.command "use" "ML text from file" (K.tag_ml K.thy_decl)
   305     (P.path >> (fn path => Toplevel.generic_theory (ThyInfo.exec_file false path #> propagate_env)));
   306 
   307 val _ =
   308   OuterSyntax.command "ML" "ML text within theory or local theory" (K.tag_ml K.thy_decl)
   309     (P.ML_source >> (fn (txt, pos) =>
   310       Toplevel.generic_theory
   311         (ML_Context.exec (fn () => ML_Context.eval true pos txt) #> propagate_env)));
   312 
   313 val _ =
   314   OuterSyntax.command "ML_prf" "ML text within proof" (K.tag_proof K.prf_decl)
   315     (P.ML_source >> (fn (txt, pos) =>
   316       Toplevel.proof (Proof.map_context (Context.proof_map
   317         (ML_Context.exec (fn () => ML_Context.eval true pos txt))) #> propagate_env_prf)));
   318 
   319 val _ =
   320   OuterSyntax.command "ML_val" "diagnostic ML text" (K.tag_ml K.diag)
   321     (P.ML_source >> IsarCmd.ml_diag true);
   322 
   323 val _ =
   324   OuterSyntax.command "ML_command" "diagnostic ML text (silent)" (K.tag_ml K.diag)
   325     (P.ML_source >> (Toplevel.no_timing oo IsarCmd.ml_diag false));
   326 
   327 val _ =
   328   OuterSyntax.command "setup" "ML theory setup" (K.tag_ml K.thy_decl)
   329     (P.ML_source >> (Toplevel.theory o IsarCmd.global_setup));
   330 
   331 val _ =
   332   OuterSyntax.local_theory "local_setup" "ML local theory setup" (K.tag_ml K.thy_decl)
   333     (P.ML_source >> IsarCmd.local_setup);
   334 
   335 val _ =
   336   OuterSyntax.command "attribute_setup" "define attribute in ML" (K.tag_ml K.thy_decl)
   337     (P.position P.name -- P.!!! (P.$$$ "=" |-- P.ML_source -- P.text)
   338     >> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt)));
   339 
   340 val _ =
   341   OuterSyntax.command "method_setup" "define proof method in ML" (K.tag_ml K.thy_decl)
   342     (P.position P.name -- P.!!! (P.$$$ "=" |-- P.ML_source -- P.text)
   343     >> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt)));
   344 
   345 val _ =
   346   OuterSyntax.local_theory "declaration" "generic ML declaration" (K.tag_ml K.thy_decl)
   347     (P.opt_keyword "pervasive" -- P.ML_source >> uncurry IsarCmd.declaration);
   348 
   349 val _ =
   350   OuterSyntax.local_theory "simproc_setup" "define simproc in ML" (K.tag_ml K.thy_decl)
   351     (P.name -- (P.$$$ "(" |-- P.enum1 "|" P.term --| P.$$$ ")" --| P.$$$ "=") --
   352       P.ML_source -- Scan.optional (P.$$$ "identifier" |-- Scan.repeat1 P.xname) []
   353     >> (fn (((a, b), c), d) => IsarCmd.simproc_setup a b c d));
   354 
   355 
   356 (* translation functions *)
   357 
   358 val trfun = P.opt_keyword "advanced" -- P.ML_source;
   359 
   360 val _ =
   361   OuterSyntax.command "parse_ast_translation" "install parse ast translation functions"
   362     (K.tag_ml K.thy_decl)
   363     (trfun >> (Toplevel.theory o IsarCmd.parse_ast_translation));
   364 
   365 val _ =
   366   OuterSyntax.command "parse_translation" "install parse translation functions"
   367     (K.tag_ml K.thy_decl)
   368     (trfun >> (Toplevel.theory o IsarCmd.parse_translation));
   369 
   370 val _ =
   371   OuterSyntax.command "print_translation" "install print translation functions"
   372     (K.tag_ml K.thy_decl)
   373     (trfun >> (Toplevel.theory o IsarCmd.print_translation));
   374 
   375 val _ =
   376   OuterSyntax.command "typed_print_translation" "install typed print translation functions"
   377     (K.tag_ml K.thy_decl)
   378     (trfun >> (Toplevel.theory o IsarCmd.typed_print_translation));
   379 
   380 val _ =
   381   OuterSyntax.command "print_ast_translation" "install print ast translation functions"
   382     (K.tag_ml K.thy_decl)
   383     (trfun >> (Toplevel.theory o IsarCmd.print_ast_translation));
   384 
   385 
   386 (* oracles *)
   387 
   388 val _ =
   389   OuterSyntax.command "oracle" "declare oracle" (K.tag_ml K.thy_decl)
   390     (P.position P.name -- (P.$$$ "=" |-- P.ML_source) >>
   391       (fn (x, y) => Toplevel.theory (IsarCmd.oracle x y)));
   392 
   393 
   394 (* local theories *)
   395 
   396 val _ =
   397   OuterSyntax.command "context" "enter local theory context" K.thy_decl
   398     (P.name --| P.begin >> (fn name =>
   399       Toplevel.print o Toplevel.begin_local_theory true (Theory_Target.context_cmd name)));
   400 
   401 
   402 (* locales *)
   403 
   404 val locale_val =
   405   SpecParse.locale_expression false --
   406     Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] ||
   407   Scan.repeat1 SpecParse.context_element >> pair ([], []);
   408 
   409 val _ =
   410   OuterSyntax.command "locale" "define named proof context" K.thy_decl
   411     (P.binding -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (([], []), []) -- P.opt_begin
   412       >> (fn ((name, (expr, elems)), begin) =>
   413           (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   414             (Expression.add_locale_cmd name Binding.empty expr elems #> snd)));
   415 
   416 val _ =
   417   OuterSyntax.command "sublocale"
   418     "prove sublocale relation between a locale and a locale expression" K.thy_goal
   419     (P.xname --| (P.$$$ "\\<subseteq>" || P.$$$ "<") -- P.!!! (SpecParse.locale_expression false)
   420       >> (fn (loc, expr) =>
   421           Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr)));
   422 
   423 val _ =
   424   OuterSyntax.command "interpretation"
   425     "prove interpretation of locale expression in theory" K.thy_goal
   426     (P.!!! (SpecParse.locale_expression true) --
   427       Scan.optional (P.where_ |-- P.and_list1 (SpecParse.opt_thm_name ":" -- P.prop)) []
   428       >> (fn (expr, equations) => Toplevel.print o
   429           Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations)));
   430 
   431 val _ =
   432   OuterSyntax.command "interpret"
   433     "prove interpretation of locale expression in proof context"
   434     (K.tag_proof K.prf_goal)
   435     (P.!!! (SpecParse.locale_expression true)
   436       >> (fn expr => Toplevel.print o Toplevel.proof' (Expression.interpret_cmd expr)));
   437 
   438 
   439 (* classes *)
   440 
   441 val class_val =
   442   SpecParse.class_expr --
   443     Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] ||
   444   Scan.repeat1 SpecParse.context_element >> pair [];
   445 
   446 val _ =
   447   OuterSyntax.command "class" "define type class" K.thy_decl
   448    (P.binding -- Scan.optional (P.$$$ "=" |-- class_val) ([], []) -- P.opt_begin
   449     >> (fn ((name, (supclasses, elems)), begin) =>
   450         (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   451           (Class.class_cmd name supclasses elems #> snd)));
   452 
   453 val _ =
   454   OuterSyntax.local_theory_to_proof "subclass" "prove a subclass relation" K.thy_goal
   455     (P.xname >> Class.subclass_cmd);
   456 
   457 val _ =
   458   OuterSyntax.command "instantiation" "instantiate and prove type arity" K.thy_decl
   459    (P.multi_arity --| P.begin
   460      >> (fn arities => Toplevel.print o
   461          Toplevel.begin_local_theory true (Theory_Target.instantiation_cmd arities)));
   462 
   463 val _ =
   464   OuterSyntax.command "instance" "prove type arity or subclass relation" K.thy_goal
   465   ((P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) >> Class.classrel_cmd ||
   466     P.multi_arity >> Class.instance_arity_cmd)
   467     >> (Toplevel.print oo Toplevel.theory_to_proof)
   468   || Scan.succeed (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I)));
   469 
   470 
   471 (* arbitrary overloading *)
   472 
   473 val _ =
   474   OuterSyntax.command "overloading" "overloaded definitions" K.thy_decl
   475    (Scan.repeat1 (P.name --| (P.$$$ "\\<equiv>" || P.$$$ "==") -- P.term --
   476       Scan.optional (P.$$$ "(" |-- (P.$$$ "unchecked" >> K false) --| P.$$$ ")") true
   477       >> P.triple1) --| P.begin
   478    >> (fn operations => Toplevel.print o
   479          Toplevel.begin_local_theory true (Theory_Target.overloading_cmd operations)));
   480 
   481 
   482 (* code generation *)
   483 
   484 val _ =
   485   OuterSyntax.command "code_datatype" "define set of code datatype constructors" K.thy_decl
   486     (Scan.repeat1 P.term >> (Toplevel.theory o Code.add_datatype_cmd));
   487 
   488 
   489 
   490 (** proof commands **)
   491 
   492 (* statements *)
   493 
   494 fun gen_theorem schematic kind =
   495   OuterSyntax.local_theory_to_proof'
   496     (if schematic then "schematic_" ^ kind else kind)
   497     ("state " ^ (if schematic then "schematic " ^ kind else kind))
   498     (if schematic then K.thy_schematic_goal else K.thy_goal)
   499     (Scan.optional (SpecParse.opt_thm_name ":" --|
   500       Scan.ahead (SpecParse.locale_keyword || SpecParse.statement_keyword)) Attrib.empty_binding --
   501       SpecParse.general_statement >> (fn (a, (elems, concl)) =>
   502         ((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd)
   503           kind NONE (K I) a elems concl)));
   504 
   505 val _ = gen_theorem false Thm.theoremK;
   506 val _ = gen_theorem false Thm.lemmaK;
   507 val _ = gen_theorem false Thm.corollaryK;
   508 val _ = gen_theorem true Thm.theoremK;
   509 val _ = gen_theorem true Thm.lemmaK;
   510 val _ = gen_theorem true Thm.corollaryK;
   511 
   512 val _ =
   513   OuterSyntax.local_theory_to_proof "example_proof"
   514     "example proof body, without any result" K.thy_schematic_goal
   515     (Scan.succeed
   516       (Specification.schematic_theorem_cmd "" NONE (K I)
   517         Attrib.empty_binding [] (Element.Shows []) false #> Proof.enter_forward));
   518 
   519 val _ =
   520   OuterSyntax.command "have" "state local goal"
   521     (K.tag_proof K.prf_goal)
   522     (SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.have));
   523 
   524 val _ =
   525   OuterSyntax.command "hence" "abbreviates \"then have\""
   526     (K.tag_proof K.prf_goal)
   527     (SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.hence));
   528 
   529 val _ =
   530   OuterSyntax.command "show" "state local goal, solving current obligation"
   531     (K.tag_proof K.prf_asm_goal)
   532     (SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.show));
   533 
   534 val _ =
   535   OuterSyntax.command "thus" "abbreviates \"then show\""
   536     (K.tag_proof K.prf_asm_goal)
   537     (SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.thus));
   538 
   539 
   540 (* facts *)
   541 
   542 val facts = P.and_list1 SpecParse.xthms1;
   543 
   544 val _ =
   545   OuterSyntax.command "then" "forward chaining"
   546     (K.tag_proof K.prf_chain)
   547     (Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain));
   548 
   549 val _ =
   550   OuterSyntax.command "from" "forward chaining from given facts"
   551     (K.tag_proof K.prf_chain)
   552     (facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd)));
   553 
   554 val _ =
   555   OuterSyntax.command "with" "forward chaining from given and current facts"
   556     (K.tag_proof K.prf_chain)
   557     (facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd)));
   558 
   559 val _ =
   560   OuterSyntax.command "note" "define facts"
   561     (K.tag_proof K.prf_decl)
   562     (SpecParse.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd)));
   563 
   564 val _ =
   565   OuterSyntax.command "using" "augment goal facts"
   566     (K.tag_proof K.prf_decl)
   567     (facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd)));
   568 
   569 val _ =
   570   OuterSyntax.command "unfolding" "unfold definitions in goal and facts"
   571     (K.tag_proof K.prf_decl)
   572     (facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd)));
   573 
   574 
   575 (* proof context *)
   576 
   577 val _ =
   578   OuterSyntax.command "fix" "fix local variables (Skolem constants)"
   579     (K.tag_proof K.prf_asm)
   580     (P.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd)));
   581 
   582 val _ =
   583   OuterSyntax.command "assume" "assume propositions"
   584     (K.tag_proof K.prf_asm)
   585     (SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd)));
   586 
   587 val _ =
   588   OuterSyntax.command "presume" "assume propositions, to be established later"
   589     (K.tag_proof K.prf_asm)
   590     (SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd)));
   591 
   592 val _ =
   593   OuterSyntax.command "def" "local definition"
   594     (K.tag_proof K.prf_asm)
   595     (P.and_list1
   596       (SpecParse.opt_thm_name ":" --
   597         ((P.binding -- P.opt_mixfix) -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp)))
   598     >> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd)));
   599 
   600 val _ =
   601   OuterSyntax.command "obtain" "generalized existence"
   602     (K.tag_proof K.prf_asm_goal)
   603     (P.parname -- Scan.optional (P.fixes --| P.where_) [] -- SpecParse.statement
   604       >> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z)));
   605 
   606 val _ =
   607   OuterSyntax.command "guess" "wild guessing (unstructured)"
   608     (K.tag_proof K.prf_asm_goal)
   609     (Scan.optional P.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd)));
   610 
   611 val _ =
   612   OuterSyntax.command "let" "bind text variables"
   613     (K.tag_proof K.prf_decl)
   614     (P.and_list1 (P.and_list1 P.term -- (P.$$$ "=" |-- P.term))
   615       >> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd)));
   616 
   617 val case_spec =
   618   (P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.maybe P.name) --| P.$$$ ")") ||
   619     P.xname >> rpair []) -- SpecParse.opt_attribs >> P.triple1;
   620 
   621 val _ =
   622   OuterSyntax.command "case" "invoke local context"
   623     (K.tag_proof K.prf_asm)
   624     (case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd)));
   625 
   626 
   627 (* proof structure *)
   628 
   629 val _ =
   630   OuterSyntax.command "{" "begin explicit proof block"
   631     (K.tag_proof K.prf_open)
   632     (Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block));
   633 
   634 val _ =
   635   OuterSyntax.command "}" "end explicit proof block"
   636     (K.tag_proof K.prf_close)
   637     (Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block));
   638 
   639 val _ =
   640   OuterSyntax.command "next" "enter next proof block"
   641     (K.tag_proof K.prf_block)
   642     (Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block));
   643 
   644 
   645 (* end proof *)
   646 
   647 val _ =
   648   OuterSyntax.command "qed" "conclude (sub-)proof"
   649     (K.tag_proof K.qed_block)
   650     (Scan.option Method.parse >> IsarCmd.qed);
   651 
   652 val _ =
   653   OuterSyntax.command "by" "terminal backward proof"
   654     (K.tag_proof K.qed)
   655     (Method.parse -- Scan.option Method.parse >> IsarCmd.terminal_proof);
   656 
   657 val _ =
   658   OuterSyntax.command ".." "default proof"
   659     (K.tag_proof K.qed)
   660     (Scan.succeed IsarCmd.default_proof);
   661 
   662 val _ =
   663   OuterSyntax.command "." "immediate proof"
   664     (K.tag_proof K.qed)
   665     (Scan.succeed IsarCmd.immediate_proof);
   666 
   667 val _ =
   668   OuterSyntax.command "done" "done proof"
   669     (K.tag_proof K.qed)
   670     (Scan.succeed IsarCmd.done_proof);
   671 
   672 val _ =
   673   OuterSyntax.command "sorry" "skip proof (quick-and-dirty mode only!)"
   674     (K.tag_proof K.qed)
   675     (Scan.succeed IsarCmd.skip_proof);
   676 
   677 val _ =
   678   OuterSyntax.command "oops" "forget proof"
   679     (K.tag_proof K.qed_global)
   680     (Scan.succeed Toplevel.forget_proof);
   681 
   682 
   683 (* proof steps *)
   684 
   685 val _ =
   686   OuterSyntax.command "defer" "shuffle internal proof state"
   687     (K.tag_proof K.prf_script)
   688     (Scan.option P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer)));
   689 
   690 val _ =
   691   OuterSyntax.command "prefer" "shuffle internal proof state"
   692     (K.tag_proof K.prf_script)
   693     (P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer)));
   694 
   695 val _ =
   696   OuterSyntax.command "apply" "initial refinement step (unstructured)"
   697     (K.tag_proof K.prf_script)
   698     (Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply)));
   699 
   700 val _ =
   701   OuterSyntax.command "apply_end" "terminal refinement (unstructured)"
   702     (K.tag_proof K.prf_script)
   703     (Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end)));
   704 
   705 val _ =
   706   OuterSyntax.command "proof" "backward proof"
   707     (K.tag_proof K.prf_block)
   708     (Scan.option Method.parse >> (fn m => Toplevel.print o
   709       Toplevel.actual_proof (Proof_Node.applys (Proof.proof m)) o
   710       Toplevel.skip_proof (fn i => i + 1)));
   711 
   712 
   713 (* calculational proof commands *)
   714 
   715 val calc_args =
   716   Scan.option (P.$$$ "(" |-- P.!!! ((SpecParse.xthms1 --| P.$$$ ")")));
   717 
   718 val _ =
   719   OuterSyntax.command "also" "combine calculation and current facts"
   720     (K.tag_proof K.prf_decl)
   721     (calc_args >> (Toplevel.proofs' o Calculation.also_cmd));
   722 
   723 val _ =
   724   OuterSyntax.command "finally" "combine calculation and current facts, exhibit result"
   725     (K.tag_proof K.prf_chain)
   726     (calc_args >> (Toplevel.proofs' o Calculation.finally_cmd));
   727 
   728 val _ =
   729   OuterSyntax.command "moreover" "augment calculation by current facts"
   730     (K.tag_proof K.prf_decl)
   731     (Scan.succeed (Toplevel.proof' Calculation.moreover));
   732 
   733 val _ =
   734   OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result"
   735     (K.tag_proof K.prf_chain)
   736     (Scan.succeed (Toplevel.proof' Calculation.ultimately));
   737 
   738 
   739 (* proof navigation *)
   740 
   741 val _ =
   742   OuterSyntax.command "back" "backtracking of proof command"
   743     (K.tag_proof K.prf_script)
   744     (Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I));
   745 
   746 
   747 (* nested commands *)
   748 
   749 val props_text =
   750   Scan.optional ValueParse.properties [] -- P.position P.string >> (fn (props, (str, pos)) =>
   751     (Position.of_properties (Position.default_properties pos props), str));
   752 
   753 val _ =
   754   OuterSyntax.improper_command "Isabelle.command" "nested Isabelle command" K.control
   755     (props_text :|-- (fn (pos, str) =>
   756       (case OuterSyntax.parse pos str of
   757         [tr] => Scan.succeed (K tr)
   758       | _ => Scan.fail_with (K "exactly one command expected"))
   759       handle ERROR msg => Scan.fail_with (K msg)));
   760 
   761 
   762 
   763 (** diagnostic commands (for interactive mode only) **)
   764 
   765 val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) [];
   766 val opt_bang = Scan.optional (P.$$$ "!" >> K true) false;
   767 
   768 val _ =
   769   OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing"
   770     K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin));
   771 
   772 val _ =
   773   OuterSyntax.improper_command "help" "print outer syntax commands" K.diag
   774     (Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax));
   775 
   776 val _ =
   777   OuterSyntax.improper_command "print_commands" "print outer syntax commands" K.diag
   778     (Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax));
   779 
   780 val _ =
   781   OuterSyntax.improper_command "print_configs" "print configuration options" K.diag
   782     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_configs));
   783 
   784 val _ =
   785   OuterSyntax.improper_command "print_context" "print theory context name" K.diag
   786     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_context));
   787 
   788 val _ =
   789   OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag
   790     (opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theory));
   791 
   792 val _ =
   793   OuterSyntax.improper_command "print_syntax" "print inner syntax of context (verbose!)" K.diag
   794     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax));
   795 
   796 val _ =
   797   OuterSyntax.improper_command "print_abbrevs" "print constant abbreviation of context" K.diag
   798     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_abbrevs));
   799 
   800 val _ =
   801   OuterSyntax.improper_command "print_theorems"
   802       "print theorems of local theory or proof context" K.diag
   803     (opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theorems));
   804 
   805 val _ =
   806   OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag
   807     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_locales));
   808 
   809 val _ =
   810   OuterSyntax.improper_command "print_classes" "print classes of this theory" K.diag
   811     (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory
   812       o Toplevel.keep (Class.print_classes o Toplevel.theory_of)));
   813 
   814 val _ =
   815   OuterSyntax.improper_command "print_locale" "print locale of this theory" K.diag
   816     (opt_bang -- P.xname >> (Toplevel.no_timing oo IsarCmd.print_locale));
   817 
   818 val _ =
   819   OuterSyntax.improper_command "print_interps"
   820     "print interpretations of locale for this theory" K.diag
   821     (P.xname >> (Toplevel.no_timing oo IsarCmd.print_registrations));
   822 
   823 val _ =
   824   OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag
   825     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes));
   826 
   827 val _ =
   828   OuterSyntax.improper_command "print_simpset" "print context of Simplifier" K.diag
   829     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_simpset));
   830 
   831 val _ =
   832   OuterSyntax.improper_command "print_rules" "print intro/elim rules" K.diag
   833     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_rules));
   834 
   835 val _ =
   836   OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag
   837     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules));
   838 
   839 val _ =
   840   OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag
   841     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods));
   842 
   843 val _ =
   844   OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag
   845     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations));
   846 
   847 val _ =
   848   OuterSyntax.improper_command "thy_deps" "visualize theory dependencies"
   849     K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.thy_deps));
   850 
   851 val _ =
   852   OuterSyntax.improper_command "class_deps" "visualize class dependencies"
   853     K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.class_deps));
   854 
   855 val _ =
   856   OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies"
   857     K.diag (SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps));
   858 
   859 val _ =
   860   OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag
   861     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds));
   862 
   863 val _ =
   864   OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag
   865     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_facts));
   866 
   867 val _ =
   868   OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag
   869     (Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases));
   870 
   871 val _ =
   872   OuterSyntax.improper_command "print_statement" "print theorems as long statements" K.diag
   873     (opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_stmts));
   874 
   875 val _ =
   876   OuterSyntax.improper_command "thm" "print theorems" K.diag
   877     (opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms));
   878 
   879 val _ =
   880   OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag
   881     (opt_modes -- Scan.option SpecParse.xthms1
   882       >> (Toplevel.no_timing oo IsarCmd.print_prfs false));
   883 
   884 val _ =
   885   OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag
   886     (opt_modes -- Scan.option SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs true));
   887 
   888 val _ =
   889   OuterSyntax.improper_command "prop" "read and print proposition" K.diag
   890     (opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_prop));
   891 
   892 val _ =
   893   OuterSyntax.improper_command "term" "read and print term" K.diag
   894     (opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_term));
   895 
   896 val _ =
   897   OuterSyntax.improper_command "typ" "read and print type" K.diag
   898     (opt_modes -- P.typ >> (Toplevel.no_timing oo IsarCmd.print_type));
   899 
   900 val _ =
   901   OuterSyntax.improper_command "print_codesetup" "print code generator setup" K.diag
   902     (Scan.succeed
   903       (Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep
   904         (Code.print_codesetup o Toplevel.theory_of)));
   905 
   906 val _ =
   907   OuterSyntax.improper_command "unused_thms" "find unused theorems" K.diag
   908     (Scan.option ((Scan.repeat1 (Scan.unless P.minus P.name) --| P.minus) --
   909        Scan.option (Scan.repeat1 (Scan.unless P.minus P.name))) >>
   910          (Toplevel.no_timing oo IsarCmd.unused_thms));
   911 
   912 
   913 
   914 (** system commands (for interactive mode only) **)
   915 
   916 val _ =
   917   OuterSyntax.improper_command "cd" "change current working directory" K.diag
   918     (P.path >> (Toplevel.no_timing oo IsarCmd.cd));
   919 
   920 val _ =
   921   OuterSyntax.improper_command "pwd" "print current working directory" K.diag
   922     (Scan.succeed (Toplevel.no_timing o IsarCmd.pwd));
   923 
   924 val _ =
   925   OuterSyntax.improper_command "use_thy" "use theory file" K.diag
   926     (P.name >> (fn name =>
   927       Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.use_thy name)));
   928 
   929 val _ =
   930   OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag
   931     (P.name >> (fn name =>
   932       Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.touch_thy name)));
   933 
   934 val _ =
   935   OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag
   936     (P.name >> (fn name =>
   937       Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.remove_thy name)));
   938 
   939 val _ =
   940   OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database"
   941     K.diag (P.name >> (fn name =>
   942       Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.kill_thy name)));
   943 
   944 val _ =
   945   OuterSyntax.improper_command "display_drafts" "display raw source files with symbols"
   946     K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.display_drafts));
   947 
   948 val _ =
   949   OuterSyntax.improper_command "print_drafts" "print raw source files with symbols"
   950     K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.print_drafts));
   951 
   952 val opt_limits =
   953   Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat);
   954 
   955 val _ =
   956   OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag
   957     (opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr));
   958 
   959 val _ =
   960   OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag
   961     (Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr));
   962 
   963 val _ =
   964   OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag
   965     (Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr));
   966 
   967 val _ =
   968   OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag
   969     (P.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit));
   970 
   971 val _ =
   972   OuterSyntax.improper_command "quit" "quit Isabelle" K.control
   973     (P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit));
   974 
   975 val _ =
   976   OuterSyntax.improper_command "exit" "exit Isar loop" K.control
   977     (Scan.succeed (Toplevel.no_timing o IsarCmd.exit));
   978 
   979 end;
   980