[WIP] Negative exponent matching #750
Draft
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 builds on top of the defslot feature i added in another pr. The aim is for rule
@rule (~x)^(~m) => ..something..
to match 1 / (x^2) with m=-2.I did that by modifying the
term_matcher
anddefslot_term_matcher
functions, they are functions called when the rule gets applied, and they have to check wheter a certain term (the pattern to match in the ruel, like in this example(~x)^(~m)
) matches with certain data (1/(x^2) in this example). I did basically the same modification to the two of them. They work by using a loop function called recursively, that uses some matcher functions (1) that assign the values to their label. The modification di did interm_matcher
is:in
defslot_term_matcher
i did a similar thing, and if after all this still doesnt find a match, also tries to match with the default value of defslotI find it a bit messy