Added remaining possibility messages to the rules.

parent 0551ec1b
...@@ -53,7 +53,7 @@ def expand_single(root, args): ...@@ -53,7 +53,7 @@ def expand_single(root, args):
return scope.as_nary_node() return scope.as_nary_node()
MESSAGES[expand_single] = _('Expand {1}({2}) to {1}({2[0]}) + {1}({2[1]}).') MESSAGES[expand_single] = _('Expand {1}({2}).')
def expand_double(root, args): def expand_double(root, args):
...@@ -74,5 +74,4 @@ def expand_double(root, args): ...@@ -74,5 +74,4 @@ def expand_double(root, args):
return scope.as_nary_node() return scope.as_nary_node()
MESSAGES[expand_double] = _('Expand ({1})({2}) to {1[0]}{2[0]} + {1[0]}{2[1]}' MESSAGES[expand_double] = _('Expand ({1})({2}).')
' + {1[1]}{2[0]} + {1[1]}{2[1]}.')
...@@ -171,7 +171,7 @@ def add_nominators(root, args): ...@@ -171,7 +171,7 @@ def add_nominators(root, args):
# TODO: convert this to a lambda. Example: 22 / 77 - 28 / 77. the "-" is above # TODO: convert this to a lambda. Example: 22 / 77 - 28 / 77. the "-" is above
# the "28/77" division. # the "28/77" division.
MESSAGES[add_nominators] = _('Add nominators {1[0]} and {2[0]} of the division.') MESSAGES[add_nominators] = _('Add the nominators of {1} and {2}.')
def match_expand_and_add_fractions(node): def match_expand_and_add_fractions(node):
......
...@@ -82,6 +82,9 @@ def double_negation(root, args): ...@@ -82,6 +82,9 @@ def double_negation(root, args):
return node[0][0] return node[0][0]
MESSAGES[double_negation] = _('Remove double negation in {1}.')
def match_negated_division(node): def match_negated_division(node):
""" """
-a / -b -> a / b -a / -b -> a / b
...@@ -109,6 +112,8 @@ def single_negated_division(root, args): ...@@ -109,6 +112,8 @@ def single_negated_division(root, args):
""" """
a, b = args a, b = args
# FIXME: "-a/b" results in "-(a/b)", which will cause a loop.
return -(a / b) return -(a / b)
...@@ -127,6 +132,3 @@ def double_negated_division(root, args): ...@@ -127,6 +132,3 @@ def double_negated_division(root, args):
MESSAGES[double_negated_division] = \ MESSAGES[double_negated_division] = \
_('Eliminate top and bottom negation in {1}.') _('Eliminate top and bottom negation in {1}.')
MESSAGES[double_negation] = _('Remove double negation in {1}.')
...@@ -38,8 +38,7 @@ def add_numerics(root, args): ...@@ -38,8 +38,7 @@ def add_numerics(root, args):
return scope.as_nary_node() return scope.as_nary_node()
MESSAGES[add_numerics] = _('Combine the constants {1} and {2}, which' MESSAGES[add_numerics] = _('Combine the constants {1} and {2}.')
' will reduce to {1} + {2}.')
#def match_subtract_numerics(node): #def match_subtract_numerics(node):
...@@ -106,6 +105,9 @@ def divide_numerics(root, args): ...@@ -106,6 +105,9 @@ def divide_numerics(root, args):
return Leaf(n / d) return Leaf(n / d)
MESSAGES[divide_numerics] = _('Divide constant {1} by constant {2}.')
def match_multiply_zero(node): def match_multiply_zero(node):
""" """
a * 0 -> 0 a * 0 -> 0
...@@ -201,3 +203,6 @@ def multiply_numerics(root, args): ...@@ -201,3 +203,6 @@ def multiply_numerics(root, args):
scope.remove(n1) scope.remove(n1)
return scope.as_nary_node() return scope.as_nary_node()
MESSAGES[multiply_numerics] = _('Multiply constant {1} with {2}.')
...@@ -62,8 +62,7 @@ def add_exponents(root, args): ...@@ -62,8 +62,7 @@ def add_exponents(root, args):
return scope.as_nary_node() return scope.as_nary_node()
MESSAGES[add_exponents] = _('Add the exponents of {1} and {2}, which' MESSAGES[add_exponents] = _('Add the exponents of {1} and {2}.')
' will reduce to {1[0]}^({1[1]} + {2[1]}).')
def match_subtract_exponents(node): def match_subtract_exponents(node):
...@@ -186,8 +185,7 @@ def subtract_exponents(root, args): ...@@ -186,8 +185,7 @@ def subtract_exponents(root, args):
return a ** (p - q) return a ** (p - q)
MESSAGES[subtract_exponents] = _('Substract the exponents {1} and {2},' MESSAGES[subtract_exponents] = _('Substract the exponents {2} and {3}.')
' which will reduce to {1[0]}^({1[1]} - {2[1]}).')
def multiply_exponents(root, args): def multiply_exponents(root, args):
...@@ -199,8 +197,7 @@ def multiply_exponents(root, args): ...@@ -199,8 +197,7 @@ def multiply_exponents(root, args):
return a ** (p * q) return a ** (p * q)
MESSAGES[multiply_exponents] = _('Multiply the exponents {1} and {2},' MESSAGES[multiply_exponents] = _('Multiply the exponents {2} and {3}.')
' which will reduce to {1[0]}^({1[1]} * {2[1]}).')
def duplicate_exponent(root, args): def duplicate_exponent(root, args):
...@@ -217,8 +214,7 @@ def duplicate_exponent(root, args): ...@@ -217,8 +214,7 @@ def duplicate_exponent(root, args):
return result return result
MESSAGES[duplicate_exponent] = _('Duplicate the exponents {1} and {2},' MESSAGES[duplicate_exponent] = _('Duplicate the exponent {2}.')
' which will reduce to {1[0]}^({1[1]} * {2[1]}).')
def remove_negative_exponent(root, args): def remove_negative_exponent(root, args):
...@@ -230,6 +226,9 @@ def remove_negative_exponent(root, args): ...@@ -230,6 +226,9 @@ def remove_negative_exponent(root, args):
return L(1) / a ** p return L(1) / a ** p
MESSAGES[remove_negative_exponent] = _('Remove negative exponent {2}.')
def exponent_to_root(root, args): def exponent_to_root(root, args):
""" """
a^(1 / m) -> sqrt(a, m) a^(1 / m) -> sqrt(a, m)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment