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