author | haftmann |
Wed, 07 Jan 2009 08:03:25 +0100 | |
changeset 29378 | 2821c2c5270d |
parent 29363 | c1f024b4d76d |
child 29390 | 5c26e3a63b8e |
permissions | -rw-r--r-- |
5832 | 1 |
(* Title: Pure/Isar/isar_syn.ML |
2 |
Author: Markus Wenzel, TU Muenchen |
|
3 |
||
6353 | 4 |
Isar/Pure outer syntax. |
5832 | 5 |
*) |
6 |
||
17353 | 7 |
structure IsarSyn: sig end = |
5832 | 8 |
struct |
9 |
||
17068 | 10 |
structure P = OuterParse and K = OuterKeyword; |
5832 | 11 |
|
12 |
||
24868 | 13 |
(** keywords **) |
14 |
||
15 |
(*keep keywords consistent with the parsers, otherwise be prepared for |
|
16 |
unexpected errors*) |
|
17 |
||
27353
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
27200
diff
changeset
|
18 |
val _ = List.app OuterKeyword.keyword |
24868 | 19 |
["!!", "!", "%", "(", ")", "+", ",", "--", ":", "::", ";", "<", "<=", |
20 |
"=", "==", "=>", "?", "[", "\\<equiv>", "\\<leftharpoondown>", |
|
21 |
"\\<rightharpoonup>", "\\<rightleftharpoons>", "\\<subseteq>", "]", |
|
26888 | 22 |
"advanced", "and", "assumes", "attach", "begin", "binder", |
24868 | 23 |
"constrains", "defines", "fixes", "for", "identifier", "if", |
28721 | 24 |
"imports", "in", "infix", "infixl", "infixr", "is", |
25003 | 25 |
"notes", "obtains", "open", "output", "overloaded", "shows", |
24868 | 26 |
"structure", "unchecked", "uses", "where", "|"]; |
27 |
||
28 |
||
5832 | 29 |
(** init and exit **) |
30 |
||
24868 | 31 |
val _ = |
17068 | 32 |
OuterSyntax.command "theory" "begin theory" (K.tag_theory K.thy_begin) |
27575 | 33 |
(ThyHeader.args >> (Toplevel.print oo IsarCmd.init_theory)); |
5832 | 34 |
|
24868 | 35 |
val _ = |
20958 | 36 |
OuterSyntax.command "end" "end (local) theory" (K.tag_theory K.thy_end) |
21004 | 37 |
(Scan.succeed (Toplevel.exit o Toplevel.end_local_theory)); |
6687 | 38 |
|
5832 | 39 |
|
7749 | 40 |
(** markup commands **) |
5832 | 41 |
|
24868 | 42 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "header" "theory header" K.diag |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
43 |
(P.doc_source >> IsarCmd.header_markup); |
6353 | 44 |
|
24868 | 45 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "chapter" "chapter heading" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
46 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 47 |
|
24868 | 48 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "section" "section heading" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
49 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 50 |
|
24868 | 51 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "subsection" "subsection heading" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
52 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 53 |
|
24868 | 54 |
val _ = |
22117 | 55 |
OuterSyntax.markup_command ThyOutput.Markup "subsubsection" "subsubsection heading" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
56 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5832 | 57 |
|
24868 | 58 |
val _ = OuterSyntax.markup_command ThyOutput.MarkupEnv "text" "formal comment (theory)" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
59 |
K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
7172 | 60 |
|
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
61 |
val _ = OuterSyntax.markup_command ThyOutput.Verbatim "text_raw" "raw document preparation text" |
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
62 |
K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
7172 | 63 |
|
24868 | 64 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "sect" "formal comment (proof)" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
65 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 66 |
|
24868 | 67 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "subsect" "formal comment (proof)" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
68 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 69 |
|
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
70 |
val _ = OuterSyntax.markup_command ThyOutput.Markup "subsubsect" "formal comment (proof)" |
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
71 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 72 |
|
24868 | 73 |
val _ = OuterSyntax.markup_command ThyOutput.MarkupEnv "txt" "formal comment (proof)" |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
74 |
(K.tag_proof K.prf_decl) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 75 |
|
24868 | 76 |
val _ = OuterSyntax.markup_command ThyOutput.Verbatim "txt_raw" |
17068 | 77 |
"raw document preparation text (proof)" (K.tag_proof K.prf_decl) |
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
78 |
(P.doc_source >> IsarCmd.proof_markup); |
7775 | 79 |
|
5832 | 80 |
|
6886 | 81 |
|
82 |
(** theory sections **) |
|
83 |
||
5832 | 84 |
(* classes and sorts *) |
85 |
||
24868 | 86 |
val _ = |
6723 | 87 |
OuterSyntax.command "classes" "declare type classes" K.thy_decl |
11101
014e7b5c77ba
support \<subseteq> syntax in classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
88 |
(Scan.repeat1 (P.name -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- |
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
89 |
P.!!! (P.list1 P.xname)) []) >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd)); |
5832 | 90 |
|
24868 | 91 |
val _ = |
6723 | 92 |
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl |
14779 | 93 |
(P.and_list1 (P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname)) |
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
94 |
>> (Toplevel.theory o AxClass.axiomatize_classrel_cmd)); |
5832 | 95 |
|
24868 | 96 |
val _ = |
6723 | 97 |
OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl |
22796 | 98 |
(P.sort >> (Toplevel.theory o Sign.add_defsort)); |
5832 | 99 |
|
24868 | 100 |
val _ = |
19245 | 101 |
OuterSyntax.command "axclass" "define axiomatic type class" K.thy_decl |
21462
74ddf3a522f8
added Isar syntax for adding parameters to axclasses
haftmann
parents:
21437
diff
changeset
|
102 |
(P.name -- Scan.optional ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- |
74ddf3a522f8
added Isar syntax for adding parameters to axclasses
haftmann
parents:
21437
diff
changeset
|
103 |
P.!!! (P.list1 P.xname)) [] |
22117 | 104 |
-- Scan.repeat (SpecParse.thm_name ":" -- (P.prop >> single)) |
24219 | 105 |
>> (fn (x, y) => Toplevel.theory (snd o Class.axclass_cmd x y))); |
19245 | 106 |
|
5832 | 107 |
|
108 |
(* types *) |
|
109 |
||
24868 | 110 |
val _ = |
12624 | 111 |
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
|
112 |
(P.type_args -- P.name -- P.opt_infix >> (fn ((args, a), mx) => |
25495 | 113 |
Toplevel.theory (ObjectLogic.typedecl (a, args, mx) #> snd))); |
5832 | 114 |
|
24868 | 115 |
val _ = |
6723 | 116 |
OuterSyntax.command "types" "declare type abbreviations" K.thy_decl |
6727 | 117 |
(Scan.repeat1 |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
118 |
(P.type_args -- P.name -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_infix'))) |
22796 | 119 |
>> (Toplevel.theory o Sign.add_tyabbrs o |
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
12768
diff
changeset
|
120 |
map (fn ((args, a), (T, mx)) => (a, args, T, mx)))); |
5832 | 121 |
|
24868 | 122 |
val _ = |
6370 | 123 |
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" |
22796 | 124 |
K.thy_decl (Scan.repeat1 P.name >> (Toplevel.theory o Sign.add_nonterminals)); |
5832 | 125 |
|
24868 | 126 |
val _ = |
6723 | 127 |
OuterSyntax.command "arities" "state type arities (axiomatic!)" K.thy_decl |
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
128 |
(Scan.repeat1 P.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd)); |
5832 | 129 |
|
130 |
||
131 |
(* consts and syntax *) |
|
132 |
||
24868 | 133 |
val _ = |
8227 | 134 |
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
|
135 |
(P.const >> (Toplevel.theory o ObjectLogic.add_judgment)); |
8227 | 136 |
|
24868 | 137 |
val _ = |
6723 | 138 |
OuterSyntax.command "consts" "declare constants" K.thy_decl |
22796 | 139 |
(Scan.repeat1 P.const >> (Toplevel.theory o Sign.add_consts)); |
5832 | 140 |
|
14642 | 141 |
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
|
142 |
|
24868 | 143 |
val _ = |
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
144 |
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
|
145 |
(opt_overloaded -- Scan.repeat1 P.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); |
9731 | 146 |
|
12142 | 147 |
val mode_spec = |
9731 | 148 |
(P.$$$ "output" >> K ("", false)) || P.name -- Scan.optional (P.$$$ "output" >> K false) true; |
149 |
||
14900 | 150 |
val opt_mode = |
24960 | 151 |
Scan.optional (P.$$$ "(" |-- P.!!! (mode_spec --| P.$$$ ")")) Syntax.mode_default; |
5832 | 152 |
|
24868 | 153 |
val _ = |
6723 | 154 |
OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl |
22796 | 155 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 156 |
|
24868 | 157 |
val _ = |
15748 | 158 |
OuterSyntax.command "no_syntax" "delete syntax declarations" K.thy_decl |
22796 | 159 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.del_modesyntax)); |
15748 | 160 |
|
5832 | 161 |
|
162 |
(* translations *) |
|
163 |
||
164 |
val trans_pat = |
|
6723 | 165 |
Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string; |
5832 | 166 |
|
167 |
fun trans_arrow toks = |
|
10688 | 168 |
((P.$$$ "\\<rightharpoonup>" || P.$$$ "=>") >> K Syntax.ParseRule || |
169 |
(P.$$$ "\\<leftharpoondown>" || P.$$$ "<=") >> K Syntax.PrintRule || |
|
170 |
(P.$$$ "\\<rightleftharpoons>" || P.$$$ "==") >> K Syntax.ParsePrintRule) toks; |
|
5832 | 171 |
|
172 |
val trans_line = |
|
6723 | 173 |
trans_pat -- P.!!! (trans_arrow -- trans_pat) |
5832 | 174 |
>> (fn (left, (arr, right)) => arr (left, right)); |
175 |
||
24868 | 176 |
val _ = |
6723 | 177 |
OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl |
22796 | 178 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.add_trrules)); |
5832 | 179 |
|
24868 | 180 |
val _ = |
19260 | 181 |
OuterSyntax.command "no_translations" "remove syntax translation rules" K.thy_decl |
22796 | 182 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.del_trrules)); |
19260 | 183 |
|
5832 | 184 |
|
185 |
(* axioms and definitions *) |
|
186 |
||
24868 | 187 |
val _ = |
6723 | 188 |
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl |
22117 | 189 |
(Scan.repeat1 SpecParse.spec_name >> (Toplevel.theory o IsarCmd.add_axioms)); |
5832 | 190 |
|
19631 | 191 |
val opt_unchecked_overloaded = |
192 |
Scan.optional (P.$$$ "(" |-- P.!!! |
|
193 |
(((P.$$$ "unchecked" >> K true) -- Scan.optional (P.$$$ "overloaded" >> K true) false || |
|
194 |
P.$$$ "overloaded" >> K (false, true)) --| P.$$$ ")")) (false, false); |
|
195 |
||
24868 | 196 |
val _ = |
6723 | 197 |
OuterSyntax.command "defs" "define constants" K.thy_decl |
22117 | 198 |
(opt_unchecked_overloaded -- Scan.repeat1 SpecParse.spec_name |
21350 | 199 |
>> (Toplevel.theory o IsarCmd.add_defs)); |
6370 | 200 |
|
14642 | 201 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
202 |
(* old constdefs *) |
14642 | 203 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
204 |
val old_constdecl = |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
205 |
P.binding --| P.where_ >> (fn x => (x, NONE, NoSyn)) || |
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
206 |
P.binding -- (P.$$$ "::" |-- P.!!! P.typ >> SOME) -- P.opt_mixfix' |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
207 |
--| Scan.option P.where_ >> P.triple1 || |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
208 |
P.binding -- (P.mixfix >> pair NONE) --| Scan.option P.where_ >> P.triple2; |
19076 | 209 |
|
22117 | 210 |
val old_constdef = Scan.option old_constdecl -- (SpecParse.opt_thm_name ":" -- P.prop); |
14642 | 211 |
|
19076 | 212 |
val structs = |
213 |
Scan.optional ((P.$$$ "(" -- P.$$$ "structure") |-- P.!!! (P.simple_fixes --| P.$$$ ")")) []; |
|
214 |
||
24868 | 215 |
val _ = |
19076 | 216 |
OuterSyntax.command "constdefs" "old-style constant definition" K.thy_decl |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
217 |
(structs -- Scan.repeat1 old_constdef >> (Toplevel.theory o Constdefs.add_constdefs)); |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
218 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
219 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
220 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
221 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
222 |
val constdecl = |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
223 |
P.binding -- |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
224 |
(P.where_ >> K (NONE, NoSyn) || |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
225 |
P.$$$ "::" |-- P.!!! ((P.typ >> SOME) -- P.opt_mixfix' --| P.where_) || |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
226 |
Scan.ahead (P.$$$ "(") |-- P.!!! (P.mixfix' --| P.where_ >> pair NONE)) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
227 |
>> P.triple2; |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
228 |
|
22117 | 229 |
val constdef = Scan.option constdecl -- (SpecParse.opt_thm_name ":" -- P.prop); |
5832 | 230 |
|
24868 | 231 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
232 |
OuterSyntax.local_theory "definition" "constant definition" K.thy_decl |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
233 |
(constdef >> (fn args => #2 o Specification.definition_cmd args)); |
18780 | 234 |
|
24868 | 235 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
236 |
OuterSyntax.local_theory "abbreviation" "constant abbreviation" K.thy_decl |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
237 |
(opt_mode -- (Scan.option constdecl -- P.prop) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
238 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 239 |
|
24868 | 240 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
241 |
OuterSyntax.local_theory "notation" "add notation for constants / fixed variables" K.thy_decl |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
242 |
(opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
243 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 244 |
|
245 |
val _ = |
|
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
246 |
OuterSyntax.local_theory "no_notation" "delete notation for constants / fixed variables" K.thy_decl |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
247 |
(opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
248 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 249 |
|
5832 | 250 |
|
18616 | 251 |
(* constant specifications *) |
252 |
||
24868 | 253 |
val _ = |
28114 | 254 |
OuterSyntax.command "axiomatization" "axiomatic constant specification" K.thy_decl |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
255 |
(Scan.optional P.fixes [] -- |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
256 |
Scan.optional (P.where_ |-- P.!!! (P.and_list1 SpecParse.spec)) [] |
28114 | 257 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 258 |
|
259 |
||
5914 | 260 |
(* theorems *) |
261 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
262 |
fun theorems kind = |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
263 |
SpecParse.name_facts >> (fn args => #2 o Specification.theorems_cmd kind args); |
12712 | 264 |
|
24868 | 265 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
266 |
OuterSyntax.local_theory "theorems" "define theorems" K.thy_decl (theorems Thm.theoremK); |
5914 | 267 |
|
24868 | 268 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
269 |
OuterSyntax.local_theory "lemmas" "define lemmas" K.thy_decl (theorems Thm.lemmaK); |
5914 | 270 |
|
24868 | 271 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
272 |
OuterSyntax.local_theory "declare" "declare theorems (improper)" K.thy_decl |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
273 |
(P.and_list1 SpecParse.xthms1 |
28965 | 274 |
>> (fn args => #2 o Specification.theorems_cmd "" [(Attrib.empty_binding, flat args)])); |
9589 | 275 |
|
5914 | 276 |
|
5832 | 277 |
(* name space entry path *) |
278 |
||
24868 | 279 |
val _ = |
6723 | 280 |
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl |
16447 | 281 |
(Scan.succeed (Toplevel.theory Sign.root_path)); |
5832 | 282 |
|
24868 | 283 |
val _ = |
6723 | 284 |
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl |
16447 | 285 |
(Scan.succeed (Toplevel.theory Sign.local_path)); |
8723 | 286 |
|
24868 | 287 |
val _ = |
8723 | 288 |
OuterSyntax.command "hide" "hide names from given name space" K.thy_decl |
17397 | 289 |
((P.opt_keyword "open" >> not) -- (P.name -- Scan.repeat1 P.xname) >> |
26672 | 290 |
(Toplevel.theory o uncurry IsarCmd.hide_names)); |
5832 | 291 |
|
292 |
||
293 |
(* use ML text *) |
|
294 |
||
24868 | 295 |
val _ = |
26490 | 296 |
OuterSyntax.command "use" "eval ML text from file" (K.tag_ml K.thy_decl) |
297 |
(P.path >> (Toplevel.generic_theory o ThyInfo.exec_file false)); |
|
5832 | 298 |
|
24868 | 299 |
val _ = |
28269 | 300 |
OuterSyntax.command "ML" "eval ML text within theory" (K.tag_ml K.thy_decl) |
27877 | 301 |
(P.ML_source >> (fn (txt, pos) => |
26490 | 302 |
Toplevel.generic_theory (ML_Context.exec (fn () => ML_Context.eval true pos txt)))); |
7891 | 303 |
|
24868 | 304 |
val _ = |
28269 | 305 |
OuterSyntax.command "ML_prf" "eval ML text within proof" (K.tag_proof K.prf_decl) |
306 |
(P.ML_source >> (fn (txt, pos) => |
|
307 |
Toplevel.proof (Proof.map_context (Context.proof_map |
|
28277
f2995a28e0e4
ML_prf: inherit env for all contexts within the proof;
wenzelm
parents:
28269
diff
changeset
|
308 |
(ML_Context.exec (fn () => ML_Context.eval true pos txt))) #> |
f2995a28e0e4
ML_prf: inherit env for all contexts within the proof;
wenzelm
parents:
28269
diff
changeset
|
309 |
(fn prf => Proof.map_contexts (ML_Context.inherit_env (Proof.context_of prf)) prf)))); |
28269 | 310 |
|
311 |
val _ = |
|
26396 | 312 |
OuterSyntax.command "ML_val" "eval ML text (diagnostic)" (K.tag_ml K.diag) |
27877 | 313 |
(P.ML_source >> IsarCmd.ml_diag true); |
26396 | 314 |
|
315 |
val _ = |
|
316 |
OuterSyntax.command "ML_command" "silently eval ML text (diagnostic)" (K.tag_ml K.diag) |
|
27877 | 317 |
(P.ML_source >> (Toplevel.no_timing oo IsarCmd.ml_diag false)); |
5832 | 318 |
|
24868 | 319 |
val _ = |
17068 | 320 |
OuterSyntax.command "setup" "apply ML theory setup" (K.tag_ml K.thy_decl) |
27877 | 321 |
(P.ML_source >> (Toplevel.theory o IsarCmd.generic_setup)); |
5832 | 322 |
|
24868 | 323 |
val _ = |
17068 | 324 |
OuterSyntax.command "method_setup" "define proof method in ML" (K.tag_ml K.thy_decl) |
27877 | 325 |
(P.name -- P.!!! (P.$$$ "=" |-- P.ML_source -- P.text) |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26248
diff
changeset
|
326 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
9197 | 327 |
|
24868 | 328 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
329 |
OuterSyntax.local_theory "declaration" "generic ML declaration" (K.tag_ml K.thy_decl) |
27877 | 330 |
(P.ML_source >> IsarCmd.declaration); |
22088 | 331 |
|
24868 | 332 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
333 |
OuterSyntax.local_theory "simproc_setup" "define simproc in ML" (K.tag_ml K.thy_decl) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
334 |
(P.name -- (P.$$$ "(" |-- P.enum1 "|" P.term --| P.$$$ ")" --| P.$$$ "=") -- |
27877 | 335 |
P.ML_source -- Scan.optional (P.$$$ "identifier" |-- Scan.repeat1 P.xname) [] |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
336 |
>> (fn (((a, b), c), d) => IsarCmd.simproc_setup a b c d)); |
22202 | 337 |
|
5832 | 338 |
|
339 |
(* translation functions *) |
|
340 |
||
27877 | 341 |
val trfun = P.opt_keyword "advanced" -- P.ML_source; |
14642 | 342 |
|
24868 | 343 |
val _ = |
17068 | 344 |
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" |
345 |
(K.tag_ml K.thy_decl) |
|
22117 | 346 |
(trfun >> (Toplevel.theory o IsarCmd.parse_ast_translation)); |
5832 | 347 |
|
24868 | 348 |
val _ = |
17068 | 349 |
OuterSyntax.command "parse_translation" "install parse translation functions" |
350 |
(K.tag_ml K.thy_decl) |
|
22117 | 351 |
(trfun >> (Toplevel.theory o IsarCmd.parse_translation)); |
5832 | 352 |
|
24868 | 353 |
val _ = |
17068 | 354 |
OuterSyntax.command "print_translation" "install print translation functions" |
355 |
(K.tag_ml K.thy_decl) |
|
22117 | 356 |
(trfun >> (Toplevel.theory o IsarCmd.print_translation)); |
5832 | 357 |
|
24868 | 358 |
val _ = |
6370 | 359 |
OuterSyntax.command "typed_print_translation" "install typed print translation functions" |
17068 | 360 |
(K.tag_ml K.thy_decl) |
22117 | 361 |
(trfun >> (Toplevel.theory o IsarCmd.typed_print_translation)); |
5832 | 362 |
|
24868 | 363 |
val _ = |
17068 | 364 |
OuterSyntax.command "print_ast_translation" "install print ast translation functions" |
365 |
(K.tag_ml K.thy_decl) |
|
22117 | 366 |
(trfun >> (Toplevel.theory o IsarCmd.print_ast_translation)); |
5832 | 367 |
|
368 |
||
369 |
(* oracles *) |
|
370 |
||
24868 | 371 |
val _ = |
17068 | 372 |
OuterSyntax.command "oracle" "declare oracle" (K.tag_ml K.thy_decl) |
28290 | 373 |
(P.name -- (P.$$$ "=" |-- P.ML_source) >> (fn (x, y) => Toplevel.theory (IsarCmd.oracle x y))); |
5832 | 374 |
|
375 |
||
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
376 |
(* local theories *) |
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
377 |
|
24868 | 378 |
val _ = |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
379 |
OuterSyntax.command "context" "enter local theory context" K.thy_decl |
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
380 |
(P.name --| P.begin >> (fn name => |
25290 | 381 |
Toplevel.print o Toplevel.begin_local_theory true (TheoryTarget.context name))); |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
382 |
|
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
383 |
|
12061 | 384 |
(* locales *) |
385 |
||
12758 | 386 |
val locale_val = |
29223 | 387 |
SpecParse.locale_expression -- |
22117 | 388 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
29223 | 389 |
Scan.repeat1 SpecParse.context_element >> pair ([], []); |
12061 | 390 |
|
24868 | 391 |
val _ = |
12061 | 392 |
OuterSyntax.command "locale" "define named proof context" K.thy_decl |
29223 | 393 |
(P.name -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (([], []), []) -- P.opt_begin |
27681 | 394 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 395 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
29358 | 396 |
(Expression.add_locale_cmd name name expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
397 |
|
24868 | 398 |
val _ = |
28895 | 399 |
OuterSyntax.command "sublocale" |
400 |
"prove sublocale relation between a locale and a locale expression" K.thy_goal |
|
29033
721529248e31
Enable keyword 'structure' in for clause of locale expression.
ballarin
parents:
29006
diff
changeset
|
401 |
(P.xname --| (P.$$$ "\\<subseteq>" || P.$$$ "<") -- P.!!! SpecParse.locale_expression |
28895 | 402 |
>> (fn (loc, expr) => |
28951
e89dde5f365c
Sublocale: removed public after_qed; identifiers private to NewLocale.
ballarin
parents:
28902
diff
changeset
|
403 |
Toplevel.print o (Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr)))); |
28895 | 404 |
|
405 |
val _ = |
|
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
406 |
OuterSyntax.command "interpretation" |
29223 | 407 |
"prove interpretation of locale expression in theory" K.thy_goal |
29225
cfea1f3719b3
Merged; updated interpretation command in isar_syn.ML.
ballarin
parents:
29223
diff
changeset
|
408 |
(P.!!! SpecParse.locale_expression -- |
cfea1f3719b3
Merged; updated interpretation command in isar_syn.ML.
ballarin
parents:
29223
diff
changeset
|
409 |
Scan.optional (P.$$$ "where" |-- P.and_list1 (SpecParse.opt_thm_name ":" -- P.prop)) [] |
cfea1f3719b3
Merged; updated interpretation command in isar_syn.ML.
ballarin
parents:
29223
diff
changeset
|
410 |
>> (fn (expr, equations) => Toplevel.print o |
cfea1f3719b3
Merged; updated interpretation command in isar_syn.ML.
ballarin
parents:
29223
diff
changeset
|
411 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 412 |
|
413 |
val _ = |
|
414 |
OuterSyntax.command "interpret" |
|
415 |
"prove interpretation of locale expression in proof context" |
|
416 |
(K.tag_proof K.prf_goal) |
|
417 |
(P.!!! SpecParse.locale_expression |
|
418 |
>> (fn expr => Toplevel.print o |
|
419 |
Toplevel.proof' (fn int => Expression.interpret_cmd expr int))); |
|
420 |
||
421 |
local |
|
422 |
||
423 |
val opt_prefix = Scan.optional (P.binding --| P.$$$ ":") Binding.empty; |
|
424 |
||
425 |
in |
|
426 |
||
427 |
val locale_val = |
|
428 |
SpecParse.locale_expr -- |
|
429 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
|
29360 | 430 |
Scan.repeat1 SpecParse.context_element >> pair Old_Locale.empty; |
29223 | 431 |
|
432 |
val _ = |
|
433 |
OuterSyntax.command "class_locale" "define named proof context based on classes" K.thy_decl |
|
29360 | 434 |
(P.name -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (Old_Locale.empty, []) -- P.opt_begin |
29223 | 435 |
>> (fn ((name, (expr, elems)), begin) => |
436 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
|
29360 | 437 |
(Old_Locale.add_locale_cmd name expr elems #-> TheoryTarget.begin))); |
29223 | 438 |
|
439 |
val _ = |
|
440 |
OuterSyntax.command "class_interpretation" |
|
16736
1e792b32abef
Preparations for interpretation of locales in locales.
ballarin
parents:
16604
diff
changeset
|
441 |
"prove and register interpretation of locale expression in theory or locale" K.thy_goal |
22117 | 442 |
(P.xname --| (P.$$$ "\\<subseteq>" || P.$$$ "<") -- P.!!! SpecParse.locale_expr |
29360 | 443 |
>> (Toplevel.print oo (Toplevel.theory_to_proof o Old_Locale.interpretation_in_locale I)) || |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
444 |
opt_prefix -- SpecParse.locale_expr -- SpecParse.locale_insts |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
445 |
>> (fn ((name, expr), insts) => Toplevel.print o |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
446 |
Toplevel.theory_to_proof |
29360 | 447 |
(Old_Locale.interpretation_cmd (Binding.base_name name) expr insts))); |
12061 | 448 |
|
24868 | 449 |
val _ = |
29223 | 450 |
OuterSyntax.command "class_interpret" |
17068 | 451 |
"prove and register interpretation of locale expression in proof context" |
452 |
(K.tag_proof K.prf_goal) |
|
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
453 |
(opt_prefix -- SpecParse.locale_expr -- SpecParse.locale_insts |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
454 |
>> (fn ((name, expr), insts) => Toplevel.print o |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
455 |
Toplevel.proof' |
29360 | 456 |
(fn int => Old_Locale.interpret_cmd (Binding.base_name name) expr insts int))); |
15703 | 457 |
|
29223 | 458 |
end; |
459 |
||
15703 | 460 |
|
22299 | 461 |
(* classes *) |
462 |
||
24868 | 463 |
val class_val = |
464 |
SpecParse.class_expr -- |
|
26248 | 465 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
466 |
Scan.repeat1 SpecParse.context_element >> pair []; |
|
22299 | 467 |
|
24868 | 468 |
val _ = |
469 |
OuterSyntax.command "class" "define type class" K.thy_decl |
|
26516 | 470 |
(P.name -- (P.$$$ "=" |-- class_val) -- P.opt_begin |
471 |
>> (fn ((name, (supclasses, elems)), begin) => |
|
24938 | 472 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
29378 | 473 |
(Class.class_cmd name supclasses elems #> snd))); |
22299 | 474 |
|
24868 | 475 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
476 |
OuterSyntax.local_theory_to_proof "subclass" "prove a subclass relation" K.thy_goal |
29358 | 477 |
(P.xname >> Class.subclass_cmd); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
478 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
479 |
val _ = |
25519 | 480 |
OuterSyntax.command "instantiation" "instantiate and prove type arity" K.thy_decl |
25536 | 481 |
(P.multi_arity --| P.begin |
25462 | 482 |
>> (fn arities => Toplevel.print o |
29358 | 483 |
Toplevel.begin_local_theory true (TheoryTarget.instantiation_cmd arities))); |
24589 | 484 |
|
25485 | 485 |
val _ = |
486 |
OuterSyntax.command "instance" "prove type arity or subclass relation" K.thy_goal |
|
487 |
((P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) >> Class.classrel_cmd || |
|
27113 | 488 |
P.arity >> Class.instance_arity_cmd) |
25485 | 489 |
>> (Toplevel.print oo Toplevel.theory_to_proof) |
490 |
|| Scan.succeed (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 491 |
|
492 |
||
25519 | 493 |
(* arbitrary overloading *) |
494 |
||
495 |
val _ = |
|
496 |
OuterSyntax.command "overloading" "overloaded definitions" K.thy_decl |
|
25861 | 497 |
(Scan.repeat1 (P.name --| (P.$$$ "\\<equiv>" || P.$$$ "==") -- P.term -- |
26048 | 498 |
Scan.optional (P.$$$ "(" |-- (P.$$$ "unchecked" >> K false) --| P.$$$ ")") true |
499 |
>> P.triple1) --| P.begin |
|
25519 | 500 |
>> (fn operations => Toplevel.print o |
501 |
Toplevel.begin_local_theory true (TheoryTarget.overloading_cmd operations))); |
|
502 |
||
503 |
||
22866 | 504 |
(* code generation *) |
505 |
||
24868 | 506 |
val _ = |
22866 | 507 |
OuterSyntax.command "code_datatype" "define set of code datatype constructors" K.thy_decl |
24423
ae9cd0e92423
overloaded definitions accompanied by explicit constants
haftmann
parents:
24314
diff
changeset
|
508 |
(Scan.repeat1 P.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 509 |
|
510 |
||
5832 | 511 |
|
512 |
(** proof commands **) |
|
513 |
||
514 |
(* statements *) |
|
515 |
||
17353 | 516 |
fun gen_theorem kind = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
517 |
OuterSyntax.local_theory_to_proof' kind ("state " ^ kind) K.thy_goal |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
518 |
(Scan.optional (SpecParse.opt_thm_name ":" --| |
28965 | 519 |
Scan.ahead (SpecParse.locale_keyword || SpecParse.statement_keyword)) Attrib.empty_binding -- |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
520 |
SpecParse.general_statement >> (fn (a, (elems, concl)) => |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
521 |
(Specification.theorem_cmd kind NONE (K I) a elems concl))); |
5832 | 522 |
|
24868 | 523 |
val _ = gen_theorem Thm.theoremK; |
524 |
val _ = gen_theorem Thm.lemmaK; |
|
525 |
val _ = gen_theorem Thm.corollaryK; |
|
5832 | 526 |
|
24868 | 527 |
val _ = |
17353 | 528 |
OuterSyntax.command "have" "state local goal" |
529 |
(K.tag_proof K.prf_goal) |
|
22117 | 530 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.have)); |
17353 | 531 |
|
24868 | 532 |
val _ = |
17353 | 533 |
OuterSyntax.command "hence" "abbreviates \"then have\"" |
534 |
(K.tag_proof K.prf_goal) |
|
22117 | 535 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.hence)); |
17353 | 536 |
|
24868 | 537 |
val _ = |
17068 | 538 |
OuterSyntax.command "show" "state local goal, solving current obligation" |
21800
6035bfcd72d8
classified show/thus as prf_asm_goal, which is usually hilited in PG;
wenzelm
parents:
21726
diff
changeset
|
539 |
(K.tag_proof K.prf_asm_goal) |
22117 | 540 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.show)); |
5832 | 541 |
|
24868 | 542 |
val _ = |
17068 | 543 |
OuterSyntax.command "thus" "abbreviates \"then show\"" |
21800
6035bfcd72d8
classified show/thus as prf_asm_goal, which is usually hilited in PG;
wenzelm
parents:
21726
diff
changeset
|
544 |
(K.tag_proof K.prf_asm_goal) |
22117 | 545 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.thus)); |
6501 | 546 |
|
5832 | 547 |
|
5914 | 548 |
(* facts *) |
5832 | 549 |
|
22117 | 550 |
val facts = P.and_list1 SpecParse.xthms1; |
9197 | 551 |
|
24868 | 552 |
val _ = |
17068 | 553 |
OuterSyntax.command "then" "forward chaining" |
554 |
(K.tag_proof K.prf_chain) |
|
17900 | 555 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 556 |
|
24868 | 557 |
val _ = |
17068 | 558 |
OuterSyntax.command "from" "forward chaining from given facts" |
559 |
(K.tag_proof K.prf_chain) |
|
17900 | 560 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss))); |
5914 | 561 |
|
24868 | 562 |
val _ = |
17068 | 563 |
OuterSyntax.command "with" "forward chaining from given and current facts" |
564 |
(K.tag_proof K.prf_chain) |
|
17900 | 565 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss))); |
6878 | 566 |
|
24868 | 567 |
val _ = |
17068 | 568 |
OuterSyntax.command "note" "define facts" |
569 |
(K.tag_proof K.prf_decl) |
|
22117 | 570 |
(SpecParse.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss))); |
5832 | 571 |
|
24868 | 572 |
val _ = |
17068 | 573 |
OuterSyntax.command "using" "augment goal facts" |
574 |
(K.tag_proof K.prf_decl) |
|
18544 | 575 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using))); |
576 |
||
24868 | 577 |
val _ = |
18544 | 578 |
OuterSyntax.command "unfolding" "unfold definitions in goal and facts" |
579 |
(K.tag_proof K.prf_decl) |
|
580 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding))); |
|
12926 | 581 |
|
5832 | 582 |
|
583 |
(* proof context *) |
|
584 |
||
24868 | 585 |
val _ = |
17068 | 586 |
OuterSyntax.command "fix" "fix local variables (Skolem constants)" |
587 |
(K.tag_proof K.prf_asm) |
|
19844 | 588 |
(P.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix))); |
11890 | 589 |
|
24868 | 590 |
val _ = |
17068 | 591 |
OuterSyntax.command "assume" "assume propositions" |
592 |
(K.tag_proof K.prf_asm) |
|
22117 | 593 |
(SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume))); |
5832 | 594 |
|
24868 | 595 |
val _ = |
17068 | 596 |
OuterSyntax.command "presume" "assume propositions, to be established later" |
597 |
(K.tag_proof K.prf_asm) |
|
22117 | 598 |
(SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume))); |
6850 | 599 |
|
24868 | 600 |
val _ = |
17068 | 601 |
OuterSyntax.command "def" "local definition" |
602 |
(K.tag_proof K.prf_asm) |
|
18308 | 603 |
(P.and_list1 |
22117 | 604 |
(SpecParse.opt_thm_name ":" -- |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
605 |
((P.binding -- P.opt_mixfix) -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp))) |
18308 | 606 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def))); |
6953 | 607 |
|
24868 | 608 |
val _ = |
11890 | 609 |
OuterSyntax.command "obtain" "generalized existence" |
17068 | 610 |
(K.tag_proof K.prf_asm_goal) |
22117 | 611 |
(P.parname -- Scan.optional (P.fixes --| P.where_) [] -- SpecParse.statement |
18895 | 612 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain x y z))); |
5832 | 613 |
|
24868 | 614 |
val _ = |
17854 | 615 |
OuterSyntax.command "guess" "wild guessing (unstructured)" |
616 |
(K.tag_proof K.prf_asm_goal) |
|
19844 | 617 |
(Scan.optional P.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess))); |
17854 | 618 |
|
24868 | 619 |
val _ = |
17068 | 620 |
OuterSyntax.command "let" "bind text variables" |
621 |
(K.tag_proof K.prf_decl) |
|
27378 | 622 |
(P.and_list1 (P.and_list1 P.term -- (P.$$$ "=" |-- P.term)) |
17900 | 623 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind))); |
5832 | 624 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
625 |
val case_spec = |
15703 | 626 |
(P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.maybe P.name) --| P.$$$ ")") || |
22117 | 627 |
P.xname >> rpair []) -- SpecParse.opt_attribs >> P.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
628 |
|
24868 | 629 |
val _ = |
17068 | 630 |
OuterSyntax.command "case" "invoke local context" |
631 |
(K.tag_proof K.prf_asm) |
|
17900 | 632 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case))); |
8370 | 633 |
|
5832 | 634 |
|
635 |
(* proof structure *) |
|
636 |
||
24868 | 637 |
val _ = |
17068 | 638 |
OuterSyntax.command "{" "begin explicit proof block" |
639 |
(K.tag_proof K.prf_open) |
|
17900 | 640 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 641 |
|
24868 | 642 |
val _ = |
17068 | 643 |
OuterSyntax.command "}" "end explicit proof block" |
644 |
(K.tag_proof K.prf_close) |
|
20305 | 645 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 646 |
|
24868 | 647 |
val _ = |
17068 | 648 |
OuterSyntax.command "next" "enter next proof block" |
649 |
(K.tag_proof K.prf_block) |
|
17900 | 650 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 651 |
|
652 |
||
653 |
(* end proof *) |
|
654 |
||
24868 | 655 |
val _ = |
17068 | 656 |
OuterSyntax.command "qed" "conclude (sub-)proof" |
657 |
(K.tag_proof K.qed_block) |
|
26676 | 658 |
(Scan.option Method.parse >> IsarCmd.qed); |
5832 | 659 |
|
24868 | 660 |
val _ = |
17068 | 661 |
OuterSyntax.command "by" "terminal backward proof" |
662 |
(K.tag_proof K.qed) |
|
26676 | 663 |
(Method.parse -- Scan.option Method.parse >> IsarCmd.terminal_proof); |
6404 | 664 |
|
24868 | 665 |
val _ = |
17068 | 666 |
OuterSyntax.command ".." "default proof" |
667 |
(K.tag_proof K.qed) |
|
26676 | 668 |
(Scan.succeed IsarCmd.default_proof); |
8966 | 669 |
|
24868 | 670 |
val _ = |
17068 | 671 |
OuterSyntax.command "." "immediate proof" |
672 |
(K.tag_proof K.qed) |
|
26676 | 673 |
(Scan.succeed IsarCmd.immediate_proof); |
6404 | 674 |
|
24868 | 675 |
val _ = |
17068 | 676 |
OuterSyntax.command "done" "done proof" |
677 |
(K.tag_proof K.qed) |
|
26676 | 678 |
(Scan.succeed IsarCmd.done_proof); |
5832 | 679 |
|
24868 | 680 |
val _ = |
25108 | 681 |
OuterSyntax.command "sorry" "skip proof (quick-and-dirty mode only!)" |
17068 | 682 |
(K.tag_proof K.qed) |
26676 | 683 |
(Scan.succeed IsarCmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
684 |
|
24868 | 685 |
val _ = |
17068 | 686 |
OuterSyntax.command "oops" "forget proof" |
687 |
(K.tag_proof K.qed_global) |
|
18561 | 688 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 689 |
|
5832 | 690 |
|
691 |
(* proof steps *) |
|
692 |
||
24868 | 693 |
val _ = |
17068 | 694 |
OuterSyntax.command "defer" "shuffle internal proof state" |
695 |
(K.tag_proof K.prf_script) |
|
17900 | 696 |
(Scan.option P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
8165 | 697 |
|
24868 | 698 |
val _ = |
17068 | 699 |
OuterSyntax.command "prefer" "shuffle internal proof state" |
700 |
(K.tag_proof K.prf_script) |
|
17900 | 701 |
(P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
8165 | 702 |
|
24868 | 703 |
val _ = |
17068 | 704 |
OuterSyntax.command "apply" "initial refinement step (unstructured)" |
705 |
(K.tag_proof K.prf_script) |
|
22117 | 706 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 707 |
|
24868 | 708 |
val _ = |
17068 | 709 |
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" |
710 |
(K.tag_proof K.prf_script) |
|
22117 | 711 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 712 |
|
24868 | 713 |
val _ = |
17068 | 714 |
OuterSyntax.command "proof" "backward proof" |
715 |
(K.tag_proof K.prf_block) |
|
22117 | 716 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
27563 | 717 |
Toplevel.actual_proof (ProofNode.applys (Proof.proof m)) o |
718 |
Toplevel.skip_proof (fn i => i + 1))); |
|
5832 | 719 |
|
720 |
||
6773 | 721 |
(* calculational proof commands *) |
722 |
||
6878 | 723 |
val calc_args = |
22117 | 724 |
Scan.option (P.$$$ "(" |-- P.!!! ((SpecParse.xthms1 --| P.$$$ ")"))); |
6878 | 725 |
|
24868 | 726 |
val _ = |
17068 | 727 |
OuterSyntax.command "also" "combine calculation and current facts" |
728 |
(K.tag_proof K.prf_decl) |
|
17900 | 729 |
(calc_args >> (Toplevel.proofs' o Calculation.also)); |
6773 | 730 |
|
24868 | 731 |
val _ = |
17068 | 732 |
OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" |
733 |
(K.tag_proof K.prf_chain) |
|
22573 | 734 |
(calc_args >> (Toplevel.proofs' o Calculation.finally_)); |
6773 | 735 |
|
24868 | 736 |
val _ = |
17068 | 737 |
OuterSyntax.command "moreover" "augment calculation by current facts" |
738 |
(K.tag_proof K.prf_decl) |
|
17900 | 739 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 740 |
|
24868 | 741 |
val _ = |
8588 | 742 |
OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result" |
17068 | 743 |
(K.tag_proof K.prf_chain) |
17900 | 744 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 745 |
|
6773 | 746 |
|
6742 | 747 |
(* proof navigation *) |
5944 | 748 |
|
24868 | 749 |
val _ = |
17068 | 750 |
OuterSyntax.command "back" "backtracking of proof command" |
751 |
(K.tag_proof K.prf_script) |
|
27563 | 752 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof ProofNode.back o Toplevel.skip_proof I)); |
6742 | 753 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
754 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
755 |
(* nested commands *) |
25578 | 756 |
|
29309 | 757 |
val props_text = |
758 |
Scan.optional ValueParse.properties [] -- P.position P.string >> (fn (props, (str, pos)) => |
|
759 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
760 |
||
25578 | 761 |
val _ = |
762 |
OuterSyntax.improper_command "Isabelle.command" "nested Isabelle command" K.control |
|
29309 | 763 |
(props_text :|-- (fn (pos, str) => |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
764 |
(case OuterSyntax.parse pos str of |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
765 |
[tr] => Scan.succeed (K tr) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
766 |
| _ => Scan.fail_with (K "exactly one command expected")) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
767 |
handle ERROR msg => Scan.fail_with (K msg))); |
25578 | 768 |
|
769 |
||
27563 | 770 |
(* global history commands *) |
27525
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
771 |
|
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
772 |
val _ = |
27534
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
773 |
OuterSyntax.improper_command "init_toplevel" "init toplevel point-of-interest" K.control |
29349 | 774 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.init)); |
27531 | 775 |
|
776 |
val _ = |
|
27534
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
777 |
OuterSyntax.improper_command "linear_undo" "undo commands" K.control |
27529 | 778 |
(Scan.optional P.nat 1 >> |
779 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.linear_undo n))); |
|
780 |
||
781 |
val _ = |
|
27534
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
782 |
OuterSyntax.improper_command "undo" "undo commands (skipping closed proofs)" K.control |
27525
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
783 |
(Scan.optional P.nat 1 >> |
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
784 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo n))); |
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
785 |
|
27531 | 786 |
val _ = |
27534
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
787 |
OuterSyntax.improper_command "undos_proof" "undo commands (skipping closed proofs)" K.control |
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
788 |
(Scan.optional P.nat 1 >> (fn n => Toplevel.no_timing o |
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
789 |
Toplevel.keep (fn state => |
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
790 |
if Toplevel.is_proof state then (Isar.undo n; Isar.print ()) else raise Toplevel.UNDEF))); |
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
791 |
|
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
792 |
val _ = |
27563 | 793 |
OuterSyntax.improper_command "cannot_undo" "partial undo -- Proof General legacy" K.control |
794 |
(P.name >> |
|
795 |
(fn "end" => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo 1) |
|
796 |
| txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt)))); |
|
797 |
||
798 |
val _ = |
|
27534
048294b251ee
activated new versions of init_toplevel, linear_undo, undo, undos_proof kill;
wenzelm
parents:
27531
diff
changeset
|
799 |
OuterSyntax.improper_command "kill" "kill partial proof or theory development" K.control |
27531 | 800 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.kill)); |
801 |
||
27525
ee2721e9e900
added Isar.undo, which emulates old-style undo on global tty state;
wenzelm
parents:
27494
diff
changeset
|
802 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
803 |
|
5832 | 804 |
(** diagnostic commands (for interactive mode only) **) |
805 |
||
8464 | 806 |
val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) []; |
20621 | 807 |
val opt_bang = Scan.optional (P.$$$ "!" >> K true) false; |
8464 | 808 |
|
24868 | 809 |
val _ = |
7124 | 810 |
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
9010 | 811 |
K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin)); |
7124 | 812 |
|
24868 | 813 |
val _ = |
21714 | 814 |
OuterSyntax.improper_command "help" "print outer syntax commands" K.diag |
24871 | 815 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax)); |
21714 | 816 |
|
24868 | 817 |
val _ = |
21714 | 818 |
OuterSyntax.improper_command "print_commands" "print outer syntax commands" K.diag |
24871 | 819 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax)); |
5832 | 820 |
|
24868 | 821 |
val _ = |
24115 | 822 |
OuterSyntax.improper_command "print_configs" "print configuration options" K.diag |
823 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_configs)); |
|
23989 | 824 |
|
24868 | 825 |
val _ = |
7308 | 826 |
OuterSyntax.improper_command "print_context" "print theory context name" K.diag |
9010 | 827 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_context)); |
7308 | 828 |
|
24868 | 829 |
val _ = |
6723 | 830 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag |
20621 | 831 |
(opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theory)); |
5832 | 832 |
|
24868 | 833 |
val _ = |
21726 | 834 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of context (verbose!)" K.diag |
9010 | 835 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax)); |
5832 | 836 |
|
24868 | 837 |
val _ = |
21726 | 838 |
OuterSyntax.improper_command "print_abbrevs" "print constant abbreviation of context" K.diag |
839 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_abbrevs)); |
|
840 |
||
24868 | 841 |
val _ = |
17068 | 842 |
OuterSyntax.improper_command "print_theorems" |
843 |
"print theorems of local theory or proof context" K.diag |
|
9010 | 844 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_theorems)); |
5881 | 845 |
|
24868 | 846 |
val _ = |
12061 | 847 |
OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag |
848 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_locales)); |
|
849 |
||
24868 | 850 |
val _ = |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
851 |
OuterSyntax.improper_command "print_classes" "print classes of this theory" K.diag |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
852 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory |
24219 | 853 |
o Toplevel.keep (Class.print_classes o Toplevel.theory_of))); |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
854 |
|
24868 | 855 |
val _ = |
15596 | 856 |
OuterSyntax.improper_command "print_locale" "print locale expression in this theory" K.diag |
29223 | 857 |
(opt_bang -- P.xname >> (Toplevel.no_timing oo IsarCmd.print_locale)); |
12061 | 858 |
|
24868 | 859 |
val _ = |
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
860 |
OuterSyntax.improper_command "print_interps" |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16074
diff
changeset
|
861 |
"print interpretations of named locale" K.diag |
18670 | 862 |
(Scan.optional (P.$$$ "!" >> K true) false -- P.xname |
863 |
>> (Toplevel.no_timing oo uncurry IsarCmd.print_registrations)); |
|
15596 | 864 |
|
24868 | 865 |
val _ = |
12061 | 866 |
OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag |
9010 | 867 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes)); |
5832 | 868 |
|
24868 | 869 |
val _ = |
16027 | 870 |
OuterSyntax.improper_command "print_simpset" "print context of Simplifier" K.diag |
871 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_simpset)); |
|
872 |
||
24868 | 873 |
val _ = |
12383 | 874 |
OuterSyntax.improper_command "print_rules" "print intro/elim rules" K.diag |
875 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_rules)); |
|
876 |
||
24868 | 877 |
val _ = |
11666 | 878 |
OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag |
9221 | 879 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules)); |
880 |
||
24868 | 881 |
val _ = |
12061 | 882 |
OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag |
9010 | 883 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods)); |
5832 | 884 |
|
24868 | 885 |
val _ = |
9221 | 886 |
OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag |
887 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations)); |
|
888 |
||
24868 | 889 |
val _ = |
22485 | 890 |
OuterSyntax.improper_command "thy_deps" "visualize theory dependencies" |
891 |
K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.thy_deps)); |
|
892 |
||
24868 | 893 |
val _ = |
20574 | 894 |
OuterSyntax.improper_command "class_deps" "visualize class dependencies" |
895 |
K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.class_deps)); |
|
896 |
||
24868 | 897 |
val _ = |
9454 | 898 |
OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies" |
22117 | 899 |
K.diag (SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps)); |
9454 | 900 |
|
22866 | 901 |
local |
902 |
||
16027 | 903 |
val criterion = |
904 |
P.reserved "name" |-- P.!!! (P.$$$ ":" |-- P.xname) >> FindTheorems.Name || |
|
905 |
P.reserved "intro" >> K FindTheorems.Intro || |
|
906 |
P.reserved "elim" >> K FindTheorems.Elim || |
|
907 |
P.reserved "dest" >> K FindTheorems.Dest || |
|
16074 | 908 |
P.reserved "simp" |-- P.!!! (P.$$$ ":" |-- P.term) >> FindTheorems.Simp || |
16027 | 909 |
P.term >> FindTheorems.Pattern; |
910 |
||
22866 | 911 |
val options = |
912 |
Scan.optional |
|
913 |
(P.$$$ "(" |-- |
|
914 |
P.!!! (Scan.option P.nat -- Scan.optional (P.reserved "with_dups" >> K false) true |
|
915 |
--| P.$$$ ")")) (NONE, true); |
|
916 |
in |
|
917 |
||
24868 | 918 |
val _ = |
22866 | 919 |
OuterSyntax.improper_command "find_theorems" "print theorems meeting specified criteria" K.diag |
920 |
(options -- Scan.repeat (((Scan.option P.minus >> is_none) -- criterion)) |
|
17219
515badbfc4d6
renamed 'thms_containing' to 'find_theorems' -- keep old version for the time being;
wenzelm
parents:
17142
diff
changeset
|
921 |
>> (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
|
922 |
|
22866 | 923 |
end; |
924 |
||
24868 | 925 |
val _ = |
6723 | 926 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag |
9010 | 927 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds)); |
5832 | 928 |
|
24868 | 929 |
val _ = |
8370 | 930 |
OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag |
21004 | 931 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_facts)); |
5832 | 932 |
|
24868 | 933 |
val _ = |
8370 | 934 |
OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag |
9010 | 935 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases)); |
8370 | 936 |
|
24868 | 937 |
val _ = |
19269 | 938 |
OuterSyntax.improper_command "print_statement" "print theorems as long statements" K.diag |
22117 | 939 |
(opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_stmts)); |
19269 | 940 |
|
24868 | 941 |
val _ = |
8464 | 942 |
OuterSyntax.improper_command "thm" "print theorems" K.diag |
22117 | 943 |
(opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms)); |
5832 | 944 |
|
24868 | 945 |
val _ = |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
946 |
OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag |
22866 | 947 |
(opt_modes -- Scan.option SpecParse.xthms1 |
948 |
>> (Toplevel.no_timing oo IsarCmd.print_prfs false)); |
|
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
949 |
|
24868 | 950 |
val _ = |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
951 |
OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag |
22117 | 952 |
(opt_modes -- Scan.option SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_prfs true)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
953 |
|
24868 | 954 |
val _ = |
6723 | 955 |
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
|
956 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_prop)); |
5832 | 957 |
|
24868 | 958 |
val _ = |
6723 | 959 |
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
|
960 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_term)); |
5832 | 961 |
|
24868 | 962 |
val _ = |
6723 | 963 |
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
|
964 |
(opt_modes -- P.typ >> (Toplevel.no_timing oo IsarCmd.print_type)); |
5832 | 965 |
|
24868 | 966 |
val _ = |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
967 |
OuterSyntax.improper_command "print_codesetup" "print code generator setup of this theory" K.diag |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
968 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
969 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 970 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 971 |
|
26184 | 972 |
val _ = |
973 |
OuterSyntax.improper_command "unused_thms" "find unused theorems" K.diag |
|
974 |
(Scan.option ((Scan.repeat1 (Scan.unless P.minus P.name) --| P.minus) -- |
|
975 |
Scan.option (Scan.repeat1 (Scan.unless P.minus P.name))) >> |
|
976 |
(Toplevel.no_timing oo IsarCmd.unused_thms)); |
|
977 |
||
5832 | 978 |
|
979 |
(** system commands (for interactive mode only) **) |
|
980 |
||
24868 | 981 |
val _ = |
8650 | 982 |
OuterSyntax.improper_command "cd" "change current working directory" K.diag |
14950 | 983 |
(P.path >> (Toplevel.no_timing oo IsarCmd.cd)); |
5832 | 984 |
|
24868 | 985 |
val _ = |
6723 | 986 |
OuterSyntax.improper_command "pwd" "print current working directory" K.diag |
9010 | 987 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.pwd)); |
5832 | 988 |
|
24868 | 989 |
val _ = |
6723 | 990 |
OuterSyntax.improper_command "use_thy" "use theory file" K.diag |
26404 | 991 |
(P.name >> (fn name => |
992 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.use_thy name))); |
|
5832 | 993 |
|
24868 | 994 |
val _ = |
7102 | 995 |
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag |
27494 | 996 |
(P.name >> (fn name => |
997 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.touch_thy name))); |
|
7908 | 998 |
|
24868 | 999 |
val _ = |
7102 | 1000 |
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag |
27494 | 1001 |
(P.name >> (fn name => |
1002 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.remove_thy name))); |
|
7102 | 1003 |
|
24868 | 1004 |
val _ = |
7931 | 1005 |
OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
27494 | 1006 |
K.diag (P.name >> (fn name => |
1007 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.kill_thy name))); |
|
7931 | 1008 |
|
24868 | 1009 |
val _ = |
14934 | 1010 |
OuterSyntax.improper_command "display_drafts" "display raw source files with symbols" |
14950 | 1011 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.display_drafts)); |
14934 | 1012 |
|
24868 | 1013 |
val _ = |
14934 | 1014 |
OuterSyntax.improper_command "print_drafts" "print raw source files with symbols" |
14950 | 1015 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.print_drafts)); |
14934 | 1016 |
|
9731 | 1017 |
val opt_limits = |
1018 |
Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat); |
|
1019 |
||
24868 | 1020 |
val _ = |
8886 | 1021 |
OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag |
9731 | 1022 |
(opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr)); |
7199 | 1023 |
|
24868 | 1024 |
val _ = |
7222 | 1025 |
OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag |
9010 | 1026 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr)); |
5832 | 1027 |
|
24868 | 1028 |
val _ = |
7222 | 1029 |
OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag |
9010 | 1030 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr)); |
7222 | 1031 |
|
24868 | 1032 |
val _ = |
6723 | 1033 |
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag |
26490 | 1034 |
(P.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 1035 |
|
24868 | 1036 |
val _ = |
6723 | 1037 |
OuterSyntax.improper_command "quit" "quit Isabelle" K.control |
9010 | 1038 |
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit)); |
5832 | 1039 |
|
24868 | 1040 |
val _ = |
6723 | 1041 |
OuterSyntax.improper_command "exit" "exit Isar loop" K.control |
9010 | 1042 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.exit)); |
5832 | 1043 |
|
24868 | 1044 |
val _ = |
8678 | 1045 |
OuterSyntax.improper_command "welcome" "print welcome message" K.diag |
9010 | 1046 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.welcome)); |
7462 | 1047 |
|
5832 | 1048 |
end; |
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
1049 |