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