author  blanchet 
Mon, 02 Aug 2010 18:52:51 +0200  
changeset 38167  ab528533db92 
parent 37765  26bdfb7b680b 
child 38621  d6cb7e625d75 
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 
30663
0b6aff7451b2
Main is (Complex_Main) base entry point in library theories
haftmann
parents:
29668
diff
changeset

8 
imports Main 
15131  9 
begin 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

10 

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

12 

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

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

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

17 

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

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

19 

21210  20 
notation (xsymbols) 
19736  21 
Infty ("\<infinity>") 
22 

21210  23 
notation (HTML output) 
19736  24 
Infty ("\<infinity>") 
25 

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

26 

31084  27 
lemma not_Infty_eq[iff]: "(x ~= Infty) = (EX i. x = Fin i)" 
28 
by (cases x) auto 

29 

30 
lemma not_Fin_eq [iff]: "(ALL y. x ~= Fin y) = (x = Infty)" 

31077  31 
by (cases x) auto 
32 

33 

27110  34 
subsection {* Constructors and numbers *} 
35 

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

25594  37 
begin 
38 

39 
definition 

27110  40 
"0 = Fin 0" 
25594  41 

42 
definition 

32069
6d28bbd33e2c
prefer code_inline over code_unfold; use code_unfold_post where appropriate
haftmann
parents:
31998
diff
changeset

43 
[code_unfold]: "1 = Fin 1" 
25594  44 

45 
definition 

32069
6d28bbd33e2c
prefer code_inline over code_unfold; use code_unfold_post where appropriate
haftmann
parents:
31998
diff
changeset

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

47 

25594  48 
instance .. 
49 

50 
end 

51 

27110  52 
definition iSuc :: "inat \<Rightarrow> inat" where 
53 
"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

54 

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

55 
lemma Fin_0: "Fin 0 = 0" 
27110  56 
by (simp add: zero_inat_def) 
57 

58 
lemma Fin_1: "Fin 1 = 1" 

59 
by (simp add: one_inat_def) 

60 

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

62 
by (simp add: number_of_inat_def) 

63 

64 
lemma one_iSuc: "1 = iSuc 0" 

65 
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

66 

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

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

69 

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

70 
lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>" 
27110  71 
by (simp add: zero_inat_def) 
72 

73 
lemma zero_inat_eq [simp]: 

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

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

76 
unfolding zero_inat_def number_of_inat_def by simp_all 

77 

78 
lemma one_inat_eq [simp]: 

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

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

81 
unfolding one_inat_def number_of_inat_def by simp_all 

82 

83 
lemma zero_one_inat_neq [simp]: 

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

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

86 
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

87 

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

90 

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

92 
by (simp add: one_inat_def) 

93 

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

95 
by (simp add: number_of_inat_def) 

96 

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

98 
by (simp add: number_of_inat_def) 

99 

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

101 
by (simp add: iSuc_def) 

102 

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

104 
by (simp add: iSuc_Fin number_of_inat_def) 

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

105 

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

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

108 

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

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

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

113 
by (rule iSuc_ne_0 [symmetric]) 

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

114 

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

117 

118 
lemma number_of_inat_inject [simp]: 

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

120 
by (simp add: number_of_inat_def) 

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

121 

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

122 

27110  123 
subsection {* Addition *} 
124 

125 
instantiation inat :: comm_monoid_add 

126 
begin 

127 

38167  128 
definition [nitpick_simp]: 
37765  129 
"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

130 

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

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

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

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

136 

137 
instance proof 

138 
fix n m q :: inat 

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

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

141 
show "n + m = m + n" 

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

143 
show "0 + n = n" 

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

26089  145 
qed 
146 

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

148 

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

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

152 
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

153 

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

27110  157 
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

158 

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

161 
unfolding iSuc_number_of 

162 
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

163 

27110  164 
lemma iSuc_plus_1: 
165 
"iSuc n = n + 1" 

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

167 

168 
lemma plus_1_iSuc: 

169 
"1 + q = iSuc q" 

170 
"q + 1 = iSuc q" 

171 
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

172 

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

173 

29014  174 
subsection {* Multiplication *} 
175 

176 
instantiation inat :: comm_semiring_1 

177 
begin 

178 

38167  179 
definition times_inat_def [nitpick_simp]: 
29014  180 
"m * n = (case m of \<infinity> \<Rightarrow> if n = 0 then 0 else \<infinity>  Fin m \<Rightarrow> 
181 
(case n of \<infinity> \<Rightarrow> if m = 0 then 0 else \<infinity>  Fin n \<Rightarrow> Fin (m * n)))" 

182 

183 
lemma times_inat_simps [simp, code]: 

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

185 
"\<infinity> * \<infinity> = \<infinity>" 

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

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

188 
unfolding times_inat_def zero_inat_def 

189 
by (simp_all split: inat.split) 

190 

191 
instance proof 

192 
fix a b c :: inat 

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

194 
unfolding times_inat_def zero_inat_def 

195 
by (simp split: inat.split) 

196 
show "a * b = b * a" 

197 
unfolding times_inat_def zero_inat_def 

198 
by (simp split: inat.split) 

199 
show "1 * a = a" 

200 
unfolding times_inat_def zero_inat_def one_inat_def 

201 
by (simp split: inat.split) 

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

203 
unfolding times_inat_def zero_inat_def 

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

205 
show "0 * a = 0" 

206 
unfolding times_inat_def zero_inat_def 

207 
by (simp split: inat.split) 

208 
show "a * 0 = 0" 

209 
unfolding times_inat_def zero_inat_def 

210 
by (simp split: inat.split) 

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

212 
unfolding zero_inat_def one_inat_def 

213 
by simp 

214 
qed 

215 

216 
end 

217 

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

29667  219 
unfolding iSuc_plus_1 by (simp add: algebra_simps) 
29014  220 

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

29667  222 
unfolding iSuc_plus_1 by (simp add: algebra_simps) 
29014  223 

29023  224 
lemma of_nat_eq_Fin: "of_nat n = Fin n" 
225 
apply (induct n) 

226 
apply (simp add: Fin_0) 

227 
apply (simp add: plus_1_iSuc iSuc_Fin) 

228 
done 

229 

230 
instance inat :: semiring_char_0 

231 
by default (simp add: of_nat_eq_Fin) 

232 

29014  233 

27110  234 
subsection {* Ordering *} 
235 

35028
108662d50512
more consistent naming of type classes involving orderings (and lattices)  c.f. NEWS
haftmann
parents:
32069
diff
changeset

236 
instantiation inat :: linordered_ab_semigroup_add 
27110  237 
begin 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

238 

38167  239 
definition [nitpick_simp]: 
37765  240 
"m \<le> n = (case n of Fin n1 \<Rightarrow> (case m of Fin m1 \<Rightarrow> m1 \<le> n1  \<infinity> \<Rightarrow> False) 
27110  241 
 \<infinity> \<Rightarrow> True)" 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

242 

38167  243 
definition [nitpick_simp]: 
37765  244 
"m < n = (case m of Fin m1 \<Rightarrow> (case n of Fin n1 \<Rightarrow> m1 < n1  \<infinity> \<Rightarrow> True) 
27110  245 
 \<infinity> \<Rightarrow> False)" 
11351
c5c403d30c77
added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff
changeset

246 

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

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

250 
"q \<le> \<infinity>" 

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

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

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

254 
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

255 

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

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

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

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

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

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

263 
by simp_all 

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

264 

27110  265 
instance by default 
266 
(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

267 

27110  268 
end 
269 

35028
108662d50512
more consistent naming of type classes involving orderings (and lattices)  c.f. NEWS
haftmann
parents:
32069
diff
changeset

270 
instance inat :: ordered_comm_semiring 
29014  271 
proof 
272 
fix a b c :: inat 

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

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

275 
unfolding times_inat_def less_eq_inat_def zero_inat_def 

276 
by (simp split: inat.splits) 

277 
qed 

278 

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

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

282 
by (simp_all add: number_of_inat_def) 

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

283 

27110  284 
lemma i0_lb [simp]: "(0\<Colon>inat) \<le> n" 
285 
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

286 

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

289 

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

291 
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

292 

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

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

295 

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

298 

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

300 
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

301 

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

304 

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

306 
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

307 

27110  308 
lemma ile_iSuc [simp]: "n \<le> iSuc n" 
309 
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

310 

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

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

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

316 

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

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

319 

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

321 
by (cases n) auto 

322 

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

324 
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

325 

27110  326 
lemma min_inat_simps [simp]: 
327 
"min (Fin m) (Fin n) = Fin (min m n)" 

328 
"min q 0 = 0" 

329 
"min 0 q = 0" 

330 
"min q \<infinity> = q" 

331 
"min \<infinity> q = q" 

332 
by (auto simp add: min_def) 

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

333 

27110  334 
lemma max_inat_simps [simp]: 
335 
"max (Fin m) (Fin n) = Fin (max m n)" 

336 
"max q 0 = q" 

337 
"max 0 q = q" 

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

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

340 
by (simp_all add: max_def) 

341 

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

343 
by (cases n) simp_all 

344 

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

346 
by (cases n) simp_all 

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

347 

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

348 
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

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

350 
apply (simp (no_asm) only: Fin_0) 
27110  351 
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

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

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

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

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

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

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

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

360 

29337  361 
instantiation inat :: "{bot, top}" 
362 
begin 

363 

364 
definition bot_inat :: inat where 

365 
"bot_inat = 0" 

366 

367 
definition top_inat :: inat where 

368 
"top_inat = \<infinity>" 

369 

370 
instance proof 

371 
qed (simp_all add: bot_inat_def top_inat_def) 

372 

373 
end 

374 

26089  375 

27110  376 
subsection {* Wellordering *} 
26089  377 

378 
lemma less_FinE: 

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

380 
by (induct n) auto 

381 

382 
lemma less_InftyE: 

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

384 
by (induct n) auto 

385 

386 
lemma inat_less_induct: 

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

388 
proof  

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

390 
apply (rule nat_less_induct) 

391 
apply (rule prem, clarify) 

392 
apply (erule less_FinE, simp) 

393 
done 

394 
show ?thesis 

395 
proof (induct n) 

396 
fix nat 

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

398 
next 

399 
show "P Infty" 

400 
apply (rule prem, clarify) 

401 
apply (erule less_InftyE) 

402 
apply (simp add: P_Fin) 

403 
done 

404 
qed 

405 
qed 

406 

407 
instance inat :: wellorder 

408 
proof 

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

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

26089  412 
qed 
413 

27110  414 

415 
subsection {* Traditional theorem names *} 

416 

417 
lemmas inat_defs = zero_inat_def one_inat_def number_of_inat_def iSuc_def 

418 
plus_inat_def less_eq_inat_def less_inat_def 

419 

420 
lemmas inat_splits = inat.splits 

421 

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

422 
end 