-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add option to apply a rule multiple times if the input pattern is matched multiple times #23
Comments
I believe https://github.com/socraticorg/mathsteps/blob/master/lib/TreeSearch.js |
If I'm understanding things correctly, once |
Sorry, Kevin. I'm not quite following your train of thought there. But I can provide you with a better explanation of I'm not sure which PRs you are referencing. Maybe you could elaborate a little more. |
In #34 we apply the I'll have to step through the |
Even though TreeSearch.js checks each search function in the list, it only applies one of them and only applies it once (afaict). |
@evykassirer may provide better insight than I can in terms of the functionality of |
Yeah pretty sure that's true What do you want math-rules to do though? Match a certain instance of a rule? Match every instance of it throughout the whole tree? From my understanding, it was a single instance matcher, and a tool that could be used to see if a particular tree (at the top level) matched a rule. One you get deeper, you'll be wanting to return tree positions and stuff so whoever's using math-rules knows where all the rule matchings are (not sure if you were already planning on doing that) For mathsteps, I'd rather use a single rule matcher, but if you want to add the option in math-rules I won't argue against it haha. I'm hoping to read through how all this stuff works in the next month or two so I can understand how the pieces fit together and and help work on it! |
A conventional CAS like MathPiper is designed to keep applying rules to an expression until the expression stops changing. These rule applications are not recorded, so a conventional CAS is not useful for step-by-step equation solving. The first thing I did when I started to give MathPiper step-by-step capabilities is to create a procedure that returned all the tree positions which matched a given pattern without applying any rules:
The step-by-step code then inspects the subtrees that are at these positions to determine if a rule should be applied to them. However, it is sometimes also useful to apply a rule using traditional CAS mode if the rule applications don't need to be recorded. For example, the following rule replaces all unary minus operators that have numbers as operands with multiplication:
I like the idea of having math-rules provide the option to apply a rule multiple times because it gives it useful conventional CAS capabilities in addition to its step-by-step capabilities. |
Thanks for the input guys :D Glad to get multiple perspectives on this. |
I've create a new issue to return the paths of the nodes being modified in the input and output ASTs, see #40. |
e.g. PRODUCT_RULE should be able to handle this case:
The text was updated successfully, but these errors were encountered: