author  nipkow 
Wed, 28 Jan 2009 16:29:16 +0100  
changeset 29667  53103fc8ffa3 
parent 29337  450805a4a91f 
child 29668  33ba3faeaa0e 
permissions  rwrr 
11355  1 
(* Title: HOL/Library/Nat_Infinity.thy 
27110  2 
Author: David von Oheimb, TU Muenchen; Florian Haftmann, TU Muenchen 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

3 
*) 
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

4 

14706  5 
header {* Natural numbers with infinity *} 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

6 

15131  7 
theory Nat_Infinity 
27487  8 
imports Plain "~~/src/HOL/Presburger" 
15131  9 
begin 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

10 

29337  11 
text {* FIXME: move to Nat.thy *} 
12 

13 
instantiation nat :: bot 

14 
begin 

15 

16 
definition bot_nat :: nat where 

17 
"bot_nat = 0" 

18 

19 
instance proof 

20 
qed (simp add: bot_nat_def) 

21 

27110  22 
subsection {* Type definition *} 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

23 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

24 
text {* 
11355  25 
We extend the standard natural numbers by a special value indicating 
27110  26 
infinity. 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

27 
*} 
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

28 

29337  29 
end 
30 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

31 
datatype inat = Fin nat  Infty 
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

32 

21210  33 
notation (xsymbols) 
19736  34 
Infty ("\<infinity>") 
35 

21210  36 
notation (HTML output) 
19736  37 
Infty ("\<infinity>") 
38 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

39 

27110  40 
subsection {* Constructors and numbers *} 
41 

42 
instantiation inat :: "{zero, one, number}" 

25594  43 
begin 
44 

45 
definition 

27110  46 
"0 = Fin 0" 
25594  47 

48 
definition 

27110  49 
[code inline]: "1 = Fin 1" 
25594  50 

51 
definition 

28562  52 
[code inline, code del]: "number_of k = Fin (number_of k)" 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

53 

25594  54 
instance .. 
55 

56 
end 

57 

27110  58 
definition iSuc :: "inat \<Rightarrow> inat" where 
59 
"iSuc i = (case i of Fin n \<Rightarrow> Fin (Suc n)  \<infinity> \<Rightarrow> \<infinity>)" 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

60 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

61 
lemma Fin_0: "Fin 0 = 0" 
27110  62 
by (simp add: zero_inat_def) 
63 

64 
lemma Fin_1: "Fin 1 = 1" 

65 
by (simp add: one_inat_def) 

66 

67 
lemma Fin_number: "Fin (number_of k) = number_of k" 

68 
by (simp add: number_of_inat_def) 

69 

70 
lemma one_iSuc: "1 = iSuc 0" 

71 
by (simp add: zero_inat_def one_inat_def iSuc_def) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

72 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

73 
lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0" 
27110  74 
by (simp add: zero_inat_def) 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

75 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

76 
lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>" 
27110  77 
by (simp add: zero_inat_def) 
78 

79 
lemma zero_inat_eq [simp]: 

80 
"number_of k = (0\<Colon>inat) \<longleftrightarrow> number_of k = (0\<Colon>nat)" 

81 
"(0\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (0\<Colon>nat)" 

82 
unfolding zero_inat_def number_of_inat_def by simp_all 

83 

84 
lemma one_inat_eq [simp]: 

85 
"number_of k = (1\<Colon>inat) \<longleftrightarrow> number_of k = (1\<Colon>nat)" 

86 
"(1\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (1\<Colon>nat)" 

87 
unfolding one_inat_def number_of_inat_def by simp_all 

88 

89 
lemma zero_one_inat_neq [simp]: 

90 
"\<not> 0 = (1\<Colon>inat)" 

91 
"\<not> 1 = (0\<Colon>inat)" 

92 
unfolding zero_inat_def one_inat_def by simp_all 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

93 

27110  94 
lemma Infty_ne_i1 [simp]: "\<infinity> \<noteq> 1" 
95 
by (simp add: one_inat_def) 

96 

97 
lemma i1_ne_Infty [simp]: "1 \<noteq> \<infinity>" 

98 
by (simp add: one_inat_def) 

99 

100 
lemma Infty_ne_number [simp]: "\<infinity> \<noteq> number_of k" 

101 
by (simp add: number_of_inat_def) 

102 

103 
lemma number_ne_Infty [simp]: "number_of k \<noteq> \<infinity>" 

104 
by (simp add: number_of_inat_def) 

105 

106 
lemma iSuc_Fin: "iSuc (Fin n) = Fin (Suc n)" 

107 
by (simp add: iSuc_def) 

108 

109 
lemma iSuc_number_of: "iSuc (number_of k) = Fin (Suc (number_of k))" 

110 
by (simp add: iSuc_Fin number_of_inat_def) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

111 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

112 
lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>" 
27110  113 
by (simp add: iSuc_def) 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

114 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

115 
lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0" 
27110  116 
by (simp add: iSuc_def zero_inat_def split: inat.splits) 
117 

118 
lemma zero_ne_iSuc [simp]: "0 \<noteq> iSuc n" 

119 
by (rule iSuc_ne_0 [symmetric]) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

120 

27110  121 
lemma iSuc_inject [simp]: "iSuc m = iSuc n \<longleftrightarrow> m = n" 
122 
by (simp add: iSuc_def split: inat.splits) 

123 

124 
lemma number_of_inat_inject [simp]: 

125 
"(number_of k \<Colon> inat) = number_of l \<longleftrightarrow> (number_of k \<Colon> nat) = number_of l" 

126 
by (simp add: number_of_inat_def) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

127 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

128 

27110  129 
subsection {* Addition *} 
130 

131 
instantiation inat :: comm_monoid_add 

132 
begin 

133 

134 
definition 

135 
[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)))" 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

136 

27110  137 
lemma plus_inat_simps [simp, code]: 
138 
"Fin m + Fin n = Fin (m + n)" 

139 
"\<infinity> + q = \<infinity>" 

140 
"q + \<infinity> = \<infinity>" 

141 
by (simp_all add: plus_inat_def split: inat.splits) 

142 

143 
instance proof 

144 
fix n m q :: inat 

145 
show "n + m + q = n + (m + q)" 

146 
by (cases n, auto, cases m, auto, cases q, auto) 

147 
show "n + m = m + n" 

148 
by (cases n, auto, cases m, auto) 

149 
show "0 + n = n" 

150 
by (cases n) (simp_all add: zero_inat_def) 

26089  151 
qed 
152 

27110  153 
end 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

154 

27110  155 
lemma plus_inat_0 [simp]: 
156 
"0 + (q\<Colon>inat) = q" 

157 
"(q\<Colon>inat) + 0 = q" 

158 
by (simp_all add: plus_inat_def zero_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

159 

27110  160 
lemma plus_inat_number [simp]: 
29012  161 
"(number_of k \<Colon> inat) + number_of l = (if k < Int.Pls then number_of l 
162 
else if l < Int.Pls then number_of k else number_of (k + l))" 

27110  163 
unfolding number_of_inat_def plus_inat_simps nat_arith(1) if_distrib [symmetric, of _ Fin] .. 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

164 

27110  165 
lemma iSuc_number [simp]: 
166 
"iSuc (number_of k) = (if neg (number_of k \<Colon> int) then 1 else number_of (Int.succ k))" 

167 
unfolding iSuc_number_of 

168 
unfolding one_inat_def number_of_inat_def Suc_nat_number_of if_distrib [symmetric] .. 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

169 

27110  170 
lemma iSuc_plus_1: 
171 
"iSuc n = n + 1" 

172 
by (cases n) (simp_all add: iSuc_Fin one_inat_def) 

173 

174 
lemma plus_1_iSuc: 

175 
"1 + q = iSuc q" 

176 
"q + 1 = iSuc q" 

177 
unfolding iSuc_plus_1 by (simp_all add: add_ac) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

178 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

179 

29014  180 
subsection {* Multiplication *} 
181 

182 
instantiation inat :: comm_semiring_1 

183 
begin 

184 

185 
definition 

186 
times_inat_def [code del]: 

187 
"m * n = (case m of \<infinity> \<Rightarrow> if n = 0 then 0 else \<infinity>  Fin m \<Rightarrow> 

188 
(case n of \<infinity> \<Rightarrow> if m = 0 then 0 else \<infinity>  Fin n \<Rightarrow> Fin (m * n)))" 

189 

190 
lemma times_inat_simps [simp, code]: 

191 
"Fin m * Fin n = Fin (m * n)" 

192 
"\<infinity> * \<infinity> = \<infinity>" 

193 
"\<infinity> * Fin n = (if n = 0 then 0 else \<infinity>)" 

194 
"Fin m * \<infinity> = (if m = 0 then 0 else \<infinity>)" 

195 
unfolding times_inat_def zero_inat_def 

196 
by (simp_all split: inat.split) 

197 

198 
instance proof 

199 
fix a b c :: inat 

200 
show "(a * b) * c = a * (b * c)" 

201 
unfolding times_inat_def zero_inat_def 

202 
by (simp split: inat.split) 

203 
show "a * b = b * a" 

204 
unfolding times_inat_def zero_inat_def 

205 
by (simp split: inat.split) 

206 
show "1 * a = a" 

207 
unfolding times_inat_def zero_inat_def one_inat_def 

208 
by (simp split: inat.split) 

209 
show "(a + b) * c = a * c + b * c" 

210 
unfolding times_inat_def zero_inat_def 

211 
by (simp split: inat.split add: left_distrib) 

212 
show "0 * a = 0" 

213 
unfolding times_inat_def zero_inat_def 

214 
by (simp split: inat.split) 

215 
show "a * 0 = 0" 

216 
unfolding times_inat_def zero_inat_def 

217 
by (simp split: inat.split) 

218 
show "(0::inat) \<noteq> 1" 

219 
unfolding zero_inat_def one_inat_def 

220 
by simp 

221 
qed 

222 

223 
end 

224 

225 
lemma mult_iSuc: "iSuc m * n = n + m * n" 

29667  226 
unfolding iSuc_plus_1 by (simp add: algebra_simps) 
29014  227 

228 
lemma mult_iSuc_right: "m * iSuc n = m + m * n" 

29667  229 
unfolding iSuc_plus_1 by (simp add: algebra_simps) 
29014  230 

29023  231 
lemma of_nat_eq_Fin: "of_nat n = Fin n" 
232 
apply (induct n) 

233 
apply (simp add: Fin_0) 

234 
apply (simp add: plus_1_iSuc iSuc_Fin) 

235 
done 

236 

237 
instance inat :: semiring_char_0 

238 
by default (simp add: of_nat_eq_Fin) 

239 

29014  240 

27110  241 
subsection {* Ordering *} 
242 

243 
instantiation inat :: ordered_ab_semigroup_add 

244 
begin 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

245 

27110  246 
definition 
247 
[code del]: "m \<le> n = (case n of Fin n1 \<Rightarrow> (case m of Fin m1 \<Rightarrow> m1 \<le> n1  \<infinity> \<Rightarrow> False) 

248 
 \<infinity> \<Rightarrow> True)" 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

249 

27110  250 
definition 
251 
[code del]: "m < n = (case m of Fin m1 \<Rightarrow> (case n of Fin n1 \<Rightarrow> m1 < n1  \<infinity> \<Rightarrow> True) 

252 
 \<infinity> \<Rightarrow> False)" 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

253 

27110  254 
lemma inat_ord_simps [simp]: 
255 
"Fin m \<le> Fin n \<longleftrightarrow> m \<le> n" 

256 
"Fin m < Fin n \<longleftrightarrow> m < n" 

257 
"q \<le> \<infinity>" 

258 
"q < \<infinity> \<longleftrightarrow> q \<noteq> \<infinity>" 

259 
"\<infinity> \<le> q \<longleftrightarrow> q = \<infinity>" 

260 
"\<infinity> < q \<longleftrightarrow> False" 

261 
by (simp_all add: less_eq_inat_def less_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

262 

27110  263 
lemma inat_ord_code [code]: 
264 
"Fin m \<le> Fin n \<longleftrightarrow> m \<le> n" 

265 
"Fin m < Fin n \<longleftrightarrow> m < n" 

266 
"q \<le> \<infinity> \<longleftrightarrow> True" 

267 
"Fin m < \<infinity> \<longleftrightarrow> True" 

268 
"\<infinity> \<le> Fin n \<longleftrightarrow> False" 

269 
"\<infinity> < q \<longleftrightarrow> False" 

270 
by simp_all 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

271 

27110  272 
instance by default 
273 
(auto simp add: less_eq_inat_def less_inat_def plus_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

274 

27110  275 
end 
276 

29014  277 
instance inat :: pordered_comm_semiring 
278 
proof 

279 
fix a b c :: inat 

280 
assume "a \<le> b" and "0 \<le> c" 

281 
thus "c * a \<le> c * b" 

282 
unfolding times_inat_def less_eq_inat_def zero_inat_def 

283 
by (simp split: inat.splits) 

284 
qed 

285 

27110  286 
lemma inat_ord_number [simp]: 
287 
"(number_of m \<Colon> inat) \<le> number_of n \<longleftrightarrow> (number_of m \<Colon> nat) \<le> number_of n" 

288 
"(number_of m \<Colon> inat) < number_of n \<longleftrightarrow> (number_of m \<Colon> nat) < number_of n" 

289 
by (simp_all add: number_of_inat_def) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

290 

27110  291 
lemma i0_lb [simp]: "(0\<Colon>inat) \<le> n" 
292 
by (simp add: zero_inat_def less_eq_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

293 

27110  294 
lemma i0_neq [simp]: "n \<le> (0\<Colon>inat) \<longleftrightarrow> n = 0" 
295 
by (simp add: zero_inat_def less_eq_inat_def split: inat.splits) 

296 

297 
lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m \<Longrightarrow> R" 

298 
by (simp add: zero_inat_def less_eq_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

299 

27110  300 
lemma Infty_ilessE [elim!]: "\<infinity> < Fin m \<Longrightarrow> R" 
301 
by simp 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

302 

27110  303 
lemma not_ilessi0 [simp]: "\<not> n < (0\<Colon>inat)" 
304 
by (simp add: zero_inat_def less_inat_def split: inat.splits) 

305 

306 
lemma i0_eq [simp]: "(0\<Colon>inat) < n \<longleftrightarrow> n \<noteq> 0" 

307 
by (simp add: zero_inat_def less_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

308 

27110  309 
lemma iSuc_ile_mono [simp]: "iSuc n \<le> iSuc m \<longleftrightarrow> n \<le> m" 
310 
by (simp add: iSuc_def less_eq_inat_def split: inat.splits) 

311 

312 
lemma iSuc_mono [simp]: "iSuc n < iSuc m \<longleftrightarrow> n < m" 

313 
by (simp add: iSuc_def less_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

314 

27110  315 
lemma ile_iSuc [simp]: "n \<le> iSuc n" 
316 
by (simp add: iSuc_def less_eq_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

317 

11355  318 
lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0" 
27110  319 
by (simp add: zero_inat_def iSuc_def less_eq_inat_def split: inat.splits) 
320 

321 
lemma i0_iless_iSuc [simp]: "0 < iSuc n" 

322 
by (simp add: zero_inat_def iSuc_def less_inat_def split: inat.splits) 

323 

324 
lemma ileI1: "m < n \<Longrightarrow> iSuc m \<le> n" 

325 
by (simp add: iSuc_def less_eq_inat_def less_inat_def split: inat.splits) 

326 

327 
lemma Suc_ile_eq: "Fin (Suc m) \<le> n \<longleftrightarrow> Fin m < n" 

328 
by (cases n) auto 

329 

330 
lemma iless_Suc_eq [simp]: "Fin m < iSuc n \<longleftrightarrow> Fin m \<le> n" 

331 
by (auto simp add: iSuc_def less_inat_def split: inat.splits) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

332 

27110  333 
lemma min_inat_simps [simp]: 
334 
"min (Fin m) (Fin n) = Fin (min m n)" 

335 
"min q 0 = 0" 

336 
"min 0 q = 0" 

337 
"min q \<infinity> = q" 

338 
"min \<infinity> q = q" 

339 
by (auto simp add: min_def) 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

340 

27110  341 
lemma max_inat_simps [simp]: 
342 
"max (Fin m) (Fin n) = Fin (max m n)" 

343 
"max q 0 = q" 

344 
"max 0 q = q" 

345 
"max q \<infinity> = \<infinity>" 

346 
"max \<infinity> q = \<infinity>" 

347 
by (simp_all add: max_def) 

348 

349 
lemma Fin_ile: "n \<le> Fin m \<Longrightarrow> \<exists>k. n = Fin k" 

350 
by (cases n) simp_all 

351 

352 
lemma Fin_iless: "n < Fin m \<Longrightarrow> \<exists>k. n = Fin k" 

353 
by (cases n) simp_all 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

354 

c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

355 
lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j" 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

356 
apply (induct_tac k) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

357 
apply (simp (no_asm) only: Fin_0) 
27110  358 
apply (fast intro: le_less_trans [OF i0_lb]) 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

359 
apply (erule exE) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

360 
apply (drule spec) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

361 
apply (erule exE) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

362 
apply (drule ileI1) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

363 
apply (rule iSuc_Fin [THEN subst]) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

364 
apply (rule exI) 
27110  365 
apply (erule (1) le_less_trans) 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

366 
done 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

367 

29337  368 
instantiation inat :: "{bot, top}" 
369 
begin 

370 

371 
definition bot_inat :: inat where 

372 
"bot_inat = 0" 

373 

374 
definition top_inat :: inat where 

375 
"top_inat = \<infinity>" 

376 

377 
instance proof 

378 
qed (simp_all add: bot_inat_def top_inat_def) 

379 

380 
end 

381 

26089  382 

27110  383 
subsection {* Wellordering *} 
26089  384 

385 
lemma less_FinE: 

386 
"[ n < Fin m; !!k. n = Fin k ==> k < m ==> P ] ==> P" 

387 
by (induct n) auto 

388 

389 
lemma less_InftyE: 

390 
"[ n < Infty; !!k. n = Fin k ==> P ] ==> P" 

391 
by (induct n) auto 

392 

393 
lemma inat_less_induct: 

394 
assumes prem: "!!n. \<forall>m::inat. m < n > P m ==> P n" shows "P n" 

395 
proof  

396 
have P_Fin: "!!k. P (Fin k)" 

397 
apply (rule nat_less_induct) 

398 
apply (rule prem, clarify) 

399 
apply (erule less_FinE, simp) 

400 
done 

401 
show ?thesis 

402 
proof (induct n) 

403 
fix nat 

404 
show "P (Fin nat)" by (rule P_Fin) 

405 
next 

406 
show "P Infty" 

407 
apply (rule prem, clarify) 

408 
apply (erule less_InftyE) 

409 
apply (simp add: P_Fin) 

410 
done 

411 
qed 

412 
qed 

413 

414 
instance inat :: wellorder 

415 
proof 

27823  416 
fix P and n 
417 
assume hyp: "(\<And>n\<Colon>inat. (\<And>m\<Colon>inat. m < n \<Longrightarrow> P m) \<Longrightarrow> P n)" 

418 
show "P n" by (blast intro: inat_less_induct hyp) 

26089  419 
qed 
420 

27110  421 

422 
subsection {* Traditional theorem names *} 

423 

424 
lemmas inat_defs = zero_inat_def one_inat_def number_of_inat_def iSuc_def 

425 
plus_inat_def less_eq_inat_def less_inat_def 

426 

427 
lemmas inat_splits = inat.splits 

428 

11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

429 
end 