author | wenzelm |
Tue, 19 Sep 2006 23:15:26 +0200 | |
changeset 20621 | 29d57880ba00 |
parent 20574 | a10885a269cb |
child 20803 | ac78eee049ce |
permissions | -rw-r--r-- |
5832 | 1 |
(* Title: Pure/Isar/isar_syn.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
6353 | 5 |
Isar/Pure outer syntax. |
5832 | 6 |
*) |
7 |
||
17353 | 8 |
structure IsarSyn: sig end = |
5832 | 9 |
struct |
10 |
||
17068 | 11 |
structure P = OuterParse and K = OuterKeyword; |
5832 | 12 |
|
13 |
||
14 |
(** init and exit **) |
|
15 |
||
16 |
val theoryP = |
|
17068 | 17 |
OuterSyntax.command "theory" "begin theory" (K.tag_theory K.thy_begin) |
9129 | 18 |
(ThyHeader.args >> (Toplevel.print oo IsarThy.theory)); |
5832 | 19 |
|
6687 | 20 |
val end_excursionP = |
17068 | 21 |
OuterSyntax.command "end" "end current excursion" (K.tag_theory K.thy_end) |
6687 | 22 |
(Scan.succeed (Toplevel.print o Toplevel.exit)); |
23 |
||
6245 | 24 |
val contextP = |
17068 | 25 |
OuterSyntax.improper_command "context" "switch theory context" (K.tag_theory K.thy_switch) |
6723 | 26 |
(P.name >> (Toplevel.print oo IsarThy.context)); |
6245 | 27 |
|
5832 | 28 |
|
29 |
||
7749 | 30 |
(** markup commands **) |
5832 | 31 |
|
9129 | 32 |
val headerP = OuterSyntax.markup_command IsarOutput.Markup "header" "theory header" K.diag |
12940 | 33 |
(P.position P.text >> IsarCmd.add_header); |
6353 | 34 |
|
9129 | 35 |
val chapterP = OuterSyntax.markup_command IsarOutput.Markup "chapter" "chapter heading" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
36 |
K.thy_heading (P.opt_locale_target -- P.position P.text >> IsarCmd.add_chapter); |
5958 | 37 |
|
9129 | 38 |
val sectionP = OuterSyntax.markup_command IsarOutput.Markup "section" "section heading" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
39 |
K.thy_heading (P.opt_locale_target -- P.position P.text >> IsarCmd.add_section); |
5958 | 40 |
|
9129 | 41 |
val subsectionP = OuterSyntax.markup_command IsarOutput.Markup "subsection" "subsection heading" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
42 |
K.thy_heading (P.opt_locale_target -- P.position P.text >> IsarCmd.add_subsection); |
5958 | 43 |
|
7749 | 44 |
val subsubsectionP = |
9129 | 45 |
OuterSyntax.markup_command IsarOutput.Markup "subsubsection" "subsubsection heading" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
46 |
K.thy_heading (P.opt_locale_target -- P.position P.text >> IsarCmd.add_subsubsection); |
5832 | 47 |
|
9129 | 48 |
val textP = OuterSyntax.markup_command IsarOutput.MarkupEnv "text" "formal comment (theory)" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
49 |
K.thy_decl (P.opt_locale_target -- P.position P.text >> IsarCmd.add_text); |
7172 | 50 |
|
9129 | 51 |
val text_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "text_raw" |
17264
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
52 |
"raw document preparation text" |
c5b280a52a67
chapter/section/subsection/subsubsection/text: optional locale specification;
wenzelm
parents:
17228
diff
changeset
|
53 |
K.thy_decl (P.position P.text >> IsarCmd.add_text_raw); |
7172 | 54 |
|
9552 | 55 |
val sectP = OuterSyntax.markup_command IsarOutput.Markup "sect" "formal comment (proof)" |
17068 | 56 |
(K.tag_proof K.prf_heading) (P.position P.text >> IsarCmd.add_sect); |
7172 | 57 |
|
9129 | 58 |
val subsectP = OuterSyntax.markup_command IsarOutput.Markup "subsect" "formal comment (proof)" |
17068 | 59 |
(K.tag_proof K.prf_heading) (P.position P.text >> IsarCmd.add_subsect); |
7172 | 60 |
|
9129 | 61 |
val subsubsectP = OuterSyntax.markup_command IsarOutput.Markup "subsubsect" |
17068 | 62 |
"formal comment (proof)" (K.tag_proof K.prf_heading) |
12940 | 63 |
(P.position P.text >> IsarCmd.add_subsubsect); |
7172 | 64 |
|
9129 | 65 |
val txtP = OuterSyntax.markup_command IsarOutput.MarkupEnv "txt" "formal comment (proof)" |
17068 | 66 |
(K.tag_proof K.prf_decl) (P.position P.text >> IsarCmd.add_txt); |
7172 | 67 |
|
9129 | 68 |
val txt_rawP = OuterSyntax.markup_command IsarOutput.Verbatim "txt_raw" |
17068 | 69 |
"raw document preparation text (proof)" (K.tag_proof K.prf_decl) |
12940 | 70 |
(P.position P.text >> IsarCmd.add_txt_raw); |
7775 | 71 |
|
5832 | 72 |
|
6886 | 73 |
|
74 |
(** theory sections **) |
|
75 |
||
5832 | 76 |
(* classes and sorts *) |
77 |
||
78 |
val classesP = |
|
6723 | 79 |
OuterSyntax.command "classes" "declare type classes" K.thy_decl |
11101
014e7b5c77ba
support \<subseteq> syntax in classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
80 |
(Scan.repeat1 (P.name -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- |
19516 | 81 |
P.!!! (P.list1 P.xname)) []) >> (Toplevel.theory o fold AxClass.axiomatize_class)); |
5832 | 82 |
|
83 |
val classrelP = |
|
6723 | 84 |
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl |
14779 | 85 |
(P.and_list1 (P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname)) |
19516 | 86 |
>> (Toplevel.theory o AxClass.axiomatize_classrel)); |
5832 | 87 |
|
88 |
val defaultsortP = |
|
6723 | 89 |
OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
90 |
(P.sort >> (Toplevel.theory o Theory.add_defsort)); |
5832 | 91 |
|
19245 | 92 |
val axclassP = |
93 |
OuterSyntax.command "axclass" "define axiomatic type class" K.thy_decl |
|
94 |
((P.name -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- |
|
19431
20e86336a53f
axclass: old-style concrete syntax for canonical specification format;
wenzelm
parents:
19410
diff
changeset
|
95 |
P.!!! (P.list1 P.xname)) []) -- |
20e86336a53f
axclass: old-style concrete syntax for canonical specification format;
wenzelm
parents:
19410
diff
changeset
|
96 |
Scan.repeat (P.thm_name ":" -- (P.prop >> single)) |
19516 | 97 |
>> (fn (x, y) => Toplevel.theory (snd o AxClass.define_class x [] y))); |
19245 | 98 |
|
5832 | 99 |
|
100 |
(* types *) |
|
101 |
||
102 |
val typedeclP = |
|
12624 | 103 |
OuterSyntax.command "typedecl" "type declaration" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
104 |
(P.type_args -- P.name -- P.opt_infix >> (fn ((args, a), mx) => |
16447 | 105 |
Toplevel.theory (Theory.add_typedecls [(a, args, mx)]))); |
5832 | 106 |
|
107 |
val typeabbrP = |
|
6723 | 108 |
OuterSyntax.command "types" "declare type abbreviations" K.thy_decl |
6727 | 109 |
(Scan.repeat1 |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
110 |
(P.type_args -- P.name -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_infix'))) |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
111 |
>> (Toplevel.theory o Theory.add_tyabbrs o |
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
112 |
map (fn ((args, a), (T, mx)) => (a, args, T, mx)))); |
5832 | 113 |
|
114 |
val nontermP = |
|
6370 | 115 |
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
116 |
K.thy_decl (Scan.repeat1 P.name >> (Toplevel.theory o Theory.add_nonterminals)); |
5832 | 117 |
|
118 |
val aritiesP = |
|
6723 | 119 |
OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
120 |
(Scan.repeat1 (P.xname -- (P.$$$ "::" |-- P.!!! P.arity) >> P.triple2) |
19516 | 121 |
>> (Toplevel.theory o fold AxClass.axiomatize_arity)); |
5832 | 122 |
|
123 |
||
124 |
(* consts and syntax *) |
|
125 |
||
8227 | 126 |
val judgmentP = |
127 |
OuterSyntax.command "judgment" "declare object-logic judgment" K.thy_decl |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
128 |
(P.const >> (Toplevel.theory o ObjectLogic.add_judgment)); |
8227 | 129 |
|
5832 | 130 |
val constsP = |
6723 | 131 |
OuterSyntax.command "consts" "declare constants" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
132 |
(Scan.repeat1 P.const >> (Toplevel.theory o Theory.add_consts)); |
5832 | 133 |
|
14642 | 134 |
val opt_overloaded = P.opt_keyword "overloaded"; |
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
135 |
|
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
136 |
val finalconstsP = |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
137 |
OuterSyntax.command "finalconsts" "declare constants as final" K.thy_decl |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
138 |
(opt_overloaded -- Scan.repeat1 P.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); |
9731 | 139 |
|
12142 | 140 |
val mode_spec = |
9731 | 141 |
(P.$$$ "output" >> K ("", false)) || P.name -- Scan.optional (P.$$$ "output" >> K false) true; |
142 |
||
14900 | 143 |
val opt_mode = |
144 |
Scan.optional (P.$$$ "(" |-- P.!!! (mode_spec --| P.$$$ ")")) Syntax.default_mode; |
|
5832 | 145 |
|
146 |
val syntaxP = |
|
6723 | 147 |
OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
148 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Theory.add_modesyntax)); |
5832 | 149 |
|
15748 | 150 |
val no_syntaxP = |
151 |
OuterSyntax.command "no_syntax" "delete syntax declarations" K.thy_decl |
|
152 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Theory.del_modesyntax)); |
|
153 |
||
5832 | 154 |
|
155 |
(* translations *) |
|
156 |
||
157 |
val trans_pat = |
|
6723 | 158 |
Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string; |
5832 | 159 |
|
160 |
fun trans_arrow toks = |
|
10688 | 161 |
((P.$$$ "\\<rightharpoonup>" || P.$$$ "=>") >> K Syntax.ParseRule || |
162 |
(P.$$$ "\\<leftharpoondown>" || P.$$$ "<=") >> K Syntax.PrintRule || |
|
163 |
(P.$$$ "\\<rightleftharpoons>" || P.$$$ "==") >> K Syntax.ParsePrintRule) toks; |
|
5832 | 164 |
|
165 |
val trans_line = |
|
6723 | 166 |
trans_pat -- P.!!! (trans_arrow -- trans_pat) |
5832 | 167 |
>> (fn (left, (arr, right)) => arr (left, right)); |
168 |
||
169 |
val translationsP = |
|
6723 | 170 |
OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
171 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Theory.add_trrules)); |
5832 | 172 |
|
19260 | 173 |
val no_translationsP = |
174 |
OuterSyntax.command "no_translations" "remove syntax translation rules" K.thy_decl |
|
175 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Theory.del_trrules)); |
|
176 |
||
5832 | 177 |
|
178 |
(* axioms and definitions *) |
|
179 |
||
180 |
val axiomsP = |
|
6723 | 181 |
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
182 |
(Scan.repeat1 P.spec_name >> (Toplevel.theory o IsarThy.add_axioms)); |
5832 | 183 |
|
19631 | 184 |
val opt_unchecked_overloaded = |
185 |
Scan.optional (P.$$$ "(" |-- P.!!! |
|
186 |
(((P.$$$ "unchecked" >> K true) -- Scan.optional (P.$$$ "overloaded" >> K true) false || |
|
187 |
P.$$$ "overloaded" >> K (false, true)) --| P.$$$ ")")) (false, false); |
|
188 |
||
5832 | 189 |
val defsP = |
6723 | 190 |
OuterSyntax.command "defs" "define constants" K.thy_decl |
19631 | 191 |
(opt_unchecked_overloaded -- Scan.repeat1 P.spec_name |
192 |
>> (Toplevel.theory o IsarThy.add_defs)); |
|
6370 | 193 |
|
14642 | 194 |
|
19076 | 195 |
(* constant definitions and abbreviations *) |
14642 | 196 |
|
197 |
val constdecl = |
|
18670 | 198 |
(P.name --| P.$$$ "where") >> (fn x => (x, NONE, NoSyn)) || |
19219 | 199 |
P.name -- (P.$$$ "::" |-- P.!!! P.typ >> SOME) -- P.opt_mixfix' |
200 |
--| Scan.option (P.$$$ "where") >> P.triple1 || |
|
201 |
P.name -- (P.mixfix >> pair NONE) --| Scan.option (P.$$$ "where") >> P.triple2; |
|
19076 | 202 |
|
14642 | 203 |
val constdef = Scan.option constdecl -- (P.opt_thm_name ":" -- P.prop); |
204 |
||
19076 | 205 |
val structs = |
206 |
Scan.optional ((P.$$$ "(" -- P.$$$ "structure") |-- P.!!! (P.simple_fixes --| P.$$$ ")")) []; |
|
207 |
||
6370 | 208 |
val constdefsP = |
19076 | 209 |
OuterSyntax.command "constdefs" "old-style constant definition" K.thy_decl |
14642 | 210 |
(structs -- Scan.repeat1 constdef >> (Toplevel.theory o Constdefs.add_constdefs)); |
5832 | 211 |
|
18780 | 212 |
val definitionP = |
19076 | 213 |
OuterSyntax.command "definition" "constant definition" K.thy_decl |
18780 | 214 |
(P.opt_locale_target -- Scan.repeat1 constdef |
18949 | 215 |
>> (fn (loc, args) => Toplevel.local_theory loc (#2 o Specification.definition args))); |
18780 | 216 |
|
19076 | 217 |
val abbreviationP = |
218 |
OuterSyntax.command "abbreviation" "constant abbreviation" K.thy_decl |
|
19368 | 219 |
(P.opt_locale_target -- opt_mode -- |
19076 | 220 |
Scan.repeat1 (Scan.option constdecl -- P.prop) |
19659 | 221 |
>> (fn ((loc, mode), args) => |
222 |
Toplevel.local_theory loc (Specification.abbreviation mode args))); |
|
223 |
||
224 |
val const_syntaxP = |
|
225 |
OuterSyntax.command "const_syntax" "constant syntax" K.thy_decl |
|
226 |
(P.opt_locale_target -- opt_mode -- Scan.repeat1 (P.xname -- P.mixfix) |
|
227 |
>> (fn ((loc, mode), args) => |
|
228 |
Toplevel.local_theory loc (Specification.const_syntax mode args))); |
|
19076 | 229 |
|
5832 | 230 |
|
18616 | 231 |
(* constant specifications *) |
232 |
||
233 |
val axiomatizationP = |
|
234 |
OuterSyntax.command "axiomatization" "axiomatic constant specification" K.thy_decl |
|
18766 | 235 |
(P.opt_locale_target -- |
18949 | 236 |
(Scan.optional P.fixes [] -- |
237 |
Scan.optional (P.$$$ "where" |-- P.!!! (P.and_list1 P.spec)) []) |
|
238 |
>> (fn (loc, (x, y)) => Toplevel.local_theory loc (#2 o Specification.axiomatization x y))); |
|
18616 | 239 |
|
240 |
||
5914 | 241 |
(* theorems *) |
242 |
||
17353 | 243 |
fun theorems kind = P.opt_locale_target -- P.name_facts |
244 |
>> (Toplevel.theory_context o uncurry (IsarThy.smart_theorems kind)); |
|
12712 | 245 |
|
5914 | 246 |
val theoremsP = |
18799 | 247 |
OuterSyntax.command "theorems" "define theorems" K.thy_decl (theorems PureThy.theoremK); |
5914 | 248 |
|
249 |
val lemmasP = |
|
18799 | 250 |
OuterSyntax.command "lemmas" "define lemmas" K.thy_decl (theorems PureThy.lemmaK); |
5914 | 251 |
|
9589 | 252 |
val declareP = |
9776 | 253 |
OuterSyntax.command "declare" "declare theorems (improper)" K.thy_script |
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19431
diff
changeset
|
254 |
(P.opt_locale_target -- (P.and_list1 P.xthms1 >> flat) |
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
255 |
>> (Toplevel.theory_context o uncurry IsarThy.declare_theorems)); |
9589 | 256 |
|
5914 | 257 |
|
5832 | 258 |
(* name space entry path *) |
259 |
||
260 |
val globalP = |
|
6723 | 261 |
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl |
16447 | 262 |
(Scan.succeed (Toplevel.theory Sign.root_path)); |
5832 | 263 |
|
264 |
val localP = |
|
6723 | 265 |
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl |
16447 | 266 |
(Scan.succeed (Toplevel.theory Sign.local_path)); |
8723 | 267 |
|
268 |
val hideP = |
|
269 |
OuterSyntax.command "hide" "hide names from given name space" K.thy_decl |
|
17397 | 270 |
((P.opt_keyword "open" >> not) -- (P.name -- Scan.repeat1 P.xname) >> |
271 |
(Toplevel.theory o uncurry Sign.hide_names)); |
|
5832 | 272 |
|
273 |
||
274 |
(* use ML text *) |
|
275 |
||
276 |
val useP = |
|
17068 | 277 |
OuterSyntax.command "use" "eval ML text from file" (K.tag_ml K.diag) |
14950 | 278 |
(P.path >> (Toplevel.no_timing oo IsarCmd.use)); |
5832 | 279 |
|
280 |
val mlP = |
|
17068 | 281 |
OuterSyntax.command "ML" "eval ML text (diagnostic)" (K.tag_ml K.diag) |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
282 |
(P.text >> IsarCmd.use_mltext true); |
7891 | 283 |
|
284 |
val ml_commandP = |
|
17068 | 285 |
OuterSyntax.command "ML_command" "eval ML text" (K.tag_ml K.diag) |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
286 |
(P.text >> (Toplevel.no_timing oo IsarCmd.use_mltext false)); |
7616 | 287 |
|
288 |
val ml_setupP = |
|
17068 | 289 |
OuterSyntax.command "ML_setup" "eval ML text (may change theory)" (K.tag_ml K.thy_decl) |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
290 |
(P.text >> IsarCmd.use_mltext_theory); |
5832 | 291 |
|
292 |
val setupP = |
|
17068 | 293 |
OuterSyntax.command "setup" "apply ML theory setup" (K.tag_ml K.thy_decl) |
18670 | 294 |
(Scan.option P.text >> (Toplevel.theory o PureThy.generic_setup)); |
5832 | 295 |
|
9197 | 296 |
val method_setupP = |
17068 | 297 |
OuterSyntax.command "method_setup" "define proof method in ML" (K.tag_ml K.thy_decl) |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
298 |
(((P.name -- P.!!! (P.$$$ "=" |-- P.text -- P.text) >> P.triple2)) |
17353 | 299 |
>> (Toplevel.theory o Method.method_setup)); |
9197 | 300 |
|
5832 | 301 |
|
302 |
(* translation functions *) |
|
303 |
||
14642 | 304 |
val trfun = P.opt_keyword "advanced" -- P.text; |
305 |
||
5832 | 306 |
val parse_ast_translationP = |
17068 | 307 |
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" |
308 |
(K.tag_ml K.thy_decl) |
|
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
309 |
(trfun >> (Toplevel.theory o Sign.parse_ast_translation)); |
5832 | 310 |
|
311 |
val parse_translationP = |
|
17068 | 312 |
OuterSyntax.command "parse_translation" "install parse translation functions" |
313 |
(K.tag_ml K.thy_decl) |
|
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
314 |
(trfun >> (Toplevel.theory o Sign.parse_translation)); |
5832 | 315 |
|
316 |
val print_translationP = |
|
17068 | 317 |
OuterSyntax.command "print_translation" "install print translation functions" |
318 |
(K.tag_ml K.thy_decl) |
|
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
319 |
(trfun >> (Toplevel.theory o Sign.print_translation)); |
5832 | 320 |
|
321 |
val typed_print_translationP = |
|
6370 | 322 |
OuterSyntax.command "typed_print_translation" "install typed print translation functions" |
17068 | 323 |
(K.tag_ml K.thy_decl) |
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
324 |
(trfun >> (Toplevel.theory o Sign.typed_print_translation)); |
5832 | 325 |
|
326 |
val print_ast_translationP = |
|
17068 | 327 |
OuterSyntax.command "print_ast_translation" "install print ast translation functions" |
328 |
(K.tag_ml K.thy_decl) |
|
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
329 |
(trfun >> (Toplevel.theory o Sign.print_ast_translation)); |
5832 | 330 |
|
331 |
val token_translationP = |
|
17068 | 332 |
OuterSyntax.command "token_translation" "install token translation functions" |
333 |
(K.tag_ml K.thy_decl) |
|
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
334 |
(P.text >> (Toplevel.theory o Sign.token_translation)); |
5832 | 335 |
|
336 |
||
337 |
(* oracles *) |
|
338 |
||
339 |
val oracleP = |
|
17068 | 340 |
OuterSyntax.command "oracle" "declare oracle" (K.tag_ml K.thy_decl) |
16849 | 341 |
(P.name -- (P.$$$ "(" |-- P.text --| P.$$$ ")" --| P.$$$ "=") |
17353 | 342 |
-- P.text >> (Toplevel.theory o PureThy.add_oracle o P.triple1)); |
5832 | 343 |
|
344 |
||
12061 | 345 |
(* locales *) |
346 |
||
12758 | 347 |
val locale_val = |
348 |
(P.locale_expr -- |
|
18136 | 349 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 P.context_element)) [] || |
350 |
Scan.repeat1 P.context_element >> pair Locale.empty); |
|
12061 | 351 |
|
352 |
val localeP = |
|
353 |
OuterSyntax.command "locale" "define named proof context" K.thy_decl |
|
14642 | 354 |
((P.opt_keyword "open" >> not) -- P.name |
355 |
-- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (Locale.empty, []) |
|
18917 | 356 |
>> (Toplevel.theory_context o (fn ((is_open, name), (expr, elems)) => |
19293 | 357 |
Locale.add_locale is_open name expr elems #> (fn ((_, ctxt), thy) => (ctxt, thy))))); |
12061 | 358 |
|
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
359 |
val interpretationP = |
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
360 |
OuterSyntax.command "interpretation" |
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset
|
361 |
"prove and register interpretation of locale expression in theory or locale" K.thy_goal |
17353 | 362 |
(P.xname --| (P.$$$ "\\<subseteq>" || P.$$$ "<") -- P.!!! P.locale_expr |
20365 | 363 |
>> (Toplevel.print oo (Toplevel.theory_to_proof o Locale.interpretation_in_locale I)) || |
364 |
P.opt_thm_name ":" -- P.locale_expr -- P.locale_insts >> (fn ((x, y), z) => |
|
365 |
Toplevel.print o Toplevel.theory_to_proof (Locale.interpretation I x y z))); |
|
12061 | 366 |
|
15624
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
367 |
val interpretP = |
484178635bd8
Further work on interpretation commands. New command `interpret' for
ballarin
parents:
15598
diff
changeset
|
368 |
OuterSyntax.command "interpret" |
17068 | 369 |
"prove and register interpretation of locale expression in proof context" |
370 |
(K.tag_proof K.prf_goal) |
|
19809 | 371 |
(P.opt_thm_name ":" -- P.locale_expr -- P.locale_insts >> (fn ((x, y), z) => |
20365 | 372 |
Toplevel.print o Toplevel.proof' (Locale.interpret Seq.single x y z))); |
15703 | 373 |
|
374 |
||
5832 | 375 |
|
376 |
(** proof commands **) |
|
377 |
||
378 |
(* statements *) |
|
379 |
||
17353 | 380 |
fun gen_theorem kind = |
381 |
OuterSyntax.command kind ("state " ^ kind) K.thy_goal |
|
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset
|
382 |
(P.opt_locale_target -- Scan.optional (P.opt_thm_name ":" --| |
18895 | 383 |
Scan.ahead (P.locale_keyword || P.statement_keyword)) ("", []) -- |
384 |
P.general_statement >> (fn ((x, y), (z, w)) => |
|
17353 | 385 |
(Toplevel.print o Toplevel.theory_to_proof (Locale.smart_theorem kind x y z w)))); |
5832 | 386 |
|
18799 | 387 |
val theoremP = gen_theorem PureThy.theoremK; |
388 |
val lemmaP = gen_theorem PureThy.lemmaK; |
|
389 |
val corollaryP = gen_theorem PureThy.corollaryK; |
|
5832 | 390 |
|
17353 | 391 |
val haveP = |
392 |
OuterSyntax.command "have" "state local goal" |
|
393 |
(K.tag_proof K.prf_goal) |
|
18895 | 394 |
(P.statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.have)); |
17353 | 395 |
|
396 |
val henceP = |
|
397 |
OuterSyntax.command "hence" "abbreviates \"then have\"" |
|
398 |
(K.tag_proof K.prf_goal) |
|
18895 | 399 |
(P.statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.hence)); |
17353 | 400 |
|
5832 | 401 |
val showP = |
17068 | 402 |
OuterSyntax.command "show" "state local goal, solving current obligation" |
403 |
(K.tag_proof K.prf_goal) |
|
18895 | 404 |
(P.statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.show)); |
5832 | 405 |
|
6501 | 406 |
val thusP = |
17068 | 407 |
OuterSyntax.command "thus" "abbreviates \"then show\"" |
408 |
(K.tag_proof K.prf_goal) |
|
18895 | 409 |
(P.statement >> ((Toplevel.print oo Toplevel.proof') o IsarThy.thus)); |
6501 | 410 |
|
5832 | 411 |
|
5914 | 412 |
(* facts *) |
5832 | 413 |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
414 |
val facts = P.and_list1 P.xthms1; |
9197 | 415 |
|
5832 | 416 |
val thenP = |
17068 | 417 |
OuterSyntax.command "then" "forward chaining" |
418 |
(K.tag_proof K.prf_chain) |
|
17900 | 419 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 420 |
|
421 |
val fromP = |
|
17068 | 422 |
OuterSyntax.command "from" "forward chaining from given facts" |
423 |
(K.tag_proof K.prf_chain) |
|
17900 | 424 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss))); |
5914 | 425 |
|
6878 | 426 |
val withP = |
17068 | 427 |
OuterSyntax.command "with" "forward chaining from given and current facts" |
428 |
(K.tag_proof K.prf_chain) |
|
17900 | 429 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss))); |
6878 | 430 |
|
6773 | 431 |
val noteP = |
17068 | 432 |
OuterSyntax.command "note" "define facts" |
433 |
(K.tag_proof K.prf_decl) |
|
17900 | 434 |
(P.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss))); |
5832 | 435 |
|
12926 | 436 |
val usingP = |
17068 | 437 |
OuterSyntax.command "using" "augment goal facts" |
438 |
(K.tag_proof K.prf_decl) |
|
18544 | 439 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using))); |
440 |
||
441 |
val unfoldingP = |
|
442 |
OuterSyntax.command "unfolding" "unfold definitions in goal and facts" |
|
443 |
(K.tag_proof K.prf_decl) |
|
444 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding))); |
|
12926 | 445 |
|
5832 | 446 |
|
447 |
(* proof context *) |
|
448 |
||
11890 | 449 |
val fixP = |
17068 | 450 |
OuterSyntax.command "fix" "fix local variables (Skolem constants)" |
451 |
(K.tag_proof K.prf_asm) |
|
19844 | 452 |
(P.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix))); |
11890 | 453 |
|
5832 | 454 |
val assumeP = |
17068 | 455 |
OuterSyntax.command "assume" "assume propositions" |
456 |
(K.tag_proof K.prf_asm) |
|
18895 | 457 |
(P.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume))); |
5832 | 458 |
|
6850 | 459 |
val presumeP = |
17068 | 460 |
OuterSyntax.command "presume" "assume propositions, to be established later" |
461 |
(K.tag_proof K.prf_asm) |
|
18895 | 462 |
(P.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume))); |
6850 | 463 |
|
6953 | 464 |
val defP = |
17068 | 465 |
OuterSyntax.command "def" "local definition" |
466 |
(K.tag_proof K.prf_asm) |
|
18308 | 467 |
(P.and_list1 |
19844 | 468 |
(P.opt_thm_name ":" -- |
469 |
((P.name -- P.opt_mixfix) -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp))) |
|
18308 | 470 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def))); |
6953 | 471 |
|
11890 | 472 |
val obtainP = |
473 |
OuterSyntax.command "obtain" "generalized existence" |
|
17068 | 474 |
(K.tag_proof K.prf_asm_goal) |
19844 | 475 |
(P.parname -- Scan.optional (P.fixes --| P.$$$ "where") [] -- P.statement |
18895 | 476 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain x y z))); |
5832 | 477 |
|
17854 | 478 |
val guessP = |
479 |
OuterSyntax.command "guess" "wild guessing (unstructured)" |
|
480 |
(K.tag_proof K.prf_asm_goal) |
|
19844 | 481 |
(Scan.optional P.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess))); |
17854 | 482 |
|
5832 | 483 |
val letP = |
17068 | 484 |
OuterSyntax.command "let" "bind text variables" |
485 |
(K.tag_proof K.prf_decl) |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
486 |
(P.and_list1 (P.enum1 "and" P.term -- (P.$$$ "=" |-- P.term)) |
17900 | 487 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind))); |
5832 | 488 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
489 |
val case_spec = |
15703 | 490 |
(P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.maybe P.name) --| P.$$$ ")") || |
12267 | 491 |
P.xname >> rpair []) -- P.opt_attribs >> P.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
492 |
|
8370 | 493 |
val caseP = |
17068 | 494 |
OuterSyntax.command "case" "invoke local context" |
495 |
(K.tag_proof K.prf_asm) |
|
17900 | 496 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case))); |
8370 | 497 |
|
5832 | 498 |
|
499 |
(* proof structure *) |
|
500 |
||
501 |
val beginP = |
|
17068 | 502 |
OuterSyntax.command "{" "begin explicit proof block" |
503 |
(K.tag_proof K.prf_open) |
|
17900 | 504 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 505 |
|
6687 | 506 |
val endP = |
17068 | 507 |
OuterSyntax.command "}" "end explicit proof block" |
508 |
(K.tag_proof K.prf_close) |
|
20305 | 509 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 510 |
|
5832 | 511 |
val nextP = |
17068 | 512 |
OuterSyntax.command "next" "enter next proof block" |
513 |
(K.tag_proof K.prf_block) |
|
17900 | 514 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 515 |
|
516 |
||
517 |
(* end proof *) |
|
518 |
||
6404 | 519 |
val qedP = |
17068 | 520 |
OuterSyntax.command "qed" "conclude (sub-)proof" |
521 |
(K.tag_proof K.qed_block) |
|
17353 | 522 |
(Scan.option P.method >> (Toplevel.print3 oo IsarThy.qed)); |
5832 | 523 |
|
6404 | 524 |
val terminal_proofP = |
17068 | 525 |
OuterSyntax.command "by" "terminal backward proof" |
526 |
(K.tag_proof K.qed) |
|
17353 | 527 |
(P.method -- Scan.option P.method >> (Toplevel.print3 oo IsarThy.terminal_proof)); |
6404 | 528 |
|
8966 | 529 |
val default_proofP = |
17068 | 530 |
OuterSyntax.command ".." "default proof" |
531 |
(K.tag_proof K.qed) |
|
17353 | 532 |
(Scan.succeed (Toplevel.print3 o IsarThy.default_proof)); |
8966 | 533 |
|
6404 | 534 |
val immediate_proofP = |
17068 | 535 |
OuterSyntax.command "." "immediate proof" |
536 |
(K.tag_proof K.qed) |
|
17353 | 537 |
(Scan.succeed (Toplevel.print3 o IsarThy.immediate_proof)); |
6404 | 538 |
|
8966 | 539 |
val done_proofP = |
17068 | 540 |
OuterSyntax.command "done" "done proof" |
541 |
(K.tag_proof K.qed) |
|
17353 | 542 |
(Scan.succeed (Toplevel.print3 o IsarThy.done_proof)); |
5832 | 543 |
|
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
544 |
val skip_proofP = |
17068 | 545 |
OuterSyntax.improper_command "sorry" "skip proof (quick-and-dirty mode only!)" |
546 |
(K.tag_proof K.qed) |
|
17353 | 547 |
(Scan.succeed (Toplevel.print3 o IsarThy.skip_proof)); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
548 |
|
8210 | 549 |
val forget_proofP = |
17068 | 550 |
OuterSyntax.command "oops" "forget proof" |
551 |
(K.tag_proof K.qed_global) |
|
18561 | 552 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 553 |
|
5832 | 554 |
|
555 |
(* proof steps *) |
|
556 |
||
8165 | 557 |
val deferP = |
17068 | 558 |
OuterSyntax.command "defer" "shuffle internal proof state" |
559 |
(K.tag_proof K.prf_script) |
|
17900 | 560 |
(Scan.option P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
8165 | 561 |
|
562 |
val preferP = |
|
17068 | 563 |
OuterSyntax.command "prefer" "shuffle internal proof state" |
564 |
(K.tag_proof K.prf_script) |
|
17900 | 565 |
(P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
8165 | 566 |
|
6850 | 567 |
val applyP = |
17068 | 568 |
OuterSyntax.command "apply" "initial refinement step (unstructured)" |
569 |
(K.tag_proof K.prf_script) |
|
17900 | 570 |
(P.method >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 571 |
|
8235 | 572 |
val apply_endP = |
17068 | 573 |
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" |
574 |
(K.tag_proof K.prf_script) |
|
17900 | 575 |
(P.method >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 576 |
|
6404 | 577 |
val proofP = |
17068 | 578 |
OuterSyntax.command "proof" "backward proof" |
579 |
(K.tag_proof K.prf_block) |
|
16812 | 580 |
(Scan.option P.method >> (fn m => Toplevel.print o |
17107
2c35e00ee2ab
various Toplevel.theory_context commands: proper presentation in context;
wenzelm
parents:
17068
diff
changeset
|
581 |
Toplevel.actual_proof (ProofHistory.applys (Proof.proof m)) o |
15237
250e9be7a09d
Some changes to allow skipping of proof scripts.
berghofe
parents:
15141
diff
changeset
|
582 |
Toplevel.skip_proof (History.apply (fn i => i + 1)))); |
5832 | 583 |
|
584 |
||
6773 | 585 |
(* calculational proof commands *) |
586 |
||
6878 | 587 |
val calc_args = |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
588 |
Scan.option (P.$$$ "(" |-- P.!!! ((P.xthms1 --| P.$$$ ")"))); |
6878 | 589 |
|
6773 | 590 |
val alsoP = |
17068 | 591 |
OuterSyntax.command "also" "combine calculation and current facts" |
592 |
(K.tag_proof K.prf_decl) |
|
17900 | 593 |
(calc_args >> (Toplevel.proofs' o Calculation.also)); |
6773 | 594 |
|
595 |
val finallyP = |
|
17068 | 596 |
OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" |
597 |
(K.tag_proof K.prf_chain) |
|
17900 | 598 |
(calc_args >> (Toplevel.proofs' o Calculation.finally)); |
6773 | 599 |
|
8562 | 600 |
val moreoverP = |
17068 | 601 |
OuterSyntax.command "moreover" "augment calculation by current facts" |
602 |
(K.tag_proof K.prf_decl) |
|
17900 | 603 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 604 |
|
8588 | 605 |
val ultimatelyP = |
606 |
OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result" |
|
17068 | 607 |
(K.tag_proof K.prf_chain) |
17900 | 608 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 609 |
|
6773 | 610 |
|
6742 | 611 |
(* proof navigation *) |
5944 | 612 |
|
5832 | 613 |
val backP = |
17068 | 614 |
OuterSyntax.command "back" "backtracking of proof command" |
615 |
(K.tag_proof K.prf_script) |
|
616 |
(Scan.succeed (Toplevel.print o IsarCmd.back)); |
|
5832 | 617 |
|
618 |
||
6742 | 619 |
(* history *) |
620 |
||
621 |
val cannot_undoP = |
|
622 |
OuterSyntax.improper_command "cannot_undo" "report 'cannot undo' error message" K.control |
|
9010 | 623 |
(P.name >> (Toplevel.no_timing oo IsarCmd.cannot_undo)); |
6742 | 624 |
|
7733 | 625 |
val clear_undosP = |
626 |
OuterSyntax.improper_command "clear_undos" "clear theory-level undo information" K.control |
|
9010 | 627 |
(P.nat >> (Toplevel.no_timing oo IsarCmd.clear_undos_theory)); |
6742 | 628 |
|
629 |
val redoP = |
|
630 |
OuterSyntax.improper_command "redo" "redo last command" K.control |
|
9010 | 631 |
(Scan.succeed (Toplevel.no_timing o Toplevel.print o IsarCmd.redo)); |
6742 | 632 |
|
633 |
val undos_proofP = |
|
634 |
OuterSyntax.improper_command "undos_proof" "undo last proof commands" K.control |
|
9010 | 635 |
(P.nat >> ((Toplevel.no_timing o Toplevel.print) oo IsarCmd.undos_proof)); |
6742 | 636 |
|
637 |
val undoP = |
|
638 |
OuterSyntax.improper_command "undo" "undo last command" K.control |
|
9010 | 639 |
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.undo)); |
6742 | 640 |
|
8500 | 641 |
val killP = |
642 |
OuterSyntax.improper_command "kill" "kill current history node" K.control |
|
9010 | 643 |
(Scan.succeed ((Toplevel.no_timing o Toplevel.print) o IsarCmd.kill)); |
8500 | 644 |
|
6742 | 645 |
|
5832 | 646 |
|
647 |
(** diagnostic commands (for interactive mode only) **) |
|
648 |
||
8464 | 649 |
val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) []; |
20621 | 650 |
val opt_bang = Scan.optional (P.$$$ "!" >> K true) false; |
8464 | 651 |
|
7124 | 652 |
val pretty_setmarginP = |
653 |
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
|
9010 | 654 |
K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin)); |
7124 | 655 |
|
5832 | 656 |
val print_commandsP = |
9221 | 657 |
OuterSyntax.improper_command "print_commands" "print outer syntax (global)" K.diag |
658 |
(Scan.succeed (Toplevel.no_timing o OuterSyntax.print_commands)); |
|
5832 | 659 |
|
7308 | 660 |
val print_contextP = |
661 |
OuterSyntax.improper_command "print_context" "print theory context name" K.diag |
|
9010 | 662 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_context)); |
7308 | 663 |
|
5832 | 664 |
val print_theoryP = |
6723 | 665 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag |
20621 | 666 |
(opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theory)); |
5832 | 667 |
|
668 |
val print_syntaxP = |
|
6723 | 669 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of theory (verbose!)" K.diag |
9010 | 670 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax)); |
5832 | 671 |
|
5881 | 672 |
val print_theoremsP = |
17068 | 673 |
OuterSyntax.improper_command "print_theorems" |
674 |
"print theorems of local theory or proof context" K.diag |
|
9010 | 675 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems)); |
5881 | 676 |
|
12061 | 677 |
val print_localesP = |
678 |
OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag |
|
679 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_locales)); |
|
680 |
||
681 |
val print_localeP = |
|
15596 | 682 |
OuterSyntax.improper_command "print_locale" "print locale expression in this theory" K.diag |
20621 | 683 |
(opt_bang -- locale_val >> (Toplevel.no_timing oo IsarCmd.print_locale)); |
12061 | 684 |
|
15596 | 685 |
val print_registrationsP = |
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
686 |
OuterSyntax.improper_command "print_interps" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16074
diff
changeset
|
687 |
"print interpretations of named locale" K.diag |
18670 | 688 |
(Scan.optional (P.$$$ "!" >> K true) false -- P.xname |
689 |
>> (Toplevel.no_timing oo uncurry IsarCmd.print_registrations)); |
|
15596 | 690 |
|
5832 | 691 |
val print_attributesP = |
12061 | 692 |
OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag |
9010 | 693 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes)); |
5832 | 694 |
|
16027 | 695 |
val print_simpsetP = |
696 |
OuterSyntax.improper_command "print_simpset" "print context of Simplifier" K.diag |
|
697 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_simpset)); |
|
698 |
||
12383 | 699 |
val print_rulesP = |
700 |
OuterSyntax.improper_command "print_rules" "print intro/elim rules" K.diag |
|
701 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_rules)); |
|
702 |
||
11666 | 703 |
val print_induct_rulesP = |
704 |
OuterSyntax.improper_command "print_induct_rules" "print induction and cases rules" K.diag |
|
705 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_induct_rules)); |
|
706 |
||
9221 | 707 |
val print_trans_rulesP = |
11666 | 708 |
OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag |
9221 | 709 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules)); |
710 |
||
5832 | 711 |
val print_methodsP = |
12061 | 712 |
OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag |
9010 | 713 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods)); |
5832 | 714 |
|
9221 | 715 |
val print_antiquotationsP = |
716 |
OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag |
|
717 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations)); |
|
718 |
||
20574 | 719 |
val class_depsP = |
720 |
OuterSyntax.improper_command "class_deps" "visualize class dependencies" |
|
721 |
K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.class_deps)); |
|
722 |
||
9454 | 723 |
val thm_depsP = |
724 |
OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies" |
|
725 |
K.diag (P.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps)); |
|
726 |
||
16027 | 727 |
val criterion = |
728 |
P.reserved "name" |-- P.!!! (P.$$$ ":" |-- P.xname) >> FindTheorems.Name || |
|
729 |
P.reserved "intro" >> K FindTheorems.Intro || |
|
730 |
P.reserved "elim" >> K FindTheorems.Elim || |
|
731 |
P.reserved "dest" >> K FindTheorems.Dest || |
|
16074 | 732 |
P.reserved "simp" |-- P.!!! (P.$$$ ":" |-- P.term) >> FindTheorems.Simp || |
16027 | 733 |
P.term >> FindTheorems.Pattern; |
734 |
||
735 |
val find_theoremsP = |
|
17219
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
736 |
OuterSyntax.improper_command "find_theorems" |
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
737 |
"print theorems meeting specified criteria" K.diag |
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
738 |
(Scan.option (P.$$$ "(" |-- P.!!! (P.nat --| P.$$$ ")")) -- |
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
739 |
Scan.repeat (((Scan.option P.minus >> is_none) -- criterion)) |
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
740 |
>> (Toplevel.no_timing oo IsarCmd.find_theorems)); |
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
741 |
|
5832 | 742 |
val print_bindsP = |
6723 | 743 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag |
9010 | 744 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds)); |
5832 | 745 |
|
746 |
val print_lthmsP = |
|
8370 | 747 |
OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag |
9010 | 748 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_lthms)); |
5832 | 749 |
|
8370 | 750 |
val print_casesP = |
751 |
OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag |
|
9010 | 752 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases)); |
8370 | 753 |
|
19269 | 754 |
val print_stmtsP = |
755 |
OuterSyntax.improper_command "print_statement" "print theorems as long statements" K.diag |
|
756 |
(opt_modes -- P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_stmts)); |
|
757 |
||
5896 | 758 |
val print_thmsP = |
8464 | 759 |
OuterSyntax.improper_command "thm" "print theorems" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
760 |
(opt_modes -- P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms)); |
5832 | 761 |
|
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
762 |
val print_prfsP = |
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
763 |
OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
764 |
(opt_modes -- Scan.option P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs false)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
765 |
|
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
766 |
val print_full_prfsP = |
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
767 |
OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
768 |
(opt_modes -- Scan.option P.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs true)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
769 |
|
5832 | 770 |
val print_propP = |
6723 | 771 |
OuterSyntax.improper_command "prop" "read and print proposition" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
772 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_prop)); |
5832 | 773 |
|
774 |
val print_termP = |
|
6723 | 775 |
OuterSyntax.improper_command "term" "read and print term" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
776 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_term)); |
5832 | 777 |
|
778 |
val print_typeP = |
|
6723 | 779 |
OuterSyntax.improper_command "typ" "read and print type" K.diag |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
780 |
(opt_modes -- P.typ >> (Toplevel.no_timing oo IsarCmd.print_type)); |
5832 | 781 |
|
782 |
||
783 |
||
784 |
(** system commands (for interactive mode only) **) |
|
785 |
||
786 |
val cdP = |
|
8650 | 787 |
OuterSyntax.improper_command "cd" "change current working directory" K.diag |
14950 | 788 |
(P.path >> (Toplevel.no_timing oo IsarCmd.cd)); |
5832 | 789 |
|
790 |
val pwdP = |
|
6723 | 791 |
OuterSyntax.improper_command "pwd" "print current working directory" K.diag |
9010 | 792 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.pwd)); |
5832 | 793 |
|
794 |
val use_thyP = |
|
6723 | 795 |
OuterSyntax.improper_command "use_thy" "use theory file" K.diag |
9010 | 796 |
(P.name >> (Toplevel.no_timing oo IsarCmd.use_thy)); |
5832 | 797 |
|
6694 | 798 |
val use_thy_onlyP = |
7102 | 799 |
OuterSyntax.improper_command "use_thy_only" "use theory file only, ignoring associated ML" |
9010 | 800 |
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.use_thy_only)); |
6694 | 801 |
|
6196 | 802 |
val update_thyP = |
6723 | 803 |
OuterSyntax.improper_command "update_thy" "update theory file" K.diag |
9010 | 804 |
(P.name >> (Toplevel.no_timing oo IsarCmd.update_thy)); |
5832 | 805 |
|
7102 | 806 |
val update_thy_onlyP = |
807 |
OuterSyntax.improper_command "update_thy_only" "update theory file, ignoring associated ML" |
|
9010 | 808 |
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.update_thy_only)); |
7102 | 809 |
|
810 |
val touch_thyP = |
|
811 |
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag |
|
9010 | 812 |
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_thy)); |
7102 | 813 |
|
814 |
val touch_all_thysP = |
|
815 |
OuterSyntax.improper_command "touch_all_thys" "outdate all non-finished theories" K.diag |
|
9010 | 816 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.touch_all_thys)); |
7102 | 817 |
|
7908 | 818 |
val touch_child_thysP = |
819 |
OuterSyntax.improper_command "touch_child_thys" "outdate child theories" K.diag |
|
9010 | 820 |
(P.name >> (Toplevel.no_timing oo IsarCmd.touch_child_thys)); |
7908 | 821 |
|
7102 | 822 |
val remove_thyP = |
823 |
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag |
|
9010 | 824 |
(P.name >> (Toplevel.no_timing oo IsarCmd.remove_thy)); |
7102 | 825 |
|
7931 | 826 |
val kill_thyP = |
827 |
OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
|
9010 | 828 |
K.diag (P.name >> (Toplevel.no_timing oo IsarCmd.kill_thy)); |
7931 | 829 |
|
14934 | 830 |
val display_draftsP = |
831 |
OuterSyntax.improper_command "display_drafts" "display raw source files with symbols" |
|
14950 | 832 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.display_drafts)); |
14934 | 833 |
|
834 |
val print_draftsP = |
|
835 |
OuterSyntax.improper_command "print_drafts" "print raw source files with symbols" |
|
14950 | 836 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.print_drafts)); |
14934 | 837 |
|
9731 | 838 |
val opt_limits = |
839 |
Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat); |
|
840 |
||
5832 | 841 |
val prP = |
8886 | 842 |
OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag |
9731 | 843 |
(opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr)); |
7199 | 844 |
|
7222 | 845 |
val disable_prP = |
846 |
OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag |
|
9010 | 847 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr)); |
5832 | 848 |
|
7222 | 849 |
val enable_prP = |
850 |
OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag |
|
9010 | 851 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr)); |
7222 | 852 |
|
5832 | 853 |
val commitP = |
6723 | 854 |
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag |
9010 | 855 |
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.use_commit)); |
5832 | 856 |
|
857 |
val quitP = |
|
6723 | 858 |
OuterSyntax.improper_command "quit" "quit Isabelle" K.control |
9010 | 859 |
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit)); |
5832 | 860 |
|
861 |
val exitP = |
|
6723 | 862 |
OuterSyntax.improper_command "exit" "exit Isar loop" K.control |
9010 | 863 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.exit)); |
5832 | 864 |
|
7102 | 865 |
val init_toplevelP = |
866 |
OuterSyntax.improper_command "init_toplevel" "restart Isar toplevel loop" K.control |
|
9010 | 867 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.init_toplevel)); |
5991 | 868 |
|
7462 | 869 |
val welcomeP = |
8678 | 870 |
OuterSyntax.improper_command "welcome" "print welcome message" K.diag |
9010 | 871 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.welcome)); |
7462 | 872 |
|
5832 | 873 |
|
874 |
||
875 |
(** the Pure outer syntax **) |
|
876 |
||
877 |
(*keep keywords consistent with the parsers, including those in |
|
878 |
outer_parse.ML, otherwise be prepared for unexpected errors*) |
|
879 |
||
16038 | 880 |
val _ = OuterSyntax.add_keywords |
17068 | 881 |
["!", "!!", "%", "(", ")", "+", ",", "--", ":", "::", ";", "<", "<=", |
882 |
"=", "==", "=>", "?", "[", "]", "advanced", "and", "assumes", |
|
19809 | 883 |
"begin", "binder", "concl", "constrains", "defines", "fixes", "for", |
884 |
"imports", "if", "in", "includes", "infix", "infixl", "infixr", |
|
885 |
"is", "notes", "obtains", "open", "output", "overloaded", "shows", |
|
19631 | 886 |
"structure", "unchecked", "uses", "where", "|", "\\<equiv>", |
18895 | 887 |
"\\<leftharpoondown>", "\\<rightharpoonup>", |
888 |
"\\<rightleftharpoons>", "\\<subseteq>"]; |
|
5832 | 889 |
|
16038 | 890 |
val _ = OuterSyntax.add_parsers [ |
5832 | 891 |
(*theory structure*) |
8500 | 892 |
theoryP, end_excursionP, contextP, |
7775 | 893 |
(*markup commands*) |
7733 | 894 |
headerP, chapterP, sectionP, subsectionP, subsubsectionP, textP, |
7862 | 895 |
text_rawP, sectP, subsectP, subsubsectP, txtP, txt_rawP, |
5832 | 896 |
(*theory sections*) |
19245 | 897 |
classesP, classrelP, defaultsortP, axclassP, typedeclP, typeabbrP, |
898 |
nontermP, aritiesP, judgmentP, constsP, finalconstsP, syntaxP, |
|
19260 | 899 |
no_syntaxP, translationsP, no_translationsP, axiomsP, defsP, |
19659 | 900 |
constdefsP, definitionP, abbreviationP, const_syntaxP, |
901 |
axiomatizationP, theoremsP, lemmasP, declareP, globalP, localP, |
|
902 |
hideP, useP, mlP, ml_commandP, ml_setupP, setupP, method_setupP, |
|
903 |
parse_ast_translationP, parse_translationP, print_translationP, |
|
904 |
typed_print_translationP, print_ast_translationP, |
|
905 |
token_translationP, oracleP, localeP, |
|
5832 | 906 |
(*proof commands*) |
17353 | 907 |
theoremP, lemmaP, corollaryP, haveP, henceP, showP, thusP, fixP, |
17854 | 908 |
assumeP, presumeP, defP, obtainP, guessP, letP, caseP, thenP, fromP, |
18544 | 909 |
withP, noteP, usingP, unfoldingP, beginP, endP, nextP, qedP, |
910 |
terminal_proofP, default_proofP, immediate_proofP, done_proofP, |
|
911 |
skip_proofP, forget_proofP, deferP, preferP, applyP, apply_endP, |
|
912 |
proofP, alsoP, finallyP, moreoverP, ultimatelyP, backP, |
|
913 |
cannot_undoP, clear_undosP, redoP, undos_proofP, undoP, killP, |
|
914 |
interpretationP, interpretP, |
|
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
915 |
(*diagnostic commands*) |
19269 | 916 |
pretty_setmarginP, print_commandsP, print_contextP, print_theoryP, |
917 |
print_syntaxP, print_theoremsP, print_localesP, print_localeP, |
|
16027 | 918 |
print_registrationsP, print_attributesP, print_simpsetP, |
919 |
print_rulesP, print_induct_rulesP, print_trans_rulesP, |
|
20574 | 920 |
print_methodsP, print_antiquotationsP, class_depsP, thm_depsP, |
921 |
find_theoremsP, print_bindsP, print_lthmsP, print_casesP, |
|
922 |
print_stmtsP, print_thmsP, print_prfsP, print_full_prfsP, |
|
923 |
print_propP, print_termP, print_typeP, |
|
5832 | 924 |
(*system commands*) |
7102 | 925 |
cdP, pwdP, use_thyP, use_thy_onlyP, update_thyP, update_thy_onlyP, |
7931 | 926 |
touch_thyP, touch_all_thysP, touch_child_thysP, remove_thyP, |
14934 | 927 |
kill_thyP, display_draftsP, print_draftsP, prP, disable_prP, |
928 |
enable_prP, commitP, quitP, exitP, init_toplevelP, welcomeP]; |
|
5832 | 929 |
|
930 |
end; |