Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: find Decidable instances via unification #2816

Merged
merged 2 commits into from
Nov 12, 2023
Merged

Conversation

kim-em
Copy link
Collaborator

@kim-em kim-em commented Nov 4, 2023

I've been finding situations where these simp lemmas don't fire, because the decidable instance is not the one found by typeclass inference.

This perhaps deserves a deeper fix, but I want to see if just changing the binder types here suffices for my purposes.

(Previously this behaviour was being hidden by the default decide := true in simp.)

@kim-em kim-em added the WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. label Nov 4, 2023
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Nov 4, 2023
@leodemoura
Copy link
Member

This perhaps deserves a deeper fix,

Agreed.

but I want to see if just changing the binder types here suffices for my purposes.

Happy to merge the workaround. We have used it in other places.

@kim-em kim-em marked this pull request as ready for review November 5, 2023 23:00
@kim-em kim-em added awaiting-review Waiting for someone to review the PR and removed WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. labels Nov 5, 2023
@kim-em kim-em force-pushed the decide_eq_true_eq branch from f83f28b to 904a602 Compare November 5, 2023 23:01
Copy link
Contributor

github-actions bot commented Nov 6, 2023

  • ❗ Mathlib CI will not be attempted unless you rebase your PR onto the 'nightly' branch. (2023-11-06 00:11:29)

@leodemoura leodemoura removed the awaiting-review Waiting for someone to review the PR label Nov 6, 2023
@kim-em kim-em self-assigned this Nov 6, 2023
@kim-em kim-em force-pushed the decide_eq_true_eq branch from 904a602 to 9f4f2a8 Compare November 6, 2023 11:22
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 6, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Nov 6, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Nov 11, 2023
@kim-em kim-em enabled auto-merge (squash) November 11, 2023 23:43
@kim-em kim-em merged commit f3c3a1b into master Nov 12, 2023
15 checks passed
@@ -806,6 +806,12 @@ decidability instance instead of the proposition, which has no code).

If a proposition `p` is `Decidable`, then `(by decide : p)` will prove it by
evaluating the decidability instance to `isTrue h` and returning `h`.

Because `Decidable` carries data,
when writing `@[simp]` lemmas which include a `Decidable` instance on the LHS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the corollary here that you can no longer use the lemma with if no Decidable instance is on the RHS? And so in those cases, you need to write two versions of the same lemma?

(Re-posted as this got lost as a non-PR comment)

arthur-adjedj pushed a commit to arthur-adjedj/lean4 that referenced this pull request Nov 20, 2023
Because `Decidable` carries data,
when writing `@[simp]` lemmas which include a `Decidable` instance on the LHS,
it is best to use `{_ : Decidable p}` rather than `[Decidable p]`
so that non-canonical instances can be found via unification rather than
typeclass search.

(Previously this behaviour was often being hidden by the default `decide :=
true` in `simp`.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants