You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation is quite incomplete and it only deals with merging literals, so it can't cancel out variables; e.g.
(x+x)-x ===> x
It would be better to optimize a whole arithmetic expression at once. Gather all variables in one list, all literals in one list and all non-arithmetic sub-terms in one list. Then make a new optimized expression by combining the three lists.
However, doing this compositionally will probably lead to a lot of re-traversals of the same sub-terms, so the optimization framework will probably have to be modified so that arithmetic optimization only happens at feasible places (i.e. arithmetic sub-terms whose parents are not arithmetic expressions).
We should also think about how to deal with examples like this one (reported by Gergely):
The current implementation is quite incomplete and it only deals with merging literals, so it can't cancel out variables; e.g.
It would be better to optimize a whole arithmetic expression at once. Gather all variables in one list, all literals in one list and all non-arithmetic sub-terms in one list. Then make a new optimized expression by combining the three lists.
However, doing this compositionally will probably lead to a lot of re-traversals of the same sub-terms, so the optimization framework will probably have to be modified so that arithmetic optimization only happens at feasible places (i.e. arithmetic sub-terms whose parents are not arithmetic expressions).
We should also think about how to deal with examples like this one (reported by Gergely):
The result is correct, but not ideal from a readability point of view.
The text was updated successfully, but these errors were encountered: