Nepedia
Back to Discover
Advanced Reader
💻

Logic programming

technology Maturity 11-13 Next article →

Logic programming is a specialized paradigm for programming, databases, and knowledge representation. It is based entirely on formal logic. In this system, a program is not a list of instructions. Instead, it is a set of sentences in logical form. These sentences represent knowledge about a specific problem domain. Computation happens by applying logical reasoning to this knowledge. This allows the computer to solve problems within that domain. Major language families in this field include Prolog, Answer Set Programming (ASP), and Datalog.

To understand how it works, we must look at the structure of its rules. These rules are written as clauses. A clause follows the form A :- B1, ..., Bn. This is read as "A if B1 and ... and Bn." In this structure, A is the head of the rule. The parts B1 through Bn are called the body. These body parts are also known as literals or conditions. When there is no body, the rule is simply a fact, written as A. In the simplest version, called Horn clauses, these parts are atomic formulae. They use a predicate symbol to name a relation and terms to name specific objects.

Logic programming can be viewed through two different lenses. The first is a declarative interpretation. This focuses on what is true. In languages like ASP and Datalog, the programmer does not control how the computer executes the code. Instead, a proof procedure or model generator handles the execution. The second is a procedural interpretation. This is common in the Prolog family. Here, the clause A :- B1, ..., Bn means "to solve A, solve B1, and solve Bn." This is often called goal-reduction. It uses backward reasoning to find answers. Some systems also use negation as failure. In this process, a negative condition is true if the positive version fails to hold.

The history of these ideas spans several decades. In the 1930s, Alonzo Church used mathematical logic in lambda calculus. Later, Cordell Green proposed using clausal form logic for computer programs. This involved using an axiomatization of LISP. In the late 1960s and early 1970s, a major debate emerged. Researchers at Stanford and Edinburgh advocated for declarative representations. They included experts like John McCarthy and Robert Kowalski. Meanwhile, researchers at MIT focused on procedural representations. This group included Marvin Minsky and Seymour Papert.

Many landmark developments came from these debates. Carl Hewitt at MIT developed Planner, a procedural language. It used backtracking to keep only one computation path in memory. This led to Micro-Planner, used in the SHRDLU natural-language program. In 1971, Alain Colmerauer and Robert Kowalski discovered that logic could represent formal grammars. This collaboration led to the development of Prolog in 1972. Prolog became a practical tool after David H. D. Warren created a fast compiler in 1977. This version of Prolog could compete with the speed of Lisp.

Logic programming saw massive international interest during the 1980s. The Japanese Ministry of International Trade and Industry launched the Fifth Generation Computer Systems (FGCS) project. The goal was to use logic programming for advanced Artificial Intelligence. They wanted to run these applications on massively parallel computers. The project eventually moved from Prolog to concurrent logic programming. However, the project failed to meet its original objectives. The parallel computer systems could not compete with general-purpose computers. This caused interest in logic programming and AI to decline worldwide for a time.

Despite those challenges, the field continued to evolve in new directions. The purely declarative side of logic programming became very important for deductive databases. This field was renamed Datalog around 1977. Other branches like Answer Set Programming grew in the 1990s. Today, logic programming remains a vital tool for knowledge representation. It connects the mathematical certainty of logic with the practical needs of computer science. It allows us to define complex relationships and let the computer find the truths hidden within them.

645 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.