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