Skip to content

Commit 0276568

Browse files
committed
chore(Data/Nat/Bitwise) deprecate upstreamed lemma 'bitwise_lt' (#20284)
Replaces `bitwise_lt` with a deprecated alias to [`bitwise_lt_two_pow`](https://github.com/leanprover/lean4/blob/fe45ddd6105078a0a3bd855e5d94673e794f6b88/src/Init/Data/Nat/Bitwise/Lemmas.lean#L428-L453), which was added to core in leanprover/lean4@ca94124. Found by [`tryAtEachStep`](https://github.com/dwrensha/tryAtEachStep).
1 parent 5cd69ff commit 0276568

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

Mathlib/Data/Nat/Bitwise.lean

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -368,29 +368,15 @@ theorem even_xor {m n : ℕ} : Even (m ^^^ n) ↔ (Even m ↔ Even n) := by
368368
@[simp] theorem bit_lt_two_pow_succ_iff {b x n} : bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n := by
369369
cases b <;> simp <;> omega
370370

371-
/-- If `x` and `y` fit within `n` bits, then the result of any bitwise operation on `x` and `y` also
372-
fits within `n` bits -/
373-
theorem bitwise_lt {f x y n} (hx : x < 2 ^ n) (hy : y < 2 ^ n) :
374-
bitwise f x y < 2 ^ n := by
375-
induction x using Nat.binaryRec' generalizing n y with
376-
| z =>
377-
simp only [bitwise_zero_left]
378-
split <;> assumption
379-
| @f bx nx hnx ih =>
380-
cases y using Nat.binaryRec' with
381-
| z =>
382-
simp only [bitwise_zero_right]
383-
split <;> assumption
384-
| f «by» ny hny =>
385-
rw [bitwise_bit' _ _ _ _ hnx hny]
386-
cases n <;> simp_all
371+
@[deprecated bitwise_lt_two_pow (since := "2024-12-28")]
372+
alias bitwise_lt := bitwise_lt_two_pow
387373

388374
lemma shiftLeft_lt {x n m : ℕ} (h : x < 2 ^ n) : x <<< m < 2 ^ (n + m) := by
389375
simp only [Nat.pow_add, shiftLeft_eq, Nat.mul_lt_mul_right (Nat.two_pow_pos _), h]
390376

391377
/-- Note that the LHS is the expression used within `Std.BitVec.append`, hence the name. -/
392378
lemma append_lt {x y n m} (hx : x < 2 ^ n) (hy : y < 2 ^ m) : y <<< n ||| x < 2 ^ (n + m) := by
393-
apply bitwise_lt
379+
apply bitwise_lt_two_pow
394380
· rw [add_comm]; apply shiftLeft_lt hy
395381
· apply lt_of_lt_of_le hx <| Nat.pow_le_pow_right (le_succ _) (le_add_right _ _)
396382

0 commit comments

Comments
 (0)