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