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