author | wenzelm |
Wed, 21 Jul 2010 16:14:16 +0200 | |
changeset 37873 | 66d90b2b87bc |
parent 37861 | e1f028a8c76a |
child 37949 | 48a874444164 |
permissions | -rw-r--r-- |
5832 | 1 |
(* Title: Pure/Isar/isar_syn.ML |
2 |
Author: Markus Wenzel, TU Muenchen |
|
3 |
||
6353 | 4 |
Isar/Pure outer syntax. |
5832 | 5 |
*) |
6 |
||
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
7 |
structure Isar_Syn: sig end = |
5832 | 8 |
struct |
9 |
||
24868 | 10 |
(** keywords **) |
11 |
||
12 |
(*keep keywords consistent with the parsers, otherwise be prepared for |
|
13 |
unexpected errors*) |
|
14 |
||
36950 | 15 |
val _ = List.app Keyword.keyword |
24868 | 16 |
["!!", "!", "%", "(", ")", "+", ",", "--", ":", "::", ";", "<", "<=", |
17 |
"=", "==", "=>", "?", "[", "\\<equiv>", "\\<leftharpoondown>", |
|
18 |
"\\<rightharpoonup>", "\\<rightleftharpoons>", "\\<subseteq>", "]", |
|
26888 | 19 |
"advanced", "and", "assumes", "attach", "begin", "binder", |
24868 | 20 |
"constrains", "defines", "fixes", "for", "identifier", "if", |
28721 | 21 |
"imports", "in", "infix", "infixl", "infixr", "is", |
33456
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
22 |
"notes", "obtains", "open", "output", "overloaded", "pervasive", |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
23 |
"shows", "structure", "unchecked", "uses", "where", "|"]; |
fbd47f9b9b12
allow "pervasive" local theory declarations, which are applied the background theory;
wenzelm
parents:
33390
diff
changeset
|
24 |
|
24868 | 25 |
|
26 |
||
5832 | 27 |
(** init and exit **) |
28 |
||
24868 | 29 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
30 |
Outer_Syntax.command "theory" "begin theory" (Keyword.tag_theory Keyword.thy_begin) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
31 |
(Thy_Header.args >> (Toplevel.print oo Isar_Cmd.init_theory)); |
5832 | 32 |
|
24868 | 33 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
34 |
Outer_Syntax.command "end" "end (local) theory" (Keyword.tag_theory Keyword.thy_end) |
21004 | 35 |
(Scan.succeed (Toplevel.exit o Toplevel.end_local_theory)); |
6687 | 36 |
|
5832 | 37 |
|
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
|
38 |
|
7749 | 39 |
(** markup commands **) |
5832 | 40 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
41 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "header" "theory header" Keyword.diag |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
42 |
(Parse.doc_source >> Isar_Cmd.header_markup); |
6353 | 43 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
44 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "chapter" "chapter heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
45 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 46 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
47 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "section" "section heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
48 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 49 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
50 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsection" "subsection heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
51 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5958 | 52 |
|
24868 | 53 |
val _ = |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
54 |
Outer_Syntax.markup_command Thy_Output.Markup "subsubsection" "subsubsection heading" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
55 |
Keyword.thy_heading (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
5832 | 56 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
57 |
val _ = Outer_Syntax.markup_command Thy_Output.MarkupEnv "text" "formal comment (theory)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
58 |
Keyword.thy_decl (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 59 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
60 |
val _ = Outer_Syntax.markup_command Thy_Output.Verbatim "text_raw" "raw document preparation text" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
61 |
Keyword.thy_decl (Parse.opt_target -- Parse.doc_source >> Isar_Cmd.local_theory_markup); |
7172 | 62 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
63 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "sect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
64 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 65 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
66 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
67 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 68 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
69 |
val _ = Outer_Syntax.markup_command Thy_Output.Markup "subsubsect" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
70 |
(Keyword.tag_proof Keyword.prf_heading) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 71 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
72 |
val _ = Outer_Syntax.markup_command Thy_Output.MarkupEnv "txt" "formal comment (proof)" |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
73 |
(Keyword.tag_proof Keyword.prf_decl) (Parse.doc_source >> Isar_Cmd.proof_markup); |
7172 | 74 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
75 |
val _ = Outer_Syntax.markup_command Thy_Output.Verbatim "txt_raw" |
36950 | 76 |
"raw document preparation text (proof)" (Keyword.tag_proof Keyword.prf_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
77 |
(Parse.doc_source >> Isar_Cmd.proof_markup); |
7775 | 78 |
|
5832 | 79 |
|
6886 | 80 |
|
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
|
81 |
(** theory commands **) |
6886 | 82 |
|
5832 | 83 |
(* classes and sorts *) |
84 |
||
24868 | 85 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
86 |
Outer_Syntax.command "classes" "declare type classes" Keyword.thy_decl |
36950 | 87 |
(Scan.repeat1 (Parse.binding -- Scan.optional ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |-- |
88 |
Parse.!!! (Parse.list1 Parse.xname)) []) |
|
89 |
>> (Toplevel.theory o fold AxClass.axiomatize_class_cmd)); |
|
5832 | 90 |
|
24868 | 91 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
92 |
Outer_Syntax.command "classrel" "state inclusion of type classes (axiomatic!)" Keyword.thy_decl |
36950 | 93 |
(Parse.and_list1 (Parse.xname -- ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |
94 |
|-- Parse.!!! Parse.xname)) |
|
24932
86ef9a828a9e
AxClass.axiomatize and Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents:
24914
diff
changeset
|
95 |
>> (Toplevel.theory o AxClass.axiomatize_classrel_cmd)); |
5832 | 96 |
|
24868 | 97 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
98 |
Outer_Syntax.local_theory "default_sort" "declare default sort for explicit type variables" |
36950 | 99 |
Keyword.thy_decl |
100 |
(Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy)); |
|
5832 | 101 |
|
102 |
||
103 |
(* types *) |
|
104 |
||
24868 | 105 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
106 |
Outer_Syntax.local_theory "typedecl" "type declaration" Keyword.thy_decl |
36950 | 107 |
(Parse.type_args -- Parse.binding -- Parse.opt_mixfix |
35835 | 108 |
>> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd)); |
5832 | 109 |
|
24868 | 110 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
111 |
Outer_Syntax.local_theory "types" "declare type abbreviations" Keyword.thy_decl |
6727 | 112 |
(Scan.repeat1 |
36950 | 113 |
(Parse.type_args -- Parse.binding -- |
114 |
(Parse.$$$ "=" |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))) |
|
36178
0e5c133b48b6
keep localized 'types' as regular non-old-style version -- 'type_abbrev' as 'type' just causes too many problems, e.g. clash with "type" in translations or "type:" argument syntax;
wenzelm
parents:
36176
diff
changeset
|
115 |
>> (fold (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs))); |
5832 | 116 |
|
24868 | 117 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
118 |
Outer_Syntax.command "nonterminals" "declare types treated as grammar nonterminal symbols" |
36950 | 119 |
Keyword.thy_decl (Scan.repeat1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals)); |
5832 | 120 |
|
24868 | 121 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
122 |
Outer_Syntax.command "arities" "state type arities (axiomatic!)" Keyword.thy_decl |
36950 | 123 |
(Scan.repeat1 Parse.arity >> (Toplevel.theory o fold AxClass.axiomatize_arity_cmd)); |
5832 | 124 |
|
125 |
||
126 |
(* consts and syntax *) |
|
127 |
||
24868 | 128 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
129 |
Outer_Syntax.command "judgment" "declare object-logic judgment" Keyword.thy_decl |
36950 | 130 |
(Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
8227 | 131 |
|
24868 | 132 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
133 |
Outer_Syntax.command "consts" "declare constants" Keyword.thy_decl |
36950 | 134 |
(Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts)); |
5832 | 135 |
|
36950 | 136 |
val opt_overloaded = Parse.opt_keyword "overloaded"; |
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
13802
diff
changeset
|
137 |
|
24868 | 138 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
139 |
Outer_Syntax.command "finalconsts" "declare constants as final" Keyword.thy_decl |
36950 | 140 |
(opt_overloaded -- Scan.repeat1 Parse.term >> (uncurry (Toplevel.theory oo Theory.add_finals))); |
9731 | 141 |
|
12142 | 142 |
val mode_spec = |
36950 | 143 |
(Parse.$$$ "output" >> K ("", false)) || |
144 |
Parse.name -- Scan.optional (Parse.$$$ "output" >> K false) true; |
|
9731 | 145 |
|
14900 | 146 |
val opt_mode = |
36950 | 147 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! (mode_spec --| Parse.$$$ ")")) Syntax.mode_default; |
5832 | 148 |
|
24868 | 149 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
150 |
Outer_Syntax.command "syntax" "declare syntactic constants" Keyword.thy_decl |
36950 | 151 |
(opt_mode -- Scan.repeat1 Parse.const >> (Toplevel.theory o uncurry Sign.add_modesyntax)); |
5832 | 152 |
|
24868 | 153 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
154 |
Outer_Syntax.command "no_syntax" "delete syntax declarations" Keyword.thy_decl |
36950 | 155 |
(opt_mode -- Scan.repeat1 Parse.const >> (Toplevel.theory o uncurry Sign.del_modesyntax)); |
15748 | 156 |
|
5832 | 157 |
|
158 |
(* translations *) |
|
159 |
||
160 |
val trans_pat = |
|
36950 | 161 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Parse.xname --| Parse.$$$ ")")) "logic" |
162 |
-- Parse.string; |
|
5832 | 163 |
|
164 |
fun trans_arrow toks = |
|
36950 | 165 |
((Parse.$$$ "\\<rightharpoonup>" || Parse.$$$ "=>") >> K Syntax.ParseRule || |
166 |
(Parse.$$$ "\\<leftharpoondown>" || Parse.$$$ "<=") >> K Syntax.PrintRule || |
|
167 |
(Parse.$$$ "\\<rightleftharpoons>" || Parse.$$$ "==") >> K Syntax.ParsePrintRule) toks; |
|
5832 | 168 |
|
169 |
val trans_line = |
|
36950 | 170 |
trans_pat -- Parse.!!! (trans_arrow -- trans_pat) |
5832 | 171 |
>> (fn (left, (arr, right)) => arr (left, right)); |
172 |
||
24868 | 173 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
174 |
Outer_Syntax.command "translations" "declare syntax translation rules" Keyword.thy_decl |
22796 | 175 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.add_trrules)); |
5832 | 176 |
|
24868 | 177 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
178 |
Outer_Syntax.command "no_translations" "remove syntax translation rules" Keyword.thy_decl |
22796 | 179 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Sign.del_trrules)); |
19260 | 180 |
|
5832 | 181 |
|
182 |
(* axioms and definitions *) |
|
183 |
||
24868 | 184 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
185 |
Outer_Syntax.command "axioms" "state arbitrary propositions (axiomatic!)" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
186 |
(Scan.repeat1 Parse_Spec.spec >> |
37861 | 187 |
(fn spec => Toplevel.theory (fn thy => |
188 |
(legacy_feature "Old 'axioms' command -- use 'axiomatization' instead"; |
|
189 |
Isar_Cmd.add_axioms spec thy)))); |
|
5832 | 190 |
|
19631 | 191 |
val opt_unchecked_overloaded = |
36950 | 192 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! |
193 |
(((Parse.$$$ "unchecked" >> K true) -- Scan.optional (Parse.$$$ "overloaded" >> K true) false || |
|
194 |
Parse.$$$ "overloaded" >> K (false, true)) --| Parse.$$$ ")")) (false, false); |
|
19631 | 195 |
|
24868 | 196 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
197 |
Outer_Syntax.command "defs" "define constants" Keyword.thy_decl |
35852
4e3fe0b8687b
minor renovation of old-style 'axioms' -- make it an alias of iterated 'axiomatization';
wenzelm
parents:
35835
diff
changeset
|
198 |
(opt_unchecked_overloaded -- |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
199 |
Scan.repeat1 (Parse_Spec.thm_name ":" -- Parse.prop >> (fn ((x, y), z) => ((x, z), y))) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
200 |
>> (Toplevel.theory o Isar_Cmd.add_defs)); |
6370 | 201 |
|
14642 | 202 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
203 |
(* old constdefs *) |
14642 | 204 |
|
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
205 |
val old_constdecl = |
36950 | 206 |
Parse.binding --| Parse.where_ >> (fn x => (x, NONE, NoSyn)) || |
207 |
Parse.binding -- (Parse.$$$ "::" |-- Parse.!!! Parse.typ >> SOME) -- Parse.opt_mixfix' |
|
208 |
--| Scan.option Parse.where_ >> Parse.triple1 || |
|
209 |
Parse.binding -- (Parse.mixfix >> pair NONE) --| Scan.option Parse.where_ >> Parse.triple2; |
|
19076 | 210 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
211 |
val old_constdef = Scan.option old_constdecl -- (Parse_Spec.opt_thm_name ":" -- Parse.prop); |
14642 | 212 |
|
19076 | 213 |
val structs = |
36950 | 214 |
Scan.optional ((Parse.$$$ "(" -- Parse.$$$ "structure") |
215 |
|-- Parse.!!! (Parse.simple_fixes --| Parse.$$$ ")")) []; |
|
19076 | 216 |
|
24868 | 217 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
218 |
Outer_Syntax.command "constdefs" "old-style constant definition" Keyword.thy_decl |
21601
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
219 |
(structs -- Scan.repeat1 old_constdef >> (Toplevel.theory o Constdefs.add_constdefs)); |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
220 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
221 |
|
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
222 |
(* constant definitions and abbreviations *) |
6588b947d631
simplified syntax for 'definition', 'abbreviation';
wenzelm
parents:
21527
diff
changeset
|
223 |
|
24868 | 224 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
225 |
Outer_Syntax.local_theory "definition" "constant definition" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
226 |
(Parse_Spec.constdef >> (fn args => #2 o Specification.definition_cmd args)); |
18780 | 227 |
|
24868 | 228 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
229 |
Outer_Syntax.local_theory "abbreviation" "constant abbreviation" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
230 |
(opt_mode -- (Scan.option Parse_Spec.constdecl -- Parse.prop) |
36950 | 231 |
>> (fn (mode, args) => Specification.abbreviation_cmd mode args)); |
19659 | 232 |
|
24868 | 233 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
234 |
Outer_Syntax.local_theory "type_notation" "add concrete syntax for type constructors" |
36950 | 235 |
Keyword.thy_decl |
236 |
(opt_mode -- Parse.and_list1 (Parse.xname -- Parse.mixfix) |
|
237 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
|
35413 | 238 |
|
239 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
240 |
Outer_Syntax.local_theory "no_type_notation" "delete concrete syntax for type constructors" |
36950 | 241 |
Keyword.thy_decl |
242 |
(opt_mode -- Parse.and_list1 (Parse.xname -- Parse.mixfix) |
|
243 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
|
35413 | 244 |
|
245 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
246 |
Outer_Syntax.local_theory "notation" "add concrete syntax for constants / fixed variables" |
36950 | 247 |
Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
248 |
(opt_mode -- Parse.and_list1 (Parse.xname -- Parse_Spec.locale_mixfix) |
36950 | 249 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
24950 | 250 |
|
251 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
252 |
Outer_Syntax.local_theory "no_notation" "delete concrete syntax for constants / fixed variables" |
36950 | 253 |
Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
254 |
(opt_mode -- Parse.and_list1 (Parse.xname -- Parse_Spec.locale_mixfix) |
36950 | 255 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
19076 | 256 |
|
5832 | 257 |
|
18616 | 258 |
(* constant specifications *) |
259 |
||
24868 | 260 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
261 |
Outer_Syntax.command "axiomatization" "axiomatic constant specification" Keyword.thy_decl |
36950 | 262 |
(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
|
263 |
Scan.optional (Parse.where_ |-- Parse.!!! (Parse.and_list1 Parse_Spec.specs)) [] |
36950 | 264 |
>> (fn (x, y) => Toplevel.theory (#2 o Specification.axiomatization_cmd x y))); |
18616 | 265 |
|
266 |
||
5914 | 267 |
(* theorems *) |
268 |
||
26988
742e26213212
more uniform treatment of OuterSyntax.local_theory commands;
wenzelm
parents:
26888
diff
changeset
|
269 |
fun theorems kind = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
270 |
Parse_Spec.name_facts >> (fn args => #2 o Specification.theorems_cmd kind args); |
12712 | 271 |
|
24868 | 272 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
273 |
Outer_Syntax.local_theory "theorems" "define theorems" Keyword.thy_decl (theorems Thm.theoremK); |
5914 | 274 |
|
24868 | 275 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
276 |
Outer_Syntax.local_theory "lemmas" "define lemmas" Keyword.thy_decl (theorems Thm.lemmaK); |
5914 | 277 |
|
24868 | 278 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
279 |
Outer_Syntax.local_theory "declare" "declare theorems" Keyword.thy_decl |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
280 |
(Parse.and_list1 Parse_Spec.xthms1 |
28965 | 281 |
>> (fn args => #2 o Specification.theorems_cmd "" [(Attrib.empty_binding, flat args)])); |
9589 | 282 |
|
5914 | 283 |
|
5832 | 284 |
(* name space entry path *) |
285 |
||
24868 | 286 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
287 |
Outer_Syntax.command "global" "disable prefixing of theory name" Keyword.thy_decl |
16447 | 288 |
(Scan.succeed (Toplevel.theory Sign.root_path)); |
5832 | 289 |
|
24868 | 290 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
291 |
Outer_Syntax.command "local" "enable prefixing of theory name" Keyword.thy_decl |
16447 | 292 |
(Scan.succeed (Toplevel.theory Sign.local_path)); |
8723 | 293 |
|
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
|
294 |
fun hide_names name hide what = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
295 |
Outer_Syntax.command name ("hide " ^ what ^ " from name space") Keyword.thy_decl |
36950 | 296 |
((Parse.opt_keyword "open" >> not) -- Scan.repeat1 Parse.xname >> |
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
297 |
(Toplevel.theory o uncurry hide)); |
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36174
diff
changeset
|
298 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
299 |
val _ = hide_names "hide_class" Isar_Cmd.hide_class "classes"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
300 |
val _ = hide_names "hide_type" Isar_Cmd.hide_type "types"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
301 |
val _ = hide_names "hide_const" Isar_Cmd.hide_const "constants"; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
302 |
val _ = hide_names "hide_fact" Isar_Cmd.hide_fact "facts"; |
5832 | 303 |
|
304 |
||
305 |
(* use ML text *) |
|
306 |
||
30703 | 307 |
fun propagate_env (context as Context.Proof lthy) = |
33671 | 308 |
Context.Proof (Local_Theory.map_contexts (ML_Env.inherit context) lthy) |
30703 | 309 |
| propagate_env context = context; |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
310 |
|
30703 | 311 |
fun propagate_env_prf prf = Proof.map_contexts |
31327 | 312 |
(Context.proof_map (ML_Env.inherit (Context.Proof (Proof.context_of prf)))) prf; |
5832 | 313 |
|
24868 | 314 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
315 |
Outer_Syntax.command "use" "ML text from file" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 316 |
(Parse.path >> |
37873
66d90b2b87bc
eliminated old time_use/time_use_thy variants -- timing is implicitly controlled via Output.timing;
wenzelm
parents:
37861
diff
changeset
|
317 |
(fn path => Toplevel.generic_theory (Thy_Info.exec_file path #> propagate_env))); |
7891 | 318 |
|
24868 | 319 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
320 |
Outer_Syntax.command "ML" "ML text within theory or local theory" |
36950 | 321 |
(Keyword.tag_ml Keyword.thy_decl) |
322 |
(Parse.ML_source >> (fn (txt, pos) => |
|
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
323 |
Toplevel.generic_theory |
37198
3af985b10550
replaced ML_Lex.read_antiq by more concise ML_Lex.read, which includes full read/report with explicit position information;
wenzelm
parents:
36953
diff
changeset
|
324 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt) #> propagate_env))); |
30579
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
325 |
|
4169ddbfe1f9
command 'use', 'ML': apply ML environment to theory and target as well;
wenzelm
parents:
30576
diff
changeset
|
326 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
327 |
Outer_Syntax.command "ML_prf" "ML text within proof" (Keyword.tag_proof Keyword.prf_decl) |
36950 | 328 |
(Parse.ML_source >> (fn (txt, pos) => |
28269 | 329 |
Toplevel.proof (Proof.map_context (Context.proof_map |
37198
3af985b10550
replaced ML_Lex.read_antiq by more concise ML_Lex.read, which includes full read/report with explicit position information;
wenzelm
parents:
36953
diff
changeset
|
330 |
(ML_Context.exec (fn () => ML_Context.eval_text true pos txt))) #> propagate_env_prf))); |
28269 | 331 |
|
332 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
333 |
Outer_Syntax.command "ML_val" "diagnostic ML text" (Keyword.tag_ml Keyword.diag) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
334 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
26396 | 335 |
|
336 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
337 |
Outer_Syntax.command "ML_command" "diagnostic ML text (silent)" (Keyword.tag_ml Keyword.diag) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
338 |
(Parse.ML_source >> (Toplevel.no_timing oo Isar_Cmd.ml_diag false)); |
5832 | 339 |
|
24868 | 340 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
341 |
Outer_Syntax.command "setup" "ML theory setup" (Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
342 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.global_setup)); |
30461 | 343 |
|
344 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
345 |
Outer_Syntax.local_theory "local_setup" "ML local theory setup" (Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
346 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
5832 | 347 |
|
24868 | 348 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
349 |
Outer_Syntax.command "attribute_setup" "define attribute in ML" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 350 |
(Parse.position Parse.name -- Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Parse.text) |
351 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Attrib.attribute_setup name txt cmt))); |
|
30526 | 352 |
|
353 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
354 |
Outer_Syntax.command "method_setup" "define proof method in ML" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 355 |
(Parse.position Parse.name -- Parse.!!! (Parse.$$$ "=" |-- Parse.ML_source -- Parse.text) |
356 |
>> (fn (name, (txt, cmt)) => Toplevel.theory (Method.method_setup name txt cmt))); |
|
9197 | 357 |
|
24868 | 358 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
359 |
Outer_Syntax.local_theory "declaration" "generic ML declaration" (Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
360 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source >> uncurry Isar_Cmd.declaration); |
22088 | 361 |
|
24868 | 362 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
363 |
Outer_Syntax.local_theory "simproc_setup" "define simproc in ML" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 364 |
(Parse.name -- |
365 |
(Parse.$$$ "(" |-- Parse.enum1 "|" Parse.term --| Parse.$$$ ")" --| Parse.$$$ "=") -- |
|
366 |
Parse.ML_source -- Scan.optional (Parse.$$$ "identifier" |-- Scan.repeat1 Parse.xname) [] |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
367 |
>> (fn (((a, b), c), d) => Isar_Cmd.simproc_setup a b c d)); |
22202 | 368 |
|
5832 | 369 |
|
370 |
(* translation functions *) |
|
371 |
||
36950 | 372 |
val trfun = Parse.opt_keyword "advanced" -- Parse.ML_source; |
14642 | 373 |
|
24868 | 374 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
375 |
Outer_Syntax.command "parse_ast_translation" "install parse ast translation functions" |
36950 | 376 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
377 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
5832 | 378 |
|
24868 | 379 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
380 |
Outer_Syntax.command "parse_translation" "install parse translation functions" |
36950 | 381 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
382 |
(trfun >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
5832 | 383 |
|
24868 | 384 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
385 |
Outer_Syntax.command "print_translation" "install print translation functions" |
36950 | 386 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
387 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_translation)); |
5832 | 388 |
|
24868 | 389 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
390 |
Outer_Syntax.command "typed_print_translation" "install typed print translation functions" |
36950 | 391 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
392 |
(trfun >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
5832 | 393 |
|
24868 | 394 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
395 |
Outer_Syntax.command "print_ast_translation" "install print ast translation functions" |
36950 | 396 |
(Keyword.tag_ml Keyword.thy_decl) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
397 |
(trfun >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
5832 | 398 |
|
399 |
||
400 |
(* oracles *) |
|
401 |
||
24868 | 402 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
403 |
Outer_Syntax.command "oracle" "declare oracle" (Keyword.tag_ml Keyword.thy_decl) |
36950 | 404 |
(Parse.position Parse.name -- (Parse.$$$ "=" |-- Parse.ML_source) >> |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
405 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
5832 | 406 |
|
407 |
||
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
408 |
(* local theories *) |
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
409 |
|
24868 | 410 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
411 |
Outer_Syntax.command "context" "enter local theory context" Keyword.thy_decl |
36950 | 412 |
(Parse.name --| Parse.begin >> (fn name => |
35205 | 413 |
Toplevel.print o Toplevel.begin_local_theory true (Theory_Target.context_cmd name))); |
21306
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
414 |
|
7ab6e95e6b0b
turned 'context' into plain thy_decl, discontinued thy_switch;
wenzelm
parents:
21269
diff
changeset
|
415 |
|
12061 | 416 |
(* locales *) |
417 |
||
12758 | 418 |
val locale_val = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
419 |
Parse_Spec.locale_expression false -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
420 |
Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
421 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
12061 | 422 |
|
24868 | 423 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
424 |
Outer_Syntax.command "locale" "define named proof context" Keyword.thy_decl |
36950 | 425 |
(Parse.binding -- |
426 |
Scan.optional (Parse.$$$ "=" |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
|
27681 | 427 |
>> (fn ((name, (expr, elems)), begin) => |
21843 | 428 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
30344
10a67c5ddddb
more uniform handling of binding in targets and derived elements;
wenzelm
parents:
30334
diff
changeset
|
429 |
(Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
28084
diff
changeset
|
430 |
|
24868 | 431 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
432 |
Outer_Syntax.command "sublocale" |
36950 | 433 |
"prove sublocale relation between a locale and a locale expression" Keyword.thy_goal |
434 |
(Parse.xname --| (Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") -- |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
435 |
Parse.!!! (Parse_Spec.locale_expression false) |
28895 | 436 |
>> (fn (loc, expr) => |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
437 |
Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr))); |
28895 | 438 |
|
439 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
440 |
Outer_Syntax.command "interpretation" |
36950 | 441 |
"prove interpretation of locale expression in theory" Keyword.thy_goal |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
442 |
(Parse.!!! (Parse_Spec.locale_expression true) -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
443 |
Scan.optional (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [] |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
444 |
>> (fn (expr, equations) => Toplevel.print o |
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
445 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
29223 | 446 |
|
447 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
448 |
Outer_Syntax.command "interpret" |
29223 | 449 |
"prove interpretation of locale expression in proof context" |
36950 | 450 |
(Keyword.tag_proof Keyword.prf_goal) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
451 |
(Parse.!!! (Parse_Spec.locale_expression true) |
30727
519f8f0fcbf3
interpretation/interpret: prefixes within locale expression are mandatory by default;
wenzelm
parents:
30703
diff
changeset
|
452 |
>> (fn expr => Toplevel.print o Toplevel.proof' (Expression.interpret_cmd expr))); |
29223 | 453 |
|
15703 | 454 |
|
22299 | 455 |
(* classes *) |
456 |
||
24868 | 457 |
val class_val = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
458 |
Parse_Spec.class_expr -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
459 |
Scan.optional (Parse.$$$ "+" |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
460 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
22299 | 461 |
|
24868 | 462 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
463 |
Outer_Syntax.command "class" "define type class" Keyword.thy_decl |
36950 | 464 |
(Parse.binding -- Scan.optional (Parse.$$$ "=" |-- class_val) ([], []) -- Parse.opt_begin |
26516 | 465 |
>> (fn ((name, (supclasses, elems)), begin) => |
24938 | 466 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
29378 | 467 |
(Class.class_cmd name supclasses elems #> snd))); |
22299 | 468 |
|
24868 | 469 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
470 |
Outer_Syntax.local_theory_to_proof "subclass" "prove a subclass relation" Keyword.thy_goal |
36950 | 471 |
(Parse.xname >> Class.subclass_cmd); |
24914
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
472 |
|
95cda5dd58d5
added proper subclass concept; improved class target
haftmann
parents:
24871
diff
changeset
|
473 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
474 |
Outer_Syntax.command "instantiation" "instantiate and prove type arity" Keyword.thy_decl |
36950 | 475 |
(Parse.multi_arity --| Parse.begin |
25462 | 476 |
>> (fn arities => Toplevel.print o |
33553 | 477 |
Toplevel.begin_local_theory true (Theory_Target.instantiation_cmd arities))); |
24589 | 478 |
|
25485 | 479 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
480 |
Outer_Syntax.command "instance" "prove type arity or subclass relation" Keyword.thy_goal |
36950 | 481 |
((Parse.xname -- ((Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") |-- Parse.!!! Parse.xname) |
482 |
>> Class.classrel_cmd || |
|
483 |
Parse.multi_arity >> Class.instance_arity_cmd) |
|
484 |
>> (Toplevel.print oo Toplevel.theory_to_proof) || |
|
485 |
Scan.succeed |
|
486 |
(Toplevel.print o Toplevel.local_theory_to_proof NONE (Class.instantiation_instance I))); |
|
22299 | 487 |
|
488 |
||
25519 | 489 |
(* arbitrary overloading *) |
490 |
||
491 |
val _ = |
|
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
492 |
Outer_Syntax.command "overloading" "overloaded definitions" Keyword.thy_decl |
36950 | 493 |
(Scan.repeat1 (Parse.name --| (Parse.$$$ "\\<equiv>" || Parse.$$$ "==") -- Parse.term -- |
494 |
Scan.optional (Parse.$$$ "(" |-- (Parse.$$$ "unchecked" >> K false) --| Parse.$$$ ")") true |
|
495 |
>> Parse.triple1) --| Parse.begin |
|
25519 | 496 |
>> (fn operations => Toplevel.print o |
33553 | 497 |
Toplevel.begin_local_theory true (Theory_Target.overloading_cmd operations))); |
25519 | 498 |
|
499 |
||
22866 | 500 |
(* code generation *) |
501 |
||
24868 | 502 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
503 |
Outer_Syntax.command "code_datatype" "define set of code datatype constructors" Keyword.thy_decl |
36950 | 504 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.add_datatype_cmd)); |
22866 | 505 |
|
506 |
||
5832 | 507 |
|
508 |
(** proof commands **) |
|
509 |
||
510 |
(* statements *) |
|
511 |
||
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
512 |
fun gen_theorem schematic kind = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
513 |
Outer_Syntax.local_theory_to_proof' |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
514 |
(if schematic then "schematic_" ^ kind else kind) |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
515 |
("state " ^ (if schematic then "schematic " ^ kind else kind)) |
36950 | 516 |
(if schematic then Keyword.thy_schematic_goal else Keyword.thy_goal) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
517 |
(Scan.optional (Parse_Spec.opt_thm_name ":" --| |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
518 |
Scan.ahead (Parse_Spec.locale_keyword || Parse_Spec.statement_keyword)) Attrib.empty_binding -- |
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
519 |
Parse_Spec.general_statement >> (fn (a, (elems, concl)) => |
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
520 |
((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd) |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
521 |
kind NONE (K I) a elems concl))); |
5832 | 522 |
|
36317
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
523 |
val _ = gen_theorem false Thm.theoremK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
524 |
val _ = gen_theorem false Thm.lemmaK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
525 |
val _ = gen_theorem false Thm.corollaryK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
526 |
val _ = gen_theorem true Thm.theoremK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
527 |
val _ = gen_theorem true Thm.lemmaK; |
506d732cb522
explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents:
36178
diff
changeset
|
528 |
val _ = gen_theorem true Thm.corollaryK; |
5832 | 529 |
|
24868 | 530 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
531 |
Outer_Syntax.local_theory_to_proof "example_proof" |
36950 | 532 |
"example proof body, without any result" Keyword.thy_schematic_goal |
36356
5ab0f8859f9f
command 'example_proof' opens an empty proof body;
wenzelm
parents:
36323
diff
changeset
|
533 |
(Scan.succeed |
5ab0f8859f9f
command 'example_proof' opens an empty proof body;
wenzelm
parents:
36323
diff
changeset
|
534 |
(Specification.schematic_theorem_cmd "" NONE (K I) |
5ab0f8859f9f
command 'example_proof' opens an empty proof body;
wenzelm
parents:
36323
diff
changeset
|
535 |
Attrib.empty_binding [] (Element.Shows []) false #> Proof.enter_forward)); |
5ab0f8859f9f
command 'example_proof' opens an empty proof body;
wenzelm
parents:
36323
diff
changeset
|
536 |
|
5ab0f8859f9f
command 'example_proof' opens an empty proof body;
wenzelm
parents:
36323
diff
changeset
|
537 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
538 |
Outer_Syntax.command "have" "state local goal" |
36950 | 539 |
(Keyword.tag_proof Keyword.prf_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
540 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.have)); |
17353 | 541 |
|
24868 | 542 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
543 |
Outer_Syntax.command "hence" "abbreviates \"then have\"" |
36950 | 544 |
(Keyword.tag_proof Keyword.prf_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
545 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.hence)); |
17353 | 546 |
|
24868 | 547 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
548 |
Outer_Syntax.command "show" "state local goal, solving current obligation" |
36950 | 549 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
550 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.show)); |
5832 | 551 |
|
24868 | 552 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
553 |
Outer_Syntax.command "thus" "abbreviates \"then show\"" |
36950 | 554 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
555 |
(Parse_Spec.statement >> ((Toplevel.print oo Toplevel.proof') o Isar_Cmd.thus)); |
6501 | 556 |
|
5832 | 557 |
|
5914 | 558 |
(* facts *) |
5832 | 559 |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
560 |
val facts = Parse.and_list1 Parse_Spec.xthms1; |
9197 | 561 |
|
24868 | 562 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
563 |
Outer_Syntax.command "then" "forward chaining" |
36950 | 564 |
(Keyword.tag_proof Keyword.prf_chain) |
17900 | 565 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.chain)); |
5832 | 566 |
|
24868 | 567 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
568 |
Outer_Syntax.command "from" "forward chaining from given facts" |
36950 | 569 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
570 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.from_thmss_cmd))); |
5914 | 571 |
|
24868 | 572 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
573 |
Outer_Syntax.command "with" "forward chaining from given and current facts" |
36950 | 574 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
575 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.with_thmss_cmd))); |
6878 | 576 |
|
24868 | 577 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
578 |
Outer_Syntax.command "note" "define facts" |
36950 | 579 |
(Keyword.tag_proof Keyword.prf_decl) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
580 |
(Parse_Spec.name_facts >> (Toplevel.print oo (Toplevel.proof o Proof.note_thmss_cmd))); |
5832 | 581 |
|
24868 | 582 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
583 |
Outer_Syntax.command "using" "augment goal facts" |
36950 | 584 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
585 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.using_cmd))); |
18544 | 586 |
|
24868 | 587 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
588 |
Outer_Syntax.command "unfolding" "unfold definitions in goal and facts" |
36950 | 589 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
590 |
(facts >> (Toplevel.print oo (Toplevel.proof o Proof.unfolding_cmd))); |
12926 | 591 |
|
5832 | 592 |
|
593 |
(* proof context *) |
|
594 |
||
24868 | 595 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
596 |
Outer_Syntax.command "fix" "fix local variables (Skolem constants)" |
36950 | 597 |
(Keyword.tag_proof Keyword.prf_asm) |
598 |
(Parse.fixes >> (Toplevel.print oo (Toplevel.proof o Proof.fix_cmd))); |
|
11890 | 599 |
|
24868 | 600 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
601 |
Outer_Syntax.command "assume" "assume propositions" |
36950 | 602 |
(Keyword.tag_proof Keyword.prf_asm) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
603 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.assume_cmd))); |
5832 | 604 |
|
24868 | 605 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
606 |
Outer_Syntax.command "presume" "assume propositions, to be established later" |
36950 | 607 |
(Keyword.tag_proof Keyword.prf_asm) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
608 |
(Parse_Spec.statement >> (Toplevel.print oo (Toplevel.proof o Proof.presume_cmd))); |
6850 | 609 |
|
24868 | 610 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
611 |
Outer_Syntax.command "def" "local definition" |
36950 | 612 |
(Keyword.tag_proof Keyword.prf_asm) |
613 |
(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
|
614 |
(Parse_Spec.opt_thm_name ":" -- |
36950 | 615 |
((Parse.binding -- Parse.opt_mixfix) -- |
616 |
((Parse.$$$ "\\<equiv>" || Parse.$$$ "==") |-- Parse.!!! Parse.termp))) |
|
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
617 |
>> (Toplevel.print oo (Toplevel.proof o Proof.def_cmd))); |
6953 | 618 |
|
24868 | 619 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
620 |
Outer_Syntax.command "obtain" "generalized existence" |
36950 | 621 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
622 |
(Parse.parname -- Scan.optional (Parse.fixes --| Parse.where_) [] -- Parse_Spec.statement |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
623 |
>> (fn ((x, y), z) => Toplevel.print o Toplevel.proof' (Obtain.obtain_cmd x y z))); |
5832 | 624 |
|
24868 | 625 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
626 |
Outer_Syntax.command "guess" "wild guessing (unstructured)" |
36950 | 627 |
(Keyword.tag_proof Keyword.prf_asm_goal) |
628 |
(Scan.optional Parse.fixes [] >> (Toplevel.print oo (Toplevel.proof' o Obtain.guess_cmd))); |
|
17854 | 629 |
|
24868 | 630 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
631 |
Outer_Syntax.command "let" "bind text variables" |
36950 | 632 |
(Keyword.tag_proof Keyword.prf_decl) |
633 |
(Parse.and_list1 (Parse.and_list1 Parse.term -- (Parse.$$$ "=" |-- Parse.term)) |
|
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
634 |
>> (Toplevel.print oo (Toplevel.proof o Proof.let_bind_cmd))); |
5832 | 635 |
|
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
636 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
637 |
Outer_Syntax.command "write" "add concrete syntax for constants / fixed variables" |
36950 | 638 |
(Keyword.tag_proof Keyword.prf_decl) |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
639 |
(opt_mode -- Parse.and_list1 (Parse.xname -- Parse_Spec.locale_mixfix) |
36505
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
640 |
>> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args))); |
79c1d2bbe5a9
ProofContext.read_const: allow for type constraint (for fixed variable);
wenzelm
parents:
36452
diff
changeset
|
641 |
|
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
642 |
val case_spec = |
36950 | 643 |
(Parse.$$$ "(" |-- |
644 |
Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.name) --| Parse.$$$ ")") || |
|
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
645 |
Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1; |
11793
5f0ab6f5c280
support impromptu terminology of cases parameters;
wenzelm
parents:
11742
diff
changeset
|
646 |
|
24868 | 647 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
648 |
Outer_Syntax.command "case" "invoke local context" |
36950 | 649 |
(Keyword.tag_proof Keyword.prf_asm) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
650 |
(case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd))); |
8370 | 651 |
|
5832 | 652 |
|
653 |
(* proof structure *) |
|
654 |
||
24868 | 655 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
656 |
Outer_Syntax.command "{" "begin explicit proof block" |
36950 | 657 |
(Keyword.tag_proof Keyword.prf_open) |
17900 | 658 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.begin_block)); |
5832 | 659 |
|
24868 | 660 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
661 |
Outer_Syntax.command "}" "end explicit proof block" |
36950 | 662 |
(Keyword.tag_proof Keyword.prf_close) |
20305 | 663 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.end_block)); |
6687 | 664 |
|
24868 | 665 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
666 |
Outer_Syntax.command "next" "enter next proof block" |
36950 | 667 |
(Keyword.tag_proof Keyword.prf_block) |
17900 | 668 |
(Scan.succeed (Toplevel.print o Toplevel.proof Proof.next_block)); |
5832 | 669 |
|
670 |
||
671 |
(* end proof *) |
|
672 |
||
24868 | 673 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
674 |
Outer_Syntax.command "qed" "conclude (sub-)proof" |
36950 | 675 |
(Keyword.tag_proof Keyword.qed_block) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
676 |
(Scan.option Method.parse >> Isar_Cmd.qed); |
5832 | 677 |
|
24868 | 678 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
679 |
Outer_Syntax.command "by" "terminal backward proof" |
36950 | 680 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
681 |
(Method.parse -- Scan.option Method.parse >> Isar_Cmd.terminal_proof); |
6404 | 682 |
|
24868 | 683 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
684 |
Outer_Syntax.command ".." "default proof" |
36950 | 685 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
686 |
(Scan.succeed Isar_Cmd.default_proof); |
8966 | 687 |
|
24868 | 688 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
689 |
Outer_Syntax.command "." "immediate proof" |
36950 | 690 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
691 |
(Scan.succeed Isar_Cmd.immediate_proof); |
6404 | 692 |
|
24868 | 693 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
694 |
Outer_Syntax.command "done" "done proof" |
36950 | 695 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
696 |
(Scan.succeed Isar_Cmd.done_proof); |
5832 | 697 |
|
24868 | 698 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
699 |
Outer_Syntax.command "sorry" "skip proof (quick-and-dirty mode only!)" |
36950 | 700 |
(Keyword.tag_proof Keyword.qed) |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
701 |
(Scan.succeed Isar_Cmd.skip_proof); |
6888
d0c68ebdabc5
skip_proof feature 'sorry' (for quick_and_dirty mode only);
wenzelm
parents:
6886
diff
changeset
|
702 |
|
24868 | 703 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
704 |
Outer_Syntax.command "oops" "forget proof" |
36950 | 705 |
(Keyword.tag_proof Keyword.qed_global) |
18561 | 706 |
(Scan.succeed Toplevel.forget_proof); |
8210 | 707 |
|
5832 | 708 |
|
709 |
(* proof steps *) |
|
710 |
||
24868 | 711 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
712 |
Outer_Syntax.command "defer" "shuffle internal proof state" |
36950 | 713 |
(Keyword.tag_proof Keyword.prf_script) |
714 |
(Scan.option Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.defer))); |
|
8165 | 715 |
|
24868 | 716 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
717 |
Outer_Syntax.command "prefer" "shuffle internal proof state" |
36950 | 718 |
(Keyword.tag_proof Keyword.prf_script) |
719 |
(Parse.nat >> (Toplevel.print oo (Toplevel.proofs o Proof.prefer))); |
|
8165 | 720 |
|
24868 | 721 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
722 |
Outer_Syntax.command "apply" "initial refinement step (unstructured)" |
36950 | 723 |
(Keyword.tag_proof Keyword.prf_script) |
22117 | 724 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply))); |
5832 | 725 |
|
24868 | 726 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
727 |
Outer_Syntax.command "apply_end" "terminal refinement (unstructured)" |
36950 | 728 |
(Keyword.tag_proof Keyword.prf_script) |
22117 | 729 |
(Method.parse >> (Toplevel.print oo (Toplevel.proofs o Proof.apply_end))); |
5832 | 730 |
|
24868 | 731 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
732 |
Outer_Syntax.command "proof" "backward proof" |
36950 | 733 |
(Keyword.tag_proof Keyword.prf_block) |
22117 | 734 |
(Scan.option Method.parse >> (fn m => Toplevel.print o |
33390 | 735 |
Toplevel.actual_proof (Proof_Node.applys (Proof.proof m)) o |
27563 | 736 |
Toplevel.skip_proof (fn i => i + 1))); |
5832 | 737 |
|
738 |
||
6773 | 739 |
(* calculational proof commands *) |
740 |
||
6878 | 741 |
val calc_args = |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
742 |
Scan.option (Parse.$$$ "(" |-- Parse.!!! ((Parse_Spec.xthms1 --| Parse.$$$ ")"))); |
6878 | 743 |
|
24868 | 744 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
745 |
Outer_Syntax.command "also" "combine calculation and current facts" |
36950 | 746 |
(Keyword.tag_proof Keyword.prf_decl) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
747 |
(calc_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
6773 | 748 |
|
24868 | 749 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
750 |
Outer_Syntax.command "finally" "combine calculation and current facts, exhibit result" |
36950 | 751 |
(Keyword.tag_proof Keyword.prf_chain) |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36317
diff
changeset
|
752 |
(calc_args >> (Toplevel.proofs' o Calculation.finally_cmd)); |
6773 | 753 |
|
24868 | 754 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
755 |
Outer_Syntax.command "moreover" "augment calculation by current facts" |
36950 | 756 |
(Keyword.tag_proof Keyword.prf_decl) |
17900 | 757 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
8562 | 758 |
|
24868 | 759 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
760 |
Outer_Syntax.command "ultimately" "augment calculation by current facts, exhibit result" |
36950 | 761 |
(Keyword.tag_proof Keyword.prf_chain) |
17900 | 762 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
8588 | 763 |
|
6773 | 764 |
|
6742 | 765 |
(* proof navigation *) |
5944 | 766 |
|
24868 | 767 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
768 |
Outer_Syntax.command "back" "backtracking of proof command" |
36950 | 769 |
(Keyword.tag_proof Keyword.prf_script) |
33390 | 770 |
(Scan.succeed (Toplevel.print o Toplevel.actual_proof Proof_Node.back o Toplevel.skip_proof I)); |
6742 | 771 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
772 |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
773 |
(* nested commands *) |
25578 | 774 |
|
29309 | 775 |
val props_text = |
36951 | 776 |
Scan.optional Parse_Value.properties [] -- Parse.position Parse.string |
36950 | 777 |
>> (fn (props, (str, pos)) => |
778 |
(Position.of_properties (Position.default_properties pos props), str)); |
|
29309 | 779 |
|
25578 | 780 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
781 |
Outer_Syntax.improper_command "Isabelle.command" "nested Isabelle command" Keyword.control |
29309 | 782 |
(props_text :|-- (fn (pos, str) => |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
783 |
(case Outer_Syntax.parse pos str of |
27838
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
784 |
[tr] => Scan.succeed (K tr) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
785 |
| _ => Scan.fail_with (K "exactly one command expected")) |
0340fd7cccc3
Isabelle.command: inline former OuterSyntax.prepare_command;
wenzelm
parents:
27831
diff
changeset
|
786 |
handle ERROR msg => Scan.fail_with (K msg))); |
25578 | 787 |
|
788 |
||
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
789 |
|
5832 | 790 |
(** diagnostic commands (for interactive mode only) **) |
791 |
||
36950 | 792 |
val opt_modes = |
793 |
Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Scan.repeat1 Parse.xname --| Parse.$$$ ")")) []; |
|
794 |
||
795 |
val opt_bang = Scan.optional (Parse.$$$ "!" >> K true) false; |
|
8464 | 796 |
|
24868 | 797 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
798 |
Outer_Syntax.improper_command "pretty_setmargin" "change default margin for pretty printing" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
799 |
Keyword.diag (Parse.nat >> (Toplevel.no_timing oo Isar_Cmd.pretty_setmargin)); |
7124 | 800 |
|
24868 | 801 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
802 |
Outer_Syntax.improper_command "help" "print outer syntax commands" Keyword.diag |
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
803 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
21714 | 804 |
|
24868 | 805 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
806 |
Outer_Syntax.improper_command "print_commands" "print outer syntax commands" Keyword.diag |
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
807 |
(Scan.succeed (Toplevel.no_timing o Toplevel.imperative Outer_Syntax.print_outer_syntax)); |
5832 | 808 |
|
24868 | 809 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
810 |
Outer_Syntax.improper_command "print_configs" "print configuration options" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
811 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_configs)); |
23989 | 812 |
|
24868 | 813 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
814 |
Outer_Syntax.improper_command "print_context" "print theory context name" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
815 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_context)); |
7308 | 816 |
|
24868 | 817 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
818 |
Outer_Syntax.improper_command "print_theory" "print logical theory contents (verbose!)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
819 |
Keyword.diag (opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theory)); |
5832 | 820 |
|
24868 | 821 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
822 |
Outer_Syntax.improper_command "print_syntax" "print inner syntax of context (verbose!)" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
823 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_syntax)); |
5832 | 824 |
|
24868 | 825 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
826 |
Outer_Syntax.improper_command "print_abbrevs" "print constant abbreviation of context" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
827 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_abbrevs)); |
21726 | 828 |
|
24868 | 829 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
830 |
Outer_Syntax.improper_command "print_theorems" |
36950 | 831 |
"print theorems of local theory or proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
832 |
(opt_bang >> (Toplevel.no_timing oo Isar_Cmd.print_theorems)); |
5881 | 833 |
|
24868 | 834 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
835 |
Outer_Syntax.improper_command "print_locales" "print locales of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
836 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_locales)); |
12061 | 837 |
|
24868 | 838 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
839 |
Outer_Syntax.improper_command "print_classes" "print classes of this theory" Keyword.diag |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
840 |
(Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory |
24219 | 841 |
o Toplevel.keep (Class.print_classes o Toplevel.theory_of))); |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
842 |
|
24868 | 843 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
844 |
Outer_Syntax.improper_command "print_locale" "print locale of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
845 |
(opt_bang -- Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_locale)); |
12061 | 846 |
|
24868 | 847 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
848 |
Outer_Syntax.improper_command "print_interps" |
36950 | 849 |
"print interpretations of locale for this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
850 |
(Parse.xname >> (Toplevel.no_timing oo Isar_Cmd.print_registrations)); |
32804
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
851 |
|
ca430e6aee1c
Propagation of mixins for interpretation; reactivated diagnostic command print_interps.
ballarin
parents:
31869
diff
changeset
|
852 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
853 |
Outer_Syntax.improper_command "print_attributes" "print attributes of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
854 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_attributes)); |
5832 | 855 |
|
24868 | 856 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
857 |
Outer_Syntax.improper_command "print_simpset" "print context of Simplifier" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
858 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_simpset)); |
16027 | 859 |
|
24868 | 860 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
861 |
Outer_Syntax.improper_command "print_rules" "print intro/elim rules" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
862 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_rules)); |
12383 | 863 |
|
24868 | 864 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
865 |
Outer_Syntax.improper_command "print_trans_rules" "print transitivity rules" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
866 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_trans_rules)); |
9221 | 867 |
|
24868 | 868 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
869 |
Outer_Syntax.improper_command "print_methods" "print methods of this theory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
870 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_methods)); |
5832 | 871 |
|
24868 | 872 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
873 |
Outer_Syntax.improper_command "print_antiquotations" "print antiquotations (global)" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
874 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_antiquotations)); |
9221 | 875 |
|
24868 | 876 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
877 |
Outer_Syntax.improper_command "thy_deps" "visualize theory dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
878 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.thy_deps)); |
22485 | 879 |
|
24868 | 880 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
881 |
Outer_Syntax.improper_command "class_deps" "visualize class dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
882 |
Keyword.diag (Scan.succeed (Toplevel.no_timing o Isar_Cmd.class_deps)); |
20574 | 883 |
|
24868 | 884 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
885 |
Outer_Syntax.improper_command "thm_deps" "visualize theorem dependencies" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
886 |
Keyword.diag (Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.thm_deps)); |
9454 | 887 |
|
24868 | 888 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
889 |
Outer_Syntax.improper_command "print_binds" "print term bindings of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
890 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_binds)); |
5832 | 891 |
|
24868 | 892 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
893 |
Outer_Syntax.improper_command "print_facts" "print facts of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
894 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_facts)); |
5832 | 895 |
|
24868 | 896 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
897 |
Outer_Syntax.improper_command "print_cases" "print cases of proof context" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
898 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.print_cases)); |
8370 | 899 |
|
24868 | 900 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
901 |
Outer_Syntax.improper_command "print_statement" "print theorems as long statements" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
902 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_stmts)); |
19269 | 903 |
|
24868 | 904 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
905 |
Outer_Syntax.improper_command "thm" "print theorems" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
906 |
(opt_modes -- Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_thms)); |
5832 | 907 |
|
24868 | 908 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
909 |
Outer_Syntax.improper_command "prf" "print proof terms of theorems" Keyword.diag |
36952
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
wenzelm
parents:
36951
diff
changeset
|
910 |
(opt_modes -- Scan.option Parse_Spec.xthms1 |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
911 |
>> (Toplevel.no_timing oo Isar_Cmd.print_prfs false)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
912 |
|
24868 | 913 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
914 |
Outer_Syntax.improper_command "full_prf" "print full proof terms of theorems" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
915 |
(opt_modes -- Scan.option Parse_Spec.xthms1 >> (Toplevel.no_timing oo Isar_Cmd.print_prfs true)); |
11524
197f2e14a714
Added functions for printing primitive proof terms.
berghofe
parents:
11101
diff
changeset
|
916 |
|
24868 | 917 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
918 |
Outer_Syntax.improper_command "prop" "read and print proposition" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
919 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_prop)); |
5832 | 920 |
|
24868 | 921 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
922 |
Outer_Syntax.improper_command "term" "read and print term" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
923 |
(opt_modes -- Parse.term >> (Toplevel.no_timing oo Isar_Cmd.print_term)); |
5832 | 924 |
|
24868 | 925 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
926 |
Outer_Syntax.improper_command "typ" "read and print type" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
927 |
(opt_modes -- Parse.typ >> (Toplevel.no_timing oo Isar_Cmd.print_type)); |
5832 | 928 |
|
24868 | 929 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
930 |
Outer_Syntax.improper_command "print_codesetup" "print code generator setup" Keyword.diag |
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
931 |
(Scan.succeed |
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22573
diff
changeset
|
932 |
(Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep |
24219 | 933 |
(Code.print_codesetup o Toplevel.theory_of))); |
5832 | 934 |
|
26184 | 935 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
936 |
Outer_Syntax.improper_command "unused_thms" "find unused theorems" Keyword.diag |
36950 | 937 |
(Scan.option ((Scan.repeat1 (Scan.unless Parse.minus Parse.name) --| Parse.minus) -- |
938 |
Scan.option (Scan.repeat1 (Scan.unless Parse.minus Parse.name))) >> |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
939 |
(Toplevel.no_timing oo Isar_Cmd.unused_thms)); |
26184 | 940 |
|
5832 | 941 |
|
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
|
942 |
|
5832 | 943 |
(** system commands (for interactive mode only) **) |
944 |
||
24868 | 945 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
946 |
Outer_Syntax.improper_command "cd" "change current working directory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
947 |
(Parse.path >> (Toplevel.no_timing oo Isar_Cmd.cd)); |
5832 | 948 |
|
24868 | 949 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
950 |
Outer_Syntax.improper_command "pwd" "print current working directory" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
951 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.pwd)); |
5832 | 952 |
|
24868 | 953 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
954 |
Outer_Syntax.improper_command "use_thy" "use theory file" Keyword.diag |
36950 | 955 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
956 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.use_thy name))); |
5832 | 957 |
|
24868 | 958 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
959 |
Outer_Syntax.improper_command "touch_thy" "outdate theory, including descendants" Keyword.diag |
36950 | 960 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
961 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.touch_thy name))); |
7908 | 962 |
|
24868 | 963 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
964 |
Outer_Syntax.improper_command "remove_thy" "remove theory from loader database" Keyword.diag |
36950 | 965 |
(Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
966 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.remove_thy name))); |
7102 | 967 |
|
24868 | 968 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
969 |
Outer_Syntax.improper_command "kill_thy" "kill theory -- try to remove from loader database" |
36950 | 970 |
Keyword.diag (Parse.name >> (fn name => |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
971 |
Toplevel.no_timing o Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
7931 | 972 |
|
24868 | 973 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
974 |
Outer_Syntax.improper_command "display_drafts" "display raw source files with symbols" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
975 |
Keyword.diag (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.display_drafts)); |
14934 | 976 |
|
24868 | 977 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
978 |
Outer_Syntax.improper_command "print_drafts" "print raw source files with symbols" |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
979 |
Keyword.diag (Scan.repeat1 Parse.path >> (Toplevel.no_timing oo Isar_Cmd.print_drafts)); |
14934 | 980 |
|
9731 | 981 |
val opt_limits = |
36950 | 982 |
Scan.option Parse.nat -- Scan.option (Parse.$$$ "," |-- Parse.!!! Parse.nat); |
9731 | 983 |
|
24868 | 984 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
985 |
Outer_Syntax.improper_command "pr" "print current proof state (if present)" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
986 |
(opt_modes -- opt_limits >> (Toplevel.no_timing oo Isar_Cmd.pr)); |
7199 | 987 |
|
24868 | 988 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
989 |
Outer_Syntax.improper_command "disable_pr" "disable printing of toplevel state" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
990 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.disable_pr)); |
5832 | 991 |
|
24868 | 992 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
993 |
Outer_Syntax.improper_command "enable_pr" "enable printing of toplevel state" Keyword.diag |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
994 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.enable_pr)); |
7222 | 995 |
|
24868 | 996 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
997 |
Outer_Syntax.improper_command "commit" "commit current session to ML database" Keyword.diag |
36950 | 998 |
(Parse.opt_unit >> K (Toplevel.no_timing o Toplevel.imperative Secure.commit)); |
5832 | 999 |
|
24868 | 1000 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
1001 |
Outer_Syntax.improper_command "quit" "quit Isabelle" Keyword.control |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
1002 |
(Parse.opt_unit >> (Toplevel.no_timing oo K Isar_Cmd.quit)); |
5832 | 1003 |
|
24868 | 1004 |
val _ = |
36953
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
wenzelm
parents:
36952
diff
changeset
|
1005 |
Outer_Syntax.improper_command "exit" "exit Isar loop" Keyword.control |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
37198
diff
changeset
|
1006 |
(Scan.succeed (Toplevel.no_timing o Isar_Cmd.exit)); |
5832 | 1007 |
|
1008 |
end; |
|
27614
f38c25d106a7
renamed IsarCmd.nested_command to OuterSyntax.prepare_command;
wenzelm
parents:
27575
diff
changeset
|
1009 |