@@ -365,96 +365,99 @@ theorem testBit_lnot : ∀ n k, testBit (lnot n) k = not (testBit n k)
365
365
#align int.test_bit_lnot Int.testBit_lnot
366
366
367
367
@[simp]
368
- theorem shiftl_neg (m n : ℤ) : shiftl m (-n) = shiftr m n :=
368
+ theorem shiftLeft_neg (m n : ℤ) : m <<< (-n) = m >>> n :=
369
369
rfl
370
- #align int.shiftl_neg Int.shiftl_neg
370
+ #align int.shiftl_neg Int.shiftLeft_neg
371
371
372
372
@[simp]
373
- theorem shiftr_neg (m n : ℤ) : shiftr m (-n) = shiftl m n := by rw [← shiftl_neg , neg_neg]
374
- #align int.shiftr_neg Int.shiftr_neg
373
+ theorem shiftRight_neg (m n : ℤ) : m >>> (-n) = m <<< n := by rw [← shiftLeft_neg , neg_neg]
374
+ #align int.shiftr_neg Int.shiftRight_neg
375
375
376
376
-- Porting note: what's the correct new name?
377
377
@[simp]
378
- theorem shiftl_coe_nat (m n : ℕ) : shiftl m n = m <<< n :=
379
- by simp [shiftl ]
380
- #align int.shiftl_coe_nat Int.shiftl_coe_nat
378
+ theorem shiftLeft_coe_nat (m n : ℕ) : (m : ℤ) <<< (n : ℤ) = ↑( m <<< n) :=
379
+ by simp [instShiftLeftInt, HShiftLeft.hShiftLeft ]
380
+ #align int.shiftl_coe_nat Int.shiftLeft_coe_nat
381
381
382
382
-- Porting note: what's the correct new name?
383
383
@[simp]
384
- theorem shiftr_coe_nat (m n : ℕ) : shiftr m n = m >>> n := by cases n <;> rfl
385
- #align int.shiftr_coe_nat Int.shiftr_coe_nat
384
+ theorem shiftRight_coe_nat (m n : ℕ) : (m : ℤ) >>> (n : ℤ) = m >>> n := by cases n <;> rfl
385
+ #align int.shiftr_coe_nat Int.shiftRight_coe_nat
386
386
387
387
@[simp]
388
- theorem shiftl_negSucc (m n : ℕ) : shiftl -[m+1 ] n = -[Nat.shiftLeft' true m n+1 ] :=
388
+ theorem shiftLeft_negSucc (m n : ℕ) : -[m+1 ] <<< (n : ℤ) = -[Nat.shiftLeft' true m n+1 ] :=
389
389
rfl
390
- #align int.shiftl_neg_succ Int.shiftl_negSucc
390
+ #align int.shiftl_neg_succ Int.shiftLeft_negSucc
391
391
392
392
@[simp]
393
- theorem shiftr_negSucc (m n : ℕ) : shiftr -[m+1 ] n = -[m >>> n+1 ] := by cases n <;> rfl
394
- #align int.shiftr_neg_succ Int.shiftr_negSucc
393
+ theorem shiftRight_negSucc (m n : ℕ) : -[m+1 ] >>> (n : ℤ) = -[m >>> n+1 ] := by cases n <;> rfl
394
+ #align int.shiftr_neg_succ Int.shiftRight_negSucc
395
395
396
- theorem shiftr_add : ∀ (m : ℤ) (n k : ℕ), shiftr m (n + k) = shiftr (shiftr m n) k
396
+ theorem shiftRight_add : ∀ (m : ℤ) (n k : ℕ), m >>> (n + k : ℤ ) = (m >>> (n : ℤ)) >>> (k : ℤ)
397
397
| (m : ℕ), n, k => by
398
- rw [shiftr_coe_nat, shiftr_coe_nat, ← Int.ofNat_add, shiftr_coe_nat, Nat.shiftRight_add]
398
+ rw [shiftRight_coe_nat, shiftRight_coe_nat, ← Int.ofNat_add, shiftRight_coe_nat,
399
+ Nat.shiftRight_add]
399
400
| -[m+1 ], n, k => by
400
- rw [shiftr_negSucc, shiftr_negSucc, ← Int.ofNat_add, shiftr_negSucc, Nat.shiftRight_add]
401
- #align int.shiftr_add Int.shiftr_add
401
+ rw [shiftRight_negSucc, shiftRight_negSucc, ← Int.ofNat_add, shiftRight_negSucc,
402
+ Nat.shiftRight_add]
403
+ #align int.shiftr_add Int.shiftRight_add
402
404
403
405
/-! ### bitwise ops -/
404
406
405
407
attribute [local simp] Int.zero_div
406
408
407
- theorem shiftl_add : ∀ (m : ℤ) (n : ℕ) (k : ℤ), shiftl m (n + k) = shiftl (shiftl m n) k
409
+ theorem shiftLeft_add : ∀ (m : ℤ) (n : ℕ) (k : ℤ), m <<< (n + k) = (m <<< (n : ℤ)) <<< k
408
410
| (m : ℕ), n, (k : ℕ) =>
409
411
congr_arg ofNat (by simp [Nat.pow_add, mul_assoc])
410
412
| -[m+1 ], n, (k : ℕ) => congr_arg negSucc (Nat.shiftLeft'_add _ _ _ _)
411
413
| (m : ℕ), n, -[k+1 ] =>
412
- subNatNat_elim n k.succ (fun n k i => shiftl (↑m) i = (Nat.shiftLeft' false m n) >>> k)
414
+ subNatNat_elim n k.succ (fun n k i => (↑m) <<< i = (Nat.shiftLeft' false m n) >>> k)
413
415
(fun (i n : ℕ) =>
414
416
by dsimp; simp [- Nat.shiftLeft_eq, ← Nat.shiftLeft_sub _ , add_tsub_cancel_left])
415
- fun i n =>
416
- by dsimp; simp [- Nat.shiftLeft_eq, Nat.shiftLeft_zero, Nat.shiftRight_add,
417
- ← Nat.shiftLeft_sub, shiftl]
417
+ fun i n => by
418
+ dsimp
419
+ simp [- Nat.shiftLeft_eq, Nat.shiftLeft_zero, Nat.shiftRight_add, ← Nat.shiftLeft_sub]
420
+ rfl
418
421
| -[m+1 ], n, -[k+1 ] =>
419
422
subNatNat_elim n k.succ
420
- (fun n k i => shiftl -[m+1 ] i = -[(Nat.shiftLeft' true m n) >>> k+1 ])
423
+ (fun n k i => -[m+1 ] <<< i = -[(Nat.shiftLeft' true m n) >>> k+1 ])
421
424
(fun i n =>
422
425
congr_arg negSucc <| by
423
426
rw [← Nat.shiftLeft'_sub, add_tsub_cancel_left]; apply Nat.le_add_right)
424
427
fun i n =>
425
428
congr_arg negSucc <| by rw [add_assoc, Nat.shiftRight_add, ← Nat.shiftLeft'_sub, tsub_self]
426
429
<;> rfl
427
- #align int.shiftl_add Int.shiftl_add
430
+ #align int.shiftl_add Int.shiftLeft_add
428
431
429
- theorem shiftl_sub (m : ℤ) (n : ℕ) (k : ℤ) : shiftl m (n - k) = shiftr (shiftl m n) k :=
430
- shiftl_add _ _ _
431
- #align int.shiftl_sub Int.shiftl_sub
432
+ theorem shiftLeft_sub (m : ℤ) (n : ℕ) (k : ℤ) : m <<< (n - k) = (m <<< (n : ℤ)) >>> k :=
433
+ shiftLeft_add _ _ _
434
+ #align int.shiftl_sub Int.shiftLeft_sub
432
435
433
- theorem shiftl_eq_mul_pow : ∀ (m : ℤ) (n : ℕ), shiftl m n = m * ↑(2 ^ n)
436
+ theorem shiftLeft_eq_mul_pow : ∀ (m : ℤ) (n : ℕ), m <<< (n : ℤ) = m * ↑(2 ^ n)
434
437
| (m : ℕ), _ => congr_arg ((↑) : ℕ → ℤ) (by simp)
435
438
| -[_+1 ], _ => @congr_arg ℕ ℤ _ _ (fun i => -i) (Nat.shiftLeft'_tt_eq_mul_pow _ _)
436
- #align int.shiftl_eq_mul_pow Int.shiftl_eq_mul_pow
439
+ #align int.shiftl_eq_mul_pow Int.shiftLeft_eq_mul_pow
437
440
438
- theorem shiftr_eq_div_pow : ∀ (m : ℤ) (n : ℕ), shiftr m n = m / ↑(2 ^ n)
439
- | (m : ℕ), n => by rw [shiftr_coe_nat , Nat.shiftRight_eq_div_pow _ _]; simp
441
+ theorem shiftRight_eq_div_pow : ∀ (m : ℤ) (n : ℕ), m >>> (n : ℤ) = m / ↑(2 ^ n)
442
+ | (m : ℕ), n => by rw [shiftRight_coe_nat , Nat.shiftRight_eq_div_pow _ _]; simp
440
443
| -[m+1 ], n => by
441
- rw [shiftr_negSucc , negSucc_ediv, Nat.shiftRight_eq_div_pow]; rfl
444
+ rw [shiftRight_negSucc , negSucc_ediv, Nat.shiftRight_eq_div_pow]; rfl
442
445
exact ofNat_lt_ofNat_of_lt (pow_pos (by decide) _)
443
- #align int.shiftr_eq_div_pow Int.shiftr_eq_div_pow
446
+ #align int.shiftr_eq_div_pow Int.shiftRight_eq_div_pow
444
447
445
- theorem one_shiftl (n : ℕ) : shiftl 1 n = (2 ^ n : ℕ) :=
448
+ theorem one_shiftLeft (n : ℕ) : 1 <<< (n : ℤ) = (2 ^ n : ℕ) :=
446
449
congr_arg ((↑) : ℕ → ℤ) (by simp)
447
- #align int.one_shiftl Int.one_shiftl
450
+ #align int.one_shiftl Int.one_shiftLeft
448
451
449
452
@[simp]
450
- theorem zero_shiftl : ∀ n : ℤ, shiftl 0 n = 0
453
+ theorem zero_shiftLeft : ∀ n : ℤ, 0 <<< n = 0
451
454
| (n : ℕ) => congr_arg ((↑) : ℕ → ℤ) (by simp)
452
455
| -[_+1 ] => congr_arg ((↑) : ℕ → ℤ) (by simp)
453
- #align int.zero_shiftl Int.zero_shiftl
456
+ #align int.zero_shiftl Int.zero_shiftLeft
454
457
455
458
@[simp]
456
- theorem zero_shiftr (n) : shiftr 0 n = 0 :=
457
- zero_shiftl _
458
- #align int.zero_shiftr Int.zero_shiftr
459
+ theorem zero_shiftRight (n : ℤ) : 0 >>> n = 0 :=
460
+ zero_shiftLeft _
461
+ #align int.zero_shiftr Int.zero_shiftRight
459
462
460
463
end Int
0 commit comments