author | wenzelm |
Tue, 09 Mar 2010 23:32:13 +0100 | |
changeset 35681 | 8b22a498b034 |
parent 35626 | 06197484c6ad |
child 35835 | 51c6ac100bd9 |
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", |
33456
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
25 |
"notes", "obtains", "open", "output", "overloaded", "pervasive", |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
26 |
"shows", "structure", "unchecked", "uses", "where", "|"]; |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
27 |
|
24868 | 28 |
|
29 |
||
5832 | 30 |
(** init and exit **) |
31 |
||
24868 | 32 |
val _ = |
17068 | 33 |
OuterSyntax.command "theory" "begin theory" (K.tag_theory K.thy_begin) |
32466 | 34 |
(Thy_Header.args >> (Toplevel.print oo IsarCmd.init_theory)); |
5832 | 35 |
|
24868 | 36 |
val _ = |
20958 | 37 |
OuterSyntax.command "end" "end (local) theory" (K.tag_theory K.thy_end) |
21004 | 38 |
(Scan.succeed (Toplevel.exit o Toplevel.end_local_theory)); |
6687 | 39 |
|
5832 | 40 |
|
30142
8d6145694bb5
moved find_theorems.ML and find_consts.ML to Pure/Tools, collecting main implementation in one place each;
wenzelm
parents:
29882
diff
changeset
|
41 |
|
7749 | 42 |
(** markup commands **) |
5832 | 43 |
|
24868 | 44 |
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
|
45 |
(P.doc_source >> IsarCmd.header_markup); |
6353 | 46 |
|
24868 | 47 |
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
|
48 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 49 |
|
24868 | 50 |
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
|
51 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 52 |
|
24868 | 53 |
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
|
54 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5958 | 55 |
|
24868 | 56 |
val _ = |
22117 | 57 |
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
|
58 |
K.thy_heading (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
5832 | 59 |
|
24868 | 60 |
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
|
61 |
K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
7172 | 62 |
|
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
63 |
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
|
64 |
K.thy_decl (P.opt_target -- P.doc_source >> IsarCmd.local_theory_markup); |
7172 | 65 |
|
24868 | 66 |
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
|
67 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 68 |
|
24868 | 69 |
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
|
70 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 71 |
|
27872
631371a02b8c
P.doc_source and P.ml_sorce for proper SymbolPos.text;
wenzelm
parents:
27854
diff
changeset
|
72 |
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
|
73 |
(K.tag_proof K.prf_heading) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 74 |
|
24868 | 75 |
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
|
76 |
(K.tag_proof K.prf_decl) (P.doc_source >> IsarCmd.proof_markup); |
7172 | 77 |
|
24868 | 78 |
val _ = OuterSyntax.markup_command ThyOutput.Verbatim "txt_raw" |
17068 | 79 |
"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
|
80 |
(P.doc_source >> IsarCmd.proof_markup); |
7775 | 81 |
|
5832 | 82 |
|
6886 | 83 |
|
30142
8d6145694bb5
moved find_theorems.ML and find_consts.ML to Pure/Tools, collecting main implementation in one place each;
wenzelm
parents:
29882
diff
changeset
|
84 |
(** theory commands **) |
6886 | 85 |
|
5832 | 86 |
(* classes and sorts *) |
87 |
||
24868 | 88 |
val _ = |
6723 | 89 |
OuterSyntax.command "classes" "declare type classes" K.thy_decl |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
90 |
(Scan.repeat1 (P.binding -- 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
|
91 |
P.!!! (P.list1 P.xname)) []) >> (Toplevel.theory o fold AxClass.axiomatize_class_cmd)); |
5832 | 92 |
|
24868 | 93 |
val _ = |
6723 | 94 |
OuterSyntax.command "classrel" "state inclusion of type classes (axiomatic!)" K.thy_decl |
14779 | 95 |
(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
|
96 |
>> (Toplevel.theory o AxClass.axiomatize_classrel_cmd)); |
5832 | 97 |
|
24868 | 98 |
val _ = |
6723 | 99 |
OuterSyntax.command "defaultsort" "declare default sort" K.thy_decl |
22796 | 100 |
(P.sort >> (Toplevel.theory o Sign.add_defsort)); |
5832 | 101 |
|
102 |
||
103 |
(* types *) |
|
104 |
||
24868 | 105 |
val _ = |
35681 | 106 |
OuterSyntax.local_theory "typedecl" "type declaration" K.thy_decl |
107 |
(P.type_args -- P.binding -- P.opt_mixfix |
|
108 |
>> (fn ((args, a), mx) => Typedecl.typedecl (a, args, mx) #> snd)); |
|
5832 | 109 |
|
24868 | 110 |
val _ = |
6723 | 111 |
OuterSyntax.command "types" "declare type abbreviations" K.thy_decl |
6727 | 112 |
(Scan.repeat1 |
35351
7425aece4ee3
allow general mixfix syntax for type constructors;
wenzelm
parents:
35315
diff
changeset
|
113 |
(P.type_args -- P.binding -- (P.$$$ "=" |-- P.!!! (P.typ -- P.opt_mixfix'))) |
35681 | 114 |
>> (Toplevel.theory o Sign.add_tyabbrs o map (fn ((args, a), (T, mx)) => (a, args, T, mx)))); |
5832 | 115 |
|
24868 | 116 |
val _ = |
6370 | 117 |
OuterSyntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
118 |
K.thy_decl (Scan.repeat1 P.binding >> (Toplevel.theory o Sign.add_nonterminals)); |
5832 | 119 |
|
24868 | 120 |
val _ = |
6723 | 121 |
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
|
122 |
(Scan.repeat1 P.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd)); |
5832 | 123 |
|
124 |
||
125 |
(* consts and syntax *) |
|
126 |
||
24868 | 127 |
val _ = |
8227 | 128 |
OuterSyntax.command "judgment" "declare object-logic judgment" K.thy_decl |
35625 | 129 |
(P.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
8227 | 130 |
|
24868 | 131 |
val _ = |
6723 | 132 |
OuterSyntax.command "consts" "declare constants" K.thy_decl |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
133 |
(Scan.repeat1 P.const_binding >> (Toplevel.theory o Sign.add_consts)); |
5832 | 134 |
|
14642 | 135 |
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
|
136 |
|
24868 | 137 |
val _ = |
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
138 |
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
|
139 |
(opt_overloaded -- Scan.repeat1 P.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); |
9731 | 140 |
|
12142 | 141 |
val mode_spec = |
9731 | 142 |
(P.$$$ "output" >> K ("", false)) || P.name -- Scan.optional (P.$$$ "output" >> K false) true; |
143 |
||
14900 | 144 |
val opt_mode = |
24960 | 145 |
Scan.optional (P.$$$ "(" |-- P.!!! (mode_spec --| P.$$$ ")")) Syntax.mode_default; |
5832 | 146 |
|
24868 | 147 |
val _ = |
6723 | 148 |
OuterSyntax.command "syntax" "declare syntactic constants" K.thy_decl |
22796 | 149 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 150 |
|
24868 | 151 |
val _ = |
15748 | 152 |
OuterSyntax.command "no_syntax" "delete syntax declarations" K.thy_decl |
22796 | 153 |
(opt_mode -- Scan.repeat1 P.const >> (Toplevel.theory o uncurry Sign.del_modesyntax)); |
15748 | 154 |
|
5832 | 155 |
|
156 |
(* translations *) |
|
157 |
||
158 |
val trans_pat = |
|
6723 | 159 |
Scan.optional (P.$$$ "(" |-- P.!!! (P.xname --| P.$$$ ")")) "logic" -- P.string; |
5832 | 160 |
|
161 |
fun trans_arrow toks = |
|
10688 | 162 |
((P.$$$ "\\<rightharpoonup>" || P.$$$ "=>") >> K Syntax.ParseRule || |
163 |
(P.$$$ "\\<leftharpoondown>" || P.$$$ "<=") >> K Syntax.PrintRule || |
|
164 |
(P.$$$ "\\<rightleftharpoons>" || P.$$$ "==") >> K Syntax.ParsePrintRule) toks; |
|
5832 | 165 |
|
166 |
val trans_line = |
|
6723 | 167 |
trans_pat -- P.!!! (trans_arrow -- trans_pat) |
5832 | 168 |
>> (fn (left, (arr, right)) => arr (left, right)); |
169 |
||
24868 | 170 |
val _ = |
6723 | 171 |
OuterSyntax.command "translations" "declare syntax translation rules" K.thy_decl |
22796 | 172 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.add_trrules)); |
5832 | 173 |
|
24868 | 174 |
val _ = |
19260 | 175 |
OuterSyntax.command "no_translations" "remove syntax translation rules" K.thy_decl |
22796 | 176 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.del_trrules)); |
19260 | 177 |
|
5832 | 178 |
|
179 |
(* axioms and definitions *) |
|
180 |
||
30484
bc2a4dc6f1be
old name_spec for 'axioms' and 'defs' (from spec_parse.ML);
wenzelm
parents:
30461
diff
changeset
|
181 |
val named_spec = SpecParse.thm_name ":" -- P.prop >> (fn ((x, y), z) => ((x, z), y)); |
bc2a4dc6f1be
old name_spec for 'axioms' and 'defs' (from spec_parse.ML);
wenzelm
parents:
30461
diff
changeset
|
182 |
|
24868 | 183 |
val _ = |
6723 | 184 |
OuterSyntax.command "axioms" "state arbitrary propositions (axiomatic!)" K.thy_decl |
30484
bc2a4dc6f1be
old name_spec for 'axioms' and 'defs' (from spec_parse.ML);
wenzelm
parents:
30461
diff
changeset
|
185 |
(Scan.repeat1 named_spec >> (Toplevel.theory o IsarCmd.add_axioms)); |
5832 | 186 |
|
19631 | 187 |
val opt_unchecked_overloaded = |
188 |
Scan.optional (P.$$$ "(" |-- P.!!! |
|
189 |
(((P.$$$ "unchecked" >> K true) -- Scan.optional (P.$$$ "overloaded" >> K true) false || |
|
190 |
P.$$$ "overloaded" >> K (false, true)) --| P.$$$ ")")) (false, false); |
|
191 |
||
24868 | 192 |
val _ = |
6723 | 193 |
OuterSyntax.command "defs" "define constants" K.thy_decl |
30484
bc2a4dc6f1be
old name_spec for 'axioms' and 'defs' (from spec_parse.ML);
wenzelm
parents:
30461
diff
changeset
|
194 |
(opt_unchecked_overloaded -- Scan.repeat1 named_spec |
21350 | 195 |
>> (Toplevel.theory o IsarCmd.add_defs)); |
6370 | 196 |
|
14642 | 197 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
198 |
(* old constdefs *) |
14642 | 199 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
200 |
val old_constdecl = |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
201 |
P.binding --| P.where_ >> (fn x => (x, NONE, NoSyn)) || |
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
202 |
P.binding -- (P.$$$ "::" |-- P.!!! P.typ >> SOME) -- P.opt_mixfix' |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
203 |
--| Scan.option P.where_ >> P.triple1 || |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
204 |
P.binding -- (P.mixfix >> pair NONE) --| Scan.option P.where_ >> P.triple2; |
19076 | 205 |
|
22117 | 206 |
val old_constdef = Scan.option old_constdecl -- (SpecParse.opt_thm_name ":" -- P.prop); |
14642 | 207 |
|
19076 | 208 |
val structs = |
209 |
Scan.optional ((P.$$$ "(" -- P.$$$ "structure") |-- P.!!! (P.simple_fixes --| P.$$$ ")")) []; |
|
210 |
||
24868 | 211 |
val _ = |
19076 | 212 |
OuterSyntax.command "constdefs" "old-style constant definition" K.thy_decl |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
213 |
(structs -- Scan.repeat1 old_constdef >> (Toplevel.theory o Constdefs.add_constdefs)); |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
214 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
215 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
216 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
217 |
|
24868 | 218 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
219 |
OuterSyntax.local_theory "definition" "constant definition" K.thy_decl |
33287
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
wenzelm
parents:
32805
diff
changeset
|
220 |
(SpecParse.constdef >> (fn args => #2 o Specification.definition_cmd args)); |
18780 | 221 |
|
24868 | 222 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
223 |
OuterSyntax.local_theory "abbreviation" "constant abbreviation" K.thy_decl |
33287
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
wenzelm
parents:
32805
diff
changeset
|
224 |
(opt_mode -- (Scan.option SpecParse.constdecl -- P.prop) |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
225 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 226 |
|
24868 | 227 |
val _ = |
35413 | 228 |
OuterSyntax.local_theory "type_notation" "add notation for type constructors" K.thy_decl |
229 |
(opt_mode -- P.and_list1 (P.xname -- P.mixfix) |
|
230 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
|
231 |
||
232 |
val _ = |
|
233 |
OuterSyntax.local_theory "no_type_notation" "delete notation for type constructors" K.thy_decl |
|
234 |
(opt_mode -- P.and_list1 (P.xname -- P.mixfix) |
|
235 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
|
236 |
||
237 |
val _ = |
|
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
238 |
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
|
239 |
(opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
240 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 241 |
|
242 |
val _ = |
|
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
243 |
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
|
244 |
(opt_mode -- P.and_list1 (P.xname -- SpecParse.locale_mixfix) |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
245 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 246 |
|
5832 | 247 |
|
18616 | 248 |
(* constant specifications *) |
249 |
||
24868 | 250 |
val _ = |
28114 | 251 |
OuterSyntax.command "axiomatization" "axiomatic constant specification" K.thy_decl |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
252 |
(Scan.optional P.fixes [] -- |
30484
bc2a4dc6f1be
old name_spec for 'axioms' and 'defs' (from spec_parse.ML);
wenzelm
parents:
30461
diff
changeset
|
253 |
Scan.optional (P.where_ |-- P.!!! (P.and_list1 SpecParse.specs)) [] |
28114 | 254 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 255 |
|
256 |
||
5914 | 257 |
(* theorems *) |
258 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
259 |
fun theorems kind = |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
260 |
SpecParse.name_facts >> (fn args => #2 o Specification.theorems_cmd kind args); |
12712 | 261 |
|
24868 | 262 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
263 |
OuterSyntax.local_theory "theorems" "define theorems" K.thy_decl (theorems Thm.theoremK); |
5914 | 264 |
|
24868 | 265 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
266 |
OuterSyntax.local_theory "lemmas" "define lemmas" K.thy_decl (theorems Thm.lemmaK); |
5914 | 267 |
|
24868 | 268 |
val _ = |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
269 |
OuterSyntax.local_theory "declare" "declare theorems" K.thy_decl |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
270 |
(P.and_list1 SpecParse.xthms1 |
28965 | 271 |
>> (fn args => #2 o Specification.theorems_cmd "" [(Attrib.empty_binding, flat args)])); |
9589 | 272 |
|
5914 | 273 |
|
5832 | 274 |
(* name space entry path *) |
275 |
||
24868 | 276 |
val _ = |
6723 | 277 |
OuterSyntax.command "global" "disable prefixing of theory name" K.thy_decl |
16447 | 278 |
(Scan.succeed (Toplevel.theory Sign.root_path)); |
5832 | 279 |
|
24868 | 280 |
val _ = |
6723 | 281 |
OuterSyntax.command "local" "enable prefixing of theory name" K.thy_decl |
16447 | 282 |
(Scan.succeed (Toplevel.theory Sign.local_path)); |
8723 | 283 |
|
24868 | 284 |
val _ = |
8723 | 285 |
OuterSyntax.command "hide" "hide names from given name space" K.thy_decl |
17397 | 286 |
((P.opt_keyword "open" >> not) -- (P.name -- Scan.repeat1 P.xname) >> |
26672 | 287 |
(Toplevel.theory o uncurry IsarCmd.hide_names)); |
5832 | 288 |
|
289 |
||
290 |
(* use ML text *) |
|
291 |
||
30703 | 292 |
fun propagate_env (context as Context.Proof lthy) = |
33671 | 293 |
Context.Proof (Local_Theory.map_contexts (ML_Env.inherit context) lthy) |
30703 | 294 |
| propagate_env context = context; |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
295 |
|
30703 | 296 |
fun propagate_env_prf prf = Proof.map_contexts |
31327 | 297 |
(Context.proof_map (ML_Env.inherit (Context.Proof (Proof.context_of prf)))) prf; |
5832 | 298 |
|
24868 | 299 |
val _ = |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
300 |
OuterSyntax.command "use" "ML text from file" (K.tag_ml K.thy_decl) |
30703 | 301 |
(P.path >> (fn path => Toplevel.generic_theory (ThyInfo.exec_file false path #> propagate_env))); |
7891 | 302 |
|
24868 | 303 |
val _ = |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
304 |
OuterSyntax.command "ML" "ML text within theory or local theory" (K.tag_ml K.thy_decl) |
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
305 |
(P.ML_source >> (fn (txt, pos) => |
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
306 |
Toplevel.generic_theory |
30703 | 307 |
(ML_Context.exec (fn () => ML_Context.eval true pos txt) #> propagate_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
308 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
309 |
val _ = |
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
310 |
OuterSyntax.command "ML_prf" "ML text within proof" (K.tag_proof K.prf_decl) |
28269 | 311 |
(P.ML_source >> (fn (txt, pos) => |
312 |
Toplevel.proof (Proof.map_context (Context.proof_map |
|
30703 | 313 |
(ML_Context.exec (fn () => ML_Context.eval true pos txt))) #> propagate_env_prf))); |
28269 | 314 |
|
315 |
val _ = |
|
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
316 |
OuterSyntax.command "ML_val" "diagnostic ML text" (K.tag_ml K.diag) |
27877 | 317 |
(P.ML_source >> IsarCmd.ml_diag true); |
26396 | 318 |
|
319 |
val _ = |
|
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
320 |
OuterSyntax.command "ML_command" "diagnostic ML text (silent)" (K.tag_ml K.diag) |
27877 | 321 |
(P.ML_source >> (Toplevel.no_timing oo IsarCmd.ml_diag false)); |
5832 | 322 |
|
24868 | 323 |
val _ = |
30461 | 324 |
OuterSyntax.command "setup" "ML theory setup" (K.tag_ml K.thy_decl) |
325 |
(P.ML_source >> (Toplevel.theory o IsarCmd.global_setup)); |
|
326 |
||
327 |
val _ = |
|
328 |
OuterSyntax.local_theory "local_setup" "ML local theory setup" (K.tag_ml K.thy_decl) |
|
329 |
(P.ML_source >> IsarCmd.local_setup); |
|
5832 | 330 |
|
24868 | 331 |
val _ = |
30526 | 332 |
OuterSyntax.command "attribute_setup" "define attribute in ML" (K.tag_ml K.thy_decl) |
333 |
(P.position P.name -- P.!!! (P.$$$ "=" |-- P.ML_source -- P.text) |
|
334 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt))); |
|
335 |
||
336 |
val _ = |
|
17068 | 337 |
OuterSyntax.command "method_setup" "define proof method in ML" (K.tag_ml K.thy_decl) |
30544 | 338 |
(P.position P.name -- P.!!! (P.$$$ "=" |-- P.ML_source -- P.text) |
26385
ae7564661e76
ML runtime compilation: pass position, tuned signature;
wenzelm
parents:
26248
diff
changeset
|
339 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
9197 | 340 |
|
24868 | 341 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
342 |
OuterSyntax.local_theory "declaration" "generic ML declaration" (K.tag_ml K.thy_decl) |
33456
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
343 |
(P.opt_keyword "pervasive" -- P.ML_source >> uncurry IsarCmd.declaration); |
22088 | 344 |
|
24868 | 345 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
346 |
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
|
347 |
(P.name -- (P.$$$ "(" |-- P.enum1 "|" P.term --| P.$$$ ")" --| P.$$$ "=") -- |
27877 | 348 |
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
|
349 |
>> (fn (((a, b), c), d) => IsarCmd.simproc_setup a b c d)); |
22202 | 350 |
|
5832 | 351 |
|
352 |
(* translation functions *) |
|
353 |
||
27877 | 354 |
val trfun = P.opt_keyword "advanced" -- P.ML_source; |
14642 | 355 |
|
24868 | 356 |
val _ = |
17068 | 357 |
OuterSyntax.command "parse_ast_translation" "install parse ast translation functions" |
358 |
(K.tag_ml K.thy_decl) |
|
22117 | 359 |
(trfun >> (Toplevel.theory o IsarCmd.parse_ast_translation)); |
5832 | 360 |
|
24868 | 361 |
val _ = |
17068 | 362 |
OuterSyntax.command "parse_translation" "install parse translation functions" |
363 |
(K.tag_ml K.thy_decl) |
|
22117 | 364 |
(trfun >> (Toplevel.theory o IsarCmd.parse_translation)); |
5832 | 365 |
|
24868 | 366 |
val _ = |
17068 | 367 |
OuterSyntax.command "print_translation" "install print translation functions" |
368 |
(K.tag_ml K.thy_decl) |
|
22117 | 369 |
(trfun >> (Toplevel.theory o IsarCmd.print_translation)); |
5832 | 370 |
|
24868 | 371 |
val _ = |
6370 | 372 |
OuterSyntax.command "typed_print_translation" "install typed print translation functions" |
17068 | 373 |
(K.tag_ml K.thy_decl) |
22117 | 374 |
(trfun >> (Toplevel.theory o IsarCmd.typed_print_translation)); |
5832 | 375 |
|
24868 | 376 |
val _ = |
17068 | 377 |
OuterSyntax.command "print_ast_translation" "install print ast translation functions" |
378 |
(K.tag_ml K.thy_decl) |
|
22117 | 379 |
(trfun >> (Toplevel.theory o IsarCmd.print_ast_translation)); |
5832 | 380 |
|
381 |
||
382 |
(* oracles *) |
|
383 |
||
24868 | 384 |
val _ = |
17068 | 385 |
OuterSyntax.command "oracle" "declare oracle" (K.tag_ml K.thy_decl) |
30334 | 386 |
(P.position P.name -- (P.$$$ "=" |-- P.ML_source) >> |
387 |
(fn (x, y) => Toplevel.theory (IsarCmd.oracle x y))); |
|
5832 | 388 |
|
389 |
||
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
390 |
(* local theories *) |
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
391 |
|
24868 | 392 |
val _ = |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
393 |
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
|
394 |
(P.name --| P.begin >> (fn name => |
35205 | 395 |
Toplevel.print o Toplevel.begin_local_theory true (Theory_Target.context_cmd name))); |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
396 |
|
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
397 |
|
12061 | 398 |
(* locales *) |
399 |
||
12758 | 400 |
val locale_val = |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
401 |
SpecParse.locale_expression false -- |
22117 | 402 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
29223 | 403 |
Scan.repeat1 SpecParse.context_element >> pair ([], []); |
12061 | 404 |
|
24868 | 405 |
val _ = |
12061 | 406 |
OuterSyntax.command "locale" "define named proof context" K.thy_decl |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
407 |
(P.binding -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (([], []), []) -- P.opt_begin |
27681 | 408 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 409 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
410 |
(Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
411 |
|
24868 | 412 |
val _ = |
28895 | 413 |
OuterSyntax.command "sublocale" |
414 |
"prove sublocale relation between a locale and a locale expression" K.thy_goal |
|
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
415 |
(P.xname --| (P.$$$ "\\<subseteq>" || P.$$$ "<") -- P.!!! (SpecParse.locale_expression false) |
28895 | 416 |
>> (fn (loc, expr) => |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
417 |
Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr))); |
28895 | 418 |
|
419 |
val _ = |
|
15598
4ab52355bb53
Registrations of global locale interpretations: improved, better naming.
ballarin
parents:
15596
diff
changeset
|
420 |
OuterSyntax.command "interpretation" |
29223 | 421 |
"prove interpretation of locale expression in theory" K.thy_goal |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
422 |
(P.!!! (SpecParse.locale_expression true) -- |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
423 |
Scan.optional (P.where_ |-- P.and_list1 (SpecParse.opt_thm_name ":" -- P.prop)) [] |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
424 |
>> (fn (expr, equations) => Toplevel.print o |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
425 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 426 |
|
427 |
val _ = |
|
428 |
OuterSyntax.command "interpret" |
|
429 |
"prove interpretation of locale expression in proof context" |
|
430 |
(K.tag_proof K.prf_goal) |
|
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
431 |
(P.!!! (SpecParse.locale_expression true) |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
432 |
>> (fn expr => Toplevel.print o Toplevel.proof' (Expression.interpret_cmd expr))); |
29223 | 433 |
|
15703 | 434 |
|
22299 | 435 |
(* classes *) |
436 |
||
24868 | 437 |
val class_val = |
438 |
SpecParse.class_expr -- |
|
26248 | 439 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
440 |
Scan.repeat1 SpecParse.context_element >> pair []; |
|
22299 | 441 |
|
24868 | 442 |
val _ = |
443 |
OuterSyntax.command "class" "define type class" K.thy_decl |
|
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
444 |
(P.binding -- Scan.optional (P.$$$ "=" |-- class_val) ([], []) -- P.opt_begin |
26516 | 445 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 446 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
29378 | 447 |
(Class.class_cmd name supclasses elems #> snd))); |
22299 | 448 |
|
24868 | 449 |
val _ = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
450 |
OuterSyntax.local_theory_to_proof "subclass" "prove a subclass relation" K.thy_goal |
29358 | 451 |
(P.xname >> Class.subclass_cmd); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
452 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
453 |
val _ = |
25519 | 454 |
OuterSyntax.command "instantiation" "instantiate and prove type arity" K.thy_decl |
25536 | 455 |
(P.multi_arity --| P.begin |
25462 | 456 |
>> (fn arities => Toplevel.print o |
33553 | 457 |
Toplevel.begin_local_theory true (Theory_Target.instantiation_cmd arities))); |
24589 | 458 |
|
25485 | 459 |
val _ = |
460 |
OuterSyntax.command "instance" "prove type arity or subclass relation" K.thy_goal |
|
461 |
((P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) >> Class.classrel_cmd || |
|
31869 | 462 |
P.multi_arity >> Class.instance_arity_cmd) |
25485 | 463 |
>> (Toplevel.print oo Toplevel.theory_to_proof) |
464 |
|| Scan.succeed (Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 465 |
|
466 |
||
25519 | 467 |
(* arbitrary overloading *) |
468 |
||
469 |
val _ = |
|
470 |
OuterSyntax.command "overloading" "overloaded definitions" K.thy_decl |
|
25861 | 471 |
(Scan.repeat1 (P.name --| (P.$$$ "\\<equiv>" || P.$$$ "==") -- P.term -- |
26048 | 472 |
Scan.optional (P.$$$ "(" |-- (P.$$$ "unchecked" >> K false) --| P.$$$ ")") true |
473 |
>> P.triple1) --| P.begin |
|
25519 | 474 |
>> (fn operations => Toplevel.print o |
33553 | 475 |
Toplevel.begin_local_theory true (Theory_Target.overloading_cmd operations))); |
25519 | 476 |
|
477 |
||
22866 | 478 |
(* code generation *) |
479 |
||
24868 | 480 |
val _ = |
22866 | 481 |
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
|
482 |
(Scan.repeat1 P.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 483 |
|
35223 | 484 |
val _ = |
485 |
OuterSyntax.command "code_abstype" "define abstract code type" K.thy_goal |
|
486 |
(P.term -- P.term >> (fn (abs, rep) => Toplevel.print |
|
487 |
o Toplevel.theory_to_proof (Code.add_abstype_cmd abs rep))); |
|
488 |
||
22866 | 489 |
|
5832 | 490 |
|
491 |
(** proof commands **) |
|
492 |
||
493 |
(* statements *) |
|
494 |
||
17353 | 495 |
fun gen_theorem kind = |
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
496 |
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
|
497 |
(Scan.optional (SpecParse.opt_thm_name ":" --| |
28965 | 498 |
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
|
499 |
SpecParse.general_statement >> (fn (a, (elems, concl)) => |
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
500 |
(Specification.theorem_cmd kind NONE (K I) a elems concl))); |
5832 | 501 |
|
24868 | 502 |
val _ = gen_theorem Thm.theoremK; |
503 |
val _ = gen_theorem Thm.lemmaK; |
|
504 |
val _ = gen_theorem Thm.corollaryK; |
|
5832 | 505 |
|
24868 | 506 |
val _ = |
17353 | 507 |
OuterSyntax.command "have" "state local goal" |
508 |
(K.tag_proof K.prf_goal) |
|
22117 | 509 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.have)); |
17353 | 510 |
|
24868 | 511 |
val _ = |
17353 | 512 |
OuterSyntax.command "hence" "abbreviates \"then have\"" |
513 |
(K.tag_proof K.prf_goal) |
|
22117 | 514 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.hence)); |
17353 | 515 |
|
24868 | 516 |
val _ = |
17068 | 517 |
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
|
518 |
(K.tag_proof K.prf_asm_goal) |
22117 | 519 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.show)); |
5832 | 520 |
|
24868 | 521 |
val _ = |
17068 | 522 |
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
|
523 |
(K.tag_proof K.prf_asm_goal) |
22117 | 524 |
(SpecParse.statement >> ((Toplevel.print oo Toplevel.proof') o IsarCmd.thus)); |
6501 | 525 |
|
5832 | 526 |
|
5914 | 527 |
(* facts *) |
5832 | 528 |
|
22117 | 529 |
val facts = P.and_list1 SpecParse.xthms1; |
9197 | 530 |
|
24868 | 531 |
val _ = |
17068 | 532 |
OuterSyntax.command "then" "forward chaining" |
533 |
(K.tag_proof K.prf_chain) |
|
17900 | 534 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 535 |
|
24868 | 536 |
val _ = |
17068 | 537 |
OuterSyntax.command "from" "forward chaining from given facts" |
538 |
(K.tag_proof K.prf_chain) |
|
17900 | 539 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss))); |
5914 | 540 |
|
24868 | 541 |
val _ = |
17068 | 542 |
OuterSyntax.command "with" "forward chaining from given and current facts" |
543 |
(K.tag_proof K.prf_chain) |
|
17900 | 544 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss))); |
6878 | 545 |
|
24868 | 546 |
val _ = |
17068 | 547 |
OuterSyntax.command "note" "define facts" |
548 |
(K.tag_proof K.prf_decl) |
|
22117 | 549 |
(SpecParse.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss))); |
5832 | 550 |
|
24868 | 551 |
val _ = |
17068 | 552 |
OuterSyntax.command "using" "augment goal facts" |
553 |
(K.tag_proof K.prf_decl) |
|
18544 | 554 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using))); |
555 |
||
24868 | 556 |
val _ = |
18544 | 557 |
OuterSyntax.command "unfolding" "unfold definitions in goal and facts" |
558 |
(K.tag_proof K.prf_decl) |
|
559 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding))); |
|
12926 | 560 |
|
5832 | 561 |
|
562 |
(* proof context *) |
|
563 |
||
24868 | 564 |
val _ = |
17068 | 565 |
OuterSyntax.command "fix" "fix local variables (Skolem constants)" |
566 |
(K.tag_proof K.prf_asm) |
|
19844 | 567 |
(P.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix))); |
11890 | 568 |
|
24868 | 569 |
val _ = |
17068 | 570 |
OuterSyntax.command "assume" "assume propositions" |
571 |
(K.tag_proof K.prf_asm) |
|
22117 | 572 |
(SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume))); |
5832 | 573 |
|
24868 | 574 |
val _ = |
17068 | 575 |
OuterSyntax.command "presume" "assume propositions, to be established later" |
576 |
(K.tag_proof K.prf_asm) |
|
22117 | 577 |
(SpecParse.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume))); |
6850 | 578 |
|
24868 | 579 |
val _ = |
17068 | 580 |
OuterSyntax.command "def" "local definition" |
581 |
(K.tag_proof K.prf_asm) |
|
18308 | 582 |
(P.and_list1 |
22117 | 583 |
(SpecParse.opt_thm_name ":" -- |
28083
103d9282a946
explicit type Name.binding for higher-specification elements;
wenzelm
parents:
27877
diff
changeset
|
584 |
((P.binding -- P.opt_mixfix) -- ((P.$$$ "\\<equiv>" || P.$$$ "==") |-- P.!!! P.termp))) |
18308 | 585 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def))); |
6953 | 586 |
|
24868 | 587 |
val _ = |
11890 | 588 |
OuterSyntax.command "obtain" "generalized existence" |
17068 | 589 |
(K.tag_proof K.prf_asm_goal) |
22117 | 590 |
(P.parname -- Scan.optional (P.fixes --| P.where_) [] -- SpecParse.statement |
18895 | 591 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain x y z))); |
5832 | 592 |
|
24868 | 593 |
val _ = |
17854 | 594 |
OuterSyntax.command "guess" "wild guessing (unstructured)" |
595 |
(K.tag_proof K.prf_asm_goal) |
|
19844 | 596 |
(Scan.optional P.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess))); |
17854 | 597 |
|
24868 | 598 |
val _ = |
17068 | 599 |
OuterSyntax.command "let" "bind text variables" |
600 |
(K.tag_proof K.prf_decl) |
|
27378 | 601 |
(P.and_list1 (P.and_list1 P.term -- (P.$$$ "=" |-- P.term)) |
17900 | 602 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind))); |
5832 | 603 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
604 |
val case_spec = |
15703 | 605 |
(P.$$$ "(" |-- P.!!! (P.xname -- Scan.repeat1 (P.maybe P.name) --| P.$$$ ")") || |
22117 | 606 |
P.xname >> rpair []) -- SpecParse.opt_attribs >> P.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
607 |
|
24868 | 608 |
val _ = |
17068 | 609 |
OuterSyntax.command "case" "invoke local context" |
610 |
(K.tag_proof K.prf_asm) |
|
17900 | 611 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case))); |
8370 | 612 |
|
5832 | 613 |
|
614 |
(* proof structure *) |
|
615 |
||
24868 | 616 |
val _ = |
17068 | 617 |
OuterSyntax.command "{" "begin explicit proof block" |
618 |
(K.tag_proof K.prf_open) |
|
17900 | 619 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 620 |
|
24868 | 621 |
val _ = |
17068 | 622 |
OuterSyntax.command "}" "end explicit proof block" |
623 |
(K.tag_proof K.prf_close) |
|
20305 | 624 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 625 |
|
24868 | 626 |
val _ = |
17068 | 627 |
OuterSyntax.command "next" "enter next proof block" |
628 |
(K.tag_proof K.prf_block) |
|
17900 | 629 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 630 |
|
631 |
||
632 |
(* end proof *) |
|
633 |
||
24868 | 634 |
val _ = |
17068 | 635 |
OuterSyntax.command "qed" "conclude (sub-)proof" |
636 |
(K.tag_proof K.qed_block) |
|
26676 | 637 |
(Scan.option Method.parse >> IsarCmd.qed); |
5832 | 638 |
|
24868 | 639 |
val _ = |
17068 | 640 |
OuterSyntax.command "by" "terminal backward proof" |
641 |
(K.tag_proof K.qed) |
|
26676 | 642 |
(Method.parse -- Scan.option Method.parse >> IsarCmd.terminal_proof); |
6404 | 643 |
|
24868 | 644 |
val _ = |
17068 | 645 |
OuterSyntax.command ".." "default proof" |
646 |
(K.tag_proof K.qed) |
|
26676 | 647 |
(Scan.succeed IsarCmd.default_proof); |
8966 | 648 |
|
24868 | 649 |
val _ = |
17068 | 650 |
OuterSyntax.command "." "immediate proof" |
651 |
(K.tag_proof K.qed) |
|
26676 | 652 |
(Scan.succeed IsarCmd.immediate_proof); |
6404 | 653 |
|
24868 | 654 |
val _ = |
17068 | 655 |
OuterSyntax.command "done" "done proof" |
656 |
(K.tag_proof K.qed) |
|
26676 | 657 |
(Scan.succeed IsarCmd.done_proof); |
5832 | 658 |
|
24868 | 659 |
val _ = |
25108 | 660 |
OuterSyntax.command "sorry" "skip proof (quick-and-dirty mode only!)" |
17068 | 661 |
(K.tag_proof K.qed) |
26676 | 662 |
(Scan.succeed IsarCmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
663 |
|
24868 | 664 |
val _ = |
17068 | 665 |
OuterSyntax.command "oops" "forget proof" |
666 |
(K.tag_proof K.qed_global) |
|
18561 | 667 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 668 |
|
5832 | 669 |
|
670 |
(* proof steps *) |
|
671 |
||
24868 | 672 |
val _ = |
17068 | 673 |
OuterSyntax.command "defer" "shuffle internal proof state" |
674 |
(K.tag_proof K.prf_script) |
|
17900 | 675 |
(Scan.option P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
8165 | 676 |
|
24868 | 677 |
val _ = |
17068 | 678 |
OuterSyntax.command "prefer" "shuffle internal proof state" |
679 |
(K.tag_proof K.prf_script) |
|
17900 | 680 |
(P.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
8165 | 681 |
|
24868 | 682 |
val _ = |
17068 | 683 |
OuterSyntax.command "apply" "initial refinement step (unstructured)" |
684 |
(K.tag_proof K.prf_script) |
|
22117 | 685 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 686 |
|
24868 | 687 |
val _ = |
17068 | 688 |
OuterSyntax.command "apply_end" "terminal refinement (unstructured)" |
689 |
(K.tag_proof K.prf_script) |
|
22117 | 690 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 691 |
|
24868 | 692 |
val _ = |
17068 | 693 |
OuterSyntax.command "proof" "backward proof" |
694 |
(K.tag_proof K.prf_block) |
|
22117 | 695 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
33390 | 696 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof m)) o |
27563 | 697 |
Toplevel.skip_proof (fn i => i + 1))); |
5832 | 698 |
|
699 |
||
6773 | 700 |
(* calculational proof commands *) |
701 |
||
6878 | 702 |
val calc_args = |
22117 | 703 |
Scan.option (P.$$$ "(" |-- P.!!! ((SpecParse.xthms1 --| P.$$$ ")"))); |
6878 | 704 |
|
24868 | 705 |
val _ = |
17068 | 706 |
OuterSyntax.command "also" "combine calculation and current facts" |
707 |
(K.tag_proof K.prf_decl) |
|
17900 | 708 |
(calc_args >> (Toplevel.proofs' o Calculation.also)); |
6773 | 709 |
|
24868 | 710 |
val _ = |
17068 | 711 |
OuterSyntax.command "finally" "combine calculation and current facts, exhibit result" |
712 |
(K.tag_proof K.prf_chain) |
|
30189
3633f560f4c3
discontinued experimental support for Alice -- too hard to maintain its many language incompatibilities, never really worked anyway;
wenzelm
parents:
30173
diff
changeset
|
713 |
(calc_args >> (Toplevel.proofs' o Calculation.finally)); |
6773 | 714 |
|
24868 | 715 |
val _ = |
17068 | 716 |
OuterSyntax.command "moreover" "augment calculation by current facts" |
717 |
(K.tag_proof K.prf_decl) |
|
17900 | 718 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 719 |
|
24868 | 720 |
val _ = |
8588 | 721 |
OuterSyntax.command "ultimately" "augment calculation by current facts, exhibit result" |
17068 | 722 |
(K.tag_proof K.prf_chain) |
17900 | 723 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 724 |
|
6773 | 725 |
|
6742 | 726 |
(* proof navigation *) |
5944 | 727 |
|
24868 | 728 |
val _ = |
17068 | 729 |
OuterSyntax.command "back" "backtracking of proof command" |
730 |
(K.tag_proof K.prf_script) |
|
33390 | 731 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I)); |
6742 | 732 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
733 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
734 |
(* nested commands *) |
25578 | 735 |
|
29309 | 736 |
val props_text = |
737 |
Scan.optional ValueParse.properties [] -- P.position P.string >> (fn (props, (str, pos)) => |
|
738 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
739 |
||
25578 | 740 |
val _ = |
741 |
OuterSyntax.improper_command "Isabelle.command" "nested Isabelle command" K.control |
|
29309 | 742 |
(props_text :|-- (fn (pos, str) => |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
743 |
(case OuterSyntax.parse pos str of |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
744 |
[tr] => Scan.succeed (K tr) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
745 |
| _ => Scan.fail_with (K "exactly one command expected")) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
746 |
handle ERROR msg => Scan.fail_with (K msg))); |
25578 | 747 |
|
748 |
||
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
749 |
|
5832 | 750 |
(** diagnostic commands (for interactive mode only) **) |
751 |
||
8464 | 752 |
val opt_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) []; |
20621 | 753 |
val opt_bang = Scan.optional (P.$$$ "!" >> K true) false; |
8464 | 754 |
|
24868 | 755 |
val _ = |
7124 | 756 |
OuterSyntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
9010 | 757 |
K.diag (P.nat >> (Toplevel.no_timing oo IsarCmd.pretty_setmargin)); |
7124 | 758 |
|
24868 | 759 |
val _ = |
21714 | 760 |
OuterSyntax.improper_command "help" "print outer syntax commands" K.diag |
24871 | 761 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax)); |
21714 | 762 |
|
24868 | 763 |
val _ = |
21714 | 764 |
OuterSyntax.improper_command "print_commands" "print outer syntax commands" K.diag |
24871 | 765 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative OuterSyntax.print_outer_syntax)); |
5832 | 766 |
|
24868 | 767 |
val _ = |
24115 | 768 |
OuterSyntax.improper_command "print_configs" "print configuration options" K.diag |
769 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_configs)); |
|
23989 | 770 |
|
24868 | 771 |
val _ = |
7308 | 772 |
OuterSyntax.improper_command "print_context" "print theory context name" K.diag |
9010 | 773 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_context)); |
7308 | 774 |
|
24868 | 775 |
val _ = |
6723 | 776 |
OuterSyntax.improper_command "print_theory" "print logical theory contents (verbose!)" K.diag |
20621 | 777 |
(opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theory)); |
5832 | 778 |
|
24868 | 779 |
val _ = |
21726 | 780 |
OuterSyntax.improper_command "print_syntax" "print inner syntax of context (verbose!)" K.diag |
9010 | 781 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_syntax)); |
5832 | 782 |
|
24868 | 783 |
val _ = |
21726 | 784 |
OuterSyntax.improper_command "print_abbrevs" "print constant abbreviation of context" K.diag |
785 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_abbrevs)); |
|
786 |
||
24868 | 787 |
val _ = |
17068 | 788 |
OuterSyntax.improper_command "print_theorems" |
789 |
"print theorems of local theory or proof context" K.diag |
|
33515
d066e8369a33
print_theorems: suppress concealed (global) facts, unless "!" option is given;
wenzelm
parents:
33456
diff
changeset
|
790 |
(opt_bang >> (Toplevel.no_timing oo IsarCmd.print_theorems)); |
5881 | 791 |
|
24868 | 792 |
val _ = |
12061 | 793 |
OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag |
794 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_locales)); |
|
795 |
||
24868 | 796 |
val _ = |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
797 |
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
|
798 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory |
24219 | 799 |
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
|
800 |
|
24868 | 801 |
val _ = |
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
802 |
OuterSyntax.improper_command "print_locale" "print locale of this theory" K.diag |
29223 | 803 |
(opt_bang -- P.xname >> (Toplevel.no_timing oo IsarCmd.print_locale)); |
12061 | 804 |
|
24868 | 805 |
val _ = |
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
806 |
OuterSyntax.improper_command "print_interps" |
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
807 |
"print interpretations of locale for this theory" K.diag |
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
808 |
(P.xname >> (Toplevel.no_timing oo IsarCmd.print_registrations)); |
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
809 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
810 |
val _ = |
12061 | 811 |
OuterSyntax.improper_command "print_attributes" "print attributes of this theory" K.diag |
9010 | 812 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_attributes)); |
5832 | 813 |
|
24868 | 814 |
val _ = |
16027 | 815 |
OuterSyntax.improper_command "print_simpset" "print context of Simplifier" K.diag |
816 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_simpset)); |
|
817 |
||
24868 | 818 |
val _ = |
12383 | 819 |
OuterSyntax.improper_command "print_rules" "print intro/elim rules" K.diag |
820 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_rules)); |
|
821 |
||
24868 | 822 |
val _ = |
11666 | 823 |
OuterSyntax.improper_command "print_trans_rules" "print transitivity rules" K.diag |
9221 | 824 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_trans_rules)); |
825 |
||
24868 | 826 |
val _ = |
12061 | 827 |
OuterSyntax.improper_command "print_methods" "print methods of this theory" K.diag |
9010 | 828 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_methods)); |
5832 | 829 |
|
24868 | 830 |
val _ = |
9221 | 831 |
OuterSyntax.improper_command "print_antiquotations" "print antiquotations (global)" K.diag |
832 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_antiquotations)); |
|
833 |
||
24868 | 834 |
val _ = |
22485 | 835 |
OuterSyntax.improper_command "thy_deps" "visualize theory dependencies" |
836 |
K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.thy_deps)); |
|
837 |
||
24868 | 838 |
val _ = |
20574 | 839 |
OuterSyntax.improper_command "class_deps" "visualize class dependencies" |
840 |
K.diag (Scan.succeed (Toplevel.no_timing o IsarCmd.class_deps)); |
|
841 |
||
24868 | 842 |
val _ = |
9454 | 843 |
OuterSyntax.improper_command "thm_deps" "visualize theorem dependencies" |
22117 | 844 |
K.diag (SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.thm_deps)); |
9454 | 845 |
|
24868 | 846 |
val _ = |
6723 | 847 |
OuterSyntax.improper_command "print_binds" "print term bindings of proof context" K.diag |
9010 | 848 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_binds)); |
5832 | 849 |
|
24868 | 850 |
val _ = |
8370 | 851 |
OuterSyntax.improper_command "print_facts" "print facts of proof context" K.diag |
21004 | 852 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_facts)); |
5832 | 853 |
|
24868 | 854 |
val _ = |
8370 | 855 |
OuterSyntax.improper_command "print_cases" "print cases of proof context" K.diag |
9010 | 856 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.print_cases)); |
8370 | 857 |
|
24868 | 858 |
val _ = |
19269 | 859 |
OuterSyntax.improper_command "print_statement" "print theorems as long statements" K.diag |
22117 | 860 |
(opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_stmts)); |
19269 | 861 |
|
24868 | 862 |
val _ = |
8464 | 863 |
OuterSyntax.improper_command "thm" "print theorems" K.diag |
22117 | 864 |
(opt_modes -- SpecParse.xthms1 >> (Toplevel.no_timing oo IsarCmd.print_thms)); |
5832 | 865 |
|
24868 | 866 |
val _ = |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
867 |
OuterSyntax.improper_command "prf" "print proof terms of theorems" K.diag |
22866 | 868 |
(opt_modes -- Scan.option SpecParse.xthms1 |
869 |
>> (Toplevel.no_timing oo IsarCmd.print_prfs false)); |
|
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
870 |
|
24868 | 871 |
val _ = |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
872 |
OuterSyntax.improper_command "full_prf" "print full proof terms of theorems" K.diag |
22117 | 873 |
(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
|
874 |
|
24868 | 875 |
val _ = |
6723 | 876 |
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
|
877 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_prop)); |
5832 | 878 |
|
24868 | 879 |
val _ = |
6723 | 880 |
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
|
881 |
(opt_modes -- P.term >> (Toplevel.no_timing oo IsarCmd.print_term)); |
5832 | 882 |
|
24868 | 883 |
val _ = |
6723 | 884 |
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
|
885 |
(opt_modes -- P.typ >> (Toplevel.no_timing oo IsarCmd.print_type)); |
5832 | 886 |
|
24868 | 887 |
val _ = |
31125
80218ee73167
transferred code generator preprocessor into separate module
haftmann
parents:
30727
diff
changeset
|
888 |
OuterSyntax.improper_command "print_codesetup" "print code generator setup" K.diag |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
889 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
890 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 891 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 892 |
|
26184 | 893 |
val _ = |
894 |
OuterSyntax.improper_command "unused_thms" "find unused theorems" K.diag |
|
895 |
(Scan.option ((Scan.repeat1 (Scan.unless P.minus P.name) --| P.minus) -- |
|
896 |
Scan.option (Scan.repeat1 (Scan.unless P.minus P.name))) >> |
|
897 |
(Toplevel.no_timing oo IsarCmd.unused_thms)); |
|
898 |
||
5832 | 899 |
|
30142
8d6145694bb5
moved find_theorems.ML and find_consts.ML to Pure/Tools, collecting main implementation in one place each;
wenzelm
parents:
29882
diff
changeset
|
900 |
|
5832 | 901 |
(** system commands (for interactive mode only) **) |
902 |
||
24868 | 903 |
val _ = |
8650 | 904 |
OuterSyntax.improper_command "cd" "change current working directory" K.diag |
14950 | 905 |
(P.path >> (Toplevel.no_timing oo IsarCmd.cd)); |
5832 | 906 |
|
24868 | 907 |
val _ = |
6723 | 908 |
OuterSyntax.improper_command "pwd" "print current working directory" K.diag |
9010 | 909 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.pwd)); |
5832 | 910 |
|
24868 | 911 |
val _ = |
6723 | 912 |
OuterSyntax.improper_command "use_thy" "use theory file" K.diag |
26404 | 913 |
(P.name >> (fn name => |
914 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.use_thy name))); |
|
5832 | 915 |
|
24868 | 916 |
val _ = |
7102 | 917 |
OuterSyntax.improper_command "touch_thy" "outdate theory, including descendants" K.diag |
27494 | 918 |
(P.name >> (fn name => |
919 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.touch_thy name))); |
|
7908 | 920 |
|
24868 | 921 |
val _ = |
7102 | 922 |
OuterSyntax.improper_command "remove_thy" "remove theory from loader database" K.diag |
27494 | 923 |
(P.name >> (fn name => |
924 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.remove_thy name))); |
|
7102 | 925 |
|
24868 | 926 |
val _ = |
7931 | 927 |
OuterSyntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
27494 | 928 |
K.diag (P.name >> (fn name => |
929 |
Toplevel.no_timing o Toplevel.imperative (fn () => ThyInfo.kill_thy name))); |
|
7931 | 930 |
|
24868 | 931 |
val _ = |
14934 | 932 |
OuterSyntax.improper_command "display_drafts" "display raw source files with symbols" |
14950 | 933 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.display_drafts)); |
14934 | 934 |
|
24868 | 935 |
val _ = |
14934 | 936 |
OuterSyntax.improper_command "print_drafts" "print raw source files with symbols" |
14950 | 937 |
K.diag (Scan.repeat1 P.path >> (Toplevel.no_timing oo IsarCmd.print_drafts)); |
14934 | 938 |
|
9731 | 939 |
val opt_limits = |
940 |
Scan.option P.nat -- Scan.option (P.$$$ "," |-- P.!!! P.nat); |
|
941 |
||
24868 | 942 |
val _ = |
8886 | 943 |
OuterSyntax.improper_command "pr" "print current proof state (if present)" K.diag |
9731 | 944 |
(opt_modes -- opt_limits >> (Toplevel.no_timing oo IsarCmd.pr)); |
7199 | 945 |
|
24868 | 946 |
val _ = |
7222 | 947 |
OuterSyntax.improper_command "disable_pr" "disable printing of toplevel state" K.diag |
9010 | 948 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.disable_pr)); |
5832 | 949 |
|
24868 | 950 |
val _ = |
7222 | 951 |
OuterSyntax.improper_command "enable_pr" "enable printing of toplevel state" K.diag |
9010 | 952 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.enable_pr)); |
7222 | 953 |
|
24868 | 954 |
val _ = |
6723 | 955 |
OuterSyntax.improper_command "commit" "commit current session to ML database" K.diag |
26490 | 956 |
(P.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 957 |
|
24868 | 958 |
val _ = |
6723 | 959 |
OuterSyntax.improper_command "quit" "quit Isabelle" K.control |
9010 | 960 |
(P.opt_unit >> (Toplevel.no_timing oo K IsarCmd.quit)); |
5832 | 961 |
|
24868 | 962 |
val _ = |
6723 | 963 |
OuterSyntax.improper_command "exit" "exit Isar loop" K.control |
9010 | 964 |
(Scan.succeed (Toplevel.no_timing o IsarCmd.exit)); |
5832 | 965 |
|
966 |
end; |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
967 |