src/HOL/Library/Word.thy
changeset 73853 52b829b18066
parent 73816 0510c7a4256a
child 73932 fd21b4a93043
equal deleted inserted replaced
73852:adb34395b622 73853:52b829b18066
  1148   for w :: \<open>'b::len word\<close>
  1148   for w :: \<open>'b::len word\<close>
  1149   by (rule bit_eqI) (auto simp add: bit_unsigned_iff bit_take_bit_iff bit_drop_bit_eq Parity.bit_drop_bit_eq dest: bit_imp_le_length)
  1149   by (rule bit_eqI) (auto simp add: bit_unsigned_iff bit_take_bit_iff bit_drop_bit_eq Parity.bit_drop_bit_eq dest: bit_imp_le_length)
  1150 
  1150 
  1151 end
  1151 end
  1152 
  1152 
       
  1153 lemma ucast_drop_bit_eq:
       
  1154   \<open>ucast (drop_bit n w) = drop_bit n (ucast w :: 'b::len word)\<close>
       
  1155   if \<open>LENGTH('a) \<le> LENGTH('b)\<close> for w :: \<open>'a::len word\<close>
       
  1156   by (rule bit_word_eqI) (use that in \<open>auto simp add: bit_unsigned_iff bit_drop_bit_eq dest: bit_imp_le_length\<close>)
       
  1157 
  1153 context semiring_bit_operations
  1158 context semiring_bit_operations
  1154 begin
  1159 begin
  1155 
  1160 
  1156 lemma unsigned_and_eq:
  1161 lemma unsigned_and_eq:
  1157   \<open>unsigned (v AND w) = unsigned v AND unsigned w\<close>
  1162   \<open>unsigned (v AND w) = unsigned v AND unsigned w\<close>
  3544 lemma drop_bit_word_numeral [simp]:
  3549 lemma drop_bit_word_numeral [simp]:
  3545   \<open>drop_bit (numeral n) (numeral k) =
  3550   \<open>drop_bit (numeral n) (numeral k) =
  3546     (word_of_int (drop_bit (numeral n) (take_bit LENGTH('a) (numeral k))) :: 'a::len word)\<close>
  3551     (word_of_int (drop_bit (numeral n) (take_bit LENGTH('a) (numeral k))) :: 'a::len word)\<close>
  3547   by transfer simp
  3552   by transfer simp
  3548 
  3553 
       
  3554 lemma signed_drop_bit_word_numeral [simp]:
       
  3555   \<open>signed_drop_bit (numeral n) (numeral k) =
       
  3556     (word_of_int (drop_bit (numeral n) (signed_take_bit (LENGTH('a) - 1) (numeral k))) :: 'a::len word)\<close>
       
  3557   by transfer simp
       
  3558 
  3549 lemma False_map2_or: "\<lbrakk>set xs \<subseteq> {False}; length ys = length xs\<rbrakk> \<Longrightarrow> map2 (\<or>) xs ys = ys"
  3559 lemma False_map2_or: "\<lbrakk>set xs \<subseteq> {False}; length ys = length xs\<rbrakk> \<Longrightarrow> map2 (\<or>) xs ys = ys"
  3550   by (induction xs arbitrary: ys) (auto simp: length_Suc_conv)
  3560   by (induction xs arbitrary: ys) (auto simp: length_Suc_conv)
  3551 
  3561 
  3552 lemma align_lem_or:
  3562 lemma align_lem_or:
  3553   assumes "length xs = n + m" "length ys = n + m" 
  3563   assumes "length xs = n + m" "length ys = n + m" 
  4165   by (induct n) (simp_all add: word_rec_Suc)
  4175   by (induct n) (simp_all add: word_rec_Suc)
  4166 
  4176 
  4167 lemma word_rec_in2: "f n (word_rec z f n) = word_rec (f 0 z) (f \<circ> (+) 1) n"
  4177 lemma word_rec_in2: "f n (word_rec z f n) = word_rec (f 0 z) (f \<circ> (+) 1) n"
  4168   by (induct n) (simp_all add: word_rec_Suc)
  4178   by (induct n) (simp_all add: word_rec_Suc)
  4169 
  4179 
  4170 
       
  4171 
       
  4172 lemma word_rec_twice:
  4180 lemma word_rec_twice:
  4173   "m \<le> n \<Longrightarrow> word_rec z f n = word_rec (word_rec z f (n - m)) (f \<circ> (+) (n - m)) m"
  4181   "m \<le> n \<Longrightarrow> word_rec z f n = word_rec (word_rec z f (n - m)) (f \<circ> (+) (n - m)) m"
  4174 proof (induction n arbitrary: z f)
  4182 proof (induction n arbitrary: z f)
  4175   case zero
  4183   case zero
  4176   then show ?case
  4184   then show ?case