At EasyTechJunkie, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

# What is Logical Programming?

Logical programming is a type of computer programming in which the programmer must give the computer instructions on how to make decisions using mathematical logic, such as the use of a mathematical algorithm. Computer programs are made up of code that tells the computer what to do. Eventually, however, the computer will run into an instance where it must make a decision on how to proceed and without any information on how to do this, it could not complete its current function. Logic programming deals with these types of decisions and gives instructions to the computer so it can make a "logical" decision about how best to respond to a certain situation. For logic programming to work, the programmer writing the code needs to ensure her statements make sense and are true, thus are logical, and a computer program known as a theorem-prover is required to make decisions based on the statements it encounters in the programmer's code.

A theorem-prover refers to a computer program that has been designed to solve mathematical statements known as theorems. Theorems are statements that are shown to be true based on previous statements. In logical programming, the theorem-prover works together with the statements created by the computer programmer to reach conclusions. For example, if the code states that A is equal to B and B is equal to C, the theorem-prover will make the logical conclusion that A must be equal to C. This process is different than the programmer simply telling the computer in the code that A is equal to C because the computer program must draw this conclusion using the theorem-prover and the programmer's original statements in the code.

In theory, for logical programming to work, the programmer only needs to ensure that her statements are correct and the creator of the theorem-prover should ensure that the program can read statements and make the most efficient decisions based on them. The ability to make an efficient decision is referred to as a computer functioning "logically." In reality, the two fields of work overlap, and those who perform logical programming often have to change and manipulate the code based on how the theorem-prover works in order to achieve the results they want. Simply putting in accurate statements about how to make a certain decision may not be enough to get the computer to perform the correct function, and the programmer will have to test her code and make adjustments accordingly.

For logical programming to work, it also relies on backward reasoning. In backward reasoning, the program comes to conclusions by looking at a set of data and working from general known statements to reach more advanced conclusions. The program may know that two pieces of information are true, and it will infer that since those two pieces of information are true, that means a third piece of information is also true. It continues this process until it reaches a logical conclusion based on the information it's given. Due to the way it works, logical programming is built on declarative representation language, meaning the program tells the computer what it should do, but leaves it up to the theorem-prover to determine the most logical or efficient way to perform the requested procedure.

## Discuss this Article

## Post your comments