Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Polish notation

From Wikipedia, the free encyclopedia
Mathematics notation with operators preceding operands
This article is about a prefix notation in mathematics and computer sciences. For the similarly named logic, seeŁukasiewicz logic.

Infix notation

Polish notation (PN), also known asnormal Polish notation (NPN),[1]Łukasiewicz notation,Warsaw notation,Polish prefix notation,Eastern Notation, or simplyprefix notation, is a mathematical notation in whichoperatorsprecede theiroperands, in contrast to the more commoninfix notation, in which operators are placedbetween operands, as well asreverse Polish notation (RPN), in which operatorsfollow their operands. It does not need any parentheses as long as each operator has a fixednumber of operands. The description "Polish" refers to thenationality oflogicianJan Łukasiewicz,[2]: 24 [3]: 78 [4] who invented Polish notation in 1924.[5]: 367, Footnote 3 [6]: 180, Footnote 3 

Sometimes the termPolish notation refers collectively tonormal Polish notation andreverse Polish notation (prefix notation and postfix notation, the two alternatives toinfix notation).[7]

When Polish notation is used as a syntax for mathematical expressions byprogramming languageinterpreters it is readily parsed intoabstract syntax trees and can, in fact, define aone-to-one representation for the same. Because of this,Lisp (seeImplementations, below) and related programming languages define their entire syntax in prefix notation (and others use postfix notation).

History

[edit]

A quotation from a paper byJan Łukasiewicz in 1931[5]: 367, Footnote 3 [6]: 180, Footnote 3  states how the notation was invented:

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 Łukasiewicz, i.e., Łukasiewicz (1),[8] is apparently a lithographed report inPolish. The referring paper[5] by Łukasiewicz was reviewed byHenry A. Pogorzelski in theJournal of Symbolic Logic in 1965.[9]Heinrich Behmann, editor in 1924 of the article ofMoses Schönfinkel,[10] already had the idea of eliminating parentheses in logic formulas. In one of his papers Łukasiewicz stated that his notation is the most compact and the first linearly written parentheses-free notation, but not the first one asGottlob Frege proposed his parentheses-freeBegriffsschrift notation in 1879 already.[11]

Alonzo Church mentions this notation in his classic book onmathematical logic as worthy of remark in notational systems even contrasted toAlfred Whitehead andBertrand Russell's logical notational exposition and work inPrincipia Mathematica.[12]

In Łukasiewicz's 1951 book,Aristotle's Syllogistic from the Standpoint of Modern Formal Logic, he mentions that the principle of his notation was to write thefunctors before thearguments to avoid brackets and that he had employed his notation in his logical papers since 1929.[3]: 78  He then goes on to cite, as an example, a 1930 paper he wrote withAlfred Tarski on thesentential calculus.[13]

While no longer used much in logic,[14] Polish notation has since found a place incomputer science.

Explanation

[edit]

The expression for adding the numbers 1 and 2 is written in Polish notation as+ 1 2 (prefix), rather than as1 + 2 (infix). In more complex expressions, the operators still precede their operands, but the operands may themselves be expressions including again operators and their operands. For instance, the expression that would be written in conventional infix notation as

(5 − 6) × 7

can be written in Polish notation as

× (− 5 6) 7

Assuming a givenarity of all involved operators (here the "−" denotes the binary operation of subtraction, not the unary function of sign-change), any well-formed prefix representation is unambiguous, and brackets within the prefix expression are unnecessary. As such, the above expression can be further simplified to

× − 5 6 7

The processing of the product is deferred until its two operands are available (i.e., 5 minus 6, and 7). As withany notation, the innermost expressions are evaluated first, but in Polish notation this "innermost-ness" can be conveyed by the sequence of operators and operands rather than by bracketing.

In the conventional infix notation, parentheses are required to override the standardprecedence rules, since, referring to the above example, moving them

5 − (6 × 7)

or removing them

5 − 6 × 7

changes the meaning and the result of the expression. This version is written in Polish notation as

− 5 × 6 7.

When dealing with non-commutative operations, like division or subtraction, it is necessary to coordinate the sequential arrangement of the operands with the definition of how the operator takes its arguments, i.e., from left to right. For example,÷ 10 5, with 10 to the left of 5, has the meaning of 10 ÷ 5 (read as "divide 10 by 5"), or− 7 6, with 7 left to 6, has the meaning of 7 − 6 (read as "subtract from 7 the operand 6").

Evaluation algorithm

[edit]

Prefix/postfix notation is especially popular for its innate ability to express the intended order of operations without the need for parentheses and other precedence rules, as are usually employed withinfix notation. Instead, the notation uniquely indicates which operator to evaluate first. The operators are assumed to have a fixedarity each, and all necessary operands are assumed to be explicitly given. A valid prefix expression always starts with an operator and ends with an operand. Evaluation can either proceed from left to right, or in the opposite direction. Starting at the left, the input string, consisting of tokens denoting operators or operands, is pushed token for token on astack, until the top entries of the stack contain the number of operands that fits to the top-most operator (immediately beneath). This group of tokens at the stacktop (the last stacked operator and the according number of operands) is replaced by the result of executing the operator on these/this operand(s). Then the processing of the input continues in this manner. The rightmost operand in a valid prefix expression thus empties the stack, except for the result of evaluating the whole expression. When starting at the right, the pushing of tokens is performed similarly, just the evaluation is triggered by an operator, finding the appropriate number of operands that fits its arity already at the stacktop. Now the leftmost token of a valid prefix expression must be an operator, fitting to the number of operands in the stack, which again yields the result. As can be seen from the description, apush-down store with no capability of arbitrary stack inspection suffices to implement thisparsing.

The above sketched stack manipulation works—with mirrored input—also for expressions inreverse Polish notation.

Polish notation for logic

[edit]

The table below shows the core ofJan Łukasiewicz's notation in modern logic, which was also used, for instance, inFormal Logic byArthur Prior.[15] Some letters in the Polish notation table stand for particular words inPolish, as shown:

ConceptConventional
notation
Polish
notation
Polish
term
Negation¬ϕ{\displaystyle \neg \phi }Nϕ{\displaystyle N\phi }[16][2]: 27–28 negacja
Material conditionalϕψ{\displaystyle \phi \to \psi }Cϕψ{\displaystyle C\phi \psi }[16][2]: 28–31 implikacja
Disjunctionϕψ{\displaystyle \phi \lor \psi }Aϕψ{\displaystyle A\phi \psi }[16][2]: 34–35 alternatywa
Conjunctionϕψ{\displaystyle \phi \land \psi }Kϕψ{\displaystyle K\phi \psi }[16][2]: 35–36 koniunkcja
Non-conjunctionϕψ{\displaystyle \phi \mid \psi }Dϕψ{\displaystyle D\phi \psi }[16][2]: 36 dysjunkcja
Biconditionalϕψ{\displaystyle \phi \leftrightarrow \psi }Eϕψ{\displaystyle E\phi \psi }[16][2]: 37  orQϕψ{\displaystyle Q\phi \psi }[3]: 108 ekwiwalencja
Universal quantifierpϕ{\displaystyle \forall p\,\phi }Πpϕ{\displaystyle \varPi p\,\phi }[2]: 154–156 kwantyfikator ogólny
Existential quantifierpϕ{\displaystyle \exists p\,\phi }Σpϕ{\displaystyle \varSigma p\,\phi }[2]: 157 kwantyfikator szczegółowy
Verum{\displaystyle \top }V{\displaystyle V}[17]: 275 prawda, prawdziwy
Falsum{\displaystyle \bot }O{\displaystyle O}[17]: 275 fałsz, fałszywy
Possibilityϕ{\displaystyle \Diamond \phi }Mϕ{\displaystyle M\phi }[18]: 52 [3]: 134  orΔϕ{\displaystyle \varDelta \phi }[19]: 111 możliwość
Necessityϕ{\displaystyle \Box \phi }Lϕ{\displaystyle L\phi }[3]: 134  orΓϕ{\displaystyle \varGamma \phi }[19]: 111 konieczność

Thequantifiers ranged over propositional values in Łukasiewicz's work on many-valued logics.

Bocheński introduced a system of Polish notation that names all 16 binaryconnectives of classicalpropositional logic.[20]: 16  For classical propositional logic, it is a compatible extension of the notation of Łukasiewicz. But the notations are incompatible in the sense that Bocheński usesL{\displaystyle L} andM{\displaystyle M} (for nonimplication and converse nonimplication) in propositional logic and Łukasiewicz usesL{\displaystyle L} andM{\displaystyle M} in modal logic.

Implementations

[edit]

Prefix notation has seen wide application inLispS-expressions, where the parentheses are required since the operators in the language are themselves data (first-class functions). Lisp functions may also bevariadic. TheTcl programming language, much like Lisp also uses Polish notation through the mathop library. The Ambi[21] programming language uses Polish notation for arithmetic operations and program construction.LDAP filter syntax uses Polish prefix notation.[22]

Postfix notation is used in manystack-oriented programming languages likePostScript andForth.CoffeeScript syntax also allows functions to be called using prefix notation, while still supporting the unary postfix syntax common in other languages.

The number of return values of an expression equals the difference between the number of operands in an expression and the total arity of the operators minus the total number of return values of the operators.

Polish notation, usually in postfix form, is the chosen notation of certaincalculators, notably fromHewlett-Packard.[23] At a lower level, postfix operators are used by somestack machines such as theBurroughs large systems.

See also

[edit]

References

[edit]
  1. ^Jorke, Günter; Lampe, Bernhard; Wengel, Norbert (1989).Arithmetische Algorithmen der Mikrorechentechnik [Arithmetic algorithms in microcomputers] (in German) (1 ed.). Berlin, Germany:VEB Verlag Technik.ISBN 3-34100515-3.EAN 978-3-34100515-6. MPN 5539165. License 201.370/4/89. Retrieved2015-12-01.
  2. ^abcdefghiŁukasiewicz, Jan (1929).Elementy logiki matematycznej (in Polish) (1 ed.). Warsaw, Poland:Państwowe Wydawnictwo Naukowe;Łukasiewicz, Jan (1963).Elements of Mathematical Logic. Translated byWojtasiewicz, Olgierd Adrian[in Polish]. New York, USA:The MacMillan Company.
  3. ^abcdeŁukasiewicz, Jan (1957) [1951].Aristotle's Syllogistic from the Standpoint of Modern Formal Logic (2 ed.).Oxford University Press. (Reprinted byGarland Publishing in 1987,ISBN 0-8240-6924-2.)
  4. ^Kennedy, John (August 1982)."RPN Perspective".PPC Calculator Journal.9 (5). Mathematics Department, Santa Monica College, Santa Monica, California, USA:26–29.CiteSeerX 10.1.1.90.6448.Archived from the original on 2022-07-01. Retrieved2022-07-02. (12 pages)
  5. ^abcŁukasiewicz, Jan (1931)."Uwagi o aksjomacie Nicoda i 'dedukcji uogólniającej'" [Comments on Nicod's Axiom and on 'Generalizing Deduction'].Księga pamiątkowa Polskiego Towarzystwa Filozoficznego We Lwowie, 12. II. 1904–1912. II. 1929 (in Polish). Lwów: Wydawnictwo Polskie Towarzystwo Filozoficzne. pp. 366–383.
  6. ^abŁukasiewicz, Jan (1970). "Comments on Nicod's Axiom and on 'Generalizing Deduction'". In Borkowski, L. (ed.).Selected Works. Amsterdam and London/Warszawa: North-Holland Publishing Company/Polish Scientific Publishers. pp. 179–196.
  7. ^Main, Michael (2006).Data structures and other objects using Java (3 ed.).Pearson PLCAddison-Wesley. p. 334.ISBN 978-0-321-37525-4.
  8. ^Łukasiewicz, Jan (1929)."O znaczeniu i potrzebach logiki matematycznej".Nauka Polska (in Polish).10:604–620.
  9. ^Pogorzelski, Henry Andrew (September 1965)."Reviewed work(s): Remarks on Nicod's Axiom and on "Generalizing Deduction" by Jan Łukasiewicz, Jerzy Słupecki, Państwowe Wydawnictwo Naukowe".The Journal of Symbolic Logic (Review).30 (3).Association for Symbolic Logic:376–377.JSTOR 2269644. (NB. The original 1931 paper "Uwagi o aksjomacie Nicoda i 'dedukcji uogólniającej" byJan Łukasiewicz was re-published atPaństwowe Wydawnictwo Naukowe (National Scientific Publishers),Warsaw, Poland in 1961 in a volume edited byJerzy Słupecki.)
  10. ^Schönfinkel, Moses (1924). "Über die Bausteine der mathematischen Logik" [On the building blocks of mathematical logic].Mathematische Annalen (in German).92 (3–4):305–316.doi:10.1007/BF01448013.S2CID 118507515;van Heijenoort, Jean, ed. (1967). "On the building blocks of mathematical logic".A Source Book in Mathematical Logic, 1879–1931. Translated byBauer-Mengelberg, Stefan[in Dutch].Harvard University Press. pp. 355–366.
  11. ^Gottschall, Christian (2005).Logische Notationen und deren Verarbeitung auf elektronischen Rechenanlagen aus theoretischer, praktischer und historischer Sicht [Logical notations and their processing on electronic computing systems from a theoretical, practical and historical perspective] (Thesis) (in German). Vienna, Austria. p. 88:Die ältesten Texte in den 'Selected Works', in denen Łukasiewicz polnische Notation verwendet, datieren relativ spät, sind aber Präsentationen vorangehender Arbeiten, die 'in the course of the years 1920–1930' (S. 131) stattgefunden haben, also auch keine genauere Zeitangabe geben. [The oldest texts in the 'Selected Works', in which Łukasiewicz uses Polish notation, date relatively late, but are presentations of previous works that took place 'in the course of the years 1920–1930' (p. 131), thus not giving a more precise date.]
  12. ^Church, Alonzo (1944).Introduction to Mathematical Logic. Princeton, New Jersey, USA:Princeton University Press. 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. ...
  13. ^Łukasiewicz, Jan;Tarski, Alfred (1930)."Untersuchungen über den Aussagenkalküls" [Investigations into the Sentential Calculus].Comptes Rendus des Séances de la Société des Sciences et des Lettres de Varsovie (in German).23 (Cl. III):30–50.
  14. ^Martínez Nava, Xóchitl (2011-06-01), "Mhy bib I fail logic? Dyslexia in the teaching of logic", in Blackburn, Patrick; van Ditmarsch, Hans;Manzano, Maria; Soler-Toscano, Fernando (eds.),Tools for Teaching Logic: Third International Congress, TICTTL 2011, Salamanca, Spain, 1–4 June 2011, Proceedings, Lecture Notes in Artificial Intelligence, vol. 6680,Springer Nature, pp. 162–169,doi:10.1007/978-3-642-21350-2_19,ISBN 978-3-64221349-6,... Polish or prefix notation has come to disuse given the difficulty that using it implies. ...
  15. ^A. N. Prior (1955).Formal Logic. Internet Archive.
  16. ^abcdefWolenski, Jan (1989)."Logic and Philosophy in the Lvov—Warsaw School".SpringerLink: 97.doi:10.1007/978-94-009-2581-6.
  17. ^abŁukasiewicz, Jan (1939). "Der Äquivalenzenkalkül".Collectanea Logica (in German).1:145–169.
  18. ^Łukasiewicz, Jan (1930)."Untersuchungen über den Aussagenkalküls" [Investigations into the Sentential Calculus].Comptes Rendus des Séances de la Société des Sciences et des Lettres de Varsovie (in German).23 (Cl. III):51–77.
  19. ^abŁukasiewicz, Jan (1953). "A System of Modal Logic".The Journal of Computing Systems.3 (1):111–149.
  20. ^Bocheński, Józef Maria (1949). Written at Fribourg.Précis de logique mathématique(PDF). Collection Synthese (in French). Vol. 2. Bussum, Pays-Bas, Netherlands: F. G. Kroonder.Archived(PDF) from the original on 2023-08-03. Retrieved2023-11-12. Translated asBocheński, Józef Maria (1959).A Precis of Mathematical Logic. Translated byBird, Otto A.[at Wikidata]. Dordrecht, Netherlands: D. Reidel Publishing Company.
  21. ^"Google Code Archive - Long-term storage for Google Code Project Hosting".Archived from the original on 2017-09-28. Retrieved2022-11-14.
  22. ^"LDAP Filter Syntax".Archived from the original on 2022-10-14. Retrieved2022-11-14.
  23. ^"HP calculators - HP 35s RPN Mode"(PDF).Hewlett-Packard.Archived(PDF) from the original on 2022-01-21. Retrieved2022-11-14.

Further reading

[edit]

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Polish_notation&oldid=1337661451"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp