src/Pure/Isar/isar_syn.ML
author wenzelm
Fri, 29 Mar 2013 22:14:27 +0100
changeset 51580 64ef8260dc60
parent 51313 102a0a0718c5
child 51585 fcd5af4aac2b
permissions -rw-r--r--
Pretty.item markup for improved readability of lists of items;
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
    Author:     Markus Wenzel, TU Muenchen
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     3
6353
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
     4
Isar/Pure outer syntax.
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     5
*)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     6
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
     7
structure Isar_Syn: sig end =
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     8
struct
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     9
7749
dfb8beddbefe OuterSyntax.markup_command;
wenzelm
parents: 7733
diff changeset
    10
(** markup commands **)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    11
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    12
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    13
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    14
    @{command_spec "header"} "theory header"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    15
    (Parse.doc_source >> Isar_Cmd.header_markup);
6353
5a76eb9030df added 'title';
wenzelm
parents: 6265
diff changeset
    16
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    17
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    18
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    19
    @{command_spec "chapter"} "chapter heading"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    20
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    21
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    22
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    23
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    24
    @{command_spec "section"} "section heading"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    25
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    26
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    27
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    28
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    29
    @{command_spec "subsection"} "subsection heading"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    30
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    31
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    32
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    33
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    34
    @{command_spec "subsubsection"} "subsubsection heading"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    35
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
5958
c48efb523a4d chapter etc. headings;
wenzelm
parents: 5944
diff changeset
    36
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    37
val _ =
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    38
  Outer_Syntax.markup_command Thy_Output.MarkupEnv
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    39
    @{command_spec "text"} "formal comment (theory)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    40
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
7172
wenzelm
parents: 7140
diff changeset
    41
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    42
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    43
  Outer_Syntax.markup_command Thy_Output.Verbatim
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    44
    @{command_spec "text_raw"} "raw document preparation text"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    45
    (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup);
7172
wenzelm
parents: 7140
diff changeset
    46
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    47
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    48
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    49
    @{command_spec "sect"} "formal comment (proof)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    50
    (Parse.doc_source >> Isar_Cmd.proof_markup);
7172
wenzelm
parents: 7140
diff changeset
    51
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    52
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    53
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    54
    @{command_spec "subsect"} "formal comment (proof)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    55
    (Parse.doc_source >> Isar_Cmd.proof_markup);
7172
wenzelm
parents: 7140
diff changeset
    56
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    57
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    58
  Outer_Syntax.markup_command Thy_Output.Markup
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    59
    @{command_spec "subsubsect"} "formal comment (proof)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    60
    (Parse.doc_source >> Isar_Cmd.proof_markup);
7172
wenzelm
parents: 7140
diff changeset
    61
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    62
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    63
  Outer_Syntax.markup_command Thy_Output.MarkupEnv
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    64
    @{command_spec "txt"} "formal comment (proof)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    65
    (Parse.doc_source >> Isar_Cmd.proof_markup);
7172
wenzelm
parents: 7140
diff changeset
    66
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    67
val _ =
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    68
  Outer_Syntax.markup_command Thy_Output.Verbatim
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    69
    @{command_spec "txt_raw"} "raw document preparation text (proof)"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    70
    (Parse.doc_source >> Isar_Cmd.proof_markup);
7775
26898fbd19ca verbatim / verb markupup commands;
wenzelm
parents: 7749
diff changeset
    71
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    72
6886
7d0f7ad5a35f added 'txt';
wenzelm
parents: 6878
diff changeset
    73
30142
8d6145694bb5 moved find_theorems.ML and find_consts.ML to Pure/Tools, collecting main implementation in one place each;
wenzelm
parents: 29882
diff changeset
    74
(** theory commands **)
6886
7d0f7ad5a35f added 'txt';
wenzelm
parents: 6878
diff changeset
    75
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    76
(* classes and sorts *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    77
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    78
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    79
  Outer_Syntax.command @{command_spec "classes"} "declare type classes"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    80
    (Scan.repeat1 (Parse.binding -- Scan.optional ((@{keyword "\<subseteq>"} || @{keyword "<"}) |--
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
    81
        Parse.!!! (Parse.list1 Parse.class)) [])
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    82
      >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    83
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    84
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    85
  Outer_Syntax.command @{command_spec "classrel"} "state inclusion of type classes (axiomatic!)"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    86
    (Parse.and_list1 (Parse.class -- ((@{keyword "\<subseteq>"} || @{keyword "<"})
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
    87
        |-- Parse.!!! Parse.class))
24932
86ef9a828a9e AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents: 24914
diff changeset
    88
    >> (Toplevel.theory o AxClass.axiomatize_classrel_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    89
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    90
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    91
  Outer_Syntax.local_theory @{command_spec "default_sort"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    92
    "declare default sort for explicit type variables"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    93
    (Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    94
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    95
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    96
(* types *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    97
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    98
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
    99
  Outer_Syntax.local_theory @{command_spec "typedecl"} "type declaration"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   100
    (Parse.type_args -- Parse.binding -- Parse.opt_mixfix
35835
51c6ac100bd9 typedecl: no sort constraints;
wenzelm
parents: 35681
diff changeset
   101
      >> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   102
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   103
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   104
  Outer_Syntax.local_theory @{command_spec "type_synonym"} "declare type abbreviation"
45837
wenzelm
parents: 45600
diff changeset
   105
    (Parse.type_args -- Parse.binding --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   106
      (@{keyword "="} |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))
45837
wenzelm
parents: 45600
diff changeset
   107
      >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   108
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   109
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   110
  Outer_Syntax.command @{command_spec "nonterminal"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   111
    "declare syntactic type constructors (grammar nonterminal symbols)"
42375
774df7c59508 report Name_Space.declare/define, relatively to context;
wenzelm
parents: 42359
diff changeset
   112
    (Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   113
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   114
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   115
  Outer_Syntax.command @{command_spec "arities"} "state type arities (axiomatic!)"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   116
    (Scan.repeat1 Parse.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   117
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   118
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   119
(* consts and syntax *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   120
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   121
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   122
  Outer_Syntax.command @{command_spec "judgment"} "declare object-logic judgment"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   123
    (Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd));
8227
d67db92897df add_judgment;
wenzelm
parents: 8210
diff changeset
   124
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   125
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   126
  Outer_Syntax.command @{command_spec "consts"} "declare constants"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   127
    (Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   128
12142
c81ef8865cfb "theorem" etc.: multiple statements;
wenzelm
parents: 12125
diff changeset
   129
val mode_spec =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   130
  (@{keyword "output"} >> K ("", false)) ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   131
    Parse.name -- Scan.optional (@{keyword "output"} >> K false) true;
9731
3eb72671e5db pr: added prems limit;
wenzelm
parents: 9589
diff changeset
   132
14900
c66394c408f7 Syntax.default_mode;
wenzelm
parents: 14779
diff changeset
   133
val opt_mode =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   134
  Scan.optional (@{keyword "("} |-- Parse.!!! (mode_spec --| @{keyword ")"})) Syntax.mode_default;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   135
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   136
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   137
  Outer_Syntax.command @{command_spec "syntax"} "add raw syntax clauses"
42299
06e93f257d0e tuned signature;
wenzelm
parents: 42204
diff changeset
   138
    (opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   139
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   140
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   141
  Outer_Syntax.command @{command_spec "no_syntax"} "delete raw syntax clauses"
42299
06e93f257d0e tuned signature;
wenzelm
parents: 42204
diff changeset
   142
    (opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.del_modesyntax));
15748
e26fdd4aa95a added 'no_syntax' command;
wenzelm
parents: 15712
diff changeset
   143
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   144
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   145
(* translations *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   146
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   147
val trans_pat =
42326
e2d22eb4aeb9 some position reports for 'translations';
wenzelm
parents: 42300
diff changeset
   148
  Scan.optional
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   149
    (@{keyword "("} |-- Parse.!!! (Parse.xname --| @{keyword ")"})) "logic"
42326
e2d22eb4aeb9 some position reports for 'translations';
wenzelm
parents: 42300
diff changeset
   150
    -- Parse.inner_syntax Parse.string;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   151
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   152
fun trans_arrow toks =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   153
  ((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   154
    (@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   155
    (@{keyword "\<rightleftharpoons>"} || @{keyword "=="}) >> K Syntax.Parse_Print_Rule) toks;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   156
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   157
val trans_line =
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   158
  trans_pat -- Parse.!!! (trans_arrow -- trans_pat)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   159
    >> (fn (left, (arr, right)) => arr (left, right));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   160
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   161
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   162
  Outer_Syntax.command @{command_spec "translations"} "add syntax translation rules"
42204
b3277168c1e7 added Position.reports convenience;
wenzelm
parents: 41944
diff changeset
   163
    (Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   164
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   165
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   166
  Outer_Syntax.command @{command_spec "no_translations"} "delete syntax translation rules"
42204
b3277168c1e7 added Position.reports convenience;
wenzelm
parents: 41944
diff changeset
   167
    (Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations));
19260
a3d3a4b75c71 added 'no_translations';
wenzelm
parents: 19245
diff changeset
   168
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   169
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   170
(* axioms and definitions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   171
19631
4445b353f78b 'defs': unchecked flag;
wenzelm
parents: 19516
diff changeset
   172
val opt_unchecked_overloaded =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   173
  Scan.optional (@{keyword "("} |-- Parse.!!!
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   174
    (((@{keyword "unchecked"} >> K true) --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   175
        Scan.optional (@{keyword "overloaded"} >> K true) false ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   176
      @{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false);
19631
4445b353f78b 'defs': unchecked flag;
wenzelm
parents: 19516
diff changeset
   177
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   178
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   179
  Outer_Syntax.command @{command_spec "defs"} "define constants"
35852
4e3fe0b8687b minor renovation of old-style 'axioms' -- make it an alias of iterated 'axiomatization';
wenzelm
parents: 35835
diff changeset
   180
    (opt_unchecked_overloaded --
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   181
      Scan.repeat1 (Parse_Spec.thm_name ":" -- Parse.prop >> (fn ((x, y), z) => ((x, z), y)))
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   182
      >> (Toplevel.theory o Isar_Cmd.add_defs));
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   183
14642
2bfe5de2d1fa improved constdefs and translation functions;
wenzelm
parents: 14528
diff changeset
   184
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21527
diff changeset
   185
(* constant definitions and abbreviations *)
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21527
diff changeset
   186
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   187
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   188
  Outer_Syntax.local_theory' @{command_spec "definition"} "constant definition"
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 44187
diff changeset
   189
    (Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args));
18780
a9c38d41cd27 added 'definition';
wenzelm
parents: 18766
diff changeset
   190
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   191
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   192
  Outer_Syntax.local_theory' @{command_spec "abbreviation"} "constant abbreviation"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   193
    (opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   194
      >> (fn (mode, args) => Specification.abbreviation_cmd mode args));
19659
88d246e5f4bd added 'const_syntax';
wenzelm
parents: 19631
diff changeset
   195
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   196
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   197
  Outer_Syntax.local_theory @{command_spec "type_notation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   198
    "add concrete syntax for type constructors"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   199
    (opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   200
      >> (fn (mode, args) => Specification.type_notation_cmd true mode args));
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   201
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   202
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   203
  Outer_Syntax.local_theory @{command_spec "no_type_notation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   204
    "delete concrete syntax for type constructors"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   205
    (opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   206
      >> (fn (mode, args) => Specification.type_notation_cmd false mode args));
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   207
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   208
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   209
  Outer_Syntax.local_theory @{command_spec "notation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   210
    "add concrete syntax for constants / fixed variables"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   211
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   212
      >> (fn (mode, args) => Specification.notation_cmd true mode args));
24950
106fc30769a9 added 'no_notation';
wenzelm
parents: 24938
diff changeset
   213
106fc30769a9 added 'no_notation';
wenzelm
parents: 24938
diff changeset
   214
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   215
  Outer_Syntax.local_theory @{command_spec "no_notation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   216
    "delete concrete syntax for constants / fixed variables"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   217
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   218
      >> (fn (mode, args) => Specification.notation_cmd false mode args));
19076
e1948ebe9c7d added 'abbreviation';
wenzelm
parents: 18949
diff changeset
   219
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   220
18616
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   221
(* constant specifications *)
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   222
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   223
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   224
  Outer_Syntax.command @{command_spec "axiomatization"} "axiomatic constant specification"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   225
    (Scan.optional Parse.fixes [] --
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   226
      Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) []
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   227
      >> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y)));
18616
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   228
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   229
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   230
(* theorems *)
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   231
26988
742e26213212 more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents: 26888
diff changeset
   232
fun theorems kind =
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   233
  Parse_Spec.name_facts -- Parse.for_fixes
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   234
    >> (fn (facts, fixes) => #2 oo Specification.theorems_cmd kind facts fixes);
12712
a659fd913a89 localized 'lemmas', 'theorems', 'declare';
wenzelm
parents: 12696
diff changeset
   235
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   236
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   237
  Outer_Syntax.local_theory' @{command_spec "theorems"} "define theorems"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   238
    (theorems Thm.theoremK);
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   239
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   240
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   241
  Outer_Syntax.local_theory' @{command_spec "lemmas"} "define lemmas" (theorems Thm.lemmaK);
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   242
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   243
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   244
  Outer_Syntax.local_theory' @{command_spec "declare"} "declare theorems"
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   245
    (Parse.and_list1 Parse_Spec.xthms1 -- Parse.for_fixes
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   246
      >> (fn (facts, fixes) =>
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   247
          #2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes));
9589
95a66548c883 added "declare" command;
wenzelm
parents: 9552
diff changeset
   248
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   249
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   250
(* name space entry path *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   251
48645
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   252
fun hide_names spec hide what =
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   253
  Outer_Syntax.command spec ("hide " ^ what ^ " from name space")
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   254
    ((Parse.opt_keyword "open" >> not) -- Scan.repeat1 Parse.xname >>
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 36174
diff changeset
   255
      (Toplevel.theory o uncurry hide));
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 36174
diff changeset
   256
48645
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   257
val _ = hide_names @{command_spec "hide_class"} Isar_Cmd.hide_class "classes";
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   258
val _ = hide_names @{command_spec "hide_type"} Isar_Cmd.hide_type "types";
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   259
val _ = hide_names @{command_spec "hide_const"} Isar_Cmd.hide_const "constants";
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   260
val _ = hide_names @{command_spec "hide_fact"} Isar_Cmd.hide_fact "facts";
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   261
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   262
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   263
(* use ML text *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   264
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   265
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   266
  Outer_Syntax.command @{command_spec "ML"} "ML text within theory or local theory"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   267
    (Parse.ML_source >> (fn (txt, pos) =>
30579
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   268
      Toplevel.generic_theory
37949
48a874444164 moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents: 37873
diff changeset
   269
        (ML_Context.exec (fn () => ML_Context.eval_text true pos txt) #>
48a874444164 moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents: 37873
diff changeset
   270
          Local_Theory.propagate_ml_env)));
30579
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   271
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   272
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   273
  Outer_Syntax.command @{command_spec "ML_prf"} "ML text within proof"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   274
    (Parse.ML_source >> (fn (txt, pos) =>
28269
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   275
      Toplevel.proof (Proof.map_context (Context.proof_map
37949
48a874444164 moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents: 37873
diff changeset
   276
        (ML_Context.exec (fn () => ML_Context.eval_text true pos txt))) #> Proof.propagate_ml_env)));
28269
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   277
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   278
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   279
  Outer_Syntax.command @{command_spec "ML_val"} "diagnostic ML text"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   280
    (Parse.ML_source >> Isar_Cmd.ml_diag true);
26396
e44c5a1a47bd added 'ML_val' command (diagnostic);
wenzelm
parents: 26385
diff changeset
   281
e44c5a1a47bd added 'ML_val' command (diagnostic);
wenzelm
parents: 26385
diff changeset
   282
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   283
  Outer_Syntax.command @{command_spec "ML_command"} "diagnostic ML text (silent)"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   284
    (Parse.ML_source >> (Toplevel.no_timing oo Isar_Cmd.ml_diag false));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   285
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   286
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   287
  Outer_Syntax.command @{command_spec "setup"} "ML theory setup"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   288
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup));
30461
00323c45ea83 added 'local_setup' command;
wenzelm
parents: 30344
diff changeset
   289
00323c45ea83 added 'local_setup' command;
wenzelm
parents: 30344
diff changeset
   290
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   291
  Outer_Syntax.local_theory @{command_spec "local_setup"} "ML local theory setup"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   292
    (Parse.ML_source >> Isar_Cmd.local_setup);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   293
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   294
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   295
  Outer_Syntax.command @{command_spec "attribute_setup"} "define attribute in ML"
42813
6c841fa92fa2 optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents: 42496
diff changeset
   296
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   297
        Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   298
      >> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt)));
30526
7f9a9ec1c94d added 'attribute_setup' command;
wenzelm
parents: 30484
diff changeset
   299
7f9a9ec1c94d added 'attribute_setup' command;
wenzelm
parents: 30484
diff changeset
   300
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   301
  Outer_Syntax.command @{command_spec "method_setup"} "define proof method in ML"
42813
6c841fa92fa2 optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents: 42496
diff changeset
   302
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   303
        Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   304
      >> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt)));
9197
16d88c5547bd added method_setup;
wenzelm
parents: 9129
diff changeset
   305
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   306
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   307
  Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration"
40784
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   308
    (Parse.opt_keyword "pervasive" -- Parse.ML_source
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   309
      >> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt));
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   310
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   311
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   312
  Outer_Syntax.local_theory @{command_spec "syntax_declaration"} "generic ML syntax declaration"
40784
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   313
    (Parse.opt_keyword "pervasive" -- Parse.ML_source
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   314
      >> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt));
22088
4c53bb6e10e4 added 'declaration' command;
wenzelm
parents: 21956
diff changeset
   315
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   316
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   317
  Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML"
42464
ae16b8abf1a8 proper binding/report of defined simprocs;
wenzelm
parents: 42375
diff changeset
   318
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   319
      (@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   320
      Parse.ML_source -- Scan.optional (@{keyword "identifier"} |-- Scan.repeat1 Parse.xname) []
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   321
    >> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d));
22202
0544af1a5117 added simproc_setup;
wenzelm
parents: 22117
diff changeset
   322
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   323
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   324
(* translation functions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   325
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   326
val trfun = Parse.opt_keyword "advanced" -- Parse.ML_source;
14642
2bfe5de2d1fa improved constdefs and translation functions;
wenzelm
parents: 14528
diff changeset
   327
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   328
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   329
  Outer_Syntax.command @{command_spec "parse_ast_translation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   330
    "install parse ast translation functions"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   331
    (trfun >> (Toplevel.theory o Isar_Cmd.parse_ast_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   332
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   333
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   334
  Outer_Syntax.command @{command_spec "parse_translation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   335
    "install parse translation functions"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   336
    (trfun >> (Toplevel.theory o Isar_Cmd.parse_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   337
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   338
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   339
  Outer_Syntax.command @{command_spec "print_translation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   340
    "install print translation functions"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   341
    (trfun >> (Toplevel.theory o Isar_Cmd.print_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   342
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   343
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   344
  Outer_Syntax.command @{command_spec "typed_print_translation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   345
    "install typed print translation functions"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   346
    (trfun >> (Toplevel.theory o Isar_Cmd.typed_print_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   347
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   348
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   349
  Outer_Syntax.command @{command_spec "print_ast_translation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   350
    "install print ast translation functions"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   351
    (trfun >> (Toplevel.theory o Isar_Cmd.print_ast_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   352
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   353
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   354
(* oracles *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   355
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   356
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   357
  Outer_Syntax.command @{command_spec "oracle"} "declare oracle"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   358
    (Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   359
      (fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   360
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   361
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   362
(* bundled declarations *)
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   363
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   364
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   365
  Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   366
    ((Parse.binding --| @{keyword "="}) -- Parse_Spec.xthms1 -- Parse.for_fixes
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   367
      >> (uncurry Bundle.bundle_cmd));
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   368
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   369
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   370
  Outer_Syntax.command @{command_spec "include"}
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   371
    "include declarations from bundle in proof body"
47066
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   372
    (Scan.repeat1 (Parse.position Parse.xname)
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   373
      >> (Toplevel.print oo (Toplevel.proof o Bundle.include_cmd)));
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   374
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   375
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   376
  Outer_Syntax.command @{command_spec "including"}
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   377
    "include declarations from bundle in goal refinement"
47066
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   378
    (Scan.repeat1 (Parse.position Parse.xname)
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   379
      >> (Toplevel.print oo (Toplevel.proof o Bundle.including_cmd)));
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   380
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   381
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   382
  Outer_Syntax.improper_command @{command_spec "print_bundles"}
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   383
    "print bundles of declarations"
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   384
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   385
      Toplevel.keep (Bundle.print_bundles o Toplevel.context_of)));
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   386
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   387
47069
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   388
(* local theories *)
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   389
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   390
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   391
  Outer_Syntax.command @{command_spec "context"} "begin local theory context"
47253
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   392
    ((Parse.position Parse.xname >> (fn name =>
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   393
        Toplevel.print o Toplevel.begin_local_theory true (Named_Target.context_cmd name)) ||
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   394
      Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   395
        >> (fn (incls, elems) => Toplevel.open_target (Bundle.context_cmd incls elems)))
47069
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   396
      --| Parse.begin);
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   397
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   398
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   399
(* locales *)
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   400
12758
f6aceb9d4b8e print_locale: allow full body specification;
wenzelm
parents: 12712
diff changeset
   401
val locale_val =
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   402
  Parse_Spec.locale_expression false --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   403
    Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   404
  Scan.repeat1 Parse_Spec.context_element >> pair ([], []);
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   405
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   406
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   407
  Outer_Syntax.command @{command_spec "locale"} "define named proof context"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   408
    (Parse.binding --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   409
      Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin
27681
8cedebf55539 dropped locale (open)
haftmann
parents: 27617
diff changeset
   410
      >> (fn ((name, (expr, elems)), begin) =>
21843
2015be1b6a03 locale: print context for begin;
wenzelm
parents: 21800
diff changeset
   411
          (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
41585
45d7da4e4ccf added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents: 41536
diff changeset
   412
            (Expression.add_locale_cmd I name Binding.empty expr elems #> snd)));
28085
914183e229e9 Interpretation commands no longer accept interpretation attributes.
ballarin
parents: 28084
diff changeset
   413
41270
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   414
fun parse_interpretation_arguments mandatory =
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   415
  Parse.!!! (Parse_Spec.locale_expression mandatory) --
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   416
    Scan.optional
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   417
      (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [];
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   418
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   419
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   420
  Outer_Syntax.command @{command_spec "sublocale"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   421
    "prove sublocale relation between a locale and a locale expression"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   422
    (Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) --
41270
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   423
      parse_interpretation_arguments false
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   424
      >> (fn (loc, (expr, equations)) =>
41585
45d7da4e4ccf added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents: 41536
diff changeset
   425
          Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations)));
28895
4e2914c2f8c5 Sublocale command.
ballarin
parents: 28820
diff changeset
   426
4e2914c2f8c5 Sublocale command.
ballarin
parents: 28820
diff changeset
   427
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   428
  Outer_Syntax.command @{command_spec "interpretation"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   429
    "prove interpretation of locale expression in theory"
41270
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   430
    (parse_interpretation_arguments true
30727
519f8f0fcbf3 interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents: 30703
diff changeset
   431
      >> (fn (expr, equations) => Toplevel.print o
519f8f0fcbf3 interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents: 30703
diff changeset
   432
          Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations)));
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   433
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   434
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   435
  Outer_Syntax.command @{command_spec "interpret"}
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   436
    "prove interpretation of locale expression in proof context"
41270
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   437
    (parse_interpretation_arguments true
38108
b4115423c049 Interpretation in proofs supports mixins.
ballarin
parents: 37987
diff changeset
   438
      >> (fn (expr, equations) => Toplevel.print o
b4115423c049 Interpretation in proofs supports mixins.
ballarin
parents: 37987
diff changeset
   439
          Toplevel.proof' (Expression.interpret_cmd expr equations)));
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   440
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15624
diff changeset
   441
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   442
(* classes *)
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   443
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   444
val class_val =
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
   445
  Parse_Spec.class_expression --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   446
    Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] ||
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   447
  Scan.repeat1 Parse_Spec.context_element >> pair [];
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   448
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   449
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   450
  Outer_Syntax.command @{command_spec "class"} "define type class"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   451
   (Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin
26516
1bf210ac0a90 removed obscure "attach" feature
haftmann
parents: 26490
diff changeset
   452
    >> (fn ((name, (supclasses, elems)), begin) =>
24938
a220317465b4 class: print result is for locale;
wenzelm
parents: 24932
diff changeset
   453
        (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
41585
45d7da4e4ccf added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents: 41536
diff changeset
   454
          (Class_Declaration.class_cmd I name supclasses elems #> snd)));
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   455
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   456
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   457
  Outer_Syntax.local_theory_to_proof @{command_spec "subclass"} "prove a subclass relation"
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
   458
    (Parse.class >> Class_Declaration.subclass_cmd I);
24914
95cda5dd58d5 added proper subclass concept; improved class target
haftmann
parents: 24871
diff changeset
   459
95cda5dd58d5 added proper subclass concept; improved class target
haftmann
parents: 24871
diff changeset
   460
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   461
  Outer_Syntax.command @{command_spec "instantiation"} "instantiate and prove type arity"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   462
   (Parse.multi_arity --| Parse.begin
25462
dad0291cb76a rudimentary instantiation target
haftmann
parents: 25290
diff changeset
   463
     >> (fn arities => Toplevel.print o
38348
cf7b2121ad9d moved instantiation target formally to class_target.ML
haftmann
parents: 38342
diff changeset
   464
         Toplevel.begin_local_theory true (Class.instantiation_cmd arities)));
24589
d3fca349736c clarified class interfaces and internals
haftmann
parents: 24451
diff changeset
   465
25485
33840a854e63 tuned interfaces of class module
haftmann
parents: 25462
diff changeset
   466
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   467
  Outer_Syntax.command @{command_spec "instance"} "prove type arity or subclass relation"
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
   468
  ((Parse.class --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   469
    ((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd ||
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   470
    Parse.multi_arity >> Class.instance_arity_cmd)
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   471
    >> (Toplevel.print oo Toplevel.theory_to_proof) ||
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   472
    Scan.succeed
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   473
      (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I)));
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   474
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   475
25519
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   476
(* arbitrary overloading *)
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   477
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   478
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   479
  Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   480
   (Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   481
      Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   482
      >> Parse.triple1) --| Parse.begin
25519
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   483
   >> (fn operations => Toplevel.print o
38342
09d4a04d5c2e moved overloading target formally to overloading.ML
haftmann
parents: 38108
diff changeset
   484
         Toplevel.begin_local_theory true (Overloading.overloading_cmd operations)));
25519
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   485
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   486
22866
wenzelm
parents: 22796
diff changeset
   487
(* code generation *)
wenzelm
parents: 22796
diff changeset
   488
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   489
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   490
  Outer_Syntax.command @{command_spec "code_datatype"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   491
    "define set of code datatype constructors"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   492
    (Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd));
22866
wenzelm
parents: 22796
diff changeset
   493
wenzelm
parents: 22796
diff changeset
   494
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   495
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   496
(** proof commands **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   497
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   498
(* statements *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   499
48645
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   500
fun gen_theorem spec schematic kind =
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   501
  Outer_Syntax.local_theory_to_proof' spec
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36178
diff changeset
   502
    ("state " ^ (if schematic then "schematic " ^ kind else kind))
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   503
    (Scan.optional (Parse_Spec.opt_thm_name ":" --|
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   504
      Scan.ahead (Parse_Spec.includes >> K "" ||
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   505
        Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding --
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   506
      Scan.optional Parse_Spec.includes [] --
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   507
      Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) =>
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36178
diff changeset
   508
        ((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd)
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   509
          kind NONE (K I) a includes elems concl)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   510
48645
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   511
val _ = gen_theorem @{command_spec "theorem"} false Thm.theoremK;
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   512
val _ = gen_theorem @{command_spec "lemma"} false Thm.lemmaK;
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   513
val _ = gen_theorem @{command_spec "corollary"} false Thm.corollaryK;
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   514
val _ = gen_theorem @{command_spec "schematic_theorem"} true Thm.theoremK;
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   515
val _ = gen_theorem @{command_spec "schematic_lemma"} true Thm.lemmaK;
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   516
val _ = gen_theorem @{command_spec "schematic_corollary"} true Thm.corollaryK;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   517
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   518
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   519
  Outer_Syntax.local_theory_to_proof @{command_spec "notepad"} "begin proof context"
40960
9e54eb514a46 formal notepad without any result;
wenzelm
parents: 40784
diff changeset
   520
    (Parse.begin >> K Proof.begin_notepad);
9e54eb514a46 formal notepad without any result;
wenzelm
parents: 40784
diff changeset
   521
9e54eb514a46 formal notepad without any result;
wenzelm
parents: 40784
diff changeset
   522
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   523
  Outer_Syntax.command @{command_spec "have"} "state local goal"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   524
    (Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have));
17353
cd440b6812b1 cleanup parsers and interfaces;
wenzelm
parents: 17264
diff changeset
   525
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   526
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   527
  Outer_Syntax.command @{command_spec "hence"} "old-style alias of \"then have\""
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   528
    (Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence));
17353
cd440b6812b1 cleanup parsers and interfaces;
wenzelm
parents: 17264
diff changeset
   529
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   530
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   531
  Outer_Syntax.command @{command_spec "show"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   532
    "state local goal, solving current obligation"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   533
    (Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   534
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   535
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   536
  Outer_Syntax.command @{command_spec "thus"} "old-style alias of  \"then show\""
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   537
    (Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus));
6501
392333eb31cb added thus, hence;
wenzelm
parents: 6404
diff changeset
   538
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   539
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   540
(* facts *)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   541
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   542
val facts = Parse.and_list1 Parse_Spec.xthms1;
9197
16d88c5547bd added method_setup;
wenzelm
parents: 9129
diff changeset
   543
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   544
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   545
  Outer_Syntax.command @{command_spec "then"} "forward chaining"
17900
5f44c71c4ca4 use simplified Toplevel.proof etc.;
wenzelm
parents: 17854
diff changeset
   546
    (Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   547
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   548
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   549
  Outer_Syntax.command @{command_spec "from"} "forward chaining from given facts"
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   550
    (facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd)));
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   551
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   552
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   553
  Outer_Syntax.command @{command_spec "with"} "forward chaining from given and current facts"
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   554
    (facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd)));
6878
1e97e7fbcca5 'with' as == 'from' as facts;
wenzelm
parents: 6869
diff changeset
   555
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   556
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   557
  Outer_Syntax.command @{command_spec "note"} "define facts"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   558
    (Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   559
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   560
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   561
  Outer_Syntax.command @{command_spec "using"} "augment goal facts"
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   562
    (facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd)));
18544
cbad888756b2 added 'using' command;
wenzelm
parents: 18308
diff changeset
   563
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   564
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   565
  Outer_Syntax.command @{command_spec "unfolding"} "unfold definitions in goal and facts"
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   566
    (facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd)));
12926
cd0dd6e0bf5c 'using' command;
wenzelm
parents: 12876
diff changeset
   567
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   568
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   569
(* proof context *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   570
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   571
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   572
  Outer_Syntax.command @{command_spec "fix"} "fix local variables (Skolem constants)"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   573
    (Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd)));
11890
28e42a90bea8 improved source arrangement of obtain;
wenzelm
parents: 11793
diff changeset
   574
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   575
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   576
  Outer_Syntax.command @{command_spec "assume"} "assume propositions"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   577
    (Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   578
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   579
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   580
  Outer_Syntax.command @{command_spec "presume"} "assume propositions, to be established later"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   581
    (Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd)));
6850
da8a4660fb0c added presume command;
wenzelm
parents: 6773
diff changeset
   582
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   583
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   584
  Outer_Syntax.command @{command_spec "def"} "local definition (non-polymorphic)"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   585
    (Parse.and_list1
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   586
      (Parse_Spec.opt_thm_name ":" --
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   587
        ((Parse.binding -- Parse.opt_mixfix) --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   588
          ((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp)))
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   589
    >> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd)));
6953
b3f6c39aaa2e added 'def';
wenzelm
parents: 6936
diff changeset
   590
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   591
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   592
  Outer_Syntax.command @{command_spec "obtain"} "generalized elimination"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   593
    (Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   594
      >> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   595
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   596
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   597
  Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   598
    (Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd)));
17854
44b6dde80bf4 added 'guess';
wenzelm
parents: 17512
diff changeset
   599
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   600
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   601
  Outer_Syntax.command @{command_spec "let"} "bind text variables"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   602
    (Parse.and_list1 (Parse.and_list1 Parse.term -- (@{keyword "="} |-- Parse.term))
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   603
      >> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   604
36505
79c1d2bbe5a9 ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents: 36452
diff changeset
   605
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   606
  Outer_Syntax.command @{command_spec "write"} "add concrete syntax for constants / fixed variables"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   607
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix)
36505
79c1d2bbe5a9 ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents: 36452
diff changeset
   608
    >> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args)));
79c1d2bbe5a9 ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents: 36452
diff changeset
   609
11793
5f0ab6f5c280 support impromptu terminology of cases parameters;
wenzelm
parents: 11742
diff changeset
   610
val case_spec =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   611
  (@{keyword "("} |--
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   612
    Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| @{keyword ")"}) ||
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   613
    Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1;
11793
5f0ab6f5c280 support impromptu terminology of cases parameters;
wenzelm
parents: 11742
diff changeset
   614
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   615
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   616
  Outer_Syntax.command @{command_spec "case"} "invoke local context"
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   617
    (case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd)));
8370
6b45749d37d6 added 'case' command;
wenzelm
parents: 8349
diff changeset
   618
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   619
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   620
(* proof structure *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   621
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   622
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   623
  Outer_Syntax.command @{command_spec "{"} "begin explicit proof block"
17900
5f44c71c4ca4 use simplified Toplevel.proof etc.;
wenzelm
parents: 17854
diff changeset
   624
    (Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   625
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   626
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   627
  Outer_Syntax.command @{command_spec "}"} "end explicit proof block"
20305
16c8f44b1852 simplified Proof.end_block;
wenzelm
parents: 19844
diff changeset
   628
    (Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block));
6687
134df1440f6e renamed 'begin' / 'end' to '{{' / '}}';
wenzelm
parents: 6551
diff changeset
   629
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   630
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   631
  Outer_Syntax.command @{command_spec "next"} "enter next proof block"
17900
5f44c71c4ca4 use simplified Toplevel.proof etc.;
wenzelm
parents: 17854
diff changeset
   632
    (Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   633
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   634
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   635
(* end proof *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   636
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   637
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   638
  Outer_Syntax.command @{command_spec "qed"} "conclude proof"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   639
    (Scan.option Method.parse >> Isar_Cmd.qed);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   640
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   641
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   642
  Outer_Syntax.command @{command_spec "by"} "terminal backward proof"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   643
    (Method.parse -- Scan.option Method.parse >> Isar_Cmd.terminal_proof);
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   644
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   645
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   646
  Outer_Syntax.command @{command_spec ".."} "default proof"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   647
    (Scan.succeed Isar_Cmd.default_proof);
8966
916966f68907 added "done" proof;
wenzelm
parents: 8896
diff changeset
   648
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   649
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   650
  Outer_Syntax.command @{command_spec "."} "immediate proof"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   651
    (Scan.succeed Isar_Cmd.immediate_proof);
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   652
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   653
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   654
  Outer_Syntax.command @{command_spec "done"} "done proof"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   655
    (Scan.succeed Isar_Cmd.done_proof);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   656
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   657
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   658
  Outer_Syntax.command @{command_spec "sorry"} "skip proof (quick-and-dirty mode only!)"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   659
    (Scan.succeed Isar_Cmd.skip_proof);
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents: 6886
diff changeset
   660
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   661
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   662
  Outer_Syntax.command @{command_spec "oops"} "forget proof"
18561
b0e134637479 Toplevel.forget_proof;
wenzelm
parents: 18544
diff changeset
   663
    (Scan.succeed Toplevel.forget_proof);
8210
ca3997312f47 added forget_proof;
wenzelm
parents: 8165
diff changeset
   664
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   665
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   666
(* proof steps *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   667
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   668
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   669
  Outer_Syntax.command @{command_spec "defer"} "shuffle internal proof state"
49865
eeaf1ec7eac2 clarified defer/prefer: more specific errors;
wenzelm
parents: 49863
diff changeset
   670
    (Scan.optional Parse.nat 1 >> (fn n => Toplevel.print o Toplevel.proof (Proof.defer n)));
8165
651b006d7eb8 added defer, prefer;
wenzelm
parents: 8097
diff changeset
   671
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   672
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   673
  Outer_Syntax.command @{command_spec "prefer"} "shuffle internal proof state"
49865
eeaf1ec7eac2 clarified defer/prefer: more specific errors;
wenzelm
parents: 49863
diff changeset
   674
    (Parse.nat >> (fn n => Toplevel.print o Toplevel.proof (Proof.prefer n)));
8165
651b006d7eb8 added defer, prefer;
wenzelm
parents: 8097
diff changeset
   675
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   676
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   677
  Outer_Syntax.command @{command_spec "apply"} "initial refinement step (unstructured)"
49863
b5fb6e7f8d81 more informative errors for 'proof' and 'apply' steps;
wenzelm
parents: 49569
diff changeset
   678
    (Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_results)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   679
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   680
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   681
  Outer_Syntax.command @{command_spec "apply_end"} "terminal refinement step (unstructured)"
49863
b5fb6e7f8d81 more informative errors for 'proof' and 'apply' steps;
wenzelm
parents: 49569
diff changeset
   682
    (Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end_results)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   683
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   684
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   685
  Outer_Syntax.command @{command_spec "proof"} "backward proof step"
22117
505e040bdcdb renamed IsarOutput to ThyOutput;
wenzelm
parents: 22088
diff changeset
   686
    (Scan.option Method.parse >> (fn m => Toplevel.print o
49863
b5fb6e7f8d81 more informative errors for 'proof' and 'apply' steps;
wenzelm
parents: 49569
diff changeset
   687
      Toplevel.actual_proof (Proof_Node.applys (Proof.proof_results m)) o
27563
38f26d4079be removed obsolete 'redo' command;
wenzelm
parents: 27534
diff changeset
   688
      Toplevel.skip_proof (fn i => i + 1)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   689
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   690
6773
83c09a9684cf added 'also', 'finally' commands;
wenzelm
parents: 6757
diff changeset
   691
(* calculational proof commands *)
83c09a9684cf added 'also', 'finally' commands;
wenzelm
parents: 6757
diff changeset
   692
6878
1e97e7fbcca5 'with' as == 'from' as facts;
wenzelm
parents: 6869
diff changeset
   693
val calc_args =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   694
  Scan.option (@{keyword "("} |-- Parse.!!! ((Parse_Spec.xthms1 --| @{keyword ")"})));
6878
1e97e7fbcca5 'with' as == 'from' as facts;
wenzelm
parents: 6869
diff changeset
   695
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   696
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   697
  Outer_Syntax.command @{command_spec "also"} "combine calculation and current facts"
49868
3039922ffd8d more informative errors for 'also' and 'finally';
wenzelm
parents: 49865
diff changeset
   698
    (calc_args >> (Toplevel.proofs' o Calculation.also_cmd));
6773
83c09a9684cf added 'also', 'finally' commands;
wenzelm
parents: 6757
diff changeset
   699
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   700
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   701
  Outer_Syntax.command @{command_spec "finally"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   702
    "combine calculation and current facts, exhibit result"
49868
3039922ffd8d more informative errors for 'also' and 'finally';
wenzelm
parents: 49865
diff changeset
   703
    (calc_args >> (Toplevel.proofs' o Calculation.finally_cmd));
6773
83c09a9684cf added 'also', 'finally' commands;
wenzelm
parents: 6757
diff changeset
   704
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   705
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   706
  Outer_Syntax.command @{command_spec "moreover"} "augment calculation by current facts"
17900
5f44c71c4ca4 use simplified Toplevel.proof etc.;
wenzelm
parents: 17854
diff changeset
   707
    (Scan.succeed (Toplevel.proof' Calculation.moreover));
8562
ce0e2b8e8844 added 'moreover' command;
wenzelm
parents: 8521
diff changeset
   708
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   709
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   710
  Outer_Syntax.command @{command_spec "ultimately"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   711
    "augment calculation by current facts, exhibit result"
17900
5f44c71c4ca4 use simplified Toplevel.proof etc.;
wenzelm
parents: 17854
diff changeset
   712
    (Scan.succeed (Toplevel.proof' Calculation.ultimately));
8588
b7c3f264f8ac added 'ultimately';
wenzelm
parents: 8562
diff changeset
   713
6773
83c09a9684cf added 'also', 'finally' commands;
wenzelm
parents: 6757
diff changeset
   714
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6735
diff changeset
   715
(* proof navigation *)
5944
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   716
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   717
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   718
  Outer_Syntax.command @{command_spec "back"} "backtracking of proof command"
33390
5b499f36dd25 modernized structure Proof_Node;
wenzelm
parents: 33287
diff changeset
   719
    (Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I));
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6735
diff changeset
   720
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   721
27614
f38c25d106a7 renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents: 27575
diff changeset
   722
(* nested commands *)
25578
11ee8b183477 added nested 'Isabelle.command';
wenzelm
parents: 25536
diff changeset
   723
29309
aa6d11fbe3b6 added props_text (from outer_parse.ML);
wenzelm
parents: 29225
diff changeset
   724
val props_text =
43775
b361c7d184e7 added Parse.properties (again) -- allow empty list like Parse_Value.properties but unlike Parse.properties of ef86de9c98aa;
wenzelm
parents: 43227
diff changeset
   725
  Scan.optional Parse.properties [] -- Parse.position Parse.string
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   726
  >> (fn (props, (str, pos)) =>
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   727
      (Position.of_properties (Position.default_properties pos props), str));
29309
aa6d11fbe3b6 added props_text (from outer_parse.ML);
wenzelm
parents: 29225
diff changeset
   728
25578
11ee8b183477 added nested 'Isabelle.command';
wenzelm
parents: 25536
diff changeset
   729
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   730
  Outer_Syntax.improper_command @{command_spec "Isabelle.command"} "evaluate nested Isabelle command"
29309
aa6d11fbe3b6 added props_text (from outer_parse.ML);
wenzelm
parents: 29225
diff changeset
   731
    (props_text :|-- (fn (pos, str) =>
36953
2af1ad9aa1a3 renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents: 36952
diff changeset
   732
      (case Outer_Syntax.parse pos str of
27838
0340fd7cccc3 Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents: 27831
diff changeset
   733
        [tr] => Scan.succeed (K tr)
43947
9b00f09f7721 defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents: 43775
diff changeset
   734
      | _ => Scan.fail_with (K (fn () => "exactly one command expected")))
9b00f09f7721 defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents: 43775
diff changeset
   735
      handle ERROR msg => Scan.fail_with (K (fn () => msg))));
25578
11ee8b183477 added nested 'Isabelle.command';
wenzelm
parents: 25536
diff changeset
   736
11ee8b183477 added nested 'Isabelle.command';
wenzelm
parents: 25536
diff changeset
   737
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   738
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   739
(** diagnostic commands (for interactive mode only) **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   740
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   741
val opt_modes =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   742
  Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) [];
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   743
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   744
val opt_bang = Scan.optional (@{keyword "!"} >> K true) false;
8464
0f78101b249a 'pr': modes, optional limit;
wenzelm
parents: 8454
diff changeset
   745
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   746
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   747
  Outer_Syntax.improper_command @{command_spec "pretty_setmargin"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   748
    "change default margin for pretty printing"
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   749
    (Parse.nat >>
38870
wenzelm
parents: 38708
diff changeset
   750
      (fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Pretty.margin_default := n)));
7124
78c01842d3b5 added pretty_setmargin;
wenzelm
parents: 7102
diff changeset
   751
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   752
val _ =
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 49868
diff changeset
   753
  Outer_Syntax.improper_command @{command_spec "help"}
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 49868
diff changeset
   754
    "retrieve outer syntax commands according to name patterns"
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 49868
diff changeset
   755
    (Scan.repeat Parse.name >> (fn pats =>
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 49868
diff changeset
   756
      Toplevel.no_timing o Toplevel.imperative (fn () => Outer_Syntax.help_outer_syntax pats)));
21714
d64cb19c79e2 added 'help' command (same of 'print_commands');
wenzelm
parents: 21705
diff changeset
   757
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   758
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   759
  Outer_Syntax.improper_command @{command_spec "print_commands"} "print outer syntax commands"
36953
2af1ad9aa1a3 renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents: 36952
diff changeset
   760
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   761
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   762
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   763
  Outer_Syntax.improper_command @{command_spec "print_configs"} "print configuration options"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   764
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   765
      Toplevel.keep (Attrib.print_configs o Toplevel.context_of)));
23989
d7df8545f9f6 added command 'print_options';
wenzelm
parents: 23865
diff changeset
   766
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   767
val _ =
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   768
  Outer_Syntax.improper_command @{command_spec "print_context"} "print main context"
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   769
    (Scan.succeed (Toplevel.no_timing o Toplevel.keep Toplevel.print_state_context));
7308
e01aab03a2a1 print_context;
wenzelm
parents: 7269
diff changeset
   770
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   771
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   772
  Outer_Syntax.improper_command @{command_spec "print_theory"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   773
    "print logical theory contents (verbose!)"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   774
    (opt_bang >> (fn b => Toplevel.no_timing o Toplevel.unknown_theory o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   775
      Toplevel.keep (Pretty.writeln o Proof_Display.pretty_full_theory b o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   776
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   777
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   778
  Outer_Syntax.improper_command @{command_spec "print_syntax"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   779
    "print inner syntax of context (verbose!)"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   780
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   781
      Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   782
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   783
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   784
  Outer_Syntax.improper_command @{command_spec "print_abbrevs"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   785
    "print constant abbreviation of context"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   786
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   787
      Toplevel.keep (Proof_Context.print_abbrevs o Toplevel.context_of)));
21726
092b967da9b7 added 'print_abbrevs';
wenzelm
parents: 21714
diff changeset
   788
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   789
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   790
  Outer_Syntax.improper_command @{command_spec "print_theorems"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   791
    "print theorems of local theory or proof context"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   792
    (opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theorems));
5881
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   793
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   794
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   795
  Outer_Syntax.improper_command @{command_spec "print_locales"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   796
    "print locales of this theory"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   797
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   798
      Toplevel.keep (Locale.print_locales o Toplevel.theory_of)));
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   799
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   800
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   801
  Outer_Syntax.improper_command @{command_spec "print_classes"}
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   802
    "print classes of this theory"
42359
6ca5407863ed prefer local name spaces;
wenzelm
parents: 42326
diff changeset
   803
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o
6ca5407863ed prefer local name spaces;
wenzelm
parents: 42326
diff changeset
   804
      Toplevel.keep (Class.print_classes o Toplevel.context_of)));
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   805
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   806
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   807
  Outer_Syntax.improper_command @{command_spec "print_locale"}
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   808
    "print locale of this theory"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   809
    (opt_bang -- Parse.position Parse.xname >> (fn (b, name) =>
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   810
      Toplevel.no_timing o Toplevel.unknown_theory o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   811
      Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name)));
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   812
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   813
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   814
  Outer_Syntax.improper_command @{command_spec "print_interps"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   815
    "print interpretations of locale for this theory or proof context"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   816
    (Parse.position Parse.xname >> (fn name => Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   817
      Toplevel.keep (fn state => Locale.print_registrations (Toplevel.context_of state) name)));
32804
ca430e6aee1c Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents: 31869
diff changeset
   818
ca430e6aee1c Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents: 31869
diff changeset
   819
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   820
  Outer_Syntax.improper_command @{command_spec "print_dependencies"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   821
    "print dependencies of locale expression"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   822
    (opt_bang -- Parse_Spec.locale_expression true >> (fn (clean, expr) =>
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   823
      Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   824
        Toplevel.keep (fn state =>
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   825
          Expression.print_dependencies (Toplevel.context_of state) clean expr)));
41435
12585dfb86fe Diagnostic command to show locale dependencies.
ballarin
parents: 41270
diff changeset
   826
12585dfb86fe Diagnostic command to show locale dependencies.
ballarin
parents: 41270
diff changeset
   827
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   828
  Outer_Syntax.improper_command @{command_spec "print_attributes"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   829
    "print attributes of this theory"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   830
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   831
      Toplevel.keep (Attrib.print_attributes o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   832
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   833
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   834
  Outer_Syntax.improper_command @{command_spec "print_simpset"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   835
    "print context of Simplifier"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   836
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   837
      Toplevel.keep (fn state =>
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   838
        let val ctxt = Toplevel.context_of state
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   839
        in Pretty.writeln (Simplifier.pretty_ss ctxt (simpset_of ctxt)) end)));
16027
77c1171090d9 added 'print_simpset';
wenzelm
parents: 15979
diff changeset
   840
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   841
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   842
  Outer_Syntax.improper_command @{command_spec "print_rules"} "print intro/elim rules"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   843
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   844
      Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of)));
12383
af14fd56b189 added 'print_rules' command;
wenzelm
parents: 12288
diff changeset
   845
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   846
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   847
  Outer_Syntax.improper_command @{command_spec "print_trans_rules"} "print transitivity rules"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   848
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   849
      Toplevel.keep (Calculation.print_rules o Toplevel.context_of)));
9221
e1fd1003d5f9 removed "help";
wenzelm
parents: 9197
diff changeset
   850
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   851
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   852
  Outer_Syntax.improper_command @{command_spec "print_methods"} "print methods of this theory"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   853
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   854
      Toplevel.keep (Method.print_methods o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   855
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   856
val _ =
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   857
  Outer_Syntax.improper_command @{command_spec "print_antiquotations"} "print antiquotations"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   858
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   859
      Toplevel.keep (Thy_Output.print_antiquotations o Toplevel.context_of)));
9221
e1fd1003d5f9 removed "help";
wenzelm
parents: 9197
diff changeset
   860
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   861
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   862
  Outer_Syntax.improper_command @{command_spec "thy_deps"} "visualize theory dependencies"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   863
    (Scan.succeed (Toplevel.no_timing o Isar_Cmd.thy_deps));
22485
3a7d623485fa added theory dependency graph
haftmann
parents: 22417
diff changeset
   864
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   865
val _ =
49569
7b6aaf446496 tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents: 48997
diff changeset
   866
  Outer_Syntax.improper_command @{command_spec "locale_deps"} "visualize locale dependencies"
7b6aaf446496 tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents: 48997
diff changeset
   867
    (Scan.succeed (Toplevel.no_timing o Isar_Cmd.locale_deps));
7b6aaf446496 tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents: 48997
diff changeset
   868
7b6aaf446496 tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents: 48997
diff changeset
   869
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   870
  Outer_Syntax.improper_command @{command_spec "class_deps"} "visualize class dependencies"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   871
    (Scan.succeed (Toplevel.no_timing o Isar_Cmd.class_deps));
20574
a10885a269cb added class_deps;
wenzelm
parents: 20365
diff changeset
   872
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   873
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   874
  Outer_Syntax.improper_command @{command_spec "thm_deps"} "visualize theorem dependencies"
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   875
    (Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.thm_deps));
9454
ea80449107cc added thm_deps;
wenzelm
parents: 9323
diff changeset
   876
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   877
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   878
  Outer_Syntax.improper_command @{command_spec "print_binds"} "print term bindings of proof context"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   879
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   880
      Toplevel.keep (Proof_Context.print_binds o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   881
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   882
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   883
  Outer_Syntax.improper_command @{command_spec "print_facts"} "print facts of proof context"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   884
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   885
      Toplevel.keep (Proof_Context.print_lthms o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   886
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   887
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   888
  Outer_Syntax.improper_command @{command_spec "print_cases"} "print cases of proof context"
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   889
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   890
      Toplevel.keep (Proof_Context.print_cases o Toplevel.context_of)));
8370
6b45749d37d6 added 'case' command;
wenzelm
parents: 8349
diff changeset
   891
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   892
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   893
  Outer_Syntax.improper_command @{command_spec "print_statement"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   894
    "print theorems as long statements"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   895
    (opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_stmts));
19269
620616bc7632 added 'print_statement' command;
wenzelm
parents: 19260
diff changeset
   896
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   897
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   898
  Outer_Syntax.improper_command @{command_spec "thm"} "print theorems"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   899
    (opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_thms));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   900
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   901
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   902
  Outer_Syntax.improper_command @{command_spec "prf"} "print proof terms of theorems"
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   903
    (opt_modes -- Scan.option Parse_Spec.xthms1
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   904
      >> (Toplevel.no_timing oo Isar_Cmd.print_prfs false));
11524
197f2e14a714 Added functions for printing primitive proof terms.
berghofe
parents: 11101
diff changeset
   905
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   906
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   907
  Outer_Syntax.improper_command @{command_spec "full_prf"} "print full proof terms of theorems"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   908
    (opt_modes -- Scan.option Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_prfs true));
11524
197f2e14a714 Added functions for printing primitive proof terms.
berghofe
parents: 11101
diff changeset
   909
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   910
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   911
  Outer_Syntax.improper_command @{command_spec "prop"} "read and print proposition"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   912
    (opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_prop));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   913
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   914
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   915
  Outer_Syntax.improper_command @{command_spec "term"} "read and print term"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   916
    (opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_term));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   917
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   918
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   919
  Outer_Syntax.improper_command @{command_spec "typ"} "read and print type"
48792
4aa5b965f70e support for 'typ' with explicit sort constraint;
wenzelm
parents: 48646
diff changeset
   920
    (opt_modes -- (Parse.typ -- Scan.option (@{keyword "::"} |-- Parse.!!! Parse.sort))
4aa5b965f70e support for 'typ' with explicit sort constraint;
wenzelm
parents: 48646
diff changeset
   921
      >> (Toplevel.no_timing oo Isar_Cmd.print_type));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   922
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   923
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   924
  Outer_Syntax.improper_command @{command_spec "print_codesetup"} "print code generator setup"
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   925
    (Scan.succeed
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   926
      (Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep
24219
e558fe311376 new structure for code generator modules
haftmann
parents: 24174
diff changeset
   927
        (Code.print_codesetup o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   928
26184
64ee6a2ca6d6 Added unused_thms command.
berghofe
parents: 26048
diff changeset
   929
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   930
  Outer_Syntax.improper_command @{command_spec "unused_thms"} "find unused theorems"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   931
    (Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) --
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   932
       Scan.option (Scan.repeat1 (Scan.unless Parse.minus Parse.name))) >>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   933
         (Toplevel.no_timing oo Isar_Cmd.unused_thms));
26184
64ee6a2ca6d6 Added unused_thms command.
berghofe
parents: 26048
diff changeset
   934
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   935
30142
8d6145694bb5 moved find_theorems.ML and find_consts.ML to Pure/Tools, collecting main implementation in one place each;
wenzelm
parents: 29882
diff changeset
   936
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   937
(** system commands (for interactive mode only) **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   938
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   939
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   940
  Outer_Syntax.improper_command @{command_spec "cd"} "change current working directory"
48881
46e053eda5dd clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents: 48792
diff changeset
   941
    (Parse.path >> (fn name =>
46e053eda5dd clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents: 48792
diff changeset
   942
      Toplevel.no_timing o Toplevel.imperative (fn () => File.cd (Path.explode name))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   943
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   944
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   945
  Outer_Syntax.improper_command @{command_spec "pwd"} "print current working directory"
40395
4985aaade799 mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents: 39214
diff changeset
   946
    (Scan.succeed (Toplevel.no_timing o
41944
b97091ae583a Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
wenzelm
parents: 41585
diff changeset
   947
      Toplevel.imperative (fn () => writeln (Path.print (File.pwd ())))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   948
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   949
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   950
  Outer_Syntax.improper_command @{command_spec "use_thy"} "use theory file"
48927
ef462b5558eb theory def/ref position reports, which enable hyperlinks etc.;
wenzelm
parents: 48881
diff changeset
   951
    (Parse.position Parse.name >> (fn name =>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   952
      Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.use_thy name)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   953
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   954
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   955
  Outer_Syntax.improper_command @{command_spec "remove_thy"} "remove theory from loader database"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   956
    (Parse.name >> (fn name =>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   957
      Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.remove_thy name)));
7102
ead5c234b28c removed update_context;
wenzelm
parents: 7023
diff changeset
   958
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   959
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   960
  Outer_Syntax.improper_command @{command_spec "kill_thy"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   961
    "kill theory -- try to remove from loader database"
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   962
    (Parse.name >> (fn name =>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   963
      Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.kill_thy name)));
7931
fa6fec415492 added kill_thy;
wenzelm
parents: 7908
diff changeset
   964
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   965
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   966
  Outer_Syntax.improper_command @{command_spec "display_drafts"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   967
    "display raw source files with symbols"
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   968
    (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.display_drafts));
14934
bf9f525d4821 added display_drafts and print_drafts commands;
wenzelm
parents: 14900
diff changeset
   969
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   970
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   971
  Outer_Syntax.improper_command @{command_spec "print_drafts"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   972
    "print raw source files with symbols"
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   973
    (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.print_drafts));
14934
bf9f525d4821 added display_drafts and print_drafts commands;
wenzelm
parents: 14900
diff changeset
   974
39165
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   975
val _ =  (* FIXME tty only *)
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   976
  Outer_Syntax.improper_command @{command_spec "pr"} "print current proof state (if present)"
39165
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   977
    (opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) =>
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   978
      Toplevel.no_timing o Toplevel.keep (fn state =>
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   979
       (case limit of NONE => () | SOME n => Goal_Display.goals_limit_default := n;
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   980
        Toplevel.quiet := false;
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   981
        Print_Mode.with_modes modes (Toplevel.print_state true) state))));
7199
7fede88e5c73 pr / no_pr: maintain Toplevel.quiet;
wenzelm
parents: 7172
diff changeset
   982
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   983
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   984
  Outer_Syntax.improper_command @{command_spec "disable_pr"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   985
    "disable printing of toplevel state"
39165
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   986
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := true)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   987
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   988
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   989
  Outer_Syntax.improper_command @{command_spec "enable_pr"}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   990
    "enable printing of toplevel state"
39165
e790a5560834 discontinued obsolete ProofContext.prems_limit;
wenzelm
parents: 38888
diff changeset
   991
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := false)));
7222
e4244b2e70ef disable_pr, enable_pr;
wenzelm
parents: 7199
diff changeset
   992
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   993
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   994
  Outer_Syntax.improper_command @{command_spec "commit"}
50214
67fb9a168d10 tuned command descriptions;
wenzelm
parents: 50213
diff changeset
   995
    "commit current session to ML session image"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   996
    (Parse.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   997
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   998
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   999
  Outer_Syntax.improper_command @{command_spec "quit"} "quit Isabelle"
37977
3ceccd415145 simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents: 37949
diff changeset
  1000
    (Parse.opt_unit >> (Toplevel.no_timing oo K (Toplevel.imperative quit)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
  1001
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
  1002
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
  1003
  Outer_Syntax.improper_command @{command_spec "exit"} "exit Isar loop"
37977
3ceccd415145 simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents: 37949
diff changeset
  1004
    (Scan.succeed
3ceccd415145 simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents: 37949
diff changeset
  1005
      (Toplevel.no_timing o Toplevel.keep (fn state =>
3ceccd415145 simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents: 37949
diff changeset
  1006
        (Context.set_thread_data (try Toplevel.generic_theory_of state);
38888
8248cda328de moved Toplevel.run_command to Pure/PIDE/document.ML;
wenzelm
parents: 38870
diff changeset
  1007
          raise Runtime.TERMINATE))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
  1008
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1009
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1010
  Outer_Syntax.improper_command @{command_spec "welcome"} "print welcome message"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1011
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative (writeln o Session.welcome)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1012
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1013
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1014
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1015
(** raw Isar read-eval-print loop **)
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1016
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1017
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1018
  Outer_Syntax.improper_command @{command_spec "init_toplevel"} "init toplevel point-of-interest"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1019
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.init));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1020
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1021
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1022
  Outer_Syntax.improper_command @{command_spec "linear_undo"} "undo commands"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1023
    (Scan.optional Parse.nat 1 >>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1024
      (fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.linear_undo n)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1025
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1026
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1027
  Outer_Syntax.improper_command @{command_spec "undo"} "undo commands (skipping closed proofs)"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1028
    (Scan.optional Parse.nat 1 >>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1029
      (fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo n)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1030
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1031
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1032
  Outer_Syntax.improper_command @{command_spec "undos_proof"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1033
    "undo commands (skipping closed proofs)"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1034
    (Scan.optional Parse.nat 1 >> (fn n => Toplevel.no_timing o
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1035
      Toplevel.keep (fn state =>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1036
        if Toplevel.is_proof state then (Isar.undo n; Isar.print ()) else raise Toplevel.UNDEF)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1037
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1038
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1039
  Outer_Syntax.improper_command @{command_spec "cannot_undo"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1040
    "partial undo -- Proof General legacy"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1041
    (Parse.name >>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1042
      (fn "end" => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo 1)
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1043
        | txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt))));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1044
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1045
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1046
  Outer_Syntax.improper_command @{command_spec "kill"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1047
    "kill partial proof or theory development"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1048
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.kill));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1049
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1050
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1051
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1052
(** extraction of programs from proofs **)
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1053
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1054
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") [];
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1055
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1056
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1057
  Outer_Syntax.command @{command_spec "realizers"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1058
    "specify realizers for primitive axioms / theorems, together with correctness proof"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1059
    (Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1060
     (fn xs => Toplevel.theory (fn thy => Extraction.add_realizers
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1061
       (map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1062
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1063
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1064
  Outer_Syntax.command @{command_spec "realizability"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1065
    "add equations characterizing realizability"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1066
    (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1067
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1068
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1069
  Outer_Syntax.command @{command_spec "extract_type"}
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1070
    "add equations characterizing type of extracted program"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1071
    (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1072
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1073
val _ =
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1074
  Outer_Syntax.command @{command_spec "extract"} "extract terms from proofs"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1075
    (Scan.repeat1 (Parse.xname -- parse_vars) >> (fn xs => Toplevel.theory (fn thy =>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1076
      Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
  1077
48641
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1078
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1079
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1080
(** end **)
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1081
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1082
val _ =
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
  1083
  Outer_Syntax.command @{command_spec "end"} "end context"
48641
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1084
    (Scan.succeed
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1085
      (Toplevel.exit o Toplevel.end_local_theory o Toplevel.close_target o
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1086
        Toplevel.end_proof (K Proof.end_notepad)));
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
  1087
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
  1088
end;
27614
f38c25d106a7 renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents: 27575
diff changeset
  1089