src/HOL/Library/Word.thy
changeset 28562 4e74209f113e
parent 28229 4f06fae6a55e
child 30224 79136ce06bdb
equal deleted inserted replaced
28561:056255ade52a 28562:4e74209f113e
  2040 lemma bv_slice_length [simp]: "[| j \<le> i; i < length w |] ==> length (bv_slice w (i,j)) = i - j + 1"
  2040 lemma bv_slice_length [simp]: "[| j \<le> i; i < length w |] ==> length (bv_slice w (i,j)) = i - j + 1"
  2041   by (auto simp add: bv_slice_def)
  2041   by (auto simp add: bv_slice_def)
  2042 
  2042 
  2043 definition
  2043 definition
  2044   length_nat :: "nat => nat" where
  2044   length_nat :: "nat => nat" where
  2045   [code func del]: "length_nat x = (LEAST n. x < 2 ^ n)"
  2045   [code del]: "length_nat x = (LEAST n. x < 2 ^ n)"
  2046 
  2046 
  2047 lemma length_nat: "length (nat_to_bv n) = length_nat n"
  2047 lemma length_nat: "length (nat_to_bv n) = length_nat n"
  2048   apply (simp add: length_nat_def)
  2048   apply (simp add: length_nat_def)
  2049   apply (rule Least_equality [symmetric])
  2049   apply (rule Least_equality [symmetric])
  2050   prefer 2
  2050   prefer 2
  2265 primrec
  2265 primrec
  2266   fast_bv_to_nat_Nil: "fast_bv_to_nat_helper [] k = k"
  2266   fast_bv_to_nat_Nil: "fast_bv_to_nat_helper [] k = k"
  2267   fast_bv_to_nat_Cons: "fast_bv_to_nat_helper (b#bs) k =
  2267   fast_bv_to_nat_Cons: "fast_bv_to_nat_helper (b#bs) k =
  2268     fast_bv_to_nat_helper bs ((bit_case Int.Bit0 Int.Bit1 b) k)"
  2268     fast_bv_to_nat_helper bs ((bit_case Int.Bit0 Int.Bit1 b) k)"
  2269 
  2269 
  2270 declare fast_bv_to_nat_helper.simps [code func del]
  2270 declare fast_bv_to_nat_helper.simps [code del]
  2271 
  2271 
  2272 lemma fast_bv_to_nat_Cons0: "fast_bv_to_nat_helper (\<zero>#bs) bin =
  2272 lemma fast_bv_to_nat_Cons0: "fast_bv_to_nat_helper (\<zero>#bs) bin =
  2273     fast_bv_to_nat_helper bs (Int.Bit0 bin)"
  2273     fast_bv_to_nat_helper bs (Int.Bit0 bin)"
  2274   by simp
  2274   by simp
  2275 
  2275