Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit f7e82d0

Browse files
gebnerrobertylewis
andauthored
feat(tactic/lint): check for redundant simp lemmas (#2066)
* chore(*): fix simp lemmas * feat(tactic/lint): check for redundant simp lemmas Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
1 parent 2d1bd45 commit f7e82d0

Some content is hidden

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

73 files changed

+538
-362
lines changed

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The following linters are run by default:
116116
9. `incorrect_type_class_argument` checks for arguments in [square brackets] that are not classes.
117117
10. `dangerous_instance` checks for instances that generate type-class problems with metavariables.
118118
11. `inhabited_nonempty` checks for `inhabited` instance arguments that should be changed to `nonempty`.
119-
12. `simp_nf` checks that arguments of the left-hand side of simp lemmas are in simp-normal form.
119+
12. `simp_nf` checks that the left-hand side of simp lemmas is in simp-normal form.
120120
13. `simp_var_head` checks that there are no variables as head symbol of left-hand sides of simp lemmas.
121121
14. `simp_comm` checks that no commutativity lemmas (such as `add_comm`) are marked simp.
122122

src/algebra/associated.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ by rw [mul_comm, mul_dvd_of_is_unit_left h]
4949
@[simp] lemma unit_mul_dvd_iff [comm_semiring α] {a b : α} {u : units α} : (u : α) * a ∣ b ↔ a ∣ b :=
5050
mul_dvd_of_is_unit_left (is_unit_unit _)
5151

52-
@[simp] lemma mul_unit_dvd_iff [comm_semiring α] {a b : α} {u : units α} : a * u ∣ b ↔ a ∣ b :=
53-
mul_dvd_of_is_unit_right (is_unit_unit _)
52+
lemma mul_unit_dvd_iff [comm_semiring α] {a b : α} {u : units α} : a * u ∣ b ↔ a ∣ b :=
53+
units.coe_mul_dvd _ _ _
5454

5555
theorem is_unit_of_dvd_unit {α} [comm_semiring α] {x y : α}
5656
(xy : x ∣ y) (hu : is_unit y) : is_unit x :=
@@ -258,9 +258,8 @@ multiset.induction_on s (by simp [mt is_unit_iff_dvd_one.2 hp.not_unit])
258258
lemma dvd_iff_dvd_of_rel_left [comm_semiring α] {a b c : α} (h : a ~ᵤ b) : a ∣ c ↔ b ∣ c :=
259259
let ⟨u, hu⟩ := h in hu ▸ mul_unit_dvd_iff.symm
260260

261-
@[simp] lemma dvd_mul_unit_iff [comm_semiring α] {a b : α} {u : units α} : a ∣ b * u ↔ a ∣ b :=
262-
⟨λ ⟨d, hd⟩, ⟨d * (u⁻¹ : units α), by simp [(mul_assoc _ _ _).symm, hd.symm]⟩,
263-
λ h, dvd.trans h (by simp)⟩
261+
lemma dvd_mul_unit_iff [comm_semiring α] {a b : α} {u : units α} : a ∣ b * u ↔ a ∣ b :=
262+
units.dvd_coe_mul _ _ _
264263

265264
lemma dvd_iff_dvd_of_rel_right [comm_semiring α] {a b c : α} (h : b ~ᵤ c) : a ∣ b ↔ a ∣ c :=
266265
let ⟨u, hu⟩ := h in hu ▸ dvd_mul_unit_iff.symm

src/algebra/big_operators.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ lemma prod_pair [decidable_eq α] {a b : α} (h : a ≠ b) :
5555
({a, b} : finset α).prod f = f a * f b :=
5656
by simp [prod_insert (not_mem_singleton.2 h.symm), mul_comm]
5757

58-
@[simp] lemma prod_const_one : s.prod (λx, (1 : β)) = 1 :=
58+
@[simp, priority 1100] lemma prod_const_one : s.prod (λx, (1 : β)) = 1 :=
5959
by simp only [finset.prod, multiset.map_const, multiset.prod_repeat, one_pow]
60-
@[simp] lemma sum_const_zero {β} {s : finset α} [add_comm_monoid β] : s.sum (λx, (0 : β)) = 0 :=
60+
@[simp, priority 1100] lemma sum_const_zero {β} {s : finset α} [add_comm_monoid β] :
61+
s.sum (λx, (0 : β)) = 0 :=
6162
@prod_const_one _ (multiplicative β) _ _
6263
attribute [to_additive] prod_const_one
6364

src/algebra/category/Group.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def mul_equiv.to_Group_iso [group X] [group Y] (e : X ≃* Y) : Group.of X ≅ G
103103
attribute [simps] mul_equiv.to_Group_iso add_equiv.to_AddGroup_iso
104104

105105
/-- Build an isomorphism in the category `CommGroup` from a `mul_equiv` between `comm_group`s. -/
106-
@[simps, to_additive add_equiv.to_AddCommGroup_iso "Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between `add_comm_group`s."]
106+
@[to_additive add_equiv.to_AddCommGroup_iso "Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between `add_comm_group`s."]
107107
def mul_equiv.to_CommGroup_iso [comm_group X] [comm_group Y] (e : X ≃* Y) : CommGroup.of X ≅ CommGroup.of Y :=
108108
{ hom := e.to_monoid_hom,
109109
inv := e.symm.to_monoid_hom }

src/algebra/char_zero.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cast_injective.eq_iff
5555
@[simp, elim_cast] theorem cast_eq_zero {n : ℕ} : (n : α) = 0 ↔ n = 0 :=
5656
by rw [← cast_zero, cast_inj]
5757

58-
@[simp, elim_cast] theorem cast_ne_zero {n : ℕ} : (n : α) ≠ 0 ↔ n ≠ 0 :=
58+
@[elim_cast] theorem cast_ne_zero {n : ℕ} : (n : α) ≠ 0 ↔ n ≠ 0 :=
5959
not_congr cast_eq_zero
6060

6161
end nat

src/algebra/commute.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ variables {M : Type*} [monoid M]
8282
@[simp] theorem one_right (a : M) : commute a 1 := semiconj_by.one_right a
8383
@[simp] theorem one_left (a : M) : commute 1 a := semiconj_by.one_left a
8484

85-
@[simp] theorem units_inv_right {a : M} {u : units M} : commute a u → commute a ↑u⁻¹ :=
85+
theorem units_inv_right {a : M} {u : units M} : commute a u → commute a ↑u⁻¹ :=
8686
semiconj_by.units_inv_right
8787

8888
@[simp] theorem units_inv_right_iff {a : M} {u : units M} : commute a ↑u⁻¹ ↔ commute a u :=
8989
semiconj_by.units_inv_right_iff
9090

91-
@[simp] theorem units_inv_left {u : units M} {a : M} : commute ↑u a → commute ↑u⁻¹ a :=
91+
theorem units_inv_left {u : units M} {a : M} : commute ↑u a → commute ↑u⁻¹ a :=
9292
semiconj_by.units_inv_symm_left
9393

9494
@[simp] theorem units_inv_left_iff {u : units M} {a : M}: commute ↑u⁻¹ a ↔ commute ↑u a :=
@@ -122,10 +122,10 @@ section group
122122

123123
variables {G : Type*} [group G] {a b : G}
124124

125-
@[simp] theorem inv_right : commute a b → commute a b⁻¹ := semiconj_by.inv_right
125+
theorem inv_right : commute a b → commute a b⁻¹ := semiconj_by.inv_right
126126
@[simp] theorem inv_right_iff : commute a b⁻¹ ↔ commute a b := semiconj_by.inv_right_iff
127127

128-
@[simp] theorem inv_left : commute a b → commute a⁻¹ b := semiconj_by.inv_symm_left
128+
theorem inv_left : commute a b → commute a⁻¹ b := semiconj_by.inv_symm_left
129129
@[simp] theorem inv_left_iff : commute a⁻¹ b ↔ commute a b := semiconj_by.inv_symm_left_iff
130130

131131
theorem inv_inv : commute a b → commute a⁻¹ b⁻¹ := semiconj_by.inv_inv_symm
@@ -186,10 +186,10 @@ section ring
186186

187187
variables {R : Type*} [ring R] {a b c : R}
188188

189-
@[simp] theorem neg_right : commute a b → commute a (- b) := semiconj_by.neg_right
189+
theorem neg_right : commute a b → commute a (- b) := semiconj_by.neg_right
190190
@[simp] theorem neg_right_iff : commute a (-b) ↔ commute a b := semiconj_by.neg_right_iff
191191

192-
@[simp] theorem neg_left : commute a b → commute (- a) b := semiconj_by.neg_left
192+
theorem neg_left : commute a b → commute (- a) b := semiconj_by.neg_left
193193
@[simp] theorem neg_left_iff : commute (-a) b ↔ commute a b := semiconj_by.neg_left_iff
194194

195195
@[simp] theorem neg_one_right (a : R) : commute a (-1) := semiconj_by.neg_one_right a

src/algebra/free.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def lift (x : free_semigroup α) : β :=
252252
lift' f x.1 x.2
253253

254254
@[simp] lemma lift_of (x : α) : lift f (of x) = f x := rfl
255-
@[simp] lemma lift_of_mul (x y) : lift f (of x * y) = f x * lift f y := rfl
255+
lemma lift_of_mul (x y) : lift f (of x * y) = f x * lift f y := rfl
256256

257257
@[simp] lemma lift_mul (x y) : lift f (x * y) = lift f x * lift f y :=
258258
free_semigroup.induction_on x (λ p, rfl)

src/algebra/group/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ theorem mul_right_surjective (a : G) : function.surjective (λ x, x * a) :=
6060
theorem eq_of_inv_eq_inv : a⁻¹ = b⁻¹ → a = b :=
6161
inv_inj'.1
6262

63-
@[simp, to_additive]
63+
@[to_additive]
6464
theorem mul_self_iff_eq_one : a * a = a ↔ a = 1 :=
6565
by have := @mul_left_inj _ _ a a 1; rwa mul_one at this
6666

6767
@[simp, to_additive]
6868
theorem inv_eq_one : a⁻¹ = 1 ↔ a = 1 :=
6969
by rw [← @inv_inj' _ _ a 1, one_inv]
7070

71-
@[simp, to_additive]
71+
@[to_additive]
7272
theorem inv_ne_one : a⁻¹ ≠ 1 ↔ a ≠ 1 :=
7373
not_congr inv_eq_one
7474

src/algebra/group_power.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ by rw [←pow_add, ←pow_add, add_comm]
9898
theorem smul_add_comm : ∀ (a : A) (m n : ℕ), m•a + n•a = n•a + m•a :=
9999
@pow_mul_comm (multiplicative A) _
100100

101-
@[simp] theorem list.prod_repeat (a : M) (n : ℕ) : (list.repeat a n).prod = a ^ n :=
101+
@[simp, priority 500]
102+
theorem list.prod_repeat (a : M) (n : ℕ) : (list.repeat a n).prod = a ^ n :=
102103
by induction n with n ih; [refl, rw [list.repeat_succ, list.prod_cons, ih]]; refl
103-
@[simp] theorem list.sum_repeat : ∀ (a : A) (n : ℕ), (list.repeat a n).sum = n • a :=
104+
@[simp, priority 500]
105+
theorem list.sum_repeat : ∀ (a : A) (n : ℕ), (list.repeat a n).sum = n • a :=
104106
@list.prod_repeat (multiplicative A) _
105107

106108
theorem monoid_hom.map_pow (f : M →* N) (a : M) : ∀(n : ℕ), f (a ^ n) = (f a) ^ n

src/algebra/lie_algebra.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,14 @@ instance (R : Type u) (L : Type v) (L' : Type v)
191191
[comm_ring R] [add_comm_group L] [lie_algebra R L] [add_comm_group L'] [lie_algebra R L'] :
192192
has_coe (L →ₗ⁅R⁆ L') (L →ₗ[R] L') := ⟨morphism.to_linear_map⟩
193193

194-
@[simp] lemma map_lie {R : Type u} {L : Type v} {L' : Type v}
194+
lemma map_lie {R : Type u} {L : Type v} {L' : Type v}
195195
[comm_ring R] [add_comm_group L] [lie_algebra R L] [add_comm_group L'] [lie_algebra R L']
196196
(f : L →ₗ⁅R⁆ L') (x y : L) : f ⁅x, y⁆ = ⁅f x, f y⁆ := morphism.map_lie f
197197

198+
@[simp] lemma map_lie' {R : Type u} {L : Type v} {L' : Type v}
199+
[comm_ring R] [add_comm_group L] [lie_algebra R L] [add_comm_group L'] [lie_algebra R L']
200+
(f : L →ₗ⁅R⁆ L') (x y : L) : (f : L →ₗ[R] L') ⁅x, y⁆ = ⁅f x, f y⁆ := morphism.map_lie f
201+
198202
variables {R : Type u} {L : Type v} [comm_ring R] [add_comm_group L] [lie_algebra R L]
199203

200204
/--

0 commit comments

Comments
 (0)