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

AC Rules/Loop Prevention for MatchCore rewriting backend #9

Closed
1 of 5 tasks
0x0f0f0f opened this issue Jan 30, 2021 · 2 comments
Closed
1 of 5 tasks

AC Rules/Loop Prevention for MatchCore rewriting backend #9

0x0f0f0f opened this issue Jan 30, 2021 · 2 comments

Comments

@0x0f0f0f
Copy link
Member

0x0f0f0f commented Jan 30, 2021

While the egg-like backend fully supports Associative-Commutative (and Distributive) rules (see also #8), the MatchCore backend is still heavily affected by non-terminating (infinite) rewriting loops.
When compiling theories for the MatchCore backend, a few improvements could be done:

  • Identify (and disallow for MatchCore?) associative, commutative and distributive rules, and other rules known to cause computational loops.
  • Keep an history of the expressions that have been visited by the classic fixpoint recursive rewriting algorithm during reduction. Halt, warn and return the expression when a loop is detected. (A vector of hash-es for storing history can suffice, but vulnerable to collisions)
  • Consider a "fuel" mechanism, used for example in GHC. Based on the input expression, at the beginning of reduction each rule is assigned a "fuel" counter. When the left hand of a rule is matched repeatedly, decrement its fuel. If a rule runs out of fuel (e.g. because of a loop due to commutativity or associativity), temporarily remove it from the theory and recompile the pattern matching block, after the expression changes, reintroduce the rule (in which position??) and reset its fuel counter.
  • Consider designing a smarter algorithm that considers both fuel and reduction history.
  • (Hardest point) Consider compile time transformations and rule reordering for the MatchCore backend, when a set of rewriting rules can be inferred to be terminating a priori.
@0x0f0f0f 0x0f0f0f added this to To do in Main Project via automation Jan 30, 2021
@0x0f0f0f 0x0f0f0f moved this from To do to In progress in Main Project Feb 2, 2021
@0x0f0f0f
Copy link
Member Author

In MT 1.0 we now have the SymbolicUtils.jl pattern matcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Main Project
In progress
Development

No branches or pull requests

1 participant