Skip to content

[Merged by Bors] - feat(Algebra/Group/Pointwise/Set): add IsSelfInv predicate - #42611

Closed
justus-springer wants to merge 31 commits into
leanprover-community:masterfrom
justus-springer:justus/IsMulSymmetric
Closed

justus-springer wants to merge 31 commits into
leanprover-community:masterfrom
justus-springer:justus/IsMulSymmetric

Conversation

@justus-springer

@justus-springer justus-springer commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

See also #36605 for the discussion that led to this PR.

We add a predicate for terms to be self-inverse in a type with inversion and add basic API. We apply this also to pointwise operations on sets. The lemma InvMemClass.isSelfInv relates this to the existing InvMemClass, which will make it easy to show that e.g. additive subgroups are closed under negation.


Open in Gitpod

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

PR summary d8bed3ea36

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all
There are 6737 files with changed transitive imports taking up over 304068 characters: this is too many to display!
You can run this locally from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci


Declarations diff (regex)

+ IsOfFinOrder.isSelfInv_iff
+ IsSelfInv
+ IsSelfInv.compl
+ IsSelfInv.conj
+ IsSelfInv.diff
+ IsSelfInv.div
+ IsSelfInv.empty
+ IsSelfInv.eq_inv
+ IsSelfInv.iInter
+ IsSelfInv.iUnion
+ IsSelfInv.inter
+ IsSelfInv.inv
+ IsSelfInv.inv_eq
+ IsSelfInv.inv_mem
+ IsSelfInv.inv_subset
+ IsSelfInv.mul
+ IsSelfInv.neg
+ IsSelfInv.of_compl
+ IsSelfInv.of_invMemClass
+ IsSelfInv.of_inv_eq
+ IsSelfInv.of_inv_subset
+ IsSelfInv.of_subset_inv
+ IsSelfInv.one
+ IsSelfInv.pow
+ IsSelfInv.prod
+ IsSelfInv.sInter
+ IsSelfInv.sUnion
+ IsSelfInv.subset_inv
+ IsSelfInv.union
+ IsSelfInv.univ
+ IsSelfInv.zero
+ IsSelfInv.zpow
+ IsSelfNeg.inv
+ IsSelfNeg.one
+ Pi.isSelfInv_iff
+ instance [DecidableEq α] : Decidable (IsSelfInv a) := decidable_of_iff _ isSelfInv_iff.symm
+ isSelfInv_compl_iff
+ isSelfInv_conj_iff
+ isSelfInv_iff_eq_neg_one_or_eq_zero_or_eq_one
+ isSelfInv_iff_eq_one
+ isSelfInv_iff_forall_inv_mem
+ isSelfInv_iff_forall_inv_mem_iff
+ isSelfInv_iff_inv_subset
+ isSelfInv_iff_isOfFinOrder_and_orderOf_le_two
+ isSelfInv_iff_sq_eq_one
+ isSelfInv_iff_subset_inv
+ isSelfInv_inv
+ isSelfInv_neg_iff
+ isSelfInv_singleton_iff
+ isSelfNeg_inv_iff
+ isSelfNeg_of_isSMulRegular_two
++ isSelfInv_iff

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)

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

  • +98 new declarations
  • −0 removed declarations
+IsOfFinAddOrder.isSelfNeg_iff
+IsOfFinOrder.isSelfInv_iff
+IsSelfInv
+IsSelfInv.compl
+IsSelfInv.conj
+IsSelfInv.diff
+IsSelfInv.div
+IsSelfInv.empty
+IsSelfInv.eq_inv
+IsSelfInv.iInter
+IsSelfInv.iUnion
+IsSelfInv.inter
+IsSelfInv.inv
+IsSelfInv.inv_eq
+IsSelfInv.inv_mem
+IsSelfInv.inv_subset
+IsSelfInv.mul
+IsSelfInv.neg
+IsSelfInv.of_compl
+IsSelfInv.of_invMemClass
+IsSelfInv.of_inv_eq
+IsSelfInv.of_inv_subset
+IsSelfInv.of_subset_inv
+IsSelfInv.one
+IsSelfInv.pow
+IsSelfInv.prod
+IsSelfInv.sInter
+IsSelfInv.sUnion
+IsSelfInv.subset_inv
+IsSelfInv.union
+IsSelfInv.univ
+IsSelfInv.zero
+IsSelfInv.zpow
+IsSelfNeg
+IsSelfNeg.add
+IsSelfNeg.addConj
+IsSelfNeg.compl
+IsSelfNeg.diff
+IsSelfNeg.empty
+IsSelfNeg.eq_neg
+IsSelfNeg.iInter
+IsSelfNeg.iUnion
+IsSelfNeg.inter
+IsSelfNeg.inv
+IsSelfNeg.neg
+IsSelfNeg.neg_eq
+IsSelfNeg.neg_mem
+IsSelfNeg.neg_subset
+IsSelfNeg.nsmul
+IsSelfNeg.of_compl
+IsSelfNeg.of_negMemClass
+IsSelfNeg.of_neg_eq
+IsSelfNeg.of_neg_subset
+IsSelfNeg.of_subset_neg
+IsSelfNeg.one
+IsSelfNeg.sInter
+IsSelfNeg.sUnion
+IsSelfNeg.sub
+IsSelfNeg.subset_neg
+IsSelfNeg.sum
+IsSelfNeg.union
+IsSelfNeg.univ
+IsSelfNeg.zero
+IsSelfNeg.zsmul
+Pi.isSelfInv_iff
+Pi.isSelfNeg_iff
+Prod.isSelfInv_iff
+Prod.isSelfNeg_iff
+instDecidableIsSelfInvOfDecidableEq
+instDecidableIsSelfNegOfDecidableEq
+isSelfInv_compl_iff
+isSelfInv_conj_iff
+isSelfInv_iff
+isSelfInv_iff_eq_neg_one_or_eq_zero_or_eq_one
+isSelfInv_iff_eq_one
+isSelfInv_iff_forall_inv_mem
+isSelfInv_iff_forall_inv_mem_iff
+isSelfInv_iff_inv_subset
+isSelfInv_iff_isOfFinOrder_and_orderOf_le_two
+isSelfInv_iff_sq_eq_one
+isSelfInv_iff_subset_inv
+isSelfInv_inv
+isSelfInv_neg_iff
+isSelfInv_singleton_iff
+isSelfNeg_addConj_iff
+isSelfNeg_compl_iff
+isSelfNeg_iff
+isSelfNeg_iff_eq_zero
+isSelfNeg_iff_forall_neg_mem
+isSelfNeg_iff_forall_neg_mem_iff
+isSelfNeg_iff_isOfFinAddOrder_and_addOrderOf_le_two
+isSelfNeg_iff_neg_subset
+isSelfNeg_iff_subset_neg
+isSelfNeg_iff_two_nsmul_eq_zero
+isSelfNeg_inv_iff
+isSelfNeg_neg
+isSelfNeg_of_isSMulRegular_two
+isSelfNeg_singleton_iff

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (1.00, 1.00)
Current number Change Type (weak)
large files 1 1
exposed public sections 5031 1

Current commit d8bed3ea36
Reference commit b7527c8e1d

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).

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Aug 10, 2026
Comment thread Mathlib/Algebra/Group/Pointwise/Set/Symmetric.lean Outdated
@justus-springer justus-springer changed the title feat(Algebra/Group/Pointwise/Set): add IsMulSymmetric predicate feat(Algebra/Group/Pointwise/Set): add IsInvClosed predicate Aug 11, 2026
Comment thread Mathlib/Algebra/Group/Subgroup/Pointwise.lean Outdated
Co-authored-by: Aaron Liu <aaronliu2008@outlook.com>
Comment thread Mathlib/Algebra/Group/Subgroup/Pointwise.lean Outdated
Co-authored-by: Aaron Liu <aaronliu2008@outlook.com>
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated

@YaelDillies YaelDillies 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.

Can you show closure under cartesian products and multiplication (assuming commutativity)?

Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Aug 14, 2026
@justus-springer justus-springer added t-algebra Algebra (groups, rings, fields, etc) and removed awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. t-algebra Algebra (groups, rings, fields, etc) labels Aug 14, 2026
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/InvClosed.lean Outdated
@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Aug 16, 2026
@YaelDillies YaelDillies self-assigned this Aug 16, 2026
@justus-springer justus-springer added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Aug 30, 2026
@justus-springer justus-springer added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. large-import Automatically added label for PRs with a significant increase in transitive imports labels Sep 1, 2026
@github-actions github-actions Bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Sep 1, 2026
@justus-springer

Copy link
Copy Markdown
Collaborator Author

The last commit after the maintainer merge moved two lemmas (Pi.isSelfInv_iff and isSelfNeg_of_isSMulRegular_two) into further downstream files to get rid of the large import.

@justus-springer justus-springer removed the large-import Automatically added label for PRs with a significant increase in transitive imports label Sep 1, 2026

@j-loreaux j-loreaux 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.

Looks nice. I do wish there were a way to unify this further with IsSelfAdjoint so that we get all the generic theorems for free, but I think it would probably be more trouble than it's worth at the moment.

bors +

Comment thread Mathlib/Algebra/Group/Pointwise/Set/SelfInv.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/SelfInv.lean
Comment thread Mathlib/Algebra/Group/SelfInv.lean Outdated
@mathlib-bors

mathlib-bors Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Did you mean "r+"?

@j-loreaux

Copy link
Copy Markdown
Contributor

oops

bors d+

@mathlib-bors mathlib-bors Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Sep 1, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

✌️ justus-springer can now approve this pull request until 2026-09-15 22:25 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

