Skip to content
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

Coinduction handler for the recursive solver #690

Conversation

firefighterduck
Copy link
Contributor

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 and coinductive_multicycle4). As such it is an improved version of #683 .

The PR adds a dedicated handler mechanisms for delaying insertion of results into the cache if they occur inside a coinductive cycle. This is done by tracking dependencies of result to coinductive assumptions (via the Minimums) and storing those "premature" results in a temporary cache. 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.

@firefighterduck
Copy link
Contributor Author

@nikomatsakis FYI PR #683 that you wanted to have a look at was closed in favour of this PR.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @firefighterduck for not reviewing earlier. I'm posting some random comments that had accrued, but don't feel the need to respond to them -- I want to give this another pass today. I have this "feeling" like there's a simplification possible, but I'm having a hard time articulating precisely what I mean so I need to block out some time for that.

This search for a disproof is done by the standard recursive solving process described in the sub-chapters before.

Albeit this approach would allow for the handling of mixed inductive/co-inductive cycles, these are actually handled as errors to prevent propagation of the assumed provability outside of the coinductive cycle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Albeit this approach would allow for the handling of mixed inductive/co-inductive cycles, these are actually handled as errors to prevent propagation of the assumed provability outside of the coinductive cycle.
Although this approach would allow for the handling of mixed inductive/co-inductive cycles, these are actually handled as errors to prevent propagation of the assumed provability outside of the coinductive cycle.

Albeit is an odd word to use here -- I think maybe yo mean "Allow"? In general I had a hard time figuring out just what this paragraph means though.

pub(crate) struct Minimums {
pub(crate) positive: DepthFirstNumber,
pub(crate) coinductive_cycle_starts: FxHashSet<DepthFirstNumber>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need a set of starts

Copy link
Contributor Author

@firefighterduck firefighterduck Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some kind of over-approximation by an upper and a lower bound DFN would probably work here as well. If then a cycle start depends on another cycle start, all results inside the inner cycle could simply be dropped, as tracking the precise dependencies would be rather cumbersome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to exchange the set for two bounds. The upper bound represents the current innermost cycle whereas the lower bound represents whether there exists an intercycle dependency.

@firefighterduck firefighterduck force-pushed the recursive-coinduction-handler branch from 3a097cc to 3df6b42 Compare March 9, 2021 17:17
pub(crate) struct CoinductionHandler<I: Interner> {
/// Heap of start DFNs for nested cycles.
/// The innermost cycle start is the first element in the heap.
cycle_start_dfns: BinaryHeap<DepthFirstNumber>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heap could also be vector that then needs to be sorted after every insertion. Otherwise, the order in which goals are evaluated would matter for intercycle dependencies.

@nikomatsakis
Copy link
Contributor

I'm going to close this PR for now in favor of the other approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants