src/HOL/simpdata.ML
 author wenzelm Fri Nov 23 19:20:58 2001 +0100 (2001-11-23) changeset 12278 75103ba03035 parent 12038 343a9888e875 child 12281 3bd113b8f7a6 permissions -rw-r--r--
tuned;
```     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 for HOL.
```
```     7 *)
```
```     8
```
```     9 section "Simplifier";
```
```    10
```
```    11 val [prem] = goal (the_context ()) "x==y ==> x=y";
```
```    12 by (rewtac prem);
```
```    13 by (rtac refl 1);
```
```    14 qed "meta_eq_to_obj_eq";
```
```    15
```
```    16 Goal "(%s. f s) = f";
```
```    17 br refl 1;
```
```    18 qed "eta_contract_eq";
```
```    19
```
```    20
```
```    21 fun prover s = prove_goal (the_context ()) s (fn _ => [(Blast_tac 1)]);
```
```    22
```
```    23 bind_thm ("not_not", prover "(~ ~ P) = P");
```
```    24
```
```    25 bind_thms ("simp_thms", [not_not] @ map prover
```
```    26  ["(x=x) = True",
```
```    27   "(~True) = False", "(~False) = True",
```
```    28   "(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))",
```
```    29   "(True=P) = P", "(P=True) = P", "(False=P) = (~P)", "(P=False) = (~P)",
```
```    30   "(True --> P) = P", "(False --> P) = True",
```
```    31   "(P --> True) = True", "(P --> P) = True",
```
```    32   "(P --> False) = (~P)", "(P --> ~P) = (~P)",
```
```    33   "(P & True) = P", "(True & P) = P",
```
```    34   "(P & False) = False", "(False & P) = False",
```
```    35   "(P & P) = P", "(P & (P & Q)) = (P & Q)",
```
```    36   "(P & ~P) = False",    "(~P & P) = False",
```
```    37   "(P | True) = True", "(True | P) = True",
```
```    38   "(P | False) = P", "(False | P) = P",
```
```    39   "(P | P) = P", "(P | (P | Q)) = (P | Q)",
```
```    40   "(P | ~P) = True",    "(~P | P) = True",
```
```    41   "((~P) = (~Q)) = (P=Q)",
```
```    42   "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x",
```
```    43 (* needed for the one-point-rule quantifier simplification procs*)
```
```    44 (*essential for termination!!*)
```
```    45   "(? x. x=t & P(x)) = P(t)",
```
```    46   "(? x. t=x & P(x)) = P(t)",
```
```    47   "(! x. x=t --> P(x)) = P(t)",
```
```    48   "(! x. t=x --> P(x)) = P(t)"]);
```
```    49
```
```    50 bind_thm ("imp_cong", standard (impI RSN
```
```    51     (2, prove_goal (the_context ()) "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))"
```
```    52         (fn _=> [(Blast_tac 1)]) RS mp RS mp)));
```
```    53
```
```    54 (*Miniscoping: pushing in existential quantifiers*)
```
```    55 bind_thms ("ex_simps", map prover
```
```    56  ["(EX x. P x & Q)   = ((EX x. P x) & Q)",
```
```    57   "(EX x. P & Q x)   = (P & (EX x. Q x))",
```
```    58   "(EX x. P x | Q)   = ((EX x. P x) | Q)",
```
```    59   "(EX x. P | Q x)   = (P | (EX x. Q x))",
```
```    60   "(EX x. P x --> Q) = ((ALL x. P x) --> Q)",
```
```    61   "(EX x. P --> Q x) = (P --> (EX x. Q x))"]);
```
```    62
```
```    63 (*Miniscoping: pushing in universal quantifiers*)
```
```    64 bind_thms ("all_simps", map prover
```
```    65  ["(ALL x. P x & Q)   = ((ALL x. P x) & Q)",
```
```    66   "(ALL x. P & Q x)   = (P & (ALL x. Q x))",
```
```    67   "(ALL x. P x | Q)   = ((ALL x. P x) | Q)",
```
```    68   "(ALL x. P | Q x)   = (P | (ALL x. Q x))",
```
```    69   "(ALL x. P x --> Q) = ((EX x. P x) --> Q)",
```
```    70   "(ALL x. P --> Q x) = (P --> (ALL x. Q x))"]);
```
```    71
```
```    72
```
```    73 fun prove nm thm  = qed_goal nm (the_context ()) thm (fn _ => [(Blast_tac 1)]);
```
```    74
```
```    75 prove "eq_commute" "(a=b) = (b=a)";
```
```    76 prove "eq_left_commute" "(P=(Q=R)) = (Q=(P=R))";
```
```    77 prove "eq_assoc" "((P=Q)=R) = (P=(Q=R))";
```
```    78 bind_thms ("eq_ac", [eq_commute, eq_left_commute, eq_assoc]);
```
```    79
```
```    80 prove "neq_commute" "(a~=b) = (b~=a)";
```
```    81
```
```    82 prove "conj_commute" "(P&Q) = (Q&P)";
```
```    83 prove "conj_left_commute" "(P&(Q&R)) = (Q&(P&R))";
```
```    84 bind_thms ("conj_comms", [conj_commute, conj_left_commute]);
```
```    85 prove "conj_assoc" "((P&Q)&R) = (P&(Q&R))";
```
```    86
```
```    87 prove "disj_commute" "(P|Q) = (Q|P)";
```
```    88 prove "disj_left_commute" "(P|(Q|R)) = (Q|(P|R))";
```
```    89 bind_thms ("disj_comms", [disj_commute, disj_left_commute]);
```
```    90 prove "disj_assoc" "((P|Q)|R) = (P|(Q|R))";
```
```    91
```
```    92 prove "conj_disj_distribL" "(P&(Q|R)) = (P&Q | P&R)";
```
```    93 prove "conj_disj_distribR" "((P|Q)&R) = (P&R | Q&R)";
```
```    94
```
```    95 prove "disj_conj_distribL" "(P|(Q&R)) = ((P|Q) & (P|R))";
```
```    96 prove "disj_conj_distribR" "((P&Q)|R) = ((P|R) & (Q|R))";
```
```    97
```
```    98 prove "imp_conjR" "(P --> (Q&R)) = ((P-->Q) & (P-->R))";
```
```    99 prove "imp_conjL" "((P&Q) -->R)  = (P --> (Q --> R))";
```
```   100 prove "imp_disjL" "((P|Q) --> R) = ((P-->R)&(Q-->R))";
```
```   101
```
```   102 (*These two are specialized, but imp_disj_not1 is useful in Auth/Yahalom.ML*)
```
```   103 prove "imp_disj_not1" "(P --> Q | R) = (~Q --> P --> R)";
```
```   104 prove "imp_disj_not2" "(P --> Q | R) = (~R --> P --> Q)";
```
```   105
```
```   106 prove "imp_disj1" "((P-->Q)|R) = (P--> Q|R)";
```
```   107 prove "imp_disj2" "(Q|(P-->R)) = (P--> Q|R)";
```
```   108
```
```   109 prove "de_Morgan_disj" "(~(P | Q)) = (~P & ~Q)";
```
```   110 prove "de_Morgan_conj" "(~(P & Q)) = (~P | ~Q)";
```
```   111 prove "not_imp" "(~(P --> Q)) = (P & ~Q)";
```
```   112 prove "not_iff" "(P~=Q) = (P = (~Q))";
```
```   113 prove "disj_not1" "(~P | Q) = (P --> Q)";
```
```   114 prove "disj_not2" "(P | ~Q) = (Q --> P)"; (* changes orientation :-( *)
```
```   115 prove "imp_conv_disj" "(P --> Q) = ((~P) | Q)";
```
```   116
```
```   117 prove "iff_conv_conj_imp" "(P = Q) = ((P --> Q) & (Q --> P))";
```
```   118
```
```   119
```
```   120 (*Avoids duplication of subgoals after split_if, when the true and false
```
```   121   cases boil down to the same thing.*)
```
```   122 prove "cases_simp" "((P --> Q) & (~P --> Q)) = Q";
```
```   123
```
```   124 prove "not_all" "(~ (! x. P(x))) = (? x.~P(x))";
```
```   125 prove "imp_all" "((! x. P x) --> Q) = (? x. P x --> Q)";
```
```   126 prove "not_ex"  "(~ (? x. P(x))) = (! x.~P(x))";
```
```   127 prove "imp_ex" "((? x. P x) --> Q) = (! x. P x --> Q)";
```
```   128
```
```   129 prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))";
```
```   130 prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))";
```
```   131
```
```   132 (* '&' congruence rule: not included by default!
```
```   133    May slow rewrite proofs down by as much as 50% *)
```
```   134
```
```   135 let val th = prove_goal (the_context ())
```
```   136                 "(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))"
```
```   137                 (fn _=> [(Blast_tac 1)])
```
```   138 in  bind_thm("conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
```
```   139
```
```   140 let val th = prove_goal (the_context ())
```
```   141                 "(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))"
```
```   142                 (fn _=> [(Blast_tac 1)])
```
```   143 in  bind_thm("rev_conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
```
```   144
```
```   145 (* '|' congruence rule: not included by default! *)
```
```   146
```
```   147 let val th = prove_goal (the_context ())
```
```   148                 "(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))"
```
```   149                 (fn _=> [(Blast_tac 1)])
```
```   150 in  bind_thm("disj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
```
```   151
```
```   152 prove "eq_sym_conv" "(x=y) = (y=x)";
```
```   153
```
```   154
```
```   155 (** if-then-else rules **)
```
```   156
```
```   157 Goalw [if_def] "(if True then x else y) = x";
```
```   158 by (Blast_tac 1);
```
```   159 qed "if_True";
```
```   160
```
```   161 Goalw [if_def] "(if False then x else y) = y";
```
```   162 by (Blast_tac 1);
```
```   163 qed "if_False";
```
```   164
```
```   165 Goalw [if_def] "P ==> (if P then x else y) = x";
```
```   166 by (Blast_tac 1);
```
```   167 qed "if_P";
```
```   168
```
```   169 Goalw [if_def] "~P ==> (if P then x else y) = y";
```
```   170 by (Blast_tac 1);
```
```   171 qed "if_not_P";
```
```   172
```
```   173 Goal "P(if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))";
```
```   174 by (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1);
```
```   175 by (stac if_P 2);
```
```   176 by (stac if_not_P 1);
```
```   177 by (ALLGOALS (Blast_tac));
```
```   178 qed "split_if";
```
```   179
```
```   180 Goal "P(if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))";
```
```   181 by (stac split_if 1);
```
```   182 by (Blast_tac 1);
```
```   183 qed "split_if_asm";
```
```   184
```
```   185 bind_thms ("if_splits", [split_if, split_if_asm]);
```
```   186
```
```   187 bind_thm ("if_def2", read_instantiate [("P","\\<lambda>x. x")] split_if);
```
```   188
```
```   189 Goal "(if c then x else x) = x";
```
```   190 by (stac split_if 1);
```
```   191 by (Blast_tac 1);
```
```   192 qed "if_cancel";
```
```   193
```
```   194 Goal "(if x = y then y else x) = x";
```
```   195 by (stac split_if 1);
```
```   196 by (Blast_tac 1);
```
```   197 qed "if_eq_cancel";
```
```   198
```
```   199 (*This form is useful for expanding IFs on the RIGHT of the ==> symbol*)
```
```   200 Goal "(if P then Q else R) = ((P-->Q) & (~P-->R))";
```
```   201 by (rtac split_if 1);
```
```   202 qed "if_bool_eq_conj";
```
```   203
```
```   204 (*And this form is useful for expanding IFs on the LEFT*)
```
```   205 Goal "(if P then Q else R) = ((P&Q) | (~P&R))";
```
```   206 by (stac split_if 1);
```
```   207 by (Blast_tac 1);
```
```   208 qed "if_bool_eq_disj";
```
```   209
```
```   210 local
```
```   211 val uncurry = prove_goal (the_context()) "P --> Q --> R ==> P & Q --> R"
```
```   212               (fn prems => [cut_facts_tac prems 1, Blast_tac 1]);
```
```   213
```
```   214 val iff_allI = allI RS
```
```   215     prove_goal (the_context()) "!x. P x = Q x ==> (!x. P x) = (!x. Q x)"
```
```   216                (fn prems => [cut_facts_tac prems 1, Blast_tac 1])
```
```   217 in
```
```   218
```
```   219 (*** make simplification procedures for quantifier elimination ***)
```
```   220
```
```   221 structure Quantifier1 = Quantifier1Fun
```
```   222 (struct
```
```   223   (*abstract syntax*)
```
```   224   fun dest_eq((c as Const("op =",_)) \$ s \$ t) = Some(c,s,t)
```
```   225     | dest_eq _ = None;
```
```   226   fun dest_conj((c as Const("op &",_)) \$ s \$ t) = Some(c,s,t)
```
```   227     | dest_conj _ = None;
```
```   228   fun dest_imp((c as Const("op -->",_)) \$ s \$ t) = Some(c,s,t)
```
```   229     | dest_imp _ = None;
```
```   230   val conj = HOLogic.conj
```
```   231   val imp  = HOLogic.imp
```
```   232   (*rules*)
```
```   233   val iff_reflection = eq_reflection
```
```   234   val iffI = iffI
```
```   235   val conjI= conjI
```
```   236   val conjE= conjE
```
```   237   val impI = impI
```
```   238   val mp   = mp
```
```   239   val uncurry = uncurry
```
```   240   val exI  = exI
```
```   241   val exE  = exE
```
```   242   val iff_allI = iff_allI
```
```   243 end);
```
```   244
```
```   245 end;
```
```   246
```
```   247 local
```
```   248 val ex_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
```
```   249     ("EX x. P(x) & Q(x)",HOLogic.boolT)
```
```   250 val all_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
```
```   251     ("ALL x. P(x) --> Q(x)",HOLogic.boolT)
```
```   252 in
```
```   253 val defEX_regroup = mk_simproc "defined EX" [ex_pattern]
```
```   254       Quantifier1.rearrange_ex
```
```   255 val defALL_regroup = mk_simproc "defined ALL" [all_pattern]
```
```   256       Quantifier1.rearrange_all
```
```   257 end;
```
```   258
```
```   259
```
```   260 (*** Case splitting ***)
```
```   261
```
```   262 (*Make meta-equalities.  The operator below is Trueprop*)
```
```   263
```
```   264 fun mk_meta_eq r = r RS eq_reflection;
```
```   265 fun safe_mk_meta_eq r = mk_meta_eq r handle Thm.THM _ => r;
```
```   266
```
```   267 bind_thm ("Eq_TrueI", mk_meta_eq (prover  "P --> (P = True)"  RS mp));
```
```   268 bind_thm ("Eq_FalseI", mk_meta_eq(prover "~P --> (P = False)" RS mp));
```
```   269
```
```   270 fun mk_eq th = case concl_of th of
```
```   271         Const("==",_)\$_\$_       => th
```
```   272     |   _\$(Const("op =",_)\$_\$_) => mk_meta_eq th
```
```   273     |   _\$(Const("Not",_)\$_)    => th RS Eq_FalseI
```
```   274     |   _                       => th RS Eq_TrueI;
```
```   275 (* last 2 lines requires all formulae to be of the from Trueprop(.) *)
```
```   276
```
```   277 fun mk_eq_True r =
```
```   278   Some (r RS meta_eq_to_obj_eq RS Eq_TrueI) handle Thm.THM _ => None;
```
```   279
```
```   280 (*Congruence rules for = (instead of ==)*)
```
```   281 fun mk_meta_cong rl =
```
```   282   standard(mk_meta_eq(replicate (nprems_of rl) meta_eq_to_obj_eq MRS rl))
```
```   283   handle THM _ =>
```
```   284   error("Premises and conclusion of congruence rules must be =-equalities");
```
```   285
```
```   286 (* Elimination of True from asumptions: *)
```
```   287
```
```   288 local fun rd s = read_cterm (sign_of (the_context())) (s, propT);
```
```   289 in val True_implies_equals = standard' (equal_intr
```
```   290   (implies_intr_hyps (implies_elim (assume (rd "True ==> PROP P")) TrueI))
```
```   291   (implies_intr_hyps (implies_intr (rd "True") (assume (rd "PROP P")))));
```
```   292 end;
```
```   293
```
```   294
```
```   295 structure SplitterData =
```
```   296   struct
```
```   297   structure Simplifier = Simplifier
```
```   298   val mk_eq          = mk_eq
```
```   299   val meta_eq_to_iff = meta_eq_to_obj_eq
```
```   300   val iffD           = iffD2
```
```   301   val disjE          = disjE
```
```   302   val conjE          = conjE
```
```   303   val exE            = exE
```
```   304   val contrapos      = contrapos_nn
```
```   305   val contrapos2     = contrapos_pp
```
```   306   val notnotD        = notnotD
```
```   307   end;
```
```   308
```
```   309 structure Splitter = SplitterFun(SplitterData);
```
```   310
```
```   311 val split_tac        = Splitter.split_tac;
```
```   312 val split_inside_tac = Splitter.split_inside_tac;
```
```   313 val split_asm_tac    = Splitter.split_asm_tac;
```
```   314 val op addsplits     = Splitter.addsplits;
```
```   315 val op delsplits     = Splitter.delsplits;
```
```   316 val Addsplits        = Splitter.Addsplits;
```
```   317 val Delsplits        = Splitter.Delsplits;
```
```   318
```
```   319 (*In general it seems wrong to add distributive laws by default: they
```
```   320   might cause exponential blow-up.  But imp_disjL has been in for a while
```
```   321   and cannot be removed without affecting existing proofs.  Moreover,
```
```   322   rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
```
```   323   grounds that it allows simplification of R in the two cases.*)
```
```   324
```
```   325 val mksimps_pairs =
```
```   326   [("op -->", [mp]), ("op &", [conjunct1,conjunct2]),
```
```   327    ("All", [spec]), ("True", []), ("False", []),
```
```   328    ("If", [if_bool_eq_conj RS iffD1])];
```
```   329
```
```   330 (* ###FIXME: move to Provers/simplifier.ML
```
```   331 val mk_atomize:      (string * thm list) list -> thm -> thm list
```
```   332 *)
```
```   333 (* ###FIXME: move to Provers/simplifier.ML *)
```
```   334 fun mk_atomize pairs =
```
```   335   let fun atoms th =
```
```   336         (case concl_of th of
```
```   337            Const("Trueprop",_) \$ p =>
```
```   338              (case head_of p of
```
```   339                 Const(a,_) =>
```
```   340                   (case assoc(pairs,a) of
```
```   341                      Some(rls) => flat (map atoms ([th] RL rls))
```
```   342                    | None => [th])
```
```   343               | _ => [th])
```
```   344          | _ => [th])
```
```   345   in atoms end;
```
```   346
```
```   347 fun mksimps pairs =
```
```   348   (mapfilter (try mk_eq) o mk_atomize pairs o forall_elim_vars_safe);
```
```   349
```
```   350 fun unsafe_solver_tac prems =
```
```   351   FIRST'[resolve_tac(reflexive_thm::TrueI::refl::prems), atac, etac FalseE];
```
```   352 val unsafe_solver = mk_solver "HOL unsafe" unsafe_solver_tac;
```
```   353
```
```   354 (*No premature instantiation of variables during simplification*)
```
```   355 fun safe_solver_tac prems =
```
```   356   FIRST'[match_tac(reflexive_thm::TrueI::refl::prems),
```
```   357          eq_assume_tac, ematch_tac [FalseE]];
```
```   358 val safe_solver = mk_solver "HOL safe" safe_solver_tac;
```
```   359
```
```   360 val HOL_basic_ss =
```
```   361   empty_ss setsubgoaler asm_simp_tac
```
```   362     setSSolver safe_solver
```
```   363     setSolver unsafe_solver
```
```   364     setmksimps (mksimps mksimps_pairs)
```
```   365     setmkeqTrue mk_eq_True
```
```   366     setmkcong mk_meta_cong;
```
```   367
```
```   368 val HOL_ss =
```
```   369     HOL_basic_ss addsimps
```
```   370      ([triv_forall_equality, (* prunes params *)
```
```   371        True_implies_equals, (* prune asms `True' *)
```
```   372        eta_contract_eq, (* prunes eta-expansions *)
```
```   373        if_True, if_False, if_cancel, if_eq_cancel,
```
```   374        imp_disjL, conj_assoc, disj_assoc,
```
```   375        de_Morgan_conj, de_Morgan_disj, imp_disj1, imp_disj2, not_imp,
```
```   376        disj_not1, not_all, not_ex, cases_simp,
```
```   377        thm "the_eq_trivial", the_sym_eq_trivial, thm "plus_ac0.zero", thm "plus_ac0_zero_right"]
```
```   378      @ ex_simps @ all_simps @ simp_thms)
```
```   379      addsimprocs [defALL_regroup,defEX_regroup]
```
```   380      addcongs [imp_cong]
```
```   381      addsplits [split_if];
```
```   382
```
```   383 fun hol_simplify rews = Simplifier.full_simplify (HOL_basic_ss addsimps rews);
```
```   384
```
```   385
```
```   386 (*Simplifies x assuming c and y assuming ~c*)
```
```   387 val prems = Goalw [if_def]
```
```   388   "[| b=c; c ==> x=u; ~c ==> y=v |] ==> \
```
```   389 \  (if b then x else y) = (if c then u else v)";
```
```   390 by (asm_simp_tac (HOL_ss addsimps prems) 1);
```
```   391 qed "if_cong";
```
```   392
```
```   393 (*Prevents simplification of x and y: faster and allows the execution
```
```   394   of functional programs. NOW THE DEFAULT.*)
```
```   395 Goal "b=c ==> (if b then x else y) = (if c then x else y)";
```
```   396 by (etac arg_cong 1);
```
```   397 qed "if_weak_cong";
```
```   398
```
```   399 (*Prevents simplification of t: much faster*)
```
```   400 Goal "a = b ==> (let x=a in t(x)) = (let x=b in t(x))";
```
```   401 by (etac arg_cong 1);
```
```   402 qed "let_weak_cong";
```
```   403
```
```   404 Goal "f(if c then x else y) = (if c then f x else f y)";
```
```   405 by (simp_tac (HOL_ss setloop (split_tac [split_if])) 1);
```
```   406 qed "if_distrib";
```
```   407
```
```   408 (*For expand_case_tac*)
```
```   409 val prems = Goal "[| P ==> Q(True); ~P ==> Q(False) |] ==> Q(P)";
```
```   410 by (case_tac "P" 1);
```
```   411 by (ALLGOALS (asm_simp_tac (HOL_ss addsimps prems)));
```
```   412 qed "expand_case";
```
```   413
```
```   414 (*Used in Auth proofs.  Typically P contains Vars that become instantiated
```
```   415   during unification.*)
```
```   416 fun expand_case_tac P i =
```
```   417     res_inst_tac [("P",P)] expand_case i THEN
```
```   418     Simp_tac (i+1) THEN
```
```   419     Simp_tac i;
```
```   420
```
```   421 (*This lemma restricts the effect of the rewrite rule u=v to the left-hand
```
```   422   side of an equality.  Used in {Integ,Real}/simproc.ML*)
```
```   423 Goal "x=y ==> (x=z) = (y=z)";
```
```   424 by (asm_simp_tac HOL_ss 1);
```
```   425 qed "restrict_to_left";
```
```   426
```
```   427 (* default simpset *)
```
```   428 val simpsetup =
```
```   429   [fn thy => (simpset_ref_of thy := HOL_ss addcongs [if_weak_cong]; thy)];
```
```   430
```
```   431
```
```   432 (*** integration of simplifier with classical reasoner ***)
```
```   433
```
```   434 structure Clasimp = ClasimpFun
```
```   435  (structure Simplifier = Simplifier and Splitter = Splitter
```
```   436   and Classical  = Classical and Blast = Blast
```
```   437   val iffD1 = iffD1 val iffD2 = iffD2 val notE = notE
```
```   438   val cla_make_elim = cla_make_elim);
```
```   439 open Clasimp;
```
```   440
```
```   441 val HOL_css = (HOL_cs, HOL_ss);
```
```   442
```
```   443
```
```   444
```
```   445 (*** A general refutation procedure ***)
```
```   446
```
```   447 (* Parameters:
```
```   448
```
```   449    test: term -> bool
```
```   450    tests if a term is at all relevant to the refutation proof;
```
```   451    if not, then it can be discarded. Can improve performance,
```
```   452    esp. if disjunctions can be discarded (no case distinction needed!).
```
```   453
```
```   454    prep_tac: int -> tactic
```
```   455    A preparation tactic to be applied to the goal once all relevant premises
```
```   456    have been moved to the conclusion.
```
```   457
```
```   458    ref_tac: int -> tactic
```
```   459    the actual refutation tactic. Should be able to deal with goals
```
```   460    [| A1; ...; An |] ==> False
```
```   461    where the Ai are atomic, i.e. no top-level &, | or EX
```
```   462 *)
```
```   463
```
```   464 fun refute_tac test prep_tac ref_tac =
```
```   465   let val nnf_simps =
```
```   466         [imp_conv_disj,iff_conv_conj_imp,de_Morgan_disj,de_Morgan_conj,
```
```   467          not_all,not_ex,not_not];
```
```   468       val nnf_simpset =
```
```   469         empty_ss setmkeqTrue mk_eq_True
```
```   470                  setmksimps (mksimps mksimps_pairs)
```
```   471                  addsimps nnf_simps;
```
```   472       val prem_nnf_tac = full_simp_tac nnf_simpset;
```
```   473
```
```   474       val refute_prems_tac =
```
```   475         REPEAT(eresolve_tac [conjE, exE] 1 ORELSE
```
```   476                filter_prems_tac test 1 ORELSE
```
```   477                etac disjE 1) THEN
```
```   478         ((etac notE 1 THEN eq_assume_tac 1) ORELSE
```
```   479          ref_tac 1);
```
```   480   in EVERY'[TRY o filter_prems_tac test,
```
```   481             DETERM o REPEAT o etac rev_mp, prep_tac, rtac ccontr, prem_nnf_tac,
```
```   482             SELECT_GOAL (DEPTH_SOLVE refute_prems_tac)]
```
```   483   end;
```