Misplaced Pages

PL

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Prolog is a logic programming language that has its origins in artificial intelligence , automated theorem proving and computational linguistics .

#262737

42-480: [REDACTED] Look up PL , pl , or pl. in Wiktionary, the free dictionary. PL , P.L. , Pl , or .pl may refer to: Businesses and organizations [ edit ] Government and political [ edit ] Partit Laburista , a Maltese political party Liberal Party (Brazil, 2006) , a Brazilian political party Liberal Party (Moldova) ,

84-664: A formal logic , and unlike many other programming languages , Prolog is intended primarily as a declarative programming language: the program is a set of facts and rules , which define relations . A computation is initiated by running a query over the program. Prolog was one of the first logic programming languages and remains the most popular such language today, with several free and commercial implementations available. The language has been used for theorem proving , expert systems , term rewriting , type systems , and automated planning , as well as its original intended field of use, natural language processing . Prolog

126-458: A 1993 book by the American philosopher John Rawls Private label , an arrangement between companies regarding the exclusive sale of goods Public law Public liability Topics referred to by the same term [REDACTED] This disambiguation page lists articles associated with the title PL . If an internal link led you here, you may wish to change the link to point directly to

168-524: A French aircraft designer Plastic limit , in geotechnical engineering PL / Positive Lock, a lens mount used on Arri cameras and lenses pl., abbreviation for printing plates , often indicating the number of plate-based illustrations in a book Adobe Prelude , an Adobe software Other uses [ edit ] Platoon leader , in the US Army Plural , in grammar Polish language (ISO 639-1 code "pl") Political Liberalism ,

210-619: A Moldovan political party Liberal Party (Rwanda) , a Rwandan political party Parlamentarische Linke , a parliamentary caucus in Germany Patriotic League (Bosnia and Herzegovina) (Bosnian: Patriotska Liga ), a military organisation of the Republic of Bosnia and Herzegovina Philippine Legislature , a legislature that existed in the Philippines from 1907 to 1935 Progressive Labor Party (United States) ,

252-830: A United States communist party Sports leagues [ edit ] Premier League , the top English football league Pacific League , one of the two leagues in Japan's Nippon Professional Baseball Pioneer Baseball League , a Rookie league in American Minor League Baseball Pioneer Football League , NCAA FCS conference Other businesses and organizations [ edit ] Airstars Airways (IATA airline designator PL, 2000–2011) Aeroperú (IATA airline designator PL, 1973–1999) Papillion-La Vista Senior High School in Papillion, Nebraska, USA Public library ,

294-421: A concise meta-circular evaluator (also called meta-interpreter ) for pure Prolog code: where true represents an empty conjunction, and clause(Head, Body) unifies with clauses in the database of the form Head :- Body . Since Prolog programs are themselves sequences of Prolog terms ( :-/2 is an infix operator ) that are easily read and inspected using built-in mechanisms (like read/1 ), it

336-541: 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, analogous to monads in other languages. DCGs are often used to write parsers or list generators, as they also provide a convenient interface to difference lists. Prolog is a homoiconic language and provides many facilities for reflective programming (reflection). Its implicit execution strategy makes it possible to write

378-427: A given query in a list. This can be used for list comprehension . For example, perfect numbers equal the sum of their proper divisors: This can be used to enumerate perfect numbers, and to check if a number is perfect. As another example, the predicate maplist applies a predicate P to all corresponding positions in a pair of lists: When P is a predicate that for all X , P(X,Y) unifies Y with

420-492: A kind of squelching of an audio signal Packet loss , one of the three main error types encountered in digital communications Path loss , in telecommunication engineering Presentation layer , one of the seven layers in the OSI model of computer networking Digital Private Line , another form of tone squelching Mathematics [ edit ] Piecewise linear (disambiguation) , in mathematics Propositional logic ,

462-474: A library maintained by government for public use Professional Limited Liability Company , a limited liability company organized for the purpose of providing professional services Places [ edit ] PL postcode area , UK, a group of postcode districts in England Poland (ISO 3166-1 country code) Religion [ edit ] PL Kyodan , a religious movement founded in Japan in

SECTION 10

#1732765847263

504-429: A list List ). 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

546-528: A semi-colon ; . There are guidelines on good programming practice to improve code efficiency, readability and maintainability. Here follow some example programs written in Prolog. Example of a basic query in a couple of popular Prolog dialects: This comparison shows the prompt ("?-" vs "| ?-") and resolution status ("true." vs "yes", "false." vs "no") can differ from one Prolog implementation to another. Any computation can be expressed declaratively as

588-589: 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: or equivalently using DCG notation: The quicksort sorting algorithm, relating a list to its sorted version: A design pattern is a general reusable solution to a commonly occurring problem in software design . Some design patterns in Prolog are skeletons, techniques, cliches, program schemata, logic description schemata, and higher-order programming . A higher-order predicate

630-561: A single unique value, maplist(P, Xs, Ys) is equivalent to applying the map function in functional programming as Ys = map(Function, Xs) . Higher-order programming style in Prolog was pioneered in HiLog and λProlog . For programming in the large , Prolog provides a module system , which is in the ISO Standard. However, while most Prolog systems support structuring the code into modules, virtually no implementation adheres to

672-453: A system of evaluating truth-based propositions in terms of binary logic PL (complexity) , in complexity theory Other uses in science and technology [ edit ] Ice pellets (METAR weather code PL), a form of precipitation Picolitre (pL), and petaliter (PL), units of volume Pluto , a dwarf planet Photoluminescence , the re-emission of photons from a surface following exposure Pierre Levasseur (aircraft builder) ,

714-403: Is a Turing-complete, general-purpose programming language, which is well-suited for intelligent knowledge-processing applications. 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 . Relations are defined by clauses . Given a query,

756-460: 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, ISO Prolog now has some built-in higher-order predicates such as call/1 , call/2 , call/3 , findall/3 , setof/3 , and bagof/3 . Furthermore, since arbitrary Prolog goals can be constructed and evaluated at run-time, it

798-426: Is a set of predicates. For example, the following Prolog program, which defines some family relations, has four predicates: Predicate father_child/2 has three clauses, all of which are facts, and predicate parent_child/2 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, length/2 can be used to determine

840-417: Is always true. Given the above fact, one can ask: is socrates a human? what things are humans? Clauses with bodies are called rules . An example of a rule is: If we add that rule and ask what things are mortals? 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

882-403: Is called chronological backtracking . For example, given the family relation program defined above, the following query will be evaluated to true: This is obtained as follows: Initially, the only matching clause-head for the query sibling(sally, erica) 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.,

SECTION 20

#1732765847263

924-445: Is easy to write higher-order predicates like maplist/2 , which applies an arbitrary predicate to each member of a given list, and sublist/3 , which filters elements that satisfy a given predicate, also allowing for currying . 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

966-400: Is generated, and the next goal to be proved is the second part of the above conjunction: parent_child(tom, erica) . 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: enumerates all valid answers on backtracking. Notice that with

1008-448: Is recursive because it is defined in terms of itself (there is a call to predicate ancestor/2 in the body of the second clause). 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 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

1050-448: Is the term . Terms are either atoms , numbers , variables or compound terms . Special cases of compound terms: Prolog programs describe relations, defined by means of clauses. Pure Prolog is restricted to Horn clauses . Two types of Horn clauses are used to define Prolog programs: rules and facts. A rule is of the form and is read as "Head is true if Body is true". A rule's body consists of calls to predicates, which are called

1092-427: Is the case of Logtalk . GNU Prolog initially diverted from ISO modules, opting instead for Contextual Logic Programming , in which unit (module) loading and unloading can be made dynamically. 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

1134-404: The truth value of certain special predicates may have some deliberate 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. Prolog's single data type

1176-475: The PL/I computer programming language, developed at Cornell University in the 1970s PL/I , a computer programming language developed in the 1960s PL/SQL , Oracle's procedural language extension (inception in 1995) PL/pgSQL , PostgreSQL's procedural language extension (inception 1998) Telecommunication and networking [ edit ] .pl , country code top-level domain for Poland PL tone ,

1218-589: The Prolog engine attempts to find a 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 predicates , checking

1260-428: The code as stated above, the query ?- sibling(sally, sally). also succeeds. One would insert additional goals to describe the relevant restrictions, if desired. The built-in Prolog predicate \+/1 provides negation as failure , which allows for non-monotonic reasoning. The goal \+ illegal(X) in the rule is evaluated as follows: Prolog attempts to prove illegal(X) . If a proof for that goal can be found,

1302-407: The conjunction (parent_child(Z,sally), parent_child(Z,erica)) . The next goal to be proved is the leftmost one of this conjunction, i.e., parent_child(Z, sally) . Two clause heads match this goal. The system creates a choice-point and tries the first alternative, whose body is father_child(Z, sally) . This goal can be proved using the fact father_child(tom, sally) , so the binding Z = tom

PL - Misplaced Pages Continue

1344-882: The early 20th century Patrologia Latina , a collection of Catholic writings published by Jacques-Paul Migne between 1841 and 1855 Science, technology, and mathematics [ edit ] Chemistry [ edit ] Pyridoxal , one form of vitamin B6 Pulchellidin (Pl), an anthocyanidin Phospholipid , a class of lipids that are a major component of all cell membranes Computing and telecommunications [ edit ] File formats [ edit ] .pl , common filename suffix for Perl scripts .pl , common filename suffix for Prolog programs .pl , common filename suffix for TeX font property lists Programming [ edit ] Programming language PL/C , an instructional dialect of

1386-528: The intended article. Retrieved from " https://en.wikipedia.org/w/index.php?title=PL&oldid=1258508552 " Category : Disambiguation pages Hidden categories: Short description is different from Wikidata All article disambiguation pages All disambiguation pages PL">PL The requested page title contains unsupported characters : ">". Return to Main Page . Prolog Prolog has its roots in first-order logic ,

1428-438: The large. XSB takes a different approach and offers an atom-based module system. The latter two Prolog systems allow controlling the visibility of terms in addition to that of predicates. There is a special notation called definite clause grammars (DCGs). A rule defined via -->/2 instead of :-/2 is expanded by the preprocessor ( expand_term/2 , a facility analogous to macros in other languages) according to

1470-415: The length of a list ( length(List, L) , given a list List ), and to generate a list skeleton of a given length ( length(X, 5) ), and to generate both list skeletons and their lengths together ( length(X, L) ). Similarly, append/3 can be used both to append two lists ( append(ListA, ListB, X) given lists ListA and ListB ), and to split a given list into parts ( append(X, Y, List) , given

1512-527: The modules part of the ISO standard. Instead, most Prolog systems have decided to support as de-facto module standard the Quintus / SICStus module system. However, further convenience predicates concerning modules are provided by some implementations only and often have subtle differences in their semantics. Some systems chose to implement module concepts as source-to-source compilation into base ISO Prolog, as

1554-399: The original goal (i.e., \+ illegal(X) ) fails. If no proof can be found, the original goal succeeds. Therefore, the \+/1 prefix operator is called the "not provable" operator, since the query ?- \+ Goal. succeeds if Goal is not provable. This kind of negation is sound if its argument is "ground" (i.e. contains no variables). Soundness is lost if the argument contains variables and

1596-447: The proof procedure is complete. In particular, the query ?- legal(X). now cannot be used to enumerate all things that are legal. In Prolog, loading code is referred to as consulting . Prolog can be used interactively by entering queries at the Prolog prompt ?- . If there is no solution, Prolog writes no . If a solution exists then it is printed. If there are multiple solutions to the query, then these can be requested by entering

1638-418: 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,

1680-403: The rule's goals . The built-in logical operator ,/2 (meaning an arity 2 operator with name , ) denotes conjunction of goals, and ;/2 denotes 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: which is equivalent to the rule: The built-in predicate true/0

1722-406: The system creates a choice-point, 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

PL - Misplaced Pages Continue

1764-412: The system. For example, the predicate write/1 displays a term on the screen. Iterative algorithms can be implemented by means of recursive predicates. Consider the parent_child/2 predicate defined in the family relation program above. The following Prolog program defines the ancestor relation: 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

#262737