⚠️ This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, Wanted/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean, Wanted.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 1, 2026
Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
Comment thread Mathlib/Algebra/Group/Pointwise/Set/SelfInv.lean Outdated
Comment thread Mathlib/Algebra/Group/Pointwise/Set/SelfInv.lean Outdated
Comment thread Mathlib/Algebra/Group/SelfInv.lean Outdated
@justus-springer

Copy link
Copy Markdown
Collaborator Author

bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Sep 2, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 2, 2026
See also #36605 for the discussion that led to this PR.

We add a predicate for terms to be self-inverse in a type with inversion and add basic API. We apply this also to pointwise operations on sets. The lemma `InvMemClass.isSelfInv` relates this to the existing `InvMemClass`, which will make it easy to show that e.g. additive subgroups are closed under negation.

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Sep 2, 2026
@mathlib-bors

mathlib-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat(Algebra/Group/Pointwise/Set): add IsSelfInv predicate [Merged by Bors] - feat(Algebra/Group/Pointwise/Set): add IsSelfInv predicate Sep 2, 2026
@mathlib-bors mathlib-bors Bot closed this Sep 2, 2026
@mathlib-bors mathlib-bors Bot removed the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Sep 2, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 3, 2026
…d negation (#36605)

Prove lemmas about the interaction of hull, span and negation.

Main additions:
* `PointedCone.toSubmodule` that produces a submodule with the same support given that `IsSelfNeg C`. Also the corresponding `CanLift`
* `PointedCone.hull_neg_pair_eq_span_singleton` proving `hull R {-x, x} = R ∙ x` (simp lemma)
* `PointedCone.span_eq_hull_neg_sup_hull` proving `span R s = hull R (-s) ⊔ hull R s`
* `PointedCone.mem_span` proving `x ∈ span R C ↔ ∃ p, n ∈ C, x = p - n`

#### Note

This PR resulted in #42611 and the introduction of `IsSelfNeg` to unify several ways to express the same fact:
* `-C = C`
* `-C ≤ C` or `C ≤ -C`
* `C = span R C`
* `C = C.lineal`

Co-authored by: Olivia Röhrig, Kilian Rueß, Artie Khovanov

Co-authored-by: Martin Winter <martin.winter.math@gmail.com>
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Sep 5, 2026
…ver-community#42611)

See also leanprover-community#36605 for the discussion that led to this PR.

We add a predicate for terms to be self-inverse in a type with inversion and add basic API. We apply this also to pointwise operations on sets. The lemma `InvMemClass.isSelfInv` relates this to the existing `InvMemClass`, which will make it easy to show that e.g. additive subgroups are closed under negation.

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Sep 5, 2026
…d negation (leanprover-community#36605)

Prove lemmas about the interaction of hull, span and negation.

Main additions:
* `PointedCone.toSubmodule` that produces a submodule with the same support given that `IsSelfNeg C`. Also the corresponding `CanLift`
* `PointedCone.hull_neg_pair_eq_span_singleton` proving `hull R {-x, x} = R ∙ x` (simp lemma)
* `PointedCone.span_eq_hull_neg_sup_hull` proving `span R s = hull R (-s) ⊔ hull R s`
* `PointedCone.mem_span` proving `x ∈ span R C ↔ ∃ p, n ∈ C, x = p - n`

#### Note

This PR resulted in leanprover-community#42611 and the introduction of `IsSelfNeg` to unify several ways to express the same fact:
* `-C = C`
* `-C ≤ C` or `C ≤ -C`
* `C = span R C`
* `C = C.lineal`

Co-authored by: Olivia Röhrig, Kilian Rueß, Artie Khovanov

Co-authored-by: Martin Winter <martin.winter.math@gmail.com>

public section

open Set

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I claim this should all be in the Set namespace.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree for lemmas like isSelfInv_iff_forall_inv_mem_iff . But much of this file is putting lemmas into IsSelfInv namespace to make available for dot notation. I guess we could also put those into Set, e.g. Set.IsSelfInv.inter, using the "dot-notation-respects-open" feature. But it seems not everyone likes this feature.

@justus-springer justus-springer Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Opened #43792 (I put everything in the Set namespace for now).

Comment on lines +10 to +20
/-!
# Self-inverse elements

This file defines self-inverse elements of a type with an inversion, i.e. elements `a` satisfying
`a⁻¹ = a`.

## Main declarations

* `IsSelfInv a`: The element `a` satisfies `a⁻¹ = a`.
* `IsSelfNeg a`: The element `a` satisfies `-a = a`.
-/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you make a follow-up PR that extends the docstring to explain why this is useful? I believe that it is, but would prefer not to have to

In order to understand why I should choose it over writing a = -a.

Is the answer as simple as "IsSelfInv (oneReally bigExpression) is nicer to read than oneReallyBig Expression = -oneReallyBig Expression"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will do. The main point is just to have a canonical way of talking about self-inverse elements (or "symmetric sets"). That's how it showed up in the discussion of the cones PR. And indeed, we have places in the library where we write A⁻¹ = A for sets, and other places where it's ∀ x ∈ A, x⁻¹ ∈ A.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Opened #43793

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

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants