author | wenzelm |
Mon, 14 Nov 2011 16:52:19 +0100 | |
changeset 45488 | 6d71d9e52369 |
parent 45134 | 9b02f6665fc8 |
child 45600 | 1bbbac9a0cb0 |
permissions | -rw-r--r-- |
5832 | 1 |
(* Title: Pure/Isar/isar_syn.ML |
2 |
Author: Markus Wenzel, TU Muenchen |
|
3 |
||
6353 | 4 |
Isar/Pure outer syntax. |
5832 | 5 |
*) |
6 |
||
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
7 |
structure Isar_Syn: sig end = |
5832 | 8 |
struct |
9 |
||
24868 | 10 |
(** keywords **) |
11 |
||
12 |
(*keep keywords consistent with the parsers, otherwise be prepared for |
|
13 |
unexpected errors*) |
|
14 |
||
36950 | 15 |
val _ = List.app Keyword.keyword |
24868 | 16 |
["!!", "!", "%", "(", ")", "+", ",", "--", ":", "::", ";", "<", "<=", |
17 |
"=", "==", "=>", "?", "[", "\\<equiv>", "\\<leftharpoondown>", |
|
18 |
"\\<rightharpoonup>", "\\<rightleftharpoons>", "\\<subseteq>", "]", |
|
26888 | 19 |
"advanced", "and", "assumes", "attach", "begin", "binder", |
24868 | 20 |
"constrains", "defines", "fixes", "for", "identifier", "if", |
28721 | 21 |
"imports", "in", "infix", "infixl", "infixr", "is", |
33456
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
22 |
"notes", "obtains", "open", "output", "overloaded", "pervasive", |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
23 |
"shows", "structure", "unchecked", "uses", "where", "|"]; |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
24 |
|
24868 | 25 |
|
26 |
||
5832 | 27 |
(** init and exit **) |
28 |
||
24868 | 29 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
30 |
Outer_Syntax.command "theory" "begin theory" (Keyword.tag_theory Keyword.thy_begin) |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
31 |
(Thy_Header.args >> (fn (name, imports, uses) => |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
32 |
Toplevel.print o |
44187
88d770052bac
simplified Toplevel.init_theory: discontinued special name argument;
wenzelm
parents:
44186
diff
changeset
|
33 |
Toplevel.init_theory |
44186
806f0ec1a43d
simplified Toplevel.init_theory: discontinued special master argument;
wenzelm
parents:
43947
diff
changeset
|
34 |
(fn () => |
806f0ec1a43d
simplified Toplevel.init_theory: discontinued special master argument;
wenzelm
parents:
43947
diff
changeset
|
35 |
Thy_Info.toplevel_begin_theory (Thy_Load.get_master_path ()) |
806f0ec1a43d
simplified Toplevel.init_theory: discontinued special master argument;
wenzelm
parents:
43947
diff
changeset
|
36 |
name imports (map (apfst Path.explode) uses)))); |
5832 | 37 |
|
24868 | 38 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
39 |
Outer_Syntax.command "end" "end (local) theory" (Keyword.tag_theory Keyword.thy_end) |
40960 | 40 |
(Scan.succeed |
41 |
(Toplevel.exit o Toplevel.end_local_theory o Toplevel.end_proof (K Proof.end_notepad))); |
|
6687 | 42 |
|
5832 | 43 |
|
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
|
44 |
|
7749 | 45 |
(** markup commands **) |
5832 | 46 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
47 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "header" "theory header" Keyword.diag |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
48 |
(Parse.doc_source >> Isar_Cmd.header_markup); |
6353 | 49 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
50 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "chapter" "chapter heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
51 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 52 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
53 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "section" "section heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
54 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 55 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
56 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsection" "subsection heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
57 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 58 |
|
24868 | 59 |
val _ = |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
60 |
Outer_Syntax.markup_command Thy_Output.Markup "subsubsection" "subsubsection heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
61 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5832 | 62 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
63 |
val _ = Outer_Syntax.markup_command Thy_Output.MarkupEnv "text" "formal comment (theory)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
64 |
Keyword.thy_decl (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 65 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
66 |
val _ = Outer_Syntax.markup_command Thy_Output.Verbatim "text_raw" "raw document preparation text" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
67 |
Keyword.thy_decl (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 68 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
69 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "sect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
70 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 71 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
72 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
73 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 74 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
75 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsubsect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
76 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 77 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
78 |
val _ = Outer_Syntax.markup_command Thy_Output.MarkupEnv "txt" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
79 |
(Keyword.tag_proof Keyword.prf_decl) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 80 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
81 |
val _ = Outer_Syntax.markup_command Thy_Output.Verbatim "txt_raw" |
36950 | 82 |
"raw document preparation text (proof)" (Keyword.tag_proof Keyword.prf_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
83 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7775 | 84 |
|
5832 | 85 |
|
6886 | 86 |
|
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
|
87 |
(** theory commands **) |
6886 | 88 |
|
5832 | 89 |
(* classes and sorts *) |
90 |
||
24868 | 91 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
92 |
Outer_Syntax.command "classes" "declare type classes" Keyword.thy_decl |
36950 | 93 |
(Scan.repeat1 (Parse.binding -- Scan.optional ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |-- |
94 |
Parse.!!! (Parse.list1 Parse.xname)) []) |
|
95 |
>> (Toplevel.theory o fold AxClass.axiomatize_class_cmd)); |
|
5832 | 96 |
|
24868 | 97 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
98 |
Outer_Syntax.command "classrel" "state inclusion of type classes (axiomatic!)" Keyword.thy_decl |
36950 | 99 |
(Parse.and_list1 (Parse.xname -- ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |
100 |
|-- Parse.!!! Parse.xname)) |
|
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
101 |
>> (Toplevel.theory o AxClass.axiomatize_classrel_cmd)); |
5832 | 102 |
|
24868 | 103 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
104 |
Outer_Syntax.local_theory "default_sort" "declare default sort for explicit type variables" |
36950 | 105 |
Keyword.thy_decl |
106 |
(Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy)); |
|
5832 | 107 |
|
108 |
||
109 |
(* types *) |
|
110 |
||
24868 | 111 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
112 |
Outer_Syntax.local_theory "typedecl" "type declaration" Keyword.thy_decl |
36950 | 113 |
(Parse.type_args -- Parse.binding -- Parse.opt_mixfix |
35835 | 114 |
>> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd)); |
5832 | 115 |
|
41249
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
116 |
val type_abbrev = |
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
117 |
Parse.type_args -- Parse.binding -- |
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
118 |
(Parse.$$$ "=" |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix')); |
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
119 |
|
24868 | 120 |
val _ = |
41249
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
121 |
Outer_Syntax.local_theory "type_synonym" "declare type abbreviation" Keyword.thy_decl |
26f12f98f50a
Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature);
wenzelm
parents:
41229
diff
changeset
|
122 |
(type_abbrev >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)); |
5832 | 123 |
|
24868 | 124 |
val _ = |
41229
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40965
diff
changeset
|
125 |
Outer_Syntax.command "nonterminal" |
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40965
diff
changeset
|
126 |
"declare syntactic type constructors (grammar nonterminal symbols)" Keyword.thy_decl |
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42359
diff
changeset
|
127 |
(Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global)); |
5832 | 128 |
|
24868 | 129 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
130 |
Outer_Syntax.command "arities" "state type arities (axiomatic!)" Keyword.thy_decl |
36950 | 131 |
(Scan.repeat1 Parse.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd)); |
5832 | 132 |
|
133 |
||
134 |
(* consts and syntax *) |
|
135 |
||
24868 | 136 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
137 |
Outer_Syntax.command "judgment" "declare object-logic judgment" Keyword.thy_decl |
36950 | 138 |
(Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
8227 | 139 |
|
24868 | 140 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
141 |
Outer_Syntax.command "consts" "declare constants" Keyword.thy_decl |
36950 | 142 |
(Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts)); |
5832 | 143 |
|
36950 | 144 |
val opt_overloaded = Parse.opt_keyword "overloaded"; |
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
145 |
|
24868 | 146 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
147 |
Outer_Syntax.command "finalconsts" "declare constants as final" Keyword.thy_decl |
36950 | 148 |
(opt_overloaded -- Scan.repeat1 Parse.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); |
9731 | 149 |
|
12142 | 150 |
val mode_spec = |
36950 | 151 |
(Parse.$$$ "output" >> K ("", false)) || |
152 |
Parse.name -- Scan.optional (Parse.$$$ "output" >> K false) true; |
|
9731 | 153 |
|
14900 | 154 |
val opt_mode = |
36950 | 155 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! (mode_spec --| Parse.$$$ ")")) Syntax.mode_default; |
5832 | 156 |
|
24868 | 157 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
158 |
Outer_Syntax.command "syntax" "declare syntactic constants" Keyword.thy_decl |
42299 | 159 |
(opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 160 |
|
24868 | 161 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
162 |
Outer_Syntax.command "no_syntax" "delete syntax declarations" Keyword.thy_decl |
42299 | 163 |
(opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.del_modesyntax)); |
15748 | 164 |
|
5832 | 165 |
|
166 |
(* translations *) |
|
167 |
||
168 |
val trans_pat = |
|
42326 | 169 |
Scan.optional |
170 |
(Parse.$$$ "(" |-- Parse.!!! (Parse.xname --| Parse.$$$ ")")) "logic" |
|
171 |
-- Parse.inner_syntax Parse.string; |
|
5832 | 172 |
|
173 |
fun trans_arrow toks = |
|
42204 | 174 |
((Parse.$$$ "\\<rightharpoonup>" || Parse.$$$ "=>") >> K Syntax.Parse_Rule || |
175 |
(Parse.$$$ "\\<leftharpoondown>" || Parse.$$$ "<=") >> K Syntax.Print_Rule || |
|
176 |
(Parse.$$$ "\\<rightleftharpoons>" || Parse.$$$ "==") >> K Syntax.Parse_Print_Rule) toks; |
|
5832 | 177 |
|
178 |
val trans_line = |
|
36950 | 179 |
trans_pat -- Parse.!!! (trans_arrow -- trans_pat) |
5832 | 180 |
>> (fn (left, (arr, right)) => arr (left, right)); |
181 |
||
24868 | 182 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
183 |
Outer_Syntax.command "translations" "declare syntax translation rules" Keyword.thy_decl |
42204 | 184 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations)); |
5832 | 185 |
|
24868 | 186 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
187 |
Outer_Syntax.command "no_translations" "remove syntax translation rules" Keyword.thy_decl |
42204 | 188 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations)); |
19260 | 189 |
|
5832 | 190 |
|
191 |
(* axioms and definitions *) |
|
192 |
||
24868 | 193 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
194 |
Outer_Syntax.command "axioms" "state arbitrary propositions (axiomatic!)" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
195 |
(Scan.repeat1 Parse_Spec.spec >> |
37861 | 196 |
(fn spec => Toplevel.theory (fn thy => |
197 |
(legacy_feature "Old 'axioms' command -- use 'axiomatization' instead"; |
|
198 |
Isar_Cmd.add_axioms spec thy)))); |
|
5832 | 199 |
|
19631 | 200 |
val opt_unchecked_overloaded = |
36950 | 201 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! |
202 |
(((Parse.$$$ "unchecked" >> K true) -- Scan.optional (Parse.$$$ "overloaded" >> K true) false || |
|
203 |
Parse.$$$ "overloaded" >> K (false, true)) --| Parse.$$$ ")")) (false, false); |
|
19631 | 204 |
|
24868 | 205 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
206 |
Outer_Syntax.command "defs" "define constants" Keyword.thy_decl |
35852
4e3fe0b8687b
minor renovation of old-style 'axioms' -- make it an alias of iterated 'axiomatization';
wenzelm
parents:
35835
diff
changeset
|
207 |
(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
|
208 |
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
|
209 |
>> (Toplevel.theory o Isar_Cmd.add_defs)); |
6370 | 210 |
|
14642 | 211 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
212 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
213 |
|
24868 | 214 |
val _ = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
215 |
Outer_Syntax.local_theory' "definition" "constant definition" Keyword.thy_decl |
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
216 |
(Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args)); |
18780 | 217 |
|
24868 | 218 |
val _ = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
219 |
Outer_Syntax.local_theory' "abbreviation" "constant abbreviation" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
220 |
(opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop) |
36950 | 221 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 222 |
|
24868 | 223 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
224 |
Outer_Syntax.local_theory "type_notation" "add concrete syntax for type constructors" |
36950 | 225 |
Keyword.thy_decl |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
226 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 227 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
35413 | 228 |
|
229 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
230 |
Outer_Syntax.local_theory "no_type_notation" "delete concrete syntax for type constructors" |
36950 | 231 |
Keyword.thy_decl |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
232 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 233 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
35413 | 234 |
|
235 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
236 |
Outer_Syntax.local_theory "notation" "add concrete syntax for constants / fixed variables" |
36950 | 237 |
Keyword.thy_decl |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
238 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 239 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 240 |
|
241 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
242 |
Outer_Syntax.local_theory "no_notation" "delete concrete syntax for constants / fixed variables" |
36950 | 243 |
Keyword.thy_decl |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
244 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 245 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 246 |
|
5832 | 247 |
|
18616 | 248 |
(* constant specifications *) |
249 |
||
24868 | 250 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
251 |
Outer_Syntax.command "axiomatization" "axiomatic constant specification" Keyword.thy_decl |
36950 | 252 |
(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
|
253 |
Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) [] |
36950 | 254 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 255 |
|
256 |
||
5914 | 257 |
(* theorems *) |
258 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
259 |
fun theorems kind = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
260 |
Parse_Spec.name_facts >> (fn args => #2 oo Specification.theorems_cmd kind args); |
12712 | 261 |
|
24868 | 262 |
val _ = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
263 |
Outer_Syntax.local_theory' "theorems" "define theorems" Keyword.thy_decl (theorems Thm.theoremK); |
5914 | 264 |
|
24868 | 265 |
val _ = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
266 |
Outer_Syntax.local_theory' "lemmas" "define lemmas" Keyword.thy_decl (theorems Thm.lemmaK); |
5914 | 267 |
|
24868 | 268 |
val _ = |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
269 |
Outer_Syntax.local_theory' "declare" "declare theorems" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
270 |
(Parse.and_list1 Parse_Spec.xthms1 |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
271 |
>> (fn args => #2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat args)])); |
9589 | 272 |
|
5914 | 273 |
|
5832 | 274 |
(* name space entry path *) |
275 |
||
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
|
276 |
fun hide_names name hide what = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
277 |
Outer_Syntax.command name ("hide " ^ what ^ " from name space") Keyword.thy_decl |
36950 | 278 |
((Parse.opt_keyword "open" >> not) -- Scan.repeat1 Parse.xname >> |
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
279 |
(Toplevel.theory o uncurry hide)); |
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
280 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
281 |
val _ = hide_names "hide_class" Isar_Cmd.hide_class "classes"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
282 |
val _ = hide_names "hide_type" Isar_Cmd.hide_type "types"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
283 |
val _ = hide_names "hide_const" Isar_Cmd.hide_const "constants"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
284 |
val _ = hide_names "hide_fact" Isar_Cmd.hide_fact "facts"; |
5832 | 285 |
|
286 |
||
287 |
(* use ML text *) |
|
288 |
||
24868 | 289 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
290 |
Outer_Syntax.command "use" "ML text from file" (Keyword.tag_ml Keyword.thy_decl) |
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
|
291 |
(Parse.path >> (fn path => Toplevel.generic_theory (Thy_Load.exec_ml path))); |
7891 | 292 |
|
24868 | 293 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
294 |
Outer_Syntax.command "ML" "ML text within theory or local theory" |
36950 | 295 |
(Keyword.tag_ml Keyword.thy_decl) |
296 |
(Parse.ML_source >> (fn (txt, pos) => |
|
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
297 |
Toplevel.generic_theory |
37949
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
298 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt) #> |
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
299 |
Local_Theory.propagate_ml_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
300 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
301 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
302 |
Outer_Syntax.command "ML_prf" "ML text within proof" (Keyword.tag_proof Keyword.prf_decl) |
36950 | 303 |
(Parse.ML_source >> (fn (txt, pos) => |
28269 | 304 |
Toplevel.proof (Proof.map_context (Context.proof_map |
37949
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
305 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt))) #> Proof.propagate_ml_env))); |
28269 | 306 |
|
307 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
308 |
Outer_Syntax.command "ML_val" "diagnostic ML text" (Keyword.tag_ml Keyword.diag) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
309 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
26396 | 310 |
|
311 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
312 |
Outer_Syntax.command "ML_command" "diagnostic ML text (silent)" (Keyword.tag_ml Keyword.diag) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
313 |
(Parse.ML_source >> (Toplevel.no_timing oo Isar_Cmd.ml_diag false)); |
5832 | 314 |
|
24868 | 315 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
316 |
Outer_Syntax.command "setup" "ML theory setup" (Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
317 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup)); |
30461 | 318 |
|
319 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
320 |
Outer_Syntax.local_theory "local_setup" "ML local theory setup" (Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
321 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
5832 | 322 |
|
24868 | 323 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
324 |
Outer_Syntax.command "attribute_setup" "define attribute in ML" (Keyword.tag_ml Keyword.thy_decl) |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
325 |
(Parse.position Parse.name -- |
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
326 |
Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 327 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt))); |
30526 | 328 |
|
329 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
330 |
Outer_Syntax.command "method_setup" "define proof method in ML" (Keyword.tag_ml Keyword.thy_decl) |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
331 |
(Parse.position Parse.name -- |
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
332 |
Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 333 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
9197 | 334 |
|
24868 | 335 |
val _ = |
40784 | 336 |
Outer_Syntax.local_theory "declaration" "generic ML declaration" |
337 |
(Keyword.tag_ml Keyword.thy_decl) |
|
338 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
|
339 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt)); |
|
340 |
||
341 |
val _ = |
|
342 |
Outer_Syntax.local_theory "syntax_declaration" "generic ML declaration" |
|
343 |
(Keyword.tag_ml Keyword.thy_decl) |
|
344 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
|
345 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt)); |
|
22088 | 346 |
|
24868 | 347 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
348 |
Outer_Syntax.local_theory "simproc_setup" "define simproc in ML" (Keyword.tag_ml Keyword.thy_decl) |
42464 | 349 |
(Parse.position Parse.name -- |
36950 | 350 |
(Parse.$$$ "(" |-- Parse.enum1 "|" Parse.term --| Parse.$$$ ")" --| Parse.$$$ "=") -- |
351 |
Parse.ML_source -- Scan.optional (Parse.$$$ "identifier" |-- Scan.repeat1 Parse.xname) [] |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
352 |
>> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d)); |
22202 | 353 |
|
5832 | 354 |
|
355 |
(* translation functions *) |
|
356 |
||
36950 | 357 |
val trfun = Parse.opt_keyword "advanced" -- Parse.ML_source; |
14642 | 358 |
|
24868 | 359 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
360 |
Outer_Syntax.command "parse_ast_translation" "install parse ast translation functions" |
36950 | 361 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
362 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 363 |
|
24868 | 364 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
365 |
Outer_Syntax.command "parse_translation" "install parse translation functions" |
36950 | 366 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
367 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 368 |
|
24868 | 369 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
370 |
Outer_Syntax.command "print_translation" "install print translation functions" |
36950 | 371 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
372 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 373 |
|
24868 | 374 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
375 |
Outer_Syntax.command "typed_print_translation" "install typed print translation functions" |
36950 | 376 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
377 |
(trfun >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 378 |
|
24868 | 379 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
380 |
Outer_Syntax.command "print_ast_translation" "install print ast translation functions" |
36950 | 381 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
382 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 383 |
|
384 |
||
385 |
(* oracles *) |
|
386 |
||
24868 | 387 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
388 |
Outer_Syntax.command "oracle" "declare oracle" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 389 |
(Parse.position Parse.name -- (Parse.$$$ "=" |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
390 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 391 |
|
392 |
||
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
393 |
(* local theories *) |
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
394 |
|
24868 | 395 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
396 |
Outer_Syntax.command "context" "enter local theory context" Keyword.thy_decl |
45488
6d71d9e52369
pass positions for named targets, for formal links in the document model;
wenzelm
parents:
45134
diff
changeset
|
397 |
(Parse.position Parse.name --| Parse.begin >> (fn name => |
38350
480b2de9927c
renamed Theory_Target to the more appropriate Named_Target
haftmann
parents:
38348
diff
changeset
|
398 |
Toplevel.print o Toplevel.begin_local_theory true (Named_Target.context_cmd name))); |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
399 |
|
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
400 |
|
12061 | 401 |
(* locales *) |
402 |
||
12758 | 403 |
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
|
404 |
Parse_Spec.locale_expression false -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
405 |
Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
406 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 407 |
|
24868 | 408 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
409 |
Outer_Syntax.command "locale" "define named proof context" Keyword.thy_decl |
36950 | 410 |
(Parse.binding -- |
411 |
Scan.optional (Parse.$$$ "=" |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
|
27681 | 412 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 413 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
414 |
(Expression.add_locale_cmd I name Binding.empty expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
415 |
|
41270 | 416 |
fun parse_interpretation_arguments mandatory = |
417 |
Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
|
418 |
Scan.optional |
|
419 |
(Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
420 |
||
24868 | 421 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
422 |
Outer_Syntax.command "sublocale" |
36950 | 423 |
"prove sublocale relation between a locale and a locale expression" Keyword.thy_goal |
424 |
(Parse.xname --| (Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") -- |
|
41270 | 425 |
parse_interpretation_arguments false |
426 |
>> (fn (loc, (expr, equations)) => |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
427 |
Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations))); |
28895 | 428 |
|
429 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
430 |
Outer_Syntax.command "interpretation" |
36950 | 431 |
"prove interpretation of locale expression in theory" Keyword.thy_goal |
41270 | 432 |
(parse_interpretation_arguments true |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
433 |
>> (fn (expr, equations) => Toplevel.print o |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
434 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 435 |
|
436 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
437 |
Outer_Syntax.command "interpret" |
29223 | 438 |
"prove interpretation of locale expression in proof context" |
36950 | 439 |
(Keyword.tag_proof Keyword.prf_goal) |
41270 | 440 |
(parse_interpretation_arguments true |
38108 | 441 |
>> (fn (expr, equations) => Toplevel.print o |
442 |
Toplevel.proof' (Expression.interpret_cmd expr equations))); |
|
29223 | 443 |
|
15703 | 444 |
|
22299 | 445 |
(* classes *) |
446 |
||
24868 | 447 |
val class_val = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
448 |
Parse_Spec.class_expr -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
449 |
Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
450 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 451 |
|
24868 | 452 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
453 |
Outer_Syntax.command "class" "define type class" Keyword.thy_decl |
36950 | 454 |
(Parse.binding -- Scan.optional (Parse.$$$ "=" |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 455 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 456 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
457 |
(Class_Declaration.class_cmd I name supclasses elems #> snd))); |
22299 | 458 |
|
24868 | 459 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
460 |
Outer_Syntax.local_theory_to_proof "subclass" "prove a subclass relation" Keyword.thy_goal |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
461 |
(Parse.xname >> Class_Declaration.subclass_cmd I); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
462 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
463 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
464 |
Outer_Syntax.command "instantiation" "instantiate and prove type arity" Keyword.thy_decl |
36950 | 465 |
(Parse.multi_arity --| Parse.begin |
25462 | 466 |
>> (fn arities => Toplevel.print o |
38348
cf7b2121ad9d
moved instantiation target formally to class_target.ML
haftmann
parents:
38342
diff
changeset
|
467 |
Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
24589 | 468 |
|
25485 | 469 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
470 |
Outer_Syntax.command "instance" "prove type arity or subclass relation" Keyword.thy_goal |
36950 | 471 |
((Parse.xname -- ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |-- Parse.!!! Parse.xname) |
472 |
>> Class.classrel_cmd || |
|
473 |
Parse.multi_arity >> Class.instance_arity_cmd) |
|
474 |
>> (Toplevel.print oo Toplevel.theory_to_proof) || |
|
475 |
Scan.succeed |
|
476 |
(Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 477 |
|
478 |
||
25519 | 479 |
(* arbitrary overloading *) |
480 |
||
481 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
482 |
Outer_Syntax.command "overloading" "overloaded definitions" Keyword.thy_decl |
36950 | 483 |
(Scan.repeat1 (Parse.name --| (Parse.$$$ "\\<equiv>" || Parse.$$$ "==") -- Parse.term -- |
484 |
Scan.optional (Parse.$$$ "(" |-- (Parse.$$$ "unchecked" >> K false) --| Parse.$$$ ")") true |
|
485 |
>> Parse.triple1) --| Parse.begin |
|
25519 | 486 |
>> (fn operations => Toplevel.print o |
38342
09d4a04d5c2e
moved overloading target formally to overloading.ML
haftmann
parents:
38108
diff
changeset
|
487 |
Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
25519 | 488 |
|
489 |
||
22866 | 490 |
(* code generation *) |
491 |
||
24868 | 492 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
493 |
Outer_Syntax.command "code_datatype" "define set of code datatype constructors" Keyword.thy_decl |
36950 | 494 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 495 |
|
496 |
||
5832 | 497 |
|
498 |
(** proof commands **) |
|
499 |
||
500 |
(* statements *) |
|
501 |
||
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
502 |
fun gen_theorem schematic kind = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
503 |
Outer_Syntax.local_theory_to_proof' |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
504 |
(if schematic then "schematic_" ^ kind else kind) |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
505 |
("state " ^ (if schematic then "schematic " ^ kind else kind)) |
36950 | 506 |
(if schematic then Keyword.thy_schematic_goal else Keyword.thy_goal) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
507 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
508 |
Scan.ahead (Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
509 |
Parse_Spec.general_statement >> (fn (a, (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
510 |
((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd) |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
511 |
kind NONE (K I) a elems concl))); |
5832 | 512 |
|
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
513 |
val _ = gen_theorem false Thm.theoremK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
514 |
val _ = gen_theorem false Thm.lemmaK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
515 |
val _ = gen_theorem false Thm.corollaryK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
516 |
val _ = gen_theorem true Thm.theoremK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
517 |
val _ = gen_theorem true Thm.lemmaK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
518 |
val _ = gen_theorem true Thm.corollaryK; |
5832 | 519 |
|
24868 | 520 |
val _ = |
40960 | 521 |
Outer_Syntax.local_theory_to_proof "notepad" |
522 |
"Isar proof state as formal notepad, without any result" Keyword.thy_decl |
|
523 |
(Parse.begin >> K Proof.begin_notepad); |
|
524 |
||
525 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
526 |
Outer_Syntax.command "have" "state local goal" |
36950 | 527 |
(Keyword.tag_proof Keyword.prf_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
528 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have)); |
17353 | 529 |
|
24868 | 530 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
531 |
Outer_Syntax.command "hence" "abbreviates \"then have\"" |
36950 | 532 |
(Keyword.tag_proof Keyword.prf_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
533 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence)); |
17353 | 534 |
|
24868 | 535 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
536 |
Outer_Syntax.command "show" "state local goal, solving current obligation" |
36950 | 537 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
538 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show)); |
5832 | 539 |
|
24868 | 540 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
541 |
Outer_Syntax.command "thus" "abbreviates \"then show\"" |
36950 | 542 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
543 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus)); |
6501 | 544 |
|
5832 | 545 |
|
5914 | 546 |
(* facts *) |
5832 | 547 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
548 |
val facts = Parse.and_list1 Parse_Spec.xthms1; |
9197 | 549 |
|
24868 | 550 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
551 |
Outer_Syntax.command "then" "forward chaining" |
36950 | 552 |
(Keyword.tag_proof Keyword.prf_chain) |
17900 | 553 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 554 |
|
24868 | 555 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
556 |
Outer_Syntax.command "from" "forward chaining from given facts" |
36950 | 557 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
558 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd))); |
5914 | 559 |
|
24868 | 560 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
561 |
Outer_Syntax.command "with" "forward chaining from given and current facts" |
36950 | 562 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
563 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd))); |
6878 | 564 |
|
24868 | 565 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
566 |
Outer_Syntax.command "note" "define facts" |
36950 | 567 |
(Keyword.tag_proof Keyword.prf_decl) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
568 |
(Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd))); |
5832 | 569 |
|
24868 | 570 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
571 |
Outer_Syntax.command "using" "augment goal facts" |
36950 | 572 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
573 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd))); |
18544 | 574 |
|
24868 | 575 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
576 |
Outer_Syntax.command "unfolding" "unfold definitions in goal and facts" |
36950 | 577 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
578 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd))); |
12926 | 579 |
|
5832 | 580 |
|
581 |
(* proof context *) |
|
582 |
||
24868 | 583 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
584 |
Outer_Syntax.command "fix" "fix local variables (Skolem constants)" |
36950 | 585 |
(Keyword.tag_proof Keyword.prf_asm) |
586 |
(Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd))); |
|
11890 | 587 |
|
24868 | 588 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
589 |
Outer_Syntax.command "assume" "assume propositions" |
36950 | 590 |
(Keyword.tag_proof Keyword.prf_asm) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
591 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd))); |
5832 | 592 |
|
24868 | 593 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
594 |
Outer_Syntax.command "presume" "assume propositions, to be established later" |
36950 | 595 |
(Keyword.tag_proof Keyword.prf_asm) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
596 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd))); |
6850 | 597 |
|
24868 | 598 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
599 |
Outer_Syntax.command "def" "local definition" |
36950 | 600 |
(Keyword.tag_proof Keyword.prf_asm) |
601 |
(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
|
602 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 603 |
((Parse.binding -- Parse.opt_mixfix) -- |
604 |
((Parse.$$$ "\\<equiv>" || Parse.$$$ "==") |-- Parse.!!! Parse.termp))) |
|
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
605 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd))); |
6953 | 606 |
|
24868 | 607 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
608 |
Outer_Syntax.command "obtain" "generalized existence" |
36950 | 609 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
610 |
(Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
611 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 612 |
|
24868 | 613 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
614 |
Outer_Syntax.command "guess" "wild guessing (unstructured)" |
36950 | 615 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
616 |
(Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd))); |
|
17854 | 617 |
|
24868 | 618 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
619 |
Outer_Syntax.command "let" "bind text variables" |
36950 | 620 |
(Keyword.tag_proof Keyword.prf_decl) |
621 |
(Parse.and_list1 (Parse.and_list1 Parse.term -- (Parse.$$$ "=" |-- Parse.term)) |
|
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
622 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd))); |
5832 | 623 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
624 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
625 |
Outer_Syntax.command "write" "add concrete syntax for constants / fixed variables" |
36950 | 626 |
(Keyword.tag_proof Keyword.prf_decl) |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
627 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
628 |
>> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args))); |
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
629 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
630 |
val case_spec = |
36950 | 631 |
(Parse.$$$ "(" |-- |
42496 | 632 |
Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| Parse.$$$ ")") || |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
633 |
Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
634 |
|
24868 | 635 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
636 |
Outer_Syntax.command "case" "invoke local context" |
36950 | 637 |
(Keyword.tag_proof Keyword.prf_asm) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
638 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd))); |
8370 | 639 |
|
5832 | 640 |
|
641 |
(* proof structure *) |
|
642 |
||
24868 | 643 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
644 |
Outer_Syntax.command "{" "begin explicit proof block" |
36950 | 645 |
(Keyword.tag_proof Keyword.prf_open) |
17900 | 646 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 647 |
|
24868 | 648 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
649 |
Outer_Syntax.command "}" "end explicit proof block" |
36950 | 650 |
(Keyword.tag_proof Keyword.prf_close) |
20305 | 651 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 652 |
|
24868 | 653 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
654 |
Outer_Syntax.command "next" "enter next proof block" |
36950 | 655 |
(Keyword.tag_proof Keyword.prf_block) |
17900 | 656 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 657 |
|
658 |
||
659 |
(* end proof *) |
|
660 |
||
24868 | 661 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
662 |
Outer_Syntax.command "qed" "conclude (sub-)proof" |
36950 | 663 |
(Keyword.tag_proof Keyword.qed_block) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
664 |
(Scan.option Method.parse >> Isar_Cmd.qed); |
5832 | 665 |
|
24868 | 666 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
667 |
Outer_Syntax.command "by" "terminal backward proof" |
36950 | 668 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
669 |
(Method.parse -- Scan.option Method.parse >> Isar_Cmd.terminal_proof); |
6404 | 670 |
|
24868 | 671 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
672 |
Outer_Syntax.command ".." "default proof" |
36950 | 673 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
674 |
(Scan.succeed Isar_Cmd.default_proof); |
8966 | 675 |
|
24868 | 676 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
677 |
Outer_Syntax.command "." "immediate proof" |
36950 | 678 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
679 |
(Scan.succeed Isar_Cmd.immediate_proof); |
6404 | 680 |
|
24868 | 681 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
682 |
Outer_Syntax.command "done" "done proof" |
36950 | 683 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
684 |
(Scan.succeed Isar_Cmd.done_proof); |
5832 | 685 |
|
24868 | 686 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
687 |
Outer_Syntax.command "sorry" "skip proof (quick-and-dirty mode only!)" |
36950 | 688 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
689 |
(Scan.succeed Isar_Cmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
690 |
|
24868 | 691 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
692 |
Outer_Syntax.command "oops" "forget proof" |
36950 | 693 |
(Keyword.tag_proof Keyword.qed_global) |
18561 | 694 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 695 |
|
5832 | 696 |
|
697 |
(* proof steps *) |
|
698 |
||
24868 | 699 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
700 |
Outer_Syntax.command "defer" "shuffle internal proof state" |
36950 | 701 |
(Keyword.tag_proof Keyword.prf_script) |
702 |
(Scan.option Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
|
8165 | 703 |
|
24868 | 704 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
705 |
Outer_Syntax.command "prefer" "shuffle internal proof state" |
36950 | 706 |
(Keyword.tag_proof Keyword.prf_script) |
707 |
(Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
|
8165 | 708 |
|
24868 | 709 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
710 |
Outer_Syntax.command "apply" "initial refinement step (unstructured)" |
36950 | 711 |
(Keyword.tag_proof Keyword.prf_script) |
22117 | 712 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 713 |
|
24868 | 714 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
715 |
Outer_Syntax.command "apply_end" "terminal refinement (unstructured)" |
36950 | 716 |
(Keyword.tag_proof Keyword.prf_script) |
22117 | 717 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 718 |
|
24868 | 719 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
720 |
Outer_Syntax.command "proof" "backward proof" |
36950 | 721 |
(Keyword.tag_proof Keyword.prf_block) |
22117 | 722 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
33390 | 723 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof m)) o |
27563 | 724 |
Toplevel.skip_proof (fn i => i + 1))); |
5832 | 725 |
|
726 |
||
6773 | 727 |
(* calculational proof commands *) |
728 |
||
6878 | 729 |
val calc_args = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
730 |
Scan.option (Parse.$$$ "(" |-- Parse.!!! ((Parse_Spec.xthms1 --| Parse.$$$ ")"))); |
6878 | 731 |
|
24868 | 732 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
733 |
Outer_Syntax.command "also" "combine calculation and current facts" |
36950 | 734 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
735 |
(calc_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
6773 | 736 |
|
24868 | 737 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
738 |
Outer_Syntax.command "finally" "combine calculation and current facts, exhibit result" |
36950 | 739 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
740 |
(calc_args >> (Toplevel.proofs' o Calculation.finally_cmd)); |
6773 | 741 |
|
24868 | 742 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
743 |
Outer_Syntax.command "moreover" "augment calculation by current facts" |
36950 | 744 |
(Keyword.tag_proof Keyword.prf_decl) |
17900 | 745 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 746 |
|
24868 | 747 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
748 |
Outer_Syntax.command "ultimately" "augment calculation by current facts, exhibit result" |
36950 | 749 |
(Keyword.tag_proof Keyword.prf_chain) |
17900 | 750 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 751 |
|
6773 | 752 |
|
6742 | 753 |
(* proof navigation *) |
5944 | 754 |
|
24868 | 755 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
756 |
Outer_Syntax.command "back" "backtracking of proof command" |
36950 | 757 |
(Keyword.tag_proof Keyword.prf_script) |
33390 | 758 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I)); |
6742 | 759 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
760 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
761 |
(* nested commands *) |
25578 | 762 |
|
29309 | 763 |
val props_text = |
43775
b361c7d184e7
added Parse.properties (again) -- allow empty list like Parse_Value.properties but unlike Parse.properties of ef86de9c98aa;
wenzelm
parents:
43227
diff
changeset
|
764 |
Scan.optional Parse.properties [] -- Parse.position Parse.string |
36950 | 765 |
>> (fn (props, (str, pos)) => |
766 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
29309 | 767 |
|
25578 | 768 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
769 |
Outer_Syntax.improper_command "Isabelle.command" "nested Isabelle command" Keyword.control |
29309 | 770 |
(props_text :|-- (fn (pos, str) => |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
771 |
(case Outer_Syntax.parse pos str of |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
772 |
[tr] => Scan.succeed (K tr) |
43947
9b00f09f7721
defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents:
43775
diff
changeset
|
773 |
| _ => Scan.fail_with (K (fn () => "exactly one command expected"))) |
9b00f09f7721
defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents:
43775
diff
changeset
|
774 |
handle ERROR msg => Scan.fail_with (K (fn () => msg)))); |
25578 | 775 |
|
776 |
||
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
777 |
|
5832 | 778 |
(** diagnostic commands (for interactive mode only) **) |
779 |
||
36950 | 780 |
val opt_modes = |
781 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Scan.repeat1 Parse.xname --| Parse.$$$ ")")) []; |
|
782 |
||
783 |
val opt_bang = Scan.optional (Parse.$$$ "!" >> K true) false; |
|
8464 | 784 |
|
24868 | 785 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
786 |
Outer_Syntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
38870 | 787 |
Keyword.diag (Parse.nat >> |
788 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Pretty.margin_default := n))); |
|
7124 | 789 |
|
24868 | 790 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
791 |
Outer_Syntax.improper_command "help" "print outer syntax commands" Keyword.diag |
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
792 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
21714 | 793 |
|
24868 | 794 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
795 |
Outer_Syntax.improper_command "print_commands" "print outer syntax commands" Keyword.diag |
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
796 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
5832 | 797 |
|
24868 | 798 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
799 |
Outer_Syntax.improper_command "print_configs" "print configuration options" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
800 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_configs)); |
23989 | 801 |
|
24868 | 802 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
803 |
Outer_Syntax.improper_command "print_context" "print theory context name" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
804 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_context)); |
7308 | 805 |
|
24868 | 806 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
807 |
Outer_Syntax.improper_command "print_theory" "print logical theory contents (verbose!)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
808 |
Keyword.diag (opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theory)); |
5832 | 809 |
|
24868 | 810 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
811 |
Outer_Syntax.improper_command "print_syntax" "print inner syntax of context (verbose!)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
812 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_syntax)); |
5832 | 813 |
|
24868 | 814 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
815 |
Outer_Syntax.improper_command "print_abbrevs" "print constant abbreviation of context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
816 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_abbrevs)); |
21726 | 817 |
|
24868 | 818 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
819 |
Outer_Syntax.improper_command "print_theorems" |
36950 | 820 |
"print theorems of local theory or proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
821 |
(opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theorems)); |
5881 | 822 |
|
24868 | 823 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
824 |
Outer_Syntax.improper_command "print_locales" "print locales of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
825 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_locales)); |
12061 | 826 |
|
24868 | 827 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
828 |
Outer_Syntax.improper_command "print_classes" "print classes of this theory" Keyword.diag |
42359 | 829 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
830 |
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
|
831 |
|
24868 | 832 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
833 |
Outer_Syntax.improper_command "print_locale" "print locale of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
834 |
(opt_bang -- Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_locale)); |
12061 | 835 |
|
24868 | 836 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
837 |
Outer_Syntax.improper_command "print_interps" |
41435 | 838 |
"print interpretations of locale for this theory or proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
839 |
(Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_registrations)); |
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
840 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
841 |
val _ = |
41435 | 842 |
Outer_Syntax.improper_command "print_dependencies" |
843 |
"print dependencies of locale expression" Keyword.diag |
|
844 |
(opt_bang -- Parse_Spec.locale_expression true >> |
|
845 |
(Toplevel.no_timing oo Isar_Cmd.print_dependencies)); |
|
846 |
||
847 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
848 |
Outer_Syntax.improper_command "print_attributes" "print attributes of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
849 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_attributes)); |
5832 | 850 |
|
24868 | 851 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
852 |
Outer_Syntax.improper_command "print_simpset" "print context of Simplifier" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
853 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_simpset)); |
16027 | 854 |
|
24868 | 855 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
856 |
Outer_Syntax.improper_command "print_rules" "print intro/elim rules" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
857 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_rules)); |
12383 | 858 |
|
24868 | 859 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
860 |
Outer_Syntax.improper_command "print_trans_rules" "print transitivity rules" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
861 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_trans_rules)); |
9221 | 862 |
|
24868 | 863 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
864 |
Outer_Syntax.improper_command "print_methods" "print methods of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
865 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_methods)); |
5832 | 866 |
|
24868 | 867 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
868 |
Outer_Syntax.improper_command "print_antiquotations" "print antiquotations (global)" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
869 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_antiquotations)); |
9221 | 870 |
|
24868 | 871 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
872 |
Outer_Syntax.improper_command "thy_deps" "visualize theory dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
873 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.thy_deps)); |
22485 | 874 |
|
24868 | 875 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
876 |
Outer_Syntax.improper_command "class_deps" "visualize class dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
877 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.class_deps)); |
20574 | 878 |
|
24868 | 879 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
880 |
Outer_Syntax.improper_command "thm_deps" "visualize theorem dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
881 |
Keyword.diag (Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.thm_deps)); |
9454 | 882 |
|
24868 | 883 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
884 |
Outer_Syntax.improper_command "print_binds" "print term bindings of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
885 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_binds)); |
5832 | 886 |
|
24868 | 887 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
888 |
Outer_Syntax.improper_command "print_facts" "print facts of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
889 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_facts)); |
5832 | 890 |
|
24868 | 891 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
892 |
Outer_Syntax.improper_command "print_cases" "print cases of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
893 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_cases)); |
8370 | 894 |
|
24868 | 895 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
896 |
Outer_Syntax.improper_command "print_statement" "print theorems as long statements" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
897 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_stmts)); |
19269 | 898 |
|
24868 | 899 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
900 |
Outer_Syntax.improper_command "thm" "print theorems" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
901 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_thms)); |
5832 | 902 |
|
24868 | 903 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
904 |
Outer_Syntax.improper_command "prf" "print proof terms of theorems" Keyword.diag |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
905 |
(opt_modes -- Scan.option Parse_Spec.xthms1 |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
906 |
>> (Toplevel.no_timing oo Isar_Cmd.print_prfs false)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
907 |
|
24868 | 908 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
909 |
Outer_Syntax.improper_command "full_prf" "print full proof terms of theorems" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
910 |
(opt_modes -- Scan.option Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_prfs true)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
911 |
|
24868 | 912 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
913 |
Outer_Syntax.improper_command "prop" "read and print proposition" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
914 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_prop)); |
5832 | 915 |
|
24868 | 916 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
917 |
Outer_Syntax.improper_command "term" "read and print term" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
918 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_term)); |
5832 | 919 |
|
24868 | 920 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
921 |
Outer_Syntax.improper_command "typ" "read and print type" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
922 |
(opt_modes -- Parse.typ >> (Toplevel.no_timing oo Isar_Cmd.print_type)); |
5832 | 923 |
|
24868 | 924 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
925 |
Outer_Syntax.improper_command "print_codesetup" "print code generator setup" Keyword.diag |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
926 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
927 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 928 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 929 |
|
26184 | 930 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
931 |
Outer_Syntax.improper_command "unused_thms" "find unused theorems" Keyword.diag |
36950 | 932 |
(Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) -- |
933 |
Scan.option (Scan.repeat1 (Scan.unless Parse.minus Parse.name))) >> |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
934 |
(Toplevel.no_timing oo Isar_Cmd.unused_thms)); |
26184 | 935 |
|
5832 | 936 |
|
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
|
937 |
|
5832 | 938 |
(** system commands (for interactive mode only) **) |
939 |
||
24868 | 940 |
val _ = |
40395
4985aaade799
mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents:
39214
diff
changeset
|
941 |
Outer_Syntax.improper_command "cd" "change current working directory" Keyword.control |
4985aaade799
mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents:
39214
diff
changeset
|
942 |
(Parse.path >> (fn path => Toplevel.no_timing o Toplevel.imperative (fn () => File.cd path))); |
5832 | 943 |
|
24868 | 944 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
945 |
Outer_Syntax.improper_command "pwd" "print current working directory" Keyword.diag |
40395
4985aaade799
mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents:
39214
diff
changeset
|
946 |
(Scan.succeed (Toplevel.no_timing o |
41944
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
wenzelm
parents:
41585
diff
changeset
|
947 |
Toplevel.imperative (fn () => writeln (Path.print (File.pwd ()))))); |
5832 | 948 |
|
24868 | 949 |
val _ = |
37987
aac4eb1fa1d8
explicit Keyword.control markup for various control commands -- to prevent them from occurring in proof documents;
wenzelm
parents:
37981
diff
changeset
|
950 |
Outer_Syntax.improper_command "use_thy" "use theory file" Keyword.control |
36950 | 951 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
952 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.use_thy name))); |
5832 | 953 |
|
24868 | 954 |
val _ = |
37987
aac4eb1fa1d8
explicit Keyword.control markup for various control commands -- to prevent them from occurring in proof documents;
wenzelm
parents:
37981
diff
changeset
|
955 |
Outer_Syntax.improper_command "remove_thy" "remove theory from loader database" Keyword.control |
36950 | 956 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
957 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.remove_thy name))); |
7102 | 958 |
|
24868 | 959 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
960 |
Outer_Syntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
37987
aac4eb1fa1d8
explicit Keyword.control markup for various control commands -- to prevent them from occurring in proof documents;
wenzelm
parents:
37981
diff
changeset
|
961 |
Keyword.control (Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
962 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
7931 | 963 |
|
24868 | 964 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
965 |
Outer_Syntax.improper_command "display_drafts" "display raw source files with symbols" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
966 |
Keyword.diag (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.display_drafts)); |
14934 | 967 |
|
24868 | 968 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
969 |
Outer_Syntax.improper_command "print_drafts" "print raw source files with symbols" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
970 |
Keyword.diag (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.print_drafts)); |
14934 | 971 |
|
39165 | 972 |
val _ = (* FIXME tty only *) |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
973 |
Outer_Syntax.improper_command "pr" "print current proof state (if present)" Keyword.diag |
39165 | 974 |
(opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) => |
975 |
Toplevel.no_timing o Toplevel.keep (fn state => |
|
976 |
(case limit of NONE => () | SOME n => Goal_Display.goals_limit_default := n; |
|
977 |
Toplevel.quiet := false; |
|
978 |
Print_Mode.with_modes modes (Toplevel.print_state true) state)))); |
|
7199 | 979 |
|
24868 | 980 |
val _ = |
37987
aac4eb1fa1d8
explicit Keyword.control markup for various control commands -- to prevent them from occurring in proof documents;
wenzelm
parents:
37981
diff
changeset
|
981 |
Outer_Syntax.improper_command "disable_pr" "disable printing of toplevel state" Keyword.control |
39165 | 982 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := true))); |
5832 | 983 |
|
24868 | 984 |
val _ = |
37987
aac4eb1fa1d8
explicit Keyword.control markup for various control commands -- to prevent them from occurring in proof documents;
wenzelm
parents:
37981
diff
changeset
|
985 |
Outer_Syntax.improper_command "enable_pr" "enable printing of toplevel state" Keyword.control |
39165 | 986 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := false))); |
7222 | 987 |
|
24868 | 988 |
val _ = |
40395
4985aaade799
mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents:
39214
diff
changeset
|
989 |
Outer_Syntax.improper_command "commit" "commit current session to ML database" Keyword.control |
36950 | 990 |
(Parse.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 991 |
|
24868 | 992 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
993 |
Outer_Syntax.improper_command "quit" "quit Isabelle" Keyword.control |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
994 |
(Parse.opt_unit >> (Toplevel.no_timing oo K (Toplevel.imperative quit))); |
5832 | 995 |
|
24868 | 996 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
997 |
Outer_Syntax.improper_command "exit" "exit Isar loop" Keyword.control |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
998 |
(Scan.succeed |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
999 |
(Toplevel.no_timing o Toplevel.keep (fn state => |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
1000 |
(Context.set_thread_data (try Toplevel.generic_theory_of state); |
38888
8248cda328de
moved Toplevel.run_command to Pure/PIDE/document.ML;
wenzelm
parents:
38870
diff
changeset
|
1001 |
raise Runtime.TERMINATE)))); |
5832 | 1002 |
|
1003 |
end; |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
1004 |