src/HOL/ex/Classical.thy
author haftmann
Wed Mar 12 19:38:14 2008 +0100 (2008-03-12)
changeset 26265 4b63b9e9b10d
parent 24300 e170cee91c66
child 30607 c3d1590debd8
permissions -rw-r--r--
separated Random.thy from Quickcheck.thy
paulson@14220
     1
(*  Title:      HOL/ex/Classical
paulson@14220
     2
    ID:         $Id$
paulson@14220
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@14220
     4
    Copyright   1994  University of Cambridge
paulson@14220
     5
*)
paulson@14220
     6
paulson@14220
     7
header{*Classical Predicate Calculus Problems*}
paulson@14220
     8
haftmann@16417
     9
theory Classical imports Main begin
paulson@14220
    10
paulson@14220
    11
subsection{*Traditional Classical Reasoner*}
paulson@14220
    12
paulson@16011
    13
text{*The machine "griffon" mentioned below is a 2.5GHz Power Mac G5.*}
paulson@16011
    14
paulson@14249
    15
text{*Taken from @{text "FOL/Classical.thy"}. When porting examples from
paulson@14249
    16
first-order logic, beware of the precedence of @{text "="} versus @{text
paulson@14249
    17
"\<leftrightarrow>"}.*}
paulson@14220
    18
paulson@14220
    19
lemma "(P --> Q | R) --> (P-->Q) | (P-->R)"
paulson@14220
    20
by blast
paulson@14220
    21
paulson@14220
    22
text{*If and only if*}
paulson@14220
    23
paulson@14220
    24
lemma "(P=Q) = (Q = (P::bool))"
paulson@14220
    25
by blast
paulson@14220
    26
paulson@14220
    27
lemma "~ (P = (~P))"
paulson@14220
    28
by blast
paulson@14220
    29
paulson@14220
    30
paulson@14249
    31
text{*Sample problems from
paulson@14249
    32
  F. J. Pelletier,
paulson@14220
    33
  Seventy-Five Problems for Testing Automatic Theorem Provers,
paulson@14220
    34
  J. Automated Reasoning 2 (1986), 191-216.
paulson@14220
    35
  Errata, JAR 4 (1988), 236-236.
paulson@14220
    36
paulson@14220
    37
The hardest problems -- judging by experience with several theorem provers,
paulson@14220
    38
including matrix ones -- are 34 and 43.
paulson@14220
    39
*}
paulson@14220
    40
paulson@14220
    41
subsubsection{*Pelletier's examples*}
paulson@14220
    42
paulson@14220
    43
text{*1*}
paulson@14220
    44
lemma "(P-->Q)  =  (~Q --> ~P)"
paulson@14220
    45
by blast
paulson@14220
    46
paulson@14220
    47
text{*2*}
paulson@14220
    48
lemma "(~ ~ P) =  P"
paulson@14220
    49
by blast
paulson@14220
    50
paulson@14220
    51
text{*3*}
paulson@14220
    52
lemma "~(P-->Q) --> (Q-->P)"
paulson@14220
    53
by blast
paulson@14220
    54
paulson@14220
    55
text{*4*}
paulson@14220
    56
lemma "(~P-->Q)  =  (~Q --> P)"
paulson@14220
    57
by blast
paulson@14220
    58
paulson@14220
    59
text{*5*}
paulson@14220
    60
lemma "((P|Q)-->(P|R)) --> (P|(Q-->R))"
paulson@14220
    61
by blast
paulson@14220
    62
paulson@14220
    63
text{*6*}
paulson@14220
    64
lemma "P | ~ P"
paulson@14220
    65
by blast
paulson@14220
    66
paulson@14220
    67
text{*7*}
paulson@14220
    68
lemma "P | ~ ~ ~ P"
paulson@14220
    69
by blast
paulson@14220
    70
paulson@14220
    71
text{*8.  Peirce's law*}
paulson@14220
    72
lemma "((P-->Q) --> P)  -->  P"
paulson@14220
    73
by blast
paulson@14220
    74
paulson@14220
    75
text{*9*}
paulson@14220
    76
lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
paulson@14220
    77
by blast
paulson@14220
    78
paulson@14220
    79
text{*10*}
paulson@14220
    80
lemma "(Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P=Q)"
paulson@14220
    81
by blast
paulson@14220
    82
paulson@14220
    83
text{*11.  Proved in each direction (incorrectly, says Pelletier!!)  *}
paulson@14220
    84
lemma "P=(P::bool)"
paulson@14220
    85
by blast
paulson@14220
    86
paulson@14220
    87
text{*12.  "Dijkstra's law"*}
paulson@14220
    88
lemma "((P = Q) = R) = (P = (Q = R))"
paulson@14220
    89
by blast
paulson@14220
    90
paulson@14220
    91
text{*13.  Distributive law*}
paulson@14220
    92
lemma "(P | (Q & R)) = ((P | Q) & (P | R))"
paulson@14220
    93
by blast
paulson@14220
    94
paulson@14220
    95
text{*14*}
paulson@14220
    96
lemma "(P = Q) = ((Q | ~P) & (~Q|P))"
paulson@14220
    97
by blast
paulson@14220
    98
paulson@14220
    99
text{*15*}
paulson@14220
   100
lemma "(P --> Q) = (~P | Q)"
paulson@14220
   101
by blast
paulson@14220
   102
paulson@14220
   103
text{*16*}
paulson@14220
   104
lemma "(P-->Q) | (Q-->P)"
paulson@14220
   105
by blast
paulson@14220
   106
paulson@14220
   107
text{*17*}
paulson@14220
   108
lemma "((P & (Q-->R))-->S)  =  ((~P | Q | S) & (~P | ~R | S))"
paulson@14220
   109
by blast
paulson@14220
   110
paulson@14220
   111
subsubsection{*Classical Logic: examples with quantifiers*}
paulson@14220
   112
paulson@14220
   113
lemma "(\<forall>x. P(x) & Q(x)) = ((\<forall>x. P(x)) & (\<forall>x. Q(x)))"
paulson@14220
   114
by blast
paulson@14220
   115
paulson@14220
   116
lemma "(\<exists>x. P-->Q(x))  =  (P --> (\<exists>x. Q(x)))"
paulson@14220
   117
by blast
paulson@14220
   118
paulson@14220
   119
lemma "(\<exists>x. P(x)-->Q) = ((\<forall>x. P(x)) --> Q)"
paulson@14220
   120
by blast
paulson@14220
   121
paulson@14220
   122
lemma "((\<forall>x. P(x)) | Q)  =  (\<forall>x. P(x) | Q)"
paulson@14220
   123
by blast
paulson@14220
   124
paulson@14220
   125
text{*From Wishnu Prasetya*}
paulson@14249
   126
lemma "(\<forall>s. q(s) --> r(s)) & ~r(s) & (\<forall>s. ~r(s) & ~q(s) --> p(t) | q(t))
paulson@14220
   127
    --> p(t) | r(t)"
paulson@14220
   128
by blast
paulson@14220
   129
paulson@14220
   130
paulson@14220
   131
subsubsection{*Problems requiring quantifier duplication*}
paulson@14220
   132
paulson@14249
   133
text{*Theorem B of Peter Andrews, Theorem Proving via General Matings,
paulson@14220
   134
  JACM 28 (1981).*}
paulson@14220
   135
lemma "(\<exists>x. \<forall>y. P(x) = P(y)) --> ((\<exists>x. P(x)) = (\<forall>y. P(y)))"
paulson@14220
   136
by blast
paulson@14220
   137
paulson@14220
   138
text{*Needs multiple instantiation of the quantifier.*}
paulson@14220
   139
lemma "(\<forall>x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))"
paulson@14220
   140
by blast
paulson@14220
   141
paulson@14220
   142
text{*Needs double instantiation of the quantifier*}
paulson@14220
   143
lemma "\<exists>x. P(x) --> P(a) & P(b)"
paulson@14220
   144
by blast
paulson@14220
   145
paulson@14220
   146
lemma "\<exists>z. P(z) --> (\<forall>x. P(x))"
paulson@14220
   147
by blast
paulson@14220
   148
paulson@14220
   149
lemma "\<exists>x. (\<exists>y. P(y)) --> P(x)"
paulson@14220
   150
by blast
paulson@14220
   151
paulson@14220
   152
subsubsection{*Hard examples with quantifiers*}
paulson@14220
   153
paulson@14220
   154
text{*Problem 18*}
paulson@14220
   155
lemma "\<exists>y. \<forall>x. P(y)-->P(x)"
paulson@14220
   156
by blast
paulson@14220
   157
paulson@14220
   158
text{*Problem 19*}
paulson@14220
   159
lemma "\<exists>x. \<forall>y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
paulson@14220
   160
by blast
paulson@14220
   161
paulson@14220
   162
text{*Problem 20*}
paulson@14249
   163
lemma "(\<forall>x y. \<exists>z. \<forall>w. (P(x)&Q(y)-->R(z)&S(w)))
paulson@14220
   164
    --> (\<exists>x y. P(x) & Q(y)) --> (\<exists>z. R(z))"
paulson@14220
   165
by blast
paulson@14220
   166
paulson@14220
   167
text{*Problem 21*}
paulson@14220
   168
lemma "(\<exists>x. P-->Q(x)) & (\<exists>x. Q(x)-->P) --> (\<exists>x. P=Q(x))"
paulson@14220
   169
by blast
paulson@14220
   170
paulson@14220
   171
text{*Problem 22*}
paulson@14220
   172
lemma "(\<forall>x. P = Q(x))  -->  (P = (\<forall>x. Q(x)))"
paulson@14220
   173
by blast
paulson@14220
   174
paulson@14220
   175
text{*Problem 23*}
paulson@14220
   176
lemma "(\<forall>x. P | Q(x))  =  (P | (\<forall>x. Q(x)))"
paulson@14220
   177
by blast
paulson@14220
   178
paulson@14220
   179
text{*Problem 24*}
paulson@14249
   180
lemma "~(\<exists>x. S(x)&Q(x)) & (\<forall>x. P(x) --> Q(x)|R(x)) &
paulson@14249
   181
     (~(\<exists>x. P(x)) --> (\<exists>x. Q(x))) & (\<forall>x. Q(x)|R(x) --> S(x))
paulson@14220
   182
    --> (\<exists>x. P(x)&R(x))"
paulson@14220
   183
by blast
paulson@14220
   184
paulson@14220
   185
text{*Problem 25*}
paulson@14249
   186
lemma "(\<exists>x. P(x)) &
paulson@14249
   187
        (\<forall>x. L(x) --> ~ (M(x) & R(x))) &
paulson@14249
   188
        (\<forall>x. P(x) --> (M(x) & L(x))) &
paulson@14249
   189
        ((\<forall>x. P(x)-->Q(x)) | (\<exists>x. P(x)&R(x)))
paulson@14220
   190
    --> (\<exists>x. Q(x)&P(x))"
paulson@14220
   191
by blast
paulson@14220
   192
paulson@14220
   193
text{*Problem 26*}
paulson@14249
   194
lemma "((\<exists>x. p(x)) = (\<exists>x. q(x))) &
paulson@14249
   195
      (\<forall>x. \<forall>y. p(x) & q(y) --> (r(x) = s(y)))
paulson@14220
   196
  --> ((\<forall>x. p(x)-->r(x)) = (\<forall>x. q(x)-->s(x)))"
paulson@14220
   197
by blast
paulson@14220
   198
paulson@14220
   199
text{*Problem 27*}
paulson@14249
   200
lemma "(\<exists>x. P(x) & ~Q(x)) &
paulson@14249
   201
              (\<forall>x. P(x) --> R(x)) &
paulson@14249
   202
              (\<forall>x. M(x) & L(x) --> P(x)) &
paulson@14249
   203
              ((\<exists>x. R(x) & ~ Q(x)) --> (\<forall>x. L(x) --> ~ R(x)))
paulson@14220
   204
          --> (\<forall>x. M(x) --> ~L(x))"
paulson@14220
   205
by blast
paulson@14220
   206
paulson@14220
   207
text{*Problem 28.  AMENDED*}
paulson@14249
   208
lemma "(\<forall>x. P(x) --> (\<forall>x. Q(x))) &
paulson@14249
   209
        ((\<forall>x. Q(x)|R(x)) --> (\<exists>x. Q(x)&S(x))) &
paulson@14249
   210
        ((\<exists>x. S(x)) --> (\<forall>x. L(x) --> M(x)))
paulson@14220
   211
    --> (\<forall>x. P(x) & L(x) --> M(x))"
paulson@14220
   212
by blast
paulson@14220
   213
paulson@14220
   214
text{*Problem 29.  Essentially the same as Principia Mathematica *11.71*}
paulson@14249
   215
lemma "(\<exists>x. F(x)) & (\<exists>y. G(y))
paulson@14249
   216
    --> ( ((\<forall>x. F(x)-->H(x)) & (\<forall>y. G(y)-->J(y)))  =
paulson@14220
   217
          (\<forall>x y. F(x) & G(y) --> H(x) & J(y)))"
paulson@14220
   218
by blast
paulson@14220
   219
paulson@14220
   220
text{*Problem 30*}
paulson@14249
   221
lemma "(\<forall>x. P(x) | Q(x) --> ~ R(x)) &
paulson@14249
   222
        (\<forall>x. (Q(x) --> ~ S(x)) --> P(x) & R(x))
paulson@14220
   223
    --> (\<forall>x. S(x))"
paulson@14220
   224
by blast
paulson@14220
   225
paulson@14220
   226
text{*Problem 31*}
paulson@14249
   227
lemma "~(\<exists>x. P(x) & (Q(x) | R(x))) &
paulson@14249
   228
        (\<exists>x. L(x) & P(x)) &
paulson@14249
   229
        (\<forall>x. ~ R(x) --> M(x))
paulson@14220
   230
    --> (\<exists>x. L(x) & M(x))"
paulson@14220
   231
by blast
paulson@14220
   232
paulson@14220
   233
text{*Problem 32*}
paulson@14249
   234
lemma "(\<forall>x. P(x) & (Q(x)|R(x))-->S(x)) &
paulson@14249
   235
        (\<forall>x. S(x) & R(x) --> L(x)) &
paulson@14249
   236
        (\<forall>x. M(x) --> R(x))
paulson@14220
   237
    --> (\<forall>x. P(x) & M(x) --> L(x))"
paulson@14220
   238
by blast
paulson@14220
   239
paulson@14220
   240
text{*Problem 33*}
paulson@14249
   241
lemma "(\<forall>x. P(a) & (P(x)-->P(b))-->P(c))  =
paulson@14220
   242
     (\<forall>x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))"
paulson@14220
   243
by blast
paulson@14220
   244
paulson@14220
   245
text{*Problem 34  AMENDED (TWICE!!)*}
paulson@14220
   246
text{*Andrews's challenge*}
paulson@14249
   247
lemma "((\<exists>x. \<forall>y. p(x) = p(y))  =
paulson@14249
   248
               ((\<exists>x. q(x)) = (\<forall>y. p(y))))   =
paulson@14249
   249
              ((\<exists>x. \<forall>y. q(x) = q(y))  =
paulson@14220
   250
               ((\<exists>x. p(x)) = (\<forall>y. q(y))))"
paulson@14220
   251
by blast
paulson@14220
   252
paulson@14220
   253
text{*Problem 35*}
paulson@14220
   254
lemma "\<exists>x y. P x y -->  (\<forall>u v. P u v)"
paulson@14220
   255
by blast
paulson@14220
   256
paulson@14220
   257
text{*Problem 36*}
paulson@14249
   258
lemma "(\<forall>x. \<exists>y. J x y) &
paulson@14249
   259
        (\<forall>x. \<exists>y. G x y) &
paulson@14249
   260
        (\<forall>x y. J x y | G x y -->
paulson@14249
   261
        (\<forall>z. J y z | G y z --> H x z))
paulson@14220
   262
    --> (\<forall>x. \<exists>y. H x y)"
paulson@14220
   263
by blast
paulson@14220
   264
paulson@14220
   265
text{*Problem 37*}
paulson@14249
   266
lemma "(\<forall>z. \<exists>w. \<forall>x. \<exists>y.
paulson@14249
   267
           (P x z -->P y w) & P y z & (P y w --> (\<exists>u. Q u w))) &
paulson@14249
   268
        (\<forall>x z. ~(P x z) --> (\<exists>y. Q y z)) &
paulson@14249
   269
        ((\<exists>x y. Q x y) --> (\<forall>x. R x x))
paulson@14220
   270
    --> (\<forall>x. \<exists>y. R x y)"
paulson@14220
   271
by blast
paulson@14220
   272
paulson@14220
   273
text{*Problem 38*}
paulson@14249
   274
lemma "(\<forall>x. p(a) & (p(x) --> (\<exists>y. p(y) & r x y)) -->
paulson@14249
   275
           (\<exists>z. \<exists>w. p(z) & r x w & r w z))  =
paulson@14249
   276
     (\<forall>x. (~p(a) | p(x) | (\<exists>z. \<exists>w. p(z) & r x w & r w z)) &
paulson@14249
   277
           (~p(a) | ~(\<exists>y. p(y) & r x y) |
paulson@14220
   278
            (\<exists>z. \<exists>w. p(z) & r x w & r w z)))"
paulson@14220
   279
by blast (*beats fast!*)
paulson@14220
   280
paulson@14220
   281
text{*Problem 39*}
paulson@14220
   282
lemma "~ (\<exists>x. \<forall>y. F y x = (~ F y y))"
paulson@14220
   283
by blast
paulson@14220
   284
paulson@14220
   285
text{*Problem 40.  AMENDED*}
paulson@14249
   286
lemma "(\<exists>y. \<forall>x. F x y = F x x)
paulson@14220
   287
        -->  ~ (\<forall>x. \<exists>y. \<forall>z. F z y = (~ F z x))"
paulson@14220
   288
by blast
paulson@14220
   289
paulson@14220
   290
text{*Problem 41*}
paulson@14249
   291
lemma "(\<forall>z. \<exists>y. \<forall>x. f x y = (f x z & ~ f x x))
paulson@14220
   292
               --> ~ (\<exists>z. \<forall>x. f x z)"
paulson@14220
   293
by blast
paulson@14220
   294
paulson@14220
   295
text{*Problem 42*}
paulson@14220
   296
lemma "~ (\<exists>y. \<forall>x. p x y = (~ (\<exists>z. p x z & p z x)))"
paulson@14220
   297
by blast
paulson@14220
   298
paulson@14220
   299
text{*Problem 43!!*}
paulson@14249
   300
lemma "(\<forall>x::'a. \<forall>y::'a. q x y = (\<forall>z. p z x = (p z y::bool)))
paulson@14220
   301
  --> (\<forall>x. (\<forall>y. q x y = (q y x::bool)))"
paulson@14220
   302
by blast
paulson@14220
   303
paulson@14220
   304
text{*Problem 44*}
paulson@14249
   305
lemma "(\<forall>x. f(x) -->
paulson@14249
   306
              (\<exists>y. g(y) & h x y & (\<exists>y. g(y) & ~ h x y)))  &
paulson@14249
   307
              (\<exists>x. j(x) & (\<forall>y. g(y) --> h x y))
paulson@14220
   308
              --> (\<exists>x. j(x) & ~f(x))"
paulson@14220
   309
by blast
paulson@14220
   310
paulson@14220
   311
text{*Problem 45*}
paulson@14249
   312
lemma "(\<forall>x. f(x) & (\<forall>y. g(y) & h x y --> j x y)
paulson@14249
   313
                      --> (\<forall>y. g(y) & h x y --> k(y))) &
paulson@14249
   314
     ~ (\<exists>y. l(y) & k(y)) &
paulson@14249
   315
     (\<exists>x. f(x) & (\<forall>y. h x y --> l(y))
paulson@14249
   316
                & (\<forall>y. g(y) & h x y --> j x y))
paulson@14220
   317
      --> (\<exists>x. f(x) & ~ (\<exists>y. g(y) & h x y))"
paulson@14220
   318
by blast
paulson@14220
   319
paulson@14220
   320
paulson@14220
   321
subsubsection{*Problems (mainly) involving equality or functions*}
paulson@14220
   322
paulson@14220
   323
text{*Problem 48*}
paulson@14220
   324
lemma "(a=b | c=d) & (a=c | b=d) --> a=d | b=c"
paulson@14220
   325
by blast
paulson@14220
   326
paulson@14249
   327
text{*Problem 49  NOT PROVED AUTOMATICALLY.
paulson@14249
   328
     Hard because it involves substitution for Vars
paulson@14220
   329
  the type constraint ensures that x,y,z have the same type as a,b,u. *}
paulson@14249
   330
lemma "(\<exists>x y::'a. \<forall>z. z=x | z=y) & P(a) & P(b) & (~a=b)
paulson@14220
   331
                --> (\<forall>u::'a. P(u))"
paulson@23508
   332
by metis
paulson@14220
   333
paulson@14220
   334
text{*Problem 50.  (What has this to do with equality?) *}
paulson@14220
   335
lemma "(\<forall>x. P a x | (\<forall>y. P x y)) --> (\<exists>x. \<forall>y. P x y)"
paulson@14220
   336
by blast
paulson@14220
   337
paulson@14220
   338
text{*Problem 51*}
paulson@14249
   339
lemma "(\<exists>z w. \<forall>x y. P x y = (x=z & y=w)) -->
paulson@14220
   340
     (\<exists>z. \<forall>x. \<exists>w. (\<forall>y. P x y = (y=w)) = (x=z))"
paulson@14220
   341
by blast
paulson@14220
   342
paulson@14220
   343
text{*Problem 52. Almost the same as 51. *}
paulson@14249
   344
lemma "(\<exists>z w. \<forall>x y. P x y = (x=z & y=w)) -->
paulson@14220
   345
     (\<exists>w. \<forall>y. \<exists>z. (\<forall>x. P x y = (x=z)) = (y=w))"
paulson@14220
   346
by blast
paulson@14220
   347
paulson@14220
   348
text{*Problem 55*}
paulson@14220
   349
paulson@14220
   350
text{*Non-equational version, from Manthey and Bry, CADE-9 (Springer, 1988).
paulson@14220
   351
  fast DISCOVERS who killed Agatha. *}
paulson@14249
   352
lemma "lives(agatha) & lives(butler) & lives(charles) &
paulson@14249
   353
   (killed agatha agatha | killed butler agatha | killed charles agatha) &
paulson@14249
   354
   (\<forall>x y. killed x y --> hates x y & ~richer x y) &
paulson@14249
   355
   (\<forall>x. hates agatha x --> ~hates charles x) &
paulson@14249
   356
   (hates agatha agatha & hates agatha charles) &
paulson@14249
   357
   (\<forall>x. lives(x) & ~richer x agatha --> hates butler x) &
paulson@14249
   358
   (\<forall>x. hates agatha x --> hates butler x) &
paulson@14249
   359
   (\<forall>x. ~hates x agatha | ~hates x butler | ~hates x charles) -->
paulson@14220
   360
    killed ?who agatha"
paulson@14220
   361
by fast
paulson@14220
   362
paulson@14220
   363
text{*Problem 56*}
paulson@14220
   364
lemma "(\<forall>x. (\<exists>y. P(y) & x=f(y)) --> P(x)) = (\<forall>x. P(x) --> P(f(x)))"
paulson@14220
   365
by blast
paulson@14220
   366
paulson@14220
   367
text{*Problem 57*}
paulson@14249
   368
lemma "P (f a b) (f b c) & P (f b c) (f a c) &
paulson@14220
   369
     (\<forall>x y z. P x y & P y z --> P x z)    -->   P (f a b) (f a c)"
paulson@14220
   370
by blast
paulson@14220
   371
paulson@14220
   372
text{*Problem 58  NOT PROVED AUTOMATICALLY*}
paulson@14220
   373
lemma "(\<forall>x y. f(x)=g(y)) --> (\<forall>x y. f(f(x))=f(g(y)))"
paulson@14220
   374
by (fast intro: arg_cong [of concl: f])
paulson@14220
   375
paulson@14220
   376
text{*Problem 59*}
paulson@14220
   377
lemma "(\<forall>x. P(x) = (~P(f(x)))) --> (\<exists>x. P(x) & ~P(f(x)))"
paulson@14220
   378
by blast
paulson@14220
   379
paulson@14220
   380
text{*Problem 60*}
paulson@14220
   381
lemma "\<forall>x. P x (f x) = (\<exists>y. (\<forall>z. P z y --> P z (f x)) & P x y)"
paulson@14220
   382
by blast
paulson@14220
   383
paulson@14220
   384
text{*Problem 62 as corrected in JAR 18 (1997), page 135*}
paulson@14249
   385
lemma "(\<forall>x. p a & (p x --> p(f x)) --> p(f(f x)))  =
paulson@14249
   386
      (\<forall>x. (~ p a | p x | p(f(f x))) &
paulson@14220
   387
              (~ p a | ~ p(f x) | p(f(f x))))"
paulson@14220
   388
by blast
paulson@14220
   389
paulson@14220
   390
text{*From Davis, Obvious Logical Inferences, IJCAI-81, 530-531
paulson@14220
   391
  fast indeed copes!*}
paulson@14249
   392
lemma "(\<forall>x. F(x) & ~G(x) --> (\<exists>y. H(x,y) & J(y))) &
paulson@14249
   393
       (\<exists>x. K(x) & F(x) & (\<forall>y. H(x,y) --> K(y))) &
paulson@14220
   394
       (\<forall>x. K(x) --> ~G(x))  -->  (\<exists>x. K(x) & J(x))"
paulson@14220
   395
by fast
paulson@14220
   396
paulson@14249
   397
text{*From Rudnicki, Obvious Inferences, JAR 3 (1987), 383-393.
paulson@14220
   398
  It does seem obvious!*}
paulson@14249
   399
lemma "(\<forall>x. F(x) & ~G(x) --> (\<exists>y. H(x,y) & J(y))) &
paulson@14249
   400
       (\<exists>x. K(x) & F(x) & (\<forall>y. H(x,y) --> K(y)))  &
paulson@14220
   401
       (\<forall>x. K(x) --> ~G(x))   -->   (\<exists>x. K(x) --> ~G(x))"
paulson@14220
   402
by fast
paulson@14220
   403
paulson@14249
   404
text{*Attributed to Lewis Carroll by S. G. Pulman.  The first or last
paulson@14220
   405
assumption can be deleted.*}
paulson@14249
   406
lemma "(\<forall>x. honest(x) & industrious(x) --> healthy(x)) &
paulson@14249
   407
      ~ (\<exists>x. grocer(x) & healthy(x)) &
paulson@14249
   408
      (\<forall>x. industrious(x) & grocer(x) --> honest(x)) &
paulson@14249
   409
      (\<forall>x. cyclist(x) --> industrious(x)) &
paulson@14249
   410
      (\<forall>x. ~healthy(x) & cyclist(x) --> ~honest(x))
paulson@14220
   411
      --> (\<forall>x. grocer(x) --> ~cyclist(x))"
paulson@14220
   412
by blast
paulson@14220
   413
paulson@14249
   414
lemma "(\<forall>x y. R(x,y) | R(y,x)) &
paulson@14249
   415
       (\<forall>x y. S(x,y) & S(y,x) --> x=y) &
paulson@14220
   416
       (\<forall>x y. R(x,y) --> S(x,y))    -->   (\<forall>x y. S(x,y) --> R(x,y))"
paulson@14220
   417
by blast
paulson@14220
   418
paulson@14220
   419
paulson@14220
   420
subsection{*Model Elimination Prover*}
paulson@14220
   421
paulson@16563
   422
paulson@16563
   423
text{*Trying out meson with arguments*}
paulson@16563
   424
lemma "x < y & y < z --> ~ (z < (x::nat))"
paulson@16563
   425
by (meson order_less_irrefl order_less_trans)
paulson@16563
   426
paulson@14220
   427
text{*The "small example" from Bezem, Hendriks and de Nivelle,
paulson@14220
   428
Automatic Proof Construction in Type Theory Using Resolution,
paulson@14220
   429
JAR 29: 3-4 (2002), pages 253-275 *}
paulson@14220
   430
lemma "(\<forall>x y z. R(x,y) & R(y,z) --> R(x,z)) &
paulson@14220
   431
       (\<forall>x. \<exists>y. R(x,y)) -->
paulson@14220
   432
       ~ (\<forall>x. P x = (\<forall>y. R(x,y) --> ~ P y))"
wenzelm@24300
   433
by (tactic{*Meson.safe_best_meson_tac 1*})
paulson@16011
   434
    --{*In contrast, @{text meson} is SLOW: 7.6s on griffon*}
paulson@14220
   435
paulson@14220
   436
paulson@14220
   437
subsubsection{*Pelletier's examples*}
paulson@14220
   438
text{*1*}
paulson@14220
   439
lemma "(P --> Q)  =  (~Q --> ~P)"
paulson@16011
   440
by blast
paulson@14220
   441
paulson@14220
   442
text{*2*}
paulson@14220
   443
lemma "(~ ~ P) =  P"
paulson@16011
   444
by blast
paulson@14220
   445
paulson@14220
   446
text{*3*}
paulson@14220
   447
lemma "~(P-->Q) --> (Q-->P)"
paulson@16011
   448
by blast
paulson@14220
   449
paulson@14220
   450
text{*4*}
paulson@14220
   451
lemma "(~P-->Q)  =  (~Q --> P)"
paulson@16011
   452
by blast
paulson@14220
   453
paulson@14220
   454
text{*5*}
paulson@14220
   455
lemma "((P|Q)-->(P|R)) --> (P|(Q-->R))"
paulson@16011
   456
by blast
paulson@14220
   457
paulson@14220
   458
text{*6*}
paulson@14220
   459
lemma "P | ~ P"
paulson@16011
   460
by blast
paulson@14220
   461
paulson@14220
   462
text{*7*}
paulson@14220
   463
lemma "P | ~ ~ ~ P"
paulson@16011
   464
by blast
paulson@14220
   465
paulson@14220
   466
text{*8.  Peirce's law*}
paulson@14220
   467
lemma "((P-->Q) --> P)  -->  P"
paulson@16011
   468
by blast
paulson@14220
   469
paulson@14220
   470
text{*9*}
paulson@14220
   471
lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
paulson@16011
   472
by blast
paulson@14220
   473
paulson@14220
   474
text{*10*}
paulson@14220
   475
lemma "(Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P=Q)"
paulson@16011
   476
by blast
paulson@14220
   477
paulson@14220
   478
text{*11.  Proved in each direction (incorrectly, says Pelletier!!)  *}
paulson@14220
   479
lemma "P=(P::bool)"
paulson@16011
   480
by blast
paulson@14220
   481
paulson@14220
   482
text{*12.  "Dijkstra's law"*}
paulson@14220
   483
lemma "((P = Q) = R) = (P = (Q = R))"
paulson@16011
   484
by blast
paulson@14220
   485
paulson@14220
   486
text{*13.  Distributive law*}
paulson@14220
   487
lemma "(P | (Q & R)) = ((P | Q) & (P | R))"
paulson@16011
   488
by blast
paulson@14220
   489
paulson@14220
   490
text{*14*}
paulson@14220
   491
lemma "(P = Q) = ((Q | ~P) & (~Q|P))"
paulson@16011
   492
by blast
paulson@14220
   493
paulson@14220
   494
text{*15*}
paulson@14220
   495
lemma "(P --> Q) = (~P | Q)"
paulson@16011
   496
by blast
paulson@14220
   497
paulson@14220
   498
text{*16*}
paulson@14220
   499
lemma "(P-->Q) | (Q-->P)"
paulson@16011
   500
by blast
paulson@14220
   501
paulson@14220
   502
text{*17*}
paulson@14220
   503
lemma "((P & (Q-->R))-->S)  =  ((~P | Q | S) & (~P | ~R | S))"
paulson@16011
   504
by blast
paulson@14220
   505
paulson@14220
   506
subsubsection{*Classical Logic: examples with quantifiers*}
paulson@14220
   507
paulson@14220
   508
lemma "(\<forall>x. P x & Q x) = ((\<forall>x. P x) & (\<forall>x. Q x))"
paulson@16011
   509
by blast
paulson@14220
   510
paulson@14220
   511
lemma "(\<exists>x. P --> Q x)  =  (P --> (\<exists>x. Q x))"
paulson@16011
   512
by blast
paulson@14220
   513
paulson@14220
   514
lemma "(\<exists>x. P x --> Q) = ((\<forall>x. P x) --> Q)"
paulson@16011
   515
by blast
paulson@14220
   516
paulson@14220
   517
lemma "((\<forall>x. P x) | Q)  =  (\<forall>x. P x | Q)"
paulson@16011
   518
by blast
paulson@14220
   519
paulson@14220
   520
lemma "(\<forall>x. P x --> P(f x))  &  P d --> P(f(f(f d)))"
paulson@16011
   521
by blast
paulson@14220
   522
paulson@14220
   523
text{*Needs double instantiation of EXISTS*}
paulson@14220
   524
lemma "\<exists>x. P x --> P a & P b"
paulson@16011
   525
by blast
paulson@14220
   526
paulson@14220
   527
lemma "\<exists>z. P z --> (\<forall>x. P x)"
paulson@16011
   528
by blast
paulson@14220
   529
paulson@14249
   530
text{*From a paper by Claire Quigley*}
paulson@14249
   531
lemma "\<exists>y. ((P c & Q y) | (\<exists>z. ~ Q z)) | (\<exists>x. ~ P x & Q d)"
paulson@14249
   532
by fast
paulson@14249
   533
paulson@14220
   534
subsubsection{*Hard examples with quantifiers*}
paulson@14220
   535
paulson@14220
   536
text{*Problem 18*}
paulson@14220
   537
lemma "\<exists>y. \<forall>x. P y --> P x"
paulson@16011
   538
by blast
paulson@14220
   539
paulson@14220
   540
text{*Problem 19*}
paulson@14220
   541
lemma "\<exists>x. \<forall>y z. (P y --> Q z) --> (P x --> Q x)"
paulson@16011
   542
by blast
paulson@14220
   543
paulson@14220
   544
text{*Problem 20*}
paulson@14249
   545
lemma "(\<forall>x y. \<exists>z. \<forall>w. (P x & Q y --> R z & S w))
paulson@14220
   546
    --> (\<exists>x y. P x & Q y) --> (\<exists>z. R z)"
paulson@16011
   547
by blast
paulson@14220
   548
paulson@14220
   549
text{*Problem 21*}
paulson@14220
   550
lemma "(\<exists>x. P --> Q x) & (\<exists>x. Q x --> P) --> (\<exists>x. P=Q x)"
paulson@16011
   551
by blast
paulson@14220
   552
paulson@14220
   553
text{*Problem 22*}
paulson@14220
   554
lemma "(\<forall>x. P = Q x)  -->  (P = (\<forall>x. Q x))"
paulson@16011
   555
by blast
paulson@14220
   556
paulson@14220
   557
text{*Problem 23*}
paulson@14220
   558
lemma "(\<forall>x. P | Q x)  =  (P | (\<forall>x. Q x))"
paulson@16011
   559
by blast
paulson@14220
   560
paulson@14220
   561
text{*Problem 24*}  (*The first goal clause is useless*)
paulson@14249
   562
lemma "~(\<exists>x. S x & Q x) & (\<forall>x. P x --> Q x | R x) &
paulson@14249
   563
      (~(\<exists>x. P x) --> (\<exists>x. Q x)) & (\<forall>x. Q x | R x --> S x)
paulson@14220
   564
    --> (\<exists>x. P x & R x)"
paulson@16011
   565
by blast
paulson@14220
   566
paulson@14220
   567
text{*Problem 25*}
paulson@14249
   568
lemma "(\<exists>x. P x) &
paulson@14249
   569
      (\<forall>x. L x --> ~ (M x & R x)) &
paulson@14249
   570
      (\<forall>x. P x --> (M x & L x)) &
paulson@14249
   571
      ((\<forall>x. P x --> Q x) | (\<exists>x. P x & R x))
paulson@14220
   572
    --> (\<exists>x. Q x & P x)"
paulson@16011
   573
by blast
paulson@14220
   574
paulson@14220
   575
text{*Problem 26; has 24 Horn clauses*}
paulson@14249
   576
lemma "((\<exists>x. p x) = (\<exists>x. q x)) &
paulson@14249
   577
      (\<forall>x. \<forall>y. p x & q y --> (r x = s y))
paulson@14220
   578
  --> ((\<forall>x. p x --> r x) = (\<forall>x. q x --> s x))"
paulson@16011
   579
by blast
paulson@14220
   580
paulson@14220
   581
text{*Problem 27; has 13 Horn clauses*}
paulson@14249
   582
lemma "(\<exists>x. P x & ~Q x) &
paulson@14249
   583
      (\<forall>x. P x --> R x) &
paulson@14249
   584
      (\<forall>x. M x & L x --> P x) &
paulson@14249
   585
      ((\<exists>x. R x & ~ Q x) --> (\<forall>x. L x --> ~ R x))
paulson@14220
   586
      --> (\<forall>x. M x --> ~L x)"
paulson@16011
   587
by blast
paulson@14220
   588
paulson@14220
   589
text{*Problem 28.  AMENDED; has 14 Horn clauses*}
paulson@14249
   590
lemma "(\<forall>x. P x --> (\<forall>x. Q x)) &
paulson@14249
   591
      ((\<forall>x. Q x | R x) --> (\<exists>x. Q x & S x)) &
paulson@14249
   592
      ((\<exists>x. S x) --> (\<forall>x. L x --> M x))
paulson@14220
   593
    --> (\<forall>x. P x & L x --> M x)"
paulson@16011
   594
by blast
paulson@14220
   595
paulson@14249
   596
text{*Problem 29.  Essentially the same as Principia Mathematica *11.71.
paulson@14249
   597
      62 Horn clauses*}
paulson@14249
   598
lemma "(\<exists>x. F x) & (\<exists>y. G y)
paulson@14249
   599
    --> ( ((\<forall>x. F x --> H x) & (\<forall>y. G y --> J y))  =
paulson@14220
   600
          (\<forall>x y. F x & G y --> H x & J y))"
paulson@16011
   601
by blast
paulson@14220
   602
paulson@14220
   603
paulson@14220
   604
text{*Problem 30*}
paulson@14249
   605
lemma "(\<forall>x. P x | Q x --> ~ R x) & (\<forall>x. (Q x --> ~ S x) --> P x & R x)
paulson@14220
   606
       --> (\<forall>x. S x)"
paulson@16011
   607
by blast
paulson@14220
   608
paulson@14220
   609
text{*Problem 31; has 10 Horn clauses; first negative clauses is useless*}
paulson@14249
   610
lemma "~(\<exists>x. P x & (Q x | R x)) &
paulson@14249
   611
      (\<exists>x. L x & P x) &
paulson@14249
   612
      (\<forall>x. ~ R x --> M x)
paulson@14220
   613
    --> (\<exists>x. L x & M x)"
paulson@16011
   614
by blast
paulson@14220
   615
paulson@14220
   616
text{*Problem 32*}
paulson@14249
   617
lemma "(\<forall>x. P x & (Q x | R x)-->S x) &
paulson@14249
   618
      (\<forall>x. S x & R x --> L x) &
paulson@14249
   619
      (\<forall>x. M x --> R x)
paulson@14220
   620
    --> (\<forall>x. P x & M x --> L x)"
paulson@16011
   621
by blast
paulson@14220
   622
paulson@14220
   623
text{*Problem 33; has 55 Horn clauses*}
paulson@14249
   624
lemma "(\<forall>x. P a & (P x --> P b)-->P c)  =
paulson@14220
   625
      (\<forall>x. (~P a | P x | P c) & (~P a | ~P b | P c))"
paulson@16011
   626
by blast
paulson@14220
   627
paulson@14249
   628
text{*Problem 34: Andrews's challenge has 924 Horn clauses*}
paulson@14249
   629
lemma "((\<exists>x. \<forall>y. p x = p y)  = ((\<exists>x. q x) = (\<forall>y. p y)))     =
paulson@14249
   630
      ((\<exists>x. \<forall>y. q x = q y)  = ((\<exists>x. p x) = (\<forall>y. q y)))"
paulson@16011
   631
by blast
paulson@14220
   632
paulson@14220
   633
text{*Problem 35*}
paulson@14220
   634
lemma "\<exists>x y. P x y -->  (\<forall>u v. P u v)"
paulson@16011
   635
by blast
paulson@14220
   636
paulson@14220
   637
text{*Problem 36; has 15 Horn clauses*}
paulson@14249
   638
lemma "(\<forall>x. \<exists>y. J x y) & (\<forall>x. \<exists>y. G x y) &
paulson@14249
   639
       (\<forall>x y. J x y | G x y --> (\<forall>z. J y z | G y z --> H x z))
paulson@14249
   640
       --> (\<forall>x. \<exists>y. H x y)"
paulson@16011
   641
by blast
paulson@14220
   642
paulson@14220
   643
text{*Problem 37; has 10 Horn clauses*}
paulson@14249
   644
lemma "(\<forall>z. \<exists>w. \<forall>x. \<exists>y.
paulson@14249
   645
           (P x z --> P y w) & P y z & (P y w --> (\<exists>u. Q u w))) &
paulson@14249
   646
      (\<forall>x z. ~P x z --> (\<exists>y. Q y z)) &
paulson@14249
   647
      ((\<exists>x y. Q x y) --> (\<forall>x. R x x))
paulson@14220
   648
    --> (\<forall>x. \<exists>y. R x y)"
paulson@16011
   649
by blast --{*causes unification tracing messages*}
paulson@14220
   650
paulson@14220
   651
paulson@14220
   652
text{*Problem 38*}  text{*Quite hard: 422 Horn clauses!!*}
paulson@14249
   653
lemma "(\<forall>x. p a & (p x --> (\<exists>y. p y & r x y)) -->
paulson@14249
   654
           (\<exists>z. \<exists>w. p z & r x w & r w z))  =
paulson@14249
   655
      (\<forall>x. (~p a | p x | (\<exists>z. \<exists>w. p z & r x w & r w z)) &
paulson@14249
   656
            (~p a | ~(\<exists>y. p y & r x y) |
paulson@14220
   657
             (\<exists>z. \<exists>w. p z & r x w & r w z)))"
paulson@16011
   658
by blast
paulson@14220
   659
paulson@14220
   660
text{*Problem 39*}
paulson@14220
   661
lemma "~ (\<exists>x. \<forall>y. F y x = (~F y y))"
paulson@16011
   662
by blast
paulson@14220
   663
paulson@14220
   664
text{*Problem 40.  AMENDED*}
paulson@14249
   665
lemma "(\<exists>y. \<forall>x. F x y = F x x)
paulson@14220
   666
      -->  ~ (\<forall>x. \<exists>y. \<forall>z. F z y = (~F z x))"
paulson@16011
   667
by blast
paulson@14220
   668
paulson@14220
   669
text{*Problem 41*}
paulson@14249
   670
lemma "(\<forall>z. (\<exists>y. (\<forall>x. f x y = (f x z & ~ f x x))))
paulson@14220
   671
      --> ~ (\<exists>z. \<forall>x. f x z)"
paulson@16011
   672
by blast
paulson@14220
   673
paulson@14220
   674
text{*Problem 42*}
paulson@14220
   675
lemma "~ (\<exists>y. \<forall>x. p x y = (~ (\<exists>z. p x z & p z x)))"
paulson@16011
   676
by blast
paulson@14220
   677
paulson@14220
   678
text{*Problem 43  NOW PROVED AUTOMATICALLY!!*}
paulson@14249
   679
lemma "(\<forall>x. \<forall>y. q x y = (\<forall>z. p z x = (p z y::bool)))
paulson@14220
   680
      --> (\<forall>x. (\<forall>y. q x y = (q y x::bool)))"
paulson@16011
   681
by blast
paulson@14220
   682
paulson@14220
   683
text{*Problem 44: 13 Horn clauses; 7-step proof*}
paulson@14249
   684
lemma "(\<forall>x. f x --> (\<exists>y. g y & h x y & (\<exists>y. g y & ~ h x y)))  &
paulson@14249
   685
       (\<exists>x. j x & (\<forall>y. g y --> h x y))
paulson@14249
   686
       --> (\<exists>x. j x & ~f x)"
paulson@16011
   687
by blast
paulson@14220
   688
paulson@14220
   689
text{*Problem 45; has 27 Horn clauses; 54-step proof*}
paulson@14249
   690
lemma "(\<forall>x. f x & (\<forall>y. g y & h x y --> j x y)
paulson@14249
   691
            --> (\<forall>y. g y & h x y --> k y)) &
paulson@14249
   692
      ~ (\<exists>y. l y & k y) &
paulson@14249
   693
      (\<exists>x. f x & (\<forall>y. h x y --> l y)
paulson@14249
   694
                & (\<forall>y. g y & h x y --> j x y))
paulson@14220
   695
      --> (\<exists>x. f x & ~ (\<exists>y. g y & h x y))"
paulson@16011
   696
by blast
paulson@14220
   697
paulson@14220
   698
text{*Problem 46; has 26 Horn clauses; 21-step proof*}
paulson@14249
   699
lemma "(\<forall>x. f x & (\<forall>y. f y & h y x --> g y) --> g x) &
paulson@14249
   700
       ((\<exists>x. f x & ~g x) -->
paulson@14249
   701
       (\<exists>x. f x & ~g x & (\<forall>y. f y & ~g y --> j x y))) &
paulson@14249
   702
       (\<forall>x y. f x & f y & h x y --> ~j y x)
paulson@14249
   703
       --> (\<forall>x. f x --> g x)"
paulson@16011
   704
by blast
paulson@14220
   705
paulson@16593
   706
text{*Problem 47.  Schubert's Steamroller.
paulson@16593
   707
      26 clauses; 63 Horn clauses.
paulson@16593
   708
      87094 inferences so far.  Searching to depth 36*}
paulson@16593
   709
lemma "(\<forall>x. wolf x \<longrightarrow> animal x) & (\<exists>x. wolf x) &
paulson@16593
   710
       (\<forall>x. fox x \<longrightarrow> animal x) & (\<exists>x. fox x) &
paulson@16593
   711
       (\<forall>x. bird x \<longrightarrow> animal x) & (\<exists>x. bird x) &
paulson@16593
   712
       (\<forall>x. caterpillar x \<longrightarrow> animal x) & (\<exists>x. caterpillar x) &
paulson@16593
   713
       (\<forall>x. snail x \<longrightarrow> animal x) & (\<exists>x. snail x) &
paulson@16593
   714
       (\<forall>x. grain x \<longrightarrow> plant x) & (\<exists>x. grain x) &
paulson@16593
   715
       (\<forall>x. animal x \<longrightarrow>
paulson@16593
   716
             ((\<forall>y. plant y \<longrightarrow> eats x y)  \<or> 
paulson@16593
   717
	      (\<forall>y. animal y & smaller_than y x &
paulson@16593
   718
                    (\<exists>z. plant z & eats y z) \<longrightarrow> eats x y))) &
paulson@16593
   719
       (\<forall>x y. bird y & (snail x \<or> caterpillar x) \<longrightarrow> smaller_than x y) &
paulson@16593
   720
       (\<forall>x y. bird x & fox y \<longrightarrow> smaller_than x y) &
paulson@16593
   721
       (\<forall>x y. fox x & wolf y \<longrightarrow> smaller_than x y) &
paulson@16593
   722
       (\<forall>x y. wolf x & (fox y \<or> grain y) \<longrightarrow> ~eats x y) &
paulson@16593
   723
       (\<forall>x y. bird x & caterpillar y \<longrightarrow> eats x y) &
paulson@16593
   724
       (\<forall>x y. bird x & snail y \<longrightarrow> ~eats x y) &
paulson@16593
   725
       (\<forall>x. (caterpillar x \<or> snail x) \<longrightarrow> (\<exists>y. plant y & eats x y))
paulson@16593
   726
       \<longrightarrow> (\<exists>x y. animal x & animal y & (\<exists>z. grain z & eats y z & eats x y))"
wenzelm@24300
   727
by (tactic{*Meson.safe_best_meson_tac 1*})
paulson@15384
   728
    --{*Nearly twice as fast as @{text meson},
paulson@15384
   729
        which performs iterative deepening rather than best-first search*}
paulson@14220
   730
paulson@14220
   731
text{*The Los problem. Circulated by John Harrison*}
paulson@14249
   732
lemma "(\<forall>x y z. P x y & P y z --> P x z) &
paulson@14249
   733
       (\<forall>x y z. Q x y & Q y z --> Q x z) &
paulson@14249
   734
       (\<forall>x y. P x y --> P y x) &
paulson@14249
   735
       (\<forall>x y. P x y | Q x y)
paulson@14249
   736
       --> (\<forall>x y. P x y) | (\<forall>x y. Q x y)"
paulson@14220
   737
by meson
paulson@14220
   738
paulson@14220
   739
text{*A similar example, suggested by Johannes Schumann and
paulson@14220
   740
 credited to Pelletier*}
paulson@14249
   741
lemma "(\<forall>x y z. P x y --> P y z --> P x z) -->
paulson@14249
   742
       (\<forall>x y z. Q x y --> Q y z --> Q x z) -->
paulson@14249
   743
       (\<forall>x y. Q x y --> Q y x) -->  (\<forall>x y. P x y | Q x y) -->
paulson@14249
   744
       (\<forall>x y. P x y) | (\<forall>x y. Q x y)"
paulson@14220
   745
by meson
paulson@14220
   746
paulson@14220
   747
text{*Problem 50.  What has this to do with equality?*}
paulson@14220
   748
lemma "(\<forall>x. P a x | (\<forall>y. P x y)) --> (\<exists>x. \<forall>y. P x y)"
paulson@16011
   749
by blast
paulson@14220
   750
paulson@15151
   751
text{*Problem 54: NOT PROVED*}
paulson@15151
   752
lemma "(\<forall>y::'a. \<exists>z. \<forall>x. F x z = (x=y)) -->
paulson@16011
   753
      ~ (\<exists>w. \<forall>x. F x w = (\<forall>u. F x u --> (\<exists>y. F y u & ~ (\<exists>z. F z u & F z y))))"
paulson@16011
   754
oops 
paulson@15151
   755
paulson@15151
   756
paulson@14220
   757
text{*Problem 55*}
paulson@14220
   758
paulson@14220
   759
text{*Non-equational version, from Manthey and Bry, CADE-9 (Springer, 1988).
paulson@14220
   760
  @{text meson} cannot report who killed Agatha. *}
paulson@14249
   761
lemma "lives agatha & lives butler & lives charles &
paulson@14249
   762
       (killed agatha agatha | killed butler agatha | killed charles agatha) &
paulson@14249
   763
       (\<forall>x y. killed x y --> hates x y & ~richer x y) &
paulson@14249
   764
       (\<forall>x. hates agatha x --> ~hates charles x) &
paulson@14249
   765
       (hates agatha agatha & hates agatha charles) &
paulson@14249
   766
       (\<forall>x. lives x & ~richer x agatha --> hates butler x) &
paulson@14249
   767
       (\<forall>x. hates agatha x --> hates butler x) &
paulson@14249
   768
       (\<forall>x. ~hates x agatha | ~hates x butler | ~hates x charles) -->
paulson@14249
   769
       (\<exists>x. killed x agatha)"
paulson@14220
   770
by meson
paulson@14220
   771
paulson@14220
   772
text{*Problem 57*}
paulson@14249
   773
lemma "P (f a b) (f b c) & P (f b c) (f a c) &
paulson@14220
   774
      (\<forall>x y z. P x y & P y z --> P x z)    -->   P (f a b) (f a c)"
paulson@16011
   775
by blast
paulson@14220
   776
paulson@14249
   777
text{*Problem 58: Challenge found on info-hol *}
paulson@14220
   778
lemma "\<forall>P Q R x. \<exists>v w. \<forall>y z. P x & Q y --> (P v | R w) & (R z --> Q v)"
paulson@16011
   779
by blast
paulson@14220
   780
paulson@14220
   781
text{*Problem 59*}
paulson@14220
   782
lemma "(\<forall>x. P x = (~P(f x))) --> (\<exists>x. P x & ~P(f x))"
paulson@16011
   783
by blast
paulson@14220
   784
paulson@14220
   785
text{*Problem 60*}
paulson@14220
   786
lemma "\<forall>x. P x (f x) = (\<exists>y. (\<forall>z. P z y --> P z (f x)) & P x y)"
paulson@16011
   787
by blast
paulson@14220
   788
paulson@14220
   789
text{*Problem 62 as corrected in JAR 18 (1997), page 135*}
paulson@14249
   790
lemma "(\<forall>x. p a & (p x --> p(f x)) --> p(f(f x)))  =
paulson@14249
   791
       (\<forall>x. (~ p a | p x | p(f(f x))) &
paulson@14249
   792
            (~ p a | ~ p(f x) | p(f(f x))))"
paulson@16011
   793
by blast
paulson@16011
   794
paulson@16011
   795
text{** Charles Morgan's problems **}
paulson@16011
   796
paulson@16011
   797
lemma
paulson@16011
   798
  assumes a: "\<forall>x y.  T(i x(i y x))"
paulson@16011
   799
      and b: "\<forall>x y z. T(i (i x (i y z)) (i (i x y) (i x z)))"
paulson@16011
   800
      and c: "\<forall>x y.   T(i (i (n x) (n y)) (i y x))"
paulson@16011
   801
      and c': "\<forall>x y.   T(i (i y x) (i (n x) (n y)))"
paulson@16011
   802
      and d: "\<forall>x y.   T(i x y) & T x --> T y"
paulson@16011
   803
 shows True
paulson@16011
   804
proof -
paulson@16011
   805
  from a b d have "\<forall>x. T(i x x)" by blast
paulson@16011
   806
  from a b c d have "\<forall>x. T(i x (n(n x)))" --{*Problem 66*}
paulson@23508
   807
    by metis
paulson@16011
   808
  from a b c d have "\<forall>x. T(i (n(n x)) x)" --{*Problem 67*}
paulson@16011
   809
    by meson
paulson@16011
   810
      --{*4.9s on griffon. 51061 inferences, depth 21 *}
paulson@16011
   811
  from a b c' d have "\<forall>x. T(i x (n(n x)))" 
paulson@16011
   812
      --{*Problem 68: not proved.  Listed as satisfiable in TPTP (LCL078-1)*}
paulson@16011
   813
oops
paulson@16011
   814
paulson@16011
   815
text{*Problem 71, as found in TPTP (SYN007+1.005)*}
paulson@16011
   816
lemma "p1 = (p2 = (p3 = (p4 = (p5 = (p1 = (p2 = (p3 = (p4 = p5))))))))"
paulson@16011
   817
by blast
paulson@14220
   818
paulson@14220
   819
end