What is Logic Programming?
Logic programming is a programming paradigm where program statements show rules and facts about problems. It is a way of writing computer programs using languages based on a system of formal logic.
All logic programming languages lie under the category of declarative programming languages. The computation is satisfied by specifying the properties of the correct answer. Logic programs can be interpreted using two main concepts: truth and logical deduction.
Truth derives whether or not the computation in the program is true, under the implementation of the program symbols.
Logical Deduction determines whether a logical clause is a consequence of the program.
All logical programming languages have exact operational meaning and most support the processing of finite sets. The programs themselves are instructions for execution by a compiler.
These instructions are always interpreted as logical statements and clauses, and the result of the execution is a logical consequence of the computations in it.
Using logical languages and any other declarative language offers three main advantages:
- Logic programming languages are classified as high-level languages as they implement computation’s logic rather than mechanics. They have a powerful pattern matching mechanism as well as good memory management (stacks and pointers). This makes them ideal for expressing complex ideas and algorithms.
- Logical programming languages allow data to be represented both extensionally and intentionally. An intentional representation can also generate related representations, for example, adjacency lists for easy access to the following data elements. These can be derived dynamically from configuration rules.
- Another advantage of logic programming languages is that they are well suited for rapid interpretation of the data structure and the code to implement very complicated ideas. Due to their compact syntax and logical nature experienced programmers find the code simple to read and debug. From the programmer’s point of view, the difficulty of coding is vagueness in human thinking. However, Prolog coding is easier as the syntax is very short and precise.
Here is a list of programming languages used for Logic programming:
- ASP (Answer Set Programming)
- ALF (Algebraic Logic Functional programming language)
- Transaction Logic
- Visual Prolog
- Maude system
- Mozart Programming System
- Rebeca Modeling Language
One way to look at a program is as a series of statements about the world to determine whether they are true. In that sense, it is an example of declarative programming: instead of instructing the computer exactly how to transform data, you provide the rules that govern the world described by your data. These rules are often given by premises (things assumed to be true) and consequences (things that happen if the premises are true).
Logic programming languages (like Prolog) use a notation that replicates many aspects of First-order logic, in which we establish relations between known facts (thus creating a knowledge base) and later write rules that the interpreter or compiler can translate to a plan for execution in the Warren Abstract Machine, a virtual machine that understands and resolves logical statements. A good place to start is downloading and installing SWI-Prolog.
Let’s have a look at some other MAJOR Programming Paradigms in detail:
Visit FinsliQ | Tech Academy. A variety of course are available in cloud computing, Dev-ops, Cloud Architecture, Cyber Security and much more.