Skip to content

Commit cda9a04

Browse files
chore: adaptations for batteries#1441 (#30138)
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: F. G. Dorais <fgdorais@gmail.com>
1 parent ac853c6 commit cda9a04

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

Mathlib/Data/Nat/Bitwise.lean

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Mathlib.Data.Nat.Bits
1212
import Mathlib.Order.Basic
1313
import Mathlib.Tactic.AdaptationNote
1414
import Mathlib.Tactic.Common
15+
import Batteries.Data.Nat.Bitwise
1516

1617
/-!
1718
# Bitwise operations on natural numbers
@@ -283,45 +284,28 @@ theorem land_assoc (n m k : ℕ) : (n &&& m) &&& k = n &&& (m &&& k) := by bitwi
283284

284285
theorem lor_assoc (n m k : ℕ) : (n ||| m) ||| k = n ||| (m ||| k) := by bitwise_assoc_tac
285286

286-
-- These lemmas match `mul_inv_cancel_right` and `mul_inv_cancel_left`.
287-
theorem xor_cancel_right (n m : ℕ) : (m ^^^ n) ^^^ n = m := by
288-
rw [Nat.xor_assoc, Nat.xor_self, xor_zero]
287+
@[deprecated Nat.xor_xor_cancel_right (since := "2025-10-02")]
288+
theorem xor_cancel_right (n m : ℕ) : (m ^^^ n) ^^^ n = m := Nat.xor_xor_cancel_right ..
289289

290-
theorem xor_cancel_left (n m : ℕ) : n ^^^ (n ^^^ m) = m := by
291-
rw [← Nat.xor_assoc, Nat.xor_self, zero_xor]
290+
@[deprecated Nat.xor_xor_cancel_left (since := "2025-10-02")]
291+
theorem xor_cancel_left (n m : ℕ) : n ^^^ (n ^^^ m) = m := Nat.xor_xor_cancel_left ..
292292

293-
theorem xor_right_injective {n : ℕ} : Function.Injective (HXor.hXor n : ℕ → ℕ) := fun m m' h => by
294-
rw [← xor_cancel_left n m, ← xor_cancel_left n m', h]
293+
@[deprecated Nat.xor_eq_zero_iff (since := "2025-10-02")]
294+
theorem xor_eq_zero {n m : ℕ} : n ^^^ m = 0 ↔ n = m := Nat.xor_eq_zero_iff
295295

296-
theorem xor_left_injective {n : ℕ} : Function.Injective fun m => m ^^^ n :=
297-
fun m m' (h : m ^^^ n = m' ^^^ n) => by
298-
rw [← xor_cancel_right n m, ← xor_cancel_right n m', h]
299-
300-
@[simp]
301-
theorem xor_right_inj {n m m' : ℕ} : n ^^^ m = n ^^^ m' ↔ m = m' :=
302-
xor_right_injective.eq_iff
303-
304-
@[simp]
305-
theorem xor_left_inj {n m m' : ℕ} : m ^^^ n = m' ^^^ n ↔ m = m' :=
306-
xor_left_injective.eq_iff
307-
308-
@[simp]
309-
theorem xor_eq_zero {n m : ℕ} : n ^^^ m = 0 ↔ n = m := by
310-
rw [← Nat.xor_self n, xor_right_inj, eq_comm]
311-
312-
theorem xor_ne_zero {n m : ℕ} : n ^^^ m ≠ 0 ↔ n ≠ m :=
313-
xor_eq_zero.not
296+
@[deprecated Nat.xor_ne_zero_iff (since := "2025-10-02")]
297+
theorem xor_ne_zero {n m : ℕ} : n ^^^ m ≠ 0 ↔ n ≠ m := Nat.xor_ne_zero_iff
314298

315299
theorem xor_trichotomy {a b c : ℕ} (h : a ^^^ b ^^^ c ≠ 0) :
316300
b ^^^ c < a ∨ c ^^^ a < b ∨ a ^^^ b < c := by
317301
set v := a ^^^ b ^^^ c with hv
318302
-- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
319303
have hab : a ^^^ b = c ^^^ v := by
320-
rw [Nat.xor_comm c, xor_cancel_right]
304+
rw [Nat.xor_comm c, Nat.xor_xor_cancel_right]
321305
have hbc : b ^^^ c = a ^^^ v := by
322-
rw [← Nat.xor_assoc, xor_cancel_left]
306+
rw [← Nat.xor_assoc, Nat.xor_xor_cancel_left]
323307
have hca : c ^^^ a = b ^^^ v := by
324-
rw [hv, Nat.xor_assoc, Nat.xor_comm a, ← Nat.xor_assoc, xor_cancel_left]
308+
rw [hv, Nat.xor_assoc, Nat.xor_comm a, ← Nat.xor_assoc, Nat.xor_xor_cancel_left]
325309
-- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
326310
-- has a one bit at position `i`.
327311
obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit h
@@ -343,7 +327,7 @@ theorem xor_trichotomy {a b c : ℕ} (h : a ^^^ b ^^^ c ≠ 0) :
343327
· simp only [testBit_xor, hi' _ hj, Bool.bne_false]
344328

345329
theorem lt_xor_cases {a b c : ℕ} (h : a < b ^^^ c) : a ^^^ c < b ∨ a ^^^ b < c := by
346-
obtain ha | hb | hc := xor_trichotomy <| Nat.xor_assoc _ _ _ ▸ xor_ne_zero.2 h.ne
330+
obtain ha | hb | hc := xor_trichotomy <| Nat.xor_assoc _ _ _ ▸ xor_ne_zero_iff.2 h.ne
347331
exacts [(h.asymm ha).elim, Or.inl <| Nat.xor_comm _ _ ▸ hb, Or.inr hc]
348332

349333
@[simp]

Mathlib/SetTheory/Nimber/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ theorem add_nat (a b : ℕ) : ∗a + ∗b = ∗(a ^^^ b) := by
394394
rw [hc', OrderIso.lt_iff_lt, Nat.cast_lt] at hc
395395
obtain h | h := Nat.lt_xor_cases hc
396396
· apply h.ne
397-
simpa [Nat.xor_comm, Nat.xor_cancel_left, ← hc'] using add_nat (c ^^^ b) b
397+
simpa [Nat.xor_comm, Nat.xor_xor_cancel_left, ← hc'] using add_nat (c ^^^ b) b
398398
· apply h.ne
399-
simpa [Nat.xor_comm, Nat.xor_cancel_left, ← hc'] using add_nat a (c ^^^ a)
399+
simpa [Nat.xor_comm, Nat.xor_xor_cancel_left, ← hc'] using add_nat a (c ^^^ a)
400400

401401
end Nimber

lake-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"type": "git",
6666
"subDir": null,
6767
"scope": "leanprover-community",
68-
"rev": "5a4e38939564f38cef2c55051ea24567df6030ad",
68+
"rev": "4f1632ef39c006eee1e4686dce8739d9f2fb3063",
6969
"name": "batteries",
7070
"manifestFile": "lake-manifest.json",
7171
"inputRev": "main",

0 commit comments

Comments
 (0)