Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Prolog
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Programming language that uses first order logic}} {{About|the programming language|the narrative device|Prologue|other uses|Prologue (disambiguation)}} {{Infobox programming language | paradigm = [[Logic programming|Logic]] | designers = [[Alain Colmerauer]] | released = {{Start date and age|1972}} | latest release version = Part 1: General core-Edition 1 ({{Start date and age|1995|06}})<br />Part 2: Modules-Edition 1 ({{Start date and age|2000|06}}) | latest release date = | typing = Untyped (its single data type is "term") | implementations = [http://www.amzi.com/#apls Amzi! Prolog], [[B-Prolog]], [[Ciao (programming language)|Ciao]], [[ECLiPSe]], [[GNU Prolog]], [[Logic Programming Associates|LPA Prolog]], [[Poplog]], [https://homepages.inf.ed.ac.uk/stg/research/Psharp/ P#], [[Quintus Prolog]], [https://www.scryer.pl/ Scryer Prolog], [https://sicstus.sics.se/ SICStus], [https://dobrev.com/ Strawberry], [[SWI-Prolog]], [http://tau-prolog.org/ Tau Prolog], [http://tuprolog.unibo.it/ tuProlog], [https://www.lpai.uk/win.htm WIN-PROLOG] [[XSB]], [[YAP (Prolog)|YAP]]. | dialects = [[#ISO Prolog|ISO Prolog]], Edinburgh Prolog | influenced by = [[Planner (programming language)|Planner]] | influenced = [[Constraint Handling Rules|CHR]], [[Clojure]], [[Datalog]], [[Erlang (programming language)|Erlang]], [http://epilog.stanford.edu/ Epilog], [[KL0]], [[KL1]], [[Logtalk]], [[Mercury (programming language)|Mercury]], [[Oz (programming language)|Oz]], [[Strand (programming language)|Strand]], [[Visual Prolog]] | file_ext = <code>.pl</code>, <code>.pro</code>, <code>.P</code> | website = Part 1: {{URL|https://www.iso.org/standard/21413.html}}<br /> Part 2: {{URL|https://www.iso.org/standard/20775.html}} | wikibooks = Prolog }} '''Prolog''' is a [[logic programming]] language that has its origins in [[artificial intelligence]], [[automated theorem proving]] and [[computational linguistics]].<ref name=Clocksin2003>{{Cite book |last1=Clocksin |first1=William F. |last2=Mellish |first2=Christopher S. |title=Programming in Prolog |year=2003 |publisher=Springer-Verlag |location=Berlin; New York |isbn=978-3-540-00678-7}}</ref><ref name=Bratko2012>{{Cite book |last1=Bratko |first1=Ivan |title=Prolog programming for artificial intelligence |edition=4th |year=2012 |publisher=Addison Wesley |location=Harlow, England; New York |isbn=978-0-321-41746-6}}</ref><ref name=Covington1994>{{Cite book |last1=Covington |first1=Michael A. |title=Natural language processing for Prolog programmers |year=1994 |publisher=Prentice Hall |location=Englewood Cliffs, N.J. |isbn=978-0-13-629213-5}}</ref> Prolog has its roots in [[first-order logic]], a [[formal logic]], and unlike many other [[programming language]]s, Prolog is intended primarily as a [[declarative programming]] language: the program is a set of facts and [[Horn clause|rules]], which define [[Finitary relation|relations]]. A [[computation]] is initiated by running a ''query'' over the program.<ref name=lloyd84/> Prolog was one of the first logic programming languages<ref>See {{section link|Logic programming|History}}.</ref> and remains the most popular such language today, with several free and commercial implementations available. The language has been used for [[automated theorem proving|theorem proving]],<ref>{{Cite journal |last1=Stickel |first1=M. E. |title=A prolog technology theorem prover: Implementation by an extended prolog compiler |journal=[[Journal of Automated Reasoning]] |volume=4 |issue=4 |pages=353–380 |year=1988 |doi=10.1007/BF00297245 |citeseerx=10.1.1.47.3057 |s2cid=14621218}}</ref> [[expert system]]s,<ref>{{cite book |author=Merritt, Dennis |title=Building expert systems in Prolog |publisher=Springer-Verlag |location=Berlin |year=1989 |isbn=978-0-387-97016-5 |url-access=registration |url=https://archive.org/details/buildingexpertsy0000merr}}</ref> [[term rewriting]],<ref>Felty, Amy. "A logic programming approach to implementing higher-order term rewriting." Extensions of Logic Programming (1992): 135-161.</ref> [[type system]]s,<ref name="Lee2015">{{cite book|author=Kent D. Lee|title=Foundations of Programming Languages|url=https://books.google.com/books?id=dERFBgAAQBAJ&q=prolog+type+inference&pg=PA298|date=19 January 2015|publisher=Springer|isbn=978-3-319-13314-0|pages=298–}}</ref> and [[automated planning]],<ref name="Schmid2003">{{cite book|author=Ute Schmid|author-link= Ute Schmid |title=Inductive Synthesis of Functional Programs: Universal Planning, Folding of Finite Programs, and Schema Abstraction by Analogical Reasoning|url=https://books.google.com/books?id=p-Fy25LE4lMC|date=21 August 2003|publisher=Springer Science & Business Media|isbn=978-3-540-40174-2}}</ref> as well as its original intended field of use, [[natural language processing]].<ref>{{cite book |author1=Fernando C. N. Pereira |author-link1=Fernando Pereira |author2=Stuart M. Shieber |year=2005 |title=Prolog and Natural Language Analysis |publisher=Microtome |url=http://mtome.com/Publications/PNLA/pnla.html}}</ref><ref name=lally>{{cite web |author1=Adam Lally |author2=Paul Fodor |date=31 March 2011 |url=http://www.cs.nmsu.edu/ALP/2011/03/natural-language-processing-with-prolog-in-the-ibm-watson-system/ |title=Natural Language Processing With Prolog in the IBM Watson System |publisher=Association for Logic Programming |access-date=13 June 2014 |archive-date=3 September 2014 |archive-url=https://web.archive.org/web/20140903064037/http://www.cs.nmsu.edu/ALP/2011/03/natural-language-processing-with-prolog-in-the-ibm-watson-system/ |url-status=dead }} See also [[Watson (computer)]].</ref> Prolog is a Turing-complete, general-purpose programming language, which is well-suited for intelligent knowledge-processing applications. == History == {| class="wikitable floatright" style="padding-left: 1.5em;" |+Timeline of Prolog language |- ! Year ! Aix-Marseille ! ISO/IEC Standard |- | 1972 | Prolog 0 | {{n/a}} |- | 1973 | Prolog I | {{n/a}} |- | 1982 | Prolog II | {{n/a}} |- | 1990 | Prolog III | {{n/a}} |- | 1995 | {{n/a}} | 13211-1 |- | 1996 | Prolog IV | {{n/a}} |- | 2000 | {{n/a}} | 13211-2 |- | 2007 | {{n/a}} | 13211-1:1995/Cor 1:2007 |- | 2012 | {{n/a}} | 13211-1:1995/Cor 2:2012 |- | 2017 | {{n/a}} | 13211-1:1995/Cor 3:2017 |} [[File:Early Prolog timeline.svg|thumb|upright=2|Timeline of some early Prolog systems, up to the ISO Standard]] The name ''Prolog'' was chosen by Philippe Roussel, at the suggestion of his wife, as an abbreviation for ''{{lang|fr|'''Pro'''grammation en '''log'''ique}}'' ([[French language|French]] for ''Programming in [[logic]]'').<ref> Colmerauer, A. and Roussel, P., 1996. The birth of Prolog. In History of programming languages---II (pp. 331-367).</ref> It was created around 1972 by [[Alain Colmerauer]] with Philippe Roussel, from the ''Artificial Intelligence Group'' of the [[Aix-Marseille University Faculty of Sciences|Faculty of Sciences of Luminy]] of [[University of the Mediterranean|Aix-Marseille II University]] of [[France]]. It was based on [[Robert Kowalski]]'s procedural interpretation of [[Horn clause]]s, and it was motivated in part by the desire to reconcile the use of logic as a declarative knowledge representation language with the procedural representation of knowledge that was popular in North America in the late 1960s and early 1970s. According to [[Robert Kowalski]], the first Prolog system was developed in 1972 by Colmerauer and Phillipe Roussel.<ref name="Kowalski">{{Cite journal |last1=Kowalski |first1=R. A. |year=1988 |title=The early years of logic programming |journal=[[Communications of the ACM]] |volume=31 |page=38 |s2cid=12259230 |url=http://www.doc.ic.ac.uk/~rak/papers/the%20early%20years.pdf |doi=10.1145/35043.35046}}</ref><ref>{{Cite journal |last1=Colmerauer |first1=A. |last2=Roussel |first2=P. |title=The birth of Prolog |journal=[[ACM SIGPLAN Notices]] |volume=28 |issue=3 |page=37 |year=1993 |url=http://alain.colmerauer.free.fr/alcol/ArchivesPublications/PrologHistory/19november92.pdf |doi=10.1145/155360.155362}}</ref><ref>{{cite web |url=https://www.mta.ca/~rrosebru/oldcourse/371199/prolog/history.html |title=Prolog: a brief history |access-date=21 November 2021}}</ref> The first implementation of Prolog was an interpreter written in [[Fortran]] by Gerard Battani and Henri Meloni. [[David H. D. Warren]] took this interpreter to the [[University of Edinburgh]], and there implemented an alternative front-end, which came to define the "Edinburgh Prolog" syntax used by most modern implementations. Warren also implemented the first compiler for Prolog, creating the influential DEC-10 Prolog in collaboration with Fernando Pereira. Warren later generalised the ideas behind DEC-10 Prolog, to create the [[Warren Abstract Machine]] ('''WAM'''). European AI researchers favored Prolog while Americans favored [[Lisp (programming language)|Lisp]], reportedly causing many nationalistic debates on the merits of the languages.<ref name="pountain198410">{{cite news |last=Pountain |first=Dick |date=October 1984 |url=https://archive.org/stream/byte-magazine-1984-10/1984_10_BYTE_09-11_Databases#page/n377/mode/2up |title=POP and SNAP |work=[[Byte (magazine)|Byte]] |access-date=23 October 2013 |page=381}}</ref> Much of the modern development of Prolog came from the impetus of the [[Fifth Generation Computer Systems project]] (FGCS), which developed a variant of Prolog named ''[[KL1|Kernel Language]]'' for its first [[operating system]]. Pure Prolog was originally restricted to the use of a [[resolution (logic)|resolution]] theorem prover with [[Horn clause]]s of the form: H :- B<sub>1</sub>, ..., B<sub>n</sub>. The application of the theorem-prover treats such clauses as procedures: to show/solve H, show/solve B<sub>1</sub> and ... and B<sub>n</sub>. Pure Prolog was soon extended, however, to include [[negation as failure]], in which negative conditions of the form not(B<sub>i</sub>) are shown by trying and failing to solve the corresponding positive conditions B<sub>i</sub>. Subsequent extensions of Prolog by the original team introduced [[constraint logic programming]] abilities into the implementations. === Impact === Although Prolog is widely used in research and education,<ref>{{Cite web |title=Computer science - Programming Languages, Syntax, Algorithms {{!}} Britannica |url=https://www.britannica.com/science/computer-science/Programming-languages |access-date=2023-07-12 |website=www.britannica.com |language=en}}</ref> Prolog and other logic programming languages have not had a significant impact on the computer industry in general.<ref name="RealWorld">Logic programming for the real world. Zoltan Somogyi, Fergus Henderson, Thomas Conway, Richard O'Keefe. Proceedings of the ILPS'95 Postconference Workshop on Visions for the Future of Logic Programming.</ref> Most applications are small by industrial standards, with few exceeding 100,000 lines of code.<ref name="RealWorld"/><ref name="The Prolog 1000 database">{{Cite web |url=http://www.faqs.org/faqs/prolog/resource-guide/part1/section-9.html |title=FAQ: Prolog Resource Guide 1/2 [Monthly posting]Section - [1-8] The Prolog 1000 Database |website=Faqs.org}}</ref> [[Programming in the large]] is considered to be complex because not all Prolog compilers support modules, and there are compatibility problems between the module systems of the major Prolog compilers.<ref name="cs.kuleuven.ac.be"/> Portability of Prolog code across implementations has also been a problem, but developments since 2007 have meant: "the portability within the family of Edinburgh/Quintus derived Prolog implementations is good enough to allow for maintaining portable real-world applications."<ref>Jan Wielemaker and Vıtor Santos Costa: [http://www.swi-prolog.org/download/publications/porting.pdf Portability of Prolog programs: theory and case-studies]. [http://www.floc-conference.org/CICLOPS-WLPE-accepted.html CICLOPS-WLPE Workshop 2010] {{Webarchive|url=https://web.archive.org/web/20100716184811/http://www.floc-conference.org/CICLOPS-WLPE-accepted.html |date=2010-07-16}}.</ref> Software developed in Prolog has been criticised for having a high performance penalty compared to conventional programming languages. In particular, Prolog's non-deterministic evaluation strategy can be problematic when programming deterministic computations, or when even using "don't care non-determinism" (where a single choice is made instead of backtracking over all possibilities). Cuts and other language constructs may have to be used to achieve desirable performance, destroying one of Prolog's main attractions, the ability to run programs "backwards and forwards".<ref name="rethinking">{{cite conference |first1=Oleg |last1=Kiselyov |first2=Yukiyoshi |last2=Kameyama |title=Re-thinking Prolog |conference=Proc. 31st meeting of the Japan Society for Software Science and Technology |year=2014 |url=http://okmij.org/ftp/kakuritu/logic-programming.html#vs-prolog}}</ref> Prolog is not purely declarative: because of constructs like the [[Cut (logic programming)|cut operator]], a procedural reading of a Prolog program is needed to understand it.<ref>{{citation|first=Torkel|last=Franzen|date=1994|url=http://dtai.cs.kuleuven.be/projects/ALP/newsletter/archive_93_96/comment/decl.html|title=Declarative vs procedural|journal=Association of Logic Programming|volume=7|issue=3}}</ref> The order of clauses in a Prolog program is significant, as the execution strategy of the language depends on it.<ref>{{cite journal |title=Complexity and Expressive Power of Logic Programming |journal=[[ACM Computing Surveys]] |first1=Evgeny |last1=Dantsin |first2=Thomas |last2=Eiter |first3=Georg |last3=Gottlob |first4=Andrei |last4=Voronkov |year=2001 |volume=33 |issue=3 |pages=374–425 |doi=10.1145/502807.502810|citeseerx=10.1.1.616.6372 |s2cid=518049}}</ref> Other logic programming languages, such as [[Datalog]], are truly declarative but restrict the language. As a result, many practical Prolog programs are written to conform to Prolog's [[depth-first search]] order, rather than as purely declarative logic programs.<ref name="rethinking"/> === Use in industry === Prolog has been used in [[Watson (computer)|Watson]]. Watson uses IBM's DeepQA software and the Apache [[UIMA]] (Unstructured Information Management Architecture) framework. The system was written in various languages, including Java, {{nowrap|C++}}, and Prolog, and runs on the [[SUSE Linux Enterprise Server]] 11 operating system using [[Apache Hadoop]] framework to provide distributed computing. Prolog is used for [[pattern matching]] over natural language parse trees. The developers have stated: "We required a language in which we could conveniently express pattern matching rules over the parse trees and other annotations (such as named entity recognition results), and a technology that could execute these rules very efficiently. We found that Prolog was the ideal choice for the language due to its simplicity and [[Expressive power (computer science)|expressiveness]]."<ref name=lally/> Prolog is being used in the Low-Code Development Platform [[GeneXus]], which is focused around AI.{{Citation needed|date=November 2022}} Open source [[graph database]] [[TerminusDB]] is implemented in Prolog.<ref>{{Citation|title=terminusdb/terminusdb|date=2020-12-13|url=https://github.com/terminusdb/terminusdb|publisher=TerminusDB|access-date=2020-12-15}}</ref> TerminusDB is designed for collaboratively building and curating [[knowledge graph]]s. == Syntax and semantics == {{Main|Prolog syntax and semantics}} In Prolog, program logic is expressed in terms of relations, and a computation is initiated by running a ''query'' over these relations. Relations and queries are constructed using Prolog's single data type, the ''term''.<ref name=lloyd84>{{cite book |author=Lloyd, J. W. |title=Foundations of logic programming |publisher=Springer-Verlag |location=Berlin |year=1984 |isbn=978-3-540-13299-8}}</ref> Relations are defined by ''clauses''. Given a query, the Prolog engine attempts to find a [[resolution (logic)|resolution]] [[refutation]] of the negated query. If the negated query can be refuted, i.e., an instantiation for all free variables is found that makes the union of clauses and the singleton set consisting of the negated query false, it follows that the original query, with the found instantiation applied, is a [[logical consequence]] of the program. This makes Prolog (and other logic programming languages) particularly useful for database, [[symbolic mathematics]], and language parsing applications. Because Prolog allows impure [[Predicate (mathematical logic)|predicates]], checking the [[truth value]] of certain special predicates may have some deliberate [[side effect (computer science)|side effect]], such as printing a value to the screen. Because of this, the programmer is permitted to use some amount of conventional [[imperative programming]] when the logical paradigm is inconvenient. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features. === Data types === Prolog's single [[data type]] is the ''term''. Terms are either ''[[symbol (programming)#Prolog|atom]]s'', ''numbers'', ''variables'' or ''compound terms''.<ref group=note> The Prolog terminology differs from that of [[First-order logic|logic]]. A term of Prolog is (depending on the context) a [[Term (logic)|term]] or an [[atomic formula]] of logic. An atom in a standard logic terminology means an [[atomic formula]]; an atom of Prolog (depending on the context) is a constant, function symbol or predicate symbol of logic. </ref> * An '''atom''' is a symbol name starting with a lower case letter or guarded by quotes. Examples of atoms include <code>x</code>, <code>red</code>, <code>'Taco'</code>, <code>'some atom'</code>, and <code>'p(a)'</code>. * '''Numbers''' can be [[floating-point arithmetic|floats]] or [[integer]]s. Most of the major Prolog systems support arbitrary length integer numbers. * '''Variables''' are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore. Variables closely resemble variables in logic in that they are placeholders for arbitrary terms. * A '''compound term''' is composed of an atom called a "functor" and a number of "arguments", which are again terms. Compound terms are ordinarily written as a functor followed by a comma-separated list of argument terms, which is contained in parentheses. The number of arguments is called the term's [[arity]]. An atom can be regarded as a compound term with [[arity]] zero. An example of a compound term is <code>person_friends(zelda,[tom,jim])</code>. Special cases of compound terms: * A ''List'' is an ordered collection of terms. It is denoted by square brackets with the terms separated by commas, or in the case of the empty list, by <code>[]</code>. For example, <code>[1,2,3,4]</code> or <code>[red,green,blue]</code>. * ''Strings'': A sequence of characters surrounded by quotes is equivalent to either a list of (numeric) character codes, a list of characters (atoms of length 1), or an atom depending on the value of the Prolog flag <code>double_quotes</code>. For example, <code>"to be, or not to be"</code>.<ref name="ISO 13211-1 6.3.7">ISO/IEC 13211-1:1995 Prolog, 6.3.7 Terms - double quoted list notation. [[International Organization for Standardization]], Geneva.</ref> === Rules and facts === Prolog programs describe relations, defined by means of clauses. Pure Prolog is restricted to [[Horn clause]]s. Two types of Horn clauses are used to define Prolog programs: rules and facts. A rule is of the form <syntaxhighlight lang="prolog">Head :- Body.</syntaxhighlight> and is read as "Head is true if Body is true". A rule's body consists of calls to predicates, which are called the rule's '''goals'''. The built-in [[logical operator]] <code>,/2</code> (meaning an arity 2 [[Operator (programming)|operator]] with name <code>,</code>) denotes [[logical conjunction|conjunction]] of goals, and <code>;/2</code> denotes [[logical disjunction|disjunction]]. Conjunctions and disjunctions can only appear in the body, not in the head of a rule. Clauses with empty bodies are called '''facts'''. An example of a fact is: <syntaxhighlight lang="prolog">human(socrates).</syntaxhighlight> which is equivalent to the rule: <syntaxhighlight lang="prolog">human(socrates) :- true.</syntaxhighlight> The built-in predicate <code>true/0</code> is always true. Given the above fact, one can ask: ''is socrates a human?'' <syntaxhighlight lang="prolog"> ?- human(socrates). Yes </syntaxhighlight> ''what things are humans?'' <syntaxhighlight lang="prolog"> ?- human(X). X = socrates </syntaxhighlight> Clauses with bodies are called '''rules'''. An example of a rule is: <syntaxhighlight lang="prolog">mortal(X) :- human(X).</syntaxhighlight> If we add that rule and ask ''what things are mortals?'' <syntaxhighlight lang="prolog"> ?- mortal(X). X = socrates </syntaxhighlight> === Predicates and programs === A ''predicate'' (or ''procedure definition'') is a collection of clauses whose heads have the same name and arity. We use the notation ''name/arity'' to refer to predicates. A ''logic program'' is a set of predicates. For example, the following Prolog program, which defines some family relations, has four predicates: <syntaxhighlight lang="prolog"> mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y), not(X = Y). parent_child(X, Y) :- father_child(X, Y). parent_child(X, Y) :- mother_child(X, Y). </syntaxhighlight> Predicate <code>father_child/2</code> has three clauses, all of which are facts, and predicate <code>parent_child/2</code> has two clauses, both are rules. Due to the relational nature of many built-in predicates, they can typically be used in several directions. For example, <code>length/2</code> can be used to determine the length of a list (<code>length(List, L)</code>, given a list <code>List</code>), and to generate a list skeleton of a given length (<code>length(X, 5)</code>), and to generate both list skeletons and their lengths together (<code>length(X, L)</code>). Similarly, <code>append/3</code> can be used both to append two lists (<code>append(ListA, ListB, X)</code> given lists <code>ListA</code> and <code>ListB</code>), and to split a given list into parts (<code>append(X, Y, List)</code>, given a list <code>List</code>). For this reason, a comparatively small set of library predicates suffices for many Prolog programs. As a general purpose language, Prolog also provides various built-in predicates to perform routine activities like [[input/output]], using graphics and otherwise communicating with the operating system. These predicates are not given a relational meaning and are only useful for the side-effects they exhibit on the system. For example, the predicate <code>write/1</code> displays a term on the screen. === Loops and recursion === Iterative algorithms can be implemented by means of recursive predicates.<ref>{{cite book |last=Carlsson |first=Mats |url=https://books.google.com/books?id=dZimAwAAQBAJ&q=prolog%20failure%20driven%20loop%20%22iteration%22&pg=PA148 |title=SICStus Prolog User's Manual 4.3: Core reference documentation |date=27 May 2014 |publisher=BoD – Books on Demand |isbn=978-3-7357-3744-1 |via=Google Books}}</ref> Consider the <code>parent_child/2</code> predicate defined in the family relation program above. The following Prolog program defines the ''ancestor'' relation:<syntaxhighlight lang="prolog"> ancestor(X, Y) :- parent_child(X, Y). ancestor(X, Y) :- parent_child(X, Z), ancestor(Z, Y). </syntaxhighlight>It expresses that X is an ancestor of Y if X is parent of Y or X is parent of an ancestor of Y. It is recursive because it is defined in terms of itself (there is a call to predicate <code>ancestor/2</code> in the body of the second clause). === Execution === Execution of a Prolog program is initiated by the user's posting of a single goal, called the query. Logically, the Prolog engine tries to find a [[resolution (logic)|resolution]] refutation of the negated query. The resolution method used by Prolog is called [[SLD resolution]]. If the negated query can be refuted, it follows that the query, with the appropriate variable bindings in place, is a logical consequence of the program. In that case, all generated variable bindings are reported to the user, and the query is said to have succeeded. Operationally, Prolog's execution strategy can be thought of as a generalization of function calls in other languages, one difference being that multiple clause heads can match a given call. In that case, the system creates a choice-point, [[unification (computer science)|unifies]] the goal with the clause head of the first alternative, and continues with the goals of that first alternative. If any goal fails in the course of executing the program, all variable bindings that were made since the most recent choice-point was created are undone, and execution continues with the next alternative of that choice-point. This execution strategy is called chronological [[backtracking]]. For example, given the family relation program defined above, the following query will be evaluated to true: <syntaxhighlight lang="prolog"> ?- sibling(sally, erica). Yes </syntaxhighlight> This is obtained as follows: Initially, the only matching clause-head for the query <code>sibling(sally, erica)</code> is the first one, so proving the query is equivalent to proving the body of that clause with the appropriate variable bindings in place, i.e., the conjunction <code>(parent_child(Z,sally), parent_child(Z,erica))</code>. The next goal to be proved is the leftmost one of this conjunction, i.e., <code>parent_child(Z, sally)</code>. Two clause heads match this goal. The system creates a choice-point and tries the first alternative, whose body is <code>father_child(Z, sally)</code>. This goal can be proved using the fact <code>father_child(tom, sally)</code>, so the binding <code>Z = tom</code> is generated, and the next goal to be proved is the second part of the above conjunction: <code>parent_child(tom, erica)</code>. Again, this can be proved by the corresponding fact. Since all goals could be proved, the query succeeds. Since the query contained no variables, no bindings are reported to the user. A query with variables, like: <syntaxhighlight lang="prolog">?- father_child(Father, Child).</syntaxhighlight> enumerates all valid answers on backtracking. Notice that with the code as stated above, the query <code>?- sibling(sally, sally).</code> also succeeds. One would insert additional goals to describe the relevant restrictions, if desired. === Negation === The built-in Prolog predicate <code>\+/1</code> provides [[negation as failure]], which allows for [[non-monotonic logic|non-monotonic]] reasoning. The goal <code>\+ illegal(X)</code> in the rule <syntaxhighlight lang="prolog">legal(X) :- \+ illegal(X).</syntaxhighlight> is evaluated as follows: Prolog attempts to prove <code>illegal(X)</code>. If a proof for that goal can be found, the original goal (i.e., <code>\+ illegal(X)</code>) fails. If no proof can be found, the original goal succeeds. Therefore, the <code>\+/1</code> prefix operator is called the "not provable" operator, since the query <code>?- \+ Goal.</code> succeeds if Goal is not provable. This kind of negation is [[Soundness|sound]] if its argument is [[Ground expression|"ground"]] (i.e. contains no variables). Soundness is lost if the argument contains variables and the proof procedure is complete. In particular, the query <code>?- legal(X).</code> now cannot be used to enumerate all things that are legal. == Programming in Prolog == In Prolog, loading code is referred to as ''consulting''. Prolog can be used interactively by entering queries at the Prolog prompt <code>?-</code>. If there is no solution, Prolog writes <code>no</code>. If a solution exists then it is printed. If there are multiple solutions to the query, then these can be requested by entering a semi-colon <code>;</code>. There are guidelines on good programming practice to improve code efficiency, readability and maintainability.<ref>{{Cite journal |last1=Covington |first1=Michael A. |last2=Bagnara |first2=Roberto |last3=O'Keefe |first3=Richard A. |author-link3=Richard O'Keefe |last4=Wielemaker |first4=Jan |last5=Price |first5=Simon |title=Coding guidelines for Prolog |doi=10.1017/S1471068411000391 |journal=[[Theory and Practice of Logic Programming]] |volume=12 |issue=6 |pages=889–927 |year=2011 |arxiv=0911.2899|s2cid=438363}}</ref> Here follow some example programs written in Prolog. === Hello World === Example of a basic query in a couple of popular Prolog dialects: {| |- ! [[SWI-Prolog]] ! [[GNU Prolog]] |- |<syntaxhighlight lang="prolog"> ?- write('Hello World!'), nl. Hello World! true. ?- </syntaxhighlight> |<syntaxhighlight lang="prolog"> | ?- write('Hello World!'), nl. Hello World! yes | ?- </syntaxhighlight> |} This comparison shows the prompt ("?-" vs "| ?-") and resolution status ("true". vs "yes", "false". vs "no") can differ from one Prolog implementation to another. === Compiler optimization === Any computation can be expressed declaratively as a sequence of state transitions. As an example, an [[optimizing compiler]] with three optimization passes could be implemented as a relation between an initial program and its optimized form: <syntaxhighlight lang="prolog"> program_optimized(Prog0, Prog) :- optimization_pass_1(Prog0, Prog1), optimization_pass_2(Prog1, Prog2), optimization_pass_3(Prog2, Prog). </syntaxhighlight> or equivalently using [[definite clause grammar|DCG]] notation: <syntaxhighlight lang="prolog"> program_optimized --> optimization_pass_1, optimization_pass_2, optimization_pass_3. </syntaxhighlight> === Quicksort === The [[quicksort]] sorting algorithm, relating a list to its sorted version: <syntaxhighlight lang="prolog"> partition([], _, [], []). partition([X|Xs], Pivot, Smalls, Bigs) :- ( X @< Pivot -> Smalls = [X|Rest], partition(Xs, Pivot, Rest, Bigs) ; Bigs = [X|Rest], partition(Xs, Pivot, Smalls, Rest) ). quicksort([]) --> []. quicksort([X|Xs]) --> { partition(Xs, X, Smaller, Bigger) }, quicksort(Smaller), [X], quicksort(Bigger). </syntaxhighlight> == Design patterns of Prolog == A [[design pattern (computer science)|design pattern]] is a general reusable solution to a commonly occurring problem in [[software design]]. Some design patterns in Prolog are skeletons, techniques,<ref> {{cite journal |last1=Kirschenbaum |first1=M. |last2=Sterling |first2=L.S. |year=1993 |series=Lecture Notes in Computer Science / Lecture Notes in Artificial Intelligence |title=Applying Techniques to Skeletons - Patterns for Prolog Programming |journal=Constructing Logic Programs, (Ed. J.M.J. Jacquet) |pages=27–140 |citeseerx =10.1.1.56.7278}}</ref><ref>{{cite book |title=Computational Logic: Logic Programming and Beyond |first=Leon |last=Sterling |year=2002 |volume=2407 |pages=17–26 |doi=10.1007/3-540-45628-7_15 |isbn=978-3-540-43959-2 }}</ref> cliches,<ref>D. Barker-Plummer. Cliche programming in Prolog. In M. Bruynooghe, editor, Proc. Second Workshop on Meta-Programming in Logic, pages 247--256. Dept. of Comp. Sci., Katholieke Univ. Leuven, 1990.</ref> program schemata,<ref name=Gegg-harrison1995> {{cite conference |last=Gegg-harrison |first=T. S. |year=1995 |title=Representing Logic Program Schemata in Prolog |conference=Procs Twelfth International Conference on Logic Programming |pages=467–481 }}</ref> logic description schemata,<ref name=Deville1990> {{cite book |last=Deville |first=Yves |year=1990 |title=Logic programming: systematic program development |publisher=Addison-Wesley |location=Wokingham, England |isbn=978-0-201-17576-9 }}</ref> and [[higher-order programming]].<ref name=Naish1996> {{cite report |last=Naish |first=Lee |year=1996 |title=Higher-order logic programming in Prolog |publisher=Department of Computer Science, [[University of Melbourne]] |citeseerx=10.1.1.35.4505 }}</ref> == Higher-order programming == {{Main|Higher-order logic|Higher-order programming}} A higher-order predicate is a predicate that takes one or more other predicates as arguments. Although support for higher-order programming takes Prolog outside the domain of first-order logic, which does not allow quantification over predicates,<ref>{{cite web|title=With regard to Prolog variables, variables only in the head are implicitly universally quantified, and those only in the body are implicitly existentially quantified|url=http://okmij.org/ftp/Prolog/quantification.txt|access-date=2013-05-04}}</ref> ISO Prolog now has some built-in higher-order predicates such as <code>call/1</code>, <code>call/2</code>, <code>call/3</code>, <code>findall/3</code>, <code>setof/3</code>, and <code>bagof/3</code>.<ref name="ISO 13211"/> Furthermore, since arbitrary Prolog goals can be constructed and evaluated at run-time, it is easy to write higher-order predicates like <code>maplist/2</code>, which applies an arbitrary predicate to each member of a given list, and <code>sublist/3</code>, which filters elements that satisfy a given predicate, also allowing for [[currying]].<ref name="Naish1996"/> To convert solutions from temporal representation (answer substitutions on backtracking) to spatial representation (terms), Prolog has various all-solutions predicates that collect all answer substitutions of a given query in a list. This can be used for [[list comprehension]]. For example, [[perfect numbers]] equal the sum of their proper divisors: <syntaxhighlight lang="prolog"> perfect(N) :- between(1, inf, N), U is N // 2, findall(D, (between(1,U,D), N mod D =:= 0), Ds), sumlist(Ds, N). </syntaxhighlight> This can be used to enumerate perfect numbers, and to check if a number is perfect. As another example, the predicate <code>maplist</code> applies a predicate <code>P</code> to all corresponding positions in a pair of lists: <syntaxhighlight lang="prolog"> maplist(_, [], []). maplist(P, [X|Xs], [Y|Ys]) :- call(P, X, Y), maplist(P, Xs, Ys). </syntaxhighlight> When <code>P</code> is a predicate that for all <code>X</code>, <code>P(X,Y)</code> unifies <code>Y</code> with a single unique value, <code>maplist(P, Xs, Ys)</code> is equivalent to applying the [[Map (higher-order function)|map]] function in [[functional programming]] as <code>Ys = map(Function, Xs)</code>. Higher-order programming style in Prolog was pioneered in [[HiLog]] and [[λProlog]]. == Modules == For [[Programming in the large and programming in the small#Programming in the large|programming in the large]], Prolog provides a [[modular programming|module system]], which is in the ISO Standard.<ref>ISO/IEC 13211-2: Modules.</ref> However, while most Prolog systems support structuring the code into modules, virtually no implementation adheres to the modules part of the ISO standard. Instead, most [[Comparison of Prolog implementations|Prolog systems]] have decided to support as ''de-facto'' module standard the [[Quintus Prolog|Quintus]]/[[SICStus]] module system. However, further convenience predicates concerning modules are provided by some implementations only and often have subtle differences in their semantics.<ref name="auto">{{citation |author=Philipp Körner |author2=Michael Leuschel |author3=João Barbosa |author4=Vítor Santos Costa |author5=Verónica Dahl |author6=Manuel V. Hermenegildo |author7=Jose F. Morales |author8=Jan Wielemaker |author9=Daniel Diaz |author10=Salvador Abreu |author11=Giovanni Ciatto |title=Fifty Years of Prolog and Beyond |date=November 2022 |journal=Theory and Practice of Logic Programming|volume=22|issue=6 |pages=776–858 |doi=10.1017/S1471068422000102 |doi-access=free|hdl=10174/33387 |hdl-access=free }}</ref> Some systems chose to implement module concepts as source-to-source compilation into base ISO Prolog, as is the case of [[Logtalk]].<ref name="cs.kuleuven.ac.be">{{citation|first=Paulo|last=Moura|title=Logtalk|journal=Association of Logic Programming|volume=17|issue=3|date=August 2004|url=http://www.cs.kuleuven.ac.be/~dtai/projects/ALP/newsletter/aug04/nav/print/all.html#logtalk|access-date=2010-02-16|archive-date=2010-04-12|archive-url=https://web.archive.org/web/20100412151301/http://www.cs.kuleuven.ac.be/~dtai/projects/ALP/newsletter/aug04/nav/print/all.html#logtalk|url-status=dead}}</ref> GNU Prolog initially diverted from ISO modules, opting instead for [[Contextual Logic Programming]], in which unit (module) loading and unloading can be made dynamically.<ref>{{citation|last1=Abreu|last2=Nogueira|year=2005|journal=Lecture Notes in Artificia Intelligence|volume=4369|title=Using a Logic Programming Language with Persistence and Contexts}}</ref> [[Ciao (programming language)|Ciao]] designed a strict module system that, while being basically compatible with the ''de-facto'' standard used by other Prolog systems, is amenable to precise static analysis, supports term hiding, and facilitates programming in the large.<ref>{{citation|last1=Cabeza|last2=Hermenegildo|title=A new module system for Prolog|series=Lecture Notes in Computer Science|volume=1861|year=2000}}</ref> [[XSB]] takes a different approach and offers an ''atom-based'' module system.<ref>{{citation|last1=Sagonas|last2=Swift|last3=Warren|year=1994|title=XSB as an efficient deductive database engine |journal=SIGMOD}}</ref> The latter two Prolog systems allow controlling the ''visibility of terms'' in addition to that of predicates.<ref name="auto"/> == Parsing == {{Main|Prolog syntax and semantics#Definite clause grammars|Definite clause grammar}} There is a special notation called [[definite clause grammar]]s (DCGs). A rule defined via <code>-->/2</code> instead of <code>:-/2</code> is expanded by the preprocessor (<code>expand_term/2</code>, a facility analogous to macros in other languages) according to a few straightforward rewriting rules, resulting in ordinary Prolog clauses. Most notably, the rewriting equips the predicate with two additional arguments, which can be used to implicitly thread state around,{{Clarify|date=October 2012}} analogous to [[monads in functional programming|monads]] in other languages. DCGs are often used to write parsers or list generators, as they also provide a convenient interface to difference lists. == Meta-interpreters and reflection == Prolog is a [[homoiconic]] language and provides many facilities for [[reflective programming]] (reflection). Its implicit execution strategy makes it possible to write a concise [[meta-circular evaluator]] (also called ''meta-interpreter'') for pure Prolog code: <syntaxhighlight lang="prolog"> solve(true). solve((Subgoal1,Subgoal2)) :- solve(Subgoal1), solve(Subgoal2). solve(Head) :- clause(Head, Body), solve(Body). </syntaxhighlight> where <code>true</code> represents an empty conjunction, and <code>clause(Head, Body)</code> unifies with clauses in the database of the form <code>Head :- Body</code>. Since Prolog programs are themselves sequences of Prolog terms (<code>:-/2</code> is an infix [[Operator (programming)|operator]]) that are easily read and inspected using built-in mechanisms (like <code>read/1</code>), it is possible to write customized interpreters that augment Prolog with domain-specific features. For example, Sterling and Shapiro present a meta-interpreter that performs reasoning with uncertainty, reproduced here with slight modifications:<ref name=AOP94>{{cite book |author1=Shapiro, Ehud Y. |author2=Sterling, Leon |title=The Art of Prolog: Advanced Programming Techniques |publisher=MIT Press |location=Cambridge, Massachusetts |year=1994 |isbn=978-0-262-19338-2}}</ref>{{rp|330}} <syntaxhighlight lang="prolog"> solve(true, 1) :- !. solve((Subgoal1,Subgoal2), Certainty) :- !, solve(Subgoal1, Certainty1), solve(Subgoal2, Certainty2), Certainty is min(Certainty1, Certainty2). solve(Goal, 1) :- builtin(Goal), !, Goal. solve(Head, Certainty) :- clause_cf(Head, Body, Certainty1), solve(Body, Certainty2), Certainty is Certainty1 * Certainty2. </syntaxhighlight> This interpreter uses a table of built-in Prolog predicates of the form<ref name="AOP94"/>{{rp|327}} <syntaxhighlight lang="prolog"> builtin(A is B). builtin(read(X)). % etc. </syntaxhighlight> and clauses represented as <code>clause_cf(Head, Body, Certainty)</code>. Given those, it can be called as <code>solve(Goal, Certainty)</code> to execute <code>Goal</code> and obtain a measure of certainty about the result. == Turing completeness == Pure Prolog is based on a subset of first-order [[predicate logic]], [[Horn clause]]s, which is [[Turing completeness|Turing-complete]]. Turing completeness of Prolog can be shown by using it to simulate a Turing machine: <syntaxhighlight lang="prolog"> turing(Tape0, Tape) :- perform(q0, [], Ls, Tape0, Rs), reverse(Ls, Ls1), append(Ls1, Rs, Tape). perform(qf, Ls, Ls, Rs, Rs) :- !. perform(Q0, Ls0, Ls, Rs0, Rs) :- symbol(Rs0, Sym, RsRest), once(rule(Q0, Sym, Q1, NewSym, Action)), action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1), perform(Q1, Ls1, Ls, Rs1, Rs). symbol([], b, []). symbol([Sym|Rs], Sym, Rs). action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs). action(stay, Ls, Ls, Rs, Rs). action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs). left([], [], Rs0, [b|Rs0]). left([L|Ls], Ls, Rs, [L|Rs]). </syntaxhighlight> A simple example Turing machine is specified by the facts: <syntaxhighlight lang="prolog"> rule(q0, 1, q0, 1, right). rule(q0, b, qf, 1, stay). </syntaxhighlight> This machine performs incrementation by one of a number in unary encoding: It loops over any number of "1" cells and appends an additional "1" at the end. Example query and result: <syntaxhighlight lang="prolog"> ?- turing([1,1,1], Ts). Ts = [1, 1, 1, 1] ; </syntaxhighlight> This illustrates how any computation can be expressed declaratively as a sequence of state transitions, implemented in Prolog as a relation between successive states of interest. == Implementation == {{Further|Comparison of Prolog implementations}} [[File:Prolog systems.svg|thumb|upright=2|Prolog Heritage.<br />Systems with a dark gray background are not supported any more. Arrows denote influences and inspiration of systems. Quick legend: JIT = "Just in Time Compiler", JVM = "Java Virtual Machine", TOAM = "Tree-Oriented Abstract Machine"]] === ISO Prolog === The [[International Organization for Standardization]] (ISO) Prolog [[technical standard]] consists of two parts. ISO/IEC 13211-1,<ref name="ISO 13211">ISO/IEC 13211: Information technology – Programming languages – Prolog. [[International Organization for Standardization]], Geneva.</ref><ref>{{cite book |last1=Ed-Dbali |first1=A. |last2=Deransart |first2=Pierre |last3=Cervoni |first3=L. |year=1996 |title=Prolog: the standard: reference manual |publisher=Springer |location=Berlin |isbn=978-3-540-59304-1}}</ref> published in 1995, aims to standardize the existing practices of the many implementations of the core elements of Prolog. It has clarified aspects of the language that were previously ambiguous and leads to portable programs. There are three corrigenda: Cor.1:2007,<ref name="Cor.1">{{Cite web|url=https://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/05/04/50405.html|title=ISO/IEC 13211-1:1995/Cor 1:2007|website=ISO}}</ref> Cor.2:2012,<ref name="Cor.2">{{Cite web|url=https://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/05/80/58033.html|title=ISO/IEC 13211-1:1995/Cor 2:2012|website=ISO}}</ref> and Cor.3:2017.<ref name="Cor.3">{{Cite web|url=https://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/07/31/73194.html|title=ISO/IEC 13211-1:1995/Cor 3:2017|website=ISO}}</ref> ISO/IEC 13211-2,<ref name="ISO 13211"/> published in 2000, adds support for modules to the standard. The standard is maintained by the [[JTC1|ISO/IEC JTC1]]/[[SC22]]/WG17<ref name="WG17">{{Cite web|url=http://iso.org/jtc1sc22wg17|title=ISO/IEC JTC1 SC22 WG17}}{{Dead link|date=February 2023 |bot=InternetArchiveBot |fix-attempted=yes}}</ref> working group. ANSI X3J17 is the US Technical Advisory Group for the standard.<ref name="X3J17">{{cite web|url=http://www.sju.edu/~jhodgson/x3j17.html|title=X3J17 and the Prolog Standard|access-date=2009-10-02|archive-url=https://web.archive.org/web/20090823160951/http://www.sju.edu/~jhodgson/x3j17.html|archive-date=2009-08-23|url-status=dead}}</ref> === Compilation === For efficiency, Prolog code is typically compiled to abstract machine code, often influenced by the register-based [[Warren Abstract Machine]] (WAM) instruction set.<ref>David H. D. Warren. [http://www.ai.sri.com/pubs/files/641.pdf "An abstract Prolog instruction set"]. Technical Note 309, [[SRI International]], Menlo Park, CA, October 1983.</ref> Some implementations employ [[abstract interpretation]] to derive type and mode information of predicates at compile time, or compile to real machine code for high performance.<ref>{{Cite journal |doi=10.1109/2.108055 |last1=Van Roy |first1=P. |last2=Despain |first2=A. M. |title=High-performance logic programming with the Aquarius Prolog compiler |journal=Computer |volume=25 |pages=54–68 |year=1992 |s2cid=16447071}}</ref> Devising efficient implementation methods for Prolog code is a field of active research in the logic programming community, and various other execution methods are employed in some implementations. These include [[clause binarization]] and [[stack machines|stack-based virtual machines]].{{Citation needed|date=November 2010}} === Tail recursion === Prolog systems typically implement a well-known optimization method called [[tail call#Tail call optimization|tail call optimization]] (TCO) for deterministic predicates exhibiting [[tail recursion]] or, more generally, tail calls: A clause's stack frame is discarded before performing a call in a tail position. Therefore, deterministic tail-recursive predicates are executed with constant stack space, like loops in other languages. === Term indexing === {{Main|Term indexing}} Finding clauses that are unifiable with a term in a query is linear in the number of clauses. [[Term indexing]] uses a [[data structure]] that enables [[Sublinear time|sub-linear-time]] lookups.<ref>{{Cite book |last1=Graf |first1=Peter |title=Term indexing |year=1995 |publisher=Springer |isbn=978-3-540-61040-3}}</ref> Indexing only affects program performance, it does not affect semantics. Most Prologs only use indexing on the first term, as indexing on all terms is expensive, but techniques based on ''field-encoded words'' or ''[[Superimposed code|superimposed]] codewords'' provide fast indexing across the full query and head.<ref name=WisePowers>{{cite conference |last1=Wise |first1=Michael J. |last2=Powers |first2=David M. W. |title=Indexing Prolog Clauses via Superimposed Code Words and Field Encoded Words |journal=International Symposium on Logic Programming |pages=203–210 |year=1986}}</ref><ref name=Colomb>{{Cite journal |doi=10.1016/0743-1066(91)90004-9 |title=Enhancing unification in PROLOG through clause indexing |journal=The Journal of Logic Programming |volume=10 |pages=23–44 |year=1991 |last1=Colomb |first1=Robert M. |doi-access =}}</ref> === Hashing === Some Prolog systems, such as [[Logic Programming Associates|WIN-PROLOG]] and SWI-Prolog, now implement hashing to help handle large datasets more efficiently. This tends to yield very large performance gains when working with large corpora such as [[WordNet]]. === Tabling === {{main|Tabled logic programming}} Some Prolog systems, ([[B-Prolog]], [[XSB]], [[SWI-Prolog]], [[YAP (Prolog)|YAP]], and [[Ciao (programming language)|Ciao]]), implement a [[memoization]] method called ''tabling'', which frees the user from manually storing intermediate results. Tabling is a [[space–time tradeoff]]; execution time can be reduced by using more memory to store intermediate results:<ref>{{Cite journal |last1=Swift |first1=T. |journal=Annals of Mathematics and Artificial Intelligence |volume=25 |issue=3/4 |pages=201–240|title=Tabling for non-monotonic programming |year=1999 |doi=10.1023/A:1018990308362 |s2cid=16695800}}</ref><ref>{{cite journal|last1=Zhou|first1=Neng-Fa|last2=Sato|first2=Taisuke|title=Efficient Fixpoint Computation in Linear Tabling|journal=Proceedings of the 5th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming|date=2003|pages=275–283|url=http://www.sci.brooklyn.cuny.edu/~zhou/papers/ppdp03.pdf}}</ref> <blockquote>Subgoals encountered in a query evaluation are maintained in a table, along with answers to these subgoals. If a subgoal is re-encountered, the evaluation reuses information from the table rather than re-performing resolution against program clauses.<ref>{{Cite journal |doi=10.1017/S1471068411000500 |title=XSB: Extending Prolog with Tabled Logic Programming |journal=Theory and Practice of Logic Programming |volume=12 |issue=1–2 |pages=157–187 |year=2011 |last1=Swift |first1=T. |last2=Warren |first2=D. S. |arxiv=1012.5123 |s2cid=6153112}}</ref></blockquote> Tabling can be extended in various directions. It can support recursive predicates through '''SLG resolution''' or linear tabling. In a multi-threaded Prolog system tabling results could be kept private to a thread or shared among all threads. And in incremental tabling, tabling might react to changes. === Implementation in hardware === During the [[Fifth Generation Computer Systems project]], there were attempts to implement Prolog in hardware with the aim of achieving faster execution with dedicated architectures.<ref>{{Cite book |first5=K. |last5=Kiriyama |page=100 |doi=10.1145/30350.30362 |year=1987 |first4=K. |last4=Kurosawa |last2=Bandoh |first1=S. |first2=T. |title=Proceedings of the 14th annual international symposium on Computer architecture - ISCA '87 |last3=Yamaguchi |first3=S. |last1=Abe |chapter=High performance integrated Prolog processor IPP |isbn=978-0-8186-0776-9 |s2cid=10283148}}</ref><ref>{{cite conference |first=Ian |last=Robinson |isbn=978-3-540-16492-0 |doi=10.1007/3-540-16492-8_73 |title=A Prolog processor based on a pattern matching memory device |conference=Third International Conference on Logic Programming |series=Lecture Notes in Computer Science |publisher=Springer |volume=225|pages=172–179 |year=1986}}</ref><ref>{{Cite journal |journal=ACM SIGPLAN Notices |title=Performance and architectural evaluation of the PSI machine |volume=22 |page=128 |doi=10.1145/36205.36195 |year=1987 |last1=Taki |first4=M. |last2=Nakajima |first1=K. |last4=Ikeda |first2=K. |last3=Nakashima |first3=H. |issue=10 |doi-access=free}}</ref> Furthermore, Prolog has a number of properties that may allow speed-up through parallel execution.<ref>{{Cite journal |last1=Gupta |first1=G. |last2=Pontelli |first2=E. |last3=Ali |first3=K. A. M. |last4=Carlsson |first4=M. |last5=Hermenegildo |first5=M. V. |year=2001 |journal=[[ACM Transactions on Programming Languages and Systems]] |title=Parallel execution of prolog programs: a survey |volume=23 |page=472 |doi=10.1145/504083.504085 |issue=4 |s2cid=2978041 |url=http://oa.upm.es/11160/ |doi-access=free}}</ref> A more recent approach has been to compile restricted Prolog programs to a [[field programmable gate array]].<ref>{{Cite web|url=http://www.cl.cam.ac.uk/~am21/research/sa/byrdbox.ps.gz|title=Statically Allocated Systems}}</ref> However, rapid progress in general-purpose hardware has consistently overtaken more specialised architectures. In 1982, computers operated at around 10,000 to 100,000 LIPS [logical inferences per second]. The FGCS planned to produce computers operating at 0.1 to 1 GLIPS.<ref>{{Cite book |last1=Bramer |first1=M. A. |url=https://archive.org/details/fifthgenerationa0000bram |title=The fifth generation: an annotated bibliography |last2=Bramer |first2=Dawn |date=1984 |publisher=Addison-Wesley |isbn=978-0-201-14427-7 |location=Wokingham, England ; Reading, Mass |pages=6}}</ref> The Institute for New Generation Computer Technology documents estimated that 1 LIP took about 100 operations on a conventional computer. The plan was to produce at the end of the project (in 1992) a machine with 1000 processors achieving 1 GLIPS, implying at least 1 MLIPS per processor.<ref>{{Cite journal |last1=Feigenbaum |first1=Edward |last2=Shrobe |first2=Howard |date=1993-07-01 |title=The Japanese national Fifth Generation project: Introduction, survey, and evaluation |journal=Future Generation Computer Systems |series=FGCS Conference |volume=9 |issue=2 |pages=105–117 |doi=10.1016/0167-739X(93)90003-8 |issn=0167-739X|doi-access=free }}</ref> [[Sega]] implemented Prolog for use with the Sega AI Computer, released for the Japanese market in 1986. Prolog was used for reading [[natural language]] inputs, in the [[Japanese language]], via a [[touch pad]].<ref>{{cite magazine |date=March 26, 1987 |title=Software that takes games seriously |magazine=[[New Scientist]] |publisher=[[Reed Business Information]] |via=[[Google Books]] |page=34 |url=https://books.google.com/books?id=RI51dkpbcGoC&pg=PA34 }}{{Dead link|date=November 2023 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> == Extensions == Various implementations have been developed from Prolog to extend logic programming abilities in many directions. These include [[type system|types]], modes, [[constraint logic programming]] (CLP), [[Object-oriented programming|object-oriented]] logic programming (OOLP), concurrency, [[linear logic]] (LLP), functional and [[higher-order logic]] programming abilities, plus interoperability with [[knowledge base]]s: === Types === Prolog is an untyped language. Attempts to introduce and extend Prolog with types began in the 1980s,<ref>{{Cite journal |doi=10.1016/0004-3702(84)90017-1 |last1=Mycroft |first1=A. |last2=O'Keefe |first2=R. A. |title=A polymorphic type system for prolog |journal=[[Artificial Intelligence (journal)|Artificial Intelligence]] |volume=23 |issue=3 |page=295 |year=1984}}</ref><ref>{{cite book |author=Pfenning, Frank |title=Types in logic programming |publisher=MIT Press |location=Cambridge, Massachusetts |year=1992 |isbn=978-0-262-16131-2}}</ref> and continue {{as of|2008|lc=y}}.<ref>{{Cite book |last1=Schrijvers |first1=Tom |last2=Santos Costa |first2=Vitor |last3=Wielemaker |first3=Jan |last4=Demoen |first4=Bart |year=2008 |chapter=Towards Typed Prolog |editor1=María García de la Banda |editor1-link=María García de la Banda|editor2=Enrico Pontelli |title=Logic programming: 24th international conference, ICLP 2008, Udine, Italy, December 9-13, 2008: proceedings |series=Lecture Notes in Computer Science |volume=5366 |pages=693–697 |doi=10.1007/978-3-540-89982-2_59 |isbn=978-3-540-89982-2 |chapter-url=https://lirias.kuleuven.be/handle/123456789/197561}}</ref> Type information is useful not only for [[type safety]] but also for reasoning about Prolog programs.<ref name="cite doi|10.1007/BF01213601">{{Cite journal |doi=10.1007/BF01213601 |last1=Apt |first1=K. R. |last2=Marchiori |first2=E. |title=Reasoning about Prolog programs: From modes through types to assertions |journal=Formal Aspects of Computing |volume=6 |issue=S1 |page=743 |year=1994 |url=http://www.cwi.nl/~apt/am.ps |citeseerx=10.1.1.57.395 |s2cid=12235465}}</ref> === Modes === {| style="float: right;" class="wikitable" border="1" |- ! Mode specifier ! Interpretation |- | <code>+</code> | <code>nonvar</code> on entry |- | <code>-</code> | <code>var</code> on entry |- | <code>?</code> | Not specified |} The syntax of Prolog does not specify which arguments of a predicate are inputs and which are outputs.<ref name="craft">{{cite book |author=O'Keefe, Richard A. |title=The craft of Prolog |publisher=MIT Press |location=Cambridge, Massachusetts |year=1990 |isbn=978-0-262-15039-2}}</ref> However, this information is significant and it is recommended that it be included in the comments.<ref>{{cite arXiv |title=Coding guidelines for Prolog |date=2010 |eprint=0911.2899 |last1=Covington |first1=Michael |last2=Bagnara |first2=Roberto |last3=O'Keefe |first3=Richard |last4=Wielemaker |first4=Jan |last5=Price |first5=Simon |display-authors=2 |class=cs.PL}}</ref> Modes provide valuable information when reasoning about Prolog programs<ref name="cite doi|10.1007/BF01213601"/> and can also be used to accelerate execution.<ref>{{Cite book |doi=10.1007/BFb0014976 |last1=Roy |first1=P. |last2=Demoen |first2=B. |isbn=978-3-540-17611-4 |last3=Willems |first3=Y. D. |chapter=Improving the execution speed of compiled Prolog with modes, clause selection, and determinism |title=Tapsoft '87 |series=Lecture Notes in Computer Science |volume=250 |pages=[https://archive.org/details/tapsoft87proceed0000inte/page/111 111] |year=1987 |chapter-url=https://archive.org/details/tapsoft87proceed0000inte/page/111}}</ref> === Constraints === [[Constraint logic programming]] extends Prolog to include concepts from [[constraint satisfaction]].<ref>{{Cite journal |last=Jaffar |first=J. |year=1994 |title=Constraint logic programming: a survey |journal=The Journal of Logic Programming |volume=19–20 |pages=503–581 |doi=10.1016/0743-1066(94)90033-7 |doi-access=free}}</ref><ref> {{cite journal |first=Alain |last=Colmerauer |year=1987 |title=Opening the Prolog III Universe |journal=Byte |volume=August }}</ref> A constraint logic program allows constraints in the body of clauses, such as: <code>A(X,Y) :- X+Y>0.</code> It is suited to large-scale [[combinatorial optimisation]] problems<ref>{{Cite book |last=Wallace |first=M. |year=2002 |chapter=Constraint Logic Programming |isbn=978-3-540-45628-5 |title=Computational Logic: Logic Programming and Beyond |series=Lecture Notes in Computer Science |volume=2407 |pages=512–556 |doi=10.1007/3-540-45628-7_19}}</ref> and is thus useful for applications in industrial settings, such as automated time-tabling and [[production scheduling]]. Most Prolog systems ship with at least one constraint solver for finite domains, and often also with solvers for other domains like [[rational number]]s. === Object-orientation === [[Flora-2]] is an object-oriented knowledge representation and reasoning system based on [[F-logic]] and incorporates [[HiLog]], [[Transaction logic]], and [[defeasible reasoning]]. [[Logtalk]] is an object-oriented logic programming language that can use most Prolog implementations as a back-end compiler. As a multi-paradigm language, it includes support for both prototypes and classes. [[Oblog]] is a small, portable, object-oriented extension to Prolog by Margaret McDougall of EdCAAD, University of Edinburgh. [[Objlog]] was a frame-based language combining objects and Prolog II from CNRS, Marseille, France. [[Prolog++]] was developed by [[Logic Programming Associates]] and first released in 1989 for MS-DOS PCs. Support for other platforms was added, and a second version was released in 1995. A book about Prolog++ by Chris Moss was published by Addison-Wesley in 1994. [[Visual Prolog]] is a multi-paradigm language with interfaces, classes, implementations and object expressions. === Graphics === Prolog systems that provide a [[graphics library]] are [[SWI-Prolog]],<ref>{{Cite web |url=https://www.swi-prolog.org/packages/xpce/ |title=XPCE: the SWI-Prolog native GUI library |website=swi-prolog.org}}</ref> [[Visual Prolog]], [[Logic Programming Associates|WIN-PROLOG]], and [[B-Prolog]]. === Concurrency === Prolog-MPI is an open-source [[SWI-Prolog]] extension for [[distributed computing]] over the [[Message Passing Interface]].<ref>{{cite web|url=http://apps.lumii.lv/prolog-mpi/ |title=prolog-mpi |publisher=Apps.lumii.lv |access-date=2010-09-16}}</ref> Also there are various concurrent Prolog programming languages.<ref>Ehud Shapiro. ''The family of concurrent logic programming languages'' [[ACM Computing Surveys]]. September 1989.</ref> === Web programming === Some Prolog implementations, notably [[Visual Prolog]], [[SWI-Prolog]] and [[Ciao (programming language)|Ciao]], support [[server-side]] [[web programming]] with support for web protocols, [[HTML]] and [[XML]].<ref>{{Cite journal |journal=Theory and Practice of Logic Programming |volume=8 |year=2008 |doi=10.1017/S1471068407003237 |title=SWI-Prolog and the web |first3=L. |first1=J. |last2=Huang |first2=Z. |last1=Wielemaker |last3=Van Der Meij |issue=3 |page=363 |s2cid=5404048 |url=https://pure.uva.nl/ws/files/4221287/58604_285112.pdf}}</ref> There are also extensions to support [[semantic web]] formats such as [[Resource Description Framework]] (RDF) and [[Web Ontology Language]] (OWL).<ref> {{citation |last1=Wielemaker |first1=Jan |last2=Hildebrand |first2=Michiel |last3=van Ossenbruggen |first3=Jacco |year=2007 |title=Using {Prolog} as the fundament for applications on the semantic web |periodical=Proceedings of the 2nd Workshop on Applications of Logic Programming and to the Web, Semantic Web and Semantic Web Services |publisher=CEUR-WS.org |series=CEUR Workshop Proceedings |volume=287 |pages=84–98 |location=Porto, Portugal |editor1-last=Heymans |editor1-first=S. |editor2-last=Polleres |editor2-first=A. |editor3-last=Ruckhaus |editor3-first=E. |editor4-last=Pearse |editor4-first=D. |editor5-last=Gupta |editor5-first=G. |url=http://ftp.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-287/paper_1.pdf }}</ref><ref>[http://ceur-ws.org/Vol-529/owled2009_submission_43.pdf Processing OWL2 Ontologies using Thea: An Application of Logic Programming]. Vangelis Vassiliadis, Jan Wielemaker and Chris Mungall. Proceedings of the 5th International Workshop on OWL: Experiences and Directions (OWLED 2009), Chantilly, VA, United States, October 23–24, 2009</ref> Prolog has also been suggested as a [[client-side]] language.<ref>{{Cite journal |last1=Loke |first1=S. W. |last2=Davison |first2=A. |title=Secure Prolog-based mobile code |journal=Theory and Practice of Logic Programming |volume=1 |issue=3 |page=321 |year=2001 |doi=10.1017/S1471068401001211 |citeseerx=10.1.1.58.6610 |arxiv=cs/0406012 |s2cid=11754347}}</ref> In addition, Visual Prolog supports [[JSON-RPC]] and [[Websockets]]. === Adobe Flash === [http://sites.google.com/site/cedarprolog/ Cedar] {{Webarchive|url=https://web.archive.org/web/20101019074143/http://sites.google.com/site/cedarprolog/ |date=2010-10-19}} is a free and basic Prolog interpreter. From version 4 and above Cedar has a FCA (Flash Cedar App) support. This provides a new platform to programming in Prolog through [[ActionScript]]. === Other === * [[F-logic]] extends Prolog with frames/objects for [[knowledge representation]]. * [[Transaction logic]] extends Prolog with a logical theory of state-changing update operators. It has both a model-theoretic and procedural semantics. * [[OW Prolog]] has been created in order to answer Prolog's lack of graphics and interface. == Interfaces to other languages == Frameworks exist which can bridge between Prolog and other languages: * The [https://www.lpai.uk/int.htm LPA Intelligence Server] allows embedding [https://www.lpai.uk/win.htm LPA Prolog for Windows] in other programming languages, including: [[C (programming language)|C]], {{nowrap|[[C++]]}}, [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]], [[Visual Basic (classic)|Visual Basic]] (VB), [[Delphi (software)|Delphi]], [[.NET]], [[Lua (programming language)|Lua]], [[Python (programming language)|Python]], and others. It exploits the dedicated string data type which LPA Prolog provides * The [http://www.amzi.com/#apls Logic Server] Application Programming Interface ([[API]]) allows both the extension and embedding of Prolog in [[C (programming language)|C]], {{nowrap|[[C++]]}}, [[Java (programming language)|Java]], [[Visual Basic (classic)|Visual Basic]] (VB), [[Delphi (software)|Delphi]], [[.NET]], and any language or environment which can call a .dll or .so. It is implemented for [http://www.amzi.com/#apls Amzi! Prolog + Logic Server] but the API specification can be made available for any implementation. * [https://jpl7.org/ JPL] is a bi-directional Java Prolog bridge which ships with SWI-Prolog by default, allowing Java and Prolog to call each other (recursively). It is known to have good concurrency support and is under active development. * [http://interprolog.com/ InterProlog], a programming [[Library (computing)|library]] bridge between [[Java platform|Java]] and Prolog, implementing bi-directional predicate/method calling between both languages. Java objects can be mapped into Prolog terms and vice versa. Allows the development of [[graphical user interface]]s (GUIs) and other functions in Java while leaving logic processing in the Prolog layer. Supports [[XSB]] and [[SWI-Prolog]]. * [[Prova]] provides native syntax integration with Java, agent messaging and reaction rules. Prova positions itself as a rule-based scripting (RBS) system for middleware. The language breaks new ground in combining [[imperative programming|imperative]] and [[declarative programming]]. * [https://github.com/raydac/jprol/ PROL] An embeddable Prolog engine for Java. It includes a small IDE and a few libraries. * [https://www.gnu.org/software/gnuprologjava/ GNU Prolog for Java] is an implementation of ISO Prolog as a Java library (gnu.prolog) * [[Ciao (programming language)|Ciao]] provides interfaces to C, {{nowrap|C++}}, Java, and relational databases. * [http://sourceforge.net/projects/cs-prolog/ C#-Prolog] is a Prolog interpreter written in (managed) C#. Can easily be integrated in C# programs. Characteristics: reliable and fairly fast interpreter, command line interface, Windows-interface, builtin DCG, XML-predicates, SQL-predicates, extendible. The complete source code is available, including a parser generator that can be used for adding special purpose extensions. * [https://github.com/Trismegiste/WamBundle A Warren Abstract Machine for PHP] A Prolog compiler and interpreter in PHP 5.3. A library that can be used standalone or within Symfony2.1 framework which was translated from [http://stefan.buettcher.org/ Stephan Buettcher's] work in Java which can be found [here {{URL|http://stefan.buettcher.org/cs/wam/}}] * [http://tuprolog.unibo.it tuProlog] is a lightweight Prolog system for distributed applications and infrastructures, intentionally designed around a minimal core, to be either statically or dynamically configured by loading/unloading libraries of predicates. tuProlog natively supports multi-paradigm programming, providing a clean, seamless integration model between Prolog and mainstream object-oriented languages, namely Java, for tuProlog Java version, and any .NET-based language (C#, F#..), for tuProlog .NET version. * [https://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/janus.html%27) Janus] is a bi-directional interface between Prolog and Python using portable low-level primitives. It was initially developed for XSB by Anderson and Swift,<ref>Andersen, C. and Swift, T., 2023. The Janus System: a bridge to new prolog applications. In Prolog: The Next 50 Years (pp. 93-104). Cham: Springer Nature Switzerland.</ref> but has been adopted as a joint initiative by the XSB, Ciao and SWI-Prolog teams. == See also == * [[Comparison of Prolog implementations]] * [[Logico-linguistic modeling]]. A method for building knowledge-based system that uses Prolog. * [[Answer set programming]]. A fully declarative approach to logic programming. * [[Association for Logic Programming]] ===Related languages=== * The [[Gödel (programming language)|Gödel]] language is a strongly typed implementation of [[concurrent constraint logic programming]]. It is built on [[SICStus Prolog]]. * [[Visual Prolog]], formerly named PDC Prolog and Turbo Prolog, is a [[data type|strongly typed]] [[Object-oriented programming|object-oriented]] dialect of Prolog, which is very different from standard Prolog. As Turbo Prolog, it was marketed by Borland, but is now developed and marketed by the Danish firm Prolog Development Center (PDC) that originally produced it. * [[Datalog]] is a subset of Prolog. It is limited to relationships that may be stratified and does not allow compound terms. In contrast to Prolog, Datalog is not [[Turing-complete]]. * [[Mercury (programming language)|Mercury]] is an offshoot of Prolog geared toward software engineering in the large with a static, polymorphic type system, as well as a mode and determinism system. * GraphTalk is a proprietary implementation of Warren's Abstract Machine, with additional object-oriented properties. * In some ways{{Which|date=February 2010}} Prolog is a subset of [[Planner (programming language)|Planner]]. The ideas in Planner were later further developed in the [[Scientific Community Metaphor]]. * [[AgentSpeak]] is a variant of Prolog for programming agent behavior in [[multi-agent system]]s. * [[Erlang (programming language)|Erlang]] began life with a Prolog-based implementation and maintains much of Prolog's unification-based syntax. * [https://picolisp.com/wiki/?accessToLispFunctionFromPilog Pilog] is a declarative language built on top of [[PicoLisp]], that has the semantics of Prolog, but uses the syntax of Lisp. * [[λProlog]] is an extension of core Prolog that features polymorphic typing, modular programming, and higher-order programming, including direct support for terms with variable-binding operators through so-called λ-tree syntax and higher-order pattern unification. == Notes == {{reflist|group=note}} == References == {{reflist}} == Further reading == {{refbegin|35em}} * {{cite book |first1=Patrick |last1=Blackburn |first2=Johan |last2=Bos |first3=Kristina |last3=Striegnitz |title=Learn Prolog Now! |url=http://www.learnprolognow.org/ |year=2006 |publisher=College Publications |isbn=978-1-904987-17-8 |access-date=2008-12-02 |archive-date=2007-08-26 |archive-url=https://web.archive.org/web/20070826231318/http://www.learnprolognow.org/ |url-status=dead }} * [[Ivan Bratko (computer scientist)|Ivan Bratko]], ''Prolog Programming for Artificial Intelligence'', 4th ed., 2012, {{ISBN|978-0-321-41746-6}}. [https://ailab.si/ivan/datoteke/dokumenti/32/107_19_Bratko_Prolog_book_web_resources.htm Book supplements and source code]{{Dead link|date=August 2019 |bot=InternetArchiveBot |fix-attempted=yes }} * William F. Clocksin, Christopher S. Mellish: ''Programming in Prolog: Using the ISO Standard''. Springer, 5th ed., 2003, {{ISBN|978-3-540-00678-7}}. ''(This edition is updated for ISO Prolog. Prior editions described Edinburgh Prolog.)'' * William F. Clocksin: ''Clause and Effect. Prolog Programming for the Working Programmer''. Springer, 2003, {{ISBN|978-3-540-62971-9}}. * [[Michael A. Covington]], Donald Nute, Andre Vellino, ''Prolog Programming in Depth'', 1996, {{ISBN|0-13-138645-X}}. * Michael A. Covington, ''Natural Language Processing for Prolog Programmers'', 1994, {{ISBN|978-0-13-629213-5}} * M. S. Dawe and C.M.Dawe, ''Prolog for Computer Sciences'', Springer Verlag 1992. * ''ISO/IEC 13211: Information technology – Programming languages – Prolog''. [[International Organization for Standardization]], Geneva. * Feliks Kluźniak and Stanisław Szpakowicz (with a contribution by Janusz S. Bień). ''Prolog for Programmers''. Academic Press Inc. (London), 1985, 1987 (available under a [[Creative Commons]] license at {{URL|https://sites.google.com/site/prologforprogrammers/}}{{Dead link|date=September 2019 |bot=InternetArchiveBot |fix-attempted=yes}}). {{ISBN|0-12-416521-4}}. * [[Richard O'Keefe]], ''The Craft of Prolog'', {{ISBN|0-262-15039-5}}. * Robert Smith, John Gibson, [[Aaron Sloman]]: 'POPLOG's two-level virtual machine support for interactive languages', in ''Research Directions in Cognitive Science Volume 5: Artificial Intelligence'', Eds [[Derek H. Sleeman|D. Sleeman]] and N. Bernsen, Lawrence Erlbaum Associates, pp 203–231, 1992. * [[Leon Sterling]] and [[Ehud Shapiro]], ''The Art of Prolog: Advanced Programming Techniques'', 1994, {{ISBN|0-262-19338-8}}. * David H D Warren, Luis M. Pereira and Fernando Pereira, Prolog - the language and its implementation compared with Lisp. ACM SIGART Bulletin archive, Issue 64. Proceedings of the 1977 symposium on Artificial intelligence and programming languages, pp 109–115. {{refend}} ==External links== * {{Wikibooks-inline}} {{Programming languages}} {{ISO standards}} {{Authority control}} [[Category:Dynamically typed programming languages]] [[Category:Logic programming languages]] [[Category:Pattern matching programming languages]] [[Category:Programming languages created in 1972]] [[Category:Programming languages with an ISO standard]] [[Category:Prolog programming language family]] [[Category:Homoiconic programming languages]] [[Category:French inventions]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:As of
(
edit
)
Template:Authority control
(
edit
)
Template:Citation
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite arXiv
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite magazine
(
edit
)
Template:Cite news
(
edit
)
Template:Cite report
(
edit
)
Template:Cite web
(
edit
)
Template:Clarify
(
edit
)
Template:Dead link
(
edit
)
Template:Further
(
edit
)
Template:ISBN
(
edit
)
Template:ISO standards
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Lang
(
edit
)
Template:Main
(
edit
)
Template:Main other
(
edit
)
Template:N/a
(
edit
)
Template:Nowrap
(
edit
)
Template:Programming languages
(
edit
)
Template:Refbegin
(
edit
)
Template:Refend
(
edit
)
Template:Reflist
(
edit
)
Template:Rp
(
edit
)
Template:Section link
(
edit
)
Template:Short description
(
edit
)
Template:URL
(
edit
)
Template:Webarchive
(
edit
)
Template:Which
(
edit
)
Template:Wikibooks-inline
(
edit
)