4

Let $expr$ be an algebraic expression involving natural numbers, addition operator and multiplication operator, e.g., $$(1+2)\cdot(3+4 \cdot 5)+6.$$ By iteratively applying the distributivity of multiplication over addition to $expr$, that is, transforming subexpressions of the form $(expr_1 + expr_2)\cdot expr_3$ into the form $(expr_1\cdot expr_3) + (expr_2 \cdot expr_3)$, until it is no longer possible, at each iteration applying the distribituvity rule to the first (the "leftmost" one) subexpression that it can be applied to, one obtains a sum of products. No other rules are applied, no addition and no multiplication is actually performed. For the above example, the result would be $$1\cdot 3 + 1\cdot 4 \cdot 5 + 2 \cdot 3 + 2\cdot 4 \cdot 5 + 6.$$

Is the obtained sum of products unique?

If yes (as I believe is the case), is there a general result that this fact follows from?

$\textbf{Edit:}$

  • the distributivity rule $expr_1 \cdot (expr_2+ expr_3) \rightarrow (expr_1 \cdot expr_2 )+ (expr_1 \cdot expr_3)$ can also be applied

$\textbf{Solution:}$ By formalizing properly the reduction rules that I had in mind, I got a reduction system that is both locally confluent and terminating. Now the uniqueness of the normal form follows from the Newman's lemma.

  • 1
    Do you know about Newman's diamond lemma? I suspect it leads to a fairly straightforward proof of this once you have formalized the question (there are a few choices to be made in formalizing it, such as whether you encode sums $a_1+a_2+\cdots+a_k$ as multisets or as tuples, and likewise for products). – darij grinberg Aug 08 '19 at 16:24
  • I'm just seeing you are trying to tie-break your rewrite system by applying the rewrite rule to the leftmost pattern at each step. But then there is nothing to prove! – darij grinberg Aug 08 '19 at 16:27
  • Alternatively, you can work in the polynomial ring over $\mathbb{Z}$ in a bunch of variables (as many as there are numbers in your original expression). Replace the numbers in your original expression by the variables. All rewriting steps you make still work after this replacement, since you are never actually simplifying the numbers. But the result is clearly unique, since it is the expanded form of the polynomial. – darij grinberg Aug 08 '19 at 16:30
  • @darij grinberg: will have a look at the lemma, thanks!

    And yes, I tried to make things easier by applying the rules to the leftmost patterns. I see that in such a case it is somewhat "obvious" that the result is unique, but I fail to provide even a simplest formal justification for that.

    – abebebebahabe Aug 08 '19 at 16:37

1 Answers1

0

Let $N$ be a language for natural numbers. The set $E$ of algebraic expressions is inductively defined by the following rules:

  1. If $n \in N$, then $n \in E$.
  2. If $e, e' \in E$, then $(e + e') \in E$.
  3. If $e, e' \in E$, then $(e \cdot e') \in E$.

In order to define a function $f \colon E \to E$ transforming an expression $e$ into another expression $f(e)$, one just needs to use structural recursion. In your case, the function $f$ is defined by the following rules:

  1. If $n \in N$, then $f(n) = n$.
  2. If $e, e' \in E$, then $f((e + e')) = (f(e) + f(e'))$.
  3. If $e \in E$, then:
    1. If $n \in E$, then $f((n \cdot e)) = (f(n) \cdot f(e))$.
    2. If $e', e'' \in E$, then $f(((e' + e'') \cdot e)) = ((f(e') \cdot f(e)) + (f(e'') \cdot f(e)))$.
    3. If $e', e'' \in E$, then $f(((e' \cdot e'') \cdot e)) = ((f(e') \cdot f(e'')) \cdot f(e))$.

With these rules the function $f$ is well-defined, so for a given expression $e$ the rewritten expression $f(e)$ is clearly unique.

Now, if you only allow expressions of the form $((e' + e'') \cdot e)$ to be transformed into $((e' \cdot e) + (e'' \cdot e))$, then an expression such as $(2 \cdot (3 + 4))$ won't be transformed into a sum of products. In order to apply left-distributivity as well, you need to adjust the definition of $f$. (Hint: in rule 3, instead of three cases there will be nine cases to handle).

Luca Bressan
  • 6,961
  • 1
    IMHO the OP is not looking for a deterministic tie-breaking rule, but for a proof that every order of rewritings leads to the same result. While your $f$ is probably helpful for that, in itself it is not the answer. Note that if I'm not mistaken, you need associativity and commutativity of addition for the confluence to hold. – darij grinberg Aug 08 '19 at 16:23