src/Sequents/LK/Hard_Quantifiers.thy
author wenzelm
Sat Feb 01 18:00:28 2014 +0100 (2014-02-01)
changeset 55229 08f2ebb65078
parent 55228 901a6696cdd8
child 61385 538100cc4399
permissions -rw-r--r--
simplified sessions;
wenzelm@41959
     1
(*  Title:      Sequents/LK/Hard_Quantifiers.thy
wenzelm@21426
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
wenzelm@21426
     3
    Copyright   1992  University of Cambridge
wenzelm@21426
     4
wenzelm@21426
     5
Hard examples with quantifiers.  Can be read to test the LK system.
wenzelm@21426
     6
From  F. J. Pelletier,
wenzelm@21426
     7
  Seventy-Five Problems for Testing Automatic Theorem Provers,
wenzelm@21426
     8
  J. Automated Reasoning 2 (1986), 191-216.
wenzelm@21426
     9
  Errata, JAR 4 (1988), 236-236.
wenzelm@21426
    10
wenzelm@21426
    11
Uses pc_tac rather than fast_tac when the former is significantly faster.
wenzelm@21426
    12
*)
wenzelm@21426
    13
wenzelm@21426
    14
theory Hard_Quantifiers
wenzelm@55229
    15
imports "../LK"
wenzelm@21426
    16
begin
wenzelm@21426
    17
wenzelm@21426
    18
lemma "|- (ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))"
wenzelm@21426
    19
  by fast
wenzelm@21426
    20
wenzelm@21426
    21
lemma "|- (EX x. P-->Q(x))  <->  (P --> (EX x. Q(x)))"
wenzelm@21426
    22
  by fast
wenzelm@21426
    23
wenzelm@21426
    24
lemma "|- (EX x. P(x)-->Q)  <->  (ALL x. P(x)) --> Q"
wenzelm@21426
    25
  by fast
wenzelm@21426
    26
wenzelm@21426
    27
lemma "|- (ALL x. P(x)) | Q  <->  (ALL x. P(x) | Q)"
wenzelm@21426
    28
  by fast
wenzelm@21426
    29
wenzelm@21426
    30
wenzelm@21426
    31
text "Problems requiring quantifier duplication"
wenzelm@21426
    32
wenzelm@21426
    33
(*Not provable by fast: needs multiple instantiation of ALL*)
wenzelm@21426
    34
lemma "|- (ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))"
wenzelm@21426
    35
  by best_dup
wenzelm@21426
    36
wenzelm@21426
    37
(*Needs double instantiation of the quantifier*)
wenzelm@21426
    38
lemma "|- EX x. P(x) --> P(a) & P(b)"
wenzelm@21426
    39
  by fast_dup
wenzelm@21426
    40
wenzelm@21426
    41
lemma "|- EX z. P(z) --> (ALL x. P(x))"
wenzelm@21426
    42
  by best_dup
wenzelm@21426
    43
wenzelm@21426
    44
wenzelm@21426
    45
text "Hard examples with quantifiers"
wenzelm@21426
    46
wenzelm@21426
    47
text "Problem 18"
wenzelm@21426
    48
lemma "|- EX y. ALL x. P(y)-->P(x)"
wenzelm@21426
    49
  by best_dup
wenzelm@21426
    50
wenzelm@21426
    51
text "Problem 19"
wenzelm@21426
    52
lemma "|- EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
wenzelm@21426
    53
  by best_dup
wenzelm@21426
    54
wenzelm@21426
    55
text "Problem 20"
wenzelm@21426
    56
lemma "|- (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))      
wenzelm@21426
    57
    --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
wenzelm@21426
    58
  by fast
wenzelm@21426
    59
wenzelm@21426
    60
text "Problem 21"
wenzelm@21426
    61
lemma "|- (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))"
wenzelm@21426
    62
  by best_dup
wenzelm@21426
    63
wenzelm@21426
    64
text "Problem 22"
wenzelm@21426
    65
lemma "|- (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))"
wenzelm@21426
    66
  by fast
wenzelm@21426
    67
wenzelm@21426
    68
text "Problem 23"
wenzelm@21426
    69
lemma "|- (ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))"
wenzelm@21426
    70
  by best
wenzelm@21426
    71
wenzelm@21426
    72
text "Problem 24"
wenzelm@21426
    73
lemma "|- ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &   
wenzelm@21426
    74
     ~(EX x. P(x)) --> (EX x. Q(x)) & (ALL x. Q(x)|R(x) --> S(x))   
wenzelm@21426
    75
    --> (EX x. P(x)&R(x))"
wenzelm@55228
    76
  by pc
wenzelm@21426
    77
wenzelm@21426
    78
text "Problem 25"
wenzelm@21426
    79
lemma "|- (EX x. P(x)) &   
wenzelm@21426
    80
        (ALL x. L(x) --> ~ (M(x) & R(x))) &   
wenzelm@21426
    81
        (ALL x. P(x) --> (M(x) & L(x))) &    
wenzelm@21426
    82
        ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))   
wenzelm@21426
    83
    --> (EX x. Q(x)&P(x))"
wenzelm@21426
    84
  by best
wenzelm@21426
    85
wenzelm@21426
    86
text "Problem 26"
wenzelm@21426
    87
lemma "|- ((EX x. p(x)) <-> (EX x. q(x))) &        
wenzelm@21426
    88
      (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))    
wenzelm@21426
    89
  --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))"
wenzelm@55228
    90
  by pc
wenzelm@21426
    91
wenzelm@21426
    92
text "Problem 27"
wenzelm@21426
    93
lemma "|- (EX x. P(x) & ~Q(x)) &    
wenzelm@21426
    94
              (ALL x. P(x) --> R(x)) &    
wenzelm@21426
    95
              (ALL x. M(x) & L(x) --> P(x)) &    
wenzelm@21426
    96
              ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))   
wenzelm@21426
    97
          --> (ALL x. M(x) --> ~L(x))"
wenzelm@55228
    98
  by pc
wenzelm@21426
    99
wenzelm@21426
   100
text "Problem 28.  AMENDED"
wenzelm@21426
   101
lemma "|- (ALL x. P(x) --> (ALL x. Q(x))) &    
wenzelm@21426
   102
        ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &   
wenzelm@21426
   103
        ((EX x. S(x)) --> (ALL x. L(x) --> M(x)))   
wenzelm@21426
   104
    --> (ALL x. P(x) & L(x) --> M(x))"
wenzelm@55228
   105
  by pc
wenzelm@21426
   106
wenzelm@21426
   107
text "Problem 29.  Essentially the same as Principia Mathematica *11.71"
wenzelm@21426
   108
lemma "|- (EX x. P(x)) & (EX y. Q(y))   
wenzelm@21426
   109
    --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->      
wenzelm@21426
   110
         (ALL x y. P(x) & Q(y) --> R(x) & S(y)))"
wenzelm@55228
   111
  by pc
wenzelm@21426
   112
wenzelm@21426
   113
text "Problem 30"
wenzelm@21426
   114
lemma "|- (ALL x. P(x) | Q(x) --> ~ R(x)) &  
wenzelm@21426
   115
        (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))   
wenzelm@21426
   116
    --> (ALL x. S(x))"
wenzelm@21426
   117
  by fast
wenzelm@21426
   118
wenzelm@21426
   119
text "Problem 31"
wenzelm@21426
   120
lemma "|- ~(EX x. P(x) & (Q(x) | R(x))) &  
wenzelm@21426
   121
        (EX x. L(x) & P(x)) &  
wenzelm@21426
   122
        (ALL x. ~ R(x) --> M(x))   
wenzelm@21426
   123
    --> (EX x. L(x) & M(x))"
wenzelm@21426
   124
  by fast
wenzelm@21426
   125
wenzelm@21426
   126
text "Problem 32"
wenzelm@21426
   127
lemma "|- (ALL x. P(x) & (Q(x)|R(x))-->S(x)) &  
wenzelm@21426
   128
        (ALL x. S(x) & R(x) --> L(x)) &  
wenzelm@21426
   129
        (ALL x. M(x) --> R(x))   
wenzelm@21426
   130
    --> (ALL x. P(x) & M(x) --> L(x))"
wenzelm@21426
   131
  by best
wenzelm@21426
   132
wenzelm@21426
   133
text "Problem 33"
wenzelm@21426
   134
lemma "|- (ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->     
wenzelm@21426
   135
     (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))"
wenzelm@21426
   136
  by fast
wenzelm@21426
   137
wenzelm@21426
   138
text "Problem 34  AMENDED (TWICE!!)"
wenzelm@21426
   139
(*Andrews's challenge*)
wenzelm@21426
   140
lemma "|- ((EX x. ALL y. p(x) <-> p(y))  <->               
wenzelm@21426
   141
               ((EX x. q(x)) <-> (ALL y. p(y))))     <->         
wenzelm@21426
   142
              ((EX x. ALL y. q(x) <-> q(y))  <->                 
wenzelm@21426
   143
               ((EX x. p(x)) <-> (ALL y. q(y))))"
wenzelm@21426
   144
  by best_dup
wenzelm@21426
   145
wenzelm@21426
   146
text "Problem 35"
wenzelm@21426
   147
lemma "|- EX x y. P(x,y) -->  (ALL u v. P(u,v))"
wenzelm@21426
   148
  by best_dup
wenzelm@21426
   149
wenzelm@21426
   150
text "Problem 36"
wenzelm@21426
   151
lemma "|- (ALL x. EX y. J(x,y)) &  
wenzelm@21426
   152
         (ALL x. EX y. G(x,y)) &  
wenzelm@21426
   153
         (ALL x y. J(x,y) | G(x,y) -->    
wenzelm@21426
   154
         (ALL z. J(y,z) | G(y,z) --> H(x,z)))    
wenzelm@21426
   155
         --> (ALL x. EX y. H(x,y))"
wenzelm@21426
   156
  by fast
wenzelm@21426
   157
wenzelm@21426
   158
text "Problem 37"
wenzelm@21426
   159
lemma "|- (ALL z. EX w. ALL x. EX y.  
wenzelm@21426
   160
           (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u. Q(u,w)))) &  
wenzelm@21426
   161
        (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) &  
wenzelm@21426
   162
        ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))   
wenzelm@21426
   163
    --> (ALL x. EX y. R(x,y))"
wenzelm@55228
   164
  by pc
wenzelm@21426
   165
wenzelm@21426
   166
text "Problem 38"
wenzelm@21426
   167
lemma "|- (ALL x. p(a) & (p(x) --> (EX y. p(y) & r(x,y))) -->         
wenzelm@21426
   168
                 (EX z. EX w. p(z) & r(x,w) & r(w,z)))  <->          
wenzelm@21426
   169
         (ALL x. (~p(a) | p(x) | (EX z. EX w. p(z) & r(x,w) & r(w,z))) &     
wenzelm@21426
   170
                 (~p(a) | ~(EX y. p(y) & r(x,y)) |                           
wenzelm@21426
   171
                 (EX z. EX w. p(z) & r(x,w) & r(w,z))))"
wenzelm@55228
   172
  by pc
wenzelm@21426
   173
wenzelm@21426
   174
text "Problem 39"
wenzelm@21426
   175
lemma "|- ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))"
wenzelm@21426
   176
  by fast
wenzelm@21426
   177
wenzelm@21426
   178
text "Problem 40.  AMENDED"
wenzelm@21426
   179
lemma "|- (EX y. ALL x. F(x,y) <-> F(x,x)) -->   
wenzelm@21426
   180
         ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))"
wenzelm@21426
   181
  by fast
wenzelm@21426
   182
wenzelm@21426
   183
text "Problem 41"
wenzelm@21426
   184
lemma "|- (ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))       
wenzelm@21426
   185
         --> ~ (EX z. ALL x. f(x,z))"
wenzelm@21426
   186
  by fast
wenzelm@21426
   187
wenzelm@21426
   188
text "Problem 42"
wenzelm@21426
   189
lemma "|- ~ (EX y. ALL x. p(x,y) <-> ~ (EX z. p(x,z) & p(z,x)))"
wenzelm@21426
   190
  oops
wenzelm@21426
   191
wenzelm@21426
   192
text "Problem 43"
wenzelm@21426
   193
lemma "|- (ALL x. ALL y. q(x,y) <-> (ALL z. p(z,x) <-> p(z,y)))  
wenzelm@21426
   194
          --> (ALL x. (ALL y. q(x,y) <-> q(y,x)))"
wenzelm@21426
   195
  oops
wenzelm@21426
   196
wenzelm@21426
   197
text "Problem 44"
wenzelm@21426
   198
lemma "|- (ALL x. f(x) -->                                         
wenzelm@21426
   199
                 (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &        
wenzelm@21426
   200
         (EX x. j(x) & (ALL y. g(y) --> h(x,y)))                    
wenzelm@21426
   201
         --> (EX x. j(x) & ~f(x))"
wenzelm@21426
   202
  by fast
wenzelm@21426
   203
wenzelm@21426
   204
text "Problem 45"
wenzelm@21426
   205
lemma "|- (ALL x. f(x) & (ALL y. g(y) & h(x,y) --> j(x,y))         
wenzelm@21426
   206
                      --> (ALL y. g(y) & h(x,y) --> k(y))) &     
wenzelm@21426
   207
      ~ (EX y. l(y) & k(y)) &                                    
wenzelm@21426
   208
      (EX x. f(x) & (ALL y. h(x,y) --> l(y))                     
wenzelm@21426
   209
                   & (ALL y. g(y) & h(x,y) --> j(x,y)))          
wenzelm@21426
   210
      --> (EX x. f(x) & ~ (EX y. g(y) & h(x,y)))"
wenzelm@21426
   211
  by best
wenzelm@21426
   212
wenzelm@21426
   213
wenzelm@21426
   214
text "Problems (mainly) involving equality or functions"
wenzelm@21426
   215
wenzelm@21426
   216
text "Problem 48"
wenzelm@21426
   217
lemma "|- (a=b | c=d) & (a=c | b=d) --> a=d | b=c"
wenzelm@55228
   218
  by (fast add!: subst)
wenzelm@21426
   219
wenzelm@21426
   220
text "Problem 50"
wenzelm@21426
   221
lemma "|- (ALL x. P(a,x) | (ALL y. P(x,y))) --> (EX x. ALL y. P(x,y))"
wenzelm@21426
   222
  by best_dup
wenzelm@21426
   223
wenzelm@21426
   224
text "Problem 51"
wenzelm@21426
   225
lemma "|- (EX z w. ALL x y. P(x,y) <->  (x=z & y=w)) -->   
wenzelm@21426
   226
         (EX z. ALL x. EX w. (ALL y. P(x,y) <-> y=w) <-> x=z)"
wenzelm@55228
   227
  by (fast add!: subst)
wenzelm@21426
   228
wenzelm@21426
   229
text "Problem 52"  (*Almost the same as 51. *)
wenzelm@21426
   230
lemma "|- (EX z w. ALL x y. P(x,y) <->  (x=z & y=w)) -->
wenzelm@21426
   231
         (EX w. ALL y. EX z. (ALL x. P(x,y) <-> x=z) <-> y=w)"
wenzelm@55228
   232
  by (fast add!: subst)
wenzelm@21426
   233
wenzelm@21426
   234
text "Problem 56"
wenzelm@21426
   235
lemma "|- (ALL x.(EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))"
wenzelm@55228
   236
  by (best add: symL subst)
wenzelm@21426
   237
  (*requires tricker to orient the equality properly*)
wenzelm@21426
   238
wenzelm@21426
   239
text "Problem 57"
wenzelm@21426
   240
lemma "|- P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) &  
wenzelm@21426
   241
         (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))"
wenzelm@21426
   242
  by fast
wenzelm@21426
   243
wenzelm@21426
   244
text "Problem 58!"
wenzelm@21426
   245
lemma "|- (ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))"
wenzelm@55228
   246
  by (fast add!: subst)
wenzelm@21426
   247
wenzelm@21426
   248
text "Problem 59"
wenzelm@21426
   249
(*Unification works poorly here -- the abstraction %sobj prevents efficient
wenzelm@21426
   250
  operation of the occurs check*)
wenzelm@24178
   251
wenzelm@21426
   252
lemma "|- (ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))"
wenzelm@21426
   253
  by best_dup
wenzelm@21426
   254
wenzelm@21426
   255
text "Problem 60"
wenzelm@21426
   256
lemma "|- ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))"
wenzelm@21426
   257
  by fast
wenzelm@21426
   258
wenzelm@21426
   259
text "Problem 62 as corrected in JAR 18 (1997), page 135"
wenzelm@21426
   260
lemma "|- (ALL x. p(a) & (p(x) --> p(f(x))) --> p(f(f(x))))  <->
wenzelm@21426
   261
      (ALL x. (~p(a) | p(x) | p(f(f(x)))) &                       
wenzelm@21426
   262
              (~p(a) | ~p(f(x)) | p(f(f(x)))))"
wenzelm@21426
   263
  by fast
wenzelm@21426
   264
wenzelm@21426
   265
(*18 June 92: loaded in 372 secs*)
wenzelm@21426
   266
(*19 June 92: loaded in 166 secs except #34, using repeat_goal_tac*)
wenzelm@21426
   267
(*29 June 92: loaded in 370 secs*)
wenzelm@21426
   268
(*18 September 2005: loaded in 1.809 secs*)
wenzelm@21426
   269
wenzelm@21426
   270
end