src/HOL/Library/Word.thy
changeset 15067 02be3516e90b
parent 15013 34264f5e4691
child 15131 c69542757a4d
equal deleted inserted replaced
15066:d2f2b908e0a4 15067:02be3516e90b
     7 
     7 
     8 theory Word = Main files "word_setup.ML":
     8 theory Word = Main files "word_setup.ML":
     9 
     9 
    10 subsection {* Auxilary Lemmas *}
    10 subsection {* Auxilary Lemmas *}
    11 
    11 
    12 text {* Amazing that these are necessary, but I can't find equivalent
       
    13 ones in the other HOL theories. *}
       
    14 
       
    15 lemma max_le [intro!]: "[| x \<le> z; y \<le> z |] ==> max x y \<le> z"
    12 lemma max_le [intro!]: "[| x \<le> z; y \<le> z |] ==> max x y \<le> z"
    16   by (simp add: max_def)
    13   by (simp add: max_def)
    17 
    14 
    18 lemma max_mono:
    15 lemma max_mono:
       
    16   fixes x :: "'a::linorder"
    19   assumes mf: "mono f"
    17   assumes mf: "mono f"
    20   shows       "max (f (x::'a::linorder)) (f y) \<le> f (max x y)"
    18   shows       "max (f x) (f y) \<le> f (max x y)"
    21 proof -
    19 proof -
    22   from mf and le_maxI1 [of x y]
    20   from mf and le_maxI1 [of x y]
    23   have fx: "f x \<le> f (max x y)"
    21   have fx: "f x \<le> f (max x y)"
    24     by (rule monoD)
    22     by (rule monoD)
    25   from mf and le_maxI2 [of y x]
    23   from mf and le_maxI2 [of y x]
    28   from fx and fy
    26   from fx and fy
    29   show "max (f x) (f y) \<le> f (max x y)"
    27   show "max (f x) (f y) \<le> f (max x y)"
    30     by auto
    28     by auto
    31 qed
    29 qed
    32 
    30 
    33 lemma le_imp_power_le:
    31 declare zero_le_power [intro]
    34   assumes b0: "0 < (b::nat)"
    32     and zero_less_power [intro]
    35   and     xy: "x \<le> y"
       
    36   shows       "b ^ x \<le> b ^ y"
       
    37 proof (rule ccontr)
       
    38   assume "~ b ^ x \<le> b ^ y"
       
    39   hence bybx: "b ^ y < b ^ x"
       
    40     by simp
       
    41   have "y < x"
       
    42   proof (rule nat_power_less_imp_less [OF _ bybx])
       
    43     from b0
       
    44     show "0 < b"
       
    45       .
       
    46   qed
       
    47   with xy
       
    48   show False
       
    49     by simp
       
    50 qed
       
    51 
       
    52 lemma less_imp_power_less:
       
    53   assumes b1: "1 < (b::nat)"
       
    54   and     xy: "x < y"
       
    55   shows       "b ^ x < b ^ y"
       
    56 proof (rule ccontr)
       
    57   assume "~ b ^ x < b ^ y"
       
    58   hence bybx: "b ^ y \<le> b ^ x"
       
    59     by simp
       
    60   have "y \<le> x"
       
    61   proof (rule power_le_imp_le_exp [OF _ bybx])
       
    62     from b1
       
    63     show "1 < b"
       
    64       .
       
    65   qed
       
    66   with xy
       
    67   show False
       
    68     by simp
       
    69 qed
       
    70 
       
    71 lemma [simp]: "1 < (b::nat) ==> (b ^ x \<le> b ^ y) = (x \<le> y)"
       
    72   apply rule
       
    73   apply (erule power_le_imp_le_exp)
       
    74   apply assumption
       
    75   apply (subgoal_tac "0 < b")
       
    76   apply (erule le_imp_power_le)
       
    77   apply assumption
       
    78   apply simp
       
    79   done
       
    80 
       
    81 lemma [simp]: "1 < (b::nat) ==> (b ^ x < b ^ y) = (x < y)"
       
    82   apply rule
       
    83   apply (subgoal_tac "0 < b")
       
    84   apply (erule nat_power_less_imp_less)
       
    85   apply assumption
       
    86   apply simp
       
    87   apply (erule less_imp_power_less)
       
    88   apply assumption
       
    89   done
       
    90 
       
    91 lemma power_le_imp_zle:
       
    92   assumes b1:   "1 < (b::int)"
       
    93   and     bxby: "b ^ x \<le> b ^ y"
       
    94   shows         "x \<le> y"
       
    95 proof -
       
    96   from b1
       
    97   have nb1: "1 < nat b"
       
    98     by arith
       
    99   from b1
       
   100   have nb0: "0 \<le> b"
       
   101     by simp
       
   102   from bxby
       
   103   have "nat (b ^ x) \<le> nat (b ^ y)"
       
   104     by arith
       
   105   hence "nat b ^ x \<le> nat b ^ y"
       
   106     by (simp add: nat_power_eq [OF nb0])
       
   107   with power_le_imp_le_exp and nb1
       
   108   show "x \<le> y"
       
   109     by auto
       
   110 qed
       
   111 
       
   112 lemma zero_le_zpower [intro]:
       
   113   assumes b0: "0 \<le> (b::int)"
       
   114   shows       "0 \<le> b ^ n"
       
   115 proof (induct n,simp)
       
   116   fix n
       
   117   assume ind: "0 \<le> b ^ n"
       
   118   have "b * 0 \<le> b * b ^ n"
       
   119   proof (subst mult_le_cancel_left,auto intro!: ind)
       
   120     assume "b < 0"
       
   121     with b0
       
   122     show "b ^ n \<le> 0"
       
   123       by simp
       
   124   qed
       
   125   thus "0 \<le> b ^ Suc n"
       
   126     by simp
       
   127 qed
       
   128 
       
   129 lemma zero_less_zpower [intro]:
       
   130   assumes b0: "0 < (b::int)"
       
   131   shows       "0 < b ^ n"
       
   132 proof -
       
   133   from b0
       
   134   have b0': "0 \<le> b"
       
   135     by simp
       
   136   from b0
       
   137   have "0 < nat b"
       
   138     by simp
       
   139   hence "0 < nat b ^ n"
       
   140     by (rule zero_less_power)
       
   141   hence xx: "nat 0 < nat (b ^ n)"
       
   142     by (subst nat_power_eq [OF b0'],simp)
       
   143   show "0 < b ^ n"
       
   144     apply (subst nat_less_eq_zless [symmetric])
       
   145     apply simp
       
   146     apply (rule xx)
       
   147     done
       
   148 qed
       
   149 
       
   150 lemma power_less_imp_zless:
       
   151   assumes b0:   "0 < (b::int)"
       
   152   and     bxby: "b ^ x < b ^ y"
       
   153   shows         "x < y"
       
   154 proof -
       
   155   from b0
       
   156   have nb0: "0 < nat b"
       
   157     by arith
       
   158   from b0
       
   159   have b0': "0 \<le> b"
       
   160     by simp
       
   161   have "nat (b ^ x) < nat (b ^ y)"
       
   162   proof (subst nat_less_eq_zless)
       
   163     show "0 \<le> b ^ x"
       
   164       by (rule zero_le_zpower [OF b0'])
       
   165   next
       
   166     show "b ^ x < b ^ y"
       
   167       by (rule bxby)
       
   168   qed
       
   169   hence "nat b ^ x < nat b ^ y"
       
   170     by (simp add: nat_power_eq [OF b0'])
       
   171   with nat_power_less_imp_less [OF nb0]
       
   172   show "x < y"
       
   173     .
       
   174 qed
       
   175 
       
   176 lemma le_imp_power_zle:
       
   177   assumes b0: "0 < (b::int)"
       
   178   and     xy: "x \<le> y"
       
   179   shows       "b ^ x \<le> b ^ y"
       
   180 proof (rule ccontr)
       
   181   assume "~ b ^ x \<le> b ^ y"
       
   182   hence bybx: "b ^ y < b ^ x"
       
   183     by simp
       
   184   have "y < x"
       
   185   proof (rule power_less_imp_zless [OF _ bybx])
       
   186     from b0
       
   187     show "0 < b"
       
   188       .
       
   189   qed
       
   190   with xy
       
   191   show False
       
   192     by simp
       
   193 qed
       
   194 
       
   195 lemma less_imp_power_zless:
       
   196   assumes b1: "1 < (b::int)"
       
   197   and     xy: "x < y"
       
   198   shows       "b ^ x < b ^ y"
       
   199 proof (rule ccontr)
       
   200   assume "~ b ^ x < b ^ y"
       
   201   hence bybx: "b ^ y \<le> b ^ x"
       
   202     by simp
       
   203   have "y \<le> x"
       
   204   proof (rule power_le_imp_zle [OF _ bybx])
       
   205     from b1
       
   206     show "1 < b"
       
   207       .
       
   208   qed
       
   209   with xy
       
   210   show False
       
   211     by simp
       
   212 qed
       
   213 
       
   214 lemma [simp]: "1 < (b::int) ==> (b ^ x \<le> b ^ y) = (x \<le> y)"
       
   215   apply rule
       
   216   apply (erule power_le_imp_zle)
       
   217   apply assumption
       
   218   apply (subgoal_tac "0 < b")
       
   219   apply (erule le_imp_power_zle)
       
   220   apply assumption
       
   221   apply simp
       
   222   done
       
   223 
       
   224 lemma [simp]: "1 < (b::int) ==> (b ^ x < b ^ y) = (x < y)"
       
   225   apply rule
       
   226   apply (subgoal_tac "0 < b")
       
   227   apply (erule power_less_imp_zless)
       
   228   apply assumption
       
   229   apply simp
       
   230   apply (erule less_imp_power_zless)
       
   231   apply assumption
       
   232   done
       
   233 
       
   234 lemma suc_zero_le: "[| 0 < x ; 0 < y |] ==> Suc 0 < x + y"
       
   235   by simp
       
   236 
    33 
   237 lemma int_nat_two_exp: "2 ^ k = int (2 ^ k)"
    34 lemma int_nat_two_exp: "2 ^ k = int (2 ^ k)"
   238   by (induct k,simp_all)
    35   by (induct k,simp_all)
   239 
    36 
   240 subsection {* Bits *}
    37 subsection {* Bits *}
  1403     apply simp
  1200     apply simp
  1404     apply (rule add_le_less_mono)
  1201     apply (rule add_le_less_mono)
  1405     apply simp
  1202     apply simp
  1406     apply (rule order_trans [of _ 0])
  1203     apply (rule order_trans [of _ 0])
  1407     apply simp
  1204     apply simp
  1408     apply (rule zero_le_zpower,simp)
  1205     apply (rule zero_le_power,simp)
  1409     apply simp
  1206     apply simp
  1410     apply simp
  1207     apply simp
  1411     apply (simp del: bv_to_nat1 bv_to_nat_helper)
  1208     apply (simp del: bv_to_nat1 bv_to_nat_helper)
  1412     apply simp
  1209     apply simp
  1413     done
  1210     done
  1705     by simp
  1502     by simp
  1706   hence "k \<le> length (int_to_bv i) - 1"
  1503   hence "k \<le> length (int_to_bv i) - 1"
  1707     by arith
  1504     by arith
  1708   hence a: "k - 1 \<le> length (int_to_bv i) - 2"
  1505   hence a: "k - 1 \<le> length (int_to_bv i) - 2"
  1709     by arith
  1506     by arith
  1710   have "(2::int) ^ (k - 1) \<le> 2 ^ (length (int_to_bv i) - 2)"
  1507   hence "(2::int) ^ (k - 1) \<le> 2 ^ (length (int_to_bv i) - 2)" by simp
  1711     apply (rule le_imp_power_zle,simp)
       
  1712     apply (rule a)
       
  1713     done
       
  1714   also have "... \<le> i"
  1508   also have "... \<le> i"
  1715   proof -
  1509   proof -
  1716     have "2 ^ (length (norm_signed (int_to_bv i)) - 2) \<le> bv_to_int (int_to_bv i)"
  1510     have "2 ^ (length (norm_signed (int_to_bv i)) - 2) \<le> bv_to_int (int_to_bv i)"
  1717     proof (rule bv_to_int_lower_limit_gt0)
  1511     proof (rule bv_to_int_lower_limit_gt0)
  1718       from w0
  1512       from w0
  1791 lemma length_int_to_bv_lower_limit_gt0:
  1585 lemma length_int_to_bv_lower_limit_gt0:
  1792   assumes wk: "2 ^ (k - 1) \<le> i"
  1586   assumes wk: "2 ^ (k - 1) \<le> i"
  1793   shows       "k < length (int_to_bv i)"
  1587   shows       "k < length (int_to_bv i)"
  1794 proof (rule ccontr)
  1588 proof (rule ccontr)
  1795   have "0 < (2::int) ^ (k - 1)"
  1589   have "0 < (2::int) ^ (k - 1)"
  1796     by (rule zero_less_zpower,simp)
  1590     by (rule zero_less_power,simp)
  1797   also have "... \<le> i"
  1591   also have "... \<le> i"
  1798     by (rule wk)
  1592     by (rule wk)
  1799   finally have i0: "0 < i"
  1593   finally have i0: "0 < i"
  1800     .
  1594     .
  1801   have lii0: "0 < length (int_to_bv i)"
  1595   have lii0: "0 < length (int_to_bv i)"
  1814       by simp
  1608       by simp
  1815     also have "... < 2 ^ (length (int_to_bv i) - 1)"
  1609     also have "... < 2 ^ (length (int_to_bv i) - 1)"
  1816       by (rule bv_to_int_upper_range)
  1610       by (rule bv_to_int_upper_range)
  1817     finally show ?thesis .
  1611     finally show ?thesis .
  1818   qed
  1612   qed
  1819   also have "(2::int) ^ (length (int_to_bv i) - 1) \<le> 2 ^ (k - 1)"
  1613   also have "(2::int) ^ (length (int_to_bv i) - 1) \<le> 2 ^ (k - 1)" using a
  1820     apply (rule le_imp_power_zle,simp)
  1614          by simp
  1821     apply (rule a)
       
  1822     done
       
  1823   finally have "i < 2 ^ (k - 1)" .
  1615   finally have "i < 2 ^ (k - 1)" .
  1824   with wk
  1616   with wk
  1825   show False
  1617   show False
  1826     by simp
  1618     by simp
  1827 qed
  1619 qed
  1849       by (rule bv_to_int_upper_limit_lem1,simp,rule w1)
  1641       by (rule bv_to_int_upper_limit_lem1,simp,rule w1)
  1850     finally show ?thesis by simp
  1642     finally show ?thesis by simp
  1851   qed
  1643   qed
  1852   also have "... \<le> -(2 ^ (k - 1))"
  1644   also have "... \<le> -(2 ^ (k - 1))"
  1853   proof -
  1645   proof -
  1854     have "(2::int) ^ (k - 1) \<le> 2 ^ (length (int_to_bv i) - 2)"
  1646     have "(2::int) ^ (k - 1) \<le> 2 ^ (length (int_to_bv i) - 2)" using a
  1855       apply (rule le_imp_power_zle,simp)
  1647       by simp
  1856       apply (rule a)
       
  1857       done
       
  1858     thus ?thesis
  1648     thus ?thesis
  1859       by simp
  1649       by simp
  1860   qed
  1650   qed
  1861   finally have "i < -(2 ^ (k - 1))" .
  1651   finally have "i < -(2 ^ (k - 1))" .
  1862   with wk
  1652   with wk
  1872   have "i \<le> -(2 ^ (k - 1)) - 1"
  1662   have "i \<le> -(2 ^ (k - 1)) - 1"
  1873     by simp
  1663     by simp
  1874   also have "... < -1"
  1664   also have "... < -1"
  1875   proof -
  1665   proof -
  1876     have "0 < (2::int) ^ (k - 1)"
  1666     have "0 < (2::int) ^ (k - 1)"
  1877       by (rule zero_less_zpower,simp)
  1667       by (rule zero_less_power,simp)
  1878     hence "-((2::int) ^ (k - 1)) < 0"
  1668     hence "-((2::int) ^ (k - 1)) < 0"
  1879       by simp
  1669       by simp
  1880     thus ?thesis by simp
  1670     thus ?thesis by simp
  1881   qed
  1671   qed
  1882   finally have i1: "i < -1" .
  1672   finally have i1: "i < -1" .
  1888   hence "length (int_to_bv i) \<le> k"
  1678   hence "length (int_to_bv i) \<le> k"
  1889     by simp
  1679     by simp
  1890   with lii0
  1680   with lii0
  1891   have a: "length (int_to_bv i) - 1 \<le> k - 1"
  1681   have a: "length (int_to_bv i) - 1 \<le> k - 1"
  1892     by arith
  1682     by arith
  1893   have "(2::int) ^ (length (int_to_bv i) - 1) \<le> 2 ^ (k - 1)"
  1683   hence "(2::int) ^ (length (int_to_bv i) - 1) \<le> 2 ^ (k - 1)" by simp
  1894     apply (rule le_imp_power_zle,simp)
       
  1895     apply (rule a)
       
  1896     done
       
  1897   hence "-((2::int) ^ (k - 1)) \<le> - (2 ^ (length (int_to_bv i) - 1))"
  1684   hence "-((2::int) ^ (k - 1)) \<le> - (2 ^ (length (int_to_bv i) - 1))"
  1898     by simp
  1685     by simp
  1899   also have "... \<le> i"
  1686   also have "... \<le> i"
  1900   proof -
  1687   proof -
  1901     have "- (2 ^ (length (int_to_bv i) - 1)) \<le> bv_to_int (int_to_bv i)"
  1688     have "- (2 ^ (length (int_to_bv i) - 1)) \<le> bv_to_int (int_to_bv i)"
  2001       apply (rule p)
  1788       apply (rule p)
  2002       apply simp
  1789       apply simp
  2003     proof -
  1790     proof -
  2004       have "bv_to_int w < 2 ^ (length w - 1)"
  1791       have "bv_to_int w < 2 ^ (length w - 1)"
  2005 	by (rule bv_to_int_upper_range)
  1792 	by (rule bv_to_int_upper_range)
  2006       also have "... \<le> 2 ^ length w"
  1793       also have "... \<le> 2 ^ length w" by simp
  2007 	by (rule le_imp_power_zle,simp_all)
       
  2008       finally show "bv_to_int w \<le> 2 ^ length w"
  1794       finally show "bv_to_int w \<le> 2 ^ length w"
  2009 	by simp
  1795 	by simp
  2010     qed
  1796     qed
  2011   qed
  1797   qed
  2012 qed
  1798 qed
  2299       proof simp
  2085       proof simp
  2300 	have "?Q < 2 ^ (length w1 - 1) * 2 ^ (length w2 - 1)"
  2086 	have "?Q < 2 ^ (length w1 - 1) * 2 ^ (length w2 - 1)"
  2301 	  apply (rule mult_strict_mono)
  2087 	  apply (rule mult_strict_mono)
  2302 	  apply (rule bv_to_int_upper_range)
  2088 	  apply (rule bv_to_int_upper_range)
  2303 	  apply (rule bv_to_int_upper_range)
  2089 	  apply (rule bv_to_int_upper_range)
  2304 	  apply (rule zero_less_zpower)
  2090 	  apply (rule zero_less_power)
  2305 	  apply simp
  2091 	  apply simp
  2306 	  using bi2
  2092 	  using bi2
  2307 	  apply simp
  2093 	  apply simp
  2308 	  done
  2094 	  done
  2309 	also have "... \<le> 2 ^ (length w1 + length w2 - Suc 0)"
  2095 	also have "... \<le> 2 ^ (length w1 + length w2 - Suc 0)"
  2327 	  apply (rule mult_mono)
  2113 	  apply (rule mult_mono)
  2328 	  using bv_to_int_lower_range [of w1]
  2114 	  using bv_to_int_lower_range [of w1]
  2329 	  apply simp
  2115 	  apply simp
  2330 	  using bv_to_int_lower_range [of w2]
  2116 	  using bv_to_int_lower_range [of w2]
  2331 	  apply simp
  2117 	  apply simp
  2332 	  apply (rule zero_le_zpower,simp)
  2118 	  apply (rule zero_le_power,simp)
  2333 	  using bi2
  2119 	  using bi2
  2334 	  apply simp
  2120 	  apply simp
  2335 	  done
  2121 	  done
  2336 	hence "?Q \<le> 2 ^ (length w1 - 1) * 2 ^(length w2 - 1)"
  2122 	hence "?Q \<le> 2 ^ (length w1 - 1) * 2 ^(length w2 - 1)"
  2337 	  by simp
  2123 	  by simp
  2378 	    apply (rule mult_mono)
  2164 	    apply (rule mult_mono)
  2379 	    using bv_to_int_lower_range [of w2]
  2165 	    using bv_to_int_lower_range [of w2]
  2380 	    apply simp
  2166 	    apply simp
  2381 	    using bv_to_int_upper_range [of w1]
  2167 	    using bv_to_int_upper_range [of w1]
  2382 	    apply simp
  2168 	    apply simp
  2383 	    apply (rule zero_le_zpower,simp)
  2169 	    apply (rule zero_le_power,simp)
  2384 	    using bi1
  2170 	    using bi1
  2385 	    apply simp
  2171 	    apply simp
  2386 	    done
  2172 	    done
  2387 	  hence "-?Q \<le> ((2::int)^(length w1 - 1)) * (2 ^ (length w2 - 1))"
  2173 	  hence "-?Q \<le> ((2::int)^(length w1 - 1)) * (2 ^ (length w2 - 1))"
  2388 	    by (simp add: zmult_ac)
  2174 	    by (simp add: zmult_ac)
  2395 	    apply (rule mult_mono)
  2181 	    apply (rule mult_mono)
  2396 	    using bv_to_int_lower_range [of w1]
  2182 	    using bv_to_int_lower_range [of w1]
  2397 	    apply simp
  2183 	    apply simp
  2398 	    using bv_to_int_upper_range [of w2]
  2184 	    using bv_to_int_upper_range [of w2]
  2399 	    apply simp
  2185 	    apply simp
  2400 	    apply (rule zero_le_zpower,simp)
  2186 	    apply (rule zero_le_power,simp)
  2401 	    using bi2
  2187 	    using bi2
  2402 	    apply simp
  2188 	    apply simp
  2403 	    done
  2189 	    done
  2404 	  hence "-?Q \<le> ((2::int)^(length w1 - 1)) * (2 ^ (length w2 - 1))"
  2190 	  hence "-?Q \<le> ((2::int)^(length w1 - 1)) * (2 ^ (length w2 - 1))"
  2405 	    by (simp add: zmult_ac)
  2191 	    by (simp add: zmult_ac)
  2416 lemma bv_msb_one: "bv_msb w = \<one> ==> 0 < bv_to_nat w"
  2202 lemma bv_msb_one: "bv_msb w = \<one> ==> 0 < bv_to_nat w"
  2417   apply (cases w,simp_all)
  2203   apply (cases w,simp_all)
  2418   apply (subgoal_tac "0 + 0 < 2 ^ length list + bv_to_nat list")
  2204   apply (subgoal_tac "0 + 0 < 2 ^ length list + bv_to_nat list")
  2419   apply simp
  2205   apply simp
  2420   apply (rule add_less_le_mono)
  2206   apply (rule add_less_le_mono)
  2421   apply (rule zero_less_zpower)
  2207   apply (rule zero_less_power)
  2422   apply simp_all
  2208   apply simp_all
  2423   done
  2209   done
  2424 
  2210 
  2425 lemma bv_smult_length_utos: "length (bv_smult (utos w1) w2) \<le> length w1 + length w2"
  2211 lemma bv_smult_length_utos: "length (bv_smult (utos w1) w2) \<le> length w1 + length w2"
  2426 proof -
  2212 proof -
  2453 	have "?Q < 2 ^ length w1 * 2 ^ (length w2 - 1)"
  2239 	have "?Q < 2 ^ length w1 * 2 ^ (length w2 - 1)"
  2454 	  apply (rule mult_strict_mono)
  2240 	  apply (rule mult_strict_mono)
  2455 	  apply (simp add: bv_to_int_utos)
  2241 	  apply (simp add: bv_to_int_utos)
  2456 	  apply (rule bv_to_nat_upper_range)
  2242 	  apply (rule bv_to_nat_upper_range)
  2457 	  apply (rule bv_to_int_upper_range)
  2243 	  apply (rule bv_to_int_upper_range)
  2458 	  apply (rule zero_less_zpower,simp)
  2244 	  apply (rule zero_less_power,simp)
  2459 	  using biw2
  2245 	  using biw2
  2460 	  apply simp
  2246 	  apply simp
  2461 	  done
  2247 	  done
  2462 	also have "... \<le> 2 ^ (length w1 + length w2 - Suc 0)"
  2248 	also have "... \<le> 2 ^ (length w1 + length w2 - Suc 0)"
  2463  	  apply simp
  2249  	  apply simp
  2519 	    using bv_to_int_lower_range [of w2]
  2305 	    using bv_to_int_lower_range [of w2]
  2520 	    apply simp
  2306 	    apply simp
  2521 	    apply (simp add: bv_to_int_utos)
  2307 	    apply (simp add: bv_to_int_utos)
  2522 	    using bv_to_nat_upper_range [of w1]
  2308 	    using bv_to_nat_upper_range [of w1]
  2523 	    apply simp
  2309 	    apply simp
  2524 	    apply (rule zero_le_zpower,simp)
  2310 	    apply (rule zero_le_power,simp)
  2525 	    using bi1
  2311 	    using bi1
  2526 	    apply simp
  2312 	    apply simp
  2527 	    done
  2313 	    done
  2528 	  hence "-?Q \<le> ((2::int)^length w1) * (2 ^ (length w2 - 1))"
  2314 	  hence "-?Q \<le> ((2::int)^length w1) * (2 ^ (length w2 - 1))"
  2529 	    by (simp add: zmult_ac)
  2315 	    by (simp add: zmult_ac)