background preloader

Logic Programming

Facebook Twitter

Prolog. Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.[1][2][3] Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is declarative: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.[4] The language was first conceived by a group around Alain Colmerauer in Marseille, France, in the early 1970s and the first Prolog system was developed in 1972 by Colmerauer with Philippe Roussel.[5][6] Prolog was one of the first logic programming languages,[7] and remains the most popular among such languages today, with many free and commercial implementations available.

Prolog is well-suited for specific tasks that benefit from rule-based logical queries such as databases searching, voice control systems, and template filling. §Syntax and semantics[edit] §Data types[edit] ? ? ? ? Declarative programming. Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, functional programming, and configuration management systems. Definition[edit] Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions exist that attempt to give the term a definition other than simply contrasting it with imperative programming. For example: These definitions overlap substantially. Subparadigms[edit] Declarative programming is an umbrella term that includes a number of better-known programming paradigms.

Constraint programming[edit] Constraint programming is often used as a complement to other paradigms: functional, logical or even imperative programming. Domain-specific languages[edit] Many markup languages such as HTML, MXML, XAML, XSLT or other user-interface markup languages are often declarative. Functional programming[edit] Hybrid languages[edit] Logic programming[edit] Logic programming. Logic programming is a programming paradigm based on formal logic. Programs written in a logical programming language are sets of logical sentences, expressing facts and rules about some problem domain. Together with an inference algorithm, they form a program.

Major logic programming languages include Prolog and Datalog. A form of logical sentences commonly found in logic programming, but not exclusively, is the Horn clause. An example is: p(X, Y) if q(X) and r(Y) Logical sentences can be understood purely declaratively. The programmer can use the declarative reading of logic programs to verify their correctness. History[edit] The use of mathematical logic to represent and execute computer programs is also a feature of the lambda calculus, developed by Alonzo Church in the 1930s.

In 1997, the Association of Logic Programming bestowed to fifteen recognized researchers in logic programming the title Founders of Logic Programming to recognize them as pioneers in the field:[1] Prolog[edit] Abductive logic programming. Abductive logic programming (ALP) is a high level knowledge-representation framework that can be used to solve problems declaratively based on abductive reasoning. It extends normal logic programming by allowing some predicates to be incompletely defined, declared as abducible predicates. Problem solving is effected by deriving hypotheses on these abducible predicates (abductive hypotheses) as solutions of problems to be solved. These problems can be either observations that need to be explained (as in classical abduction) or goals to be achieved (as in normal logic programming).

It can be used to solve problems in Diagnosis, Planning, Natural Language and Machine Learning. Syntax[edit] Abductive logic programs have three components, where: P is a logic program of exactly the same form as in Logic ProgrammingA is a set of predicate names, called the abducible predicatesIC is a set of first order classical formulae. false:- A1,... Informal meaning and problem solving[edit] Example 1[edit] is: Inductive logic programming. Inductive logic programming (ILP) is a subfield of machine learning which uses logic programming as a uniform representation for examples, background knowledge and hypotheses. Given an encoding of the known background knowledge and a set of examples represented as a logical database of facts, an ILP system will derive a hypothesised logic program which entails all the positive and none of the negative examples. Schema: positive examples + negative examples + background knowledge => hypothesis.

Inductive logic programming is particularly useful in bioinformatics and natural language processing. The term Inductive Logic Programming was first introduced[1] in a paper by Stephen Muggleton in 1991.[2] The term "inductive" here refers to philosophical (i.e. suggesting a theory to explain observed facts) rather than mathematical (i.e. proving a property for all members of a well-ordered set) induction. Formal definition[edit] The background knowledge is given as a logical proposition and. . . , and. Constraint logic programming. As in regular logic programming, programs are queried about the provability of a goal, which may contain constraints in addition to literals.

A proof for a goal is composed of clauses whose bodies are satisfiable constraints and literals that can in turn be proved using other clauses. Execution is performed by an interpreter, which starts from the goal and recursively scans the clauses trying to prove the goal. Constraints encountered during this scan are placed in a set called constraint store. If this set is found out to be unsatisfiable, the interpreter backtracks, trying to use other clauses for proving the goal. In practice, satisfiability of the constraint store may be checked using an incomplete algorithm, which does not always detect inconsistency. Overview[edit] Formally, constraint logic programs are like regular logic programs, but the body of clauses can contain constraints, in addition to the regular logic programming literals.

Semantics[edit] during execution. . To state . To. Answer set programming. Answer set programming (ASP) is a form of declarative programming oriented towards difficult (primarily NP-hard) search problems. It is based on the stable model (answer set) semantics of logic programming. In ASP, search problems are reduced to computing stable models, and answer set solvers — programs for generating stable models—are used to perform search. The computational process employed in the design of many answer set solvers is an enhancement of the DPLL algorithm and, in principle, it always terminates (unlike Prolog query evaluation, which may lead to an infinite loop). In a more general sense, ASP includes all applications of answer sets to knowledge representation[1][2] and the use of Prolog-style query evaluation for solving problems arising in these applications.

History[edit] The planning method proposed in 1993 by Dimopoulos, Nebel and Köhler[3] is an early example of answer set programming. Answer set programming language AnsProlog[edit] to include in the stable model. . Programming paradigm. A programming paradigm is a fundamental style of computer programming, a way of building the structure and elements of computer programs. Capablities and styles of various programming languages are defined by their supported programming paradigms; some programming languages are designed to follow only one paradigm, while others support multiple paradigms. There are six main programming paradigms: imperative, declarative, functional, object-oriented, logic and symbolic programming.[1][2][3] Overview[edit] Overview of the various programming paradigms[4]:5 In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming a program can be thought of as a sequence of stateless function evaluations.

When programming computers or systems with many processors, process-oriented programming allows programmers to think about applications as sets of concurrent processes acting upon logically shared data structures. History[edit] Computational Logic and Human Thinking: How to be Artificially Intelligent.