Skip to content

Commit

Permalink
Update src/Init/Data/BitVec/Lemmas.lean
Browse files Browse the repository at this point in the history
Co-authored-by: Siddharth <siddu.druid@gmail.com>
  • Loading branch information
mhk119 and bollu authored Oct 27, 2024
1 parent 32e2ec0 commit d74477f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Init/Data/BitVec/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,8 @@ theorem signExtend_eq_setWidth_of_lt (x : BitVec w) {v : Nat} (hv : v ≤ w):
theorem signExtend_eq (x : BitVec w) : x.signExtend w = x := by
rw [signExtend_eq_setWidth_of_lt _ (Nat.le_refl _), setWidth_eq]

theorem toNat_signExtend_of_gt (x : BitVec w) {v : Nat} :
(x.signExtend (w + v)).toNat = x.toNat + (2 ^ (w + v) - 2^w) * (if x.msb then 1 else 0) := by
theorem toNat_signExtend_of_gt (x : BitVec w) {v : Nat} (hv : v >= w):
(x.signExtend v).toNat = x.toNat + (2^v - 2^w) * (if x.msb then 1 else 0) := by
apply Nat.eq_of_testBit_eq
intro i
rw [testBit_toNat, getLsbD_signExtend, Nat.pow_add, ← Nat.mul_sub_one,
Expand Down

0 comments on commit d74477f

Please sign in to comment.