src/HOL/ex/Classical.thy
changeset 16011 237aafbdb1f4
parent 15384 b13eb8a8897d
child 16417 9bc16273c2d4
equal deleted inserted replaced
16010:0705c8d1f107 16011:237aafbdb1f4
     7 header{*Classical Predicate Calculus Problems*}
     7 header{*Classical Predicate Calculus Problems*}
     8 
     8 
     9 theory Classical = Main:
     9 theory Classical = Main:
    10 
    10 
    11 subsection{*Traditional Classical Reasoner*}
    11 subsection{*Traditional Classical Reasoner*}
       
    12 
       
    13 text{*The machine "griffon" mentioned below is a 2.5GHz Power Mac G5.*}
    12 
    14 
    13 text{*Taken from @{text "FOL/Classical.thy"}. When porting examples from
    15 text{*Taken from @{text "FOL/Classical.thy"}. When porting examples from
    14 first-order logic, beware of the precedence of @{text "="} versus @{text
    16 first-order logic, beware of the precedence of @{text "="} versus @{text
    15 "\<leftrightarrow>"}.*}
    17 "\<leftrightarrow>"}.*}
    16 
    18 
   425 JAR 29: 3-4 (2002), pages 253-275 *}
   427 JAR 29: 3-4 (2002), pages 253-275 *}
   426 lemma "(\<forall>x y z. R(x,y) & R(y,z) --> R(x,z)) &
   428 lemma "(\<forall>x y z. R(x,y) & R(y,z) --> R(x,z)) &
   427        (\<forall>x. \<exists>y. R(x,y)) -->
   429        (\<forall>x. \<exists>y. R(x,y)) -->
   428        ~ (\<forall>x. P x = (\<forall>y. R(x,y) --> ~ P y))"
   430        ~ (\<forall>x. P x = (\<forall>y. R(x,y) --> ~ P y))"
   429 by (tactic{*safe_best_meson_tac 1*})
   431 by (tactic{*safe_best_meson_tac 1*})
   430     --{*In contrast, @{text meson} is SLOW: 15s on a 1.8GHz machine!*}
   432     --{*In contrast, @{text meson} is SLOW: 7.6s on griffon*}
   431 
   433 
   432 
   434 
   433 subsubsection{*Pelletier's examples*}
   435 subsubsection{*Pelletier's examples*}
   434 text{*1*}
   436 text{*1*}
   435 lemma "(P --> Q)  =  (~Q --> ~P)"
   437 lemma "(P --> Q)  =  (~Q --> ~P)"
   436 by meson
   438 by blast
   437 
   439 
   438 text{*2*}
   440 text{*2*}
   439 lemma "(~ ~ P) =  P"
   441 lemma "(~ ~ P) =  P"
   440 by meson
   442 by blast
   441 
   443 
   442 text{*3*}
   444 text{*3*}
   443 lemma "~(P-->Q) --> (Q-->P)"
   445 lemma "~(P-->Q) --> (Q-->P)"
   444 by meson
   446 by blast
   445 
   447 
   446 text{*4*}
   448 text{*4*}
   447 lemma "(~P-->Q)  =  (~Q --> P)"
   449 lemma "(~P-->Q)  =  (~Q --> P)"
   448 by meson
   450 by blast
   449 
   451 
   450 text{*5*}
   452 text{*5*}
   451 lemma "((P|Q)-->(P|R)) --> (P|(Q-->R))"
   453 lemma "((P|Q)-->(P|R)) --> (P|(Q-->R))"
   452 by meson
   454 by blast
   453 
   455 
   454 text{*6*}
   456 text{*6*}
   455 lemma "P | ~ P"
   457 lemma "P | ~ P"
   456 by meson
   458 by blast
   457 
   459 
   458 text{*7*}
   460 text{*7*}
   459 lemma "P | ~ ~ ~ P"
   461 lemma "P | ~ ~ ~ P"
   460 by meson
   462 by blast
   461 
   463 
   462 text{*8.  Peirce's law*}
   464 text{*8.  Peirce's law*}
   463 lemma "((P-->Q) --> P)  -->  P"
   465 lemma "((P-->Q) --> P)  -->  P"
   464 by meson
   466 by blast
   465 
   467 
   466 text{*9*}
   468 text{*9*}
   467 lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
   469 lemma "((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
   468 by meson
   470 by blast
   469 
   471 
   470 text{*10*}
   472 text{*10*}
   471 lemma "(Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P=Q)"
   473 lemma "(Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P=Q)"
   472 by meson
   474 by blast
   473 
   475 
   474 text{*11.  Proved in each direction (incorrectly, says Pelletier!!)  *}
   476 text{*11.  Proved in each direction (incorrectly, says Pelletier!!)  *}
   475 lemma "P=(P::bool)"
   477 lemma "P=(P::bool)"
   476 by meson
   478 by blast
   477 
   479 
   478 text{*12.  "Dijkstra's law"*}
   480 text{*12.  "Dijkstra's law"*}
   479 lemma "((P = Q) = R) = (P = (Q = R))"
   481 lemma "((P = Q) = R) = (P = (Q = R))"
   480 by meson
   482 by blast
   481 
   483 
   482 text{*13.  Distributive law*}
   484 text{*13.  Distributive law*}
   483 lemma "(P | (Q & R)) = ((P | Q) & (P | R))"
   485 lemma "(P | (Q & R)) = ((P | Q) & (P | R))"
   484 by meson
   486 by blast
   485 
   487 
   486 text{*14*}
   488 text{*14*}
   487 lemma "(P = Q) = ((Q | ~P) & (~Q|P))"
   489 lemma "(P = Q) = ((Q | ~P) & (~Q|P))"
   488 by meson
   490 by blast
   489 
   491 
   490 text{*15*}
   492 text{*15*}
   491 lemma "(P --> Q) = (~P | Q)"
   493 lemma "(P --> Q) = (~P | Q)"
   492 by meson
   494 by blast
   493 
   495 
   494 text{*16*}
   496 text{*16*}
   495 lemma "(P-->Q) | (Q-->P)"
   497 lemma "(P-->Q) | (Q-->P)"
   496 by meson
   498 by blast
   497 
   499 
   498 text{*17*}
   500 text{*17*}
   499 lemma "((P & (Q-->R))-->S)  =  ((~P | Q | S) & (~P | ~R | S))"
   501 lemma "((P & (Q-->R))-->S)  =  ((~P | Q | S) & (~P | ~R | S))"
   500 by meson
   502 by blast
   501 
   503 
   502 subsubsection{*Classical Logic: examples with quantifiers*}
   504 subsubsection{*Classical Logic: examples with quantifiers*}
   503 
   505 
   504 lemma "(\<forall>x. P x & Q x) = ((\<forall>x. P x) & (\<forall>x. Q x))"
   506 lemma "(\<forall>x. P x & Q x) = ((\<forall>x. P x) & (\<forall>x. Q x))"
   505 by meson
   507 by blast
   506 
   508 
   507 lemma "(\<exists>x. P --> Q x)  =  (P --> (\<exists>x. Q x))"
   509 lemma "(\<exists>x. P --> Q x)  =  (P --> (\<exists>x. Q x))"
   508 by meson
   510 by blast
   509 
   511 
   510 lemma "(\<exists>x. P x --> Q) = ((\<forall>x. P x) --> Q)"
   512 lemma "(\<exists>x. P x --> Q) = ((\<forall>x. P x) --> Q)"
   511 by meson
   513 by blast
   512 
   514 
   513 lemma "((\<forall>x. P x) | Q)  =  (\<forall>x. P x | Q)"
   515 lemma "((\<forall>x. P x) | Q)  =  (\<forall>x. P x | Q)"
   514 by meson
   516 by blast
   515 
   517 
   516 lemma "(\<forall>x. P x --> P(f x))  &  P d --> P(f(f(f d)))"
   518 lemma "(\<forall>x. P x --> P(f x))  &  P d --> P(f(f(f d)))"
   517 by meson
   519 by blast
   518 
   520 
   519 text{*Needs double instantiation of EXISTS*}
   521 text{*Needs double instantiation of EXISTS*}
   520 lemma "\<exists>x. P x --> P a & P b"
   522 lemma "\<exists>x. P x --> P a & P b"
   521 by meson
   523 by blast
   522 
   524 
   523 lemma "\<exists>z. P z --> (\<forall>x. P x)"
   525 lemma "\<exists>z. P z --> (\<forall>x. P x)"
   524 by meson
   526 by blast
   525 
   527 
   526 text{*From a paper by Claire Quigley*}
   528 text{*From a paper by Claire Quigley*}
   527 lemma "\<exists>y. ((P c & Q y) | (\<exists>z. ~ Q z)) | (\<exists>x. ~ P x & Q d)"
   529 lemma "\<exists>y. ((P c & Q y) | (\<exists>z. ~ Q z)) | (\<exists>x. ~ P x & Q d)"
   528 by fast
   530 by fast
   529 
   531 
   530 subsubsection{*Hard examples with quantifiers*}
   532 subsubsection{*Hard examples with quantifiers*}
   531 
   533 
   532 text{*Problem 18*}
   534 text{*Problem 18*}
   533 lemma "\<exists>y. \<forall>x. P y --> P x"
   535 lemma "\<exists>y. \<forall>x. P y --> P x"
   534 by meson
   536 by blast
   535 
   537 
   536 text{*Problem 19*}
   538 text{*Problem 19*}
   537 lemma "\<exists>x. \<forall>y z. (P y --> Q z) --> (P x --> Q x)"
   539 lemma "\<exists>x. \<forall>y z. (P y --> Q z) --> (P x --> Q x)"
   538 by meson
   540 by blast
   539 
   541 
   540 text{*Problem 20*}
   542 text{*Problem 20*}
   541 lemma "(\<forall>x y. \<exists>z. \<forall>w. (P x & Q y --> R z & S w))
   543 lemma "(\<forall>x y. \<exists>z. \<forall>w. (P x & Q y --> R z & S w))
   542     --> (\<exists>x y. P x & Q y) --> (\<exists>z. R z)"
   544     --> (\<exists>x y. P x & Q y) --> (\<exists>z. R z)"
   543 by meson
   545 by blast
   544 
   546 
   545 text{*Problem 21*}
   547 text{*Problem 21*}
   546 lemma "(\<exists>x. P --> Q x) & (\<exists>x. Q x --> P) --> (\<exists>x. P=Q x)"
   548 lemma "(\<exists>x. P --> Q x) & (\<exists>x. Q x --> P) --> (\<exists>x. P=Q x)"
   547 by meson
   549 by blast
   548 
   550 
   549 text{*Problem 22*}
   551 text{*Problem 22*}
   550 lemma "(\<forall>x. P = Q x)  -->  (P = (\<forall>x. Q x))"
   552 lemma "(\<forall>x. P = Q x)  -->  (P = (\<forall>x. Q x))"
   551 by meson
   553 by blast
   552 
   554 
   553 text{*Problem 23*}
   555 text{*Problem 23*}
   554 lemma "(\<forall>x. P | Q x)  =  (P | (\<forall>x. Q x))"
   556 lemma "(\<forall>x. P | Q x)  =  (P | (\<forall>x. Q x))"
   555 by meson
   557 by blast
   556 
   558 
   557 text{*Problem 24*}  (*The first goal clause is useless*)
   559 text{*Problem 24*}  (*The first goal clause is useless*)
   558 lemma "~(\<exists>x. S x & Q x) & (\<forall>x. P x --> Q x | R x) &
   560 lemma "~(\<exists>x. S x & Q x) & (\<forall>x. P x --> Q x | R x) &
   559       (~(\<exists>x. P x) --> (\<exists>x. Q x)) & (\<forall>x. Q x | R x --> S x)
   561       (~(\<exists>x. P x) --> (\<exists>x. Q x)) & (\<forall>x. Q x | R x --> S x)
   560     --> (\<exists>x. P x & R x)"
   562     --> (\<exists>x. P x & R x)"
   561 by meson
   563 by blast
   562 
   564 
   563 text{*Problem 25*}
   565 text{*Problem 25*}
   564 lemma "(\<exists>x. P x) &
   566 lemma "(\<exists>x. P x) &
   565       (\<forall>x. L x --> ~ (M x & R x)) &
   567       (\<forall>x. L x --> ~ (M x & R x)) &
   566       (\<forall>x. P x --> (M x & L x)) &
   568       (\<forall>x. P x --> (M x & L x)) &
   567       ((\<forall>x. P x --> Q x) | (\<exists>x. P x & R x))
   569       ((\<forall>x. P x --> Q x) | (\<exists>x. P x & R x))
   568     --> (\<exists>x. Q x & P x)"
   570     --> (\<exists>x. Q x & P x)"
   569 by meson
   571 by blast
   570 
   572 
   571 text{*Problem 26; has 24 Horn clauses*}
   573 text{*Problem 26; has 24 Horn clauses*}
   572 lemma "((\<exists>x. p x) = (\<exists>x. q x)) &
   574 lemma "((\<exists>x. p x) = (\<exists>x. q x)) &
   573       (\<forall>x. \<forall>y. p x & q y --> (r x = s y))
   575       (\<forall>x. \<forall>y. p x & q y --> (r x = s y))
   574   --> ((\<forall>x. p x --> r x) = (\<forall>x. q x --> s x))"
   576   --> ((\<forall>x. p x --> r x) = (\<forall>x. q x --> s x))"
   575 by meson
   577 by blast
   576 
   578 
   577 text{*Problem 27; has 13 Horn clauses*}
   579 text{*Problem 27; has 13 Horn clauses*}
   578 lemma "(\<exists>x. P x & ~Q x) &
   580 lemma "(\<exists>x. P x & ~Q x) &
   579       (\<forall>x. P x --> R x) &
   581       (\<forall>x. P x --> R x) &
   580       (\<forall>x. M x & L x --> P x) &
   582       (\<forall>x. M x & L x --> P x) &
   581       ((\<exists>x. R x & ~ Q x) --> (\<forall>x. L x --> ~ R x))
   583       ((\<exists>x. R x & ~ Q x) --> (\<forall>x. L x --> ~ R x))
   582       --> (\<forall>x. M x --> ~L x)"
   584       --> (\<forall>x. M x --> ~L x)"
   583 by meson
   585 by blast
   584 
   586 
   585 text{*Problem 28.  AMENDED; has 14 Horn clauses*}
   587 text{*Problem 28.  AMENDED; has 14 Horn clauses*}
   586 lemma "(\<forall>x. P x --> (\<forall>x. Q x)) &
   588 lemma "(\<forall>x. P x --> (\<forall>x. Q x)) &
   587       ((\<forall>x. Q x | R x) --> (\<exists>x. Q x & S x)) &
   589       ((\<forall>x. Q x | R x) --> (\<exists>x. Q x & S x)) &
   588       ((\<exists>x. S x) --> (\<forall>x. L x --> M x))
   590       ((\<exists>x. S x) --> (\<forall>x. L x --> M x))
   589     --> (\<forall>x. P x & L x --> M x)"
   591     --> (\<forall>x. P x & L x --> M x)"
   590 by meson
   592 by blast
   591 
   593 
   592 text{*Problem 29.  Essentially the same as Principia Mathematica *11.71.
   594 text{*Problem 29.  Essentially the same as Principia Mathematica *11.71.
   593       62 Horn clauses*}
   595       62 Horn clauses*}
   594 lemma "(\<exists>x. F x) & (\<exists>y. G y)
   596 lemma "(\<exists>x. F x) & (\<exists>y. G y)
   595     --> ( ((\<forall>x. F x --> H x) & (\<forall>y. G y --> J y))  =
   597     --> ( ((\<forall>x. F x --> H x) & (\<forall>y. G y --> J y))  =
   596           (\<forall>x y. F x & G y --> H x & J y))"
   598           (\<forall>x y. F x & G y --> H x & J y))"
   597 by meson
   599 by blast
   598 
   600 
   599 
   601 
   600 text{*Problem 30*}
   602 text{*Problem 30*}
   601 lemma "(\<forall>x. P x | Q x --> ~ R x) & (\<forall>x. (Q x --> ~ S x) --> P x & R x)
   603 lemma "(\<forall>x. P x | Q x --> ~ R x) & (\<forall>x. (Q x --> ~ S x) --> P x & R x)
   602        --> (\<forall>x. S x)"
   604        --> (\<forall>x. S x)"
   603 by meson
   605 by blast
   604 
   606 
   605 text{*Problem 31; has 10 Horn clauses; first negative clauses is useless*}
   607 text{*Problem 31; has 10 Horn clauses; first negative clauses is useless*}
   606 lemma "~(\<exists>x. P x & (Q x | R x)) &
   608 lemma "~(\<exists>x. P x & (Q x | R x)) &
   607       (\<exists>x. L x & P x) &
   609       (\<exists>x. L x & P x) &
   608       (\<forall>x. ~ R x --> M x)
   610       (\<forall>x. ~ R x --> M x)
   609     --> (\<exists>x. L x & M x)"
   611     --> (\<exists>x. L x & M x)"
   610 by meson
   612 by blast
   611 
   613 
   612 text{*Problem 32*}
   614 text{*Problem 32*}
   613 lemma "(\<forall>x. P x & (Q x | R x)-->S x) &
   615 lemma "(\<forall>x. P x & (Q x | R x)-->S x) &
   614       (\<forall>x. S x & R x --> L x) &
   616       (\<forall>x. S x & R x --> L x) &
   615       (\<forall>x. M x --> R x)
   617       (\<forall>x. M x --> R x)
   616     --> (\<forall>x. P x & M x --> L x)"
   618     --> (\<forall>x. P x & M x --> L x)"
   617 by meson
   619 by blast
   618 
   620 
   619 text{*Problem 33; has 55 Horn clauses*}
   621 text{*Problem 33; has 55 Horn clauses*}
   620 lemma "(\<forall>x. P a & (P x --> P b)-->P c)  =
   622 lemma "(\<forall>x. P a & (P x --> P b)-->P c)  =
   621       (\<forall>x. (~P a | P x | P c) & (~P a | ~P b | P c))"
   623       (\<forall>x. (~P a | P x | P c) & (~P a | ~P b | P c))"
   622 by meson
   624 by blast
   623 
   625 
   624 text{*Problem 34: Andrews's challenge has 924 Horn clauses*}
   626 text{*Problem 34: Andrews's challenge has 924 Horn clauses*}
   625 lemma "((\<exists>x. \<forall>y. p x = p y)  = ((\<exists>x. q x) = (\<forall>y. p y)))     =
   627 lemma "((\<exists>x. \<forall>y. p x = p y)  = ((\<exists>x. q x) = (\<forall>y. p y)))     =
   626       ((\<exists>x. \<forall>y. q x = q y)  = ((\<exists>x. p x) = (\<forall>y. q y)))"
   628       ((\<exists>x. \<forall>y. q x = q y)  = ((\<exists>x. p x) = (\<forall>y. q y)))"
   627 by meson
   629 by blast
   628 
   630 
   629 text{*Problem 35*}
   631 text{*Problem 35*}
   630 lemma "\<exists>x y. P x y -->  (\<forall>u v. P u v)"
   632 lemma "\<exists>x y. P x y -->  (\<forall>u v. P u v)"
   631 by meson
   633 by blast
   632 
   634 
   633 text{*Problem 36; has 15 Horn clauses*}
   635 text{*Problem 36; has 15 Horn clauses*}
   634 lemma "(\<forall>x. \<exists>y. J x y) & (\<forall>x. \<exists>y. G x y) &
   636 lemma "(\<forall>x. \<exists>y. J x y) & (\<forall>x. \<exists>y. G x y) &
   635        (\<forall>x y. J x y | G x y --> (\<forall>z. J y z | G y z --> H x z))
   637        (\<forall>x y. J x y | G x y --> (\<forall>z. J y z | G y z --> H x z))
   636        --> (\<forall>x. \<exists>y. H x y)"
   638        --> (\<forall>x. \<exists>y. H x y)"
   637 by meson
   639 by blast
   638 
   640 
   639 text{*Problem 37; has 10 Horn clauses*}
   641 text{*Problem 37; has 10 Horn clauses*}
   640 lemma "(\<forall>z. \<exists>w. \<forall>x. \<exists>y.
   642 lemma "(\<forall>z. \<exists>w. \<forall>x. \<exists>y.
   641            (P x z --> P y w) & P y z & (P y w --> (\<exists>u. Q u w))) &
   643            (P x z --> P y w) & P y z & (P y w --> (\<exists>u. Q u w))) &
   642       (\<forall>x z. ~P x z --> (\<exists>y. Q y z)) &
   644       (\<forall>x z. ~P x z --> (\<exists>y. Q y z)) &
   643       ((\<exists>x y. Q x y) --> (\<forall>x. R x x))
   645       ((\<exists>x y. Q x y) --> (\<forall>x. R x x))
   644     --> (\<forall>x. \<exists>y. R x y)"
   646     --> (\<forall>x. \<exists>y. R x y)"
   645 by meson --{*causes unification tracing messages*}
   647 by blast --{*causes unification tracing messages*}
   646 
   648 
   647 
   649 
   648 text{*Problem 38*}  text{*Quite hard: 422 Horn clauses!!*}
   650 text{*Problem 38*}  text{*Quite hard: 422 Horn clauses!!*}
   649 lemma "(\<forall>x. p a & (p x --> (\<exists>y. p y & r x y)) -->
   651 lemma "(\<forall>x. p a & (p x --> (\<exists>y. p y & r x y)) -->
   650            (\<exists>z. \<exists>w. p z & r x w & r w z))  =
   652            (\<exists>z. \<exists>w. p z & r x w & r w z))  =
   651       (\<forall>x. (~p a | p x | (\<exists>z. \<exists>w. p z & r x w & r w z)) &
   653       (\<forall>x. (~p a | p x | (\<exists>z. \<exists>w. p z & r x w & r w z)) &
   652             (~p a | ~(\<exists>y. p y & r x y) |
   654             (~p a | ~(\<exists>y. p y & r x y) |
   653              (\<exists>z. \<exists>w. p z & r x w & r w z)))"
   655              (\<exists>z. \<exists>w. p z & r x w & r w z)))"
   654 by meson
   656 by blast
   655 
   657 
   656 text{*Problem 39*}
   658 text{*Problem 39*}
   657 lemma "~ (\<exists>x. \<forall>y. F y x = (~F y y))"
   659 lemma "~ (\<exists>x. \<forall>y. F y x = (~F y y))"
   658 by meson
   660 by blast
   659 
   661 
   660 text{*Problem 40.  AMENDED*}
   662 text{*Problem 40.  AMENDED*}
   661 lemma "(\<exists>y. \<forall>x. F x y = F x x)
   663 lemma "(\<exists>y. \<forall>x. F x y = F x x)
   662       -->  ~ (\<forall>x. \<exists>y. \<forall>z. F z y = (~F z x))"
   664       -->  ~ (\<forall>x. \<exists>y. \<forall>z. F z y = (~F z x))"
   663 by meson
   665 by blast
   664 
   666 
   665 text{*Problem 41*}
   667 text{*Problem 41*}
   666 lemma "(\<forall>z. (\<exists>y. (\<forall>x. f x y = (f x z & ~ f x x))))
   668 lemma "(\<forall>z. (\<exists>y. (\<forall>x. f x y = (f x z & ~ f x x))))
   667       --> ~ (\<exists>z. \<forall>x. f x z)"
   669       --> ~ (\<exists>z. \<forall>x. f x z)"
   668 by meson
   670 by blast
   669 
   671 
   670 text{*Problem 42*}
   672 text{*Problem 42*}
   671 lemma "~ (\<exists>y. \<forall>x. p x y = (~ (\<exists>z. p x z & p z x)))"
   673 lemma "~ (\<exists>y. \<forall>x. p x y = (~ (\<exists>z. p x z & p z x)))"
   672 by meson
   674 by blast
   673 
   675 
   674 text{*Problem 43  NOW PROVED AUTOMATICALLY!!*}
   676 text{*Problem 43  NOW PROVED AUTOMATICALLY!!*}
   675 lemma "(\<forall>x. \<forall>y. q x y = (\<forall>z. p z x = (p z y::bool)))
   677 lemma "(\<forall>x. \<forall>y. q x y = (\<forall>z. p z x = (p z y::bool)))
   676       --> (\<forall>x. (\<forall>y. q x y = (q y x::bool)))"
   678       --> (\<forall>x. (\<forall>y. q x y = (q y x::bool)))"
   677 by meson
   679 by blast
   678 
   680 
   679 text{*Problem 44: 13 Horn clauses; 7-step proof*}
   681 text{*Problem 44: 13 Horn clauses; 7-step proof*}
   680 lemma "(\<forall>x. f x --> (\<exists>y. g y & h x y & (\<exists>y. g y & ~ h x y)))  &
   682 lemma "(\<forall>x. f x --> (\<exists>y. g y & h x y & (\<exists>y. g y & ~ h x y)))  &
   681        (\<exists>x. j x & (\<forall>y. g y --> h x y))
   683        (\<exists>x. j x & (\<forall>y. g y --> h x y))
   682        --> (\<exists>x. j x & ~f x)"
   684        --> (\<exists>x. j x & ~f x)"
   683 by meson
   685 by blast
   684 
   686 
   685 text{*Problem 45; has 27 Horn clauses; 54-step proof*}
   687 text{*Problem 45; has 27 Horn clauses; 54-step proof*}
   686 lemma "(\<forall>x. f x & (\<forall>y. g y & h x y --> j x y)
   688 lemma "(\<forall>x. f x & (\<forall>y. g y & h x y --> j x y)
   687             --> (\<forall>y. g y & h x y --> k y)) &
   689             --> (\<forall>y. g y & h x y --> k y)) &
   688       ~ (\<exists>y. l y & k y) &
   690       ~ (\<exists>y. l y & k y) &
   689       (\<exists>x. f x & (\<forall>y. h x y --> l y)
   691       (\<exists>x. f x & (\<forall>y. h x y --> l y)
   690                 & (\<forall>y. g y & h x y --> j x y))
   692                 & (\<forall>y. g y & h x y --> j x y))
   691       --> (\<exists>x. f x & ~ (\<exists>y. g y & h x y))"
   693       --> (\<exists>x. f x & ~ (\<exists>y. g y & h x y))"
   692 by meson
   694 by blast
   693 
   695 
   694 text{*Problem 46; has 26 Horn clauses; 21-step proof*}
   696 text{*Problem 46; has 26 Horn clauses; 21-step proof*}
   695 lemma "(\<forall>x. f x & (\<forall>y. f y & h y x --> g y) --> g x) &
   697 lemma "(\<forall>x. f x & (\<forall>y. f y & h y x --> g y) --> g x) &
   696        ((\<exists>x. f x & ~g x) -->
   698        ((\<exists>x. f x & ~g x) -->
   697        (\<exists>x. f x & ~g x & (\<forall>y. f y & ~g y --> j x y))) &
   699        (\<exists>x. f x & ~g x & (\<forall>y. f y & ~g y --> j x y))) &
   698        (\<forall>x y. f x & f y & h x y --> ~j y x)
   700        (\<forall>x y. f x & f y & h x y --> ~j y x)
   699        --> (\<forall>x. f x --> g x)"
   701        --> (\<forall>x. f x --> g x)"
   700 by meson
   702 by blast
   701 
   703 
   702 text{*Problem 47.  Schubert's Steamroller*}
   704 text{*Problem 47.  Schubert's Steamroller*}
   703         text{*26 clauses; 63 Horn clauses
   705         text{*26 clauses; 63 Horn clauses
   704           87094 inferences so far.  Searching to depth 36*}
   706           87094 inferences so far.  Searching to depth 36*}
   705 lemma "(\<forall>x. P1 x --> P0 x) & (\<exists>x. P1 x) &
   707 lemma "(\<forall>x. P1 x --> P0 x) & (\<exists>x. P1 x) &
   739        (\<forall>x y. P x y) | (\<forall>x y. Q x y)"
   741        (\<forall>x y. P x y) | (\<forall>x y. Q x y)"
   740 by meson
   742 by meson
   741 
   743 
   742 text{*Problem 50.  What has this to do with equality?*}
   744 text{*Problem 50.  What has this to do with equality?*}
   743 lemma "(\<forall>x. P a x | (\<forall>y. P x y)) --> (\<exists>x. \<forall>y. P x y)"
   745 lemma "(\<forall>x. P a x | (\<forall>y. P x y)) --> (\<exists>x. \<forall>y. P x y)"
   744 by meson
   746 by blast
   745 
   747 
   746 text{*Problem 54: NOT PROVED*}
   748 text{*Problem 54: NOT PROVED*}
   747 lemma "(\<forall>y::'a. \<exists>z. \<forall>x. F x z = (x=y)) -->
   749 lemma "(\<forall>y::'a. \<exists>z. \<forall>x. F x z = (x=y)) -->
   748       ~ (\<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))))"oops 
   750       ~ (\<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))))"
       
   751 oops 
   749 
   752 
   750 
   753 
   751 text{*Problem 55*}
   754 text{*Problem 55*}
   752 
   755 
   753 text{*Non-equational version, from Manthey and Bry, CADE-9 (Springer, 1988).
   756 text{*Non-equational version, from Manthey and Bry, CADE-9 (Springer, 1988).
   764 by meson
   767 by meson
   765 
   768 
   766 text{*Problem 57*}
   769 text{*Problem 57*}
   767 lemma "P (f a b) (f b c) & P (f b c) (f a c) &
   770 lemma "P (f a b) (f b c) & P (f b c) (f a c) &
   768       (\<forall>x y z. P x y & P y z --> P x z)    -->   P (f a b) (f a c)"
   771       (\<forall>x y z. P x y & P y z --> P x z)    -->   P (f a b) (f a c)"
   769 by meson
   772 by blast
   770 
   773 
   771 text{*Problem 58: Challenge found on info-hol *}
   774 text{*Problem 58: Challenge found on info-hol *}
   772 lemma "\<forall>P Q R x. \<exists>v w. \<forall>y z. P x & Q y --> (P v | R w) & (R z --> Q v)"
   775 lemma "\<forall>P Q R x. \<exists>v w. \<forall>y z. P x & Q y --> (P v | R w) & (R z --> Q v)"
   773 by meson
   776 by blast
   774 
   777 
   775 text{*Problem 59*}
   778 text{*Problem 59*}
   776 lemma "(\<forall>x. P x = (~P(f x))) --> (\<exists>x. P x & ~P(f x))"
   779 lemma "(\<forall>x. P x = (~P(f x))) --> (\<exists>x. P x & ~P(f x))"
   777 by meson
   780 by blast
   778 
   781 
   779 text{*Problem 60*}
   782 text{*Problem 60*}
   780 lemma "\<forall>x. P x (f x) = (\<exists>y. (\<forall>z. P z y --> P z (f x)) & P x y)"
   783 lemma "\<forall>x. P x (f x) = (\<exists>y. (\<forall>z. P z y --> P z (f x)) & P x y)"
   781 by meson
   784 by blast
   782 
   785 
   783 text{*Problem 62 as corrected in JAR 18 (1997), page 135*}
   786 text{*Problem 62 as corrected in JAR 18 (1997), page 135*}
   784 lemma "(\<forall>x. p a & (p x --> p(f x)) --> p(f(f x)))  =
   787 lemma "(\<forall>x. p a & (p x --> p(f x)) --> p(f(f x)))  =
   785        (\<forall>x. (~ p a | p x | p(f(f x))) &
   788        (\<forall>x. (~ p a | p x | p(f(f x))) &
   786             (~ p a | ~ p(f x) | p(f(f x))))"
   789             (~ p a | ~ p(f x) | p(f(f x))))"
   787 by meson
   790 by blast
       
   791 
       
   792 text{** Charles Morgan's problems **}
       
   793 
       
   794 lemma
       
   795   assumes a: "\<forall>x y.  T(i x(i y x))"
       
   796       and b: "\<forall>x y z. T(i (i x (i y z)) (i (i x y) (i x z)))"
       
   797       and c: "\<forall>x y.   T(i (i (n x) (n y)) (i y x))"
       
   798       and c': "\<forall>x y.   T(i (i y x) (i (n x) (n y)))"
       
   799       and d: "\<forall>x y.   T(i x y) & T x --> T y"
       
   800  shows True
       
   801 proof -
       
   802   from a b d have "\<forall>x. T(i x x)" by blast
       
   803   from a b c d have "\<forall>x. T(i x (n(n x)))" --{*Problem 66*}
       
   804     by meson
       
   805       --{*SLOW: 18s on griffon. 208346 inferences, depth 23 *}
       
   806   from a b c d have "\<forall>x. T(i (n(n x)) x)" --{*Problem 67*}
       
   807     by meson
       
   808       --{*4.9s on griffon. 51061 inferences, depth 21 *}
       
   809   from a b c' d have "\<forall>x. T(i x (n(n x)))" 
       
   810       --{*Problem 68: not proved.  Listed as satisfiable in TPTP (LCL078-1)*}
       
   811 oops
       
   812 
       
   813 text{*Problem 71, as found in TPTP (SYN007+1.005)*}
       
   814 lemma "p1 = (p2 = (p3 = (p4 = (p5 = (p1 = (p2 = (p3 = (p4 = p5))))))))"
       
   815 by blast
   788 
   816 
   789 text{*A manual resolution proof of problem 19.*}
   817 text{*A manual resolution proof of problem 19.*}
   790 lemma "\<exists>x. \<forall>y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
   818 lemma "\<exists>x. \<forall>y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
   791 proof (rule ccontr, skolemize, make_clauses)
   819 proof (rule ccontr, skolemize, make_clauses)
   792   fix f g
   820   fix f g