src/Pure/Isar/isar_syn.ML
changeset 48643 9b9b36a89e56
parent 48642 1737bdb896bb
child 48645 33f00ce23e63
equal deleted inserted replaced
48642:1737bdb896bb 48643:9b9b36a89e56
    75 
    75 
    76 (* classes and sorts *)
    76 (* classes and sorts *)
    77 
    77 
    78 val _ =
    78 val _ =
    79   Outer_Syntax.command @{command_spec "classes"} "declare type classes"
    79   Outer_Syntax.command @{command_spec "classes"} "declare type classes"
    80     (Scan.repeat1 (Parse.binding -- Scan.optional ((Parse.$$$ "\<subseteq>" || Parse.$$$ "<") |--
    80     (Scan.repeat1 (Parse.binding -- Scan.optional ((@{keyword "\<subseteq>"} || @{keyword "<"}) |--
    81         Parse.!!! (Parse.list1 Parse.class)) [])
    81         Parse.!!! (Parse.list1 Parse.class)) [])
    82       >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd));
    82       >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd));
    83 
    83 
    84 val _ =
    84 val _ =
    85   Outer_Syntax.command @{command_spec "classrel"} "state inclusion of type classes (axiomatic!)"
    85   Outer_Syntax.command @{command_spec "classrel"} "state inclusion of type classes (axiomatic!)"
    86     (Parse.and_list1 (Parse.class -- ((Parse.$$$ "\<subseteq>" || Parse.$$$ "<")
    86     (Parse.and_list1 (Parse.class -- ((@{keyword "\<subseteq>"} || @{keyword "<"})
    87         |-- Parse.!!! Parse.class))
    87         |-- Parse.!!! Parse.class))
    88     >> (Toplevel.theory o AxClass.axiomatize_classrel_cmd));
    88     >> (Toplevel.theory o AxClass.axiomatize_classrel_cmd));
    89 
    89 
    90 val _ =
    90 val _ =
    91   Outer_Syntax.local_theory @{command_spec "default_sort"}
    91   Outer_Syntax.local_theory @{command_spec "default_sort"}
   101       >> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd));
   101       >> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd));
   102 
   102 
   103 val _ =
   103 val _ =
   104   Outer_Syntax.local_theory @{command_spec "type_synonym"} "declare type abbreviation"
   104   Outer_Syntax.local_theory @{command_spec "type_synonym"} "declare type abbreviation"
   105     (Parse.type_args -- Parse.binding --
   105     (Parse.type_args -- Parse.binding --
   106       (Parse.$$$ "=" |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))
   106       (@{keyword "="} |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))
   107       >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs));
   107       >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs));
   108 
   108 
   109 val _ =
   109 val _ =
   110   Outer_Syntax.command @{command_spec "nonterminal"}
   110   Outer_Syntax.command @{command_spec "nonterminal"}
   111     "declare syntactic type constructors (grammar nonterminal symbols)"
   111     "declare syntactic type constructors (grammar nonterminal symbols)"
   125 val _ =
   125 val _ =
   126   Outer_Syntax.command @{command_spec "consts"} "declare constants"
   126   Outer_Syntax.command @{command_spec "consts"} "declare constants"
   127     (Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts));
   127     (Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts));
   128 
   128 
   129 val mode_spec =
   129 val mode_spec =
   130   (Parse.$$$ "output" >> K ("", false)) ||
   130   (@{keyword "output"} >> K ("", false)) ||
   131     Parse.name -- Scan.optional (Parse.$$$ "output" >> K false) true;
   131     Parse.name -- Scan.optional (@{keyword "output"} >> K false) true;
   132 
   132 
   133 val opt_mode =
   133 val opt_mode =
   134   Scan.optional (Parse.$$$ "(" |-- Parse.!!! (mode_spec --| Parse.$$$ ")")) Syntax.mode_default;
   134   Scan.optional (@{keyword "("} |-- Parse.!!! (mode_spec --| @{keyword ")"})) Syntax.mode_default;
   135 
   135 
   136 val _ =
   136 val _ =
   137   Outer_Syntax.command @{command_spec "syntax"} "declare syntactic constants"
   137   Outer_Syntax.command @{command_spec "syntax"} "declare syntactic constants"
   138     (opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax));
   138     (opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax));
   139 
   139 
   144 
   144 
   145 (* translations *)
   145 (* translations *)
   146 
   146 
   147 val trans_pat =
   147 val trans_pat =
   148   Scan.optional
   148   Scan.optional
   149     (Parse.$$$ "(" |-- Parse.!!! (Parse.xname --| Parse.$$$ ")")) "logic"
   149     (@{keyword "("} |-- Parse.!!! (Parse.xname --| @{keyword ")"})) "logic"
   150     -- Parse.inner_syntax Parse.string;
   150     -- Parse.inner_syntax Parse.string;
   151 
   151 
   152 fun trans_arrow toks =
   152 fun trans_arrow toks =
   153   ((Parse.$$$ "\<rightharpoonup>" || Parse.$$$ "=>") >> K Syntax.Parse_Rule ||
   153   ((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule ||
   154     (Parse.$$$ "\<leftharpoondown>" || Parse.$$$ "<=") >> K Syntax.Print_Rule ||
   154     (@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule ||
   155     (Parse.$$$ "\<rightleftharpoons>" || Parse.$$$ "==") >> K Syntax.Parse_Print_Rule) toks;
   155     (@{keyword "\<rightleftharpoons>"} || @{keyword "=="}) >> K Syntax.Parse_Print_Rule) toks;
   156 
   156 
   157 val trans_line =
   157 val trans_line =
   158   trans_pat -- Parse.!!! (trans_arrow -- trans_pat)
   158   trans_pat -- Parse.!!! (trans_arrow -- trans_pat)
   159     >> (fn (left, (arr, right)) => arr (left, right));
   159     >> (fn (left, (arr, right)) => arr (left, right));
   160 
   160 
   175       (fn spec => Toplevel.theory (fn thy =>
   175       (fn spec => Toplevel.theory (fn thy =>
   176         (legacy_feature "Old 'axioms' command -- use 'axiomatization' instead";
   176         (legacy_feature "Old 'axioms' command -- use 'axiomatization' instead";
   177           Isar_Cmd.add_axioms spec thy))));
   177           Isar_Cmd.add_axioms spec thy))));
   178 
   178 
   179 val opt_unchecked_overloaded =
   179 val opt_unchecked_overloaded =
   180   Scan.optional (Parse.$$$ "(" |-- Parse.!!!
   180   Scan.optional (@{keyword "("} |-- Parse.!!!
   181     (((Parse.$$$ "unchecked" >> K true) -- Scan.optional (Parse.$$$ "overloaded" >> K true) false ||
   181     (((@{keyword "unchecked"} >> K true) --
   182       Parse.$$$ "overloaded" >> K (false, true)) --| Parse.$$$ ")")) (false, false);
   182         Scan.optional (@{keyword "overloaded"} >> K true) false ||
       
   183       @{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false);
   183 
   184 
   184 val _ =
   185 val _ =
   185   Outer_Syntax.command @{command_spec "defs"} "define constants"
   186   Outer_Syntax.command @{command_spec "defs"} "define constants"
   186     (opt_unchecked_overloaded --
   187     (opt_unchecked_overloaded --
   187       Scan.repeat1 (Parse_Spec.thm_name ":" -- Parse.prop >> (fn ((x, y), z) => ((x, z), y)))
   188       Scan.repeat1 (Parse_Spec.thm_name ":" -- Parse.prop >> (fn ((x, y), z) => ((x, z), y)))
   302     (Parse.ML_source >> Isar_Cmd.local_setup);
   303     (Parse.ML_source >> Isar_Cmd.local_setup);
   303 
   304 
   304 val _ =
   305 val _ =
   305   Outer_Syntax.command @{command_spec "attribute_setup"} "define attribute in ML"
   306   Outer_Syntax.command @{command_spec "attribute_setup"} "define attribute in ML"
   306     (Parse.position Parse.name --
   307     (Parse.position Parse.name --
   307         Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Scan.optional Parse.text "")
   308         Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
   308       >> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt)));
   309       >> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt)));
   309 
   310 
   310 val _ =
   311 val _ =
   311   Outer_Syntax.command @{command_spec "method_setup"} "define proof method in ML"
   312   Outer_Syntax.command @{command_spec "method_setup"} "define proof method in ML"
   312     (Parse.position Parse.name --
   313     (Parse.position Parse.name --
   313         Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Scan.optional Parse.text "")
   314         Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
   314       >> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt)));
   315       >> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt)));
   315 
   316 
   316 val _ =
   317 val _ =
   317   Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration"
   318   Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration"
   318     (Parse.opt_keyword "pervasive" -- Parse.ML_source
   319     (Parse.opt_keyword "pervasive" -- Parse.ML_source
   324       >> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt));
   325       >> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt));
   325 
   326 
   326 val _ =
   327 val _ =
   327   Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML"
   328   Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML"
   328     (Parse.position Parse.name --
   329     (Parse.position Parse.name --
   329       (Parse.$$$ "(" |-- Parse.enum1 "|" Parse.term --| Parse.$$$ ")" --| Parse.$$$ "=") --
   330       (@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) --
   330       Parse.ML_source -- Scan.optional (Parse.$$$ "identifier" |-- Scan.repeat1 Parse.xname) []
   331       Parse.ML_source -- Scan.optional (@{keyword "identifier"} |-- Scan.repeat1 Parse.xname) []
   331     >> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d));
   332     >> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d));
   332 
   333 
   333 
   334 
   334 (* translation functions *)
   335 (* translation functions *)
   335 
   336 
   363 
   364 
   364 (* oracles *)
   365 (* oracles *)
   365 
   366 
   366 val _ =
   367 val _ =
   367   Outer_Syntax.command @{command_spec "oracle"} "declare oracle"
   368   Outer_Syntax.command @{command_spec "oracle"} "declare oracle"
   368     (Parse.position Parse.name -- (Parse.$$$ "=" |-- Parse.ML_source) >>
   369     (Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >>
   369       (fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y)));
   370       (fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y)));
   370 
   371 
   371 
   372 
   372 (* bundled declarations *)
   373 (* bundled declarations *)
   373 
   374 
   374 val _ =
   375 val _ =
   375   Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations"
   376   Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations"
   376     ((Parse.binding --| Parse.$$$ "=") -- Parse_Spec.xthms1 -- Parse.for_fixes
   377     ((Parse.binding --| @{keyword "="}) -- Parse_Spec.xthms1 -- Parse.for_fixes
   377       >> (uncurry Bundle.bundle_cmd));
   378       >> (uncurry Bundle.bundle_cmd));
   378 
   379 
   379 val _ =
   380 val _ =
   380   Outer_Syntax.command @{command_spec "include"}
   381   Outer_Syntax.command @{command_spec "include"}
   381     "include declarations from bundle in proof body"
   382     "include declarations from bundle in proof body"
   408 
   409 
   409 (* locales *)
   410 (* locales *)
   410 
   411 
   411 val locale_val =
   412 val locale_val =
   412   Parse_Spec.locale_expression false --
   413   Parse_Spec.locale_expression false --
   413     Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
   414     Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
   414   Scan.repeat1 Parse_Spec.context_element >> pair ([], []);
   415   Scan.repeat1 Parse_Spec.context_element >> pair ([], []);
   415 
   416 
   416 val _ =
   417 val _ =
   417   Outer_Syntax.command @{command_spec "locale"} "define named proof context"
   418   Outer_Syntax.command @{command_spec "locale"} "define named proof context"
   418     (Parse.binding --
   419     (Parse.binding --
   419       Scan.optional (Parse.$$$ "=" |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin
   420       Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin
   420       >> (fn ((name, (expr, elems)), begin) =>
   421       >> (fn ((name, (expr, elems)), begin) =>
   421           (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   422           (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   422             (Expression.add_locale_cmd I name Binding.empty expr elems #> snd)));
   423             (Expression.add_locale_cmd I name Binding.empty expr elems #> snd)));
   423 
   424 
   424 fun parse_interpretation_arguments mandatory =
   425 fun parse_interpretation_arguments mandatory =
   427       (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [];
   428       (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [];
   428 
   429 
   429 val _ =
   430 val _ =
   430   Outer_Syntax.command @{command_spec "sublocale"}
   431   Outer_Syntax.command @{command_spec "sublocale"}
   431     "prove sublocale relation between a locale and a locale expression"
   432     "prove sublocale relation between a locale and a locale expression"
   432     (Parse.position Parse.xname --| (Parse.$$$ "\<subseteq>" || Parse.$$$ "<") --
   433     (Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) --
   433       parse_interpretation_arguments false
   434       parse_interpretation_arguments false
   434       >> (fn (loc, (expr, equations)) =>
   435       >> (fn (loc, (expr, equations)) =>
   435           Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations)));
   436           Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations)));
   436 
   437 
   437 val _ =
   438 val _ =
   451 
   452 
   452 (* classes *)
   453 (* classes *)
   453 
   454 
   454 val class_val =
   455 val class_val =
   455   Parse_Spec.class_expression --
   456   Parse_Spec.class_expression --
   456     Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
   457     Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
   457   Scan.repeat1 Parse_Spec.context_element >> pair [];
   458   Scan.repeat1 Parse_Spec.context_element >> pair [];
   458 
   459 
   459 val _ =
   460 val _ =
   460   Outer_Syntax.command @{command_spec "class"} "define type class"
   461   Outer_Syntax.command @{command_spec "class"} "define type class"
   461    (Parse.binding -- Scan.optional (Parse.$$$ "=" |-- class_val) ([], []) -- Parse.opt_begin
   462    (Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin
   462     >> (fn ((name, (supclasses, elems)), begin) =>
   463     >> (fn ((name, (supclasses, elems)), begin) =>
   463         (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   464         (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
   464           (Class_Declaration.class_cmd I name supclasses elems #> snd)));
   465           (Class_Declaration.class_cmd I name supclasses elems #> snd)));
   465 
   466 
   466 val _ =
   467 val _ =
   474          Toplevel.begin_local_theory true (Class.instantiation_cmd arities)));
   475          Toplevel.begin_local_theory true (Class.instantiation_cmd arities)));
   475 
   476 
   476 val _ =
   477 val _ =
   477   Outer_Syntax.command @{command_spec "instance"} "prove type arity or subclass relation"
   478   Outer_Syntax.command @{command_spec "instance"} "prove type arity or subclass relation"
   478   ((Parse.class --
   479   ((Parse.class --
   479     ((Parse.$$$ "\<subseteq>" || Parse.$$$ "<") |-- Parse.!!! Parse.class) >> Class.classrel_cmd ||
   480     ((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd ||
   480     Parse.multi_arity >> Class.instance_arity_cmd)
   481     Parse.multi_arity >> Class.instance_arity_cmd)
   481     >> (Toplevel.print oo Toplevel.theory_to_proof) ||
   482     >> (Toplevel.print oo Toplevel.theory_to_proof) ||
   482     Scan.succeed
   483     Scan.succeed
   483       (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I)));
   484       (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I)));
   484 
   485 
   485 
   486 
   486 (* arbitrary overloading *)
   487 (* arbitrary overloading *)
   487 
   488 
   488 val _ =
   489 val _ =
   489   Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions"
   490   Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions"
   490    (Scan.repeat1 (Parse.name --| (Parse.$$$ "\<equiv>" || Parse.$$$ "==") -- Parse.term --
   491    (Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term --
   491       Scan.optional (Parse.$$$ "(" |-- (Parse.$$$ "unchecked" >> K false) --| Parse.$$$ ")") true
   492       Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true
   492       >> Parse.triple1) --| Parse.begin
   493       >> Parse.triple1) --| Parse.begin
   493    >> (fn operations => Toplevel.print o
   494    >> (fn operations => Toplevel.print o
   494          Toplevel.begin_local_theory true (Overloading.overloading_cmd operations)));
   495          Toplevel.begin_local_theory true (Overloading.overloading_cmd operations)));
   495 
   496 
   496 
   497 
   595 val _ =
   596 val _ =
   596   Outer_Syntax.command @{command_spec "def"} "local definition"
   597   Outer_Syntax.command @{command_spec "def"} "local definition"
   597     (Parse.and_list1
   598     (Parse.and_list1
   598       (Parse_Spec.opt_thm_name ":" --
   599       (Parse_Spec.opt_thm_name ":" --
   599         ((Parse.binding -- Parse.opt_mixfix) --
   600         ((Parse.binding -- Parse.opt_mixfix) --
   600           ((Parse.$$$ "\<equiv>" || Parse.$$$ "==") |-- Parse.!!! Parse.termp)))
   601           ((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp)))
   601     >> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd)));
   602     >> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd)));
   602 
   603 
   603 val _ =
   604 val _ =
   604   Outer_Syntax.command @{command_spec "obtain"} "generalized elimination"
   605   Outer_Syntax.command @{command_spec "obtain"} "generalized elimination"
   605     (Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement
   606     (Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement
   609   Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)"
   610   Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)"
   610     (Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd)));
   611     (Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd)));
   611 
   612 
   612 val _ =
   613 val _ =
   613   Outer_Syntax.command @{command_spec "let"} "bind text variables"
   614   Outer_Syntax.command @{command_spec "let"} "bind text variables"
   614     (Parse.and_list1 (Parse.and_list1 Parse.term -- (Parse.$$$ "=" |-- Parse.term))
   615     (Parse.and_list1 (Parse.and_list1 Parse.term -- (@{keyword "="} |-- Parse.term))
   615       >> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd)));
   616       >> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd)));
   616 
   617 
   617 val _ =
   618 val _ =
   618   Outer_Syntax.command @{command_spec "write"} "add concrete syntax for constants / fixed variables"
   619   Outer_Syntax.command @{command_spec "write"} "add concrete syntax for constants / fixed variables"
   619     (opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix)
   620     (opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix)
   620     >> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args)));
   621     >> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args)));
   621 
   622 
   622 val case_spec =
   623 val case_spec =
   623   (Parse.$$$ "(" |--
   624   (@{keyword "("} |--
   624     Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| Parse.$$$ ")") ||
   625     Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| @{keyword ")"}) ||
   625     Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1;
   626     Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1;
   626 
   627 
   627 val _ =
   628 val _ =
   628   Outer_Syntax.command @{command_spec "case"} "invoke local context"
   629   Outer_Syntax.command @{command_spec "case"} "invoke local context"
   629     (case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd)));
   630     (case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd)));
   701 
   702 
   702 
   703 
   703 (* calculational proof commands *)
   704 (* calculational proof commands *)
   704 
   705 
   705 val calc_args =
   706 val calc_args =
   706   Scan.option (Parse.$$$ "(" |-- Parse.!!! ((Parse_Spec.xthms1 --| Parse.$$$ ")")));
   707   Scan.option (@{keyword "("} |-- Parse.!!! ((Parse_Spec.xthms1 --| @{keyword ")"})));
   707 
   708 
   708 val _ =
   709 val _ =
   709   Outer_Syntax.command @{command_spec "also"} "combine calculation and current facts"
   710   Outer_Syntax.command @{command_spec "also"} "combine calculation and current facts"
   710     (calc_args >> (Toplevel.proofs' o Calculation.also_cmd));
   711     (calc_args >> (Toplevel.proofs' o Calculation.also_cmd));
   711 
   712 
   749 
   750 
   750 
   751 
   751 (** diagnostic commands (for interactive mode only) **)
   752 (** diagnostic commands (for interactive mode only) **)
   752 
   753 
   753 val opt_modes =
   754 val opt_modes =
   754   Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Scan.repeat1 Parse.xname --| Parse.$$$ ")")) [];
   755   Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) [];
   755 
   756 
   756 val opt_bang = Scan.optional (Parse.$$$ "!" >> K true) false;
   757 val opt_bang = Scan.optional (@{keyword "!"} >> K true) false;
   757 
   758 
   758 val _ =
   759 val _ =
   759   Outer_Syntax.improper_command @{command_spec "pretty_setmargin"}
   760   Outer_Syntax.improper_command @{command_spec "pretty_setmargin"}
   760     "change default margin for pretty printing"
   761     "change default margin for pretty printing"
   761     (Parse.nat >>
   762     (Parse.nat >>