-
Notifications
You must be signed in to change notification settings - Fork 124
[WIP] Condition inside rule match process, not just at the end #772
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
Draft
Bumblebee00
wants to merge
26
commits into
JuliaSymbolics:master
Choose a base branch
from
Bumblebee00:condition_inside_rule
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] Condition inside rule match process, not just at the end #772
Bumblebee00
wants to merge
26
commits into
JuliaSymbolics:master
from
Bumblebee00:condition_inside_rule
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… expressions like (1/...)^(...)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this pr aims to solve the oooomm problem described in this issue
Proposed solution
basically it works like this: when the rule is created with the macro, another argument is passed to the function that creates the matchers. This argument is a function that given a dictionary of corrispondences (slot, matched value), substitutes every slot with its mached value in the condition expression (passed after the where keyboard) and evaluates it to true or false, this function is called
condition.
Then every time a term matches succeeds and should call the next matcher or the succes function, before that I put a check, thecheck_conditions
function.check_conditions
tries (with a try block) to callcondition
. If we are not yet at the end of the matching process, the dictionary will not be complete and the condition function will error, so thecheck_conditions
will return true and make the matching process continue. If instead condition doesnt error, it means we are at the end of the matching process, it will be true or false, and depending on that we continue or no the matching process.With this implementation we have:
Problems of the proposed solution
As said before if we are not yet at the end of the matching process ,the dictionary of (slot, matched value) will be probably incomplete, and probably the condition expression cannot be built and evaluated.
In particular if one has a condition that requires a lot of matched variables, and the commutative operation is not the first of the expression, for every possible rule match the condition expression will try to be build but without success, and the rule will be evaluated only at the end, effectively making this proposed solution behave in the same way as the original code. For example
in this rule the ~z slot is not matched before the matchers try al the possible combinations of arguments in the multiplication. Therfore the conditions can never be built