diff --git a/src/Init/Data/BitVec/Lemmas.lean b/src/Init/Data/BitVec/Lemmas.lean index 77bb33ebbc..d41d236a8a 100644 --- a/src/Init/Data/BitVec/Lemmas.lean +++ b/src/Init/Data/BitVec/Lemmas.lean @@ -303,6 +303,14 @@ theorem toInt_ofNat {n : Nat} (x : Nat) : @[simp] theorem ofInt_natCast (w n : Nat) : BitVec.ofInt w (n : Int) = BitVec.ofNat w n := rfl +theorem toInt_neg_iff {w : Nat} {x : BitVec w} : + BitVec.toInt x < 0 ↔ 2 ^ w ≤ 2 * x.toNat := by + simp [toInt_eq_toNat_cond]; omega + +theorem toInt_pos_iff {w : Nat} {x : BitVec w} : + 0 ≤ BitVec.toInt x ↔ 2 * x.toNat < 2 ^ w := by + simp [toInt_eq_toNat_cond]; omega + /-! ### zeroExtend and truncate -/ theorem truncate_eq_zeroExtend {v : Nat} {x : BitVec w} :