Skip to content

Commit

Permalink
chore: parentheses and brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
luisacicolini committed Jan 27, 2025
1 parent fc22884 commit 4537011
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Init/Data/BitVec/Bitblast.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,10 @@ theorem saddOverflow_eq {w : Nat} (x y : BitVec w) :
simp only [saddOverflow]
rcases w with _|w
· revert x y; decide
· have := le_toInt x; have := toInt_lt x
have := le_toInt y; have := toInt_lt y
have := toInd_add_toInt_lt_two_pow x y
have := neg_two_pow_le_toInd_add_toInt x y
· have := le_toInt (x := x); have := toInt_lt (x := x)
have := le_toInt (x := y); have := toInt_lt (x := y)
have := toInd_add_toInt_lt_two_pow (x := x) (y := y)
have := neg_two_pow_le_toInd_add_toInt (x := x) (y := y)
have bmod_neg_iff {m : Nat} {x : Int} (h2 : -m ≤ x) (h1 : x < m) :
(x.bmod m) < 0 ↔ (-(m / 2) ≤ x ∧ x < 0) ∨ ((m + 1) / 2 ≤ x) := by
simp only [Int.bmod_def]
Expand Down
16 changes: 8 additions & 8 deletions src/Init/Data/BitVec/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -542,37 +542,37 @@ theorem eq_zero_or_eq_one (a : BitVec 1) : a = 0#1 ∨ a = 1#1 := by
theorem toInt_zero {w : Nat} : (0#w).toInt = 0 := by
simp [BitVec.toInt, show 0 < 2^w by exact Nat.two_pow_pos w]

theorem toInt_lt {w : Nat} (x : BitVec w) : x.toInt < 2 ^ (w - 1) := by
theorem toInt_lt {w : Nat} {x : BitVec w} : x.toInt < 2 ^ (w - 1) := by
simp only [BitVec.toInt]
rcases w with _|w'
· omega
· rw [← Nat.two_pow_pred_add_two_pow_pred (by omega), ← Nat.two_mul, Nat.add_sub_cancel]
simp only [Nat.zero_lt_succ, Nat.mul_lt_mul_left, Int.natCast_mul, Int.Nat.cast_ofNat_Int]
norm_cast; omega

theorem le_toInt {w : Nat} (x : BitVec w) : -2 ^ (w - 1) ≤ x.toInt := by
theorem le_toInt {w : Nat} {x : BitVec w} : -2 ^ (w - 1) ≤ x.toInt := by
simp only [BitVec.toInt]
rcases w with _|w'
· omega
· rw [← Nat.two_pow_pred_add_two_pow_pred (by omega), ← Nat.two_mul, Nat.add_sub_cancel]
simp only [Nat.zero_lt_succ, Nat.mul_lt_mul_left, Int.natCast_mul, Int.Nat.cast_ofNat_Int]
norm_cast; omega

theorem toInd_add_toInt_lt_two_pow (x y : BitVec w) :
theorem toInd_add_toInt_lt_two_pow {x y : BitVec w} :
x.toInt + y.toInt < 2 ^ w := by
rcases w with _|w'
· simp [BitVec.eq_nil x, BitVec.eq_nil y]
· have hx := toInt_lt x
have hy := toInt_lt y
· have hx := toInt_lt (x := x)
have hy := toInt_lt (x := y)
rw [Nat.add_sub_cancel] at hx hy
omega

theorem neg_two_pow_le_toInd_add_toInt (x y : BitVec w) :
theorem neg_two_pow_le_toInd_add_toInt {x y : BitVec w} :
- 2 ^ w ≤ x.toInt + y.toInt := by
rcases w with _|w'
· simp [BitVec.eq_nil x, BitVec.eq_nil y]
· have hx := le_toInt x
have hy := le_toInt y
· have hx := le_toInt (x := x)
have hy := le_toInt (x := y)
rw [Nat.add_sub_cancel] at hx hy
omega

Expand Down

0 comments on commit 4537011

Please sign in to comment.