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