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