src/FOLP/ex/quant.ML
author clasohm
Tue, 30 Jan 1996 15:19:20 +0100
changeset 1464 a608f83e3421
parent 1459 d12da312eff4
child 3836 f1a1817659e6
permissions -rw-r--r--
expanded tabs; removed commit() from ROOT.ML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1464
a608f83e3421 expanded tabs; removed commit() from ROOT.ML
clasohm
parents: 1459
diff changeset
     1
(*  Title:      FOLP/ex/quant.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1459
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
First-Order Logic: quantifier examples (intuitionistic and classical)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
Needs declarations of the theory "thy" and the tactic "tac"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
1464
a608f83e3421 expanded tabs; removed commit() from ROOT.ML
clasohm
parents: 1459
diff changeset
    10
writeln"File FOLP/ex/quant.ML";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
goal thy "?p : (ALL x y.P(x,y))  -->  (ALL y x.P(x,y))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
goal thy "?p : (EX x y.P(x,y)) --> (EX y x.P(x,y))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
(*Converse is false*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
goal thy "?p : (ALL x.P(x)) | (ALL x.Q(x)) --> (ALL x. P(x) | Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
goal thy "?p : (ALL x. P-->Q(x))  <->  (P--> (ALL x.Q(x)))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
goal thy "?p : (ALL x.P(x)-->Q)  <->  ((EX x.P(x)) --> Q)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
writeln"Some harder ones";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
goal thy "?p : (EX x. P(x) | Q(x)) <-> (EX x.P(x)) | (EX x.Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
(*6 secs*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
(*Converse is false*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
goal thy "?p : (EX x. P(x)&Q(x)) --> (EX x.P(x))  &  (EX x.Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
writeln"Basic test of quantifier reasoning";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
(*TRUE*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
goal thy "?p : (EX y. ALL x. Q(x,y)) -->  (ALL x. EX y. Q(x,y))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
by tac;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
goal thy "?p : (ALL x. Q(x))  -->  (EX x. Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
by tac;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
writeln"The following should fail, as they are false!";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
goal thy "?p : (ALL x. EX y. Q(x,y))  -->  (EX y. ALL x. Q(x,y))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
by tac handle ERROR => writeln"Failed, as expected";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
(*Check that subgoals remain: proof failed.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
getgoal 1; 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
goal thy "?p : (EX x. Q(x))  -->  (ALL x. Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
by tac handle ERROR => writeln"Failed, as expected";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
getgoal 1; 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
goal thy "?p : P(?a) --> (ALL x.P(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
by tac handle ERROR => writeln"Failed, as expected";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
(*Check that subgoals remain: proof failed.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
getgoal 1;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
goal thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
    "?p : (P(?a) --> (ALL x.Q(x))) --> (ALL x. P(x) --> Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
by tac handle ERROR => writeln"Failed, as expected";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
getgoal 1;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
writeln"Back to things that are provable...";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
goal thy "?p : (ALL x.P(x)-->Q(x)) & (EX x.P(x)) --> (EX x.Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
by tac;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
(*An example of why exI should be delayed as long as possible*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
goal thy "?p : (P --> (EX x.Q(x))) & P --> (EX x.Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
by tac;  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
goal thy "?p : (ALL x. P(x)-->Q(f(x))) & (ALL x. Q(x)-->R(g(x))) & P(d) --> R(?a)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
by tac; 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
(*Verify that no subgoals remain.*) 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
uresult();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
goal thy "?p : (ALL x. Q(x))  -->  (EX x. Q(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
writeln"Some slow ones";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
(*Principia Mathematica *11.53  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
goal thy "?p : (ALL x y. P(x) --> Q(y)) <-> ((EX x. P(x)) --> (ALL y. Q(y)))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
(*6 secs*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
(*Principia Mathematica *11.55  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
goal thy "?p : (EX x y. P(x) & Q(x,y)) <-> (EX x. P(x) & (EX y. Q(x,y)))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
(*9 secs*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
(*Principia Mathematica *11.61  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
goal thy "?p : (EX y. ALL x. P(x) --> Q(x,y)) --> (ALL x. P(x) --> (EX y. Q(x,y)))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
by tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
result();  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
(*3 secs*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
writeln"Reached end of file.";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129