src/FOLP/ex/quant.ML
author ballarin
Thu, 28 Nov 2002 10:50:42 +0100
changeset 13735 7de9342aca7a
parent 5061 f947332d5465
child 15531 08c8dad8e399
permissions -rw-r--r--
HOL-Algebra partially ported to Isar.
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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    12
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    17
Goal "?p : (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*)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    23
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    27
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    32
Goal "?p : (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
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
writeln"Some harder ones";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    39
Goal "?p : (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*)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    45
Goal "?p : (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*)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    52
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    57
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    64
Goal "?p : (ALL x. EX y. Q(x,y))  -->  (EX y. ALL x. Q(x,y))";
0
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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    69
Goal "?p : (EX x. Q(x))  -->  (ALL x. Q(x))";
0
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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    73
Goal "?p : P(?a) --> (ALL x. P(x))";
0
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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    78
Goal
3836
f1a1817659e6 fixed dots;
wenzelm
parents: 1464
diff changeset
    79
    "?p : (P(?a) --> (ALL x. Q(x))) --> (ALL x. P(x) --> Q(x))";
0
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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    86
Goal "?p : (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*)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    92
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
    96
Goal "?p : (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
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
   102
Goal "?p : (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
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  *)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
   111
Goal "?p : (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  *)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
   117
Goal "?p : (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  *)
5061
f947332d5465 isatool fixgoal;
wenzelm
parents: 3836
diff changeset
   123
Goal "?p : (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