Polish notation

Polish notation

Polish notation, also known as prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. If the arity of the operators is fixed, the result is a syntax lacking parentheses or other brackets, that can still be parsed without ambiguity. The Polish logician Jan Łukasiewicz invented this notation around 1920 in order to simplify sentential logic.

Here is a quotation from Nicod's Axiom and Generalizing Deduction, page 180.

I came upon the idea of a parenthesis-free notation in 1924. I used that notation for the first time in my article Łukasiewicz(1), p. 610, footnote.

The reference cited by Jan Łukasiewicz above is apparently a lithographed report in Polish.

Alonzo Church mentions this notation in his classic book on Mathematical logic as worthy of remark in notational systems even contrasted to Whitehead and Russell's logical notational exposition and work in Principia Mathematica. [cite book|first=Alonzo|last=Church|title=Introduction to Mathematical Logic|location=Princeton, New Jersey|publisher=Princeton University Press|year=1944 - p.38: "Worthy of remark is the parenthesis-free notation of Jan Łukasiewicz. In this the letters N, A, C, E, K are used in the roles of negation, disjunction, implication, equivalence, conjunction respectively. ..." ]

While no longer used much in logic, Polish notation has since found a place in computer science.


The expression for adding the numbers one and two is, in prefix notation, written "+ 1 2" rather than "1 + 2". In more complex expressions, the operators still precede their operands, but the operands may themselves be nontrivial expressions including operators of their own. For instance, the expression that would be written in conventional infix notation as: (5 − 6) * 7can be written in prefix as : *+ (− 5 6) 7or simply: * − 5 6 7

Since the simple arithmetic operators are all binary (at least, in arithmetic contexts), any prefix representation thereof is unambiguous, and bracketing the prefix expression is unnecessary. In the previous example, the parentheses in the infix version were required, since moving them: 5 − (6 * 7)or simply removing them: 5 − 6 * 7would change the meaning and result of the overall expression. However, the corresponding prefix version of this second calculation would be written: − 5 * 6 7The processing of the subtraction is deferred until both operands of the subtraction have been read in (i.e., 5 and the product of 6 and 7). As with "any" notation, the innermost expressions are evaluated first, but in prefix notation this "innermost-ness" can be conveyed by order rather than bracketing.

Prefix notation of simple arithmetic is largely of academic interest. Unlike the similar postfix reverse Polish notation, prefix notation has been used in few if any commercially-made calculators. However, prefix-notated arithmetic is frequently used as a first, conceptual step in the teaching of compiler construction

Computer programming

Prefix notation has seen wide application in Lisp s-expressions, where the brackets are required due to the arithmetic operators having variable arity. The postfix reverse Polish notation is used in many stack-based programming languages like PostScript, and is the operating principle of certain calculators, notably from Hewlett-Packard.

Although obvious, it is important to note that the number of operands in an expression must equal the number of operators plus one, otherwise the statement makes no sense (assuming only binary operators are used in the expression). This can be easy to overlook when dealing with longer, more complicated expressions with several operators, so care must be taken to double check that an expression makes sense when using prefix notation.

Order of operations

Order of operations is defined within the structure of prefix notation and can be easily determined. One thing to keep in mind is that when executing an operation, the operation is applied TO the first operand BY the second operand. This is not an issue with operations that commute, but for non-commutative operations like division or subtraction, this fact is crucial to the analysis of a statement. For example, the following statement:

/ 10 5 = 2 (Prefix)

is read as "Divide 10 BY 5". Thus the solution is 2, not ½ as would be the result of an incorrect analysis.

Prefix notation is especially popular with stack-based operations due to its innate ability to easily distinguish order of operations without the need for parentheses. To evaluate order of operations under prefix notation, one does not even need to memorize an operational hierarchy, as with infix notation. Instead, one looks directly to the notation to discover which operator to evaluate first. Reading an expression from left to right, one first looks for an operator and proceeds to look for two operands. If another operator is found before two operands are found, then the old operator is placed aside until this new operator is resolved. This process iterates until an operator is resolved, which must happen eventually, as there must be one more operand than there are operators in a complete statement. Once resolved, the operator and the two operands are replaced with a new operand. Because one operator and two operands were removed and one operand was added, there was a net loss of one operator and one operand, meaning that there still exist more operands than operators by a factor of one, allowing the iterative process to complete once again. This is the general theory behind using stacks in programming languages to evaluate a statement in prefix notation, although there are various algorithms that manipulate the process. Once analyzed, a statement in prefix notation becomes less intimidating to the human mind as it allows some separation from convention with added convenience. An example shows the ease with which a complex statement in prefix notation can be deciphered through order of operations:

