src/HOL/Isar_examples/Cantor.thy
author wenzelm
Fri, 08 Oct 1999 15:09:14 +0200
changeset 7800 8ee919e42174
parent 7748 5b9c45b21782
child 7819 6dd018b6cf3f
permissions -rw-r--r--
improved presentation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Isar_examples/Cantor.thy
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     4
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
     5
Cantor's theorem -- Isar'ized version of the final section of the HOL
6507
wenzelm
parents: 6506
diff changeset
     6
chapter of "Isabelle's Object-Logics" (Larry Paulson).
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     7
*)
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     8
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7748
diff changeset
     9
header {* Cantor's Theorem *};
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
    10
7748
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    11
theory Cantor = Main:;
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
    12
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    13
text {*
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
    14
  Cantor's Theorem states that every set has more subsets than it has
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7748
diff changeset
    15
  elements.  It has become a favorite basic example in pure
8ee919e42174 improved presentation;
wenzelm
parents: 7748
diff changeset
    16
  higher-order logic since it is so easily expressed: \[\all{f::\alpha
8ee919e42174 improved presentation;
wenzelm
parents: 7748
diff changeset
    17
  \To \alpha \To \idt{bool}} \ex{S::\alpha \To \idt{bool}}
8ee919e42174 improved presentation;
wenzelm
parents: 7748
diff changeset
    18
  \all{x::\alpha}. f \ap x \not= S\]
7748
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    19
  
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    20
  Viewing types as sets, $\alpha \To \idt{bool}$ represents the powerset of
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    21
  $\alpha$.  This version of the theorem states that for every function from
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    22
  $\alpha$ to its powerset, some subset is outside its range.  The
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    23
  Isabelle/Isar proofs below use HOL's set theory, with the type $\alpha \ap
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    24
  \idt{set}$ and the operator $\idt{range}$.
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    25
  
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    26
  \bigskip We first consider a rather verbose version of the proof, with the
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    27
  reasoning expressed quite naively.  We only make use of the pure core of the
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    28
  Isar proof language.
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    29
*};
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
    30
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    31
theorem "EX S. S ~: range(f :: 'a => 'a set)";
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    32
proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    33
  let ?S = "{x. x ~: f x}";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    34
  show "?S ~: range f";
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    35
  proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    36
    assume "?S : range f";
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    37
    then; show False;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    38
    proof;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    39
      fix y; 
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    40
      assume "?S = f y";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    41
      then; show ?thesis;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    42
      proof (rule equalityCE);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    43
        assume y_in_S: "y : ?S";
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    44
        assume y_in_fy: "y : f y";
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    45
        from y_in_S; have y_notin_fy: "y ~: f y"; ..;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    46
        from y_notin_fy y_in_fy; show ?thesis; by contradiction;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    47
      next;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    48
        assume y_notin_S: "y ~: ?S";
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    49
        assume y_notin_fy: "y ~: f y";
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    50
        from y_notin_S; have y_in_fy: "y : f y"; ..;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    51
        from y_notin_fy y_in_fy; show ?thesis; by contradiction;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    52
      qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    53
    qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    54
  qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    55
qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    56
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    57
text {*
7748
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    58
  The following version of the proof essentially does the same reasoning, only
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    59
  that it is expressed more neatly, with some derived Isar language elements
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    60
  involved.
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    61
*};
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    62
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    63
theorem "EX S. S ~: range(f :: 'a => 'a set)";
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    64
proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    65
  let ?S = "{x. x ~: f x}";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    66
  show "?S ~: range f";
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    67
  proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    68
    assume "?S : range f";
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
    69
    thus False;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    70
    proof;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    71
      fix y; 
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    72
      assume "?S = f y";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    73
      thus ?thesis;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    74
      proof (rule equalityCE);
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    75
        assume "y : f y";
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    76
        assume "y : ?S"; hence "y ~: f y"; ..;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    77
        thus ?thesis; by contradiction;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    78
      next;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    79
        assume "y ~: f y";
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    80
        assume "y ~: ?S"; hence "y : f y"; ..;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 6746
diff changeset
    81
        thus ?thesis; by contradiction;
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    82
      qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    83
    qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    84
  qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    85
qed;
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    86
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    87
text {*
7748
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    88
  How much creativity is required?  As it happens, Isabelle can prove this
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    89
  theorem automatically.  The default classical set contains rules for most of
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    90
  the constructs of HOL's set theory.  We must augment it with
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    91
  \name{equalityCE} to break up set equalities, and then apply best-first
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    92
  search.  Depth-first search would diverge, but best-first search
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
    93
  successfully navigates through the large search space.
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    94
*};
6505
2863855a6902 elaborated;
wenzelm
parents: 6494
diff changeset
    95
6494
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    96
theorem "EX S. S ~: range(f :: 'a => 'a set)";
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    97
  by (best elim: equalityCE);
ab1442d2e4e1 detailed proofs;
wenzelm
parents: 6444
diff changeset
    98
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
    99
text {*
7748
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
   100
  While this establishes the same theorem internally, we do not get any idea
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
   101
  of how the proof actually works.  There is currently no way to transform
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
   102
  internal system-level representations of Isabelle proofs back into Isar
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
   103
  documents.  Note that writing Isabelle/Isar proof documents actually
5b9c45b21782 improved presentation;
wenzelm
parents: 7480
diff changeset
   104
  \emph{is} a creative process.
6744
9727e83f0578 changed {| |} verbatim syntax to {* *};
wenzelm
parents: 6517
diff changeset
   105
*};
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
   106
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
   107
end;