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,
denotes
,
whose value is 5. The expression
is written
, whereas
is written
. The first has value 35 and the second has value
23. In the first expression, the multiplication
operator acts on the entire expression
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 denotes
, not
.
The corresponding reverse Polish expression for
is
.
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).