src/FOL/fol.ML
author wenzelm
Thu Aug 27 20:46:36 1998 +0200 (1998-08-27)
changeset 5400 645f46a24c72
parent 0 a5a9c433f639
permissions -rw-r--r--
made tutorial first;
clasohm@0
     1
(*  Title: 	FOL/fol.ML
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1991  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Tactics and lemmas for fol.thy (classical First-Order Logic)
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
open FOL;
clasohm@0
    10
clasohm@0
    11
signature FOL_LEMMAS = 
clasohm@0
    12
  sig
clasohm@0
    13
  val disjCI : thm
clasohm@0
    14
  val excluded_middle : thm
clasohm@0
    15
  val exCI : thm
clasohm@0
    16
  val ex_classical : thm
clasohm@0
    17
  val iffCE : thm
clasohm@0
    18
  val impCE : thm
clasohm@0
    19
  val notnotD : thm
clasohm@0
    20
  val swap : thm
clasohm@0
    21
  end;
clasohm@0
    22
clasohm@0
    23
clasohm@0
    24
structure FOL_Lemmas : FOL_LEMMAS = 
clasohm@0
    25
struct
clasohm@0
    26
clasohm@0
    27
(*** Classical introduction rules for | and EX ***)
clasohm@0
    28
clasohm@0
    29
val disjCI = prove_goal FOL.thy 
clasohm@0
    30
   "(~Q ==> P) ==> P|Q"
clasohm@0
    31
 (fn prems=>
clasohm@0
    32
  [ (resolve_tac [classical] 1),
clasohm@0
    33
    (REPEAT (ares_tac (prems@[disjI1,notI]) 1)),
clasohm@0
    34
    (REPEAT (ares_tac (prems@[disjI2,notE]) 1)) ]);
clasohm@0
    35
clasohm@0
    36
(*introduction rule involving only EX*)
clasohm@0
    37
val ex_classical = prove_goal FOL.thy 
clasohm@0
    38
   "( ~(EX x. P(x)) ==> P(a)) ==> EX x.P(x)"
clasohm@0
    39
 (fn prems=>
clasohm@0
    40
  [ (resolve_tac [classical] 1),
clasohm@0
    41
    (eresolve_tac (prems RL [exI]) 1) ]);
clasohm@0
    42
clasohm@0
    43
(*version of above, simplifying ~EX to ALL~ *)
clasohm@0
    44
val exCI = prove_goal FOL.thy 
clasohm@0
    45
   "(ALL x. ~P(x) ==> P(a)) ==> EX x.P(x)"
clasohm@0
    46
 (fn [prem]=>
clasohm@0
    47
  [ (resolve_tac [ex_classical] 1),
clasohm@0
    48
    (resolve_tac [notI RS allI RS prem] 1),
clasohm@0
    49
    (eresolve_tac [notE] 1),
clasohm@0
    50
    (eresolve_tac [exI] 1) ]);
clasohm@0
    51
clasohm@0
    52
val excluded_middle = prove_goal FOL.thy "~P | P"
clasohm@0
    53
 (fn _=> [ rtac disjCI 1, assume_tac 1 ]);
clasohm@0
    54
clasohm@0
    55
clasohm@0
    56
(*** Special elimination rules *)
clasohm@0
    57
clasohm@0
    58
clasohm@0
    59
(*Classical implies (-->) elimination. *)
clasohm@0
    60
val impCE = prove_goal FOL.thy 
clasohm@0
    61
    "[| P-->Q;  ~P ==> R;  Q ==> R |] ==> R"
clasohm@0
    62
 (fn major::prems=>
clasohm@0
    63
  [ (resolve_tac [excluded_middle RS disjE] 1),
clasohm@0
    64
    (DEPTH_SOLVE (ares_tac (prems@[major RS mp]) 1)) ]);
clasohm@0
    65
clasohm@0
    66
(*Double negation law*)
clasohm@0
    67
val notnotD = prove_goal FOL.thy "~~P ==> P"
clasohm@0
    68
 (fn [major]=>
clasohm@0
    69
  [ (resolve_tac [classical] 1), (eresolve_tac [major RS notE] 1) ]);
clasohm@0
    70
clasohm@0
    71
clasohm@0
    72
(*** Tactics for implication and contradiction ***)
clasohm@0
    73
clasohm@0
    74
(*Classical <-> elimination.  Proof substitutes P=Q in 
clasohm@0
    75
    ~P ==> ~Q    and    P ==> Q  *)
clasohm@0
    76
val iffCE = prove_goalw FOL.thy [iff_def]
clasohm@0
    77
    "[| P<->Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R"
clasohm@0
    78
 (fn prems =>
clasohm@0
    79
  [ (resolve_tac [conjE] 1),
clasohm@0
    80
    (REPEAT (DEPTH_SOLVE_1 
clasohm@0
    81
	(etac impCE 1  ORELSE  mp_tac 1  ORELSE  ares_tac prems 1))) ]);
clasohm@0
    82
clasohm@0
    83
clasohm@0
    84
(*Should be used as swap since ~P becomes redundant*)
clasohm@0
    85
val swap = prove_goal FOL.thy 
clasohm@0
    86
   "~P ==> (~Q ==> P) ==> Q"
clasohm@0
    87
 (fn major::prems=>
clasohm@0
    88
  [ (resolve_tac [classical] 1),
clasohm@0
    89
    (rtac (major RS notE) 1),
clasohm@0
    90
    (REPEAT (ares_tac prems 1)) ]);
clasohm@0
    91
clasohm@0
    92
end;
clasohm@0
    93
clasohm@0
    94
open FOL_Lemmas;