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