src/HOL/simpdata.ML
author paulson
Wed Dec 24 10:02:30 1997 +0100 (1997-12-24 ago)
changeset 4477 b3e5857d8d99
parent 4351 36b28f78ed1b
child 4525 b96b513c6c65
permissions -rw-r--r--
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
     1 (*  Title:      HOL/simpdata.ML
     2     ID:         $Id$
     3     Author:     Tobias Nipkow
     4     Copyright   1991  University of Cambridge
     5 
     6 Instantiation of the generic simplifier
     7 *)
     8 
     9 section "Simplifier";
    10 
    11 open Simplifier;
    12 
    13 (*** Addition of rules to simpsets and clasets simultaneously ***)
    14 
    15 (*Takes UNCONDITIONAL theorems of the form A<->B to 
    16         the Safe Intr     rule B==>A and 
    17         the Safe Destruct rule A==>B.
    18   Also ~A goes to the Safe Elim rule A ==> ?R
    19   Failing other cases, A is added as a Safe Intr rule*)
    20 local
    21   val iff_const = HOLogic.eq_const HOLogic.boolT;
    22 
    23   fun addIff th = 
    24       (case HOLogic.dest_Trueprop (#prop(rep_thm th)) of
    25                 (Const("Not",_) $ A) =>
    26                     AddSEs [zero_var_indexes (th RS notE)]
    27               | (con $ _ $ _) =>
    28                     if con=iff_const
    29                     then (AddSIs [zero_var_indexes (th RS iffD2)];  
    30                           AddSDs [zero_var_indexes (th RS iffD1)])
    31                     else  AddSIs [th]
    32               | _ => AddSIs [th];
    33        Addsimps [th])
    34       handle _ => error ("AddIffs: theorem must be unconditional\n" ^ 
    35                          string_of_thm th)
    36 
    37   fun delIff th = 
    38       (case HOLogic.dest_Trueprop (#prop(rep_thm th)) of
    39                 (Const("Not",_) $ A) =>
    40                     Delrules [zero_var_indexes (th RS notE)]
    41               | (con $ _ $ _) =>
    42                     if con=iff_const
    43                     then Delrules [zero_var_indexes (th RS iffD2),
    44                                    make_elim (zero_var_indexes (th RS iffD1))]
    45                     else Delrules [th]
    46               | _ => Delrules [th];
    47        Delsimps [th])
    48       handle _ => warning("DelIffs: ignoring conditional theorem\n" ^ 
    49                           string_of_thm th)
    50 in
    51 val AddIffs = seq addIff
    52 val DelIffs = seq delIff
    53 end;
    54 
    55 local
    56 
    57   fun prover s = prove_goal HOL.thy s (fn _ => [blast_tac HOL_cs 1]);
    58 
    59   val P_imp_P_iff_True = prover "P --> (P = True)" RS mp;
    60   val P_imp_P_eq_True = P_imp_P_iff_True RS eq_reflection;
    61 
    62   val not_P_imp_P_iff_F = prover "~P --> (P = False)" RS mp;
    63   val not_P_imp_P_eq_False = not_P_imp_P_iff_F RS eq_reflection;
    64 
    65   fun atomize pairs =
    66     let fun atoms th =
    67           (case concl_of th of
    68              Const("Trueprop",_) $ p =>
    69                (case head_of p of
    70                   Const(a,_) =>
    71                     (case assoc(pairs,a) of
    72                        Some(rls) => flat (map atoms ([th] RL rls))
    73                      | None => [th])
    74                 | _ => [th])
    75            | _ => [th])
    76     in atoms end;
    77 
    78   fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
    79 
    80 in
    81 
    82   fun mk_meta_eq r = r RS eq_reflection;
    83 
    84   fun mk_meta_eq_simp r = case concl_of r of
    85           Const("==",_)$_$_ => r
    86       |   _$(Const("op =",_)$lhs$rhs) =>
    87              (case fst(Logic.rewrite_rule_ok (#sign(rep_thm r)) (prems_of r) lhs rhs) of
    88                 None => mk_meta_eq r
    89               | Some _ => r RS P_imp_P_eq_True)
    90       |   _$(Const("Not",_)$_) => r RS not_P_imp_P_eq_False
    91       |   _ => r RS P_imp_P_eq_True;
    92   (* last 2 lines requires all formulae to be of the from Trueprop(.) *)
    93 
    94 val simp_thms = map prover
    95  [ "(x=x) = True",
    96    "(~True) = False", "(~False) = True", "(~ ~ P) = P",
    97    "(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))",
    98    "(True=P) = P", "(P=True) = P",
    99    "(True --> P) = P", "(False --> P) = True", 
   100    "(P --> True) = True", "(P --> P) = True",
   101    "(P --> False) = (~P)", "(P --> ~P) = (~P)",
   102    "(P & True) = P", "(True & P) = P", 
   103    "(P & False) = False", "(False & P) = False",
   104    "(P & P) = P", "(P & (P & Q)) = (P & Q)",
   105    "(P & ~P) = False",    "(~P & P) = False",
   106    "(P | True) = True", "(True | P) = True", 
   107    "(P | False) = P", "(False | P) = P",
   108    "(P | P) = P", "(P | (P | Q)) = (P | Q)",
   109    "(P | ~P) = True",    "(~P | P) = True",
   110    "((~P) = (~Q)) = (P=Q)",
   111    "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x", 
   112 (*two needed for the one-point-rule quantifier simplification procs*)
   113    "(? x. x=t & P(x)) = P(t)",		(*essential for termination!!*)
   114    "(! x. t=x --> P(x)) = P(t)" ];      (*covers a stray case*)
   115 
   116 (*Add congruence rules for = (instead of ==) *)
   117 infix 4 addcongs delcongs;
   118 fun ss addcongs congs = ss addeqcongs 
   119                         (map standard (congs RL [eq_reflection]));
   120 
   121 fun ss delcongs congs = ss deleqcongs 
   122                         (map standard (congs RL [eq_reflection]));
   123 
   124 fun Addcongs congs = (simpset_ref() := simpset() addcongs congs);
   125 fun Delcongs congs = (simpset_ref() := simpset() delcongs congs);
   126 
   127 fun mksimps pairs = map mk_meta_eq_simp o atomize pairs o gen_all;
   128 
   129 val imp_cong = impI RSN
   130     (2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))"
   131         (fn _=> [blast_tac HOL_cs 1]) RS mp RS mp);
   132 
   133 (*Miniscoping: pushing in existential quantifiers*)
   134 val ex_simps = map prover 
   135                 ["(EX x. P x & Q)   = ((EX x. P x) & Q)",
   136                  "(EX x. P & Q x)   = (P & (EX x. Q x))",
   137                  "(EX x. P x | Q)   = ((EX x. P x) | Q)",
   138                  "(EX x. P | Q x)   = (P | (EX x. Q x))",
   139                  "(EX x. P x --> Q) = ((ALL x. P x) --> Q)",
   140                  "(EX x. P --> Q x) = (P --> (EX x. Q x))"];
   141 
   142 (*Miniscoping: pushing in universal quantifiers*)
   143 val all_simps = map prover
   144                 ["(ALL x. P x & Q)   = ((ALL x. P x) & Q)",
   145                  "(ALL x. P & Q x)   = (P & (ALL x. Q x))",
   146                  "(ALL x. P x | Q)   = ((ALL x. P x) | Q)",
   147                  "(ALL x. P | Q x)   = (P | (ALL x. Q x))",
   148                  "(ALL x. P x --> Q) = ((EX x. P x) --> Q)",
   149                  "(ALL x. P --> Q x) = (P --> (ALL x. Q x))"];
   150 
   151 
   152 (* elimination of existential quantifiers in assumptions *)
   153 
   154 val ex_all_equiv =
   155   let val lemma1 = prove_goal HOL.thy
   156         "(? x. P(x) ==> PROP Q) ==> (!!x. P(x) ==> PROP Q)"
   157         (fn prems => [resolve_tac prems 1, etac exI 1]);
   158       val lemma2 = prove_goalw HOL.thy [Ex_def]
   159         "(!!x. P(x) ==> PROP Q) ==> (? x. P(x) ==> PROP Q)"
   160         (fn prems => [REPEAT(resolve_tac prems 1)])
   161   in equal_intr lemma1 lemma2 end;
   162 
   163 end;
   164 
   165 (* Elimination of True from asumptions: *)
   166 
   167 val True_implies_equals = prove_goal HOL.thy
   168  "(True ==> PROP P) == PROP P"
   169 (fn _ => [rtac equal_intr_rule 1, atac 2,
   170           METAHYPS (fn prems => resolve_tac prems 1) 1,
   171           rtac TrueI 1]);
   172 
   173 fun prove nm thm  = qed_goal nm HOL.thy thm (fn _ => [blast_tac HOL_cs 1]);
   174 
   175 prove "conj_commute" "(P&Q) = (Q&P)";
   176 prove "conj_left_commute" "(P&(Q&R)) = (Q&(P&R))";
   177 val conj_comms = [conj_commute, conj_left_commute];
   178 prove "conj_assoc" "((P&Q)&R) = (P&(Q&R))";
   179 
   180 prove "disj_commute" "(P|Q) = (Q|P)";
   181 prove "disj_left_commute" "(P|(Q|R)) = (Q|(P|R))";
   182 val disj_comms = [disj_commute, disj_left_commute];
   183 prove "disj_assoc" "((P|Q)|R) = (P|(Q|R))";
   184 
   185 prove "conj_disj_distribL" "(P&(Q|R)) = (P&Q | P&R)";
   186 prove "conj_disj_distribR" "((P|Q)&R) = (P&R | Q&R)";
   187 
   188 prove "disj_conj_distribL" "(P|(Q&R)) = ((P|Q) & (P|R))";
   189 prove "disj_conj_distribR" "((P&Q)|R) = ((P|R) & (Q|R))";
   190 
   191 prove "imp_conjR" "(P --> (Q&R)) = ((P-->Q) & (P-->R))";
   192 prove "imp_conjL" "((P&Q) -->R)  = (P --> (Q --> R))";
   193 prove "imp_disjL" "((P|Q) --> R) = ((P-->R)&(Q-->R))";
   194 
   195 (*These two are specialized, but imp_disj_not1 is useful in Auth/Yahalom.ML*)
   196 prove "imp_disj_not1" "((P --> Q | R)) = (~Q --> P --> R)";
   197 prove "imp_disj_not2" "((P --> Q | R)) = (~R --> P --> Q)";
   198 
   199 prove "imp_disj1" "((P-->Q)|R) = (P--> Q|R)";
   200 prove "imp_disj2" "(Q|(P-->R)) = (P--> Q|R)";
   201 
   202 prove "de_Morgan_disj" "(~(P | Q)) = (~P & ~Q)";
   203 prove "de_Morgan_conj" "(~(P & Q)) = (~P | ~Q)";
   204 prove "not_imp" "(~(P --> Q)) = (P & ~Q)";
   205 prove "not_iff" "(P~=Q) = (P = (~Q))";
   206 
   207 (*Avoids duplication of subgoals after expand_if, when the true and false 
   208   cases boil down to the same thing.*) 
   209 prove "cases_simp" "((P --> Q) & (~P --> Q)) = Q";
   210 
   211 prove "not_all" "(~ (! x. P(x))) = (? x.~P(x))";
   212 prove "imp_all" "((! x. P x) --> Q) = (? x. P x --> Q)";
   213 prove "not_ex"  "(~ (? x. P(x))) = (! x.~P(x))";
   214 prove "imp_ex" "((? x. P x) --> Q) = (! x. P x --> Q)";
   215 
   216 prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))";
   217 prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))";
   218 
   219 (* '&' congruence rule: not included by default!
   220    May slow rewrite proofs down by as much as 50% *)
   221 
   222 let val th = prove_goal HOL.thy 
   223                 "(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))"
   224                 (fn _=> [blast_tac HOL_cs 1])
   225 in  bind_thm("conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   226 
   227 let val th = prove_goal HOL.thy 
   228                 "(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))"
   229                 (fn _=> [blast_tac HOL_cs 1])
   230 in  bind_thm("rev_conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   231 
   232 (* '|' congruence rule: not included by default! *)
   233 
   234 let val th = prove_goal HOL.thy 
   235                 "(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))"
   236                 (fn _=> [blast_tac HOL_cs 1])
   237 in  bind_thm("disj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   238 
   239 prove "eq_sym_conv" "(x=y) = (y=x)";
   240 
   241 qed_goalw "o_apply" HOL.thy [o_def] "(f o g) x = f (g x)"
   242  (fn _ => [rtac refl 1]);
   243 
   244 qed_goal "meta_eq_to_obj_eq" HOL.thy "x==y ==> x=y"
   245   (fn [prem] => [rewtac prem, rtac refl 1]);
   246 
   247 qed_goalw "if_True" HOL.thy [if_def] "(if True then x else y) = x"
   248  (fn _=>[blast_tac (HOL_cs addIs [select_equality]) 1]);
   249 
   250 qed_goalw "if_False" HOL.thy [if_def] "(if False then x else y) = y"
   251  (fn _=>[blast_tac (HOL_cs addIs [select_equality]) 1]);
   252 
   253 qed_goal "if_P" HOL.thy "P ==> (if P then x else y) = x"
   254  (fn [prem] => [ stac (prem RS eqTrueI) 1, rtac if_True 1 ]);
   255 (*
   256 qed_goal "if_not_P" HOL.thy "~P ==> (if P then x else y) = y"
   257  (fn [prem] => [ stac (prem RS not_P_imp_P_iff_F) 1, rtac if_False 1 ]);
   258 *)
   259 qed_goalw "if_not_P" HOL.thy [if_def] "!!P. ~P ==> (if P then x else y) = y"
   260  (fn _ => [blast_tac (HOL_cs addIs [select_equality]) 1]);
   261 
   262 qed_goal "expand_if" HOL.thy
   263     "P(if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))" (K [
   264 	res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1,
   265          stac if_P 2,
   266          stac if_not_P 1,
   267          ALLGOALS (blast_tac HOL_cs)]);
   268 
   269 qed_goal "split_if_asm" HOL.thy
   270     "P(if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))" (K [
   271 	stac expand_if 1,
   272         blast_tac HOL_cs 1]);
   273 
   274 qed_goal "if_bool_eq" HOL.thy
   275                    "(if P then Q else R) = ((P-->Q) & (~P-->R))"
   276                    (fn _ => [rtac expand_if 1]);
   277 
   278 
   279 (*** make simplification procedures for quantifier elimination ***)
   280 
   281 structure Quantifier1 = Quantifier1Fun(
   282 struct
   283   (*abstract syntax*)
   284   fun dest_eq((c as Const("op =",_)) $ s $ t) = Some(c,s,t)
   285     | dest_eq _ = None;
   286   fun dest_conj((c as Const("op &",_)) $ s $ t) = Some(c,s,t)
   287     | dest_conj _ = None;
   288   val conj = HOLogic.conj
   289   val imp  = HOLogic.imp
   290   (*rules*)
   291   val iff_reflection = eq_reflection
   292   val iffI = iffI
   293   val sym  = sym
   294   val conjI= conjI
   295   val conjE= conjE
   296   val impI = impI
   297   val impE = impE
   298   val mp   = mp
   299   val exI  = exI
   300   val exE  = exE
   301   val allI = allI
   302   val allE = allE
   303 end);
   304 
   305 local
   306 val ex_pattern =
   307   read_cterm (sign_of HOL.thy) ("EX x. P(x) & Q(x)",HOLogic.boolT)
   308 
   309 val all_pattern =
   310   read_cterm (sign_of HOL.thy) ("ALL x. P(x) & P'(x) --> Q(x)",HOLogic.boolT)
   311 
   312 in
   313 val defEX_regroup =
   314   mk_simproc "defined EX" [ex_pattern] Quantifier1.rearrange_ex;
   315 val defALL_regroup =
   316   mk_simproc "defined ALL" [all_pattern] Quantifier1.rearrange_all;
   317 end;
   318 
   319 
   320 (*** Case splitting ***)
   321 
   322 local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2)
   323 in
   324 fun split_tac splits = mktac (map mk_meta_eq splits)
   325 end;
   326 
   327 local val mktac = mk_case_split_inside_tac (meta_eq_to_obj_eq RS iffD2)
   328 in
   329 fun split_inside_tac splits = mktac (map mk_meta_eq splits)
   330 end;
   331 
   332 val split_asm_tac = mk_case_split_asm_tac split_tac 
   333 			(disjE,conjE,exE,contrapos,contrapos2,notnotD);
   334 
   335 infix 4 addsplits;
   336 fun ss addsplits splits = ss addloop (split_tac splits);
   337 
   338 
   339 qed_goal "if_cancel" HOL.thy "(if c then x else x) = x"
   340   (fn _ => [split_tac [expand_if] 1, blast_tac HOL_cs 1]);
   341 
   342 (** 'if' congruence rules: neither included by default! *)
   343 
   344 (*Simplifies x assuming c and y assuming ~c*)
   345 qed_goal "if_cong" HOL.thy
   346   "[| b=c; c ==> x=u; ~c ==> y=v |] ==>\
   347 \  (if b then x else y) = (if c then u else v)"
   348   (fn rew::prems =>
   349    [stac rew 1, stac expand_if 1, stac expand_if 1,
   350     blast_tac (HOL_cs addDs prems) 1]);
   351 
   352 (*Prevents simplification of x and y: much faster*)
   353 qed_goal "if_weak_cong" HOL.thy
   354   "b=c ==> (if b then x else y) = (if c then x else y)"
   355   (fn [prem] => [rtac (prem RS arg_cong) 1]);
   356 
   357 (*Prevents simplification of t: much faster*)
   358 qed_goal "let_weak_cong" HOL.thy
   359   "a = b ==> (let x=a in t(x)) = (let x=b in t(x))"
   360   (fn [prem] => [rtac (prem RS arg_cong) 1]);
   361 
   362 (*In general it seems wrong to add distributive laws by default: they
   363   might cause exponential blow-up.  But imp_disjL has been in for a while
   364   and cannot be removed without affecting existing proofs.  Moreover, 
   365   rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
   366   grounds that it allows simplification of R in the two cases.*)
   367 
   368 val mksimps_pairs =
   369   [("op -->", [mp]), ("op &", [conjunct1,conjunct2]),
   370    ("All", [spec]), ("True", []), ("False", []),
   371    ("If", [if_bool_eq RS iffD1])];
   372 
   373 fun unsafe_solver prems = FIRST'[resolve_tac (TrueI::refl::prems),
   374 				 atac, etac FalseE];
   375 (*No premature instantiation of variables during simplification*)
   376 fun   safe_solver prems = FIRST'[match_tac (TrueI::refl::prems),
   377 				 eq_assume_tac, ematch_tac [FalseE]];
   378 
   379 val HOL_basic_ss = empty_ss setsubgoaler asm_simp_tac
   380 			    setSSolver   safe_solver
   381 			    setSolver  unsafe_solver
   382 			    setmksimps (mksimps mksimps_pairs);
   383 
   384 val HOL_ss = 
   385     HOL_basic_ss addsimps 
   386      ([triv_forall_equality, (* prunes params *)
   387        True_implies_equals, (* prune asms `True' *)
   388        if_True, if_False, if_cancel,
   389        o_apply, imp_disjL, conj_assoc, disj_assoc,
   390        de_Morgan_conj, de_Morgan_disj, imp_disj1, imp_disj2, not_imp,
   391        not_all, not_ex, cases_simp]
   392      @ ex_simps @ all_simps @ simp_thms)
   393      addsimprocs [defALL_regroup,defEX_regroup]
   394      addcongs [imp_cong];
   395 
   396 qed_goal "if_distrib" HOL.thy
   397   "f(if c then x else y) = (if c then f x else f y)" 
   398   (fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]);
   399 
   400 qed_goalw "o_assoc" HOL.thy [o_def] "f o (g o h) = f o g o h"
   401   (fn _ => [rtac ext 1, rtac refl 1]);
   402 
   403 
   404 (*For expand_case_tac*)
   405 val prems = goal HOL.thy "[| P ==> Q(True); ~P ==> Q(False) |] ==> Q(P)";
   406 by (case_tac "P" 1);
   407 by (ALLGOALS (asm_simp_tac (HOL_ss addsimps prems)));
   408 val expand_case = result();
   409 
   410 (*Used in Auth proofs.  Typically P contains Vars that become instantiated
   411   during unification.*)
   412 fun expand_case_tac P i =
   413     res_inst_tac [("P",P)] expand_case i THEN
   414     Simp_tac (i+1) THEN 
   415     Simp_tac i;
   416 
   417 
   418 (* install implicit simpset *)
   419 
   420 simpset_ref() := HOL_ss;
   421 
   422 
   423 (*** Integration of simplifier with classical reasoner ***)
   424 
   425 (* rot_eq_tac rotates the first equality premise of subgoal i to the front,
   426    fails if there is no equaliy or if an equality is already at the front *)
   427 local
   428   fun is_eq (Const ("Trueprop", _) $ (Const("op ="  ,_) $ _ $ _)) = true
   429     | is_eq _ = false;
   430   val find_eq = find_index is_eq;
   431 in
   432 val rot_eq_tac = 
   433      SUBGOAL (fn (Bi,i) => let val n = find_eq (Logic.strip_assums_hyp Bi) in
   434 		if n>0 then rotate_tac n i else no_tac end)
   435 end;
   436 
   437 (*an unsatisfactory fix for the incomplete asm_full_simp_tac!
   438   better: asm_really_full_simp_tac, a yet to be implemented version of
   439 			asm_full_simp_tac that applies all equalities in the
   440 			premises to all the premises *)
   441 fun safe_asm_more_full_simp_tac ss = TRY o rot_eq_tac THEN' 
   442 				     safe_asm_full_simp_tac ss;
   443 
   444 (*Add a simpset to a classical set!*)
   445 infix 4 addSss addss;
   446 fun cs addSss ss = cs addSaltern (CHANGED o (safe_asm_more_full_simp_tac ss));
   447 fun cs addss  ss = cs addbefore                        asm_full_simp_tac ss;
   448 
   449 fun Addss ss = (claset_ref() := claset() addss ss);
   450 
   451 (*Designed to be idempotent, except if best_tac instantiates variables
   452   in some of the subgoals*)
   453 
   454 type clasimpset = (claset * simpset);
   455 
   456 val HOL_css = (HOL_cs, HOL_ss);
   457 
   458 fun pair_upd1 f ((a,b),x) = (f(a,x), b);
   459 fun pair_upd2 f ((a,b),x) = (a, f(b,x));
   460 
   461 infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2
   462 	addsimps2 delsimps2 addcongs2 delcongs2;
   463 fun op addSIs2   arg = pair_upd1 (op addSIs) arg;
   464 fun op addSEs2   arg = pair_upd1 (op addSEs) arg;
   465 fun op addSDs2   arg = pair_upd1 (op addSDs) arg;
   466 fun op addIs2    arg = pair_upd1 (op addIs ) arg;
   467 fun op addEs2    arg = pair_upd1 (op addEs ) arg;
   468 fun op addDs2    arg = pair_upd1 (op addDs ) arg;
   469 fun op addsimps2 arg = pair_upd2 (op addsimps) arg;
   470 fun op delsimps2 arg = pair_upd2 (op delsimps) arg;
   471 fun op addcongs2 arg = pair_upd2 (op addcongs) arg;
   472 fun op delcongs2 arg = pair_upd2 (op delcongs) arg;
   473 
   474 fun mk_auto_tac (cs, ss) m n =
   475     let val cs' = cs addss ss 
   476 	val bdt = Blast.depth_tac cs m;
   477 	fun blast_depth_tac i thm = bdt i thm handle Blast.TRANS s => 
   478 		(warning ("Blast_tac: " ^ s); Seq.empty);
   479         val maintac = 
   480           blast_depth_tac	   (*fast but can't use addss*)
   481           ORELSE'
   482           depth_tac cs' n;         (*slower but general*)
   483     in  EVERY [ALLGOALS (asm_full_simp_tac ss),
   484 	       TRY (safe_tac cs'),
   485 	       REPEAT (FIRSTGOAL maintac),
   486                TRY (safe_tac (cs addSss ss)),
   487 	       prune_params_tac] 
   488     end;
   489 
   490 fun auto_tac (cs,ss) = mk_auto_tac (cs,ss) 4 2;
   491 
   492 fun Auto_tac st = auto_tac (claset(), simpset()) st;
   493 
   494 fun auto () = by Auto_tac;