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