17 include BASIC_METHOD |
17 include BASIC_METHOD |
18 type src |
18 type src |
19 val trace: Proof.context -> thm list -> unit |
19 val trace: Proof.context -> thm list -> unit |
20 val RAW_METHOD: (thm list -> tactic) -> Proof.method |
20 val RAW_METHOD: (thm list -> tactic) -> Proof.method |
21 val RAW_METHOD_CASES: |
21 val RAW_METHOD_CASES: |
22 (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> Proof.method |
22 (thm list -> thm -> (thm * (string * RuleCases.T option) list) Seq.seq) -> Proof.method |
23 val METHOD: (thm list -> tactic) -> Proof.method |
23 val METHOD: (thm list -> tactic) -> Proof.method |
24 val METHOD_CASES: |
24 val METHOD_CASES: |
25 (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> Proof.method |
25 (thm list -> thm -> (thm * (string * RuleCases.T option) list) Seq.seq) -> Proof.method |
26 val SIMPLE_METHOD: tactic -> Proof.method |
26 val SIMPLE_METHOD: tactic -> Proof.method |
27 val SIMPLE_METHOD': ((int -> tactic) -> tactic) -> (int -> tactic) -> Proof.method |
27 val SIMPLE_METHOD': ((int -> tactic) -> tactic) -> (int -> tactic) -> Proof.method |
28 val fail: Proof.method |
28 val fail: Proof.method |
29 val succeed: Proof.method |
29 val succeed: Proof.method |
30 val defer: int option -> Proof.method |
30 val defer: int option -> Proof.method |
520 fun print _ {space, meths} = |
520 fun print _ {space, meths} = |
521 let |
521 let |
522 fun prt_meth (name, ((_, comment), _)) = Pretty.block |
522 fun prt_meth (name, ((_, comment), _)) = Pretty.block |
523 [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment]; |
523 [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment]; |
524 in |
524 in |
525 [Pretty.big_list "methods:" (map prt_meth (NameSpace.cond_extern_table space meths))] |
525 [Pretty.big_list "methods:" (map prt_meth (NameSpace.extern_table space meths))] |
526 |> Pretty.chunks |> Pretty.writeln |
526 |> Pretty.chunks |> Pretty.writeln |
527 end; |
527 end; |
528 end; |
528 end; |
529 |
529 |
530 structure MethodsData = TheoryDataFun(MethodsDataArgs); |
530 structure MethodsData = TheoryDataFun(MethodsDataArgs); |
554 |
554 |
555 (* add_method(s) *) |
555 (* add_method(s) *) |
556 |
556 |
557 fun add_methods raw_meths thy = |
557 fun add_methods raw_meths thy = |
558 let |
558 let |
559 val full = Sign.full_name (Theory.sign_of thy); |
559 val sg = Theory.sign_of thy; |
560 val new_meths = |
560 val new_meths = raw_meths |> map (fn (name, f, comment) => |
561 map (fn (name, f, comment) => (full name, ((f, comment), stamp ()))) raw_meths; |
561 (Sign.full_name sg name, ((f, comment), stamp ()))); |
562 |
562 |
563 val {space, meths} = MethodsData.get thy; |
563 val {space, meths} = MethodsData.get thy; |
564 val space' = NameSpace.extend (space, map fst new_meths); |
564 val space' = fold (Sign.declare_name sg) (map fst new_meths) space; |
565 val meths' = Symtab.extend (meths, new_meths) handle Symtab.DUPS dups => |
565 val meths' = Symtab.extend (meths, new_meths) handle Symtab.DUPS dups => |
566 error ("Duplicate declaration of method(s) " ^ commas_quote dups); |
566 error ("Duplicate declaration of method(s) " ^ commas_quote dups); |
567 in |
567 in thy |> MethodsData.put {space = space', meths = meths'} end; |
568 thy |> MethodsData.put {space = space', meths = meths'} |
|
569 end; |
|
570 |
568 |
571 val add_method = add_methods o Library.single; |
569 val add_method = add_methods o Library.single; |
572 |
570 |
573 (*implicit version*) |
571 (*implicit version*) |
574 fun Method name meth cmt = Context.>> (add_methods [(name, meth, cmt)]); |
572 fun Method name meth cmt = Context.>> (add_methods [(name, meth, cmt)]); |
782 val pure_methods = |
780 val pure_methods = |
783 [("fail", no_args fail, "force failure"), |
781 [("fail", no_args fail, "force failure"), |
784 ("succeed", no_args succeed, "succeed"), |
782 ("succeed", no_args succeed, "succeed"), |
785 ("-", no_args insert_facts, "do nothing (insert current facts only)"), |
783 ("-", no_args insert_facts, "do nothing (insert current facts only)"), |
786 ("insert", thms_args insert, "insert theorems, ignoring facts (improper)"), |
784 ("insert", thms_args insert, "insert theorems, ignoring facts (improper)"), |
787 ("unfold", thms_args unfold, "unfold definitions"), |
785 ("unfold", thms_args unfold_meth, "unfold definitions"), |
788 ("intro", thms_args intro, "repeatedly apply introduction rules"), |
786 ("intro", thms_args intro, "repeatedly apply introduction rules"), |
789 ("elim", thms_args elim, "repeatedly apply elimination rules"), |
787 ("elim", thms_args elim, "repeatedly apply elimination rules"), |
790 ("fold", thms_args fold, "fold definitions"), |
788 ("fold", thms_args fold_meth, "fold definitions"), |
791 ("atomize", (atomize o #2) oo syntax (Args.mode "full"), |
789 ("atomize", (atomize o #2) oo syntax (Args.mode "full"), |
792 "present local premises as object-level statements"), |
790 "present local premises as object-level statements"), |
793 ("rules", rules_args rules_meth, "apply many rules, including proof search"), |
791 ("rules", rules_args rules_meth, "apply many rules, including proof search"), |
794 ("rule", thms_ctxt_args some_rule, "apply some intro/elim rule"), |
792 ("rule", thms_ctxt_args some_rule, "apply some intro/elim rule"), |
795 ("erule", nat_thms_args erule, "apply rule in elimination manner (improper)"), |
793 ("erule", nat_thms_args erule, "apply rule in elimination manner (improper)"), |