Logical programming
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 .
Explanations
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.
example
This example is written in natural language to illustrate the principle.
Facts:
- Lucia is the mother of Minna.
- Lucia is the mother of Klaus.
- Minna is Nadine's mother.
Rule:
- 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:
- Lucia
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:
- Economy and trade : product configurator, route planner, market simulation (e.g. for pricing)
- Medicine : diagnostic systems
- Mathematics : theorem provers and theorem generators
- Natural sciences : Evaluation and queries of geological and meteorological data collections, simulators and forecast systems for weather, earthquakes and water levels
- Technology : CAD , CAM
- sociology
- psychology
- Computational Linguistics : Machine translation of natural language, recognition and understanding of spoken language
- and many more
In the field of informatics and computer technology:
- Computer technology : design and simulation of processors and circuits
- Compiler construction
- Computer games : "intelligent" behavior of simulated players, tactics, strategy
- parallel data processing
- Document management : processing structured documents, semantic web , XSLT
- Rapid prototyping