-
Notifications
You must be signed in to change notification settings - Fork 183
move universes from environment into the inference table #73
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
Conversation
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
This way we avoid hard-coding assumption that we are instantiating always to existential variables.
The existing technique of creating an identity substitution was less nice.
Also remove some unused methods that did not apply to quantified values.
This method will canonicalize the universes in a value, yielding a `UCanonical` value, and also produce a map that can convert those universes back from canonical form.
If goals are not yet leaf goals, then we solve them by simplifying them.
This seems to fix some bugs. I don't know why.
1b84f39
to
110a071
Compare
I suppose I will merge this. |
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.
This PR does a pretty big refactoring to how we handle universes, initially suggested by @arielb1. Along the way, it fixes a few random bugs and refactored a few other things.
Perhaps the main goal of this branch is to do a more thorough form of canonicalization when creating queries. In particular, we currently canonicalize by taking all free, existentially quantified variables and "renumbering" them in order of their appearance, basically. But we could do even better if we canonicalized the universally quantified things to.
Consider this example. Here is an initial query:
when we push this goal, we will wind up with something like
then when we canonicalize this query we get something like:
Now consider this query, which is the same but for a (unused) forall:
when we push this goal, we will wind up with something like
If we canonicalize that, we get a distinct result:
But really they are the same query.
In this branch, we have a notion of "universal canonicalization" that takes an existentially canonical thing (like what we have above) and renumbers the universally quantified names in order of left-to-right appearance. So in that case both queries wind up canonicalized to:
We then keep a "universe map" that goes from the canonicalized universe (say, U1 here) back to the original universe (U2, in our second example).
In the final commit, this change to introduce canonical universes lets us go one step further. We can remove the
universe
field from the environment altogether and instead just track the 'max universe' in the inference table. Basically, every time we create a new universe, we just increment this (almost) global counter. And whenever we would cross between inference tables, that's precisely the points where we are performing universal canonicalization anyway.I also did a few other refactorings along the way. In fact, I just remembered one I overlooked. (I also encountered a kind of serious problem with how we do normalization, but I'll describe that in a separate issue.)
cc @aturon @scalexm