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;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
     1
(*  Title:      FOL/ex/quant
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
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
writeln"File FOL/ex/quant.";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    12
Goal "(ALL x y. P(x,y))  -->  (ALL y x. P(x,y))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    17
Goal "(EX x y. P(x,y)) --> (EX y x. P(x,y))";
0
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*)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    23
Goal "(ALL x. P(x)) | (ALL x. Q(x)) --> (ALL x. P(x) | Q(x))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    27
Goal "(ALL x. P-->Q(x))  <->  (P--> (ALL x. Q(x)))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    32
Goal "(ALL x. P(x)-->Q)  <->  ((EX x. P(x)) --> Q)";
0
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
15661
9ef583b08647 reverted renaming of Some/None in comments and strings;
wenzelm
parents: 15531
diff changeset
    37
writeln"Some harder ones";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    39
Goal "(EX x. P(x) | Q(x)) <-> (EX x. P(x)) | (EX x. Q(x))";
0
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*)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    45
Goal "(EX x. P(x)&Q(x)) --> (EX x. P(x))  &  (EX x. Q(x))";
0
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*)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    52
Goal "(EX y. ALL x. Q(x,y)) -->  (ALL x. EX y. Q(x,y))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    57
Goal "(ALL x. Q(x))  -->  (EX x. Q(x))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    64
Goal "(ALL x. EX y. Q(x,y))  -->  (EX y. ALL x. Q(x,y))";
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 15661
diff changeset
    65
by tac handle ERROR _ => writeln"Failed, as expected";  
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    69
Goal "(EX x. Q(x))  -->  (ALL x. Q(x))";
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 15661
diff changeset
    70
by tac handle ERROR _ => writeln"Failed, as expected";  
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
getgoal 1; 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    73
Goal "P(?a) --> (ALL x. P(x))";
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 15661
diff changeset
    74
by tac handle ERROR _ => writeln"Failed, as expected";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    78
Goal
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 1459
diff changeset
    79
    "(P(?a) --> (ALL x. Q(x))) --> (ALL x. P(x) --> Q(x))";
18678
dd0c569fa43d sane ERROR handling;
wenzelm
parents: 15661
diff changeset
    80
by tac handle ERROR _ => writeln"Failed, as expected";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    86
Goal "(ALL x. P(x)-->Q(x)) & (EX x. P(x)) --> (EX x. Q(x))";
0
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*)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    92
Goal "(P --> (EX x. Q(x))) & P --> (EX x. Q(x))";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
    96
Goal "(ALL x. P(x)-->Q(f(x))) & (ALL x. Q(x)-->R(g(x))) & P(d) --> R(?a)";
0
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
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
   102
Goal "(ALL x. Q(x))  -->  (EX x. Q(x))";
0
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
15661
9ef583b08647 reverted renaming of Some/None in comments and strings;
wenzelm
parents: 15531
diff changeset
   107
writeln"Some slow ones";
0
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  *)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
   111
Goal "(ALL x y. P(x) --> Q(y)) <-> ((EX x. P(x)) --> (ALL y. Q(y)))";
0
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  *)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
   117
Goal "(EX x y. P(x) & Q(x,y)) <-> (EX x. P(x) & (EX y. Q(x,y)))";
0
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  *)
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3835
diff changeset
   123
Goal "(EX y. ALL x. P(x) --> Q(x,y)) --> (ALL x. P(x) --> (EX y. Q(x,y)))";
0
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