ML ‹ local val _ = Outer_Syntax.command 🍋‹external_file› " (Resources.provide_parse_file >> (fn get_file => Toplevel.theory (#2 o get_file)));
val _ = Outer_Syntax.command 🍋‹bibtex_file› "check bibtex database filein 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 🍋‹ROOTS_file› "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 🍋‹generate_file› "generate source file, with antiquotations" (Parse.path_binding -- (🍋‹=› |-- Parse.embedded_input) >> Generated_Files.generate_file_cmd);
val files_in_theory = (Parse.underscore >> K [] || Scan.repeat1 Parse.path_binding) -- Scan.option (🍋‹(› |-- Parse.!!! (🍋‹in› |-- Parse.theory_name --| 🍋‹)›));
val _ = Outer_Syntax.command 🍋‹export_generated_files› "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 _ = Outer_Syntax.command 🍋‹scala_build_generated_files› "build and export Isabelle/Scala/Java module" (Parse.and_list files_in_theory -- Scan.optional (🍋‹external_files› |-- Parse.!!! (Parse.and_list1 external_files)) [] >> (fn (args, external) => Toplevel.keep (fn st => Generated_Files.scala_build_generated_files_cmd (Toplevel.context_of st) args external))); in end›
external_file ‹ROOT0.ML› external_file ‹ROOT.ML›
subsection ‹Embedded ML text›
ML ‹ local val semi = Scan.option 🍋‹;›;
val _ = Outer_Syntax.command 🍋‹ML_file› "read and evaluate Isabelle/ML file" (Resources.parse_file --| semi >> ML_File.ML NONE);
val _ = Outer_Syntax.command 🍋‹ML_file_debug› "read and evaluate Isabelle/ML file (with debugger information)" (Resources.parse_file --| semi >> ML_File.ML (SOME true));
val _ = Outer_Syntax.command 🍋‹ML_file_no_debug› "read and evaluate Isabelle/ML file (no debugger information)" (Resources.parse_file --| semi >> ML_File.ML (SOME false));
val _ = Outer_Syntax.command 🍋‹SML_file› "read and evaluate Standard ML file" (Resources.parse_file --| semi >> ML_File.SML NONE);
val _ = Outer_Syntax.command 🍋‹SML_file_debug› "read and evaluate Standard ML file (with debugger information)" (Resources.parse_file --| semi >> ML_File.SML (SOME true));
val _ = Outer_Syntax.command 🍋‹SML_file_no_debug› "read and evaluate Standard ML file (no debugger information)" (Resources.parse_file --| semi >> ML_File.SML (SOME false));
val _ = Outer_Syntax.local_theory 🍋‹simproc_setup› "define simproc in ML" Simplifier.simproc_setup_command;
in end›
subsection ‹Theory commands›
subsubsection ‹Sorts and types›
ML ‹ local val _ = Outer_Syntax.local_theory 🍋‹default_sort› "declare default sort for explicit type variables" (Parse.sort >> (fn s => fn lthy => Local_Theory.set_defsort (Syntax.read_sort lthy s) lthy));
ML ‹ local val _ = Outer_Syntax.command 🍋‹judgment› " (Parse.const_binding >> (Toplevel.theory o Object_Logic.add_judgment_cmd));
val _ = Outer_Syntax.command 🍋‹consts› "declare constants" (Scan.repeat1 Parse.const_binding >> (Toplevel.theory o Sign.add_consts_cmd));
in end›
subsubsection ‹Syntax and translations›
ML ‹ local val _ = Outer_Syntax.command 🍋‹nonterminal› "declare syntactic type constructors (grammar nonterminal symbols)" (Parse.and_list1 Parse.binding >> (Toplevel.theory o Sign.add_nonterminals_global));
val _ = Outer_Syntax.local_theory 🍋‹syntax› "add raw syntax clauses" (Parse.syntax_mode -- Scan.repeat1 Parse.const_decl >> uncurry (Local_Theory.syntax_cmd true));
val _ = Outer_Syntax.local_theory 🍋‹no_syntax› "delete raw syntax clauses" (Parse.syntax_mode -- Scan.repeat1 Parse.const_decl >> uncurry (Local_Theory.syntax_cmd false));
fun trans_arrow toks = ((🍋‹⇀› || 🍋‹=>›) >> K Syntax.Parse_Rule || (🍋‹↽› || 🍋‹<=›) >> K Syntax.Print_Rule || (🍋‹⇌› || 🍋‹==›) >> K Syntax.Parse_Print_Rule) toks;
ML ‹ local val _ = Outer_Syntax.command 🍋‹parse_ast_translation› "install parse ast translation functions" (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_ast_translation));
val _ = Outer_Syntax.command 🍋‹parse_translation› "install parse translation functions" (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.parse_translation));
val _ = Outer_Syntax.command 🍋‹print_translation› "install print translation functions" (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_translation));
val _ = Outer_Syntax.command 🍋‹typed_print_translation› "install typed print translation functions" (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.typed_print_translation));
val _ = Outer_Syntax.command 🍋‹print_ast_translation› "install print ast translation functions" (Parse.ML_source >> (Toplevel.theory o Isar_Cmd.print_ast_translation));
val _ = Outer_Syntax.command 🍋‹axiomatization› "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 🍋‹alias› "name-space alias for constant" (Parse.binding -- (Parse.!!! 🍋‹=› |-- Parse.name_position) >> Specification.alias_cmd);
val _ = Outer_Syntax.local_theory 🍋‹type_alias› "name-space alias for type constructor" (Parse.binding -- (Parse.!!! 🍋‹=› |-- Parse.name_position) >> Specification.type_alias_cmd);
in end›
subsubsection ‹Notation›
ML ‹ local val _ = Outer_Syntax.local_theory 🍋‹type_notation› "add concrete syntaxfor 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.command 🍋‹include› "open bundle inproof body" (Parse_Spec.bundles >> (Toplevel.proof o Bundle.include_cmd));
val _ = Outer_Syntax.command 🍋‹including› "open bundle in goal refinement" (Parse_Spec.bundles >> (Toplevel.proof o Bundle.including_cmd));
val _ = Outer_Syntax.command 🍋‹print_bundles› "print bundles of declarations" (Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹end› "endcontext" (Scan.succeed (Toplevel.exit o Toplevel.end_main_target o Toplevel.end_nested_target o Toplevel.end_proof (K Proof.end_notepad)));
in end›
subsubsection ‹Locales and interpretation›
ML ‹ local val locale_context_elements = Scan.repeat1 Parse_Spec.context_element; val locale_val = ((Parse_Spec.locale_expression -- Scan.optional Parse_Spec.opening []) || Parse_Spec.opening >> pair ([], [])) -- Scan.optional (🍋‹+› | || locale_context_elements >> pair (([], []), []);
val _ = Outer_Syntax.command 🍋‹locale› "define named specificationcontext" (Parse.binding -- Scan.optional (🍋‹=› |-- Parse.!!! locale_val) ((([], []), []), []) -- Parse.opt_begin >> (fn ((name, ((expr, includes), elems)), begin) => Toplevel.begin_main_target begin (Expression.add_locale_cmd name Binding.empty includes expr elems #> snd)));
ML ‹ local val _ = Outer_Syntax.command 🍋‹overloading› " (Scan.repeat1 (Parse.name --| (🍋‹==› || 🍋‹≡›) -- Parse.term -- Scan.optional (🍋‹(› |-- (🍋‹unchecked› >> K false) --| 🍋‹)›) true >> Scan.triple1) --| Parse.begin >> (fn operations => Toplevel.begin_main_target true (Overloading.overloading_cmd operations)));
in end›
subsection ‹Proof commands›
ML ‹ local val _ = Outer_Syntax.local_theory_to_proof 🍋‹notepad› " (Parse.begin >> K Proof.begin_notepad);
in end›
subsubsection ‹Statements›
ML ‹ local val structured_statement = Parse_Spec.statement -- Parse_Spec.cond_statement -- Parse.for_fixes >> (fn ((shows, (strict, assumes)), fixes) => (strict, fixes, assumes, shows)); val _ = Outer_Syntax.command 🍋‹have› " (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 🍋‹show› "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 🍋‹hence› "old-style alias of \"thenhave\"" (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 🍋‹thus› "old-style alias of \"thenshow\"" (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)));
in end›
subsubsection ‹Local facts›
ML ‹ local val facts = Parse.and_list1 Parse.thms1; val _ = Outer_Syntax.command 🍋‹then› " (Scan.succeed (Toplevel.proof Proof.chain));
val _ = Outer_Syntax.command 🍋‹from› "forward chaining from given facts" (facts >> (Toplevel.proof o Proof.from_thmss_cmd));
val _ = Outer_Syntax.command 🍋‹with› "forward chaining from given and current facts" (facts >> (Toplevel.proof o Proof.with_thmss_cmd));
val _ = Outer_Syntax.command 🍋‹note› "define facts" (Parse_Spec.name_facts >> (Toplevel.proof o Proof.note_thmss_cmd));
val _ = Outer_Syntax.command 🍋‹supply› "define facts during goal refinement (unstructured)" (Parse_Spec.name_facts >> (Toplevel.proof o Proof.supply_cmd));
val _ = Outer_Syntax.command 🍋‹using› "augment goal facts" (facts >> (Toplevel.proof o Proof.using_cmd));
val _ = Outer_Syntax.command 🍋‹unfolding› "unfold definitions in goal and facts" (facts >> (Toplevel.proof o Proof.unfolding_cmd));
in end›
subsubsection ‹Proof context›
ML ‹ local val structured_statement = Parse_Spec.statement -- Parse_Spec.if_statement' -- Parse.for_fixes >> (fn ((shows, assumes), fixes) => (fixes, assumes, shows)); val _ = Outer_Syntax.command 🍋‹fix› " (Parse.vars >> (Toplevel.proof o Proof.fix_cmd));
val _ = Outer_Syntax.command 🍋‹assume› "assume propositions" (structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.assume_cmd a b c)));
val _ = Outer_Syntax.command 🍋‹presume› "assume propositions, to be established later" (structured_statement >> (fn (a, b, c) => Toplevel.proof (Proof.presume_cmd a b c)));
val _ = Outer_Syntax.command 🍋‹define› "localdefinition (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 🍋‹consider› "state cases rule" (Parse_Spec.obtains >> (Toplevel.proof' o Obtain.consider_cmd));
val _ = Outer_Syntax.command 🍋‹obtain› "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 🍋‹let› "bind text variables" (Parse.and_list1 (Parse.and_list1 Parse.term -- (🍋‹=› |-- Parse.term)) >> (Toplevel.proof o Proof.let_bind_cmd));
val _ = Outer_Syntax.command 🍋‹oops› "forget proof" (Scan.succeed Toplevel.forget_proof);
in end›
subsubsection ‹Proof steps›
ML ‹ local val _ = Outer_Syntax.command 🍋‹defer› " (Scan.optional Parse.nat 1 >> (Toplevel.proof o Proof.defer));
val _ = Outer_Syntax.command 🍋‹prefer› "shuffle internal proof state" (Parse.nat >> (Toplevel.proof o Proof.prefer));
val _ = Outer_Syntax.command 🍋‹apply› "initial goal refinement step (unstructured)" (Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply m))));
val _ = Outer_Syntax.command 🍋‹apply_end› "terminal goal refinement step (unstructured)" (Method.parse >> (fn m => (Method.report m; Toplevel.proofs (Proof.apply_end m))));
val _ = Outer_Syntax.command 🍋‹proof› "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))))
in end›
subsubsection ‹Subgoal focus›
ML ‹ local val opt_fact_binding = Scan.optional (Parse.binding -- Parse.opt_attribs || Parse.attribs >> pair Binding.empty) Binding.empty_atts; val for_params = Scan.optional (🍋‹for› | Parse.!!! ((Scan.option Parse.dots >> is_some) -- (Scan.repeat1 (Parse.maybe_position Parse.name_position)))) (false, []);
val _ = Outer_Syntax.command 🍋‹subgoal› "focus on first subgoal within backward refinement" (opt_fact_binding -- (Scan.option (🍋‹premises› |-- 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)));
in end›
subsubsection ‹Calculation›
ML ‹ local val calculation_args = Scan.option (🍋‹(› |
val _ = Outer_Syntax.command 🍋‹also› "combine calculation and current facts" (calculation_args >> (Toplevel.proofs' o Calculation.also_cmd));
val _ = Outer_Syntax.command 🍋‹finally› "combine calculation and current facts, exhibit result" (calculation_args >> (Toplevel.proofs' o Calculation.finally_cmd));
val _ = Outer_Syntax.command 🍋‹moreover› "augment calculation by current facts" (Scan.succeed (Toplevel.proof' Calculation.moreover));
val _ = Outer_Syntax.command 🍋‹ultimately› "augment calculation by current facts, exhibit result" (Scan.succeed (Toplevel.proof' Calculation.ultimately));
val _ = Outer_Syntax.command 🍋‹print_trans_rules› "print transitivity rules" (Scan.succeed (Toplevel.keep (Calculation.print_rules o Toplevel.context_of)));
in end›
subsubsection ‹Proof navigation›
ML ‹ local fun report_back () = Output.report [Markup.markup (Markup.bad ()) "Explicit backtracking"]; val _ = Outer_Syntax.command 🍋‹back› " (Scan.succeed (Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o Toplevel.skip_proof report_back));
val _ = Outer_Syntax.command 🍋‹help› "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 🍋‹print_commands› "print outer syntax commands" (Scan.succeed (Toplevel.keep (Outer_Syntax.print_commands o Toplevel.theory_of)));
val _ = Outer_Syntax.command 🍋‹print_options› "print configuration options" (Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_options b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_context› "print context of localtheory target" (Scan.succeed (Toplevel.keep (Pretty.writeln o Pretty.chunks o Toplevel.pretty_context)));
val _ = Outer_Syntax.command 🍋‹print_theory› "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 🍋‹print_definitions› "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 🍋‹print_syntax› "print inner syntax of context" (Scan.succeed (Toplevel.keep (Proof_Context.print_syntax o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_defn_rules› "print definitional rewrite rules of context" (Scan.succeed (Toplevel.keep (Local_Defs.print_rules o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_abbrevs› "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 🍋‹print_theorems› "print theorems of localtheory or proofcontext" (Parse.opt_bang >> (fn b => Toplevel.keep (Pretty.writeln o Pretty.chunks o Isar_Cmd.pretty_theorems b)));
val _ = Outer_Syntax.command 🍋‹print_locales› "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 🍋‹print_classes› "print classes of this theory" (Scan.succeed (Toplevel.keep (Class.print_classes o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_locale› "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 🍋‹print_interps› "print interpretations of localefor this theory or proofcontext" (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 🍋‹print_attributes› "print attributes of this theory" (Parse.opt_bang >> (fn b => Toplevel.keep (Attrib.print_attributes b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_simpset› "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 🍋‹print_rules› "print intro/elim rules" (Scan.succeed (Toplevel.keep (Context_Rules.print_rules o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_methods› "print methods of this theory" (Parse.opt_bang >> (fn b => Toplevel.keep (Method.print_methods b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_antiquotations› "print document antiquotations" (Parse.opt_bang >> (fn b => Toplevel.keep (Document_Antiquotation.print_antiquotations b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_ML_antiquotations› "print ML antiquotations" (Parse.opt_bang >> (fn b => Toplevel.keep (ML_Context.print_antiquotations b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹locale_deps› "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 🍋‹print_term_bindings› "print term bindings of proofcontext" (Scan.succeed (Toplevel.keep (Pretty.writeln o Pretty.chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_facts› "print facts of proofcontext" (Parse.opt_bang >> (fn b => Toplevel.keep (Proof_Context.print_local_facts b o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_cases› "print cases of proofcontext" (Scan.succeed (Toplevel.keep (Pretty.writeln o Pretty.chunks o Proof_Context.pretty_cases o Toplevel.context_of)));
val _ = Outer_Syntax.command 🍋‹print_statement› "print theorems as long statements" (opt_modes -- Parse.thms1 >> Isar_Cmd.print_stmts);
val _ = Outer_Syntax.command 🍋‹prf› "print proof terms of theorems" (opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs false);
val _ = Outer_Syntax.command 🍋‹full_prf› "print full proof terms of theorems" (opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs true);
val _ = Outer_Syntax.command 🍋‹prop› "read and print proposition" (opt_modes -- Parse.term >> Isar_Cmd.print_prop);
val _ = Outer_Syntax.command 🍋‹term› "read and print term" (opt_modes -- Parse.term >> Isar_Cmd.print_term);
val _ = Outer_Syntax.command 🍋‹typ› "read and print type" (opt_modes -- (Parse.typ -- Scan.option (🍋‹::› |-- Parse.!!! Parse.sort)) >> Isar_Cmd.print_type);
val _ = Outer_Syntax.command 🍋‹print_codesetup› "print code generator setup" (Scan.succeed (Toplevel.keep (Code.print_codesetup o Toplevel.theory_of)));
val _ = Outer_Syntax.command 🍋‹print_context_tracing› "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 🍋‹print_state› "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))));
ML ‹ local val theory_bounds = Parse.theory_name >> single || (🍋‹(› |
val _ = Outer_Syntax.command 🍋‹thy_deps› "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 || (🍋‹(› |-- Parse.enum "|" Parse.sort --| 🍋‹)›);
val _ = Outer_Syntax.command 🍋‹class_deps› "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 🍋‹thm_deps› "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 🍋‹thm_oracles› "print all oracles used intheorems (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 🍋‹unused_thms› "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)));
in end›
subsubsection ‹Adhoc overloading›
ML ‹ local val adhoc_overloading_args = Parse.and_list1 ((Parse.const --| (🍋‹⇌› |
ML ‹ local val _ = Outer_Syntax.command 🍋‹find_consts› "find constants by name / type patterns" (Find_Consts.query_parser >> (fn spec => Toplevel.keep (fn st => Pretty.writeln (Find_Consts.pretty_consts (Toplevel.context_of st) spec)))); val options = Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Scan.option Parse.nat -- Scan.optional (Parse.reserved "with_dups" >> K false) true --| Parse.$$$ ")")) (NONE, true); val _ = Outer_Syntax.command 🍋‹find_theorems› "find theorems meeting specified criteria" (options -- Find_Theorems.query_parser >> (fn ((opt_lim, rem_dups), spec) => Toplevel.keep (fn st => Pretty.writeln (Find_Theorems.pretty_theorems (Find_Theorems.proof_state st) opt_lim rem_dups spec)))); in end›
subsection ‹Code generation›
ML ‹ local val _ = Outer_Syntax.command 🍋‹code_datatype› "define set of code datatype constructors" (Scan.repeat1 Parse.term >> (Toplevel.theory o Code.declare_datatype_cmd)); in end›
subsection ‹Extraction of programs from proofs›
ML ‹ local val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; val _ = Outer_Syntax.command 🍋‹realizers› "specify realizers for primitive axioms / theorems, together with correctness proof" (Scan.repeat1 (Parse.name -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> (fn xs => Toplevel.theory (fn thy => Extraction.add_realizers (map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy))); val _ = Outer_Syntax.command 🍋‹realizability› "add equations characterizing realizability" (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_realizes_eqns)); val _ = Outer_Syntax.command 🍋‹extract_type› "add equations characterizing type of extracted program" (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); val _ = Outer_Syntax.command 🍋‹extract›"extract terms from proofs" (Scan.repeat1 (Parse.name -- parse_vars) >> (fn xs => Toplevel.theory (fn thy => Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); in end›
section ‹Auxiliary lemmas›
subsection ‹Meta-level connectives in assumptions›
lemma meta_mp: assumes "PROP P ==>PROP Q" and "PROP P" shows "PROP Q" by (rule ‹PROP P ==> PROP Q› [OF ‹PROP P›])
lemmas meta_impE = meta_mp [elim_format]
lemma meta_spec: assumes "∧x. PROP P x" shows "PROP P x" by (rule ‹∧x. PROP P x›)
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: ‹(∧x. PROP P x) ≡ (∧x. PROP Q x)› if ‹∧x. PROP P x ≡ PROP Q x› by (simp only: that)
subsection ‹Meta-level conjunction›
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 ‹PROP A›] show "PROP B" by (rule conjunctionD1) from conj [OF ‹PROP A›] 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 ‹PROP A› show "PROP B" by (rule conj [THEN conjunctionD1]) from ‹PROP A› 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 ‹Misc›
bundle constrain_space_syntax 🍋‹type constraints with spacing› 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.46Bemerkung:
(vorverarbeitet am 2026-04-30)
¤
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 und die Messung sind noch experimentell.