Skip to content

[Merged by Bors] - feat(Logic/Equiv/Fintype): generalize toCompl to finite source; add exists_extending_pair#34599

Closed
cameronfreer wants to merge 33 commits intoleanprover-community:masterfrom
cameronfreer:feat/perm-extend-injective-fin
Closed

[Merged by Bors] - feat(Logic/Equiv/Fintype): generalize toCompl to finite source; add exists_extending_pair#34599
cameronfreer wants to merge 33 commits intoleanprover-community:masterfrom
cameronfreer:feat/perm-extend-injective-fin

Conversation

@cameronfreer
Copy link
Copy Markdown
Contributor

@cameronfreer cameronfreer commented Jan 30, 2026

Generalize Equiv.toCompl from [Finite α] to [Finite {x | p x}], which allows the target type to be infinite. In the process we add Perm.exists_extending_pair (given injections f, g : α → β for finite α, there is some σ : Perm β s.t. σ ∘ f = g) and Perm.exists_map_finset_eq.

This lets us simplifyPerm.isMultiplyPretransitive from 70 lines to 2 lines, avoiding cardinal arithmetic.

A version of this was used in formalizing de Finetti's theorem.

Co-authored-by: tb65536 tb65536@users.noreply.github.com

…ermutations

Add lemmas for extending injective functions `Fin m → Fin n` to permutations of `Fin n`.

- `Equiv.Perm.exists_extending_injective`: Any injective `k : Fin m → Fin n` extends to
  `σ : Perm (Fin n)` with `σ (Fin.castLE hmn i) = k i`
- `Equiv.Perm.exists_extending_strictMono`: Special case for strictly monotone functions
Make docstrings more concise per mathlib style guidelines.
@github-actions github-actions bot added new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-group-theory Group theory labels Jan 30, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 30, 2026

PR summary 865d150803

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Perm.exists_extending_pair
+ Perm.exists_map_finset_eq
+ exists_smul_eq_embedding
+ setDiffEquiv

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

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

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/reporting/technical-debt-metrics.sh 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).

@tb65536 tb65536 added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 3, 2026
…emma

Remove `Equiv.Perm.exists_extending_strictMono` since it's a trivial
special case of `exists_extending_injective` (just apply `.injective`).
`Mathlib.Logic.Equiv.Fintype` is already imported transitively via
`Cycle.Type` → `Cycle.Factors` → `Cycle.Basic` → `Perm.Finite`.
Add a general theorem stating that any two injective functions from a
finite type to a finite type can be related by a permutation.

This is the elementary form of the multiple pretransitivity of
permutation groups (see `Equiv.Perm.isMultiplyPretransitive`).
Simplify `exists_extending_injective` to a one-line corollary of the
new general `Perm.exists_extending_pair` theorem.
The `Finite β` constraint suffices since the ranges are subsets of `β`.
cameronfreer and others added 9 commits February 17, 2026 16:45
…yPretransitive proof

Use `Equiv.subtypeCongr` with `ofInjective` to build the permutation
directly, eliminating the 57-line manual bijectivity proof via
`Function.extend` and `Equiv.ofBijective`. The complement equivalence
is still obtained via cardinal arithmetic.
…_extending_pair

Add `Equiv.Perm.exists_extending_pair'` which generalizes
`exists_extending_pair` from `[Finite β]` (target finite) to
`[Finite α]` (source finite), using cardinal arithmetic for the
complement equivalence. This allows the target type to be infinite.

Use it to further simplify `isMultiplyPretransitive` to a 3-line proof.
The hypothesis is `[Finite β]` (target finite), not `[Finite α]`.
Add cross-reference to the generalized `exists_extending_pair'`.
This was a one-line specialization of `exists_extending_pair` with no
downstream uses. Callers can use `exists_extending_pair` directly.

