src/Pure/Isar/isar_syn.ML
author wenzelm
Tue Oct 16 00:34:34 2001 +0200 (2001-10-16 ago)
changeset 11793 5f0ab6f5c280
parent 11742 44034a6474e5
child 11890 28e42a90bea8
permissions -rw-r--r--
support impromptu terminology of cases parameters;
wenzelm@5832
     1
(*  Title:      Pure/Isar/isar_syn.ML
wenzelm@5832
     2
    ID:         $Id$
wenzelm@5832
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@8807
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@5832
     5
wenzelm@6353
     6
Isar/Pure outer syntax.
wenzelm@5832
     7
*)
wenzelm@5832
     8
wenzelm@5832
     9
signature ISAR_SYN =
wenzelm@5832
    10
sig
wenzelm@5832
    11
  val keywords: string list
wenzelm@5832
    12
  val parsers: OuterSyntax.parser list
wenzelm@5832
    13
end;
wenzelm@5832
    14
wenzelm@5832
    15
structure IsarSyn: ISAR_SYN =
wenzelm@5832
    16
struct
wenzelm@5832
    17
wenzelm@6723
    18
structure P = OuterParse and K = OuterSyntax.Keyword;
wenzelm@5832
    19
wenzelm@5832
    20
wenzelm@5832
    21
(** init and exit **)
wenzelm@5832
    22
wenzelm@5832
    23
val theoryP =
wenzelm@6723
    24
  OuterSyntax.command "theory" "begin theory" K.thy_begin
wenzelm@9129
    25
    (ThyHeader.args >> (Toplevel.print oo IsarThy.theory));
wenzelm@5832
    26
wenzelm@6687
    27
val end_excursionP =
wenzelm@6723
    28
  OuterSyntax.command "end" "end current excursion" K.thy_end
wenzelm@6687
    29
    (Scan.succeed (Toplevel.print o Toplevel.exit));
wenzelm@6687
    30
wenzelm@6245
    31
val contextP =
wenzelm@7102
    32
  OuterSyntax.improper_command "context" "switch theory context" K.thy_switch
wenzelm@6723
    33
    (P.name >> (Toplevel.print oo IsarThy.context));
wenzelm@6245
    34
wenzelm@5832
    35
wenzelm@5832
    36
wenzelm@7749
    37
(** markup commands **)
wenzelm@5832
    38
wenzelm@9129
    39
val headerP = OuterSyntax.markup_command IsarOutput.Markup "header" "theory header" K.diag
wenzelm@7733
    40
  (P.comment >> IsarThy.add_header);
wenzelm@6353
    41
wenzelm@9129
    42
val chapterP = OuterSyntax.markup_command IsarOutput.Markup "chapter" "chapter heading"
wenzelm@9129
    43
  K.thy_heading (P.comment >> (Toplevel.theory o IsarThy.add_chapter));
wenzelm@5958
    44
wenzelm@9129
    45
val sectionP = OuterSyntax.markup_command IsarOutput.Markup "section" "section heading"
wenzelm@9129
    46
  K.thy_heading (P.comment >> (Toplevel.theory o IsarThy.add_section));
wenzelm@5958
    47
wenzelm@9129
    48
val subsectionP = OuterSyntax.markup_command IsarOutput.Markup "subsection" "subsection heading"
wenzelm@9129
    49
  K.thy_heading (P.comment >> (Toplevel.theory o IsarThy.add_subsection));
wenzelm@5958
    50
wenzelm@7749
    51
val subsubsectionP =
wenzelm@9129
    52
  OuterSyntax.markup_command IsarOutput.Markup "subsubsection" "subsubsection heading"
wenzelm@9129
    53
  K.thy_heading (P.comment >> (Toplevel.theory o IsarThy.add_subsubsection));
wenzelm@5832
    54
wenzelm@9129
    55
val textP = OuterSyntax.markup_command IsarOutput.MarkupEnv "text" "formal comment (theory)"
wenzelm@9129
    56
  K.thy_decl (P.comment >> (Toplevel.theory o IsarThy.add_text));
wenzelm@7172
    57
wenzelm@9129
    58
val text_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "text_raw"
wenzelm@9129
    59
  "raw document preparation text" K.thy_decl
wenzelm@9129
    60
  (P.comment >> (Toplevel.theory o IsarThy.add_text_raw));
wenzelm@7775
    61
wenzelm@7172
    62
wenzelm@9552
    63
val sectP = OuterSyntax.markup_command IsarOutput.Markup "sect" "formal comment (proof)"
wenzelm@9552
    64
  K.prf_heading (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_sect)));
wenzelm@7172
    65
wenzelm@9129
    66
val subsectP = OuterSyntax.markup_command IsarOutput.Markup "subsect" "formal comment (proof)"
wenzelm@9552
    67
  K.prf_heading (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_subsect)));
wenzelm@7172
    68
wenzelm@9129
    69
val subsubsectP = OuterSyntax.markup_command IsarOutput.Markup "subsubsect"
wenzelm@9552
    70
  "formal comment (proof)" K.prf_heading
wenzelm@7172
    71
  (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_subsubsect)));
wenzelm@7172
    72
wenzelm@9129
    73
val txtP = OuterSyntax.markup_command IsarOutput.MarkupEnv "txt" "formal comment (proof)"
wenzelm@9129
    74
  K.prf_decl (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_txt)));
wenzelm@7172
    75
wenzelm@9129
    76
val txt_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "txt_raw"
wenzelm@9129
    77
  "raw document preparation text (proof)" K.prf_decl
wenzelm@9129
    78
  (P.comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.add_txt_raw)));
wenzelm@7775
    79
wenzelm@5832
    80
wenzelm@6886
    81
wenzelm@6886
    82
(** theory sections **)
wenzelm@6886
    83
wenzelm@5832
    84
(* classes and sorts *)
wenzelm@5832
    85
wenzelm@5832
    86
val classesP =
wenzelm@6723
    87
  OuterSyntax.command "classes" "declare type classes" K.thy_decl
wenzelm@11101
    88
    (Scan.repeat1 (P.name -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |--
wenzelm@11101
    89
        P.!!! (P.list1 P.xname)) [])
wenzelm@6727
    90
      -- P.marg_comment >> (Toplevel.theory o IsarThy.add_classes));
wenzelm@5832
    91
wenzelm@5832
    92
val classrelP =
wenzelm@6723
    93
  OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl
wenzelm@11101
    94
    (P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) -- P.marg_comment
wenzelm@6727
    95
      >> (Toplevel.theory o IsarThy.add_classrel));
wenzelm@5832
    96
wenzelm@5832
    97
val defaultsortP =
wenzelm@6723
    98
  OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl
wenzelm@6727
    99
    (P.sort -- P.marg_comment >> (Toplevel.theory o IsarThy.add_defsort));
wenzelm@5832
   100
wenzelm@5832
   101
wenzelm@5832
   102
(* types *)
wenzelm@5832
   103
wenzelm@5832
   104
val typedeclP =
wenzelm@6723
   105
  OuterSyntax.command "typedecl" "Pure type declaration" K.thy_decl
wenzelm@6727
   106
    (P.type_args -- P.name -- P.opt_infix -- P.marg_comment >> (fn (((args, a), mx), cmt) =>
wenzelm@6727
   107
      Toplevel.theory (IsarThy.add_typedecl ((a, args, mx), cmt))));
wenzelm@5832
   108
wenzelm@5832
   109
val typeabbrP =
wenzelm@6723
   110
  OuterSyntax.command "types" "declare type abbreviations" K.thy_decl
wenzelm@6727
   111
    (Scan.repeat1
wenzelm@9037
   112
      (P.type_args -- P.name -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_infix')) -- P.marg_comment)
wenzelm@6727
   113
      >> (Toplevel.theory o IsarThy.add_tyabbrs o
wenzelm@6727
   114
        map (fn (((args, a), (T, mx)), cmt) => ((a, args, T, mx), cmt))));
wenzelm@5832
   115
wenzelm@5832
   116
val nontermP =
wenzelm@6370
   117
  OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols"
wenzelm@6727
   118
    K.thy_decl (Scan.repeat1 (P.name -- P.marg_comment)
wenzelm@6727
   119
      >> (Toplevel.theory o IsarThy.add_nonterminals));
wenzelm@5832
   120
wenzelm@5832
   121
val aritiesP =
wenzelm@6723
   122
  OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl
wenzelm@6727
   123
    (Scan.repeat1 ((P.xname -- (P.$$$ "::" |-- P.!!! P.arity) >> P.triple2) -- P.marg_comment)
wenzelm@6727
   124
      >> (Toplevel.theory o IsarThy.add_arities));
wenzelm@5832
   125
wenzelm@5832
   126
wenzelm@5832
   127
(* consts and syntax *)
wenzelm@5832
   128
wenzelm@8227
   129
val judgmentP =
wenzelm@8227
   130
  OuterSyntax.command "judgment" "declare object-logic judgment" K.thy_decl
wenzelm@8227
   131
    (P.const -- P.marg_comment >> (Toplevel.theory o IsarThy.add_judgment));
wenzelm@8227
   132
wenzelm@5832
   133
val constsP =
wenzelm@6723
   134
  OuterSyntax.command "consts" "declare constants" K.thy_decl
wenzelm@6727
   135
    (Scan.repeat1 (P.const -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_consts));
wenzelm@5832
   136
wenzelm@9731
   137
wenzelm@9731
   138
val mode_spec = 
wenzelm@9731
   139
  (P.$$$ "output" >> K ("", false)) || P.name -- Scan.optional (P.$$$ "output" >> K false) true;
wenzelm@9731
   140
wenzelm@9731
   141
val opt_mode = Scan.optional (P.$$$ "(" |-- P.!!! (mode_spec --| P.$$$ ")")) ("", true);
wenzelm@5832
   142
wenzelm@5832
   143
val syntaxP =
wenzelm@6723
   144
  OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl
wenzelm@6727
   145
    (opt_mode -- Scan.repeat1 (P.const -- P.marg_comment)
wenzelm@6727
   146
      >> (Toplevel.theory o uncurry IsarThy.add_modesyntax));
wenzelm@5832
   147
wenzelm@5832
   148
wenzelm@5832
   149
(* translations *)
wenzelm@5832
   150
wenzelm@5832
   151
val trans_pat =
wenzelm@6723
   152
  Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string;
wenzelm@5832
   153
wenzelm@5832
   154
fun trans_arrow toks =
wenzelm@10688
   155
  ((P.$$$ "\\<rightharpoonup>" || P.$$$ "=>") >> K Syntax.ParseRule ||
wenzelm@10688
   156
    (P.$$$ "\\<leftharpoondown>" || P.$$$ "<=") >> K Syntax.PrintRule ||
wenzelm@10688
   157
    (P.$$$ "\\<rightleftharpoons>" || P.$$$ "==") >> K Syntax.ParsePrintRule) toks;
wenzelm@5832
   158
wenzelm@5832
   159
val trans_line =
wenzelm@6723
   160
  trans_pat -- P.!!! (trans_arrow -- trans_pat)
wenzelm@5832
   161
    >> (fn (left, (arr, right)) => arr (left, right));
wenzelm@5832
   162
wenzelm@5832
   163
val translationsP =
wenzelm@6723
   164
  OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl
wenzelm@6727
   165
    (Scan.repeat1 (trans_line -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_trrules));
wenzelm@5832
   166
wenzelm@5832
   167
wenzelm@5832
   168
(* axioms and definitions *)
wenzelm@5832
   169
wenzelm@5832
   170
val axiomsP =
wenzelm@6723
   171
  OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl
wenzelm@6727
   172
    (Scan.repeat1 (P.spec_name -- P.marg_comment) >> (Toplevel.theory o IsarThy.add_axioms));
wenzelm@5832
   173
wenzelm@9323
   174
val opt_overloaded =
wenzelm@9323
   175
  Scan.optional (P.$$$ "(" |-- P.!!! ((P.$$$ "overloaded" >> K true) --| P.$$$ ")")) false;
wenzelm@9323
   176
wenzelm@5832
   177
val defsP =
wenzelm@6723
   178
  OuterSyntax.command "defs" "define constants" K.thy_decl
wenzelm@9323
   179
    (opt_overloaded -- Scan.repeat1 (P.spec_name -- P.marg_comment)
wenzelm@9323
   180
  >> (Toplevel.theory o IsarThy.add_defs));
wenzelm@6370
   181
wenzelm@6370
   182
val constdefsP =
wenzelm@6723
   183
  OuterSyntax.command "constdefs" "declare and define constants" K.thy_decl
wenzelm@6727
   184
    (Scan.repeat1 ((P.const -- P.marg_comment) -- (P.term -- P.marg_comment))
wenzelm@6727
   185
      >> (Toplevel.theory o IsarThy.add_constdefs));
wenzelm@5832
   186
wenzelm@5832
   187
wenzelm@5914
   188
(* theorems *)
wenzelm@5914
   189
wenzelm@9197
   190
val name_facts = P.and_list1 (P.opt_thm_name "=" -- P.xthms1 -- P.marg_comment);
wenzelm@5914
   191
wenzelm@5914
   192
val theoremsP =
wenzelm@6723
   193
  OuterSyntax.command "theorems" "define theorems" K.thy_decl
wenzelm@11742
   194
    (name_facts >> (Toplevel.theory o IsarThy.have_theorems Drule.theoremK));
wenzelm@5914
   195
wenzelm@5914
   196
val lemmasP =
wenzelm@6723
   197
  OuterSyntax.command "lemmas" "define lemmas" K.thy_decl
wenzelm@11742
   198
    (name_facts >> (Toplevel.theory o IsarThy.have_theorems Drule.lemmaK));
wenzelm@5914
   199
wenzelm@9589
   200
val declareP =
wenzelm@9776
   201
  OuterSyntax.command "declare" "declare theorems (improper)" K.thy_script
wenzelm@9589
   202
    (P.xthms1 -- P.marg_comment >> (Toplevel.theory o IsarThy.declare_theorems));
wenzelm@9589
   203
wenzelm@5914
   204
wenzelm@5832
   205
(* name space entry path *)
wenzelm@5832
   206
wenzelm@5832
   207
val globalP =
wenzelm@6723
   208
  OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl
wenzelm@8723
   209
    (P.marg_comment >> (Toplevel.theory o IsarThy.global_path));
wenzelm@5832
   210
wenzelm@5832
   211
val localP =
wenzelm@6723
   212
  OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl
wenzelm@8723
   213
    (P.marg_comment >> (Toplevel.theory o IsarThy.local_path));
wenzelm@8723
   214
wenzelm@8723
   215
val hideP =
wenzelm@8723
   216
  OuterSyntax.command "hide" "hide names from given name space" K.thy_decl
wenzelm@8723
   217
    (P.name -- Scan.repeat1 P.xname -- P.marg_comment >> (Toplevel.theory o IsarThy.hide_space));
wenzelm@5832
   218
wenzelm@5832
   219
wenzelm@5832
   220
(* use ML text *)
wenzelm@5832
   221
wenzelm@5832
   222
val useP =
wenzelm@6723
   223
  OuterSyntax.command "use" "eval ML text from file" K.diag
wenzelm@9273
   224
    (P.name -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.use));