- * / 15 - 7 + 1 1 3 + 2 + 1 1 = - * / 15 - 7 2 3 + 2 + 1 1 = - * / 15 5 3 + 2 + 1 1 = - * 3 3 + 2 + 1 1 = - 9 + 2 + 1 1 = - 9 + 2 2 = - 9 4 = 5

Polish notation for logic

The table below shows the core of Jan Łukasiewicz's notation for sentential logic. The "conventional" notation did not become so until the 1970s and 80s. Some letters in the Polish notation table means a certain word in Polish, as shown:

Note that the quantifiers ranged over propositional values in Łukasiewicz's work on many-valued logics.


ee also

*Lisp (programming language)
*Reverse Polish notation

Further reading

*cite book |last=Łukasiewicz |first=Jan |authorlink=Jan Łukasiewicz | title=Aristotle’s Syllogistic from the Standpoint of Modern Formal Logic | publisher=Oxford University Press | year=1957
*Łukasiewicz, Jan, "Philosophische Bemerkungen zu mehrwertigen Systemen des Aussagenkalküls", "Comptes rendus des séances de la Société des Sciences et des Lettres de Varsovie", 23:51-77 (1930). Translated by H. Weber as "Philosophical Remarks on Many-Valued Systems of Propositional Logics", in Storrs McCall, "Polish Logic 1920-1939", Clarendon Press: Oxford (1967).

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Polish Notation —   [engl.], polnische Notation …   Universal-Lexikon

  • Polish notation — Logical notation devised by the Polish logician Jan Łukasiewicz (1878–1956) which dispenses with the need for parentheses indicating the scope of each logical connective. The propositional functors are N for ¬ (negation); K for & (conjunction); C …   Philosophy dictionary

  • Polish notation — beskliaustis užrašas statusas T sritis informatika apibrėžtis ↑Reiškinio užrašymo būdas nenaudojant skliaustų, bet išlaikant bet kokią reikiamą operacijų atlikimo eilę. Pirmiau rašomi operandai, po jų – operacijos ženklas, pavyzdžiui, vietoj a +… …   Enciklopedinis kompiuterijos žodynas

  • Polish notation — noun a parenthesis free notation for forming mathematical expressions in which each operator precedes its operands • Syn: ↑prefix notation, ↑Lukasiewicz notation • Hypernyms: ↑parenthesis free notation …   Useful english dictionary

  • Polish notation — noun A notation for arithmetic (and logical) formulae in which operations (respectively, quantifiers and operands) are written immediately before their operands, used to avoid the need for parentheses; for example, 3 , (4 + 7) is written as , 3 + …   Wiktionary

  • Polish notation — noun Logic & Computing a system of formula notation without brackets or special punctuation, used to represent arithmetical operations …   English new terms dictionary

  • Reverse Polish notation — (or just RPN) by analogy with the related Polish notation, a prefix notation introduced in 1920 by the Polish mathematician Jan Łukasiewicz, is a mathematical notation wherein every operator follows all of its operands. It is also known as… …   Wikipedia

  • reverse Polish notation — noun an arithmetic notation in which numbers precede the operators to be applied to them. Back in my day, we had reverse Polish notation calculators: You had to write 2 4 3 , + instead of 2 + 4 , 3 . Syn: postfix notation …   Wiktionary

  • reverse Polish notation — noun Date: 1975 a system of representing mathematical and logical operations in which the operands precede the operator and which does not require the use of parentheses < (3 + 5) (2 + 1) in reverse Polish notation is expressed as 3 5 + 2 1 + >… …   New Collegiate Dictionary

  • Reverse Polish notation —   [engl.], umgekehrte polnische Notation …   Universal-Lexikon