src/HOL/Library/Nat_Infinity.thy
author haftmann
Wed Jan 28 11:02:12 2009 +0100 (2009-01-28)
changeset 29652 f4c6e546b7fe
parent 29337 450805a4a91f
child 29668 33ba3faeaa0e
permissions -rw-r--r--
nat is a bot instance
wenzelm@11355
     1
(*  Title:      HOL/Library/Nat_Infinity.thy
haftmann@27110
     2
    Author:     David von Oheimb, TU Muenchen;  Florian Haftmann, TU Muenchen
oheimb@11351
     3
*)
oheimb@11351
     4
wenzelm@14706
     5
header {* Natural numbers with infinity *}
oheimb@11351
     6
nipkow@15131
     7
theory Nat_Infinity
haftmann@27487
     8
imports Plain "~~/src/HOL/Presburger"
nipkow@15131
     9
begin
oheimb@11351
    10
haftmann@27110
    11
subsection {* Type definition *}
oheimb@11351
    12
oheimb@11351
    13
text {*
wenzelm@11355
    14
  We extend the standard natural numbers by a special value indicating
haftmann@27110
    15
  infinity.
oheimb@11351
    16
*}
oheimb@11351
    17
oheimb@11351
    18
datatype inat = Fin nat | Infty
oheimb@11351
    19
wenzelm@21210
    20
notation (xsymbols)
wenzelm@19736
    21
  Infty  ("\<infinity>")
wenzelm@19736
    22
wenzelm@21210
    23
notation (HTML output)
wenzelm@19736
    24
  Infty  ("\<infinity>")
wenzelm@19736
    25
oheimb@11351
    26
haftmann@27110
    27
subsection {* Constructors and numbers *}
haftmann@27110
    28
haftmann@27110
    29
instantiation inat :: "{zero, one, number}"
haftmann@25594
    30
begin
haftmann@25594
    31
haftmann@25594
    32
definition
haftmann@27110
    33
  "0 = Fin 0"
haftmann@25594
    34
haftmann@25594
    35
definition
haftmann@27110
    36
  [code inline]: "1 = Fin 1"
haftmann@25594
    37
haftmann@25594
    38
definition
haftmann@28562
    39
  [code inline, code del]: "number_of k = Fin (number_of k)"
oheimb@11351
    40
haftmann@25594
    41
instance ..
haftmann@25594
    42
haftmann@25594
    43
end
haftmann@25594
    44
haftmann@27110
    45
definition iSuc :: "inat \<Rightarrow> inat" where
haftmann@27110
    46
  "iSuc i = (case i of Fin n \<Rightarrow> Fin (Suc n) | \<infinity> \<Rightarrow> \<infinity>)"
oheimb@11351
    47
oheimb@11351
    48
lemma Fin_0: "Fin 0 = 0"
haftmann@27110
    49
  by (simp add: zero_inat_def)
haftmann@27110
    50
haftmann@27110
    51
lemma Fin_1: "Fin 1 = 1"
haftmann@27110
    52
  by (simp add: one_inat_def)
haftmann@27110
    53
haftmann@27110
    54
lemma Fin_number: "Fin (number_of k) = number_of k"
haftmann@27110
    55
  by (simp add: number_of_inat_def)
haftmann@27110
    56
haftmann@27110
    57
lemma one_iSuc: "1 = iSuc 0"
haftmann@27110
    58
  by (simp add: zero_inat_def one_inat_def iSuc_def)
oheimb@11351
    59
oheimb@11351
    60
lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
haftmann@27110
    61
  by (simp add: zero_inat_def)
oheimb@11351
    62
oheimb@11351
    63
lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
haftmann@27110
    64
  by (simp add: zero_inat_def)
haftmann@27110
    65
haftmann@27110
    66
lemma zero_inat_eq [simp]:
haftmann@27110
    67
  "number_of k = (0\<Colon>inat) \<longleftrightarrow> number_of k = (0\<Colon>nat)"
haftmann@27110
    68
  "(0\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (0\<Colon>nat)"
haftmann@27110
    69
  unfolding zero_inat_def number_of_inat_def by simp_all
haftmann@27110
    70
haftmann@27110
    71
lemma one_inat_eq [simp]:
haftmann@27110
    72
  "number_of k = (1\<Colon>inat) \<longleftrightarrow> number_of k = (1\<Colon>nat)"
haftmann@27110
    73
  "(1\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (1\<Colon>nat)"
haftmann@27110
    74
  unfolding one_inat_def number_of_inat_def by simp_all
haftmann@27110
    75
haftmann@27110
    76
lemma zero_one_inat_neq [simp]:
haftmann@27110
    77
  "\<not> 0 = (1\<Colon>inat)"
haftmann@27110
    78
  "\<not> 1 = (0\<Colon>inat)"
haftmann@27110
    79
  unfolding zero_inat_def one_inat_def by simp_all
oheimb@11351
    80
haftmann@27110
    81
lemma Infty_ne_i1 [simp]: "\<infinity> \<noteq> 1"
haftmann@27110
    82
  by (simp add: one_inat_def)
haftmann@27110
    83
haftmann@27110
    84
lemma i1_ne_Infty [simp]: "1 \<noteq> \<infinity>"
haftmann@27110
    85
  by (simp add: one_inat_def)
haftmann@27110
    86
haftmann@27110
    87
lemma Infty_ne_number [simp]: "\<infinity> \<noteq> number_of k"
haftmann@27110
    88
  by (simp add: number_of_inat_def)
haftmann@27110
    89
haftmann@27110
    90
lemma number_ne_Infty [simp]: "number_of k \<noteq> \<infinity>"
haftmann@27110
    91
  by (simp add: number_of_inat_def)
haftmann@27110
    92
haftmann@27110
    93
lemma iSuc_Fin: "iSuc (Fin n) = Fin (Suc n)"
haftmann@27110
    94
  by (simp add: iSuc_def)
haftmann@27110
    95
haftmann@27110
    96
lemma iSuc_number_of: "iSuc (number_of k) = Fin (Suc (number_of k))"
haftmann@27110
    97
  by (simp add: iSuc_Fin number_of_inat_def)
oheimb@11351
    98
oheimb@11351
    99
lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
haftmann@27110
   100
  by (simp add: iSuc_def)
oheimb@11351
   101
oheimb@11351
   102
lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
haftmann@27110
   103
  by (simp add: iSuc_def zero_inat_def split: inat.splits)
haftmann@27110
   104
haftmann@27110
   105
lemma zero_ne_iSuc [simp]: "0 \<noteq> iSuc n"
haftmann@27110
   106
  by (rule iSuc_ne_0 [symmetric])
oheimb@11351
   107
haftmann@27110
   108
lemma iSuc_inject [simp]: "iSuc m = iSuc n \<longleftrightarrow> m = n"
haftmann@27110
   109
  by (simp add: iSuc_def split: inat.splits)
haftmann@27110
   110
haftmann@27110
   111
lemma number_of_inat_inject [simp]:
haftmann@27110
   112
  "(number_of k \<Colon> inat) = number_of l \<longleftrightarrow> (number_of k \<Colon> nat) = number_of l"
haftmann@27110
   113
  by (simp add: number_of_inat_def)
oheimb@11351
   114
oheimb@11351
   115
haftmann@27110
   116
subsection {* Addition *}
haftmann@27110
   117
haftmann@27110
   118
instantiation inat :: comm_monoid_add
haftmann@27110
   119
begin
haftmann@27110
   120
haftmann@27110
   121
definition
haftmann@27110
   122
  [code del]: "m + n = (case m of \<infinity> \<Rightarrow> \<infinity> | Fin m \<Rightarrow> (case n of \<infinity> \<Rightarrow> \<infinity> | Fin n \<Rightarrow> Fin (m + n)))"
oheimb@11351
   123
haftmann@27110
   124
lemma plus_inat_simps [simp, code]:
haftmann@27110
   125
  "Fin m + Fin n = Fin (m + n)"
haftmann@27110
   126
  "\<infinity> + q = \<infinity>"
haftmann@27110
   127
  "q + \<infinity> = \<infinity>"
haftmann@27110
   128
  by (simp_all add: plus_inat_def split: inat.splits)
haftmann@27110
   129
haftmann@27110
   130
instance proof
haftmann@27110
   131
  fix n m q :: inat
haftmann@27110
   132
  show "n + m + q = n + (m + q)"
haftmann@27110
   133
    by (cases n, auto, cases m, auto, cases q, auto)
haftmann@27110
   134
  show "n + m = m + n"
haftmann@27110
   135
    by (cases n, auto, cases m, auto)
haftmann@27110
   136
  show "0 + n = n"
haftmann@27110
   137
    by (cases n) (simp_all add: zero_inat_def)
huffman@26089
   138
qed
huffman@26089
   139
haftmann@27110
   140
end
oheimb@11351
   141
haftmann@27110
   142
lemma plus_inat_0 [simp]:
haftmann@27110
   143
  "0 + (q\<Colon>inat) = q"
haftmann@27110
   144
  "(q\<Colon>inat) + 0 = q"
haftmann@27110
   145
  by (simp_all add: plus_inat_def zero_inat_def split: inat.splits)
oheimb@11351
   146
haftmann@27110
   147
lemma plus_inat_number [simp]:
huffman@29012
   148
  "(number_of k \<Colon> inat) + number_of l = (if k < Int.Pls then number_of l
huffman@29012
   149
    else if l < Int.Pls then number_of k else number_of (k + l))"
haftmann@27110
   150
  unfolding number_of_inat_def plus_inat_simps nat_arith(1) if_distrib [symmetric, of _ Fin] ..
oheimb@11351
   151
haftmann@27110
   152
lemma iSuc_number [simp]:
haftmann@27110
   153
  "iSuc (number_of k) = (if neg (number_of k \<Colon> int) then 1 else number_of (Int.succ k))"
haftmann@27110
   154
  unfolding iSuc_number_of
haftmann@27110
   155
  unfolding one_inat_def number_of_inat_def Suc_nat_number_of if_distrib [symmetric] ..
oheimb@11351
   156
haftmann@27110
   157
lemma iSuc_plus_1:
haftmann@27110
   158
  "iSuc n = n + 1"
haftmann@27110
   159
  by (cases n) (simp_all add: iSuc_Fin one_inat_def)
haftmann@27110
   160
  
haftmann@27110
   161
lemma plus_1_iSuc:
haftmann@27110
   162
  "1 + q = iSuc q"
haftmann@27110
   163
  "q + 1 = iSuc q"
haftmann@27110
   164
  unfolding iSuc_plus_1 by (simp_all add: add_ac)
oheimb@11351
   165
oheimb@11351
   166
huffman@29014
   167
subsection {* Multiplication *}
huffman@29014
   168
huffman@29014
   169
instantiation inat :: comm_semiring_1
huffman@29014
   170
begin
huffman@29014
   171
huffman@29014
   172
definition
huffman@29014
   173
  times_inat_def [code del]:
huffman@29014
   174
  "m * n = (case m of \<infinity> \<Rightarrow> if n = 0 then 0 else \<infinity> | Fin m \<Rightarrow>
huffman@29014
   175
    (case n of \<infinity> \<Rightarrow> if m = 0 then 0 else \<infinity> | Fin n \<Rightarrow> Fin (m * n)))"
huffman@29014
   176
huffman@29014
   177
lemma times_inat_simps [simp, code]:
huffman@29014
   178
  "Fin m * Fin n = Fin (m * n)"
