@@ -1811,7 +1811,7 @@ theorem toNat_pos_of_ne_zero {x : BitVec w} (hx : x ≠ 0#w) :
18111811 omega
18121812
18131813@[simp]
1814- theorem toInt_umod_neg_add {x y : BitVec w} (humod : ¬y.toInt ∣ x.toInt ) (hymsb : y .msb = true ) (hxmsb : x.msb = false ) :
1814+ theorem toInt_umod_neg_add {x y : BitVec w} (hymsb : y.msb = true ) (hxmsb : x .msb = false ) (hdvd : ¬y.toInt ∣ x.toInt ) :
18151815 (x % -y + y).toInt = x.toInt % y.toInt + y.toInt := by
18161816 rcases w with _|w ; simp [of_length_zero]
18171817 have hypos : 0 < y.toNat := toNat_pos_of_ne_zero (by simp [hymsb])
@@ -1820,16 +1820,16 @@ theorem toInt_umod_neg_add {x y : BitVec w} (humod : ¬y.toInt ∣ x.toInt) (hym
18201820 have hylt : (-y).toNat ≤ 2 ^ (w) := toNat_neg_lt y hymsb
18211821 have hmodlt := Nat.mod_lt x.toNat (y := (-y).toNat)
18221822 (by rw [toNat_neg, Nat.mod_eq_of_lt (by omega)]; omega)
1823- simp only [humod , reduceIte, toInt_add, hxnonneg, show ¬0 ≤ y.toInt by omega]
1823+ simp only [hdvd , reduceIte, toInt_add, hxnonneg, show ¬0 ≤ y.toInt by omega]
18241824 rw [toInt_umod, toInt_eq_neg_toNat_neg_of_msb_true hymsb, Int.bmod_add_bmod,
18251825 Int.bmod_eq_of_le (n := (x.toNat : Int) % ((-y).toNat : Int) + -((-y).toNat : Int))
18261826 (m := 2 ^ (w+1 )) (by omega) (by omega),
18271827 toInt_eq_toNat_of_msb hxmsb, Int.emod_neg]
18281828
18291829@[simp]
1830- theorem toInt_sub_neg_umod {x y : BitVec (w + 1 )} (hxmsb : x.msb = true) (hymsb : y.msb = false)
1831- (hx_dvd_y : ¬y.toInt ∣ x.toInt) :
1830+ theorem toInt_sub_neg_umod {x y : BitVec w} (hxmsb : x.msb = true) (hymsb : y.msb = false) (hdvd : ¬y.toInt ∣ x.toInt) :
18321831 (y - -x % y).toInt = x.toInt % y.toInt := by
1832+ rcases w with _|w ; simp [of_length_zero]
18331833 have : y.toNat < 2 ^ w := toNat_lt_of_msb_false hymsb
18341834 by_cases hyzero : y = 0 #(w+1 ); subst hyzero; simp
18351835 simp only [toNat_eq, toNat_ofNat, zero_mod] at hyzero
@@ -1839,8 +1839,8 @@ theorem toInt_sub_neg_umod {x y : BitVec (w + 1)} (hxmsb : x.msb = true) (hymsb
18391839 have hmodlt := Nat.mod_lt (x := (-x).toNat) (y := y.toNat) hypos
18401840 rw [Int.bmod_eq_of_le (by omega) (by omega)]
18411841 simp only [toInt_eq_toNat_of_msb hymsb, BitVec.toInt_eq_neg_toNat_neg_of_msb_true hxmsb,
1842- Int.dvd_neg] at hx_dvd_y
1843- simp only [hx_dvd_y ]
1842+ Int.dvd_neg] at hdvd
1843+ simp only [hdvd ]
18441844 simp
18451845
18461846theorem toInt_smod {x y : BitVec w} :
0 commit comments