src/HOL/Word/Word.thy
changeset 46021 272c63f83398
parent 46020 0a29b51f0b0d
child 46022 657f87b10944
equal deleted inserted replaced
46020:0a29b51f0b0d 46021:272c63f83398
   658   apply (subst word_ubin.norm_Rep [symmetric])
   658   apply (subst word_ubin.norm_Rep [symmetric])
   659   apply (simp only: nth_bintr word_size)
   659   apply (simp only: nth_bintr word_size)
   660   apply fast
   660   apply fast
   661   done
   661   done
   662 
   662 
   663 lemma word_eqI [rule_format] : 
   663 lemma word_eq_iff:
       
   664   fixes x y :: "'a::len0 word"
       
   665   shows "x = y \<longleftrightarrow> (\<forall>n<len_of TYPE('a). x !! n = y !! n)"
       
   666   unfolding uint_inject [symmetric] bin_eq_iff word_test_bit_def [symmetric]
       
   667   by (metis test_bit_size [unfolded word_size])
       
   668 
       
   669 lemma word_eqI:
   664   fixes u :: "'a::len0 word"
   670   fixes u :: "'a::len0 word"
   665   shows "(ALL n. n < size u --> u !! n = v !! n) \<Longrightarrow> u = v"
   671   shows "(ALL n. n < size u --> u !! n = v !! n) \<Longrightarrow> u = v"
   666   apply (rule test_bit_eq_iff [THEN iffD1])
   672   by (simp add: word_size word_eq_iff)
   667   apply (rule ext)
       
   668   apply (erule allE)
       
   669   apply (erule impCE)
       
   670    prefer 2
       
   671    apply assumption
       
   672   apply (auto dest!: test_bit_size simp add: word_size)
       
   673   done
       
   674 
   673 
   675 lemma word_eqD: "(u::'a::len0 word) = v \<Longrightarrow> u !! x = v !! x"
   674 lemma word_eqD: "(u::'a::len0 word) = v \<Longrightarrow> u !! x = v !! x"
   676   by simp
   675   by simp
   677 
   676 
   678 lemma test_bit_bin': "w !! n = (n < size w & bin_nth (uint w) n)"
   677 lemma test_bit_bin': "w !! n = (n < size w & bin_nth (uint w) n)"