src/FOLP/FOLP.thy
author wenzelm
Sat May 14 11:42:43 2011 +0200 (2011-05-14)
changeset 42799 4e33894aec6d
parent 41779 a68f503805ed
child 48891 c0eafbd55de3
permissions -rw-r--r--
modernized functor names;
tuned;
clasohm@1477
     1
(*  Title:      FOLP/FOLP.thy
clasohm@1477
     2
    Author:     Martin D Coen, Cambridge University Computer Laboratory
lcp@1142
     3
    Copyright   1992  University of Cambridge
lcp@1142
     4
*)
lcp@1142
     5
wenzelm@17480
     6
header {* Classical First-Order Logic with Proofs *}
wenzelm@17480
     7
wenzelm@17480
     8
theory FOLP
wenzelm@17480
     9
imports IFOLP
wenzelm@17480
    10
uses
wenzelm@26322
    11
  ("classical.ML") ("simp.ML") ("simpdata.ML")
wenzelm@17480
    12
begin
wenzelm@17480
    13
wenzelm@41779
    14
axiomatization cla :: "[p=>p]=>p"
wenzelm@41779
    15
  where classical: "(!!x. x:~P ==> f(x):P) ==> cla(f):P"
wenzelm@17480
    16
wenzelm@26322
    17
wenzelm@26322
    18
(*** Classical introduction rules for | and EX ***)
wenzelm@26322
    19
wenzelm@36319
    20
schematic_lemma disjCI:
wenzelm@26322
    21
  assumes "!!x. x:~Q ==> f(x):P"
wenzelm@26322
    22
  shows "?p : P|Q"
wenzelm@26322
    23
  apply (rule classical)
wenzelm@26322
    24
  apply (assumption | rule assms disjI1 notI)+
wenzelm@26322
    25
  apply (assumption | rule disjI2 notE)+
wenzelm@26322
    26
  done
wenzelm@26322
    27
wenzelm@26322
    28
(*introduction rule involving only EX*)
wenzelm@36319
    29
schematic_lemma ex_classical:
wenzelm@26322
    30
  assumes "!!u. u:~(EX x. P(x)) ==> f(u):P(a)"
wenzelm@26322
    31
  shows "?p : EX x. P(x)"
wenzelm@26322
    32
  apply (rule classical)
wenzelm@26322
    33
  apply (rule exI, rule assms, assumption)
wenzelm@26322
    34
  done
wenzelm@26322
    35
wenzelm@26322
    36
(*version of above, simplifying ~EX to ALL~ *)
wenzelm@36319
    37
schematic_lemma exCI:
wenzelm@26322
    38
  assumes "!!u. u:ALL x. ~P(x) ==> f(u):P(a)"
wenzelm@26322
    39
  shows "?p : EX x. P(x)"
wenzelm@26322
    40
  apply (rule ex_classical)
wenzelm@26322
    41
  apply (rule notI [THEN allI, THEN assms])
wenzelm@26322
    42
  apply (erule notE)
wenzelm@26322
    43
  apply (erule exI)
wenzelm@26322
    44
  done
wenzelm@26322
    45
wenzelm@36319
    46
schematic_lemma excluded_middle: "?p : ~P | P"
wenzelm@26322
    47
  apply (rule disjCI)
wenzelm@26322
    48
  apply assumption
wenzelm@26322
    49
  done
wenzelm@26322
    50
wenzelm@26322
    51
wenzelm@26322
    52
(*** Special elimination rules *)
wenzelm@17480
    53
wenzelm@26322
    54
(*Classical implies (-->) elimination. *)
wenzelm@36319
    55
schematic_lemma impCE:
wenzelm@26322
    56
  assumes major: "p:P-->Q"
wenzelm@26322
    57
    and r1: "!!x. x:~P ==> f(x):R"
wenzelm@26322
    58
    and r2: "!!y. y:Q ==> g(y):R"
wenzelm@26322
    59
  shows "?p : R"
wenzelm@26322
    60
  apply (rule excluded_middle [THEN disjE])
wenzelm@26322
    61
   apply (tactic {* DEPTH_SOLVE (atac 1 ORELSE
wenzelm@26322
    62
       resolve_tac [@{thm r1}, @{thm r2}, @{thm major} RS @{thm mp}] 1) *})
wenzelm@26322
    63
  done
wenzelm@26322
    64
wenzelm@26322
    65
(*Double negation law*)
wenzelm@36319
    66
schematic_lemma notnotD: "p:~~P ==> ?p : P"
wenzelm@26322
    67
  apply (rule classical)
wenzelm@26322
    68
  apply (erule notE)
wenzelm@26322
    69
  apply assumption
wenzelm@26322
    70
  done
wenzelm@26322
    71
wenzelm@26322
    72
wenzelm@26322
    73
(*** Tactics for implication and contradiction ***)
wenzelm@17480
    74
wenzelm@26322
    75
(*Classical <-> elimination.  Proof substitutes P=Q in
wenzelm@26322
    76
    ~P ==> ~Q    and    P ==> Q  *)
wenzelm@36319
    77
schematic_lemma iffCE:
wenzelm@26322
    78
  assumes major: "p:P<->Q"
wenzelm@26322
    79
    and r1: "!!x y.[| x:P; y:Q |] ==> f(x,y):R"
wenzelm@26322
    80
    and r2: "!!x y.[| x:~P; y:~Q |] ==> g(x,y):R"
wenzelm@26322
    81
  shows "?p : R"
wenzelm@26322
    82
  apply (insert major)
wenzelm@26322
    83
  apply (unfold iff_def)
wenzelm@26322
    84
  apply (rule conjE)
wenzelm@26322
    85
  apply (tactic {* DEPTH_SOLVE_1 (etac @{thm impCE} 1 ORELSE
wenzelm@26322
    86
      eresolve_tac [@{thm notE}, @{thm impE}] 1 THEN atac 1 ORELSE atac 1 ORELSE
wenzelm@26322
    87
      resolve_tac [@{thm r1}, @{thm r2}] 1) *})+
wenzelm@26322
    88
  done
wenzelm@26322
    89
wenzelm@26322
    90
wenzelm@26322
    91
(*Should be used as swap since ~P becomes redundant*)
wenzelm@36319
    92
schematic_lemma swap:
wenzelm@26322
    93
  assumes major: "p:~P"
wenzelm@26322
    94
    and r: "!!x. x:~Q ==> f(x):P"
wenzelm@26322
    95
  shows "?p : Q"
wenzelm@26322
    96
  apply (rule classical)
wenzelm@26322
    97
  apply (rule major [THEN notE])
wenzelm@26322
    98
  apply (rule r)
wenzelm@26322
    99
  apply assumption
wenzelm@26322
   100
  done
wenzelm@26322
   101
wenzelm@17480
   102
use "classical.ML"      (* Patched 'cos matching won't instantiate proof *)
wenzelm@17480
   103
use "simp.ML"           (* Patched 'cos matching won't instantiate proof *)
wenzelm@17480
   104
wenzelm@17480
   105
ML {*
wenzelm@42799
   106
structure Cla = Classical
wenzelm@42799
   107
(
wenzelm@17480
   108
  val sizef = size_of_thm
wenzelm@26322
   109
  val mp = @{thm mp}
wenzelm@26322
   110
  val not_elim = @{thm notE}
wenzelm@26322
   111
  val swap = @{thm swap}
wenzelm@26322
   112
  val hyp_subst_tacs = [hyp_subst_tac]
wenzelm@42799
   113
);
wenzelm@17480
   114
open Cla;
wenzelm@17480
   115
wenzelm@17480
   116
(*Propositional rules
wenzelm@17480
   117
  -- iffCE might seem better, but in the examples in ex/cla
wenzelm@17480
   118
     run about 7% slower than with iffE*)
wenzelm@26322
   119
val prop_cs =
wenzelm@26322
   120
  empty_cs addSIs [@{thm refl}, @{thm TrueI}, @{thm conjI}, @{thm disjCI},
wenzelm@26322
   121
      @{thm impI}, @{thm notI}, @{thm iffI}]
wenzelm@26322
   122
    addSEs [@{thm conjE}, @{thm disjE}, @{thm impCE}, @{thm FalseE}, @{thm iffE}];
wenzelm@17480
   123
wenzelm@17480
   124
(*Quantifier rules*)
wenzelm@26322
   125
val FOLP_cs =
wenzelm@26322
   126
  prop_cs addSIs [@{thm allI}] addIs [@{thm exI}, @{thm ex1I}]
wenzelm@26322
   127
    addSEs [@{thm exE}, @{thm ex1E}] addEs [@{thm allE}];
wenzelm@17480
   128
wenzelm@26322
   129
val FOLP_dup_cs =
wenzelm@26322
   130
  prop_cs addSIs [@{thm allI}] addIs [@{thm exCI}, @{thm ex1I}]
wenzelm@26322
   131
    addSEs [@{thm exE}, @{thm ex1E}] addEs [@{thm all_dupE}];
wenzelm@26322
   132
*}
wenzelm@17480
   133
wenzelm@36319
   134
schematic_lemma cla_rews:
wenzelm@26322
   135
  "?p1 : P | ~P"
wenzelm@26322
   136
  "?p2 : ~P | P"
wenzelm@26322
   137
  "?p3 : ~ ~ P <-> P"
wenzelm@26322
   138
  "?p4 : (~P --> P) <-> P"
wenzelm@26322
   139
  apply (tactic {* ALLGOALS (Cla.fast_tac FOLP_cs) *})
wenzelm@26322
   140
  done
wenzelm@17480
   141
wenzelm@17480
   142
use "simpdata.ML"
wenzelm@17480
   143
clasohm@0
   144
end