Logic programming

Logic Programming ( Predictive Programming) is a programming paradigm that is based on the mathematical logic. Unlike imperative programming, there is a logic program is not a sequence of instructions, but from a set of axioms, which are to be understood here as a mere accumulation of facts or assumptions. If the user of a logic program a request, the interpreter attempts to calculate the solution statement alone from the axioms.

These are a lot of so called rules and instructions that are constructed according to the syntax, pasted together with the information which solution method is provided in the program code. Logic programming languages ​​belong to the declarative programming languages ​​and have their origins in the research area of artificial intelligence.

In an imperative program is described exactly how and in what order is a problem to solve. In contrast, ideally only described in a logic-based program, which is true. The how is already given by the solution method. The solution is derived from the existing rules. Mostly already only a set of rules is called a "program " when it is clear which solution method that entails: namely the (only ) realized in the inference engine provided by the rule-based system.

The most popular logic programming language, Prolog.

Notes

The syntax specifies how rules must be written so that the computer can use it. Rules are " if -then" statements and facts that describe the knowledge to a problem area. In addition, there are often special constructs to affect the solution method. Best known is the Rückwärtsabschneidung (English cut) in Prolog, which " If - then - out " Rules are modeled eg.

A rule-based program you can ask questions (English query) by specifying a target (English goal ). This corresponds roughly to calling a function or procedure in imperative programming languages.

The solution method specifies how the inference rules ( the program text ) interpreted to answer the question. In Prolog depth-first search ( engl. depth first) is used with unification and backtracking. However, other methods are also suitable, and are also used depending on the application.

Special logic programming languages

Logic -oriented programming languages ​​have unusual properties ( backtracking, Unifikationsalgorithmen ), which makes them ideal for certain types of problems that are difficult to resolve with other programming languages.

Since logic programming to declarative programming languages ​​include come to their particularities.

Example

This example is expressed in natural language, in order to show the principle. The concrete application can be seen in the programming language Prolog.

Facts:

Rule:

Question / goal:

Response of the computer inference from the facts and rules:

This unspectacular example, one can easily extend to other intellectual kinship.

Areas of application

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

  • Artificial intelligence
  • Databases
  • Expert Systems

Examples outside of computer science:

  • Economy and Trade: Product Configurator, directions, market simulation (eg for pricing )
  • Medicine: diagnostic systems
  • Mathematics: Theorem Prover and Theoremgeneratoren
  • Science: Evaluate and queries geological and meteorological data collections, simulators and forecasting systems for weather, earthquakes and water levels
  • Engineering: CAD, CAM
  • Sociology
  • Psychology
  • Computational Linguistics: Machine translation of natural language recognition and understanding of spoken language
  • And many more

In the field of computer science and computer engineering:

  • Computer Technology: Design and simulation of processors and circuits
  • Compiler
  • Video Games: "intelligent" behavior of simulated players, tactics, strategy
  • Parallel data processing
  • Document management: process structured documents, Semantic Web, XSLT
  • Rapid Prototyping
527402
de