| 7355 |      1 | (*  Title:      FOL/IFOL_lemmas.ML
 | 
|  |      2 |     ID:         $Id$
 | 
|  |      3 |     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
 | 
|  |      4 |     Copyright   1992  University of Cambridge
 | 
|  |      5 | 
 | 
|  |      6 | Tactics and lemmas for theory IFOL (intuitionistic first-order logic).
 | 
|  |      7 | *)
 | 
|  |      8 | 
 | 
|  |      9 | (* ML bindings *)
 | 
|  |     10 | 
 | 
|  |     11 | val refl = thm "refl";
 | 
|  |     12 | val subst = thm "subst";
 | 
|  |     13 | val conjI = thm "conjI";
 | 
|  |     14 | val conjunct1 = thm "conjunct1";
 | 
|  |     15 | val conjunct2 = thm "conjunct2";
 | 
|  |     16 | val disjI1 = thm "disjI1";
 | 
|  |     17 | val disjI2 = thm "disjI2";
 | 
|  |     18 | val disjE = thm "disjE";
 | 
|  |     19 | val impI = thm "impI";
 | 
|  |     20 | val mp = thm "mp";
 | 
|  |     21 | val FalseE = thm "FalseE";
 | 
|  |     22 | val True_def = thm "True_def";
 | 
|  |     23 | val not_def = thm "not_def";
 | 
|  |     24 | val iff_def = thm "iff_def";
 | 
|  |     25 | val ex1_def = thm "ex1_def";
 | 
|  |     26 | val allI = thm "allI";
 | 
|  |     27 | val spec = thm "spec";
 | 
|  |     28 | val exI = thm "exI";
 | 
|  |     29 | val exE = thm "exE";
 | 
|  |     30 | val eq_reflection = thm "eq_reflection";
 | 
|  |     31 | val iff_reflection = thm "iff_reflection";
 | 
|  |     32 | 
 | 
|  |     33 | 
 | 
|  |     34 | 
 | 
| 9264 |     35 | Goalw [True_def]  "True";
 | 
|  |     36 | by (REPEAT (ares_tac [impI] 1)) ;
 | 
|  |     37 | qed "TrueI";
 | 
| 7355 |     38 | 
 | 
|  |     39 | (*** Sequent-style elimination rules for & --> and ALL ***)
 | 
|  |     40 | 
 | 
| 9264 |     41 | val major::prems = Goal 
 | 
|  |     42 |     "[| P&Q; [| P; Q |] ==> R |] ==> R";
 | 
|  |     43 | by (resolve_tac prems 1);
 | 
|  |     44 | by (rtac (major RS conjunct1) 1);
 | 
|  |     45 | by (rtac (major RS conjunct2) 1);
 | 
|  |     46 | qed "conjE";
 | 
| 7355 |     47 | 
 | 
| 9264 |     48 | val major::prems = Goal 
 | 
|  |     49 |     "[| P-->Q;  P;  Q ==> R |] ==> R";
 | 
|  |     50 | by (resolve_tac prems 1);
 | 
|  |     51 | by (rtac (major RS mp) 1);
 | 
|  |     52 | by (resolve_tac prems 1);
 | 
|  |     53 | qed "impE";
 | 
| 7355 |     54 | 
 | 
| 9264 |     55 | val major::prems = Goal 
 | 
|  |     56 |     "[| ALL x. P(x); P(x) ==> R |] ==> R";
 | 
|  |     57 | by (resolve_tac prems 1);
 | 
|  |     58 | by (rtac (major RS spec) 1);
 | 
|  |     59 | qed "allE";
 | 
| 7355 |     60 | 
 | 
|  |     61 | (*Duplicates the quantifier; for use with eresolve_tac*)
 | 
| 9264 |     62 | val major::prems = Goal 
 | 
| 7355 |     63 |     "[| ALL x. P(x);  [| P(x); ALL x. P(x) |] ==> R \
 | 
| 9264 |     64 | \    |] ==> R";
 | 
|  |     65 | by (resolve_tac prems 1);
 | 
