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