src/Pure/Isar/isar_syn.ML
author wenzelm
Mon Oct 22 18:02:50 2001 +0200 (2001-10-22 ago)
changeset 11890 28e42a90bea8
parent 11793 5f0ab6f5c280
child 12006 72fd225a5aa2
permissions -rw-r--r--
improved source arrangement of obtain;
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@11890
   341
val fixP =
wenzelm@11890
   342
  OuterSyntax.command "fix" "fix variables (Skolem constants)" K.prf_asm
wenzelm@11890
   343
    (P.and_list1 (Scan.repeat1 P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- P.marg_comment)
wenzelm@11890
   344
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.fix)));
wenzelm@11890
   345
wenzelm@5832
   346
val assumeP =
wenzelm@6869
   347
  OuterSyntax.command "assume" "assume propositions" K.prf_asm
wenzelm@10464
   348
    (P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp -- P.marg_comment)
wenzelm@6727
   349
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.assume)));
wenzelm@5832
   350
wenzelm@6850
   351
val presumeP =
wenzelm@6869
   352
  OuterSyntax.command "presume" "assume propositions, to be established later" K.prf_asm
wenzelm@10464
   353
    (P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp -- P.marg_comment)
wenzelm@6850
   354
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.presume)));
wenzelm@6850
   355
wenzelm@6953
   356
val defP =
wenzelm@6953
   357
  OuterSyntax.command "def" "local definition" K.prf_asm
wenzelm@10688
   358
    (P.opt_thm_name ":" -- (P.name -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp))
wenzelm@9465
   359
      -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.local_def)));
wenzelm@6953
   360
wenzelm@11890
   361
val obtainP =
wenzelm@11890
   362
  OuterSyntax.command "obtain" "generalized existence"
wenzelm@11890
   363
    K.prf_asm_goal
wenzelm@11890
   364
    (Scan.optional
wenzelm@11890
   365
      (P.and_list1 (Scan.repeat1 P.name -- Scan.option (P.$$$ "::" |-- P.typ) -- P.marg_comment)
wenzelm@11890
   366
        --| P.$$$ "where") [] --
wenzelm@11890
   367
      P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp -- P.marg_comment)
wenzelm@11890
   368
    >> (Toplevel.print oo (Toplevel.proof o IsarThy.obtain)));
wenzelm@5832
   369
wenzelm@5832
   370
val letP =
wenzelm@6723
   371
  OuterSyntax.command "let" "bind text variables" K.prf_decl
wenzelm@8669
   372
    (P.and_list1 (P.enum1 "and" P.term -- (P.$$$ "=" |-- P.term) -- P.marg_comment)
wenzelm@8615
   373
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.let_bind)));
wenzelm@5832
   374
wenzelm@11793
   375
val case_spec =
wenzelm@11793
   376
  (P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.underscore >> K None || P.name >> Some)
wenzelm@11793
   377
    --| P.$$$ ")") || P.xname >> rpair []) -- P.opt_attribs >> P.triple1;
wenzelm@11793
   378
wenzelm@8370
   379
val caseP =
wenzelm@8370
   380
  OuterSyntax.command "case" "invoke local context" K.prf_asm
wenzelm@11793
   381
    (case_spec -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.invoke_case)));
wenzelm@8370
   382
wenzelm@5832
   383
wenzelm@5832
   384
(* proof structure *)
wenzelm@5832
   385
wenzelm@5832
   386
val beginP =
wenzelm@9056
   387
  OuterSyntax.command "{" "begin explicit proof block" K.prf_open
wenzelm@9032
   388
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.begin_block)));
wenzelm@5832
   389
wenzelm@6687
   390
val endP =
wenzelm@9056
   391
  OuterSyntax.command "}" "end explicit proof block" K.prf_close
wenzelm@9032
   392
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.end_block)));
wenzelm@6687
   393
wenzelm@5832
   394
val nextP =
wenzelm@6723
   395
  OuterSyntax.command "next" "enter next proof block" K.prf_block
wenzelm@9032
   396
    (P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.next_block)));
wenzelm@5832
   397
wenzelm@5832
   398
wenzelm@5832
   399
(* end proof *)
wenzelm@5832
   400
wenzelm@6404
   401
val qedP =
wenzelm@6735
   402
  OuterSyntax.command "qed" "conclude (sub-)proof" K.qed_block
