src/FOLP/ex/cla.ML
 changeset 0 a5a9c433f639 child 1459 d12da312eff4
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/FOLP/ex/cla.ML	Thu Sep 16 12:20:38 1993 +0200
1.3 @@ -0,0 +1,360 @@
1.4 +(*  Title: 	FOLP/ex/cla
1.5 +    ID:         \$Id\$
1.6 +    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
1.7 +    Copyright   1993  University of Cambridge
1.8 +
1.9 +Classical First-Order Logic
1.10 +*)
1.11 +
1.12 +writeln"File FOL/ex/cla.";
1.13 +
1.14 +open Cla;    (*in case structure Int is open!*)
1.15 +
1.16 +goal FOLP.thy "?p : (P --> Q | R) --> (P-->Q) | (P-->R)";
1.17 +by (fast_tac FOLP_cs 1);
1.18 +result();
1.19 +
1.20 +(*If and only if*)
1.21 +
1.22 +goal FOLP.thy "?p : (P<->Q) <-> (Q<->P)";
1.23 +by (fast_tac FOLP_cs 1);
1.24 +result();
1.25 +
1.26 +goal FOLP.thy "?p : ~ (P <-> ~P)";
1.27 +by (fast_tac FOLP_cs 1);
1.28 +result();
1.29 +
1.30 +
1.31 +(*Sample problems from
1.32 +  F. J. Pelletier,
1.33 +  Seventy-Five Problems for Testing Automatic Theorem Provers,
1.34 +  J. Automated Reasoning 2 (1986), 191-216.
1.35 +  Errata, JAR 4 (1988), 236-236.
1.36 +
1.37 +The hardest problems -- judging by experience with several theorem provers,
1.38 +including matrix ones -- are 34 and 43.
1.39 +*)
1.40 +
1.41 +writeln"Pelletier's examples";
1.42 +(*1*)
1.43 +goal FOLP.thy "?p : (P-->Q)  <->  (~Q --> ~P)";
1.44 +by (fast_tac FOLP_cs 1);
1.45 +result();
1.46 +
1.47 +(*2*)
1.48 +goal FOLP.thy "?p : ~ ~ P  <->  P";
1.49 +by (fast_tac FOLP_cs 1);
1.50 +result();
1.51 +
1.52 +(*3*)
1.53 +goal FOLP.thy "?p : ~(P-->Q) --> (Q-->P)";
1.54 +by (fast_tac FOLP_cs 1);
1.55 +result();
1.56 +
1.57 +(*4*)
1.58 +goal FOLP.thy "?p : (~P-->Q)  <->  (~Q --> P)";
1.59 +by (fast_tac FOLP_cs 1);
1.60 +result();
1.61 +
1.62 +(*5*)
1.63 +goal FOLP.thy "?p : ((P|Q)-->(P|R)) --> (P|(Q-->R))";
1.64 +by (fast_tac FOLP_cs 1);
1.65 +result();
1.66 +
1.67 +(*6*)
1.68 +goal FOLP.thy "?p : P | ~ P";
1.69 +by (fast_tac FOLP_cs 1);
1.70 +result();
1.71 +
1.72 +(*7*)
1.73 +goal FOLP.thy "?p : P | ~ ~ ~ P";
1.74 +by (fast_tac FOLP_cs 1);
1.75 +result();
1.76 +
1.77 +(*8.  Peirce's law*)
1.78 +goal FOLP.thy "?p : ((P-->Q) --> P)  -->  P";
1.79 +by (fast_tac FOLP_cs 1);
1.80 +result();
1.81 +
1.82 +(*9*)
1.83 +goal FOLP.thy "?p : ((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)";
1.84 +by (fast_tac FOLP_cs 1);
1.85 +result();
1.86 +
1.87 +(*10*)
1.88 +goal FOLP.thy "?p : (Q-->R) & (R-->P&Q) & (P-->Q|R) --> (P<->Q)";
1.89 +by (fast_tac FOLP_cs 1);
1.90 +result();
1.91 +
1.92 +(*11.  Proved in each direction (incorrectly, says Pelletier!!)  *)
1.93 +goal FOLP.thy "?p : P<->P";
1.94 +by (fast_tac FOLP_cs 1);
1.95 +result();
1.96 +
1.97 +(*12.  "Dijkstra's law"*)
1.98 +goal FOLP.thy "?p : ((P <-> Q) <-> R)  <->  (P <-> (Q <-> R))";
1.99 +by (fast_tac FOLP_cs 1);
1.100 +result();
1.101 +
1.102 +(*13.  Distributive law*)
1.103 +goal FOLP.thy "?p : P | (Q & R)  <-> (P | Q) & (P | R)";
1.104 +by (fast_tac FOLP_cs 1);
1.105 +result();
1.106 +
1.107 +(*14*)
1.108 +goal FOLP.thy "?p : (P <-> Q) <-> ((Q | ~P) & (~Q|P))";
1.109 +by (fast_tac FOLP_cs 1);
1.110 +result();
1.111 +
1.112 +(*15*)
1.113 +goal FOLP.thy "?p : (P --> Q) <-> (~P | Q)";
1.114 +by (fast_tac FOLP_cs 1);
1.115 +result();
1.116 +
1.117 +(*16*)
1.118 +goal FOLP.thy "?p : (P-->Q) | (Q-->P)";
1.119 +by (fast_tac FOLP_cs 1);
1.120 +result();
1.121 +
1.122 +(*17*)
1.123 +goal FOLP.thy "?p : ((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S))";
1.124 +by (fast_tac FOLP_cs 1);
1.125 +result();
1.126 +
1.127 +writeln"Classical Logic: examples with quantifiers";
1.128 +
1.129 +goal FOLP.thy "?p : (ALL x. P(x) & Q(x)) <-> (ALL x. P(x))  &  (ALL x. Q(x))";
1.130 +by (fast_tac FOLP_cs 1);
1.131 +result();
1.132 +
1.133 +goal FOLP.thy "?p : (EX x. P-->Q(x))  <->  (P --> (EX x.Q(x)))";
1.134 +by (fast_tac FOLP_cs 1);
1.135 +result();
1.136 +
1.137 +goal FOLP.thy "?p : (EX x.P(x)-->Q)  <->  (ALL x.P(x)) --> Q";
1.138 +by (fast_tac FOLP_cs 1);
1.139 +result();
1.140 +
1.141 +goal FOLP.thy "?p : (ALL x.P(x)) | Q  <->  (ALL x. P(x) | Q)";
1.142 +by (fast_tac FOLP_cs 1);
1.143 +result();
1.144 +
1.145 +writeln"Problems requiring quantifier duplication";
1.146 +
1.147 +(*Needs multiple instantiation of ALL.*)
1.148 +(*
1.149 +goal FOLP.thy "?p : (ALL x. P(x)-->P(f(x)))  &  P(d)-->P(f(f(f(d))))";
1.150 +by (best_tac FOLP_dup_cs 1);
1.151 +result();
1.152 +*)
1.153 +(*Needs double instantiation of the quantifier*)
1.154 +goal FOLP.thy "?p : EX x. P(x) --> P(a) & P(b)";
1.155 +by (best_tac FOLP_dup_cs 1);
1.156 +result();
1.157 +
1.158 +goal FOLP.thy "?p : EX z. P(z) --> (ALL x. P(x))";
1.159 +by (best_tac FOLP_dup_cs 1);
1.160 +result();
1.161 +
1.162 +
1.163 +writeln"Hard examples with quantifiers";
1.164 +
1.165 +writeln"Problem 18";
1.166 +goal FOLP.thy "?p : EX y. ALL x. P(y)-->P(x)";
1.167 +by (best_tac FOLP_dup_cs 1);
1.168 +result();
1.169 +
1.170 +writeln"Problem 19";
1.171 +goal FOLP.thy "?p : EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x))";
1.172 +by (best_tac FOLP_dup_cs 1);
1.173 +result();
1.174 +
1.175 +writeln"Problem 20";
1.176 +goal FOLP.thy "?p : (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))     \
1.177 +\   --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))";
1.178 +by (fast_tac FOLP_cs 1);
1.179 +result();
1.180 +(*
1.181 +writeln"Problem 21";
1.182 +goal FOLP.thy "?p : (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> (EX x. P<->Q(x))";
1.183 +by (best_tac FOLP_dup_cs 1);
1.184 +result();
1.185 +*)
1.186 +writeln"Problem 22";
1.187 +goal FOLP.thy "?p : (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))";
1.188 +by (fast_tac FOLP_cs 1);
1.189 +result();
1.190 +
1.191 +writeln"Problem 23";
1.192 +goal FOLP.thy "?p : (ALL x. P | Q(x))  <->  (P | (ALL x. Q(x)))";
1.193 +by (best_tac FOLP_cs 1);
1.194 +result();
1.195 +
1.196 +writeln"Problem 24";
1.197 +goal FOLP.thy "?p : ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &  \
1.198 +\    ~(EX x.P(x)) --> (EX x.Q(x)) & (ALL x. Q(x)|R(x) --> S(x))  \
1.199 +\   --> (EX x. P(x)&R(x))";
1.200 +by (fast_tac FOLP_cs 1);
1.201 +result();
1.202 +(*
1.203 +writeln"Problem 25";
1.204 +goal FOLP.thy "?p : (EX x. P(x)) &  \
1.205 +\       (ALL x. L(x) --> ~ (M(x) & R(x))) &  \
1.206 +\       (ALL x. P(x) --> (M(x) & L(x))) &   \
1.207 +\       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  \
1.208 +\   --> (EX x. Q(x)&P(x))";
1.209 +by (best_tac FOLP_cs 1);
1.210 +result();
1.211 +
1.212 +writeln"Problem 26";
1.213 +goal FOLP.thy "?u : ((EX x. p(x)) <-> (EX x. q(x))) &	\
1.214 +\     (ALL x. ALL y. p(x) & q(y) --> (r(x) <-> s(y)))	\
1.215 +\ --> ((ALL x. p(x)-->r(x)) <-> (ALL x. q(x)-->s(x)))";
1.216 +by (fast_tac FOLP_cs 1);
1.217 +result();
1.218 +*)
1.219 +writeln"Problem 27";
1.220 +goal FOLP.thy "?p : (EX x. P(x) & ~Q(x)) &   \
1.221 +\             (ALL x. P(x) --> R(x)) &   \
1.222 +\             (ALL x. M(x) & L(x) --> P(x)) &   \
1.223 +\             ((EX x. R(x) & ~ Q(x)) --> (ALL x. L(x) --> ~ R(x)))  \
1.224 +\         --> (ALL x. M(x) --> ~L(x))";
1.225 +by (fast_tac FOLP_cs 1);
1.226 +result();
1.227 +
1.228 +writeln"Problem 28.  AMENDED";
1.229 +goal FOLP.thy "?p : (ALL x. P(x) --> (ALL x. Q(x))) &   \
1.230 +\       ((ALL x. Q(x)|R(x)) --> (EX x. Q(x)&S(x))) &  \
1.231 +\       ((EX x.S(x)) --> (ALL x. L(x) --> M(x)))  \
1.232 +\   --> (ALL x. P(x) & L(x) --> M(x))";
1.233 +by (fast_tac FOLP_cs 1);
1.234 +result();
1.235 +
1.236 +writeln"Problem 29.  Essentially the same as Principia Mathematica *11.71";
1.237 +goal FOLP.thy "?p : (EX x. P(x)) & (EX y. Q(y))  \
1.238 +\   --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->     \
1.239 +\        (ALL x y. P(x) & Q(y) --> R(x) & S(y)))";
1.240 +by (fast_tac FOLP_cs 1);
1.241 +result();
1.242 +
1.243 +writeln"Problem 30";
1.244 +goal FOLP.thy "?p : (ALL x. P(x) | Q(x) --> ~ R(x)) & \
1.245 +\       (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))  \
1.246 +\   --> (ALL x. S(x))";
1.247 +by (fast_tac FOLP_cs 1);
1.248 +result();
1.249 +
1.250 +writeln"Problem 31";
1.251 +goal FOLP.thy "?p : ~(EX x.P(x) & (Q(x) | R(x))) & \
1.252 +\       (EX x. L(x) & P(x)) & \
1.253 +\       (ALL x. ~ R(x) --> M(x))  \
1.254 +\   --> (EX x. L(x) & M(x))";
1.255 +by (fast_tac FOLP_cs 1);
1.256 +result();
1.257 +
1.258 +writeln"Problem 32";
1.259 +goal FOLP.thy "?p : (ALL x. P(x) & (Q(x)|R(x))-->S(x)) & \
1.260 +\       (ALL x. S(x) & R(x) --> L(x)) & \
1.261 +\       (ALL x. M(x) --> R(x))  \
1.262 +\   --> (ALL x. P(x) & M(x) --> L(x))";
1.263 +by (best_tac FOLP_cs 1);
1.264 +result();
1.265 +
1.266 +writeln"Problem 33";
1.267 +goal FOLP.thy "?p : (ALL x. P(a) & (P(x)-->P(b))-->P(c))  <->    \
1.268 +\    (ALL x. (~P(a) | P(x) | P(c)) & (~P(a) | ~P(b) | P(c)))";
1.269 +by (best_tac FOLP_cs 1);
1.270 +result();
1.271 +
1.272 +writeln"Problem 35";
1.273 +goal FOLP.thy "?p : EX x y. P(x,y) -->  (ALL u v. P(u,v))";
1.274 +by (best_tac FOLP_dup_cs 1);
1.275 +result();
1.276 +
1.277 +writeln"Problem 36";
1.278 +goal FOLP.thy
1.279 +"?p : (ALL x. EX y. J(x,y)) & \
1.280 +\     (ALL x. EX y. G(x,y)) & \
1.281 +\     (ALL x y. J(x,y) | G(x,y) --> (ALL z. J(y,z) | G(y,z) --> H(x,z)))   \
1.282 +\ --> (ALL x. EX y. H(x,y))";
1.283 +by (fast_tac FOLP_cs 1);
1.284 +result();
1.285 +
1.286 +writeln"Problem 37";
1.287 +goal FOLP.thy "?p : (ALL z. EX w. ALL x. EX y. \
1.288 +\          (P(x,z)-->P(y,w)) & P(y,z) & (P(y,w) --> (EX u.Q(u,w)))) & \
1.289 +\       (ALL x z. ~P(x,z) --> (EX y. Q(y,z))) & \
1.290 +\       ((EX x y. Q(x,y)) --> (ALL x. R(x,x)))  \
1.291 +\   --> (ALL x. EX y. R(x,y))";
1.292 +by (fast_tac FOLP_cs 1);
1.293 +result();
1.294 +
1.295 +writeln"Problem 39";
1.296 +goal FOLP.thy "?p : ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
1.297 +by (fast_tac FOLP_cs 1);
1.298 +result();
1.299 +
1.300 +writeln"Problem 40.  AMENDED";
1.301 +goal FOLP.thy "?p : (EX y. ALL x. F(x,y) <-> F(x,x)) -->  \
1.302 +\             ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))";
1.303 +by (fast_tac FOLP_cs 1);
1.304 +result();
1.305 +
1.306 +writeln"Problem 41";
1.307 +goal FOLP.thy "?p : (ALL z. EX y. ALL x. f(x,y) <-> f(x,z) & ~ f(x,x))	\
1.308 +\         --> ~ (EX z. ALL x. f(x,z))";
1.309 +by (best_tac FOLP_cs 1);
1.310 +result();
1.311 +
1.312 +writeln"Problem 44";
1.313 +goal FOLP.thy "?p : (ALL x. f(x) -->					\
1.314 +\             (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &   	\
1.315 +\             (EX x. j(x) & (ALL y. g(y) --> h(x,y)))			\
1.316 +\             --> (EX x. j(x) & ~f(x))";
1.317 +by (fast_tac FOLP_cs 1);
1.318 +result();
1.319 +
1.320 +writeln"Problems (mainly) involving equality or functions";
1.321 +
1.322 +writeln"Problem 48";
1.323 +goal FOLP.thy "?p : (a=b | c=d) & (a=c | b=d) --> a=d | b=c";
1.324 +by (fast_tac FOLP_cs 1);
1.325 +result();
1.326 +
1.327 +writeln"Problem 50";
1.328 +(*What has this to do with equality?*)
1.329 +goal FOLP.thy "?p : (ALL x. P(a,x) | (ALL y.P(x,y))) --> (EX x. ALL y.P(x,y))";
1.330 +by (best_tac FOLP_dup_cs 1);
1.331 +result();
1.332 +
1.333 +writeln"Problem 56";
1.334 +goal FOLP.thy
1.335 + "?p : (ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))";
1.336 +by (fast_tac FOLP_cs 1);
1.337 +result();
1.338 +
1.339 +writeln"Problem 57";
1.340 +goal FOLP.thy
1.341 +"?p : P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) & \
1.342 +\     (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))";
1.343 +by (fast_tac FOLP_cs 1);
1.344 +result();
1.345 +
1.346 +writeln"Problem 58  NOT PROVED AUTOMATICALLY";
1.347 +goal FOLP.thy "?p : (ALL x y. f(x)=g(y)) --> (ALL x y. f(f(x))=f(g(y)))";
1.348 +val f_cong = read_instantiate [("t","f")] subst_context;
1.349 +by (fast_tac (FOLP_cs addIs [f_cong]) 1);
1.350 +result();
1.351 +
1.352 +writeln"Problem 59";
1.353 +goal FOLP.thy "?p : (ALL x. P(x) <-> ~P(f(x))) --> (EX x. P(x) & ~P(f(x)))";
1.354 +by (best_tac FOLP_dup_cs 1);
1.355 +result();
1.356 +
1.357 +writeln"Problem 60";
1.358 +goal FOLP.thy
1.359 +"?p : ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))";
1.360 +by (fast_tac FOLP_cs 1);
1.361 +result();
1.362 +
1.363 +writeln"Reached end of file.";
```