-
Notifications
You must be signed in to change notification settings - Fork 182
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
normalization and the meaning of unique #44
Comments
Evaluating the "cannot prove" rule on the various examples shows that it works well, modulo the imprecision around Example 1. In the first case ( Example 2. Negation and binders. We would yield Example 3. Unifying the |
After #45, this might be basically done -- the only thing left might be changing how we handle negative reasoning, if we decide we want more precise results. That could also be a separate bug. |
That's not quite right. The reading is rather: if this goal is to ever work, the existentials must take the given values. |
@aturon updated |
So I resolved this in #60. The first key observation is that free universally quantified variables (i.e., Revisiting my examples: Example 1.
Example 2.
Example 3.
|
We are still wrestling to some extent with the meaning of "unique" and how to handle negative reasoning. In #38, @aturon made a number of changes, but I have some reservations about some of the details of that PR. There are also some scenarions that are still not handled very well in that PR that we may want to consider.
When @aturon and I last spoke, we had decided to shift the approach of the PR in two ways -- at least, if I remember correctly. First, to introduce a
CannotProve
variant, which is used to mean that the system cannot prove a particular goal, and never will be able to, but that the goal may hold for some instantiations of the universally quantified variables in scope (but it also may not hold for some instantiations). In particular, this would be returned when you attempt to unify (e.g.)!1
and!2
or!1
andVec<T>
. Currently, those unification attempts "succeed" with the "ambiguous" flag set to true, and henceforall<T,U> { T = U }
yields an ambiguous result. Under this proposal it would yieldCannotProve
.The meaning of the various return values for proving goal G is thus:
In general, the modality controls whether we consider the set of impls/environmental clauses/etc to be a closed world.
Just adding
CannotProve
alone doesn't quite give us enough resolution to always negate the way we might want to. In particular,not { G }
whereG
yieldsCannotProve
also yieldsCannotProve
, and hencenot { forall<T,U> { T = U } }
is also going to yield up "cannot prove" (as wouldforall<T,U> { not { T = U } }
). It is plausible that we could instead say thatnot { forall }
isUnique
andforall { not }
isError
; but to handle it, we would have to track the "sense" of a goal more deeply (right now, the fulfillment context cannot distinguish between anot
inside or outside theforall
binder).If we add
CannotProve
, we ought to be able to remove the "special treatment" that we give to the environment right now (which makes me uncomfortable in any case, at least in its current form). In particular, we have some logic that makes an ambiguous unification in the environment become a "hard error", which implies thatforall<T,U> if (T: Foo) { U: Foo }
will reject usingT: Foo
, even thoughT = U
yields "ambiguous". Once we haveCannotProve
, thenT = U
can yieldCannotProve
, and we are universally justified in ignoring proof routes that yieldCannotProve
.Test cases
Some interesting benchmarks and examples to use to evaluate possible solutions:
Example 1: Maybe implements.
It's vital here that we treat
T
as possibly implementingFoo
due to the impls. So that's at least the minimum bar.Example 2: negation and binders.
Example 3: Normalization.
Given the query
forall<T> { if (T: Iterator<Item = i32>) { T: Iterator } }
, current code can fail with ambiguity. The environment suppliesT: Iterator<Item = i32>
but the program clauses supplyi32: Iterator<Item = i32>
.The text was updated successfully, but these errors were encountered: