equal
deleted
inserted
replaced
81 assume "P 0" then have init: "P (of_nat 0)" by simp |
81 assume "P 0" then have init: "P (of_nat 0)" by simp |
82 assume "\<And>k. P k \<Longrightarrow> P (Suc_code_numeral k)" |
82 assume "\<And>k. P k \<Longrightarrow> P (Suc_code_numeral k)" |
83 then have "\<And>n. P (of_nat n) \<Longrightarrow> P (Suc_code_numeral (of_nat n))" . |
83 then have "\<And>n. P (of_nat n) \<Longrightarrow> P (Suc_code_numeral (of_nat n))" . |
84 then have step: "\<And>n. P (of_nat n) \<Longrightarrow> P (of_nat (Suc n))" by simp |
84 then have step: "\<And>n. P (of_nat n) \<Longrightarrow> P (of_nat (Suc n))" by simp |
85 from init step have "P (of_nat (nat_of k))" |
85 from init step have "P (of_nat (nat_of k))" |
86 by (induct "nat_of k") simp_all |
86 by (induct ("nat_of k")) simp_all |
87 then show "P k" by simp |
87 then show "P k" by simp |
88 qed simp_all |
88 qed simp_all |
89 |
89 |
90 declare code_numeral_case [case_names nat, cases type: code_numeral] |
90 declare code_numeral_case [case_names nat, cases type: code_numeral] |
91 declare code_numeral.induct [case_names nat, induct type: code_numeral] |
91 declare code_numeral.induct [case_names nat, induct type: code_numeral] |
98 "code_numeral_size = nat_of" |
98 "code_numeral_size = nat_of" |
99 proof (rule ext) |
99 proof (rule ext) |
100 fix k |
100 fix k |
101 have "code_numeral_size k = nat_size (nat_of k)" |
101 have "code_numeral_size k = nat_size (nat_of k)" |
102 by (induct k rule: code_numeral.induct) (simp_all del: zero_code_numeral_def Suc_code_numeral_def, simp_all) |
102 by (induct k rule: code_numeral.induct) (simp_all del: zero_code_numeral_def Suc_code_numeral_def, simp_all) |
103 also have "nat_size (nat_of k) = nat_of k" by (induct "nat_of k") simp_all |
103 also have "nat_size (nat_of k) = nat_of k" by (induct ("nat_of k")) simp_all |
104 finally show "code_numeral_size k = nat_of k" . |
104 finally show "code_numeral_size k = nat_of k" . |
105 qed |
105 qed |
106 |
106 |
107 lemma [simp, code]: |
107 lemma [simp, code]: |
108 "size = nat_of" |
108 "size = nat_of" |