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