Logical programming

from Wikipedia, the free encyclopedia

Logical programming ( predictive programming ) is a programming paradigm based on mathematical logic . In contrast to imperative programming , a logic program does not consist of a sequence of instructions, but of a set of axioms , which are to be understood here as a collection of facts or assumptions. If the user of a logic program makes a request, the interpreter tries to calculate the solution statement from the axioms alone.

For this purpose, a set of so-called rules and instructions, which are structured according to the syntax, are inserted into the program code together with information about which solution method is intended. Logical programming languages ​​are among the declarative programming languages and have their origins in the research field of artificial intelligence .

An imperative program describes exactly how and in what order a problem is to be solved. In contrast, a logic-based program describes what applies. The how is given by the solution method. The solution is made to the rules derived .

The most popular logical programming language is Prolog . Alain Colmerauer and Robert Kowalski were among the founders of logical programming in the 1970s .


The syntax indicates how rules must be written in order for the computer to use them. Rules are if-then statements and facts that describe the knowledge of a problem area. There are also special constructs to influence the solution method. The best known is the backward cut in Prolog. B. Exception rules can be modeled.

A rule-based program can be asked questions (English query ) by setting a goal (English goal ).

The solving method dictates how the inference engine interprets the rules to answer the question. Prolog is a depth-first search (engl. Depth first ) with unification and backtracking used. Other methods are also suitable and are also used depending on the application.


This example is written in natural language to illustrate the principle.


Lucia is the mother of Minna.
Lucia is the mother of Klaus.
Minna is Nadine's mother.


If X is the mother of Y and Y is the mother of Z Then X is the grandmother of Z.

Question / goal:

Who is Nadine's grandmother?

Answer of the computer, conclusion from the facts and rules:


Areas of application

Typical areas of application are simulators, generators and systems for diagnosis and prognosis. Applications of logic programming can be found in the following areas:

Examples outside of computer science:

In the field of informatics and computer technology:

Web links

  • [1] - a brief overview of the development of classical logic up to logical programming (110 kB)
  • XSB (English) logic system and deductive database (open source)