src/FOL/ex/cla.ML
author paulson
Tue Mar 04 10:21:16 1997 +0100 (1997-03-04)
changeset 2715 79c35a051196
parent 2614 0b1364481214
child 2729 44cbfeebd0fe
permissions -rw-r--r--
Updated reference to Pelletier erratum
clasohm@1462
     1
(*  Title:      FOL/ex/cla.ML
clasohm@0
     2
    ID:         $Id$
clasohm@1459
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@665
     4
    Copyright   1994  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Classical First-Order Logic
clasohm@0
     7
*)
clasohm@0
     8
clasohm@1462
     9
writeln"File FOL/ex/cla.ML";
clasohm@0
    10
paulson@2601
    11
open Cla;    (*in case structure IntPr is open!*)
clasohm@0
    12
clasohm@0
    13
goal FOL.thy "(P --> Q | R) --> (P-->Q) | (P-->R)";
paulson@2469
    14
by (Fast_tac 1);
clasohm@0
    15
result();
clasohm@0
    16
clasohm@0
    17
(*If and only if*)
clasohm@0
    18
clasohm@0
    19
goal FOL.thy "(P<->Q) <-> (Q<->P)";
paulson@2469
    20
by (Fast_tac 1);
clasohm@0
    21
result();
clasohm@0
    22
clasohm@0
    23
goal FOL.thy "~ (P <-> ~P)";
paulson@2469
    24
by (Fast_tac 1);
clasohm@0
    25
result();
clasohm@0
    26
clasohm@0
    27
clasohm@0
    28
(*Sample problems from 
clasohm@0
    29
  F. J. Pelletier, 
clasohm@0
    30
  Seventy-Five Problems for Testing Automatic Theorem Provers,
clasohm@0
    31
  J. Automated Reasoning 2 (1986), 191-216.
clasohm@0
    32
  Errata, JAR 4 (1988), 236-236.
clasohm@0
    33
clasohm@0
    34
The hardest problems -- judging by experience with several theorem provers,
clasohm@0
    35
including matrix ones -- are 34 and 43.
clasohm@0
    36
*)
clasohm@0
    37
clasohm@0
    38
writeln"Pelletier's examples";
clasohm@0
    39
(*1*)
clasohm@0
    40
goal FOL.thy "(P-->Q)  <->  (~Q --> ~P)";
paulson@2469
    41
by (Fast_tac 1);
clasohm@0
    42
result();
clasohm@0
    43
clasohm@0
    44
(*2*)
clasohm@0
    45
goal FOL.thy "~ ~ P  <->  P";
paulson@2469
    46
by (Fast_tac 1);
clasohm@0
    47
result();
clasohm@0
    48
clasohm@0
    49
(*3*)
clasohm@0
    50
goal FOL.thy "~(P-->Q) --> (Q-->P)";
paulson@2469
    51
by (Fast_tac 1);
clasohm@0
    52
result();
clasohm@0
    53
clasohm@0
    54
(*4*)
clasohm@0
    55
goal FOL.thy "(~P-->Q)  <->  (~Q --> P)";
paulson@2469
    56
by (Fast_tac 1);
clasohm@0
    57
result();
clasohm@0
    58
clasohm@0
    59
(*5*)
clasohm@0
    60
goal FOL.thy "((P|Q)-->(P|R)) --> (P|(Q-->R))";
paulson@2469
    61
by (Fast_tac 1);
clasohm@0
    62
result();
clasohm@0
    63
clasohm@0
    64
(*6*)
clasohm@0
    65
goal FOL.thy "P | ~ P";
paulson@2469
    66
by (Fast_tac 1);
clasohm@0
    67
result();
clasohm@0
    68
clasohm@0
    69
(*7*)
clasohm@0
    70
goal FOL.thy "P | ~ ~ ~ P";
paulson@2469
    71
by (Fast_tac 1);
clasohm@0
    72
result();
clasohm@0
    73
clasohm@0
    74
(*8.  Peirce's law*)
clasohm@0
    75
goal FOL.thy "((P-->Q) --> P)  -->  P";
paulson@2469
    76
by (Fast_tac 1);
clasohm@0
    77
result();
clasohm@0
    78
clasohm@0
    79
(*9*)
clasohm@0
    80
goal FOL.thy "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)";
paulson@2469
    81
by (Fast_tac 1);
clasohm@0
    82
result();
clasohm@0
    83
clasohm@0
    84
(*10*)
clasohm@0
    85
goal FOL.thy "(Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P<->Q)";
paulson@2469
    86
by (Fast_tac 1);
clasohm@0
    87
result();
clasohm@0
    88
clasohm@0
    89
(*11.  Proved in each direction (incorrectly, says Pelletier!!)  *)
clasohm@0
    90
goal FOL.thy "P<->P";
paulson@2469
    91
by (Fast_tac 1);
clasohm@0
    92
result();
clasohm@0
    93
clasohm@0
    94
(*12.  "Dijkstra's law"*)
clasohm@0
    95
goal FOL.thy "((P <-> Q) <-> R)  <->  (P <-> (Q <-> R))";
paulson@2469
    96
by (Fast_tac 1);
clasohm@0
    97
result();
clasohm@0
    98
clasohm@0
    99
(*13.  Distributive law*)
clasohm@0
   100
goal FOL.thy "P | (Q & R)  <-> (P | Q) & (P | R)";
paulson@2469
   101
by (Fast_tac 1);
clasohm@0
   102
result();
clasohm@0
   103
clasohm@0
   104
(*14*)
clasohm@0
   105
goal FOL.thy "(P <-> Q) <-> ((Q | ~P) & (~Q|P))";
paulson@2469
   106
by (Fast_tac 1);
clasohm@0
   107
result();
clasohm@0
   108
clasohm@0
   109
(*15*)
clasohm@0
   110
goal FOL.thy "(P --> Q) <-> (~P | Q)";
paulson@2469
   111
by (Fast_tac 1);
clasohm@0
   112
result();
clasohm@0
   113
clasohm@0
   114
(*16*)
clasohm@0
   115
goal FOL.thy "(P-->Q) | (Q-->P)";
paulson@2469
   116
by (Fast_tac 1);
clasohm@0
   117
result();
clasohm@0
   118
clasohm@0
   119
(*17*)
clasohm@0
   120
goal FOL.thy "((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S))";
paulson@2469
   121
by (Fast_tac 1);
clasohm@0
   122
result();
clasohm@0
   123
clasohm@0
   124
writeln"Classical Logic: examples with quantifiers";
clasohm@0
   125
clasohm@0
   126
goal FOL.thy "(ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))";
paulson@2469
   127
by (Fast_tac 1);
clasohm@0
   128
result(); 
clasohm@0
   129
clasohm@0
   130
goal FOL.thy "(EX x. P-->Q(x))  <->  (P --> (EX x.Q(x)))";
paulson@2469
   131
by (Fast_tac 1);
clasohm@0
   132
result(); 
clasohm@0
   133
clasohm@0
   134
goal FOL.thy "(EX x.P(x)-->Q)  <->  (ALL x.P(x)) --> Q";
paulson@2469
   135
by (Fast_tac 1);
clasohm@0
   136
result(); 
clasohm@0
   137
clasohm@0
   138
goal FOL.thy "(ALL x.P(x)) | Q  <->  (ALL x. P(x) | Q)";
paulson@2469
   139
by (Fast_tac 1);
clasohm@0
   140
result(); 
clasohm@0
   141
lcp@13
   142
(*Discussed in Avron, Gentzen-Type Systems, Resolution and Tableaux,
lcp@13
   143
  JAR 10 (265-281), 1993.  Proof is trivial!*)
lcp@13
   144
goal FOL.thy
lcp@13
   145
    "~ ((EX x.~P(x)) & ((EX x.P(x)) | (EX x.P(x) & Q(x))) & ~ (EX x.P(x)))";
paulson@2469
   146
by (Fast_tac 1);
lcp@13
   147
result();
lcp@13
   148
clasohm@0
   149
writeln"Problems requiring quantifier duplication";
clasohm@0
   150
clasohm@0
   151
(*Needs multiple instantiation of ALL.*)
clasohm@0
   152
goal FOL.thy "(ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))";
paulson@2469
   153
by (Deepen_tac 0 1);
clasohm@0
   154
result();
clasohm@0
   155
clasohm@0
   156
(*Needs double instantiation of the quantifier*)
clasohm@0
   157
goal FOL.thy "EX x. P(x) --> P(a) & P(b)";
paulson@2469
   158
by (Deepen_tac 0 1);
clasohm@0
   159
result();
clasohm@0
   160
clasohm@0
   161
goal FOL.thy "EX z. P(z) --> (ALL x. P(x))";
paulson@2469
   162
by (Deepen_tac 0 1);
clasohm@0
   163
result();
clasohm@0
   164
lcp@492
   165
goal FOL.thy "EX x. (EX y. P(y)) --> P(x)";
paulson@2469
   166
by (Deepen_tac 0 1);
lcp@492
   167
result();
lcp@492
   168
lcp@665
   169
(*V. Lifschitz, What Is the Inverse Method?, JAR 5 (1989), 1--23.  NOT PROVED*)
clasohm@0
   170
goal FOL.thy "EX x x'. ALL y. EX z z'. \
clasohm@0
   171
\               (~P(y,y) | P(x,x) | ~S(z,x)) & \
clasohm@0
   172
\               (S(x,y) | ~S(y,z) | Q(z',z'))  & \
clasohm@0
   173
\               (Q(x',y) | ~Q(y,z') | S(x',x'))";
clasohm@0
   174
clasohm@0
   175
writeln"Hard examples with quantifiers";
clasohm@0
   176
clasohm@0
   177
writeln"Problem 18";
clasohm@0
   178
goal FOL.thy "EX y. ALL x. P(y)-->P(x)";
paulson@2469
   179
by (Deepen_tac 0 1);
clasohm@0
   180
result(); 
clasohm@0
   181
clasohm@0
   182
writeln"Problem 19";
clasohm@0
   183
goal FOL.thy "EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))";
paulson@2469
   184
by (Deepen_tac 0 1);
clasohm@0
   185
result();
clasohm@0
   186
clasohm@0
   187
writeln"Problem 20";
clasohm@0
   188
goal FOL.thy "(ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))     \
clasohm@0
   189
\   --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))";
paulson@2469
   190
by (Fast_tac 1); 
clasohm@0
   191
result();
clasohm@0
   192
clasohm@0
   193
writeln"Problem 21";
clasohm@0
   194
goal FOL.thy "(EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))";
paulson@2469
   195
by (Deepen_tac 0 1);
clasohm@0
   196
result();
clasohm@0
   197
clasohm@0
   198
writeln"Problem 22";
clasohm@0
   199
goal FOL.thy "(ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))";
paulson@2469
   200
by (Fast_tac 1); 
clasohm@0
   201
result();
clasohm@0
   202
clasohm@0
   203
writeln"Problem 23";
clasohm@0
   204
goal FOL.thy "(ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))";
paulson@2469
   205
by (Best_tac 1);  
clasohm@0
   206
result();
clasohm@0
   207
clasohm@0
   208
writeln"Problem 24";
clasohm@0
   209
goal FOL.thy "~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &  \
paulson@2574
   210
\    (~(EX x.P(x)) --> (EX x.Q(x))) & (ALL x. Q(x)|R(x) --> S(x))  \
clasohm@0
   211
\   --> (EX x. P(x)&R(x))";
paulson@2469
   212
by (Fast_tac 1); 
clasohm@0
   213
result();
clasohm@0
   214
clasohm@0
   215
writeln"Problem 25";
clasohm@0
   216
goal FOL.thy "(EX x. P(x)) &  \
clasohm@0
   217
\       (ALL x. L(x) --> ~ (M(x) & R(x))) &  \
clasohm@0
   218
\       (ALL x. P(x) --> (M(x) & L(x))) &   \
clasohm@0
   219
\       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  \
clasohm@0
   220
\   --> (EX x. Q(x)&P(x))";
paulson@2469
   221
by (Best_tac 1); 
clasohm@0
   222
result();
clasohm@0
   223
clasohm@0
   224
writeln"Problem 26";
clasohm@1459
   225
goal FOL.thy "((EX x. p(x)) <-> (EX x. q(x))) & \
clasohm@1459
   226
\     (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))   \
clasohm@0
   227
\ --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))";
paulson@2469
   228
by (Fast_tac 1);
clasohm@0
   229
result();
clasohm@0
   230
clasohm@0
   231
writeln"Problem 27";
clasohm@0
   232
goal FOL.thy "(EX x. P(x) & ~Q(x)) &   \
clasohm@0
   233
\             (ALL x. P(x) --> R(x)) &   \
clasohm@0
   234
\             (ALL x. M(x) & L(x) --> P(x)) &   \
clasohm@0
   235
\             ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))  \
clasohm@0
   236
\         --> (ALL x. M(x) --> ~L(x))";
paulson@2469
   237
by (Fast_tac 1); 
clasohm@0
   238
result();
clasohm@0
   239
clasohm@0
   240
writeln"Problem 28.  AMENDED";
clasohm@0
   241
goal FOL.thy "(ALL x. P(x) --> (ALL x. Q(x))) &   \
clasohm@0
   242
\       ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &  \
clasohm@0
   243
\       ((EX x.S(x)) --> (ALL x. L(x) --> M(x)))  \
clasohm@0
   244
\   --> (ALL x. P(x) & L(x) --> M(x))";
paulson@2469
   245
by (Fast_tac 1);  
clasohm@0
   246
result();
clasohm@0
   247
clasohm@0
   248
writeln"Problem 29.  Essentially the same as Principia Mathematica *11.71";
clasohm@0
   249
goal FOL.thy "(EX x. P(x)) & (EX y. Q(y))  \
clasohm@0
   250
\   --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->     \
clasohm@0
   251
\        (ALL x y. P(x) & Q(y) --> R(x) & S(y)))";
paulson@2469
   252
by (Fast_tac 1); 
clasohm@0
   253
result();
clasohm@0
   254
clasohm@0
   255
writeln"Problem 30";
clasohm@0
   256
goal FOL.thy "(ALL x. P(x) | Q(x) --> ~ R(x)) & \
clasohm@0
   257
\       (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))  \
clasohm@0
   258
\   --> (ALL x. S(x))";
paulson@2469
   259
by (Fast_tac 1);  
clasohm@0
   260
result();
clasohm@0
   261
clasohm@0
   262
writeln"Problem 31";
clasohm@0
   263
goal FOL.thy "~(EX x.P(x) & (Q(x) | R(x))) & \
clasohm@0
   264
\       (EX x. L(x) & P(x)) & \
clasohm@0
   265
\       (ALL x. ~ R(x) --> M(x))  \
clasohm@0
   266
\   --> (EX x. L(x) & M(x))";
paulson@2469
   267
by (Fast_tac 1);
clasohm@0
   268
result();
clasohm@0
   269
clasohm@0
   270
writeln"Problem 32";
clasohm@0
   271
goal FOL.thy "(ALL x. P(x) & (Q(x)|R(x))-->S(x)) & \
clasohm@0
   272
\       (ALL x. S(x) & R(x) --> L(x)) & \
clasohm@0
   273
\       (ALL x. M(x) --> R(x))  \
clasohm@0
   274
\   --> (ALL x. P(x) & M(x) --> L(x))";
paulson@2469
   275
by (Best_tac 1);
clasohm@0
   276
result();
clasohm@0
   277
clasohm@0
   278
writeln"Problem 33";
clasohm@0
   279
goal FOL.thy "(ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->    \
clasohm@0
   280
\    (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))";
paulson@2469
   281
by (Best_tac 1);
clasohm@0
   282
result();
clasohm@0
   283
lcp@665
   284
writeln"Problem 34  AMENDED (TWICE!!)";
clasohm@0
   285
(*Andrews's challenge*)
clasohm@1459
   286
goal FOL.thy "((EX x. ALL y. p(x) <-> p(y))  <->                \
clasohm@1459
   287
\              ((EX x. q(x)) <-> (ALL y. p(y))))     <->        \
clasohm@1459
   288
\             ((EX x. ALL y. q(x) <-> q(y))  <->                \
clasohm@0
   289
\              ((EX x. p(x)) <-> (ALL y. q(y))))";
paulson@2469
   290
by (Deepen_tac 0 1);
clasohm@0
   291
result();
clasohm@0
   292
clasohm@0
   293
writeln"Problem 35";
clasohm@0
   294
goal FOL.thy "EX x y. P(x,y) -->  (ALL u v. P(u,v))";
lcp@732
   295
by (mini_tac 1);
paulson@2469
   296
by (Fast_tac 1);
lcp@665
   297
(*Without miniscope, would have to use deepen_tac; would be slower*)
clasohm@0
   298
result();
clasohm@0
   299
clasohm@0
   300
writeln"Problem 36";
clasohm@0
   301
goal FOL.thy
clasohm@0
   302
     "(ALL x. EX y. J(x,y)) & \
clasohm@0
   303
\     (ALL x. EX y. G(x,y)) & \
clasohm@0
   304
\     (ALL x y. J(x,y) | G(x,y) --> (ALL z. J(y,z) | G(y,z) --> H(x,z)))   \
clasohm@0
   305
\ --> (ALL x. EX y. H(x,y))";
paulson@2469
   306
by (Fast_tac 1);
clasohm@0
   307
result();
clasohm@0
   308
clasohm@0
   309
writeln"Problem 37";
clasohm@0
   310
goal FOL.thy "(ALL z. EX w. ALL x. EX y. \
clasohm@0
   311
\          (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u.Q(u,w)))) & \
clasohm@0
   312
\       (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) & \
clasohm@0
   313
\       ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))  \
clasohm@0
   314
\   --> (ALL x. EX y. R(x,y))";
paulson@2469
   315
by (Fast_tac 1);
clasohm@0
   316
result();
clasohm@0
   317
lcp@428
   318
writeln"Problem 38";
clasohm@0
   319
goal FOL.thy
clasohm@1459
   320
    "(ALL x. p(a) & (p(x) --> (EX y. p(y) & r(x,y))) -->        \
clasohm@1459
   321
\            (EX z. EX w. p(z) & r(x,w) & r(w,z)))  <->         \
clasohm@1459
   322
\    (ALL x. (~p(a) | p(x) | (EX z. EX w. p(z) & r(x,w) & r(w,z))) &    \
clasohm@1459
   323
\            (~p(a) | ~(EX y. p(y) & r(x,y)) |                          \
clasohm@0
   324
\             (EX z. EX w. p(z) & r(x,w) & r(w,z))))";
paulson@2469
   325
by (Deepen_tac 0 1);  (*beats fast_tac!*)
lcp@665
   326
result();
clasohm@0
   327
clasohm@0
   328
writeln"Problem 39";
clasohm@0
   329
goal FOL.thy "~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
paulson@2469
   330
by (Fast_tac 1);
clasohm@0
   331
result();
clasohm@0
   332
clasohm@0
   333
writeln"Problem 40.  AMENDED";
clasohm@0
   334
goal FOL.thy "(EX y. ALL x. F(x,y) <-> F(x,x)) -->  \
clasohm@0
   335
\             ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))";
paulson@2469
   336
by (Fast_tac 1);
clasohm@0
   337
result();
clasohm@0
   338
clasohm@0
   339
writeln"Problem 41";
clasohm@1459
   340
goal FOL.thy "(ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))        \
clasohm@0
   341
\         --> ~ (EX z. ALL x. f(x,z))";
paulson@2469
   342
by (Fast_tac 1);
clasohm@0
   343
result();
clasohm@0
   344
lcp@428
   345
writeln"Problem 42";
clasohm@0
   346
goal FOL.thy "~ (EX y. ALL x. p(x,y) <-> ~ (EX z. p(x,z) & p(z,x)))";
paulson@2469
   347
by (Deepen_tac 0 1);
lcp@428
   348
result();
clasohm@0
   349
lcp@732
   350
writeln"Problem 43";
clasohm@1459
   351
goal FOL.thy "(ALL x. ALL y. q(x,y) <-> (ALL z. p(z,x) <-> p(z,y)))     \
lcp@665
   352
\         --> (ALL x. ALL y. q(x,y) <-> q(y,x))";
paulson@2469
   353
by (Auto_tac());
paulson@2469
   354
(*The proof above cheats by using rewriting!  A purely logical proof is
paulson@2469
   355
  by (mini_tac 1 THEN Deepen_tac 5 1);
paulson@1809
   356
Can use just deepen_tac but it requires 253 secs?!?
paulson@2469
   357
  by (Deepen_tac 0 1);     
lcp@732
   358
*)
lcp@665
   359
result();
clasohm@0
   360
clasohm@0
   361
writeln"Problem 44";
clasohm@1459
   362
goal FOL.thy "(ALL x. f(x) -->                                          \
clasohm@1459
   363
\             (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &       \
clasohm@1459
   364
\             (EX x. j(x) & (ALL y. g(y) --> h(x,y)))                   \
clasohm@0
   365
\             --> (EX x. j(x) & ~f(x))";
paulson@2469
   366
by (Fast_tac 1);
clasohm@0
   367
result();
clasohm@0
   368
clasohm@0
   369
writeln"Problem 45";
clasohm@1459
   370
goal FOL.thy "(ALL x. f(x) & (ALL y. g(y) & h(x,y) --> j(x,y))  \
clasohm@1459
   371
\                     --> (ALL y. g(y) & h(x,y) --> k(y))) &    \
clasohm@1459
   372
\     ~ (EX y. l(y) & k(y)) &                                   \
clasohm@1459
   373
\     (EX x. f(x) & (ALL y. h(x,y) --> l(y))                    \
clasohm@1459
   374
\                 & (ALL y. g(y) & h(x,y) --> j(x,y)))          \
clasohm@0
   375
\     --> (EX x. f(x) & ~ (EX y. g(y) & h(x,y)))";
paulson@2469
   376
by (Best_tac 1); 
clasohm@0
   377
result();
clasohm@0
   378
clasohm@0
   379
clasohm@0
   380
writeln"Problems (mainly) involving equality or functions";
clasohm@0
   381
clasohm@0
   382
writeln"Problem 48";
clasohm@0
   383
goal FOL.thy "(a=b | c=d) & (a=c | b=d) --> a=d | b=c";
paulson@2469
   384
by (Fast_tac 1);
clasohm@0
   385
result();
clasohm@0
   386
clasohm@0
   387
writeln"Problem 49  NOT PROVED AUTOMATICALLY";
clasohm@0
   388
(*Hard because it involves substitution for Vars;
clasohm@0
   389
  the type constraint ensures that x,y,z have the same type as a,b,u. *)
lcp@36
   390
goal FOL.thy "(EX x y::'a. ALL z. z=x | z=y) & P(a) & P(b) & a~=b \
clasohm@1459
   391
\               --> (ALL u::'a.P(u))";
paulson@2469
   392
by (Step_tac 1);
clasohm@0
   393
by (res_inst_tac [("x","a")] allE 1);
clasohm@1459
   394
by (assume_tac 1);
clasohm@0
   395
by (res_inst_tac [("x","b")] allE 1);
clasohm@1459
   396
by (assume_tac 1);
paulson@2469
   397
by (Fast_tac 1);
clasohm@0
   398
result();
clasohm@0
   399
clasohm@0
   400
writeln"Problem 50";  
clasohm@0
   401
(*What has this to do with equality?*)
clasohm@0
   402
goal FOL.thy "(ALL x. P(a,x) | (ALL y.P(x,y))) --> (EX x. ALL y.P(x,y))";
lcp@732
   403
by (mini_tac 1);
paulson@2469
   404
by (Deepen_tac 0 1);
clasohm@0
   405
result();
clasohm@0
   406
clasohm@0
   407
writeln"Problem 51";
clasohm@0
   408
goal FOL.thy
clasohm@0
   409
    "(EX z w. ALL x y. P(x,y) <->  (x=z & y=w)) -->  \
clasohm@0
   410
\    (EX z. ALL x. EX w. (ALL y. P(x,y) <-> y=w) <-> x=z)";
paulson@2469
   411
by (Fast_tac 1);
clasohm@0
   412
result();
clasohm@0
   413
clasohm@0
   414
writeln"Problem 52";
clasohm@0
   415
(*Almost the same as 51. *)
clasohm@0
   416
goal FOL.thy
clasohm@0
   417
    "(EX z w. ALL x y. P(x,y) <->  (x=z & y=w)) -->  \
clasohm@0
   418
\    (EX w. ALL y. EX z. (ALL x. P(x,y) <-> x=z) <-> y=w)";
paulson@2469
   419
by (Best_tac 1);
clasohm@0
   420
result();
clasohm@0
   421
clasohm@0
   422
writeln"Problem 55";
clasohm@0
   423
clasohm@0
   424
(*Original, equational version by Len Schubert, via Pelletier *** NOT PROVED
clasohm@0
   425
goal FOL.thy
clasohm@0
   426
  "(EX x. lives(x) & killed(x,agatha)) & \
clasohm@0
   427
\  lives(agatha) & lives(butler) & lives(charles) & \
clasohm@0
   428
\  (ALL x. lives(x) --> x=agatha | x=butler | x=charles) & \
clasohm@0
   429
\  (ALL x y. killed(x,y) --> hates(x,y)) & \
clasohm@0
   430
\  (ALL x y. killed(x,y) --> ~richer(x,y)) & \
clasohm@0
   431
\  (ALL x. hates(agatha,x) --> ~hates(charles,x)) & \
clasohm@0
   432
\  (ALL x. ~ x=butler --> hates(agatha,x)) & \
clasohm@0
   433
\  (ALL x. ~richer(x,agatha) --> hates(butler,x)) & \
clasohm@0
   434
\  (ALL x. hates(agatha,x) --> hates(butler,x)) & \
clasohm@0
   435
\  (ALL x. EX y. ~hates(x,y)) & \
clasohm@0
   436
\  ~ agatha=butler --> \
clasohm@0
   437
\  killed(?who,agatha)";
paulson@2469
   438
by (Step_tac 1);
clasohm@0
   439
by (dres_inst_tac [("x1","x")] (spec RS mp) 1);
clasohm@1459
   440
by (assume_tac 1);
clasohm@1459
   441
by (etac (spec RS exE) 1);
clasohm@0
   442
by (REPEAT (etac allE 1));
paulson@2469
   443
by (Fast_tac 1);
clasohm@0
   444
result();
clasohm@0
   445
****)
clasohm@0
   446
clasohm@0
   447
(*Non-equational version, from Manthey and Bry, CADE-9 (Springer, 1988).
clasohm@0
   448
  fast_tac DISCOVERS who killed Agatha. *)
clasohm@0
   449
goal FOL.thy "lives(agatha) & lives(butler) & lives(charles) & \
clasohm@0
   450
\  (killed(agatha,agatha) | killed(butler,agatha) | killed(charles,agatha)) & \
clasohm@0
   451
\  (ALL x y. killed(x,y) --> hates(x,y) & ~richer(x,y)) & \
clasohm@0
   452
\  (ALL x. hates(agatha,x) --> ~hates(charles,x)) & \
clasohm@0
   453
\  (hates(agatha,agatha) & hates(agatha,charles)) & \
clasohm@0
   454
\  (ALL x. lives(x) & ~richer(x,agatha) --> hates(butler,x)) & \
clasohm@0
   455
\  (ALL x. hates(agatha,x) --> hates(butler,x)) & \
clasohm@0
   456
\  (ALL x. ~hates(x,agatha) | ~hates(x,butler) | ~hates(x,charles)) --> \
clasohm@0
   457
\   killed(?who,agatha)";
paulson@2469
   458
by (Fast_tac 1);
clasohm@0
   459
result();
clasohm@0
   460
clasohm@0
   461
clasohm@0
   462
writeln"Problem 56";
clasohm@0
   463
goal FOL.thy
clasohm@0
   464
    "(ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))";
paulson@2469
   465
by (Fast_tac 1);
clasohm@0
   466
result();
clasohm@0
   467
clasohm@0
   468
writeln"Problem 57";
clasohm@0
   469
goal FOL.thy
clasohm@0
   470
    "P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) & \
clasohm@0
   471
\    (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))";
paulson@2469
   472
by (Fast_tac 1);
clasohm@0
   473
result();
clasohm@0
   474
clasohm@0
   475
writeln"Problem 58  NOT PROVED AUTOMATICALLY";
clasohm@0
   476
goal FOL.thy "(ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))";
paulson@2469
   477
by (slow_tac (!claset addEs [subst_context]) 1);
clasohm@0
   478
result();
clasohm@0
   479
clasohm@0
   480
writeln"Problem 59";
clasohm@0
   481
goal FOL.thy "(ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))";
paulson@2469
   482
by (Deepen_tac 0 1);
clasohm@0
   483
result();
clasohm@0
   484
clasohm@0
   485
writeln"Problem 60";
clasohm@0
   486
goal FOL.thy
clasohm@0
   487
    "ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))";
paulson@2469
   488
by (Fast_tac 1);
clasohm@0
   489
result();
clasohm@0
   490
paulson@2715
   491
writeln"Problem 62 as corrected in JAR 18 (1997), page 135";
paulson@1404
   492
goal FOL.thy
clasohm@1459
   493
    "(ALL x. p(a) & (p(x) --> p(f(x))) --> p(f(f(x))))  <->     \
clasohm@1459
   494
\    (ALL x. (~p(a) | p(x) | p(f(f(x)))) &                      \
paulson@1404
   495
\            (~p(a) | ~p(f(x)) | p(f(f(x)))))";
paulson@2469
   496
by (Fast_tac 1);
paulson@1404
   497
result();
paulson@1404
   498
paulson@1560
   499
(*Halting problem: Formulation of Li Dafa (AAR Newsletter 27, Oct 1994.)
paulson@1560
   500
	author U. Egly*)
paulson@1560
   501
goal FOL.thy
paulson@1560
   502
"((EX X. a(X) & (ALL Y. c(Y) --> (ALL Z. d(X, Y, Z)))) -->  \
paulson@1560
   503
\  (EX W. c(W) & (ALL Y. c(Y) --> (ALL Z. d(W, Y, Z)))))     \
paulson@1560
   504
\ &                                                          \
paulson@1560
   505
\ (ALL W. c(W) & (ALL U. c(U) --> (ALL V. d(W, U, V))) -->       \
paulson@1560
   506
\       (ALL Y Z.                                               \
paulson@1560
   507
\           (c(Y) & h2(Y, Z) --> h3(W, Y, Z) & o(W, g)) &       \
paulson@1560
   508
\           (c(Y) & ~h2(Y, Z) --> h3(W, Y, Z) & o(W, b))))  \
paulson@1560
   509
\ &                    \
paulson@1560
   510
\ (ALL W. c(W) &       \
paulson@1560
   511
\   (ALL Y Z.          \
paulson@1560
   512
\       (c(Y) & h2(Y, Z) --> h3(W, Y, Z) & o(W, g)) &       \
paulson@1560
   513
\       (c(Y) & ~h2(Y, Z) --> h3(W, Y, Z) & o(W, b))) -->       \
paulson@1560
   514
\   (EX V. c(V) &       \
paulson@1560
   515
\         (ALL Y. ((c(Y) & h3(W, Y, Y)) & o(W, g) --> ~h2(V, Y)) &       \
paulson@1560
   516
\                 ((c(Y) & h3(W, Y, Y)) & o(W, b) --> h2(V, Y) & o(V, b))))) \
paulson@1560
   517
\  -->                  \
paulson@1560
   518
\  ~ (EX X. a(X) & (ALL Y. c(Y) --> (ALL Z. d(X, Y, Z))))";
paulson@1560
   519
clasohm@0
   520
paulson@2614
   521
(* Challenge found on info-hol *)
paulson@2614
   522
goal FOL.thy
paulson@2614
   523
    "ALL x. EX v w. ALL y z. P(x) & Q(y) --> (P(v) | R(w)) & (R(z) --> Q(v))";
paulson@2614
   524
by (Deepen_tac 0 1);
paulson@2614
   525
result();
paulson@2614
   526
clasohm@0
   527
writeln"Reached end of file.";
clasohm@0
   528
lcp@732
   529
(*Thu Jul 23 1992: loaded in 467s using iffE [on SPARC2] *)
lcp@732
   530
(*Mon Nov 14 1994: loaded in 144s [on SPARC10, with deepen_tac] *)
lcp@732
   531
(*Wed Nov 16 1994: loaded in 138s [after addition of norm_term_skip] *)
lcp@732
   532
(*Mon Nov 21 1994: loaded in 131s [DEPTH_FIRST suppressing repetitions] *)
lcp@732
   533