wenzelm@7002
   403
    (Scan.option (P.method -- P.interest) -- P.marg_comment >> IsarThy.qed);
wenzelm@5832
   404
wenzelm@6404
   405
val terminal_proofP =
wenzelm@6723
   406
  OuterSyntax.command "by" "terminal backward proof" K.qed
wenzelm@7002
   407
    (P.method -- P.interest -- Scan.option (P.method -- P.interest)
wenzelm@7002
   408
      -- P.marg_comment >> IsarThy.terminal_proof);
wenzelm@6404
   409
wenzelm@8966
   410
val default_proofP =
wenzelm@8966
   411
  OuterSyntax.command ".." "default proof" K.qed
wenzelm@8966
   412
    (P.marg_comment >> IsarThy.default_proof);
wenzelm@8966
   413
wenzelm@6404
   414
val immediate_proofP =
wenzelm@6723
   415
  OuterSyntax.command "." "immediate proof" K.qed
wenzelm@7002
   416
    (P.marg_comment >> IsarThy.immediate_proof);
wenzelm@6404
   417
wenzelm@8966
   418
val done_proofP =
wenzelm@8966
   419
  OuterSyntax.command "done" "done proof" K.qed
wenzelm@8966
   420
    (P.marg_comment >> IsarThy.done_proof);
wenzelm@5832
   421
wenzelm@6888
   422
val skip_proofP =
wenzelm@7172
   423
  OuterSyntax.improper_command "sorry" "skip proof (quick-and-dirty mode only!)" K.qed
wenzelm@7002
   424
    (P.marg_comment >> IsarThy.skip_proof);
wenzelm@6888
   425
wenzelm@8210
   426
val forget_proofP =
wenzelm@8521
   427
  OuterSyntax.command "oops" "forget proof" K.qed_global
wenzelm@8210
   428
    (P.marg_comment >> IsarThy.forget_proof);
wenzelm@8210
   429
wenzelm@8210
   430
wenzelm@5832
   431
wenzelm@5832
   432
(* proof steps *)
wenzelm@5832
   433
wenzelm@8165
   434
val deferP =
wenzelm@8681
   435
  OuterSyntax.command "defer" "shuffle internal proof state" K.prf_script
wenzelm@8681
   436
    (Scan.option P.nat -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.defer)));
wenzelm@8165
   437
wenzelm@8165
   438
val preferP =
wenzelm@8681
   439
  OuterSyntax.command "prefer" "shuffle internal proof state" K.prf_script
wenzelm@8681
   440
    (P.nat -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.prefer)));
wenzelm@8165
   441
wenzelm@6850
   442
val applyP =
wenzelm@8681
   443
  OuterSyntax.command "apply" "initial refinement step (unstructured)" K.prf_script
wenzelm@8681
   444
    (P.method -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply)));
wenzelm@5832
   445
wenzelm@8235
   446
val apply_endP =
wenzelm@8681
   447
  OuterSyntax.command "apply_end" "terminal refinement (unstructured)" K.prf_script
wenzelm@8681
   448
    (P.method -- P.marg_comment >> (Toplevel.print oo (Toplevel.proof o IsarThy.apply_end)));
wenzelm@5832
   449
wenzelm@6404
   450
val proofP =
wenzelm@6723
   451
  OuterSyntax.command "proof" "backward proof" K.prf_block
wenzelm@7002
   452
    (P.interest -- Scan.option (P.method -- P.interest) -- P.marg_comment
wenzelm@6727
   453
      >> (Toplevel.print oo (Toplevel.proof o IsarThy.proof)));
wenzelm@5832
   454
wenzelm@5832
   455
wenzelm@6773
   456
(* calculational proof commands *)
wenzelm@6773
   457
wenzelm@6878
   458
val calc_args =
wenzelm@6878
   459
  Scan.option (P.$$$ "(" |-- P.!!! ((P.xthms1 --| P.$$$ ")") -- P.interest));
wenzelm@6878
   460
wenzelm@6773
   461
val alsoP =
wenzelm@8562
   462
  OuterSyntax.command "also" "combine calculation and current facts" K.prf_decl
wenzelm@6878
   463
    (calc_args -- P.marg_comment >> IsarThy.also);
wenzelm@6773
   464
wenzelm@6773
   465
val finallyP =
wenzelm@8562
   466
  OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" K.prf_chain
wenzelm@6878
   467
    (calc_args -- P.marg_comment >> IsarThy.finally);
wenzelm@6773
   468
wenzelm@8562
   469
val moreoverP =
wenzelm@8562
   470
  OuterSyntax.command "moreover" "augment calculation by current facts" K.prf_decl
wenzelm@8562
   471
    (P.marg_comment >> IsarThy.moreover);
wenzelm@8562
   472
wenzelm@8588
   473
val ultimatelyP =
wenzelm@8588
   474
  OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result"
wenzelm@8588
   475
    K.prf_chain (P.marg_comment >> IsarThy.ultimately);
wenzelm@8588
   476
wenzelm@6773
   477
wenzelm@6742
   478
(* proof navigation *)
wenzelm@5944
   479
wenzelm@5832
   480
val backP =
wenzelm@8235
   481
  OuterSyntax.command "back" "backtracking of proof command" K.prf_script
wenzelm@9273
   482
    (Scan.optional (P.$$$ "!" >> K true) false -- P.marg_comment >>
wenzelm@9273
   483
      (Toplevel.print oo IsarCmd.back));
wenzelm@5832
   484
wenzelm@5832
   485
wenzelm@6742
   486
(* history *)
wenzelm@6742
   487
wenzelm@6742
   488
val cannot_undoP =
wenzelm@6742
   489
  OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control
wenzelm@9010
   490
    (P.name >> (Toplevel.no_timing oo IsarCmd.cannot_undo));
wenzelm@6742
   491
wenzelm@7733
   492
val clear_undosP =
wenzelm@7733
   493
  OuterSyntax.improper_command "clear_undos" "clear theory-level undo information" K.control
wenzelm@9010
   494
    (P.nat >> (Toplevel.no_timing oo IsarCmd.clear_undos_theory));
wenzelm@6742
   495
wenzelm@6742
   496
val redoP =
wenzelm@6742
   497
  OuterSyntax.improper_command "redo" "redo last command" K.control
wenzelm@9010
   498
    (Scan.succeed (Toplevel.no_timing o Toplevel.print o IsarCmd.redo));
wenzelm@6742
   499
wenzelm@6742
   500
val undos_proofP =
wenzelm@6742
   501
  OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control
wenzelm@9010
   502
    (P.nat >> ((Toplevel.no_timing o Toplevel.print) oo IsarCmd.undos_proof));
wenzelm@6742
   503
wenzelm@6742
   504
val undoP =
wenzelm@6742
   505
  OuterSyntax.improper_command "undo" "undo last command" K.control
wenzelm@9010
   506
    (Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.undo));
wenzelm@6742
   507
wenzelm@8500
   508
val killP =
wenzelm@8500
   509
  OuterSyntax.improper_command "kill" "kill current history node" K.control
wenzelm@9010
   510
    (Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.kill));
wenzelm@8500
   511
wenzelm@6742
   512
wenzelm@5832
   513
wenzelm@5832
   514
(** diagnostic commands (for interactive mode only) **)
wenzelm@5832
   515
wenzelm@8464
   516
val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) [];
wenzelm@8464
   517
wenzelm@8464
   518
wenzelm@7124
   519
val pretty_setmarginP =
wenzelm@7124
   520
  OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing"
wenzelm@9010
   521
    K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin));
wenzelm@7124
   522
wenzelm@5832
   523
val print_commandsP =
wenzelm@9221
   524
  OuterSyntax.improper_command "print_commands" "print outer syntax (global)" K.diag
wenzelm@9221
   525
    (Scan.succeed (Toplevel.no_timing o OuterSyntax.print_commands));
wenzelm@5832
   526
wenzelm@7308
   527
val print_contextP =
wenzelm@7308
   528
  OuterSyntax.improper_command "print_context" "print theory context name" K.diag
wenzelm@9010
   529
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_context));
wenzelm@7308
   530
wenzelm@5832
   531
val print_theoryP =
wenzelm@6723
   532
  OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag
wenzelm@9010
   533
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_theory));
wenzelm@5832
   534
wenzelm@5832
   535
val print_syntaxP =
wenzelm@6723
   536
  OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag
wenzelm@9010
   537
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax));
wenzelm@5832
   538
wenzelm@5881
   539
val print_theoremsP =
wenzelm@6723
   540
  OuterSyntax.improper_command "print_theorems" "print theorems known in this theory" K.diag
wenzelm@9010
   541
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems));
wenzelm@5881
   542
wenzelm@5832
   543
val print_attributesP =
wenzelm@6723
   544
  OuterSyntax.improper_command "print_attributes" "print attributes known in this theory" K.diag
wenzelm@9010
   545
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes));
wenzelm@5832
   546
wenzelm@11666
   547
val print_induct_rulesP =
wenzelm@11666
   548
  OuterSyntax.improper_command "print_induct_rules" "print induction and cases rules" K.diag
wenzelm@11666
   549
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_induct_rules));
wenzelm@11666
   550
wenzelm@9221
   551
val print_trans_rulesP =
wenzelm@11666
   552
  OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag
wenzelm@9221
   553
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules));
wenzelm@9221
   554
wenzelm@5832
   555
val print_methodsP =
wenzelm@6723
   556
  OuterSyntax.improper_command "print_methods" "print methods known in this theory" K.diag
wenzelm@9010
   557
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods));
wenzelm@5832
   558
wenzelm@9221
   559
val print_antiquotationsP =
wenzelm@9221
   560
  OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag
wenzelm@9221
   561
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations));
wenzelm@9221
   562
wenzelm@7616
   563
val thms_containingP =
wenzelm@11017
   564
  OuterSyntax.improper_command "thms_containing" "print theorems containing certain constants"
wenzelm@11017
   565
    K.diag (Scan.repeat P.term >> (Toplevel.no_timing oo IsarCmd.print_thms_containing));
wenzelm@7616
   566
wenzelm@9454
   567
val thm_depsP =
wenzelm@9454
   568
  OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies"
wenzelm@9454
   569
    K.diag (P.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps));
wenzelm@9454
   570
wenzelm@5832
   571
val print_bindsP =
wenzelm@6723
   572
  OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag
wenzelm@9010
   573
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds));
wenzelm@5832
   574
wenzelm@5832
   575
val print_lthmsP =
wenzelm@8370
   576
  OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag
wenzelm@9010
   577
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_lthms));
wenzelm@5832
   578
wenzelm@8370
   579
val print_casesP =
wenzelm@8370
   580
  OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag
wenzelm@9010
   581
    (Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases));
wenzelm@8370
   582
wenzelm@5896
   583
val print_thmsP =
wenzelm@8464
   584
  OuterSyntax.improper_command "thm" "print theorems" K.diag
wenzelm@10581
   585
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_thms));
wenzelm@5832
   586
berghofe@11524
   587
val print_prfsP =
berghofe@11524
   588
  OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag
berghofe@11524
   589
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prfs false));
berghofe@11524
   590
berghofe@11524
   591
val print_full_prfsP =
berghofe@11524
   592
  OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag
berghofe@11524
   593
    (opt_modes -- P.xthms1 -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prfs true));
berghofe@11524
   594
wenzelm@5832
   595
val print_propP =
wenzelm@6723
   596
  OuterSyntax.improper_command "prop" "read and print proposition" K.diag
wenzelm@10581
   597
    (opt_modes -- P.term -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_prop));
wenzelm@5832
   598
wenzelm@5832
   599
val print_termP =
wenzelm@6723
   600
  OuterSyntax.improper_command "term" "read and print term" K.diag
wenzelm@10581
   601
    (opt_modes -- P.term -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_term));
wenzelm@5832
   602
wenzelm@5832
   603
val print_typeP =
wenzelm@6723
   604
  OuterSyntax.improper_command "typ" "read and print type" K.diag
wenzelm@10581
   605
    (opt_modes -- P.typ -- P.marg_comment >> (Toplevel.no_timing oo IsarCmd.print_type));
wenzelm@5832
   606
wenzelm@5832
   607
wenzelm@5832
   608
wenzelm@5832
   609
(** system commands (for interactive mode only) **)
wenzelm@5832
   610
wenzelm@5832
   611
val cdP =
wenzelm@8650
   612
  OuterSyntax.improper_command "cd" "change current working directory" K.diag
wenzelm@9010
   613
    (P.name >> (Toplevel.no_timing oo IsarCmd.cd));
wenzelm@5832
   614
wenzelm@5832
   615
val pwdP =
wenzelm@6723
   616
  OuterSyntax.improper_command "pwd" "print current working directory" K.diag
wenzelm@9010
   617
    (Scan.succeed (Toplevel.no_timing o IsarCmd.pwd));
wenzelm@5832
   618
wenzelm@5832
   619
val use_thyP =
wenzelm@6723
   620
  OuterSyntax.improper_command "use_thy" "use theory file" K.diag
wenzelm@9010
   621
    (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy));
wenzelm@5832
   622
wenzelm@6694
   623
val use_thy_onlyP =
wenzelm@7102
   624
  OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML"
wenzelm@9010
   625
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy_only));
wenzelm@6694
   626
wenzelm@6196
   627
val update_thyP =
wenzelm@6723
   628
  OuterSyntax.improper_command "update_thy" "update theory file" K.diag
wenzelm@9010
   629
    (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy));
wenzelm@5832
   630
wenzelm@7102
   631
val update_thy_onlyP =
wenzelm@7102
   632
  OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML"
wenzelm@9010
   633
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy_only));
wenzelm@7102
   634
wenzelm@7102
   635
val touch_thyP =
wenzelm@7102
   636
  OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag
wenzelm@9010
   637
    (P.name >> (Toplevel.no_timing oo IsarCmd.touch_thy));
wenzelm@7102
   638
wenzelm@7102
   639
val touch_all_thysP =
wenzelm@7102
   640
  OuterSyntax.improper_command "touch_all_thys" "outdate all non-finished theories" K.diag
wenzelm@9010
   641
    (Scan.succeed (Toplevel.no_timing o IsarCmd.touch_all_thys));
wenzelm@7102
   642
wenzelm@7908
   643
val touch_child_thysP =
wenzelm@7908
   644
  OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag
wenzelm@9010
   645
    (P.name >> (Toplevel.no_timing oo IsarCmd.touch_child_thys));
wenzelm@7908
   646
wenzelm@7102
   647
val remove_thyP =
wenzelm@7102
   648
  OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag
wenzelm@9010
   649
    (P.name >> (Toplevel.no_timing oo IsarCmd.remove_thy));
wenzelm@7102
   650
wenzelm@7931
   651
val kill_thyP =
wenzelm@7931
   652
  OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database"
wenzelm@9010
   653
    K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.kill_thy));
wenzelm@7931
   654
wenzelm@9731
   655
val opt_limits =
wenzelm@9731
   656
  Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat);
wenzelm@9731
   657
wenzelm@5832
   658
val prP =
wenzelm@8886
   659
  OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag
wenzelm@9731
   660
    (opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr));
wenzelm@7199
   661
wenzelm@7222
   662
val disable_prP =
wenzelm@7222
   663
  OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag
wenzelm@9010
   664
    (Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr));
wenzelm@5832
   665
wenzelm@7222
   666
val enable_prP =
wenzelm@7222
   667
  OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag
wenzelm@9010
   668
    (Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr));
wenzelm@7222
   669
wenzelm@5832
   670
val commitP =
wenzelm@6723
   671
  OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag
wenzelm@9010
   672
    (P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.use_commit));
wenzelm@5832
   673
wenzelm@5832
   674
val quitP =
wenzelm@6723
   675
  OuterSyntax.improper_command "quit" "quit Isabelle" K.control
wenzelm@9010
   676
    (P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit));
wenzelm@5832
   677
wenzelm@5832
   678
val exitP =
wenzelm@6723
   679
  OuterSyntax.improper_command "exit" "exit Isar loop" K.control
wenzelm@9010
   680
    (Scan.succeed (Toplevel.no_timing o IsarCmd.exit));
wenzelm@5832
   681
wenzelm@7102
   682
val init_toplevelP =
wenzelm@7102
   683
  OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control
wenzelm@9010
   684
    (Scan.succeed (Toplevel.no_timing o IsarCmd.init_toplevel));
wenzelm@5991
   685
wenzelm@7462
   686
val welcomeP =
wenzelm@8678
   687
  OuterSyntax.improper_command "welcome" "print welcome message" K.diag
wenzelm@9010
   688
    (Scan.succeed (Toplevel.no_timing o IsarCmd.welcome));
wenzelm@7462
   689
wenzelm@5832
   690
wenzelm@5832
   691
