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