7 abbreviation (input) pow2 :: "int \<Rightarrow> int"
8 where "pow2 i \<equiv> 2 ^ nat i"
10 why3_open "bv/Pow2int.xml"
14 why3_vc Power_0 by simp
16 why3_vc Power_s using assms by (simp add: Power_s)
18 why3_vc Power_1 by simp
20 why3_vc Power_sum using assms by (simp add: Power_sum)
22 why3_vc pow2pos using assms by simp
24 why3_vc pow2_0 by simp
25 why3_vc pow2_1 by simp
26 why3_vc pow2_2 by simp
27 why3_vc pow2_3 by simp
28 why3_vc pow2_4 by simp
29 why3_vc pow2_5 by simp
30 why3_vc pow2_6 by simp
31 why3_vc pow2_7 by simp
32 why3_vc pow2_8 by simp
33 why3_vc pow2_9 by simp
34 why3_vc pow2_10 by simp
35 why3_vc pow2_11 by simp
36 why3_vc pow2_12 by simp
37 why3_vc pow2_13 by simp
38 why3_vc pow2_14 by simp
39 why3_vc pow2_15 by simp
40 why3_vc pow2_16 by simp
41 why3_vc pow2_17 by simp
42 why3_vc pow2_18 by simp
43 why3_vc pow2_19 by simp
44 why3_vc pow2_20 by simp
45 why3_vc pow2_21 by simp
46 why3_vc pow2_22 by simp
47 why3_vc pow2_23 by simp
48 why3_vc pow2_24 by simp
49 why3_vc pow2_25 by simp
50 why3_vc pow2_26 by simp
51 why3_vc pow2_27 by simp
52 why3_vc pow2_28 by simp
53 why3_vc pow2_29 by simp
54 why3_vc pow2_30 by simp
55 why3_vc pow2_31 by simp
56 why3_vc pow2_32 by simp
57 why3_vc pow2_33 by simp
58 why3_vc pow2_34 by simp
59 why3_vc pow2_35 by simp
60 why3_vc pow2_36 by simp
61 why3_vc pow2_37 by simp
62 why3_vc pow2_38 by simp
63 why3_vc pow2_39 by simp
64 why3_vc pow2_40 by simp
65 why3_vc pow2_41 by simp
66 why3_vc pow2_42 by simp
67 why3_vc pow2_43 by simp
68 why3_vc pow2_44 by simp
69 why3_vc pow2_45 by simp
70 why3_vc pow2_46 by simp
71 why3_vc pow2_47 by simp
72 why3_vc pow2_48 by simp
73 why3_vc pow2_49 by simp
74 why3_vc pow2_50 by simp
75 why3_vc pow2_51 by simp
76 why3_vc pow2_52 by simp
77 why3_vc pow2_53 by simp
78 why3_vc pow2_54 by simp
79 why3_vc pow2_55 by simp
80 why3_vc pow2_56 by simp
81 why3_vc pow2_57 by simp
82 why3_vc pow2_58 by simp
83 why3_vc pow2_59 by simp
84 why3_vc pow2_60 by simp
85 why3_vc pow2_61 by simp
86 why3_vc pow2_62 by simp
87 why3_vc pow2_63 by simp
88 why3_vc pow2_64 by simp
94 assumes "0 < length xs"
95 shows "rotate1 xs ! (i mod length xs) = xs ! (Suc i mod length xs)"
98 with `0 < length xs` show ?thesis by simp
101 with mod_less_divisor [of "Suc (length ys)" i]
103 by (auto simp add: nth_append mod_Suc simp del: mod_less_divisor)
106 lemma word_rotl_0: "word_rotl 0 w = w"
109 lemma word_rotr_0: "word_rotr 0 w = w"
113 "bit (word_rotl j w) (((i + j) mod len_of TYPE('a))) = bit (w::'a::len word) (i mod len_of TYPE('a))"
115 have "bit (word_rotl j w) (((i + j) mod len_of TYPE('a))) =
116 bit (word_roti (- int j) w) (((i + j) mod len_of TYPE('a)))"
117 by (simp add: word_rotl_0 word_rotr_0)
119 apply (simp only: bit_word_roti_iff)
120 apply (simp add: zmod_int mod_diff_left_eq)
121 apply (simp add: zmod_int [symmetric])
126 "bit (word_rotr j w) (i mod len_of TYPE('a)) = bit (w::'a::len word) ((i + j) mod len_of TYPE('a))"
127 by (simp add: bit_word_rotr_iff mod_add_left_eq)
129 lemma uint_pow: "uint ((b::'a::len word) ^ n) = uint b ^ n mod 2 ^ len_of TYPE('a)"
130 by (induct n) (simp_all add: uint_word_ariths mod_mult_right_eq)
133 includes bit_operations_syntax
136 lemma eq_sub_equiv_aux:
137 "(\<forall>j. uint i \<le> j \<and> j < uint i + uint n \<longrightarrow>
138 (0 \<le> j \<and> bit a (nat j)) = (0 \<le> j \<and> bit b (nat j))) =
139 ((b::('a::len) word) AND (push_bit (unat i) (mask (unat n))) = a AND (push_bit (unat i) (mask (unat n))))"
140 apply (simp add: bit_eq_iff bit_and_iff bit_push_bit_iff)
143 apply (drule_tac x="int na" in spec)
144 apply (auto simp add: uint_nat bit_mask_iff simp del: of_nat_unat)[1]
146 apply (drule_tac x="nat j" in spec)
147 apply (auto simp add: uint_nat bit_mask_iff simp del: of_nat_unat dest: bit_imp_le_length)
152 lemma int_minus_mod: "((i::int) - j) mod n = (i + (n - j mod n)) mod n"
154 have "(i + (n - j mod n)) mod n = (i mod n + (n - j mod n) mod n) mod n"
155 by (simp only: mod_add_eq)
156 also have "(n - j mod n) mod n = (n mod n - j mod n) mod n"
158 finally show ?thesis by (simp add: mod_minus_eq mod_add_eq)
162 assumes "0 < (n::nat)"
163 shows "((n - i mod n) + i) mod n = 0"
165 have "((n - i mod n) + i) mod n = (i + (n - i mod n)) mod n"
166 by (simp add: add_ac)
167 also have "\<dots> = (i mod n + (n - i mod n)) mod n"
168 by (simp add: mod_add_left_eq)
169 also from assms have "\<dots> = (n mod n + (i mod n - i mod n)) mod n"
170 by (simp add: add_ac)
171 finally show ?thesis by simp
174 lemma nat_minus_mod':
175 assumes "0 < (n::nat)"
176 shows "(i + (n - j mod n) + j) mod n = i mod n"
178 have "(i + (n - j mod n) + j) mod n = (i + ((n - j mod n) + j)) mod n"
179 by (simp add: add_ac)
180 also have "\<dots> = (i mod n + ((n - j mod n) + j) mod n) mod n"
181 by (simp add: mod_add_left_eq mod_add_right_eq)
182 also note nat_minus_mod [OF assms]
183 finally show ?thesis by simp
187 definition bv_nth :: "'a::len word \<Rightarrow> int \<Rightarrow> bool"
188 where "bv_nth bv i \<equiv> 0 \<le> i \<and> bit bv (nat i)"
190 abbreviation (input) nth_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> bool"
191 where "nth_bv bv bv' \<equiv> bit bv (unat bv')"
193 abbreviation (input) lsr :: "'a::len word \<Rightarrow> int \<Rightarrow> 'a word"
194 where "lsr v i \<equiv> drop_bit (nat i) v"
196 abbreviation (input) lsr_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word"
197 where "lsr_bv v n \<equiv> drop_bit (unat n) v"
199 abbreviation (input) asr :: "'a::len word \<Rightarrow> int \<Rightarrow> 'a word"
200 where "asr v i \<equiv> signed_drop_bit (nat i) v"
202 abbreviation (input) asr_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word"
203 where "asr_bv v n \<equiv> signed_drop_bit (unat n) v"
205 abbreviation (input) lsl :: "'a::len word \<Rightarrow> int \<Rightarrow> 'a word"
206 where "lsl v i \<equiv> push_bit (nat i) v"
208 abbreviation (input) lsl_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word"
209 where "lsl_bv v n \<equiv> push_bit (unat n) v"
211 abbreviation (input) rotate_left :: "'a::len word \<Rightarrow> int \<Rightarrow> 'a word"
212 where "rotate_left v n \<equiv> word_rotl (nat n) v"
214 abbreviation (input) rotate_right :: "'a::len word \<Rightarrow> int \<Rightarrow> 'a word"
215 where "rotate_right v n \<equiv> word_rotr (nat n) v"
217 abbreviation (input) rotate_left_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word"
218 where "rotate_left_bv v n \<equiv> word_rotl (unat n) v"
220 abbreviation (input) rotate_right_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word"
221 where "rotate_right_bv v n \<equiv> word_rotr (unat n) v"
224 includes bit_operations_syntax
227 definition eq_sub_bv :: "'a::len word \<Rightarrow> 'a word \<Rightarrow> 'a word \<Rightarrow> 'a word \<Rightarrow> bool" where
228 eq_sub_bv_defn: "eq_sub_bv a b i n =
229 (b AND (push_bit (unat i) (mask (unat n))) = a AND (push_bit (unat i) (mask (unat n))))"
233 definition size_bv :: "'a::len word" where
234 "size_bv = of_nat LENGTH('a)"
236 definition is_signed_positive :: "'a::len word \<Rightarrow> bool" where
237 "is_signed_positive w = (0 \<le> sint w)"
240 "sint (x::'a::len word) =
241 (if is_signed_positive x then uint x else - (2 ^ LENGTH('a) - uint x))"
242 proof (cases "0 \<le> sint x")
245 also have "(2::int) ^ (LENGTH('a) - 1) < 2 ^ LENGTH('a)"
246 by (rule power_strict_increasing) simp_all
247 finally have "sint x < 2 ^ LENGTH('a)" .
248 with True show ?thesis
249 by (simp add: is_signed_positive_def uint_sint take_bit_eq_mod)
253 have "- sint x \<le> 2 ^ (LENGTH('a) - 1)" by simp
254 also have "(2::int) ^ (LENGTH('a) - 1) < 2 ^ LENGTH('a)"
255 by (rule power_strict_increasing) simp_all
256 finally have "- sint x < 2 ^ LENGTH('a)" .
257 then have "- (2 ^ LENGTH('a)) < sint x" by simp
258 moreover from False have "0 < - sint x" by simp
259 ultimately have "- sint x = - sint x mod 2 ^ LENGTH('a)"
261 also have "sint x mod 2 ^ LENGTH('a) \<noteq> 0"
263 assume "sint x mod 2 ^ LENGTH('a) = 0"
264 then obtain y where y: "sint x = y * 2 ^ LENGTH('a)" by auto
265 with False have "\<not> 0 \<le> y" by auto
266 then have "y \<le> - 1" by simp
267 then have "y * 2 ^ LENGTH('a) \<le> - 1 * 2 ^ LENGTH('a)"
268 by (rule mult_right_mono) simp
269 with y have "sint x \<le> - (2 ^ LENGTH('a))" by simp
270 with \<open>- (2 ^ LENGTH('a)) < sint x\<close> show False by simp
272 then have "- sint x mod 2 ^ LENGTH('a) = 2 ^ LENGTH('a) - sint x mod 2 ^ LENGTH('a)"
273 by (simp add: zmod_zminus1_eq_if)
274 finally show ?thesis using False
275 by (simp add: is_signed_positive_def uint_sint take_bit_eq_mod)
278 lemma shiftr_div_2n: "uint (drop_bit n v) = uint v div 2 ^ n"
279 apply (auto simp add: uint_div_distrib uint_pow exp_mod_exp drop_bit_eq_div)
280 apply (rule div_pos_pos_trivial)
282 apply (rule less_le_trans)
283 apply (rule uint_bounded)
285 apply (rule div_pos_pos_trivial)
287 apply (rule less_le_trans)
288 apply (rule uint_bounded)
289 apply (rule power_increasing)
293 lemma shiftl_aux: "uint (push_bit n (v::'a word)) = (uint v * 2 ^ n) mod 2 ^ LENGTH('a::len)"
294 by (auto simp add: uint_word_ariths uint_pow mod_mult_right_eq push_bit_eq_mult)
296 mod_mult_eq [of "uint v", symmetric]
297 power_mod [of 2 2 n, symmetric]
298 power_mult_distrib [symmetric])
300 type_synonym word8 = "8 word"
302 abbreviation (input) max_word :: "'a::len word"
303 where "max_word \<equiv> - 1"
305 why3_open "bv/BV8.xml"
307 zeros=zero_class.zero
325 rotate_left=rotate_left
326 rotate_right=rotate_right
327 rotate_left_bv=rotate_left_bv
328 rotate_right_bv=rotate_right_bv
336 is_signed_positive=is_signed_positive
340 why3_vc nth_out_of_bound
342 by (auto simp add: bv_nth_def dest: bit_imp_le_length)
344 why3_vc Nth_zeros by (simp add: bv_nth_def)
348 by (simp add: bv_nth_def)
352 by (simp add: bv_nth_def bit_and_iff)
356 by (simp add: bv_nth_def bit_or_iff)
360 by (simp add: bv_nth_def bit_xor_iff)
364 by (simp add: bv_nth_def bit_not_iff nat_less_iff)
368 by (simp add: bv_nth_def bit_drop_bit_eq nat_add_distrib add_ac)
372 by (simp add: bv_nth_def bit_drop_bit_eq)
373 (simp add: bit_word.rep_eq nat_add_distrib [symmetric] nat_less_iff)
375 why3_vc lsr_zeros by simp
379 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
380 (auto simp add: nat_add_distrib [symmetric] add_ac)
384 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
385 (auto simp add: nat_add_distrib [symmetric])
387 why3_vc asr_zeros by (simp add: bit_signed_drop_bit_iff)
391 by (simp add: bv_nth_def bit_push_bit_iff nat_diff_distrib nat_less_iff nat_le_eq_zle)
395 by (simp add: bv_nth_def bit_push_bit_iff nat_le_eq_zle)
397 why3_vc lsl_zeros by simp
399 why3_vc to_uint_extensionality using assms by (simp add: word_uint_eq_iff)
401 why3_vc to_intqtdef by (simp add: to_int_eq)
403 why3_vc to_int_extensionality using assms by (simp add: signed_word_eqI)
405 why3_vc positive_is_ge_zeros
406 by (simp add: is_signed_positive_def sge_def)
408 why3_vc to_uint_bounds
409 using uint_ge_0 [of v] uint_bounded [of v]
412 why3_vc to_uint_of_int
414 by (simp add: uint_in_range_def uint_word_of_int)
417 by (simp add: bit_eq_iff bit_and_iff)
418 (simp add: bit_1_iff bit_drop_bit_eq del: bit_0)
420 why3_vc Nth_bv_is_nth
421 by (simp add: bv_nth_def)
423 why3_vc Nth_bv_is_nth2
425 by (simp add: bv_nth_def unat_eq_nat_uint to_uint_of_int uint_in_range_def)
427 why3_vc to_uint_size_bv by (simp add: size_bv_def)
429 why3_vc to_uint_zeros by simp
431 why3_vc to_uint_one by simp
433 why3_vc to_uint_ones by (simp add: uint_word_ariths)
436 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
438 why3_vc to_uint_add_bounded
440 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
443 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
445 why3_vc to_uint_sub_bounded
447 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
450 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
453 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
455 why3_vc to_uint_mul_bounded
457 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
460 by (cases "uint v2 = 0")
461 (auto simp add: uint_div ediv_def)
464 by (simp add: uint_mod emod_def)
466 why3_vc Nth_rotate_left
467 using assms rotl_nth [of "nat n" v "nat i + (size v - nat n mod size v)"]
468 by (simp add: emod_def bv_nth_def word_size nat_minus_mod' int_minus_mod
469 nat_mod_distrib nat_add_distrib nat_diff_distrib del: add_diff_assoc)
471 why3_vc Nth_rotate_right
472 using assms rotr_nth [of "nat n" v "nat i"]
473 by (simp add: emod_def bv_nth_def nat_mod_distrib nat_add_distrib)
475 why3_vc rotate_left_bv_is_rotate_left by simp
477 why3_vc rotate_right_bv_is_rotate_right by simp
479 why3_vc lsr_bv_is_lsr by simp
482 by (simp add: ediv_def shiftr_div_2n)
484 why3_vc asr_bv_is_asr by simp
486 why3_vc lsl_bv_is_lsl by simp
489 by (simp add: emod_def shiftl_aux)
491 why3_vc Extensionality
493 by (simp add: eq_sub_def bv_nth_def bit_eq_iff all_nat)
496 by (simp add: eq_sub_equiv_aux eq_sub_def eq_sub_bv_defn bv_nth_def)
498 why3_vc eq_sub_bv_def
499 by (simp add: eq_sub_bv_defn mask_eq_exp_minus_1)
504 type_synonym word16 = "16 word"
506 why3_open "bv/BV16.xml"
508 zeros=zero_class.zero
526 rotate_left=rotate_left
527 rotate_right=rotate_right
528 rotate_left_bv=rotate_left_bv
529 rotate_right_bv=rotate_right_bv
537 is_signed_positive=is_signed_positive
541 why3_vc nth_out_of_bound
543 by (auto simp add: bv_nth_def dest: bit_imp_le_length)
545 why3_vc Nth_zeros by (simp add: bv_nth_def)
549 by (simp add: bv_nth_def)
553 by (simp add: bv_nth_def bit_and_iff)
557 by (simp add: bv_nth_def bit_or_iff)
561 by (simp add: bv_nth_def bit_xor_iff)
565 by (simp add: bv_nth_def bit_not_iff nat_less_iff)
569 by (simp add: bv_nth_def bit_drop_bit_eq nat_add_distrib add_ac)
573 by (simp add: bv_nth_def bit_drop_bit_eq)
574 (simp add: bit_word.rep_eq nat_add_distrib [symmetric] nat_less_iff)
576 why3_vc lsr_zeros by simp
580 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
581 (auto simp add: nat_add_distrib [symmetric] add_ac)
585 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
586 (auto simp add: nat_add_distrib [symmetric])
588 why3_vc asr_zeros by (simp add: bit_signed_drop_bit_iff)
592 by (simp add: bv_nth_def bit_push_bit_iff nat_diff_distrib nat_less_iff nat_le_eq_zle)
596 by (simp add: bv_nth_def bit_push_bit_iff nat_le_eq_zle)
598 why3_vc lsl_zeros by simp
600 why3_vc to_uint_extensionality using assms by (simp add: word_uint_eq_iff)
602 why3_vc to_intqtdef by (simp add: to_int_eq)
604 why3_vc to_int_extensionality using assms by (simp add: signed_word_eqI)
606 why3_vc positive_is_ge_zeros
607 by (simp add: is_signed_positive_def sge_def)
609 why3_vc to_uint_bounds
610 using uint_ge_0 [of v] uint_bounded [of v]
613 why3_vc to_uint_of_int
615 by (simp add: uint_in_range_def uint_word_of_int)
618 by (simp add: bit_eq_iff bit_and_iff)
619 (simp add: bit_1_iff bit_drop_bit_eq del: bit_0)
621 why3_vc Nth_bv_is_nth
622 by (simp add: bv_nth_def)
624 why3_vc Nth_bv_is_nth2
626 by (simp add: bv_nth_def unat_eq_nat_uint to_uint_of_int uint_in_range_def)
628 why3_vc to_uint_size_bv by (simp add: size_bv_def)
630 why3_vc to_uint_zeros by simp
632 why3_vc to_uint_one by simp
634 why3_vc to_uint_ones by (simp add: uint_word_ariths)
637 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
639 why3_vc to_uint_add_bounded
641 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
644 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
646 why3_vc to_uint_sub_bounded
648 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
651 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
654 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
656 why3_vc to_uint_mul_bounded
658 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
661 by (cases "uint v2 = 0")
662 (auto simp add: uint_div ediv_def)
665 by (simp add: uint_mod emod_def)
667 why3_vc Nth_rotate_left
668 using assms rotl_nth [of "nat n" v "nat i + (size v - nat n mod size v)"]
669 by (simp add: emod_def bv_nth_def word_size nat_minus_mod' int_minus_mod
670 nat_mod_distrib nat_add_distrib nat_diff_distrib del: add_diff_assoc)
672 why3_vc Nth_rotate_right
673 using assms rotr_nth [of "nat n" v "nat i"]
674 by (simp add: emod_def bv_nth_def nat_mod_distrib nat_add_distrib)
676 why3_vc rotate_left_bv_is_rotate_left by simp
678 why3_vc rotate_right_bv_is_rotate_right by simp
680 why3_vc lsr_bv_is_lsr by simp
683 by (simp add: ediv_def shiftr_div_2n)
685 why3_vc asr_bv_is_asr by simp
687 why3_vc lsl_bv_is_lsl by simp
690 by (simp add: emod_def shiftl_aux)
692 why3_vc Extensionality
694 by (simp add: eq_sub_def bv_nth_def bit_eq_iff all_nat)
697 by (simp add: eq_sub_equiv_aux eq_sub_def eq_sub_bv_defn bv_nth_def)
699 why3_vc eq_sub_bv_def
700 by (simp add: eq_sub_bv_defn mask_eq_exp_minus_1)
705 type_synonym word32 = "32 word"
707 why3_open "bv/BV32.xml"
709 zeros=zero_class.zero
727 rotate_left=rotate_left
728 rotate_right=rotate_right
729 rotate_left_bv=rotate_left_bv
730 rotate_right_bv=rotate_right_bv
738 is_signed_positive=is_signed_positive
742 why3_vc nth_out_of_bound
744 by (auto simp add: bv_nth_def dest: bit_imp_le_length)
746 why3_vc Nth_zeros by (simp add: bv_nth_def)
750 by (simp add: bv_nth_def)
754 by (simp add: bv_nth_def bit_and_iff)
758 by (simp add: bv_nth_def bit_or_iff)
762 by (simp add: bv_nth_def bit_xor_iff)
766 by (simp add: bv_nth_def bit_not_iff nat_less_iff)
770 by (simp add: bv_nth_def bit_drop_bit_eq nat_add_distrib add_ac)
774 by (simp add: bv_nth_def bit_drop_bit_eq)
775 (simp add: bit_word.rep_eq nat_add_distrib [symmetric] nat_less_iff)
777 why3_vc lsr_zeros by simp
781 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
782 (auto simp add: nat_add_distrib [symmetric] add_ac)
786 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
787 (auto simp add: nat_add_distrib [symmetric])
789 why3_vc asr_zeros by (simp add: bit_signed_drop_bit_iff)
793 by (simp add: bv_nth_def bit_push_bit_iff nat_diff_distrib nat_less_iff nat_le_eq_zle)
797 by (simp add: bv_nth_def bit_push_bit_iff nat_le_eq_zle)
799 why3_vc lsl_zeros by simp
801 why3_vc to_uint_extensionality using assms by (simp add: word_uint_eq_iff)
803 why3_vc to_intqtdef by (simp add: to_int_eq)
805 why3_vc to_int_extensionality using assms by (simp add: signed_word_eqI)
807 why3_vc positive_is_ge_zeros
808 by (simp add: is_signed_positive_def sge_def)
810 why3_vc to_uint_bounds
811 using uint_ge_0 [of v] uint_bounded [of v]
814 why3_vc to_uint_of_int
816 by (simp add: uint_in_range_def uint_word_of_int)
819 by (simp add: bit_eq_iff bit_and_iff)
820 (simp add: bit_1_iff bit_drop_bit_eq del: bit_0)
822 why3_vc Nth_bv_is_nth
823 by (simp add: bv_nth_def)
825 why3_vc Nth_bv_is_nth2
827 by (simp add: bv_nth_def unat_eq_nat_uint to_uint_of_int uint_in_range_def)
829 why3_vc to_uint_size_bv by (simp add: size_bv_def)
831 why3_vc to_uint_zeros by simp
833 why3_vc to_uint_one by simp
835 why3_vc to_uint_ones by (simp add: uint_word_ariths)
838 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
840 why3_vc to_uint_add_bounded
842 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
845 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
847 why3_vc to_uint_sub_bounded
849 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
852 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
855 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
857 why3_vc to_uint_mul_bounded
859 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
862 by (cases "uint v2 = 0")
863 (auto simp add: uint_div ediv_def)
866 by (simp add: uint_mod emod_def)
868 why3_vc Nth_rotate_left
869 using assms rotl_nth [of "nat n" v "nat i + (size v - nat n mod size v)"]
870 by (simp add: emod_def bv_nth_def word_size nat_minus_mod' int_minus_mod
871 nat_mod_distrib nat_add_distrib nat_diff_distrib del: add_diff_assoc)
873 why3_vc Nth_rotate_right
874 using assms rotr_nth [of "nat n" v "nat i"]
875 by (simp add: emod_def bv_nth_def nat_mod_distrib nat_add_distrib)
877 why3_vc rotate_left_bv_is_rotate_left by simp
879 why3_vc rotate_right_bv_is_rotate_right by simp
881 why3_vc lsr_bv_is_lsr by simp
884 by (simp add: ediv_def shiftr_div_2n)
886 why3_vc asr_bv_is_asr by simp
888 why3_vc lsl_bv_is_lsl by simp
891 by (simp add: emod_def shiftl_aux)
893 why3_vc Extensionality
895 by (simp add: eq_sub_def bv_nth_def bit_eq_iff all_nat)
898 by (simp add: eq_sub_equiv_aux eq_sub_def eq_sub_bv_defn bv_nth_def)
900 why3_vc eq_sub_bv_def
901 by (simp add: eq_sub_bv_defn mask_eq_exp_minus_1)
906 type_synonym word64 = "64 word"
908 why3_open "bv/BV64.xml"
910 zeros=zero_class.zero
928 rotate_left=rotate_left
929 rotate_right=rotate_right
930 rotate_left_bv=rotate_left_bv
931 rotate_right_bv=rotate_right_bv
939 is_signed_positive=is_signed_positive
943 why3_vc nth_out_of_bound
945 by (auto simp add: bv_nth_def dest: bit_imp_le_length)
947 why3_vc Nth_zeros by (simp add: bv_nth_def)
951 by (simp add: bv_nth_def)
955 by (simp add: bv_nth_def bit_and_iff)
959 by (simp add: bv_nth_def bit_or_iff)
963 by (simp add: bv_nth_def bit_xor_iff)
967 by (simp add: bv_nth_def bit_not_iff nat_less_iff)
971 by (simp add: bv_nth_def bit_drop_bit_eq nat_add_distrib add_ac)
975 by (simp add: bv_nth_def bit_drop_bit_eq)
976 (simp add: bit_word.rep_eq nat_add_distrib [symmetric] nat_less_iff)
978 why3_vc lsr_zeros by simp
982 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
983 (auto simp add: nat_add_distrib [symmetric] add_ac)
987 by (simp add: bv_nth_def bit_signed_drop_bit_iff)
988 (auto simp add: nat_add_distrib [symmetric])
990 why3_vc asr_zeros by (simp add: bit_signed_drop_bit_iff)
994 by (simp add: bv_nth_def bit_push_bit_iff nat_diff_distrib nat_less_iff nat_le_eq_zle)
998 by (simp add: bv_nth_def bit_push_bit_iff nat_le_eq_zle)
1000 why3_vc lsl_zeros by simp
1002 why3_vc to_uint_extensionality using assms by (simp add: word_uint_eq_iff)
1004 why3_vc to_intqtdef by (simp add: to_int_eq)
1006 why3_vc to_int_extensionality using assms by (simp add: signed_word_eqI)
1008 why3_vc positive_is_ge_zeros
1009 by (simp add: is_signed_positive_def sge_def)
1011 why3_vc to_uint_bounds
1012 using uint_ge_0 [of v] uint_bounded [of v]
1015 why3_vc to_uint_of_int
1017 by (simp add: uint_in_range_def uint_word_of_int)
1020 by (simp add: bit_eq_iff bit_and_iff)
1021 (simp add: bit_1_iff bit_drop_bit_eq del: bit_0)
1023 why3_vc Nth_bv_is_nth
1024 by (simp add: bv_nth_def)
1026 why3_vc Nth_bv_is_nth2
1028 by (simp add: bv_nth_def unat_eq_nat_uint to_uint_of_int uint_in_range_def)
1030 why3_vc to_uint_size_bv by (simp add: size_bv_def)
1032 why3_vc to_uint_zeros by simp
1034 why3_vc to_uint_one by simp
1036 why3_vc to_uint_ones by (simp add: uint_word_ariths)
1039 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
1041 why3_vc to_uint_add_bounded
1043 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
1046 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
1048 why3_vc to_uint_sub_bounded
1050 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
1053 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
1056 by (simp add: uint_word_arith_bintrs take_bit_eq_mod emod_def)
1058 why3_vc to_uint_mul_bounded
1060 by (simp add: uint_word_arith_bintrs take_bit_eq_mod)
1062 why3_vc to_uint_udiv
1063 by (cases "uint v2 = 0")
1064 (auto simp add: uint_div ediv_def)
1066 why3_vc to_uint_urem
1067 by (simp add: uint_mod emod_def)
1069 why3_vc Nth_rotate_left
1070 using assms rotl_nth [of "nat n" v "nat i + (size v - nat n mod size v)"]
1071 by (simp add: emod_def bv_nth_def word_size nat_minus_mod' int_minus_mod
1072 nat_mod_distrib nat_add_distrib nat_diff_distrib del: add_diff_assoc)
1074 why3_vc Nth_rotate_right
1075 using assms rotr_nth [of "nat n" v "nat i"]
1076 by (simp add: emod_def bv_nth_def nat_mod_distrib nat_add_distrib)
1078 why3_vc rotate_left_bv_is_rotate_left by simp
1080 why3_vc rotate_right_bv_is_rotate_right by simp
1082 why3_vc lsr_bv_is_lsr by simp
1085 by (simp add: ediv_def shiftr_div_2n)
1087 why3_vc asr_bv_is_asr by simp
1089 why3_vc lsl_bv_is_lsl by simp
1092 by (simp add: emod_def shiftl_aux)
1094 why3_vc Extensionality
1096 by (simp add: eq_sub_def bv_nth_def bit_eq_iff all_nat)
1098 why3_vc eq_sub_equiv
1099 by (simp add: eq_sub_equiv_aux eq_sub_def eq_sub_bv_defn bv_nth_def)
1101 why3_vc eq_sub_bv_def
1102 by (simp add: eq_sub_bv_defn mask_eq_exp_minus_1)
1107 why3_open "bv/BVConverter_32_64.xml"
1112 why3_vc toSmall_to_uint
1114 by (simp add: BV64.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1116 why3_vc toBig_to_uint
1117 by (simp add: uint_up_ucast is_up)
1122 why3_open "bv/BVConverter_16_64.xml"
1127 why3_vc toSmall_to_uint
1129 by (simp add: BV64.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1131 why3_vc toBig_to_uint
1132 by (simp add: uint_up_ucast is_up)
1137 why3_open "bv/BVConverter_8_64.xml"
1142 why3_vc toSmall_to_uint
1144 by (simp add: BV64.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1146 why3_vc toBig_to_uint
1147 by (simp add: uint_up_ucast is_up)
1152 why3_open "bv/BVConverter_16_32.xml"
1157 why3_vc toSmall_to_uint
1159 by (simp add: BV32.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1161 why3_vc toBig_to_uint
1162 by (simp add: uint_up_ucast is_up)
1167 why3_open "bv/BVConverter_8_32.xml"
1172 why3_vc toSmall_to_uint
1174 by (simp add: BV32.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1176 why3_vc toBig_to_uint
1177 by (simp add: uint_up_ucast is_up)
1182 why3_open "bv/BVConverter_8_16.xml"
1187 why3_vc toSmall_to_uint
1189 by (simp add: BV16.ule_def ucast_eq uint_word_of_int del: of_int_uint)
1191 why3_vc toBig_to_uint
1192 by (simp add: uint_up_ucast is_up)