src/FOLP/ex/Classical.thy
author wenzelm
Fri Apr 23 23:35:43 2010 +0200 (2010-04-23)
changeset 36319 8feb2c4bef1a
parent 35762 af3ff2ba4c54
child 58860 fee7cfa69c50
permissions -rw-r--r--
mark schematic statements explicitly;
     1 (*  Title:      FOLP/ex/Classical.thy
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Copyright   1993  University of Cambridge
     4 
     5 Classical First-Order Logic.
     6 *)
     7 
     8 theory Classical
     9 imports FOLP
    10 begin
    11 
    12 schematic_lemma "?p : (P --> Q | R) --> (P-->Q) | (P-->R)"
    13   by (tactic "fast_tac FOLP_cs 1")
    14 
    15 (*If and only if*)
    16 schematic_lemma "?p : (P<->Q) <-> (Q<->P)"
    17   by (tactic "fast_tac FOLP_cs 1")
    18 
    19 schematic_lemma "?p : ~ (P <-> ~P)"
    20   by (tactic "fast_tac FOLP_cs 1")
    21 
    22 
    23 (*Sample problems from 
    24   F. J. Pelletier, 
    25   Seventy-Five Problems for Testing Automatic Theorem Provers,
    26   J. Automated Reasoning 2 (1986), 191-216.
    27   Errata, JAR 4 (1988), 236-236.
    28 
    29 The hardest problems -- judging by experience with several theorem provers,
    30 including matrix ones -- are 34 and 43.
    31 *)
    32 
    33 text "Pelletier's examples"
    34 (*1*)
    35 schematic_lemma "?p : (P-->Q)  <->  (~Q --> ~P)"
    36   by (tactic "fast_tac FOLP_cs 1")
    37 
    38 (*2*)
    39 schematic_lemma "?p : ~ ~ P  <->  P"
    40   by (tactic "fast_tac FOLP_cs 1")
    41 
    42 (*3*)
    43 schematic_lemma "?p : ~(P-->Q) --> (Q-->P)"
    44   by (tactic "fast_tac FOLP_cs 1")
    45 
    46 (*4*)
    47 schematic_lemma "?p : (~P-->Q)  <->  (~Q --> P)"
    48   by (tactic "fast_tac FOLP_cs 1")
    49 
    50 (*5*)
    51 schematic_lemma "?p : ((P|Q)-->(P|R)) --> (P|(Q-->R))"
    52   by (tactic "fast_tac FOLP_cs 1")
    53 
    54 (*6*)
    55 schematic_lemma "?p : P | ~ P"
    56   by (tactic "fast_tac FOLP_cs 1")
    57 
    58 (*7*)
    59 schematic_lemma "?p : P | ~ ~ ~ P"
    60   by (tactic "fast_tac FOLP_cs 1")
    61 
    62 (*8.  Peirce's law*)
    63 schematic_lemma "?p : ((P-->Q) --> P)  -->  P"
    64   by (tactic "fast_tac FOLP_cs 1")
    65 
    66 (*9*)
    67 schematic_lemma "?p : ((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)"
    68   by (tactic "fast_tac FOLP_cs 1")
    69 
    70 (*10*)
    71 schematic_lemma "?p : (Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P<->Q)"
    72   by (tactic "fast_tac FOLP_cs 1")
    73 
    74 (*11.  Proved in each direction (incorrectly, says Pelletier!!)  *)
    75 schematic_lemma "?p : P<->P"
    76   by (tactic "fast_tac FOLP_cs 1")
    77 
    78 (*12.  "Dijkstra's law"*)
    79 schematic_lemma "?p : ((P <-> Q) <-> R)  <->  (P <-> (Q <-> R))"
    80   by (tactic "fast_tac FOLP_cs 1")
    81 
    82 (*13.  Distributive law*)
    83 schematic_lemma "?p : P | (Q & R)  <-> (P | Q) & (P | R)"
    84   by (tactic "fast_tac FOLP_cs 1")
    85 
    86 (*14*)
    87 schematic_lemma "?p : (P <-> Q) <-> ((Q | ~P) & (~Q|P))"
    88   by (tactic "fast_tac FOLP_cs 1")
    89 
    90 (*15*)
    91 schematic_lemma "?p : (P --> Q) <-> (~P | Q)"
    92   by (tactic "fast_tac FOLP_cs 1")
    93 
    94 (*16*)
    95 schematic_lemma "?p : (P-->Q) | (Q-->P)"
    96   by (tactic "fast_tac FOLP_cs 1")
    97 
    98 (*17*)
    99 schematic_lemma "?p : ((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S))"
   100   by (tactic "fast_tac FOLP_cs 1")
   101 
   102 
   103 text "Classical Logic: examples with quantifiers"
   104 
   105 schematic_lemma "?p : (ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))"
   106   by (tactic "fast_tac FOLP_cs 1")
   107 
   108 schematic_lemma "?p : (EX x. P-->Q(x))  <->  (P --> (EX x. Q(x)))"
   109   by (tactic "fast_tac FOLP_cs 1")
   110 
   111 schematic_lemma "?p : (EX x. P(x)-->Q)  <->  (ALL x. P(x)) --> Q"
   112   by (tactic "fast_tac FOLP_cs 1")
   113 
   114 schematic_lemma "?p : (ALL x. P(x)) | Q  <->  (ALL x. P(x) | Q)"
   115   by (tactic "fast_tac FOLP_cs 1")
   116 
   117 
   118 text "Problems requiring quantifier duplication"
   119 
   120 (*Needs multiple instantiation of ALL.*)
   121 schematic_lemma "?p : (ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))"
   122   by (tactic "best_tac FOLP_dup_cs 1")
   123 
   124 (*Needs double instantiation of the quantifier*)
   125 schematic_lemma "?p : EX x. P(x) --> P(a) & P(b)"
   126   by (tactic "best_tac FOLP_dup_cs 1")
   127 
   128 schematic_lemma "?p : EX z. P(z) --> (ALL x. P(x))"
   129   by (tactic "best_tac FOLP_dup_cs 1")
   130 
   131 
   132 text "Hard examples with quantifiers"
   133 
   134 text "Problem 18"
   135 schematic_lemma "?p : EX y. ALL x. P(y)-->P(x)"
   136   by (tactic "best_tac FOLP_dup_cs 1")
   137 
   138 text "Problem 19"
   139 schematic_lemma "?p : EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))"
   140   by (tactic "best_tac FOLP_dup_cs 1")
   141 
   142 text "Problem 20"
   143 schematic_lemma "?p : (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))      
   144     --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))"
   145   by (tactic "fast_tac FOLP_cs 1")
   146 
   147 text "Problem 21"
   148 schematic_lemma "?p : (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))";
   149   by (tactic "best_tac FOLP_dup_cs 1")
   150 
   151 text "Problem 22"
   152 schematic_lemma "?p : (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))"
   153   by (tactic "fast_tac FOLP_cs 1")
   154 
   155 text "Problem 23"
   156 schematic_lemma "?p : (ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))"
   157   by (tactic "best_tac FOLP_dup_cs 1")
   158 
   159 text "Problem 24"
   160 schematic_lemma "?p : ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &   
   161      (~(EX x. P(x)) --> (EX x. Q(x))) & (ALL x. Q(x)|R(x) --> S(x))   
   162     --> (EX x. P(x)&R(x))"
   163   by (tactic "fast_tac FOLP_cs 1")
   164 
   165 text "Problem 25"
   166 schematic_lemma "?p : (EX x. P(x)) &  
   167        (ALL x. L(x) --> ~ (M(x) & R(x))) &  
   168        (ALL x. P(x) --> (M(x) & L(x))) &   
   169        ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  
   170    --> (EX x. Q(x)&P(x))"
   171   oops
   172 
   173 text "Problem 26"
   174 schematic_lemma "?u : ((EX x. p(x)) <-> (EX x. q(x))) &   
   175      (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))   
   176   --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))";
   177   by (tactic "fast_tac FOLP_cs 1")
   178 
   179 text "Problem 27"
   180 schematic_lemma "?p : (EX x. P(x) & ~Q(x)) &    
   181               (ALL x. P(x) --> R(x)) &    
   182               (ALL x. M(x) & L(x) --> P(x)) &    
   183               ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))   
   184           --> (ALL x. M(x) --> ~L(x))"
   185   by (tactic "fast_tac FOLP_cs 1")
   186 
   187 text "Problem 28.  AMENDED"
   188 schematic_lemma "?p : (ALL x. P(x) --> (ALL x. Q(x))) &    
   189         ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &   
   190         ((EX x. S(x)) --> (ALL x. L(x) --> M(x)))   
   191     --> (ALL x. P(x) & L(x) --> M(x))"
   192   by (tactic "fast_tac FOLP_cs 1")
   193 
   194 text "Problem 29.  Essentially the same as Principia Mathematica *11.71"
   195 schematic_lemma "?p : (EX x. P(x)) & (EX y. Q(y))   
   196     --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->      
   197          (ALL x y. P(x) & Q(y) --> R(x) & S(y)))"
   198   by (tactic "fast_tac FOLP_cs 1")
   199 
   200 text "Problem 30"
   201 schematic_lemma "?p : (ALL x. P(x) | Q(x) --> ~ R(x)) &  
   202         (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))   
   203     --> (ALL x. S(x))"
   204   by (tactic "fast_tac FOLP_cs 1")
   205 
   206 text "Problem 31"
   207 schematic_lemma "?p : ~(EX x. P(x) & (Q(x) | R(x))) &  
   208         (EX x. L(x) & P(x)) &  
   209         (ALL x. ~ R(x) --> M(x))   
   210     --> (EX x. L(x) & M(x))"
   211   by (tactic "fast_tac FOLP_cs 1")
   212 
   213 text "Problem 32"
   214 schematic_lemma "?p : (ALL x. P(x) & (Q(x)|R(x))-->S(x)) &  
   215         (ALL x. S(x) & R(x) --> L(x)) &  
   216         (ALL x. M(x) --> R(x))   
   217     --> (ALL x. P(x) & M(x) --> L(x))"
   218   by (tactic "best_tac FOLP_dup_cs 1")
   219 
   220 text "Problem 33"
   221 schematic_lemma "?p : (ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->     
   222      (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))"
   223   by (tactic "best_tac FOLP_dup_cs 1")
   224 
   225 text "Problem 35"
   226 schematic_lemma "?p : EX x y. P(x,y) -->  (ALL u v. P(u,v))"
   227   by (tactic "best_tac FOLP_dup_cs 1")
   228 
   229 text "Problem 36"
   230 schematic_lemma
   231 "?p : (ALL x. EX y. J(x,y)) &  
   232       (ALL x. EX y. G(x,y)) &  
   233       (ALL x y. J(x,y) | G(x,y) --> (ALL z. J(y,z) | G(y,z) --> H(x,z)))    
   234   --> (ALL x. EX y. H(x,y))"
   235   by (tactic "fast_tac FOLP_cs 1")
   236 
   237 text "Problem 37"
   238 schematic_lemma "?p : (ALL z. EX w. ALL x. EX y.  
   239            (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u. Q(u,w)))) &  
   240         (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) &  
   241         ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))   
   242     --> (ALL x. EX y. R(x,y))"
   243   by (tactic "fast_tac FOLP_cs 1")
   244 
   245 text "Problem 39"
   246 schematic_lemma "?p : ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))"
   247   by (tactic "fast_tac FOLP_cs 1")
   248 
   249 text "Problem 40.  AMENDED"
   250 schematic_lemma "?p : (EX y. ALL x. F(x,y) <-> F(x,x)) -->   
   251               ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))"
   252   by (tactic "fast_tac FOLP_cs 1")
   253 
   254 text "Problem 41"
   255 schematic_lemma "?p : (ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))   
   256           --> ~ (EX z. ALL x. f(x,z))"
   257   by (tactic "best_tac FOLP_dup_cs 1")
   258 
   259 text "Problem 44"
   260 schematic_lemma "?p : (ALL x. f(x) -->                                     
   261               (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &        
   262               (EX x. j(x) & (ALL y. g(y) --> h(x,y)))                    
   263               --> (EX x. j(x) & ~f(x))"
   264   by (tactic "fast_tac FOLP_cs 1")
   265 
   266 text "Problems (mainly) involving equality or functions"
   267 
   268 text "Problem 48"
   269 schematic_lemma "?p : (a=b | c=d) & (a=c | b=d) --> a=d | b=c"
   270   by (tactic "fast_tac FOLP_cs 1")
   271 
   272 text "Problem 50"
   273 (*What has this to do with equality?*)
   274 schematic_lemma "?p : (ALL x. P(a,x) | (ALL y. P(x,y))) --> (EX x. ALL y. P(x,y))"
   275   by (tactic "best_tac FOLP_dup_cs 1")
   276 
   277 text "Problem 56"
   278 schematic_lemma
   279  "?p : (ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))"
   280   by (tactic "fast_tac FOLP_cs 1")
   281 
   282 text "Problem 57"
   283 schematic_lemma
   284 "?p : P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) &  
   285       (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))"
   286   by (tactic "fast_tac FOLP_cs 1")
   287 
   288 text "Problem 58  NOT PROVED AUTOMATICALLY"
   289 schematic_lemma
   290   notes f_cong = subst_context [where t = f]
   291   shows "?p : (ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))"
   292   by (tactic {* fast_tac (FOLP_cs addSIs [@{thm f_cong}]) 1 *})
   293 
   294 text "Problem 59"
   295 schematic_lemma "?p : (ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))"
   296   by (tactic "best_tac FOLP_dup_cs 1")
   297 
   298 text "Problem 60"
   299 schematic_lemma "?p : ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))"
   300   by (tactic "fast_tac FOLP_cs 1")
   301 
   302 end