src/Pure/Isar/isar_syn.ML
author wenzelm
Tue, 06 Oct 2015 13:31:44 +0200
changeset 61336 fa4ebbd350ae
parent 61266 eb9522a9d997
child 61337 4645502c3c64
permissions -rw-r--r--
just one theorem kind, which is legacy anyway;
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
52546
7118524a2a24 tuned comments;
wenzelm
parents: 52438
diff changeset
     2
    Author:     Makarius
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
     3
52546
7118524a2a24 tuned comments;
wenzelm
parents: 52438
diff changeset
     4
Outer syntax for Isabelle/Pure.
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
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
    10
(** theory commands **)
6886
7d0f7ad5a35f added 'txt';
wenzelm
parents: 6878
diff changeset
    11
55385
169e12bbf9a3 discontinued axiomatic 'classes', 'classrel', 'arities';
wenzelm
parents: 55141
diff changeset
    12
(* sorts *)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    13
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    14
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    15
  Outer_Syntax.local_theory @{command_keyword default_sort}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    16
    "declare default sort for explicit type variables"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    17
    (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
    18
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    19
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    20
(* types *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    21
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    22
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    23
  Outer_Syntax.local_theory @{command_keyword typedecl} "type declaration"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    24
    (Parse.type_args -- Parse.binding -- Parse.opt_mixfix
61259
6dc3d5d50e57 tuned signature;
wenzelm
parents: 61252
diff changeset
    25
      >> (fn ((args, a), mx) =>
6dc3d5d50e57 tuned signature;
wenzelm
parents: 61252
diff changeset
    26
          Typedecl.typedecl {final = true} (a, map (rpair dummyS) args, mx) #> snd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    27
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    28
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    29
  Outer_Syntax.local_theory @{command_keyword type_synonym} "declare type abbreviation"
45837
wenzelm
parents: 45600
diff changeset
    30
    (Parse.type_args -- Parse.binding --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    31
      (@{keyword "="} |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))
45837
wenzelm
parents: 45600
diff changeset
    32
      >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    33
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    34
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    35
  Outer_Syntax.command @{command_keyword nonterminal}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
    36
    "declare syntactic type constructors (grammar nonterminal symbols)"
42375
774df7c59508 report Name_Space.declare/define, relatively to context;
wenzelm
parents: 42359
diff changeset
    37
    (Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    38
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    39
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    40
(* consts and syntax *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    41
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    42
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    43
  Outer_Syntax.command @{command_keyword judgment} "declare object-logic judgment"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    44
    (Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd));
8227
d67db92897df add_judgment;
wenzelm
parents: 8210
diff changeset
    45
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    46
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    47
  Outer_Syntax.command @{command_keyword consts} "declare constants"
56239
17df7145a871 tuned signature;
wenzelm
parents: 56158
diff changeset
    48
    (Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    49
12142
c81ef8865cfb "theorem" etc.: multiple statements;
wenzelm
parents: 12125
diff changeset
    50
val mode_spec =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    51
  (@{keyword "output"} >> K ("", false)) ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    52
    Parse.name -- Scan.optional (@{keyword "output"} >> K false) true;
9731
3eb72671e5db pr: added prems limit;
wenzelm
parents: 9589
diff changeset
    53
14900
c66394c408f7 Syntax.default_mode;
wenzelm
parents: 14779
diff changeset
    54
val opt_mode =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    55
  Scan.optional (@{keyword "("} |-- Parse.!!! (mode_spec --| @{keyword ")"})) Syntax.mode_default;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    56
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    57
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    58
  Outer_Syntax.command @{command_keyword syntax} "add raw syntax clauses"
56239
17df7145a871 tuned signature;
wenzelm
parents: 56158
diff changeset
    59
    (opt_mode -- Scan.repeat1 Parse.const_decl
56240
938c6c7e10eb tuned signature;
wenzelm
parents: 56239
diff changeset
    60
      >> (Toplevel.theory o uncurry Sign.add_syntax_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    61
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    62
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    63
  Outer_Syntax.command @{command_keyword no_syntax} "delete raw syntax clauses"
56239
17df7145a871 tuned signature;
wenzelm
parents: 56158
diff changeset
    64
    (opt_mode -- Scan.repeat1 Parse.const_decl
56240
938c6c7e10eb tuned signature;
wenzelm
parents: 56239
diff changeset
    65
      >> (Toplevel.theory o uncurry Sign.del_syntax_cmd));
15748
e26fdd4aa95a added 'no_syntax' command;
wenzelm
parents: 15712
diff changeset
    66
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    67
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    68
(* translations *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    69
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    70
val trans_pat =
42326
e2d22eb4aeb9 some position reports for 'translations';
wenzelm
parents: 42300
diff changeset
    71
  Scan.optional
56006
6a4dcaf53664 more formal read_root;
wenzelm
parents: 56005
diff changeset
    72
    (@{keyword "("} |-- Parse.!!! (Parse.inner_syntax Parse.xname --| @{keyword ")"})) "logic"
42326
e2d22eb4aeb9 some position reports for 'translations';
wenzelm
parents: 42300
diff changeset
    73
    -- Parse.inner_syntax Parse.string;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    74
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    75
fun trans_arrow toks =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    76
  ((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    77
    (@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    78
    (@{keyword "\<rightleftharpoons>"} || @{keyword "=="}) >> K Syntax.Parse_Print_Rule) toks;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    79
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    80
val trans_line =
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
    81
  trans_pat -- Parse.!!! (trans_arrow -- trans_pat)
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    82
    >> (fn (left, (arr, right)) => arr (left, right));
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    83
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    84
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    85
  Outer_Syntax.command @{command_keyword translations} "add syntax translation rules"
42204
b3277168c1e7 added Position.reports convenience;
wenzelm
parents: 41944
diff changeset
    86
    (Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    87
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
    88
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
    89
  Outer_Syntax.command @{command_keyword no_translations} "delete syntax translation rules"
42204
b3277168c1e7 added Position.reports convenience;
wenzelm
parents: 41944
diff changeset
    90
    (Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations));
19260
a3d3a4b75c71 added 'no_translations';
wenzelm
parents: 19245
diff changeset
    91
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    92
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    93
(* axioms and definitions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
    94
19631
4445b353f78b 'defs': unchecked flag;
wenzelm
parents: 19516
diff changeset
    95
val opt_unchecked_overloaded =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    96
  Scan.optional (@{keyword "("} |-- Parse.!!!
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    97
    (((@{keyword "unchecked"} >> K true) --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    98
        Scan.optional (@{keyword "overloaded"} >> K true) false ||
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
    99
      @{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false);
19631
4445b353f78b 'defs': unchecked flag;
wenzelm
parents: 19516
diff changeset
   100
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   101
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   102
  Outer_Syntax.command @{command_keyword defs} "define constants"
35852
4e3fe0b8687b minor renovation of old-style 'axioms' -- make it an alias of iterated 'axiomatization';
wenzelm
parents: 35835
diff changeset
   103
    (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
   104
      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
   105
      >> (Toplevel.theory o Isar_Cmd.add_defs));
6370
e71ac23a9111 OuterSyntax.(improper_)command;
wenzelm
parents: 6353
diff changeset
   106
14642
2bfe5de2d1fa improved constdefs and translation functions;
wenzelm
parents: 14528
diff changeset
   107
21601
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21527
diff changeset
   108
(* constant definitions and abbreviations *)
6588b947d631 simplified syntax for 'definition', 'abbreviation';
wenzelm
parents: 21527
diff changeset
   109
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   110
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   111
  Outer_Syntax.local_theory' @{command_keyword definition} "constant definition"
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 44187
diff changeset
   112
    (Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args));
18780
a9c38d41cd27 added 'definition';
wenzelm
parents: 18766
diff changeset
   113
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   114
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   115
  Outer_Syntax.local_theory' @{command_keyword 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
   116
    (opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   117
      >> (fn (mode, args) => Specification.abbreviation_cmd mode args));
19659
88d246e5f4bd added 'const_syntax';
wenzelm
parents: 19631
diff changeset
   118
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   119
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   120
  Outer_Syntax.local_theory @{command_keyword type_notation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   121
    "add concrete syntax for type constructors"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   122
    (opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   123
      >> (fn (mode, args) => Specification.type_notation_cmd true mode args));
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   124
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   125
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   126
  Outer_Syntax.local_theory @{command_keyword no_type_notation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   127
    "delete concrete syntax for type constructors"
42300
0d1cbc1fe579 notation: proper markup for type constructor / constant;
wenzelm
parents: 42299
diff changeset
   128
    (opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   129
      >> (fn (mode, args) => Specification.type_notation_cmd false mode args));
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   130
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35351
diff changeset
   131
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   132
  Outer_Syntax.local_theory @{command_keyword notation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   133
    "add concrete syntax for constants / fixed variables"
51654
8450b944e58a just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents: 51627
diff changeset
   134
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   135
      >> (fn (mode, args) => Specification.notation_cmd true mode args));
24950
106fc30769a9 added 'no_notation';
wenzelm
parents: 24938
diff changeset
   136
106fc30769a9 added 'no_notation';
wenzelm
parents: 24938
diff changeset
   137
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   138
  Outer_Syntax.local_theory @{command_keyword no_notation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   139
    "delete concrete syntax for constants / fixed variables"
51654
8450b944e58a just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents: 51627
diff changeset
   140
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix)
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   141
      >> (fn (mode, args) => Specification.notation_cmd false mode args));
19076
e1948ebe9c7d added 'abbreviation';
wenzelm
parents: 18949
diff changeset
   142
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   143
18616
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   144
(* constant specifications *)
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   145
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   146
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   147
  Outer_Syntax.command @{command_keyword axiomatization} "axiomatic constant specification"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   148
    (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
   149
      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
   150
      >> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y)));
18616
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   151
cf5d07758d3f added 'axiomatization';
wenzelm
parents: 18561
diff changeset
   152
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   153
(* theorems *)
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   154
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   155
val theorems =
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   156
  Parse_Spec.name_facts -- Parse.for_fixes
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   157
    >> (fn (facts, fixes) => #2 oo Specification.theorems_cmd Thm.theoremK facts fixes);
12712
a659fd913a89 localized 'lemmas', 'theorems', 'declare';
wenzelm
parents: 12696
diff changeset
   158
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   159
val _ =
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   160
  Outer_Syntax.local_theory' @{command_keyword theorems} "define theorems" theorems;
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   161
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   162
val _ =
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   163
  Outer_Syntax.local_theory' @{command_keyword lemmas} "define lemmas" theorems;
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   164
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   165
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   166
  Outer_Syntax.local_theory' @{command_keyword declare} "declare theorems"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   167
    (Parse.and_list1 Parse.xthms1 -- Parse.for_fixes
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   168
      >> (fn (facts, fixes) =>
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45488
diff changeset
   169
          #2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes));
9589
95a66548c883 added "declare" command;
wenzelm
parents: 9552
diff changeset
   170
5914
2c069b0a98ee added 'theorems', 'lemmas', 'note';
wenzelm
parents: 5896
diff changeset
   171
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   172
(* hide names *)
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   173
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   174
local
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   175
59935
343905de27b1 clarified command keyword markup;
wenzelm
parents: 59930
diff changeset
   176
fun hide_names command_keyword what hide parse prep =
343905de27b1 clarified command keyword markup;
wenzelm
parents: 59930
diff changeset
   177
  Outer_Syntax.command command_keyword ("hide " ^ what ^ " from name space")
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   178
    ((Parse.opt_keyword "open" >> not) -- Scan.repeat1 parse >> (fn (fully, args) =>
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   179
      (Toplevel.theory (fn thy =>
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   180
        let val ctxt = Proof_Context.init_global thy
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   181
        in fold (hide fully o prep ctxt) args thy end))));
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   182
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   183
in
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   184
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   185
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   186
  hide_names @{command_keyword hide_class} "classes" Sign.hide_class Parse.class
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   187
    Proof_Context.read_class;
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   188
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   189
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   190
  hide_names @{command_keyword hide_type} "types" Sign.hide_type Parse.type_const
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   191
    ((#1 o dest_Type) oo Proof_Context.read_type_name {proper = true, strict = false});
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
   192
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   193
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   194
  hide_names @{command_keyword hide_const} "constants" Sign.hide_const Parse.const
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   195
    ((#1 o dest_Const) oo Proof_Context.read_const {proper = true, strict = false});
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   196
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   197
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   198
  hide_names @{command_keyword hide_fact} "facts" Global_Theory.hide_fact
56005
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   199
    (Parse.position Parse.xname) (Global_Theory.check_fact o Proof_Context.theory_of);
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   200
4f4fc80b0613 simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents: 55997
diff changeset
   201
end;
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   202
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   203
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   204
(* use ML text *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   205
60957
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   206
fun SML_file_cmd debug files = Toplevel.theory (fn thy =>
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   207
  let
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   208
    val ([{lines, pos, ...}: Token.file], thy') = files thy;
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   209
    val source = Input.source true (cat_lines lines) (pos, pos);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   210
    val flags: ML_Compiler.flags =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   211
      {SML = true, exchange = false, redirect = true, verbose = true,
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   212
        debug = debug, writeln = writeln, warning = warning};
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   213
  in
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   214
    thy' |> Context.theory_map
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   215
      (ML_Context.exec (fn () => ML_Context.eval_source flags source))
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   216
  end);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   217
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   218
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   219
  Outer_Syntax.command @{command_keyword SML_file} "read and evaluate Standard ML file"
60957
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   220
    (Resources.provide_parse_files "SML_file" >> SML_file_cmd NONE);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   221
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   222
val _ =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   223
  Outer_Syntax.command @{command_keyword SML_file_debug}
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   224
    "read and evaluate Standard ML file (with debugger information)"
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   225
    (Resources.provide_parse_files "SML_file_debug" >> SML_file_cmd (SOME true));
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   226
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   227
val _ =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   228
  Outer_Syntax.command @{command_keyword SML_file_no_debug}
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   229
    "read and evaluate Standard ML file (no debugger information)"
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
   230
    (Resources.provide_parse_files "SML_file_no_debug" >> SML_file_cmd (SOME false));
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56240
diff changeset
   231
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56240
diff changeset
   232
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   233
  Outer_Syntax.command @{command_keyword SML_export} "evaluate SML within Isabelle/ML environment"
56618
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   234
    (Parse.ML_source >> (fn source =>
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   235
      let
60956
10d463883dc2 explicit debug flag for ML compiler;
wenzelm
parents: 60858
diff changeset
   236
        val flags: ML_Compiler.flags =
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   237
          {SML = true, exchange = true, redirect = false, verbose = true,
60956
10d463883dc2 explicit debug flag for ML compiler;
wenzelm
parents: 60858
diff changeset
   238
            debug = NONE, writeln = writeln, warning = warning};
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   239
      in
56618
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   240
        Toplevel.theory
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   241
          (Context.theory_map (ML_Context.exec (fn () => ML_Context.eval_source flags source)))
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   242
      end));
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   243
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   244
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   245
  Outer_Syntax.command @{command_keyword SML_import} "evaluate Isabelle/ML within SML environment"
56618
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   246
    (Parse.ML_source >> (fn source =>
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   247
      let
60956
10d463883dc2 explicit debug flag for ML compiler;
wenzelm
parents: 60858
diff changeset
   248
        val flags: ML_Compiler.flags =
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   249
          {SML = false, exchange = true, redirect = false, verbose = true,
60956
10d463883dc2 explicit debug flag for ML compiler;
wenzelm
parents: 60858
diff changeset
   250
            debug = NONE, writeln = writeln, warning = warning};
60858
7bf2188a0998 evaluate ML expressions within debugger context;
wenzelm
parents: 60693
diff changeset
   251
      in
56618
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   252
        Toplevel.generic_theory
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   253
          (ML_Context.exec (fn () => ML_Context.eval_source flags source) #>
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   254
            Local_Theory.propagate_ml_env)
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   255
      end));
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   256
874bdedb2313 added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents: 56467
diff changeset
   257
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   258
  Outer_Syntax.command @{command_keyword ML} "ML text within theory or local theory"
55828
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55795
diff changeset
   259
    (Parse.ML_source >> (fn source =>
30579
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   260
      Toplevel.generic_theory
56304
40274e4f5ebf redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents: 56275
diff changeset
   261
        (ML_Context.exec (fn () =>
40274e4f5ebf redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents: 56275
diff changeset
   262
            ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source) #>
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
   263
          Local_Theory.propagate_ml_env)));
30579
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   264
4169ddbfe1f9 command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents: 30576
diff changeset
   265
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   266
  Outer_Syntax.command @{command_keyword ML_prf} "ML text within proof"
55828
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55795
diff changeset
   267
    (Parse.ML_source >> (fn source =>
28269
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   268
      Toplevel.proof (Proof.map_context (Context.proof_map
56304
40274e4f5ebf redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents: 56275
diff changeset
   269
        (ML_Context.exec (fn () =>
40274e4f5ebf redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents: 56275
diff changeset
   270
            ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source))) #>
55828
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55795
diff changeset
   271
          Proof.propagate_ml_env)));
28269
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   272
b1e5e6c4c10e added ML_prf;
wenzelm
parents: 28259
diff changeset
   273
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   274
  Outer_Syntax.command @{command_keyword ML_val} "diagnostic ML text"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   275
    (Parse.ML_source >> Isar_Cmd.ml_diag true);
26396
e44c5a1a47bd added 'ML_val' command (diagnostic);
wenzelm
parents: 26385
diff changeset
   276
e44c5a1a47bd added 'ML_val' command (diagnostic);
wenzelm
parents: 26385
diff changeset
   277
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   278
  Outer_Syntax.command @{command_keyword ML_command} "diagnostic ML text (silent)"
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   279
    (Parse.ML_source >> Isar_Cmd.ml_diag false);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   280
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   281
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   282
  Outer_Syntax.command @{command_keyword setup} "ML setup for global theory"
59930
bdbc4b761c31 tuned signature;
wenzelm
parents: 59923
diff changeset
   283
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.setup));
30461
00323c45ea83 added 'local_setup' command;
wenzelm
parents: 30344
diff changeset
   284
00323c45ea83 added 'local_setup' command;
wenzelm
parents: 30344
diff changeset
   285
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   286
  Outer_Syntax.local_theory @{command_keyword local_setup} "ML setup for local theory"
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   287
    (Parse.ML_source >> Isar_Cmd.local_setup);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   288
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   289
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   290
  Outer_Syntax.local_theory @{command_keyword attribute_setup} "define attribute in ML"
42813
6c841fa92fa2 optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents: 42496
diff changeset
   291
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   292
        Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
57941
57200bdc2aa7 localized command 'method_setup' and 'attribute_setup';
wenzelm
parents: 57934
diff changeset
   293
      >> (fn (name, (txt, cmt)) => Attrib.attribute_setup name txt cmt));
30526
7f9a9ec1c94d added 'attribute_setup' command;
wenzelm
parents: 30484
diff changeset
   294
7f9a9ec1c94d added 'attribute_setup' command;
wenzelm
parents: 30484
diff changeset
   295
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   296
  Outer_Syntax.local_theory @{command_keyword method_setup} "define proof method in ML"
42813
6c841fa92fa2 optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents: 42496
diff changeset
   297
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   298
        Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "")
57941
57200bdc2aa7 localized command 'method_setup' and 'attribute_setup';
wenzelm
parents: 57934
diff changeset
   299
      >> (fn (name, (txt, cmt)) => Method.method_setup name txt cmt));
9197
16d88c5547bd added method_setup;
wenzelm
parents: 9129
diff changeset
   300
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   301
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   302
  Outer_Syntax.local_theory @{command_keyword declaration} "generic ML declaration"
40784
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   303
    (Parse.opt_keyword "pervasive" -- Parse.ML_source
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   304
      >> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt));
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   305
177e8cea3e09 added 'syntax_declaration' command;
wenzelm
parents: 40399
diff changeset
   306
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   307
  Outer_Syntax.local_theory @{command_keyword syntax_declaration} "generic ML syntax 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 = true, pervasive = pervasive} txt));
22088
4c53bb6e10e4 added 'declaration' command;
wenzelm
parents: 21956
diff changeset
   310
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   311
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   312
  Outer_Syntax.local_theory @{command_keyword simproc_setup} "define simproc in ML"
42464
ae16b8abf1a8 proper binding/report of defined simprocs;
wenzelm
parents: 42375
diff changeset
   313
    (Parse.position Parse.name --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   314
      (@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   315
      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
   316
    >> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d));
22202
0544af1a5117 added simproc_setup;
wenzelm
parents: 22117
diff changeset
   317
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   318
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   319
(* translation functions *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   320
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   321
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   322
  Outer_Syntax.command @{command_keyword parse_ast_translation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   323
    "install parse ast translation functions"
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 52060
diff changeset
   324
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_ast_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   325
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   326
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   327
  Outer_Syntax.command @{command_keyword parse_translation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   328
    "install parse translation functions"
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 52060
diff changeset
   329
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   330
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   331
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   332
  Outer_Syntax.command @{command_keyword print_translation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   333
    "install print translation functions"
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 52060
diff changeset
   334
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   335
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   336
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   337
  Outer_Syntax.command @{command_keyword typed_print_translation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   338
    "install typed print translation functions"
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 52060
diff changeset
   339
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.typed_print_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   340
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   341
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   342
  Outer_Syntax.command @{command_keyword print_ast_translation}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   343
    "install print ast translation functions"
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 52060
diff changeset
   344
    (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_ast_translation));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   345
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   346
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   347
(* oracles *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   348
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   349
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   350
  Outer_Syntax.command @{command_keyword oracle} "declare oracle"
59029
c907cbe36713 more careful ML source positions, for improved PIDE markup;
wenzelm
parents: 58999
diff changeset
   351
    (Parse.range Parse.name -- (@{keyword "="} |-- Parse.ML_source) >>
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 37198
diff changeset
   352
      (fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   353
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   354
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   355
(* bundled declarations *)
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   356
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   357
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   358
  Outer_Syntax.local_theory @{command_keyword bundle} "define bundle of declarations"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   359
    ((Parse.binding --| @{keyword "="}) -- Parse.xthms1 -- Parse.for_fixes
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   360
      >> (uncurry Bundle.bundle_cmd));
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   361
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   362
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   363
  Outer_Syntax.command @{command_keyword include}
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   364
    "include declarations from bundle in proof body"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   365
    (Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.include_cmd));
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   366
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   367
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   368
  Outer_Syntax.command @{command_keyword including}
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   369
    "include declarations from bundle in goal refinement"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   370
    (Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.including_cmd));
47066
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   371
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47057
diff changeset
   372
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   373
  Outer_Syntax.command @{command_keyword print_bundles}
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   374
    "print bundles of declarations"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   375
    (Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of)));
47057
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   376
12423b36fcc4 basic support for bundled declarations;
wenzelm
parents: 46999
diff changeset
   377
47069
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   378
(* local theories *)
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   379
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   380
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   381
  Outer_Syntax.command @{command_keyword context} "begin local theory context"
47253
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   382
    ((Parse.position Parse.xname >> (fn name =>
57483
950dc7446454 centralized (ad-hoc) switching of targets in named_target.ML
haftmann
parents: 57442
diff changeset
   383
        Toplevel.begin_local_theory true (Named_Target.begin name)) ||
47253
a00c5c88d8f3 more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents: 47069
diff changeset
   384
      Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element
59890
01aff5aa081d tuned signature;
wenzelm
parents: 59064
diff changeset
   385
        >> (fn (incls, elems) => Toplevel.open_target (#2 o Bundle.context_cmd incls elems)))
47069
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   386
      --| Parse.begin);
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   387
451fc10a81f3 more explicit Toplevel.open_target/close_target;
wenzelm
parents: 47067
diff changeset
   388
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   389
(* locales *)
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   390
12758
f6aceb9d4b8e print_locale: allow full body specification;
wenzelm
parents: 12712
diff changeset
   391
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
   392
  Parse_Spec.locale_expression false --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   393
    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
   394
  Scan.repeat1 Parse_Spec.context_element >> pair ([], []);
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   395
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   396
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   397
  Outer_Syntax.command @{command_keyword locale} "define named specification context"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   398
    (Parse.binding --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   399
      Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin
27681
8cedebf55539 dropped locale (open)
haftmann
parents: 27617
diff changeset
   400
      >> (fn ((name, (expr, elems)), begin) =>
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   401
          Toplevel.begin_local_theory begin
57181
2d13bf9ea77b dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents: 56895
diff changeset
   402
            (Expression.add_locale_cmd name Binding.empty expr elems #> snd)));
28085
914183e229e9 Interpretation commands no longer accept interpretation attributes.
ballarin
parents: 28084
diff changeset
   403
59901
840d03805755 added command 'experiment';
wenzelm
parents: 59890
diff changeset
   404
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   405
  Outer_Syntax.command @{command_keyword experiment} "open private specification context"
59901
840d03805755 added command 'experiment';
wenzelm
parents: 59890
diff changeset
   406
    (Scan.repeat Parse_Spec.context_element --| Parse.begin
840d03805755 added command 'experiment';
wenzelm
parents: 59890
diff changeset
   407
      >> (fn elems =>
840d03805755 added command 'experiment';
wenzelm
parents: 59890
diff changeset
   408
          Toplevel.begin_local_theory true (Experiment.experiment_cmd elems #> snd)));
840d03805755 added command 'experiment';
wenzelm
parents: 59890
diff changeset
   409
53988
wenzelm
parents: 53403
diff changeset
   410
fun interpretation_args mandatory =
41270
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   411
  Parse.!!! (Parse_Spec.locale_expression mandatory) --
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   412
    Scan.optional
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   413
      (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [];
dea60d052923 Add mixins to sublocale command.
ballarin
parents: 41249
diff changeset
   414
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   415
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   416
  Outer_Syntax.command @{command_keyword sublocale}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   417
    "prove sublocale relation between a locale and a locale expression"
51737
718866dda2fa target-sensitive user-level commands interpretation and sublocale
haftmann
parents: 51717
diff changeset
   418
    ((Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) --
53988
wenzelm
parents: 53403
diff changeset
   419
      interpretation_args false >> (fn (loc, (expr, equations)) =>
57181
2d13bf9ea77b dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents: 56895
diff changeset
   420
        Toplevel.theory_to_proof (Expression.sublocale_global_cmd loc expr equations)))
53988
wenzelm
parents: 53403
diff changeset
   421
    || interpretation_args false >> (fn (expr, equations) =>
59923
b21c82422d65 support private scope for individual local theory commands;
wenzelm
parents: 59917
diff changeset
   422
        Toplevel.local_theory_to_proof NONE NONE (Expression.sublocale_cmd expr equations)));
28895
4e2914c2f8c5 Sublocale command.
ballarin
parents: 28820
diff changeset
   423
4e2914c2f8c5 Sublocale command.
ballarin
parents: 28820
diff changeset
   424
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   425
  Outer_Syntax.command @{command_keyword interpretation}
51737
718866dda2fa target-sensitive user-level commands interpretation and sublocale
haftmann
parents: 51717
diff changeset
   426
    "prove interpretation of locale expression in local theory"
53988
wenzelm
parents: 53403
diff changeset
   427
    (interpretation_args true >> (fn (expr, equations) =>
59923
b21c82422d65 support private scope for individual local theory commands;
wenzelm
parents: 59917
diff changeset
   428
      Toplevel.local_theory_to_proof NONE NONE (Expression.interpretation_cmd expr equations)));
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   429
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   430
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   431
  Outer_Syntax.command @{command_keyword interpret}
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   432
    "prove interpretation of locale expression in proof context"
53988
wenzelm
parents: 53403
diff changeset
   433
    (interpretation_args true >> (fn (expr, equations) =>
wenzelm
parents: 53403
diff changeset
   434
      Toplevel.proof' (Expression.interpret_cmd expr equations)));
29223
e09c53289830 Conversion of HOL-Main and ZF to new locales.
ballarin
parents: 29033
diff changeset
   435
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15624
diff changeset
   436
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   437
(* classes *)
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   438
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   439
val class_val =
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
   440
  Parse_Spec.class_expression --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   441
    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
   442
  Scan.repeat1 Parse_Spec.context_element >> pair [];
22299
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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   445
  Outer_Syntax.command @{command_keyword class} "define type class"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   446
   (Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin
26516
1bf210ac0a90 removed obscure "attach" feature
haftmann
parents: 26490
diff changeset
   447
    >> (fn ((name, (supclasses, elems)), begin) =>
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   448
        Toplevel.begin_local_theory begin
57181
2d13bf9ea77b dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents: 56895
diff changeset
   449
          (Class_Declaration.class_cmd name supclasses elems #> snd)));
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   450
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   451
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   452
  Outer_Syntax.local_theory_to_proof @{command_keyword subclass} "prove a subclass relation"
57181
2d13bf9ea77b dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents: 56895
diff changeset
   453
    (Parse.class >> Class_Declaration.subclass_cmd);
24914
95cda5dd58d5 added proper subclass concept; improved class target
haftmann
parents: 24871
diff changeset
   454
95cda5dd58d5 added proper subclass concept; improved class target
haftmann
parents: 24871
diff changeset
   455
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   456
  Outer_Syntax.command @{command_keyword instantiation} "instantiate and prove type arity"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   457
   (Parse.multi_arity --| Parse.begin
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   458
     >> (fn arities => Toplevel.begin_local_theory true (Class.instantiation_cmd arities)));
24589
d3fca349736c clarified class interfaces and internals
haftmann
parents: 24451
diff changeset
   459
25485
33840a854e63 tuned interfaces of class module
haftmann
parents: 25462
diff changeset
   460
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   461
  Outer_Syntax.command @{command_keyword instance} "prove type arity or subclass relation"
46922
3717f3878714 source positions for locale and class expressions;
wenzelm
parents: 45837
diff changeset
   462
  ((Parse.class --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   463
    ((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd ||
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   464
    Parse.multi_arity >> Class.instance_arity_cmd) >> Toplevel.theory_to_proof ||
59923
b21c82422d65 support private scope for individual local theory commands;
wenzelm
parents: 59917
diff changeset
   465
    Scan.succeed (Toplevel.local_theory_to_proof NONE NONE (Class.instantiation_instance I)));
22299
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   466
a1293efe7ea5 moved commands of class package here
haftmann
parents: 22239
diff changeset
   467
25519
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   468
(* arbitrary overloading *)
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   469
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   470
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   471
  Outer_Syntax.command @{command_keyword overloading} "overloaded definitions"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   472
   (Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term --
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   473
      Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   474
      >> Parse.triple1) --| Parse.begin
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   475
   >> (fn operations => Toplevel.begin_local_theory true (Overloading.overloading_cmd operations)));
25519
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   476
8570745cb40b overloading target
haftmann
parents: 25502
diff changeset
   477
22866
wenzelm
parents: 22796
diff changeset
   478
(* code generation *)
wenzelm
parents: 22796
diff changeset
   479
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   480
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   481
  Outer_Syntax.command @{command_keyword code_datatype}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   482
    "define set of code datatype constructors"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   483
    (Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd));
22866
wenzelm
parents: 22796
diff changeset
   484
wenzelm
parents: 22796
diff changeset
   485
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   486
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   487
(** proof commands **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   488
60414
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   489
val _ =
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   490
  Outer_Syntax.local_theory_to_proof @{command_keyword notepad} "begin proof context"
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   491
    (Parse.begin >> K Proof.begin_notepad);
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   492
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   493
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   494
(* statements *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   495
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   496
fun theorem spec schematic descr =
48645
33f00ce23e63 more antiquotations;
wenzelm
parents: 48643
diff changeset
   497
  Outer_Syntax.local_theory_to_proof' spec
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   498
    ("state " ^ descr)
36952
338c3f8229e4 renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents: 36951
diff changeset
   499
    (Scan.optional (Parse_Spec.opt_thm_name ":" --|
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   500
      Scan.ahead (Parse_Spec.includes >> K "" ||
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   501
        Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding --
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   502
      Scan.optional Parse_Spec.includes [] --
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   503
      Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) =>
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36178
diff changeset
   504
        ((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd)
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   505
          Thm.theoremK NONE (K I) a includes elems concl)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   506
61336
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   507
val _ = theorem @{command_keyword theorem} false "theorem";
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   508
val _ = theorem @{command_keyword lemma} false "lemma";
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   509
val _ = theorem @{command_keyword corollary} false "corollary";
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   510
val _ = theorem @{command_keyword schematic_theorem} true "schematic goal";
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   511
val _ = theorem @{command_keyword schematic_lemma} true "schematic goal";
fa4ebbd350ae just one theorem kind, which is legacy anyway;
wenzelm
parents: 61266
diff changeset
   512
val _ = theorem @{command_keyword schematic_corollary} true "schematic goal";
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   513
60414
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   514
f25f2f2ba48c support for "if prems" in local goal statements;
wenzelm
parents: 60406
diff changeset
   515
val structured_statement =
60555
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   516
  Parse_Spec.statement -- Parse_Spec.cond_statement -- Parse.for_fixes
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   517
    >> (fn ((shows, (strict, assumes)), fixes) => (strict, fixes, assumes, shows));
40960
9e54eb514a46 formal notepad without any result;
wenzelm
parents: 40784
diff changeset
   518
9e54eb514a46 formal notepad without any result;
wenzelm
parents: 40784
diff changeset
   519
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   520
  Outer_Syntax.command @{command_keyword have} "state local goal"
60555
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   521
    (structured_statement >> (fn (a, b, c, d) =>
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   522
      Toplevel.proof' (fn int => Proof.have_cmd a NONE (K I) b c d int #> #2)));
60406
12cc54fac9b0 allow for_fixes for 'have', 'show' etc.;
wenzelm
parents: 60378
diff changeset
   523
12cc54fac9b0 allow for_fixes for 'have', 'show' etc.;
wenzelm
parents: 60378
diff changeset
   524
val _ =
12cc54fac9b0 allow for_fixes for 'have', 'show' etc.;
wenzelm
parents: 60378
diff changeset
   525
  Outer_Syntax.command @{command_keyword show} "state local goal, to refine pending subgoals"
60555
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   526
    (structured_statement >> (fn (a, b, c, d) =>
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   527
      Toplevel.proof' (fn int => Proof.show_cmd a NONE (K I) b c d int #> #2)));
17353
cd440b6812b1 cleanup parsers and interfaces;
wenzelm
parents: 17264
diff changeset
   528
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   529
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   530
  Outer_Syntax.command @{command_keyword hence} "old-style alias of \"then have\""
60555
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   531
    (structured_statement >> (fn (a, b, c, d) =>
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   532
      Toplevel.proof' (fn int => Proof.chain #> Proof.have_cmd a NONE (K I) b c d int #> #2)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   533
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   534
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   535
  Outer_Syntax.command @{command_keyword thus} "old-style alias of  \"then show\""
60555
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   536
    (structured_statement >> (fn (a, b, c, d) =>
51a6997b1384 support 'when' statement, which corresponds to 'presume';
wenzelm
parents: 60461
diff changeset
   537
      Toplevel.proof' (fn int => Proof.chain #> Proof.show_cmd a NONE (K I) b c d int #> #2)));
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
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   542
val facts = Parse.and_list1 Parse.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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   545
  Outer_Syntax.command @{command_keyword then} "forward chaining"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   546
    (Scan.succeed (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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   549
  Outer_Syntax.command @{command_keyword from} "forward chaining from given facts"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   550
    (facts >> (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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   553
  Outer_Syntax.command @{command_keyword with} "forward chaining from given and current facts"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   554
    (facts >> (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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   557
  Outer_Syntax.command @{command_keyword note} "define facts"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   558
    (Parse_Spec.name_facts >> (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 _ =
60371
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   561
  Outer_Syntax.command @{command_keyword supply} "define facts during goal refinement (unstructured)"
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   562
    (Parse_Spec.name_facts >> (Toplevel.proof o Proof.supply_cmd));
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   563
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   564
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   565
  Outer_Syntax.command @{command_keyword using} "augment goal facts"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   566
    (facts >> (Toplevel.proof o Proof.using_cmd));
18544
cbad888756b2 added 'using' command;
wenzelm
parents: 18308
diff changeset
   567
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   568
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   569
  Outer_Syntax.command @{command_keyword unfolding} "unfold definitions in goal and facts"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   570
    (facts >> (Toplevel.proof o Proof.unfolding_cmd));
12926
cd0dd6e0bf5c 'using' command;
wenzelm
parents: 12876
diff changeset
   571
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   572
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   573
(* proof context *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   574
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   575
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   576
  Outer_Syntax.command @{command_keyword fix} "fix local variables (Skolem constants)"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   577
    (Parse.fixes >> (Toplevel.proof o Proof.fix_cmd));
11890
28e42a90bea8 improved source arrangement of obtain;
wenzelm
parents: 11793
diff changeset
   578
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   579
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   580
  Outer_Syntax.command @{command_keyword assume} "assume propositions"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   581
    (Parse_Spec.statement >> (Toplevel.proof o Proof.assume_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   582
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   583
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   584
  Outer_Syntax.command @{command_keyword presume} "assume propositions, to be established later"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   585
    (Parse_Spec.statement >> (Toplevel.proof o Proof.presume_cmd));
6850
da8a4660fb0c added presume command;
wenzelm
parents: 6773
diff changeset
   586
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   587
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   588
  Outer_Syntax.command @{command_keyword def} "local definition (non-polymorphic)"
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   589
    (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
   590
      (Parse_Spec.opt_thm_name ":" --
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   591
        ((Parse.binding -- Parse.opt_mixfix) --
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   592
          ((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp)))
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   593
    >> (Toplevel.proof o Proof.def_cmd));
6953
b3f6c39aaa2e added 'def';
wenzelm
parents: 6936
diff changeset
   594
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   595
val _ =
60448
78f3c67bc35e support for 'consider' command;
wenzelm
parents: 60414
diff changeset
   596
  Outer_Syntax.command @{command_keyword consider} "state cases rule"
78f3c67bc35e support for 'consider' command;
wenzelm
parents: 60414
diff changeset
   597
    (Parse_Spec.obtains >> (Toplevel.proof' o Obtain.consider_cmd));
78f3c67bc35e support for 'consider' command;
wenzelm
parents: 60414
diff changeset
   598
78f3c67bc35e support for 'consider' command;
wenzelm
parents: 60414
diff changeset
   599
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   600
  Outer_Syntax.command @{command_keyword obtain} "generalized elimination"
60453
ba9085f7433f clarified 'obtain', using structured 'have' statement;
wenzelm
parents: 60449
diff changeset
   601
    (Parse.parbinding -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   602
      >> (fn ((x, y), z) => Toplevel.proof' (Obtain.obtain_cmd x y z)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   603
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   604
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   605
  Outer_Syntax.command @{command_keyword guess} "wild guessing (unstructured)"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   606
    (Scan.optional Parse.fixes [] >> (Toplevel.proof' o Obtain.guess_cmd));
17854
44b6dde80bf4 added 'guess';
wenzelm
parents: 17512
diff changeset
   607
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   608
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   609
  Outer_Syntax.command @{command_keyword let} "bind text variables"
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   610
    (Parse.and_list1 (Parse.and_list1 Parse.term -- (@{keyword "="} |-- Parse.term))
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   611
      >> (Toplevel.proof o Proof.let_bind_cmd));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   612
36505
79c1d2bbe5a9 ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents: 36452
diff changeset
   613
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   614
  Outer_Syntax.command @{command_keyword write} "add concrete syntax for constants / fixed variables"
51654
8450b944e58a just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents: 51627
diff changeset
   615
    (opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix)
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   616
    >> (fn (mode, args) => Toplevel.proof (Proof.write_cmd mode args)));
36505
79c1d2bbe5a9 ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents: 36452
diff changeset
   617
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   618
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   619
  Outer_Syntax.command @{command_keyword case} "invoke local context"
60565
b7ee41f72add clarified 'case' command;
wenzelm
parents: 60555
diff changeset
   620
    (Parse_Spec.opt_thm_name ":" --
b7ee41f72add clarified 'case' command;
wenzelm
parents: 60555
diff changeset
   621
      (@{keyword "("} |--
b7ee41f72add clarified 'case' command;
wenzelm
parents: 60555
diff changeset
   622
        Parse.!!! (Parse.position Parse.xname -- Scan.repeat (Parse.maybe Parse.binding)
b7ee41f72add clarified 'case' command;
wenzelm
parents: 60555
diff changeset
   623
          --| @{keyword ")"}) ||
b7ee41f72add clarified 'case' command;
wenzelm
parents: 60555
diff changeset
   624
        Parse.position Parse.xname >> rpair []) >> (Toplevel.proof o Proof.case_cmd));
8370
6b45749d37d6 added 'case' command;
wenzelm
parents: 8349
diff changeset
   625
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   626
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   627
(* proof structure *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   628
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   629
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   630
  Outer_Syntax.command @{command_keyword "{"} "begin explicit proof block"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   631
    (Scan.succeed (Toplevel.proof Proof.begin_block));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   632
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   633
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   634
  Outer_Syntax.command @{command_keyword "}"} "end explicit proof block"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   635
    (Scan.succeed (Toplevel.proof Proof.end_block));
6687
134df1440f6e renamed 'begin' / 'end' to '{{' / '}}';
wenzelm
parents: 6551
diff changeset
   636
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   637
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   638
  Outer_Syntax.command @{command_keyword next} "enter next proof block"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   639
    (Scan.succeed (Toplevel.proof Proof.next_block));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   640
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   641
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   642
(* end proof *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   643
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   644
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   645
  Outer_Syntax.command @{command_keyword qed} "conclude proof"
56869
6e26ae897bad uniform Toplevel.print for all proof commands;
wenzelm
parents: 56868
diff changeset
   646
    (Scan.option Method.parse >> (fn m =>
6e26ae897bad uniform Toplevel.print for all proof commands;
wenzelm
parents: 56868
diff changeset
   647
     (Option.map Method.report m;
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   648
      Isar_Cmd.qed m)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   649
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   650
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   651
  Outer_Syntax.command @{command_keyword by} "terminal backward proof"
55795
2d4cf0005a02 more explicit method reports;
wenzelm
parents: 55761
diff changeset
   652
    (Method.parse -- Scan.option Method.parse >> (fn (m1, m2) =>
56869
6e26ae897bad uniform Toplevel.print for all proof commands;
wenzelm
parents: 56868
diff changeset
   653
     (Method.report m1;
6e26ae897bad uniform Toplevel.print for all proof commands;
wenzelm
parents: 56868
diff changeset
   654
      Option.map Method.report m2;
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   655
      Isar_Cmd.terminal_proof (m1, m2))));
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   656
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   657
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   658
  Outer_Syntax.command @{command_keyword ".."} "default proof"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   659
    (Scan.succeed Isar_Cmd.default_proof);
8966
916966f68907 added "done" proof;
wenzelm
parents: 8896
diff changeset
   660
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   661
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   662
  Outer_Syntax.command @{command_keyword "."} "immediate proof"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   663
    (Scan.succeed Isar_Cmd.immediate_proof);
6404
2daaf2943c79 common qed and end of proofs;
wenzelm
parents: 6370
diff changeset
   664
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   665
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   666
  Outer_Syntax.command @{command_keyword done} "done proof"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   667
    (Scan.succeed Isar_Cmd.done_proof);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   668
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   669
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   670
  Outer_Syntax.command @{command_keyword sorry} "skip proof (quick-and-dirty mode only!)"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   671
    (Scan.succeed Isar_Cmd.skip_proof);
6888
d0c68ebdabc5 skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents: 6886
diff changeset
   672
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   673
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   674
  Outer_Syntax.command @{command_keyword oops} "forget proof"
58798
49ed5eea15d4 'oops' requires proper goal statement -- exclude 'notepad' to avoid disrupting begin/end structure;
wenzelm
parents: 58201
diff changeset
   675
    (Scan.succeed (Toplevel.forget_proof true));
8210
ca3997312f47 added forget_proof;
wenzelm
parents: 8165
diff changeset
   676
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   677
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   678
(* proof steps *)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   679
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   680
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   681
  Outer_Syntax.command @{command_keyword defer} "shuffle internal proof state"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   682
    (Scan.optional Parse.nat 1 >> (Toplevel.proof o Proof.defer));
8165
651b006d7eb8 added defer, prefer;
wenzelm
parents: 8097
diff changeset
   683
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   684
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   685
  Outer_Syntax.command @{command_keyword prefer} "shuffle internal proof state"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   686
    (Parse.nat >> (Toplevel.proof o Proof.prefer));
8165
651b006d7eb8 added defer, prefer;
wenzelm
parents: 8097
diff changeset
   687
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   688
val _ =
60371
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   689
  Outer_Syntax.command @{command_keyword apply} "initial goal refinement step (unstructured)"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   690
    (Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_results m))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   691
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   692
val _ =
60371
8a5cfdda1b98 added Isar command 'supply';
wenzelm
parents: 60273
diff changeset
   693
  Outer_Syntax.command @{command_keyword apply_end} "terminal goal refinement step (unstructured)"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   694
    (Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_end_results m))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   695
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   696
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   697
  Outer_Syntax.command @{command_keyword proof} "backward proof step"
55795
2d4cf0005a02 more explicit method reports;
wenzelm
parents: 55761
diff changeset
   698
    (Scan.option Method.parse >> (fn m =>
60693
044f8bb3dd30 more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents: 60629
diff changeset
   699
      (Option.map Method.report m; Toplevel.proofs (Proof.proof_results m))));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   700
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   701
60623
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   702
(* subgoal focus *)
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   703
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   704
local
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   705
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   706
val opt_fact_binding =
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   707
  Scan.optional (Parse.binding -- Parse.opt_attribs || Parse.attribs >> pair Binding.empty)
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   708
    Attrib.empty_binding;
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   709
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   710
val for_params =
60629
d4e97fcdf83e allow to specify suffix of goal parameters;
wenzelm
parents: 60628
diff changeset
   711
  Scan.optional
d4e97fcdf83e allow to specify suffix of goal parameters;
wenzelm
parents: 60628
diff changeset
   712
    (@{keyword "for"} |--
d4e97fcdf83e allow to specify suffix of goal parameters;
wenzelm
parents: 60628
diff changeset
   713
      Parse.!!! ((Scan.option Parse.dots >> is_some) --
d4e97fcdf83e allow to specify suffix of goal parameters;
wenzelm
parents: 60628
diff changeset
   714
        (Scan.repeat1 (Parse.position (Parse.maybe Parse.name)))))
d4e97fcdf83e allow to specify suffix of goal parameters;
wenzelm
parents: 60628
diff changeset
   715
    (false, []);
60623
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   716
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   717
in
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   718
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   719
val _ =
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   720
  Outer_Syntax.command @{command_keyword subgoal}
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   721
    "focus on first subgoal within backward refinement"
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   722
    (opt_fact_binding -- (Scan.option (@{keyword "premises"} |-- Parse.!!! opt_fact_binding)) --
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   723
      for_params >> (fn ((a, b), c) =>
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   724
        Toplevel.proofs (Seq.make_results o Seq.single o #2 o Subgoal.subgoal_cmd a b c)));
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   725
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   726
end;
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   727
be39fe6c5620 support for subgoal focus command;
wenzelm
parents: 60565
diff changeset
   728
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6735
diff changeset
   729
(* proof navigation *)
5944
dcc446da8e19 added undos, redos;
wenzelm
parents: 5937
diff changeset
   730
56065
600781e03bf6 more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents: 56006
diff changeset
   731
fun report_back () =
56333
38f1422ef473 support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
wenzelm
parents: 56304
diff changeset
   732
  Output.report [Markup.markup Markup.bad "Explicit backtracking"];
56065
600781e03bf6 more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents: 56006
diff changeset
   733
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   734
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   735
  Outer_Syntax.command @{command_keyword back} "explicit backtracking of proof command"
56895
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   736
    (Scan.succeed
f058120aaad4 discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents: 56893
diff changeset
   737
     (Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o
60693
044f8bb3dd30 more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents: 60629
diff changeset
   738
      Toplevel.skip_proof report_back));
6742
6b5cb872d997 improved undo / kill operations;
wenzelm
parents: 6735
diff changeset
   739
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22573
diff changeset
   740
56869
6e26ae897bad uniform Toplevel.print for all proof commands;
wenzelm
parents: 56868
diff changeset
   741
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   742
(** diagnostic commands (for interactive mode only) **)
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   743
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   744
val opt_modes =
48643
9b9b36a89e56 more antiquotations;
wenzelm
parents: 48642
diff changeset
   745
  Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) [];
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36865
diff changeset
   746
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   747
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   748
  Outer_Syntax.command @{command_keyword help}
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 49868
diff changeset
   749
    "retrieve outer syntax commands according to name patterns"
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   750
    (Scan.repeat Parse.name >>
58930
13d3eb07a17a tuned signature;
wenzelm
parents: 58928
diff changeset
   751
      (fn pats => Toplevel.keep (fn st => Outer_Syntax.help (Toplevel.theory_of st) pats)));
21714
d64cb19c79e2 added 'help' command (same of 'print_commands');
wenzelm
parents: 21705
diff changeset
   752
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   753
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   754
  Outer_Syntax.command @{command_keyword print_commands} "print outer syntax commands"
58930
13d3eb07a17a tuned signature;
wenzelm
parents: 58928
diff changeset
   755
    (Scan.succeed (Toplevel.keep (Outer_Syntax.print_commands o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   756
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   757
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   758
  Outer_Syntax.command @{command_keyword print_options} "print configuration options"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   759
    (Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_options b o Toplevel.context_of)));
23989
d7df8545f9f6 added command 'print_options';
wenzelm
parents: 23865
diff changeset
   760
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   761
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   762
  Outer_Syntax.command @{command_keyword print_context}
56893
wenzelm
parents: 56887
diff changeset
   763
    "print context of local theory target"
wenzelm
parents: 56887
diff changeset
   764
    (Scan.succeed (Toplevel.keep (Pretty.writeln_chunks o Toplevel.pretty_context)));
7308
e01aab03a2a1 print_context;
wenzelm
parents: 7269
diff changeset
   765
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   766
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   767
  Outer_Syntax.command @{command_keyword print_theory}
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   768
    "print logical theory contents"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   769
    (Parse.opt_bang >> (fn b =>
61266
eb9522a9d997 proper context;
wenzelm
parents: 61259
diff changeset
   770
      Toplevel.keep (Pretty.writeln o Proof_Display.pretty_theory b o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   771
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   772
val _ =
61252
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   773
  Outer_Syntax.command @{command_keyword print_definitions}
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   774
    "print dependencies of definitional theory content"
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   775
    (Parse.opt_bang >> (fn b =>
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   776
      Toplevel.keep (Pretty.writeln o Proof_Display.pretty_definitions b o Toplevel.context_of)));
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   777
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 61246
diff changeset
   778
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   779
  Outer_Syntax.command @{command_keyword print_syntax}
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   780
    "print inner syntax of context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   781
    (Scan.succeed (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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   784
  Outer_Syntax.command @{command_keyword print_defn_rules}
51585
fcd5af4aac2b added 'print_defn_rules' command;
wenzelm
parents: 51313
diff changeset
   785
    "print definitional rewrite rules of context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   786
    (Scan.succeed (Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of)));
51585
fcd5af4aac2b added 'print_defn_rules' command;
wenzelm
parents: 51313
diff changeset
   787
fcd5af4aac2b added 'print_defn_rules' command;
wenzelm
parents: 51313
diff changeset
   788
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   789
  Outer_Syntax.command @{command_keyword print_abbrevs}
51585
fcd5af4aac2b added 'print_defn_rules' command;
wenzelm
parents: 51313
diff changeset
   790
    "print constant abbreviations of context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   791
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   792
      Toplevel.keep (Proof_Context.print_abbrevs b o Toplevel.context_of)));
21726
092b967da9b7 added 'print_abbrevs';
wenzelm
parents: 21714
diff changeset
   793
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   794
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   795
  Outer_Syntax.command @{command_keyword print_theorems}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   796
    "print theorems of local theory or proof context"
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   797
    (Parse.opt_bang >> (fn b =>
57605
8e0a7eaffe47 tuned messages;
wenzelm
parents: 57483
diff changeset
   798
      Toplevel.keep (Pretty.writeln o Pretty.chunks o Isar_Cmd.pretty_theorems b)));
5881
2bded7137593 add print_theorems;
wenzelm
parents: 5832
diff changeset
   799
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   800
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   801
  Outer_Syntax.command @{command_keyword print_locales}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   802
    "print locales of this theory"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   803
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   804
      Toplevel.keep (Locale.print_locales b o Toplevel.theory_of)));
12061
1b77d46d0fd1 added 'locale', 'print_locales', 'print_locale';
wenzelm
parents: 12044
diff changeset
   805
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   806
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   807
  Outer_Syntax.command @{command_keyword print_classes}
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   808
    "print classes of this theory"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   809
    (Scan.succeed (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
   810
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   811
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   812
  Outer_Syntax.command @{command_keyword print_locale}
48642
1737bdb896bb more antiquotations;
wenzelm
parents: 48641
diff changeset
   813
    "print locale of this theory"
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   814
    (Parse.opt_bang -- Parse.position Parse.xname >> (fn (b, name) =>
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   815
      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
   816
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   817
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   818
  Outer_Syntax.command @{command_keyword print_interps}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   819
    "print interpretations of locale for this theory or proof context"
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   820
    (Parse.position Parse.xname >> (fn name =>
50737
f310d1735d93 tuned -- less indirection;
wenzelm
parents: 50214
diff changeset
   821
      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
   822
ca430e6aee1c Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents: 31869
diff changeset
   823
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   824
  Outer_Syntax.command @{command_keyword print_dependencies}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   825
    "print dependencies of locale expression"
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   826
    (Parse.opt_bang -- Parse_Spec.locale_expression true >> (fn (b, expr) =>
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   827
      Toplevel.keep (fn state => Expression.print_dependencies (Toplevel.context_of state) b expr)));
41435
12585dfb86fe Diagnostic command to show locale dependencies.
ballarin
parents: 41270
diff changeset
   828
12585dfb86fe Diagnostic command to show locale dependencies.
ballarin
parents: 41270
diff changeset
   829
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   830
  Outer_Syntax.command @{command_keyword print_attributes}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   831
    "print attributes of this theory"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   832
    (Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_attributes b o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   833
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   834
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   835
  Outer_Syntax.command @{command_keyword print_simpset}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   836
    "print context of Simplifier"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   837
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   838
      Toplevel.keep (Pretty.writeln o Simplifier.pretty_simpset b o Toplevel.context_of)));
16027
77c1171090d9 added 'print_simpset';
wenzelm
parents: 15979
diff changeset
   839
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   840
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   841
  Outer_Syntax.command @{command_keyword print_rules} "print intro/elim rules"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   842
    (Scan.succeed (Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of)));
12383
af14fd56b189 added 'print_rules' command;
wenzelm
parents: 12288
diff changeset
   843
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   844
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   845
  Outer_Syntax.command @{command_keyword print_methods} "print methods of this theory"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   846
    (Parse.opt_bang >> (fn b => Toplevel.keep (Method.print_methods b o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   847
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   848
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   849
  Outer_Syntax.command @{command_keyword print_antiquotations}
56069
451d5b73f8cf simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents: 56065
diff changeset
   850
    "print document antiquotations"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   851
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   852
      Toplevel.keep (Thy_Output.print_antiquotations b o Toplevel.context_of)));
9221
e1fd1003d5f9 removed "help";
wenzelm
parents: 9197
diff changeset
   853
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   854
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   855
  Outer_Syntax.command @{command_keyword print_ML_antiquotations}
56069
451d5b73f8cf simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents: 56065
diff changeset
   856
    "print ML antiquotations"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   857
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   858
      Toplevel.keep (ML_Context.print_antiquotations b o Toplevel.context_of)));
56069
451d5b73f8cf simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents: 56065
diff changeset
   859
451d5b73f8cf simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents: 56065
diff changeset
   860
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   861
  Outer_Syntax.command @{command_keyword locale_deps} "visualize locale dependencies"
60098
wenzelm
parents: 60097
diff changeset
   862
    (Scan.succeed
wenzelm
parents: 60097
diff changeset
   863
      (Toplevel.keep (Toplevel.theory_of #> (fn thy =>
wenzelm
parents: 60097
diff changeset
   864
        Locale.pretty_locale_deps thy
wenzelm
parents: 60097
diff changeset
   865
        |> map (fn {name, parents, body} =>
wenzelm
parents: 60097
diff changeset
   866
          ((name, Graph_Display.content_node (Locale.extern thy name) [body]), parents))
60273
83de10e27007 use display_graph_old for locale_deps, to show a bit more than nothing for cyclic graphs;
wenzelm
parents: 60189
diff changeset
   867
        |> Graph_Display.display_graph_old))));
49569
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 _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   870
  Outer_Syntax.command @{command_keyword print_term_bindings}
57415
e721124f1b1e command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents: 57181
diff changeset
   871
    "print term bindings of proof context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   872
    (Scan.succeed
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   873
      (Toplevel.keep
57415
e721124f1b1e command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents: 57181
diff changeset
   874
        (Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   875
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   876
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   877
  Outer_Syntax.command @{command_keyword print_facts} "print facts of proof context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   878
    (Parse.opt_bang >> (fn b =>
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59901
diff changeset
   879
      Toplevel.keep (Proof_Context.print_local_facts b o Toplevel.context_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   880
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   881
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   882
  Outer_Syntax.command @{command_keyword print_cases} "print cases of proof context"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   883
    (Scan.succeed
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   884
      (Toplevel.keep (Pretty.writeln_chunks o Proof_Context.pretty_cases o Toplevel.context_of)));
8370
6b45749d37d6 added 'case' command;
wenzelm
parents: 8349
diff changeset
   885
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   886
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   887
  Outer_Syntax.command @{command_keyword print_statement}
46961
5c6955f487e5 outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents: 46958
diff changeset
   888
    "print theorems as long statements"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   889
    (opt_modes -- Parse.xthms1 >> Isar_Cmd.print_stmts);
19269
620616bc7632 added 'print_statement' command;
wenzelm
parents: 19260
diff changeset
   890
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   891
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   892
  Outer_Syntax.command @{command_keyword thm} "print theorems"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   893
    (opt_modes -- Parse.xthms1 >> Isar_Cmd.print_thms);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   894
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   895
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   896
  Outer_Syntax.command @{command_keyword prf} "print proof terms of theorems"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   897
    (opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs false);
11524
197f2e14a714 Added functions for printing primitive proof terms.
berghofe
parents: 11101
diff changeset
   898
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   899
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   900
  Outer_Syntax.command @{command_keyword full_prf} "print full proof terms of theorems"
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 57941
diff changeset
   901
    (opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs true);
11524
197f2e14a714 Added functions for printing primitive proof terms.
berghofe
parents: 11101
diff changeset
   902
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   903
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   904
  Outer_Syntax.command @{command_keyword prop} "read and print proposition"
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   905
    (opt_modes -- Parse.term >> Isar_Cmd.print_prop);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   906
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   907
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   908
  Outer_Syntax.command @{command_keyword term} "read and print term"
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   909
    (opt_modes -- Parse.term >> Isar_Cmd.print_term);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   910
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   911
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   912
  Outer_Syntax.command @{command_keyword typ} "read and print type"
48792
4aa5b965f70e support for 'typ' with explicit sort constraint;
wenzelm
parents: 48646
diff changeset
   913
    (opt_modes -- (Parse.typ -- Scan.option (@{keyword "::"} |-- Parse.!!! Parse.sort))
51658
21c10672633b discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents: 51654
diff changeset
   914
      >> Isar_Cmd.print_type);
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   915
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   916
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   917
  Outer_Syntax.command @{command_keyword print_codesetup} "print code generator setup"
60097
d20ca79d50e4 discontinued pointless warnings: commands are only defined inside a theory context;
wenzelm
parents: 60093
diff changeset
   918
    (Scan.succeed (Toplevel.keep (Code.print_codesetup o Toplevel.theory_of)));
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   919
52430
289e36c2870a proper diagnostic command 'print_state';
wenzelm
parents: 52143
diff changeset
   920
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   921
  Outer_Syntax.command @{command_keyword print_state}
52430
289e36c2870a proper diagnostic command 'print_state';
wenzelm
parents: 52143
diff changeset
   922
    "print current proof state (if present)"
61208
19118f9b939d separate panel for proof state output;
wenzelm
parents: 60957
diff changeset
   923
    (opt_modes >> (fn modes =>
19118f9b939d separate panel for proof state output;
wenzelm
parents: 60957
diff changeset
   924
      Toplevel.keep (Print_Mode.with_modes modes (Output.state o Toplevel.string_of_state))));
52430
289e36c2870a proper diagnostic command 'print_state';
wenzelm
parents: 52143
diff changeset
   925
24868
2990c327d8c6 simplified interfaces for outer syntax;
wenzelm
parents: 24830
diff changeset
   926
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   927
  Outer_Syntax.command @{command_keyword welcome} "print welcome message"
60189
0d3a62127057 tuned signature;
wenzelm
parents: 60098
diff changeset
   928
    (Scan.succeed (Toplevel.keep (fn _ => writeln (Session.welcome ()))));
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   929
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   930
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   931
  Outer_Syntax.command @{command_keyword display_drafts}
58846
98c03412079b discontinued Isar TTY loop;
wenzelm
parents: 58845
diff changeset
   932
    "display raw source files with symbols"
98c03412079b discontinued Isar TTY loop;
wenzelm
parents: 58845
diff changeset
   933
    (Scan.repeat1 Parse.path >> (fn names =>
60189
0d3a62127057 tuned signature;
wenzelm
parents: 60098
diff changeset
   934
      Toplevel.keep (fn _ => ignore (Present.display_drafts (map Path.explode names)))));
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   935
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   936
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   937
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   938
(** extraction of programs from proofs **)
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   939
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   940
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") [];
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   941
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   942
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   943
  Outer_Syntax.command @{command_keyword realizers}
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   944
    "specify realizers for primitive axioms / theorems, together with correctness proof"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   945
    (Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >>
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   946
     (fn xs => Toplevel.theory (fn thy => Extraction.add_realizers
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   947
       (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
   948
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   949
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   950
  Outer_Syntax.command @{command_keyword realizability}
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   951
    "add equations characterizing realizability"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   952
    (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   953
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   954
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   955
  Outer_Syntax.command @{command_keyword extract_type}
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   956
    "add equations characterizing type of extracted program"
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   957
    (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   958
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   959
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   960
  Outer_Syntax.command @{command_keyword extract} "extract terms from proofs"
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   961
    (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
   962
      Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy)));
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 48645
diff changeset
   963
48641
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   964
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   965
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   966
(** end **)
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   967
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   968
val _ =
59936
b8ffc3dc9e24 @{command_spec} is superseded by @{command_keyword};
wenzelm
parents: 59935
diff changeset
   969
  Outer_Syntax.command @{command_keyword end} "end context"
48641
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   970
    (Scan.succeed
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   971
      (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
   972
        Toplevel.end_proof (K Proof.end_notepad)));
92b48b8abfe4 more standard bootstrapping of Pure outer syntax;
wenzelm
parents: 47416
diff changeset
   973
5832
112a67aa9c2c Pure outer syntax.
wenzelm
parents:
diff changeset
   974
end;