Skip to content

[Merged by Bors] - refactor: make Rel less see-through#25587

Closed
YaelDillies wants to merge 2 commits intomasterfrom
rel_refactor
Closed

[Merged by Bors] - refactor: make Rel less see-through#25587
YaelDillies wants to merge 2 commits intomasterfrom
rel_refactor

Conversation

@YaelDillies
Copy link
Copy Markdown
Contributor

@YaelDillies YaelDillies commented Jun 8, 2025

There is tension throughout the library between considering relations between α and β simply as α → β → Prop, or as a bundled object Rel α β with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:

  • composition of relations R : α → β → Prop, S : β → γ → Prop is the unwieldy Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c
  • map of a relation R : α → β → Prop, under f : α → γ, g : β → δ is the monstruous Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d.

The latter approach is embodied by the existing type Rel α β, with dedicated notation like for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as

def Rel (α β : Type*) := α → β → Prop

The fact that Rel isn't an abbrev confuses automation. But simply making it an abbrev would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type α as elements of Set (α × α). This cannot be worked around, since Set (α × α) is the type of elements of a filter on α × α. This theory is already developed in Topology.UniformSpace.Defs, and duplicates the existing Rel material.

This PR is a proposal to refactor Rel to be less see-through by redefining it as

abbrev Rel (α β : Type*) := Set (α × β)

This has several advantages:

  • The use of α × β means that one can't abuse the defeq of Rel α β with the function type α → β → Prop.
  • Instead, we get to provide an explicit notation a ~[R] b that very closely follows the paper convention a ~R b of using relations as infixes. This notation is scoped to the Rel namespace.
  • The use of Set is an extra layer of indirection to avoid automation confusing Rel α β with α × β → Prop.
  • It can directly be used in the theory of uniform spaces because of the syntactic equality between Rel α α and Set (α × α).
  • A relation can still be defined from an explicit function α → β → Prop, with nice notation: What was previously fun a b ↦ R a b becomes {(a, b) | R a b}.
  • In general, fallout is manageably small and easily fixed by inserting the {(a, b) | R a b} and a ~[R] b notations.

The benefits can be seen in places like CategoryTheory.Category.RelCat where automation is significantly improved, or Combinatorics.Hall.Basic where defeq abuse is avoided and dot notation becomes available.

Zulip


I will add deprecations once CI passes and people agree this is a step forward.

Open in Gitpod

@YaelDillies YaelDillies added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. RFC Request for comment t-data Data (lists, quotients, numbers, etc) labels Jun 8, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 8, 2025

PR summary 117f640573

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Hom
+ IsIrrefl
+ IsTrans
+ IsWellFounded
+ Rel.FiniteDimensional.inv
+ Rel.InfiniteDimensional.inv
+ Rel.IsWellFounded.inv_of_finiteDimensional
+ Rel.IsWellFounded.of_finiteDimensional
+ Rel.exists_graph_eq_iff
+ Rel.finiteDimensional_inv
+ Rel.infiniteDimensional_inv
+ cod
+ cod_empty
+ cod_inv
+ cod_mono
+ cod_univ
+ comp_empty
+ comp_id
+ comp_univ
+ core_subset_core
+ core_union_subset
+ dom_empty
+ dom_univ
+ empty_comp
+ id
+ id_comp
+ image_empty_left
+ image_empty_right
+ image_eq_cod_of_dom_subset
+ image_inter_dom
+ image_inter_subset
+ image_inv
+ image_subset_image
+ image_univ_left
+ image_univ_right
+ instance {R : α → α → Prop} [IsIrrefl α R] : Rel.IsIrrefl {(a, b) | R a b} := ‹_›
+ instance {R : α → α → Prop} [IsTrans α R] : Rel.IsTrans {(a, b) | R a b} := ‹_›
+ instance {α : Type u} {β : Type v} [DecidableEq β] (R : Rel α β)
+ inter_cod_subset_image_preimage
+ inv_empty
+ inv_mono
+ inv_univ
+ irrefl
+ mem_cod
+ mem_comp
+ mem_dom
+ mem_graph
+ mem_id
+ mem_inv
+ preimage_empty_left
+ preimage_empty_right
+ preimage_eq_dom_of_cod_subset
+ preimage_inter_cod
+ preimage_inter_subset
+ preimage_subset_preimage
+ preimage_univ_left
+ preimage_univ_right
+ rel_comp
+ rel_id
+ trans
+ univ_comp
+++- Rel
+-- ext
+--+ preimage
- Rel.FiniteDimensional.swap
- Rel.InfiniteDimensional.swap
- comp_left_bot
- comp_left_id
- comp_right_bot
- comp_right_id
- core_subset
- core_union
- image_bot
- image_empty
- image_inter
- image_inter_dom_eq
- image_subset
- image_top
- image_univ
- instance : CompleteLattice (Rel α β) := show CompleteLattice (α → β → Prop) from inferInstance
- instance : Inhabited (Rel α β) := show Inhabited (α → β → Prop) from inferInstance
- instance {α : Type u} {β : Type v} [DecidableEq β] (r : α → β → Prop)
- inv_top
- preimage_def
- preimage_empty
- preimage_inter
- preimage_univ

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

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

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


No changes to technical debt.

You can run this locally as

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

@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 Jun 8, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 8, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 15, 2025
@mathlib4-dependent-issues-bot
Copy link
Copy Markdown
Collaborator

This PR/issue depends on:

Comment on lines -121 to -131
map_id X := by
congr
simp only [unop_op, RelCat.rel_id]
ext x y
exact Eq.comm
map_comp {X Y Z} f g := by
unfold Category.opposite
congr
ext x y
apply exists_congr
exact fun a => And.comm
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 found a way to independently eliminate this in #25914

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 5, 2025
@leanprover-community-bot-assistant
Copy link
Copy Markdown
Collaborator

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

@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 Jul 5, 2025
Copy link
Copy Markdown
Member

@PatrickMassot PatrickMassot left a comment

Choose a reason for hiding this comment

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

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 5, 2025

✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Jul 5, 2025
@eric-wieser
Copy link
Copy Markdown
Member

Does this change mean that Rel will no longer work with RelHom?

/-- A relation on `α` and `β`, aka a set-valued function, aka a partial multifunction.

-/
We represent them as sets due to how relations are used in the context of uniform spaces. -/
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 this should have rather a longer explanation, perhaps in the module docstring. Perhaps some of your PR description can be repurposed.

What you have right now is not enough to persuade someone reading the source against changing to the _ -> _ -> Prop spelling again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What about now?

@YaelDillies
Copy link
Copy Markdown
Contributor Author

Does this change mean that Rel will no longer work with RelHom?

Indeed not, but it wouldn't be difficult to adapt it (OrderIso itself needn't change), and probably it would be slightly useful too.

There is tension throughout the library between considering relations between `α` and `β` simply as `α → β → Prop`, or as a bundled object `Rel α β` with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:
* composition of relations `R : α → β → Prop`, `S : β → γ → Prop` is the unwieldy `Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c`
* map of a relation `R : α → β → Prop`, under `f : α → γ`, `g : β → δ` is the monstruous `Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d`.

The latter approach is embodied by the existing type `Rel α β`, with dedicated notation like `○` for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as
```
def Rel (α β : Type*) := α → β → Prop
```
The fact that `Rel` isn't an `abbrev` confuses automation. But simply making it an `abbrev` would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type `α` as elements of  `Set (α × α)`. This cannot be worked around, since `Set (α × α)` is the type of elements of a filter on `α × α`. This theory is already developed in `Topology.UniformSpace.Defs`, and duplicates the existing `Rel` material.

This PR is a proposal to refactor `Rel` to be less see-through by redefining it as
```
abbrev Rel (α β : Type*) := Set (α × β)
```

This has several advantages:
* The use of `α × β` means that one can't abuse the defeq of `Rel α β` with the function type `α → β → Prop`.
* Instead, we get to provide an explicit notation `a ~[R] b` that very closely follows the paper convention `a ~R b` of using relations as infixes. This notation is scoped to the `Rel` namespace.
* The use of `Set` is an extra layer of indirection to avoid automation confusing `Rel α β` with `α × β → Prop`.
* It can directly be used in the theory of uniform spaces because of the syntactic equality between `Rel α α` and `Set (α × α)`.
* A relation can still be defined explicitly with nice notation: What was previously `fun a b ↦ R a b` becomes `{(a, b) | R a b}`.
* In general, fallout is manageably small and easily fixed by inserting the `{(a, b) | R a b}` and `a ~[R] b` notations.

The benefits can be seen in places like `CategoryTheory.Category.RelCat` where automation is significantly improved, or `Combinatorics.Hall.Basic` where defeq abuse is avoided and dot notation becomes available.
@YaelDillies
Copy link
Copy Markdown
Contributor Author

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Jul 6, 2025
There is tension throughout the library between considering relations between `α` and `β` simply as `α → β → Prop`, or as a bundled object `Rel α β` with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:
* composition of relations `R : α → β → Prop`, `S : β → γ → Prop` is the unwieldy `Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c`
* map of a relation `R : α → β → Prop`, under `f : α → γ`, `g : β → δ` is the monstruous `Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d`.

The latter approach is embodied by the existing type `Rel α β`, with dedicated notation like `○` for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as
```
def Rel (α β : Type*) := α → β → Prop
```
The fact that `Rel` isn't an `abbrev` confuses automation. But simply making it an `abbrev` would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type `α` as elements of  `Set (α × α)`. This cannot be worked around, since `Set (α × α)` is the type of elements of a filter on `α × α`. This theory is already developed in `Topology.UniformSpace.Defs`, and duplicates the existing `Rel` material.

This PR is a proposal to refactor `Rel` to be less see-through by redefining it as
```
abbrev Rel (α β : Type*) := Set (α × β)
```

This has several advantages:
* The use of `α × β` means that one can't abuse the defeq of `Rel α β` with the function type `α → β → Prop`.
* Instead, we get to provide an explicit notation `a ~[R] b` that very closely follows the paper convention `a ~R b` of using relations as infixes. This notation is scoped to the `Rel` namespace.
* The use of `Set` is an extra layer of indirection to avoid automation confusing `Rel α β` with `α × β → Prop`.
* It can directly be used in the theory of uniform spaces because of the syntactic equality between `Rel α α` and `Set (α × α)`.
* A relation can still be defined from an explicit function `α → β → Prop`, with nice notation: What was previously `fun a b ↦ R a b` becomes `{(a, b) | R a b}`.
* In general, fallout is manageably small and easily fixed by inserting the `{(a, b) | R a b}` and `a ~[R] b` notations.

The benefits can be seen in places like `CategoryTheory.Category.RelCat` where automation is significantly improved, or `Combinatorics.Hall.Basic` where defeq abuse is avoided and dot notation becomes available.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Uniform.20spaces.20and.20relations.20as.20sets)
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 6, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor: make Rel less see-through [Merged by Bors] - refactor: make Rel less see-through Jul 6, 2025
@mathlib-bors mathlib-bors bot closed this Jul 6, 2025
@mathlib-bors mathlib-bors bot deleted the rel_refactor branch July 6, 2025 13:34
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Jul 7, 2025
There is tension throughout the library between considering relations between `α` and `β` simply as `α → β → Prop`, or as a bundled object `Rel α β` with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:
* composition of relations `R : α → β → Prop`, `S : β → γ → Prop` is the unwieldy `Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c`
* map of a relation `R : α → β → Prop`, under `f : α → γ`, `g : β → δ` is the monstruous `Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d`.

The latter approach is embodied by the existing type `Rel α β`, with dedicated notation like `○` for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as
```
def Rel (α β : Type*) := α → β → Prop
```
The fact that `Rel` isn't an `abbrev` confuses automation. But simply making it an `abbrev` would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type `α` as elements of  `Set (α × α)`. This cannot be worked around, since `Set (α × α)` is the type of elements of a filter on `α × α`. This theory is already developed in `Topology.UniformSpace.Defs`, and duplicates the existing `Rel` material.

This PR is a proposal to refactor `Rel` to be less see-through by redefining it as
```
abbrev Rel (α β : Type*) := Set (α × β)
```

This has several advantages:
* The use of `α × β` means that one can't abuse the defeq of `Rel α β` with the function type `α → β → Prop`.
* Instead, we get to provide an explicit notation `a ~[R] b` that very closely follows the paper convention `a ~R b` of using relations as infixes. This notation is scoped to the `Rel` namespace.
* The use of `Set` is an extra layer of indirection to avoid automation confusing `Rel α β` with `α × β → Prop`.
* It can directly be used in the theory of uniform spaces because of the syntactic equality between `Rel α α` and `Set (α × α)`.
* A relation can still be defined from an explicit function `α → β → Prop`, with nice notation: What was previously `fun a b ↦ R a b` becomes `{(a, b) | R a b}`.
* In general, fallout is manageably small and easily fixed by inserting the `{(a, b) | R a b}` and `a ~[R] b` notations.

The benefits can be seen in places like `CategoryTheory.Category.RelCat` where automation is significantly improved, or `Combinatorics.Hall.Basic` where defeq abuse is avoided and dot notation becomes available.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Uniform.20spaces.20and.20relations.20as.20sets)
callesonne pushed a commit to callesonne/mathlib4 that referenced this pull request Jul 24, 2025
There is tension throughout the library between considering relations between `α` and `β` simply as `α → β → Prop`, or as a bundled object `Rel α β` with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:
* composition of relations `R : α → β → Prop`, `S : β → γ → Prop` is the unwieldy `Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c`
* map of a relation `R : α → β → Prop`, under `f : α → γ`, `g : β → δ` is the monstruous `Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d`.

The latter approach is embodied by the existing type `Rel α β`, with dedicated notation like `○` for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as
```
def Rel (α β : Type*) := α → β → Prop
```
The fact that `Rel` isn't an `abbrev` confuses automation. But simply making it an `abbrev` would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type `α` as elements of  `Set (α × α)`. This cannot be worked around, since `Set (α × α)` is the type of elements of a filter on `α × α`. This theory is already developed in `Topology.UniformSpace.Defs`, and duplicates the existing `Rel` material.

This PR is a proposal to refactor `Rel` to be less see-through by redefining it as
```
abbrev Rel (α β : Type*) := Set (α × β)
```

This has several advantages:
* The use of `α × β` means that one can't abuse the defeq of `Rel α β` with the function type `α → β → Prop`.
* Instead, we get to provide an explicit notation `a ~[R] b` that very closely follows the paper convention `a ~R b` of using relations as infixes. This notation is scoped to the `Rel` namespace.
* The use of `Set` is an extra layer of indirection to avoid automation confusing `Rel α β` with `α × β → Prop`.
* It can directly be used in the theory of uniform spaces because of the syntactic equality between `Rel α α` and `Set (α × α)`.
* A relation can still be defined from an explicit function `α → β → Prop`, with nice notation: What was previously `fun a b ↦ R a b` becomes `{(a, b) | R a b}`.
* In general, fallout is manageably small and easily fixed by inserting the `{(a, b) | R a b}` and `a ~[R] b` notations.

The benefits can be seen in places like `CategoryTheory.Category.RelCat` where automation is significantly improved, or `Combinatorics.Hall.Basic` where defeq abuse is avoided and dot notation becomes available.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Uniform.20spaces.20and.20relations.20as.20sets)
hrmacbeth pushed a commit to szqzs/mathlib4 that referenced this pull request Jul 28, 2025
There is tension throughout the library between considering relations between `α` and `β` simply as `α → β → Prop`, or as a bundled object `Rel α β` with dedicated operations and API.

The former approach is used almost everywhere as it is very lightweight and has arguably native support from core Lean features, but it cracks at the seams whenever one starts talking about operations on relations. For example:
* composition of relations `R : α → β → Prop`, `S : β → γ → Prop` is the unwieldy `Relation.Comp R S := fun a c ↦ ∃ b, R a b ∧ S b c`
* map of a relation `R : α → β → Prop`, under `f : α → γ`, `g : β → δ` is the monstruous `Relation.map R f g := fun c d ↦ ∃ a b, r a b ∧ f a = c ∧ g b = d`.

The latter approach is embodied by the existing type `Rel α β`, with dedicated notation like `○` for composition. It makes it much easier to reason about operations relations, but currently its API suffers from the leakage of its definition as
```
def Rel (α β : Type*) := α → β → Prop
```
The fact that `Rel` isn't an `abbrev` confuses automation. But simply making it an `abbrev` would kill the point of having a separate less see-through type to perform relation operations on.

A final point, and the original motivation for this refactor, is that uniform spaces need a theory of relations on a type `α` as elements of  `Set (α × α)`. This cannot be worked around, since `Set (α × α)` is the type of elements of a filter on `α × α`. This theory is already developed in `Topology.UniformSpace.Defs`, and duplicates the existing `Rel` material.

This PR is a proposal to refactor `Rel` to be less see-through by redefining it as
```
abbrev Rel (α β : Type*) := Set (α × β)
```

This has several advantages:
* The use of `α × β` means that one can't abuse the defeq of `Rel α β` with the function type `α → β → Prop`.
* Instead, we get to provide an explicit notation `a ~[R] b` that very closely follows the paper convention `a ~R b` of using relations as infixes. This notation is scoped to the `Rel` namespace.
* The use of `Set` is an extra layer of indirection to avoid automation confusing `Rel α β` with `α × β → Prop`.
* It can directly be used in the theory of uniform spaces because of the syntactic equality between `Rel α α` and `Set (α × α)`.
* A relation can still be defined from an explicit function `α → β → Prop`, with nice notation: What was previously `fun a b ↦ R a b` becomes `{(a, b) | R a b}`.
* In general, fallout is manageably small and easily fixed by inserting the `{(a, b) | R a b}` and `a ~[R] b` notations.

The benefits can be seen in places like `CategoryTheory.Category.RelCat` where automation is significantly improved, or `Combinatorics.Hall.Basic` where defeq abuse is avoided and dot notation becomes available.

[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Uniform.20spaces.20and.20relations.20as.20sets)
mathlib-bors bot pushed a commit that referenced this pull request Aug 13, 2025
Many users are confused that Rel no longer means what it used to. Since the design is not obvious (and the implementation is explicitly part of the interface thanks to `abbrev`), let's give it a name that makes the choice obvious.

This then restores the old definition of `Rel`, as an abbrev; it's conceivable that many users were just using this as a shorthand, and this stops them being broken by #25587. Such users will of course be broken if they used [the old API](https://github.com/leanprover-community/mathlib4/blob/59bd63c72671849996d64c5d3b5f24a36333483c%5E/Mathlib/Data/Rel.lean).

This way, users bumping from 4.21.0 to 4.22.0 and using `Rel` only as a shorthand will not be broken.

[#mathlib4 > Changing &#96;Rel&#96; to &#96;Set (α × β)&#96;, to help uniform spaces @ 💬](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Changing.20.60Rel.60.20to.20.60Set.20.28.CE.B1.20.C3.97.20.CE.B2.29.60.2C.20to.20help.20uniform.20spaces/near/528531852)
Paul-Lez pushed a commit to Paul-Lez/mathlib4 that referenced this pull request Aug 23, 2025
…-community#27447)

Many users are confused that Rel no longer means what it used to. Since the design is not obvious (and the implementation is explicitly part of the interface thanks to `abbrev`), let's give it a name that makes the choice obvious.

This then restores the old definition of `Rel`, as an abbrev; it's conceivable that many users were just using this as a shorthand, and this stops them being broken by leanprover-community#25587. Such users will of course be broken if they used [the old API](https://github.com/leanprover-community/mathlib4/blob/59bd63c72671849996d64c5d3b5f24a36333483c%5E/Mathlib/Data/Rel.lean).

This way, users bumping from 4.21.0 to 4.22.0 and using `Rel` only as a shorthand will not be broken.

[#mathlib4 > Changing &leanprover-community#96;Rel&leanprover-community#96; to &leanprover-community#96;Set (α × β)&leanprover-community#96;, to help uniform spaces @ 💬](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Changing.20.60Rel.60.20to.20.60Set.20.28.CE.B1.20.C3.97.20.CE.B2.29.60.2C.20to.20help.20uniform.20spaces/near/528531852)
mathlib-bors bot pushed a commit that referenced this pull request Mar 10, 2026
It used to be identical to its neighbor, `preimage_eq_dom_of_cod_subset`.
Both lemmas seem to have been introduced in #25587.

Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
xroblot pushed a commit to xroblot/mathlib4 that referenced this pull request Mar 10, 2026
…rover-community#35696)

It used to be identical to its neighbor, `preimage_eq_dom_of_cod_subset`.
Both lemmas seem to have been introduced in leanprover-community#25587.

Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). RFC Request for comment t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants