equal
deleted
inserted
replaced
220 done |
220 done |
221 |
221 |
222 lemma induct: |
222 lemma induct: |
223 "(\<And>z. \<lbrakk>0 \<le> z; z < n\<rbrakk> \<Longrightarrow> P (of_int z)) \<Longrightarrow> P (x::'a)" |
223 "(\<And>z. \<lbrakk>0 \<le> z; z < n\<rbrakk> \<Longrightarrow> P (of_int z)) \<Longrightarrow> P (x::'a)" |
224 by (cases x rule: cases) simp |
224 by (cases x rule: cases) simp |
|
225 |
|
226 lemma UNIV_eq: "(UNIV :: 'a set) = Abs ` {0..<n}" |
|
227 using type type_definition.univ by blast |
|
228 |
|
229 lemma CARD_eq: "CARD('a) = nat n" |
|
230 proof - |
|
231 have "CARD('a) = card (Abs ` {0..<n})" |
|
232 by (simp add: UNIV_eq) |
|
233 also have "inj_on Abs {0..<n}" |
|
234 by (metis Abs_inverse inj_onI) |
|
235 hence "card (Abs ` {0..<n}) = nat n" |
|
236 using size1 by (subst card_image) auto |
|
237 finally show ?thesis . |
|
238 qed |
|
239 |
|
240 lemma CHAR_eq [simp]: "CHAR('a) = CARD('a)" |
|
241 proof (rule CHAR_eqI) |
|
242 show "of_nat (CARD('a)) = (0 :: 'a)" |
|
243 by (simp add: CARD_eq of_nat_eq zero_def) |
|
244 next |
|
245 fix n assume "of_nat n = (0 :: 'a)" |
|
246 thus "CARD('a) dvd n" |
|
247 by (metis CARD_eq Rep_0 Rep_Abs_mod Rep_le_n mod_0_imp_dvd nat_dvd_iff of_nat_eq) |
|
248 qed |
225 |
249 |
226 end |
250 end |
227 |
251 |
228 |
252 |
229 subsection \<open>Ring class instances\<close> |
253 subsection \<open>Ring class instances\<close> |
572 |
596 |
573 subsection \<open>Examples\<close> |
597 subsection \<open>Examples\<close> |
574 |
598 |
575 lemma "CARD(0) = 0" by simp |
599 lemma "CARD(0) = 0" by simp |
576 lemma "CARD(17) = 17" by simp |
600 lemma "CARD(17) = 17" by simp |
|
601 lemma "CHAR(23) = 23" by simp |
577 lemma "8 * 11 ^ 3 - 6 = (2::5)" by simp |
602 lemma "8 * 11 ^ 3 - 6 = (2::5)" by simp |
578 |
603 |
579 end |
604 end |