Skip to content

[Merged by Bors] - chore: unsimp Set.coe_setOf#39582

Closed
plp127 wants to merge 12 commits into
leanprover-community:masterfrom
plp127:aliu/set-coe
Closed

[Merged by Bors] - chore: unsimp Set.coe_setOf#39582
plp127 wants to merge 12 commits into
leanprover-community:masterfrom
plp127:aliu/set-coe

Conversation

@plp127

@plp127 plp127 commented May 19, 2026

Copy link
Copy Markdown
Contributor

@plp127 plp127 added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label May 19, 2026
@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label May 19, 2026
@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

PR summary c02dada2cf

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

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

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


Increase in strong tech debt: (relative, absolute) = (0.45, 0.00)
Current number Change Type (strong)
502 1 erw
4515 -1 backward.defeqAttrib.useBackward
5675 -4 backward.isDefEq.respectTransparency
No changes to weak technical debt.

Current commit c02dada2cf
Reference commit aaedc74a09

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.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 added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 23, 2026
@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 May 23, 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 May 23, 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 May 30, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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 Jun 4, 2026
@plp127 plp127 temporarily deployed to cache-upload-forks June 4, 2026 02:00 — with GitHub Actions Inactive
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@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 Jun 25, 2026
@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 Jun 29, 2026

@TwoFX TwoFX left a comment

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.

bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Jun 30, 2026
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Jun 30, 2026
@mathlib-bors

mathlib-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title chore: unsimp Set.coe_setOf [Merged by Bors] - chore: unsimp Set.coe_setOf Jun 30, 2026
@mathlib-bors mathlib-bors Bot closed this Jun 30, 2026
@plp127 plp127 deleted the aliu/set-coe branch June 30, 2026 09:34
@YaelDillies

Copy link
Copy Markdown
Contributor

I am very worried about this PR. There are plenty of lemmas about the coercion of a set to a type, and now we will need to duplicate each of them to have both a version for sets and a version for predicates. See #41223. This issue is widespread enough that I suggest we revert this PR.

@TwoFX

TwoFX commented Jul 1, 2026

Copy link
Copy Markdown
Member

Reading through the Zulip thread again more closely, I guess there wasn't really consensus that unsimping the lemma is a good idea. Personally, I think the diff in this PR is an overall improvement, and I think it is inconsistent that coe_setOf is simp but coe_eq_subtype is not, but oh well... ping me on the revert PR and I'll bors it @YaelDillies

@plp127

plp127 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I am very worried about this PR. There are plenty of lemmas about the coercion of a set to a type, and now we will need to duplicate each of them to have both a version for sets and a version for predicates. See #41223. This issue is widespread enough that I suggest we revert this PR.

Why do we need such a duplication? The lemma Set.coe_setOf still exists, it's just not @[simp] anymore, so you can still use it to rewrite things. The issue with being @[simp] is that it changes the types of things to something that's not defeq at reducible-and-instances transparency, which you don't want happening automatically.

@YaelDillies

Copy link
Copy Markdown
Contributor

As you say, in an ideal world one shouldn't be rewriting with the current Set.coe_setOf because it changes types at semireducible transparency. The solution IMO however isn't to unsimp it (after all, one could still stumble upon the LHS of Set.coe_setOf and in the ideal world there is no way to get rid of it) but instead to make it defeq at reducible-and-instances transparency. Have you tried doing that?

@plp127

plp127 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

to make it defeq at reducible-and-instances transparency. Have you tried doing that?

The only solution I can think of for this is to make Set a one-field structure. Indeed I have not tried doing this yet.

@YaelDillies

Copy link
Copy Markdown
Contributor

Why does this have anything to do with Set being a one-field structure? Mind enlightening me?

@plp127

plp127 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Why does this have anything to do with Set being a one-field structure? Mind enlightening me?

When s is a set, ↥s is reducibly defeq to { x // x ∈ s }. So the lhs of Set.coe_setOf is { x // x ∈ {x | p x} }, and the rhs is { x // p x }. The issue is then making Set.mem_setOf defeq at lower transparency (currently it only works at default transparency). The reason this doesn't happen now is because Set.Mem and setOf are defs, and so won't be unfolded when checking Set.Mem (setOf p) a = p a. However, we also don't want Set α = α → Prop leaking out. So the solution I came up with is to make Set a one-field structure, which lets us have the eta rule at reducible transparency without confusing Set α with α → Prop.

@YaelDillies

Copy link
Copy Markdown
Contributor

I got this far myself, except for the fact that making it a one-field structure is the only remedy. Is the forbidden defeq for Set really going to leak out if we increase the transparency of the "translation functions" Set.Mem and setOf from semireducible to instance_reducible? After all, this only affects TC search. Is the issue somehow that the only way to make foo (bar x) reduce to x without foo nor bar themselves reducing is to make them the constructor/destructor of a one-field structure?

@plp127

plp127 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

If you have another solution I'd love to hear it!

@YaelDillies

Copy link
Copy Markdown
Contributor

Okay, let's fix it: #41506

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-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants