[Merged by Bors] - feat: subsingleton tactic#12525
Closed
Conversation
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type, usually because there is a `Subsingleton` instance. It also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance, but it can also transform a `@HEq α x β y` goal into a `α = β` goal using `Subsingleton.helim`. The tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This PR also eliminates some uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
adomani
reviewed
Apr 29, 2024
…lib4 into kmill_subsingleton
Contributor
Author
|
!bench |
Collaborator
|
Here are the benchmark results for commit 6ac7cfe. |
…lib4 into kmill_subsingleton
Contributor
|
bors merge |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
|
Build failed (retrying...): |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
|
Build failed (retrying...): |
Contributor
|
bors r- |
Contributor
|
Canceled. |
Contributor
|
Can you merge master, fix the build, and send it back to bors? |
Contributor
|
✌️ kmill can now approve this pull request. To approve and merge a pull request, simply reply with |
…lib4 into kmill_subsingleton
Contributor
Author
|
bors r+ |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
Author
|
bors r- |
Contributor
|
Canceled. |
Contributor
Author
|
bors r+ |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
|
This PR was included in a batch that was canceled, it will be automatically retried |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
|
Build failed (retrying...): |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jul 1, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
Contributor
|
Pull request successfully merged into master. Build succeeded: |
subsingleton tacticsubsingleton tactic
dagurtomas
pushed a commit
that referenced
this pull request
Jul 2, 2024
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
subsingletontactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via aSubsingletoninstance (viaSubsingleton.elim), but it also handles some cases where morally the types are subsingletons; for example, it can prove that twoBEqinstances are equal if they both haveLawfulBEqinstances. For heterogeneous equality, it tries theHEqversion of proof irrelevance.This tactic avoids the issue where
is a "proof" that every type is trivial. Changing this to
by subsingletonprevents it from assigning the universe level metavariable inSort _to0.This tactic can accept a list of instances
subsingleton [inst1, inst2, ...]to do something likehave := inst1; have := inst2; ...; subsingleton, but it elaborates them in a lenient way (likesimparguments), and they can even be universe polymorphic. For example,subsingleton [CharP.CharOne.subsingleton]is allowed even though the type ofCharP.CharOne.subsingletonisSubsingleton ?Rwith a number of pending instance problems.This PR also eliminates a number of uses of
Subsingleton.elim, either by switching acongrtocongr!or by using this new tactic.