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
to know before reading: the rule matching process works with lots of macher functions definied at the creation of the rule. These functions are called recursively by one another. If a match is found, the rule rewrites the rhs swapping the slots ~x with the matched values.
The oooomm problem
oooomm stands for only one out of multiple matches.
one rule can have more than one match, if it contains a commutative operation such as + or *. for example @rule (~x)^(~m)*(~y)^(~n) => (~x, ~m, ~y, ~n)
can match x^2 * x^3 with both m=2, n=3, or m=3, n=2, . Currently only one match of the possible ones is returned, the first found. But let's say we have some conditions on the rule, as is suggested in the documentation we will use the where keyword: @rule (~x)^(~m)*(~y)^(~n) => (~x, ~m, ~y, ~n) where (~m)^(~n)==8
The where keyword is just syntactic sugar for condition ? result : nothing, so when the first match is found, the rule matcher finishes and returns the condition ? result : nothing expression. If the condition fails the rule returns nothing. But maybe another one of the possible matches satisfied the condition and the rule would have been applied, like in this example
Note
to know before reading: the rule matching process works with lots of macher functions definied at the creation of the rule. These functions are called recursively by one another. If a match is found, the rule rewrites the rhs swapping the slots
~xwith the matched values.The oooomm problem
oooomm stands for only one out of multiple matches.
one rule can have more than one match, if it contains a commutative operation such as
+or*. for example@rule (~x)^(~m)*(~y)^(~n) => (~x, ~m, ~y, ~n)can match
x^2 * x^3with both m=2, n=3, or m=3, n=2, . Currently only one match of the possible ones is returned, the first found. But let's say we have some conditions on the rule, as is suggested in the documentation we will use thewherekeyword:@rule (~x)^(~m)*(~y)^(~n) => (~x, ~m, ~y, ~n) where (~m)^(~n)==8The
wherekeyword is just syntactic sugar forcondition ? result : nothing, so when the first match is found, the rule matcher finishes and returns thecondition ? result : nothingexpression. If the condition fails the rule returns nothing. But maybe another one of the possible matches satisfied the condition and the rule would have been applied, like in this exampleMathematica does this:
possibilities to circumnavigate this without solving the issue
Note that this could be somewhat solved putting conditions as predicates on the variables like this:
in fact predicates are evaluated during the matching process. But this has two drawbacks:
real word occurrencies of this problem
to see a real word occurrence of this problem, read this