src/Sequents/LK/quant.ML
author wenzelm
Sun Sep 18 15:20:08 2005 +0200 (2005-09-18)
changeset 17481 75166ebb619b
parent 6252 935f183bf406
child 18678 dd0c569fa43d
permissions -rw-r--r--
converted to Isar theory format;
wenzelm@17481
     1
(*  Title:      LK/ex/quant.ML
wenzelm@6252
     2
    ID:         $Id$
wenzelm@6252
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
wenzelm@6252
     4
    Copyright   1992  University of Cambridge
wenzelm@6252
     5
wenzelm@6252
     6
Classical sequent calculus: examples with quantifiers.
wenzelm@6252
     7
*)
wenzelm@6252
     8
wenzelm@17481
     9
goal (theory "LK") "|- (ALL x. P)  <->  P";
wenzelm@6252
    10
by (fast_tac LK_pack 1);
wenzelm@17481
    11
result();
wenzelm@6252
    12
wenzelm@17481
    13
goal (theory "LK") "|- (ALL x y. P(x,y))  <->  (ALL y x. P(x,y))";
wenzelm@6252
    14
by (fast_tac LK_pack 1);
wenzelm@17481
    15
result();
wenzelm@6252
    16
wenzelm@17481
    17
goal (theory "LK") "ALL u. P(u), ALL v. Q(v) |- ALL u v. P(u) & Q(v)";
wenzelm@6252
    18
by (fast_tac LK_pack 1);
wenzelm@17481
    19
result();
wenzelm@6252
    20
wenzelm@6252
    21
writeln"Permutation of existential quantifier.";
wenzelm@17481
    22
goal (theory "LK") "|- (EX x y. P(x,y)) <-> (EX y x. P(x,y))";
wenzelm@6252
    23
by (fast_tac LK_pack 1);
wenzelm@17481
    24
result();
wenzelm@6252
    25
wenzelm@17481
    26
goal (theory "LK") "|- (ALL x. P(x) & Q(x)) <-> (ALL x. P(x)) & (ALL x. Q(x))";
wenzelm@6252
    27
by (fast_tac LK_pack 1);
wenzelm@17481
    28
result();
wenzelm@6252
    29
wenzelm@6252
    30
wenzelm@6252
    31
(*Converse is invalid*)
wenzelm@17481
    32
goal (theory "LK") "|- (ALL x. P(x)) | (ALL x. Q(x)) --> (ALL x. P(x)|Q(x))";
wenzelm@6252
    33
by (fast_tac LK_pack 1);
wenzelm@17481
    34
result();
wenzelm@6252
    35
wenzelm@6252
    36
wenzelm@6252
    37
writeln"Pushing ALL into an implication.";
wenzelm@17481
    38
goal (theory "LK") "|- (ALL x. P --> Q(x))  <->  (P --> (ALL x. Q(x)))";
wenzelm@6252
    39
by (fast_tac LK_pack 1);
wenzelm@17481
    40
result();
wenzelm@6252
    41
wenzelm@6252
    42
wenzelm@17481
    43
goal (theory "LK") "|- (ALL x. P(x)-->Q)  <->  ((EX x. P(x)) --> Q)";
wenzelm@6252
    44
by (fast_tac LK_pack 1);
wenzelm@17481
    45
result();
wenzelm@6252
    46
wenzelm@6252
    47
wenzelm@17481
    48
goal (theory "LK") "|- (EX x. P)  <->  P";
wenzelm@6252
    49
by (fast_tac LK_pack 1);
wenzelm@17481
    50
result();
wenzelm@6252
    51
wenzelm@6252
    52
wenzelm@6252
    53
writeln"Distribution of EX over disjunction.";
wenzelm@17481
    54
goal (theory "LK") "|- (EX x. P(x) | Q(x)) <-> (EX x. P(x))  |  (EX x. Q(x))";
wenzelm@6252
    55
by (fast_tac LK_pack 1);
wenzelm@17481
    56
result();
wenzelm@6252
    57
(*5 secs*)
wenzelm@6252
    58
wenzelm@6252
    59
(*Converse is invalid*)
wenzelm@17481
    60
goal (theory "LK") "|- (EX x. P(x) & Q(x))  -->  (EX x. P(x))  &  (EX x. Q(x))";
wenzelm@6252
    61
by (fast_tac LK_pack 1);
wenzelm@17481
    62
result();
wenzelm@6252
    63
wenzelm@6252
    64
wenzelm@6252
    65
writeln"Harder examples: classical theorems.";
wenzelm@6252
    66
wenzelm@17481
    67
goal (theory "LK") "|- (EX x. P-->Q(x))  <->  (P --> (EX x. Q(x)))";
wenzelm@6252
    68
by (fast_tac LK_pack 1);
wenzelm@17481
    69
result();
wenzelm@6252
    70
(*3 secs*)
wenzelm@6252
    71
wenzelm@6252
    72
wenzelm@17481
    73
goal (theory "LK") "|- (EX x. P(x)-->Q)  <->  (ALL x. P(x)) --> Q";
wenzelm@6252
    74
by (fast_tac LK_pack 1);
wenzelm@17481
    75
result();
wenzelm@6252
    76
(*5 secs*)
wenzelm@6252
    77
wenzelm@6252
    78
wenzelm@17481
    79
goal (theory "LK") "|- (ALL x. P(x)) | Q  <->  (ALL x. P(x) | Q)";
wenzelm@6252
    80
