equal
deleted
inserted
replaced
278 (Parse.syntax_mode -- Scan.repeat1 Parse.const_decl |
278 (Parse.syntax_mode -- Scan.repeat1 Parse.const_decl |
279 >> (Toplevel.theory o uncurry Sign.del_syntax_cmd)); |
279 >> (Toplevel.theory o uncurry Sign.del_syntax_cmd)); |
280 |
280 |
281 val trans_pat = |
281 val trans_pat = |
282 Scan.optional |
282 Scan.optional |
283 (@{keyword "("} |-- Parse.!!! (Parse.inner_syntax Parse.xname --| @{keyword ")"})) "logic" |
283 (@{keyword "("} |-- Parse.!!! (Parse.inner_syntax Parse.name --| @{keyword ")"})) "logic" |
284 -- Parse.inner_syntax Parse.string; |
284 -- Parse.inner_syntax Parse.string; |
285 |
285 |
286 fun trans_arrow toks = |
286 fun trans_arrow toks = |
287 ((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule || |
287 ((@{keyword "\<rightharpoonup>"} || @{keyword "=>"}) >> K Syntax.Parse_Rule || |
288 (@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule || |
288 (@{keyword "\<leftharpoondown>"} || @{keyword "<="}) >> K Syntax.Print_Rule || |
401 (Parse_Spec.name_facts -- Parse.for_fixes >> |
401 (Parse_Spec.name_facts -- Parse.for_fixes >> |
402 (fn (facts, fixes) => #2 oo Specification.theorems_cmd Thm.theoremK facts fixes)); |
402 (fn (facts, fixes) => #2 oo Specification.theorems_cmd Thm.theoremK facts fixes)); |
403 |
403 |
404 val _ = |
404 val _ = |
405 Outer_Syntax.local_theory' @{command_keyword declare} "declare theorems" |
405 Outer_Syntax.local_theory' @{command_keyword declare} "declare theorems" |
406 (Parse.and_list1 Parse.xthms1 -- Parse.for_fixes |
406 (Parse.and_list1 Parse.thms1 -- Parse.for_fixes |
407 >> (fn (facts, fixes) => |
407 >> (fn (facts, fixes) => |
408 #2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes)); |
408 #2 oo Specification.theorems_cmd "" [(Attrib.empty_binding, flat facts)] fixes)); |
409 |
409 |
410 val _ = |
410 val _ = |
411 Outer_Syntax.local_theory @{command_keyword named_theorems} |
411 Outer_Syntax.local_theory @{command_keyword named_theorems} |
440 hide_names @{command_keyword hide_const} "consts" Sign.hide_const Parse.const |
440 hide_names @{command_keyword hide_const} "consts" Sign.hide_const Parse.const |
441 ((#1 o dest_Const) oo Proof_Context.read_const {proper = true, strict = false}); |
441 ((#1 o dest_Const) oo Proof_Context.read_const {proper = true, strict = false}); |
442 |
442 |
443 val _ = |
443 val _ = |
444 hide_names @{command_keyword hide_fact} "facts" Global_Theory.hide_fact |
444 hide_names @{command_keyword hide_fact} "facts" Global_Theory.hide_fact |
445 (Parse.position Parse.xname) (Global_Theory.check_fact o Proof_Context.theory_of); |
445 (Parse.position Parse.name) (Global_Theory.check_fact o Proof_Context.theory_of); |
446 |
446 |
447 in end\<close> |
447 in end\<close> |
448 |
448 |
449 |
449 |
450 subsection \<open>Bundled declarations\<close> |
450 subsection \<open>Bundled declarations\<close> |
452 ML \<open> |
452 ML \<open> |
453 local |
453 local |
454 |
454 |
455 val _ = |
455 val _ = |
456 Outer_Syntax.local_theory @{command_keyword bundle} "define bundle of declarations" |
456 Outer_Syntax.local_theory @{command_keyword bundle} "define bundle of declarations" |
457 ((Parse.binding --| @{keyword "="}) -- Parse.xthms1 -- Parse.for_fixes |
457 ((Parse.binding --| @{keyword "="}) -- Parse.thms1 -- Parse.for_fixes |
458 >> (uncurry Bundle.bundle_cmd)); |
458 >> (uncurry Bundle.bundle_cmd)); |
459 |
459 |
460 val _ = |
460 val _ = |
461 Outer_Syntax.command @{command_keyword include} |
461 Outer_Syntax.command @{command_keyword include} |
462 "include declarations from bundle in proof body" |
462 "include declarations from bundle in proof body" |
463 (Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.include_cmd)); |
463 (Scan.repeat1 (Parse.position Parse.name) >> (Toplevel.proof o Bundle.include_cmd)); |
464 |
464 |
465 val _ = |
465 val _ = |
466 Outer_Syntax.command @{command_keyword including} |
466 Outer_Syntax.command @{command_keyword including} |
467 "include declarations from bundle in goal refinement" |
467 "include declarations from bundle in goal refinement" |
468 (Scan.repeat1 (Parse.position Parse.xname) >> (Toplevel.proof o Bundle.including_cmd)); |
468 (Scan.repeat1 (Parse.position Parse.name) >> (Toplevel.proof o Bundle.including_cmd)); |
469 |
469 |
470 val _ = |
470 val _ = |
471 Outer_Syntax.command @{command_keyword print_bundles} |
471 Outer_Syntax.command @{command_keyword print_bundles} |
472 "print bundles of declarations" |
472 "print bundles of declarations" |
473 (Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of))); |
473 (Parse.opt_bang >> (fn b => Toplevel.keep (Bundle.print_bundles b o Toplevel.context_of))); |
482 ML \<open> |
482 ML \<open> |
483 local |
483 local |
484 |
484 |
485 val _ = |
485 val _ = |
486 Outer_Syntax.command @{command_keyword context} "begin local theory context" |
486 Outer_Syntax.command @{command_keyword context} "begin local theory context" |
487 ((Parse.position Parse.xname >> (fn name => |
487 ((Parse.position Parse.name >> (fn name => |
488 Toplevel.begin_local_theory true (Named_Target.begin name)) || |
488 Toplevel.begin_local_theory true (Named_Target.begin name)) || |
489 Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element |
489 Scan.optional Parse_Spec.includes [] -- Scan.repeat Parse_Spec.context_element |
490 >> (fn (incls, elems) => Toplevel.open_target (#2 o Bundle.context_cmd incls elems))) |
490 >> (fn (incls, elems) => Toplevel.open_target (#2 o Bundle.context_cmd incls elems))) |
491 --| Parse.begin); |
491 --| Parse.begin); |
492 |
492 |
548 Interpretation.global_interpretation_cmd expr defs equations)); |
548 Interpretation.global_interpretation_cmd expr defs equations)); |
549 |
549 |
550 val _ = |
550 val _ = |
551 Outer_Syntax.command @{command_keyword sublocale} |
551 Outer_Syntax.command @{command_keyword sublocale} |
552 "prove sublocale relation between a locale and a locale expression" |
552 "prove sublocale relation between a locale and a locale expression" |
553 ((Parse.position Parse.xname --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
553 ((Parse.position Parse.name --| (@{keyword "\<subseteq>"} || @{keyword "<"}) -- |
554 interpretation_args_with_defs >> (fn (loc, (expr, (defs, equations))) => |
554 interpretation_args_with_defs >> (fn (loc, (expr, (defs, equations))) => |
555 Toplevel.theory_to_proof (Interpretation.global_sublocale_cmd loc expr defs equations))) |
555 Toplevel.theory_to_proof (Interpretation.global_sublocale_cmd loc expr defs equations))) |
556 || interpretation_args_with_defs >> (fn (expr, (defs, equations)) => |
556 || interpretation_args_with_defs >> (fn (expr, (defs, equations)) => |
557 Toplevel.local_theory_to_proof NONE NONE (Interpretation.sublocale_cmd expr defs equations))); |
557 Toplevel.local_theory_to_proof NONE NONE (Interpretation.sublocale_cmd expr defs equations))); |
558 |
558 |
682 subsubsection \<open>Local facts\<close> |
682 subsubsection \<open>Local facts\<close> |
683 |
683 |
684 ML \<open> |
684 ML \<open> |
685 local |
685 local |
686 |
686 |
687 val facts = Parse.and_list1 Parse.xthms1; |
687 val facts = Parse.and_list1 Parse.thms1; |
688 |
688 |
689 val _ = |
689 val _ = |
690 Outer_Syntax.command @{command_keyword then} "forward chaining" |
690 Outer_Syntax.command @{command_keyword then} "forward chaining" |
691 (Scan.succeed (Toplevel.proof Proof.chain)); |
691 (Scan.succeed (Toplevel.proof Proof.chain)); |
692 |
692 |
771 |
771 |
772 val _ = |
772 val _ = |
773 Outer_Syntax.command @{command_keyword case} "invoke local context" |
773 Outer_Syntax.command @{command_keyword case} "invoke local context" |
774 (Parse_Spec.opt_thm_name ":" -- |
774 (Parse_Spec.opt_thm_name ":" -- |
775 (@{keyword "("} |-- |
775 (@{keyword "("} |-- |
776 Parse.!!! (Parse.position Parse.xname -- Scan.repeat (Parse.maybe Parse.binding) |
776 Parse.!!! (Parse.position Parse.name -- Scan.repeat (Parse.maybe Parse.binding) |
777 --| @{keyword ")"}) || |
777 --| @{keyword ")"}) || |
778 Parse.position Parse.xname >> rpair []) >> (Toplevel.proof o Proof.case_cmd)); |
778 Parse.position Parse.name >> rpair []) >> (Toplevel.proof o Proof.case_cmd)); |
779 |
779 |
780 in end\<close> |
780 in end\<close> |
781 |
781 |
782 |
782 |
783 subsubsection \<open>Proof structure\<close> |
783 subsubsection \<open>Proof structure\<close> |
904 |
904 |
905 ML \<open> |
905 ML \<open> |
906 local |
906 local |
907 |
907 |
908 val calculation_args = |
908 val calculation_args = |
909 Scan.option (@{keyword "("} |-- Parse.!!! ((Parse.xthms1 --| @{keyword ")"}))); |
909 Scan.option (@{keyword "("} |-- Parse.!!! ((Parse.thms1 --| @{keyword ")"}))); |
910 |
910 |
911 val _ = |
911 val _ = |
912 Outer_Syntax.command @{command_keyword also} "combine calculation and current facts" |
912 Outer_Syntax.command @{command_keyword also} "combine calculation and current facts" |
913 (calculation_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
913 (calculation_args >> (Toplevel.proofs' o Calculation.also_cmd)); |
914 |
914 |
954 |
954 |
955 ML \<open> |
955 ML \<open> |
956 local |
956 local |
957 |
957 |
958 val opt_modes = |
958 val opt_modes = |
959 Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
959 Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.name --| @{keyword ")"})) []; |
960 |
960 |
961 val _ = |
961 val _ = |
962 Outer_Syntax.command @{command_keyword help} |
962 Outer_Syntax.command @{command_keyword help} |
963 "retrieve outer syntax commands according to name patterns" |
963 "retrieve outer syntax commands according to name patterns" |
964 (Scan.repeat Parse.name >> |
964 (Scan.repeat Parse.name >> |
1023 (Scan.succeed (Toplevel.keep (Class.print_classes o Toplevel.context_of))); |
1023 (Scan.succeed (Toplevel.keep (Class.print_classes o Toplevel.context_of))); |
1024 |
1024 |
1025 val _ = |
1025 val _ = |
1026 Outer_Syntax.command @{command_keyword print_locale} |
1026 Outer_Syntax.command @{command_keyword print_locale} |
1027 "print locale of this theory" |
1027 "print locale of this theory" |
1028 (Parse.opt_bang -- Parse.position Parse.xname >> (fn (b, name) => |
1028 (Parse.opt_bang -- Parse.position Parse.name >> (fn (b, name) => |
1029 Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name))); |
1029 Toplevel.keep (fn state => Locale.print_locale (Toplevel.theory_of state) b name))); |
1030 |
1030 |
1031 val _ = |
1031 val _ = |
1032 Outer_Syntax.command @{command_keyword print_interps} |
1032 Outer_Syntax.command @{command_keyword print_interps} |
1033 "print interpretations of locale for this theory or proof context" |
1033 "print interpretations of locale for this theory or proof context" |
1034 (Parse.position Parse.xname >> (fn name => |
1034 (Parse.position Parse.name >> (fn name => |
1035 Toplevel.keep (fn state => Locale.print_registrations (Toplevel.context_of state) name))); |
1035 Toplevel.keep (fn state => Locale.print_registrations (Toplevel.context_of state) name))); |
1036 |
1036 |
1037 val _ = |
1037 val _ = |
1038 Outer_Syntax.command @{command_keyword print_dependencies} |
1038 Outer_Syntax.command @{command_keyword print_dependencies} |
1039 "print dependencies of locale expression" |
1039 "print dependencies of locale expression" |
1098 (Toplevel.keep (Pretty.writeln_chunks o Proof_Context.pretty_cases o Toplevel.context_of))); |
1098 (Toplevel.keep (Pretty.writeln_chunks o Proof_Context.pretty_cases o Toplevel.context_of))); |
1099 |
1099 |
1100 val _ = |
1100 val _ = |
1101 Outer_Syntax.command @{command_keyword print_statement} |
1101 Outer_Syntax.command @{command_keyword print_statement} |
1102 "print theorems as long statements" |
1102 "print theorems as long statements" |
1103 (opt_modes -- Parse.xthms1 >> Isar_Cmd.print_stmts); |
1103 (opt_modes -- Parse.thms1 >> Isar_Cmd.print_stmts); |
1104 |
1104 |
1105 val _ = |
1105 val _ = |
1106 Outer_Syntax.command @{command_keyword thm} "print theorems" |
1106 Outer_Syntax.command @{command_keyword thm} "print theorems" |
1107 (opt_modes -- Parse.xthms1 >> Isar_Cmd.print_thms); |
1107 (opt_modes -- Parse.thms1 >> Isar_Cmd.print_thms); |
1108 |
1108 |
1109 val _ = |
1109 val _ = |
1110 Outer_Syntax.command @{command_keyword prf} "print proof terms of theorems" |
1110 Outer_Syntax.command @{command_keyword prf} "print proof terms of theorems" |
1111 (opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs false); |
1111 (opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs false); |
1112 |
1112 |
1113 val _ = |
1113 val _ = |
1114 Outer_Syntax.command @{command_keyword full_prf} "print full proof terms of theorems" |
1114 Outer_Syntax.command @{command_keyword full_prf} "print full proof terms of theorems" |
1115 (opt_modes -- Scan.option Parse.xthms1 >> Isar_Cmd.print_prfs true); |
1115 (opt_modes -- Scan.option Parse.thms1 >> Isar_Cmd.print_prfs true); |
1116 |
1116 |
1117 val _ = |
1117 val _ = |
1118 Outer_Syntax.command @{command_keyword prop} "read and print proposition" |
1118 Outer_Syntax.command @{command_keyword prop} "read and print proposition" |
1119 (opt_modes -- Parse.term >> Isar_Cmd.print_prop); |
1119 (opt_modes -- Parse.term >> Isar_Cmd.print_prop); |
1120 |
1120 |
1154 |
1154 |
1155 ML \<open> |
1155 ML \<open> |
1156 local |
1156 local |
1157 |
1157 |
1158 val theory_bounds = |
1158 val theory_bounds = |
1159 Parse.position Parse.theory_xname >> single || |
1159 Parse.position Parse.theory_name >> single || |
1160 (@{keyword "("} |-- Parse.enum "|" (Parse.position Parse.theory_xname) --| @{keyword ")"}); |
1160 (@{keyword "("} |-- Parse.enum "|" (Parse.position Parse.theory_name) --| @{keyword ")"}); |
1161 |
1161 |
1162 val _ = |
1162 val _ = |
1163 Outer_Syntax.command @{command_keyword thy_deps} "visualize theory dependencies" |
1163 Outer_Syntax.command @{command_keyword thy_deps} "visualize theory dependencies" |
1164 (Scan.option theory_bounds -- Scan.option theory_bounds >> |
1164 (Scan.option theory_bounds -- Scan.option theory_bounds >> |
1165 (fn args => Toplevel.keep (fn st => Thy_Deps.thy_deps_cmd (Toplevel.context_of st) args))); |
1165 (fn args => Toplevel.keep (fn st => Thy_Deps.thy_deps_cmd (Toplevel.context_of st) args))); |
1175 Toplevel.keep (fn st => Class_Deps.class_deps_cmd (Toplevel.context_of st) args))); |
1175 Toplevel.keep (fn st => Class_Deps.class_deps_cmd (Toplevel.context_of st) args))); |
1176 |
1176 |
1177 |
1177 |
1178 val _ = |
1178 val _ = |
1179 Outer_Syntax.command @{command_keyword thm_deps} "visualize theorem dependencies" |
1179 Outer_Syntax.command @{command_keyword thm_deps} "visualize theorem dependencies" |
1180 (Parse.xthms1 >> (fn args => |
1180 (Parse.thms1 >> (fn args => |
1181 Toplevel.keep (fn st => |
1181 Toplevel.keep (fn st => |
1182 Thm_Deps.thm_deps (Toplevel.theory_of st) |
1182 Thm_Deps.thm_deps (Toplevel.theory_of st) |
1183 (Attrib.eval_thms (Toplevel.context_of st) args)))); |
1183 (Attrib.eval_thms (Toplevel.context_of st) args)))); |
1184 |
1184 |
1185 |
1185 |
1186 val thy_names = |
1186 val thy_names = |
1187 Scan.repeat1 (Scan.unless Parse.minus (Parse.position Parse.theory_xname)); |
1187 Scan.repeat1 (Scan.unless Parse.minus (Parse.position Parse.theory_name)); |
1188 |
1188 |
1189 val _ = |
1189 val _ = |
1190 Outer_Syntax.command @{command_keyword unused_thms} "find unused theorems" |
1190 Outer_Syntax.command @{command_keyword unused_thms} "find unused theorems" |
1191 (Scan.option ((thy_names --| Parse.minus) -- Scan.option thy_names) >> (fn opt_range => |
1191 (Scan.option ((thy_names --| Parse.minus) -- Scan.option thy_names) >> (fn opt_range => |
1192 Toplevel.keep (fn st => |
1192 Toplevel.keep (fn st => |
1258 val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
1258 val parse_vars = Scan.optional (Parse.$$$ "(" |-- Parse.list1 Parse.name --| Parse.$$$ ")") []; |
1259 |
1259 |
1260 val _ = |
1260 val _ = |
1261 Outer_Syntax.command @{command_keyword realizers} |
1261 Outer_Syntax.command @{command_keyword realizers} |
1262 "specify realizers for primitive axioms / theorems, together with correctness proof" |
1262 "specify realizers for primitive axioms / theorems, together with correctness proof" |
1263 (Scan.repeat1 (Parse.xname -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
1263 (Scan.repeat1 (Parse.name -- parse_vars --| Parse.$$$ ":" -- Parse.string -- Parse.string) >> |
1264 (fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
1264 (fn xs => Toplevel.theory (fn thy => Extraction.add_realizers |
1265 (map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy))); |
1265 (map (fn (((a, vs), s1), s2) => (Global_Theory.get_thm thy a, (vs, s1, s2))) xs) thy))); |
1266 |
1266 |
1267 val _ = |
1267 val _ = |
1268 Outer_Syntax.command @{command_keyword realizability} |
1268 Outer_Syntax.command @{command_keyword realizability} |
1274 "add equations characterizing type of extracted program" |
1274 "add equations characterizing type of extracted program" |
1275 (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
1275 (Scan.repeat1 Parse.string >> (Toplevel.theory o Extraction.add_typeof_eqns)); |
1276 |
1276 |
1277 val _ = |
1277 val _ = |
1278 Outer_Syntax.command @{command_keyword extract} "extract terms from proofs" |
1278 Outer_Syntax.command @{command_keyword extract} "extract terms from proofs" |
1279 (Scan.repeat1 (Parse.xname -- parse_vars) >> (fn xs => Toplevel.theory (fn thy => |
1279 (Scan.repeat1 (Parse.name -- parse_vars) >> (fn xs => Toplevel.theory (fn thy => |
1280 Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
1280 Extraction.extract (map (apfst (Global_Theory.get_thm thy)) xs) thy))); |
1281 |
1281 |
1282 in end\<close> |
1282 in end\<close> |
1283 |
1283 |
1284 |
1284 |