-
Notifications
You must be signed in to change notification settings - Fork 463
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
simp should try more specific lemmas first #4173
Comments
In type class synthesis, this code gets the result from the discrimination tree:
They purposefully use a stable sorting algorithm, and the results are used in the order back-to-front in the array. My interpretation is that this is good because the patterns with more * patterns are at the start of the array. The implementation of This means that earlier results aren't necessarily always more general than later results, but it does means that earlier results are usually more general than later results |
In my |
Thanks for the cross-references, that's helpful! It also means that my experiment in #4158 may have affected type class inference negatively, which may skew perf results. |
…#4434) This assigns priorities to the equational lemmas so that more specific ones are tried first before a possible catch-all with possible side-conditions. We assign very low priorities to match the simplifiers behavior when unfolding a definition, which happens in `simpLoop`’ `visitPreContinue` after applying rewrite rules. Definitions with more than 100 equational theorems will use priority 1 for all but the last (a heuristic, not perfect). fixes #4173, to some extent.
Consider the following code
The recursion in
DOW.isWorkday
is there so that we get equational theorems; with #3983 this would apply to a non-recursive function as well.The lemma
DOW.isWorkday.eq_5
should solve this rather quickly. But as the trace reveals,simp
tries the rather more complicatedDOW.isWorkday.eq_6
first!(In fact, it does something even weirder that I don’t fully understand, unfolding the definition and then trying to appliy
.match_2.eq_n
lemmas, or so; the trace is far longer than I would have expected here, so there may be another issue lurking here.)A possible fix, explored in #4158, might be to tweak the DiscrTree to return more specific lemmas first, but there might be other approaches (e.g. ordering all lemmas returned from the discrtree somehow, maybe trying unconstrainted lemmas before those with side-conditions), hence opening this as an issue.
The text was updated successfully, but these errors were encountered: