equal
deleted
inserted
replaced
156 consts |
156 consts |
157 -- "corresponding operations analysing bins" |
157 -- "corresponding operations analysing bins" |
158 bin_last :: "int => bit" |
158 bin_last :: "int => bit" |
159 bin_rest :: "int => int" |
159 bin_rest :: "int => int" |
160 bin_sign :: "int => int" |
160 bin_sign :: "int => int" |
161 bin_nth :: "int => nat => bool" |
|
162 |
|
163 primrec |
|
164 Z : "bin_nth w 0 = (bin_last w = bit.B1)" |
|
165 Suc : "bin_nth w (Suc n) = bin_nth (bin_rest w) n" |
|
166 |
161 |
167 defs |
162 defs |
168 bin_rest_def : "bin_rest w == fst (bin_rl w)" |
163 bin_rest_def : "bin_rest w == fst (bin_rl w)" |
169 bin_last_def : "bin_last w == snd (bin_rl w)" |
164 bin_last_def : "bin_last w == snd (bin_rl w)" |
170 bin_sign_def : "bin_sign == bin_rec Numeral.Pls Numeral.Min (%w b s. s)" |
165 bin_sign_def : "bin_sign == bin_rec Numeral.Pls Numeral.Min (%w b s. s)" |
225 apply (simp add: z1pdiv2 split: bit.split) |
220 apply (simp add: z1pdiv2 split: bit.split) |
226 done |
221 done |
227 |
222 |
228 lemma Bit_div2 [simp]: "(w BIT b) div 2 = w" |
223 lemma Bit_div2 [simp]: "(w BIT b) div 2 = w" |
229 unfolding bin_rest_div [symmetric] by auto |
224 unfolding bin_rest_div [symmetric] by auto |
|
225 |
|
226 subsection {* Testing bit positions *} |
|
227 |
|
228 consts |
|
229 bin_nth :: "int => nat => bool" |
|
230 |
|
231 primrec |
|
232 Z : "bin_nth w 0 = (bin_last w = bit.B1)" |
|
233 Suc : "bin_nth w (Suc n) = bin_nth (bin_rest w) n" |
230 |
234 |
231 lemma bin_nth_lem [rule_format]: |
235 lemma bin_nth_lem [rule_format]: |
232 "ALL y. bin_nth x = bin_nth y --> x = y" |
236 "ALL y. bin_nth x = bin_nth y --> x = y" |
233 apply (induct x rule: bin_induct) |
237 apply (induct x rule: bin_induct) |
234 apply safe |
238 apply safe |