Skip to content

Commit f57201f

Browse files
committed
chore: deduplicate inv_mul_cancel/mul_inv_cancel, etc. (#15717)
* `mul_left_inv`, `inv_mul_self` → `inv_mul_cancel` (for `Group`) * `mul_right_inv`, `mul_inv_self` → `mul_inv_cancel` * `add_left_neg`, `neg_add_self` → `neg_add_cancel` (for `AddGroup`) * `add_right_neg`, `add_neg_self` → `add_neg_cancel` * `inv_mul_cancel` → `inv_mul_cancel₀` (for `GroupWithZero`) * `mul_inv_cancel` → `mul_inv_cancel₀`
1 parent 9bb9d9e commit f57201f

File tree

412 files changed

+930
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

412 files changed

+930
-925
lines changed

Archive/Imo/Imo2008Q3.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ theorem p_lemma (p : ℕ) (hpp : Nat.Prime p) (hp_mod_4_eq_1 : p ≡ 1 [MOD 4])
4343
simp only [n, Int.natAbs_sq, Int.natCast_pow, Int.ofNat_succ, Int.natCast_dvd_natCast.mp]
4444
refine (ZMod.intCast_zmod_eq_zero_iff_dvd (m ^ 2 + 1) p).mp ?_
4545
simp only [m, Int.cast_pow, Int.cast_add, Int.cast_one, ZMod.coe_valMinAbs]
46-
rw [pow_two, ← hy]; exact add_left_neg 1
46+
rw [pow_two, ← hy]; exact neg_add_cancel 1
4747
have hnat₂ : n ≤ p / 2 := ZMod.natAbs_valMinAbs_le y
4848
have hnat₃ : p ≥ 2 * n := by linarith [Nat.div_mul_le_self p 2]
4949
set k : ℕ := p - 2 * n with hnat₄

Archive/Imo/Imo2024Q2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ lemma ab_add_one_dvd_a_pow_large_n_add_b : a * b + 1 ∣ a ^ h.large_n + b := by
136136
(IsUnit.mul_right_eq_zero (ZMod.unitOfCoprime _ a_coprime_ab_add_one).isUnit).1 this
137137
rw [mul_add]
138138
norm_cast
139-
simp only [mul_right_inv, Units.val_one, ZMod.coe_unitOfCoprime]
139+
simp only [mul_inv_cancel, Units.val_one, ZMod.coe_unitOfCoprime]
140140
norm_cast
141141
convert ZMod.natCast_self (a * b + 1) using 2
142142
exact add_comm _ _

Archive/Imo/Imo2024Q6.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ lemma Aquaesulian.apply_zero : f 0 = 0 := by
6262
@[simp]
6363
lemma Aquaesulian.apply_neg_apply_add (x : G) : f (-(f x)) + x = 0 := by
6464
rcases h x (-(f x)) with hc | hc
65-
· rw [add_right_neg, ← h.apply_zero] at hc
65+
· rw [add_neg_cancel, ← h.apply_zero] at hc
6666
exact h.injective hc
67-
· rw [add_right_neg, h.apply_zero] at hc
67+
· rw [add_neg_cancel, h.apply_zero] at hc
6868
exact hc.symm
6969

7070
@[simp]

Archive/Wiedijk100Theorems/AreaOfACircle.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ theorem area_disc : volume (disc r) = NNReal.pi * r ^ 2 := by
113113
ring
114114
· suffices -(1 : ℝ) < (r : ℝ)⁻¹ * x by exact this.ne'
115115
calc
116-
-(1 : ℝ) = (r : ℝ)⁻¹ * -r := by simp [inv_mul_cancel hlt.ne']
116+
-(1 : ℝ) = (r : ℝ)⁻¹ * -r := by simp [inv_mul_cancel hlt.ne']
117117
_ < (r : ℝ)⁻¹ * x := by nlinarith [inv_pos.mpr hlt]
118118
· suffices (r : ℝ)⁻¹ * x < 1 by exact this.ne
119119
calc
120120
(r : ℝ)⁻¹ * x < (r : ℝ)⁻¹ * r := by nlinarith [inv_pos.mpr hlt]
121-
_ = 1 := inv_mul_cancel hlt.ne'
121+
_ = 1 := inv_mul_cancel hlt.ne'
122122
· nlinarith
123123
have hcont : ContinuousOn F (Icc (-r) r) := (by continuity : Continuous F).continuousOn
124124
calc
125125
∫ x in -r..r, 2 * f x = F r - F (-r) :=
126126
integral_eq_sub_of_hasDerivAt_of_le (neg_le_self r.2) hcont hderiv
127127
(continuous_const.mul hf).continuousOn.intervalIntegrable
128128
_ = NNReal.pi * (r : ℝ) ^ 2 := by
129-
norm_num [F, inv_mul_cancel hlt.ne', ← mul_div_assoc, mul_comm π]
129+
norm_num [F, inv_mul_cancel hlt.ne', ← mul_div_assoc, mul_comm π]
130130

131131
end Theorems100

Archive/Wiedijk100Theorems/BuffonsNeedle.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ lemma integral_min_eq_two_mul :
285285
rw [← intervalIntegral.integral_add_adjacent_intervals (b := π / 2) (c := π)]
286286
conv => lhs; arg 2; arg 1; intro θ; rw [← neg_neg θ, Real.sin_neg]
287287
· simp_rw [intervalIntegral.integral_comp_neg fun θ => min d (-θ.sin * l), ← Real.sin_add_pi,
288-
intervalIntegral.integral_comp_add_right (fun θ => min d (θ.sin * l)), add_left_neg,
288+
intervalIntegral.integral_comp_add_right (fun θ => min d (θ.sin * l)), neg_add_cancel,
289289
(by ring : -(π / 2) + π = π / 2), two_mul]
290290
all_goals exact intervalIntegrable_min_const_sin_mul d l _ _
291291

Counterexamples/SorgenfreyLine.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ theorem not_separatedNhds_rat_irrational_antidiag :
278278
`Ico x (x + k⁻¹) ×ˢ Ico (-x) (-x + k⁻¹) ⊆ V`. -/
279279
have : ∀ x : ℝₗ, Irrational (toReal x) →
280280
∃ k : ℕ+, Ico x (x + (k : ℝₗ)⁻¹) ×ˢ Ico (-x) (-x + (k : ℝₗ)⁻¹) ⊆ V := fun x hx ↦ by
281-
have hV : V ∈ 𝓝 (x, -x) := Vo.mem_nhds (@TV (x, -x) ⟨add_neg_self x, hx⟩)
281+
have hV : V ∈ 𝓝 (x, -x) := Vo.mem_nhds (@TV (x, -x) ⟨add_neg_cancel x, hx⟩)
282282
exact (nhds_prod_antitone_basis_inv_pnat _ _).mem_iff.1 hV
283283
choose! k hkV using this
284284
/- Since the set of irrational numbers is a dense Gδ set in the usual topology of `ℝ`, there
@@ -294,7 +294,7 @@ theorem not_separatedNhds_rat_irrational_antidiag :
294294
/- Choose a rational number `r` in the interior of the closure of `C N`, then choose `n ≥ N > 0`
295295
such that `Ico r (r + n⁻¹) × Ico (-r) (-r + n⁻¹) ⊆ U`. -/
296296
rcases Rat.denseRange_cast.exists_mem_open isOpen_interior hN with ⟨r, hr⟩
297-
have hrU : ((r, -r) : ℝₗ × ℝₗ) ∈ U := @SU (r, -r) ⟨add_neg_self _, r, rfl⟩
297+
have hrU : ((r, -r) : ℝₗ × ℝₗ) ∈ U := @SU (r, -r) ⟨add_neg_cancel _, r, rfl⟩
298298
obtain ⟨n, hnN, hn⟩ :
299299
∃ n, N ≤ n ∧ Ico (r : ℝₗ) (r + (n : ℝₗ)⁻¹) ×ˢ Ico (-r : ℝₗ) (-r + (n : ℝₗ)⁻¹) ⊆ U :=
300300
((nhds_prod_antitone_basis_inv_pnat _ _).hasBasis_ge N).mem_iff.1 (Uo.mem_nhds hrU)

Mathlib/Algebra/AddTorsor.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ
146146
as subtracting the points and subtracting that group element. -/
147147
theorem vsub_vadd_eq_vsub_sub (p₁ p₂ : P) (g : G) : p₁ -ᵥ (g +ᵥ p₂) = p₁ -ᵥ p₂ - g := by
148148
rw [← add_right_inj (p₂ -ᵥ p₁ : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←
149-
add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]
149+
add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_cancel, zero_sub]
150150

151151
/-- Cancellation subtracting the results of two subtractions. -/
152152
@[simp]

Mathlib/Algebra/Algebra/Equiv.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ instance aut : Group (A₁ ≃ₐ[R] A₁) where
604604
one_mul ϕ := ext fun x => rfl
605605
mul_one ϕ := ext fun x => rfl
606606
inv := symm
607-
mul_left_inv ϕ := ext <| symm_apply_apply ϕ
607+
inv_mul_cancel ϕ := ext <| symm_apply_apply ϕ
608608

609609
theorem aut_mul (ϕ ψ : A₁ ≃ₐ[R] A₁) : ϕ * ψ = ψ.trans ϕ :=
610610
rfl
@@ -714,8 +714,8 @@ def algHomUnitsEquiv (R S : Type*) [CommSemiring R] [Semiring S] [Algebra R S] :
714714
toFun := fun f ↦
715715
{ (f : S →ₐ[R] S) with
716716
invFun := ↑(f⁻¹)
717-
left_inv := (fun x ↦ show (↑(f⁻¹ * f) : S →ₐ[R] S) x = x by rw [inv_mul_self]; rfl)
718-
right_inv := (fun x ↦ show (↑(f * f⁻¹) : S →ₐ[R] S) x = x by rw [mul_inv_self]; rfl) }
717+
left_inv := (fun x ↦ show (↑(f⁻¹ * f) : S →ₐ[R] S) x = x by rw [inv_mul_cancel]; rfl)
718+
right_inv := (fun x ↦ show (↑(f * f⁻¹) : S →ₐ[R] S) x = x by rw [mul_inv_cancel]; rfl) }
719719
invFun := fun f ↦ ⟨f, f.symm, f.comp_symm, f.symm_comp⟩
720720
left_inv := fun _ ↦ rfl
721721
right_inv := fun _ ↦ rfl

Mathlib/Algebra/BigOperators/Fin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ theorem partialProd_right_inv {G : Type*} [Group G] (f : Fin n → G) (i : Fin n
220220
simp only [partialProd_succ, mul_inv_rev, Fin.castSucc_mk]
221221
-- Porting note: was
222222
-- assoc_rw [hi, inv_mul_cancel_left]
223-
rw [← mul_assoc, mul_left_eq_self, mul_assoc, hi, mul_left_inv]
223+
rw [← mul_assoc, mul_left_eq_self, mul_assoc, hi, inv_mul_cancel]
224224

225225
/-- Let `(g₀, g₁, ..., gₙ)` be a tuple of elements in `Gⁿ⁺¹`.
226226
Then if `k < j`, this says `(g₀g₁...gₖ₋₁)⁻¹ * g₀g₁...gₖ = gₖ`.

Mathlib/Algebra/BigOperators/Group/List.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ lemma prod_rotate_eq_one_of_prod_eq_one :
435435
have : n % List.length (a :: l) ≤ List.length (a :: l) := le_of_lt (Nat.mod_lt _ (by simp))
436436
rw [← List.take_append_drop (n % List.length (a :: l)) (a :: l)] at hl
437437
rw [← rotate_mod, rotate_eq_drop_append_take this, List.prod_append, mul_eq_one_iff_inv_eq,
438-
← one_mul (List.prod _)⁻¹, ← hl, List.prod_append, mul_assoc, mul_inv_self, mul_one]
438+
← one_mul (List.prod _)⁻¹, ← hl, List.prod_append, mul_assoc, mul_inv_cancel, mul_one]
439439

440440
end Group
441441

0 commit comments

Comments
 (0)