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