-
Notifications
You must be signed in to change notification settings - Fork 259
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
[Merged by Bors] - feat: improvements to congr!
and convert
#2606
Closed
Conversation
This file contains 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
…lib4 into kmill_congr_fallback
kmill
changed the title
feat: use simp-style fallback congruence lemmas
feat: improvements to Mar 7, 2023
congr!
and convert
…lib4 into kmill_congr_fallback
…community/mathlib4 into kmill_congr_fallback
…lib4 into kmill_congr_fallback
semorrison
added
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Mar 10, 2023
semorrison
added
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Mar 12, 2023
semorrison
removed
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Mar 13, 2023
fpvandoorn
reviewed
Mar 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bors d+
✌️ kmill can now approve this pull request. To approve and merge a pull request, simply reply with |
…lib4 into kmill_congr_fallback
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Mar 16, 2023
* There is now configuration for `congr!`, `convert`, and `convert_to` to control parts of the congruence algorithm, in particular transparency settings when applying congruence lemmas. * `congr!` now applies congruence lemmas with reducible transparency by default. This prevents it from unfolding definitions when applying congruence lemmas. It also now tries both the LHS-biased and RHS-biased simp congruence lemmas, with a configuration option to set which it should try first. * There is now a new `HEq` congruence lemma generator that gives each hypothesis access to the proofs of previous hypotheses. This means that if you have an equality `⊢ ⟨a, x⟩ = ⟨b, y⟩` of sigma types, `congr!` turns this into goals `⊢ a = b` and `⊢ a = b → HEq x y` (note that `congr!` will also auto-introduce `a = b` for you in the second goal). This congruence lemma generator applies to more cases than the simp congruence lemma generator does. * `congr!` (and hence `convert`) are more careful about applying lemmas that don't force definitions to unfold. There were a number of cases in mathlib where the implementation of `congr` was being abused to unfold definitions. * With `set_option trace.congr! true` you can see what `congr!` sees when it is deciding on congruence lemmas. * There is also a bug fix in `convert_to` to do `using 1` when there is no `using` clause, to match its documentation. Note that `congr!` is more capable than `congr` at finding a way to equate left-hand sides and right-hand sides, so you will frequently need to limit its depth with a `using` clause. However, there is also a new heuristic to prevent considering unlikely-to-be-provable type equalities (controlled by the `typeEqs` option), which can help limit the depth automatically. There is also a predefined configuration that you can invoke with, for example, `convert (config := .unfoldSameFun) h`, that causes it to behave more like `congr`, including using default transparency when unfolding.
Pull request successfully merged into master. Build succeeded:
|
bors
bot
changed the title
feat: improvements to
[Merged by Bors] - feat: improvements to Mar 16, 2023
congr!
and convert
congr!
and convert
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
congr!
,convert
, andconvert_to
to control parts of the congruence algorithm, in particular transparency settings when applying congruence lemmas.congr!
now applies congruence lemmas with reducible transparency by default. This prevents it from unfolding definitions when applying congruence lemmas. It also now tries both the LHS-biased and RHS-biased simp congruence lemmas, with a configuration option to set which it should try first.HEq
congruence lemma generator that gives each hypothesis access to the proofs of previous hypotheses. This means that if you have an equality⊢ ⟨a, x⟩ = ⟨b, y⟩
of sigma types,congr!
turns this into goals⊢ a = b
and⊢ a = b → HEq x y
(note thatcongr!
will also auto-introducea = b
for you in the second goal). This congruence lemma generator applies to more cases than the simp congruence lemma generator does.congr!
(and henceconvert
) are more careful about applying lemmas that don't force definitions to unfold. There were a number of cases in mathlib where the implementation ofcongr
was being abused to unfold definitions.set_option trace.congr! true
you can see whatcongr!
sees when it is deciding on congruence lemmas.convert_to
to dousing 1
when there is nousing
clause, to match its documentation.Note that
congr!
is more capable thancongr
at finding a way to equate left-hand sides and right-hand sides, so you will frequently need to limit its depth with ausing
clause. However, there is also a new heuristic to prevent considering unlikely-to-be-provable type equalities (controlled by thetypeEqs
option), which can help limit the depth automatically.There is also a predefined configuration that you can invoke with, for example,
convert (config := .unfoldSameFun) h
, that causes it to behave more likecongr
, including using default transparency when unfolding.