author | wenzelm |
Sat, 10 Nov 2018 19:01:20 +0100 | |
changeset 69281 | 599b6d0d199b |
parent 69262 | f94726501b37 |
child 69349 | 7cef9e386ffe |
permissions | -rw-r--r-- |
48929
05d4e5f660ae
entity markup for theory Pure, to enable hyperlinks etc.;
wenzelm
parents:
48891
diff
changeset
|
1 |
(* Title: Pure/Pure.thy |
05d4e5f660ae
entity markup for theory Pure, to enable hyperlinks etc.;
wenzelm
parents:
48891
diff
changeset
|
2 |
Author: Makarius |
05d4e5f660ae
entity markup for theory Pure, to enable hyperlinks etc.;
wenzelm
parents:
48891
diff
changeset
|
3 |
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62913
diff
changeset
|
4 |
The Pure theory, with definitions of Isar commands and some lemmas. |
48929
05d4e5f660ae
entity markup for theory Pure, to enable hyperlinks etc.;
wenzelm
parents:
48891
diff
changeset
|
5 |
*) |
05d4e5f660ae
entity markup for theory Pure, to enable hyperlinks etc.;
wenzelm
parents:
48891
diff
changeset
|
6 |
|
48638 | 7 |
theory Pure |
62859 | 8 |
keywords |
67446 | 9 |
"!!" "!" "+" ":" ";" "<" "<=" "==" "=>" "?" "[" "\<comment>" "\<equiv>" "\<leftharpoondown>" "\<rightharpoonup>" "\<rightleftharpoons>" |
66194 | 10 |
"\<subseteq>" "]" "attach" "binder" "in" "infix" "infixl" "infixr" "is" "open" "output" |
11 |
"overloaded" "pervasive" "premises" "structure" "unchecked" |
|
63441 | 12 |
and "private" "qualified" :: before_command |
67740 | 13 |
and "assumes" "constrains" "defines" "fixes" "for" "if" "includes" "notes" "rewrites" |
66194 | 14 |
"obtains" "shows" "when" "where" "|" :: quasi_command |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58928
diff
changeset
|
15 |
and "text" "txt" :: document_body |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58928
diff
changeset
|
16 |
and "text_raw" :: document_raw |
63579 | 17 |
and "default_sort" :: thy_decl |
57506 | 18 |
and "typedecl" "type_synonym" "nonterminal" "judgment" |
62169 | 19 |
"consts" "syntax" "no_syntax" "translations" "no_translations" |
55385
169e12bbf9a3
discontinued axiomatic 'classes', 'classrel', 'arities';
wenzelm
parents:
55152
diff
changeset
|
20 |
"definition" "abbreviation" "type_notation" "no_type_notation" "notation" |
66248 | 21 |
"no_notation" "axiomatization" "alias" "type_alias" "lemmas" "declare" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
22 |
"hide_class" "hide_type" "hide_const" "hide_fact" :: thy_decl |
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
23 |
and "external_file" "bibtex_file" :: thy_load |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
24 |
and "ML_file" "ML_file_debug" "ML_file_no_debug" :: thy_load % "ML" |
60957
574254152856
support for ML files with/without debugger information;
wenzelm
parents:
60749
diff
changeset
|
25 |
and "SML_file" "SML_file_debug" "SML_file_no_debug" :: thy_load % "ML" |
68276 | 26 |
and "SML_import" "SML_export" "ML_export" :: thy_decl % "ML" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
27 |
and "ML_prf" :: prf_decl % "proof" (* FIXME % "ML" ?? *) |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
28 |
and "ML_val" "ML_command" :: diag % "ML" |
63579 | 29 |
and "simproc_setup" :: thy_decl % "ML" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
30 |
and "setup" "local_setup" "attribute_setup" "method_setup" |
55762
27a45aec67a0
suppress completion of obscure keyword, avoid confusion with plain "simp";
wenzelm
parents:
55516
diff
changeset
|
31 |
"declaration" "syntax_declaration" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
32 |
"parse_ast_translation" "parse_translation" "print_translation" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
33 |
"typed_print_translation" "print_ast_translation" "oracle" :: thy_decl % "ML" |
63273 | 34 |
and "bundle" :: thy_decl_block |
63282 | 35 |
and "unbundle" :: thy_decl |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
36 |
and "include" "including" :: prf_decl |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
37 |
and "print_bundles" :: diag |
59901 | 38 |
and "context" "locale" "experiment" :: thy_decl_block |
51224
c3e99efacb67
back to non-schematic 'sublocale' and 'interpretation' (despite df8fc0567a3d) for more potential parallelism;
wenzelm
parents:
50603
diff
changeset
|
39 |
and "interpret" :: prf_goal % "proof" |
61890
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
haftmann
parents:
61853
diff
changeset
|
40 |
and "interpretation" "global_interpretation" "sublocale" :: thy_goal |
58800
bfed1c26caed
explicit keyword category for commands that may start a block;
wenzelm
parents:
58660
diff
changeset
|
41 |
and "class" :: thy_decl_block |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
42 |
and "subclass" :: thy_goal |
58800
bfed1c26caed
explicit keyword category for commands that may start a block;
wenzelm
parents:
58660
diff
changeset
|
43 |
and "instantiation" :: thy_decl_block |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
44 |
and "instance" :: thy_goal |
58800
bfed1c26caed
explicit keyword category for commands that may start a block;
wenzelm
parents:
58660
diff
changeset
|
45 |
and "overloading" :: thy_decl_block |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
46 |
and "code_datatype" :: thy_decl |
61338 | 47 |
and "theorem" "lemma" "corollary" "proposition" :: thy_goal |
61337 | 48 |
and "schematic_goal" :: thy_goal |
58800
bfed1c26caed
explicit keyword category for commands that may start a block;
wenzelm
parents:
58660
diff
changeset
|
49 |
and "notepad" :: thy_decl_block |
50128
599c935aac82
alternative completion for outer syntax keywords;
wenzelm
parents:
49569
diff
changeset
|
50 |
and "have" :: prf_goal % "proof" |
63579 | 51 |
and "hence" :: prf_goal % "proof" |
50128
599c935aac82
alternative completion for outer syntax keywords;
wenzelm
parents:
49569
diff
changeset
|
52 |
and "show" :: prf_asm_goal % "proof" |
63579 | 53 |
and "thus" :: prf_asm_goal % "proof" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
54 |
and "then" "from" "with" :: prf_chain % "proof" |
60371 | 55 |
and "note" :: prf_decl % "proof" |
56 |
and "supply" :: prf_script % "proof" |
|
57 |
and "using" "unfolding" :: prf_decl % "proof" |
|
67119 | 58 |
and "fix" "assume" "presume" "define" :: prf_asm % "proof" |
60448 | 59 |
and "consider" :: prf_goal % "proof" |
53371
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
52549
diff
changeset
|
60 |
and "obtain" :: prf_asm_goal % "proof" |
60624 | 61 |
and "guess" :: prf_script_asm_goal % "proof" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
62 |
and "let" "write" :: prf_decl % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
63 |
and "case" :: prf_asm % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
64 |
and "{" :: prf_open % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
65 |
and "}" :: prf_close % "proof" |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60624
diff
changeset
|
66 |
and "next" :: next_block % "proof" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
67 |
and "qed" :: qed_block % "proof" |
62312
5e5a881ebc12
command '\<proof>' is an alias for 'sorry', with different typesetting;
wenzelm
parents:
62169
diff
changeset
|
68 |
and "by" ".." "." "sorry" "\<proof>" :: "qed" % "proof" |
53571
e58ca0311c0f
more explicit indication of 'done' as proof script element;
wenzelm
parents:
53371
diff
changeset
|
69 |
and "done" :: "qed_script" % "proof" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
70 |
and "oops" :: qed_global % "proof" |
50128
599c935aac82
alternative completion for outer syntax keywords;
wenzelm
parents:
49569
diff
changeset
|
71 |
and "defer" "prefer" "apply" :: prf_script % "proof" |
63579 | 72 |
and "apply_end" :: prf_script % "proof" |
60624 | 73 |
and "subgoal" :: prf_script_goal % "proof" |
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
74 |
and "proof" :: prf_block % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
75 |
and "also" "moreover" :: prf_decl % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
76 |
and "finally" "ultimately" :: prf_chain % "proof" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
77 |
and "back" :: prf_script % "proof" |
61252 | 78 |
and "help" "print_commands" "print_options" "print_context" "print_theory" |
79 |
"print_definitions" "print_syntax" "print_abbrevs" "print_defn_rules" |
|
48641
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
80 |
"print_theorems" "print_locales" "print_classes" "print_locale" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
81 |
"print_interps" "print_dependencies" "print_attributes" |
92b48b8abfe4
more standard bootstrapping of Pure outer syntax;
wenzelm
parents:
48638
diff
changeset
|
82 |
"print_simpset" "print_rules" "print_trans_rules" "print_methods" |
56069
451d5b73f8cf
simplified programming interface to define ML antiquotations -- NB: the transformed context ignores updates of the context parser;
wenzelm
parents:
55762
diff
changeset
|
83 |
"print_antiquotations" "print_ML_antiquotations" "thy_deps" |
58845 | 84 |
"locale_deps" "class_deps" "thm_deps" "print_term_bindings" |
57415
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
56864
diff
changeset
|
85 |
"print_facts" "print_cases" "print_statement" "thm" "prf" "full_prf" |
e721124f1b1e
command 'print_term_bindings' supersedes 'print_binds';
wenzelm
parents:
56864
diff
changeset
|
86 |
"prop" "term" "typ" "print_codesetup" "unused_thms" :: diag |
67263 | 87 |
and "print_state" :: diag |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48641
diff
changeset
|
88 |
and "welcome" :: diag |
68505 | 89 |
and "end" :: thy_end |
63579 | 90 |
and "realizers" :: thy_decl |
91 |
and "realizability" :: thy_decl |
|
56797 | 92 |
and "extract_type" "extract" :: thy_decl |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
48641
diff
changeset
|
93 |
and "find_theorems" "find_consts" :: diag |
57886
7cae177c9084
support for named collections of theorems in canonical order;
wenzelm
parents:
57506
diff
changeset
|
94 |
and "named_theorems" :: thy_decl |
67013
335a7dce7cb3
more uniform header syntax, in contrast to the former etc/abbrevs file-format (see 73939a9b70a3);
wenzelm
parents:
66757
diff
changeset
|
95 |
abbrevs "===>" = "===>" (*prevent replacement of very long arrows*) |
335a7dce7cb3
more uniform header syntax, in contrast to the former etc/abbrevs file-format (see 73939a9b70a3);
wenzelm
parents:
66757
diff
changeset
|
96 |
and "--->" = "\<midarrow>\<rightarrow>" |
67724 | 97 |
and "hence" "thus" "default_sort" "simproc_setup" "apply_end" "realizers" "realizability" = "" |
67013
335a7dce7cb3
more uniform header syntax, in contrast to the former etc/abbrevs file-format (see 73939a9b70a3);
wenzelm
parents:
66757
diff
changeset
|
98 |
and "hence" = "then have" |
335a7dce7cb3
more uniform header syntax, in contrast to the former etc/abbrevs file-format (see 73939a9b70a3);
wenzelm
parents:
66757
diff
changeset
|
99 |
and "thus" = "then show" |
48638 | 100 |
begin |
15803 | 101 |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
102 |
section \<open>Isar commands\<close> |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
103 |
|
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
104 |
subsection \<open>Other files\<close> |
66757 | 105 |
|
106 |
ML \<open> |
|
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
107 |
local |
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
108 |
val _ = |
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
109 |
Outer_Syntax.command \<^command_keyword>\<open>external_file\<close> "formal dependency on external file" |
69262
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
110 |
(Resources.provide_parse_files "external_file" >> (fn files => Toplevel.theory (#2 o files))); |
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
111 |
|
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
112 |
val _ = |
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
113 |
Outer_Syntax.command \<^command_keyword>\<open>bibtex_file\<close> "check bibtex database file in Prover IDE" |
69262
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
114 |
(Resources.provide_parse_files "bibtex_file" >> (fn files => |
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
115 |
Toplevel.theory (fn thy => |
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
116 |
let |
69262
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
117 |
val ([{lines, pos, ...}], thy') = files thy; |
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
118 |
val _ = Bibtex.check_database_output pos (cat_lines lines); |
f94726501b37
more standard Resources.provide_parse_files: avoid duplicate markup reports;
wenzelm
parents:
69059
diff
changeset
|
119 |
in thy' end))); |
67281
338fb884286b
added command 'bibtex_file' (for PIDE interaction only);
wenzelm
parents:
67263
diff
changeset
|
120 |
in end\<close> |
66757 | 121 |
|
122 |
||
62856 | 123 |
subsection \<open>Embedded ML text\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
124 |
|
62856 | 125 |
ML \<open> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
126 |
local |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
127 |
|
67147 | 128 |
val semi = Scan.option \<^keyword>\<open>;\<close>; |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
129 |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
130 |
val _ = |
67147 | 131 |
Outer_Syntax.command \<^command_keyword>\<open>ML_file\<close> "read and evaluate Isabelle/ML file" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
132 |
(Resources.parse_files "ML_file" --| semi >> ML_File.ML NONE); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
133 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
134 |
val _ = |
67147 | 135 |
Outer_Syntax.command \<^command_keyword>\<open>ML_file_debug\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
136 |
"read and evaluate Isabelle/ML file (with debugger information)" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
137 |
(Resources.parse_files "ML_file_debug" --| semi >> ML_File.ML (SOME true)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
138 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
139 |
val _ = |
67147 | 140 |
Outer_Syntax.command \<^command_keyword>\<open>ML_file_no_debug\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
141 |
"read and evaluate Isabelle/ML file (no debugger information)" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
142 |
(Resources.parse_files "ML_file_no_debug" --| semi >> ML_File.ML (SOME false)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
143 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
144 |
val _ = |
67147 | 145 |
Outer_Syntax.command \<^command_keyword>\<open>SML_file\<close> "read and evaluate Standard ML file" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
146 |
(Resources.parse_files "SML_file" --| semi >> ML_File.SML NONE); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
147 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
148 |
val _ = |
67147 | 149 |
Outer_Syntax.command \<^command_keyword>\<open>SML_file_debug\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
150 |
"read and evaluate Standard ML file (with debugger information)" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
151 |
(Resources.parse_files "SML_file_debug" --| semi >> ML_File.SML (SOME true)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
152 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
153 |
val _ = |
67147 | 154 |
Outer_Syntax.command \<^command_keyword>\<open>SML_file_no_debug\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
155 |
"read and evaluate Standard ML file (no debugger information)" |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
156 |
(Resources.parse_files "SML_file_no_debug" --| semi >> ML_File.SML (SOME false)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
157 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
158 |
val _ = |
67147 | 159 |
Outer_Syntax.command \<^command_keyword>\<open>SML_export\<close> "evaluate SML within Isabelle/ML environment" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
160 |
(Parse.ML_source >> (fn source => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
161 |
let |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
162 |
val flags: ML_Compiler.flags = |
68820
2e4df245754e
clarified environment: allow "read>write" specification;
wenzelm
parents:
68816
diff
changeset
|
163 |
{environment = ML_Env.SML_export, redirect = false, verbose = true, |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
164 |
debug = NONE, writeln = writeln, warning = warning}; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
165 |
in |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
166 |
Toplevel.theory |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
167 |
(Context.theory_map (ML_Context.exec (fn () => ML_Context.eval_source flags source))) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
168 |
end)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
169 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
170 |
val _ = |
67147 | 171 |
Outer_Syntax.command \<^command_keyword>\<open>SML_import\<close> "evaluate Isabelle/ML within SML environment" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
172 |
(Parse.ML_source >> (fn source => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
173 |
let |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
174 |
val flags: ML_Compiler.flags = |
68820
2e4df245754e
clarified environment: allow "read>write" specification;
wenzelm
parents:
68816
diff
changeset
|
175 |
{environment = ML_Env.SML_import, redirect = false, verbose = true, |
62902
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
wenzelm
parents:
62898
diff
changeset
|
176 |
debug = NONE, writeln = writeln, warning = warning}; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
177 |
in |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
178 |
Toplevel.generic_theory |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
179 |
(ML_Context.exec (fn () => ML_Context.eval_source flags source) #> |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
180 |
Local_Theory.propagate_ml_env) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
181 |
end)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
182 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
183 |
val _ = |
68276 | 184 |
Outer_Syntax.command ("ML_export", \<^here>) |
185 |
"ML text within theory or local theory, and export to bootstrap environment" |
|
186 |
(Parse.ML_source >> (fn source => |
|
187 |
Toplevel.generic_theory (fn context => |
|
188 |
context |
|
68826
deefe5837120
clarified ML_environment: ML_write_global requires "Isabelle";
wenzelm
parents:
68820
diff
changeset
|
189 |
|> Config.put_generic ML_Env.ML_environment ML_Env.Isabelle |
68816
5a53724fe247
support named ML environments, notably "Isabelle", "SML";
wenzelm
parents:
68813
diff
changeset
|
190 |
|> Config.put_generic ML_Env.ML_write_global true |
68276 | 191 |
|> ML_Context.exec (fn () => |
192 |
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source) |
|
68827 | 193 |
|> Config.restore_generic ML_Env.ML_write_global context |
194 |
|> Config.restore_generic ML_Env.ML_environment context |
|
68276 | 195 |
|> Local_Theory.propagate_ml_env))); |
196 |
||
197 |
val _ = |
|
67147 | 198 |
Outer_Syntax.command \<^command_keyword>\<open>ML_prf\<close> "ML text within proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
199 |
(Parse.ML_source >> (fn source => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
200 |
Toplevel.proof (Proof.map_context (Context.proof_map |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
201 |
(ML_Context.exec (fn () => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
202 |
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source))) #> |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
203 |
Proof.propagate_ml_env))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
204 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
205 |
val _ = |
67147 | 206 |
Outer_Syntax.command \<^command_keyword>\<open>ML_val\<close> "diagnostic ML text" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
207 |
(Parse.ML_source >> Isar_Cmd.ml_diag true); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
208 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
209 |
val _ = |
67147 | 210 |
Outer_Syntax.command \<^command_keyword>\<open>ML_command\<close> "diagnostic ML text (silent)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
211 |
(Parse.ML_source >> Isar_Cmd.ml_diag false); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
212 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
213 |
val _ = |
67147 | 214 |
Outer_Syntax.command \<^command_keyword>\<open>setup\<close> "ML setup for global theory" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
215 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.setup)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
216 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
217 |
val _ = |
67147 | 218 |
Outer_Syntax.local_theory \<^command_keyword>\<open>local_setup\<close> "ML setup for local theory" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
219 |
(Parse.ML_source >> Isar_Cmd.local_setup); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
220 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
221 |
val _ = |
67147 | 222 |
Outer_Syntax.command \<^command_keyword>\<open>oracle\<close> "declare oracle" |
223 |
(Parse.range Parse.name -- (\<^keyword>\<open>=\<close> |-- Parse.ML_source) >> |
|
62856 | 224 |
(fn (x, y) => Toplevel.theory (Isar_Cmd.oracle x y))); |
225 |
||
226 |
val _ = |
|
67147 | 227 |
Outer_Syntax.local_theory \<^command_keyword>\<open>attribute_setup\<close> "define attribute in ML" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
228 |
(Parse.position Parse.name -- |
67147 | 229 |
Parse.!!! (\<^keyword>\<open>=\<close> |-- Parse.ML_source -- Scan.optional Parse.text "") |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
230 |
>> (fn (name, (txt, cmt)) => Attrib.attribute_setup name txt cmt)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
231 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
232 |
val _ = |
67147 | 233 |
Outer_Syntax.local_theory \<^command_keyword>\<open>method_setup\<close> "define proof method in ML" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
234 |
(Parse.position Parse.name -- |
67147 | 235 |
Parse.!!! (\<^keyword>\<open>=\<close> |-- Parse.ML_source -- Scan.optional Parse.text "") |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
236 |
>> (fn (name, (txt, cmt)) => Method.method_setup name txt cmt)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
237 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
238 |
val _ = |
67147 | 239 |
Outer_Syntax.local_theory \<^command_keyword>\<open>declaration\<close> "generic ML declaration" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
240 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
241 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = false, pervasive = pervasive} txt)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
242 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
243 |
val _ = |
67147 | 244 |
Outer_Syntax.local_theory \<^command_keyword>\<open>syntax_declaration\<close> "generic ML syntax declaration" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
245 |
(Parse.opt_keyword "pervasive" -- Parse.ML_source |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
246 |
>> (fn (pervasive, txt) => Isar_Cmd.declaration {syntax = true, pervasive = pervasive} txt)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
247 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
248 |
val _ = |
67147 | 249 |
Outer_Syntax.local_theory \<^command_keyword>\<open>simproc_setup\<close> "define simproc in ML" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
250 |
(Parse.position Parse.name -- |
67147 | 251 |
(\<^keyword>\<open>(\<close> |-- Parse.enum1 "|" Parse.term --| \<^keyword>\<open>)\<close> --| \<^keyword>\<open>=\<close>) -- |
62913 | 252 |
Parse.ML_source >> (fn ((a, b), c) => Isar_Cmd.simproc_setup a b c)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
253 |
|
62856 | 254 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
255 |
|
62856 | 256 |
|
257 |
subsection \<open>Theory commands\<close> |
|
258 |
||
259 |
subsubsection \<open>Sorts and types\<close> |
|
260 |
||
261 |
ML \<open> |
|
262 |
local |
|
263 |
||
264 |
val _ = |
|
67147 | 265 |
Outer_Syntax.local_theory \<^command_keyword>\<open>default_sort\<close> |
62856 | 266 |
"declare default sort for explicit type variables" |
267 |
(Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy)); |
|
268 |
||
269 |
val _ = |
|
67147 | 270 |
Outer_Syntax.local_theory \<^command_keyword>\<open>typedecl\<close> "type declaration" |
62856 | 271 |
(Parse.type_args -- Parse.binding -- Parse.opt_mixfix |
272 |
>> (fn ((args, a), mx) => |
|
273 |
Typedecl.typedecl {final = true} (a, map (rpair dummyS) args, mx) #> snd)); |
|
274 |
||
275 |
val _ = |
|
67147 | 276 |
Outer_Syntax.local_theory \<^command_keyword>\<open>type_synonym\<close> "declare type abbreviation" |
62856 | 277 |
(Parse.type_args -- Parse.binding -- |
67147 | 278 |
(\<^keyword>\<open>=\<close> |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix')) |
62856 | 279 |
>> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)); |
280 |
||
281 |
in end\<close> |
|
282 |
||
283 |
||
284 |
subsubsection \<open>Consts\<close> |
|
285 |
||
286 |
ML \<open> |
|
287 |
local |
|
288 |
||
289 |
val _ = |
|
67147 | 290 |
Outer_Syntax.command \<^command_keyword>\<open>judgment\<close> "declare object-logic judgment" |
62856 | 291 |
(Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd)); |
292 |
||
293 |
val _ = |
|
67147 | 294 |
Outer_Syntax.command \<^command_keyword>\<open>consts\<close> "declare constants" |
62856 | 295 |
(Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts_cmd)); |
296 |
||
297 |
in end\<close> |
|
298 |
||
299 |
||
300 |
subsubsection \<open>Syntax and translations\<close> |
|
301 |
||
302 |
ML \<open> |
|
303 |
local |
|
304 |
||
305 |
val _ = |
|
67147 | 306 |
Outer_Syntax.command \<^command_keyword>\<open>nonterminal\<close> |
62856 | 307 |
"declare syntactic type constructors (grammar nonterminal symbols)" |
308 |
(Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global)); |
|
309 |
||
310 |
val _ = |
|
67147 | 311 |
Outer_Syntax.command \<^command_keyword>\<open>syntax\<close> "add raw syntax clauses" |
62856 | 312 |
(Parse.syntax_mode -- Scan.repeat1 Parse.const_decl |
313 |
>> (Toplevel.theory o uncurry Sign.add_syntax_cmd)); |
|
314 |
||
315 |
val _ = |
|
67147 | 316 |
Outer_Syntax.command \<^command_keyword>\<open>no_syntax\<close> "delete raw syntax clauses" |
62856 | 317 |
(Parse.syntax_mode -- Scan.repeat1 Parse.const_decl |
318 |
>> (Toplevel.theory o uncurry Sign.del_syntax_cmd)); |
|
319 |
||
320 |
val trans_pat = |
|
321 |
Scan.optional |
|
67147 | 322 |
(\<^keyword>\<open>(\<close> |-- Parse.!!! (Parse.inner_syntax Parse.name --| \<^keyword>\<open>)\<close>)) "logic" |
62856 | 323 |
-- Parse.inner_syntax Parse.string; |
324 |
||
325 |
fun trans_arrow toks = |
|
67147 | 326 |
((\<^keyword>\<open>\<rightharpoonup>\<close> || \<^keyword>\<open>=>\<close>) >> K Syntax.Parse_Rule || |
327 |
(\<^keyword>\<open>\<leftharpoondown>\<close> || \<^keyword>\<open><=\<close>) >> K Syntax.Print_Rule || |
|
328 |
(\<^keyword>\<open>\<rightleftharpoons>\<close> || \<^keyword>\<open>==\<close>) >> K Syntax.Parse_Print_Rule) toks; |
|
62856 | 329 |
|
330 |
val trans_line = |
|
331 |
trans_pat -- Parse.!!! (trans_arrow -- trans_pat) |
|
332 |
>> (fn (left, (arr, right)) => arr (left, right)); |
|
333 |
||
334 |
val _ = |
|
67147 | 335 |
Outer_Syntax.command \<^command_keyword>\<open>translations\<close> "add syntax translation rules" |
62856 | 336 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.translations)); |
337 |
||
338 |
val _ = |
|
67147 | 339 |
Outer_Syntax.command \<^command_keyword>\<open>no_translations\<close> "delete syntax translation rules" |
62856 | 340 |
(Scan.repeat1 trans_line >> (Toplevel.theory o Isar_Cmd.no_translations)); |
341 |
||
342 |
in end\<close> |
|
343 |
||
344 |
||
345 |
subsubsection \<open>Translation functions\<close> |
|
346 |
||
347 |
ML \<open> |
|
348 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
349 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
350 |
val _ = |
67147 | 351 |
Outer_Syntax.command \<^command_keyword>\<open>parse_ast_translation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
352 |
"install parse ast translation functions" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
353 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_ast_translation)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
354 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
355 |
val _ = |
67147 | 356 |
Outer_Syntax.command \<^command_keyword>\<open>parse_translation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
357 |
"install parse translation functions" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
358 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_translation)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
359 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
360 |
val _ = |
67147 | 361 |
Outer_Syntax.command \<^command_keyword>\<open>print_translation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
362 |
"install print translation functions" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
363 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_translation)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
364 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
365 |
val _ = |
67147 | 366 |
Outer_Syntax.command \<^command_keyword>\<open>typed_print_translation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
367 |
"install typed print translation functions" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
368 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.typed_print_translation)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
369 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
370 |
val _ = |
67147 | 371 |
Outer_Syntax.command \<^command_keyword>\<open>print_ast_translation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
372 |
"install print ast translation functions" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
373 |
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_ast_translation)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
374 |
|
62856 | 375 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
376 |
|
62856 | 377 |
|
378 |
subsubsection \<open>Specifications\<close> |
|
379 |
||
380 |
ML \<open> |
|
381 |
local |
|
382 |
||
383 |
val _ = |
|
67147 | 384 |
Outer_Syntax.local_theory' \<^command_keyword>\<open>definition\<close> "constant definition" |
63180 | 385 |
(Scan.option Parse_Spec.constdecl -- (Parse_Spec.opt_thm_name ":" -- Parse.prop) -- |
386 |
Parse_Spec.if_assumes -- Parse.for_fixes >> (fn (((decl, spec), prems), params) => |
|
387 |
#2 oo Specification.definition_cmd decl params prems spec)); |
|
62856 | 388 |
|
389 |
val _ = |
|
67147 | 390 |
Outer_Syntax.local_theory' \<^command_keyword>\<open>abbreviation\<close> "constant abbreviation" |
63180 | 391 |
(Parse.syntax_mode -- Scan.option Parse_Spec.constdecl -- Parse.prop -- Parse.for_fixes |
392 |
>> (fn (((mode, decl), spec), params) => Specification.abbreviation_cmd mode decl params spec)); |
|
62856 | 393 |
|
63178 | 394 |
val axiomatization = |
395 |
Parse.and_list1 (Parse_Spec.thm_name ":" -- Parse.prop) -- |
|
396 |
Parse_Spec.if_assumes -- Parse.for_fixes >> (fn ((a, b), c) => (c, b, a)); |
|
397 |
||
62856 | 398 |
val _ = |
67147 | 399 |
Outer_Syntax.command \<^command_keyword>\<open>axiomatization\<close> "axiomatic constant specification" |
63285 | 400 |
(Scan.optional Parse.vars [] -- |
63178 | 401 |
Scan.optional (Parse.where_ |-- Parse.!!! axiomatization) ([], [], []) |
402 |
>> (fn (a, (b, c, d)) => Toplevel.theory (#2 o Specification.axiomatization_cmd a b c d))); |
|
62856 | 403 |
|
66248 | 404 |
val _ = |
67147 | 405 |
Outer_Syntax.local_theory \<^command_keyword>\<open>alias\<close> "name-space alias for constant" |
406 |
(Parse.binding -- (Parse.!!! \<^keyword>\<open>=\<close> |-- Parse.position Parse.name) |
|
66248 | 407 |
>> Specification.alias_cmd); |
408 |
||
409 |
val _ = |
|
67147 | 410 |
Outer_Syntax.local_theory \<^command_keyword>\<open>type_alias\<close> "name-space alias for type constructor" |
411 |
(Parse.binding -- (Parse.!!! \<^keyword>\<open>=\<close> |-- Parse.position Parse.name) |
|
66248 | 412 |
>> Specification.type_alias_cmd); |
413 |
||
62856 | 414 |
in end\<close> |
415 |
||
416 |
||
417 |
subsubsection \<open>Notation\<close> |
|
418 |
||
419 |
ML \<open> |
|
420 |
local |
|
421 |
||
422 |
val _ = |
|
67147 | 423 |
Outer_Syntax.local_theory \<^command_keyword>\<open>type_notation\<close> |
62856 | 424 |
"add concrete syntax for type constructors" |
425 |
(Parse.syntax_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
|
426 |
>> (fn (mode, args) => Specification.type_notation_cmd true mode args)); |
|
427 |
||
428 |
val _ = |
|
67147 | 429 |
Outer_Syntax.local_theory \<^command_keyword>\<open>no_type_notation\<close> |
62856 | 430 |
"delete concrete syntax for type constructors" |
431 |
(Parse.syntax_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix) |
|
432 |
>> (fn (mode, args) => Specification.type_notation_cmd false mode args)); |
|
433 |
||
434 |
val _ = |
|
67147 | 435 |
Outer_Syntax.local_theory \<^command_keyword>\<open>notation\<close> |
62856 | 436 |
"add concrete syntax for constants / fixed variables" |
437 |
(Parse.syntax_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
|
438 |
>> (fn (mode, args) => Specification.notation_cmd true mode args)); |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
439 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
440 |
val _ = |
67147 | 441 |
Outer_Syntax.local_theory \<^command_keyword>\<open>no_notation\<close> |
62856 | 442 |
"delete concrete syntax for constants / fixed variables" |
443 |
(Parse.syntax_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
|
444 |
>> (fn (mode, args) => Specification.notation_cmd false mode args)); |
|
445 |
||
446 |
in end\<close> |
|
447 |
||
448 |
||
449 |
subsubsection \<open>Theorems\<close> |
|
450 |
||
451 |
ML \<open> |
|
452 |
local |
|
453 |
||
63094
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
454 |
val long_keyword = |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
455 |
Parse_Spec.includes >> K "" || |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
456 |
Parse_Spec.long_statement_keyword; |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
457 |
|
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
458 |
val long_statement = |
63352 | 459 |
Scan.optional (Parse_Spec.opt_thm_name ":" --| Scan.ahead long_keyword) Binding.empty_atts -- |
63094
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
460 |
Scan.optional Parse_Spec.includes [] -- Parse_Spec.long_statement |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
461 |
>> (fn ((binding, includes), (elems, concl)) => (true, binding, includes, elems, concl)); |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
462 |
|
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
463 |
val short_statement = |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
464 |
Parse_Spec.statement -- Parse_Spec.if_statement -- Parse.for_fixes |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
465 |
>> (fn ((shows, assumes), fixes) => |
63352 | 466 |
(false, Binding.empty_atts, [], [Element.Fixes fixes, Element.Assumes assumes], |
63094
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
467 |
Element.Shows shows)); |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
468 |
|
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
469 |
fun theorem spec schematic descr = |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
470 |
Outer_Syntax.local_theory_to_proof' spec ("state " ^ descr) |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
471 |
((long_statement || short_statement) >> (fn (long, binding, includes, elems, concl) => |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
472 |
((if schematic then Specification.schematic_theorem_cmd else Specification.theorem_cmd) |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
473 |
long Thm.theoremK NONE (K I) binding includes elems concl))); |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
474 |
|
67147 | 475 |
val _ = theorem \<^command_keyword>\<open>theorem\<close> false "theorem"; |
476 |
val _ = theorem \<^command_keyword>\<open>lemma\<close> false "lemma"; |
|
477 |
val _ = theorem \<^command_keyword>\<open>corollary\<close> false "corollary"; |
|
478 |
val _ = theorem \<^command_keyword>\<open>proposition\<close> false "proposition"; |
|
479 |
val _ = theorem \<^command_keyword>\<open>schematic_goal\<close> true "schematic goal"; |
|
63094
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
480 |
|
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
481 |
in end\<close> |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
482 |
|
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
483 |
ML \<open> |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
484 |
local |
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
wenzelm
parents:
63064
diff
changeset
|
485 |
|
62856 | 486 |
val _ = |
67147 | 487 |
Outer_Syntax.local_theory' \<^command_keyword>\<open>lemmas\<close> "define theorems" |
62856 | 488 |
(Parse_Spec.name_facts -- Parse.for_fixes >> |
489 |
(fn (facts, fixes) => #2 oo Specification.theorems_cmd Thm.theoremK facts fixes)); |
|
490 |
||
491 |
val _ = |
|
67147 | 492 |
Outer_Syntax.local_theory' \<^command_keyword>\<open>declare\<close> "declare theorems" |
62969 | 493 |
(Parse.and_list1 Parse.thms1 -- Parse.for_fixes |
62856 | 494 |
>> (fn (facts, fixes) => |
63352 | 495 |
#2 oo Specification.theorems_cmd "" [(Binding.empty_atts, flat facts)] fixes)); |
62856 | 496 |
|
497 |
val _ = |
|
67147 | 498 |
Outer_Syntax.local_theory \<^command_keyword>\<open>named_theorems\<close> |
62856 | 499 |
"declare named collection of theorems" |
500 |
(Parse.and_list1 (Parse.binding -- Scan.optional Parse.text "") >> |
|
501 |
fold (fn (b, descr) => snd o Named_Theorems.declare b descr)); |
|
502 |
||
503 |
in end\<close> |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
504 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
505 |
|
62856 | 506 |
subsubsection \<open>Hide names\<close> |
507 |
||
508 |
ML \<open> |
|
509 |
local |
|
510 |
||
511 |
fun hide_names command_keyword what hide parse prep = |
|
512 |
Outer_Syntax.command command_keyword ("hide " ^ what ^ " from name space") |
|
513 |
((Parse.opt_keyword "open" >> not) -- Scan.repeat1 parse >> (fn (fully, args) => |
|
514 |
(Toplevel.theory (fn thy => |
|
515 |
let val ctxt = Proof_Context.init_global thy |
|
516 |
in fold (hide fully o prep ctxt) args thy end)))); |
|
517 |
||
518 |
val _ = |
|
67147 | 519 |
hide_names \<^command_keyword>\<open>hide_class\<close> "classes" Sign.hide_class Parse.class |
62856 | 520 |
Proof_Context.read_class; |
521 |
||
522 |
val _ = |
|
67147 | 523 |
hide_names \<^command_keyword>\<open>hide_type\<close> "types" Sign.hide_type Parse.type_const |
62856 | 524 |
((#1 o dest_Type) oo Proof_Context.read_type_name {proper = true, strict = false}); |
525 |
||
526 |
val _ = |
|
67147 | 527 |
hide_names \<^command_keyword>\<open>hide_const\<close> "consts" Sign.hide_const Parse.const |
62856 | 528 |
((#1 o dest_Const) oo Proof_Context.read_const {proper = true, strict = false}); |
529 |
||
530 |
val _ = |
|
67147 | 531 |
hide_names \<^command_keyword>\<open>hide_fact\<close> "facts" Global_Theory.hide_fact |
62969 | 532 |
(Parse.position Parse.name) (Global_Theory.check_fact o Proof_Context.theory_of); |
62856 | 533 |
|
534 |
in end\<close> |
|
535 |
||
536 |
||
537 |
subsection \<open>Bundled declarations\<close> |
|
538 |
||
539 |
ML \<open> |
|
540 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
541 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
542 |
val _ = |
67147 | 543 |
Outer_Syntax.maybe_begin_local_theory \<^command_keyword>\<open>bundle\<close> |
63273 | 544 |
"define bundle of declarations" |
67147 | 545 |
((Parse.binding --| \<^keyword>\<open>=\<close>) -- Parse.thms1 -- Parse.for_fixes |
63273 | 546 |
>> (uncurry Bundle.bundle_cmd)) |
547 |
(Parse.binding --| Parse.begin >> Bundle.init); |
|
63270 | 548 |
|
549 |
val _ = |
|
67147 | 550 |
Outer_Syntax.local_theory \<^command_keyword>\<open>unbundle\<close> |
63282 | 551 |
"activate declarations from bundle in local theory" |
552 |
(Scan.repeat1 (Parse.position Parse.name) >> Bundle.unbundle_cmd); |
|
553 |
||
554 |
val _ = |
|
67147 | 555 |
Outer_Syntax.command \<^command_keyword>\<open>include\<close> |
63282 | 556 |
"activate declarations from bundle in proof body" |
62969 | 557 |
(Scan.repeat1 (Parse.position Parse.name) >> (Toplevel.proof o Bundle.include_cmd)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
558 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
559 |
val _ = |
67147 | 560 |
Outer_Syntax.command \<^command_keyword>\<open>including\<close> |
63282 | 561 |
"activate declarations from bundle in goal refinement" |
62969 | 562 |
(Scan.repeat1 (Parse.position Parse.name) >> (Toplevel.proof o Bundle.including_cmd)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
563 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
564 |
val _ = |
67147 | 565 |
Outer_Syntax.command \<^command_keyword>\<open>print_bundles\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
566 |
"print bundles of declarations" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
567 |
(Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
568 |
|
62856 | 569 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
570 |
|
62856 | 571 |
|
572 |
subsection \<open>Local theory specifications\<close> |
|
573 |
||
574 |
subsubsection \<open>Specification context\<close> |
|
575 |
||
576 |
ML \<open> |
|
577 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
578 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
579 |
val _ = |
67147 | 580 |
Outer_Syntax.command \<^command_keyword>\<open>context\<close> "begin local theory context" |
62969 | 581 |
((Parse.position Parse.name >> (fn name => |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
582 |
Toplevel.begin_local_theory true (Named_Target.begin name)) || |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
583 |
Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
584 |
>> (fn (incls, elems) => Toplevel.open_target (#2 o Bundle.context_cmd incls elems))) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
585 |
--| Parse.begin); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
586 |
|
62856 | 587 |
val _ = |
67147 | 588 |
Outer_Syntax.command \<^command_keyword>\<open>end\<close> "end context" |
62856 | 589 |
(Scan.succeed |
590 |
(Toplevel.exit o Toplevel.end_local_theory o Toplevel.close_target o |
|
591 |
Toplevel.end_proof (K Proof.end_notepad))); |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
592 |
|
62856 | 593 |
in end\<close> |
594 |
||
595 |
||
596 |
subsubsection \<open>Locales and interpretation\<close> |
|
597 |
||
598 |
ML \<open> |
|
599 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
600 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
601 |
val locale_val = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
602 |
Parse_Spec.locale_expression -- |
67147 | 603 |
Scan.optional (\<^keyword>\<open>+\<close> |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
604 |
Scan.repeat1 Parse_Spec.context_element >> pair ([], []); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
605 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
606 |
val _ = |
67147 | 607 |
Outer_Syntax.command \<^command_keyword>\<open>locale\<close> "define named specification context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
608 |
(Parse.binding -- |
67147 | 609 |
Scan.optional (\<^keyword>\<open>=\<close> |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
610 |
>> (fn ((name, (expr, elems)), begin) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
611 |
Toplevel.begin_local_theory begin |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
612 |
(Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
613 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
614 |
val _ = |
67147 | 615 |
Outer_Syntax.command \<^command_keyword>\<open>experiment\<close> "open private specification context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
616 |
(Scan.repeat Parse_Spec.context_element --| Parse.begin |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
617 |
>> (fn elems => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
618 |
Toplevel.begin_local_theory true (Experiment.experiment_cmd elems #> snd))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
619 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
620 |
val _ = |
67147 | 621 |
Outer_Syntax.command \<^command_keyword>\<open>interpret\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
622 |
"prove interpretation of locale expression in proof context" |
67740 | 623 |
(Parse.!!! Parse_Spec.locale_expression >> (fn expr => |
67777
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
624 |
Toplevel.proof (Interpretation.interpret_cmd expr))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
625 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
626 |
val interpretation_args_with_defs = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
627 |
Parse.!!! Parse_Spec.locale_expression -- |
67147 | 628 |
(Scan.optional (\<^keyword>\<open>defines\<close> |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" |
67777
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
629 |
-- ((Parse.binding -- Parse.opt_mixfix') --| \<^keyword>\<open>=\<close> -- Parse.term))) ([])); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
630 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
631 |
val _ = |
67147 | 632 |
Outer_Syntax.local_theory_to_proof \<^command_keyword>\<open>global_interpretation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
633 |
"prove interpretation of locale expression into global theory" |
67777
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
634 |
(interpretation_args_with_defs >> (fn (expr, defs) => |
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
635 |
Interpretation.global_interpretation_cmd expr defs)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
636 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
637 |
val _ = |
67147 | 638 |
Outer_Syntax.command \<^command_keyword>\<open>sublocale\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
639 |
"prove sublocale relation between a locale and a locale expression" |
67147 | 640 |
((Parse.position Parse.name --| (\<^keyword>\<open>\<subseteq>\<close> || \<^keyword>\<open><\<close>) -- |
67777
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
641 |
interpretation_args_with_defs >> (fn (loc, (expr, defs)) => |
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
642 |
Toplevel.theory_to_proof (Interpretation.global_sublocale_cmd loc expr defs))) |
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
643 |
|| interpretation_args_with_defs >> (fn (expr, defs) => |
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
644 |
Toplevel.local_theory_to_proof NONE NONE (Interpretation.sublocale_cmd expr defs))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
645 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
646 |
val _ = |
67147 | 647 |
Outer_Syntax.command \<^command_keyword>\<open>interpretation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
648 |
"prove interpretation of locale expression in local theory or into global theory" |
67740 | 649 |
(Parse.!!! Parse_Spec.locale_expression >> (fn expr => |
62856 | 650 |
Toplevel.local_theory_to_proof NONE NONE |
67777
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
ballarin
parents:
67764
diff
changeset
|
651 |
(Interpretation.isar_interpretation_cmd expr))); |
62856 | 652 |
|
653 |
in end\<close> |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
654 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
655 |
|
62856 | 656 |
subsubsection \<open>Type classes\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
657 |
|
62856 | 658 |
ML \<open> |
659 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
660 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
661 |
val class_val = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
662 |
Parse_Spec.class_expression -- |
67147 | 663 |
Scan.optional (\<^keyword>\<open>+\<close> |-- Parse.!!! (Scan.repeat1 Parse_Spec.context_element)) [] || |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
664 |
Scan.repeat1 Parse_Spec.context_element >> pair []; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
665 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
666 |
val _ = |
67147 | 667 |
Outer_Syntax.command \<^command_keyword>\<open>class\<close> "define type class" |
668 |
(Parse.binding -- Scan.optional (\<^keyword>\<open>=\<close> |-- class_val) ([], []) -- Parse.opt_begin |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
669 |
>> (fn ((name, (supclasses, elems)), begin) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
670 |
Toplevel.begin_local_theory begin |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
671 |
(Class_Declaration.class_cmd name supclasses elems #> snd))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
672 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
673 |
val _ = |
67147 | 674 |
Outer_Syntax.local_theory_to_proof \<^command_keyword>\<open>subclass\<close> "prove a subclass relation" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
675 |
(Parse.class >> Class_Declaration.subclass_cmd); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
676 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
677 |
val _ = |
67147 | 678 |
Outer_Syntax.command \<^command_keyword>\<open>instantiation\<close> "instantiate and prove type arity" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
679 |
(Parse.multi_arity --| Parse.begin |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
680 |
>> (fn arities => Toplevel.begin_local_theory true (Class.instantiation_cmd arities))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
681 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
682 |
val _ = |
67147 | 683 |
Outer_Syntax.command \<^command_keyword>\<open>instance\<close> "prove type arity or subclass relation" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
684 |
((Parse.class -- |
67147 | 685 |
((\<^keyword>\<open>\<subseteq>\<close> || \<^keyword>\<open><\<close>) |-- Parse.!!! Parse.class) >> Class.classrel_cmd || |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
686 |
Parse.multi_arity >> Class.instance_arity_cmd) >> Toplevel.theory_to_proof || |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
687 |
Scan.succeed (Toplevel.local_theory_to_proof NONE NONE (Class.instantiation_instance I))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
688 |
|
62856 | 689 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
690 |
|
62856 | 691 |
|
692 |
subsubsection \<open>Arbitrary overloading\<close> |
|
693 |
||
694 |
ML \<open> |
|
695 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
696 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
697 |
val _ = |
67147 | 698 |
Outer_Syntax.command \<^command_keyword>\<open>overloading\<close> "overloaded definitions" |
699 |
(Scan.repeat1 (Parse.name --| (\<^keyword>\<open>==\<close> || \<^keyword>\<open>\<equiv>\<close>) -- Parse.term -- |
|
700 |
Scan.optional (\<^keyword>\<open>(\<close> |-- (\<^keyword>\<open>unchecked\<close> >> K false) --| \<^keyword>\<open>)\<close>) true |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
701 |
>> Scan.triple1) --| Parse.begin |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
702 |
>> (fn operations => Toplevel.begin_local_theory true (Overloading.overloading_cmd operations))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
703 |
|
62856 | 704 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
705 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
706 |
|
62856 | 707 |
subsection \<open>Proof commands\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
708 |
|
62856 | 709 |
ML \<open> |
710 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
711 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
712 |
val _ = |
67147 | 713 |
Outer_Syntax.local_theory_to_proof \<^command_keyword>\<open>notepad\<close> "begin proof context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
714 |
(Parse.begin >> K Proof.begin_notepad); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
715 |
|
62856 | 716 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
717 |
|
62856 | 718 |
|
719 |
subsubsection \<open>Statements\<close> |
|
720 |
||
721 |
ML \<open> |
|
722 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
723 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
724 |
val structured_statement = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
725 |
Parse_Spec.statement -- Parse_Spec.cond_statement -- Parse.for_fixes |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
726 |
>> (fn ((shows, (strict, assumes)), fixes) => (strict, fixes, assumes, shows)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
727 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
728 |
val _ = |
67147 | 729 |
Outer_Syntax.command \<^command_keyword>\<open>have\<close> "state local goal" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
730 |
(structured_statement >> (fn (a, b, c, d) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
731 |
Toplevel.proof' (fn int => Proof.have_cmd a NONE (K I) b c d int #> #2))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
732 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
733 |
val _ = |
67147 | 734 |
Outer_Syntax.command \<^command_keyword>\<open>show\<close> "state local goal, to refine pending subgoals" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
735 |
(structured_statement >> (fn (a, b, c, d) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
736 |
Toplevel.proof' (fn int => Proof.show_cmd a NONE (K I) b c d int #> #2))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
737 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
738 |
val _ = |
67147 | 739 |
Outer_Syntax.command \<^command_keyword>\<open>hence\<close> "old-style alias of \"then have\"" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
740 |
(structured_statement >> (fn (a, b, c, d) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
741 |
Toplevel.proof' (fn int => Proof.chain #> Proof.have_cmd a NONE (K I) b c d int #> #2))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
742 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
743 |
val _ = |
67147 | 744 |
Outer_Syntax.command \<^command_keyword>\<open>thus\<close> "old-style alias of \"then show\"" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
745 |
(structured_statement >> (fn (a, b, c, d) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
746 |
Toplevel.proof' (fn int => Proof.chain #> Proof.show_cmd a NONE (K I) b c d int #> #2))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
747 |
|
62856 | 748 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
749 |
|
62856 | 750 |
|
751 |
subsubsection \<open>Local facts\<close> |
|
752 |
||
753 |
ML \<open> |
|
754 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
755 |
|
62969 | 756 |
val facts = Parse.and_list1 Parse.thms1; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
757 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
758 |
val _ = |
67147 | 759 |
Outer_Syntax.command \<^command_keyword>\<open>then\<close> "forward chaining" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
760 |
(Scan.succeed (Toplevel.proof Proof.chain)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
761 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
762 |
val _ = |
67147 | 763 |
Outer_Syntax.command \<^command_keyword>\<open>from\<close> "forward chaining from given facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
764 |
(facts >> (Toplevel.proof o Proof.from_thmss_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
765 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
766 |
val _ = |
67147 | 767 |
Outer_Syntax.command \<^command_keyword>\<open>with\<close> "forward chaining from given and current facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
768 |
(facts >> (Toplevel.proof o Proof.with_thmss_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
769 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
770 |
val _ = |
67147 | 771 |
Outer_Syntax.command \<^command_keyword>\<open>note\<close> "define facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
772 |
(Parse_Spec.name_facts >> (Toplevel.proof o Proof.note_thmss_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
773 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
774 |
val _ = |
67147 | 775 |
Outer_Syntax.command \<^command_keyword>\<open>supply\<close> "define facts during goal refinement (unstructured)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
776 |
(Parse_Spec.name_facts >> (Toplevel.proof o Proof.supply_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
777 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
778 |
val _ = |
67147 | 779 |
Outer_Syntax.command \<^command_keyword>\<open>using\<close> "augment goal facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
780 |
(facts >> (Toplevel.proof o Proof.using_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
781 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
782 |
val _ = |
67147 | 783 |
Outer_Syntax.command \<^command_keyword>\<open>unfolding\<close> "unfold definitions in goal and facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
784 |
(facts >> (Toplevel.proof o Proof.unfolding_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
785 |
|
62856 | 786 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
787 |
|
62856 | 788 |
|
789 |
subsubsection \<open>Proof context\<close> |
|
790 |
||
791 |
ML \<open> |
|
792 |
local |
|
793 |
||
794 |
val structured_statement = |
|
795 |
Parse_Spec.statement -- Parse_Spec.if_statement' -- Parse.for_fixes |
|
796 |
>> (fn ((shows, assumes), fixes) => (fixes, assumes, shows)); |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
797 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
798 |
val _ = |
67147 | 799 |
Outer_Syntax.command \<^command_keyword>\<open>fix\<close> "fix local variables (Skolem constants)" |
63285 | 800 |
(Parse.vars >> (Toplevel.proof o Proof.fix_cmd)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
801 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
802 |
val _ = |
67147 | 803 |
Outer_Syntax.command \<^command_keyword>\<open>assume\<close> "assume propositions" |
62856 | 804 |
(structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.assume_cmd a b c))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
805 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
806 |
val _ = |
67147 | 807 |
Outer_Syntax.command \<^command_keyword>\<open>presume\<close> "assume propositions, to be established later" |
62856 | 808 |
(structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.presume_cmd a b c))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
809 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
810 |
val _ = |
67147 | 811 |
Outer_Syntax.command \<^command_keyword>\<open>define\<close> "local definition (non-polymorphic)" |
63285 | 812 |
((Parse.vars --| Parse.where_) -- Parse_Spec.statement -- Parse.for_fixes |
63039 | 813 |
>> (fn ((a, b), c) => Toplevel.proof (Proof.define_cmd a c b))); |
814 |
||
815 |
val _ = |
|
67147 | 816 |
Outer_Syntax.command \<^command_keyword>\<open>consider\<close> "state cases rule" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
817 |
(Parse_Spec.obtains >> (Toplevel.proof' o Obtain.consider_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
818 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
819 |
val _ = |
67147 | 820 |
Outer_Syntax.command \<^command_keyword>\<open>obtain\<close> "generalized elimination" |
63285 | 821 |
(Parse.parbinding -- Scan.optional (Parse.vars --| Parse.where_) [] -- structured_statement |
63059
3f577308551e
'obtain' supports structured statements (similar to 'define');
wenzelm
parents:
63043
diff
changeset
|
822 |
>> (fn ((a, b), (c, d, e)) => Toplevel.proof' (Obtain.obtain_cmd a b c d e))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
823 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
824 |
val _ = |
67147 | 825 |
Outer_Syntax.command \<^command_keyword>\<open>guess\<close> "wild guessing (unstructured)" |
63285 | 826 |
(Scan.optional Parse.vars [] >> (Toplevel.proof' o Obtain.guess_cmd)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
827 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
828 |
val _ = |
67147 | 829 |
Outer_Syntax.command \<^command_keyword>\<open>let\<close> "bind text variables" |
830 |
(Parse.and_list1 (Parse.and_list1 Parse.term -- (\<^keyword>\<open>=\<close> |-- Parse.term)) |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
831 |
>> (Toplevel.proof o Proof.let_bind_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
832 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
833 |
val _ = |
67147 | 834 |
Outer_Syntax.command \<^command_keyword>\<open>write\<close> "add concrete syntax for constants / fixed variables" |
62856 | 835 |
(Parse.syntax_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
836 |
>> (fn (mode, args) => Toplevel.proof (Proof.write_cmd mode args))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
837 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
838 |
val _ = |
67147 | 839 |
Outer_Syntax.command \<^command_keyword>\<open>case\<close> "invoke local context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
840 |
(Parse_Spec.opt_thm_name ":" -- |
67147 | 841 |
(\<^keyword>\<open>(\<close> |-- |
62969 | 842 |
Parse.!!! (Parse.position Parse.name -- Scan.repeat (Parse.maybe Parse.binding) |
67147 | 843 |
--| \<^keyword>\<open>)\<close>) || |
62969 | 844 |
Parse.position Parse.name >> rpair []) >> (Toplevel.proof o Proof.case_cmd)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
845 |
|
62856 | 846 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
847 |
|
62856 | 848 |
|
849 |
subsubsection \<open>Proof structure\<close> |
|
850 |
||
851 |
ML \<open> |
|
852 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
853 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
854 |
val _ = |
67147 | 855 |
Outer_Syntax.command \<^command_keyword>\<open>{\<close> "begin explicit proof block" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
856 |
(Scan.succeed (Toplevel.proof Proof.begin_block)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
857 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
858 |
val _ = |
67147 | 859 |
Outer_Syntax.command \<^command_keyword>\<open>}\<close> "end explicit proof block" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
860 |
(Scan.succeed (Toplevel.proof Proof.end_block)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
861 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
862 |
val _ = |
67147 | 863 |
Outer_Syntax.command \<^command_keyword>\<open>next\<close> "enter next proof block" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
864 |
(Scan.succeed (Toplevel.proof Proof.next_block)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
865 |
|
62856 | 866 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
867 |
|
62856 | 868 |
|
869 |
subsubsection \<open>End proof\<close> |
|
870 |
||
871 |
ML \<open> |
|
872 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
873 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
874 |
val _ = |
67147 | 875 |
Outer_Syntax.command \<^command_keyword>\<open>qed\<close> "conclude proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
876 |
(Scan.option Method.parse >> (fn m => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
877 |
(Option.map Method.report m; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
878 |
Isar_Cmd.qed m))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
879 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
880 |
val _ = |
67147 | 881 |
Outer_Syntax.command \<^command_keyword>\<open>by\<close> "terminal backward proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
882 |
(Method.parse -- Scan.option Method.parse >> (fn (m1, m2) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
883 |
(Method.report m1; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
884 |
Option.map Method.report m2; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
885 |
Isar_Cmd.terminal_proof (m1, m2)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
886 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
887 |
val _ = |
67147 | 888 |
Outer_Syntax.command \<^command_keyword>\<open>..\<close> "default proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
889 |
(Scan.succeed Isar_Cmd.default_proof); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
890 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
891 |
val _ = |
67147 | 892 |
Outer_Syntax.command \<^command_keyword>\<open>.\<close> "immediate proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
893 |
(Scan.succeed Isar_Cmd.immediate_proof); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
894 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
895 |
val _ = |
67147 | 896 |
Outer_Syntax.command \<^command_keyword>\<open>done\<close> "done proof" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
897 |
(Scan.succeed Isar_Cmd.done_proof); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
898 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
899 |
val _ = |
67147 | 900 |
Outer_Syntax.command \<^command_keyword>\<open>sorry\<close> "skip proof (quick-and-dirty mode only!)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
901 |
(Scan.succeed Isar_Cmd.skip_proof); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
902 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
903 |
val _ = |
67147 | 904 |
Outer_Syntax.command \<^command_keyword>\<open>\<proof>\<close> "dummy proof (quick-and-dirty mode only!)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
905 |
(Scan.succeed Isar_Cmd.skip_proof); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
906 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
907 |
val _ = |
67147 | 908 |
Outer_Syntax.command \<^command_keyword>\<open>oops\<close> "forget proof" |
68876
cefaac3d24ff
no reset_proof for notepad: begin/end structure takes precedence over goal/proof structure;
wenzelm
parents:
68827
diff
changeset
|
909 |
(Scan.succeed Toplevel.forget_proof); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
910 |
|
62856 | 911 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
912 |
|
62856 | 913 |
|
914 |
subsubsection \<open>Proof steps\<close> |
|
915 |
||
916 |
ML \<open> |
|
917 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
918 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
919 |
val _ = |
67147 | 920 |
Outer_Syntax.command \<^command_keyword>\<open>defer\<close> "shuffle internal proof state" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
921 |
(Scan.optional Parse.nat 1 >> (Toplevel.proof o Proof.defer)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
922 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
923 |
val _ = |
67147 | 924 |
Outer_Syntax.command \<^command_keyword>\<open>prefer\<close> "shuffle internal proof state" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
925 |
(Parse.nat >> (Toplevel.proof o Proof.prefer)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
926 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
927 |
val _ = |
67147 | 928 |
Outer_Syntax.command \<^command_keyword>\<open>apply\<close> "initial goal refinement step (unstructured)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
929 |
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply m)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
930 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
931 |
val _ = |
67147 | 932 |
Outer_Syntax.command \<^command_keyword>\<open>apply_end\<close> "terminal goal refinement step (unstructured)" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
933 |
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_end m)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
934 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
935 |
val _ = |
67147 | 936 |
Outer_Syntax.command \<^command_keyword>\<open>proof\<close> "backward proof step" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
937 |
(Scan.option Method.parse >> (fn m => |
63513
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
938 |
(Option.map Method.report m; |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
939 |
Toplevel.proof (fn state => |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
940 |
let |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
941 |
val state' = state |> Proof.proof m |> Seq.the_result ""; |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
942 |
val _ = |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
943 |
Output.information |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
944 |
(Proof_Context.print_cases_proof (Proof.context_of state) (Proof.context_of state')); |
9f8d06f23c09
information about proof outline with cases (sendback);
wenzelm
parents:
63510
diff
changeset
|
945 |
in state' end)))) |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
946 |
|
62856 | 947 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
948 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
949 |
|
62856 | 950 |
subsubsection \<open>Subgoal focus\<close> |
951 |
||
952 |
ML \<open> |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
953 |
local |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
954 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
955 |
val opt_fact_binding = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
956 |
Scan.optional (Parse.binding -- Parse.opt_attribs || Parse.attribs >> pair Binding.empty) |
63352 | 957 |
Binding.empty_atts; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
958 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
959 |
val for_params = |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
960 |
Scan.optional |
67147 | 961 |
(\<^keyword>\<open>for\<close> |-- |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
962 |
Parse.!!! ((Scan.option Parse.dots >> is_some) -- |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
963 |
(Scan.repeat1 (Parse.position (Parse.maybe Parse.name))))) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
964 |
(false, []); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
965 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
966 |
val _ = |
67147 | 967 |
Outer_Syntax.command \<^command_keyword>\<open>subgoal\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
968 |
"focus on first subgoal within backward refinement" |
67147 | 969 |
(opt_fact_binding -- (Scan.option (\<^keyword>\<open>premises\<close> |-- Parse.!!! opt_fact_binding)) -- |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
970 |
for_params >> (fn ((a, b), c) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
971 |
Toplevel.proofs (Seq.make_results o Seq.single o #2 o Subgoal.subgoal_cmd a b c))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
972 |
|
62856 | 973 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
974 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
975 |
|
62856 | 976 |
subsubsection \<open>Calculation\<close> |
977 |
||
978 |
ML \<open> |
|
979 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
980 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
981 |
val calculation_args = |
67147 | 982 |
Scan.option (\<^keyword>\<open>(\<close> |-- Parse.!!! ((Parse.thms1 --| \<^keyword>\<open>)\<close>))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
983 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
984 |
val _ = |
67147 | 985 |
Outer_Syntax.command \<^command_keyword>\<open>also\<close> "combine calculation and current facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
986 |
(calculation_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
987 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
988 |
val _ = |
67147 | 989 |
Outer_Syntax.command \<^command_keyword>\<open>finally\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
990 |
"combine calculation and current facts, exhibit result" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
991 |
(calculation_args >> (Toplevel.proofs' o Calculation.finally_cmd)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
992 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
993 |
val _ = |
67147 | 994 |
Outer_Syntax.command \<^command_keyword>\<open>moreover\<close> "augment calculation by current facts" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
995 |
(Scan.succeed (Toplevel.proof' Calculation.moreover)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
996 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
997 |
val _ = |
67147 | 998 |
Outer_Syntax.command \<^command_keyword>\<open>ultimately\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
999 |
"augment calculation by current facts, exhibit result" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1000 |
(Scan.succeed (Toplevel.proof' Calculation.ultimately)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1001 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1002 |
val _ = |
67147 | 1003 |
Outer_Syntax.command \<^command_keyword>\<open>print_trans_rules\<close> "print transitivity rules" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1004 |
(Scan.succeed (Toplevel.keep (Calculation.print_rules o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1005 |
|
62856 | 1006 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1007 |
|
62856 | 1008 |
|
1009 |
subsubsection \<open>Proof navigation\<close> |
|
1010 |
||
1011 |
ML \<open> |
|
1012 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1013 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1014 |
fun report_back () = |
64677
8dc24130e8fe
more uniform treatment of "bad" like other messages (with serial number);
wenzelm
parents:
64595
diff
changeset
|
1015 |
Output.report [Markup.markup (Markup.bad ()) "Explicit backtracking"]; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1016 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1017 |
val _ = |
67147 | 1018 |
Outer_Syntax.command \<^command_keyword>\<open>back\<close> "explicit backtracking of proof command" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1019 |
(Scan.succeed |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1020 |
(Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1021 |
Toplevel.skip_proof report_back)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1022 |
|
62856 | 1023 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1024 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1025 |
|
62856 | 1026 |
subsection \<open>Diagnostic commands (for interactive mode only)\<close> |
1027 |
||
1028 |
ML \<open> |
|
1029 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1030 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1031 |
val opt_modes = |
67147 | 1032 |
Scan.optional (\<^keyword>\<open>(\<close> |-- Parse.!!! (Scan.repeat1 Parse.name --| \<^keyword>\<open>)\<close>)) []; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1033 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1034 |
val _ = |
67147 | 1035 |
Outer_Syntax.command \<^command_keyword>\<open>help\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1036 |
"retrieve outer syntax commands according to name patterns" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1037 |
(Scan.repeat Parse.name >> |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1038 |
(fn pats => Toplevel.keep (fn st => Outer_Syntax.help (Toplevel.theory_of st) pats))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1039 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1040 |
val _ = |
67147 | 1041 |
Outer_Syntax.command \<^command_keyword>\<open>print_commands\<close> "print outer syntax commands" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1042 |
(Scan.succeed (Toplevel.keep (Outer_Syntax.print_commands o Toplevel.theory_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1043 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1044 |
val _ = |
67147 | 1045 |
Outer_Syntax.command \<^command_keyword>\<open>print_options\<close> "print configuration options" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1046 |
(Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_options b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1047 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1048 |
val _ = |
67147 | 1049 |
Outer_Syntax.command \<^command_keyword>\<open>print_context\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1050 |
"print context of local theory target" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1051 |
(Scan.succeed (Toplevel.keep (Pretty.writeln_chunks o Toplevel.pretty_context))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1052 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1053 |
val _ = |
67147 | 1054 |
Outer_Syntax.command \<^command_keyword>\<open>print_theory\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1055 |
"print logical theory contents" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1056 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1057 |
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_theory b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1058 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1059 |
val _ = |
67147 | 1060 |
Outer_Syntax.command \<^command_keyword>\<open>print_definitions\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1061 |
"print dependencies of definitional theory content" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1062 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1063 |
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_definitions b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1064 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1065 |
val _ = |
67147 | 1066 |
Outer_Syntax.command \<^command_keyword>\<open>print_syntax\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1067 |
"print inner syntax of context" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1068 |
(Scan.succeed (Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1069 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1070 |
val _ = |
67147 | 1071 |
Outer_Syntax.command \<^command_keyword>\<open>print_defn_rules\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1072 |
"print definitional rewrite rules of context" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1073 |
(Scan.succeed (Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1074 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1075 |
val _ = |
67147 | 1076 |
Outer_Syntax.command \<^command_keyword>\<open>print_abbrevs\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1077 |
"print constant abbreviations of context" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1078 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1079 |
Toplevel.keep (Proof_Context.print_abbrevs b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1080 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1081 |
val _ = |
67147 | 1082 |
Outer_Syntax.command \<^command_keyword>\<open>print_theorems\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1083 |
"print theorems of local theory or proof context" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1084 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1085 |
Toplevel.keep (Pretty.writeln o Pretty.chunks o Isar_Cmd.pretty_theorems b))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1086 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1087 |
val _ = |
67147 | 1088 |
Outer_Syntax.command \<^command_keyword>\<open>print_locales\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1089 |
"print locales of this theory" |
69059
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1090 |
(Parse.opt_bang >> (fn verbose => |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1091 |
Toplevel.keep (fn state => |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1092 |
let val thy = Toplevel.theory_of state |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1093 |
in Pretty.writeln (Locale.pretty_locales thy verbose) end))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1094 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1095 |
val _ = |
67147 | 1096 |
Outer_Syntax.command \<^command_keyword>\<open>print_classes\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1097 |
"print classes of this theory" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1098 |
(Scan.succeed (Toplevel.keep (Class.print_classes o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1099 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1100 |
val _ = |
67147 | 1101 |
Outer_Syntax.command \<^command_keyword>\<open>print_locale\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1102 |
"print locale of this theory" |
69057
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1103 |
(Parse.opt_bang -- Parse.position Parse.name >> (fn (show_facts, raw_name) => |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1104 |
Toplevel.keep (fn state => |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1105 |
let |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1106 |
val thy = Toplevel.theory_of state; |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1107 |
val name = Locale.check thy raw_name; |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1108 |
in Pretty.writeln (Locale.pretty_locale thy show_facts name) end))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1109 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1110 |
val _ = |
67147 | 1111 |
Outer_Syntax.command \<^command_keyword>\<open>print_interps\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1112 |
"print interpretations of locale for this theory or proof context" |
69059
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1113 |
(Parse.position Parse.name >> (fn raw_name => |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1114 |
Toplevel.keep (fn state => |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1115 |
let |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1116 |
val ctxt = Toplevel.context_of state; |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1117 |
val thy = Toplevel.theory_of state; |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1118 |
val name = Locale.check thy raw_name; |
70f9826753f6
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
69057
diff
changeset
|
1119 |
in Pretty.writeln (Locale.pretty_registrations ctxt name) end))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1120 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1121 |
val _ = |
67147 | 1122 |
Outer_Syntax.command \<^command_keyword>\<open>print_dependencies\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1123 |
"print dependencies of locale expression" |
69057
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1124 |
(Parse.opt_bang -- Parse_Spec.locale_expression >> (fn (clean, expr) => |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1125 |
Toplevel.keep (fn state => |
56c6378ebaea
tuned signature: prefer value-oriented pretty-printing;
wenzelm
parents:
68876
diff
changeset
|
1126 |
Pretty.writeln (Expression.pretty_dependencies (Toplevel.context_of state) clean expr)))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1127 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1128 |
val _ = |
67147 | 1129 |
Outer_Syntax.command \<^command_keyword>\<open>print_attributes\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1130 |
"print attributes of this theory" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1131 |
(Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_attributes b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1132 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1133 |
val _ = |
67147 | 1134 |
Outer_Syntax.command \<^command_keyword>\<open>print_simpset\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1135 |
"print context of Simplifier" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1136 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1137 |
Toplevel.keep (Pretty.writeln o Simplifier.pretty_simpset b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1138 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1139 |
val _ = |
67147 | 1140 |
Outer_Syntax.command \<^command_keyword>\<open>print_rules\<close> "print intro/elim rules" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1141 |
(Scan.succeed (Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1142 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1143 |
val _ = |
67147 | 1144 |
Outer_Syntax.command \<^command_keyword>\<open>print_methods\<close> "print methods of this theory" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1145 |
(Parse.opt_bang >> (fn b => Toplevel.keep (Method.print_methods b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1146 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1147 |
val _ = |
67147 | 1148 |
Outer_Syntax.command \<^command_keyword>\<open>print_antiquotations\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1149 |
"print document antiquotations" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1150 |
(Parse.opt_bang >> (fn b => |
67386 | 1151 |
Toplevel.keep (Document_Antiquotation.print_antiquotations b o Toplevel.context_of))); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1152 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1153 |
val _ = |
67147 | 1154 |
Outer_Syntax.command \<^command_keyword>\<open>print_ML_antiquotations\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1155 |
"print ML antiquotations" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1156 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1157 |
Toplevel.keep (ML_Context.print_antiquotations b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1158 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1159 |
val _ = |
67147 | 1160 |
Outer_Syntax.command \<^command_keyword>\<open>locale_deps\<close> "visualize locale dependencies" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1161 |
(Scan.succeed |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1162 |
(Toplevel.keep (Toplevel.theory_of #> (fn thy => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1163 |
Locale.pretty_locale_deps thy |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1164 |
|> map (fn {name, parents, body} => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1165 |
((name, Graph_Display.content_node (Locale.extern thy name) [body]), parents)) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1166 |
|> Graph_Display.display_graph_old)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1167 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1168 |
val _ = |
67147 | 1169 |
Outer_Syntax.command \<^command_keyword>\<open>print_term_bindings\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1170 |
"print term bindings of proof context" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1171 |
(Scan.succeed |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1172 |
(Toplevel.keep |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1173 |
(Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1174 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1175 |
val _ = |
67147 | 1176 |
Outer_Syntax.command \<^command_keyword>\<open>print_facts\<close> "print facts of proof context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1177 |
(Parse.opt_bang >> (fn b => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1178 |
Toplevel.keep (Proof_Context.print_local_facts b o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1179 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1180 |
val _ = |
67147 | 1181 |
Outer_Syntax.command \<^command_keyword>\<open>print_cases\<close> "print cases of proof context" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1182 |
(Scan.succeed |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1183 |
(Toplevel.keep (Pretty.writeln_chunks o Proof_Context.pretty_cases o Toplevel.context_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1184 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1185 |
val _ = |
67147 | 1186 |
Outer_Syntax.command \<^command_keyword>\<open>print_statement\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1187 |
"print theorems as long statements" |
62969 | 1188 |
(opt_modes -- Parse.thms1 >> Isar_Cmd.print_stmts); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1189 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1190 |
val _ = |
67147 | 1191 |
Outer_Syntax.command \<^command_keyword>\<open>thm\<close> "print theorems" |
62969 | 1192 |
(opt_modes -- Parse.thms1 >> Isar_Cmd.print_thms); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1193 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1194 |
val _ = |
67147 | 1195 |
Outer_Syntax.command \<^command_keyword>\<open>prf\<close> "print proof terms of theorems" |
62969 | 1196 |
(opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs false); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1197 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1198 |
val _ = |
67147 | 1199 |
Outer_Syntax.command \<^command_keyword>\<open>full_prf\<close> "print full proof terms of theorems" |
62969 | 1200 |
(opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs true); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1201 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1202 |
val _ = |
67147 | 1203 |
Outer_Syntax.command \<^command_keyword>\<open>prop\<close> "read and print proposition" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1204 |
(opt_modes -- Parse.term >> Isar_Cmd.print_prop); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1205 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1206 |
val _ = |
67147 | 1207 |
Outer_Syntax.command \<^command_keyword>\<open>term\<close> "read and print term" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1208 |
(opt_modes -- Parse.term >> Isar_Cmd.print_term); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1209 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1210 |
val _ = |
67147 | 1211 |
Outer_Syntax.command \<^command_keyword>\<open>typ\<close> "read and print type" |
1212 |
(opt_modes -- (Parse.typ -- Scan.option (\<^keyword>\<open>::\<close> |-- Parse.!!! Parse.sort)) |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1213 |
>> Isar_Cmd.print_type); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1214 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1215 |
val _ = |
67147 | 1216 |
Outer_Syntax.command \<^command_keyword>\<open>print_codesetup\<close> "print code generator setup" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1217 |
(Scan.succeed (Toplevel.keep (Code.print_codesetup o Toplevel.theory_of))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1218 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1219 |
val _ = |
67147 | 1220 |
Outer_Syntax.command \<^command_keyword>\<open>print_state\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1221 |
"print current proof state (if present)" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1222 |
(opt_modes >> (fn modes => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1223 |
Toplevel.keep (Print_Mode.with_modes modes (Output.state o Toplevel.string_of_state)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1224 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1225 |
val _ = |
67147 | 1226 |
Outer_Syntax.command \<^command_keyword>\<open>welcome\<close> "print welcome message" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1227 |
(Scan.succeed (Toplevel.keep (fn _ => writeln (Session.welcome ())))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1228 |
|
62856 | 1229 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1230 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1231 |
|
62856 | 1232 |
subsection \<open>Dependencies\<close> |
1233 |
||
1234 |
ML \<open> |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1235 |
local |
62856 | 1236 |
|
1237 |
val theory_bounds = |
|
62969 | 1238 |
Parse.position Parse.theory_name >> single || |
67147 | 1239 |
(\<^keyword>\<open>(\<close> |-- Parse.enum "|" (Parse.position Parse.theory_name) --| \<^keyword>\<open>)\<close>); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1240 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1241 |
val _ = |
67147 | 1242 |
Outer_Syntax.command \<^command_keyword>\<open>thy_deps\<close> "visualize theory dependencies" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1243 |
(Scan.option theory_bounds -- Scan.option theory_bounds >> |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1244 |
(fn args => Toplevel.keep (fn st => Thy_Deps.thy_deps_cmd (Toplevel.context_of st) args))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1245 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1246 |
|
62856 | 1247 |
val class_bounds = |
1248 |
Parse.sort >> single || |
|
67147 | 1249 |
(\<^keyword>\<open>(\<close> |-- Parse.enum "|" Parse.sort --| \<^keyword>\<open>)\<close>); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1250 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1251 |
val _ = |
67147 | 1252 |
Outer_Syntax.command \<^command_keyword>\<open>class_deps\<close> "visualize class dependencies" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1253 |
(Scan.option class_bounds -- Scan.option class_bounds >> (fn args => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1254 |
Toplevel.keep (fn st => Class_Deps.class_deps_cmd (Toplevel.context_of st) args))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1255 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1256 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1257 |
val _ = |
67147 | 1258 |
Outer_Syntax.command \<^command_keyword>\<open>thm_deps\<close> "visualize theorem dependencies" |
62969 | 1259 |
(Parse.thms1 >> (fn args => |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1260 |
Toplevel.keep (fn st => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1261 |
Thm_Deps.thm_deps (Toplevel.theory_of st) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1262 |
(Attrib.eval_thms (Toplevel.context_of st) args)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1263 |
|
62856 | 1264 |
|
1265 |
val thy_names = |
|
62969 | 1266 |
Scan.repeat1 (Scan.unless Parse.minus (Parse.position Parse.theory_name)); |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1267 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1268 |
val _ = |
67147 | 1269 |
Outer_Syntax.command \<^command_keyword>\<open>unused_thms\<close> "find unused theorems" |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1270 |
(Scan.option ((thy_names --| Parse.minus) -- Scan.option thy_names) >> (fn opt_range => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1271 |
Toplevel.keep (fn st => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1272 |
let |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1273 |
val thy = Toplevel.theory_of st; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1274 |
val ctxt = Toplevel.context_of st; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1275 |
fun pretty_thm (a, th) = Proof_Context.pretty_fact ctxt (a, [th]); |
68482 | 1276 |
val check = Theory.check {long = false} ctxt; |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1277 |
in |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1278 |
Thm_Deps.unused_thms |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1279 |
(case opt_range of |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1280 |
NONE => (Theory.parents_of thy, [thy]) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1281 |
| SOME (xs, NONE) => (map check xs, [thy]) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1282 |
| SOME (xs, SOME ys) => (map check xs, map check ys)) |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1283 |
|> map pretty_thm |> Pretty.writeln_chunks |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1284 |
end))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1285 |
|
62856 | 1286 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1287 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1288 |
|
62856 | 1289 |
subsubsection \<open>Find consts and theorems\<close> |
1290 |
||
1291 |
ML \<open> |
|
1292 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1293 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1294 |
val _ = |
67147 | 1295 |
Outer_Syntax.command \<^command_keyword>\<open>find_consts\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1296 |
"find constants by name / type patterns" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1297 |
(Find_Consts.query_parser >> (fn spec => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1298 |
Toplevel.keep (fn st => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1299 |
Pretty.writeln (Find_Consts.pretty_consts (Toplevel.context_of st) spec)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1300 |
|
62856 | 1301 |
val options = |
1302 |
Scan.optional |
|
1303 |
(Parse.$$$ "(" |-- |
|
1304 |
Parse.!!! (Scan.option Parse.nat -- |
|
1305 |
Scan.optional (Parse.reserved "with_dups" >> K false) true --| Parse.$$$ ")")) |
|
1306 |
(NONE, true); |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1307 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1308 |
val _ = |
67147 | 1309 |
Outer_Syntax.command \<^command_keyword>\<open>find_theorems\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1310 |
"find theorems meeting specified criteria" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1311 |
(options -- Find_Theorems.query_parser >> (fn ((opt_lim, rem_dups), spec) => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1312 |
Toplevel.keep (fn st => |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1313 |
Pretty.writeln |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1314 |
(Find_Theorems.pretty_theorems (Find_Theorems.proof_state st) opt_lim rem_dups spec)))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1315 |
|
62856 | 1316 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1317 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1318 |
|
62856 | 1319 |
subsection \<open>Code generation\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1320 |
|
62856 | 1321 |
ML \<open> |
1322 |
local |
|
1323 |
||
1324 |
val _ = |
|
67147 | 1325 |
Outer_Syntax.command \<^command_keyword>\<open>code_datatype\<close> |
62856 | 1326 |
"define set of code datatype constructors" |
66251
cd935b7cb3fb
proper concept of code declaration wrt. atomicity and Isar declarations
haftmann
parents:
66248
diff
changeset
|
1327 |
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.declare_datatype_cmd)); |
62856 | 1328 |
|
1329 |
in end\<close> |
|
1330 |
||
1331 |
||
1332 |
subsection \<open>Extraction of programs from proofs\<close> |
|
1333 |
||
1334 |
ML \<open> |
|
1335 |
local |
|
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1336 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1337 |
val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1338 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1339 |
val _ = |
67147 | 1340 |
Outer_Syntax.command \<^command_keyword>\<open>realizers\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1341 |
"specify realizers for primitive axioms / theorems, together with correctness proof" |
62969 | 1342 |
(Scan.repeat1 (Parse.name -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1343 |
(fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1344 |
(map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1345 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1346 |
val _ = |
67147 | 1347 |
Outer_Syntax.command \<^command_keyword>\<open>realizability\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1348 |
"add equations characterizing realizability" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1349 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1350 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1351 |
val _ = |
67147 | 1352 |
Outer_Syntax.command \<^command_keyword>\<open>extract_type\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1353 |
"add equations characterizing type of extracted program" |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1354 |
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1355 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1356 |
val _ = |
67147 | 1357 |
Outer_Syntax.command \<^command_keyword>\<open>extract\<close> "extract terms from proofs" |
62969 | 1358 |
(Scan.repeat1 (Parse.name -- parse_vars) >> (fn xs => Toplevel.theory (fn thy => |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1359 |
Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1360 |
|
62856 | 1361 |
in end\<close> |
62849
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1362 |
|
caaa2fc4040d
clarified bootstrap -- avoid 'ML_file' in Pure.thy for uniformity;
wenzelm
parents:
62848
diff
changeset
|
1363 |
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62913
diff
changeset
|
1364 |
section \<open>Auxiliary lemmas\<close> |
20627 | 1365 |
|
58611 | 1366 |
subsection \<open>Meta-level connectives in assumptions\<close> |
15803 | 1367 |
|
1368 |
lemma meta_mp: |
|
58612 | 1369 |
assumes "PROP P \<Longrightarrow> PROP Q" and "PROP P" |
15803 | 1370 |
shows "PROP Q" |
58612 | 1371 |
by (rule \<open>PROP P \<Longrightarrow> PROP Q\<close> [OF \<open>PROP P\<close>]) |
15803 | 1372 |
|
23432 | 1373 |
lemmas meta_impE = meta_mp [elim_format] |
1374 |
||
15803 | 1375 |
lemma meta_spec: |
58612 | 1376 |
assumes "\<And>x. PROP P x" |
26958 | 1377 |
shows "PROP P x" |
58612 | 1378 |
by (rule \<open>\<And>x. PROP P x\<close>) |
15803 | 1379 |
|
1380 |
lemmas meta_allE = meta_spec [elim_format] |
|
1381 |
||
26570 | 1382 |
lemma swap_params: |
58612 | 1383 |
"(\<And>x y. PROP P x y) \<equiv> (\<And>y x. PROP P x y)" .. |
26570 | 1384 |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1385 |
|
58611 | 1386 |
subsection \<open>Meta-level conjunction\<close> |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1387 |
|
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1388 |
lemma all_conjunction: |
58612 | 1389 |
"(\<And>x. PROP A x &&& PROP B x) \<equiv> ((\<And>x. PROP A x) &&& (\<And>x. PROP B x))" |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1390 |
proof |
58612 | 1391 |
assume conj: "\<And>x. PROP A x &&& PROP B x" |
1392 |
show "(\<And>x. PROP A x) &&& (\<And>x. PROP B x)" |
|
19121 | 1393 |
proof - |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1394 |
fix x |
26958 | 1395 |
from conj show "PROP A x" by (rule conjunctionD1) |
1396 |
from conj show "PROP B x" by (rule conjunctionD2) |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1397 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1398 |
next |
58612 | 1399 |
assume conj: "(\<And>x. PROP A x) &&& (\<And>x. PROP B x)" |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1400 |
fix x |
28856
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
wenzelm
parents:
28699
diff
changeset
|
1401 |
show "PROP A x &&& PROP B x" |
19121 | 1402 |
proof - |
26958 | 1403 |
show "PROP A x" by (rule conj [THEN conjunctionD1, rule_format]) |
1404 |
show "PROP B x" by (rule conj [THEN conjunctionD2, rule_format]) |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1405 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1406 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1407 |
|
19121 | 1408 |
lemma imp_conjunction: |
58612 | 1409 |
"(PROP A \<Longrightarrow> PROP B &&& PROP C) \<equiv> ((PROP A \<Longrightarrow> PROP B) &&& (PROP A \<Longrightarrow> PROP C))" |
18836 | 1410 |
proof |
58612 | 1411 |
assume conj: "PROP A \<Longrightarrow> PROP B &&& PROP C" |
1412 |
show "(PROP A \<Longrightarrow> PROP B) &&& (PROP A \<Longrightarrow> PROP C)" |
|
19121 | 1413 |
proof - |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1414 |
assume "PROP A" |
58611 | 1415 |
from conj [OF \<open>PROP A\<close>] show "PROP B" by (rule conjunctionD1) |
1416 |
from conj [OF \<open>PROP A\<close>] show "PROP C" by (rule conjunctionD2) |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1417 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1418 |
next |
58612 | 1419 |
assume conj: "(PROP A \<Longrightarrow> PROP B) &&& (PROP A \<Longrightarrow> PROP C)" |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1420 |
assume "PROP A" |
28856
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
wenzelm
parents:
28699
diff
changeset
|
1421 |
show "PROP B &&& PROP C" |
19121 | 1422 |
proof - |
58611 | 1423 |
from \<open>PROP A\<close> show "PROP B" by (rule conj [THEN conjunctionD1]) |
1424 |
from \<open>PROP A\<close> show "PROP C" by (rule conj [THEN conjunctionD2]) |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1425 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1426 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1427 |
|
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1428 |
lemma conjunction_imp: |
58612 | 1429 |
"(PROP A &&& PROP B \<Longrightarrow> PROP C) \<equiv> (PROP A \<Longrightarrow> PROP B \<Longrightarrow> PROP C)" |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1430 |
proof |
58612 | 1431 |
assume r: "PROP A &&& PROP B \<Longrightarrow> PROP C" |
22933 | 1432 |
assume ab: "PROP A" "PROP B" |
1433 |
show "PROP C" |
|
1434 |
proof (rule r) |
|
28856
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
wenzelm
parents:
28699
diff
changeset
|
1435 |
from ab show "PROP A &&& PROP B" . |
22933 | 1436 |
qed |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1437 |
next |
58612 | 1438 |
assume r: "PROP A \<Longrightarrow> PROP B \<Longrightarrow> PROP C" |
28856
5e009a80fe6d
Pure syntax: more coherent treatment of aprop, permanent TERM and &&&;
wenzelm
parents:
28699
diff
changeset
|
1439 |
assume conj: "PROP A &&& PROP B" |
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1440 |
show "PROP C" |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1441 |
proof (rule r) |
19121 | 1442 |
from conj show "PROP A" by (rule conjunctionD1) |
1443 |
from conj show "PROP B" by (rule conjunctionD2) |
|
18466
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1444 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1445 |
qed |
389a6f9c31f4
added locale meta_conjunction_syntax and various conjunction rules;
wenzelm
parents:
18019
diff
changeset
|
1446 |
|
68816
5a53724fe247
support named ML environments, notably "Isabelle", "SML";
wenzelm
parents:
68813
diff
changeset
|
1447 |
declare [[ML_write_global = false]] |
5a53724fe247
support named ML environments, notably "Isabelle", "SML";
wenzelm
parents:
68813
diff
changeset
|
1448 |
|
48638 | 1449 |
end |