-
Notifications
You must be signed in to change notification settings - Fork 423
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
fix: WF.Fix, WF.GuessLex: Use expression cache #2982
Conversation
else the termination tactic is run on duplicated terms, e.g. in ``` def dup (a : Nat) (b : Nat := a) := a + b def rec : Nat → Nat | 0 => 1 | n+1 => dup (dup (dup (rec n))) ``` This pattern apperas in the wild in `Array.foldl` and friends.
Diff best viewed with Github’s “Hide whitespace” setting. I’ll be curious if this will show in the perf benchmarks. |
|
This interestingly breaks mathlib:
Will have to debug and improve our test suite. |
Very pecuilar. Here is a reproducer:
On
Why is that? Well, there are three calls to
(Not sure where the forth is) Note though that they have different contexts. In particular, the first one has an assumption Now let’s try to use that:
On master, we now use that extra assumption in the one call, but that’s fine, we don’t use it in the other calls. On this branch (at the time of writing), we cache the result, ignoring the context, and 💥 . Now it is clear that ignoring the context when caching is the basic mistake here, and could maybe be fixed (resetting the cache when going under binders for example). But I wonder how useful it is to try to use caching here in the first place,if the duplicated terms happen to appear in so many different contexts. Maybe there is not much of a point, and instead if we have a problem (not sure we even do in practice) we should avoid too much term duplicate. Hmm. A work-around for a user running into this is to let-bind before using
|
Better to use #3004 |
else the termination tactic is run on duplicated terms, e.g. in
This pattern apperas in the wild in
Array.foldl
and friends.