Skip to content

Commit 6997e03

Browse files
committed
chore: improve simp set to prepare for improved simpNF linter (#24961)
1 parent 59e3b18 commit 6997e03

File tree

9 files changed

+39
-25
lines changed

9 files changed

+39
-25
lines changed

Mathlib/Algebra/BigOperators/Finsupp/Basic.lean

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,15 @@ lemma prod_indicator_index_eq_prod_attach [Zero M] [CommMonoid N]
536536
rw [indicator_of_mem]
537537

538538
@[to_additive (attr := simp)]
539+
lemma prod_attach_index [CommMonoid N] {s : Finset α} (f : α → M) {h : α → M → N} :
540+
∏ x ∈ s.attach, h x (f x) = ∏ x ∈ s, h x (f x) :=
541+
prod_attach _ fun x ↦ h x (f x)
542+
543+
@[to_additive]
539544
lemma prod_indicator_index [Zero M] [CommMonoid N]
540545
{s : Finset α} (f : α → M) {h : α → M → N} (h_zero : ∀ a ∈ s, h a 0 = 1) :
541-
(indicator s (fun x _ ↦ f x)).prod h = ∏ x ∈ s, h x (f x) :=
542-
(prod_indicator_index_eq_prod_attach _ h_zero).trans <| prod_attach _ fun x ↦ h x (f x)
546+
(indicator s (fun x _ ↦ f x)).prod h = ∏ x ∈ s, h x (f x) := by
547+
simp +contextual [h_zero]
543548

544549
@[to_additive]
545550
lemma prod_mul_eq_prod_mul_of_exists [Zero M] [CommMonoid N]

Mathlib/Data/Finset/Card.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ theorem card_pair (h : a ≠ b) : #{a, b} = 2 := by
143143
theorem card_erase_of_mem : a ∈ s → #(s.erase a) = #s - 1 :=
144144
Multiset.card_erase_of_mem
145145

146-
@[simp]
146+
-- @[simp] -- removed because LHS is not in simp normal form
147147
theorem card_erase_add_one : a ∈ s → #(s.erase a) + 1 = #s :=
148148
Multiset.card_erase_add_one
149149

Mathlib/Data/Finset/CastCard.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ variable [DecidableEq α] [AddGroupWithOne R]
3232
/-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$.
3333
This result is casted to any additive group with 1,
3434
so that we don't have to work with `ℕ`-subtraction. -/
35-
@[simp]
35+
-- @[simp] -- removed because LHS is not in simp normal form
3636
theorem cast_card_erase_of_mem (hs : a ∈ s) : (#(s.erase a) : R) = #s - 1 := by
3737
rw [← card_erase_add_one hs, cast_add, cast_one, eq_sub_iff_add_eq]
3838

Mathlib/Data/List/Basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,8 @@ section Erase
11291129

11301130
variable [DecidableEq α]
11311131

1132-
@[simp] theorem length_erase_add_one {a : α} {l : List α} (h : a ∈ l) :
1132+
-- @[simp] -- removed because LHS is not in simp normal form
1133+
theorem length_erase_add_one {a : α} {l : List α} (h : a ∈ l) :
11331134
(l.erase a).length + 1 = l.length := by
11341135
rw [erase_eq_eraseP, length_eraseP_add_one h (decide_eq_true rfl)]
11351136

Mathlib/Data/Multiset/AddSub.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ theorem erase_le_iff_le_cons {s t : Multiset α} {a : α} : s.erase a ≤ t ↔
235235
theorem card_erase_of_mem {a : α} {s : Multiset α} : a ∈ s → card (s.erase a) = pred (card s) :=
236236
Quot.inductionOn s fun _l => length_erase_of_mem
237237

238-
@[simp]
238+
-- @[simp] -- removed because LHS is not in simp normal form
239239
theorem card_erase_add_one {a : α} {s : Multiset α} : a ∈ s → card (s.erase a) + 1 = card s :=
240240
Quot.inductionOn s fun _l => length_erase_add_one
241241

Mathlib/Data/Multiset/FinsetOps.lean

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ theorem ndinter_cons_of_not_mem {a : α} (s : Multiset α) {t : Multiset α} (h
212212
theorem mem_ndinter {s t : Multiset α} {a : α} : a ∈ ndinter s t ↔ a ∈ s ∧ a ∈ t := by
213213
simp [ndinter, mem_filter]
214214

215-
@[simp]
215+
-- simp can prove this once we have `ndinter_eq_inter` and `Nodup.inter` a few lines down.
216216
theorem Nodup.ndinter {s : Multiset α} (t : Multiset α) : Nodup s → Nodup (ndinter s t) :=
217217
Nodup.filter _
218218

@@ -238,6 +238,11 @@ theorem inter_le_ndinter (s t : Multiset α) : s ∩ t ≤ ndinter s t :=
238238
theorem ndinter_eq_inter {s t : Multiset α} (d : Nodup s) : ndinter s t = s ∩ t :=
239239
le_antisymm (le_inter (ndinter_le_left _ _) (ndinter_le_right _ d)) (inter_le_ndinter _ _)
240240

241+
@[simp]
242+
theorem Nodup.inter {s : Multiset α} (t : Multiset α) (d : Nodup s) : Nodup (s ∩ t) := by
243+
rw [← ndinter_eq_inter d]
244+
exact d.filter _
245+
241246
theorem ndinter_eq_zero_iff_disjoint {s t : Multiset α} : ndinter s t = 0 ↔ Disjoint s t := by
242247
rw [← subset_zero]; simp [subset_iff, disjoint_left]
243248

Mathlib/Data/Set/Card.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,20 @@ theorem ncard_le_ncard_insert (a : α) (s : Set α) : s.ncard ≤ (insert a s).n
620620
s.finite_or_infinite.elim (fun h ↦ ?_) (fun h ↦ by (rw [h.ncard]; exact Nat.zero_le _))
621621
rw [ncard_insert_eq_ite h]; split_ifs <;> simp
622622

623-
@[simp] theorem ncard_pair {a b : α} (h : a ≠ b) : ({a, b} : Set α).ncard = 2 := by
624-
rw [ncard_insert_of_not_mem, ncard_singleton]; simpa
623+
theorem ncard_pair {a b : α} (h : a ≠ b) : ({a, b} : Set α).ncard = 2 := by
624+
simp [h]
625625

626-
@[simp] theorem ncard_diff_singleton_add_one {a : α} (h : a ∈ s)
626+
-- removing `@[simp]` because the LHS is not in simp normal form
627+
theorem ncard_diff_singleton_add_one {a : α} (h : a ∈ s)
627628
(hs : s.Finite := by toFinite_tac) : (s \ {a}).ncard + 1 = s.ncard := by
628-
to_encard_tac; rw [hs.cast_ncard_eq, hs.diff.cast_ncard_eq,
629-
encard_diff_singleton_add_one h]
629+
to_encard_tac
630+
rw [hs.cast_ncard_eq, hs.diff.cast_ncard_eq, encard_diff_singleton_add_one h]
630631

631-
@[simp] theorem ncard_diff_singleton_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) :
632-
(s \ {a}).ncard = s.ncard - 1 :=
633-
eq_tsub_of_add_eq (ncard_diff_singleton_add_one h hs)
632+
@[simp] theorem ncard_diff_singleton_of_mem {a : α} (h : a ∈ s) :
633+
(s \ {a}).ncard = s.ncard - 1 := by
634+
rcases s.infinite_or_finite with hs | hs
635+
· simp_all [ncard, Infinite.diff hs (finite_singleton a)]
636+
· exact eq_tsub_of_add_eq (ncard_diff_singleton_add_one h hs)
634637

635638
theorem ncard_diff_singleton_lt_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) :
636639
(s \ {a}).ncard < s.ncard := by
@@ -643,13 +646,10 @@ theorem ncard_diff_singleton_le (s : Set α) (a : α) : (s \ {a}).ncard ≤ s.nc
643646
exact (hs.diff (by simp : Set.Finite {a})).ncard
644647

645648
theorem pred_ncard_le_ncard_diff_singleton (s : Set α) (a : α) : s.ncard - 1 ≤ (s \ {a}).ncard := by
646-
rcases s.finite_or_infinite with hs | hs
647-
· by_cases h : a ∈ s
648-
· rw [ncard_diff_singleton_of_mem h hs]
649-
rw [diff_singleton_eq_self h]
650-
apply Nat.pred_le
651-
convert Nat.zero_le _
652-
rw [hs.ncard]
649+
by_cases h : a ∈ s
650+
· rw [ncard_diff_singleton_of_mem h]
651+
rw [diff_singleton_eq_self h]
652+
apply Nat.pred_le
653653

654654
theorem ncard_exchange {a b : α} (ha : a ∉ s) (hb : b ∈ s) : (insert a (s \ {b})).ncard = s.ncard :=
655655
congr_arg ENat.toNat <| encard_exchange ha hb

Mathlib/Dynamics/PeriodicPts/Defs.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,11 @@ theorem iterate_mem_periodicOrbit (hx : x ∈ periodicPts f) (n : ℕ) :
436436
simp [hx]
437437

438438
@[simp]
439-
theorem self_mem_periodicOrbit (hx : x ∈ periodicPts f) : x ∈ periodicOrbit f x :=
440-
iterate_mem_periodicOrbit hx 0
439+
theorem exists_iterate_apply_eq_of_mem_periodicPts (hx : x ∈ periodicPts f) : ∃ n, f^[n] x = x := by
440+
simpa only [← mem_periodicOrbit_iff hx] using iterate_mem_periodicOrbit hx 0
441+
442+
theorem self_mem_periodicOrbit (hx : x ∈ periodicPts f) : x ∈ periodicOrbit f x := by
443+
simp [hx]
441444

442445
theorem nodup_periodicOrbit : (periodicOrbit f x).Nodup := by
443446
rw [periodicOrbit, Cycle.nodup_coe_iff, List.nodup_map_iff_inj_on List.nodup_range]

Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ theorem lift_ι_apply (f : M →ₗ[R] A) (cond : ∀ m, f m * f m = 0) (x) :
111111
lift R ⟨f, cond⟩ (ι R x) = f x :=
112112
CliffordAlgebra.lift_ι_apply f _ x
113113

114-
@[simp]
114+
-- removing `@[simp]` because the LHS is not in simp normal form
115115
theorem lift_unique (f : M →ₗ[R] A) (cond : ∀ m, f m * f m = 0) (g : ExteriorAlgebra R M →ₐ[R] A) :
116116
g.toLinearMap.comp (ι R) = f ↔ g = lift R ⟨f, cond⟩ :=
117117
CliffordAlgebra.lift_unique f _ _

0 commit comments

Comments
 (0)