huffman@29014
   179
  "\<infinity> * \<infinity> = \<infinity>"
huffman@29014
   180
  "\<infinity> * Fin n = (if n = 0 then 0 else \<infinity>)"
huffman@29014
   181
  "Fin m * \<infinity> = (if m = 0 then 0 else \<infinity>)"
huffman@29014
   182
  unfolding times_inat_def zero_inat_def
huffman@29014
   183
  by (simp_all split: inat.split)
huffman@29014
   184
huffman@29014
   185
instance proof
huffman@29014
   186
  fix a b c :: inat
huffman@29014
   187
  show "(a * b) * c = a * (b * c)"
huffman@29014
   188
    unfolding times_inat_def zero_inat_def
huffman@29014
   189
    by (simp split: inat.split)
huffman@29014
   190
  show "a * b = b * a"
huffman@29014
   191
    unfolding times_inat_def zero_inat_def
huffman@29014
   192
    by (simp split: inat.split)
huffman@29014
   193
  show "1 * a = a"
huffman@29014
   194
    unfolding times_inat_def zero_inat_def one_inat_def
huffman@29014
   195
    by (simp split: inat.split)
huffman@29014
   196
  show "(a + b) * c = a * c + b * c"
huffman@29014
   197
    unfolding times_inat_def zero_inat_def
huffman@29014
   198
    by (simp split: inat.split add: left_distrib)
huffman@29014
   199
  show "0 * a = 0"
huffman@29014
   200
    unfolding times_inat_def zero_inat_def
huffman@29014
   201
    by (simp split: inat.split)
huffman@29014
   202
  show "a * 0 = 0"
huffman@29014
   203
    unfolding times_inat_def zero_inat_def
huffman@29014
   204
    by (simp split: inat.split)
huffman@29014
   205
  show "(0::inat) \<noteq> 1"
huffman@29014
   206
    unfolding zero_inat_def one_inat_def
huffman@29014
   207
    by simp
huffman@29014
   208
qed
huffman@29014
   209
huffman@29014
   210
end
huffman@29014
   211
huffman@29014
   212
lemma mult_iSuc: "iSuc m * n = n + m * n"
huffman@29014
   213
  unfolding iSuc_plus_1 by (simp add: ring_simps)
huffman@29014
   214
huffman@29014
   215
lemma mult_iSuc_right: "m * iSuc n = m + m * n"
huffman@29014
   216
  unfolding iSuc_plus_1 by (simp add: ring_simps)
huffman@29014
   217
huffman@29023
   218
lemma of_nat_eq_Fin: "of_nat n = Fin n"
huffman@29023
   219
  apply (induct n)
huffman@29023
   220
  apply (simp add: Fin_0)
huffman@29023
   221
  apply (simp add: plus_1_iSuc iSuc_Fin)
huffman@29023
   222
  done
huffman@29023
   223
huffman@29023
   224
instance inat :: semiring_char_0
huffman@29023
   225
  by default (simp add: of_nat_eq_Fin)
huffman@29023
   226
huffman@29014
   227
haftmann@27110
   228
subsection {* Ordering *}
haftmann@27110
   229
haftmann@27110
   230
instantiation inat :: ordered_ab_semigroup_add
haftmann@27110
   231
begin
oheimb@11351
   232
haftmann@27110
   233
definition
haftmann@27110
   234
  [code del]: "m \<le> n = (case n of Fin n1 \<Rightarrow> (case m of Fin m1 \<Rightarrow> m1 \<le> n1 | \<infinity> \<Rightarrow> False)
haftmann@27110
   235
    | \<infinity> \<Rightarrow> True)"
oheimb@11351
   236
haftmann@27110
   237
definition
haftmann@27110
   238
  [code del]: "m < n = (case m of Fin m1 \<Rightarrow> (case n of Fin n1 \<Rightarrow> m1 < n1 | \<infinity> \<Rightarrow> True)