wenzelm@5832
   225
wenzelm@5832
   226
val mlP =
wenzelm@7616
   227
  OuterSyntax.command "ML" "eval ML text (diagnostic)" K.diag
wenzelm@9273
   228
    (P.text -- P.marg_comment >> IsarCmd.use_mltext true);
wenzelm@7891
   229
wenzelm@7891
   230
val ml_commandP =
wenzelm@7891
   231
  OuterSyntax.command "ML_command" "eval ML text" K.diag
wenzelm@9978
   232
    (P.text -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.use_mltext false));
wenzelm@7616
   233
wenzelm@7616
   234
val ml_setupP =
wenzelm@7616
   235
  OuterSyntax.command "ML_setup" "eval ML text (may change theory)" K.thy_decl
wenzelm@9273
   236
    (P.text -- P.marg_comment >> IsarCmd.use_mltext_theory);
wenzelm@5832
   237
wenzelm@5832
   238
val setupP =
wenzelm@7616
   239
  OuterSyntax.command "setup" "apply ML theory setup" K.thy_decl
wenzelm@9273
   240
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarCmd.use_setup));
wenzelm@5832
   241
wenzelm@9197
   242
val method_setupP =
wenzelm@9197
   243
  OuterSyntax.command "method_setup" "define proof method in ML" K.thy_decl
wenzelm@9197
   244
    (((P.name -- P.!!! (P.$$$ "=" |-- P.text -- P.text) >> P.triple2)
wenzelm@9197
   245
      -- P.marg_comment) >> (Toplevel.theory o IsarThy.method_setup));
wenzelm@9197
   246
wenzelm@5832
   247
wenzelm@5832
   248
(* translation functions *)
wenzelm@5832
   249
wenzelm@5832
   250
val parse_ast_translationP =
wenzelm@6723
   251
  OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" K.thy_decl
wenzelm@9273
   252
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.parse_ast_translation));
wenzelm@5832
   253
wenzelm@5832
   254
val parse_translationP =
wenzelm@6723
   255
  OuterSyntax.command "parse_translation" "install parse translation functions" K.thy_decl
wenzelm@9273
   256
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.parse_translation));
wenzelm@5832
   257
wenzelm@5832
   258
val print_translationP =
wenzelm@6723
   259
  OuterSyntax.command "print_translation" "install print translation functions" K.thy_decl
wenzelm@9273
   260
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.print_translation));
wenzelm@5832
   261
wenzelm@5832
   262
val typed_print_translationP =
wenzelm@6370
   263
  OuterSyntax.command "typed_print_translation" "install typed print translation functions"
wenzelm@9273
   264
    K.thy_decl (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.typed_print_translation));
wenzelm@5832
   265
wenzelm@5832
   266
val print_ast_translationP =
wenzelm@6723
   267
  OuterSyntax.command "print_ast_translation" "install print ast translation functions" K.thy_decl
wenzelm@9273
   268
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.print_ast_translation));
wenzelm@5832
   269
wenzelm@5832
   270
val token_translationP =
wenzelm@6723
   271
  OuterSyntax.command "token_translation" "install token translation functions" K.thy_decl
wenzelm@9273
   272
    (P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.token_translation));
wenzelm@5832
   273
wenzelm@5832
   274
wenzelm@5832
   275
(* oracles *)
wenzelm@5832
   276
wenzelm@5832
   277
val oracleP =
wenzelm@6723
   278
  OuterSyntax.command "oracle" "install oracle" K.thy_decl
wenzelm@7140
   279
    ((P.name --| P.$$$ "=") -- P.text -- P.marg_comment >> (Toplevel.theory o IsarThy.add_oracle));
wenzelm@5832
   280
wenzelm@5832
   281
wenzelm@5832
   282
wenzelm@5832
   283
(** proof commands **)
wenzelm@5832
   284
wenzelm@5832
   285
(* statements *)
wenzelm@5832
   286
wenzelm@10464
   287
fun statement f = P.opt_thm_name ":" -- P.propp -- P.marg_comment >> f;
wenzelm@5832
   288
wenzelm@5832
   289
val theoremP =
wenzelm@6723
   290
  OuterSyntax.command "theorem" "state theorem" K.thy_goal
wenzelm@11742
   291
    (statement (IsarThy.theorem Drule.theoremK) >> (Toplevel.print oo Toplevel.theory_to_proof));
wenzelm@5832
   292
wenzelm@5832
   293
val lemmaP =
wenzelm@6723
   294
  OuterSyntax.command "lemma" "state lemma" K.thy_goal
wenzelm@11742
   295
    (statement (IsarThy.theorem Drule.lemmaK) >> (Toplevel.print oo Toplevel.theory_to_proof));
wenzelm@11742
   296
wenzelm@11742
   297
val corollaryP =
wenzelm@11742
   298
  OuterSyntax.command "corollary" "state corollary" K.thy_goal
wenzelm@11742
   299
    (statement (IsarThy.theorem Drule.corollaryK) >> (Toplevel.print oo Toplevel.theory_to_proof));
wenzelm@5832
   300
wenzelm@5832
   301
val showP =
wenzelm@6723
   302
  OuterSyntax.command "show" "state local goal, solving current obligation" K.prf_goal
wenzelm@10934
   303
    (statement IsarThy.show >> (fn f => Toplevel.print o Toplevel.proof' f));
wenzelm@5832
   304
wenzelm@5832
   305
val haveP =
wenzelm@6723
   306
  OuterSyntax.command "have" "state local goal" K.prf_goal
wenzelm@5832
   307
    (statement IsarThy.have >> (fn f => Toplevel.print o Toplevel.proof f));
wenzelm@5832
   308
wenzelm@6501
   309
val thusP =
wenzelm@6723
   310
  OuterSyntax.command "thus" "abbreviates \"then show\"" K.prf_goal
wenzelm@10934
   311
    (statement IsarThy.thus >> (fn f => Toplevel.print o Toplevel.proof' f));
wenzelm@6501
   312
wenzelm@6501
   313
val henceP =
wenzelm@6723
   314
  OuterSyntax.command "hence" "abbreviates \"then have\"" K.prf_goal
wenzelm@6501
   315
    (statement IsarThy.hence >> (fn f => Toplevel.print o Toplevel.proof f));
wenzelm@6501
   316
wenzelm@5832
   317
wenzelm@5914
   318
(* facts *)
wenzelm@5832
   319
wenzelm@9197
   320
val facts = P.and_list1 (P.xthms1 -- P.marg_comment);
wenzelm@9197
   321
wenzelm@5832
   322
val thenP =
wenzelm@6723
   323
  OuterSyntax.command "then" "forward chaining" K.prf_chain
wenzelm@6727
   324
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.chain)));
wenzelm@5832
   325
wenzelm@5832
   326
val fromP =
wenzelm@6723
   327
  OuterSyntax.command "from" "forward chaining from given facts" K.prf_chain
wenzelm@9197
   328
    (facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.from_facts)));
wenzelm@5914
   329
wenzelm@6878
   330
val withP =
wenzelm@6878
   331
  OuterSyntax.command "with" "forward chaining from given and current facts" K.prf_chain
wenzelm@9197
   332
    (facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.with_facts)));
wenzelm@6878
   333
wenzelm@6773
   334
val noteP =
wenzelm@6723
   335
  OuterSyntax.command "note" "define facts" K.prf_decl
wenzelm@9197
   336
    (name_facts >> (Toplevel.print oo (Toplevel.proof o IsarThy.have_facts)));
wenzelm@5832
   337
wenzelm@5832
   338
wenzelm@5832
   339
(* proof context *)
wenzelm@5832
   340
wenzelm@5832
   341
val assumeP =
wenzelm@6869
   342
  OuterSyntax.command "assume" "assume propositions" K.prf_asm
wenzelm@10464
   343
    (P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp -- P.marg_comment)
wenzelm@6727
   344
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.assume)));
wenzelm@5832
   345
wenzelm@6850
   346
val presumeP =
wenzelm@6869
   347
  OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm
wenzelm@10464
   348
    (P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp -- P.marg_comment)
wenzelm@6850
   349
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.presume)));
wenzelm@6850
   350
wenzelm@6953
   351
val defP =
wenzelm@6953
   352
  OuterSyntax.command "def" "local definition" K.prf_asm
wenzelm@10688
   353
    (P.opt_thm_name ":" -- (P.name -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp))
wenzelm@9465
   354
      -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.local_def)));
wenzelm@6953
   355
wenzelm@5832
   356
val fixP =
wenzelm@6869
   357
  OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm
wenzelm@7415
   358
    (P.and_list1 (Scan.repeat1 P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- P.marg_comment)
wenzelm@6727
   359
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.fix)));
wenzelm@5832
   360
wenzelm@5832
   361
val letP =
wenzelm@6723
   362
  OuterSyntax.command "let" "bind text variables" K.prf_decl
wenzelm@8669
   363
    (P.and_list1 (P.enum1 "and" P.term -- (P.$$$ "=" |-- P.term) -- P.marg_comment)
wenzelm@8615
   364
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.let_bind)));
wenzelm@5832
   365
wenzelm@11793
   366
val case_spec =
wenzelm@11793
   367
  (P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.underscore >> K None || P.name >> Some)
wenzelm@11793
   368
    --| P.$$$ ")") || P.xname >> rpair []) -- P.opt_attribs >> P.triple1;
wenzelm@11793
   369
wenzelm@8370
   370
val caseP =
wenzelm@8370
   371
  OuterSyntax.command "case" "invoke local context" K.prf_asm
wenzelm@11793
   372
    (case_spec -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.invoke_case)));
wenzelm@8370
   373
wenzelm@5832
   374
wenzelm@5832
   375
(* proof structure *)
wenzelm@5832
   376
wenzelm@5832
   377
val beginP =
wenzelm@9056
   378
  OuterSyntax.command "{" "begin explicit proof block" K.prf_open
wenzelm@9032
   379
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.begin_block)));
wenzelm@5832
   380
wenzelm@6687
   381
val endP =
wenzelm@9056
   382
  OuterSyntax.command "}" "end explicit proof block" K.prf_close
wenzelm@9032
   383
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.end_block)));
wenzelm@6687
   384
wenzelm@5832
   385
val nextP =
wenzelm@6723
   386
  OuterSyntax.command "next" "enter next proof block" K.prf_block
wenzelm@9032
   387
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.next_block)));
wenzelm@5832
   388
wenzelm@5832
   389
wenzelm@5832
   390
(* end proof *)
wenzelm@5832
   391
wenzelm@6404
   392
val qedP =
wenzelm@6735
   393
  OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block
wenzelm@7002
   394
    (Scan.option (P.method -- P.interest) -- P.marg_comment >> IsarThy.qed);
wenzelm@5832
   395
wenzelm@6404
   396
val terminal_proofP =
wenzelm@6723
   397
  OuterSyntax.command "by" "terminal backward proof" K.qed
wenzelm@7002
   398
    (P.method -- P.interest -- Scan.option (P.method -- P.interest)
wenzelm@7002
   399
      -- P.marg_comment >> IsarThy.terminal_proof);
wenzelm@6404
   400
wenzelm@8966
   401
val default_proofP =
wenzelm@8966
   402
  OuterSyntax.command ".." "default proof" K.qed
wenzelm@8966
   403
    (P.marg_comment >> IsarThy.default_proof);
wenzelm@8966
   404
wenzelm@6404
   405
val immediate_proofP =
wenzelm@6723
   406
  OuterSyntax.command "." "immediate proof" K.qed
wenzelm@7002
   407
    (P.marg_comment >> IsarThy.immediate_proof);
wenzelm@6404
   408
wenzelm@8966
   409
val done_proofP =
wenzelm@8966
   410
  OuterSyntax.command "done" "done proof" K.qed
wenzelm@8966
   411
    (P.marg_comment >> IsarThy.done_proof);
wenzelm@5832
   412
wenzelm@6888
   413
val skip_proofP =
wenzelm@7172
   414
  OuterSyntax.improper_command "sorry" "skip proof (quick-and-dirty mode only!)" K.qed
wenzelm@7002
   415
    (P.marg_comment >> IsarThy.skip_proof);
wenzelm@6888
   416
wenzelm@8210
   417
val forget_proofP =
wenzelm@8521
   418
  OuterSyntax.command "oops" "forget proof" K.qed_global
wenzelm@8210
   419
    (P.marg_comment >> IsarThy.forget_proof);
wenzelm@8210
   420
wenzelm@8210
   421
wenzelm@5832
   422
wenzelm@5832
   423
(* proof steps *)
wenzelm@5832
   424
wenzelm@8165
   425
val deferP =
wenzelm@8681
   426
  OuterSyntax.command "defer" "shuffle internal proof state" K.prf_script
wenzelm@8681
   427
    (Scan.option P.nat -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.defer)));
wenzelm@8165
   428
wenzelm@8165
   429
val preferP =
wenzelm@8681
   430
  OuterSyntax.command "prefer" "shuffle internal proof state" K.prf_script
wenzelm@8681
   431
    (P.nat -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.prefer)));
wenzelm@8165
   432
wenzelm@6850
   433
val applyP =
wenzelm@8681
   434
  OuterSyntax.command "apply" "initial refinement step (unstructured)" K.prf_script
wenzelm@8681
   435
    (P.method -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply)));
wenzelm@5832
   436
wenzelm@8235
   437
val apply_endP =
wenzelm@8681
   438
  OuterSyntax.command "apply_end" "terminal refinement (unstructured)" K.prf_script
wenzelm@8681
   439
    (P.method -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply_end)));
wenzelm@5832
   440
wenzelm@6404
   441
val proofP =
wenzelm@6723
   442
  OuterSyntax.command "proof" "backward proof" K.prf_block
wenzelm@7002
   443
    (P.interest -- Scan.option (P.method -- P.interest) -- P.marg_comment
wenzelm@6727
   444
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.proof)));
wenzelm@5832
   445
