ML \<open> local
val _ =
Outer_Syntax.command \<^command_keyword>\<open>external_file\<close> "formal dependency on external file"
(Resources.provide_parse_file >> (fn get_file => Toplevel.theory (#2 o get_file)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>bibtex_file\<close> "check bibtex database file in Prover IDE"
(Resources.provide_parse_file >> (fn get_file =>
Toplevel.theory (fn thy => let
val ({lines, pos, ...}, thy') = get_file thy;
val _ = Bibtex.check_database_output pos (cat_lines lines); in thy' end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ROOTS_file\<close> "session ROOTS file"
(Resources.provide_parse_file >> (fn get_file =>
Toplevel.theory (fn thy => let
val ({src_path, lines, pos = pos0, ...}, thy') = get_file thy;
val ctxt = Proof_Context.init_global thy';
val dir = Path.dir (Path.expand (Resources.master_directory thy' + src_path));
val _ =
(lines, pos0) |-> fold (fn line => fn pos1 => let
val pos2 = Position.symbol_explode line pos1;
val range = Position.range (pos1, pos2);
val source = Input.source true line range;
val _ = if line = ""then ()
else if String.isPrefix "#" line then
Context_Position.report ctxt (#1 range) Markup.comment
else
(ignore (Resources.check_session_dir ctxt (SOME dir) source)
handle ERROR msg => Output.error_message msg); in pos2 |> Position.symbol "\n" end); in thy' end)));
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>generate_file\<close> "generate source file, with antiquotations"
(Parse.path_binding -- (\<^keyword>\<open>=\<close> |-- Parse.embedded_input)
>> Generated_Files.generate_file_cmd);
val files_in_theory =
(Parse.underscore >> K [] || Scan.repeat1 Parse.path_binding) --
Scan.option (\<^keyword>\<open>(\<close> |-- Parse.!!! (\<^keyword>\<open>in\<close> |-- Parse.theory_name --| \<^keyword>\<open>)\<close>));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>export_generated_files\<close> "export generated files from given theories"
(Parse.and_list1 files_in_theory >> (fn args =>
Toplevel.keep (fn st =>
Generated_Files.export_generated_files_cmd (Toplevel.context_of st) args)));
val semi = Scan.option \<^keyword>\<open>;\<close>;
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_file\<close> "read and evaluate Isabelle/ML file"
(Resources.parse_file --| semi >> ML_File.ML NONE);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_file_debug\<close> "read and evaluate Isabelle/ML file (with debugger information)"
(Resources.parse_file --| semi >> ML_File.ML (SOME true));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_file_no_debug\<close> "read and evaluate Isabelle/ML file (no debugger information)"
(Resources.parse_file --| semi >> ML_File.ML (SOME false));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>SML_file\<close> "read and evaluate Standard ML file"
(Resources.parse_file --| semi >> ML_File.SML NONE);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>SML_file_debug\<close> "read and evaluate Standard ML file (with debugger information)"
(Resources.parse_file --| semi >> ML_File.SML (SOME true));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>SML_file_no_debug\<close> "read and evaluate Standard ML file (no debugger information)"
(Resources.parse_file --| semi >> ML_File.SML (SOME false));
val _ =
Outer_Syntax.command ("ML_export", \<^here>) "ML text within theory or local theory, and export to bootstrap environment"
(Parse.ML_source >> (fn source =>
Toplevel.generic_theory (fn context => context
|> Config.put_generic ML_Env.ML_environment ML_Env.Isabelle
|> Config.put_generic ML_Env.ML_write_global true
|> ML_Context.exec (fn () =>
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source)
|> Config.restore_generic ML_Env.ML_write_global context
|> Config.restore_generic ML_Env.ML_environment context
|> Local_Theory.propagate_ml_env)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_prf\<close> "ML text within proof"
(Parse.ML_source >> (fn source =>
Toplevel.proof (Proof.map_context (Context.proof_map
(ML_Context.exec (fn () =>
ML_Context.eval_source (ML_Compiler.verbose true ML_Compiler.flags) source))) #> Proof.propagate_ml_env)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_val\<close> "diagnostic ML text"
(Parse.ML_source >> Isar_Cmd.ml_diag true);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ML_command\<close> "diagnostic ML text (silent)"
(Parse.ML_source >> Isar_Cmd.ml_diag false);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>setup\<close> "ML setup for global theory"
(Parse.ML_source >> (Toplevel.theory o Isar_Cmd.setup));
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>local_setup\<close> "ML setup for local theory"
(Parse.ML_source >> Isar_Cmd.local_setup);
fun trans_arrow toks =
((\<^keyword>\<open>\<rightharpoonup>\<close> || \<^keyword>\<open>=>\<close>) >> K Syntax.Parse_Rule ||
(\<^keyword>\<open>\<leftharpoondown>\<close> || \<^keyword>\<open><=\<close>) >> K Syntax.Print_Rule ||
(\<^keyword>\<open>\<rightleftharpoons>\<close> || \<^keyword>\<open>==\<close>) >> K Syntax.Parse_Print_Rule) toks;
val _ =
Outer_Syntax.command \<^command_keyword>\<open>axiomatization\<close> "axiomatic constant specification"
(Scan.optional Parse.vars [] --
Scan.optional (Parse.where_ |-- Parse.!!! axiomatization) ([], [], [])
>> (fn (a, (b, c, d)) => Toplevel.theory (#2 o Specification.axiomatization_cmd a b c d)));
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>alias\<close> "name-space alias for constant"
(Parse.binding -- (Parse.!!! \<^keyword>\<open>=\<close> |-- Parse.name_position)
>> Specification.alias_cmd);
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>type_alias\<close> "name-space alias for type constructor"
(Parse.binding -- (Parse.!!! \<^keyword>\<open>=\<close> |-- Parse.name_position)
>> Specification.type_alias_cmd);
inend\<close>
subsubsection \<open>Notation\<close>
ML \<open> local
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>type_notation\<close> "add concrete syntax for type constructors"
(Parse.syntax_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
>> (fn (mode, args) => Local_Theory.type_notation_cmd true mode args));
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>no_type_notation\<close> "delete concrete syntax for type constructors"
(Parse.syntax_mode -- Parse.and_list1 (Parse.type_const -- Parse.mixfix)
>> (fn (mode, args) => Local_Theory.type_notation_cmd false mode args));
val _ =
Outer_Syntax.maybe_begin_local_theory \<^command_keyword>\<open>bundle\<close> "define bundle of declarations" (bundle_cmd false) (bundle_begin false);
val _ =
Outer_Syntax.maybe_begin_local_theory \<^command_keyword>\<open>open_bundle\<close> "define and open bundle of declarations" (bundle_cmd true) (bundle_begin true);
val _ =
Outer_Syntax.local_theory \<^command_keyword>\<open>unbundle\<close> "open bundle in local theory" (Parse_Spec.bundles >> Bundle.unbundle_cmd);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>include\<close> "open bundle in proof body" (Parse_Spec.bundles >> (Toplevel.proof o Bundle.include_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>including\<close> "open bundle in goal refinement" (Parse_Spec.bundles >> (Toplevel.proof o Bundle.including_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_bundles\<close> "print bundles of declarations"
(Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of)));
inend\<close>
subsection \<open>Local theory specifications\<close>
val _ =
Outer_Syntax.command \<^command_keyword>\<open>end\<close> "end context"
(Scan.succeed
(Toplevel.exit o Toplevel.end_main_target o Toplevel.end_nested_target o
Toplevel.end_proof (K Proof.end_notepad)));
inend\<close>
subsubsection \<open>Locales and interpretation\<close>
ML \<open> local
val locale_context_elements =
Scan.repeat1 Parse_Spec.context_element;
val _ =
Outer_Syntax.local_theory_to_proof \<^command_keyword>\<open>global_interpretation\<close> "prove interpretation of locale expression into global theory"
(interpretation_args_with_defs >> (fn (expr, defs) => Interpretation.global_interpretation_cmd expr defs));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>sublocale\<close> "prove sublocale relation between a locale and a locale expression"
((Parse.name_position --| (\<^keyword>\<open>\<subseteq>\<close> || \<^keyword>\<open><\<close>) --
interpretation_args_with_defs >> (fn (loc, (expr, defs)) =>
Toplevel.theory_to_proof (Interpretation.global_sublocale_cmd loc expr defs)))
|| interpretation_args_with_defs >> (fn (expr, defs) =>
Toplevel.local_theory_to_proof NONE NONE (Interpretation.sublocale_cmd expr defs)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>interpretation\<close> "prove interpretation of locale expression in local theory or into global theory"
(Parse.!!! Parse_Spec.locale_expression >> (fn expr =>
Toplevel.local_theory_to_proof NONE NONE
(Interpretation.isar_interpretation_cmd expr)));
inend\<close>
subsubsection \<open>Type classes\<close>
ML \<open> local
val class_context_elements =
Scan.repeat1 Parse_Spec.context_element;
val _ =
Outer_Syntax.command \<^command_keyword>\<open>have\<close> "state local goal"
(structured_statement >> (fn (a, b, c, d) =>
Toplevel.proof' (fn int => Proof.have_cmd a NONE (K I) b c d int #> #2)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>show\<close> "state local goal, to refine pending subgoals"
(structured_statement >> (fn (a, b, c, d) =>
Toplevel.proof' (fn int => Proof.show_cmd a NONE (K I) b c d int #> #2)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>hence\<close> "old-style alias of \"then have\""
(structured_statement >> (fn (a, b, c, d) =>
Toplevel.proof' (fn int => Proof.chain #> Proof.have_cmd a NONE (K I) b c d int #> #2)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>thus\<close> "old-style alias of \"then show\""
(structured_statement >> (fn (a, b, c, d) =>
Toplevel.proof' (fn int => Proof.chain #> Proof.show_cmd a NONE (K I) b c d int #> #2)));
inend\<close>
subsubsection \<open>Local facts\<close>
ML \<open> local
val facts = Parse.and_list1 Parse.thms1;
val _ =
Outer_Syntax.command \<^command_keyword>\<open>then\<close> "forward chaining"
(Scan.succeed (Toplevel.proofProof.chain));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>from\<close> "forward chaining from given facts"
(facts >> (Toplevel.proof o Proof.from_thmss_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>with\<close> "forward chaining from given and current facts"
(facts >> (Toplevel.proof o Proof.with_thmss_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>note\<close> "define facts"
(Parse_Spec.name_facts >> (Toplevel.proof o Proof.note_thmss_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>supply\<close> "define facts during goal refinement (unstructured)"
(Parse_Spec.name_facts >> (Toplevel.proof o Proof.supply_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>using\<close> "augment goal facts"
(facts >> (Toplevel.proof o Proof.using_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>unfolding\<close> "unfold definitions in goal and facts"
(facts >> (Toplevel.proof o Proof.unfolding_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>fix\<close> "fix local variables (Skolem constants)"
(Parse.vars >> (Toplevel.proof o Proof.fix_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>assume\<close> "assume propositions"
(structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.assume_cmd a b c)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>presume\<close> "assume propositions, to be established later"
(structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.presume_cmd a b c)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>define\<close> "local definition (non-polymorphic)"
((Parse.vars --| Parse.where_) -- Parse_Spec.statement -- Parse.for_fixes
>> (fn ((a, b), c) => Toplevel.proof (Proof.define_cmd a c b)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>consider\<close> "state cases rule"
(Parse_Spec.obtains >> (Toplevel.proof' o Obtain.consider_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>obtain\<close> "generalized elimination"
(Parse.parbinding -- Scan.optional (Parse.vars --| Parse.where_) [] -- structured_statement
>> (fn ((a, b), (c, d, e)) => Toplevel.proof' (Obtain.obtain_cmd a b c d e)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>let\<close> "bind text variables"
(Parse.and_list1 (Parse.and_list1 Parse.term -- (\<^keyword>\<open>=\<close> |-- Parse.term))
>> (Toplevel.proof o Proof.let_bind_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>oops\<close> "forget proof"
(Scan.succeed Toplevel.forget_proof);
inend\<close>
subsubsection \<open>Proof steps\<close>
ML \<open> local
val _ =
Outer_Syntax.command \<^command_keyword>\<open>defer\<close> "shuffle internal proof state"
(Scan.optional Parse.nat 1 >> (Toplevel.proof o Proof.defer));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>prefer\<close> "shuffle internal proof state"
(Parse.nat >> (Toplevel.proof o Proof.prefer));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>apply\<close> "initial goal refinement step (unstructured)"
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply m))));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>apply_end\<close> "terminal goal refinement step (unstructured)"
(Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_end m))));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>proof\<close> "backward proof step"
(Scan.option Method.parse >> (fn m =>
(Option.map Method.report m;
Toplevel.proof (fn state => let
val state' = state |> Proof.proof m |> Seq.the_result "";
val _ = Output.information
(Proof_Context.print_cases_proof (Proof.context_of state) (Proof.context_of state')); in state' end))))
val _ =
Outer_Syntax.command \<^command_keyword>\<open>subgoal\<close> "focus on first subgoal within backward refinement"
(opt_fact_binding -- (Scan.option (\<^keyword>\<open>premises\<close> |-- Parse.!!! opt_fact_binding)) --
for_params >> (fn ((a, b), c) =>
Toplevel.proofs (Seq.make_results o Seq.single o #2 o Subgoal.subgoal_cmd a b c)));
inend\<close>
subsubsection \<open>Calculation\<close>
ML \<open> local
val calculation_args =
Scan.option (\<^keyword>\<open>(\<close> |-- Parse.!!! ((Parse.thms1 --| \<^keyword>\<open>)\<close>)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>also\<close> "combine calculation and current facts"
(calculation_args >> (Toplevel.proofs' o Calculation.also_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>finally\<close> "combine calculation and current facts, exhibit result"
(calculation_args >> (Toplevel.proofs' o Calculation.finally_cmd));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>moreover\<close> "augment calculation by current facts"
(Scan.succeed (Toplevel.proof' Calculation.moreover));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>ultimately\<close> "augment calculation by current facts, exhibit result"
(Scan.succeed (Toplevel.proof' Calculation.ultimately));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_trans_rules\<close> "print transitivity rules"
(Scan.succeed (Toplevel.keep (Calculation.print_rules o Toplevel.context_of)));
inend\<close>
subsubsection \<open>Proof navigation\<close>
ML \<open> local
fun report_back () = Output.report [Markup.markup (Markup.bad ()) "Explicit backtracking"];
val _ =
Outer_Syntax.command \<^command_keyword>\<open>back\<close> "explicit backtracking of proof command"
(Scan.succeed
(Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.backprf)) o
Toplevel.skip_proof report_back));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>help\<close> "retrieve outer syntax commands according to name patterns"
(Scan.repeat Parse.name >>
(fn pats => Toplevel.keep (fn st => Outer_Syntax.help (Toplevel.theory_of st) pats)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_commands\<close> "print outer syntax commands"
(Scan.succeed (Toplevel.keep (Outer_Syntax.print_commands o Toplevel.theory_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_options\<close> "print configuration options"
(Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_options b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_context\<close> "print context of local theory target"
(Scan.succeed (Toplevel.keep (Pretty.writeln o Pretty.chunks o Toplevel.pretty_context)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_theory\<close> "print logical theory contents"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_theory b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_definitions\<close> "print dependencies of definitional theory content"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Pretty.writeln o Proof_Display.pretty_definitions b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_syntax\<close> "print inner syntax of context"
(Scan.succeed (Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_defn_rules\<close> "print definitional rewrite rules of context"
(Scan.succeed (Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_abbrevs\<close> "print constant abbreviations of context"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Proof_Context.print_abbrevs b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_theorems\<close> "print theorems of local theory or proof context"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Pretty.writeln o Pretty.chunks o Isar_Cmd.pretty_theorems b)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_locales\<close> "print locales of this theory"
(Parse.opt_bang >> (fn verbose =>
Toplevel.keep (fn state => let val thy = Toplevel.theory_of state in Pretty.writeln (Locale.pretty_locales thy verbose) end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_classes\<close> "print classes of this theory"
(Scan.succeed (Toplevel.keep (Class.print_classes o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_locale\<close> "print locale of this theory"
(Parse.opt_bang -- Parse.name_position >> (fn (show_facts, raw_name) =>
Toplevel.keep (fn state => let
val thy = Toplevel.theory_of state;
val ctxt = Toplevel.context_of state;
val name = Locale.check ctxt raw_name; in Pretty.writeln (Locale.pretty_locale thy show_facts name) end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_interps\<close> "print interpretations of locale for this theory or proof context"
(Parse.name_position >> (fn raw_name =>
Toplevel.keep (fn state => let
val thy = Toplevel.theory_of state;
val ctxt = Toplevel.context_of state;
val name = Locale.check ctxt raw_name; in Pretty.writeln (Locale.pretty_registrations ctxt name) end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_attributes\<close> "print attributes of this theory"
(Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_attributes b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_simpset\<close> "print context of Simplifier"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Pretty.writeln o Simplifier.pretty_simpset b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_rules\<close> "print intro/elim rules"
(Scan.succeed (Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_methods\<close> "print methods of this theory"
(Parse.opt_bang >> (fn b => Toplevel.keep (Method.print_methods b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_antiquotations\<close> "print document antiquotations"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Document_Antiquotation.print_antiquotations b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_ML_antiquotations\<close> "print ML antiquotations"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (ML_Context.print_antiquotations b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>locale_deps\<close> "visualize locale dependencies"
(Scan.succeed (Toplevel.keep (fn state => let
val thy = Toplevel.theory_of state;
val ctxt = Toplevel.context_of state; in Locale.pretty_locale_deps thy
|> map (fn {name, parents, body} =>
((name, Graph_Display.content_node (Locale.extern ctxt name) [body]), parents))
|> Graph_Display.display_graph_old end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_term_bindings\<close> "print term bindings of proof context"
(Scan.succeed
(Toplevel.keep
(Pretty.writeln o Pretty.chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_facts\<close> "print facts of proof context"
(Parse.opt_bang >> (fn b =>
Toplevel.keep (Proof_Context.print_local_facts b o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_cases\<close> "print cases of proof context"
(Scan.succeed
(Toplevel.keep
(Pretty.writeln o Pretty.chunks o Proof_Context.pretty_cases o Toplevel.context_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_statement\<close> "print theorems as long statements"
(opt_modes -- Parse.thms1 >> Isar_Cmd.print_stmts);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>prf\<close> "print proof terms of theorems"
(opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs false);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>full_prf\<close> "print full proof terms of theorems"
(opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs true);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>prop\<close> "read and print proposition"
(opt_modes -- Parse.term >> Isar_Cmd.print_prop);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>term\<close> "read and print term"
(opt_modes -- Parse.term >> Isar_Cmd.print_term);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>typ\<close> "read and print type"
(opt_modes -- (Parse.typ -- Scan.option (\<^keyword>\<open>::\<close> |-- Parse.!!! Parse.sort))
>> Isar_Cmd.print_type);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_codesetup\<close> "print code generator setup"
(Scan.succeed (Toplevel.keep (Code.print_codesetup o Toplevel.theory_of)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_context_tracing\<close> "print result of context tracing from ML heap"
(Scan.repeat Parse.name_position >> (fn raw_names => Toplevel.keep (fn st => let
val pred = if null raw_names then K true
else let
val ctxt = Toplevel.context_of st;
val insert = Symset.insert o Context.theory_long_name o Thy_Info.check_theory ctxt;
val names = Symset.build (fold insert raw_names); in Symset.member names o Context.theory_long_name o Context.theory_of end; in Session.print_context_tracing pred end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>print_state\<close> "print current proof state (if present)"
(opt_modes >> (fn modes =>
Toplevel.keep
(Print_Mode.with_modes modes
(Output.writelns o Pretty.strings_of o Pretty.chunks o Toplevel.pretty_state))));
val theory_bounds =
Parse.theory_name >> single ||
(\<^keyword>\<open>(\<close> |-- Parse.enum "|" Parse.theory_name --| \<^keyword>\<open>)\<close>);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>thy_deps\<close> "visualize theory dependencies"
(Scan.option theory_bounds -- Scan.option theory_bounds >>
(fn args => Toplevel.keep (fn st => Thy_Deps.thy_deps_cmd (Toplevel.context_of st) args)));
val class_bounds =
Parse.sort >> single ||
(\<^keyword>\<open>(\<close> |-- Parse.enum "|" Parse.sort --| \<^keyword>\<open>)\<close>);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>class_deps\<close> "visualize class dependencies"
(Scan.option class_bounds -- Scan.option class_bounds >> (fn args =>
Toplevel.keep (fn st => Class_Deps.class_deps_cmd (Toplevel.context_of st) args)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>thm_deps\<close> "print theorem dependencies (immediate non-transitive)"
(Parse.thms1 >> (fn args =>
Toplevel.keep (fn st => let val ctxt = Toplevel.context_of st in Pretty.writeln (Thm_Deps.pretty_thm_deps ctxt (Attrib.eval_thms ctxt args)) end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>thm_oracles\<close> "print all oracles used in theorems (full graph of transitive dependencies)"
(Parse.thms1 >> (fn args =>
Toplevel.keep (fn st => let
val ctxt = Toplevel.context_of st;
val thms = Attrib.eval_thms ctxt args; in Pretty.writeln (Thm_Deps.pretty_thm_oracles ctxt thms) end)));
val thy_names = Scan.repeat1 (Scan.unless Parse.minus Parse.theory_name);
val _ =
Outer_Syntax.command \<^command_keyword>\<open>unused_thms\<close> "find unused theorems"
(Scan.option ((thy_names --| Parse.minus) -- Scan.option thy_names) >> (fn opt_range =>
Toplevel.keep (fn st => let
val thy = Toplevel.theory_of st;
val ctxt = Toplevel.context_of st; fun pretty_thm (a, th) =
Pretty.block [Pretty.quote (Proof_Context.pretty_thm_name ctxt a),
Pretty.str ":", Pretty.brk 1, Thm.pretty_thm ctxt th];
val check = Theory.check {long = false} ctxt; in Thm_Deps.unused_thms_cmd
(case opt_range of
NONE => (Theory.parents_of thy, [thy])
| SOME (xs, NONE) => (map check xs, [thy])
| SOME (xs, SOME ys) => (map check xs, map check ys))
|> map pretty_thm |> Pretty.chunks |> Pretty.writeln end)));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>code_datatype\<close> "define set of code datatype constructors"
(Scan.repeat1 Parse.term >> (Toplevel.theory o Code.declare_datatype_cmd));
inend\<close>
subsection \<open>Extraction of programs from proofs\<close>
val _ =
Outer_Syntax.command \<^command_keyword>\<open>realizability\<close> "add equations characterizing realizability"
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns));
val _ =
Outer_Syntax.command \<^command_keyword>\<open>extract_type\<close> "add equations characterizing type of extracted program"
(Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns));
subsection \<open>Meta-level connectives in assumptions\<close>
lemma meta_mp: assumes"PROP P \ PROP Q" and "PROP P" shows"PROP Q" by (rule \<open>PROP P \<Longrightarrow> PROP Q\<close> [OF \<open>PROP P\<close>])
lemmas meta_impE = meta_mp [elim_format]
lemma meta_spec: assumes"\x. PROP P x" shows"PROP P x" by (rule \<open>\<And>x. PROP P x\<close>)
lemmas meta_allE = meta_spec [elim_format]
lemma swap_params: "(\x y. PROP P x y) \ (\y x. PROP P x y)" ..
lemma equal_allI: \<open>(\<And>x. PROP P x) \<equiv> (\<And>x. PROP Q x)\<close> if \<open>\<And>x. PROP P x \<equiv> PROP Q x\<close> by (simp only: that)
subsection \<open>Meta-level conjunction\<close>
lemma all_conjunction: "(\x. PROP A x &&& PROP B x) \ ((\x. PROP A x) &&& (\x. PROP B x))" proof assume conj: "\x. PROP A x &&& PROP B x" show"(\x. PROP A x) &&& (\x. PROP B x)" proof - fix x from conj show"PROP A x"by (rule conjunctionD1) from conj show"PROP B x"by (rule conjunctionD2) qed next assume conj: "(\x. PROP A x) &&& (\x. PROP B x)" fix x show"PROP A x &&& PROP B x" proof - show"PROP A x"by (rule conj [THEN conjunctionD1, rule_format]) show"PROP B x"by (rule conj [THEN conjunctionD2, rule_format]) qed qed
lemma imp_conjunction: "(PROP A \ PROP B &&& PROP C) \ ((PROP A \ PROP B) &&& (PROP A \ PROP C))" proof assume conj: "PROP A \ PROP B &&& PROP C" show"(PROP A \ PROP B) &&& (PROP A \ PROP C)" proof - assume"PROP A" from conj [OF \<open>PROP A\<close>] show "PROP B" by (rule conjunctionD1) from conj [OF \<open>PROP A\<close>] show "PROP C" by (rule conjunctionD2) qed next assume conj: "(PROP A \ PROP B) &&& (PROP A \ PROP C)" assume"PROP A" show"PROP B &&& PROP C" proof - from\<open>PROP A\<close> show "PROP B" by (rule conj [THEN conjunctionD1]) from\<open>PROP A\<close> show "PROP C" by (rule conj [THEN conjunctionD2]) qed qed
lemma conjunction_imp: "(PROP A &&& PROP B \ PROP C) \ (PROP A \ PROP B \ PROP C)" proof assume r: "PROP A &&& PROP B \ PROP C" assume ab: "PROP A""PROP B" show"PROP C" proof (rule r) from ab show"PROP A &&& PROP B" . qed next assume r: "PROP A \ PROP B \ PROP C" assume conj: "PROP A &&& PROP B" show"PROP C" proof (rule r) from conj show"PROP A"by (rule conjunctionD1) from conj show"PROP B"by (rule conjunctionD2) qed qed
section \<open>Misc\<close>
bundle constrain_space_syntax \<comment> \<open>type constraints with spacing\<close> begin no_syntax (output) "_constrain" :: "logic \ type \ logic" (\_::_\ [4, 0] 3) "_constrain" :: "prop' \ type \ prop'" (\_::_\ [4, 0] 3) syntax (output) "_constrain" :: "logic \ type \ logic" (\_ :: _\ [4, 0] 3) "_constrain" :: "prop' \ type \ prop'" (\_ :: _\ [4, 0] 3) end
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.