haftmann@27110
   239
    | \<infinity> \<Rightarrow> False)"
oheimb@11351
   240
haftmann@27110
   241
lemma inat_ord_simps [simp]:
haftmann@27110
   242
  "Fin m \<le> Fin n \<longleftrightarrow> m \<le> n"
haftmann@27110
   243
  "Fin m < Fin n \<longleftrightarrow> m < n"
haftmann@27110
   244
  "q \<le> \<infinity>"
haftmann@27110
   245
  "q < \<infinity> \<longleftrightarrow> q \<noteq> \<infinity>"
haftmann@27110
   246
  "\<infinity> \<le> q \<longleftrightarrow> q = \<infinity>"
haftmann@27110
   247
  "\<infinity> < q \<longleftrightarrow> False"
haftmann@27110
   248
  by (simp_all add: less_eq_inat_def less_inat_def split: inat.splits)
oheimb@11351
   249
haftmann@27110
   250
lemma inat_ord_code [code]:
haftmann@27110
   251
  "Fin m \<le> Fin n \<longleftrightarrow> m \<le> n"
haftmann@27110
   252
  "Fin m < Fin n \<longleftrightarrow> m < n"
haftmann@27110
   253
  "q \<le> \<infinity> \<longleftrightarrow> True"
haftmann@27110
   254
  "Fin m < \<infinity> \<longleftrightarrow> True"
haftmann@27110
   255
  "\<infinity> \<le> Fin n \<longleftrightarrow> False"
haftmann@27110
   256
  "\<infinity> < q \<longleftrightarrow> False"
haftmann@27110
   257
  by simp_all
oheimb@11351
   258
haftmann@27110
   259
instance by default
haftmann@27110
   260
  (auto simp add: less_eq_inat_def less_inat_def plus_inat_def split: inat.splits)
oheimb@11351
   261
haftmann@27110
   262
end
haftmann@27110
   263
huffman@29014
   264
instance inat :: pordered_comm_semiring
huffman@29014
   265
proof
huffman@29014
   266
  fix a b c :: inat
huffman@29014
   267
  assume "a \<le> b" and "0 \<le> c"
huffman@29014
   268
  thus "c * a \<le> c * b"
huffman@29014
   269
    unfolding times_inat_def less_eq_inat_def zero_inat_def
huffman@29014
   270
    by (simp split: inat.splits)
huffman@29014
   271
qed
huffman@29014
   272
haftmann@27110
   273
lemma inat_ord_number [simp]:
haftmann@27110
   274
  "(number_of m \<Colon> inat) \<le> number_of n \<longleftrightarrow> (number_of m \<Colon> nat) \<le> number_of n"
haftmann@27110
   275
  "(number_of m \<Colon> inat) < number_of n \<longleftrightarrow> (number_of m \<Colon> nat) < number_of n"
haftmann@27110
   276
  by (simp_all add: number_of_inat_def)
oheimb@11351
   277
haftmann@27110
   278
lemma i0_lb [simp]: "(0\<Colon>inat) \<le> n"
haftmann@27110
   279
  by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
oheimb@11351
   280
haftmann@27110
   281
lemma i0_neq [simp]: "n \<le> (0\<Colon>inat) \<longleftrightarrow> n = 0"
haftmann@27110
   282
  by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
haftmann@27110
   283
haftmann@27110
   284
lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m \<Longrightarrow> R"
haftmann@27110
   285
  by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
oheimb@11351
   286
haftmann@27110
   287
lemma Infty_ilessE [elim!]: "\<infinity> < Fin m \<Longrightarrow> R"
haftmann@27110
   288
  by simp
oheimb@11351
   289
haftmann@27110
   290
lemma not_ilessi0 [simp]: "\<not> n < (0\<Colon>inat)"
haftmann@27110
   291
  by (simp add: zero_inat_def less_inat_def split: inat.splits)
haftmann@27110
   292
haftmann@27110
   293
lemma i0_eq [simp]: "(0\<Colon>inat) < n \<longleftrightarrow> n \<noteq> 0"
haftmann@27110
   294
  by (simp add: zero_inat_def less_inat_def split: inat.splits)
oheimb@11351
   295
haftmann@27110
   296
lemma iSuc_ile_mono [simp]: "iSuc n \<le> iSuc m \<longleftrightarrow> n \<le> m"
haftmann@27110
   297
  by (simp add: iSuc_def less_eq_inat_def split: inat.splits)
haftmann@27110
   298
 
haftmann@27110
   299
lemma iSuc_mono [simp]: "iSuc n < iSuc m \<longleftrightarrow> n < m"
haftmann@27110
   300
  by (simp add: iSuc_def less_inat_def split: inat.splits)
oheimb@11351
   301
haftmann@27110
   302
lemma ile_iSuc [simp]: "n \<le> iSuc n"
haftmann@27110
   303
  by (simp add: iSuc_def less_eq_inat_def split: inat.splits)
oheimb@11351
   304
wenzelm@11355
   305
lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0"
haftmann@27110
   306
  by (simp add: zero_inat_def iSuc_def less_eq_inat_def split: inat.splits)
haftmann@27110
   307
haftmann@27110
   308
lemma i0_iless_iSuc [simp]: "0 < iSuc n"
haftmann@27110
   309
  by (simp add: zero_inat_def iSuc_def less_inat_def split: inat.splits)
haftmann@27110
   310
haftmann@27110
   311
lemma ileI1: "m < n \<Longrightarrow> iSuc m \<le> n"
haftmann@27110
   312
  by (simp add: iSuc_def less_eq_inat_def less_inat_def split: inat.splits)
haftmann@27110
   313
haftmann@27110
   314
lemma Suc_ile_eq: "Fin (Suc m) \<le> n \<longleftrightarrow> Fin m < n"
haftmann@27110
   315
  by (cases n) auto
haftmann@27110
   316
haftmann@27110
   317
lemma iless_Suc_eq [simp]: "Fin m < iSuc n \<longleftrightarrow> Fin m \<le> n"
haftmann@27110
   318
  by (auto simp add: iSuc_def less_inat_def split: inat.splits)
oheimb@11351
   319
haftmann@27110
   320
lemma min_inat_simps [simp]:
haftmann@27110
   321
  "min (Fin m) (Fin n) = Fin (min m n)"
haftmann@27110
   322
  "min q 0 = 0"
haftmann@27110
   323
  "min 0 q = 0"
haftmann@27110
   324
  "min q \<infinity> = q"
haftmann@27110
   325
  "min \<infinity> q = q"
haftmann@27110
   326
  by (auto simp add: min_def)
oheimb@11351
   327
haftmann@27110
   328
lemma max_inat_simps [simp]:
haftmann@27110
   329
  "max (Fin m) (Fin n) = Fin (max m n)"
haftmann@27110
   330
  "max q 0 = q"
haftmann@27110
   331
  "max 0 q = q"
haftmann@27110
   332
  "max q \<infinity> = \<infinity>"
haftmann@27110
   333
  "max \<infinity> q = \<infinity>"
haftmann@27110
   334
  by (simp_all add: max_def)
haftmann@27110
   335
haftmann@27110
   336
lemma Fin_ile: "n \<le> Fin m \<Longrightarrow> \<exists>k. n = Fin k"
haftmann@27110
   337
  by (cases n) simp_all
haftmann@27110
   338
haftmann@27110
   339
lemma Fin_iless: "n < Fin m \<Longrightarrow> \<exists>k. n = Fin k"
haftmann@27110
   340
  by (cases n) simp_all
oheimb@11351
   341
oheimb@11351
   342
lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
nipkow@25134
   343
apply (induct_tac k)
nipkow@25134
   344
 apply (simp (no_asm) only: Fin_0)
haftmann@27110
   345
 apply (fast intro: le_less_trans [OF i0_lb])
nipkow@25134
   346
apply (erule exE)
nipkow@25134
   347
apply (drule spec)
nipkow@25134
   348
apply (erule exE)
nipkow@25134
   349
apply (drule ileI1)
nipkow@25134
   350
apply (rule iSuc_Fin [THEN subst])
nipkow@25134
   351
apply (rule exI)
haftmann@27110
   352
apply (erule (1) le_less_trans)
nipkow@25134
   353
done
oheimb@11351
   354
haftmann@29337
   355
instantiation inat :: "{bot, top}"
haftmann@29337
   356
begin
haftmann@29337
   357
haftmann@29337
   358
definition bot_inat :: inat where
haftmann@29337
   359
  "bot_inat = 0"
haftmann@29337
   360
haftmann@29337
   361
definition top_inat :: inat where
haftmann@29337
   362
  "top_inat = \<infinity>"
haftmann@29337
   363
haftmann@29337
   364
instance proof
haftmann@29337
   365
qed (simp_all add: bot_inat_def top_inat_def)
haftmann@29337
   366
haftmann@29337
   367
end
haftmann@29337
   368
huffman@26089
   369
haftmann@27110
   370
subsection {* Well-ordering *}
huffman@26089
   371
huffman@26089
   372
lemma less_FinE:
huffman@26089
   373
  "[| n < Fin m; !!k. n = Fin k ==> k < m ==> P |] ==> P"
huffman@26089
   374
by (induct n) auto
huffman@26089
   375
huffman@26089
   376
lemma less_InftyE:
huffman@26089
   377
  "[| n < Infty; !!k. n = Fin k ==> P |] ==> P"
huffman@26089
   378
by (induct n) auto
huffman@26089
   379
huffman@26089
   380
lemma inat_less_induct:
huffman@26089
   381
  assumes prem: "!!n. \<forall>m::inat. m < n --> P m ==> P n" shows "P n"
huffman@26089
   382
proof -
huffman@26089
   383
  have P_Fin: "!!k. P (Fin k)"
huffman@26089
   384
    apply (rule nat_less_induct)
huffman@26089
   385
    apply (rule prem, clarify)
huffman@26089
   386
    apply (erule less_FinE, simp)
huffman@26089
   387
    done
huffman@26089
   388
  show ?thesis
huffman@26089
   389
  proof (induct n)
huffman@26089
   390
    fix nat
huffman@26089
   391
    show "P (Fin nat)" by (rule P_Fin)
huffman@26089
   392
  next
huffman@26089
   393
    show "P Infty"
huffman@26089
   394
      apply (rule prem, clarify)
huffman@26089
   395
      apply (erule less_InftyE)
huffman@26089
   396
      apply (simp add: P_Fin)
huffman@26089
   397
      done
huffman@26089
   398
  qed
huffman@26089
   399
qed
huffman@26089
   400
huffman@26089
   401
instance inat :: wellorder
huffman@26089
   402
proof
haftmann@27823
   403
  fix P and n
haftmann@27823
   404
  assume hyp: "(\<And>n\<Colon>inat. (\<And>m\<Colon>inat. m < n \<Longrightarrow> P m) \<Longrightarrow> P n)"
haftmann@27823
   405
  show "P n" by (blast intro: inat_less_induct hyp)
huffman@26089
   406
qed
huffman@26089
   407
haftmann@27110
   408
haftmann@27110
   409
subsection {* Traditional theorem names *}
haftmann@27110
   410
haftmann@27110
   411
lemmas inat_defs = zero_inat_def one_inat_def number_of_inat_def iSuc_def
haftmann@27110
   412
  plus_inat_def less_eq_inat_def less_inat_def
haftmann@27110
   413
haftmann@27110
   414
lemmas inat_splits = inat.splits
haftmann@27110
   415
oheimb@11351
   416
end