wenzelm@5832
   446
wenzelm@6773
   447
(* calculational proof commands *)
wenzelm@6773
   448
wenzelm@6878
   449
val calc_args =
wenzelm@6878
   450
  Scan.option (P.$$$ "(" |-- P.!!! ((P.xthms1 --| P.$$$ ")") -- P.interest));
wenzelm@6878
   451
wenzelm@6773
   452
val alsoP =
wenzelm@8562
   453
  OuterSyntax.command "also" "combine calculation and current facts" K.prf_decl
wenzelm@6878
   454
    (calc_args -- P.marg_comment >> IsarThy.also);
wenzelm@6773
   455
wenzelm@6773
   456
val finallyP =
wenzelm@8562
   457
  OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" K.prf_chain
wenzelm@6878
   458
    (calc_args -- P.marg_comment >> IsarThy.finally);
wenzelm@6773
   459
wenzelm@8562
   460
val moreoverP =
wenzelm@8562
   461
  OuterSyntax.command "moreover" "augment calculation by current facts" K.prf_decl
wenzelm@8562
   462
    (P.marg_comment >> IsarThy.moreover);
wenzelm@8562
   463
wenzelm@8588
   464
val ultimatelyP =
wenzelm@8588
   465
  OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result"
wenzelm@8588
   466
    K.prf_chain (P.marg_comment >> IsarThy.ultimately);
wenzelm@8588
   467
wenzelm@6773
   468
wenzelm@6742
   469
(* proof navigation *)
wenzelm@5944
   470
wenzelm@5832
   471
val backP =
wenzelm@8235
   472
  OuterSyntax.command "back" "backtracking of proof command" K.prf_script
wenzelm@9273
   473
    (Scan.optional (P.$$$ "!" >> K true) false -- P.marg_comment >>
wenzelm@9273
   474
      (Toplevel.print oo IsarCmd.back));
wenzelm@5832
   475
wenzelm@5832
   476
wenzelm@6742
   477
(* history *)
wenzelm@6742
   478
wenzelm@6742
   479
val cannot_undoP =
wenzelm@6742
   480
  OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control
wenzelm@9010
   481
    (P.name >> (Toplevel.no_timing oo IsarCmd.cannot_undo));
wenzelm@6742
   482
wenzelm@7733
   483
val clear_undosP =
wenzelm@7733
   484
  OuterSyntax.improper_command "clear_undos" "clear theory-level undo information" K.control
wenzelm@9010
   485
    (P.nat >> (Toplevel.no_timing oo IsarCmd.clear_undos_theory));
wenzelm@6742
   486
wenzelm@6742
   487
val redoP =
wenzelm@6742
   488
  OuterSyntax.improper_command "redo" "redo last command" K.control
wenzelm@9010
   489
    (Scan.succeed (Toplevel.no_timing o Toplevel.print o IsarCmd.redo));
wenzelm@6742
   490
wenzelm@6742
   491
val undos_proofP =
wenzelm@6742
   492
  OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control
wenzelm@9010
   493
    (P.nat >> ((Toplevel.no_timing o Toplevel.print) oo IsarCmd.undos_proof));
wenzelm@6742
   494
wenzelm@6742
   495
val undoP =
wenzelm@6742
   496
  OuterSyntax.improper_command "undo" "undo last command" K.control
wenzelm@9010
   497
    (Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.undo));
wenzelm@6742
   498
wenzelm@8500
   499
val killP =
wenzelm@8500
   500
  OuterSyntax.improper_command "kill" "kill current history node" K.control
wenzelm@9010
   501
    (Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.kill));
wenzelm@8500
   502
wenzelm@6742
   503
wenzelm@5832
   504
wenzelm@5832
   505
(** diagnostic commands (for interactive mode only) **)
wenzelm@5832
   506
wenzelm@8464
   507
val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) [];
wenzelm@8464
   508
wenzelm@8464
   509
wenzelm@7124
   510
val pretty_setmarginP =
wenzelm@7124
   511
  OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing"
wenzelm@9010
   512
    K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin));
wenzelm@7124
   513
wenzelm@5832
   514
val print_commandsP =
wenzelm@9221
   515
  OuterSyntax.improper_command "print_commands" "print outer syntax (global)" K.diag
wenzelm@9221
   516
    (Scan.succeed (Toplevel.no_timing o OuterSyntax.print_commands));
wenzelm@5832
   517
wenzelm@7308
   518
val print_contextP =
wenzelm@7308
   519
  OuterSyntax.improper_command "print_context" "print theory context name" K.diag
wenzelm@9010
   520
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_context));
wenzelm@7308
   521
wenzelm@5832
   522
val print_theoryP =
wenzelm@6723
   523
  OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag
wenzelm@9010
   524
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_theory));
wenzelm@5832
   525
wenzelm@5832
   526
val print_syntaxP =
wenzelm@6723
   527
  OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag
wenzelm@9010
   528
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax));
wenzelm@5832
   529
wenzelm@5881
   530
val print_theoremsP =
wenzelm@6723
   531
  OuterSyntax.improper_command "print_theorems" "print theorems known in this theory" K.diag
wenzelm@9010
   532
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems));
wenzelm@5881
   533
wenzelm@5832
   534
val print_attributesP =
wenzelm@6723
   535
  OuterSyntax.improper_command "print_attributes" "print attributes known in this theory" K.diag
wenzelm@9010
   536
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes));
wenzelm@5832
   537
wenzelm@11666
   538
val print_induct_rulesP =
wenzelm@11666
   539
  OuterSyntax.improper_command "print_induct_rules" "print induction and cases rules" K.diag
wenzelm@11666
   540
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_induct_rules));
wenzelm@11666
   541
wenzelm@9221
   542
val print_trans_rulesP =
wenzelm@11666
   543
  OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag
wenzelm@9221
   544
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules));
wenzelm@9221
   545
wenzelm@5832
   546
val print_methodsP =
wenzelm@6723
   547
  OuterSyntax.improper_command "print_methods" "print methods known in this theory" K.diag
wenzelm@9010
   548
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods));
wenzelm@5832
   549
wenzelm@9221
   550
val print_antiquotationsP =
wenzelm@9221
   551
  OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag
wenzelm@9221
   552
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations));
wenzelm@9221
   553
wenzelm@7616
   554
val thms_containingP =
wenzelm@11017
   555
  OuterSyntax.improper_command "thms_containing" "print theorems containing certain constants"
wenzelm@11017
   556
    K.diag (Scan.repeat P.term >> (Toplevel.no_timing oo IsarCmd.print_thms_containing));
wenzelm@7616
   557
wenzelm@9454
   558
val thm_depsP =
wenzelm@9454
   559
  OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies"
wenzelm@9454
   560
    K.diag (P.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps));
wenzelm@9454
   561
wenzelm@5832
   562
val print_bindsP =
wenzelm@6723
   563
  OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag
wenzelm@9010
   564
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds));
wenzelm@5832
   565
wenzelm@5832
   566
val print_lthmsP =
wenzelm@8370
   567
  OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag
wenzelm@9010
   568
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_lthms));
wenzelm@5832
   569
wenzelm@8370
   570
val print_casesP =
wenzelm@8370
   571
  OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag
wenzelm@9010
   572
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases));
wenzelm@8370
   573
wenzelm@5896
   574
val print_thmsP =
wenzelm@8464
   575
  OuterSyntax.improper_command "thm" "print theorems" K.diag
wenzelm@10581
   576
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_thms));
wenzelm@5832
   577
berghofe@11524
   578
val print_prfsP =
berghofe@11524
   579
  OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag
berghofe@11524
   580
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prfs false));
berghofe@11524
   581
berghofe@11524
   582
val print_full_prfsP =
berghofe@11524
   583
  OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag
berghofe@11524
   584
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prfs true));
berghofe@11524
   585
wenzelm@5832
   586
val print_propP =
wenzelm@6723
   587
  OuterSyntax.improper_command "prop" "read and print proposition" K.diag
wenzelm@10581
   588
    (opt_modes -- P.term -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prop));
wenzelm@5832
   589
wenzelm@5832
   590
val print_termP =
wenzelm@6723
   591
  OuterSyntax.improper_command "term" "read and print term" K.diag
wenzelm@10581
   592
    (opt_modes -- P.term -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_term));
wenzelm@5832
   593
wenzelm@5832
   594
val print_typeP =
wenzelm@6723
   595
  OuterSyntax.improper_command "typ" "read and print type" K.diag
wenzelm@10581
   596
    (opt_modes -- P.typ -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_type));
wenzelm@5832
   597
wenzelm@5832
   598
wenzelm@5832
   599
wenzelm@5832
   600
(** system commands (for interactive mode only) **)
wenzelm@5832
   601
wenzelm@5832
   602
val cdP =
wenzelm@8650
   603
  OuterSyntax.improper_command "cd" "change current working directory" K.diag
wenzelm@9010
   604
    (P.name >> (Toplevel.no_timing oo IsarCmd.cd));
wenzelm@5832
   605
wenzelm@5832
   606
val pwdP =
wenzelm@6723
   607
  OuterSyntax.improper_command "pwd" "print current working directory" K.diag
wenzelm@9010
   608
    (Scan.succeed (Toplevel.no_timing o IsarCmd.pwd));
wenzelm@5832
   609
wenzelm@5832
   610
val use_thyP =
wenzelm@6723
   611
  OuterSyntax.improper_command "use_thy" "use theory file" K.diag
wenzelm@9010
   612
    (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy));
wenzelm@5832
   613
wenzelm@6694
   614
val use_thy_onlyP =
wenzelm@7102
   615
  OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML"
wenzelm@9010
   616
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy_only));
wenzelm@6694
   617
wenzelm@6196
   618
val update_thyP =
wenzelm@6723
   619
  OuterSyntax.improper_command "update_thy" "update theory file" K.diag
wenzelm@9010
   620
    (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy));
wenzelm@5832
   621
wenzelm@7102
   622
val update_thy_onlyP =
wenzelm@7102
   623
  OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML"
wenzelm@9010
   624
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy_only));
wenzelm@7102
   625
wenzelm@7102
   626
val touch_thyP =
wenzelm@7102
   627
  OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag
wenzelm@9010
   628
    (P.name >> (Toplevel.no_timing oo IsarCmd.touch_thy));
wenzelm@7102
   629
wenzelm@7102
   630
val touch_all_thysP =
wenzelm@7102
   631
  OuterSyntax.improper_command "touch_all_thys" "outdate all non-finished theories" K.diag
wenzelm@9010
   632
    (Scan.succeed (Toplevel.no_timing o IsarCmd.touch_all_thys));
wenzelm@7102
   633
wenzelm@7908
   634
val touch_child_thysP =
wenzelm@7908
   635
  OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag
wenzelm@9010
   636
    (P.name >> (Toplevel.no_timing oo IsarCmd.touch_child_thys));
wenzelm@7908
   637
wenzelm@7102
   638
val remove_thyP =
wenzelm@7102
   639
  OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag
wenzelm@9010
   640
    (P.name >> (Toplevel.no_timing oo IsarCmd.remove_thy));
wenzelm@7102
   641
wenzelm@7931
   642
val kill_thyP =
wenzelm@7931
   643
  OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database"
wenzelm@9010
   644
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.kill_thy));
wenzelm@7931
   645
wenzelm@9731
   646
val opt_limits =
wenzelm@9731
   647
  Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat);
wenzelm@9731
   648
wenzelm@5832
   649
val prP =
wenzelm@8886
   650
  OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag
wenzelm@9731
   651
    (opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr));
