src/FOL/IFOL_lemmas.ML
author kleing
Wed, 07 Jan 2004 07:52:12 +0100
changeset 14343 6bc647f472b9
parent 14085 8dc3e532959a
child 15531 08c8dad8e399
permissions -rw-r--r--
map_idI
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
14085
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    33
structure IFOL =
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    34
struct
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    35
  val thy = the_context ();
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    36
  val refl = refl;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    37
  val subst = subst;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    38
  val conjI = conjI;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    39
  val conjunct1 = conjunct1;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    40
  val conjunct2 = conjunct2;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    41
  val disjI1 = disjI1;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    42
  val disjI2 = disjI2;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    43
  val disjE = disjE;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    44
  val impI = impI;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    45
  val mp = mp;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    46
  val FalseE = FalseE;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    47
  val True_def = True_def;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    48
  val not_def = not_def;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    49
  val iff_def = iff_def;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    50
  val ex1_def = ex1_def;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    51
  val allI = allI;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    52
  val spec = spec;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    53
  val exI = exI;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    54
  val exE = exE;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    55
  val eq_reflection = eq_reflection;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    56
  val iff_reflection = iff_reflection;
8dc3e532959a moved some lemmas here from ZF
paulson
parents: 9887
diff changeset
    57
end;
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    58
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    59
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    60
Goalw [True_def]  "True";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    61
by (REPEAT (ares_tac [impI] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    62
qed "TrueI";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    63
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    64
(*** Sequent-style elimination rules for & --> and ALL ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    65
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    66
val major::prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    67
    "[| P&Q; [| P; Q |] ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    68
by (resolve_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    69
by (rtac (major RS conjunct1) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    70
by (rtac (major RS conjunct2) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    71
qed "conjE";
7355
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 major::prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    74
    "[| P-->Q;  P;  Q ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    75
by (resolve_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    76
by (rtac (major RS mp) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    77
by (resolve_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    78
qed "impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    79
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    80
val major::prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    81
    "[| ALL x. P(x); P(x) ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    82
by (resolve_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    83
by (rtac (major RS spec) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    84
qed "allE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    85
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    86
(*Duplicates the quantifier; for use with eresolve_tac*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    87
val major::prems = Goal 
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    88
    "[| ALL x. P(x);  [| P(x); ALL x. P(x) |] ==> R \
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    89
\    |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    90
by (resolve_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    91
by (rtac (major RS spec) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    92
by (rtac major 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    93
qed "all_dupE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    94
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    95
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    96
(*** Negation rules, which translate between ~P and P-->False ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
    97
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    98
val prems = Goalw [not_def]  "(P ==> False) ==> ~P";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
    99
by (REPEAT (ares_tac (prems@[impI]) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   100
qed "notI";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   101
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   102
Goalw [not_def]  "[| ~P;  P |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   103
by (etac (mp RS FalseE) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   104
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   105
qed "notE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   106
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   107
Goal "[| P; ~P |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   108
by (etac notE 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   109
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   110
qed "rev_notE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   111
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   112
(*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
   113
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   114
    "[| ~P;  (P-->False) ==> Q |] ==> Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   115
by (REPEAT (ares_tac (prems@[impI,notE]) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   116
qed "not_to_imp";
7355
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
(* 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
   119
   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
   120
   To specify P use something like
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   121
      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
   122
Goal "[| P;  P --> Q |] ==> Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   123
by (etac mp 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   124
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   125
qed "rev_mp";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   126
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   127
(*Contrapositive of an inference rule*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   128
val [major,minor]= Goal "[| ~Q;  P==>Q |] ==> ~P";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   129
by (rtac (major RS notE RS notI) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   130
by (etac minor 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   131
qed "contrapos";
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
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   134
(*** Modus Ponens Tactics ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   135
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   136
(*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
   137
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
   138
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   139
(*Like mp_tac but instantiates no variables*)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   140
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
   141
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   142
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   143
(*** If-and-only-if ***)
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
val prems = Goalw [iff_def] 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   146
   "[| P ==> Q;  Q ==> P |] ==> P<->Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   147
by (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   148
qed "iffI";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   149
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   150
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   151
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   152
val prems = Goalw [iff_def] 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   153
    "[| P <-> Q;  [| P-->Q; Q-->P |] ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   154
by (rtac conjE 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   155
by (REPEAT (ares_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   156
qed "iffE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   157
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   158
(* Destruct rules for <-> similar to Modus Ponens *)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   159
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   160
Goalw [iff_def]  "[| P <-> Q;  P |] ==> Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   161
by (etac (conjunct1 RS mp) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   162
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   163
qed "iffD1";
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
val prems = Goalw [iff_def]  "[| P <-> Q;  Q |] ==> P";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   166
by (etac (conjunct2 RS mp) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   167
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   168
qed "iffD2";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   169
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   170
Goal "[| P; P <-> Q |] ==> Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   171
by (etac iffD1 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   172
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   173
qed "rev_iffD1";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   174
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   175
Goal "[| Q; P <-> Q |] ==> P";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   176
by (etac iffD2 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   177
by (assume_tac 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   178
qed "rev_iffD2";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   179
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   180
Goal "P <-> P";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   181
by (REPEAT (ares_tac [iffI] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   182
qed "iff_refl";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   183
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   184
Goal "Q <-> P ==> P <-> Q";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   185
by (etac iffE 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   186
by (rtac iffI 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   187
by (REPEAT (eresolve_tac [asm_rl,mp] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   188
qed "iff_sym";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   189
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   190
Goal "[| P <-> Q;  Q<-> R |] ==> P <-> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   191
by (rtac iffI 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   192
by (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   193
qed "iff_trans";
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
(*** Unique existence.  NOTE THAT the following 2 quantifications
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   197
   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
   198
   EX!x,y such that P(x,y)                    (simultaneous)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   199
 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
   200
***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   201
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   202
val prems = Goalw [ex1_def] 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   203
    "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   204
by (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   205
qed "ex1I";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   206
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   207
(*Sometimes easier to use: the premises have no shared variables.  Safe!*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   208
val [ex,eq] = Goal
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   209
    "[| 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
   210
by (rtac (ex RS exE) 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   211
by (REPEAT (ares_tac [ex1I,eq] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   212
qed "ex_ex1I";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   213
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   214
val prems = Goalw [ex1_def] 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   215
    "[| 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
   216
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   217
by (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   218
qed "ex1E";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   219
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   220
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   221
(*** <-> congruence rules for simplification ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   222
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   223
(*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
   224
fun iff_tac prems i =
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   225
    resolve_tac (prems RL [iffE]) i THEN
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   226
    REPEAT1 (eresolve_tac [asm_rl,mp] i);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   227
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   228
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   229
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P&Q) <-> (P'&Q')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   230
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   231
by (REPEAT  (ares_tac [iffI,conjI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   232
     ORELSE  eresolve_tac [iffE,conjE,mp] 1 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   233
     ORELSE  iff_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   234
qed "conj_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   235
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   236
(*Reversed congruence rule!   Used in ZF/Order*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   237
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   238
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (Q&P) <-> (Q'&P')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   239
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   240
by (REPEAT  (ares_tac [iffI,conjI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   241
     ORELSE  eresolve_tac [iffE,conjE,mp] 1 ORELSE  iff_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   242
qed "conj_cong2";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   243
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   244
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   245
    "[| P <-> P';  Q <-> Q' |] ==> (P|Q) <-> (P'|Q')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   246
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   247
by (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   248
             ORELSE  ares_tac [iffI] 1 ORELSE  mp_tac 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   249
qed "disj_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   250
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   251
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   252
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   253
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   254
by (REPEAT   (ares_tac [iffI,impI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   255
      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
   256
qed "imp_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
    "[| P <-> P';  Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   260
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   261
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
   262
qed "iff_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   263
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   264
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   265
    "P <-> P' ==> ~P <-> ~P'";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   266
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   267
by (REPEAT   (ares_tac [iffI,notI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   268
      ORELSE  mp_tac 1 ORELSE  eresolve_tac [iffE,notE] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   269
qed "not_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   270
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   271
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   272
    "(!!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
   273
by (REPEAT   (ares_tac [iffI,allI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   274
     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
   275
qed "all_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   276
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   277
val prems = Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   278
    "(!!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
   279
by (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   280
     ORELSE   mp_tac 1 ORELSE   iff_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   281
qed "ex_cong";
7355
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 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   284
    "(!!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
   285
by (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   286
       ORELSE ares_tac [iffI,ex1I] 1 ORELSE   mp_tac 1
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   287
       ORELSE   iff_tac prems 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   288
qed "ex1_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   289
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   290
(*** Equality rules ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   291
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   292
Goal "a=b ==> b=a";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   293
by (etac subst 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   294
by (rtac refl 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   295
qed "sym";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   296
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   297
Goal "[| a=b;  b=c |] ==> a=c";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   298
by (etac subst 1 THEN assume_tac 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   299
qed "trans";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   300
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   301
(** ~ b=a ==> ~ a=b **)
7422
c63d619286a3 bind_thm;
wenzelm
parents: 7355
diff changeset
   302
bind_thm ("not_sym", hd (compose(sym,2,contrapos)));
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   303
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   304
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   305
(* Two theorms for rewriting only one instance of a definition:
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   306
   the first for definitions of formulae and the second for terms *)
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
val prems = goal (the_context()) "(A == B) ==> A <-> B";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   309
by (rewrite_goals_tac prems);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   310
by (rtac iff_refl 1);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   311
qed "def_imp_iff";
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
val prems = goal (the_context()) "(A == B) ==> A = B";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   314
by (rewrite_goals_tac prems);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   315
by (rtac refl 1);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   316
qed "meta_eq_to_obj_eq";
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   317
9527
de95b5125580 removed stac (now exported by HypsubstFun);
wenzelm
parents: 9264
diff changeset
   318
(*substitution*)
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   319
bind_thm ("ssubst", sym RS subst);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   320
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   321
(*A special case of ex1E that would otherwise need quantifier expansion*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   322
val prems = Goal
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   323
    "[| EX! x. P(x);  P(a);  P(b) |] ==> a=b";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   324
by (cut_facts_tac prems 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   325
by (etac ex1E 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   326
by (rtac trans 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   327
by (rtac sym 2);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   328
by (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   329
qed "ex1_equalsE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   330
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   331
(** Polymorphic congruence rules **)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   332
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   333
Goal "[| a=b |]  ==>  t(a)=t(b)";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   334
by (etac ssubst 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   335
by (rtac refl 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   336
qed "subst_context";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   337
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   338
Goal "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   339
by (REPEAT (etac ssubst 1));
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   340
by (rtac refl 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   341
qed "subst_context2";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   342
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   343
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
   344
by (REPEAT (etac ssubst 1));
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   345
by (rtac refl 1) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   346
qed "subst_context3";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   347
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   348
(*Useful with eresolve_tac for proving equalties from known equalities.
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   349
        a = b
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   350
        |   |
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   351
        c = d   *)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   352
Goal "[| a=b;  a=c;  b=d |] ==> c=d";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   353
by (rtac trans 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   354
by (rtac trans 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   355
by (rtac sym 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   356
by (REPEAT (assume_tac 1));
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   357
qed "box_equals";
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
(*Dual of box_equals: for proving equalities backwards*)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   360
Goal "[| a=c;  b=d;  c=d |] ==> a=b";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   361
by (rtac trans 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   362
by (rtac trans 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   363
by (REPEAT (assume_tac 1));
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   364
by (etac sym 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   365
qed "simp_equals";
7355
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
(** Congruence rules for predicate letters **)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   368
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   369
Goal "a=a' ==> P(a) <-> P(a')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   370
by (rtac iffI 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   371
by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   372
qed "pred1_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   373
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   374
Goal "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   375
by (rtac iffI 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   376
by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   377
qed "pred2_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   378
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   379
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
   380
by (rtac iffI 1);
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   381
by (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   382
qed "pred3_cong";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   383
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   384
(*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
   385
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   386
val pred_congs = 
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   387
    flat (map (fn c => 
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   388
               map (fn th => read_instantiate [("P",c)] th)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   389
                   [pred1_cong,pred2_cong,pred3_cong])
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   390
               (explode"PQRS"));
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   391
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   392
(*special case for the equality predicate!*)
7422
c63d619286a3 bind_thm;
wenzelm
parents: 7355
diff changeset
   393
bind_thm ("eq_cong", read_instantiate [("P","op =")] pred2_cong);
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
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   396
(*** Simplifications of assumed implications.
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   397
     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
   398
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   399
     intuitionistic propositional logic.  See
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   400
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   401
    (preprint, University of St Andrews, 1991)  ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   402
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   403
val major::prems= Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   404
    "[| (P&Q)-->S;  P-->(Q-->S) ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   405
by (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   406
qed "conj_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   407
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   408
val major::prems= Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   409
    "[| (P|Q)-->S;  [| P-->S; Q-->S |] ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   410
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
   411
qed "disj_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   412
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   413
(*Simplifies the implication.  Classical version is stronger. 
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   414
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   415
val major::prems= Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   416
    "[| (P-->Q)-->S;  [| P; Q-->S |] ==> Q;  S ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   417
by (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   418
qed "imp_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   419
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   420
(*Simplifies the implication.  Classical version is stronger. 
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   421
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   422
val major::prems= Goal
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   423
    "[| ~P --> S;  P ==> False;  S ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   424
by (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   425
qed "not_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   426
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   427
(*Simplifies the implication.   UNSAFE.  *)
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   428
val major::prems= Goal 
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   429
    "[| (P<->Q)-->S;  [| P; Q-->S |] ==> Q;  [| Q; P-->S |] ==> P;  \
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   430
\       S ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   431
by (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   432
qed "iff_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   433
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   434
(*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
   435
val major::prems= Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   436
    "[| (ALL x. P(x))-->S;  !!x. P(x);  S ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   437
by (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   438
qed "all_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   439
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   440
(*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
   441
val major::prems= Goal 
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   442
    "[| (EX x. P(x))-->S;  P(x)-->S ==> R |] ==> R";
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   443
by (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ;
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   444
qed "ex_impE";
7355
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   445
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   446
(*** Courtesy of Krzysztof Grabczewski ***)
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   447
9264
051592f4236a removal of batch style, and tidying
paulson
parents: 7422
diff changeset
   448
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
   449
by (rtac (major RS disjE) 1);
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   450
by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1));
4c43090659ca proper bootstrap of IFOL/FOL theories and packages;
wenzelm
parents:
diff changeset
   451
qed "disj_imp_disj";