src/HOL/ex/set.ML
author paulson
Mon, 21 Feb 2000 11:15:43 +0100
changeset 8266 4bc79ed1233b
parent 7377 2ad85e036c21
child 9100 9e081c812338
permissions -rw-r--r--
new examples that cannot be done in LEO
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 969
diff changeset
     1
(*  Title:      HOL/ex/set.ML
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 969
diff changeset
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
Cantor's Theorem; the Schroeder-Berstein Theorem.  
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
writeln"File HOL/ex/set.";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
4153
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4109
diff changeset
    12
context Lfp.thy;
2998
62a5230883bb New blast_tac demo
paulson
parents: 2935
diff changeset
    13
8266
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    14
(*These two are cited in Benzmueller and Kohlhash's system description of LEO,
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    15
  CADE-15, 1998 (page 139-143) as theorems LEO could not prove.*)
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    16
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    17
Goal "(X = Y Un Z) = (Y<=X & Z<=X & (ALL V. Y<=V & Z<=V --> X<=V))";
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    18
by (Blast_tac 1);
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    19
result();
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    20
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    21
Goal "(X = Y Int Z) = (X<=Y & X<=Z & (ALL V. V<=Y & V<=Z --> V<=X))";
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    22
by (Blast_tac 1);
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    23
result();
4bc79ed1233b new examples that cannot be done in LEO
paulson
parents: 7377
diff changeset
    24
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    25
(*trivial example of term synthesis: apparently hard for some provers!*)
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    26
Goal "a ~= b ==> a:?X & b ~: ?X";
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    27
by (Blast_tac 1);
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    28
result();
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    29
5724
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    30
(** Examples for the Blast_tac paper **)
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    31
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    32
(*Union-image, called Un_Union_image on equalities.ML*)
6146
00f3324048a7 renamed variables for clarity
paulson
parents: 5786
diff changeset
    33
Goal "(UN x:C. f(x) Un g(x)) = Union(f``C)  Un  Union(g``C)";
5724
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    34
by (Blast_tac 1);
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    35
result();
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    36
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    37
(*Inter-image, called Int_Inter_image on equalities.ML*)
6146
00f3324048a7 renamed variables for clarity
paulson
parents: 5786
diff changeset
    38
Goal "(INT x:C. f(x) Int g(x)) = Inter(f``C) Int Inter(g``C)";
5724
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    39
by (Blast_tac 1);
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    40
result();
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    41
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    42
(*Singleton I.  Nice demonstration of blast_tac--and its limitations*)
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    43
Goal "!!S::'a set set. ALL x:S. ALL y:S. x<=y ==> EX z. S <= {z}";
4153
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4109
diff changeset
    44
(*for some unfathomable reason, UNIV_I increases the search space greatly*)
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4109
diff changeset
    45
by (blast_tac (claset() delrules [UNIV_I]) 1);
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4109
diff changeset
    46
result();
e534c4c32d54 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4109
diff changeset
    47
5724
a9f8cb9b5b5d standard Blast_tac demos
paulson
parents: 5490
diff changeset
    48
(*Singleton II.  variant of the benchmark above*)
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    49
Goal "ALL x:S. Union(S) <= x ==> EX z. S <= {z}";
4324
9bfac4684f2f New example
paulson
parents: 4153
diff changeset
    50
by (blast_tac (claset() delrules [UNIV_I]) 1);
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    51
(*just Blast_tac takes 5 seconds instead of 1*)
4324
9bfac4684f2f New example
paulson
parents: 4153
diff changeset
    52
result();
2998
62a5230883bb New blast_tac demo
paulson
parents: 2935
diff changeset
    53
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    54
(*** A unique fixpoint theorem --- fast/best/meson all fail ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    55
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    56
Goal "?!x. f(g(x))=x ==> ?!y. g(f(y))=y";
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
    57
by (EVERY1[etac ex1E, rtac ex1I, etac arg_cong,
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    58
          rtac subst, atac, etac allE, rtac arg_cong, etac mp, etac arg_cong]);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    59
result();
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    60
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    61
(*** Cantor's Theorem: There is no surjection from a set to its powerset. ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    62
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    63
goal Set.thy "~ (? f:: 'a=>'a set. ! S. ? x. f(x) = S)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    64
(*requires best-first search because it is undirectional*)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    65
by (best_tac (claset() addSEs [equalityCE]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    66
qed "cantor1";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    67
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    68
(*This form displays the diagonal term*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    69
goal Set.thy "! f:: 'a=>'a set. ! x. f(x) ~= ?S(f)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    70
by (best_tac (claset() addSEs [equalityCE]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    71
uresult();
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    72
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    73
(*This form exploits the set constructs*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    74
goal Set.thy "?S ~: range(f :: 'a=>'a set)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    75
by (rtac notI 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    76
by (etac rangeE 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    77
by (etac equalityCE 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    78
by (dtac CollectD 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    79
by (contr_tac 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    80
by (swap_res_tac [CollectI] 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    81
by (assume_tac 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    82
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    83
choplev 0;
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    84
by (best_tac (claset() addSEs [equalityCE]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    85
6236
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
    86
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    87
(*** The Schroder-Berstein Theorem ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    88
6236
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
    89
Goal "[| -(f``X) = g``(-X);  f(a)=g(b);  a:X |] ==> b:X";
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
    90
by (blast_tac (claset() addEs [equalityE]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    91
qed "disj_lemma";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    92
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5432
diff changeset
    93
Goal "-(f``X) = g``(-X) ==> surj(%z. if z:X then f(z) else g(z))";
6236
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
    94
by (asm_simp_tac (simpset() addsimps [surj_def]) 1);
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
    95
by (blast_tac (claset() addEs [equalityE]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    96
qed "surj_if_then_else";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    97
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
    98
Goalw [inj_on_def]
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
    99
     "[| inj_on f X;  inj_on g (-X);  -(f``X) = g``(-X); \
7377
2ad85e036c21 the bij predicate forced renaming of a variable bij
paulson
parents: 6236
diff changeset
   100
\        h = (%z. if z:X then f(z) else g(z)) |]       \
2ad85e036c21 the bij predicate forced renaming of a variable bij
paulson
parents: 6236
diff changeset
   101
\     ==> inj(h) & surj(h)";
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
   102
by (asm_simp_tac (simpset() addsimps [surj_if_then_else]) 1);
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
   103
   (*PROOF FAILED if inj_onD*)
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
   104
by (blast_tac (claset() addDs [disj_lemma, sym RSN (2,disj_lemma)]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   105
qed "bij_if_then_else";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   106
5786
9a2c90bdadfe increased precedence of unary minus from 80 to 100
paulson
parents: 5724
diff changeset
   107
Goal "? X. X = - (g``(- (f``X)))";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   108
by (rtac exI 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   109
by (rtac lfp_Tarski 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   110
by (REPEAT (ares_tac [monoI, image_mono, Compl_anti_mono] 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   111
qed "decomposition";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   112
5432
983b9bf8e89f new example; tidying
paulson
parents: 4831
diff changeset
   113
val [injf,injg] = goal Lfp.thy 
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
   114
   "[| inj (f:: 'a=>'b);  inj (g:: 'b=>'a) |] ==> \
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   115
\   ? h:: 'a=>'b. inj(h) & surj(h)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   116
by (rtac (decomposition RS exE) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   117
by (rtac exI 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   118
by (rtac bij_if_then_else 1);
6171
cd237a10cbf8 inj is now a translation of inj_on
paulson
parents: 6146
diff changeset
   119
by (rtac refl 4);
6236
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
   120
by (rtac inj_on_inv 2);
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
   121
by (rtac ([subset_UNIV, injf] MRS subset_inj_on) 1);
958f4fc3e8b8 tidied Schroeder-Bernstein proof
paulson
parents: 6171
diff changeset
   122
  (**tricky variable instantiations!**)
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   123
by (EVERY1 [etac ssubst, stac double_complement, rtac subsetI,
1465
5d7a7e439cec expanded tabs
clasohm
parents: 969
diff changeset
   124
            etac imageE, etac ssubst, rtac rangeI]);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   125
by (EVERY1 [etac ssubst, stac double_complement, 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 969
diff changeset
   126
            rtac (injg RS inv_image_comp RS sym)]);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   127
qed "schroeder_bernstein";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   128
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   129
writeln"Reached end of file.";