wenzelm@5832
   692
(** the Pure outer syntax **)
wenzelm@5832
   693
wenzelm@5832
   694
(*keep keywords consistent with the parsers, including those in
wenzelm@5832
   695
  outer_parse.ML, otherwise be prepared for unexpected errors*)
wenzelm@5832
   696
wenzelm@5832
   697
val keywords =
wenzelm@7415
   698
 ["!", "!!", "%", "%%", "(", ")", "+", ",", "--", ":", "::", ";", "<",
wenzelm@8669
   699
  "<=", "=", "==", "=>", "?", "[", "]", "and", "binder", "concl",
wenzelm@11651
   700
  "files", "in", "infix", "infixl", "infixr", "is", "output", "overloaded",
wenzelm@11890
   701
  "where", "|", "\\<equiv>", "\\<rightharpoonup>", "\\<leftharpoondown>",
wenzelm@11101
   702
  "\\<rightleftharpoons>", "\\<subseteq>"];
wenzelm@5832
   703
wenzelm@5832
   704
val parsers = [
wenzelm@5832
   705
  (*theory structure*)
wenzelm@8500
   706
  theoryP, end_excursionP, contextP,
wenzelm@7775
   707
  (*markup commands*)
wenzelm@7733
   708
  headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP,
wenzelm@7862
   709
  text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP,
wenzelm@5832
   710
  (*theory sections*)
wenzelm@7172
   711
  classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP,
wenzelm@8227
   712
  aritiesP, judgmentP, constsP, syntaxP, translationsP, axiomsP,
wenzelm@9589
   713
  defsP, constdefsP, theoremsP, lemmasP, declareP, globalP, localP,
wenzelm@9589
   714
  hideP, useP, mlP, ml_commandP, ml_setupP, setupP, method_setupP,
wenzelm@9197
   715
  parse_ast_translationP, parse_translationP, print_translationP,
wenzelm@9197
   716
  typed_print_translationP, print_ast_translationP,
wenzelm@9197
   717
  token_translationP, oracleP,
wenzelm@5832
   718
  (*proof commands*)
wenzelm@11890
   719
  theoremP, lemmaP, corollaryP, showP, haveP, thusP, henceP, fixP,
wenzelm@11890
   720
  assumeP, presumeP, defP, obtainP, letP, caseP, thenP, fromP, withP,
wenzelm@11890
   721
  noteP, beginP, endP, nextP, qedP, terminal_proofP, default_proofP,
wenzelm@11742
   722
  immediate_proofP, done_proofP, skip_proofP, forget_proofP, deferP,
wenzelm@11742
   723
  preferP, applyP, apply_endP, proofP, alsoP, finallyP, moreoverP,
wenzelm@11742
   724
  ultimatelyP, backP, cannot_undoP, clear_undosP, redoP, undos_proofP,
wenzelm@11742
   725
  undoP, killP,
wenzelm@5832
   726
  (*diagnostic commands*)
wenzelm@7308
   727
  pretty_setmarginP, print_commandsP, print_contextP, print_theoryP,
wenzelm@9221
   728
  print_syntaxP, print_theoremsP, print_attributesP,
wenzelm@11666
   729
  print_induct_rulesP, print_trans_rulesP, print_methodsP,
wenzelm@11666
   730
  print_antiquotationsP, thms_containingP, thm_depsP, print_bindsP,
wenzelm@11666
   731
  print_lthmsP, print_casesP, print_thmsP, print_prfsP,
wenzelm@11666
   732
  print_full_prfsP, print_propP, print_termP, print_typeP,
wenzelm@5832
   733
  (*system commands*)
wenzelm@7102
   734
  cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP,
wenzelm@7931
   735
  touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP,
wenzelm@7931
   736
  kill_thyP, prP, disable_prP, enable_prP, commitP, quitP, exitP,
wenzelm@7931
   737
  init_toplevelP, welcomeP];
wenzelm@5832
   738
wenzelm@5832
   739
wenzelm@5832
   740
end;
wenzelm@5832
   741
wenzelm@5832
   742
wenzelm@6196
   743
(*install the Pure outer syntax*)
wenzelm@5832
   744
OuterSyntax.add_keywords IsarSyn.keywords;
wenzelm@5832
   745
OuterSyntax.add_parsers IsarSyn.parsers;