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