src/FOL/ex/quant.ML
author wenzelm
Sun, 26 Nov 2006 23:43:53 +0100
changeset 21539 c5cf9243ad62
parent 18678 dd0c569fa43d
permissions -rw-r--r--
converted legacy ML scripts;

(*  Title:      FOL/ex/quant
    ID:         $Id$
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    Copyright   1991  University of Cambridge

First-Order Logic: quantifier examples (intuitionistic and classical)
Needs declarations of the theory "thy" and the tactic "tac"
*)

writeln"File FOL/ex/quant.";

Goal "(ALL x y. P(x,y))  -->  (ALL y x. P(x,y))";
by tac;
result();  


Goal "(EX x y. P(x,y)) --> (EX y x. P(x,y))";
by tac;
result();  


(*Converse is false*)
Goal "(ALL x. P(x)) | (ALL x. Q(x)) --> (ALL x. P(x) | Q(x))";
by tac;
result();  

Goal "(ALL x. P-->Q(x))  <->  (P--> (ALL x. Q(x)))";
by tac;
result();  


Goal "(ALL x. P(x)-->Q)  <->  ((EX x. P(x)) --> Q)";
by tac;
result();  


writeln"Some harder ones";

Goal "(EX x. P(x) | Q(x)) <-> (EX x. P(x)) | (EX x. Q(x))";
by tac;
result();  
(*6 secs*)

(*Converse is false*)
Goal "(EX x. P(x)&Q(x)) --> (EX x. P(x))  &  (EX x. Q(x))";
by tac;
result();  


writeln"Basic test of quantifier reasoning";
(*TRUE*)
Goal "(EX y. ALL x. Q(x,y)) -->  (ALL x. EX y. Q(x,y))";
by tac;  
result();  


Goal "(ALL x. Q(x))  -->  (EX x. Q(x))";
by tac;  
result();  


writeln"The following should fail, as they are false!";

Goal "(ALL x. EX y. Q(x,y))  -->  (EX y. ALL x. Q(x,y))";
by tac handle ERROR _ => writeln"Failed, as expected";  
(*Check that subgoals remain: proof failed.*)
getgoal 1; 

Goal "(EX x. Q(x))  -->  (ALL x. Q(x))";
by tac handle ERROR _ => writeln"Failed, as expected";  
getgoal 1; 

Goal "P(?a) --> (ALL x. P(x))";
by tac handle ERROR _ => writeln"Failed, as expected";
(*Check that subgoals remain: proof failed.*)
getgoal 1;  

Goal
    "(P(?a) --> (ALL x. Q(x))) --> (ALL x. P(x) --> Q(x))";
by tac handle ERROR _ => writeln"Failed, as expected";
getgoal 1;  


writeln"Back to things that are provable...";

Goal "(ALL x. P(x)-->Q(x)) & (EX x. P(x)) --> (EX x. Q(x))";
by tac;  
result();  


(*An example of why exI should be delayed as long as possible*)
Goal "(P --> (EX x. Q(x))) & P --> (EX x. Q(x))";
by tac;  
result();  

Goal "(ALL x. P(x)-->Q(f(x))) & (ALL x. Q(x)-->R(g(x))) & P(d) --> R(?a)";
by tac; 
(*Verify that no subgoals remain.*) 
uresult();  


Goal "(ALL x. Q(x))  -->  (EX x. Q(x))";
by tac;
result();  


writeln"Some slow ones";


(*Principia Mathematica *11.53  *)
Goal "(ALL x y. P(x) --> Q(y)) <-> ((EX x. P(x)) --> (ALL y. Q(y)))";
by tac;
result();  
(*6 secs*)

(*Principia Mathematica *11.55  *)
Goal "(EX x y. P(x) & Q(x,y)) <-> (EX x. P(x) & (EX y. Q(x,y)))";
by tac;
result();  
(*9 secs*)

(*Principia Mathematica *11.61  *)
Goal "(EX y. ALL x. P(x) --> Q(x,y)) --> (ALL x. P(x) --> (EX y. Q(x,y)))";
by tac;
result();  
(*3 secs*)

writeln"Reached end of file.";