by (fast_tac LK_pack 1);
wenzelm@17481
    81
result();
wenzelm@6252
    82
wenzelm@6252
    83
wenzelm@6252
    84
writeln"Basic test of quantifier reasoning";
wenzelm@17481
    85
goal (theory "LK")
wenzelm@6252
    86
   "|- (EX y. ALL x. Q(x,y)) --> (ALL x. EX y. Q(x,y))";
wenzelm@6252
    87
by (fast_tac LK_pack 1);
wenzelm@17481
    88
result();
wenzelm@6252
    89
wenzelm@6252
    90
wenzelm@17481
    91
goal (theory "LK") "|- (ALL x. Q(x))  -->  (EX x. Q(x))";
wenzelm@6252
    92
by (fast_tac LK_pack 1);
wenzelm@17481
    93
result();
wenzelm@6252
    94
wenzelm@6252
    95
wenzelm@6252
    96
writeln"The following are invalid!";
wenzelm@6252
    97
wenzelm@6252
    98
(*INVALID*)
wenzelm@17481
    99
goal (theory "LK") "|- (ALL x. EX y. Q(x,y))  -->  (EX y. ALL x. Q(x,y))";
wenzelm@17481
   100
by (fast_tac LK_pack 1) handle ERROR => writeln"Failed, as expected";
wenzelm@6252
   101
(*Check that subgoals remain: proof failed.*)
wenzelm@17481
   102
getgoal 1;
wenzelm@6252
   103
wenzelm@6252
   104
(*INVALID*)
wenzelm@17481
   105
goal (theory "LK") "|- (EX x. Q(x))  -->  (ALL x. Q(x))";
wenzelm@6252
   106
by (fast_tac LK_pack 1) handle ERROR => writeln"Failed, as expected";
wenzelm@17481
   107
getgoal 1;
wenzelm@6252
   108
wenzelm@17481
   109
goal (theory "LK") "|- P(?a) --> (ALL x. P(x))";
wenzelm@6252
   110
by (fast_tac LK_pack 1) handle ERROR => writeln"Failed, as expected";
wenzelm@6252
   111
(*Check that subgoals remain: proof failed.*)
wenzelm@17481
   112
getgoal 1;
wenzelm@6252
   113
wenzelm@17481
   114
goal (theory "LK") "|- (P(?a) --> (ALL x. Q(x))) --> (ALL x. P(x) --> Q(x))";
wenzelm@6252
   115
by (fast_tac LK_pack 1) handle ERROR => writeln"Failed, as expected";
wenzelm@17481
   116
getgoal 1;
wenzelm@6252
   117
wenzelm@6252
   118
wenzelm@6252
   119
writeln"Back to things that are provable...";
wenzelm@6252
   120
wenzelm@17481
   121
goal (theory "LK") "|- (ALL x. P(x)-->Q(x)) & (EX x. P(x)) --> (EX x. Q(x))";
wenzelm@17481
   122
by (fast_tac LK_pack 1);
wenzelm@17481
   123
result();
wenzelm@6252
   124
wenzelm@6252
   125
(*An example of why exR should be delayed as long as possible*)
wenzelm@17481
   126
goal (theory "LK") "|- (P--> (EX x. Q(x))) & P--> (EX x. Q(x))";
wenzelm@6252
   127
by (fast_tac LK_pack 1);
wenzelm@17481
   128
result();
wenzelm@6252
   129
wenzelm@6252
   130
writeln"Solving for a Var";
wenzelm@17481
   131
goal (theory "LK")
wenzelm@6252
   132
   "|- (ALL x. P(x)-->Q(f(x))) & (ALL x. Q(x)-->R(g(x))) & P(d) --> R(?a)";
wenzelm@6252
   133
by (fast_tac LK_pack 1);
wenzelm@6252
   134
result();
wenzelm@6252
   135
wenzelm@6252
   136
wenzelm@6252
   137
writeln"Principia Mathematica *11.53";
wenzelm@17481
   138
goal (theory "LK")
wenzelm@6252
   139
    "|- (ALL x y. P(x) --> Q(y)) <-> ((EX x. P(x)) --> (ALL y. Q(y)))";
wenzelm@6252
   140
by (fast_tac LK_pack 1);
wenzelm@6252
   141
result();
wenzelm@6252
   142
wenzelm@6252
   143
wenzelm@6252
   144
writeln"Principia Mathematica *11.55";
wenzelm@17481
   145
goal (theory "LK") "|- (EX x y. P(x) & Q(x,y)) <-> (EX x. P(x) & (EX y. Q(x,y)))";
wenzelm@6252
   146
by (fast_tac LK_pack 1);
wenzelm@6252
   147
result();
wenzelm@6252
   148
wenzelm@6252
   149
writeln"Principia Mathematica *11.61";
wenzelm@17481
   150
goal (theory "LK")
wenzelm@6252
   151
   "|- (EX y. ALL x. P(x) --> Q(x,y)) --> (ALL x. P(x) --> (EX y. Q(x,y)))";
wenzelm@6252
   152
by (fast_tac LK_pack 1);
wenzelm@6252
   153
result();
wenzelm@6252
   154
wenzelm@6252
   155
(*21 August 88: loaded in 45.7 secs*)
wenzelm@17481
   156
(*18 September 2005: loaded in 0.114 secs*)