All different notations of an arithmetic expression?

50 Views Asked by At

There is a fixed arithmetic expression with $+$ and $\times$ operators, some variables, and no constants. How can I efficiently generate all its different notations? Two expressions are considered different if the resulting expression trees are not isomorphic. The corresponding operands of every operation must be specified; thus, brackets must be used when necessary.

Example 1: All different notations of $a+b+c$

  • $(a+b)+c$
  • $a+(b+c)$
  • $b+(a+c)$

Example 2: $a\times(b+c)$

  • $a\times(b+c)$
  • $a\times b+a\times c$

Example 3: $a\times a+b\times b+a\times b+a\times b$:

  • $((a\times a+b\times b)+a\times b)+a\times b$
  • $(a\times a+b\times b)+(a\times b+a\times b)$
  • $(a\times a+a\times b)+(b\times b+a\times b)$
  • $((a\times a+a\times b)+b\times b)+a\times b$
  • $((a\times a+a\times b)+a\times b)+b\times b$
  • $a\times (a+b)+(b\times b+a\times b)$
  • $(a\times (a+b)+b\times b)+a\times b$
  • $(a\times (a+b)+a\times b)+b\times b$

  • $b\times (a+b)+(a\times a+a\times b)$

  • $(b\times (a+b)+a\times a)+a\times b$
  • $(b\times (a+b)+a\times b)+a\times a$

  • $a\times(a+b)+b\times(a+b)$

  • $(a+b)\times(a+b)$

I hope I'm not missing any notation for the last example. I should also note that for this example, a notation like $(a\times a)+b\times b+2\times a\times b$ is not allowed as it contains constants.

Thank you.

1

There are 1 best solutions below

7
On

There are more: $$a+b+c=(a+b)+c=a+(b+c)=(b+a)+c=b+(a+c)=(a+c)+b=$$ $$=a+(c+b)=(c+a)+b=c+(a+b)=(b+c)+a=$$ $$=b+(c+a)=(c+b)+a=c+(b+a).$$