src/HOL/Word/Word.thy
changeset 46604 9f9e85264e4d
parent 46603 83a5160e6b4d
child 46617 8c5d10d41391
equal deleted inserted replaced
46603:83a5160e6b4d 46604:9f9e85264e4d
   559 
   559 
   560 lemma sint_lt: "sint (x::'a::len word) < 2 ^ (len_of TYPE('a) - 1)"
   560 lemma sint_lt: "sint (x::'a::len word) < 2 ^ (len_of TYPE('a) - 1)"
   561   using word_sint.Rep [of x] by (simp add: sints_num)
   561   using word_sint.Rep [of x] by (simp add: sints_num)
   562 
   562 
   563 lemma sign_uint_Pls [simp]: 
   563 lemma sign_uint_Pls [simp]: 
   564   "bin_sign (uint x) = Int.Pls"
   564   "bin_sign (uint x) = 0"
   565   by (simp add: sign_Pls_ge_0 number_of_eq)
   565   by (simp add: sign_Pls_ge_0 number_of_eq)
   566 
   566 
   567 lemma uint_m2p_neg: "uint (x::'a::len0 word) - 2 ^ len_of TYPE('a) < 0"
   567 lemma uint_m2p_neg: "uint (x::'a::len0 word) - 2 ^ len_of TYPE('a) < 0"
   568   by (simp only: diff_less_0_iff_less uint_lt2p)
   568   by (simp only: diff_less_0_iff_less uint_lt2p)
   569 
   569 
   585   "uint (number_of b :: 'a :: len0 word) = number_of b mod 2 ^ len_of TYPE('a)"
   585   "uint (number_of b :: 'a :: len0 word) = number_of b mod 2 ^ len_of TYPE('a)"
   586   unfolding word_number_of_alt
   586   unfolding word_number_of_alt
   587   by (simp only: int_word_uint)
   587   by (simp only: int_word_uint)
   588 
   588 
   589 lemma unat_number_of: 
   589 lemma unat_number_of: 
   590   "bin_sign b = Int.Pls \<Longrightarrow> 
   590   "bin_sign (number_of b) = 0 \<Longrightarrow> 
   591   unat (number_of b::'a::len0 word) = number_of b mod 2 ^ len_of TYPE ('a)"
   591   unat (number_of b::'a::len0 word) = number_of b mod 2 ^ len_of TYPE ('a)"
   592   apply (unfold unat_def)
   592   apply (unfold unat_def)
   593   apply (clarsimp simp only: uint_number_of)
   593   apply (clarsimp simp only: uint_number_of)
   594   apply (rule nat_mod_distrib [THEN trans])
   594   apply (rule nat_mod_distrib [THEN trans])
   595     apply (erule sign_Pls_ge_0 [THEN iffD1])
   595     apply (erule sign_Pls_ge_0 [THEN iffD1])
  2297 
  2297 
  2298 lemma word_lsb_int: "lsb w = (uint w mod 2 = 1)"
  2298 lemma word_lsb_int: "lsb w = (uint w mod 2 = 1)"
  2299   unfolding word_lsb_def bin_last_def by auto
  2299   unfolding word_lsb_def bin_last_def by auto
  2300 
  2300 
  2301 lemma word_msb_sint: "msb w = (sint w < 0)" 
  2301 lemma word_msb_sint: "msb w = (sint w < 0)" 
  2302   unfolding word_msb_def
  2302   unfolding word_msb_def sign_Min_lt_0 ..
  2303   by (simp add : sign_Min_lt_0 number_of_is_id)
       
  2304 
  2303 
  2305 lemma msb_word_of_int:
  2304 lemma msb_word_of_int:
  2306   "msb (word_of_int x::'a::len word) = bin_nth x (len_of TYPE('a) - 1)"
  2305   "msb (word_of_int x::'a::len word) = bin_nth x (len_of TYPE('a) - 1)"
  2307   unfolding word_msb_def by (simp add: word_sbin.eq_norm bin_sign_lem)
  2306   unfolding word_msb_def by (simp add: word_sbin.eq_norm bin_sign_lem)
  2308 
  2307