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