67 val addSD2 : claset * (string * thm) -> claset |
67 val addSD2 : claset * (string * thm) -> claset |
68 val addSE2 : claset * (string * thm) -> claset |
68 val addSE2 : claset * (string * thm) -> claset |
69 val appSWrappers : claset -> wrapper |
69 val appSWrappers : claset -> wrapper |
70 val appWrappers : claset -> wrapper |
70 val appWrappers : claset -> wrapper |
71 |
71 |
72 val change_claset: (claset -> claset) -> unit |
|
73 val claset_of: theory -> claset |
72 val claset_of: theory -> claset |
74 val claset: unit -> claset |
|
75 val CLASET: (claset -> tactic) -> tactic |
|
76 val CLASET': (claset -> 'a -> tactic) -> 'a -> tactic |
|
77 val local_claset_of : Proof.context -> claset |
73 val local_claset_of : Proof.context -> claset |
78 |
74 |
79 val fast_tac : claset -> int -> tactic |
75 val fast_tac : claset -> int -> tactic |
80 val slow_tac : claset -> int -> tactic |
76 val slow_tac : claset -> int -> tactic |
81 val weight_ASTAR : int ref |
77 val weight_ASTAR : int ref |
105 val swapify : thm list -> thm list |
101 val swapify : thm list -> thm list |
106 val swap_res_tac : thm list -> int -> tactic |
102 val swap_res_tac : thm list -> int -> tactic |
107 val inst_step_tac : claset -> int -> tactic |
103 val inst_step_tac : claset -> int -> tactic |
108 val inst0_step_tac : claset -> int -> tactic |
104 val inst0_step_tac : claset -> int -> tactic |
109 val instp_step_tac : claset -> int -> tactic |
105 val instp_step_tac : claset -> int -> tactic |
110 |
|
111 val AddDs : thm list -> unit |
|
112 val AddEs : thm list -> unit |
|
113 val AddIs : thm list -> unit |
|
114 val AddSDs : thm list -> unit |
|
115 val AddSEs : thm list -> unit |
|
116 val AddSIs : thm list -> unit |
|
117 val Delrules : thm list -> unit |
|
118 val Safe_tac : tactic |
|
119 val Safe_step_tac : int -> tactic |
|
120 val Clarify_tac : int -> tactic |
|
121 val Clarify_step_tac : int -> tactic |
|
122 val Step_tac : int -> tactic |
|
123 val Fast_tac : int -> tactic |
|
124 val Best_tac : int -> tactic |
|
125 val Slow_tac : int -> tactic |
|
126 val Slow_best_tac : int -> tactic |
|
127 val Deepen_tac : int -> int -> tactic |
|
128 end; |
106 end; |
129 |
107 |
130 signature CLASSICAL = |
108 signature CLASSICAL = |
131 sig |
109 sig |
132 include BASIC_CLASSICAL |
110 include BASIC_CLASSICAL |
868 |
846 |
869 val get_context_cs = #2 o GlobalClaset.get o ProofContext.theory_of; |
847 val get_context_cs = #2 o GlobalClaset.get o ProofContext.theory_of; |
870 fun map_context_cs f = GlobalClaset.map (apsnd |
848 fun map_context_cs f = GlobalClaset.map (apsnd |
871 (fn ContextCS {swrappers, uwrappers} => make_context_cs (f (swrappers, uwrappers)))); |
849 (fn ContextCS {swrappers, uwrappers} => make_context_cs (f (swrappers, uwrappers)))); |
872 |
850 |
873 fun change_claset f = Context.>> (Context.map_theory (map_claset f)); |
|
874 |
|
875 fun claset_of thy = |
851 fun claset_of thy = |
876 let val (cs, ctxt_cs) = GlobalClaset.get thy |
852 let val (cs, ctxt_cs) = GlobalClaset.get thy |
877 in context_cs (ProofContext.init thy) cs (ctxt_cs) end; |
853 in context_cs (ProofContext.init thy) cs (ctxt_cs) end; |
878 val claset = claset_of o ML_Context.the_global_context; |
|
879 |
|
880 fun CLASET tacf st = tacf (claset_of (Thm.theory_of_thm st)) st; |
|
881 fun CLASET' tacf i st = tacf (claset_of (Thm.theory_of_thm st)) i st; |
|
882 |
|
883 fun AddDs args = change_claset (fn cs => cs addDs args); |
|
884 fun AddEs args = change_claset (fn cs => cs addEs args); |
|
885 fun AddIs args = change_claset (fn cs => cs addIs args); |
|
886 fun AddSDs args = change_claset (fn cs => cs addSDs args); |
|
887 fun AddSEs args = change_claset (fn cs => cs addSEs args); |
|
888 fun AddSIs args = change_claset (fn cs => cs addSIs args); |
|
889 fun Delrules args = change_claset (fn cs => cs delrules args); |
|
890 |
854 |
891 |
855 |
892 (* context dependent components *) |
856 (* context dependent components *) |
893 |
857 |
894 fun add_context_safe_wrapper wrapper = map_context_cs (apfst ((AList.update (op =) wrapper))); |
858 fun add_context_safe_wrapper wrapper = map_context_cs (apfst ((AList.update (op =) wrapper))); |
926 val safe_intro = attrib o addSI; |
890 val safe_intro = attrib o addSI; |
927 fun haz_dest w = attrib (addE w o make_elim); |
891 fun haz_dest w = attrib (addE w o make_elim); |
928 val haz_elim = attrib o addE; |
892 val haz_elim = attrib o addE; |
929 val haz_intro = attrib o addI; |
893 val haz_intro = attrib o addI; |
930 val rule_del = attrib delrule o ContextRules.rule_del; |
894 val rule_del = attrib delrule o ContextRules.rule_del; |
931 |
|
932 |
|
933 (* tactics referring to the implicit claset *) |
|
934 |
|
935 (*the abstraction over the proof state delays the dereferencing*) |
|
936 fun Safe_tac st = safe_tac (claset()) st; |
|
937 fun Safe_step_tac i st = safe_step_tac (claset()) i st; |
|
938 fun Clarify_step_tac i st = clarify_step_tac (claset()) i st; |
|
939 fun Clarify_tac i st = clarify_tac (claset()) i st; |
|
940 fun Step_tac i st = step_tac (claset()) i st; |
|
941 fun Fast_tac i st = fast_tac (claset()) i st; |
|
942 fun Best_tac i st = best_tac (claset()) i st; |
|
943 fun Slow_tac i st = slow_tac (claset()) i st; |
|
944 fun Slow_best_tac i st = slow_best_tac (claset()) i st; |
|
945 fun Deepen_tac m = deepen_tac (claset()) m; |
|
946 |
895 |
947 |
896 |
948 end; |
897 end; |
949 |
898 |
950 |
899 |
970 |
919 |
971 |
920 |
972 |
921 |
973 (** proof methods **) |
922 (** proof methods **) |
974 |
923 |
975 fun METHOD_CLASET tac ctxt = METHOD (tac ctxt (local_claset_of ctxt)); |
|
976 fun METHOD_CLASET' tac ctxt = METHOD (HEADGOAL o tac ctxt (local_claset_of ctxt)); |
|
977 |
|
978 |
|
979 local |
924 local |
980 |
925 |
981 fun some_rule_tac ctxt (CS {xtra_netpair, ...}) facts = SUBGOAL (fn (goal, i) => |
926 fun some_rule_tac ctxt facts = SUBGOAL (fn (goal, i) => |
982 let |
927 let |
983 val [rules1, rules2, rules4] = ContextRules.find_rules false facts goal ctxt; |
928 val [rules1, rules2, rules4] = ContextRules.find_rules false facts goal ctxt; |
|
929 val CS {xtra_netpair, ...} = local_claset_of ctxt; |
984 val rules3 = ContextRules.find_rules_netpair true facts goal xtra_netpair; |
930 val rules3 = ContextRules.find_rules_netpair true facts goal xtra_netpair; |
985 val rules = rules1 @ rules2 @ rules3 @ rules4; |
931 val rules = rules1 @ rules2 @ rules3 @ rules4; |
986 val ruleq = Drule.multi_resolves facts rules; |
932 val ruleq = Drule.multi_resolves facts rules; |
987 in |
933 in |
988 Method.trace ctxt rules; |
934 Method.trace ctxt rules; |
989 fn st => Seq.flat (Seq.map (fn rule => Tactic.rtac rule i st) ruleq) |
935 fn st => Seq.flat (Seq.map (fn rule => Tactic.rtac rule i st) ruleq) |
990 end) |
936 end) |
991 THEN_ALL_NEW Goal.norm_hhf_tac; |
937 THEN_ALL_NEW Goal.norm_hhf_tac; |
992 |
938 |
993 fun rule_tac [] ctxt cs facts = some_rule_tac ctxt cs facts |
939 in |
994 | rule_tac rules _ _ facts = Method.rule_tac rules facts; |
940 |
995 |
941 fun rule_tac ctxt [] facts = some_rule_tac ctxt facts |
996 fun default_tac rules ctxt cs facts = |
942 | rule_tac _ rules facts = Method.rule_tac rules facts; |
997 HEADGOAL (rule_tac rules ctxt cs facts) ORELSE |
943 |
|
944 fun default_tac ctxt rules facts = |
|
945 HEADGOAL (rule_tac ctxt rules facts) ORELSE |
998 Class.default_intro_tac ctxt facts; |
946 Class.default_intro_tac ctxt facts; |
999 |
947 |
1000 in |
|
1001 val rule = METHOD_CLASET' o rule_tac; |
|
1002 val default = METHOD_CLASET o default_tac; |
|
1003 end; |
948 end; |
1004 |
949 |
1005 |
950 |
1006 (* contradiction method *) |
951 (* contradiction method *) |
1007 |
952 |
1031 |
976 |
1032 |
977 |
1033 (** setup_methods **) |
978 (** setup_methods **) |
1034 |
979 |
1035 val setup_methods = |
980 val setup_methods = |
1036 Method.setup @{binding default} (Attrib.thms >> default) |
981 Method.setup @{binding default} |
|
982 (Attrib.thms >> (fn rules => fn ctxt => METHOD (default_tac ctxt rules))) |
1037 "apply some intro/elim rule (potentially classical)" #> |
983 "apply some intro/elim rule (potentially classical)" #> |
1038 Method.setup @{binding rule} (Attrib.thms >> rule) |
984 Method.setup @{binding rule} |
|
985 (Attrib.thms >> (fn rules => fn ctxt => METHOD (HEADGOAL o rule_tac ctxt rules))) |
1039 "apply some intro/elim rule (potentially classical)" #> |
986 "apply some intro/elim rule (potentially classical)" #> |
1040 Method.setup @{binding contradiction} (Scan.succeed (K contradiction)) |
987 Method.setup @{binding contradiction} (Scan.succeed (K contradiction)) |
1041 "proof by contradiction" #> |
988 "proof by contradiction" #> |
1042 Method.setup @{binding clarify} (cla_method' (CHANGED_PROP oo clarify_tac)) |
989 Method.setup @{binding clarify} (cla_method' (CHANGED_PROP oo clarify_tac)) |
1043 "repeatedly apply safe steps" #> |
990 "repeatedly apply safe steps" #> |