Comments (4)
From the manual:
Be aware that enabling this flag might lead to an exponential slowdown in instance resolution and possibly (apparent) looping behaviour.
Looks like you found some actually looping behaviour. The problem seems to be that the instance goals are solved in the wrong order: when we try to solve the argument to ¿_¿
, we haven't solved the argument to _≤_
yet, so instance search (with --overlapping-instances
) falls into a death spiral trying to apply the _×_
instance over and over again.
I'm not sure if this is what you should expect from using --overlapping-instances
or if it's an actual bug. @jespercockx ?
It also reproduces on master.
from agda.
The --overlapping-instances
makes Agda more eager to start recursively searching for instances before it has determined a unique instance candidate at the top-level. Hence enabling it can make Agda go down an infinite rabbit hole while that rabbit hole could actually be ruled out if we just postpone the instance search a bit. So it is in general not a conservative extension. Perhaps this should be mentioned explicitly in the user manual.
For this particular example I agree that there's no real reason for Agda to loop. My guess would be that the instance search kicks in "too early" before we have propagated the annotated type into the type of the instance meta. In other words, Agda just sees an instance meta of type Dec _X
and before it has figured out the actual value of _X
it eagerly tries the instance for Dec (A × B)
.
We used to have a heuristic that prevented these cases, but it was very buggy and unmaintained and we ended up removing it (see #3419). In general it is easy to point at specific examples and point out "Oh it's obvious what I mean, why is Agda so stupid?" but designing a heuristic that works well in all cases has so far turned out to be impossible. (And before you say "why can't we just wait until the full type of the instance meta is resolved?" first take a look at #723 and #2760.)
In general I would discourage the use of --overlapping-instances
and instead either redesign your classes/instances so it is not necessary, or (if you must) implement your own resolution with a macro.
from agda.
I understand that the heuristics cannot be principled and there will always be corner cases.
What I am suggesting however pertains to the cases where non-overlapping search succeeds; couldn't the overlap search be redesigned in a conservative way, where first the non-overlapping search is tried and only if it fails do the heuristics kick in?
from agda.
What happens without overlapping instances is that the instance constraint is first postponed and later tried again when we have more information about the goal type. So what you are asking for is that we also postpone instance constraints with overlapping instances, and only try to solve it at the last possible moment (i.e. just before it would get frozen). That would require messing with the order in which constraints are solved, but it seems possible in theory. I believe @UlfNorell once implemented something like that, but I am not sure what happened with it since then.
from agda.
Related Issues (20)
- Instance resolution runs too late, leads to `with`-abstraction failure HOT 16
- Test suite needs to be run with debug printing enabled HOT 1
- Internal error in Mimer with module parameter and matching
- Instance resolution failure in Agda 2.6.4 HOT 6
- Mimer drops part of the solution with module parameter
- Citation.cff HOT 1
- Prune the `Makefile` HOT 7
- Delete the GitHub Wiki HOT 3
- Migrate the Chalmers Wiki HOT 4
- Prune `Setup.hs` HOT 5
- Reorganize `HACKING.md`
- Merge `.authorspellings` and `.mailmap` HOT 1
- Mimer internal error when querying `recRecursive` HOT 1
- Interactive highlighting remnants with lambda-where
- Pattern synonyms with named arguments can be defined but not used HOT 3
- Automatically create names for syntax
- Mangled trX/Con clause for indexed type with green slime
- Why do we `reduce` and `instantiateFull` constraints? HOT 2
- Use of Non-terminating Function in Data Declaration Makes Typechecker Loop HOT 4
- Misprinted domain-free parameters with cohesion attribute HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agda.