Skip to content

Commit 0170308

Browse files
committed
toNat
1 parent 1ea8d8a commit 0170308

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,10 +1532,6 @@ theorem signExtend_eq_setWidth_of_lt (x : BitVec w) {v : Nat} (hv : v ≤ w):
15321532
theorem signExtend_eq (x : BitVec w) : x.signExtend w = x := by
15331533
rw [signExtend_eq_setWidth_of_lt _ (Nat.le_refl _), setWidth_eq]
15341534

1535-
example (a b : Nat) (h : a ≤ b) : ∃ k : Nat, b = a + k:= by
1536-
exact Nat.exists_eq_add_of_le h
1537-
1538-
15391535
theorem toNat_signExtend_of_gt (x : BitVec w) {v : Nat} :
15401536
(x.signExtend (w + v)).toNat = x.toNat + (2 ^ (w + v) - 2^w) * (if x.msb then 1 else 0) := by
15411537
apply Nat.eq_of_testBit_eq
@@ -1555,8 +1551,9 @@ theorem toNat_signExtend (x : BitVec w) {v : Nat} :
15551551
· rw [signExtend_eq_setWidth_of_lt _ h, toNat_setWidth]
15561552
simp [Nat.sub_eq_zero_of_le (Nat.pow_le_pow_of_le_right Nat.two_pos h)]
15571553
· have ⟨k, hk⟩ := Nat.exists_eq_add_of_le (Nat.le_of_lt (Nat.lt_of_not_le h))
1554+
have H := Nat.pow_le_pow_of_le_right Nat.two_pos (Nat.le_add_right w k)
15581555
rw [hk, toNat_signExtend_of_gt, toNat_setWidth]
1559-
rw [Nat.mod_eq_of_lt (Nat.lt_of_lt_of_le x.isLt ((Nat.pow_le_pow_of_le_right Nat.two_pos (by simp))))]
1556+
rw [Nat.mod_eq_of_lt (Nat.lt_of_lt_of_le x.isLt H)]
15601557

15611558

15621559
/-! ### append -/

0 commit comments

Comments
 (0)