Also remove the now-unused `Mathlib.Data.Fin.Pigeonhole` import.
Rename `exists_extending_pair'` to `exists_extending_pair_of_finite_source`
for discoverability, and add `exists_smul_eq_embedding` as the
action-form wrapper. This reduces `isMultiplyPretransitive` to a
two-line proof.

Update cross-reference in `Fintype.lean` docstring accordingly.
…ite {x | p x}]

Generalize `toCompl` and related definitions (`extendSubtype`, etc.)
to only require finiteness of the subtype `{x | p x}` rather than
the ambient type `α`. This allows `exists_extending_pair` to be
strengthened from `[Finite β]` to `[Finite α]`.

Co-authored-by: tb65536 <tb65536@users.noreply.github.com>
Replace 4 `grind` calls (experimental tactic) with stable alternatives:
- Set identities: `ext; simp; tauto`
- Disjointness: term-mode proof via `disjoint_compl_right.mono_left`
…f_finite_source

Remove `exists_extending_pair_of_finite_source` which is now redundant
since `Equiv.Perm.exists_extending_pair` has been generalized from
`[Finite β]` to `[Finite α]`. Update `exists_smul_eq_embedding` to
use `exists_extending_pair` directly.
@github-actions github-actions bot removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 18, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 23, 2026
@mathlib-merge-conflicts
Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

Keep our short `isMultiplyPretransitive` proof via
`exists_smul_eq_embedding`, discarding the upstream grind-golfed
version of the old long proof.
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 23, 2026
Fix upstream regression in `extendSubtype_apply_of_not_mem` by using
`simp only` + `rfl` instead of `simp`. Remove redundant `{α β : Type*}`
from `Perm.exists_extending_pair` since they are already in scope.
@riccardobrasca
Copy link
Copy Markdown
Member

Can we please have a human written PR description that says in a couple of lines what the PR does? It is currently almost as long as the diff. Thanks!

Extract the finset sdiff cardinality argument from `toCompl` into
`Equiv.setDiffEquiv`, and fix lint warnings in `Perm.exists_map_finset_eq`.
@cameronfreer cameronfreer changed the title feat(Logic/Equiv/Fintype): generalize toCompl and exists_extending_pair to finite source feat(Logic/Equiv/Fintype): generalize toCompl to finite source; add exists_extending_pair Apr 2, 2026
@cameronfreer cameronfreer force-pushed the feat/perm-extend-injective-fin branch from 26ac0e1 to a424062 Compare April 2, 2026 14:38
@cameronfreer cameronfreer force-pushed the feat/perm-extend-injective-fin branch from a424062 to 8691629 Compare April 2, 2026 14:40
Copy link
Copy Markdown
Member

@riccardobrasca riccardobrasca left a comment

Choose a reason for hiding this comment

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

#Thanks!

bors merge

@mathlib-triage mathlib-triage bot added the ready-to-merge This PR has been sent to bors. label Apr 2, 2026
mathlib-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…xists_extending_pair (#34599)

Generalize `Equiv.toCompl` from `[Finite α]` to `[Finite {x | p x}]`, which allows the target type to be infinite. In the process we add `Perm.exists_extending_pair` (given injections `f, g : α → β` for finite `α`, there is some `σ : Perm β` s.t. `σ ∘ f = g`) and `Perm.exists_map_finset_eq`.

This lets us simplify`Perm.isMultiplyPretransitive` from 70 lines to 2 lines, avoiding cardinal arithmetic.

A [version of this](https://github.com/cameronfreer/exchangeability/blob/03a854a2/Exchangeability/Contractability.lean#L459) was used in formalizing de Finetti's theorem.

Co-authored-by: tb65536 <tb65536@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 2, 2026

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(Logic/Equiv/Fintype): generalize toCompl to finite source; add exists_extending_pair [Merged by Bors] - feat(Logic/Equiv/Fintype): generalize toCompl to finite source; add exists_extending_pair Apr 2, 2026
@mathlib-bors mathlib-bors bot closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-group-theory Group theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants