Logic Programming
Introduction
Logic programming is a type of programming paradigm which is largely based on formal logic. Any program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain.
Basics of Logic Programming
In logic programming, computation is the process of model generation. A query put to a logic program can be viewed as a question about the world the program represents. The logic programming system responds to the query by searching for proofs of the queried sentences. If a proof can be found, the system has effectively constructed a model of the world as it would be if the queried sentence were true.
History
The concept of logic programming is a result of the efforts to formalize the principles of logic and computation. The roots of logic programming can be traced back to the first-order logic, a formal logical system used in mathematics, philosophy, linguistics, and computer science. The development of the Prolog language in the 1970s marked a significant milestone in the evolution of logic programming.
Logic Programming Languages
The most commonly known logic programming language is Prolog. Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is intended primarily as a declarative programming language. In Prolog, logic is expressed as relations (called as Facts and Rules). Core heart of Prolog lies at the logic being applied. Formulation or Computation is carried out by running a query over these relations.
Other logic programming languages include Datalog, which is a subset of Prolog, and Answer Set Programming (ASP), which is a form of declarative programming oriented towards difficult (primarily NP-hard) search problems.
Principles of Logic Programming
The principles of logic programming assert that a program is a theory in logic, and computation is deduction. This means that logic programs are written in a language that can express facts and rules about some problem domain, and the logic programming system can answer questions about the domain by searching for proofs of the queried sentences.
Applications of Logic Programming
Logic programming languages, particularly Prolog, are used for artificial intelligence applications, including natural language processing, automated reasoning systems, expert systems, and artificial intelligence research. They are also used in formal methods and software verification and validation, and to a lesser extent in databases, and knowledge representation systems.
Advantages and Disadvantages
Logic programming languages offer a number of advantages, including the ability to express information in a way that closely resembles human reasoning. They also allow for the creation of declarative statements, and they can be used to solve complex problems that are difficult to express in procedural languages.
However, logic programming also has its disadvantages. These include difficulties with state representation and control issues, and the fact that logic programming languages are generally slower than their procedural counterparts.
See Also
- Declarative Programming
- Artificial Intelligence
- Natural Language Processing
- Software Verification and Validation
- Knowledge Representation Systems