Skip to content

Commit b2dc94b

Browse files
committed
feat(Algebra/Group/Submonoid/Defs): add OneMemClass.coe_nonempty (leanprover-community#38288)
The main value of this is to make `simp` stronger
1 parent 3794f76 commit b2dc94b

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

Mathlib/Algebra/Group/Subgroup/Defs.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,12 @@ theorem toSubmonoid_mono : Monotone (toSubmonoid : Subgroup G → Submonoid G) :
396396
theorem toSubmonoid_le {p q : Subgroup G} : p.toSubmonoid ≤ q.toSubmonoid ↔ p ≤ q :=
397397
Iff.rfl
398398

399-
@[to_additive (attr := simp)]
399+
@[to_additive]
400400
lemma coe_nonempty (s : Subgroup G) : (s : Set G).Nonempty := ⟨1, one_mem _⟩
401401

402+
attribute [deprecated OneMemClass.coe_nonempty (since := "2026-04-20")] Subgroup.coe_nonempty
403+
attribute [deprecated ZeroMemClass.coe_nonempty (since := "2026-04-20")] AddSubgroup.coe_nonempty
404+
402405
end Subgroup
403406

404407
namespace Subgroup

Mathlib/Algebra/Group/Submonoid/Defs.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ attribute [to_additive] OneMemClass
7676

7777
attribute [simp, aesop safe (rule_sets := [SetLike])] one_mem zero_mem
7878

79+
/-- The underlying set of a term of a `OneMemClass` is nonempty. -/
80+
@[to_additive (attr := simp)
81+
/-- The underlying set of a term of a `ZeroMemClass` is nonempty. -/]
82+
theorem OneMemClass.coe_nonempty {S M : Type*} [One M] [SetLike S M] [OneMemClass S M] (s : S) :
83+
(s : Set M).Nonempty :=
84+
1, one_mem s⟩
85+
7986
section
8087

8188
/-- A submonoid of a monoid `M` is a subset containing 1 and closed under multiplication. -/

Mathlib/Data/ZMod/QuotientGroup.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ variable {a}
167167
@[to_additive (attr := simp)]
168168
lemma finite_zpowers : (zpowers a : Set α).Finite ↔ IsOfFinOrder a := by
169169
simp only [← orderOf_pos_iff, ← Nat.card_zpowers, Nat.card_pos_iff, ← SetLike.coe_sort_coe,
170-
nonempty_coe_sort, Nat.card_pos_iff, Set.finite_coe_iff, Subgroup.coe_nonempty, true_and]
170+
nonempty_coe_sort, Nat.card_pos_iff, Set.finite_coe_iff, OneMemClass.coe_nonempty, true_and]
171171

172172
@[to_additive (attr := simp)]
173173
lemma infinite_zpowers : (zpowers a : Set α).Infinite ↔ ¬IsOfFinOrder a := finite_zpowers.not

Mathlib/GroupTheory/OrderOfElement.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ nonrec lemma Subgroup.orderOf_dvd_natCard {G : Type*} [Group G] (s : Subgroup G)
11631163
@[to_additive]
11641164
lemma Subgroup.orderOf_le_card {G : Type*} [Group G] (s : Subgroup G) (hs : (s : Set G).Finite)
11651165
{x} (hx : x ∈ s) : orderOf x ≤ Nat.card s :=
1166-
le_of_dvd (Nat.card_pos_iff.2 <| ⟨s.coe_nonempty.to_subtype, hs.to_subtype⟩) <|
1166+
le_of_dvd (Nat.card_pos_iff.2 <| ⟨(OneMemClass.coe_nonempty s).to_subtype, hs.to_subtype⟩) <|
11671167
s.orderOf_dvd_natCard hx
11681168

11691169
@[to_additive]

Mathlib/NumberTheory/LocalField/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ instance : IsAdicComplete 𝓂[K] 𝒪[K] where
177177
simpa [S] using (hf n.le_succ).symm
178178
have h n : IsClosed (S n) := (IsNoetherianRing.isClosed_ideal (𝓂[K] ^ n)).vadd (f n)
179179
obtain ⟨L, hL⟩ := (h 0).isCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed S hS
180-
(by simp [S, Submodule.nonempty]) h
180+
(by simp [S]) h
181181
refine ⟨L, fun n ↦ ?_⟩
182182
obtain ⟨y, hy, rfl⟩ := Set.mem_iInter.mp hL n
183183
simpa [SModEq.sub_mem] using hy

0 commit comments

Comments
 (0)