src/HOL/Library/ContNotDenum.thy
author wenzelm
Tue, 29 Apr 2014 22:50:55 +0200
changeset 56796 9f84219715a7
parent 54797 be020ec8560c
child 57234 596a499318ab
permissions -rw-r--r--
tuned proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
     1
(*  Title:      HOL/Library/ContNonDenum.thy
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
     2
    Author:     Benjamin Porter, Monash University, NICTA, 2005
23461
wenzelm
parents: 23389
diff changeset
     3
*)
wenzelm
parents: 23389
diff changeset
     4
wenzelm
parents: 23389
diff changeset
     5
header {* Non-denumerability of the Continuum. *}
wenzelm
parents: 23389
diff changeset
     6
wenzelm
parents: 23389
diff changeset
     7
theory ContNotDenum
30663
0b6aff7451b2 Main is (Complex_Main) base entry point in library theories
haftmann
parents: 29026
diff changeset
     8
imports Complex_Main
23461
wenzelm
parents: 23389
diff changeset
     9
begin
wenzelm
parents: 23389
diff changeset
    10
wenzelm
parents: 23389
diff changeset
    11
subsection {* Abstract *}
wenzelm
parents: 23389
diff changeset
    12
wenzelm
parents: 23389
diff changeset
    13
text {* The following document presents a proof that the Continuum is
wenzelm
parents: 23389
diff changeset
    14
uncountable. It is formalised in the Isabelle/Isar theorem proving
wenzelm
parents: 23389
diff changeset
    15
system.
wenzelm
parents: 23389
diff changeset
    16
wenzelm
parents: 23389
diff changeset
    17
{\em Theorem:} The Continuum @{text "\<real>"} is not denumerable. In other
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    18
words, there does not exist a function @{text "f: \<nat> \<Rightarrow> \<real>"} such that f is
23461
wenzelm
parents: 23389
diff changeset
    19
surjective.
wenzelm
parents: 23389
diff changeset
    20
wenzelm
parents: 23389
diff changeset
    21
{\em Outline:} An elegant informal proof of this result uses Cantor's
wenzelm
parents: 23389
diff changeset
    22
Diagonalisation argument. The proof presented here is not this
wenzelm
parents: 23389
diff changeset
    23
one. First we formalise some properties of closed intervals, then we
wenzelm
parents: 23389
diff changeset
    24
prove the Nested Interval Property. This property relies on the
wenzelm
parents: 23389
diff changeset
    25
completeness of the Real numbers and is the foundation for our
wenzelm
parents: 23389
diff changeset
    26
argument. Informally it states that an intersection of countable
wenzelm
parents: 23389
diff changeset
    27
closed intervals (where each successive interval is a subset of the
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    28
last) is non-empty. We then assume a surjective function @{text
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    29
"f: \<nat> \<Rightarrow> \<real>"} exists and find a real x such that x is not in the range of f
23461
wenzelm
parents: 23389
diff changeset
    30
by generating a sequence of closed intervals then using the NIP. *}
wenzelm
parents: 23389
diff changeset
    31
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    32
23461
wenzelm
parents: 23389
diff changeset
    33
subsection {* Closed Intervals *}
wenzelm
parents: 23389
diff changeset
    34
wenzelm
parents: 23389
diff changeset
    35
subsection {* Nested Interval Property *}
wenzelm
parents: 23389
diff changeset
    36
wenzelm
parents: 23389
diff changeset
    37
theorem NIP:
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    38
  fixes f :: "nat \<Rightarrow> real set"
23461
wenzelm
parents: 23389
diff changeset
    39
  assumes subset: "\<forall>n. f (Suc n) \<subseteq> f n"
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    40
    and closed: "\<forall>n. \<exists>a b. f n = {a..b} \<and> a \<le> b"
23461
wenzelm
parents: 23389
diff changeset
    41
  shows "(\<Inter>n. f n) \<noteq> {}"
wenzelm
parents: 23389
diff changeset
    42
proof -
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    43
  let ?I = "\<lambda>n. {Inf (f n) .. Sup (f n)}"
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    44
  {
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    45
    fix n
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    46
    from closed[rule_format, of n] obtain a b where "f n = {a .. b}" "a \<le> b"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    47
      by auto
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    48
    then have "f n = {Inf (f n) .. Sup (f n)}" and "Inf (f n) \<le> Sup (f n)"
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    49
      by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    50
  }
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    51
  note f_eq = this
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    52
  {
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    53
    fix n m :: nat
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    54
    assume "n \<le> m"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    55
    then have "f m \<subseteq> f n"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    56
      by (induct rule: dec_induct) (metis order_refl, metis order_trans subset)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    57
  }
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    58
  note subset' = this
23461
wenzelm
parents: 23389
diff changeset
    59
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    60
  have "compact (f 0)"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    61
    by (subst f_eq) (rule compact_Icc)
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    62
  then have "f 0 \<inter> (\<Inter>i. f i) \<noteq> {}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    63
  proof (rule compact_imp_fip_image)
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    64
    fix I :: "nat set"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    65
    assume I: "finite I"
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    66
    have "{} \<subset> f (Max (insert 0 I))"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    67
      using f_eq[of "Max (insert 0 I)"] by auto
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    68
    also have "\<dots> \<subseteq> (\<Inter>i\<in>insert 0 I. f i)"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    69
    proof (rule INF_greatest)
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    70
      fix i
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    71
      assume "i \<in> insert 0 I"
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    72
      with I show "f (Max (insert 0 I)) \<subseteq> f i"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    73
        by (intro subset') auto
23461
wenzelm
parents: 23389
diff changeset
    74
    qed
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    75
    finally show "f 0 \<inter> (\<Inter>i\<in>I. f i) \<noteq> {}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    76
      by auto
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    77
  qed (subst f_eq, auto)
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    78
  then show "(\<Inter>n. f n) \<noteq> {}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    79
    by auto
23461
wenzelm
parents: 23389
diff changeset
    80
qed
wenzelm
parents: 23389
diff changeset
    81
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    82
23461
wenzelm
parents: 23389
diff changeset
    83
subsection {* Generating the intervals *}
wenzelm
parents: 23389
diff changeset
    84
wenzelm
parents: 23389
diff changeset
    85
subsubsection {* Existence of non-singleton closed intervals *}
wenzelm
parents: 23389
diff changeset
    86
wenzelm
parents: 23389
diff changeset
    87
text {* This lemma asserts that given any non-singleton closed
wenzelm
parents: 23389
diff changeset
    88
interval (a,b) and any element c, there exists a closed interval that
wenzelm
parents: 23389
diff changeset
    89
is a subset of (a,b) and that does not contain c and is a
wenzelm
parents: 23389
diff changeset
    90
non-singleton itself. *}
wenzelm
parents: 23389
diff changeset
    91
wenzelm
parents: 23389
diff changeset
    92
lemma closed_subset_ex:
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
    93
  fixes c :: real
53372
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
    94
  assumes "a < b"
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
    95
  shows "\<exists>ka kb. ka < kb \<and> {ka..kb} \<subseteq> {a..b} \<and> c \<notin> {ka..kb}"
53372
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
    96
proof (cases "c < b")
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
    97
  case True
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
    98
  show ?thesis
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
    99
  proof (cases "c < a")
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   100
    case True
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   101
    with `a < b` `c < b` have "c \<notin> {a..b}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   102
      by auto
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   103
    with `a < b` show ?thesis
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   104
      by auto
53372
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   105
  next
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   106
    case False
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   107
    then have "a \<le> c" by simp
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   108
    def ka \<equiv> "(c + b)/2"
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   109
    from ka_def `c < b` have "ka < b"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   110
      by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   111
    moreover from ka_def `c < b` have "ka > c"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   112
      by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   113
    ultimately have "c \<notin> {ka..b}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   114
      by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   115
    moreover from `a \<le> c` `ka > c` have "ka \<ge> a"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   116
      by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   117
    then have "{ka..b} \<subseteq> {a..b}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   118
      by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   119
    ultimately have "ka < b  \<and> {ka..b} \<subseteq> {a..b} \<and> c \<notin> {ka..b}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   120
      using `ka < b` by auto
53372
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   121
    then show ?thesis
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   122
      by auto
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   123
  qed
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   124
next
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   125
  case False
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   126
  then have "c \<ge> b" by simp
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   127
  def kb \<equiv> "(a + b)/2"
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   128
  with `a < b` have "kb < b" by auto
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   129
  with kb_def `c \<ge> b` have "a < kb" "kb < c"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   130
    by auto
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   131
  from `kb < c` have c: "c \<notin> {a..kb}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   132
    by auto
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   133
  with `kb < b` have "{a..kb} \<subseteq> {a..b}"
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   134
    by auto
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   135
  with `a < kb` c have "a < kb \<and> {a..kb} \<subseteq> {a..b} \<and> c \<notin> {a..kb}"
53372
f5a6313c7fe4 tuned proof;
wenzelm
parents: 40702
diff changeset
   136
    by simp
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   137
  then show ?thesis
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   138
    by auto
23461
wenzelm
parents: 23389
diff changeset
   139
qed
wenzelm
parents: 23389
diff changeset
   140
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   141
23461
wenzelm
parents: 23389
diff changeset
   142
subsection {* newInt: Interval generation *}
wenzelm
parents: 23389
diff changeset
   143
wenzelm
parents: 23389
diff changeset
   144
text {* Given a function f:@{text "\<nat>\<Rightarrow>\<real>"}, newInt (Suc n) f returns a
wenzelm
parents: 23389
diff changeset
   145
closed interval such that @{text "newInt (Suc n) f \<subseteq> newInt n f"} and
wenzelm
parents: 23389
diff changeset
   146
does not contain @{text "f (Suc n)"}. With the base case defined such
wenzelm
parents: 23389
diff changeset
   147
that @{text "(f 0)\<notin>newInt 0 f"}. *}
wenzelm
parents: 23389
diff changeset
   148
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   149
23461
wenzelm
parents: 23389
diff changeset
   150
subsubsection {* Definition *}
wenzelm
parents: 23389
diff changeset
   151
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   152
primrec newInt :: "nat \<Rightarrow> (nat \<Rightarrow> real) \<Rightarrow> (real set)"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   153
where
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   154
  "newInt 0 f = {f 0 + 1..f 0 + 2}"
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   155
| "newInt (Suc n) f =
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   156
    (SOME e.
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   157
      (\<exists>e1 e2.
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   158
         e1 < e2 \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   159
         e = {e1..e2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   160
         e \<subseteq> newInt n f \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   161
         f (Suc n) \<notin> e))"
27435
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   162
23461
wenzelm
parents: 23389
diff changeset
   163
wenzelm
parents: 23389
diff changeset
   164
subsubsection {* Properties *}
wenzelm
parents: 23389
diff changeset
   165
wenzelm
parents: 23389
diff changeset
   166
text {* We now show that every application of newInt returns an
wenzelm
parents: 23389
diff changeset
   167
appropriate interval. *}
wenzelm
parents: 23389
diff changeset
   168
wenzelm
parents: 23389
diff changeset
   169
lemma newInt_ex:
wenzelm
parents: 23389
diff changeset
   170
  "\<exists>a b. a < b \<and>
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   171
    newInt (Suc n) f = {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   172
    newInt (Suc n) f \<subseteq> newInt n f \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   173
    f (Suc n) \<notin> newInt (Suc n) f"
23461
wenzelm
parents: 23389
diff changeset
   174
proof (induct n)
wenzelm
parents: 23389
diff changeset
   175
  case 0
wenzelm
parents: 23389
diff changeset
   176
  let ?e = "SOME e. \<exists>e1 e2.
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   177
    e1 < e2 \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   178
    e = {e1..e2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   179
    e \<subseteq> {f 0 + 1..f 0 + 2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   180
    f (Suc 0) \<notin> e"
23461
wenzelm
parents: 23389
diff changeset
   181
wenzelm
parents: 23389
diff changeset
   182
  have "newInt (Suc 0) f = ?e" by auto
wenzelm
parents: 23389
diff changeset
   183
  moreover
wenzelm
parents: 23389
diff changeset
   184
  have "f 0 + 1 < f 0 + 2" by simp
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   185
  with closed_subset_ex
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   186
  have "\<exists>ka kb. ka < kb \<and> {ka..kb} \<subseteq> {f 0 + 1..f 0 + 2} \<and> f (Suc 0) \<notin> {ka..kb}" .
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   187
  then have "\<exists>e. \<exists>ka kb. ka < kb \<and> e = {ka..kb} \<and> e \<subseteq> {f 0 + 1..f 0 + 2} \<and> f (Suc 0) \<notin> e"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   188
    by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   189
  then have "\<exists>ka kb. ka < kb \<and> ?e = {ka..kb} \<and> ?e \<subseteq> {f 0 + 1..f 0 + 2} \<and> f (Suc 0) \<notin> ?e"
23461
wenzelm
parents: 23389
diff changeset
   190
    by (rule someI_ex)
wenzelm
parents: 23389
diff changeset
   191
  ultimately have "\<exists>e1 e2. e1 < e2 \<and>
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   192
      newInt (Suc 0) f = {e1..e2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   193
      newInt (Suc 0) f \<subseteq> {f 0 + 1..f 0 + 2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   194
      f (Suc 0) \<notin> newInt (Suc 0) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   195
    by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   196
  then show "\<exists>a b. a < b \<and> newInt (Suc 0) f = {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   197
      newInt (Suc 0) f \<subseteq> newInt 0 f \<and> f (Suc 0) \<notin> newInt (Suc 0) f"
23461
wenzelm
parents: 23389
diff changeset
   198
    by simp
wenzelm
parents: 23389
diff changeset
   199
next
wenzelm
parents: 23389
diff changeset
   200
  case (Suc n)
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   201
  then have "\<exists>a b.
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   202
      a < b \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   203
      newInt (Suc n) f = {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   204
      newInt (Suc n) f \<subseteq> newInt n f \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   205
      f (Suc n) \<notin> newInt (Suc n) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   206
    by simp
23461
wenzelm
parents: 23389
diff changeset
   207
  then obtain a and b where ab: "a < b \<and>
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   208
      newInt (Suc n) f = {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   209
      newInt (Suc n) f \<subseteq> newInt n f \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   210
      f (Suc n) \<notin> newInt (Suc n) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   211
    by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   212
  then have cab: "{a..b} = newInt (Suc n) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   213
    by simp
23461
wenzelm
parents: 23389
diff changeset
   214
wenzelm
parents: 23389
diff changeset
   215
  let ?e = "SOME e. \<exists>e1 e2.
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   216
      e1 < e2 \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   217
      e = {e1..e2} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   218
      e \<subseteq> {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   219
      f (Suc (Suc n)) \<notin> e"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   220
  from cab have ni: "newInt (Suc (Suc n)) f = ?e"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   221
    by auto
23461
wenzelm
parents: 23389
diff changeset
   222
wenzelm
parents: 23389
diff changeset
   223
  from ab have "a < b" by simp
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   224
  with closed_subset_ex have "\<exists>ka kb. ka < kb \<and> {ka..kb} \<subseteq> {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   225
    f (Suc (Suc n)) \<notin> {ka..kb}" .
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   226
  then have "\<exists>e. \<exists>ka kb. ka < kb \<and> e = {ka..kb} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   227
      {ka..kb} \<subseteq> {a..b} \<and> f (Suc (Suc n)) \<notin> {ka..kb}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   228
    by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   229
  then have "\<exists>e.  \<exists>ka kb. ka < kb \<and> e = {ka..kb} \<and> e \<subseteq> {a..b} \<and> f (Suc (Suc n)) \<notin> e"
23461
wenzelm
parents: 23389
diff changeset
   230
    by simp
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   231
  then have "\<exists>ka kb. ka < kb \<and> ?e = {ka..kb} \<and> ?e \<subseteq> {a..b} \<and> f (Suc (Suc n)) \<notin> ?e"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   232
    by (rule someI_ex)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   233
  with ab ni show "\<exists>ka kb. ka < kb \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   234
      newInt (Suc (Suc n)) f = {ka..kb} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   235
      newInt (Suc (Suc n)) f \<subseteq> newInt (Suc n) f \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   236
      f (Suc (Suc n)) \<notin> newInt (Suc (Suc n)) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   237
    by auto
23461
wenzelm
parents: 23389
diff changeset
   238
qed
wenzelm
parents: 23389
diff changeset
   239
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   240
lemma newInt_subset: "newInt (Suc n) f \<subseteq> newInt n f"
23461
wenzelm
parents: 23389
diff changeset
   241
  using newInt_ex by auto
wenzelm
parents: 23389
diff changeset
   242
wenzelm
parents: 23389
diff changeset
   243
wenzelm
parents: 23389
diff changeset
   244
text {* Another fundamental property is that no element in the range
wenzelm
parents: 23389
diff changeset
   245
of f is in the intersection of all closed intervals generated by
wenzelm
parents: 23389
diff changeset
   246
newInt. *}
wenzelm
parents: 23389
diff changeset
   247
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   248
lemma newInt_inter: "\<forall>n. f n \<notin> (\<Inter>n. newInt n f)"
23461
wenzelm
parents: 23389
diff changeset
   249
proof
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   250
  fix n :: nat
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   251
  have "f n \<notin> newInt n f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   252
  proof (cases n)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   253
    case 0
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   254
    moreover have "newInt 0 f = {f 0 + 1..f 0 + 2}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   255
      by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   256
    ultimately show ?thesis by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   257
  next
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   258
    case (Suc m)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   259
    from newInt_ex have "\<exists>a b. a < b \<and> (newInt (Suc m) f) = {a..b} \<and>
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   260
      newInt (Suc m) f \<subseteq> newInt m f \<and> f (Suc m) \<notin> newInt (Suc m) f" .
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   261
    then have "f (Suc m) \<notin> newInt (Suc m) f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   262
      by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   263
    with Suc show ?thesis by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   264
  qed
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   265
  then show "f n \<notin> (\<Inter>n. newInt n f)" by auto
23461
wenzelm
parents: 23389
diff changeset
   266
qed
wenzelm
parents: 23389
diff changeset
   267
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   268
lemma newInt_notempty: "(\<Inter>n. newInt n f) \<noteq> {}"
23461
wenzelm
parents: 23389
diff changeset
   269
proof -
wenzelm
parents: 23389
diff changeset
   270
  let ?g = "\<lambda>n. newInt n f"
wenzelm
parents: 23389
diff changeset
   271
  have "\<forall>n. ?g (Suc n) \<subseteq> ?g n"
wenzelm
parents: 23389
diff changeset
   272
  proof
wenzelm
parents: 23389
diff changeset
   273
    fix n
wenzelm
parents: 23389
diff changeset
   274
    show "?g (Suc n) \<subseteq> ?g n" by (rule newInt_subset)
wenzelm
parents: 23389
diff changeset
   275
  qed
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   276
  moreover have "\<forall>n. \<exists>a b. ?g n = {a..b} \<and> a \<le> b"
23461
wenzelm
parents: 23389
diff changeset
   277
  proof
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   278
    fix n :: nat
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   279
    show "\<exists>a b. ?g n = {a..b} \<and> a \<le> b"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   280
    proof (cases n)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   281
      case 0
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   282
      then have "?g n = {f 0 + 1..f 0 + 2} \<and> (f 0 + 1 \<le> f 0 + 2)"
23461
wenzelm
parents: 23389
diff changeset
   283
        by simp
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   284
      then show ?thesis
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   285
        by blast
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   286
    next
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   287
      case (Suc m)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   288
      have "\<exists>a b. a < b \<and> (newInt (Suc m) f) = {a..b} \<and>
23461
wenzelm
parents: 23389
diff changeset
   289
        (newInt (Suc m) f) \<subseteq> (newInt m f) \<and> (f (Suc m)) \<notin> (newInt (Suc m) f)"
wenzelm
parents: 23389
diff changeset
   290
        by (rule newInt_ex)
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   291
      then obtain a and b where "a < b \<and> (newInt (Suc m) f) = {a..b}"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   292
        by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   293
      with Suc have "?g n = {a..b} \<and> a \<le> b"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   294
        by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   295
      then show ?thesis
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   296
        by blast
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   297
    qed
23461
wenzelm
parents: 23389
diff changeset
   298
  qed
wenzelm
parents: 23389
diff changeset
   299
  ultimately show ?thesis by (rule NIP)
wenzelm
parents: 23389
diff changeset
   300
qed
wenzelm
parents: 23389
diff changeset
   301
wenzelm
parents: 23389
diff changeset
   302
wenzelm
parents: 23389
diff changeset
   303
subsection {* Final Theorem *}
wenzelm
parents: 23389
diff changeset
   304
56796
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   305
theorem real_non_denum: "\<not> (\<exists>f :: nat \<Rightarrow> real. surj f)"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   306
proof
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   307
  assume "\<exists>f :: nat \<Rightarrow> real. surj f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   308
  then obtain f :: "nat \<Rightarrow> real" where "surj f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   309
    by auto
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   310
  txt "We now produce a real number x that is not in the range of f, using the properties of newInt."
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   311
  have "\<exists>x. x \<in> (\<Inter>n. newInt n f)"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   312
    using newInt_notempty by blast
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   313
  moreover have "\<forall>n. f n \<notin> (\<Inter>n. newInt n f)"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   314
    by (rule newInt_inter)
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   315
  ultimately obtain x where "x \<in> (\<Inter>n. newInt n f)" and "\<forall>n. f n \<noteq> x"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   316
    by blast
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   317
  moreover from `surj f` have "x \<in> range f"
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   318
    by simp
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   319
  ultimately show False
9f84219715a7 tuned proofs;
wenzelm
parents: 54797
diff changeset
   320
    by blast
23461
wenzelm
parents: 23389
diff changeset
   321
qed
wenzelm
parents: 23389
diff changeset
   322
wenzelm
parents: 23389
diff changeset
   323
end
54797
be020ec8560c modernized ContNotDenum: use Set_Interval, and finite intersection property to show the nested interval property
hoelzl
parents: 54263
diff changeset
   324