author | wenzelm |
Wed, 05 Nov 2014 16:57:12 +0100 | |
changeset 58900 | 1435cc20b022 |
parent 58893 | 9e0ecb66d6a7 |
child 58928 | 23d0ffd48006 |
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" |
58875 | 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" |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58862
diff
changeset
|
20 |
(Parse.opt_target -- Parse.document_source >> Isar_Cmd.heading_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" |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58862
diff
changeset
|
25 |
(Parse.opt_target -- Parse.document_source >> Isar_Cmd.heading_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" |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58862
diff
changeset
|
30 |
(Parse.opt_target -- Parse.document_source >> Isar_Cmd.heading_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" |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58862
diff
changeset
|
35 |
(Parse.opt_target -- Parse.document_source >> Isar_Cmd.heading_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.MarkupEnv |
48642 | 49 |
@{command_spec "txt"} "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.Verbatim |
48642 | 54 |
@{command_spec "txt_raw"} "raw document preparation text (proof)" |
51627
589daaf48dba
tuned signature -- agree with markup terminology;
wenzelm
parents:
51585
diff
changeset
|
55 |
(Parse.document_source >> Isar_Cmd.proof_markup); |
7775 | 56 |
|
5832 | 57 |
|
6886 | 58 |
|
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
|
59 |
(** theory commands **) |
6886 | 60 |
|
55385
169e12bbf9a3
discontinued axiomatic 'classes', 'classrel', 'arities';
wenzelm
parents:
55141
diff
changeset
|
61 |
(* sorts *) |
5832 | 62 |
|
24868 | 63 |
val _ = |
48642 | 64 |
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
|
65 |
"declare default sort for explicit type variables" |
36950 | 66 |
(Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy)); |
5832 | 67 |
|
68 |
||
69 |
(* types *) |
|
70 |
||
24868 | 71 |
val _ = |
48642 | 72 |
Outer_Syntax.local_theory @{command_spec "typedecl"} "type declaration" |
36950 | 73 |
(Parse.type_args -- Parse.binding -- Parse.opt_mixfix |
35835 | 74 |
>> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd)); |
5832 | 75 |
|
24868 | 76 |
val _ = |
48642 | 77 |
Outer_Syntax.local_theory @{command_spec "type_synonym"} "declare type abbreviation" |
45837 | 78 |
(Parse.type_args -- Parse.binding -- |
48643 | 79 |
(@{keyword "="} |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix')) |
45837 | 80 |
>> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)); |
5832 | 81 |
|
24868 | 82 |
val _ = |
48642 | 83 |
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
|
84 |
"declare syntactic type constructors (grammar nonterminal symbols)" |
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42359
diff
changeset
|
85 |
(Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global)); |
5832 | 86 |
|
87 |
||
88 |
(* consts and syntax *) |
|
89 |
||
24868 | 90 |
val _ = |
48642 | 91 |
Outer_Syntax.command @{command_spec "judgment"} "declare object-logic judgment" |
36950 | 92 |
(Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
8227 | 93 |
|
24868 | 94 |
val _ = |
48642 | 95 |
Outer_Syntax.command @{command_spec "consts"} "declare constants" |
56239 | 96 |
(Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts_cmd)); |
5832 | 97 |
|
12142 | 98 |
val mode_spec = |
48643 | 99 |
(@{keyword "output"} >> K ("", false)) || |
100 |
Parse.name -- Scan.optional (@{keyword "output"} >> K false) true; |
|
9731 | 101 |
|
14900 | 102 |
val opt_mode = |
48643 | 103 |
Scan.optional (@{keyword "("} |-- Parse.!!! (mode_spec --| @{keyword ")"})) Syntax.mode_default; |
5832 | 104 |
|
24868 | 105 |
val _ = |
50214 | 106 |
Outer_Syntax.command @{command_spec "syntax"} "add raw syntax clauses" |
56239 | 107 |
(opt_mode -- Scan.repeat1 Parse.const_decl |
56240 | 108 |
>> (Toplevel.theory o uncurry Sign.add_syntax_cmd)); |
5832 | 109 |
|
24868 | 110 |
val _ = |
50214 | 111 |
Outer_Syntax.command @{command_spec "no_syntax"} "delete raw syntax clauses" |
56239 | 112 |
(opt_mode -- Scan.repeat1 Parse.const_decl |
56240 | 113 |
>> (Toplevel.theory o uncurry Sign.del_syntax_cmd)); |
15748 | 114 |
|
5832 | 115 |
|
116 |
(* translations *) |
|
117 |
||
118 |
val trans_pat = |
|
42326 | 119 |
Scan.optional |
56006 | 120 |
(@{keyword "("} |-- Parse.!!! (Parse.inner_syntax Parse.xname --| @{keyword ")"})) "logic" |
42326 | 121 |
-- Parse.inner_syntax Parse.string; |
5832 | 122 |
|
123 |
fun trans_arrow toks = |
|
48643 | 124 |
((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule || |
125 |
(@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule || |
|
126 |
(@{keyword "\<rightleftharpoons>"} || @{keyword "=="}) >> K Syntax.Parse_Print_Rule) toks; |
|
5832 | 127 |
|
128 |
val trans_line = |
|
36950 | 129 |
trans_pat -- Parse.!!! (trans_arrow -- trans_pat) |
5832 | 130 |
>> (fn (left, (arr, right)) => arr (left, right)); |
131 |
||
24868 | 132 |
val _ = |
50214 | 133 |
Outer_Syntax.command @{command_spec "translations"} "add syntax translation rules" |
42204 | 134 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations)); |
5832 | 135 |
|
24868 | 136 |
val _ = |
50214 | 137 |
Outer_Syntax.command @{command_spec "no_translations"} "delete syntax translation rules" |
42204 | 138 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations)); |
19260 | 139 |
|
5832 | 140 |
|
141 |
(* axioms and definitions *) |
|
142 |
||
19631 | 143 |
val opt_unchecked_overloaded = |
48643 | 144 |
Scan.optional (@{keyword "("} |-- Parse.!!! |
145 |
(((@{keyword "unchecked"} >> K true) -- |
|
146 |
Scan.optional (@{keyword "overloaded"} >> K true) false || |
|
147 |
@{keyword "overloaded"} >> K (false, true)) --| @{keyword ")"})) (false, false); |
|
19631 | 148 |
|
24868 | 149 |
val _ = |
48642 | 150 |
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
|
151 |
(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
|
152 |
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
|
153 |
>> (Toplevel.theory o Isar_Cmd.add_defs)); |
6370 | 154 |
|
14642 | 155 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
156 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
157 |
|
24868 | 158 |
val _ = |
48642 | 159 |
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
|
160 |
(Parse_Spec.constdef >> (fn args => #2 oo Specification.definition_cmd args)); |
18780 | 161 |
|
24868 | 162 |
val _ = |
48642 | 163 |
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
|
164 |
(opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop) |
36950 | 165 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 166 |
|
24868 | 167 |
val _ = |
48642 | 168 |
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
|
169 |
"add concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
170 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 171 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
35413 | 172 |
|
173 |
val _ = |
|
48642 | 174 |
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
|
175 |
"delete concrete syntax for type constructors" |
42300
0d1cbc1fe579
notation: proper markup for type constructor / constant;
wenzelm
parents:
42299
diff
changeset
|
176 |
(opt_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
36950 | 177 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
35413 | 178 |
|
179 |
val _ = |
|
48642 | 180 |
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
|
181 |
"add concrete syntax for constants / fixed variables" |
51654
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents:
51627
diff
changeset
|
182 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
36950 | 183 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 184 |
|
185 |
val _ = |
|
48642 | 186 |
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
|
187 |
"delete concrete syntax for constants / fixed variables" |
51654
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
wenzelm
parents:
51627
diff
changeset
|
188 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
36950 | 189 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 190 |
|
5832 | 191 |
|
18616 | 192 |
(* constant specifications *) |
193 |
||
24868 | 194 |
val _ = |
48642 | 195 |
Outer_Syntax.command @{command_spec "axiomatization"} "axiomatic constant specification" |
36950 | 196 |
(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
|
197 |
Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) [] |
36950 | 198 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 199 |
|
200 |
||
5914 | 201 |
(* theorems *) |
202 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
203 |
fun theorems kind = |
45600
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
204 |
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
|
205 |
>> (fn (facts, fixes) => #2 oo Specification.theorems_cmd kind facts fixes); |
12712 | 206 |
|
24868 | 207 |
val _ = |
48642 | 208 |
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
|
209 |
(theorems Thm.theoremK); |
5914 | 210 |
|
24868 | 211 |
val _ = |
48642 | 212 |
Outer_Syntax.local_theory' @{command_spec "lemmas"} "define lemmas" (theorems Thm.lemmaK); |
5914 | 213 |
|
24868 | 214 |
val _ = |
48642 | 215 |
Outer_Syntax.local_theory' @{command_spec "declare"} "declare theorems" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
216 |
(Parse.and_list1 Parse.xthms1 -- Parse.for_fixes |
45600
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
217 |
>> (fn (facts, fixes) => |
1bbbac9a0cb0
'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents:
45488
diff
changeset
|
218 |
#2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes)); |
9589 | 219 |
|
5914 | 220 |
|
56005
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
221 |
(* hide names *) |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
222 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
223 |
local |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
224 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
225 |
fun hide_names command_spec what hide parse prep = |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
226 |
Outer_Syntax.command command_spec ("hide " ^ what ^ " from name space") |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
227 |
((Parse.opt_keyword "open" >> not) -- Scan.repeat1 parse >> (fn (fully, args) => |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
228 |
(Toplevel.theory (fn thy => |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
229 |
let val ctxt = Proof_Context.init_global thy |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
230 |
in fold (hide fully o prep ctxt) args thy end)))); |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
231 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
232 |
in |
5832 | 233 |
|
56005
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
234 |
val _ = |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
235 |
hide_names @{command_spec "hide_class"} "classes" Sign.hide_class Parse.class |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
236 |
Proof_Context.read_class; |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
237 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
238 |
val _ = |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
239 |
hide_names @{command_spec "hide_type"} "types" Sign.hide_type Parse.type_const |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
240 |
((#1 o dest_Type) oo Proof_Context.read_type_name {proper = true, strict = false}); |
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
|
241 |
|
56005
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
242 |
val _ = |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
243 |
hide_names @{command_spec "hide_const"} "constants" Sign.hide_const Parse.const |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
244 |
((#1 o dest_Const) oo Proof_Context.read_const {proper = true, strict = false}); |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
245 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
246 |
val _ = |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
247 |
hide_names @{command_spec "hide_fact"} "facts" Global_Theory.hide_fact |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
248 |
(Parse.position Parse.xname) (Global_Theory.check_fact o Proof_Context.theory_of); |
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
249 |
|
4f4fc80b0613
simplified / modernized hide commands: proper outer parsers and PIDE markup via check;
wenzelm
parents:
55997
diff
changeset
|
250 |
end; |
5832 | 251 |
|
252 |
||
253 |
(* use ML text *) |
|
254 |
||
24868 | 255 |
val _ = |
56275
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
256 |
Outer_Syntax.command @{command_spec "SML_file"} "read and evaluate Standard ML file" |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
257 |
(Resources.provide_parse_files "SML_file" >> (fn files => Toplevel.theory (fn thy => |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
258 |
let |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
259 |
val ([{lines, pos, ...}], thy') = files thy; |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
260 |
val source = {delimited = true, text = cat_lines lines, pos = pos}; |
56618
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
261 |
val flags = {SML = true, exchange = false, redirect = true, verbose = true}; |
56275
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
262 |
in |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
263 |
thy' |> Context.theory_map |
56304
40274e4f5ebf
redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents:
56275
diff
changeset
|
264 |
(ML_Context.exec (fn () => ML_Context.eval_source flags source)) |
56275
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
265 |
end))); |
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
266 |
|
600f432ab556
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents:
56240
diff
changeset
|
267 |
val _ = |
56618
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
268 |
Outer_Syntax.command @{command_spec "SML_export"} "evaluate SML within Isabelle/ML environment" |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
269 |
(Parse.ML_source >> (fn source => |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
270 |
let val flags = {SML = true, exchange = true, redirect = false, verbose = true} in |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
271 |
Toplevel.theory |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
272 |
(Context.theory_map (ML_Context.exec (fn () => ML_Context.eval_source flags source))) |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
273 |
end)); |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
274 |
|
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
275 |
val _ = |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
276 |
Outer_Syntax.command @{command_spec "SML_import"} "evaluate Isabelle/ML within SML environment" |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
277 |
(Parse.ML_source >> (fn source => |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
278 |
let val flags = {SML = false, exchange = true, redirect = false, verbose = true} in |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
279 |
Toplevel.generic_theory |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
280 |
(ML_Context.exec (fn () => ML_Context.eval_source flags source) #> |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
281 |
Local_Theory.propagate_ml_env) |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
282 |
end)); |
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
283 |
|
874bdedb2313
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
wenzelm
parents:
56467
diff
changeset
|
284 |
val _ = |
48642 | 285 |
Outer_Syntax.command @{command_spec "ML"} "ML text within theory or local theory" |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55795
diff
changeset
|
286 |
(Parse.ML_source >> (fn source => |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
287 |
Toplevel.generic_theory |
56304
40274e4f5ebf
redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents:
56275
diff
changeset
|
288 |
(ML_Context.exec (fn () => |
40274e4f5ebf
redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents:
56275
diff
changeset
|
289 |
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source) #> |
37949
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
wenzelm
parents:
37873
diff
changeset
|
290 |
Local_Theory.propagate_ml_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
291 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
292 |
val _ = |
48642 | 293 |
Outer_Syntax.command @{command_spec "ML_prf"} "ML text within proof" |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55795
diff
changeset
|
294 |
(Parse.ML_source >> (fn source => |
28269 | 295 |
Toplevel.proof (Proof.map_context (Context.proof_map |
56304
40274e4f5ebf
redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents:
56275
diff
changeset
|
296 |
(ML_Context.exec (fn () => |
40274e4f5ebf
redirect ML_Compiler reports more directly: only the (big) parse tree report is deferred via Execution.print (NB: this does not work for asynchronous "diag" commands);
wenzelm
parents:
56275
diff
changeset
|
297 |
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source))) #> |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55795
diff
changeset
|
298 |
Proof.propagate_ml_env))); |
28269 | 299 |
|
300 |
val _ = |
|
48642 | 301 |
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
|
302 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
26396 | 303 |
|
304 |
val _ = |
|
48642 | 305 |
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
|
306 |
(Parse.ML_source >> Isar_Cmd.ml_diag false); |
5832 | 307 |
|
24868 | 308 |
val _ = |
48642 | 309 |
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
|
310 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup)); |
30461 | 311 |
|
312 |
val _ = |
|
48642 | 313 |
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
|
314 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
5832 | 315 |
|
24868 | 316 |
val _ = |
57941
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
wenzelm
parents:
57934
diff
changeset
|
317 |
Outer_Syntax.local_theory @{command_spec "attribute_setup"} "define attribute in ML" |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
318 |
(Parse.position Parse.name -- |
48643 | 319 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
57941
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
wenzelm
parents:
57934
diff
changeset
|
320 |
>> (fn (name, (txt, cmt)) => Attrib.attribute_setup name txt cmt)); |
30526 | 321 |
|
322 |
val _ = |
|
57941
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
wenzelm
parents:
57934
diff
changeset
|
323 |
Outer_Syntax.local_theory @{command_spec "method_setup"} "define proof method in ML" |
42813
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
wenzelm
parents:
42496
diff
changeset
|
324 |
(Parse.position Parse.name -- |
48643 | 325 |
Parse.!!! (@{keyword "="} |-- Parse.ML_source -- Scan.optional Parse.text "") |
57941
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
wenzelm
parents:
57934
diff
changeset
|
326 |
>> (fn (name, (txt, cmt)) => Method.method_setup name txt cmt)); |
9197 | 327 |
|
24868 | 328 |
val _ = |
48642 | 329 |
Outer_Syntax.local_theory @{command_spec "declaration"} "generic ML declaration" |
40784 | 330 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
331 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt)); |
|
332 |
||
333 |
val _ = |
|
48642 | 334 |
Outer_Syntax.local_theory @{command_spec "syntax_declaration"} "generic ML syntax declaration" |
40784 | 335 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
336 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt)); |
|
22088 | 337 |
|
24868 | 338 |
val _ = |
48642 | 339 |
Outer_Syntax.local_theory @{command_spec "simproc_setup"} "define simproc in ML" |
42464 | 340 |
(Parse.position Parse.name -- |
48643 | 341 |
(@{keyword "("} |-- Parse.enum1 "|" Parse.term --| @{keyword ")"} --| @{keyword "="}) -- |
342 |
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
|
343 |
>> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d)); |
22202 | 344 |
|
5832 | 345 |
|
346 |
(* translation functions *) |
|
347 |
||
24868 | 348 |
val _ = |
48642 | 349 |
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
|
350 |
"install parse ast translation functions" |
52143 | 351 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 352 |
|
24868 | 353 |
val _ = |
48642 | 354 |
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
|
355 |
"install parse translation functions" |
52143 | 356 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 357 |
|
24868 | 358 |
val _ = |
48642 | 359 |
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
|
360 |
"install print translation functions" |
52143 | 361 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 362 |
|
24868 | 363 |
val _ = |
48642 | 364 |
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
|
365 |
"install typed print translation functions" |
52143 | 366 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 367 |
|
24868 | 368 |
val _ = |
48642 | 369 |
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
|
370 |
"install print ast translation functions" |
52143 | 371 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 372 |
|
373 |
||
374 |
(* oracles *) |
|
375 |
||
24868 | 376 |
val _ = |
48642 | 377 |
Outer_Syntax.command @{command_spec "oracle"} "declare oracle" |
48643 | 378 |
(Parse.position Parse.name -- (@{keyword "="} |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
379 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 380 |
|
381 |
||
47057 | 382 |
(* bundled declarations *) |
383 |
||
384 |
val _ = |
|
48642 | 385 |
Outer_Syntax.local_theory @{command_spec "bundle"} "define bundle of declarations" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
386 |
((Parse.binding --| @{keyword "="}) -- Parse.xthms1 -- Parse.for_fixes |
47057 | 387 |
>> (uncurry Bundle.bundle_cmd)); |
388 |
||
389 |
val _ = |
|
48642 | 390 |
Outer_Syntax.command @{command_spec "include"} |
47057 | 391 |
"include declarations from bundle in proof body" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
392 |
(Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.include_cmd)); |
47057 | 393 |
|
394 |
val _ = |
|
48642 | 395 |
Outer_Syntax.command @{command_spec "including"} |
47057 | 396 |
"include declarations from bundle in goal refinement" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
397 |
(Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.including_cmd)); |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
398 |
|
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47057
diff
changeset
|
399 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
400 |
Outer_Syntax.command @{command_spec "print_bundles"} |
48642 | 401 |
"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
|
402 |
(Scan.succeed (Toplevel.unknown_context o |
47057 | 403 |
Toplevel.keep (Bundle.print_bundles o Toplevel.context_of))); |
404 |
||
405 |
||
47069 | 406 |
(* local theories *) |
407 |
||
408 |
val _ = |
|
48642 | 409 |
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
|
410 |
((Parse.position Parse.xname >> (fn name => |
57483
950dc7446454
centralized (ad-hoc) switching of targets in named_target.ML
haftmann
parents:
57442
diff
changeset
|
411 |
Toplevel.begin_local_theory true (Named_Target.begin name)) || |
47253
a00c5c88d8f3
more general context command with auxiliary fixes/assumes etc.;
wenzelm
parents:
47069
diff
changeset
|
412 |
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
|
413 |
>> (fn (incls, elems) => Toplevel.open_target (Bundle.context_cmd incls elems))) |
47069 | 414 |
--| Parse.begin); |
415 |
||
416 |
||
12061 | 417 |
(* locales *) |
418 |
||
12758 | 419 |
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
|
420 |
Parse_Spec.locale_expression false -- |
48643 | 421 |
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
|
422 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 423 |
|
24868 | 424 |
val _ = |
48642 | 425 |
Outer_Syntax.command @{command_spec "locale"} "define named proof context" |
36950 | 426 |
(Parse.binding -- |
48643 | 427 |
Scan.optional (@{keyword "="} |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
27681 | 428 |
>> (fn ((name, (expr, elems)), begin) => |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
429 |
Toplevel.begin_local_theory begin |
57181
2d13bf9ea77b
dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents:
56895
diff
changeset
|
430 |
(Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
431 |
|
53988 | 432 |
fun interpretation_args mandatory = |
41270 | 433 |
Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
434 |
Scan.optional |
|
435 |
(Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
436 |
||
24868 | 437 |
val _ = |
48642 | 438 |
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
|
439 |
"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
|
440 |
((Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
53988 | 441 |
interpretation_args false >> (fn (loc, (expr, equations)) => |
57181
2d13bf9ea77b
dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents:
56895
diff
changeset
|
442 |
Toplevel.theory_to_proof (Expression.sublocale_global_cmd loc expr equations))) |
53988 | 443 |
|| interpretation_args false >> (fn (expr, equations) => |
444 |
Toplevel.local_theory_to_proof NONE (Expression.sublocale_cmd expr equations))); |
|
28895 | 445 |
|
446 |
val _ = |
|
48642 | 447 |
Outer_Syntax.command @{command_spec "interpretation"} |
51737
718866dda2fa
target-sensitive user-level commands interpretation and sublocale
haftmann
parents:
51717
diff
changeset
|
448 |
"prove interpretation of locale expression in local theory" |
53988 | 449 |
(interpretation_args true >> (fn (expr, equations) => |
450 |
Toplevel.local_theory_to_proof NONE (Expression.interpretation_cmd expr equations))); |
|
29223 | 451 |
|
452 |
val _ = |
|
48642 | 453 |
Outer_Syntax.command @{command_spec "interpret"} |
29223 | 454 |
"prove interpretation of locale expression in proof context" |
53988 | 455 |
(interpretation_args true >> (fn (expr, equations) => |
456 |
Toplevel.proof' (Expression.interpret_cmd expr equations))); |
|
29223 | 457 |
|
15703 | 458 |
|
22299 | 459 |
(* classes *) |
460 |
||
24868 | 461 |
val class_val = |
46922
3717f3878714
source positions for locale and class expressions;
wenzelm
parents:
45837
diff
changeset
|
462 |
Parse_Spec.class_expression -- |
48643 | 463 |
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
|
464 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 465 |
|
24868 | 466 |
val _ = |
48642 | 467 |
Outer_Syntax.command @{command_spec "class"} "define type class" |
48643 | 468 |
(Parse.binding -- Scan.optional (@{keyword "="} |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 469 |
>> (fn ((name, (supclasses, elems)), begin) => |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
470 |
Toplevel.begin_local_theory begin |
57181
2d13bf9ea77b
dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents:
56895
diff
changeset
|
471 |
(Class_Declaration.class_cmd name supclasses elems #> snd))); |
22299 | 472 |
|
24868 | 473 |
val _ = |
48642 | 474 |
Outer_Syntax.local_theory_to_proof @{command_spec "subclass"} "prove a subclass relation" |
57181
2d13bf9ea77b
dropped obscure and unused ad-hoc before_exit hook for named targets
haftmann
parents:
56895
diff
changeset
|
475 |
(Parse.class >> Class_Declaration.subclass_cmd); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
476 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
477 |
val _ = |
48642 | 478 |
Outer_Syntax.command @{command_spec "instantiation"} "instantiate and prove type arity" |
36950 | 479 |
(Parse.multi_arity --| Parse.begin |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
480 |
>> (fn arities => Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
24589 | 481 |
|
25485 | 482 |
val _ = |
48642 | 483 |
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
|
484 |
((Parse.class -- |
48643 | 485 |
((@{keyword "\<subseteq>"} || @{keyword "<"}) |-- Parse.!!! Parse.class) >> Class.classrel_cmd || |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
486 |
Parse.multi_arity >> Class.instance_arity_cmd) >> Toplevel.theory_to_proof || |
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
487 |
Scan.succeed (Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
22299 | 488 |
|
489 |
||
25519 | 490 |
(* arbitrary overloading *) |
491 |
||
492 |
val _ = |
|
48642 | 493 |
Outer_Syntax.command @{command_spec "overloading"} "overloaded definitions" |
48643 | 494 |
(Scan.repeat1 (Parse.name --| (@{keyword "\<equiv>"} || @{keyword "=="}) -- Parse.term -- |
495 |
Scan.optional (@{keyword "("} |-- (@{keyword "unchecked"} >> K false) --| @{keyword ")"}) true |
|
36950 | 496 |
>> Parse.triple1) --| Parse.begin |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
497 |
>> (fn operations => Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
25519 | 498 |
|
499 |
||
22866 | 500 |
(* code generation *) |
501 |
||
24868 | 502 |
val _ = |
48642 | 503 |
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
|
504 |
"define set of code datatype constructors" |
36950 | 505 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 506 |
|
507 |
||
5832 | 508 |
|
509 |
(** proof commands **) |
|
510 |
||
511 |
(* statements *) |
|
512 |
||
53988 | 513 |
fun theorem spec schematic kind = |
48645 | 514 |
Outer_Syntax.local_theory_to_proof' spec |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
515 |
("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
|
516 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
47067
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
517 |
Scan.ahead (Parse_Spec.includes >> K "" || |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
518 |
Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
519 |
Scan.optional Parse_Spec.includes [] -- |
4ef29b0c568f
optional 'includes' element for long theorem statements;
wenzelm
parents:
47066
diff
changeset
|
520 |
Parse_Spec.general_statement >> (fn ((a, includes), (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
521 |
((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
|
522 |
kind NONE (K I) a includes elems concl))); |
5832 | 523 |
|
53988 | 524 |
val _ = theorem @{command_spec "theorem"} false Thm.theoremK; |
525 |
val _ = theorem @{command_spec "lemma"} false Thm.lemmaK; |
|
526 |
val _ = theorem @{command_spec "corollary"} false Thm.corollaryK; |
|
527 |
val _ = theorem @{command_spec "schematic_theorem"} true Thm.theoremK; |
|
528 |
val _ = theorem @{command_spec "schematic_lemma"} true Thm.lemmaK; |
|
529 |
val _ = theorem @{command_spec "schematic_corollary"} true Thm.corollaryK; |
|
5832 | 530 |
|
24868 | 531 |
val _ = |
48642 | 532 |
Outer_Syntax.local_theory_to_proof @{command_spec "notepad"} "begin proof context" |
40960 | 533 |
(Parse.begin >> K Proof.begin_notepad); |
534 |
||
535 |
val _ = |
|
48642 | 536 |
Outer_Syntax.command @{command_spec "have"} "state local goal" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
537 |
(Parse_Spec.statement >> (Toplevel.proof' o Isar_Cmd.have)); |
17353 | 538 |
|
24868 | 539 |
val _ = |
50214 | 540 |
Outer_Syntax.command @{command_spec "hence"} "old-style alias of \"then have\"" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
541 |
(Parse_Spec.statement >> (Toplevel.proof' o Isar_Cmd.hence)); |
17353 | 542 |
|
24868 | 543 |
val _ = |
48642 | 544 |
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
|
545 |
"state local goal, solving current obligation" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
546 |
(Parse_Spec.statement >> (Toplevel.proof' o Isar_Cmd.show)); |
5832 | 547 |
|
24868 | 548 |
val _ = |
50214 | 549 |
Outer_Syntax.command @{command_spec "thus"} "old-style alias of \"then show\"" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
550 |
(Parse_Spec.statement >> (Toplevel.proof' o Isar_Cmd.thus)); |
6501 | 551 |
|
5832 | 552 |
|
5914 | 553 |
(* facts *) |
5832 | 554 |
|
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
555 |
val facts = Parse.and_list1 Parse.xthms1; |
9197 | 556 |
|
24868 | 557 |
val _ = |
48642 | 558 |
Outer_Syntax.command @{command_spec "then"} "forward chaining" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
559 |
(Scan.succeed (Toplevel.proof Proof.chain)); |
5832 | 560 |
|
24868 | 561 |
val _ = |
48642 | 562 |
Outer_Syntax.command @{command_spec "from"} "forward chaining from given facts" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
563 |
(facts >> (Toplevel.proof o Proof.from_thmss_cmd)); |
5914 | 564 |
|
24868 | 565 |
val _ = |
48642 | 566 |
Outer_Syntax.command @{command_spec "with"} "forward chaining from given and current facts" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
567 |
(facts >> (Toplevel.proof o Proof.with_thmss_cmd)); |
6878 | 568 |
|
24868 | 569 |
val _ = |
48642 | 570 |
Outer_Syntax.command @{command_spec "note"} "define facts" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
571 |
(Parse_Spec.name_facts >> (Toplevel.proof o Proof.note_thmss_cmd)); |
5832 | 572 |
|
24868 | 573 |
val _ = |
48642 | 574 |
Outer_Syntax.command @{command_spec "using"} "augment goal facts" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
575 |
(facts >> (Toplevel.proof o Proof.using_cmd)); |
18544 | 576 |
|
24868 | 577 |
val _ = |
48642 | 578 |
Outer_Syntax.command @{command_spec "unfolding"} "unfold definitions in goal and facts" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
579 |
(facts >> (Toplevel.proof o Proof.unfolding_cmd)); |
12926 | 580 |
|
5832 | 581 |
|
582 |
(* proof context *) |
|
583 |
||
24868 | 584 |
val _ = |
48642 | 585 |
Outer_Syntax.command @{command_spec "fix"} "fix local variables (Skolem constants)" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
586 |
(Parse.fixes >> (Toplevel.proof o Proof.fix_cmd)); |
11890 | 587 |
|
24868 | 588 |
val _ = |
48642 | 589 |
Outer_Syntax.command @{command_spec "assume"} "assume propositions" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
590 |
(Parse_Spec.statement >> (Toplevel.proof o Proof.assume_cmd)); |
5832 | 591 |
|
24868 | 592 |
val _ = |
48642 | 593 |
Outer_Syntax.command @{command_spec "presume"} "assume propositions, to be established later" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
594 |
(Parse_Spec.statement >> (Toplevel.proof o Proof.presume_cmd)); |
6850 | 595 |
|
24868 | 596 |
val _ = |
50214 | 597 |
Outer_Syntax.command @{command_spec "def"} "local definition (non-polymorphic)" |
36950 | 598 |
(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
|
599 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 600 |
((Parse.binding -- Parse.opt_mixfix) -- |
48643 | 601 |
((@{keyword "\<equiv>"} || @{keyword "=="}) |-- Parse.!!! Parse.termp))) |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
602 |
>> (Toplevel.proof o Proof.def_cmd)); |
6953 | 603 |
|
24868 | 604 |
val _ = |
48642 | 605 |
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
|
606 |
(Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
607 |
>> (fn ((x, y), z) => Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 608 |
|
24868 | 609 |
val _ = |
48642 | 610 |
Outer_Syntax.command @{command_spec "guess"} "wild guessing (unstructured)" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
611 |
(Scan.optional Parse.fixes [] >> (Toplevel.proof' o Obtain.guess_cmd)); |
17854 | 612 |
|
24868 | 613 |
val _ = |
48642 | 614 |
Outer_Syntax.command @{command_spec "let"} "bind text variables" |
48643 | 615 |
(Parse.and_list1 (Parse.and_list1 Parse.term -- (@{keyword "="} |-- Parse.term)) |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
616 |
>> (Toplevel.proof o Proof.let_bind_cmd)); |
5832 | 617 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
618 |
val _ = |
48642 | 619 |
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
|
620 |
(opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
621 |
>> (fn (mode, args) => Toplevel.proof (Proof.write_cmd mode args))); |
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
622 |
|
24868 | 623 |
val _ = |
48642 | 624 |
Outer_Syntax.command @{command_spec "case"} "invoke local context" |
53377
21693b7c8fbf
more liberal 'case' syntax: allow parentheses without arguments;
wenzelm
parents:
52549
diff
changeset
|
625 |
((@{keyword "("} |-- |
53378
07990ba8c0ea
cases: more position information and PIDE markup;
wenzelm
parents:
53377
diff
changeset
|
626 |
Parse.!!! (Parse.position Parse.xname -- Scan.repeat (Parse.maybe Parse.binding) |
07990ba8c0ea
cases: more position information and PIDE markup;
wenzelm
parents:
53377
diff
changeset
|
627 |
--| @{keyword ")"}) || |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
628 |
Parse.position Parse.xname >> rpair []) -- Parse.opt_attribs >> (fn ((c, xs), atts) => |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
629 |
Toplevel.proof (Proof.invoke_case_cmd (c, xs, atts)))); |
8370 | 630 |
|
5832 | 631 |
|
632 |
(* proof structure *) |
|
633 |
||
24868 | 634 |
val _ = |
48642 | 635 |
Outer_Syntax.command @{command_spec "{"} "begin explicit proof block" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
636 |
(Scan.succeed (Toplevel.proof Proof.begin_block)); |
5832 | 637 |
|
24868 | 638 |
val _ = |
48642 | 639 |
Outer_Syntax.command @{command_spec "}"} "end explicit proof block" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
640 |
(Scan.succeed (Toplevel.proof Proof.end_block)); |
6687 | 641 |
|
24868 | 642 |
val _ = |
48642 | 643 |
Outer_Syntax.command @{command_spec "next"} "enter next proof block" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
644 |
(Scan.succeed (Toplevel.proof Proof.next_block)); |
5832 | 645 |
|
646 |
||
647 |
(* end proof *) |
|
648 |
||
24868 | 649 |
val _ = |
50214 | 650 |
Outer_Syntax.command @{command_spec "qed"} "conclude proof" |
56869 | 651 |
(Scan.option Method.parse >> (fn m => |
652 |
(Option.map Method.report m; |
|
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
653 |
Isar_Cmd.qed m))); |
5832 | 654 |
|
24868 | 655 |
val _ = |
48642 | 656 |
Outer_Syntax.command @{command_spec "by"} "terminal backward proof" |
55795 | 657 |
(Method.parse -- Scan.option Method.parse >> (fn (m1, m2) => |
56869 | 658 |
(Method.report m1; |
659 |
Option.map Method.report m2; |
|
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
660 |
Isar_Cmd.terminal_proof (m1, m2)))); |
6404 | 661 |
|
24868 | 662 |
val _ = |
48642 | 663 |
Outer_Syntax.command @{command_spec ".."} "default proof" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
664 |
(Scan.succeed Isar_Cmd.default_proof); |
8966 | 665 |
|
24868 | 666 |
val _ = |
48642 | 667 |
Outer_Syntax.command @{command_spec "."} "immediate proof" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
668 |
(Scan.succeed Isar_Cmd.immediate_proof); |
6404 | 669 |
|
24868 | 670 |
val _ = |
48642 | 671 |
Outer_Syntax.command @{command_spec "done"} "done proof" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
672 |
(Scan.succeed Isar_Cmd.done_proof); |
5832 | 673 |
|
24868 | 674 |
val _ = |
48642 | 675 |
Outer_Syntax.command @{command_spec "sorry"} "skip proof (quick-and-dirty mode only!)" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
676 |
(Scan.succeed Isar_Cmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
677 |
|
24868 | 678 |
val _ = |
48642 | 679 |
Outer_Syntax.command @{command_spec "oops"} "forget proof" |
58798
49ed5eea15d4
'oops' requires proper goal statement -- exclude 'notepad' to avoid disrupting begin/end structure;
wenzelm
parents:
58201
diff
changeset
|
680 |
(Scan.succeed (Toplevel.forget_proof true)); |
8210 | 681 |
|
5832 | 682 |
|
683 |
(* proof steps *) |
|
684 |
||
24868 | 685 |
val _ = |
48642 | 686 |
Outer_Syntax.command @{command_spec "defer"} "shuffle internal proof state" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
687 |
(Scan.optional Parse.nat 1 >> (Toplevel.proof o Proof.defer)); |
8165 | 688 |
|
24868 | 689 |
val _ = |
48642 | 690 |
Outer_Syntax.command @{command_spec "prefer"} "shuffle internal proof state" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
691 |
(Parse.nat >> (Toplevel.proof o Proof.prefer)); |
8165 | 692 |
|
24868 | 693 |
val _ = |
48642 | 694 |
Outer_Syntax.command @{command_spec "apply"} "initial refinement step (unstructured)" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
695 |
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_results m)))); |
5832 | 696 |
|
24868 | 697 |
val _ = |
50214 | 698 |
Outer_Syntax.command @{command_spec "apply_end"} "terminal refinement step (unstructured)" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
699 |
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_end_results m)))); |
5832 | 700 |
|
24868 | 701 |
val _ = |
50214 | 702 |
Outer_Syntax.command @{command_spec "proof"} "backward proof step" |
55795 | 703 |
(Scan.option Method.parse >> (fn m => |
704 |
(Option.map Method.report m; |
|
705 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof_results m)) o |
|
706 |
Toplevel.skip_proof (fn i => i + 1)))); |
|
5832 | 707 |
|
708 |
||
6742 | 709 |
(* proof navigation *) |
5944 | 710 |
|
56065
600781e03bf6
more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents:
56006
diff
changeset
|
711 |
fun report_back () = |
56333
38f1422ef473
support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
wenzelm
parents:
56304
diff
changeset
|
712 |
Output.report [Markup.markup Markup.bad "Explicit backtracking"]; |
56065
600781e03bf6
more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents:
56006
diff
changeset
|
713 |
|
24868 | 714 |
val _ = |
56065
600781e03bf6
more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents:
56006
diff
changeset
|
715 |
Outer_Syntax.command @{command_spec "back"} "explicit backtracking of proof command" |
56895
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
716 |
(Scan.succeed |
f058120aaad4
discontinued Toplevel.print flag -- print uniformly according to Keyword.is_printed;
wenzelm
parents:
56893
diff
changeset
|
717 |
(Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o |
56065
600781e03bf6
more explicit markup and explanation of the improper status of 'back', following the AFP style-guide;
wenzelm
parents:
56006
diff
changeset
|
718 |
Toplevel.skip_proof (fn h => (report_back (); h)))); |
6742 | 719 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
720 |
|
56869 | 721 |
|
5832 | 722 |
(** diagnostic commands (for interactive mode only) **) |
723 |
||
36950 | 724 |
val opt_modes = |
48643 | 725 |
Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
36950 | 726 |
|
48643 | 727 |
val opt_bang = Scan.optional (@{keyword "!"} >> K true) false; |
8464 | 728 |
|
24868 | 729 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
730 |
Outer_Syntax.command @{command_spec "help"} |
50213 | 731 |
"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
|
732 |
(Scan.repeat Parse.name >> |
58862 | 733 |
(fn pats => Toplevel.imperative (fn () => Outer_Syntax.help_syntax pats))); |
21714 | 734 |
|
24868 | 735 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
736 |
Outer_Syntax.command @{command_spec "print_commands"} "print outer syntax commands" |
58862 | 737 |
(Scan.succeed (Toplevel.imperative Outer_Syntax.print_syntax)); |
5832 | 738 |
|
24868 | 739 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
740 |
Outer_Syntax.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
|
741 |
(Scan.succeed (Toplevel.unknown_context o |
52060 | 742 |
Toplevel.keep (Attrib.print_options o Toplevel.context_of))); |
23989 | 743 |
|
24868 | 744 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
745 |
Outer_Syntax.command @{command_spec "print_context"} |
56893 | 746 |
"print context of local theory target" |
747 |
(Scan.succeed (Toplevel.keep (Pretty.writeln_chunks o Toplevel.pretty_context))); |
|
7308 | 748 |
|
24868 | 749 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
750 |
Outer_Syntax.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
|
751 |
"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
|
752 |
(opt_bang >> (fn b => Toplevel.unknown_theory o |
50737 | 753 |
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_full_theory b o Toplevel.theory_of))); |
5832 | 754 |
|
24868 | 755 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
756 |
Outer_Syntax.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
|
757 |
"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
|
758 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 759 |
Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of))); |
5832 | 760 |
|
24868 | 761 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
762 |
Outer_Syntax.command @{command_spec "print_defn_rules"} |
51585 | 763 |
"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
|
764 |
(Scan.succeed (Toplevel.unknown_context o |
51585 | 765 |
Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of))); |
766 |
||
767 |
val _ = |
|
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
768 |
Outer_Syntax.command @{command_spec "print_abbrevs"} |
51585 | 769 |
"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
|
770 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 771 |
Toplevel.keep (Proof_Context.print_abbrevs o Toplevel.context_of))); |
21726 | 772 |
|
24868 | 773 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
774 |
Outer_Syntax.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
|
775 |
"print theorems of local theory or proof context" |
56868
b5fb264d53ba
clarified print operations for "terms" and "theorems";
wenzelm
parents:
56867
diff
changeset
|
776 |
(opt_bang >> (fn b => |
57605 | 777 |
Toplevel.unknown_context o |
778 |
Toplevel.keep (Pretty.writeln o Pretty.chunks o Isar_Cmd.pretty_theorems b))); |
|
5881 | 779 |
|
24868 | 780 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
781 |
Outer_Syntax.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
|
782 |
"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
|
783 |
(Scan.succeed (Toplevel.unknown_theory o |
50737 | 784 |
Toplevel.keep (Locale.print_locales o Toplevel.theory_of))); |
12061 | 785 |
|
24868 | 786 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
787 |
Outer_Syntax.command @{command_spec "print_classes"} |
48642 | 788 |
"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
|
789 |
(Scan.succeed (Toplevel.unknown_theory o |
42359 | 790 |
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
|
791 |
|
24868 | 792 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
793 |
Outer_Syntax.command @{command_spec "print_locale"} |
48642 | 794 |
"print locale of this theory" |
50737 | 795 |
(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
|
796 |
Toplevel.unknown_theory o |
50737 | 797 |
Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name))); |
12061 | 798 |
|
24868 | 799 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
800 |
Outer_Syntax.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
|
801 |
"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
|
802 |
(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
|
803 |
Toplevel.unknown_context o |
50737 | 804 |
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
|
805 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
806 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
807 |
Outer_Syntax.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
|
808 |
"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
|
809 |
(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
|
810 |
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
|
811 |
Toplevel.keep (fn state => Expression.print_dependencies (Toplevel.context_of state) b expr))); |
41435 | 812 |
|
813 |
val _ = |
|
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
814 |
Outer_Syntax.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
|
815 |
"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
|
816 |
(Scan.succeed (Toplevel.unknown_theory o |
55997
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents:
55828
diff
changeset
|
817 |
Toplevel.keep (Attrib.print_attributes o Toplevel.context_of))); |
5832 | 818 |
|
24868 | 819 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
820 |
Outer_Syntax.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
|
821 |
"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
|
822 |
(Scan.succeed (Toplevel.unknown_context o |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51685
diff
changeset
|
823 |
Toplevel.keep (Pretty.writeln o Simplifier.pretty_simpset o Toplevel.context_of))); |
16027 | 824 |
|
24868 | 825 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
826 |
Outer_Syntax.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
|
827 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 828 |
Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of))); |
12383 | 829 |
|
24868 | 830 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
831 |
Outer_Syntax.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
|
832 |
(Scan.succeed (Toplevel.unknown_theory o |
55742
a989bdaf8121
modernized Method.check_name/check_source (with reports) vs. strict Method.the_method (without interning nor reports), e.g. relevant for semantic completion;
wenzelm
parents:
55385
diff
changeset
|
833 |
Toplevel.keep (Method.print_methods o Toplevel.context_of))); |
5832 | 834 |
|
24868 | 835 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
836 |
Outer_Syntax.command @{command_spec "print_antiquotations"} |
56069
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
837 |
"print document antiquotations" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
51654
diff
changeset
|
838 |
(Scan.succeed (Toplevel.unknown_context o |
50737 | 839 |
Toplevel.keep (Thy_Output.print_antiquotations o Toplevel.context_of))); |
9221 | 840 |
|
24868 | 841 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
842 |
Outer_Syntax.command @{command_spec "print_ML_antiquotations"} |
56069
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
843 |
"print ML antiquotations" |
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
844 |
(Scan.succeed (Toplevel.unknown_context o |
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
845 |
Toplevel.keep (ML_Context.print_antiquotations o Toplevel.context_of))); |
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
846 |
|
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
56065
diff
changeset
|
847 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
848 |
Outer_Syntax.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
|
849 |
(Scan.succeed Isar_Cmd.thy_deps); |
22485 | 850 |
|
24868 | 851 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
852 |
Outer_Syntax.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
|
853 |
(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
|
854 |
|
7b6aaf446496
tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents:
48997
diff
changeset
|
855 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
856 |
Outer_Syntax.command @{command_spec "print_term_bindings"} |
57415
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
57181
diff
changeset
|
857 |
"print term bindings of proof context" |
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
57181
diff
changeset
|
858 |
(Scan.succeed (Toplevel.unknown_context o |
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
57181
diff
changeset
|
859 |
Toplevel.keep |
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
57181
diff
changeset
|
860 |
(Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of))); |
5832 | 861 |
|
24868 | 862 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
863 |
Outer_Syntax.command @{command_spec "print_facts"} "print facts of proof context" |
56158
c2c6d560e7b2
more explicit treatment of verbose mode, which includes concealed entries;
wenzelm
parents:
56155
diff
changeset
|
864 |
(opt_bang >> (fn verbose => Toplevel.unknown_context o |
c2c6d560e7b2
more explicit treatment of verbose mode, which includes concealed entries;
wenzelm
parents:
56155
diff
changeset
|
865 |
Toplevel.keep (fn st => Proof_Context.print_local_facts (Toplevel.context_of st) verbose))); |
5832 | 866 |
|
24868 | 867 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
868 |
Outer_Syntax.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
|
869 |
(Scan.succeed (Toplevel.unknown_context o |
56867 | 870 |
Toplevel.keep (Pretty.writeln_chunks o Proof_Context.pretty_cases o Toplevel.context_of))); |
8370 | 871 |
|
24868 | 872 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
873 |
Outer_Syntax.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
|
874 |
"print theorems as long statements" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
875 |
(opt_modes -- Parse.xthms1 >> Isar_Cmd.print_stmts); |
19269 | 876 |
|
24868 | 877 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
878 |
Outer_Syntax.command @{command_spec "thm"} "print theorems" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
879 |
(opt_modes -- Parse.xthms1 >> Isar_Cmd.print_thms); |
5832 | 880 |
|
24868 | 881 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
882 |
Outer_Syntax.command @{command_spec "prf"} "print proof terms of theorems" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
883 |
(opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs false); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
884 |
|
24868 | 885 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
886 |
Outer_Syntax.command @{command_spec "full_prf"} "print full proof terms of theorems" |
58028
e4250d370657
tuned signature -- define some elementary operations earlier;
wenzelm
parents:
57941
diff
changeset
|
887 |
(opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs true); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
888 |
|
24868 | 889 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
890 |
Outer_Syntax.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
|
891 |
(opt_modes -- Parse.term >> Isar_Cmd.print_prop); |
5832 | 892 |
|
24868 | 893 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
894 |
Outer_Syntax.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
|
895 |
(opt_modes -- Parse.term >> Isar_Cmd.print_term); |
5832 | 896 |
|
24868 | 897 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
898 |
Outer_Syntax.command @{command_spec "typ"} "read and print type" |
48792 | 899 |
(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
|
900 |
>> Isar_Cmd.print_type); |
5832 | 901 |
|
24868 | 902 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
903 |
Outer_Syntax.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
|
904 |
(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
|
905 |
Toplevel.keep (Code.print_codesetup o Toplevel.theory_of))); |
5832 | 906 |
|
52430 | 907 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
908 |
Outer_Syntax.command @{command_spec "print_state"} |
52430 | 909 |
"print current proof state (if present)" |
56887
1ca814da47ae
clarified print_state, which goes back to TTY loop before Proof General, and before separate print_context;
wenzelm
parents:
56869
diff
changeset
|
910 |
(opt_modes >> (fn modes => Toplevel.keep (Print_Mode.with_modes modes Toplevel.print_state))); |
52430 | 911 |
|
24868 | 912 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
913 |
Outer_Syntax.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
|
914 |
(Scan.succeed (Toplevel.imperative (writeln o Session.welcome))); |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
915 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
916 |
val _ = |
58893
9e0ecb66d6a7
eliminated unused int_only flag (see also c12484a27367);
wenzelm
parents:
58875
diff
changeset
|
917 |
Outer_Syntax.command @{command_spec "display_drafts"} |
58846 | 918 |
"display raw source files with symbols" |
919 |
(Scan.repeat1 Parse.path >> (fn names => |
|
920 |
Toplevel.imperative (fn () => ignore (Present.display_drafts (map Path.explode names))))); |
|
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
921 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
922 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
923 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
924 |
(** extraction of programs from proofs **) |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
925 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
926 |
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
927 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
928 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
929 |
Outer_Syntax.command @{command_spec "realizers"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
930 |
"specify realizers for primitive axioms / theorems, together with correctness proof" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
931 |
(Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
932 |
(fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
933 |
(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
|
934 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
935 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
936 |
Outer_Syntax.command @{command_spec "realizability"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
937 |
"add equations characterizing realizability" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
938 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
939 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
940 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
941 |
Outer_Syntax.command @{command_spec "extract_type"} |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
942 |
"add equations characterizing type of extracted program" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
943 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
944 |
|
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
945 |
val _ = |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
946 |
Outer_Syntax.command @{command_spec "extract"} "extract terms from proofs" |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
947 |
(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
|
948 |
Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48645
diff
changeset
|
949 |
|
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
950 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
951 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
952 |
(** end **) |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
953 |
|
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
954 |
val _ = |
48642 | 955 |
Outer_Syntax.command @{command_spec "end"} "end context" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
956 |
(Scan.succeed |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
957 |
(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
|
958 |
Toplevel.end_proof (K Proof.end_notepad))); |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
47416
diff
changeset
|
959 |
|
5832 | 960 |
end; |
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
961 |