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