author | wenzelm |
Thu, 28 Feb 2013 16:38:17 +0100 | |
changeset 51313 | 102a0a0718c5 |
parent 51295 | 71fc3776c453 |
child 51585 | fcd5af4aac2b |
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 _ = |
50214 | 137 |
Outer_Syntax.command @{command_spec "syntax"} "add raw syntax clauses" |
42299 | 138 |
(opt_mode -- Scan.repeat1 Parse.const_decl >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 139 |
|
24868 | 140 |
val _ = |
50214 | 141 |
Outer_Syntax.command @{command_spec "no_syntax"} "delete raw syntax clauses" |
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 _ = |
50214 | 162 |
Outer_Syntax.command @{command_spec "translations"} "add syntax translation rules" |
42204 | 163 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations)); |
5832 | 164 |
|
24868 | 165 |
val _ = |
50214 | 166 |
Outer_Syntax.command @{command_spec "no_translations"} "delete 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 |
||
19631 | 172 |
val opt_unchecked_overloaded = |
48643 | 173 |
Scan.optional (@{keyword "("} |-- Parse.!!! |
174 |
(((@{keyword "unchecked"} >> K true) -- |
|
175 |
Scan.optional (@{keyword "overloaded"} >> K true) false || |
|
176 |
@{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false); |
|
19631 | 177 |
|
24868 | 178 |
val _ = |
48642 | 179 |
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
|
180 |
(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
|
181 |
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
|
182 |
>> (Toplevel.theory o Isar_Cmd.add_defs)); |
6370 | 183 |
|
14642 | 184 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
185 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
186 |
|
24868 | 187 |
val _ = |
48642 | 188 |
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
|
189 |
(Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args)); |
18780 | 190 |
|
24868 | 191 |
val _ = |
48642 | 192 |
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
|
193 |
(opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop) |
36950 | 194 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 195 |
|
24868 | 196 |
val _ = |
48642 | 197 |
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
|
198 |
"add concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
199 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 200 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
35413 | 201 |
|
202 |
val _ = |
|
48642 | 203 |
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
|
204 |
"delete concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
205 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 206 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
35413 | 207 |
|
208 |
val _ = |
|
48642 | 209 |
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
|
210 |
"add concrete syntax for constants / fixed variables" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
211 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 212 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 213 |
|
214 |
val _ = |
|
48642 | 215 |
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
|
216 |
"delete concrete syntax for constants / fixed variables" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
217 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse_Spec.locale_mixfix) |
36950 | 218 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 219 |
|
5832 | 220 |
|
18616 | 221 |
(* constant specifications *) |
222 |
||
24868 | 223 |
val _ = |
48642 | 224 |
Outer_Syntax.command @{command_spec "axiomatization"} "axiomatic constant specification" |
36950 | 225 |
(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
|
226 |
Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) [] |
36950 | 227 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 228 |
|
229 |
||
5914 | 230 |
(* theorems *) |
231 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
232 |
fun theorems kind = |
45600
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
233 |
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
|
234 |
>> (fn (facts, fixes) => #2 oo Specification.theorems_cmd kind facts fixes); |
12712 | 235 |
|
24868 | 236 |
val _ = |
48642 | 237 |
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
|
238 |
(theorems Thm.theoremK); |
5914 | 239 |
|
24868 | 240 |
val _ = |
48642 | 241 |
Outer_Syntax.local_theory' @{command_spec "lemmas"} "define lemmas" (theorems Thm.lemmaK); |
5914 | 242 |
|
24868 | 243 |
val _ = |
48642 | 244 |
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
|
245 |
(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
|
246 |
>> (fn (facts, fixes) => |
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
247 |
#2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes)); |
9589 | 248 |
|
5914 | 249 |
|
5832 | 250 |
(* name space entry path *) |
251 |
||
48645 | 252 |
fun hide_names spec hide what = |
253 |
Outer_Syntax.command spec ("hide " ^ what ^ " from name space") |
|
36950 | 254 |
((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
|
255 |
(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
|
256 |
|
48645 | 257 |
val _ = hide_names @{command_spec "hide_class"} Isar_Cmd.hide_class "classes"; |
258 |
val _ = hide_names @{command_spec "hide_type"} Isar_Cmd.hide_type "types"; |
|
259 |
val _ = hide_names @{command_spec "hide_const"} Isar_Cmd.hide_const "constants"; |
|
260 |
val _ = hide_names @{command_spec "hide_fact"} Isar_Cmd.hide_fact "facts"; |
|
5832 | 261 |
|
262 |
||
263 |
(* use ML text *) |
|
264 |
||
24868 | 265 |
val _ = |
48642 | 266 |
Outer_Syntax.command @{command_spec "ML"} "ML text within theory or local theory" |
36950 | 267 |
(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
|
268 |
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
|
269 |
(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
|
270 |
Local_Theory.propagate_ml_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
271 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
272 |
val _ = |
48642 | 273 |
Outer_Syntax.command @{command_spec "ML_prf"} "ML text within proof" |
36950 | 274 |
(Parse.ML_source >> (fn (txt, pos) => |
28269 | 275 |
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
|
276 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt))) #> Proof.propagate_ml_env))); |
28269 | 277 |
|
278 |
val _ = |
|
48642 | 279 |
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
|
280 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
26396 | 281 |
|
282 |
val _ = |
|
48642 | 283 |
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
|
284 |
(Parse.ML_source >> (Toplevel.no_timing oo Isar_Cmd.ml_diag false)); |
5832 | 285 |
|
24868 | 286 |
val _ = |
48642 | 287 |
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
|
288 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup)); |
30461 | 289 |
|
290 |
val _ = |
|
48642 | 291 |
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
|
292 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
5832 | 293 |
|
24868 | 294 |
val _ = |
48642 | 295 |
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
|
296 |
(Parse.position Parse.name -- |
48643 | 297 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 298 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt))); |
30526 | 299 |
|
300 |
val _ = |
|
48642 | 301 |
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
|
302 |
(Parse.position Parse.name -- |
48643 | 303 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
36950 | 304 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
9197 | 305 |
|
24868 | 306 |
val _ = |
48642 | 307 |
Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration" |
40784 | 308 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
309 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt)); |
|
310 |
||
311 |
val _ = |
|
48642 | 312 |
Outer_Syntax.local_theory @{command_spec "syntax_declaration"} "generic ML syntax declaration" |
40784 | 313 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
314 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt)); |
|
22088 | 315 |
|
24868 | 316 |
val _ = |
48642 | 317 |
Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML" |
42464 | 318 |
(Parse.position Parse.name -- |
48643 | 319 |
(@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) -- |
320 |
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
|
321 |
>> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d)); |
22202 | 322 |
|
5832 | 323 |
|
324 |
(* translation functions *) |
|
325 |
||
36950 | 326 |
val trfun = Parse.opt_keyword "advanced" -- Parse.ML_source; |
14642 | 327 |
|
24868 | 328 |
val _ = |
48642 | 329 |
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
|
330 |
"install parse ast translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
331 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 332 |
|
24868 | 333 |
val _ = |
48642 | 334 |
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
|
335 |
"install parse translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
336 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 337 |
|
24868 | 338 |
val _ = |
48642 | 339 |
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
|
340 |
"install print translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
341 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 342 |
|
24868 | 343 |
val _ = |
48642 | 344 |
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
|
345 |
"install typed print translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
346 |
(trfun >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 347 |
|
24868 | 348 |
val _ = |
48642 | 349 |
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
|
350 |
"install print ast translation functions" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
351 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 352 |
|
353 |
||
354 |
(* oracles *) |
|
355 |
||
24868 | 356 |
val _ = |
48642 | 357 |
Outer_Syntax.command @{command_spec "oracle"} "declare oracle" |
48643 | 358 |
(Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
359 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 360 |
|
361 |
||
47057 | 362 |
(* bundled declarations *) |
363 |
||
364 |
val _ = |
|
48642 | 365 |
Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations" |
48643 | 366 |
((Parse.binding --| @{keyword "="}) -- Parse_Spec.xthms1 -- Parse.for_fixes |
47057 | 367 |
>> (uncurry Bundle.bundle_cmd)); |
368 |
||
369 |
val _ = |
|
48642 | 370 |
Outer_Syntax.command @{command_spec "include"} |
47057 | 371 |
"include declarations from bundle in proof body" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
372 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
373 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.include_cmd))); |
47057 | 374 |
|
375 |
val _ = |
|
48642 | 376 |
Outer_Syntax.command @{command_spec "including"} |
47057 | 377 |
"include declarations from bundle in goal refinement" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
378 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
379 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.including_cmd))); |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
380 |
|
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
381 |
val _ = |
48642 | 382 |
Outer_Syntax.improper_command @{command_spec "print_bundles"} |
383 |
"print bundles of declarations" |
|
47057 | 384 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
385 |
Toplevel.keep (Bundle.print_bundles o Toplevel.context_of))); |
|
386 |
||
387 |
||
47069 | 388 |
(* local theories *) |
389 |
||
390 |
val _ = |
|
48642 | 391 |
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
|
392 |
((Parse.position Parse.xname >> (fn name => |
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
393 |
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
|
394 |
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
|
395 |
>> (fn (incls, elems) => Toplevel.open_target (Bundle.context_cmd incls elems))) |
47069 | 396 |
--| Parse.begin); |
397 |
||
398 |
||
12061 | 399 |
(* locales *) |
400 |
||
12758 | 401 |
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
|
402 |
Parse_Spec.locale_expression false -- |
48643 | 403 |
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
|
404 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 405 |
|
24868 | 406 |
val _ = |
48642 | 407 |
Outer_Syntax.command @{command_spec "locale"} "define named proof context" |
36950 | 408 |
(Parse.binding -- |
48643 | 409 |
Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
27681 | 410 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 411 |
(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
|
412 |
(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
|
413 |
|
41270 | 414 |
fun parse_interpretation_arguments mandatory = |
415 |
Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
|
416 |
Scan.optional |
|
417 |
(Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
418 |
||
24868 | 419 |
val _ = |
48642 | 420 |
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
|
421 |
"prove sublocale relation between a locale and a locale expression" |
48643 | 422 |
(Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
41270 | 423 |
parse_interpretation_arguments false |
424 |
>> (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
|
425 |
Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd I loc expr equations))); |
28895 | 426 |
|
427 |
val _ = |
|
48642 | 428 |
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
|
429 |
"prove interpretation of locale expression in theory" |
41270 | 430 |
(parse_interpretation_arguments true |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
431 |
>> (fn (expr, equations) => Toplevel.print o |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
432 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 433 |
|
434 |
val _ = |
|
48642 | 435 |
Outer_Syntax.command @{command_spec "interpret"} |
29223 | 436 |
"prove interpretation of locale expression in proof context" |
41270 | 437 |
(parse_interpretation_arguments true |
38108 | 438 |
>> (fn (expr, equations) => Toplevel.print o |
439 |
Toplevel.proof' (Expression.interpret_cmd expr equations))); |
|
29223 | 440 |
|
15703 | 441 |
|
22299 | 442 |
(* classes *) |
443 |
||
24868 | 444 |
val class_val = |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
445 |
Parse_Spec.class_expression -- |
48643 | 446 |
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
|
447 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 448 |
|
24868 | 449 |
val _ = |
48642 | 450 |
Outer_Syntax.command @{command_spec "class"} "define type class" |
48643 | 451 |
(Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 452 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 453 |
(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
|
454 |
(Class_Declaration.class_cmd I name supclasses elems #> snd))); |
22299 | 455 |
|
24868 | 456 |
val _ = |
48642 | 457 |
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
|
458 |
(Parse.class >> Class_Declaration.subclass_cmd I); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
459 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
460 |
val _ = |
48642 | 461 |
Outer_Syntax.command @{command_spec "instantiation"} "instantiate and prove type arity" |
36950 | 462 |
(Parse.multi_arity --| Parse.begin |
25462 | 463 |
>> (fn arities => Toplevel.print o |
38348
cf7b2121ad9d
moved instantiation target formally to class_target.ML
haftmann
parents:
38342
diff
changeset
|
464 |
Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
24589 | 465 |
|
25485 | 466 |
val _ = |
48642 | 467 |
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
|
468 |
((Parse.class -- |
48643 | 469 |
((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd || |
36950 | 470 |
Parse.multi_arity >> Class.instance_arity_cmd) |
471 |
>> (Toplevel.print oo Toplevel.theory_to_proof) || |
|
472 |
Scan.succeed |
|
473 |
(Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 474 |
|
475 |
||
25519 | 476 |
(* arbitrary overloading *) |
477 |
||
478 |
val _ = |
|
48642 | 479 |
Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions" |
48643 | 480 |
(Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term -- |
481 |
Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true |
|
36950 | 482 |
>> Parse.triple1) --| Parse.begin |
25519 | 483 |
>> (fn operations => Toplevel.print o |
38342
09d4a04d5c2e
moved overloading target formally to overloading.ML
haftmann
parents:
38108
diff
changeset
|
484 |
Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
25519 | 485 |
|
486 |
||
22866 | 487 |
(* code generation *) |
488 |
||
24868 | 489 |
val _ = |
48642 | 490 |
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
|
491 |
"define set of code datatype constructors" |
36950 | 492 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 493 |
|
494 |
||
5832 | 495 |
|
496 |
(** proof commands **) |
|
497 |
||
498 |
(* statements *) |
|
499 |
||
48645 | 500 |
fun gen_theorem spec schematic kind = |
501 |
Outer_Syntax.local_theory_to_proof' spec |
|
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
502 |
("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
|
503 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
47067
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
504 |
Scan.ahead (Parse_Spec.includes >> K "" || |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
505 |
Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
506 |
Scan.optional Parse_Spec.includes [] -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
507 |
Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
508 |
((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
|
509 |
kind NONE (K I) a includes elems concl))); |
5832 | 510 |
|
48645 | 511 |
val _ = gen_theorem @{command_spec "theorem"} false Thm.theoremK; |
512 |
val _ = gen_theorem @{command_spec "lemma"} false Thm.lemmaK; |
|
513 |
val _ = gen_theorem @{command_spec "corollary"} false Thm.corollaryK; |
|
514 |
val _ = gen_theorem @{command_spec "schematic_theorem"} true Thm.theoremK; |
|
515 |
val _ = gen_theorem @{command_spec "schematic_lemma"} true Thm.lemmaK; |
|
516 |
val _ = gen_theorem @{command_spec "schematic_corollary"} true Thm.corollaryK; |
|
5832 | 517 |
|
24868 | 518 |
val _ = |
48642 | 519 |
Outer_Syntax.local_theory_to_proof @{command_spec "notepad"} "begin proof context" |
40960 | 520 |
(Parse.begin >> K Proof.begin_notepad); |
521 |
||
522 |
val _ = |
|
48642 | 523 |
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
|
524 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have)); |
17353 | 525 |
|
24868 | 526 |
val _ = |
50214 | 527 |
Outer_Syntax.command @{command_spec "hence"} "old-style alias of \"then have\"" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
528 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence)); |
17353 | 529 |
|
24868 | 530 |
val _ = |
48642 | 531 |
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
|
532 |
"state local goal, solving current obligation" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
533 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show)); |
5832 | 534 |
|
24868 | 535 |
val _ = |
50214 | 536 |
Outer_Syntax.command @{command_spec "thus"} "old-style alias of \"then show\"" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
537 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus)); |
6501 | 538 |
|
5832 | 539 |
|
5914 | 540 |
(* facts *) |
5832 | 541 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
542 |
val facts = Parse.and_list1 Parse_Spec.xthms1; |
9197 | 543 |
|
24868 | 544 |
val _ = |
48642 | 545 |
Outer_Syntax.command @{command_spec "then"} "forward chaining" |
17900 | 546 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 547 |
|
24868 | 548 |
val _ = |
48642 | 549 |
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
|
550 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd))); |
5914 | 551 |
|
24868 | 552 |
val _ = |
48642 | 553 |
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
|
554 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd))); |
6878 | 555 |
|
24868 | 556 |
val _ = |
48642 | 557 |
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
|
558 |
(Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd))); |
5832 | 559 |
|
24868 | 560 |
val _ = |
48642 | 561 |
Outer_Syntax.command @{command_spec "using"} "augment goal facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
562 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd))); |
18544 | 563 |
|
24868 | 564 |
val _ = |
48642 | 565 |
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
|
566 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd))); |
12926 | 567 |
|
5832 | 568 |
|
569 |
(* proof context *) |
|
570 |
||
24868 | 571 |
val _ = |
48642 | 572 |
Outer_Syntax.command @{command_spec "fix"} "fix local variables (Skolem constants)" |
36950 | 573 |
(Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd))); |
11890 | 574 |
|
24868 | 575 |
val _ = |
48642 | 576 |
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
|
577 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd))); |
5832 | 578 |
|
24868 | 579 |
val _ = |
48642 | 580 |
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
|
581 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd))); |
6850 | 582 |
|
24868 | 583 |
val _ = |
50214 | 584 |
Outer_Syntax.command @{command_spec "def"} "local definition (non-polymorphic)" |
36950 | 585 |
(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
|
586 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 587 |
((Parse.binding -- Parse.opt_mixfix) -- |
48643 | 588 |
((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp))) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
589 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd))); |
6953 | 590 |
|
24868 | 591 |
val _ = |
48642 | 592 |
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
|
593 |
(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
|
594 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 595 |
|
24868 | 596 |
val _ = |
48642 | 597 |
Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)" |
36950 | 598 |
(Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd))); |
17854 | 599 |
|
24868 | 600 |
val _ = |
48642 | 601 |
Outer_Syntax.command @{command_spec "let"} "bind text variables" |
48643 | 602 |
(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
|
603 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd))); |
5832 | 604 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
605 |
val _ = |
48642 | 606 |
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
|
607 |
(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
|
608 |
>> (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
|
609 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
610 |
val case_spec = |
48643 | 611 |
(@{keyword "("} |-- |
612 |
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
|
613 |
Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
614 |
|
24868 | 615 |
val _ = |
48642 | 616 |
Outer_Syntax.command @{command_spec "case"} "invoke local context" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
617 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd))); |
8370 | 618 |
|
5832 | 619 |
|
620 |
(* proof structure *) |
|
621 |
||
24868 | 622 |
val _ = |
48642 | 623 |
Outer_Syntax.command @{command_spec "{"} "begin explicit proof block" |
17900 | 624 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 625 |
|
24868 | 626 |
val _ = |
48642 | 627 |
Outer_Syntax.command @{command_spec "}"} "end explicit proof block" |
20305 | 628 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 629 |
|
24868 | 630 |
val _ = |
48642 | 631 |
Outer_Syntax.command @{command_spec "next"} "enter next proof block" |
17900 | 632 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 633 |
|
634 |
||
635 |
(* end proof *) |
|
636 |
||
24868 | 637 |
val _ = |
50214 | 638 |
Outer_Syntax.command @{command_spec "qed"} "conclude proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
639 |
(Scan.option Method.parse >> Isar_Cmd.qed); |
5832 | 640 |
|
24868 | 641 |
val _ = |
48642 | 642 |
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
|
643 |
(Method.parse -- Scan.option Method.parse >> Isar_Cmd.terminal_proof); |
6404 | 644 |
|
24868 | 645 |
val _ = |
48642 | 646 |
Outer_Syntax.command @{command_spec ".."} "default proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
647 |
(Scan.succeed Isar_Cmd.default_proof); |
8966 | 648 |
|
24868 | 649 |
val _ = |
48642 | 650 |
Outer_Syntax.command @{command_spec "."} "immediate proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
651 |
(Scan.succeed Isar_Cmd.immediate_proof); |
6404 | 652 |
|
24868 | 653 |
val _ = |
48642 | 654 |
Outer_Syntax.command @{command_spec "done"} "done proof" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
655 |
(Scan.succeed Isar_Cmd.done_proof); |
5832 | 656 |
|
24868 | 657 |
val _ = |
48642 | 658 |
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
|
659 |
(Scan.succeed Isar_Cmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
660 |
|
24868 | 661 |
val _ = |
48642 | 662 |
Outer_Syntax.command @{command_spec "oops"} "forget proof" |
18561 | 663 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 664 |
|
5832 | 665 |
|
666 |
(* proof steps *) |
|
667 |
||
24868 | 668 |
val _ = |
48642 | 669 |
Outer_Syntax.command @{command_spec "defer"} "shuffle internal proof state" |
49865 | 670 |
(Scan.optional Parse.nat 1 >> (fn n => Toplevel.print o Toplevel.proof (Proof.defer n))); |
8165 | 671 |
|
24868 | 672 |
val _ = |
48642 | 673 |
Outer_Syntax.command @{command_spec "prefer"} "shuffle internal proof state" |
49865 | 674 |
(Parse.nat >> (fn n => Toplevel.print o Toplevel.proof (Proof.prefer n))); |
8165 | 675 |
|
24868 | 676 |
val _ = |
48642 | 677 |
Outer_Syntax.command @{command_spec "apply"} "initial refinement step (unstructured)" |
49863
b5fb6e7f8d81
more informative errors for 'proof' and 'apply' steps;
wenzelm
parents:
49569
diff
changeset
|
678 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_results))); |
5832 | 679 |
|
24868 | 680 |
val _ = |
50214 | 681 |
Outer_Syntax.command @{command_spec "apply_end"} "terminal refinement step (unstructured)" |
49863
b5fb6e7f8d81
more informative errors for 'proof' and 'apply' steps;
wenzelm
parents:
49569
diff
changeset
|
682 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end_results))); |
5832 | 683 |
|
24868 | 684 |
val _ = |
50214 | 685 |
Outer_Syntax.command @{command_spec "proof"} "backward proof step" |
22117 | 686 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
49863
b5fb6e7f8d81
more informative errors for 'proof' and 'apply' steps;
wenzelm
parents:
49569
diff
changeset
|
687 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof_results m)) o |
27563 | 688 |
Toplevel.skip_proof (fn i => i + 1))); |
5832 | 689 |
|
690 |
||
6773 | 691 |
(* calculational proof commands *) |
692 |
||
6878 | 693 |
val calc_args = |
48643 | 694 |
Scan.option (@{keyword "("} |-- Parse.!!! ((Parse_Spec.xthms1 --| @{keyword ")"}))); |
6878 | 695 |
|
24868 | 696 |
val _ = |
48642 | 697 |
Outer_Syntax.command @{command_spec "also"} "combine calculation and current facts" |
49868
3039922ffd8d
more informative errors for 'also' and 'finally';
wenzelm
parents:
49865
diff
changeset
|
698 |
(calc_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
6773 | 699 |
|
24868 | 700 |
val _ = |
48642 | 701 |
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
|
702 |
"combine calculation and current facts, exhibit result" |
49868
3039922ffd8d
more informative errors for 'also' and 'finally';
wenzelm
parents:
49865
diff
changeset
|
703 |
(calc_args >> (Toplevel.proofs' o Calculation.finally_cmd)); |
6773 | 704 |
|
24868 | 705 |
val _ = |
48642 | 706 |
Outer_Syntax.command @{command_spec "moreover"} "augment calculation by current facts" |
17900 | 707 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 708 |
|
24868 | 709 |
val _ = |
48642 | 710 |
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
|
711 |
"augment calculation by current facts, exhibit result" |
17900 | 712 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 713 |
|
6773 | 714 |
|
6742 | 715 |
(* proof navigation *) |
5944 | 716 |
|
24868 | 717 |
val _ = |
48642 | 718 |
Outer_Syntax.command @{command_spec "back"} "backtracking of proof command" |
33390 | 719 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I)); |
6742 | 720 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
721 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
722 |
(* nested commands *) |
25578 | 723 |
|
29309 | 724 |
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
|
725 |
Scan.optional Parse.properties [] -- Parse.position Parse.string |
36950 | 726 |
>> (fn (props, (str, pos)) => |
727 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
29309 | 728 |
|
25578 | 729 |
val _ = |
50214 | 730 |
Outer_Syntax.improper_command @{command_spec "Isabelle.command"} "evaluate nested Isabelle command" |
29309 | 731 |
(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
|
732 |
(case Outer_Syntax.parse pos str of |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
733 |
[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
|
734 |
| _ => 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
|
735 |
handle ERROR msg => Scan.fail_with (K (fn () => msg)))); |
25578 | 736 |
|
737 |
||
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
738 |
|
5832 | 739 |
(** diagnostic commands (for interactive mode only) **) |
740 |
||
36950 | 741 |
val opt_modes = |
48643 | 742 |
Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
36950 | 743 |
|
48643 | 744 |
val opt_bang = Scan.optional (@{keyword "!"} >> K true) false; |
8464 | 745 |
|
24868 | 746 |
val _ = |
48642 | 747 |
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
|
748 |
"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
|
749 |
(Parse.nat >> |
38870 | 750 |
(fn n => Toplevel.no_timing o Toplevel.imperative (fn () => Pretty.margin_default := n))); |
7124 | 751 |
|
24868 | 752 |
val _ = |
50213 | 753 |
Outer_Syntax.improper_command @{command_spec "help"} |
754 |
"retrieve outer syntax commands according to name patterns" |
|
755 |
(Scan.repeat Parse.name >> (fn pats => |
|
756 |
Toplevel.no_timing o Toplevel.imperative (fn () => Outer_Syntax.help_outer_syntax pats))); |
|
21714 | 757 |
|
24868 | 758 |
val _ = |
48642 | 759 |
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
|
760 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
5832 | 761 |
|
24868 | 762 |
val _ = |
48642 | 763 |
Outer_Syntax.improper_command @{command_spec "print_configs"} "print configuration options" |
50737 | 764 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
765 |
Toplevel.keep (Attrib.print_configs o Toplevel.context_of))); |
|
23989 | 766 |
|
24868 | 767 |
val _ = |
50737 | 768 |
Outer_Syntax.improper_command @{command_spec "print_context"} "print main context" |
769 |
(Scan.succeed (Toplevel.no_timing o Toplevel.keep Toplevel.print_state_context)); |
|
7308 | 770 |
|
24868 | 771 |
val _ = |
48642 | 772 |
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
|
773 |
"print logical theory contents (verbose!)" |
50737 | 774 |
(opt_bang >> (fn b => Toplevel.no_timing o Toplevel.unknown_theory o |
775 |
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_full_theory b o Toplevel.theory_of))); |
|
5832 | 776 |
|
24868 | 777 |
val _ = |
48642 | 778 |
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
|
779 |
"print inner syntax of context (verbose!)" |
50737 | 780 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
781 |
Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of))); |
|
5832 | 782 |
|
24868 | 783 |
val _ = |
48642 | 784 |
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
|
785 |
"print constant abbreviation of context" |
50737 | 786 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
787 |
Toplevel.keep (Proof_Context.print_abbrevs o Toplevel.context_of))); |
|
21726 | 788 |
|
24868 | 789 |
val _ = |
48642 | 790 |
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
|
791 |
"print theorems of local theory or proof context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
792 |
(opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theorems)); |
5881 | 793 |
|
24868 | 794 |
val _ = |
48642 | 795 |
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
|
796 |
"print locales of this theory" |
50737 | 797 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
798 |
Toplevel.keep (Locale.print_locales o Toplevel.theory_of))); |
|
12061 | 799 |
|
24868 | 800 |
val _ = |
48642 | 801 |
Outer_Syntax.improper_command @{command_spec "print_classes"} |
802 |
"print classes of this theory" |
|
42359 | 803 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
804 |
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
|
805 |
|
24868 | 806 |
val _ = |
48642 | 807 |
Outer_Syntax.improper_command @{command_spec "print_locale"} |
808 |
"print locale of this theory" |
|
50737 | 809 |
(opt_bang -- Parse.position Parse.xname >> (fn (b, name) => |
810 |
Toplevel.no_timing o Toplevel.unknown_theory o |
|
811 |
Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name))); |
|
12061 | 812 |
|
24868 | 813 |
val _ = |
48642 | 814 |
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
|
815 |
"print interpretations of locale for this theory or proof context" |
50737 | 816 |
(Parse.position Parse.xname >> (fn name => Toplevel.no_timing o Toplevel.unknown_context o |
817 |
Toplevel.keep (fn state => Locale.print_registrations (Toplevel.context_of state) name))); |
|
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
818 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
819 |
val _ = |
48642 | 820 |
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
|
821 |
"print dependencies of locale expression" |
50737 | 822 |
(opt_bang -- Parse_Spec.locale_expression true >> (fn (clean, expr) => |
823 |
Toplevel.no_timing o Toplevel.unknown_context o |
|
824 |
Toplevel.keep (fn state => |
|
825 |
Expression.print_dependencies (Toplevel.context_of state) clean expr))); |
|
41435 | 826 |
|
827 |
val _ = |
|
48642 | 828 |
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
|
829 |
"print attributes of this theory" |
50737 | 830 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
831 |
Toplevel.keep (Attrib.print_attributes o Toplevel.theory_of))); |
|
5832 | 832 |
|
24868 | 833 |
val _ = |
48642 | 834 |
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
|
835 |
"print context of Simplifier" |
50737 | 836 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
837 |
Toplevel.keep (fn state => |
|
838 |
let val ctxt = Toplevel.context_of state |
|
839 |
in Pretty.writeln (Simplifier.pretty_ss ctxt (simpset_of ctxt)) end))); |
|
16027 | 840 |
|
24868 | 841 |
val _ = |
48642 | 842 |
Outer_Syntax.improper_command @{command_spec "print_rules"} "print intro/elim rules" |
50737 | 843 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
844 |
Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of))); |
|
12383 | 845 |
|
24868 | 846 |
val _ = |
48642 | 847 |
Outer_Syntax.improper_command @{command_spec "print_trans_rules"} "print transitivity rules" |
50737 | 848 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
849 |
Toplevel.keep (Calculation.print_rules o Toplevel.context_of))); |
|
9221 | 850 |
|
24868 | 851 |
val _ = |
48642 | 852 |
Outer_Syntax.improper_command @{command_spec "print_methods"} "print methods of this theory" |
50737 | 853 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o |
854 |
Toplevel.keep (Method.print_methods o Toplevel.theory_of))); |
|
5832 | 855 |
|
24868 | 856 |
val _ = |
50214 | 857 |
Outer_Syntax.improper_command @{command_spec "print_antiquotations"} "print antiquotations" |
50737 | 858 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
859 |
Toplevel.keep (Thy_Output.print_antiquotations o Toplevel.context_of))); |
|
9221 | 860 |
|
24868 | 861 |
val _ = |
48642 | 862 |
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
|
863 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.thy_deps)); |
22485 | 864 |
|
24868 | 865 |
val _ = |
49569
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
866 |
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
|
867 |
(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
|
868 |
|
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
869 |
val _ = |
48642 | 870 |
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
|
871 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.class_deps)); |
20574 | 872 |
|
24868 | 873 |
val _ = |
48642 | 874 |
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
|
875 |
(Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.thm_deps)); |
9454 | 876 |
|
24868 | 877 |
val _ = |
48642 | 878 |
Outer_Syntax.improper_command @{command_spec "print_binds"} "print term bindings of proof context" |
50737 | 879 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
880 |
Toplevel.keep (Proof_Context.print_binds o Toplevel.context_of))); |
|
5832 | 881 |
|
24868 | 882 |
val _ = |
48642 | 883 |
Outer_Syntax.improper_command @{command_spec "print_facts"} "print facts of proof context" |
50737 | 884 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
885 |
Toplevel.keep (Proof_Context.print_lthms o Toplevel.context_of))); |
|
5832 | 886 |
|
24868 | 887 |
val _ = |
48642 | 888 |
Outer_Syntax.improper_command @{command_spec "print_cases"} "print cases of proof context" |
50737 | 889 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o |
890 |
Toplevel.keep (Proof_Context.print_cases o Toplevel.context_of))); |
|
8370 | 891 |
|
24868 | 892 |
val _ = |
48642 | 893 |
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
|
894 |
"print theorems as long statements" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
895 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_stmts)); |
19269 | 896 |
|
24868 | 897 |
val _ = |
48642 | 898 |
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
|
899 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_thms)); |
5832 | 900 |
|
24868 | 901 |
val _ = |
48642 | 902 |
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
|
903 |
(opt_modes -- Scan.option Parse_Spec.xthms1 |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
904 |
>> (Toplevel.no_timing oo Isar_Cmd.print_prfs false)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
905 |
|
24868 | 906 |
val _ = |
48642 | 907 |
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
|
908 |
(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
|
909 |
|
24868 | 910 |
val _ = |
48642 | 911 |
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
|
912 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_prop)); |
5832 | 913 |
|
24868 | 914 |
val _ = |
48642 | 915 |
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
|
916 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_term)); |
5832 | 917 |
|
24868 | 918 |
val _ = |
48642 | 919 |
Outer_Syntax.improper_command @{command_spec "typ"} "read and print type" |
48792 | 920 |
(opt_modes -- (Parse.typ -- Scan.option (@{keyword "::"} |-- Parse.!!! Parse.sort)) |
921 |
>> (Toplevel.no_timing oo Isar_Cmd.print_type)); |
|
5832 | 922 |
|
24868 | 923 |
val _ = |
48642 | 924 |
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
|
925 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
926 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 927 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 928 |
|
26184 | 929 |
val _ = |
48642 | 930 |
Outer_Syntax.improper_command @{command_spec "unused_thms"} "find unused theorems" |
36950 | 931 |
(Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) -- |
932 |
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
|
933 |
(Toplevel.no_timing oo Isar_Cmd.unused_thms)); |
26184 | 934 |
|
5832 | 935 |
|
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
|
936 |
|
5832 | 937 |
(** system commands (for interactive mode only) **) |
938 |
||
24868 | 939 |
val _ = |
48642 | 940 |
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
|
941 |
(Parse.path >> (fn name => |
46e053eda5dd
clarified Parse.path vs. Parse.explode -- prefer errors in proper transaction context;
wenzelm
parents:
48792
diff
changeset
|
942 |
Toplevel.no_timing o Toplevel.imperative (fn () => File.cd (Path.explode name)))); |
5832 | 943 |
|
24868 | 944 |
val _ = |
48642 | 945 |
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
|
946 |
(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
|
947 |
Toplevel.imperative (fn () => writeln (Path.print (File.pwd ()))))); |
5832 | 948 |
|
24868 | 949 |
val _ = |
48642 | 950 |
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
|
951 |
(Parse.position Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
952 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.use_thy name))); |
5832 | 953 |
|
24868 | 954 |
val _ = |
48642 | 955 |
Outer_Syntax.improper_command @{command_spec "remove_thy"} "remove theory from loader database" |
36950 | 956 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
957 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.remove_thy name))); |
7102 | 958 |
|
24868 | 959 |
val _ = |
48642 | 960 |
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
|
961 |
"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
|
962 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
963 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
7931 | 964 |
|
24868 | 965 |
val _ = |
48642 | 966 |
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
|
967 |
"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
|
968 |
(Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.display_drafts)); |
14934 | 969 |
|
24868 | 970 |
val _ = |
48642 | 971 |
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
|
972 |
"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
|
973 |
(Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.print_drafts)); |
14934 | 974 |
|
39165 | 975 |
val _ = (* FIXME tty only *) |
48642 | 976 |
Outer_Syntax.improper_command @{command_spec "pr"} "print current proof state (if present)" |
39165 | 977 |
(opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) => |
978 |
Toplevel.no_timing o Toplevel.keep (fn state => |
|
979 |
(case limit of NONE => () | SOME n => Goal_Display.goals_limit_default := n; |
|
980 |
Toplevel.quiet := false; |
|
981 |
Print_Mode.with_modes modes (Toplevel.print_state true) state)))); |
|
7199 | 982 |
|
24868 | 983 |
val _ = |
48642 | 984 |
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
|
985 |
"disable printing of toplevel state" |
39165 | 986 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := true))); |
5832 | 987 |
|
24868 | 988 |
val _ = |
48642 | 989 |
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
|
990 |
"enable printing of toplevel state" |
39165 | 991 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative (fn () => Toplevel.quiet := false))); |
7222 | 992 |
|
24868 | 993 |
val _ = |
48642 | 994 |
Outer_Syntax.improper_command @{command_spec "commit"} |
50214 | 995 |
"commit current session to ML session image" |
36950 | 996 |
(Parse.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 997 |
|
24868 | 998 |
val _ = |
48642 | 999 |
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
|
1000 |
(Parse.opt_unit >> (Toplevel.no_timing oo K (Toplevel.imperative quit))); |
5832 | 1001 |
|
24868 | 1002 |
val _ = |
48642 | 1003 |
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
|
1004 |
(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
|
1005 |
(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
|
1006 |
(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
|
1007 |
raise Runtime.TERMINATE)))); |
5832 | 1008 |
|
48646
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 "welcome"} "print welcome message" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1011 |
(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
|
1012 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1013 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1014 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1015 |
(** raw Isar read-eval-print loop **) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1016 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1017 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1018 |
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
|
1019 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.init)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1020 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1021 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1022 |
Outer_Syntax.improper_command @{command_spec "linear_undo"} "undo commands" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1023 |
(Scan.optional Parse.nat 1 >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1024 |
(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
|
1025 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1026 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1027 |
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
|
1028 |
(Scan.optional Parse.nat 1 >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1029 |
(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
|
1030 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1031 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1032 |
Outer_Syntax.improper_command @{command_spec "undos_proof"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1033 |
"undo commands (skipping closed proofs)" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1034 |
(Scan.optional Parse.nat 1 >> (fn n => Toplevel.no_timing o |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1035 |
Toplevel.keep (fn state => |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1036 |
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
|
1037 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1038 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1039 |
Outer_Syntax.improper_command @{command_spec "cannot_undo"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1040 |
"partial undo -- Proof General legacy" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1041 |
(Parse.name >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1042 |
(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
|
1043 |
| txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt)))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1044 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1045 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1046 |
Outer_Syntax.improper_command @{command_spec "kill"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1047 |
"kill partial proof or theory development" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1048 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Isar.kill)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1049 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1050 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1051 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1052 |
(** extraction of programs from proofs **) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1053 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1054 |
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1055 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1056 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1057 |
Outer_Syntax.command @{command_spec "realizers"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1058 |
"specify realizers for primitive axioms / theorems, together with correctness proof" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1059 |
(Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1060 |
(fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1061 |
(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
|
1062 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1063 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1064 |
Outer_Syntax.command @{command_spec "realizability"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1065 |
"add equations characterizing realizability" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1066 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1067 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1068 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1069 |
Outer_Syntax.command @{command_spec "extract_type"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1070 |
"add equations characterizing type of extracted program" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1071 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1072 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1073 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1074 |
Outer_Syntax.command @{command_spec "extract"} "extract terms from proofs" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1075 |
(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
|
1076 |
Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
1077 |
|
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1078 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1079 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1080 |
(** end **) |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1081 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1082 |
val _ = |
48642 | 1083 |
Outer_Syntax.command @{command_spec "end"} "end context" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1084 |
(Scan.succeed |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1085 |
(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
|
1086 |
Toplevel.end_proof (K Proof.end_notepad))); |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
1087 |
|
5832 | 1088 |
end; |
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
1089 |