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

Fix associative-commutative relations and the use of term walk groundedness #40

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

brandonwillard
Copy link
Member

@brandonwillard brandonwillard commented Nov 14, 2021

ground_order doesn't really order terms in a way that avoids infinite recursion in term_walko (e.g. when called by the kanren.assoccomm goals). There should be a way to handle this—at least better than it currently does.

This PR adds a new test, test_eq_assoccomm_scaling, (an expected failure) that demonstrates how poorly the assoccomm goals perform.

The test creates a decently sized term graph containing assoc-comm operators and another one that differs only at the top-level (i.e. one graph starts with an add operator and the other a mul). This should be no problem, since the two cannot unify from the start due to the operator discrepancy. However, due to the way the assoccomm goals descend into all permutations, it currently takes too long to fail. The changes in this PR attempt to address this issue.

  • Get test_eq_assoccomm_scaling to pass

This PR replaces #27.

This comes along with a warning/clarification to the assoccomm relations.
They have always walked the first argument, which, when used with the
old `ground_order` would only account for improperly ordered terms when
the second argument was fully ground (and the first wasn't).  However, it
would perform this check repeatedly, incurring a full-traversal cost
on every iteration.  This inefficiency has been rectified.

The new "shallow" ground order should accomplish the same--and more--by
reordering according to "groundness" only at next level of traversal.
The assoccomm goals need to be updated so that they properly use this
shallow ordering, though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant