src/HOL/Library/ContNotDenum.thy
author haftmann
Tue, 23 Jun 2009 14:24:58 +0200
changeset 31776 151c3f5f28f9
parent 30663 0b6aff7451b2
child 37765 26bdfb7b680b
permissions -rw-r--r--
simplified proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28952
15a4b2cf8c34 made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents: 28562
diff changeset
     1
(*  Title       : HOL/ContNonDenum
23461
wenzelm
parents: 23389
diff changeset
     2
    Author      : Benjamin Porter, Monash University, NICTA, 2005
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
wenzelm
parents: 23389
diff changeset
    18
words, there does not exist a function f:@{text "\<nat>\<Rightarrow>\<real>"} such that f is
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
wenzelm
parents: 23389
diff changeset
    28
last) is non-empty. We then assume a surjective function f:@{text
wenzelm
parents: 23389
diff changeset
    29
"\<nat>\<Rightarrow>\<real>"} exists and find a real x such that x is not in the range of f
wenzelm
parents: 23389
diff changeset
    30
by generating a sequence of closed intervals then using the NIP. *}
wenzelm
parents: 23389
diff changeset
    31
wenzelm
parents: 23389
diff changeset
    32
subsection {* Closed Intervals *}
wenzelm
parents: 23389
diff changeset
    33
wenzelm
parents: 23389
diff changeset
    34
text {* This section formalises some properties of closed intervals. *}
wenzelm
parents: 23389
diff changeset
    35
wenzelm
parents: 23389
diff changeset
    36
subsubsection {* Definition *}
wenzelm
parents: 23389
diff changeset
    37
wenzelm
parents: 23389
diff changeset
    38
definition
wenzelm
parents: 23389
diff changeset
    39
  closed_int :: "real \<Rightarrow> real \<Rightarrow> real set" where
wenzelm
parents: 23389
diff changeset
    40
  "closed_int x y = {z. x \<le> z \<and> z \<le> y}"
wenzelm
parents: 23389
diff changeset
    41
wenzelm
parents: 23389
diff changeset
    42
subsubsection {* Properties *}
wenzelm
parents: 23389
diff changeset
    43
wenzelm
parents: 23389
diff changeset
    44
lemma closed_int_subset:
wenzelm
parents: 23389
diff changeset
    45
  assumes xy: "x1 \<ge> x0" "y1 \<le> y0"
wenzelm
parents: 23389
diff changeset
    46
  shows "closed_int x1 y1 \<subseteq> closed_int x0 y0"
wenzelm
parents: 23389
diff changeset
    47
proof -
wenzelm
parents: 23389
diff changeset
    48
  {
wenzelm
parents: 23389
diff changeset
    49
    fix x::real
wenzelm
parents: 23389
diff changeset
    50
    assume "x \<in> closed_int x1 y1"
wenzelm
parents: 23389
diff changeset
    51
    hence "x \<ge> x1 \<and> x \<le> y1" by (simp add: closed_int_def)
wenzelm
parents: 23389
diff changeset
    52
    with xy have "x \<ge> x0 \<and> x \<le> y0" by auto
wenzelm
parents: 23389
diff changeset
    53
    hence "x \<in> closed_int x0 y0" by (simp add: closed_int_def)
wenzelm
parents: 23389
diff changeset
    54
  }
wenzelm
parents: 23389
diff changeset
    55
  thus ?thesis by auto
wenzelm
parents: 23389
diff changeset
    56
qed
wenzelm
parents: 23389
diff changeset
    57
wenzelm
parents: 23389
diff changeset
    58
lemma closed_int_least:
wenzelm
parents: 23389
diff changeset
    59
  assumes a: "a \<le> b"
wenzelm
parents: 23389
diff changeset
    60
  shows "a \<in> closed_int a b \<and> (\<forall>x \<in> closed_int a b. a \<le> x)"
wenzelm
parents: 23389
diff changeset
    61
proof
wenzelm
parents: 23389
diff changeset
    62
  from a have "a\<in>{x. a\<le>x \<and> x\<le>b}" by simp
wenzelm
parents: 23389
diff changeset
    63
  thus "a \<in> closed_int a b" by (unfold closed_int_def)
wenzelm
parents: 23389
diff changeset
    64
next
wenzelm
parents: 23389
diff changeset
    65
  have "\<forall>x\<in>{x. a\<le>x \<and> x\<le>b}. a\<le>x" by simp
wenzelm
parents: 23389
diff changeset
    66
  thus "\<forall>x \<in> closed_int a b. a \<le> x" by (unfold closed_int_def)
wenzelm
parents: 23389
diff changeset
    67
qed
wenzelm
parents: 23389
diff changeset
    68
wenzelm
parents: 23389
diff changeset
    69
lemma closed_int_most:
wenzelm
parents: 23389
diff changeset
    70
  assumes a: "a \<le> b"
wenzelm
parents: 23389
diff changeset
    71
  shows "b \<in> closed_int a b \<and> (\<forall>x \<in> closed_int a b. x \<le> b)"
wenzelm
parents: 23389
diff changeset
    72
proof
wenzelm
parents: 23389
diff changeset
    73
  from a have "b\<in>{x. a\<le>x \<and> x\<le>b}" by simp
wenzelm
parents: 23389
diff changeset
    74
  thus "b \<in> closed_int a b" by (unfold closed_int_def)
wenzelm
parents: 23389
diff changeset
    75
next
wenzelm
parents: 23389
diff changeset
    76
  have "\<forall>x\<in>{x. a\<le>x \<and> x\<le>b}. x\<le>b" by simp
wenzelm
parents: 23389
diff changeset
    77
  thus "\<forall>x \<in> closed_int a b. x\<le>b" by (unfold closed_int_def)
wenzelm
parents: 23389
diff changeset
    78
qed
wenzelm
parents: 23389
diff changeset
    79
wenzelm
parents: 23389
diff changeset
    80
lemma closed_not_empty:
wenzelm
parents: 23389
diff changeset
    81
  shows "a \<le> b \<Longrightarrow> \<exists>x. x \<in> closed_int a b" 
wenzelm
parents: 23389
diff changeset
    82
  by (auto dest: closed_int_least)
wenzelm
parents: 23389
diff changeset
    83
wenzelm
parents: 23389
diff changeset
    84
lemma closed_mem:
wenzelm
parents: 23389
diff changeset
    85
  assumes "a \<le> c" and "c \<le> b"
wenzelm
parents: 23389
diff changeset
    86
  shows "c \<in> closed_int a b"
wenzelm
parents: 23389
diff changeset
    87
  using assms unfolding closed_int_def by auto
wenzelm
parents: 23389
diff changeset
    88
wenzelm
parents: 23389
diff changeset
    89
lemma closed_subset:
wenzelm
parents: 23389
diff changeset
    90
  assumes ac: "a \<le> b"  "c \<le> d" 
wenzelm
parents: 23389
diff changeset
    91
  assumes closed: "closed_int a b \<subseteq> closed_int c d"
wenzelm
parents: 23389
diff changeset
    92
  shows "b \<ge> c"
wenzelm
parents: 23389
diff changeset
    93
proof -
wenzelm
parents: 23389
diff changeset
    94
  from closed have "\<forall>x\<in>closed_int a b. x\<in>closed_int c d" by auto
wenzelm
parents: 23389
diff changeset
    95
  hence "\<forall>x. a\<le>x \<and> x\<le>b \<longrightarrow> c\<le>x \<and> x\<le>d" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
    96
  with ac have "c\<le>b \<and> b\<le>d" by simp
wenzelm
parents: 23389
diff changeset
    97
  thus ?thesis by auto
wenzelm
parents: 23389
diff changeset
    98
qed
wenzelm
parents: 23389
diff changeset
    99
wenzelm
parents: 23389
diff changeset
   100
wenzelm
parents: 23389
diff changeset
   101
subsection {* Nested Interval Property *}
wenzelm
parents: 23389
diff changeset
   102
wenzelm
parents: 23389
diff changeset
   103
theorem NIP:
wenzelm
parents: 23389
diff changeset
   104
  fixes f::"nat \<Rightarrow> real set"
wenzelm
parents: 23389
diff changeset
   105
  assumes subset: "\<forall>n. f (Suc n) \<subseteq> f n"
wenzelm
parents: 23389
diff changeset
   106
  and closed: "\<forall>n. \<exists>a b. f n = closed_int a b \<and> a \<le> b"
wenzelm
parents: 23389
diff changeset
   107
  shows "(\<Inter>n. f n) \<noteq> {}"
wenzelm
parents: 23389
diff changeset
   108
proof -
wenzelm
parents: 23389
diff changeset
   109
  let ?g = "\<lambda>n. (SOME c. c\<in>(f n) \<and> (\<forall>x\<in>(f n). c \<le> x))"
wenzelm
parents: 23389
diff changeset
   110
  have ne: "\<forall>n. \<exists>x. x\<in>(f n)"
wenzelm
parents: 23389
diff changeset
   111
  proof
wenzelm
parents: 23389
diff changeset
   112
    fix n
wenzelm
parents: 23389
diff changeset
   113
    from closed have "\<exists>a b. f n = closed_int a b \<and> a \<le> b" by simp
wenzelm
parents: 23389
diff changeset
   114
    then obtain a and b where fn: "f n = closed_int a b \<and> a \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   115
    hence "a \<le> b" ..
wenzelm
parents: 23389
diff changeset
   116
    with closed_not_empty have "\<exists>x. x\<in>closed_int a b" by simp
wenzelm
parents: 23389
diff changeset
   117
    with fn show "\<exists>x. x\<in>(f n)" by simp
wenzelm
parents: 23389
diff changeset
   118
  qed
wenzelm
parents: 23389
diff changeset
   119
wenzelm
parents: 23389
diff changeset
   120
  have gdef: "\<forall>n. (?g n)\<in>(f n) \<and> (\<forall>x\<in>(f n). (?g n)\<le>x)"
wenzelm
parents: 23389
diff changeset
   121
  proof
wenzelm
parents: 23389
diff changeset
   122
    fix n
wenzelm
parents: 23389
diff changeset
   123
    from closed have "\<exists>a b. f n = closed_int a b \<and> a \<le> b" ..
wenzelm
parents: 23389
diff changeset
   124
    then obtain a and b where ff: "f n = closed_int a b" and "a \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   125
    hence "a \<le> b" by simp
wenzelm
parents: 23389
diff changeset
   126
    hence "a\<in>closed_int a b \<and> (\<forall>x\<in>closed_int a b. a \<le> x)" by (rule closed_int_least)
wenzelm
parents: 23389
diff changeset
   127
    with ff have "a\<in>(f n) \<and> (\<forall>x\<in>(f n). a \<le> x)" by simp
wenzelm
parents: 23389
diff changeset
   128
    hence "\<exists>c. c\<in>(f n) \<and> (\<forall>x\<in>(f n). c \<le> x)" ..
wenzelm
parents: 23389
diff changeset
   129
    thus "(?g n)\<in>(f n) \<and> (\<forall>x\<in>(f n). (?g n)\<le>x)" by (rule someI_ex)
wenzelm
parents: 23389
diff changeset
   130
  qed
wenzelm
parents: 23389
diff changeset
   131
wenzelm
parents: 23389
diff changeset
   132
  -- "A denotes the set of all left-most points of all the intervals ..."
wenzelm
parents: 23389
diff changeset
   133
  moreover obtain A where Adef: "A = ?g ` \<nat>" by simp
wenzelm
parents: 23389
diff changeset
   134
  ultimately have "\<exists>x. x\<in>A"
wenzelm
parents: 23389
diff changeset
   135
  proof -
wenzelm
parents: 23389
diff changeset
   136
    have "(0::nat) \<in> \<nat>" by simp
wenzelm
parents: 23389
diff changeset
   137
    moreover have "?g 0 = ?g 0" by simp
wenzelm
parents: 23389
diff changeset
   138
    ultimately have "?g 0 \<in> ?g ` \<nat>" by (rule  rev_image_eqI)
wenzelm
parents: 23389
diff changeset
   139
    with Adef have "?g 0 \<in> A" by simp
wenzelm
parents: 23389
diff changeset
   140
    thus ?thesis ..
wenzelm
parents: 23389
diff changeset
   141
  qed
wenzelm
parents: 23389
diff changeset
   142
wenzelm
parents: 23389
diff changeset
   143
  -- "Now show that A is bounded above ..."
wenzelm
parents: 23389
diff changeset
   144
  moreover have "\<exists>y. isUb (UNIV::real set) A y"
wenzelm
parents: 23389
diff changeset
   145
  proof -
wenzelm
parents: 23389
diff changeset
   146
    {
wenzelm
parents: 23389
diff changeset
   147
      fix n
wenzelm
parents: 23389
diff changeset
   148
      from ne have ex: "\<exists>x. x\<in>(f n)" ..
wenzelm
parents: 23389
diff changeset
   149
      from gdef have "(?g n)\<in>(f n) \<and> (\<forall>x\<in>(f n). (?g n)\<le>x)" by simp
wenzelm
parents: 23389
diff changeset
   150
      moreover
wenzelm
parents: 23389
diff changeset
   151
      from closed have "\<exists>a b. f n = closed_int a b \<and> a \<le> b" ..
wenzelm
parents: 23389
diff changeset
   152
      then obtain a and b where "f n = closed_int a b \<and> a \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   153
      hence "b\<in>(f n) \<and> (\<forall>x\<in>(f n). x \<le> b)" using closed_int_most by blast
wenzelm
parents: 23389
diff changeset
   154
      ultimately have "\<forall>x\<in>(f n). (?g n) \<le> b" by simp
wenzelm
parents: 23389
diff changeset
   155
      with ex have "(?g n) \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   156
      hence "\<exists>b. (?g n) \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   157
    }
wenzelm
parents: 23389
diff changeset
   158
    hence aux: "\<forall>n. \<exists>b. (?g n) \<le> b" ..
wenzelm
parents: 23389
diff changeset
   159
wenzelm
parents: 23389
diff changeset
   160
    have fs: "\<forall>n::nat. f n \<subseteq> f 0"
wenzelm
parents: 23389
diff changeset
   161
    proof (rule allI, induct_tac n)
wenzelm
parents: 23389
diff changeset
   162
      show "f 0 \<subseteq> f 0" by simp
wenzelm
parents: 23389
diff changeset
   163
    next
wenzelm
parents: 23389
diff changeset
   164
      fix n
wenzelm
parents: 23389
diff changeset
   165
      assume "f n \<subseteq> f 0"
wenzelm
parents: 23389
diff changeset
   166
      moreover from subset have "f (Suc n) \<subseteq> f n" ..
wenzelm
parents: 23389
diff changeset
   167
      ultimately show "f (Suc n) \<subseteq> f 0" by simp
wenzelm
parents: 23389
diff changeset
   168
    qed
wenzelm
parents: 23389
diff changeset
   169
    have "\<forall>n. (?g n)\<in>(f 0)"
wenzelm
parents: 23389
diff changeset
   170
    proof
wenzelm
parents: 23389
diff changeset
   171
      fix n
wenzelm
parents: 23389
diff changeset
   172
      from gdef have "(?g n)\<in>(f n) \<and> (\<forall>x\<in>(f n). (?g n)\<le>x)" by simp
wenzelm
parents: 23389
diff changeset
   173
      hence "?g n \<in> f n" ..
wenzelm
parents: 23389
diff changeset
   174
      with fs show "?g n \<in> f 0" by auto
wenzelm
parents: 23389
diff changeset
   175
    qed
wenzelm
parents: 23389
diff changeset
   176
    moreover from closed
wenzelm
parents: 23389
diff changeset
   177
      obtain a and b where "f 0 = closed_int a b" and alb: "a \<le> b" by blast
wenzelm
parents: 23389
diff changeset
   178
    ultimately have "\<forall>n. ?g n \<in> closed_int a b" by auto
wenzelm
parents: 23389
diff changeset
   179
    with alb have "\<forall>n. ?g n \<le> b" using closed_int_most by blast
wenzelm
parents: 23389
diff changeset
   180
    with Adef have "\<forall>y\<in>A. y\<le>b" by auto
wenzelm
parents: 23389
diff changeset
   181
    hence "A *<= b" by (unfold setle_def)
wenzelm
parents: 23389
diff changeset
   182
    moreover have "b \<in> (UNIV::real set)" by simp
wenzelm
parents: 23389
diff changeset
   183
    ultimately have "A *<= b \<and> b \<in> (UNIV::real set)" by simp
wenzelm
parents: 23389
diff changeset
   184
    hence "isUb (UNIV::real set) A b" by (unfold isUb_def)
wenzelm
parents: 23389
diff changeset
   185
    thus ?thesis by auto
wenzelm
parents: 23389
diff changeset
   186
  qed
wenzelm
parents: 23389
diff changeset
   187
  -- "by the Axiom Of Completeness, A has a least upper bound ..."
wenzelm
parents: 23389
diff changeset
   188
  ultimately have "\<exists>t. isLub UNIV A t" by (rule reals_complete)
wenzelm
parents: 23389
diff changeset
   189
wenzelm
parents: 23389
diff changeset
   190
  -- "denote this least upper bound as t ..."
wenzelm
parents: 23389
diff changeset
   191
  then obtain t where tdef: "isLub UNIV A t" ..
wenzelm
parents: 23389
diff changeset
   192
wenzelm
parents: 23389
diff changeset
   193
  -- "and finally show that this least upper bound is in all the intervals..."
wenzelm
parents: 23389
diff changeset
   194
  have "\<forall>n. t \<in> f n"
wenzelm
parents: 23389
diff changeset
   195
  proof
wenzelm
parents: 23389
diff changeset
   196
    fix n::nat
wenzelm
parents: 23389
diff changeset
   197
    from closed obtain a and b where
wenzelm
parents: 23389
diff changeset
   198
      int: "f n = closed_int a b" and alb: "a \<le> b" by blast
wenzelm
parents: 23389
diff changeset
   199
wenzelm
parents: 23389
diff changeset
   200
    have "t \<ge> a"
wenzelm
parents: 23389
diff changeset
   201
    proof -
wenzelm
parents: 23389
diff changeset
   202
      have "a \<in> A"
wenzelm
parents: 23389
diff changeset
   203
      proof -
wenzelm
parents: 23389
diff changeset
   204
          (* by construction *)
wenzelm
parents: 23389
diff changeset
   205
        from alb int have ain: "a\<in>f n \<and> (\<forall>x\<in>f n. a \<le> x)"
wenzelm
parents: 23389
diff changeset
   206
          using closed_int_least by blast
wenzelm
parents: 23389
diff changeset
   207
        moreover have "\<forall>e. e\<in>f n \<and> (\<forall>x\<in>f n. e \<le> x) \<longrightarrow> e = a"
wenzelm
parents: 23389
diff changeset
   208
        proof clarsimp
wenzelm
parents: 23389
diff changeset
   209
          fix e
wenzelm
parents: 23389
diff changeset
   210
          assume ein: "e \<in> f n" and lt: "\<forall>x\<in>f n. e \<le> x"
wenzelm
parents: 23389
diff changeset
   211
          from lt ain have aux: "\<forall>x\<in>f n. a \<le> x \<and> e \<le> x" by auto
wenzelm
parents: 23389
diff changeset
   212
  
wenzelm
parents: 23389
diff changeset
   213
          from ein aux have "a \<le> e \<and> e \<le> e" by auto
wenzelm
parents: 23389
diff changeset
   214
          moreover from ain aux have "a \<le> a \<and> e \<le> a" by auto
wenzelm
parents: 23389
diff changeset
   215
          ultimately show "e = a" by simp
wenzelm
parents: 23389
diff changeset
   216
        qed
wenzelm
parents: 23389
diff changeset
   217
        hence "\<And>e.  e\<in>f n \<and> (\<forall>x\<in>f n. e \<le> x) \<Longrightarrow> e = a" by simp
wenzelm
parents: 23389
diff changeset
   218
        ultimately have "(?g n) = a" by (rule some_equality)
wenzelm
parents: 23389
diff changeset
   219
        moreover
wenzelm
parents: 23389
diff changeset
   220
        {
wenzelm
parents: 23389
diff changeset
   221
          have "n = of_nat n" by simp
wenzelm
parents: 23389
diff changeset
   222
          moreover have "of_nat n \<in> \<nat>" by simp
wenzelm
parents: 23389
diff changeset
   223
          ultimately have "n \<in> \<nat>"
wenzelm
parents: 23389
diff changeset
   224
            apply -
wenzelm
parents: 23389
diff changeset
   225
            apply (subst(asm) eq_sym_conv)
wenzelm
parents: 23389
diff changeset
   226
            apply (erule subst)
wenzelm
parents: 23389
diff changeset
   227
            .
wenzelm
parents: 23389
diff changeset
   228
        }
wenzelm
parents: 23389
diff changeset
   229
        with Adef have "(?g n) \<in> A" by auto
wenzelm
parents: 23389
diff changeset
   230
        ultimately show ?thesis by simp
wenzelm
parents: 23389
diff changeset
   231
      qed 
wenzelm
parents: 23389
diff changeset
   232
      with tdef show "a \<le> t" by (rule isLubD2)
wenzelm
parents: 23389
diff changeset
   233
    qed
wenzelm
parents: 23389
diff changeset
   234
    moreover have "t \<le> b"
wenzelm
parents: 23389
diff changeset
   235
    proof -
wenzelm
parents: 23389
diff changeset
   236
      have "isUb UNIV A b"
wenzelm
parents: 23389
diff changeset
   237
      proof -
wenzelm
parents: 23389
diff changeset
   238
        {
wenzelm
parents: 23389
diff changeset
   239
          from alb int have
wenzelm
parents: 23389
diff changeset
   240
            ain: "b\<in>f n \<and> (\<forall>x\<in>f n. x \<le> b)" using closed_int_most by blast
wenzelm
parents: 23389
diff changeset
   241
          
wenzelm
parents: 23389
diff changeset
   242
          have subsetd: "\<forall>m. \<forall>n. f (n + m) \<subseteq> f n"
wenzelm
parents: 23389
diff changeset
   243
          proof (rule allI, induct_tac m)
wenzelm
parents: 23389
diff changeset
   244
            show "\<forall>n. f (n + 0) \<subseteq> f n" by simp
wenzelm
parents: 23389
diff changeset
   245
          next
wenzelm
parents: 23389
diff changeset
   246
            fix m n
wenzelm
parents: 23389
diff changeset
   247
            assume pp: "\<forall>p. f (p + n) \<subseteq> f p"
wenzelm
parents: 23389
diff changeset
   248
            {
wenzelm
parents: 23389
diff changeset
   249
              fix p
wenzelm
parents: 23389
diff changeset
   250
              from pp have "f (p + n) \<subseteq> f p" by simp
wenzelm
parents: 23389
diff changeset
   251
              moreover from subset have "f (Suc (p + n)) \<subseteq> f (p + n)" by auto
wenzelm
parents: 23389
diff changeset
   252
              hence "f (p + (Suc n)) \<subseteq> f (p + n)" by simp
wenzelm
parents: 23389
diff changeset
   253
              ultimately have "f (p + (Suc n)) \<subseteq> f p" by simp
wenzelm
parents: 23389
diff changeset
   254
            }
wenzelm
parents: 23389
diff changeset
   255
            thus "\<forall>p. f (p + Suc n) \<subseteq> f p" ..
wenzelm
parents: 23389
diff changeset
   256
          qed 
wenzelm
parents: 23389
diff changeset
   257
          have subsetm: "\<forall>\<alpha> \<beta>. \<alpha> \<ge> \<beta> \<longrightarrow> (f \<alpha>) \<subseteq> (f \<beta>)"
wenzelm
parents: 23389
diff changeset
   258
          proof ((rule allI)+, rule impI)
wenzelm
parents: 23389
diff changeset
   259
            fix \<alpha>::nat and \<beta>::nat
wenzelm
parents: 23389
diff changeset
   260
            assume "\<beta> \<le> \<alpha>"
wenzelm
parents: 23389
diff changeset
   261
            hence "\<exists>k. \<alpha> = \<beta> + k" by (simp only: le_iff_add)
wenzelm
parents: 23389
diff changeset
   262
            then obtain k where "\<alpha> = \<beta> + k" ..
wenzelm
parents: 23389
diff changeset
   263
            moreover
wenzelm
parents: 23389
diff changeset
   264
            from subsetd have "f (\<beta> + k) \<subseteq> f \<beta>" by simp
wenzelm
parents: 23389
diff changeset
   265
            ultimately show "f \<alpha> \<subseteq> f \<beta>" by auto
wenzelm
parents: 23389
diff changeset
   266
          qed 
wenzelm
parents: 23389
diff changeset
   267
          
wenzelm
parents: 23389
diff changeset
   268
          fix m   
wenzelm
parents: 23389
diff changeset
   269
          {
wenzelm
parents: 23389
diff changeset
   270
            assume "m \<ge> n"
wenzelm
parents: 23389
diff changeset
   271
            with subsetm have "f m \<subseteq> f n" by simp
wenzelm
parents: 23389
diff changeset
   272
            with ain have "\<forall>x\<in>f m. x \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   273
            moreover
wenzelm
parents: 23389
diff changeset
   274
            from gdef have "?g m \<in> f m \<and> (\<forall>x\<in>f m. ?g m \<le> x)" by simp
wenzelm
parents: 23389
diff changeset
   275
            ultimately have "?g m \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   276
          }
wenzelm
parents: 23389
diff changeset
   277
          moreover
wenzelm
parents: 23389
diff changeset
   278
          {
wenzelm
parents: 23389
diff changeset
   279
            assume "\<not>(m \<ge> n)"
wenzelm
parents: 23389
diff changeset
   280
            hence "m < n" by simp
wenzelm
parents: 23389
diff changeset
   281
            with subsetm have sub: "(f n) \<subseteq> (f m)" by simp
wenzelm
parents: 23389
diff changeset
   282
            from closed obtain ma and mb where
wenzelm
parents: 23389
diff changeset
   283
              "f m = closed_int ma mb \<and> ma \<le> mb" by blast
wenzelm
parents: 23389
diff changeset
   284
            hence one: "ma \<le> mb" and fm: "f m = closed_int ma mb" by auto 
wenzelm
parents: 23389
diff changeset
   285
            from one alb sub fm int have "ma \<le> b" using closed_subset by blast
wenzelm
parents: 23389
diff changeset
   286
            moreover have "(?g m) = ma"
wenzelm
parents: 23389
diff changeset
   287
            proof -
wenzelm
parents: 23389
diff changeset
   288
              from gdef have "?g m \<in> f m \<and> (\<forall>x\<in>f m. ?g m \<le> x)" ..
wenzelm
parents: 23389
diff changeset
   289
              moreover from one have
wenzelm
parents: 23389
diff changeset
   290
                "ma \<in> closed_int ma mb \<and> (\<forall>x\<in>closed_int ma mb. ma \<le> x)"
wenzelm
parents: 23389
diff changeset
   291
                by (rule closed_int_least)
wenzelm
parents: 23389
diff changeset
   292
              with fm have "ma\<in>f m \<and> (\<forall>x\<in>f m. ma \<le> x)" by simp
wenzelm
parents: 23389
diff changeset
   293
              ultimately have "ma \<le> ?g m \<and> ?g m \<le> ma" by auto
wenzelm
parents: 23389
diff changeset
   294
              thus "?g m = ma" by auto
wenzelm
parents: 23389
diff changeset
   295
            qed
wenzelm
parents: 23389
diff changeset
   296
            ultimately have "?g m \<le> b" by simp
wenzelm
parents: 23389
diff changeset
   297
          } 
wenzelm
parents: 23389
diff changeset
   298
          ultimately have "?g m \<le> b" by (rule case_split)
wenzelm
parents: 23389
diff changeset
   299
        }
wenzelm
parents: 23389
diff changeset
   300
        with Adef have "\<forall>y\<in>A. y\<le>b" by auto
wenzelm
parents: 23389
diff changeset
   301
        hence "A *<= b" by (unfold setle_def)
wenzelm
parents: 23389
diff changeset
   302
        moreover have "b \<in> (UNIV::real set)" by simp
wenzelm
parents: 23389
diff changeset
   303
        ultimately have "A *<= b \<and> b \<in> (UNIV::real set)" by simp
wenzelm
parents: 23389
diff changeset
   304
        thus "isUb (UNIV::real set) A b" by (unfold isUb_def)
wenzelm
parents: 23389
diff changeset
   305
      qed
wenzelm
parents: 23389
diff changeset
   306
      with tdef show "t \<le> b" by (rule isLub_le_isUb)
wenzelm
parents: 23389
diff changeset
   307
    qed
wenzelm
parents: 23389
diff changeset
   308
    ultimately have "t \<in> closed_int a b" by (rule closed_mem)
wenzelm
parents: 23389
diff changeset
   309
    with int show "t \<in> f n" by simp
wenzelm
parents: 23389
diff changeset
   310
  qed
wenzelm
parents: 23389
diff changeset
   311
  hence "t \<in> (\<Inter>n. f n)" by auto
wenzelm
parents: 23389
diff changeset
   312
  thus ?thesis by auto
wenzelm
parents: 23389
diff changeset
   313
qed
wenzelm
parents: 23389
diff changeset
   314
wenzelm
parents: 23389
diff changeset
   315
subsection {* Generating the intervals *}
wenzelm
parents: 23389
diff changeset
   316
wenzelm
parents: 23389
diff changeset
   317
subsubsection {* Existence of non-singleton closed intervals *}
wenzelm
parents: 23389
diff changeset
   318
wenzelm
parents: 23389
diff changeset
   319
text {* This lemma asserts that given any non-singleton closed
wenzelm
parents: 23389
diff changeset
   320
interval (a,b) and any element c, there exists a closed interval that
wenzelm
parents: 23389
diff changeset
   321
is a subset of (a,b) and that does not contain c and is a
wenzelm
parents: 23389
diff changeset
   322
non-singleton itself. *}
wenzelm
parents: 23389
diff changeset
   323
wenzelm
parents: 23389
diff changeset
   324
lemma closed_subset_ex:
wenzelm
parents: 23389
diff changeset
   325
  fixes c::real
wenzelm
parents: 23389
diff changeset
   326
  assumes alb: "a < b"
wenzelm
parents: 23389
diff changeset
   327
  shows
wenzelm
parents: 23389
diff changeset
   328
    "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and> c \<notin> (closed_int ka kb)"
wenzelm
parents: 23389
diff changeset
   329
proof -
wenzelm
parents: 23389
diff changeset
   330
  {
wenzelm
parents: 23389
diff changeset
   331
    assume clb: "c < b"
wenzelm
parents: 23389
diff changeset
   332
    {
wenzelm
parents: 23389
diff changeset
   333
      assume cla: "c < a"
wenzelm
parents: 23389
diff changeset
   334
      from alb cla clb have "c \<notin> closed_int a b" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
   335
      with alb have
wenzelm
parents: 23389
diff changeset
   336
        "a < b \<and> closed_int a b \<subseteq> closed_int a b \<and> c \<notin> closed_int a b"
wenzelm
parents: 23389
diff changeset
   337
        by auto
wenzelm
parents: 23389
diff changeset
   338
      hence
wenzelm
parents: 23389
diff changeset
   339
        "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and> c \<notin> (closed_int ka kb)"
wenzelm
parents: 23389
diff changeset
   340
        by auto
wenzelm
parents: 23389
diff changeset
   341
    }
wenzelm
parents: 23389
diff changeset
   342
    moreover
wenzelm
parents: 23389
diff changeset
   343
    {
wenzelm
parents: 23389
diff changeset
   344
      assume ncla: "\<not>(c < a)"
wenzelm
parents: 23389
diff changeset
   345
      with clb have cdef: "a \<le> c \<and> c < b" by simp
wenzelm
parents: 23389
diff changeset
   346
      obtain ka where kadef: "ka = (c + b)/2" by blast
wenzelm
parents: 23389
diff changeset
   347
wenzelm
parents: 23389
diff changeset
   348
      from kadef clb have kalb: "ka < b" by auto
wenzelm
parents: 23389
diff changeset
   349
      moreover from kadef cdef have kagc: "ka > c" by simp
wenzelm
parents: 23389
diff changeset
   350
      ultimately have "c\<notin>(closed_int ka b)" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
   351
      moreover from cdef kagc have "ka \<ge> a" by simp
wenzelm
parents: 23389
diff changeset
   352
      hence "closed_int ka b \<subseteq> closed_int a b" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
   353
      ultimately have
wenzelm
parents: 23389
diff changeset
   354
        "ka < b  \<and> closed_int ka b \<subseteq> closed_int a b \<and> c \<notin> closed_int ka b"
wenzelm
parents: 23389
diff changeset
   355
        using kalb by auto
wenzelm
parents: 23389
diff changeset
   356
      hence
wenzelm
parents: 23389
diff changeset
   357
        "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and> c \<notin> (closed_int ka kb)"
wenzelm
parents: 23389
diff changeset
   358
        by auto
wenzelm
parents: 23389
diff changeset
   359
wenzelm
parents: 23389
diff changeset
   360
    }
wenzelm
parents: 23389
diff changeset
   361
    ultimately have
wenzelm
parents: 23389
diff changeset
   362
      "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and> c \<notin> (closed_int ka kb)"
wenzelm
parents: 23389
diff changeset
   363
      by (rule case_split)
wenzelm
parents: 23389
diff changeset
   364
  }
wenzelm
parents: 23389
diff changeset
   365
  moreover
wenzelm
parents: 23389
diff changeset
   366
  {
wenzelm
parents: 23389
diff changeset
   367
    assume "\<not> (c < b)"
wenzelm
parents: 23389
diff changeset
   368
    hence cgeb: "c \<ge> b" by simp
wenzelm
parents: 23389
diff changeset
   369
wenzelm
parents: 23389
diff changeset
   370
    obtain kb where kbdef: "kb = (a + b)/2" by blast
wenzelm
parents: 23389
diff changeset
   371
    with alb have kblb: "kb < b" by auto
wenzelm
parents: 23389
diff changeset
   372
    with kbdef cgeb have "a < kb \<and> kb < c" by auto
wenzelm
parents: 23389
diff changeset
   373
    moreover hence "c \<notin> (closed_int a kb)" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
   374
    moreover from kblb have
wenzelm
parents: 23389
diff changeset
   375
      "closed_int a kb \<subseteq> closed_int a b" by (unfold closed_int_def, auto)
wenzelm
parents: 23389
diff changeset
   376
    ultimately have
wenzelm
parents: 23389
diff changeset
   377
      "a < kb \<and>  closed_int a kb \<subseteq> closed_int a b \<and> c\<notin>closed_int a kb"
wenzelm
parents: 23389
diff changeset
   378
      by simp
wenzelm
parents: 23389
diff changeset
   379
    hence
wenzelm
parents: 23389
diff changeset
   380
      "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and> c \<notin> (closed_int ka kb)"
wenzelm
parents: 23389
diff changeset
   381
      by auto
wenzelm
parents: 23389
diff changeset
   382
  }
wenzelm
parents: 23389
diff changeset
   383
  ultimately show ?thesis by (rule case_split)
wenzelm
parents: 23389
diff changeset
   384
qed
wenzelm
parents: 23389
diff changeset
   385
wenzelm
parents: 23389
diff changeset
   386
subsection {* newInt: Interval generation *}
wenzelm
parents: 23389
diff changeset
   387
wenzelm
parents: 23389
diff changeset
   388
text {* Given a function f:@{text "\<nat>\<Rightarrow>\<real>"}, newInt (Suc n) f returns a
wenzelm
parents: 23389
diff changeset
   389
closed interval such that @{text "newInt (Suc n) f \<subseteq> newInt n f"} and
wenzelm
parents: 23389
diff changeset
   390
does not contain @{text "f (Suc n)"}. With the base case defined such
wenzelm
parents: 23389
diff changeset
   391
that @{text "(f 0)\<notin>newInt 0 f"}. *}
wenzelm
parents: 23389
diff changeset
   392
wenzelm
parents: 23389
diff changeset
   393
subsubsection {* Definition *}
wenzelm
parents: 23389
diff changeset
   394
27435
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   395
primrec newInt :: "nat \<Rightarrow> (nat \<Rightarrow> real) \<Rightarrow> (real set)" where
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   396
  "newInt 0 f = closed_int (f 0 + 1) (f 0 + 2)"
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   397
  | "newInt (Suc n) f =
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   398
      (SOME e. (\<exists>e1 e2.
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   399
       e1 < e2 \<and>
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   400
       e = closed_int e1 e2 \<and>
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   401
       e \<subseteq> (newInt n f) \<and>
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   402
       (f (Suc n)) \<notin> e)
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   403
      )"
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 27368
diff changeset
   404
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 27435
diff changeset
   405
declare newInt.simps [code del]
23461
wenzelm
parents: 23389
diff changeset
   406
wenzelm
parents: 23389
diff changeset
   407
subsubsection {* Properties *}
wenzelm
parents: 23389
diff changeset
   408
wenzelm
parents: 23389
diff changeset
   409
text {* We now show that every application of newInt returns an
wenzelm
parents: 23389
diff changeset
   410
appropriate interval. *}
wenzelm
parents: 23389
diff changeset
   411
wenzelm
parents: 23389
diff changeset
   412
lemma newInt_ex:
wenzelm
parents: 23389
diff changeset
   413
  "\<exists>a b. a < b \<and>
wenzelm
parents: 23389
diff changeset
   414
   newInt (Suc n) f = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   415
   newInt (Suc n) f \<subseteq> newInt n f \<and>
wenzelm
parents: 23389
diff changeset
   416
   f (Suc n) \<notin> newInt (Suc n) f"
wenzelm
parents: 23389
diff changeset
   417
proof (induct n)
wenzelm
parents: 23389
diff changeset
   418
  case 0
wenzelm
parents: 23389
diff changeset
   419
wenzelm
parents: 23389
diff changeset
   420
  let ?e = "SOME e. \<exists>e1 e2.
wenzelm
parents: 23389
diff changeset
   421
   e1 < e2 \<and>
wenzelm
parents: 23389
diff changeset
   422
   e = closed_int e1 e2 \<and>
wenzelm
parents: 23389
diff changeset
   423
   e \<subseteq> closed_int (f 0 + 1) (f 0 + 2) \<and>
wenzelm
parents: 23389
diff changeset
   424
   f (Suc 0) \<notin> e"
wenzelm
parents: 23389
diff changeset
   425
wenzelm
parents: 23389
diff changeset
   426
  have "newInt (Suc 0) f = ?e" by auto
wenzelm
parents: 23389
diff changeset
   427
  moreover
wenzelm
parents: 23389
diff changeset
   428
  have "f 0 + 1 < f 0 + 2" by simp
wenzelm
parents: 23389
diff changeset
   429
  with closed_subset_ex have
wenzelm
parents: 23389
diff changeset
   430
    "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int (f 0 + 1) (f 0 + 2) \<and>
wenzelm
parents: 23389
diff changeset
   431
     f (Suc 0) \<notin> (closed_int ka kb)" .
wenzelm
parents: 23389
diff changeset
   432
  hence
wenzelm
parents: 23389
diff changeset
   433
    "\<exists>e. \<exists>ka kb. ka < kb \<and> e = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   434
     e \<subseteq> closed_int (f 0 + 1) (f 0 + 2) \<and> f (Suc 0) \<notin> e" by simp
wenzelm
parents: 23389
diff changeset
   435
  hence
wenzelm
parents: 23389
diff changeset
   436
    "\<exists>ka kb. ka < kb \<and> ?e = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   437
     ?e \<subseteq> closed_int (f 0 + 1) (f 0 + 2) \<and> f (Suc 0) \<notin> ?e"
wenzelm
parents: 23389
diff changeset
   438
    by (rule someI_ex)
wenzelm
parents: 23389
diff changeset
   439
  ultimately have "\<exists>e1 e2. e1 < e2 \<and>
wenzelm
parents: 23389
diff changeset
   440
   newInt (Suc 0) f = closed_int e1 e2 \<and>
wenzelm
parents: 23389
diff changeset
   441
   newInt (Suc 0) f \<subseteq> closed_int (f 0 + 1) (f 0 + 2) \<and>
wenzelm
parents: 23389
diff changeset
   442
   f (Suc 0) \<notin> newInt (Suc 0) f" by simp
wenzelm
parents: 23389
diff changeset
   443
  thus
wenzelm
parents: 23389
diff changeset
   444
    "\<exists>a b. a < b \<and> newInt (Suc 0) f = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   445
     newInt (Suc 0) f \<subseteq> newInt 0 f \<and> f (Suc 0) \<notin> newInt (Suc 0) f"
wenzelm
parents: 23389
diff changeset
   446
    by simp
wenzelm
parents: 23389
diff changeset
   447
next
wenzelm
parents: 23389
diff changeset
   448
  case (Suc n)
wenzelm
parents: 23389
diff changeset
   449
  hence "\<exists>a b.
wenzelm
parents: 23389
diff changeset
   450
   a < b \<and>
wenzelm
parents: 23389
diff changeset
   451
   newInt (Suc n) f = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   452
   newInt (Suc n) f \<subseteq> newInt n f \<and>
wenzelm
parents: 23389
diff changeset
   453
   f (Suc n) \<notin> newInt (Suc n) f" by simp
wenzelm
parents: 23389
diff changeset
   454
  then obtain a and b where ab: "a < b \<and>
wenzelm
parents: 23389
diff changeset
   455
   newInt (Suc n) f = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   456
   newInt (Suc n) f \<subseteq> newInt n f \<and>
wenzelm
parents: 23389
diff changeset
   457
   f (Suc n) \<notin> newInt (Suc n) f" by auto
wenzelm
parents: 23389
diff changeset
   458
  hence cab: "closed_int a b = newInt (Suc n) f" by simp
wenzelm
parents: 23389
diff changeset
   459
wenzelm
parents: 23389
diff changeset
   460
  let ?e = "SOME e. \<exists>e1 e2.
wenzelm
parents: 23389
diff changeset
   461
    e1 < e2 \<and>
wenzelm
parents: 23389
diff changeset
   462
    e = closed_int e1 e2 \<and>
wenzelm
parents: 23389
diff changeset
   463
    e \<subseteq> closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   464
    f (Suc (Suc n)) \<notin> e"
wenzelm
parents: 23389
diff changeset
   465
  from cab have ni: "newInt (Suc (Suc n)) f = ?e" by auto
wenzelm
parents: 23389
diff changeset
   466
wenzelm
parents: 23389
diff changeset
   467
  from ab have "a < b" by simp
wenzelm
parents: 23389
diff changeset
   468
  with closed_subset_ex have
wenzelm
parents: 23389
diff changeset
   469
    "\<exists>ka kb. ka < kb \<and> closed_int ka kb \<subseteq> closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   470
     f (Suc (Suc n)) \<notin> closed_int ka kb" .
wenzelm
parents: 23389
diff changeset
   471
  hence
wenzelm
parents: 23389
diff changeset
   472
    "\<exists>e. \<exists>ka kb. ka < kb \<and> e = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   473
     closed_int ka kb \<subseteq> closed_int a b \<and> f (Suc (Suc n)) \<notin> closed_int ka kb"
wenzelm
parents: 23389
diff changeset
   474
    by simp
wenzelm
parents: 23389
diff changeset
   475
  hence
wenzelm
parents: 23389
diff changeset
   476
    "\<exists>e.  \<exists>ka kb. ka < kb \<and> e = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   477
     e \<subseteq> closed_int a b \<and> f (Suc (Suc n)) \<notin> e" by simp
wenzelm
parents: 23389
diff changeset
   478
  hence
wenzelm
parents: 23389
diff changeset
   479
    "\<exists>ka kb. ka < kb \<and> ?e = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   480
     ?e \<subseteq> closed_int a b \<and> f (Suc (Suc n)) \<notin> ?e" by (rule someI_ex)
wenzelm
parents: 23389
diff changeset
   481
  with ab ni show
wenzelm
parents: 23389
diff changeset
   482
    "\<exists>ka kb. ka < kb \<and>
wenzelm
parents: 23389
diff changeset
   483
     newInt (Suc (Suc n)) f = closed_int ka kb \<and>
wenzelm
parents: 23389
diff changeset
   484
     newInt (Suc (Suc n)) f \<subseteq> newInt (Suc n) f \<and>
wenzelm
parents: 23389
diff changeset
   485
     f (Suc (Suc n)) \<notin> newInt (Suc (Suc n)) f" by auto
wenzelm
parents: 23389
diff changeset
   486
qed
wenzelm
parents: 23389
diff changeset
   487
wenzelm
parents: 23389
diff changeset
   488
lemma newInt_subset:
wenzelm
parents: 23389
diff changeset
   489
  "newInt (Suc n) f \<subseteq> newInt n f"
wenzelm
parents: 23389
diff changeset
   490
  using newInt_ex by auto
wenzelm
parents: 23389
diff changeset
   491
wenzelm
parents: 23389
diff changeset
   492
wenzelm
parents: 23389
diff changeset
   493
text {* Another fundamental property is that no element in the range
wenzelm
parents: 23389
diff changeset
   494
of f is in the intersection of all closed intervals generated by
wenzelm
parents: 23389
diff changeset
   495
newInt. *}
wenzelm
parents: 23389
diff changeset
   496
wenzelm
parents: 23389
diff changeset
   497
lemma newInt_inter:
wenzelm
parents: 23389
diff changeset
   498
  "\<forall>n. f n \<notin> (\<Inter>n. newInt n f)"
wenzelm
parents: 23389
diff changeset
   499
proof
wenzelm
parents: 23389
diff changeset
   500
  fix n::nat
wenzelm
parents: 23389
diff changeset
   501
  {
wenzelm
parents: 23389
diff changeset
   502
    assume n0: "n = 0"
wenzelm
parents: 23389
diff changeset
   503
    moreover have "newInt 0 f = closed_int (f 0 + 1) (f 0 + 2)" by simp
wenzelm
parents: 23389
diff changeset
   504
    ultimately have "f n \<notin> newInt n f" by (unfold closed_int_def, simp)
wenzelm
parents: 23389
diff changeset
   505
  }
wenzelm
parents: 23389
diff changeset
   506
  moreover
wenzelm
parents: 23389
diff changeset
   507
  {
wenzelm
parents: 23389
diff changeset
   508
    assume "\<not> n = 0"
wenzelm
parents: 23389
diff changeset
   509
    hence "n > 0" by simp
wenzelm
parents: 23389
diff changeset
   510
    then obtain m where ndef: "n = Suc m" by (auto simp add: gr0_conv_Suc)
wenzelm
parents: 23389
diff changeset
   511
wenzelm
parents: 23389
diff changeset
   512
    from newInt_ex have
wenzelm
parents: 23389
diff changeset
   513
      "\<exists>a b. a < b \<and> (newInt (Suc m) f) = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   514
       newInt (Suc m) f \<subseteq> newInt m f \<and> f (Suc m) \<notin> newInt (Suc m) f" .
wenzelm
parents: 23389
diff changeset
   515
    then have "f (Suc m) \<notin> newInt (Suc m) f" by auto
wenzelm
parents: 23389
diff changeset
   516
    with ndef have "f n \<notin> newInt n f" by simp
wenzelm
parents: 23389
diff changeset
   517
  }
wenzelm
parents: 23389
diff changeset
   518
  ultimately have "f n \<notin> newInt n f" by (rule case_split)
wenzelm
parents: 23389
diff changeset
   519
  thus "f n \<notin> (\<Inter>n. newInt n f)" by auto
wenzelm
parents: 23389
diff changeset
   520
qed
wenzelm
parents: 23389
diff changeset
   521
wenzelm
parents: 23389
diff changeset
   522
wenzelm
parents: 23389
diff changeset
   523
lemma newInt_notempty:
wenzelm
parents: 23389
diff changeset
   524
  "(\<Inter>n. newInt n f) \<noteq> {}"
wenzelm
parents: 23389
diff changeset
   525
proof -
wenzelm
parents: 23389
diff changeset
   526
  let ?g = "\<lambda>n. newInt n f"
wenzelm
parents: 23389
diff changeset
   527
  have "\<forall>n. ?g (Suc n) \<subseteq> ?g n"
wenzelm
parents: 23389
diff changeset
   528
  proof
wenzelm
parents: 23389
diff changeset
   529
    fix n
wenzelm
parents: 23389
diff changeset
   530
    show "?g (Suc n) \<subseteq> ?g n" by (rule newInt_subset)
wenzelm
parents: 23389
diff changeset
   531
  qed
wenzelm
parents: 23389
diff changeset
   532
  moreover have "\<forall>n. \<exists>a b. ?g n = closed_int a b \<and> a \<le> b"
wenzelm
parents: 23389
diff changeset
   533
  proof
wenzelm
parents: 23389
diff changeset
   534
    fix n::nat
wenzelm
parents: 23389
diff changeset
   535
    {
wenzelm
parents: 23389
diff changeset
   536
      assume "n = 0"
wenzelm
parents: 23389
diff changeset
   537
      then have
wenzelm
parents: 23389
diff changeset
   538
        "?g n = closed_int (f 0 + 1) (f 0 + 2) \<and> (f 0 + 1 \<le> f 0 + 2)"
wenzelm
parents: 23389
diff changeset
   539
        by simp
wenzelm
parents: 23389
diff changeset
   540
      hence "\<exists>a b. ?g n = closed_int a b \<and> a \<le> b" by blast
wenzelm
parents: 23389
diff changeset
   541
    }
wenzelm
parents: 23389
diff changeset
   542
    moreover
wenzelm
parents: 23389
diff changeset
   543
    {
wenzelm
parents: 23389
diff changeset
   544
      assume "\<not> n = 0"
wenzelm
parents: 23389
diff changeset
   545
      then have "n > 0" by simp
wenzelm
parents: 23389
diff changeset
   546
      then obtain m where nd: "n = Suc m" by (auto simp add: gr0_conv_Suc)
wenzelm
parents: 23389
diff changeset
   547
wenzelm
parents: 23389
diff changeset
   548
      have
wenzelm
parents: 23389
diff changeset
   549
        "\<exists>a b. a < b \<and> (newInt (Suc m) f) = closed_int a b \<and>
wenzelm
parents: 23389
diff changeset
   550
        (newInt (Suc m) f) \<subseteq> (newInt m f) \<and> (f (Suc m)) \<notin> (newInt (Suc m) f)"
wenzelm
parents: 23389
diff changeset
   551
        by (rule newInt_ex)
wenzelm
parents: 23389
diff changeset
   552
      then obtain a and b where
wenzelm
parents: 23389
diff changeset
   553
        "a < b \<and> (newInt (Suc m) f) = closed_int a b" by auto
wenzelm
parents: 23389
diff changeset
   554
      with nd have "?g n = closed_int a b \<and> a \<le> b" by auto
wenzelm
parents: 23389
diff changeset
   555
      hence "\<exists>a b. ?g n = closed_int a b \<and> a \<le> b" by blast
wenzelm
parents: 23389
diff changeset
   556
    }
wenzelm
parents: 23389
diff changeset
   557
    ultimately show "\<exists>a b. ?g n = closed_int a b \<and> a \<le> b" by (rule case_split)
wenzelm
parents: 23389
diff changeset
   558
  qed
wenzelm
parents: 23389
diff changeset
   559
  ultimately show ?thesis by (rule NIP)
wenzelm
parents: 23389
diff changeset
   560
qed
wenzelm
parents: 23389
diff changeset
   561
wenzelm
parents: 23389
diff changeset
   562
wenzelm
parents: 23389
diff changeset
   563
subsection {* Final Theorem *}
wenzelm
parents: 23389
diff changeset
   564
wenzelm
parents: 23389
diff changeset
   565
theorem real_non_denum:
wenzelm
parents: 23389
diff changeset
   566
  shows "\<not> (\<exists>f::nat\<Rightarrow>real. surj f)"
wenzelm
parents: 23389
diff changeset
   567
proof -- "by contradiction"
wenzelm
parents: 23389
diff changeset
   568
  assume "\<exists>f::nat\<Rightarrow>real. surj f"
wenzelm
parents: 23389
diff changeset
   569
  then obtain f::"nat\<Rightarrow>real" where "surj f" by auto
wenzelm
parents: 23389
diff changeset
   570
  hence rangeF: "range f = UNIV" by (rule surj_range)
wenzelm
parents: 23389
diff changeset
   571
  -- "We now produce a real number x that is not in the range of f, using the properties of newInt. "
wenzelm
parents: 23389
diff changeset
   572
  have "\<exists>x. x \<in> (\<Inter>n. newInt n f)" using newInt_notempty by blast
wenzelm
parents: 23389
diff changeset
   573
  moreover have "\<forall>n. f n \<notin> (\<Inter>n. newInt n f)" by (rule newInt_inter)
wenzelm
parents: 23389
diff changeset
   574
  ultimately obtain x where "x \<in> (\<Inter>n. newInt n f)" and "\<forall>n. f n \<noteq> x" by blast
wenzelm
parents: 23389
diff changeset
   575
  moreover from rangeF have "x \<in> range f" by simp
wenzelm
parents: 23389
diff changeset
   576
  ultimately show False by blast
wenzelm
parents: 23389
diff changeset
   577
qed
wenzelm
parents: 23389
diff changeset
   578
wenzelm
parents: 23389
diff changeset
   579
end