src/Pure/Isar/isar_syn.ML
author wenzelm
Fri, 19 Mar 1999 11:24:00 +0100
changeset 6404 2daaf2943c79
parent 6370 e71ac23a9111
child 6501 392333eb31cb
permissions -rw-r--r--
common qed and end of proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/isar_syn.ML
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     4
6353
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
     5
Isar/Pure outer syntax.
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     6
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     7
TODO:
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
     8
  - '--' (comment) option almost everywhere:
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
     9
  - add_parsers: warn if command name coincides with other keyword (if
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    10
    not already present) (!?);
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    11
  - 'result' (interactive): print current result (?);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    12
  - check evaluation of transformers (exns!);
6353
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
    13
  - 'thms': xthms1 (vs. 'thm' (!?));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    14
*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    15
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    16
signature ISAR_SYN =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    17
sig
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    18
  val keywords: string list
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    19
  val parsers: OuterSyntax.parser list
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    20
end;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    21
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    22
structure IsarSyn: ISAR_SYN =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    23
struct
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    24
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    25
open OuterParse;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    26
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    27
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    28
(** init and exit **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    29
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    30
val theoryP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    31
  OuterSyntax.command "theory" "begin theory"
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    32
    (OuterSyntax.theory_header >> (Toplevel.print oo IsarThy.theory));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    33
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    34
(*end current theory / sub-proof / excursion*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    35
val endP =
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
    36
  OuterSyntax.command "end" "end current block / theory / excursion"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    37
    (Scan.succeed (Toplevel.print o Toplevel.exit o Toplevel.proof IsarThy.end_block));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    38
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    39
val contextP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    40
  OuterSyntax.improper_command "context" "switch theory context"
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    41
    (name >> (Toplevel.print oo IsarThy.context));
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    42
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    43
val update_contextP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    44
  OuterSyntax.improper_command "update_context" "switch theory context, forcing update"
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    45
    (name >> (Toplevel.print oo IsarThy.update_context));
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
    46
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    47
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    48
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    49
(** theory sections **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    50
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    51
(* formal comments *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    52
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    53
val textP = OuterSyntax.command "text" "formal comments"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    54
  (text >> (Toplevel.theory o IsarThy.add_text));
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    55
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    56
val titleP = OuterSyntax.command "title" "document title"
6353
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
    57
  ((text -- Scan.optional text "" -- Scan.optional text "")
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
    58
    >> (fn ((x, y), z) => Toplevel.theory (IsarThy.add_title x y z)));
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
    59
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    60
val chapterP = OuterSyntax.command "chapter" "chapter heading"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    61
  (text >> (Toplevel.theory o IsarThy.add_chapter));
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    62
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    63
val sectionP = OuterSyntax.command "section" "section heading"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    64
  (text >> (Toplevel.theory o IsarThy.add_section));
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    65
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    66
val subsectionP = OuterSyntax.command "subsection" "subsection heading"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    67
  (text >> (Toplevel.theory o IsarThy.add_subsection));
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    68
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    69
val subsubsectionP = OuterSyntax.command "subsubsection" "subsubsection heading"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    70
  (text >> (Toplevel.theory o IsarThy.add_subsubsection));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    71
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    72
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    73
(* classes and sorts *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    74
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    75
val classesP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    76
  OuterSyntax.command "classes" "declare type classes"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    77
    (Scan.repeat1 (name -- Scan.optional ($$$ "<" |-- !!! (list1 xname)) [])
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    78
      >> (Toplevel.theory o Theory.add_classes));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    79
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    80
val classrelP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    81
  OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    82
    (xname -- ($$$ "<" |-- !!! xname) >> (Toplevel.theory o Theory.add_classrel o single));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    83
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    84
val defaultsortP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    85
  OuterSyntax.command "defaultsort" "declare default sort"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    86
    (sort >> (Toplevel.theory o Theory.add_defsort));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    87
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    88
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    89
(* types *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    90
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    91
val typedeclP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    92
  OuterSyntax.command "typedecl" "Pure type declaration"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    93
    (type_args -- name -- opt_infix
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    94
      >> (fn ((args, a), mx) => Toplevel.theory (PureThy.add_typedecls [(a, args, mx)])));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    95
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    96
val typeabbrP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
    97
  OuterSyntax.command "types" "declare type abbreviations"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    98
    (Scan.repeat1 (type_args -- name -- ($$$ "=" |-- !!! (typ -- opt_infix)))
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    99
      >> (Toplevel.theory o Theory.add_tyabbrs o
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   100
        map (fn ((args, a), (T, mx)) => (a, args, T, mx))));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   101
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   102
val nontermP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   103
  OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   104
    (Scan.repeat1 name >> (Toplevel.theory o Theory.add_nonterminals));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   105
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   106
val aritiesP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   107
  OuterSyntax.command "arities" "state type arities (axiomatic!)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   108
    (Scan.repeat1 (xname -- ($$$ "::" |-- !!! arity) >> triple2)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   109
      >> (Toplevel.theory o Theory.add_arities));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   110
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   111
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   112
(* consts and syntax *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   113
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   114
val constsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   115
  OuterSyntax.command "consts" "declare constants"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   116
    (Scan.repeat1 const >> (Toplevel.theory o Theory.add_consts));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   117
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   118
val opt_mode =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   119
  Scan.optional
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   120
    ($$$ "(" |-- !!! (name -- Scan.optional ($$$ "output" >> K false) true --| $$$ ")"))
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   121
    ("", true);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   122
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   123
val syntaxP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   124
  OuterSyntax.command "syntax" "declare syntactic constants"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   125
    (opt_mode -- Scan.repeat1 const >> (Toplevel.theory o uncurry Theory.add_modesyntax));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   126
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   127
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   128
(* translations *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   129
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   130
val trans_pat =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   131
  Scan.optional ($$$ "(" |-- !!! (xname --| $$$ ")")) "logic" -- string;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   132
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   133
fun trans_arrow toks =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   134
  ($$$ "=>" >> K Syntax.ParseRule ||
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   135
    $$$ "<=" >> K Syntax.PrintRule ||
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   136
    $$$ "==" >> K Syntax.ParsePrintRule) toks;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   137
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   138
val trans_line =
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   139
  trans_pat -- !!! (trans_arrow -- trans_pat)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   140
    >> (fn (left, (arr, right)) => arr (left, right));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   141
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   142
val translationsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   143
  OuterSyntax.command "translations" "declare syntax translation rules"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   144
    (Scan.repeat1 trans_line >> (Toplevel.theory o Theory.add_trrules));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   145
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   146
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   147
(* axioms and definitions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   148
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   149
val axiomsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   150
  OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)"
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   151
    (Scan.repeat1 spec_name >> (Toplevel.theory o IsarThy.add_axioms));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   152
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   153
val defsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   154
  OuterSyntax.command "defs" "define constants"
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   155
    (Scan.repeat1 spec_opt_name >> (Toplevel.theory o IsarThy.add_defs));
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   156
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   157
val constdefsP =
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   158
  OuterSyntax.command "constdefs" "declare and define constants"
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   159
    (Scan.repeat1 (const -- term) >> (Toplevel.theory o IsarThy.add_constdefs));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   160
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   161
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   162
(* theorems *)
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   163
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   164
val facts = opt_thm_name "=" -- xthms1;
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   165
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   166
val theoremsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   167
  OuterSyntax.command "theorems" "define theorems"
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   168
    (facts >> (Toplevel.theory o IsarThy.have_theorems));
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   169
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   170
val lemmasP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   171
  OuterSyntax.command "lemmas" "define lemmas"
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   172
    (facts >> (Toplevel.theory o IsarThy.have_lemmas));
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   173
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   174
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   175
(* name space entry path *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   176
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   177
val globalP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   178
  OuterSyntax.command "global" "disable prefixing of theory name"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   179
    (Scan.succeed (Toplevel.theory PureThy.global_path));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   180
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   181
val localP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   182
  OuterSyntax.command "local" "enable prefixing of theory name"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   183
    (Scan.succeed (Toplevel.theory PureThy.local_path));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   184
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   185
val pathP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   186
  OuterSyntax.command "path" "modify name-space entry path"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   187
    (xname >> (Toplevel.theory o Theory.add_path));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   188
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   189
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   190
(* use ML text *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   191
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   192
val useP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   193
  OuterSyntax.command "use" "eval ML text from file"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
   194
    (name >> IsarCmd.use);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   195
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   196
val mlP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   197
  OuterSyntax.command "ML" "eval ML text"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   198
    (text >> (fn txt => IsarCmd.use_mltext txt o IsarCmd.use_mltext_theory txt));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   199
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   200
val setupP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   201
  OuterSyntax.command "setup" "apply ML theory transformer"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   202
    (text >> (Toplevel.theory o IsarThy.use_setup));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   203
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   204
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   205
(* translation functions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   206
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   207
val parse_ast_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   208
  OuterSyntax.command "parse_ast_translation" "install parse ast translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   209
    (text >> (Toplevel.theory o IsarThy.parse_ast_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   210
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   211
val parse_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   212
  OuterSyntax.command "parse_translation" "install parse translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   213
    (text >> (Toplevel.theory o IsarThy.parse_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   214
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   215
val print_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   216
  OuterSyntax.command "print_translation" "install print translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   217
    (text >> (Toplevel.theory o IsarThy.print_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   218
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   219
val typed_print_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   220
  OuterSyntax.command "typed_print_translation" "install typed print translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   221
    (text >> (Toplevel.theory o IsarThy.typed_print_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   222
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   223
val print_ast_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   224
  OuterSyntax.command "print_ast_translation" "install print ast translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   225
    (text >> (Toplevel.theory o IsarThy.print_ast_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   226
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   227
val token_translationP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   228
  OuterSyntax.command "token_translation" "install token translation functions"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   229
    (text >> (Toplevel.theory o IsarThy.token_translation));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   230
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   231
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   232
(* oracles *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   233
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   234
val oracleP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   235
  OuterSyntax.command "oracle" "install oracle"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   236
    (name -- text >> (Toplevel.theory o IsarThy.add_oracle));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   237
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   238
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   239
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   240
(** proof commands **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   241
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   242
(* statements *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   243
5937
a777d702e81f let: 'as' patterns;
wenzelm
parents: 5924
diff changeset
   244
val is_props = $$$ "(" |-- !!! (Scan.repeat1 ($$$ "is" |-- prop) --| $$$ ")");
a777d702e81f let: 'as' patterns;
wenzelm
parents: 5924
diff changeset
   245
val propp = prop -- Scan.optional is_props [];
a777d702e81f let: 'as' patterns;
wenzelm
parents: 5924
diff changeset
   246
fun statement f = opt_thm_name ":" -- propp >> (fn ((x, y), z) => f x y z);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   247
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   248
val theoremP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   249
  OuterSyntax.command "theorem" "state theorem"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   250
    (statement IsarThy.theorem >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   251
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   252
val lemmaP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   253
  OuterSyntax.command "lemma" "state lemma"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   254
    (statement IsarThy.lemma >> (fn f => Toplevel.print o Toplevel.theory_to_proof f));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   255
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   256
val showP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   257
  OuterSyntax.command "show" "state local goal, solving current obligation"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   258
    (statement IsarThy.show >> (fn f => Toplevel.print o Toplevel.proof f));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   259
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   260
val haveP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   261
  OuterSyntax.command "have" "state local goal"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   262
    (statement IsarThy.have >> (fn f => Toplevel.print o Toplevel.proof f));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   263
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   264
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   265
(* facts *)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   266
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   267
val thenP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   268
  OuterSyntax.command "then" "forward chaining"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   269
    (Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.chain));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   270
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   271
val fromP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   272
  OuterSyntax.command "from" "forward chaining from given facts"
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   273
    (xthms1 >> (fn x => Toplevel.print o Toplevel.proof (IsarThy.from_facts x)));
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   274
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   275
val factsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   276
  OuterSyntax.command "note" "define facts"
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   277
    (facts >> (Toplevel.proof o IsarThy.have_facts));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   278
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   279
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   280
(* proof context *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   281
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   282
val assumeP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   283
  OuterSyntax.command "assume" "assume propositions"
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   284
    (opt_thm_name ":" -- Scan.repeat1 propp >>
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   285
      (fn ((x, y), z) => Toplevel.print o Toplevel.proof (IsarThy.assume x y z)));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   286
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   287
val fixP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   288
  OuterSyntax.command "fix" "fix variables (Skolem constants)"
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   289
    (Scan.repeat1 (name -- Scan.option ($$$ "::" |-- typ))
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   290
      >> (fn xs => Toplevel.print o Toplevel.proof (IsarThy.fix xs)));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   291
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   292
val letP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   293
  OuterSyntax.command "let" "bind text variables"
6013
6da9ae6d40f5 and_list;
wenzelm
parents: 5991
diff changeset
   294
    (and_list1 (enum1 "as" term -- ($$$ "=" |-- term))
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   295
      >> (fn bs => Toplevel.print o Toplevel.proof (IsarThy.match_bind bs)));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   296
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   297
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   298
(* proof structure *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   299
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   300
val beginP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   301
  OuterSyntax.command "begin" "begin block"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   302
    (Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.begin_block));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   303
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   304
val nextP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   305
  OuterSyntax.command "next" "enter next block"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   306
    (Scan.succeed (Toplevel.print o Toplevel.proof IsarThy.next_block));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   307
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   308
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   309
(* end proof *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   310
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   311
val kill_proofP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   312
  OuterSyntax.improper_command "kill" "abort current proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   313
    (Scan.succeed (Toplevel.print o Toplevel.proof_to_theory IsarThy.kill_proof));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   314
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   315
val qed_withP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   316
  OuterSyntax.improper_command "qed_with" "conclude proof, may patch name and attributes"
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   317
    (Scan.option name -- Scan.option attribs -- Scan.option method
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   318
      >> (uncurry IsarThy.global_qed_with));
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   319
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   320
val qedP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   321
  OuterSyntax.command "qed" "conclude (sub-)proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   322
    (Scan.option method >> IsarThy.qed);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   323
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   324
val terminal_proofP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   325
  OuterSyntax.command "by" "terminal backward proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   326
    (method >> (Toplevel.print oo IsarThy.terminal_proof));
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   327
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   328
val immediate_proofP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   329
  OuterSyntax.command "." "immediate proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   330
    (Scan.succeed (Toplevel.print o IsarThy.immediate_proof));
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   331
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   332
val default_proofP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   333
  OuterSyntax.command ".." "default proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   334
    (Scan.succeed (Toplevel.print o IsarThy.default_proof));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   335
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   336
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   337
(* proof steps *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   338
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   339
val refineP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   340
  OuterSyntax.improper_command "refine" "unstructured backward proof step, ignoring facts"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   341
    (method >> (Toplevel.print oo (Toplevel.proof o IsarThy.tac)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   342
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   343
val then_refineP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   344
  OuterSyntax.improper_command "then_refine" "unstructured backward proof step, using facts"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   345
    (method >> (Toplevel.print oo (Toplevel.proof o IsarThy.then_tac)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   346
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   347
val proofP =
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   348
  OuterSyntax.command "proof" "backward proof"
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   349
    (Scan.option method >> (Toplevel.print oo (Toplevel.proof o IsarThy.proof)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   350
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   351
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   352
(* proof history *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   353
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   354
val clear_undoP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   355
  OuterSyntax.improper_command "clear_undo" "clear proof command undo information"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   356
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.clear));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   357
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   358
val undoP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   359
  OuterSyntax.improper_command "undo" "undo proof command"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   360
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.undo));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   361
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   362
val redoP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   363
  OuterSyntax.improper_command "redo" "redo proof command"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   364
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.redo));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   365
5944
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   366
val undosP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   367
  OuterSyntax.improper_command "undos" "undo proof commands"
5944
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   368
    (nat >> (fn n => Toplevel.print o Toplevel.proof (ProofHistory.undos n)));
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   369
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   370
val redosP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   371
  OuterSyntax.improper_command "redos" "redo proof commands"
5944
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   372
    (nat >> (fn n => Toplevel.print o Toplevel.proof (ProofHistory.redos n)));
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   373
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   374
val backP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   375
  OuterSyntax.improper_command "back" "backtracking of proof command"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   376
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.back));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   377
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   378
val prevP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   379
  OuterSyntax.improper_command "prev" "previous proof state"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   380
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.prev));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   381
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   382
val upP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   383
  OuterSyntax.improper_command "up" "upper proof state"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   384
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.up));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   385
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   386
val topP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   387
  OuterSyntax.improper_command "top" "to initial proof state"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   388
    (Scan.succeed (Toplevel.print o Toplevel.proof ProofHistory.top));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   389
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   390
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   391
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   392
(** diagnostic commands (for interactive mode only) **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   393
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   394
val print_commandsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   395
  OuterSyntax.improper_command "help" "print outer syntax (global)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   396
    (Scan.succeed (Toplevel.imperative OuterSyntax.print_outer_syntax));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   397
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   398
val print_theoryP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   399
  OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   400
    (Scan.succeed IsarCmd.print_theory);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   401
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   402
val print_syntaxP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   403
  OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   404
    (Scan.succeed IsarCmd.print_syntax);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   405
5881
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   406
val print_theoremsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   407
  OuterSyntax.improper_command "print_theorems" "print theorems known in this theory"
5881
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   408
    (Scan.succeed IsarCmd.print_theorems);
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   409
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   410
val print_attributesP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   411
  OuterSyntax.improper_command "print_attributes" "print attributes known in this theory"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   412
    (Scan.succeed IsarCmd.print_attributes);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   413
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   414
val print_methodsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   415
  OuterSyntax.improper_command "print_methods" "print methods known in this theory"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   416
    (Scan.succeed IsarCmd.print_methods);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   417
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   418
val print_bindsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   419
  OuterSyntax.improper_command "print_binds" "print term bindings of proof context"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   420
    (Scan.succeed IsarCmd.print_binds);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   421
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   422
val print_lthmsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   423
  OuterSyntax.improper_command "print_facts" "print local theorems of proof context"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   424
    (Scan.succeed IsarCmd.print_lthms);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   425
5896
4a75d89e2818 thm, thms;
wenzelm
parents: 5881
diff changeset
   426
val print_thmsP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   427
  OuterSyntax.improper_command "thm" "print theorems" (xthm >> IsarCmd.print_thms);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   428
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   429
val print_propP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   430
  OuterSyntax.improper_command "prop" "read and print proposition"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   431
    (term >> IsarCmd.print_prop);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   432
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   433
val print_termP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   434
  OuterSyntax.improper_command "term" "read and print term"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   435
    (term >> IsarCmd.print_term);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   436
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   437
val print_typeP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   438
  OuterSyntax.improper_command "type" "read and print type"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   439
    (typ >> IsarCmd.print_type);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   440
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   441
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   442
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   443
(** system commands (for interactive mode only) **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   444
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   445
val cdP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   446
  OuterSyntax.improper_command "cd" "change current working directory"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
   447
    (name >> IsarCmd.cd);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   448
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   449
val pwdP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   450
  OuterSyntax.improper_command "pwd" "print current working directory"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   451
    (Scan.succeed IsarCmd.pwd);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   452
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   453
val use_thyP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   454
  OuterSyntax.improper_command "use_thy" "use theory file"
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
   455
    (name >> IsarCmd.use_thy);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   456
6196
f9fdb4e29790 removed load;
wenzelm
parents: 6108
diff changeset
   457
val update_thyP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   458
  OuterSyntax.improper_command "update_thy" "update theory file"
6197
4328d436c556 oops, update_thy;
wenzelm
parents: 6196
diff changeset
   459
    (name >> IsarCmd.update_thy);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   460
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   461
val prP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   462
  OuterSyntax.improper_command "pr" "print current toplevel state"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   463
    (Scan.succeed (Toplevel.print o Toplevel.imperative (K ())));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   464
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   465
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   466
val opt_unit = Scan.optional ($$$ "(" -- $$$ ")" >> (K ())) ();
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   467
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   468
val commitP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   469
  OuterSyntax.improper_command "commit" "commit current session to ML database"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   470
    (opt_unit >> (K IsarCmd.use_commit));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   471
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   472
val quitP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   473
  OuterSyntax.improper_command "quit" "quit Isabelle"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   474
    (opt_unit >> (K IsarCmd.quit));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   475
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   476
val exitP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   477
  OuterSyntax.improper_command "exit" "exit Isar loop"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   478
    (Scan.succeed IsarCmd.exit);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   479
5991
832ec852fc4e added restart;
wenzelm
parents: 5958
diff changeset
   480
val restartP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   481
  OuterSyntax.improper_command "restart" "restart Isar loop"
5991
832ec852fc4e added restart;
wenzelm
parents: 5958
diff changeset
   482
    (Scan.succeed IsarCmd.restart);
832ec852fc4e added restart;
wenzelm
parents: 5958
diff changeset
   483
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   484
val breakP =
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   485
  OuterSyntax.improper_command "break" "discontinue excursion (keep current state)"
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   486
    (Scan.succeed IsarCmd.break);
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   487
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   488
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   489
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   490
(** the Pure outer syntax **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   491
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   492
(*keep keywords consistent with the parsers, including those in
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   493
  outer_parse.ML, otherwise be prepared for unexpected errors*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   494
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   495
val keywords =
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
   496
 ["(", ")", "*", "+", "--", ",", ":", "::", ";", "<", "<=", "=", "==", "=>",
6265
aaabe48bafcb "files" keyword!
wenzelm
parents: 6245
diff changeset
   497
  "?", "[", "]", "and", "as", "binder", "files", "infixl", "infixr", "is",
6013
6da9ae6d40f5 and_list;
wenzelm
parents: 5991
diff changeset
   498
  "output", "{", "|", "}"];
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   499
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   500
val parsers = [
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   501
  (*theory structure*)
6245
ebce4ebba491 improved 'theory';
wenzelm
parents: 6197
diff changeset
   502
  theoryP, endP, contextP, update_contextP,
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   503
  (*theory sections*)
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   504
  textP, titleP, chapterP, sectionP, subsectionP, subsubsectionP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   505
  classesP, classrelP, defaultsortP, typedeclP, typeabbrP, nontermP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   506
  aritiesP, constsP, syntaxP, translationsP, axiomsP, defsP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   507
  constdefsP, theoremsP, lemmasP, globalP, localP, pathP, useP, mlP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   508
  setupP, parse_ast_translationP, parse_translationP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   509
  print_translationP, typed_print_translationP,
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   510
  print_ast_translationP, token_translationP, oracleP,
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   511
  (*proof commands*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   512
  theoremP, lemmaP, showP, haveP, assumeP, fixP, letP, thenP, fromP,
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   513
  factsP, beginP, nextP, kill_proofP, qed_withP, qedP,
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   514
  terminal_proofP, immediate_proofP, default_proofP, refineP,
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   515
  then_refineP, proofP, clear_undoP, undoP, redoP, undosP, redosP,
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   516
  backP, prevP, upP, topP,
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   517
  (*diagnostic commands*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   518
  print_commandsP, print_theoryP, print_syntaxP, print_attributesP,
5881
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   519
  print_methodsP, print_theoremsP, print_bindsP, print_lthmsP,
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   520
  print_thmsP, print_propP, print_termP, print_typeP,
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   521
  (*system commands*)
6196
f9fdb4e29790 removed load;
wenzelm
parents: 6108
diff changeset
   522
  cdP, pwdP, use_thyP, update_thyP, prP, commitP, quitP, exitP,
f9fdb4e29790 removed load;
wenzelm
parents: 6108
diff changeset
   523
  restartP, breakP];
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   524
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   525
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   526
end;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   527
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   528
6196
f9fdb4e29790 removed load;
wenzelm
parents: 6108
diff changeset
   529
(*install the Pure outer syntax*)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   530
OuterSyntax.add_keywords IsarSyn.keywords;
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   531
OuterSyntax.add_parsers IsarSyn.parsers;