author | blanchet |
Sat, 26 Oct 2013 12:54:39 +0200 | |
changeset 54205 | bdb83bc60780 |
parent 53988 | 1781bf24cdf1 |
child 55141 | 863b4f9f6bd7 |
permissions | -rw-r--r-- |
5832 | 1 |
(* Title: Pure/Isar/isar_syn.ML |
52546 | 2 |
Author: Makarius |
5832 | 3 |
|
52546 | 4 |
Outer syntax for Isabelle/Pure. |
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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
15 |
(Parse.document_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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
20 |
(Parse.opt_target -- Parse.document_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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
25 |
(Parse.opt_target -- Parse.document_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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
30 |
(Parse.opt_target -- Parse.document_source >> Isar_Cmd.local_theory_markup); |
46961
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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
35 |
(Parse.opt_target -- Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
40 |
(Parse.opt_target -- Parse.document_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" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
45 |
(Parse.opt_target -- Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
50 |
(Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
55 |
(Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
60 |
(Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
65 |
(Parse.document_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)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
70 |
(Parse.document_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)) []) |
51685
385ef6706252
more standard module name Axclass (according to file name);
wenzelm
parents:
51658
diff
changeset
|
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)) |
51685
385ef6706252
more standard module name Axclass (according to file name);
wenzelm
parents:
51658
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!)" |
51685
385ef6706252
more standard module name Axclass (according to file name);
wenzelm
parents:
51658
diff
changeset
|
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" |
51654
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents:
51627
diff
changeset
|
211 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.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" |
51654
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents:
51627
diff
changeset
|
217 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.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)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
284 |
(Parse.ML_source >> 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 |
||
24868 | 326 |
val _ = |
48642 | 327 |
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
|
328 |
"install parse ast translation functions" |
52143 | 329 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 330 |
|
24868 | 331 |
val _ = |
48642 | 332 |
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
|
333 |
"install parse translation functions" |
52143 | 334 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 335 |
|
24868 | 336 |
val _ = |
48642 | 337 |
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
|
338 |
"install print translation functions" |
52143 | 339 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 340 |
|
24868 | 341 |
val _ = |
48642 | 342 |
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
|
343 |
"install typed print translation functions" |
52143 | 344 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 345 |
|
24868 | 346 |
val _ = |
48642 | 347 |
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
|
348 |
"install print ast translation functions" |
52143 | 349 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 350 |
|
351 |
||
352 |
(* oracles *) |
|
353 |
||
24868 | 354 |
val _ = |
48642 | 355 |
Outer_Syntax.command @{command_spec "oracle"} "declare oracle" |
48643 | 356 |
(Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
357 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 358 |
|
359 |
||
47057 | 360 |
(* bundled declarations *) |
361 |
||
362 |
val _ = |
|
48642 | 363 |
Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations" |
48643 | 364 |
((Parse.binding --| @{keyword "="}) -- Parse_Spec.xthms1 -- Parse.for_fixes |
47057 | 365 |
>> (uncurry Bundle.bundle_cmd)); |
366 |
||
367 |
val _ = |
|
48642 | 368 |
Outer_Syntax.command @{command_spec "include"} |
47057 | 369 |
"include declarations from bundle in proof body" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
370 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
371 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.include_cmd))); |
47057 | 372 |
|
373 |
val _ = |
|
48642 | 374 |
Outer_Syntax.command @{command_spec "including"} |
47057 | 375 |
"include declarations from bundle in goal refinement" |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
376 |
(Scan.repeat1 (Parse.position Parse.xname) |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
377 |
>> (Toplevel.print oo (Toplevel.proof o Bundle.including_cmd))); |
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
378 |
|
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
379 |
val _ = |
48642 | 380 |
Outer_Syntax.improper_command @{command_spec "print_bundles"} |
381 |
"print bundles of declarations" |
|
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
382 |
(Scan.succeed (Toplevel.unknown_context o |
47057 | 383 |
Toplevel.keep (Bundle.print_bundles o Toplevel.context_of))); |
384 |
||
385 |
||
47069 | 386 |
(* local theories *) |
387 |
||
388 |
val _ = |
|
48642 | 389 |
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
|
390 |
((Parse.position Parse.xname >> (fn name => |
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
>> (fn (incls, elems) => Toplevel.open_target (Bundle.context_cmd incls elems))) |
47069 | 394 |
--| Parse.begin); |
395 |
||
396 |
||
12061 | 397 |
(* locales *) |
398 |
||
12758 | 399 |
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
|
400 |
Parse_Spec.locale_expression false -- |
48643 | 401 |
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
|
402 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 403 |
|
24868 | 404 |
val _ = |
48642 | 405 |
Outer_Syntax.command @{command_spec "locale"} "define named proof context" |
36950 | 406 |
(Parse.binding -- |
48643 | 407 |
Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
27681 | 408 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 409 |
(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
|
410 |
(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
|
411 |
|
53988 | 412 |
fun interpretation_args mandatory = |
41270 | 413 |
Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
414 |
Scan.optional |
|
415 |
(Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
416 |
||
24868 | 417 |
val _ = |
48642 | 418 |
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
|
419 |
"prove sublocale relation between a locale and a locale expression" |
51737
718866dda2fa
target-sensitive user-level commands interpretation and sublocale
haftmann
parents:
51717
diff
changeset
|
420 |
((Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
53988 | 421 |
interpretation_args false >> (fn (loc, (expr, equations)) => |
422 |
Toplevel.print o |
|
423 |
Toplevel.theory_to_proof (Expression.sublocale_global_cmd I loc expr equations))) |
|
424 |
|| interpretation_args false >> (fn (expr, equations) => |
|
425 |
Toplevel.print o |
|
426 |
Toplevel.local_theory_to_proof NONE (Expression.sublocale_cmd expr equations))); |
|
28895 | 427 |
|
428 |
val _ = |
|
48642 | 429 |
Outer_Syntax.command @{command_spec "interpretation"} |
51737
718866dda2fa
target-sensitive user-level commands interpretation and sublocale
haftmann
parents:
51717
diff
changeset
|
430 |
"prove interpretation of locale expression in local theory" |
53988 | 431 |
(interpretation_args true >> (fn (expr, equations) => |
432 |
Toplevel.print o |
|
433 |
Toplevel.local_theory_to_proof NONE (Expression.interpretation_cmd expr equations))); |
|
29223 | 434 |
|
435 |
val _ = |
|
48642 | 436 |
Outer_Syntax.command @{command_spec "interpret"} |
29223 | 437 |
"prove interpretation of locale expression in proof context" |
53988 | 438 |
(interpretation_args true >> (fn (expr, equations) => |
439 |
Toplevel.print o |
|
440 |
Toplevel.proof' (Expression.interpret_cmd expr equations))); |
|
29223 | 441 |
|
15703 | 442 |
|
22299 | 443 |
(* classes *) |
444 |
||
24868 | 445 |
val class_val = |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
446 |
Parse_Spec.class_expression -- |
48643 | 447 |
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
|
448 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 449 |
|
24868 | 450 |
val _ = |
48642 | 451 |
Outer_Syntax.command @{command_spec "class"} "define type class" |
48643 | 452 |
(Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 453 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 454 |
(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
|
455 |
(Class_Declaration.class_cmd I name supclasses elems #> snd))); |
22299 | 456 |
|
24868 | 457 |
val _ = |
48642 | 458 |
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
|
459 |
(Parse.class >> Class_Declaration.subclass_cmd I); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
460 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
461 |
val _ = |
48642 | 462 |
Outer_Syntax.command @{command_spec "instantiation"} "instantiate and prove type arity" |
36950 | 463 |
(Parse.multi_arity --| Parse.begin |
25462 | 464 |
>> (fn arities => Toplevel.print o |
38348
cf7b2121ad9d
moved instantiation target formally to class_target.ML
haftmann
parents:
38342
diff
changeset
|
465 |
Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
24589 | 466 |
|
25485 | 467 |
val _ = |
48642 | 468 |
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
|
469 |
((Parse.class -- |
48643 | 470 |
((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd || |
36950 | 471 |
Parse.multi_arity >> Class.instance_arity_cmd) |
472 |
>> (Toplevel.print oo Toplevel.theory_to_proof) || |
|
473 |
Scan.succeed |
|
474 |
(Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 475 |
|
476 |
||
25519 | 477 |
(* arbitrary overloading *) |
478 |
||
479 |
val _ = |
|
48642 | 480 |
Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions" |
48643 | 481 |
(Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term -- |
482 |
Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true |
|
36950 | 483 |
>> Parse.triple1) --| Parse.begin |
25519 | 484 |
>> (fn operations => Toplevel.print o |
38342
09d4a04d5c2e
moved overloading target formally to overloading.ML
haftmann
parents:
38108
diff
changeset
|
485 |
Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
25519 | 486 |
|
487 |
||
22866 | 488 |
(* code generation *) |
489 |
||
24868 | 490 |
val _ = |
48642 | 491 |
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
|
492 |
"define set of code datatype constructors" |
36950 | 493 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 494 |
|
495 |
||
5832 | 496 |
|
497 |
(** proof commands **) |
|
498 |
||
499 |
(* statements *) |
|
500 |
||
53988 | 501 |
fun theorem spec schematic kind = |
48645 | 502 |
Outer_Syntax.local_theory_to_proof' spec |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
503 |
("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
|
504 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
47067
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
505 |
Scan.ahead (Parse_Spec.includes >> K "" || |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
506 |
Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
507 |
Scan.optional Parse_Spec.includes [] -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
508 |
Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
509 |
((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
|
510 |
kind NONE (K I) a includes elems concl))); |
5832 | 511 |
|
53988 | 512 |
val _ = theorem @{command_spec "theorem"} false Thm.theoremK; |
513 |
val _ = theorem @{command_spec "lemma"} false Thm.lemmaK; |
|
514 |
val _ = theorem @{command_spec "corollary"} false Thm.corollaryK; |
|
515 |
val _ = theorem @{command_spec "schematic_theorem"} true Thm.theoremK; |
|
516 |
val _ = theorem @{command_spec "schematic_lemma"} true Thm.lemmaK; |
|
517 |
val _ = theorem @{command_spec "schematic_corollary"} true Thm.corollaryK; |
|
5832 | 518 |
|
24868 | 519 |
val _ = |
48642 | 520 |
Outer_Syntax.local_theory_to_proof @{command_spec "notepad"} "begin proof context" |
40960 | 521 |
(Parse.begin >> K Proof.begin_notepad); |
522 |
||
523 |
val _ = |
|
48642 | 524 |
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
|
525 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have)); |
17353 | 526 |
|
24868 | 527 |
val _ = |
50214 | 528 |
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
|
529 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence)); |
17353 | 530 |
|
24868 | 531 |
val _ = |
48642 | 532 |
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
|
533 |
"state local goal, solving current obligation" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
534 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show)); |
5832 | 535 |
|
24868 | 536 |
val _ = |
50214 | 537 |
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
|
538 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus)); |
6501 | 539 |
|
5832 | 540 |
|
5914 | 541 |
(* facts *) |
5832 | 542 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
543 |
val facts = Parse.and_list1 Parse_Spec.xthms1; |
9197 | 544 |
|
24868 | 545 |
val _ = |
48642 | 546 |
Outer_Syntax.command @{command_spec "then"} "forward chaining" |
17900 | 547 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 548 |
|
24868 | 549 |
val _ = |
48642 | 550 |
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
|
551 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd))); |
5914 | 552 |
|
24868 | 553 |
val _ = |
48642 | 554 |
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
|
555 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd))); |
6878 | 556 |
|
24868 | 557 |
val _ = |
48642 | 558 |
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
|
559 |
(Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd))); |
5832 | 560 |
|
24868 | 561 |
val _ = |
48642 | 562 |
Outer_Syntax.command @{command_spec "using"} "augment goal facts" |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
563 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd))); |
18544 | 564 |
|
24868 | 565 |
val _ = |
48642 | 566 |
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
|
567 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd))); |
12926 | 568 |
|
5832 | 569 |
|
570 |
(* proof context *) |
|
571 |
||
24868 | 572 |
val _ = |
48642 | 573 |
Outer_Syntax.command @{command_spec "fix"} "fix local variables (Skolem constants)" |
36950 | 574 |
(Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd))); |
11890 | 575 |
|
24868 | 576 |
val _ = |
48642 | 577 |
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
|
578 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd))); |
5832 | 579 |
|
24868 | 580 |
val _ = |
48642 | 581 |
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
|
582 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd))); |
6850 | 583 |
|
24868 | 584 |
val _ = |
50214 | 585 |
Outer_Syntax.command @{command_spec "def"} "local definition (non-polymorphic)" |
36950 | 586 |
(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
|
587 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 588 |
((Parse.binding -- Parse.opt_mixfix) -- |
48643 | 589 |
((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp))) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
590 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd))); |
6953 | 591 |
|
24868 | 592 |
val _ = |
48642 | 593 |
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
|
594 |
(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
|
595 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 596 |
|
24868 | 597 |
val _ = |
48642 | 598 |
Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)" |
36950 | 599 |
(Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd))); |
17854 | 600 |
|
24868 | 601 |
val _ = |
48642 | 602 |
Outer_Syntax.command @{command_spec "let"} "bind text variables" |
48643 | 603 |
(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
|
604 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd))); |
5832 | 605 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
606 |
val _ = |
48642 | 607 |
Outer_Syntax.command @{command_spec "write"} "add concrete syntax for constants / fixed variables" |
51654
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents:
51627
diff
changeset
|
608 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
609 |
>> (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
|
610 |
|
24868 | 611 |
val _ = |
48642 | 612 |
Outer_Syntax.command @{command_spec "case"} "invoke local context" |
53377
21693b7c8fbf
more liberal 'case' syntax: allow parentheses without arguments;
wenzelm
parents:
52549
diff
changeset
|
613 |
((@{keyword "("} |-- |
53378
07990ba8c0ea
cases: more position information and PIDE markup;
wenzelm
parents:
53377
diff
changeset
|
614 |
Parse.!!! (Parse.position Parse.xname -- Scan.repeat (Parse.maybe Parse.binding) |
07990ba8c0ea
cases: more position information and PIDE markup;
wenzelm
parents:
53377
diff
changeset
|
615 |
--| @{keyword ")"}) || |
07990ba8c0ea
cases: more position information and PIDE markup;
wenzelm
parents:
53377
diff
changeset
|
616 |
Parse.position Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> (fn ((c, xs), atts) => |
53377
21693b7c8fbf
more liberal 'case' syntax: allow parentheses without arguments;
wenzelm
parents:
52549
diff
changeset
|
617 |
Toplevel.print o Toplevel.proof (Proof.invoke_case_cmd (c, xs, atts)))); |
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 |
|
53988 | 746 |
val _ = (*Proof General legacy*) |
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
749 |
(Parse.nat >> (fn n => Toplevel.imperative (fn () => Pretty.margin_default := n))); |
7124 | 750 |
|
24868 | 751 |
val _ = |
50213 | 752 |
Outer_Syntax.improper_command @{command_spec "help"} |
753 |
"retrieve outer syntax commands according to name patterns" |
|
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
754 |
(Scan.repeat Parse.name >> |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
755 |
(fn pats => Toplevel.imperative (fn () => Outer_Syntax.help_outer_syntax pats))); |
21714 | 756 |
|
24868 | 757 |
val _ = |
48642 | 758 |
Outer_Syntax.improper_command @{command_spec "print_commands"} "print outer syntax commands" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
759 |
(Scan.succeed (Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
5832 | 760 |
|
24868 | 761 |
val _ = |
52060 | 762 |
Outer_Syntax.improper_command @{command_spec "print_options"} "print configuration options" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
763 |
(Scan.succeed (Toplevel.unknown_context o |
52060 | 764 |
Toplevel.keep (Attrib.print_options o Toplevel.context_of))); |
23989 | 765 |
|
24868 | 766 |
val _ = |
50737 | 767 |
Outer_Syntax.improper_command @{command_spec "print_context"} "print main context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
768 |
(Scan.succeed (Toplevel.keep Toplevel.print_state_context)); |
7308 | 769 |
|
24868 | 770 |
val _ = |
48642 | 771 |
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
|
772 |
"print logical theory contents (verbose!)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
773 |
(opt_bang >> (fn b => Toplevel.unknown_theory o |
50737 | 774 |
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_full_theory b o Toplevel.theory_of))); |
5832 | 775 |
|
24868 | 776 |
val _ = |
48642 | 777 |
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
|
778 |
"print inner syntax of context (verbose!)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
779 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 780 |
Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of))); |
5832 | 781 |
|
24868 | 782 |
val _ = |
51585 | 783 |
Outer_Syntax.improper_command @{command_spec "print_defn_rules"} |
784 |
"print definitional rewrite rules of context" |
|
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
785 |
(Scan.succeed (Toplevel.unknown_context o |
51585 | 786 |
Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of))); |
787 |
||
788 |
val _ = |
|
48642 | 789 |
Outer_Syntax.improper_command @{command_spec "print_abbrevs"} |
51585 | 790 |
"print constant abbreviations of context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
791 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 792 |
Toplevel.keep (Proof_Context.print_abbrevs o Toplevel.context_of))); |
21726 | 793 |
|
24868 | 794 |
val _ = |
48642 | 795 |
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
|
796 |
"print theorems of local theory or proof context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
797 |
(opt_bang >> Isar_Cmd.print_theorems); |
5881 | 798 |
|
24868 | 799 |
val _ = |
48642 | 800 |
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
|
801 |
"print locales of this theory" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
802 |
(Scan.succeed (Toplevel.unknown_theory o |
50737 | 803 |
Toplevel.keep (Locale.print_locales o Toplevel.theory_of))); |
12061 | 804 |
|
24868 | 805 |
val _ = |
48642 | 806 |
Outer_Syntax.improper_command @{command_spec "print_classes"} |
807 |
"print classes of this theory" |
|
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
808 |
(Scan.succeed (Toplevel.unknown_theory o |
42359 | 809 |
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
|
810 |
|
24868 | 811 |
val _ = |
48642 | 812 |
Outer_Syntax.improper_command @{command_spec "print_locale"} |
813 |
"print locale of this theory" |
|
50737 | 814 |
(opt_bang -- Parse.position Parse.xname >> (fn (b, name) => |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
815 |
Toplevel.unknown_theory o |
50737 | 816 |
Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name))); |
12061 | 817 |
|
24868 | 818 |
val _ = |
48642 | 819 |
Outer_Syntax.improper_command @{command_spec "print_interps"} |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
820 |
"print interpretations of locale for this theory or proof context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
821 |
(Parse.position Parse.xname >> (fn name => |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
822 |
Toplevel.unknown_context o |
50737 | 823 |
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
|
824 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
825 |
val _ = |
48642 | 826 |
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
|
827 |
"print dependencies of locale expression" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
828 |
(opt_bang -- Parse_Spec.locale_expression true >> (fn (b, expr) => |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
829 |
Toplevel.unknown_context o |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
830 |
Toplevel.keep (fn state => Expression.print_dependencies (Toplevel.context_of state) b expr))); |
41435 | 831 |
|
832 |
val _ = |
|
48642 | 833 |
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
|
834 |
"print attributes of this theory" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
835 |
(Scan.succeed (Toplevel.unknown_theory o |
50737 | 836 |
Toplevel.keep (Attrib.print_attributes o Toplevel.theory_of))); |
5832 | 837 |
|
24868 | 838 |
val _ = |
48642 | 839 |
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
|
840 |
"print context of Simplifier" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
841 |
(Scan.succeed (Toplevel.unknown_context o |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51685
diff
changeset
|
842 |
Toplevel.keep (Pretty.writeln o Simplifier.pretty_simpset o Toplevel.context_of))); |
16027 | 843 |
|
24868 | 844 |
val _ = |
48642 | 845 |
Outer_Syntax.improper_command @{command_spec "print_rules"} "print intro/elim rules" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
846 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 847 |
Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of))); |
12383 | 848 |
|
24868 | 849 |
val _ = |
48642 | 850 |
Outer_Syntax.improper_command @{command_spec "print_trans_rules"} "print transitivity rules" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
851 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 852 |
Toplevel.keep (Calculation.print_rules o Toplevel.context_of))); |
9221 | 853 |
|
24868 | 854 |
val _ = |
48642 | 855 |
Outer_Syntax.improper_command @{command_spec "print_methods"} "print methods of this theory" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
856 |
(Scan.succeed (Toplevel.unknown_theory o |
50737 | 857 |
Toplevel.keep (Method.print_methods o Toplevel.theory_of))); |
5832 | 858 |
|
24868 | 859 |
val _ = |
50214 | 860 |
Outer_Syntax.improper_command @{command_spec "print_antiquotations"} "print antiquotations" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
861 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 862 |
Toplevel.keep (Thy_Output.print_antiquotations o Toplevel.context_of))); |
9221 | 863 |
|
24868 | 864 |
val _ = |
48642 | 865 |
Outer_Syntax.improper_command @{command_spec "thy_deps"} "visualize theory dependencies" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
866 |
(Scan.succeed Isar_Cmd.thy_deps); |
22485 | 867 |
|
24868 | 868 |
val _ = |
49569
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
869 |
Outer_Syntax.improper_command @{command_spec "locale_deps"} "visualize locale dependencies" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
870 |
(Scan.succeed Isar_Cmd.locale_deps); |
49569
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
871 |
|
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
872 |
val _ = |
48642 | 873 |
Outer_Syntax.improper_command @{command_spec "class_deps"} "visualize class dependencies" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
874 |
(Scan.succeed Isar_Cmd.class_deps); |
20574 | 875 |
|
24868 | 876 |
val _ = |
48642 | 877 |
Outer_Syntax.improper_command @{command_spec "thm_deps"} "visualize theorem dependencies" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
878 |
(Parse_Spec.xthms1 >> Isar_Cmd.thm_deps); |
9454 | 879 |
|
24868 | 880 |
val _ = |
48642 | 881 |
Outer_Syntax.improper_command @{command_spec "print_binds"} "print term bindings of proof context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
882 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 883 |
Toplevel.keep (Proof_Context.print_binds o Toplevel.context_of))); |
5832 | 884 |
|
24868 | 885 |
val _ = |
48642 | 886 |
Outer_Syntax.improper_command @{command_spec "print_facts"} "print facts of proof context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
887 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 888 |
Toplevel.keep (Proof_Context.print_lthms o Toplevel.context_of))); |
5832 | 889 |
|
24868 | 890 |
val _ = |
48642 | 891 |
Outer_Syntax.improper_command @{command_spec "print_cases"} "print cases of proof context" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
892 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 893 |
Toplevel.keep (Proof_Context.print_cases o Toplevel.context_of))); |
8370 | 894 |
|
24868 | 895 |
val _ = |
48642 | 896 |
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
|
897 |
"print theorems as long statements" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
898 |
(opt_modes -- Parse_Spec.xthms1 >> Isar_Cmd.print_stmts); |
19269 | 899 |
|
24868 | 900 |
val _ = |
48642 | 901 |
Outer_Syntax.improper_command @{command_spec "thm"} "print theorems" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
902 |
(opt_modes -- Parse_Spec.xthms1 >> Isar_Cmd.print_thms); |
5832 | 903 |
|
24868 | 904 |
val _ = |
48642 | 905 |
Outer_Syntax.improper_command @{command_spec "prf"} "print proof terms of theorems" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
906 |
(opt_modes -- Scan.option Parse_Spec.xthms1 >> Isar_Cmd.print_prfs false); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
907 |
|
24868 | 908 |
val _ = |
48642 | 909 |
Outer_Syntax.improper_command @{command_spec "full_prf"} "print full proof terms of theorems" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
910 |
(opt_modes -- Scan.option Parse_Spec.xthms1 >> Isar_Cmd.print_prfs true); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
911 |
|
24868 | 912 |
val _ = |
48642 | 913 |
Outer_Syntax.improper_command @{command_spec "prop"} "read and print proposition" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
914 |
(opt_modes -- Parse.term >> Isar_Cmd.print_prop); |
5832 | 915 |
|
24868 | 916 |
val _ = |
48642 | 917 |
Outer_Syntax.improper_command @{command_spec "term"} "read and print term" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
918 |
(opt_modes -- Parse.term >> Isar_Cmd.print_term); |
5832 | 919 |
|
24868 | 920 |
val _ = |
48642 | 921 |
Outer_Syntax.improper_command @{command_spec "typ"} "read and print type" |
48792 | 922 |
(opt_modes -- (Parse.typ -- Scan.option (@{keyword "::"} |-- Parse.!!! Parse.sort)) |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
923 |
>> Isar_Cmd.print_type); |
5832 | 924 |
|
24868 | 925 |
val _ = |
48642 | 926 |
Outer_Syntax.improper_command @{command_spec "print_codesetup"} "print code generator setup" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
927 |
(Scan.succeed (Toplevel.unknown_theory o |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
928 |
Toplevel.keep (Code.print_codesetup o Toplevel.theory_of))); |
5832 | 929 |
|
26184 | 930 |
val _ = |
48642 | 931 |
Outer_Syntax.improper_command @{command_spec "unused_thms"} "find unused theorems" |
36950 | 932 |
(Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) -- |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
933 |
Scan.option (Scan.repeat1 (Scan.unless Parse.minus Parse.name))) >> 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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
941 |
(Parse.path >> (fn name => Toplevel.imperative (fn () => File.cd (Path.explode name)))); |
5832 | 942 |
|
24868 | 943 |
val _ = |
48642 | 944 |
Outer_Syntax.improper_command @{command_spec "pwd"} "print current working directory" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
945 |
(Scan.succeed (Toplevel.imperative (fn () => writeln (Path.print (File.pwd ()))))); |
5832 | 946 |
|
24868 | 947 |
val _ = |
48642 | 948 |
Outer_Syntax.improper_command @{command_spec "use_thy"} "use theory file" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
949 |
(Parse.position Parse.name >> |
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
950 |
(fn name => Toplevel.imperative (fn () => Thy_Info.use_thy name))); |
5832 | 951 |
|
24868 | 952 |
val _ = |
48642 | 953 |
Outer_Syntax.improper_command @{command_spec "remove_thy"} "remove theory from loader database" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
954 |
(Parse.name >> (fn name => Toplevel.imperative (fn () => Thy_Info.remove_thy name))); |
7102 | 955 |
|
24868 | 956 |
val _ = |
48642 | 957 |
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
|
958 |
"kill theory -- try to remove from loader database" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
959 |
(Parse.name >> (fn name => Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
7931 | 960 |
|
53403
c09f4005d6bd
some explicit indication of Proof General legacy;
wenzelm
parents:
53378
diff
changeset
|
961 |
val _ = (*partial Proof General legacy*) |
48642 | 962 |
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
|
963 |
"display raw source files with symbols" |
52549 | 964 |
(Scan.repeat1 Parse.path >> (fn names => |
965 |
Toplevel.imperative (fn () => ignore (Present.display_drafts (map Path.explode names))))); |
|
14934 | 966 |
|
52430 | 967 |
val _ = |
968 |
Outer_Syntax.improper_command @{command_spec "print_state"} |
|
969 |
"print current proof state (if present)" |
|
970 |
(opt_modes >> (fn modes => |
|
971 |
Toplevel.keep (fn state => |
|
972 |
Print_Mode.with_modes modes (Toplevel.print_state true) state))); |
|
973 |
||
53403
c09f4005d6bd
some explicit indication of Proof General legacy;
wenzelm
parents:
53378
diff
changeset
|
974 |
val _ = (*Proof General legacy, e.g. for ProofGeneral-3.7.x*) |
48642 | 975 |
Outer_Syntax.improper_command @{command_spec "pr"} "print current proof state (if present)" |
39165 | 976 |
(opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) => |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
977 |
Toplevel.keep (fn state => |
52438
7b5a5116f3af
back to keyword 'pr' :: diag as required for ProofGeneral command line -- reject this TTY command in Isabelle/jEdit by other means;
wenzelm
parents:
52430
diff
changeset
|
978 |
(if Isabelle_Process.is_active () then error "Illegal TTY command" else (); |
7b5a5116f3af
back to keyword 'pr' :: diag as required for ProofGeneral command line -- reject this TTY command in Isabelle/jEdit by other means;
wenzelm
parents:
52430
diff
changeset
|
979 |
case limit of NONE => () | SOME n => Options.default_put_int @{option goals_limit} n; |
39165 | 980 |
Toplevel.quiet := false; |
981 |
Print_Mode.with_modes modes (Toplevel.print_state true) state)))); |
|
7199 | 982 |
|
53403
c09f4005d6bd
some explicit indication of Proof General legacy;
wenzelm
parents:
53378
diff
changeset
|
983 |
val _ = (*Proof General legacy*) |
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
986 |
(Scan.succeed (Toplevel.imperative (fn () => Toplevel.quiet := true))); |
5832 | 987 |
|
53403
c09f4005d6bd
some explicit indication of Proof General legacy;
wenzelm
parents:
53378
diff
changeset
|
988 |
val _ = (*Proof General legacy*) |
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
991 |
(Scan.succeed (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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
996 |
(Parse.opt_unit >> K (Toplevel.imperative Secure.commit)); |
5832 | 997 |
|
24868 | 998 |
val _ = |
48642 | 999 |
Outer_Syntax.improper_command @{command_spec "quit"} "quit Isabelle" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1000 |
(Parse.opt_unit >> (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 |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1005 |
(Toplevel.keep (fn state => |
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
|
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1011 |
(Scan.succeed (Toplevel.imperative (writeln o Session.welcome))); |
48646
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1019 |
(Scan.succeed (Toplevel.imperative Isar.init)); |
48646
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 >> |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1024 |
(fn n => Toplevel.imperative (fn () => Isar.linear_undo n))); |
48646
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 >> |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1029 |
(fn n => Toplevel.imperative (fn () => Isar.undo n))); |
48646
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)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1034 |
(Scan.optional Parse.nat 1 >> (fn n => |
48646
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 >> |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1042 |
(fn "end" => Toplevel.imperative (fn () => Isar.undo 1) |
48646
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" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
1048 |
(Scan.succeed (Toplevel.imperative Isar.kill)); |
48646
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 |