src/FOLP/IFOLP.ML
author wenzelm
Fri, 10 Oct 1997 16:29:41 +0200
changeset 3836 f1a1817659e6
parent 1459 d12da312eff4
child 9263 53e09e592278
permissions -rw-r--r--
fixed dots;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
     1
(*  Title:      FOLP/IFOLP.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
     3
    Author:     Martin D Coen, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
1142
eb0e2ff8f032 Corrected comments in headers
lcp
parents: 0
diff changeset
     6
Tactics and lemmas for IFOLP (Intuitionistic First-Order Logic with Proofs)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open IFOLP;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
signature IFOLP_LEMMAS = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
  sig
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
  val allE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
  val all_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
  val all_dupE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
  val all_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
  val box_equals: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
  val conjE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  val conj_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  val conj_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  val contrapos: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  val disj_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  val disj_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  val eq_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  val ex1I: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  val ex1E: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  val ex1_equalsE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
(*  val ex1_cong: thm****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
  val ex_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
  val ex_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
  val iffD1: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  val iffD2: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  val iffE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  val iffI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  val iff_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  val iff_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
  val iff_refl: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
  val iff_sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  val iff_trans: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  val impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
  val imp_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
  val imp_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  val mp_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
  val notE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
  val notI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  val not_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
  val not_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
  val not_sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
  val not_to_imp: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  val pred1_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
  val pred2_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  val pred3_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  val pred_congs: thm list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  val refl: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  val rev_mp: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  val simp_equals: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
  val subst: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  val ssubst: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  val subst_context: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
  val subst_context2: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  val subst_context3: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
  val sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
  val trans: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
  val TrueI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
  val uniq_assume_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
  val uniq_mp_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
structure IFOLP_Lemmas : IFOLP_LEMMAS =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
struct
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
val TrueI = TrueI;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
(*** Sequent-style elimination rules for & --> and ALL ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
val conjE = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
    "[| p:P&Q; !!x y.[| x:P; y:Q |] ==> f(x,y):R |] ==> ?a:R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
  [ (REPEAT (resolve_tac prems 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
      ORELSE (resolve_tac [conjunct1, conjunct2] 1 THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
              resolve_tac prems 1))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
val impE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
    85
    "[| p:P-->Q;  q:P;  !!x. x:Q ==> r(x):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
val allE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
    89
    "[| p:ALL x. P(x); !!y. y:P(x) ==> q(y):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
(*Duplicates the quantifier; for use with eresolve_tac*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
val all_dupE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
    94
    "[| p:ALL x. P(x);  !!y z.[| y:P(x); z:ALL x. P(x) |] ==> q(y,z):R \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
\    |] ==> ?p:R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
(*** Negation rules, which translate between ~P and P-->False ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   101
val notI = prove_goalw IFOLP.thy [not_def]  "(!!x. x:P ==> q(x):False) ==> ?p:~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
val notE = prove_goalw IFOLP.thy [not_def] "[| p:~P;  q:P |] ==> ?p:R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
  [ (resolve_tac [mp RS FalseE] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
(*This is useful with the special implication rules for each kind of P. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
val not_to_imp = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   111
    "[| p:~P;  !!x. x:(P-->False) ==> q(x):Q |] ==> ?p:Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI,notE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
(* For substitution int an assumption P, reduce Q to P-->Q, substitute into
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
   this implication, then apply impI to move P back into the assumptions.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
   To specify P use something like
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
      eres_inst_tac [ ("P","ALL y. ?S(x,y)") ] rev_mp 1   *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
val rev_mp = prove_goal IFOLP.thy "[| p:P;  q:P --> Q |] ==> ?p:Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
(*Contrapositive of an inference rule*)
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   124
val contrapos = prove_goal IFOLP.thy "[| p:~Q;  !!y. y:P==>q(y):Q |] ==> ?a:~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
 (fn [major,minor]=> 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
  [ (rtac (major RS notE RS notI) 1), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
    (etac minor 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
(** Unique assumption tactic.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
    Ignores proof objects.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
    Fails unless one assumption is equal and exactly one is unifiable 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
**)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
local
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
    fun discard_proof (Const("Proof",_) $ P $ _) = P;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
in
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
val uniq_assume_tac =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
  SUBGOAL
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
    (fn (prem,i) =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
      let val hyps = map discard_proof (Logic.strip_assums_hyp prem)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
          and concl = discard_proof (Logic.strip_assums_concl prem)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
      in  
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   143
          if exists (fn hyp => hyp aconv concl) hyps
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   144
          then case distinct (filter (fn hyp=> could_unify(hyp,concl)) hyps) of
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   145
                   [_] => assume_tac i
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
                 |  _  => no_tac
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
          else no_tac
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
      end);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
(*** Modus Ponens Tactics ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
fun mp_tac i = eresolve_tac [notE,make_elim mp] i  THEN  assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
(*Like mp_tac but instantiates no variables*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
fun uniq_mp_tac i = eresolve_tac [notE,impE] i  THEN  uniq_assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
(*** If-and-only-if ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
val iffI = prove_goalw IFOLP.thy [iff_def]
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   164
   "[| !!x. x:P ==> q(x):Q;  !!x. x:Q ==> r(x):P |] ==> ?p:P<->Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
 (fn prems=> [ (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
val iffE = prove_goalw IFOLP.thy [iff_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
    "[| p:P <-> Q;  !!x y.[| x:P-->Q; y:Q-->P |] ==> q(x,y):R |] ==> ?p:R"
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   171
 (fn prems => [ (rtac conjE 1), (REPEAT (ares_tac prems 1)) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
(* Destruct rules for <-> similar to Modus Ponens *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
val iffD1 = prove_goalw IFOLP.thy [iff_def] "[| p:P <-> Q;  q:P |] ==> ?p:Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
val iffD2 = prove_goalw IFOLP.thy [iff_def] "[| p:P <-> Q;  q:Q |] ==> ?p:P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
 (fn prems => [ (rtac (conjunct2 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
val iff_refl = prove_goal IFOLP.thy "?p:P <-> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
 (fn _ => [ (REPEAT (ares_tac [iffI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
val iff_sym = prove_goal IFOLP.thy "p:Q <-> P ==> ?p:P <-> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
 (fn [major] =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
  [ (rtac (major RS iffE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
    (REPEAT (eresolve_tac [asm_rl,mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
val iff_trans = prove_goal IFOLP.thy "[| p:P <-> Q; q:Q<-> R |] ==> ?p:P <-> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
    (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
(*** Unique existence.  NOTE THAT the following 2 quantifications
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
   EX!x such that [EX!y such that P(x,y)]     (sequential)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
   EX!x,y such that P(x,y)                    (simultaneous)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
val ex1I = prove_goalw IFOLP.thy [ex1_def]
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   204
    "[| p:P(a);  !!x u. u:P(x) ==> f(u) : x=a |] ==> ?p:EX! x. P(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
 (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
val ex1E = prove_goalw IFOLP.thy [ex1_def]
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   208
    "[| p:EX! x. P(x);  \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
\       !!x u v. [| u:P(x);  v:ALL y. P(y) --> y=x |] ==> f(x,u,v):R |] ==>\
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
\    ?a : R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
    (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
(*** <-> congruence rules for simplification ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
fun iff_tac prems i =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
    resolve_tac (prems RL [iffE]) i THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
    REPEAT1 (eresolve_tac [asm_rl,mp] i);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
val conj_cong = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   224
    "[| p:P <-> P';  !!x. x:P' ==> q(x):Q <-> Q' |] ==> ?p:(P&Q) <-> (P'&Q')"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
    (REPEAT  (ares_tac [iffI,conjI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
      ORELSE  eresolve_tac [iffE,conjE,mp] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
      ORELSE  iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
val disj_cong = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
    "[| p:P <-> P';  q:Q <-> Q' |] ==> ?p:(P|Q) <-> (P'|Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
    (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
val imp_cong = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   240
    "[| p:P <-> P';  !!x. x:P' ==> q(x):Q <-> Q' |] ==> ?p:(P-->Q) <-> (P'-->Q')"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
    (REPEAT   (ares_tac [iffI,impI] 1
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   244
      ORELSE  etac iffE 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
      ORELSE  mp_tac 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
val iff_cong = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
    "[| p:P <-> P';  q:Q <-> Q' |] ==> ?p:(P<->Q) <-> (P'<->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
  [ (cut_facts_tac prems 1),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   251
    (REPEAT   (etac iffE 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
val not_cong = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
    "p:P <-> P' ==> ?p:~P <-> ~P'"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
    (REPEAT   (ares_tac [iffI,notI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
      ORELSE  mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
      ORELSE  eresolve_tac [iffE,notE] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
val all_cong = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   264
    "(!!x. f(x):P(x) <-> Q(x)) ==> ?p:(ALL x. P(x)) <-> (ALL x. Q(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
  [ (REPEAT   (ares_tac [iffI,allI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
      ORELSE   mp_tac 1
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   268
      ORELSE   etac allE 1 ORELSE iff_tac prems 1)) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
val ex_cong = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   271
    "(!!x. f(x):P(x) <-> Q(x)) ==> ?p:(EX x. P(x)) <-> (EX x. Q(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
 (fn prems =>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   273
  [ (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
(*NOT PROVED
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
val ex1_cong = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
    "(!!x.f(x):P(x) <-> Q(x)) ==> ?p:(EX! x.P(x)) <-> (EX! x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
  [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   285
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
(*** Equality rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
val refl = ieqI;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
val subst = prove_goal IFOLP.thy "[| p:a=b;  q:P(a) |] ==> ?p : P(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
 (fn [prem1,prem2] => [ rtac (prem2 RS rev_mp) 1, (rtac (prem1 RS ieqE) 1), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
                        rtac impI 1, atac 1 ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
val sym = prove_goal IFOLP.thy "q:a=b ==> ?c:b=a"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
 (fn [major] => [ (rtac (major RS subst) 1), (rtac refl 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
val trans = prove_goal IFOLP.thy "[| p:a=b;  q:b=c |] ==> ?d:a=c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
 (fn [prem1,prem2] => [ (rtac (prem2 RS subst) 1), (rtac prem1 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
(** ~ b=a ==> ~ a=b **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
val not_sym = prove_goal IFOLP.thy "p:~ b=a ==> ?q:~ a=b"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
 (fn [prem] => [ (rtac (prem RS contrapos) 1), (etac sym 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
(*calling "standard" reduces maxidx to 0*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
val ssubst = standard (sym RS subst);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
(*A special case of ex1E that would otherwise need quantifier expansion*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
val ex1_equalsE = prove_goal IFOLP.thy
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   309
    "[| p:EX! x. P(x);  q:P(a);  r:P(b) |] ==> ?d:a=b"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   312
    (etac ex1E 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
    (rtac trans 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
    (rtac sym 2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
    (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
(** Polymorphic congruence rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
val subst_context = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
   "[| p:a=b |]  ==>  ?d:t(a)=t(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
  [ (resolve_tac (prems RL [ssubst]) 1),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   323
    (rtac refl 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
val subst_context2 = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
   "[| p:a=b;  q:c=d |]  ==>  ?p:t(a,c)=t(b,d)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   330
val subst_context3 = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   331
   "[| p:a=b;  q:c=d;  r:e=f |]  ==>  ?p:t(a,c,e)=t(b,d,f)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   332
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   335
(*Useful with eresolve_tac for proving equalties from known equalities.
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   336
        a = b
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   337
        |   |
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   338
        c = d   *)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
val box_equals = prove_goal IFOLP.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
    "[| p:a=b;  q:a=c;  r:b=d |] ==> ?p:c=d"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
 (fn prems=>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   342
  [ (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   343
    (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   344
    (rtac sym 1),
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
(*Dual of box_equals: for proving equalities backwards*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
val simp_equals = prove_goal IFOLP.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
    "[| p:a=c;  q:b=d;  r:c=d |] ==> ?p:a=b"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   350
 (fn prems=>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   351
  [ (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   352
    (rtac trans 1),
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
    (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
(** Congruence rules for predicate letters **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   356
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   357
val pred1_cong = prove_goal IFOLP.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   358
    "p:a=a' ==> ?p:P(a) <-> P(a')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   362
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   363
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   364
val pred2_cong = prove_goal IFOLP.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
    "[| p:a=a';  q:b=b' |] ==> ?p:P(a,b) <-> P(a',b')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   366
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   367
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   369
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   370
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   371
val pred3_cong = prove_goal IFOLP.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   372
    "[| p:a=a';  q:b=b';  r:c=c' |] ==> ?p:P(a,b,c) <-> P(a',b',c')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   373
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   374
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   376
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   377
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   378
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   379
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   380
val pred_congs = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   381
    flat (map (fn c => 
1459
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   382
               map (fn th => read_instantiate [("P",c)] th)
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   383
                   [pred1_cong,pred2_cong,pred3_cong])
d12da312eff4 expanded tabs
clasohm
parents: 1142
diff changeset
   384
               (explode"PQRS"));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   385
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   386
(*special case for the equality predicate!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   387
val eq_cong = read_instantiate [("P","op =")] pred2_cong;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   388
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   389
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   390
(*** Simplifications of assumed implications.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   391
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   392
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   393
     intuitionistic propositional logic.  See
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   394
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   395
    (preprint, University of St Andrews, 1991)  ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   396
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   397
val conj_impE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   398
    "[| p:(P&Q)-->S;  !!x. x:P-->(Q-->S) ==> q(x):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   399
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   400
  [ (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   401
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   402
val disj_impE = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   403
    "[| p:(P|Q)-->S;  !!x y.[| x:P-->S; y:Q-->S |] ==> q(x,y):R |] ==> ?p:R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   404
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   405
  [ (DEPTH_SOLVE (ares_tac ([disjI1, disjI2, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   406
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   407
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   408
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   409
val imp_impE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   410
    "[| p:(P-->Q)-->S;  !!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q;  !!x. x:S ==> r(x):R |] ==> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   411
\    ?p:R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   412
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   413
  [ (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   414
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   415
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   416
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   417
val not_impE = prove_goal IFOLP.thy
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   418
    "[| p:~P --> S;  !!y. y:P ==> q(y):False;  !!y. y:S ==> r(y):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   419
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   420
  [ (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   421
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   422
(*Simplifies the implication.   UNSAFE.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   423
val iff_impE = prove_goal IFOLP.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   424
    "[| p:(P<->Q)-->S;  !!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q;  \
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   425
\       !!x y.[| x:Q; y:P-->S |] ==> r(x,y):P;  !!x. x:S ==> s(x):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   426
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   427
  [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   428
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   429
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   430
val all_impE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   431
    "[| p:(ALL x. P(x))-->S;  !!x. q:P(x);  !!y. y:S ==> r(y):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   432
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   433
  [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   434
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   435
(*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   436
val ex_impE = prove_goal IFOLP.thy 
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1459
diff changeset
   437
    "[| p:(EX x. P(x))-->S;  !!y. y:P(a)-->S ==> q(y):R |] ==> ?p:R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   438
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   439
  [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   440
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   441
end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   442
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   443
open IFOLP_Lemmas;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   444