TOPICS
Search

Polish Notation


Polish notation, also called prefix notation, is a notation for expressions in which each operator precedes its operands. It contrasts with infix notation, in which a binary operator occurs between its two operands, and with reverse Polish notation, also called postfix notation, in which each operator follows its operands (Hamblin 1962). Polish notation was introduced by the Polish logician Jan Łukasiewicz (Simons 2021).

For example, + 2 3 denotes 2+3, whose value is 5. The expression (3+4)×5 is written × + 3 4 5, whereas 3+(4×5) is written + 3 × 4 5. The first has value 35 and the second has value 23. In the first expression, the multiplication operator acts on the entire expression + 3 4 and the number 5.

When each operator has a fixed, known number of operands and the individual symbols can be distinguished, parentheses and precedence rules are unnecessary. Expressions are read recursively, with each operator followed by the complete expressions for its operands in order. The order matters for subtraction, for example - 7 2 denotes 7-2, not 2-7.

The corresponding reverse Polish expression for (3+4)×5 is 3 4 + 5 ×. Thus reverse Polish notation changes the positions of the operators while preserving the order of the operands, rather than simply reversing the string of symbols (Hamblin 1962).


See also

Infix Notation, Reverse Polish Notation

Explore with Wolfram|Alpha

References

Hamblin, C. L. "Translation to and from Polish Notation." Comput. J. 5, 210-213, 1962. https://doi.org/10.1093/comjnl/5.3.210.Miller, B. and Ranum, D. "Infix, Prefix and Postfix Expressions." §4.9 in Problem Solving with Algorithms and Data Structures Using Python. Runestone Academy. https://runestone.academy/ns/books/published/pythonds/BasicDS/InfixPrefixandPostfixExpressions.html.Simons, P. "Łukasiewicz's Parenthesis-Free or Polish Notation." Stanford Encyclopedia of Philosophy. 2021. https://plato.stanford.edu/entries/lukasiewicz/polish-notation.html.

Referenced on Wolfram|Alpha

Polish Notation

Cite this as:

Weisstein, Eric W. "Polish Notation." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/PolishNotation.html

Subject classifications