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