src/FOLP/ex/cla.ML
author clasohm
Thu Sep 16 12:20:38 1993 +0200 (1993-09-16)
changeset 0 a5a9c433f639
child 1459 d12da312eff4
permissions -rw-r--r--
Initial revision
clasohm@0
     1
(*  Title: 	FOLP/ex/cla
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Classical First-Order Logic
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
writeln"File FOL/ex/cla.";
clasohm@0
    10
clasohm@0
    11
open Cla;    (*in case structure Int is open!*)
clasohm@0
    12
clasohm@0
    13
goal FOLP.thy "?p : (P --> Q | R) --> (P-->Q) | (P-->R)";
clasohm@0
    14
by (fast_tac FOLP_cs 1);
clasohm@0
    15
result();
clasohm@0
    16
clasohm@0
    17
(*If and only if*)
clasohm@0
    18
clasohm@0
    19
goal FOLP.thy "?p : (P<->Q) <-> (Q<->P)";
clasohm@0
    20
by (fast_tac FOLP_cs 1);
clasohm@0
    21
result();
clasohm@0
    22
clasohm@0
    23
goal FOLP.thy "?p : ~ (P <-> ~P)";
clasohm@0
    24
by (fast_tac FOLP_cs 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 FOLP.thy "?p : (P-->Q)  <->  (~Q --> ~P)";
clasohm@0
    41
by (fast_tac FOLP_cs 1);
clasohm@0
    42
result();
clasohm@0
    43
clasohm@0
    44
(*2*)
clasohm@0
    45
goal FOLP.thy "?p : ~ ~ P  <->  P";
clasohm@0
    46
by (fast_tac FOLP_cs 1);
clasohm@0
    47
result();
clasohm@0
    48
clasohm@0
    49
(*3*)
clasohm@0
    50
goal FOLP.thy "?p : ~(P-->Q) --> (Q-->P)";
clasohm@0
    51
by (fast_tac FOLP_cs 1);
clasohm@0
    52
result();
clasohm@0
    53
clasohm@0
    54
(*4*)
clasohm@0
    55
goal FOLP.thy "?p : (~P-->Q)  <->  (~Q --> P)";
clasohm@0
    56
by (fast_tac FOLP_cs 1);
clasohm@0
    57
result();
clasohm@0
    58
clasohm@0
    59
(*5*)
clasohm@0
    60
goal FOLP.thy "?p : ((P|Q)-->(P|R)) --> (P|(Q-->R))";
clasohm@0
    61
by (fast_tac FOLP_cs 1);
clasohm@0
    62
result();
clasohm@0
    63
clasohm@0
    64
(*6*)
clasohm@0
    65
goal FOLP.thy "?p : P | ~ P";
clasohm@0
    66
by (fast_tac FOLP_cs 1);
clasohm@0
    67
result();
clasohm@0
    68
clasohm@0
    69
(*7*)
clasohm@0
    70
goal FOLP.thy "?p : P | ~ ~ ~ P";
clasohm@0
    71
by (fast_tac FOLP_cs 1);
clasohm@0
    72
result();
clasohm@0
    73
clasohm@0
    74
(*8.  Peirce's law*)
clasohm@0
    75
goal FOLP.thy "?p : ((P-->Q) --> P)  -->  P";
clasohm@0
    76
by (fast_tac FOLP_cs 1);
clasohm@0
    77
result();
clasohm@0
    78
clasohm@0
    79
(*9*)
clasohm@0
    80
goal FOLP.thy "?p : ((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)";
clasohm@0
    81
by (fast_tac FOLP_cs 1);
clasohm@0
    82
result();
clasohm@0
    83
clasohm@0
    84
(*10*)
clasohm@0
    85
goal FOLP.thy "?p : (Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P<->Q)";
clasohm@0
    86
by (fast_tac FOLP_cs 1);
clasohm@0
    87
result();
clasohm@0
    88
clasohm@0
    89
(*11.  Proved in each direction (incorrectly, says Pelletier!!)  *)
clasohm@0
    90
goal FOLP.thy "?p : P<->P";
clasohm@0
    91
by (fast_tac FOLP_cs 1);
clasohm@0
    92
result();
clasohm@0
    93
clasohm@0
    94
(*12.  "Dijkstra's law"*)
clasohm@0
    95
goal FOLP.thy "?p : ((P <-> Q) <-> R)  <->  (P <-> (Q <-> R))";
clasohm@0
    96
by (fast_tac FOLP_cs 1);
clasohm@0
    97
result();
clasohm@0
    98
clasohm@0
    99
(*13.  Distributive law*)
clasohm@0
   100
goal FOLP.thy "?p : P | (Q & R)  <-> (P | Q) & (P | R)";
clasohm@0
   101
by (fast_tac FOLP_cs 1);
clasohm@0
   102
result();
clasohm@0
   103
clasohm@0
   104
(*14*)
clasohm@0
   105
goal FOLP.thy "?p : (P <-> Q) <-> ((Q | ~P) & (~Q|P))";
clasohm@0
   106
by (fast_tac FOLP_cs 1);
clasohm@0
   107
result();
clasohm@0
   108
clasohm@0
   109
(*15*)
clasohm@0
   110
goal FOLP.thy "?p : (P --> Q) <-> (~P | Q)";
clasohm@0
   111
by (fast_tac FOLP_cs 1);
clasohm@0
   112
result();
clasohm@0
   113
clasohm@0
   114
(*16*)
clasohm@0
   115
goal FOLP.thy "?p : (P-->Q) | (Q-->P)";
clasohm@0
   116
by (fast_tac FOLP_cs 1);
clasohm@0
   117
result();
clasohm@0
   118
clasohm@0
   119
(*17*)
clasohm@0
   120
goal FOLP.thy "?p : ((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S))";
clasohm@0
   121
by (fast_tac FOLP_cs 1);
clasohm@0
   122
result();
clasohm@0
   123
clasohm@0
   124
writeln"Classical Logic: examples with quantifiers";
clasohm@0
   125
clasohm@0
   126
goal FOLP.thy "?p : (ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))";
clasohm@0
   127
by (fast_tac FOLP_cs 1);
clasohm@0
   128
result(); 
clasohm@0
   129
clasohm@0
   130
goal FOLP.thy "?p : (EX x. P-->Q(x))  <->  (P --> (EX x.Q(x)))";
clasohm@0
   131
by (fast_tac FOLP_cs 1);
clasohm@0
   132
result(); 
clasohm@0
   133
clasohm@0
   134
goal FOLP.thy "?p : (EX x.P(x)-->Q)  <->  (ALL x.P(x)) --> Q";
clasohm@0
   135
by (fast_tac FOLP_cs 1);
clasohm@0
   136
result(); 
clasohm@0
   137
clasohm@0
   138
goal FOLP.thy "?p : (ALL x.P(x)) | Q  <->  (ALL x. P(x) | Q)";
clasohm@0
   139
by (fast_tac FOLP_cs 1);
clasohm@0
   140
result(); 
clasohm@0
   141
clasohm@0
   142
writeln"Problems requiring quantifier duplication";
clasohm@0
   143
clasohm@0
   144
(*Needs multiple instantiation of ALL.*)
clasohm@0
   145
(*
clasohm@0
   146
goal FOLP.thy "?p : (ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))";
clasohm@0
   147
by (best_tac FOLP_dup_cs 1);
clasohm@0
   148
result();
clasohm@0
   149
*)
clasohm@0
   150
(*Needs double instantiation of the quantifier*)
clasohm@0
   151
goal FOLP.thy "?p : EX x. P(x) --> P(a) & P(b)";
clasohm@0
   152
by (best_tac FOLP_dup_cs 1);
clasohm@0
   153
result();
clasohm@0
   154
clasohm@0
   155
goal FOLP.thy "?p : EX z. P(z) --> (ALL x. P(x))";
clasohm@0
   156
by (best_tac FOLP_dup_cs 1);
clasohm@0
   157
result();
clasohm@0
   158
clasohm@0
   159
clasohm@0
   160
writeln"Hard examples with quantifiers";
clasohm@0
   161
clasohm@0
   162
writeln"Problem 18";
clasohm@0
   163
goal FOLP.thy "?p : EX y. ALL x. P(y)-->P(x)";
clasohm@0
   164
by (best_tac FOLP_dup_cs 1);
clasohm@0
   165
result(); 
clasohm@0
   166
clasohm@0
   167
writeln"Problem 19";
clasohm@0
   168
goal FOLP.thy "?p : EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))";
clasohm@0
   169
by (best_tac FOLP_dup_cs 1);
clasohm@0
   170
result();
clasohm@0
   171
clasohm@0
   172
writeln"Problem 20";
clasohm@0
   173
goal FOLP.thy "?p : (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))     \
clasohm@0
   174
\   --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))";
clasohm@0
   175
by (fast_tac FOLP_cs 1); 
clasohm@0
   176
result();
clasohm@0
   177
(*
clasohm@0
   178
writeln"Problem 21";
clasohm@0
   179
goal FOLP.thy "?p : (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))";
clasohm@0
   180
by (best_tac FOLP_dup_cs 1);
clasohm@0
   181
result();
clasohm@0
   182
*)
clasohm@0
   183
writeln"Problem 22";
clasohm@0
   184
goal FOLP.thy "?p : (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))";
clasohm@0
   185
by (fast_tac FOLP_cs 1); 
clasohm@0
   186
result();
clasohm@0
   187
clasohm@0
   188
writeln"Problem 23";
clasohm@0
   189
goal FOLP.thy "?p : (ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))";
clasohm@0
   190
by (best_tac FOLP_cs 1);  
clasohm@0
   191
result();
clasohm@0
   192
clasohm@0
   193
writeln"Problem 24";
clasohm@0
   194
goal FOLP.thy "?p : ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &  \
clasohm@0
   195
\    ~(EX x.P(x)) --> (EX x.Q(x)) & (ALL x. Q(x)|R(x) --> S(x))  \
clasohm@0
   196
\   --> (EX x. P(x)&R(x))";
clasohm@0
   197
by (fast_tac FOLP_cs 1); 
clasohm@0
   198
result();
clasohm@0
   199
(*
clasohm@0
   200
writeln"Problem 25";
clasohm@0
   201
goal FOLP.thy "?p : (EX x. P(x)) &  \
clasohm@0
   202
\       (ALL x. L(x) --> ~ (M(x) & R(x))) &  \
clasohm@0
   203
\       (ALL x. P(x) --> (M(x) & L(x))) &   \
clasohm@0
   204
\       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  \
clasohm@0
   205
\   --> (EX x. Q(x)&P(x))";
clasohm@0
   206
by (best_tac FOLP_cs 1); 
clasohm@0
   207
result();
clasohm@0
   208
clasohm@0
   209
writeln"Problem 26";
clasohm@0
   210
goal FOLP.thy "?u : ((EX x. p(x)) <-> (EX x. q(x))) &	\
clasohm@0
   211
\     (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))	\
clasohm@0
   212
\ --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))";
clasohm@0
   213
by (fast_tac FOLP_cs 1);
clasohm@0
   214
result();
clasohm@0
   215
*)
clasohm@0
   216
writeln"Problem 27";
clasohm@0
   217
goal FOLP.thy "?p : (EX x. P(x) & ~Q(x)) &   \
clasohm@0
   218
\             (ALL x. P(x) --> R(x)) &   \
clasohm@0
   219
\             (ALL x. M(x) & L(x) --> P(x)) &   \
clasohm@0
   220
\             ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))  \
clasohm@0
   221
\         --> (ALL x. M(x) --> ~L(x))";
clasohm@0
   222
by (fast_tac FOLP_cs 1); 
clasohm@0
   223
result();
clasohm@0
   224
clasohm@0
   225
writeln"Problem 28.  AMENDED";
clasohm@0
   226
goal FOLP.thy "?p : (ALL x. P(x) --> (ALL x. Q(x))) &   \
clasohm@0
   227
\       ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &  \
clasohm@0
   228
\       ((EX x.S(x)) --> (ALL x. L(x) --> M(x)))  \
clasohm@0
   229
\   --> (ALL x. P(x) & L(x) --> M(x))";
clasohm@0
   230
by (fast_tac FOLP_cs 1);  
clasohm@0
   231
result();
clasohm@0
   232
clasohm@0
   233
writeln"Problem 29.  Essentially the same as Principia Mathematica *11.71";
clasohm@0
   234
goal FOLP.thy "?p : (EX x. P(x)) & (EX y. Q(y))  \
clasohm@0
   235
\   --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->     \
clasohm@0
   236
\        (ALL x y. P(x) & Q(y) --> R(x) & S(y)))";
clasohm@0
   237
by (fast_tac FOLP_cs 1); 
clasohm@0
   238
result();
clasohm@0
   239
clasohm@0
   240
writeln"Problem 30";
clasohm@0
   241
goal FOLP.thy "?p : (ALL x. P(x) | Q(x) --> ~ R(x)) & \
clasohm@0
   242
\       (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))  \
clasohm@0
   243
\   --> (ALL x. S(x))";
clasohm@0
   244
by (fast_tac FOLP_cs 1);  
clasohm@0
   245
result();
clasohm@0
   246
clasohm@0
   247
writeln"Problem 31";
clasohm@0
   248
goal FOLP.thy "?p : ~(EX x.P(x) & (Q(x) | R(x))) & \
clasohm@0
   249
\       (EX x. L(x) & P(x)) & \
clasohm@0
   250
\       (ALL x. ~ R(x) --> M(x))  \
clasohm@0
   251
\   --> (EX x. L(x) & M(x))";
clasohm@0
   252
by (fast_tac FOLP_cs 1);
clasohm@0
   253
result();
clasohm@0
   254
clasohm@0
   255
writeln"Problem 32";
clasohm@0
   256
goal FOLP.thy "?p : (ALL x. P(x) & (Q(x)|R(x))-->S(x)) & \
clasohm@0
   257
\       (ALL x. S(x) & R(x) --> L(x)) & \
clasohm@0
   258
\       (ALL x. M(x) --> R(x))  \
clasohm@0
   259
\   --> (ALL x. P(x) & M(x) --> L(x))";
clasohm@0
   260
by (best_tac FOLP_cs 1);
clasohm@0
   261
result();
clasohm@0
   262
clasohm@0
   263
writeln"Problem 33";
clasohm@0
   264
goal FOLP.thy "?p : (ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->    \
clasohm@0
   265
\    (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))";
clasohm@0
   266
by (best_tac FOLP_cs 1);
clasohm@0
   267
result();
clasohm@0
   268
clasohm@0
   269
writeln"Problem 35";
clasohm@0
   270
goal FOLP.thy "?p : EX x y. P(x,y) -->  (ALL u v. P(u,v))";
clasohm@0
   271
by (best_tac FOLP_dup_cs 1);
clasohm@0
   272
result();
clasohm@0
   273
clasohm@0
   274
writeln"Problem 36";
clasohm@0
   275
goal FOLP.thy
clasohm@0
   276
"?p : (ALL x. EX y. J(x,y)) & \
clasohm@0
   277
\     (ALL x. EX y. G(x,y)) & \
clasohm@0
   278
\     (ALL x y. J(x,y) | G(x,y) --> (ALL z. J(y,z) | G(y,z) --> H(x,z)))   \
clasohm@0
   279
\ --> (ALL x. EX y. H(x,y))";
clasohm@0
   280
by (fast_tac FOLP_cs 1);
clasohm@0
   281
result();
clasohm@0
   282
clasohm@0
   283
writeln"Problem 37";
clasohm@0
   284
goal FOLP.thy "?p : (ALL z. EX w. ALL x. EX y. \
clasohm@0
   285
\          (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u.Q(u,w)))) & \
clasohm@0
   286
\       (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) & \
clasohm@0
   287
\       ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))  \
clasohm@0
   288
\   --> (ALL x. EX y. R(x,y))";
clasohm@0
   289
by (fast_tac FOLP_cs 1);
clasohm@0
   290
result();
clasohm@0
   291
clasohm@0
   292
writeln"Problem 39";
clasohm@0
   293
goal FOLP.thy "?p : ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
clasohm@0
   294
by (fast_tac FOLP_cs 1);
clasohm@0
   295
result();
clasohm@0
   296
clasohm@0
   297
writeln"Problem 40.  AMENDED";
clasohm@0
   298
goal FOLP.thy "?p : (EX y. ALL x. F(x,y) <-> F(x,x)) -->  \
clasohm@0
   299
\             ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))";
clasohm@0
   300
by (fast_tac FOLP_cs 1);
clasohm@0
   301
result();
clasohm@0
   302
clasohm@0
   303
writeln"Problem 41";
clasohm@0
   304
goal FOLP.thy "?p : (ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))	\
clasohm@0
   305
\         --> ~ (EX z. ALL x. f(x,z))";
clasohm@0
   306
by (best_tac FOLP_cs 1);
clasohm@0
   307
result();
clasohm@0
   308
clasohm@0
   309
writeln"Problem 44";
clasohm@0
   310
goal FOLP.thy "?p : (ALL x. f(x) -->					\
clasohm@0
   311
\             (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &   	\
clasohm@0
   312
\             (EX x. j(x) & (ALL y. g(y) --> h(x,y)))			\
clasohm@0
   313
\             --> (EX x. j(x) & ~f(x))";
clasohm@0
   314
by (fast_tac FOLP_cs 1);
clasohm@0
   315
result();
clasohm@0
   316
clasohm@0
   317
writeln"Problems (mainly) involving equality or functions";
clasohm@0
   318
clasohm@0
   319
writeln"Problem 48";
clasohm@0
   320
goal FOLP.thy "?p : (a=b | c=d) & (a=c | b=d) --> a=d | b=c";
clasohm@0
   321
by (fast_tac FOLP_cs 1);
clasohm@0
   322
result();
clasohm@0
   323
clasohm@0
   324
writeln"Problem 50";  
clasohm@0
   325
(*What has this to do with equality?*)
clasohm@0
   326
goal FOLP.thy "?p : (ALL x. P(a,x) | (ALL y.P(x,y))) --> (EX x. ALL y.P(x,y))";
clasohm@0
   327
by (best_tac FOLP_dup_cs 1);
clasohm@0
   328
result();
clasohm@0
   329
clasohm@0
   330
writeln"Problem 56";
clasohm@0
   331
goal FOLP.thy
clasohm@0
   332
 "?p : (ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))";
clasohm@0
   333
by (fast_tac FOLP_cs 1);
clasohm@0
   334
result();
clasohm@0
   335
clasohm@0
   336
writeln"Problem 57";
clasohm@0
   337
goal FOLP.thy
clasohm@0
   338
"?p : P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) & \
clasohm@0
   339
\     (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))";
clasohm@0
   340
by (fast_tac FOLP_cs 1);
clasohm@0
   341
result();
clasohm@0
   342
clasohm@0
   343
writeln"Problem 58  NOT PROVED AUTOMATICALLY";
clasohm@0
   344
goal FOLP.thy "?p : (ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))";
clasohm@0
   345
val f_cong = read_instantiate [("t","f")] subst_context;
clasohm@0
   346
by (fast_tac (FOLP_cs addIs [f_cong]) 1);
clasohm@0
   347
result();
clasohm@0
   348
clasohm@0
   349
writeln"Problem 59";
clasohm@0
   350
goal FOLP.thy "?p : (ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))";
clasohm@0
   351
by (best_tac FOLP_dup_cs 1);
clasohm@0
   352
result();
clasohm@0
   353
clasohm@0
   354
writeln"Problem 60";
clasohm@0
   355
goal FOLP.thy
clasohm@0
   356
"?p : ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))";
clasohm@0
   357
by (fast_tac FOLP_cs 1);
clasohm@0
   358
result();
clasohm@0
   359
clasohm@0
   360
writeln"Reached end of file.";