-
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
Prevent false positives in coinductive cycles for recursive solver #683
Prevent false positives in coinductive cycles for recursive solver #683
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know enough about the recursive solver to be able to comment on this in any meaningful way.
Going to cc @nikomatsakis and @flodiebold since they might have better feedback.
// Find all possible false positives in the graph below the | ||
// start of the coinductive cycle | ||
for (index, node) in self.nodes[dfn.index + 1..].iter().enumerate() { | ||
if node.solution.is_ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. So, one consideration here comes with the idea of negative coinduction cycles. Currently, we don't allow them (in SLG; in recursive, they might still be allowed?). But the assumption is here is that an invalid solution is okay because it can never be used to "prove" coinduction. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. It might be a false assumption on my side, yet I'm still looking for examples where the approach doesn't work as intended. Regarding negative cycles in general, I did not really think about them as #526 seems to indicate that they are currently not supported/needed in the recursive solver.
While thinking about this rather "hacky" solution, I had a more elaborate idea: |
So, I thought a bit more about both approaches:
I'm not sure whether either one of these approaches would be acceptable for Chalk but it might help finding an even better solution while improving soundness at least a bit. |
Closed in favour of #690 . |
…tives, r=nikomatsakis Coinduction handling for recursive solver This PR is meant to address the issue of invalid result in coinductive cycles as described in #399 . It also fixes the two coinduction tests related to that issue (i.e. coinductive_unsound1 and coinductive_multicycle4). As such it is an improved version of #683 as it uses "solution0" described [here](https://hackmd.io/2nm3xPJ1TTGc2r4iiWi4Lg) and discussed [here](https://zulip-archive.rust-lang.org/144729wgtraits/71232coinduction.html) to handle more complicated coinductive cycles.
This PR is meant to address the issue of false positives in coinductive cycles as described in #399 . It also fixes the two coinduction tests related to that issue (i.e.
coinductive_unsound1
andcoinductive_multicycle4
).The PR adds a simple mechanisms to delay caching of results inside the coinductive cycle and to store only valid results that can not be false positives. This is done by a simple over-approximation that could potentially increase runtime. The exact mechanism is also described in the corresponding book chapter. In general, it follows the idea from #399 to start with a positive result instead of the negative one but delays its effects on other goals until it is know whether this assumption was correct.
Albeit the mechanism comes with two new tests and was also rather carefully designed, there could be some edge cases that I missed where the delayed caching introduces new problems. Thus the draft status. I'd be thankful for any comments and thoughts on this.