src/FOLP/ex/Classical.thy
author wenzelm
Sat Jul 25 10:31:27 2009 +0200 (2009-07-25)
changeset 32187 cca43ca13f4f
parent 26322 eaf634e975fa
child 35762 af3ff2ba4c54
permissions -rw-r--r--
renamed structure Display_Goal to Goal_Display;
wenzelm@26322
     1
(*  Title:      FOLP/ex/Classical.thy
wenzelm@26322
     2
    ID:         $Id$
wenzelm@26322
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
wenzelm@26322
     4
    Copyright   1993  University of Cambridge
wenzelm@26322
     5
wenzelm@26322
     6
Classical First-Order Logic.
wenzelm@26322
     7
*)
wenzelm@26322
     8
wenzelm@26322
     9
theory Classical
wenzelm@26322
    10
imports FOLP
wenzelm@26322
    11
begin
wenzelm@26322
    12
wenzelm@26322
    13
lemma "?p : (P --> Q | R) --> (P-->Q) | (P-->R)"
wenzelm@26322
    14
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    15
wenzelm@26322
    16
(*If and only if*)
wenzelm@26322
    17
lemma "?p : (P<->Q) <-> (Q<->P)"
wenzelm@26322
    18
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    19
wenzelm@26322
    20
lemma "?p : ~ (P <-> ~P)"
wenzelm@26322
    21
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    22
wenzelm@26322
    23
wenzelm@26322
    24
(*Sample problems from 
wenzelm@26322
    25
  F. J. Pelletier, 
wenzelm@26322
    26
  Seventy-Five Problems for Testing Automatic Theorem Provers,
wenzelm@26322
    27
  J. Automated Reasoning 2 (1986), 191-216.
wenzelm@26322
    28
  Errata, JAR 4 (1988), 236-236.
wenzelm@26322
    29
wenzelm@26322
    30
The hardest problems -- judging by experience with several theorem provers,
wenzelm@26322
    31
including matrix ones -- are 34 and 43.
wenzelm@26322
    32
*)
wenzelm@26322
    33
wenzelm@26322
    34
text "Pelletier's examples"
wenzelm@26322
    35
(*1*)
wenzelm@26322
    36
lemma "?p : (P-->Q)  <->  (~Q --> ~P)"
wenzelm@26322
    37
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    38
wenzelm@26322
    39
(*2*)
wenzelm@26322
    40
lemma "?p : ~ ~ P  <->  P"
wenzelm@26322
    41
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    42
wenzelm@26322
    43
(*3*)
wenzelm@26322
    44
lemma "?p : ~(P-->Q) --> (Q-->P)"
wenzelm@26322
    45
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    46
wenzelm@26322
    47
(*4*)
wenzelm@26322
    48
lemma "?p : (~P-->Q)  <->  (~Q --> P)"
wenzelm@26322
    49
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    50
wenzelm@26322
    51
(*5*)
wenzelm@26322
    52
lemma "?p : ((P|Q)-->(P|R)) --> (P|(Q-->R))"
wenzelm@26322
    53
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    54
wenzelm@26322
    55
(*6*)
wenzelm@26322
    56
lemma "?p : P | ~ P"
wenzelm@26322
    57
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    58
wenzelm@26322
    59
(*7*)
wenzelm@26322
    60
lemma "?p : P | ~ ~ ~ P"
wenzelm@26322
    61
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    62
wenzelm@26322
    63
(*8.  Peirce's law*)
wenzelm@26322
    64
lemma "?p : ((P-->Q) --> P)  -->  P"
wenzelm@26322
    65
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    66
wenzelm@26322
    67
(*9*)
wenzelm@26322
    68
lemma "?p : ((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
wenzelm@26322
    69
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    70
wenzelm@26322
    71
(*10*)
wenzelm@26322
    72
lemma "?p : (Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P<->Q)"
wenzelm@26322
    73
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    74
wenzelm@26322
    75
(*11.  Proved in each direction (incorrectly, says Pelletier!!)  *)
wenzelm@26322
    76
lemma "?p : P<->P"
wenzelm@26322
    77
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    78
wenzelm@26322
    79
(*12.  "Dijkstra's law"*)
wenzelm@26322
    80
lemma "?p : ((P <-> Q) <-> R)  <->  (P <-> (Q <-> R))"
wenzelm@26322
    81
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    82
wenzelm@26322
    83
(*13.  Distributive law*)
wenzelm@26322
    84
lemma "?p : P | (Q & R)  <-> (P | Q) & (P | R)"
wenzelm@26322
    85
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    86
wenzelm@26322
    87
(*14*)
wenzelm@26322
    88
lemma "?p : (P <-> Q) <-> ((Q | ~P) & (~Q|P))"
wenzelm@26322
    89
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    90
wenzelm@26322
    91
(*15*)
wenzelm@26322
    92
lemma "?p : (P --> Q) <-> (~P | Q)"
wenzelm@26322
    93
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    94
wenzelm@26322
    95
(*16*)
wenzelm@26322
    96
lemma "?p : (P-->Q) | (Q-->P)"
wenzelm@26322
    97
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
    98
wenzelm@26322
    99
(*17*)
wenzelm@26322
   100
lemma "?p : ((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S))"
wenzelm@26322
   101
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   102
wenzelm@26322
   103
wenzelm@26322
   104
text "Classical Logic: examples with quantifiers"
wenzelm@26322
   105
wenzelm@26322
   106
lemma "?p : (ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))"
wenzelm@26322
   107
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   108
wenzelm@26322
   109
lemma "?p : (EX x. P-->Q(x))  <->  (P --> (EX x. Q(x)))"
wenzelm@26322
   110
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   111
wenzelm@26322
   112
lemma "?p : (EX x. P(x)-->Q)  <->  (ALL x. P(x)) --> Q"
wenzelm@26322
   113
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   114
wenzelm@26322
   115
lemma "?p : (ALL x. P(x)) | Q  <->  (ALL x. P(x) | Q)"
wenzelm@26322
   116
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   117
wenzelm@26322
   118
wenzelm@26322
   119
text "Problems requiring quantifier duplication"
wenzelm@26322
   120
wenzelm@26322
   121
(*Needs multiple instantiation of ALL.*)
wenzelm@26322
   122
lemma "?p : (ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))"
wenzelm@26322
   123
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   124
wenzelm@26322
   125
(*Needs double instantiation of the quantifier*)
wenzelm@26322
   126
lemma "?p : EX x. P(x) --> P(a) & P(b)"
wenzelm@26322
   127
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   128
wenzelm@26322
   129
lemma "?p : EX z. P(z) --> (ALL x. P(x))"
wenzelm@26322
   130
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   131
wenzelm@26322
   132
wenzelm@26322
   133
text "Hard examples with quantifiers"
wenzelm@26322
   134
wenzelm@26322
   135
text "Problem 18"
wenzelm@26322
   136
lemma "?p : EX y. ALL x. P(y)-->P(x)"
wenzelm@26322
   137
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   138
wenzelm@26322
   139
text "Problem 19"
wenzelm@26322
   140
lemma "?p : EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
wenzelm@26322
   141
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   142
wenzelm@26322
   143
text "Problem 20"
wenzelm@26322
   144
lemma "?p : (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))      
wenzelm@26322
   145
    --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
wenzelm@26322
   146
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   147
wenzelm@26322
   148
text "Problem 21"
wenzelm@26322
   149
lemma "?p : (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))";
wenzelm@26322
   150
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   151
wenzelm@26322
   152
text "Problem 22"
wenzelm@26322
   153
lemma "?p : (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))"
wenzelm@26322
   154
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   155
wenzelm@26322
   156
text "Problem 23"
wenzelm@26322
   157
lemma "?p : (ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))"
wenzelm@26322
   158
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   159
wenzelm@26322
   160
text "Problem 24"
wenzelm@26322
   161
lemma "?p : ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &   
wenzelm@26322
   162
     (~(EX x. P(x)) --> (EX x. Q(x))) & (ALL x. Q(x)|R(x) --> S(x))   
wenzelm@26322
   163
    --> (EX x. P(x)&R(x))"
wenzelm@26322
   164
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   165
wenzelm@26322
   166
text "Problem 25"
wenzelm@26322
   167
lemma "?p : (EX x. P(x)) &  
wenzelm@26322
   168
       (ALL x. L(x) --> ~ (M(x) & R(x))) &  
wenzelm@26322
   169
       (ALL x. P(x) --> (M(x) & L(x))) &   
wenzelm@26322
   170
       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  
wenzelm@26322
   171
   --> (EX x. Q(x)&P(x))"
wenzelm@26322
   172
  oops
wenzelm@26322
   173
wenzelm@26322
   174
text "Problem 26"
wenzelm@26322
   175
lemma "?u : ((EX x. p(x)) <-> (EX x. q(x))) &   
wenzelm@26322
   176
     (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))   
wenzelm@26322
   177
  --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))";
wenzelm@26322
   178
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   179
wenzelm@26322
   180
text "Problem 27"
wenzelm@26322
   181
lemma "?p : (EX x. P(x) & ~Q(x)) &    
wenzelm@26322
   182
              (ALL x. P(x) --> R(x)) &    
wenzelm@26322
   183
              (ALL x. M(x) & L(x) --> P(x)) &    
wenzelm@26322
   184
              ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))   
wenzelm@26322
   185
          --> (ALL x. M(x) --> ~L(x))"
wenzelm@26322
   186
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   187
wenzelm@26322
   188
text "Problem 28.  AMENDED"
wenzelm@26322
   189
lemma "?p : (ALL x. P(x) --> (ALL x. Q(x))) &    
wenzelm@26322
   190
        ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &   
wenzelm@26322
   191
        ((EX x. S(x)) --> (ALL x. L(x) --> M(x)))   
wenzelm@26322
   192
    --> (ALL x. P(x) & L(x) --> M(x))"
wenzelm@26322
   193
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   194
wenzelm@26322
   195
text "Problem 29.  Essentially the same as Principia Mathematica *11.71"
wenzelm@26322
   196
lemma "?p : (EX x. P(x)) & (EX y. Q(y))   
wenzelm@26322
   197
    --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->      
wenzelm@26322
   198
         (ALL x y. P(x) & Q(y) --> R(x) & S(y)))"
wenzelm@26322
   199
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   200
wenzelm@26322
   201
text "Problem 30"
wenzelm@26322
   202
lemma "?p : (ALL x. P(x) | Q(x) --> ~ R(x)) &  
wenzelm@26322
   203
        (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))   
wenzelm@26322
   204
    --> (ALL x. S(x))"
wenzelm@26322
   205
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   206
wenzelm@26322
   207
text "Problem 31"
wenzelm@26322
   208
lemma "?p : ~(EX x. P(x) & (Q(x) | R(x))) &  
wenzelm@26322
   209
        (EX x. L(x) & P(x)) &  
wenzelm@26322
   210
        (ALL x. ~ R(x) --> M(x))   
wenzelm@26322
   211
    --> (EX x. L(x) & M(x))"
wenzelm@26322
   212
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   213
wenzelm@26322
   214
text "Problem 32"
wenzelm@26322
   215
lemma "?p : (ALL x. P(x) & (Q(x)|R(x))-->S(x)) &  
wenzelm@26322
   216
        (ALL x. S(x) & R(x) --> L(x)) &  
wenzelm@26322
   217
        (ALL x. M(x) --> R(x))   
wenzelm@26322
   218
    --> (ALL x. P(x) & M(x) --> L(x))"
wenzelm@26322
   219
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   220
wenzelm@26322
   221
text "Problem 33"
wenzelm@26322
   222
lemma "?p : (ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->     
wenzelm@26322
   223
     (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))"
wenzelm@26322
   224
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   225
wenzelm@26322
   226
text "Problem 35"
wenzelm@26322
   227
lemma "?p : EX x y. P(x,y) -->  (ALL u v. P(u,v))"
wenzelm@26322
   228
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   229
wenzelm@26322
   230
text "Problem 36"
wenzelm@26322
   231
lemma
wenzelm@26322
   232
"?p : (ALL x. EX y. J(x,y)) &  
wenzelm@26322
   233
      (ALL x. EX y. G(x,y)) &  
wenzelm@26322
   234
      (ALL x y. J(x,y) | G(x,y) --> (ALL z. J(y,z) | G(y,z) --> H(x,z)))    
wenzelm@26322
   235
  --> (ALL x. EX y. H(x,y))"
wenzelm@26322
   236
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   237
wenzelm@26322
   238
text "Problem 37"
wenzelm@26322
   239
lemma "?p : (ALL z. EX w. ALL x. EX y.  
wenzelm@26322
   240
           (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u. Q(u,w)))) &  
wenzelm@26322
   241
        (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) &  
wenzelm@26322
   242
        ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))   
wenzelm@26322
   243
    --> (ALL x. EX y. R(x,y))"
wenzelm@26322
   244
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   245
wenzelm@26322
   246
text "Problem 39"
wenzelm@26322
   247
lemma "?p : ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))"
wenzelm@26322
   248
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   249
wenzelm@26322
   250
text "Problem 40.  AMENDED"
wenzelm@26322
   251
lemma "?p : (EX y. ALL x. F(x,y) <-> F(x,x)) -->   
wenzelm@26322
   252
              ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))"
wenzelm@26322
   253
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   254
wenzelm@26322
   255
text "Problem 41"
wenzelm@26322
   256
lemma "?p : (ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))   
wenzelm@26322
   257
          --> ~ (EX z. ALL x. f(x,z))"
wenzelm@26322
   258
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   259
wenzelm@26322
   260
text "Problem 44"
wenzelm@26322
   261
lemma "?p : (ALL x. f(x) -->                                     
wenzelm@26322
   262
              (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &        
wenzelm@26322
   263
              (EX x. j(x) & (ALL y. g(y) --> h(x,y)))                    
wenzelm@26322
   264
              --> (EX x. j(x) & ~f(x))"
wenzelm@26322
   265
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   266
wenzelm@26322
   267
text "Problems (mainly) involving equality or functions"
wenzelm@26322
   268
wenzelm@26322
   269
text "Problem 48"
wenzelm@26322
   270
lemma "?p : (a=b | c=d) & (a=c | b=d) --> a=d | b=c"
wenzelm@26322
   271
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   272
wenzelm@26322
   273
text "Problem 50"
wenzelm@26322
   274
(*What has this to do with equality?*)
wenzelm@26322
   275
lemma "?p : (ALL x. P(a,x) | (ALL y. P(x,y))) --> (EX x. ALL y. P(x,y))"
wenzelm@26322
   276
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   277
wenzelm@26322
   278
text "Problem 56"
wenzelm@26322
   279
lemma
wenzelm@26322
   280
 "?p : (ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))"
wenzelm@26322
   281
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   282
wenzelm@26322
   283
text "Problem 57"
wenzelm@26322
   284
lemma
wenzelm@26322
   285
"?p : P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) &  
wenzelm@26322
   286
      (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))"
wenzelm@26322
   287
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   288
wenzelm@26322
   289
text "Problem 58  NOT PROVED AUTOMATICALLY"
wenzelm@26322
   290
lemma
wenzelm@26322
   291
  notes f_cong = subst_context [where t = f]
wenzelm@26322
   292
  shows "?p : (ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))"
wenzelm@26322
   293
  by (tactic {* fast_tac (FOLP_cs addSIs [@{thm f_cong}]) 1 *})
wenzelm@26322
   294
wenzelm@26322
   295
text "Problem 59"
wenzelm@26322
   296
lemma "?p : (ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))"
wenzelm@26322
   297
  by (tactic "best_tac FOLP_dup_cs 1")
wenzelm@26322
   298
wenzelm@26322
   299
text "Problem 60"
wenzelm@26322
   300
lemma "?p : ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))"
wenzelm@26322
   301
  by (tactic "fast_tac FOLP_cs 1")
wenzelm@26322
   302
wenzelm@26322
   303
end