@@ -22,6 +22,10 @@ import Mathlib.Init.Data.Int.Bitwise
22
22
23
23
namespace Int
24
24
25
+ -- In the `Int` namespace, `xor` will inconveniently resolve to `Int.xor`.
26
+ /-- `bxor` denotes the `xor` function, i.e. the exclusive-or function, on type `Bool`. -/
27
+ local notation "bxor" => _root_.xor
28
+
25
29
/-! ### bitwise ops -/
26
30
27
31
@[simp]
@@ -44,8 +48,8 @@ theorem bodd_coe (n : ℕ) : Int.bodd n = Nat.bodd n :=
44
48
#align int.bodd_coe Int.bodd_coe
45
49
46
50
@[simp]
47
- theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = xor m.bodd n.bodd := by
48
- apply subNatNat_elim m n fun m n i => bodd i = xor m.bodd n.bodd <;>
51
+ theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = bxor m.bodd n.bodd := by
52
+ apply subNatNat_elim m n fun m n i => bodd i = bxor m.bodd n.bodd <;>
49
53
intros i j <;>
50
54
simp only [Int.bodd, Int.bodd_coe, Nat.bodd_add] <;>
51
55
cases Nat.bodd i <;> simp
@@ -72,7 +76,7 @@ theorem bodd_neg (n : ℤ) : bodd (-n) = bodd n := by
72
76
#align int.bodd_neg Int.bodd_neg
73
77
74
78
@[simp]
75
- theorem bodd_add (m n : ℤ) : bodd (m + n) = xor (bodd m) (bodd n) := by
79
+ theorem bodd_add (m n : ℤ) : bodd (m + n) = bxor (bodd m) (bodd n) := by
76
80
cases' m with m m <;>
77
81
cases' n with n n <;>
78
82
simp only [ofNat_eq_coe, ofNat_add_negSucc, negSucc_add_ofNat,
@@ -221,13 +225,12 @@ theorem testBit_succ (m b) : ∀ n, testBit (bit b n) (Nat.succ m) = testBit n m
221
225
theorem bitwise_or : bitwise or = lor := by
222
226
funext m n
223
227
cases' m with m m <;> cases' n with n n <;> try {rfl}
224
- <;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true, cond_true, lor, Nat.ldiff' ,
225
- negSucc.injEq, Bool.true_or, Nat.land' ]
226
- · rw [Nat.bitwise'_swap , Function.swap]
228
+ <;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true, cond_true, lor, Nat.ldiff,
229
+ negSucc.injEq, Bool.true_or, Nat.land]
230
+ · rw [Nat.bitwise_swap , Function.swap]
227
231
congr
228
232
funext x y
229
233
cases x <;> cases y <;> rfl
230
- rfl
231
234
· congr
232
235
funext x y
233
236
cases x <;> cases y <;> rfl
@@ -241,45 +244,43 @@ theorem bitwise_and : bitwise and = land := by
241
244
funext m n
242
245
cases' m with m m <;> cases' n with n n <;> try {rfl}
243
246
<;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true,
244
- cond_false, cond_true, lor, Nat.ldiff' , Bool.and_true, negSucc.injEq,
245
- Bool.and_false, Nat.land' ]
246
- · rw [Nat.bitwise'_swap , Function.swap]
247
+ cond_false, cond_true, lor, Nat.ldiff, Bool.and_true, negSucc.injEq,
248
+ Bool.and_false, Nat.land]
249
+ · rw [Nat.bitwise_swap , Function.swap]
247
250
congr
248
251
funext x y
249
252
cases x <;> cases y <;> rfl
250
- rfl
251
253
· congr
252
254
funext x y
253
255
cases x <;> cases y <;> rfl
254
256
#align int.bitwise_and Int.bitwise_and
255
257
256
258
--Porting note : Was `bitwise_tac` in mathlib
257
- theorem bitwise_diff : (bitwise fun a b => a && not b) = ldiff' := by
259
+ theorem bitwise_diff : (bitwise fun a b => a && not b) = ldiff := by
258
260
funext m n
259
261
cases' m with m m <;> cases' n with n n <;> try {rfl}
260
262
<;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true,
261
- cond_false, cond_true, lor, Nat.ldiff' , Bool.and_true, negSucc.injEq,
262
- Bool.and_false, Nat.land' , Bool.not_true, ldiff' , Nat.lor' ]
263
+ cond_false, cond_true, lor, Nat.ldiff, Bool.and_true, negSucc.injEq,
264
+ Bool.and_false, Nat.land, Bool.not_true, ldiff, Nat.lor]
263
265
· congr
264
266
funext x y
265
267
cases x <;> cases y <;> rfl
266
268
· congr
267
269
funext x y
268
270
cases x <;> cases y <;> rfl
269
- · rw [Nat.bitwise'_swap , Function.swap]
271
+ · rw [Nat.bitwise_swap , Function.swap]
270
272
congr
271
273
funext x y
272
274
cases x <;> cases y <;> rfl
273
- rfl
274
275
#align int.bitwise_diff Int.bitwise_diff
275
276
276
277
--Porting note : Was `bitwise_tac` in mathlib
277
- theorem bitwise_xor : bitwise xor = lxor' := by
278
+ theorem bitwise_xor : bitwise bxor = xor := by
278
279
funext m n
279
280
cases' m with m m <;> cases' n with n n <;> try {rfl}
280
- <;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true,
281
- cond_false, cond_true, lor, Nat.ldiff' , Bool.and_true, negSucc.injEq, Bool.false_xor,
282
- Bool.true_xor, Bool.and_false, Nat.land' , Bool.not_true, ldiff' , Nat.lor', lxor' , Nat.lxor' ]
281
+ <;> simp only [bitwise, natBitwise, Bool.not_false, Bool.or_true, Bool.bne_eq_xor,
282
+ cond_false, cond_true, lor, Nat.ldiff, Bool.and_true, negSucc.injEq, Bool.false_xor,
283
+ Bool.true_xor, Bool.and_false, Nat.land, Bool.not_true, ldiff, Nat.lor, xor , Nat.xor ]
283
284
· congr
284
285
funext x y
285
286
cases x <;> cases y <;> rfl
@@ -314,12 +315,12 @@ theorem land_bit (a m b n) : land (bit a m) (bit b n) = bit (a && b) (land m n)
314
315
#align int.land_bit Int.land_bit
315
316
316
317
@[simp]
317
- theorem ldiff_bit (a m b n) : ldiff' (bit a m) (bit b n) = bit (a && not b) (ldiff' m n) := by
318
+ theorem ldiff_bit (a m b n) : ldiff (bit a m) (bit b n) = bit (a && not b) (ldiff m n) := by
318
319
rw [← bitwise_diff, bitwise_bit]
319
320
#align int.ldiff_bit Int.ldiff_bit
320
321
321
322
@[simp]
322
- theorem lxor_bit (a m b n) : lxor' (bit a m) (bit b n) = bit (xor a b) (lxor' m n) := by
323
+ theorem lxor_bit (a m b n) : xor (bit a m) (bit b n) = bit (bxor a b) (xor m n) := by
323
324
rw [← bitwise_xor, bitwise_bit]
324
325
#align int.lxor_bit Int.lxor_bit
325
326
@@ -350,12 +351,12 @@ theorem testBit_land (m n k) : testBit (land m n) k = (testBit m k && testBit n
350
351
#align int.test_bit_land Int.testBit_land
351
352
352
353
@[simp]
353
- theorem testBit_ldiff (m n k) : testBit (ldiff' m n) k = (testBit m k && not (testBit n k)) := by
354
+ theorem testBit_ldiff (m n k) : testBit (ldiff m n) k = (testBit m k && not (testBit n k)) := by
354
355
rw [← bitwise_diff, testBit_bitwise]
355
356
#align int.test_bit_ldiff Int.testBit_ldiff
356
357
357
358
@[simp]
358
- theorem testBit_lxor (m n k) : testBit (lxor' m n) k = xor (testBit m k) (testBit n k) := by
359
+ theorem testBit_lxor (m n k) : testBit (xor m n) k = bxor (testBit m k) (testBit n k) := by
359
360
rw [← bitwise_xor, testBit_bitwise]
360
361
#align int.test_bit_lxor Int.testBit_lxor
361
362
0 commit comments