@@ -12,6 +12,7 @@ import Mathlib.Data.Nat.Bits
1212import Mathlib.Order.Basic
1313import Mathlib.Tactic.AdaptationNote
1414import 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
284285theorem 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
315299theorem 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
345329theorem 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]
0 commit comments