equal
deleted
inserted
replaced
158 "word_power == op ^" |
158 "word_power == op ^" |
159 |
159 |
160 definition |
160 definition |
161 word_succ :: "'a :: len0 word => 'a word" |
161 word_succ :: "'a :: len0 word => 'a word" |
162 where |
162 where |
163 "word_succ a = word_of_int (Numeral.succ (uint a))" |
163 "word_succ a = word_of_int (Int.succ (uint a))" |
164 |
164 |
165 definition |
165 definition |
166 word_pred :: "'a :: len0 word => 'a word" |
166 word_pred :: "'a :: len0 word => 'a word" |
167 where |
167 where |
168 "word_pred a = word_of_int (Numeral.pred (uint a))" |
168 "word_pred a = word_of_int (Int.pred (uint a))" |
169 |
169 |
170 constdefs |
170 constdefs |
171 udvd :: "'a::len word => 'a::len word => bool" (infixl "udvd" 50) |
171 udvd :: "'a::len word => 'a::len word => bool" (infixl "udvd" 50) |
172 "a udvd b == EX n>=0. uint b = n * uint a" |
172 "a udvd b == EX n>=0. uint b = n * uint a" |
173 |
173 |
193 |
193 |
194 word_lsb_def: |
194 word_lsb_def: |
195 "lsb (a::'a::len0 word) == bin_last (uint a) = bit.B1" |
195 "lsb (a::'a::len0 word) == bin_last (uint a) = bit.B1" |
196 |
196 |
197 word_msb_def: |
197 word_msb_def: |
198 "msb (a::'a::len word) == bin_sign (sint a) = Numeral.Min" |
198 "msb (a::'a::len word) == bin_sign (sint a) = Int.Min" |
199 |
199 |
200 |
200 |
201 constdefs |
201 constdefs |
202 setBit :: "'a :: len0 word => nat => 'a word" |
202 setBit :: "'a :: len0 word => nat => 'a word" |
203 "setBit w n == set_bit w n True" |
203 "setBit w n == set_bit w n True" |
473 lemmas uint_lt2p [iff] = uint_lem [THEN conjunct2, standard] |
473 lemmas uint_lt2p [iff] = uint_lem [THEN conjunct2, standard] |
474 lemmas sint_ge = sint_lem [THEN conjunct1, standard] |
474 lemmas sint_ge = sint_lem [THEN conjunct1, standard] |
475 lemmas sint_lt = sint_lem [THEN conjunct2, standard] |
475 lemmas sint_lt = sint_lem [THEN conjunct2, standard] |
476 |
476 |
477 lemma sign_uint_Pls [simp]: |
477 lemma sign_uint_Pls [simp]: |
478 "bin_sign (uint x) = Numeral.Pls" |
478 "bin_sign (uint x) = Int.Pls" |
479 by (simp add: sign_Pls_ge_0 number_of_eq) |
479 by (simp add: sign_Pls_ge_0 number_of_eq) |
480 |
480 |
481 lemmas uint_m2p_neg = iffD2 [OF diff_less_0_iff_less uint_lt2p, standard] |
481 lemmas uint_m2p_neg = iffD2 [OF diff_less_0_iff_less uint_lt2p, standard] |
482 lemmas uint_m2p_not_non_neg = |
482 lemmas uint_m2p_not_non_neg = |
483 iffD2 [OF linorder_not_le uint_m2p_neg, standard] |
483 iffD2 [OF linorder_not_le uint_m2p_neg, standard] |
496 "uint (number_of b :: 'a :: len0 word) = number_of b mod 2 ^ len_of TYPE('a)" |
496 "uint (number_of b :: 'a :: len0 word) = number_of b mod 2 ^ len_of TYPE('a)" |
497 unfolding word_number_of_alt |
497 unfolding word_number_of_alt |
498 by (simp only: int_word_uint) |
498 by (simp only: int_word_uint) |
499 |
499 |
500 lemma unat_number_of: |
500 lemma unat_number_of: |
501 "bin_sign b = Numeral.Pls ==> |
501 "bin_sign b = Int.Pls ==> |
502 unat (number_of b::'a::len0 word) = number_of b mod 2 ^ len_of TYPE ('a)" |
502 unat (number_of b::'a::len0 word) = number_of b mod 2 ^ len_of TYPE ('a)" |
503 apply (unfold unat_def) |
503 apply (unfold unat_def) |
504 apply (clarsimp simp only: uint_number_of) |
504 apply (clarsimp simp only: uint_number_of) |
505 apply (rule nat_mod_distrib [THEN trans]) |
505 apply (rule nat_mod_distrib [THEN trans]) |
506 apply (erule sign_Pls_ge_0 [THEN iffD1]) |
506 apply (erule sign_Pls_ge_0 [THEN iffD1]) |
641 lemmas length_bl_gt_0 [iff] = xtr1 [OF word_bl.Rep' len_gt_0, standard] |
641 lemmas length_bl_gt_0 [iff] = xtr1 [OF word_bl.Rep' len_gt_0, standard] |
642 lemmas bl_not_Nil [iff] = |
642 lemmas bl_not_Nil [iff] = |
643 length_bl_gt_0 [THEN length_greater_0_conv [THEN iffD1], standard] |
643 length_bl_gt_0 [THEN length_greater_0_conv [THEN iffD1], standard] |
644 lemmas length_bl_neq_0 [iff] = length_bl_gt_0 [THEN gr_implies_not0] |
644 lemmas length_bl_neq_0 [iff] = length_bl_gt_0 [THEN gr_implies_not0] |
645 |
645 |
646 lemma hd_bl_sign_sint: "hd (to_bl w) = (bin_sign (sint w) = Numeral.Min)" |
646 lemma hd_bl_sign_sint: "hd (to_bl w) = (bin_sign (sint w) = Int.Min)" |
647 apply (unfold to_bl_def sint_uint) |
647 apply (unfold to_bl_def sint_uint) |
648 apply (rule trans [OF _ bl_sbin_sign]) |
648 apply (rule trans [OF _ bl_sbin_sign]) |
649 apply simp |
649 apply simp |
650 done |
650 done |
651 |
651 |