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