Skip to content

feat(Algebra/Group/Submonoid): type class to indicate that supremum in a SubmonoidClass agrees with supremum of submonoids - #39687

Open
TentativeConvert wants to merge 5 commits into
leanprover-community:masterfrom
TentativeConvert:addsubmonoid-ssup
Open

TentativeConvert wants to merge 5 commits into
leanprover-community:masterfrom
TentativeConvert:addsubmonoid-ssup

Conversation

@TentativeConvert

@TentativeConvert TentativeConvert commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Add a type class SubmonoidClass.IsConcreteSSup to indicate that the canonical map .ofClass from a class S of submonoids of M to Submonoid M preserves suprema.


This PR implements the minimal type class assumption needed to make „pushfoward of gradings along maps of indexing sets“ – see draft PR #39356 – work in some SetLike generality.

Given {S M : Type*} [SetLike S M] [Monoid M] [SubmonoidClass S M], we have canonical maps

   S → Submonoid M → Set M

The first is Submonoid.ofClass, the second and the composition are coe maps coming from the SetLike structures. Depending on S, these maps may or may not satisfy various properties with respect the lattice structures on Submonoid M and Set M. Mathlib so far includes the type class [IsConcreteLE S M], which asserts that the composition S → Set M is order-preserving and order-reflecting. The type class defined here asserts that the first map, S → Submonoid M, preserves suprema.

In examples such as S = Subgroup M, S = Submodule R M, much more is true – in these cases, S is a complete sublattice of Submonoid M. But there are also examples where only the weaker property defined here holds, e.g. S = OpenSubgroup M for a topological group M.

Zulip discussion thead about this PR

Note on outParam: I did not write (M : outParam Type*) in the assumptions of SubmonoidClass.IsConcreteSSup in accordance with the DocString of Setlike. However, we do have (B : outParam Type*) in the definition of IsConcreteLE, so perhaps I'm misinterpreting the DocString.

Open in Gitpod

@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label May 22, 2026
@github-actions

Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label May 22, 2026
@github-actions

github-actions Bot commented May 22, 2026 •

Copy link
Copy Markdown

PR summary 592d5f3468

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Algebra.Group.Submonoid.SSup (new file) 377

Declarations diff (regex)

+ AddSubmonoidClass.IsConcreteSSup
+ SubmonoidClass.IsConcreteSSup
+ iSup_toSubmonoid
+ instance (M : Type*) [Monoid M] : IsConcreteSSup (Submonoid M) M
+ mem_iSup_iff_mem_iSup_Submonoid

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean -- stale; merge master and push to refresh)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit e8f4ad4).

  • +18 new declarations
  • −0 removed declarations
+AddSubmonoidClass.IsConcreteSSup
+AddSubmonoidClass.IsConcreteSSup.casesOn
+AddSubmonoidClass.IsConcreteSSup.mk
+AddSubmonoidClass.IsConcreteSSup.rec
+AddSubmonoidClass.IsConcreteSSup.recOn
+AddSubmonoidClass.IsConcreteSSup.sSup_toAddSubmonoid
+AddSubmonoidClass.iSup_toAddSubmonoid
+AddSubmonoidClass.instIsConcreteSSupAddSubmonoid
+AddSubmonoidClass.mem_iSup_iff_mem_iSup_AddSubmonoid
+SubmonoidClass.IsConcreteSSup
+SubmonoidClass.IsConcreteSSup.casesOn
+SubmonoidClass.IsConcreteSSup.mk
+SubmonoidClass.IsConcreteSSup.rec
+SubmonoidClass.IsConcreteSSup.recOn
+SubmonoidClass.IsConcreteSSup.sSup_toSubmonoid
+SubmonoidClass.iSup_toSubmonoid
+SubmonoidClass.instIsConcreteSSupSubmonoid
+SubmonoidClass.mem_iSup_iff_mem_iSup_Submonoid

No changes to strong technical debt.
No changes to weak technical debt.

Current commit 592d5f3468
Reference commit 6bd5e549d9

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@jjdishere

jjdishere commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @TentativeConvert ,
Welcome to the lean community and thanks for your PR!

From my current understanding, the idea of this PR could be generalize to any FooClass with SetLike instances, not only SubmonoidClass. It is better to open a thread about this design on Zulip since people will respond much faster there. If you have already done this, please add a link to the zulip thread in the PR description, thanks!

@jjdishere jjdishere added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 19, 2026
@TentativeConvert

TentativeConvert commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

I've now linked the a newly created Zulip discussion thread that I created at the same time as the PR in the PR description. Sorry I didn't do that earlier.

@TentativeConvert

Copy link
Copy Markdown
Contributor Author

I'm sure this can be generalized in many different directions. I was intentionally trying to spell out only the bare minimum I need in order to move on with #39356. Whether this is an elegant approach is an entire different question, and I'd be happy for thoughts on this.

@TentativeConvert

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 22, 2026

@Vierkantor Vierkantor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Could you write some more to show that this is indeed the right way to do things? Namely, the following seem to be important drawbacks:

  • The coercion from one subobject type to another is usually custom, e.g. Subgroup.toSubmonoid, which needs a rewrite to turn into ofClass.
  • We'd need a new class for every subobject, not just SubmonoidClass.
  • Defining a whole class needs quite a bit of work.

What kind of alternatives have you considered or tried out? For example, a very simple approach would be to pass around the hypothesis ∀ (s : Set S), ofClass (sSup s) = sSup (ofClass '' s) explicitly, instead of using typeclasses.

This is not a definitive no, please do try to convince me :)

@@ -0,0 +1,55 @@
/-
Copyright (c) 2024 Joe Cool. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to update the author info. Maybe also the year, or did you already start working on this a while ago? :)

Suggested change
Copyright (c) 2024 Joe Cool. All rights reserved.
Copyright (c) 2026 Marcus Zibrowius. All rights reserved.

[SupSet S] [IsConcreteSSup S M]
{ι : Sort*} (ℳ : ι → S) :
ofClass (⨆ i, ℳ i) = ⨆ i, ofClass (ℳ i) := by
rw [iSup,IsConcreteSSup.sSup_toSubmonoid,←Set.range_comp]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit pedantic:

Suggested change
rw [iSup,IsConcreteSSup.sSup_toSubmonoid,←Set.range_comp]
rw [iSup, IsConcreteSSup.sSup_toSubmonoid, ← Set.range_comp]


open Submonoid

@[to_additive, simp]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add the attribute like this, it also gets applied to the to_additive copy.

Suggested change
@[to_additive, simp]
@[to_additive (attr := simp)]

[AddSubmonoidClass S M] [SupSet S] : Prop where
sSup_toAddSubmonoid (s : Set S) : ofClass (sSup s) = sSup (ofClass '' s)

attribute [to_additive existing] SubmonoidClass.IsConcreteSSup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also make the sSup lemma @[simp], like iSup is too:

Suggested change
attribute [to_additive existing] SubmonoidClass.IsConcreteSSup
attribute [to_additive existing] SubmonoidClass.IsConcreteSSup
attribute [simp]
SubmonoidClass.IsConcreteSSup.sSup_toSubmonoid
AddSubmonoidClass.IsConcreteSSup.sSup_toAddSubmonoid

@Vierkantor Vierkantor added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 15, 2026
@SnirBroshi

Copy link
Copy Markdown
Collaborator

IMO the concept is a good idea, but as discussed in the Zulips linked in the thread above (#mathlib4 > Abstracting the substructure lattice construction and #mathlib4 > More `IsConcrete` classes for `SetLike`) and in similar PRs, this should be defined using Membership.
See also #42661 (comment).

I think this should be marked dependent on #42661, to first land IsMemSSup.

@artie2000

Copy link
Copy Markdown
Collaborator

As mentioned in that PR, the PR to depend on is instead #43726
And yeah we should do this systematically not piecemeal

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants