src/FOLP/ex/int.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/int.ML	Thu Sep 16 12:20:38 1993 +0200
     1.3 @@ -0,0 +1,361 @@
     1.4 +(*  Title: 	FOL/ex/int
     1.5 +    ID:         $Id$
     1.6 +    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1991  University of Cambridge
     1.8 +
     1.9 +Intuitionistic First-Order Logic
    1.10 +
    1.11 +Single-step commands:
    1.12 +by (Int.step_tac 1);
    1.13 +by (biresolve_tac safe_brls 1);
    1.14 +by (biresolve_tac haz_brls 1);
    1.15 +by (assume_tac 1);
    1.16 +by (Int.safe_tac 1);
    1.17 +by (Int.mp_tac 1);
    1.18 +by (Int.fast_tac 1);
    1.19 +*)
    1.20 +
    1.21 +writeln"File FOL/ex/int.";
    1.22 +
    1.23 +(*Note: for PROPOSITIONAL formulae...
    1.24 +  ~A is classically provable iff it is intuitionistically provable.  
    1.25 +  Therefore A is classically provable iff ~~A is intuitionistically provable.
    1.26 +
    1.27 +Let Q be the conjuction of the propositions A|~A, one for each atom A in
    1.28 +P.  If P is provable classically, then clearly P&Q is provable
    1.29 +intuitionistically, so ~~(P&Q) is also provable intuitionistically.
    1.30 +The latter is intuitionistically equivalent to ~~P&~~Q, hence to ~~P,
    1.31 +since ~~Q is intuitionistically provable.  Finally, if P is a negation then
    1.32 +~~P is intuitionstically equivalent to P.  [Andy Pitts]
    1.33 +*)
    1.34 +
    1.35 +goal IFOLP.thy "?p : ~~(P&Q) <-> ~~P & ~~Q";
    1.36 +by (Int.fast_tac 1);
    1.37 +result();
    1.38 +
    1.39 +goal IFOLP.thy "?p : ~~~P <-> ~P";
    1.40 +by (Int.fast_tac 1);
    1.41 +result();
    1.42 +
    1.43 +goal IFOLP.thy "?p : ~~((P --> Q | R)  -->  (P-->Q) | (P-->R))";
    1.44 +by (Int.fast_tac 1);
    1.45 +result();
    1.46 +
    1.47 +goal IFOLP.thy "?p : (P<->Q) <-> (Q<->P)";
    1.48 +by (Int.fast_tac 1);
    1.49 +result();
    1.50 +
    1.51 +
    1.52 +writeln"Lemmas for the propositional double-negation translation";
    1.53 +
    1.54 +goal IFOLP.thy "?p : P --> ~~P";
    1.55 +by (Int.fast_tac 1);
    1.56 +result();
    1.57 +
    1.58 +goal IFOLP.thy "?p : ~~(~~P --> P)";
    1.59 +by (Int.fast_tac 1);
    1.60 +result();
    1.61 +
    1.62 +goal IFOLP.thy "?p : ~~P & ~~(P --> Q) --> ~~Q";
    1.63 +by (Int.fast_tac 1);
    1.64 +result();
    1.65 +
    1.66 +
    1.67 +writeln"The following are classically but not constructively valid.";
    1.68 +
    1.69 +(*The attempt to prove them terminates quickly!*)
    1.70 +goal IFOLP.thy "?p : ((P-->Q) --> P)  -->  P";
    1.71 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
    1.72 +(*Check that subgoals remain: proof failed.*)
    1.73 +getgoal 1;  
    1.74 +
    1.75 +goal IFOLP.thy "?p : (P&Q-->R)  -->  (P-->R) | (Q-->R)";
    1.76 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
    1.77 +getgoal 1;  
    1.78 +
    1.79 +
    1.80 +writeln"Intuitionistic FOL: propositional problems based on Pelletier.";
    1.81 +
    1.82 +writeln"Problem ~~1";
    1.83 +goal IFOLP.thy "?p : ~~((P-->Q)  <->  (~Q --> ~P))";
    1.84 +by (Int.fast_tac 1);
    1.85 +result();
    1.86 +(*5 secs*)
    1.87 +
    1.88 +
    1.89 +writeln"Problem ~~2";
    1.90 +goal IFOLP.thy "?p : ~~(~~P  <->  P)";
    1.91 +by (Int.fast_tac 1);
    1.92 +result();
    1.93 +(*1 secs*)
    1.94 +
    1.95 +
    1.96 +writeln"Problem 3";
    1.97 +goal IFOLP.thy "?p : ~(P-->Q) --> (Q-->P)";
    1.98 +by (Int.fast_tac 1);
    1.99 +result();
   1.100 +
   1.101 +writeln"Problem ~~4";
   1.102 +goal IFOLP.thy "?p : ~~((~P-->Q)  <->  (~Q --> P))";
   1.103 +by (Int.fast_tac 1);
   1.104 +result();
   1.105 +(*9 secs*)
   1.106 +
   1.107 +writeln"Problem ~~5";
   1.108 +goal IFOLP.thy "?p : ~~((P|Q-->P|R) --> P|(Q-->R))";
   1.109 +by (Int.fast_tac 1);
   1.110 +result();
   1.111 +(*10 secs*)
   1.112 +
   1.113 +
   1.114 +writeln"Problem ~~6";
   1.115 +goal IFOLP.thy "?p : ~~(P | ~P)";
   1.116 +by (Int.fast_tac 1);
   1.117 +result();
   1.118 +
   1.119 +writeln"Problem ~~7";
   1.120 +goal IFOLP.thy "?p : ~~(P | ~~~P)";
   1.121 +by (Int.fast_tac 1);
   1.122 +result();
   1.123 +
   1.124 +writeln"Problem ~~8.  Peirce's law";
   1.125 +goal IFOLP.thy "?p : ~~(((P-->Q) --> P)  -->  P)";
   1.126 +by (Int.fast_tac 1);
   1.127 +result();
   1.128 +
   1.129 +writeln"Problem 9";
   1.130 +goal IFOLP.thy "?p : ((P|Q) & (~P|Q) & (P| ~Q)) --> ~ (~P | ~Q)";
   1.131 +by (Int.fast_tac 1);
   1.132 +result();
   1.133 +(*9 secs*)
   1.134 +
   1.135 +
   1.136 +writeln"Problem 10";
   1.137 +goal IFOLP.thy "?p : (Q-->R) --> (R-->P&Q) --> (P-->(Q|R)) --> (P<->Q)";
   1.138 +by (Int.fast_tac 1);
   1.139 +result();
   1.140 +
   1.141 +writeln"11.  Proved in each direction (incorrectly, says Pelletier!!) ";
   1.142 +goal IFOLP.thy "?p : P<->P";
   1.143 +by (Int.fast_tac 1);
   1.144 +
   1.145 +writeln"Problem ~~12.  Dijkstra's law  ";
   1.146 +goal IFOLP.thy "?p : ~~(((P <-> Q) <-> R)  <->  (P <-> (Q <-> R)))";
   1.147 +by (Int.fast_tac 1);
   1.148 +result();
   1.149 +
   1.150 +goal IFOLP.thy "?p : ((P <-> Q) <-> R)  -->  ~~(P <-> (Q <-> R))";
   1.151 +by (Int.fast_tac 1);
   1.152 +result();
   1.153 +
   1.154 +writeln"Problem 13.  Distributive law";
   1.155 +goal IFOLP.thy "?p : P | (Q & R)  <-> (P | Q) & (P | R)";
   1.156 +by (Int.fast_tac 1);
   1.157 +result();
   1.158 +
   1.159 +writeln"Problem ~~14";
   1.160 +goal IFOLP.thy "?p : ~~((P <-> Q) <-> ((Q | ~P) & (~Q|P)))";
   1.161 +by (Int.fast_tac 1);
   1.162 +result();
   1.163 +
   1.164 +writeln"Problem ~~15";
   1.165 +goal IFOLP.thy "?p : ~~((P --> Q) <-> (~P | Q))";
   1.166 +by (Int.fast_tac 1);
   1.167 +result();
   1.168 +
   1.169 +writeln"Problem ~~16";
   1.170 +goal IFOLP.thy "?p : ~~((P-->Q) | (Q-->P))";
   1.171 +by (Int.fast_tac 1);
   1.172 +result();
   1.173 +
   1.174 +writeln"Problem ~~17";
   1.175 +goal IFOLP.thy
   1.176 +  "?p : ~~(((P & (Q-->R))-->S) <-> ((~P | Q | S) & (~P | ~R | S)))";
   1.177 +by (Int.fast_tac 1);
   1.178 +(*over 5 minutes?? -- printing the proof term takes 40 secs!!*)
   1.179 +result();
   1.180 +
   1.181 +
   1.182 +writeln"** Examples with quantifiers **";
   1.183 +
   1.184 +writeln"The converse is classical in the following implications...";
   1.185 +
   1.186 +goal IFOLP.thy "?p : (EX x.P(x)-->Q)  -->  (ALL x.P(x)) --> Q";
   1.187 +by (Int.fast_tac 1); 
   1.188 +result();  
   1.189 +
   1.190 +goal IFOLP.thy "?p : ((ALL x.P(x))-->Q) --> ~ (ALL x. P(x) & ~Q)";
   1.191 +by (Int.fast_tac 1); 
   1.192 +result();  
   1.193 +
   1.194 +goal IFOLP.thy "?p : ((ALL x. ~P(x))-->Q)  -->  ~ (ALL x. ~ (P(x)|Q))";
   1.195 +by (Int.fast_tac 1); 
   1.196 +result();  
   1.197 +
   1.198 +goal IFOLP.thy "?p : (ALL x.P(x)) | Q  -->  (ALL x. P(x) | Q)";
   1.199 +by (Int.fast_tac 1); 
   1.200 +result();  
   1.201 +
   1.202 +goal IFOLP.thy "?p : (EX x. P --> Q(x)) --> (P --> (EX x. Q(x)))";
   1.203 +by (Int.fast_tac 1);
   1.204 +result();  
   1.205 +
   1.206 +
   1.207 +
   1.208 +
   1.209 +writeln"The following are not constructively valid!";
   1.210 +(*The attempt to prove them terminates quickly!*)
   1.211 +
   1.212 +goal IFOLP.thy "?p : ((ALL x.P(x))-->Q) --> (EX x.P(x)-->Q)";
   1.213 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
   1.214 +getgoal 1; 
   1.215 +
   1.216 +goal IFOLP.thy "?p : (P --> (EX x.Q(x))) --> (EX x. P-->Q(x))";
   1.217 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
   1.218 +getgoal 1; 
   1.219 +
   1.220 +goal IFOLP.thy "?p : (ALL x. P(x) | Q) --> ((ALL x.P(x)) | Q)";
   1.221 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
   1.222 +getgoal 1; 
   1.223 +
   1.224 +goal IFOLP.thy "?p : (ALL x. ~~P(x)) --> ~~(ALL x. P(x))";
   1.225 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
   1.226 +getgoal 1; 
   1.227 +
   1.228 +(*Classically but not intuitionistically valid.  Proved by a bug in 1986!*)
   1.229 +goal IFOLP.thy "?p : EX x. Q(x) --> (ALL x. Q(x))";
   1.230 +by (Int.fast_tac 1) handle ERROR => writeln"Failed, as expected";  
   1.231 +getgoal 1; 
   1.232 +
   1.233 +
   1.234 +writeln"Hard examples with quantifiers";
   1.235 +
   1.236 +(*The ones that have not been proved are not known to be valid!
   1.237 +  Some will require quantifier duplication -- not currently available*)
   1.238 +
   1.239 +writeln"Problem ~~18";
   1.240 +goal IFOLP.thy "?p : ~~(EX y. ALL x. P(y)-->P(x))";
   1.241 +(*NOT PROVED*)
   1.242 +
   1.243 +writeln"Problem ~~19";
   1.244 +goal IFOLP.thy "?p : ~~(EX x. ALL y z. (P(y)-->Q(z)) --> (P(x)-->Q(x)))";
   1.245 +(*NOT PROVED*)
   1.246 +
   1.247 +writeln"Problem 20";
   1.248 +goal IFOLP.thy "?p : (ALL x y. EX z. ALL w. (P(x)&Q(y)-->R(z)&S(w)))     \
   1.249 +\   --> (EX x y. P(x) & Q(y)) --> (EX z. R(z))";
   1.250 +by (Int.fast_tac 1); 
   1.251 +result();
   1.252 +
   1.253 +writeln"Problem 21";
   1.254 +goal IFOLP.thy
   1.255 +    "?p : (EX x. P-->Q(x)) & (EX x. Q(x)-->P) --> ~~(EX x. P<->Q(x))";
   1.256 +(*NOT PROVED*)
   1.257 +
   1.258 +writeln"Problem 22";
   1.259 +goal IFOLP.thy "?p : (ALL x. P <-> Q(x))  -->  (P <-> (ALL x. Q(x)))";
   1.260 +by (Int.fast_tac 1); 
   1.261 +result();
   1.262 +
   1.263 +writeln"Problem ~~23";
   1.264 +goal IFOLP.thy "?p : ~~ ((ALL x. P | Q(x))  <->  (P | (ALL x. Q(x))))";
   1.265 +by (Int.best_tac 1);  
   1.266 +result();
   1.267 +
   1.268 +writeln"Problem 24";
   1.269 +goal IFOLP.thy "?p : ~(EX x. S(x)&Q(x)) & (ALL x. P(x) --> Q(x)|R(x)) &  \
   1.270 +\    ~(EX x.P(x)) --> (EX x.Q(x)) & (ALL x. Q(x)|R(x) --> S(x))  \
   1.271 +\   --> (EX x. P(x)&R(x))";
   1.272 +by (Int.fast_tac 1); 
   1.273 +result();
   1.274 +
   1.275 +writeln"Problem 25";
   1.276 +goal IFOLP.thy "?p : (EX x. P(x)) &  \
   1.277 +\       (ALL x. L(x) --> ~ (M(x) & R(x))) &  \
   1.278 +\       (ALL x. P(x) --> (M(x) & L(x))) &   \
   1.279 +\       ((ALL x. P(x)-->Q(x)) | (EX x. P(x)&R(x)))  \
   1.280 +\   --> (EX x. Q(x)&P(x))";
   1.281 +by (Int.best_tac 1);
   1.282 +result();
   1.283 +
   1.284 +writeln"Problem 29.  Essentially the same as Principia Mathematica *11.71";
   1.285 +goal IFOLP.thy "?p : (EX x. P(x)) & (EX y. Q(y))  \
   1.286 +\   --> ((ALL x. P(x)-->R(x)) & (ALL y. Q(y)-->S(y))   <->     \
   1.287 +\        (ALL x y. P(x) & Q(y) --> R(x) & S(y)))";
   1.288 +by (Int.fast_tac 1); 
   1.289 +result();
   1.290 +
   1.291 +writeln"Problem ~~30";
   1.292 +goal IFOLP.thy "?p : (ALL x. (P(x) | Q(x)) --> ~ R(x)) & \
   1.293 +\       (ALL x. (Q(x) --> ~ S(x)) --> P(x) & R(x))  \
   1.294 +\   --> (ALL x. ~~S(x))";
   1.295 +by (Int.fast_tac 1);  
   1.296 +result();
   1.297 +
   1.298 +writeln"Problem 31";
   1.299 +goal IFOLP.thy "?p : ~(EX x.P(x) & (Q(x) | R(x))) & \
   1.300 +\       (EX x. L(x) & P(x)) & \
   1.301 +\       (ALL x. ~ R(x) --> M(x))  \
   1.302 +\   --> (EX x. L(x) & M(x))";
   1.303 +by (Int.fast_tac 1);
   1.304 +result();
   1.305 +
   1.306 +writeln"Problem 32";
   1.307 +goal IFOLP.thy "?p : (ALL x. P(x) & (Q(x)|R(x))-->S(x)) & \
   1.308 +\       (ALL x. S(x) & R(x) --> L(x)) & \
   1.309 +\       (ALL x. M(x) --> R(x))  \
   1.310 +\   --> (ALL x. P(x) & M(x) --> L(x))";
   1.311 +by (Int.best_tac 1);  (*SLOW*)
   1.312 +result();
   1.313 +
   1.314 +writeln"Problem 39";
   1.315 +goal IFOLP.thy "?p : ~ (EX x. ALL y. F(y,x) <-> ~F(y,y))";
   1.316 +by (Int.fast_tac 1);
   1.317 +result();
   1.318 +
   1.319 +writeln"Problem 40.  AMENDED";
   1.320 +goal IFOLP.thy "?p : (EX y. ALL x. F(x,y) <-> F(x,x)) -->  \
   1.321 +\             ~(ALL x. EX y. ALL z. F(z,y) <-> ~ F(z,x))";
   1.322 +by (Int.fast_tac 1);
   1.323 +result();
   1.324 +
   1.325 +writeln"Problem 44";
   1.326 +goal IFOLP.thy "?p : (ALL x. f(x) -->					\
   1.327 +\             (EX y. g(y) & h(x,y) & (EX y. g(y) & ~ h(x,y))))  &   	\
   1.328 +\             (EX x. j(x) & (ALL y. g(y) --> h(x,y)))			\
   1.329 +\             --> (EX x. j(x) & ~f(x))";
   1.330 +by (Int.fast_tac 1);
   1.331 +result();
   1.332 +
   1.333 +writeln"Problem 48";
   1.334 +goal IFOLP.thy "?p : (a=b | c=d) & (a=c | b=d) --> a=d | b=c";
   1.335 +by (Int.fast_tac 1);
   1.336 +result();
   1.337 +
   1.338 +writeln"Problem 51";
   1.339 +goal IFOLP.thy
   1.340 +    "?p : (EX z w. ALL x y. P(x,y) <->  (x=z & y=w)) -->  \
   1.341 +\    (EX z. ALL x. EX w. (ALL y. P(x,y) <-> y=w) <-> x=z)";
   1.342 +by (Int.best_tac 1);  (*60 seconds*)
   1.343 +result();
   1.344 +
   1.345 +writeln"Problem 56";
   1.346 +goal IFOLP.thy
   1.347 +    "?p : (ALL x. (EX y. P(y) & x=f(y)) --> P(x)) <-> (ALL x. P(x) --> P(f(x)))";
   1.348 +by (Int.fast_tac 1);
   1.349 +result();
   1.350 +
   1.351 +writeln"Problem 57";
   1.352 +goal IFOLP.thy
   1.353 +    "?p : P(f(a,b), f(b,c)) & P(f(b,c), f(a,c)) & \
   1.354 +\    (ALL x y z. P(x,y) & P(y,z) --> P(x,z))    -->   P(f(a,b), f(a,c))";
   1.355 +by (Int.fast_tac 1);
   1.356 +result();
   1.357 +
   1.358 +writeln"Problem 60";
   1.359 +goal IFOLP.thy
   1.360 +    "?p : ALL x. P(x,f(x)) <-> (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))";
   1.361 +by (Int.fast_tac 1);
   1.362 +result();
   1.363 +
   1.364 +writeln"Reached end of file.";