wenzelm@7199
   652
wenzelm@7222
   653
val disable_prP =
wenzelm@7222
   654
  OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag
wenzelm@9010
   655
    (Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr));
wenzelm@5832
   656
wenzelm@7222
   657
val enable_prP =
wenzelm@7222
   658
  OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag
wenzelm@9010
   659
    (Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr));
wenzelm@7222
   660
wenzelm@5832
   661
val commitP =
wenzelm@6723
   662
  OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag
wenzelm@9010
   663
    (P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.use_commit));
wenzelm@5832
   664
wenzelm@5832
   665
val quitP =
wenzelm@6723
   666
  OuterSyntax.improper_command "quit" "quit Isabelle" K.control
wenzelm@9010
   667
    (P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit));
wenzelm@5832
   668
wenzelm@5832
   669
val exitP =
wenzelm@6723
   670
  OuterSyntax.improper_command "exit" "exit Isar loop" K.control
wenzelm@9010
   671
    (Scan.succeed (Toplevel.no_timing o IsarCmd.exit));
wenzelm@5832
   672
wenzelm@7102
   673
val init_toplevelP =
wenzelm@7102
   674
  OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control
wenzelm@9010
   675
    (Scan.succeed (Toplevel.no_timing o IsarCmd.init_toplevel));
wenzelm@5991
   676
wenzelm@7462
   677
val welcomeP =
wenzelm@8678
   678
  OuterSyntax.improper_command "welcome" "print welcome message" K.diag
wenzelm@9010
   679
    (Scan.succeed (Toplevel.no_timing o IsarCmd.welcome));
wenzelm@7462
   680
wenzelm@5832
   681
wenzelm@5832
   682
wenzelm@5832
   683
(** the Pure outer syntax **)
wenzelm@5832
   684
wenzelm@5832
   685
(*keep keywords consistent with the parsers, including those in
wenzelm@5832
   686
  outer_parse.ML, otherwise be prepared for unexpected errors*)
wenzelm@5832
   687
wenzelm@5832
   688
val keywords =
wenzelm@7415
   689
 ["!", "!!", "%", "%%", "(", ")", "+", ",", "--", ":", "::", ";", "<",
wenzelm@8669
   690
  "<=", "=", "==", "=>", "?", "[", "]", "and", "binder", "concl",
wenzelm@11651
   691
  "files", "in", "infix", "infixl", "infixr", "is", "output", "overloaded",
wenzelm@11101
   692
  "|", "\\<equiv>", "\\<rightharpoonup>", "\\<leftharpoondown>",
wenzelm@11101
   693
  "\\<rightleftharpoons>", "\\<subseteq>"];
wenzelm@5832
   694
wenzelm@5832
   695
val parsers = [
wenzelm@5832
   696
  (*theory structure*)
wenzelm@8500
   697
  theoryP, end_excursionP, contextP,
wenzelm@7775
   698
  (*markup commands*)
wenzelm@7733
   699
  headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP,
wenzelm@7862
   700
  text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP,
wenzelm@5832
   701
  (*theory sections*)
wenzelm@7172
   702
  classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP,
wenzelm@8227
   703
  aritiesP, judgmentP, constsP, syntaxP, translationsP, axiomsP,
wenzelm@9589
   704
  defsP, constdefsP, theoremsP, lemmasP, declareP, globalP, localP,
wenzelm@9589
   705
  hideP, useP, mlP, ml_commandP, ml_setupP, setupP, method_setupP,
wenzelm@9197
   706
  parse_ast_translationP, parse_translationP, print_translationP,
wenzelm@9197
   707
  typed_print_translationP, print_ast_translationP,
wenzelm@9197
   708
  token_translationP, oracleP,
wenzelm@5832
   709
  (*proof commands*)
wenzelm@11742
   710
  theoremP, lemmaP, corollaryP, showP, haveP, thusP, henceP, assumeP,
wenzelm@11742
   711
  presumeP, defP, fixP, letP, caseP, thenP, fromP, withP, noteP,
wenzelm@11742
   712
  beginP, endP, nextP, qedP, terminal_proofP, default_proofP,
wenzelm@11742
   713
  immediate_proofP, done_proofP, skip_proofP, forget_proofP, deferP,
wenzelm@11742
   714
  preferP, applyP, apply_endP, proofP, alsoP, finallyP, moreoverP,
wenzelm@11742
   715
  ultimatelyP, backP, cannot_undoP, clear_undosP, redoP, undos_proofP,
wenzelm@11742
   716
  undoP, killP,
wenzelm@5832
   717
  (*diagnostic commands*)
wenzelm@7308
   718
  pretty_setmarginP, print_commandsP, print_contextP, print_theoryP,
wenzelm@9221
   719
  print_syntaxP, print_theoremsP, print_attributesP,
wenzelm@11666
   720
  print_induct_rulesP, print_trans_rulesP, print_methodsP,
wenzelm@11666
   721
  print_antiquotationsP, thms_containingP, thm_depsP, print_bindsP,
wenzelm@11666
   722
  print_lthmsP, print_casesP, print_thmsP, print_prfsP,
wenzelm@11666
   723
  print_full_prfsP, print_propP, print_termP, print_typeP,
wenzelm@5832
   724
  (*system commands*)
wenzelm@7102
   725
  cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP,
wenzelm@7931
   726
  touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP,
wenzelm@7931
   727
  kill_thyP, prP, disable_prP, enable_prP, commitP, quitP, exitP,
wenzelm@7931
   728
  init_toplevelP, welcomeP];
wenzelm@5832
   729
wenzelm@5832
   730
wenzelm@5832
   731
end;
wenzelm@5832
   732
wenzelm@5832
   733
wenzelm@6196
   734
(*install the Pure outer syntax*)
wenzelm@5832
   735
OuterSyntax.add_keywords IsarSyn.keywords;
wenzelm@5832
   736
OuterSyntax.add_parsers IsarSyn.parsers;