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