|  |     66 | by (rtac (major RS spec) 1);
 | 
|  |     67 | by (rtac major 1);
 | 
|  |     68 | qed "all_dupE";
 | 
| 7355 |     69 | 
 | 
|  |     70 | 
 | 
|  |     71 | (*** Negation rules, which translate between ~P and P-->False ***)
 | 
|  |     72 | 
 | 
| 9264 |     73 | val prems = Goalw [not_def]  "(P ==> False) ==> ~P";
 | 
|  |     74 | by (REPEAT (ares_tac (prems@[impI]) 1)) ;
 | 
|  |     75 | qed "notI";
 | 
| 7355 |     76 | 
 | 
| 9264 |     77 | Goalw [not_def]  "[| ~P;  P |] ==> R";
 | 
|  |     78 | by (etac (mp RS FalseE) 1);
 | 
|  |     79 | by (assume_tac 1);
 | 
|  |     80 | qed "notE";
 | 
| 7355 |     81 | 
 | 
| 9264 |     82 | Goal "[| P; ~P |] ==> R";
 | 
|  |     83 | by (etac notE 1);
 | 
|  |     84 | by (assume_tac 1);
 | 
|  |     85 | qed "rev_notE";
 | 
| 7355 |     86 | 
 | 
|  |     87 | (*This is useful with the special implication rules for each kind of P. *)
 | 
| 9264 |     88 | val prems = Goal 
 | 
|  |     89 |     "[| ~P;  (P-->False) ==> Q |] ==> Q";
 | 
|  |     90 | by (REPEAT (ares_tac (prems@[impI,notE]) 1)) ;
 | 
|  |     91 | qed "not_to_imp";
 | 
| 7355 |     92 | 
 | 
|  |     93 | (* For substitution into an assumption P, reduce Q to P-->Q, substitute into
 | 
|  |     94 |    this implication, then apply impI to move P back into the assumptions.
 | 
|  |     95 |    To specify P use something like
 | 
|  |     96 |       eres_inst_tac [ ("P","ALL y. ?S(x,y)") ] rev_mp 1   *)
 | 
| 9264 |     97 | Goal "[| P;  P --> Q |] ==> Q";
 | 
|  |     98 | by (etac mp 1);
 | 
|  |     99 | by (assume_tac 1);
 | 
|  |    100 | qed "rev_mp";
 | 
| 7355 |    101 | 
 | 
|  |    102 | (*Contrapositive of an inference rule*)
 | 
| 9264 |    103 | val [major,minor]= Goal "[| ~Q;  P==>Q |] ==> ~P";
 | 
|  |    104 | by (rtac (major RS notE RS notI) 1);
 | 
|  |    105 | by (etac minor 1) ;
 | 
|  |    106 | qed "contrapos";
 | 
| 7355 |    107 | 
 | 
|  |    108 | 
 | 
|  |    109 | (*** Modus Ponens Tactics ***)
 | 
|  |    110 | 
 | 
|  |    111 | (*Finds P-->Q and P in the assumptions, replaces implication by Q *)
 | 
|  |    112 | fun mp_tac i = eresolve_tac [notE,impE] i  THEN  assume_tac i;
 | 
|  |    113 | 
 | 
|  |    114 | (*Like mp_tac but instantiates no variables*)
 | 
|  |    115 | fun eq_mp_tac i = eresolve_tac [notE,impE] i  THEN  eq_assume_tac i;
 | 
|  |    116 | 
 | 
|  |    117 | 
 | 
|  |    118 | (*** If-and-only-if ***)
 | 
|  |    119 | 
 | 
| 9264 |    120 | val prems = Goalw [iff_def] 
 | 
|  |    121 |    "[| P ==> Q;  Q ==> P |] ==> P<->Q";
 | 
|  |    122 | by (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ;
 | 
|  |    123 | qed "iffI";
 | 
| 7355 |    124 | 
 | 
|  |    125 | 
 | 
|  |    126 | (*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
 | 
| 9264 |    127 | val prems = Goalw [iff_def] 
 | 
|  |    128 |     "[| P <-> Q;  [| P-->Q; Q-->P |] ==> R |] ==> R";
 | 
|  |    129 | by (rtac conjE 1);
 | 
|  |    130 | by (REPEAT (ares_tac prems 1)) ;
 | 
|  |    131 | qed "iffE";
 | 
| 7355 |    132 | 
 | 
|  |    133 | (* Destruct rules for <-> similar to Modus Ponens *)
 | 
|  |    134 | 
 | 
| 9264 |    135 | Goalw [iff_def]  "[| P <-> Q;  P |] ==> Q";
 | 
|  |    136 | by (etac (conjunct1 RS mp) 1);
 | 
|  |    137 | by (assume_tac 1);
 | 
|  |    138 | qed "iffD1";
 | 
| 7355 |    139 | 
 | 
| 9264 |    140 | val prems = Goalw [iff_def]  "[| P <-> Q;  Q |] ==> P";
 | 
|  |    141 | by (etac (conjunct2 RS mp) 1);
 | 
|  |    142 | by (assume_tac 1);
 | 
|  |    143 | qed "iffD2";
 | 
| 7355 |    144 | 
 | 
| 9264 |    145 | Goal "[| P; P <-> Q |] ==> Q";
 | 
|  |    146 | by (etac iffD1 1);
 | 
|  |    147 | by (assume_tac 1);
 | 
|  |    148 | qed "rev_iffD1";
 | 
| 7355 |    149 | 
 | 
| 9264 |    150 | Goal "[| Q; P <-> Q |] ==> P";
 | 
|  |    151 | by (etac iffD2 1);
 | 
|  |    152 | by (assume_tac 1);
 | 
|  |    153 | qed "rev_iffD2";
 | 
|  |    154 | 
 | 
|  |    155 | Goal "P <-> P";
 | 
|  |    156 | by (REPEAT (ares_tac [iffI] 1)) ;
 | 
|  |    157 | qed "iff_refl";
 | 
| 7355 |    158 | 
 | 
| 9264 |    159 | Goal "Q <-> P ==> P <-> Q";
 | 
|  |    160 | by (etac iffE 1);
 | 
|  |    161 | by (rtac iffI 1);
 | 
|  |    162 | by (REPEAT (eresolve_tac [asm_rl,mp] 1)) ;
 | 
|  |    163 | qed "iff_sym";
 | 
| 7355 |    164 | 
 | 
| 9264 |    165 | Goal "[| P <-> Q;  Q<-> R |] ==> P <-> R";
 | 
|  |    166 | by (rtac iffI 1);
 | 
|  |    167 | by (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ;
 | 
|  |    168 | qed "iff_trans";
 | 
| 7355 |    169 | 
 | 
|  |    170 | 
 | 
|  |    171 | (*** Unique existence.  NOTE THAT the following 2 quantifications
 | 
|  |    172 |    EX!x such that [EX!y such that P(x,y)]     (sequential)
 | 
|  |    173 |    EX!x,y such that P(x,y)                    (simultaneous)
 | 
|  |    174 |  do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
 | 
|  |    175 | ***)
 | 
|  |    176 | 
 | 
| 9264 |    177 | val prems = Goalw [ex1_def] 
 | 
|  |    178 |     "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)";
 | 
|  |    179 | by (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ;
 | 
|  |    180 | qed "ex1I";
 | 
| 7355 |    181 | 
 | 
|  |    182 | (*Sometimes easier to use: the premises have no shared variables.  Safe!*)
 | 
| 9264 |    183 | val [ex,eq] = Goal
 | 
|  |    184 |     "[| EX x. P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)";
 | 
|  |    185 | by (rtac (ex RS exE) 1);
 | 
|  |    186 | by (REPEAT (ares_tac [ex1I,eq] 1)) ;
 | 
|  |    187 | qed "ex_ex1I";
 | 
| 7355 |    188 | 
 | 
| 9264 |    189 | val prems = Goalw [ex1_def] 
 | 
|  |    190 |     "[| EX! x. P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R";
 | 
|  |    191 | by (cut_facts_tac prems 1);
 | 
|  |    192 | by (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ;
 | 
|  |    193 | qed "ex1E";
 | 
| 7355 |    194 | 
 | 
|  |    195 | 
 | 
|  |    196 | (*** <-> congruence rules for simplification ***)
 | 
|  |    197 | 
 | 
|  |    198 | (*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
 | 
|  |    199 | fun iff_tac prems i =
 | 
|  |    200 |     resolve_tac (prems RL [iffE]) i THEN
 | 
|  |    201 |     REPEAT1 (eresolve_tac [asm_rl,mp] i);
 | 
|  |    202 | 
 | 
| 9264 |    203 | val prems = Goal 
 | 
|  |    204 |     "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P&Q) <-> (P'&Q')";
 | 
|  |    205 | by (cut_facts_tac prems 1);
 | 
|  |    206 | by (REPEAT  (ares_tac [iffI,conjI] 1
 | 
|  |    207 |      ORELSE  eresolve_tac [iffE,conjE,mp] 1 
 | 
|  |    208 |      ORELSE  iff_tac prems 1)) ;
 | 
|  |    209 | qed "conj_cong";
 | 
| 7355 |    210 | 
 | 
|  |    211 | (*Reversed congruence rule!   Used in ZF/Order*)
 | 
| 9264 |    212 | val prems = Goal 
 | 
|  |    213 |     "[| P <-> P';  P' ==> Q <-> Q' |] ==> (Q&P) <-> (Q'&P')";
 | 
|  |    214 | by (cut_facts_tac prems 1);
 | 
|  |    215 | by (REPEAT  (ares_tac [iffI,conjI] 1
 | 
|  |    216 |      ORELSE  eresolve_tac [iffE,conjE,mp] 1 ORELSE  iff_tac prems 1)) ;
 | 
|  |    217 | qed "conj_cong2";
 | 
| 7355 |    218 | 
 | 
| 9264 |    219 | val prems = Goal 
 | 
|  |    220 |     "[| P <-> P';  Q <-> Q' |] ==> (P|Q) <-> (P'|Q')";
 | 
|  |    221 | by (cut_facts_tac prems 1);
 | 
|  |    222 | by (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
 | 
|  |    223 |              ORELSE  ares_tac [iffI] 1 ORELSE  mp_tac 1)) ;
 | 
|  |    224 | qed "disj_cong";
 | 
| 7355 |    225 | 
 | 
| 9264 |    226 | val prems = Goal 
 | 
|  |    227 |     "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')";
 | 
|  |    228 | by (cut_facts_tac prems 1);
 | 
|  |    229 | by (REPEAT   (ares_tac [iffI,impI] 1
 | 
|  |    230 |       ORELSE  etac iffE 1 ORELSE  mp_tac 1 ORELSE iff_tac prems 1)) ;
 | 
|  |    231 | qed "imp_cong";
 | 
| 7355 |    232 | 
 | 
| 9264 |    233 | val prems = Goal 
 | 
|  |    234 |     "[| P <-> P';  Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')";
 | 
|  |    235 | by (cut_facts_tac prems 1);
 | 
|  |    236 | by (REPEAT   (etac iffE 1 ORELSE  ares_tac [iffI] 1 ORELSE  mp_tac 1)) ;
 | 
|  |    237 | qed "iff_cong";
 | 
| 7355 |    238 | 
 | 
| 9264 |    239 | val prems = Goal 
 | 
|  |    240 |     "P <-> P' ==> ~P <-> ~P'";
 | 
|  |    241 | by (cut_facts_tac prems 1);
 | 
|  |    242 | by (REPEAT   (ares_tac [iffI,notI] 1
 | 
|  |    243 |       ORELSE  mp_tac 1 ORELSE  eresolve_tac [iffE,notE] 1)) ;
 | 
|  |    244 | qed "not_cong";
 | 
| 7355 |    245 | 
 | 
| 9264 |    246 | val prems = Goal 
 | 
|  |    247 |     "(!!x. P(x) <-> Q(x)) ==> (ALL x. P(x)) <-> (ALL x. Q(x))";
 | 
|  |    248 | by (REPEAT   (ares_tac [iffI,allI] 1
 | 
|  |    249 |      ORELSE   mp_tac 1 ORELSE   etac allE 1 ORELSE iff_tac prems 1)) ;
 | 
|  |    250 | qed "all_cong";
 | 
| 7355 |    251 | 
 | 
| 9264 |    252 | val prems = Goal 
 | 
|  |    253 |     "(!!x. P(x) <-> Q(x)) ==> (EX x. P(x)) <-> (EX x. Q(x))";
 | 
|  |    254 | by (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
 | 
|  |    255 |      ORELSE   mp_tac 1 ORELSE   iff_tac prems 1)) ;
 | 
|  |    256 | qed "ex_cong";
 | 
| 7355 |    257 | 
 | 
| 9264 |    258 | val prems = Goal 
 | 
|  |    259 |     "(!!x. P(x) <-> Q(x)) ==> (EX! x. P(x)) <-> (EX! x. Q(x))";
 | 
|  |    260 | by (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1
 | 
|  |    261 |        ORELSE ares_tac [iffI,ex1I] 1 ORELSE   mp_tac 1
 | 
|  |    262 |        ORELSE   iff_tac prems 1)) ;
 | 
|  |    263 | qed "ex1_cong";
 | 
| 7355 |    264 | 
 | 
|  |    265 | (*** Equality rules ***)
 | 
|  |    266 | 
 | 
| 9264 |    267 | Goal "a=b ==> b=a";
 | 
|  |    268 | by (etac subst 1);
 | 
|  |    269 | by (rtac refl 1) ;
 | 
|  |    270 | qed "sym";
 | 
| 7355 |    271 | 
 | 
| 9264 |    272 | Goal "[| a=b;  b=c |] ==> a=c";
 | 
|  |    273 | by (etac subst 1 THEN assume_tac 1) ;
 | 
|  |    274 | qed "trans";
 | 
| 7355 |    275 | 
 | 
|  |    276 | (** ~ b=a ==> ~ a=b **)
 | 
| 7422 |    277 | bind_thm ("not_sym", hd (compose(sym,2,contrapos)));
 | 
| 7355 |    278 | 
 | 
|  |    279 | 
 | 
|  |    280 | (* Two theorms for rewriting only one instance of a definition:
 | 
|  |    281 |    the first for definitions of formulae and the second for terms *)
 | 
|  |    282 | 
 | 
| 9264 |    283 | val prems = goal (the_context()) "(A == B) ==> A <-> B";
 | 
| 7355 |    284 | by (rewrite_goals_tac prems);
 | 
|  |    285 | by (rtac iff_refl 1);
 | 
|  |    286 | qed "def_imp_iff";
 | 
|  |    287 | 
 | 
| 9264 |    288 | val prems = goal (the_context()) "(A == B) ==> A = B";
 | 
| 7355 |    289 | by (rewrite_goals_tac prems);
 | 
|  |    290 | by (rtac refl 1);
 | 
|  |    291 | qed "meta_eq_to_obj_eq";
 | 
|  |    292 | 
 | 
| 9527 |    293 | (*substitution*)
 | 
| 7355 |    294 | bind_thm ("ssubst", sym RS subst);
 | 
|  |    295 | 
 | 
|  |    296 | (*A special case of ex1E that would otherwise need quantifier expansion*)
 | 
| 9264 |    297 | val prems = Goal
 | 
|  |    298 |     "[| EX! x. P(x);  P(a);  P(b) |] ==> a=b";
 | 
|  |    299 | by (cut_facts_tac prems 1);
 | 
|  |    300 | by (etac ex1E 1);
 | 
|  |    301 | by (rtac trans 1);
 | 
|  |    302 | by (rtac sym 2);
 | 
|  |    303 | by (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ;
 | 
|  |    304 | qed "ex1_equalsE";
 | 
| 7355 |    305 | 
 | 
|  |    306 | (** Polymorphic congruence rules **)
 | 
|  |    307 | 
 | 
| 9264 |    308 | Goal "[| a=b |]  ==>  t(a)=t(b)";
 | 
|  |    309 | by (etac ssubst 1);
 | 
|  |    310 | by (rtac refl 1) ;
 | 
|  |    311 | qed "subst_context";
 | 
| 7355 |    312 | 
 | 
| 9264 |    313 | Goal "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)";
 | 
|  |    314 | by (REPEAT (etac ssubst 1));
 | 
|  |    315 | by (rtac refl 1) ;
 | 
|  |    316 | qed "subst_context2";
 | 
| 7355 |    317 | 
 | 
| 9264 |    318 | Goal "[| a=b;  c=d;  e=f |]  ==>  t(a,c,e)=t(b,d,f)";
 | 
|  |    319 | by (REPEAT (etac ssubst 1));
 | 
|  |    320 | by (rtac refl 1) ;
 | 
|  |    321 | qed "subst_context3";
 | 
| 7355 |    322 | 
 | 
|  |    323 | (*Useful with eresolve_tac for proving equalties from known equalities.
 | 
|  |    324 |         a = b
 | 
|  |    325 |         |   |
 | 
|  |    326 |         c = d   *)
 | 
| 9264 |    327 | Goal "[| a=b;  a=c;  b=d |] ==> c=d";
 | 
|  |    328 | by (rtac trans 1);
 | 
|  |    329 | by (rtac trans 1);
 | 
|  |    330 | by (rtac sym 1);
 | 
|  |    331 | by (REPEAT (assume_tac 1));
 | 
|  |    332 | qed "box_equals";
 | 
| 7355 |    333 | 
 | 
|  |    334 | (*Dual of box_equals: for proving equalities backwards*)
 | 
| 9264 |    335 | Goal "[| a=c;  b=d;  c=d |] ==> a=b";
 | 
|  |    336 | by (rtac trans 1);
 | 
|  |    337 | by (rtac trans 1);
 | 
|  |    338 | by (REPEAT (assume_tac 1));
 | 
|  |    339 | by (etac sym 1);
 | 
|  |    340 | qed "simp_equals";
 | 
| 7355 |    341 | 
 | 
|  |    342 | (** Congruence rules for predicate letters **)
 | 
|  |    343 | 
 | 
| 9264 |    344 | Goal "a=a' ==> P(a) <-> P(a')";
 | 
|  |    345 | by (rtac iffI 1);
 | 
|  |    346 | by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
 | 
|  |    347 | qed "pred1_cong";
 | 
| 7355 |    348 | 
 | 
| 9264 |    349 | Goal "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')";
 | 
|  |    350 | by (rtac iffI 1);
 | 
|  |    351 | by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
 | 
|  |    352 | qed "pred2_cong";
 | 
| 7355 |    353 | 
 | 
| 9264 |    354 | Goal "[| a=a';  b=b';  c=c' |] ==> P(a,b,c) <-> P(a',b',c')";
 | 
|  |    355 | by (rtac iffI 1);
 | 
|  |    356 | by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
 | 
|  |    357 | qed "pred3_cong";
 | 
| 7355 |    358 | 
 | 
|  |    359 | (*special cases for free variables P, Q, R, S -- up to 3 arguments*)
 | 
|  |    360 | 
 | 
|  |    361 | val pred_congs = 
 | 
|  |    362 |     flat (map (fn c => 
 | 
|  |    363 |                map (fn th => read_instantiate [("P",c)] th)
 | 
|  |    364 |                    [pred1_cong,pred2_cong,pred3_cong])
 | 
|  |    365 |                (explode"PQRS"));
 | 
|  |    366 | 
 | 
|  |    367 | (*special case for the equality predicate!*)
 | 
| 7422 |    368 | bind_thm ("eq_cong", read_instantiate [("P","op =")] pred2_cong);
 | 
| 7355 |    369 | 
 | 
|  |    370 | 
 | 
|  |    371 | (*** Simplifications of assumed implications.
 | 
|  |    372 |      Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
 | 
|  |    373 |      used with mp_tac (restricted to atomic formulae) is COMPLETE for 
 | 
|  |    374 |      intuitionistic propositional logic.  See
 | 
|  |    375 |    R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
 | 
|  |    376 |     (preprint, University of St Andrews, 1991)  ***)
 | 
|  |    377 | 
 | 
| 9264 |    378 | val major::prems= Goal 
 | 
|  |    379 |     "[| (P&Q)-->S;  P-->(Q-->S) ==> R |] ==> R";
 | 
|  |    380 | by (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ;
 | 
|  |    381 | qed "conj_impE";
 | 
| 7355 |    382 | 
 | 
| 9264 |    383 | val major::prems= Goal 
 | 
|  |    384 |     "[| (P|Q)-->S;  [| P-->S; Q-->S |] ==> R |] ==> R";
 | 
|  |    385 | by (DEPTH_SOLVE (ares_tac ([disjI1, disjI2, impI, major RS mp]@prems) 1)) ;
 | 
|  |    386 | qed "disj_impE";
 | 
| 7355 |    387 | 
 | 
|  |    388 | (*Simplifies the implication.  Classical version is stronger. 
 | 
|  |    389 |   Still UNSAFE since Q must be provable -- backtracking needed.  *)
 | 
| 9264 |    390 | val major::prems= Goal 
 | 
|  |    391 |     "[| (P-->Q)-->S;  [| P; Q-->S |] ==> Q;  S ==> R |] ==> R";
 | 
|  |    392 | by (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ;
 | 
|  |    393 | qed "imp_impE";
 | 
| 7355 |    394 | 
 | 
|  |    395 | (*Simplifies the implication.  Classical version is stronger. 
 | 
|  |    396 |   Still UNSAFE since ~P must be provable -- backtracking needed.  *)
 | 
| 9264 |    397 | val major::prems= Goal
 | 
|  |    398 |     "[| ~P --> S;  P ==> False;  S ==> R |] ==> R";
 | 
|  |    399 | by (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ;
 | 
|  |    400 | qed "not_impE";
 | 
| 7355 |    401 | 
 | 
|  |    402 | (*Simplifies the implication.   UNSAFE.  *)
 | 
| 9264 |    403 | val major::prems= Goal 
 | 
| 7355 |    404 |     "[| (P<->Q)-->S;  [| P; Q-->S |] ==> Q;  [| Q; P-->S |] ==> P;  \
 | 
| 9264 |    405 | \       S ==> R |] ==> R";
 | 
|  |    406 | by (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ;
 | 
|  |    407 | qed "iff_impE";
 | 
| 7355 |    408 | 
 | 
|  |    409 | (*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
 | 
| 9264 |    410 | val major::prems= Goal 
 | 
|  |    411 |     "[| (ALL x. P(x))-->S;  !!x. P(x);  S ==> R |] ==> R";
 | 
|  |    412 | by (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ;
 | 
|  |    413 | qed "all_impE";
 | 
| 7355 |    414 | 
 | 
|  |    415 | (*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
 | 
| 9264 |    416 | val major::prems= Goal 
 | 
|  |    417 |     "[| (EX x. P(x))-->S;  P(x)-->S ==> R |] ==> R";
 | 
|  |    418 | by (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ;
 | 
|  |    419 | qed "ex_impE";
 | 
| 7355 |    420 | 
 | 
|  |    421 | (*** Courtesy of Krzysztof Grabczewski ***)
 | 
|  |    422 | 
 | 
| 9264 |    423 | val major::prems = Goal "[| P|Q;  P==>R;  Q==>S |] ==> R|S";
 | 
| 7355 |    424 | by (rtac (major RS disjE) 1);
 | 
|  |    425 | by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1));
 | 
|  |    426 | qed "disj_imp_disj";
 |