author | wenzelm |
Wed, 26 Sep 2012 14:23:33 +0200 | |
changeset 49569 | 7b6aaf446496 |
parent 48997 | d1dbc87e3211 |
child 49863 | b5fb6e7f8d81 |
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 |
||
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
7 |
structure Isar_Syn: sig end = |
5832 | 8 |
struct |
9 |
||
7749 | 10 |
(** markup commands **) |
5832 | 11 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
12 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
13 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 14 |
@{command_spec "header"} "theory header" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
15 |
(Parse.doc_source >> Isar_Cmd.header_markup); |
6353 | 16 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
17 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
18 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 19 |
@{command_spec "chapter"} "chapter heading" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
20 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 21 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
22 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
23 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 24 |
@{command_spec "section"} "section heading" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
25 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 26 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
27 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
28 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 29 |
@{command_spec "subsection"} "subsection heading" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
30 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
31 |
|
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
32 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
33 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 34 |
@{command_spec "subsubsection"} "subsubsection heading" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
35 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 36 |
|
24868 | 37 |
val _ = |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
38 |
Outer_Syntax.markup_command Thy_Output.MarkupEnv |
48642 | 39 |
@{command_spec "text"} "formal comment (theory)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
40 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 41 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
42 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
43 |
Outer_Syntax.markup_command Thy_Output.Verbatim |
48642 | 44 |
@{command_spec "text_raw"} "raw document preparation text" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
45 |
(Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 46 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
47 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
48 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 49 |
@{command_spec "sect"} "formal comment (proof)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
50 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 51 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
52 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
53 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 54 |
@{command_spec "subsect"} "formal comment (proof)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
55 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 56 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
57 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
58 |
Outer_Syntax.markup_command Thy_Output.Markup |
48642 | 59 |
@{command_spec "subsubsect"} "formal comment (proof)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
60 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 61 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
62 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
63 |
Outer_Syntax.markup_command Thy_Output.MarkupEnv |
48642 | 64 |
@{command_spec "txt"} "formal comment (proof)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
65 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 66 |
|
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
67 |
val _ = |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
68 |
Outer_Syntax.markup_command Thy_Output.Verbatim |
48642 | 69 |
@{command_spec "txt_raw"} "raw document preparation text (proof)" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
70 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7775 | 71 |
|
5832 | 72 |
|
6886 | 73 |
|
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
|
74 |
(** theory commands **) |
6886 | 75 |
|
5832 | 76 |
(* classes and sorts *) |
77 |
||
24868 | 78 |
val _ = |
48642 | 79 |
Outer_Syntax.command @{command_spec "classes"} "declare type classes" |
48643 | 80 |
(Scan.repeat1 (Parse.binding -- Scan.optional ((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
81 |
Parse.!!! (Parse.list1 Parse.class)) []) |
36950 | 82 |
>> (Toplevel.theory o fold AxClass.axiomatize_class_cmd)); |
5832 | 83 |
|
24868 | 84 |
val _ = |
48642 | 85 |
Outer_Syntax.command @{command_spec "classrel"} "state inclusion of type classes (axiomatic!)" |
48643 | 86 |
(Parse.and_list1 (Parse.class -- ((@{keyword "\<subseteq>"} || @{keyword "<"}) |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
87 |
|-- Parse.!!! Parse.class)) |
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
88 |
>> (Toplevel.theory o AxClass.axiomatize_classrel_cmd)); |
5832 | 89 |
|
24868 | 90 |
val _ = |
48642 | 91 |
Outer_Syntax.local_theory @{command_spec "default_sort"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
92 |
"declare default sort for explicit type variables" |
36950 | 93 |
(Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy)); |
5832 | 94 |
|
95 |
||
96 |
(* types *) |
|
97 |
||
24868 | 98 |
val _ = |
48642 | 99 |
Outer_Syntax.local_theory @{command_spec "typedecl"} "type declaration" |
36950 | 100 |
(Parse.type_args -- Parse.binding -- Parse.opt_mixfix |
35835 | 101 |
>> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd)); |
5832 | 102 |
|
24868 | 103 |
val _ = |
48642 | 104 |
Outer_Syntax.local_theory @{command_spec "type_synonym"} "declare type abbreviation" |
45837 | 105 |
(Parse.type_args -- Parse.binding -- |
48643 | 106 |
(@{keyword "="} |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix')) |
45837 | 107 |
>> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)); |
5832 | 108 |
|
24868 | 109 |
val _ = |
48642 | 110 |
Outer_Syntax.command @{command_spec "nonterminal"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
111 |
"declare syntactic type constructors (grammar nonterminal symbols)" |
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42359
diff
changeset
|
112 |
(Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global)); |
5832 | 113 |
|
24868 | 114 |
val _ = |
48642 | 115 |
Outer_Syntax.command @{command_spec "arities"} "state type arities (axiomatic!)" |
36950 | 116 |
(Scan.repeat1 Parse.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd)); |
5832 | 117 |
|
118 |
||
119 |
(* consts and syntax *) |
|
120 |
||
24868 | 121 |
val _ = |
48642 | 122 |
Outer_Syntax.command @{command_spec "judgment"} "declare object-logic judgment" |
36950 | 123 |
(Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
8227 | 124 |
|
24868 | 125 |
val _ = |
48642 | 126 |
Outer_Syntax.command @{command_spec "consts"} "declare constants" |
36950 | 127 |
(Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts)); |
5832 | 128 |
|
12142 | 129 |
val mode_spec = |
48643 | 130 |
(@{keyword "output"} >> K ("", false)) || |
131 |
Parse.name -- Scan.optional (@{keyword "output"} >> K false) true; |
|
9731 | 132 |
|
14900 | 133 |
val opt_mode = |
48643 | 134 |
Scan.optional (@{keyword "("} |-- Parse.!!! (mode_spec --| @{keyword ")"})) Syntax.mode_default; |
5832 | 135 |
|
24868 | 136 |
val _ = |
48642 | 137 |
Outer_Syntax.command @{command_spec "syntax"} "declare syntactic constants" |
42299 | 138 |
(opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 139 |
|
24868 | 140 |
val _ = |
48642 | 141 |
Outer_Syntax.command @{command_spec "no_syntax"} "delete syntax declarations" |
42299 | 142 |
(opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.del_modesyntax)); |
15748 | 143 |
|
5832 | 144 |
|
145 |
(* translations *) |
|
146 |
||
147 |
val trans_pat = |
|
42326 | 148 |
Scan.optional |
48643 | 149 |
(@{keyword "("} |-- Parse.!!! (Parse.xname --| @{keyword ")"})) "logic" |
42326 | 150 |
-- Parse.inner_syntax Parse.string; |
5832 | 151 |
|
152 |
fun trans_arrow toks = |
|
48643 | 153 |
((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule || |
154 |
(@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule || |
|
155 |
(@{keyword "\<rightleftharpoons>"} || @{keyword "=="}) >> K Syntax.Parse_Print_Rule) toks; |
|
5832 | 156 |
|
157 |
val trans_line = |
|
36950 | 158 |
trans_pat -- Parse.!!! (trans_arrow -- trans_pat) |
5832 | 159 |
>> (fn (left, (arr, right)) => arr (left, right)); |
160 |
||
24868 | 161 |
val _ = |
48642 | 162 |
Outer_Syntax.command @{command_spec "translations"} "declare syntax translation rules" |
42204 | 163 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations)); |
5832 | 164 |
|
24868 | 165 |
val _ = |
48642 | 166 |
Outer_Syntax.command @{command_spec "no_translations"} "remove syntax translation rules" |
42204 | 167 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations)); |
19260 | 168 |
|
5832 | 169 |
|
170 |
(* axioms and definitions *) |
|
171 |
||
24868 | 172 |
val _ = |
48642 | 173 |
Outer_Syntax.command @{command_spec "axioms"} "state arbitrary propositions (axiomatic!)" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
174 |
(Scan.repeat1 Parse_Spec.spec >> |
37861 | 175 |
(fn spec => Toplevel.theory (fn thy => |
176 |
(legacy_feature "Old 'axioms' command -- use 'axiomatization' instead"; |
|
177 |
Isar_Cmd.add_axioms spec thy)))); |
|
5832 | 178 |
|
19631 | 179 |
val opt_unchecked_overloaded = |
48643 | 180 |
Scan.optional (@{keyword "("} |-- Parse.!!! |
181 |
(((@{keyword "unchecked"} >> K true) -- |
|
182 |
Scan.optional (@{keyword "overloaded"} >> K true) false || |
|
183 |
@{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false); |
|
19631 | 184 |
|
24868 | 185 |
val _ = |
48642 | 186 |
Outer_Syntax.command @{command_spec "defs"} "define constants" |
35852
4e3fe0b8687b
minor renovation of old-style 'axioms' -- make it an alias of iterated 'axiomatization';
wenzelm
parents:
35835
diff
changeset
|
187 |
(opt_unchecked_overloaded -- |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
188 |
Scan.repeat1 (Parse_Spec.thm_name ":" -- Parse.prop >> (fn ((x, y), z) => ((x, z), y))) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
189 |
>> (Toplevel.theory o Isar_Cmd.add_defs)); |
6370 | 190 |
|
14642 | 191 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
192 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
193 |
|
24868 | 194 |
val _ = |
48642 | 195 |
Outer_Syntax.local_theory' @{command_spec "definition"} "constant definition" |
44192
a32ca9165928
less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents:
44187
diff
changeset
|
196 |
(Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args)); |
18780 | 197 |
|
24868 | 198 |
val _ = |
48642 | 199 |
Outer_Syntax.local_theory' @{command_spec "abbreviation"} "constant abbreviation" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
200 |
(opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop) |
36950 | 201 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 202 |
|
24868 | 203 |
val _ = |
48642 | 204 |
Outer_Syntax.local_theory @{command_spec "type_notation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
205 |
"add concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
206 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 207 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
35413 | 208 |
|
209 |
val _ = |
|
48642 | 210 |
Outer_Syntax.local_theory @{command_spec "no_type_notation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
211 |
"delete concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
212 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 213 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
35413 | 214 |
|
215 |
val _ = |
|
48642 | 216 |
Outer_Syntax.local_theory @{command_spec "notation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
217 |
"add concrete syntax for constants / fixed variables" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
218 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 219 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 220 |
|
221 |
val _ = |
|
48642 | 222 |
Outer_Syntax.local_theory @{command_spec "no_notation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
223 |
"delete concrete syntax for constants / fixed variables" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
224 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 225 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 226 |
|
5832 | 227 |
|
18616 | 228 |
(* constant specifications *) |
229 |
||
24868 | 230 |
val _ = |
48642 | 231 |
Outer_Syntax.command @{command_spec "axiomatization"} "axiomatic constant specification" |
36950 | 232 |
(Scan.optional Parse.fixes [] -- |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
233 |
Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) [] |
36950 | 234 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 235 |
|
236 |
||
5914 | 237 |
(* theorems *) |
238 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
239 |
fun theorems kind = |
45600
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
240 |
Parse_Spec.name_facts -- Parse.for_fixes |
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
241 |
>> (fn (facts, fixes) => #2 oo Specification.theorems_cmd kind facts fixes); |
12712 | 242 |
|
24868 | 243 |
val _ = |
48642 | 244 |
Outer_Syntax.local_theory' @{command_spec "theorems"} "define theorems" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
245 |
(theorems Thm.theoremK); |
5914 | 246 |
|
24868 | 247 |
val _ = |
48642 | 248 |
Outer_Syntax.local_theory' @{command_spec "lemmas"} "define lemmas" (theorems Thm.lemmaK); |
5914 | 249 |
|
24868 | 250 |
val _ = |
48642 | 251 |
Outer_Syntax.local_theory' @{command_spec "declare"} "declare theorems" |
45600
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
252 |
(Parse.and_list1 Parse_Spec.xthms1 -- Parse.for_fixes |
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
253 |
>> (fn (facts, fixes) => |
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
254 |
#2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes)); |
9589 | 255 |
|
5914 | 256 |
|
5832 | 257 |
(* name space entry path *) |
258 |
||
48645 | 259 |
fun hide_names spec hide what = |
260 |
Outer_Syntax.command spec ("hide " ^ what ^ " from name space") |
|
36950 | 261 |
((Parse.opt_keyword "open" >> not) -- Scan.repeat1 Parse.xname >> |
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
262 |
(Toplevel.theory o uncurry hide)); |
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
263 |
|
48645 | 264 |
val _ = hide_names @{command_spec "hide_class"} Isar_Cmd.hide_class "classes"; |
265 |
val _ = hide_names @{command_spec "hide_type"} Isar_Cmd.hide_type "types"; |
|
266 |
val _ = hide_names @{command_spec "hide_const"} Isar_Cmd.hide_const "constants"; |
|
267 |
val _ = hide_names @{command_spec "hide_fact"} Isar_Cmd.hide_fact "facts"; |
|
5832 | 268 |
|
269 |
||
270 |
(* use ML text *) |
|
271 |
||
24868 | 272 |
val _ = |
48642 | 273 |
Outer_Syntax.command @{command_spec "use"} "ML text from file" |
48881
46e053eda5dd
clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents:
48792
diff
changeset
|
274 |
(Parse.path >> (fn name => |
48997 | 275 |
Toplevel.generic_theory (fn gthy => |
276 |
(legacy_feature "Old 'use' command -- use 'ML_file' instead"; |
|
277 |
Thy_Load.exec_ml (Path.explode name) gthy)))); |
|
7891 | 278 |
|
24868 | 279 |
val _ = |
48642 | 280 |
Outer_Syntax.command @{command_spec "ML"} "ML text within theory or local theory" |
36950 | 281 |
(Parse.ML_source >> (fn (txt, pos) => |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
282 |
Toplevel.generic_theory |
37949
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
283 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt) #> |
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
284 |
Local_Theory.propagate_ml_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
285 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
286 |
val _ = |
48642 | 287 |
Outer_Syntax.command @{command_spec "ML_prf"} "ML text within proof" |
36950 | 288 |
(Parse.ML_source >> (fn (txt, pos) => |
28269 | 289 |
Toplevel.proof (Proof.map_context (Context.proof_map |
37949
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
290 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt))) #> Proof.propagate_ml_env))); |
28269 | 291 |
|
292 |
val _ = |
|
48642 | 293 |
Outer_Syntax.command @{command_spec "ML_val"} "diagnostic ML text" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
294 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
26396 | 295 |
|
296 |
val _ = |
|
48642 | 297 |
Outer_Syntax.command @{command_spec "ML_command"} "diagnostic ML text (silent)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
298 |
(Parse.ML_source >> (Toplevel.no_timing oo Isar_Cmd.ml_diag false)); |
5832 | 299 |
|
24868 | 300 |
val _ = |
48642 | 301 |
Outer_Syntax.command @{command_spec "setup"} "ML theory setup" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
302 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup)); |
30461 | 303 |
|
304 |
val _ = |
|
48642 | 305 |
Outer_Syntax.local_theory @{command_spec "local_setup"} "ML local theory setup" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
306 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
5832 | 307 |
|
24868 | 308 |
val _ = |
48642 | 309 |
Outer_Syntax.command @{command_spec "attribute_setup"} "define attribute in ML" |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
310 |
(Parse.position Parse.name -- |
48643 | 311 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 312 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt))); |
30526 | 313 |
|
314 |
val _ = |
|
48642 | 315 |
Outer_Syntax.command @{command_spec "method_setup"} "define proof method in ML" |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
316 |
(Parse.position Parse.name -- |
48643 | 317 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 318 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
9197 | 319 |
|
24868 | 320 |
val _ = |
48642 | 321 |
Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration" |
40784 | 322 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
323 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt)); |
|
324 |
||
325 |
val _ = |
|
48642 | 326 |
Outer_Syntax.local_theory @{command_spec "syntax_declaration"} "generic ML syntax declaration" |
40784 | 327 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
328 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt)); |
|
22088 | 329 |
|
24868 | 330 |
val _ = |
48642 | 331 |
Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML" |
42464 | 332 |
(Parse.position Parse.name -- |
48643 | 333 |
(@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) -- |
334 |
Parse.ML_source -- Scan.optional (@{keyword "identifier"} |-- Scan.repeat1 Parse.xname) [] |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
335 |
>> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d)); |
22202 | 336 |
|
5832 | 337 |
|
338 |
(* translation functions *) |
|
339 |
||
36950 | 340 |
val trfun = Parse.opt_keyword "advanced" -- Parse.ML_source; |
14642 | 341 |
|
24868 | 342 |
val _ = |
48642 | 343 |
Outer_Syntax.command @{command_spec "parse_ast_translation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
344 |
"install parse ast translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
345 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 346 |
|
24868 | 347 |
val _ = |
48642 | 348 |
Outer_Syntax.command @{command_spec "parse_translation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
349 |
"install parse translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
350 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 351 |
|
24868 | 352 |
val _ = |
48642 | 353 |
Outer_Syntax.command @{command_spec "print_translation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
354 |
"install print translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
355 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 356 |
|
24868 | 357 |
val _ = |
48642 | 358 |
Outer_Syntax.command @{command_spec "typed_print_translation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
359 |
"install typed print translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
360 |
(trfun >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 361 |
|
24868 | 362 |
val _ = |
48642 | 363 |
Outer_Syntax.command @{command_spec "print_ast_translation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
364 |
"install print ast translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
365 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 366 |
|
367 |
||
368 |
(* oracles *) |
|
369 |
||
24868 | 370 |
val _ = |
48642 | 371 |
Outer_Syntax.command @{command_spec "oracle"} "declare oracle" |
48643 | 372 |
(Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
373 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 374 |
|
375 |
||
47057 | 376 |
(* bundled declarations *) |
377 |
||
378 |
val _ = |
|
48642 | 379 |
Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations" |
48643 | 380 |
((Parse.binding --| @{keyword "="}) -- Parse_Spec.xthms1 -- Parse.for_fixes |
47057 | 381 |
>> (uncurry Bundle.bundle_cmd)); |
382 |
||
383 |
val _ = |
|
48642 | 384 |
Outer_Syntax.command @{command_spec "include"} |
47057 | 385 |
"include declarations from bundle in proof body" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
386 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
387 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.include_cmd))); |
47057 | 388 |
|
389 |
val _ = |
|
48642 | 390 |
Outer_Syntax.command @{command_spec "including"} |
47057 | 391 |
"include declarations from bundle in goal refinement" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
392 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
393 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.including_cmd))); |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
394 |
|
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
395 |
val _ = |
48642 | 396 |
Outer_Syntax.improper_command @{command_spec "print_bundles"} |
397 |
"print bundles of declarations" |
|
47057 | 398 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
399 |
Toplevel.keep (Bundle.print_bundles o Toplevel.context_of))); |
|
400 |
||
401 |
||
47069 | 402 |
(* local theories *) |
403 |
||
404 |
val _ = |
|
48642 | 405 |
Outer_Syntax.command @{command_spec "context"} "begin local theory context" |
47253
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
406 |
((Parse.position Parse.xname >> (fn name => |
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
407 |
Toplevel.print o Toplevel.begin_local_theory true (Named_Target.context_cmd name)) || |
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
408 |
Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element |
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
409 |
>> (fn (incls, elems) => Toplevel.open_target (Bundle.context_cmd incls elems))) |
47069 | 410 |
--| Parse.begin); |
411 |
||
412 |
||
12061 | 413 |
(* locales *) |
414 |
||
12758 | 415 |
val locale_val = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
416 |
Parse_Spec.locale_expression false -- |
48643 | 417 |
Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
418 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 419 |
|
24868 | 420 |
val _ = |
48642 | 421 |
Outer_Syntax.command @{command_spec "locale"} "define named proof context" |
36950 | 422 |
(Parse.binding -- |
48643 | 423 |
Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
27681 | 424 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 425 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
426 |
(Expression.add_locale_cmd I name Binding.empty expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
427 |
|
41270 | 428 |
fun parse_interpretation_arguments mandatory = |
429 |
Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
|
430 |
Scan.optional |
|
431 |
(Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
432 |
||
24868 | 433 |
val _ = |
48642 | 434 |
Outer_Syntax.command @{command_spec "sublocale"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
435 |
"prove sublocale relation between a locale and a locale expression" |
48643 | 436 |
(Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
41270 | 437 |
parse_interpretation_arguments false |
438 |
>> (fn (loc, (expr, equations)) => |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
439 |
Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations))); |
28895 | 440 |
|
441 |
val _ = |
|
48642 | 442 |
Outer_Syntax.command @{command_spec "interpretation"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
443 |
"prove interpretation of locale expression in theory" |
41270 | 444 |
(parse_interpretation_arguments true |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
445 |
>> (fn (expr, equations) => Toplevel.print o |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
446 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 447 |
|
448 |
val _ = |
|
48642 | 449 |
Outer_Syntax.command @{command_spec "interpret"} |
29223 | 450 |
"prove interpretation of locale expression in proof context" |
41270 | 451 |
(parse_interpretation_arguments true |
38108 | 452 |
>> (fn (expr, equations) => Toplevel.print o |
453 |
Toplevel.proof' (Expression.interpret_cmd expr equations))); |
|
29223 | 454 |
|
15703 | 455 |
|
22299 | 456 |
(* classes *) |
457 |
||
24868 | 458 |
val class_val = |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
459 |
Parse_Spec.class_expression -- |
48643 | 460 |
Scan.optional (@{keyword "+"} |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
461 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 462 |
|
24868 | 463 |
val _ = |
48642 | 464 |
Outer_Syntax.command @{command_spec "class"} "define type class" |
48643 | 465 |
(Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 466 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 467 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
41536
diff
changeset
|
468 |
(Class_Declaration.class_cmd I name supclasses elems #> snd))); |
22299 | 469 |
|
24868 | 470 |
val _ = |
48642 | 471 |
Outer_Syntax.local_theory_to_proof @{command_spec "subclass"} "prove a subclass relation" |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
472 |
(Parse.class >> Class_Declaration.subclass_cmd I); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
473 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
474 |
val _ = |
48642 | 475 |
Outer_Syntax.command @{command_spec "instantiation"} "instantiate and prove type arity" |
36950 | 476 |
(Parse.multi_arity --| Parse.begin |
25462 | 477 |
>> (fn arities => Toplevel.print o |
38348
cf7b2121ad9d
moved instantiation target formally to class_target.ML
haftmann
parents:
38342
diff
changeset
|
478 |
Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
24589 | 479 |
|
25485 | 480 |
val _ = |
48642 | 481 |
Outer_Syntax.command @{command_spec "instance"} "prove type arity or subclass relation" |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
482 |
((Parse.class -- |
48643 | 483 |
((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd || |
36950 | 484 |
Parse.multi_arity >> Class.instance_arity_cmd) |
485 |
>> (Toplevel.print oo Toplevel.theory_to_proof) || |
|
486 |
Scan.succeed |
|
487 |
(Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 488 |
|
489 |
||
25519 | 490 |
(* arbitrary overloading *) |
491 |
||
492 |
val _ = |
|
48642 | 493 |
Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions" |
48643 | 494 |
(Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term -- |
495 |
Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true |
|
36950 | 496 |
>> Parse.triple1) --| Parse.begin |
25519 | 497 |
>> (fn operations => Toplevel.print o |
38342
09d4a04d5c2e
moved overloading target formally to overloading.ML
haftmann
parents:
38108
diff
changeset
|
498 |
Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
25519 | 499 |
|
500 |
||
22866 | 501 |
(* code generation *) |
502 |
||
24868 | 503 |
val _ = |
48642 | 504 |
Outer_Syntax.command @{command_spec "code_datatype"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
505 |
"define set of code datatype constructors" |
36950 | 506 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 507 |
|
508 |
||
5832 | 509 |
|
510 |
(** proof commands **) |
|
511 |
||
512 |
(* statements *) |
|
513 |
||
48645 | 514 |
fun gen_theorem spec schematic kind = |
515 |
Outer_Syntax.local_theory_to_proof' spec |
|
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
516 |
("state " ^ (if schematic then "schematic " ^ kind else kind)) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
517 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
47067
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
518 |
Scan.ahead (Parse_Spec.includes >> K "" || |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
519 |
Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
520 |
Scan.optional Parse_Spec.includes [] -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
521 |
Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
522 |
((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd) |
47067
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
523 |
kind NONE (K I) a includes elems concl))); |
5832 | 524 |
|
48645 | 525 |
val _ = gen_theorem @{command_spec "theorem"} false Thm.theoremK; |
526 |
val _ = gen_theorem @{command_spec "lemma"} false Thm.lemmaK; |
|
527 |
val _ = gen_theorem @{command_spec "corollary"} false Thm.corollaryK; |
|
528 |
val _ = gen_theorem @{command_spec "schematic_theorem"} true Thm.theoremK; |
|
529 |
val _ = gen_theorem @{command_spec "schematic_lemma"} true Thm.lemmaK; |
|
530 |
val _ = gen_theorem @{command_spec "schematic_corollary"} true Thm.corollaryK; |
|
5832 | 531 |
|
24868 | 532 |
val _ = |
48642 | 533 |
Outer_Syntax.local_theory_to_proof @{command_spec "notepad"} "begin proof context" |
40960 | 534 |
(Parse.begin >> K Proof.begin_notepad); |
535 |
||
536 |
val _ = |
|
48642 | 537 |
Outer_Syntax.command @{command_spec "have"} "state local goal" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
538 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have)); |
17353 | 539 |
|
24868 | 540 |
val _ = |
48642 | 541 |
Outer_Syntax.command @{command_spec "hence"} "abbreviates \"then have\"" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
542 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence)); |
17353 | 543 |
|
24868 | 544 |
val _ = |
48642 | 545 |
Outer_Syntax.command @{command_spec "show"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
546 |
"state local goal, solving current obligation" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
547 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show)); |
5832 | 548 |
|
24868 | 549 |
val _ = |
48642 | 550 |
Outer_Syntax.command @{command_spec "thus"} "abbreviates \"then show\"" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
551 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus)); |
6501 | 552 |
|
5832 | 553 |
|
5914 | 554 |
(* facts *) |
5832 | 555 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
556 |
val facts = Parse.and_list1 Parse_Spec.xthms1; |
9197 | 557 |
|
24868 | 558 |
val _ = |
48642 | 559 |
Outer_Syntax.command @{command_spec "then"} "forward chaining" |
17900 | 560 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 561 |
|
24868 | 562 |
val _ = |
48642 | 563 |
Outer_Syntax.command @{command_spec "from"} "forward chaining from given facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
564 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd))); |
5914 | 565 |
|
24868 | 566 |
val _ = |
48642 | 567 |
Outer_Syntax.command @{command_spec "with"} "forward chaining from given and current facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
568 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd))); |
6878 | 569 |
|
24868 | 570 |
val _ = |
48642 | 571 |
Outer_Syntax.command @{command_spec "note"} "define facts" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
572 |
(Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd))); |
5832 | 573 |
|
24868 | 574 |
val _ = |
48642 | 575 |
Outer_Syntax.command @{command_spec "using"} "augment goal facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
576 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd))); |
18544 | 577 |
|
24868 | 578 |
val _ = |
48642 | 579 |
Outer_Syntax.command @{command_spec "unfolding"} "unfold definitions in goal and facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
580 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd))); |
12926 | 581 |
|
5832 | 582 |
|
583 |
(* proof context *) |
|
584 |
||
24868 | 585 |
val _ = |
48642 | 586 |
Outer_Syntax.command @{command_spec "fix"} "fix local variables (Skolem constants)" |
36950 | 587 |
(Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd))); |
11890 | 588 |
|
24868 | 589 |
val _ = |
48642 | 590 |
Outer_Syntax.command @{command_spec "assume"} "assume propositions" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
591 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd))); |
5832 | 592 |
|
24868 | 593 |
val _ = |
48642 | 594 |
Outer_Syntax.command @{command_spec "presume"} "assume propositions, to be established later" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
595 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd))); |
6850 | 596 |
|
24868 | 597 |
val _ = |
48642 | 598 |
Outer_Syntax.command @{command_spec "def"} "local definition" |
36950 | 599 |
(Parse.and_list1 |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
600 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 601 |
((Parse.binding -- Parse.opt_mixfix) -- |
48643 | 602 |
((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp))) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
603 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd))); |
6953 | 604 |
|
24868 | 605 |
val _ = |
48642 | 606 |
Outer_Syntax.command @{command_spec "obtain"} "generalized elimination" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
607 |
(Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
608 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 609 |
|
24868 | 610 |
val _ = |
48642 | 611 |
Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)" |
36950 | 612 |
(Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd))); |
17854 | 613 |
|
24868 | 614 |
val _ = |
48642 | 615 |
Outer_Syntax.command @{command_spec "let"} "bind text variables" |
48643 | 616 |
(Parse.and_list1 (Parse.and_list1 Parse.term -- (@{keyword "="} |-- Parse.term)) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
617 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd))); |
5832 | 618 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
619 |
val _ = |
48642 | 620 |
Outer_Syntax.command @{command_spec "write"} "add concrete syntax for constants / fixed variables" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
621 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
622 |
>> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args))); |
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
623 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
624 |
val case_spec = |
48643 | 625 |
(@{keyword "("} |-- |
626 |
Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| @{keyword ")"}) || |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
627 |
Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
628 |
|
24868 | 629 |
val _ = |
48642 | 630 |
Outer_Syntax.command @{command_spec "case"} "invoke local context" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
631 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd))); |
8370 | 632 |
|
5832 | 633 |
|
634 |
(* proof structure *) |
|
635 |
||
24868 | 636 |
val _ = |
48642 | 637 |
Outer_Syntax.command @{command_spec "{"} "begin explicit proof block" |
17900 | 638 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 639 |
|
24868 | 640 |
val _ = |
48642 | 641 |
Outer_Syntax.command @{command_spec "}"} "end explicit proof block" |
20305 | 642 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 643 |
|
24868 | 644 |
val _ = |
48642 | 645 |
Outer_Syntax.command @{command_spec "next"} "enter next proof block" |
17900 | 646 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 647 |
|
648 |
||
649 |
(* end proof *) |
|
650 |
||
24868 | 651 |
val _ = |
48642 | 652 |
Outer_Syntax.command @{command_spec "qed"} "conclude (sub-)proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
653 |
(Scan.option Method.parse >> Isar_Cmd.qed); |
5832 | 654 |
|
24868 | 655 |
val _ = |
48642 | 656 |
Outer_Syntax.command @{command_spec "by"} "terminal backward proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
657 |
(Method.parse -- Scan.option Method.parse >> Isar_Cmd.terminal_proof); |
6404 | 658 |
|
24868 | 659 |
val _ = |
48642 | 660 |
Outer_Syntax.command @{command_spec ".."} "default proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
661 |
(Scan.succeed Isar_Cmd.default_proof); |
8966 | 662 |
|
24868 | 663 |
val _ = |
48642 | 664 |
Outer_Syntax.command @{command_spec "."} "immediate proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
665 |
(Scan.succeed Isar_Cmd.immediate_proof); |
6404 | 666 |
|
24868 | 667 |
val _ = |
48642 | 668 |
Outer_Syntax.command @{command_spec "done"} "done proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
669 |
(Scan.succeed Isar_Cmd.done_proof); |
5832 | 670 |
|
24868 | 671 |
val _ = |
48642 | 672 |
Outer_Syntax.command @{command_spec "sorry"} "skip proof (quick-and-dirty mode only!)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
673 |
(Scan.succeed Isar_Cmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
674 |
|
24868 | 675 |
val _ = |
48642 | 676 |
Outer_Syntax.command @{command_spec "oops"} "forget proof" |
18561 | 677 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 678 |
|
5832 | 679 |
|
680 |
(* proof steps *) |
|
681 |
||
24868 | 682 |
val _ = |
48642 | 683 |
Outer_Syntax.command @{command_spec "defer"} "shuffle internal proof state" |
36950 | 684 |
(Scan.option Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
8165 | 685 |
|
24868 | 686 |
val _ = |
48642 | 687 |
Outer_Syntax.command @{command_spec "prefer"} "shuffle internal proof state" |
36950 | 688 |
(Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
8165 | 689 |
|
24868 | 690 |
val _ = |
48642 | 691 |
Outer_Syntax.command @{command_spec "apply"} "initial refinement step (unstructured)" |
22117 | 692 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 693 |
|
24868 | 694 |
val _ = |
48642 | 695 |
Outer_Syntax.command @{command_spec "apply_end"} "terminal refinement (unstructured)" |
22117 | 696 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 697 |
|
24868 | 698 |
val _ = |
48642 | 699 |
Outer_Syntax.command @{command_spec "proof"} "backward proof" |
22117 | 700 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
33390 | 701 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof m)) o |
27563 | 702 |
Toplevel.skip_proof (fn i => i + 1))); |
5832 | 703 |
|
704 |
||
6773 | 705 |
(* calculational proof commands *) |
706 |
||
6878 | 707 |
val calc_args = |
48643 | 708 |
Scan.option (@{keyword "("} |-- Parse.!!! ((Parse_Spec.xthms1 --| @{keyword ")"}))); |
6878 | 709 |
|
24868 | 710 |
val _ = |
48642 | 711 |
Outer_Syntax.command @{command_spec "also"} "combine calculation and current facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
712 |
(calc_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
6773 | 713 |
|
24868 | 714 |
val _ = |
48642 | 715 |
Outer_Syntax.command @{command_spec "finally"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
716 |
"combine calculation and current facts, exhibit result" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
717 |
(calc_args >> (Toplevel.proofs' o Calculation.finally_cmd)); |
6773 | 718 |
|
24868 | 719 |
val _ = |
48642 | 720 |
Outer_Syntax.command @{command_spec "moreover"} "augment calculation by current facts" |
17900 | 721 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 722 |
|
24868 | 723 |
val _ = |
48642 | 724 |
Outer_Syntax.command @{command_spec "ultimately"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
725 |
"augment calculation by current facts, exhibit result" |
17900 | 726 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 727 |
|
6773 | 728 |
|
6742 | 729 |
(* proof navigation *) |
5944 | 730 |
|
24868 | 731 |
val _ = |
48642 | 732 |
Outer_Syntax.command @{command_spec "back"} "backtracking of proof command" |
33390 | 733 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I)); |
6742 | 734 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
735 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
736 |
(* nested commands *) |
25578 | 737 |
|
29309 | 738 |
val props_text = |
43775
b361c7d184e7
added Parse.properties (again) -- allow empty list like Parse_Value.properties but unlike Parse.properties of ef86de9c98aa;
wenzelm
parents:
43227
diff
changeset
|
739 |
Scan.optional Parse.properties [] -- Parse.position Parse.string |
36950 | 740 |
>> (fn (props, (str, pos)) => |
741 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
29309 | 742 |
|
25578 | 743 |
val _ = |
48642 | 744 |
Outer_Syntax.improper_command @{command_spec "Isabelle.command"} "nested Isabelle command" |
29309 | 745 |
(props_text :|-- (fn (pos, str) => |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
746 |
(case Outer_Syntax.parse pos str of |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
747 |
[tr] => Scan.succeed (K tr) |
43947
9b00f09f7721
defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents:
43775
diff
changeset
|
748 |
| _ => Scan.fail_with (K (fn () => "exactly one command expected"))) |
9b00f09f7721
defer evaluation of Scan.message, for improved performance in the frequent situation where failure is handled later (e.g. via ||);
wenzelm
parents:
43775
diff
changeset
|
749 |
handle ERROR msg => Scan.fail_with (K (fn () => msg)))); |
25578 | 750 |
|
751 |
||
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
752 |
|
5832 | 753 |
(** diagnostic commands (for interactive mode only) **) |
754 |
||
36950 | 755 |
val opt_modes = |
48643 | 756 |
Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
36950 | 757 |
|
48643 | 758 |
val opt_bang = Scan.optional (@{keyword "!"} >> K true) false; |
8464 | 759 |
|
24868 | 760 |
val _ = |
48642 | 761 |
Outer_Syntax.improper_command @{command_spec "pretty_setmargin"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
762 |
"change default margin for pretty printing" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
763 |
(Parse.nat >> |
38870 | 764 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Pretty.margin_default := n))); |
7124 | 765 |
|
24868 | 766 |
val _ = |
48642 | 767 |
Outer_Syntax.improper_command @{command_spec "help"} "print outer syntax commands" |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
768 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
21714 | 769 |
|
24868 | 770 |
val _ = |
48642 | 771 |
Outer_Syntax.improper_command @{command_spec "print_commands"} "print outer syntax commands" |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
772 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
5832 | 773 |
|
24868 | 774 |
val _ = |
48642 | 775 |
Outer_Syntax.improper_command @{command_spec "print_configs"} "print configuration options" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
776 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_configs)); |
23989 | 777 |
|
24868 | 778 |
val _ = |
48642 | 779 |
Outer_Syntax.improper_command @{command_spec "print_context"} "print theory context name" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
780 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_context)); |
7308 | 781 |
|
24868 | 782 |
val _ = |
48642 | 783 |
Outer_Syntax.improper_command @{command_spec "print_theory"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
784 |
"print logical theory contents (verbose!)" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
785 |
(opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theory)); |
5832 | 786 |
|
24868 | 787 |
val _ = |
48642 | 788 |
Outer_Syntax.improper_command @{command_spec "print_syntax"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
789 |
"print inner syntax of context (verbose!)" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
790 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_syntax)); |
5832 | 791 |
|
24868 | 792 |
val _ = |
48642 | 793 |
Outer_Syntax.improper_command @{command_spec "print_abbrevs"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
794 |
"print constant abbreviation of context" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
795 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_abbrevs)); |
21726 | 796 |
|
24868 | 797 |
val _ = |
48642 | 798 |
Outer_Syntax.improper_command @{command_spec "print_theorems"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
799 |
"print theorems of local theory or proof context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
800 |
(opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theorems)); |
5881 | 801 |
|
24868 | 802 |
val _ = |
48642 | 803 |
Outer_Syntax.improper_command @{command_spec "print_locales"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
804 |
"print locales of this theory" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
805 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_locales)); |
12061 | 806 |
|
24868 | 807 |
val _ = |
48642 | 808 |
Outer_Syntax.improper_command @{command_spec "print_classes"} |
809 |
"print classes of this theory" |
|
42359 | 810 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
811 |
Toplevel.keep (Class.print_classes o Toplevel.context_of))); |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
812 |
|
24868 | 813 |
val _ = |
48642 | 814 |
Outer_Syntax.improper_command @{command_spec "print_locale"} |
815 |
"print locale of this theory" |
|
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
816 |
(opt_bang -- Parse.position Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_locale)); |
12061 | 817 |
|
24868 | 818 |
val _ = |
48642 | 819 |
Outer_Syntax.improper_command @{command_spec "print_interps"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
820 |
"print interpretations of locale for this theory or proof context" |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
821 |
(Parse.position Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_registrations)); |
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
822 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
823 |
val _ = |
48642 | 824 |
Outer_Syntax.improper_command @{command_spec "print_dependencies"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
825 |
"print dependencies of locale expression" |
41435 | 826 |
(opt_bang -- Parse_Spec.locale_expression true >> |
827 |
(Toplevel.no_timing oo Isar_Cmd.print_dependencies)); |
|
828 |
||
829 |
val _ = |
|
48642 | 830 |
Outer_Syntax.improper_command @{command_spec "print_attributes"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
831 |
"print attributes of this theory" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
832 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_attributes)); |
5832 | 833 |
|
24868 | 834 |
val _ = |
48642 | 835 |
Outer_Syntax.improper_command @{command_spec "print_simpset"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
836 |
"print context of Simplifier" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
837 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_simpset)); |
16027 | 838 |
|
24868 | 839 |
val _ = |
48642 | 840 |
Outer_Syntax.improper_command @{command_spec "print_rules"} "print intro/elim rules" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
841 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_rules)); |
12383 | 842 |
|
24868 | 843 |
val _ = |
48642 | 844 |
Outer_Syntax.improper_command @{command_spec "print_trans_rules"} "print transitivity rules" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
845 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_trans_rules)); |
9221 | 846 |
|
24868 | 847 |
val _ = |
48642 | 848 |
Outer_Syntax.improper_command @{command_spec "print_methods"} "print methods of this theory" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
849 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_methods)); |
5832 | 850 |
|
24868 | 851 |
val _ = |
48642 | 852 |
Outer_Syntax.improper_command @{command_spec "print_antiquotations"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
853 |
"print antiquotations (global)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
854 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_antiquotations)); |
9221 | 855 |
|
24868 | 856 |
val _ = |
48642 | 857 |
Outer_Syntax.improper_command @{command_spec "thy_deps"} "visualize theory dependencies" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
858 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.thy_deps)); |
22485 | 859 |
|
24868 | 860 |
val _ = |
49569
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
861 |
Outer_Syntax.improper_command @{command_spec "locale_deps"} "visualize locale dependencies" |
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
862 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.locale_deps)); |
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
863 |
|
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
864 |
val _ = |
48642 | 865 |
Outer_Syntax.improper_command @{command_spec "class_deps"} "visualize class dependencies" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
866 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.class_deps)); |
20574 | 867 |
|
24868 | 868 |
val _ = |
48642 | 869 |
Outer_Syntax.improper_command @{command_spec "thm_deps"} "visualize theorem dependencies" |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
870 |
(Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.thm_deps)); |
9454 | 871 |
|
24868 | 872 |
val _ = |
48642 | 873 |
Outer_Syntax.improper_command @{command_spec "print_binds"} "print term bindings of proof context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
874 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_binds)); |
5832 | 875 |
|
24868 | 876 |
val _ = |
48642 | 877 |
Outer_Syntax.improper_command @{command_spec "print_facts"} "print facts of proof context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
878 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_facts)); |
5832 | 879 |
|
24868 | 880 |
val _ = |
48642 | 881 |
Outer_Syntax.improper_command @{command_spec "print_cases"} "print cases of proof context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
882 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_cases)); |
8370 | 883 |
|
24868 | 884 |
val _ = |
48642 | 885 |
Outer_Syntax.improper_command @{command_spec "print_statement"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
886 |
"print theorems as long statements" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
887 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_stmts)); |
19269 | 888 |
|
24868 | 889 |
val _ = |
48642 | 890 |
Outer_Syntax.improper_command @{command_spec "thm"} "print theorems" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
891 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_thms)); |
5832 | 892 |
|
24868 | 893 |
val _ = |
48642 | 894 |
Outer_Syntax.improper_command @{command_spec "prf"} "print proof terms of theorems" |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
895 |
(opt_modes -- Scan.option Parse_Spec.xthms1 |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
896 |
>> (Toplevel.no_timing oo Isar_Cmd.print_prfs false)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
897 |
|
24868 | 898 |
val _ = |
48642 | 899 |
Outer_Syntax.improper_command @{command_spec "full_prf"} "print full proof terms of theorems" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
900 |
(opt_modes -- Scan.option Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_prfs true)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
901 |
|
24868 | 902 |
val _ = |
48642 | 903 |
Outer_Syntax.improper_command @{command_spec "prop"} "read and print proposition" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
904 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_prop)); |
5832 | 905 |
|
24868 | 906 |
val _ = |
48642 | 907 |
Outer_Syntax.improper_command @{command_spec "term"} "read and print term" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
908 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_term)); |
5832 | 909 |
|
24868 | 910 |
val _ = |
48642 | 911 |
Outer_Syntax.improper_command @{command_spec "typ"} "read and print type" |
48792 | 912 |
(opt_modes -- (Parse.typ -- Scan.option (@{keyword "::"} |-- Parse.!!! Parse.sort)) |
913 |
>> (Toplevel.no_timing oo Isar_Cmd.print_type)); |
|
5832 | 914 |
|
24868 | 915 |
val _ = |
48642 | 916 |
Outer_Syntax.improper_command @{command_spec "print_codesetup"} "print code generator setup" |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
917 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
918 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 919 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 920 |
|
26184 | 921 |
val _ = |
48642 | 922 |
Outer_Syntax.improper_command @{command_spec "unused_thms"} "find unused theorems" |
36950 | 923 |
(Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) -- |
924 |
Scan.option (Scan.repeat1 (Scan.unless Parse.minus Parse.name))) >> |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
925 |
(Toplevel.no_timing oo Isar_Cmd.unused_thms)); |
26184 | 926 |
|
5832 | 927 |
|
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
|
928 |
|
5832 | 929 |
(** system commands (for interactive mode only) **) |
930 |
||
24868 | 931 |
val _ = |
48642 | 932 |
Outer_Syntax.improper_command @{command_spec "cd"} "change current working directory" |
48881
46e053eda5dd
clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents:
48792
diff
changeset
|
933 |
(Parse.path >> (fn name => |
46e053eda5dd
clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents:
48792
diff
changeset
|
934 |
Toplevel.no_timing o Toplevel.imperative (fn () => File.cd (Path.explode name)))); |
5832 | 935 |
|
24868 | 936 |
val _ = |
48642 | 937 |
Outer_Syntax.improper_command @{command_spec "pwd"} "print current working directory" |
40395
4985aaade799
mark 'cd' and 'commit' as control command -- not usable in asynchronous document model, likely to cause confusion in Proof General;
wenzelm
parents:
39214
diff
changeset
|
938 |
(Scan.succeed (Toplevel.no_timing o |
41944
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
wenzelm
parents:
41585
diff
changeset
|
939 |
Toplevel.imperative (fn () => writeln (Path.print (File.pwd ()))))); |
5832 | 940 |
|
24868 | 941 |
val _ = |
48642 | 942 |
Outer_Syntax.improper_command @{command_spec "use_thy"} "use theory file" |
48927
ef462b5558eb
theory def/ref position reports, which enable hyperlinks etc.;
wenzelm
parents:
48881
diff
changeset
|
943 |
(Parse.position Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
944 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.use_thy name))); |
5832 | 945 |
|
24868 | 946 |
val _ = |
48642 | 947 |
Outer_Syntax.improper_command @{command_spec "remove_thy"} "remove theory from loader database" |
36950 | 948 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
949 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.remove_thy name))); |
7102 | 950 |
|
24868 | 951 |
val _ = |
48642 | 952 |
Outer_Syntax.improper_command @{command_spec "kill_thy"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
953 |
"kill theory -- try to remove from loader database" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
954 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
955 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
7931 | 956 |
|
24868 | 957 |
val _ = |
48642 | 958 |
Outer_Syntax.improper_command @{command_spec "display_drafts"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
959 |
"display raw source files with symbols" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
960 |
(Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.display_drafts)); |
14934 | 961 |
|
24868 | 962 |
val _ = |
48642 | 963 |
Outer_Syntax.improper_command @{command_spec "print_drafts"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
964 |
"print raw source files with symbols" |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
965 |
(Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.print_drafts)); |
14934 | 966 |
|
39165 | 967 |
val _ = (* FIXME tty only *) |
48642 | 968 |
Outer_Syntax.improper_command @{command_spec "pr"} "print current proof state (if present)" |
39165 | 969 |
(opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) => |
970 |
Toplevel.no_timing o Toplevel.keep (fn state => |
|
971 |
(case limit of NONE => () | SOME n => Goal_Display.goals_limit_default := n; |
|
972 |
Toplevel.quiet := false; |
|
973 |
Print_Mode.with_modes modes (Toplevel.print_state true) state)))); |
|
7199 | 974 |
|
24868 | 975 |
val _ = |
48642 | 976 |
Outer_Syntax.improper_command @{command_spec "disable_pr"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
977 |
"disable printing of toplevel state" |
39165 | 978 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := true))); |
5832 | 979 |
|
24868 | 980 |
val _ = |
48642 | 981 |
Outer_Syntax.improper_command @{command_spec "enable_pr"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
982 |
"enable printing of toplevel state" |
39165 | 983 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := false))); |
7222 | 984 |
|
24868 | 985 |
val _ = |
48642 | 986 |
Outer_Syntax.improper_command @{command_spec "commit"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
987 |
"commit current session to ML database" |
36950 | 988 |
(Parse.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 989 |
|
24868 | 990 |
val _ = |
48642 | 991 |
Outer_Syntax.improper_command @{command_spec "quit"} "quit Isabelle" |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
992 |
(Parse.opt_unit >> (Toplevel.no_timing oo K (Toplevel.imperative quit))); |
5832 | 993 |
|
24868 | 994 |
val _ = |
48642 | 995 |
Outer_Syntax.improper_command @{command_spec "exit"} "exit Isar loop" |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
996 |
(Scan.succeed |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
997 |
(Toplevel.no_timing o Toplevel.keep (fn state => |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37949
diff
changeset
|
998 |
(Context.set_thread_data (try Toplevel.generic_theory_of state); |
38888
8248cda328de
moved Toplevel.run_command to Pure/PIDE/document.ML;
wenzelm
parents:
38870
diff
changeset
|
999 |
raise Runtime.TERMINATE)))); |
5832 | 1000 |
|
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1001 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1002 |
Outer_Syntax.improper_command @{command_spec "welcome"} "print welcome message" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1003 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (writeln o Session.welcome))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1004 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1005 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1006 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1007 |
(** raw Isar read-eval-print loop **) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1008 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1009 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1010 |
Outer_Syntax.improper_command @{command_spec "init_toplevel"} "init toplevel point-of-interest" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1011 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.init)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1012 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1013 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1014 |
Outer_Syntax.improper_command @{command_spec "linear_undo"} "undo commands" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1015 |
(Scan.optional Parse.nat 1 >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1016 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.linear_undo n))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1017 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1018 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1019 |
Outer_Syntax.improper_command @{command_spec "undo"} "undo commands (skipping closed proofs)" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1020 |
(Scan.optional Parse.nat 1 >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1021 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo n))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1022 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1023 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1024 |
Outer_Syntax.improper_command @{command_spec "undos_proof"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1025 |
"undo commands (skipping closed proofs)" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1026 |
(Scan.optional Parse.nat 1 >> (fn n => Toplevel.no_timing o |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1027 |
Toplevel.keep (fn state => |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1028 |
if Toplevel.is_proof state then (Isar.undo n; Isar.print ()) else raise Toplevel.UNDEF))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1029 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1030 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1031 |
Outer_Syntax.improper_command @{command_spec "cannot_undo"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1032 |
"partial undo -- Proof General legacy" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1033 |
(Parse.name >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1034 |
(fn "end" => Toplevel.no_timing o Toplevel.imperative (fn () => Isar.undo 1) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1035 |
| txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt)))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1036 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1037 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1038 |
Outer_Syntax.improper_command @{command_spec "kill"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1039 |
"kill partial proof or theory development" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1040 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.kill)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1041 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1042 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1043 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1044 |
(** extraction of programs from proofs **) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1045 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1046 |
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1047 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1048 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1049 |
Outer_Syntax.command @{command_spec "realizers"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1050 |
"specify realizers for primitive axioms / theorems, together with correctness proof" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1051 |
(Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1052 |
(fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1053 |
(map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1054 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1055 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1056 |
Outer_Syntax.command @{command_spec "realizability"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1057 |
"add equations characterizing realizability" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1058 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1059 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1060 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1061 |
Outer_Syntax.command @{command_spec "extract_type"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1062 |
"add equations characterizing type of extracted program" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1063 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1064 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1065 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1066 |
Outer_Syntax.command @{command_spec "extract"} "extract terms from proofs" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1067 |
(Scan.repeat1 (Parse.xname -- parse_vars) >> (fn xs => Toplevel.theory (fn thy => |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1068 |
Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1069 |
|
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1070 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1071 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1072 |
(** end **) |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1073 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1074 |
val _ = |
48642 | 1075 |
Outer_Syntax.command @{command_spec "end"} "end context" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1076 |
(Scan.succeed |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1077 |
(Toplevel.exit o Toplevel.end_local_theory o Toplevel.close_target o |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1078 |
Toplevel.end_proof (K Proof.end_notepad))); |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1079 |
|
5832 | 1080 |
end; |
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
1081 |