Take an example like $-x$, in functional notation this should be $-(x)$, when we actually substitute it, we do include the parenthesis so $-x=-(4)$ when $x=4$, we do this is a lot of cases with unary operators, is it a case of using polish notation (which doesn't seem defined for unary operators) or is it just an omission of the parenthesis for ease? If we consider $-x$ to be polish notation and substitute it with the number physically with no parenthesis, as done perhaps with $a+b$ we get $-4$, and if $x=-4$ we get --4 which if prefix notation is defined would suggest -(-4) in functional notation.
-
Revised version of closed question https://math.stackexchange.com/questions/4525941/is-writing-x-polish-notation – Gerry Myerson Sep 06 '22 at 13:28
-
1In Polish notation (both prefix and infix one) we have to use two different symbol for the binary subtraction (e.g. $-$) and the unary "negation". – Mauro ALLEGRANZA Sep 06 '22 at 13:46
-
Thus, if we have to translate $(a-b)$ we can use $-ab$ but if we want to write simply $-b$ we have to use e.g. $\neg b$ because the parser will interpret the $-$ sign as a binary operator. – Mauro ALLEGRANZA Sep 06 '22 at 13:54
-
@MauroALLEGRANZA so in reality $-x$ is just $-(x)$ with the brackets omitted for ease? In the same way we can consider $-7$ as referring to the value of the $-$ function on $7$? – user37577 Sep 06 '22 at 14:21
-
In what notation are you writing? Polish (prefix) of infix? I assume infix, because Polish one has no parentheses. – Mauro ALLEGRANZA Sep 06 '22 at 14:23
-
In "usual" notation (infix) $(a-b)$ and $(a+(-b))$ give the same result. In Polish $+-ab$ is wrongly written. – Mauro ALLEGRANZA Sep 06 '22 at 14:23
-
so infix notation is defined for unary functions? and $-(x)=-x$ in infix notation? Where $-(x)$ is in functional notation? How do we write $-(-4)$ (functional) in infix? We can write it as -(-4) (identical to functional) how about $--4$? – user37577 Sep 06 '22 at 14:34
-
Yes Polish notation has unary functions; in propositional logic we have $\neg p$ or $\text N p$ for negation. – Mauro ALLEGRANZA Sep 06 '22 at 14:35
-
How do we define $-$ (look at edit before) in infix, because it seems identical to functional notation but without parenthesis? – user37577 Sep 06 '22 at 14:37
1 Answers
Functional notation, with required parentheses, makes the arity of each operation explicit. For example,
-(a)= unary minus (“negation” or “additive inverse”) of one argument.-(a, b)= binary minus (“subtraction”) of two arguments.+(a)= unary plus (rarely written because it's the same as justa)+(a, b)= binary addition+(a, b, c)= $a + b + c$, because it makes sense to extend+to more than 2 operands.
Operands themselves can be expressions containing operators, resulting in nested expressions like -(^(b, 2), *(4, a, c)) for $b^2 - 4ac$.
In order to be able to omit the parentheses, you need some other way to unambiguously indicate where an argument list begins and ends.
One possible way to do this is to require that all operators take exactly two operands. With this rule, the subexpression *(4, a, c) from my example above is no longer permitted, but must be written with two explicit multiplications as *(*(4, a), c). Then the full functional expression -(^(b, 2), *(*(4, a), c)) can be unambiguously expressed:
- in prefix (“Polish”) notation as
- ^ b 2 * * 4 a c. - in postfix (“Reverse Polish”) notation as
b 2 ^ 4 a * c * -.
While this two-operand requirement is simple and practical for most uses of the +-*/^ operators, it does leave us without a direct equivalent notation for unary minus.
One simple workaround is to rewrite $-x$ as $0-x$, which then becomes -(0, x) in functional notation, - 0 x in prefix notation, or 0 x - in postfix notation.
Another is to allow both unary and binary operators, but give them distinct symbols so that we can tell them apart. For example, we could use superscript $^+$ and $^-$ for unary operators, but normal $+$ and $-$ for binary operators, so $-^-xy$ is prefix notation for $(-x) - y$, but $^--xy$ is prefix notation for $-(x-y)$.
- 14,978