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