What Is Ladder Logic Programming?

Logic programming is a programming paradigm. It sets the rules that answers must meet to solve problems, rather than setting steps to solve problems. Process is fact + rule = result.

The main point of logic programming is to bring a formal logic style into computer programming. Mathematicians and philosophers have found logic to be an effective tool for theoretical analysis. Many problems can naturally be expressed as a theory. Saying that you need to answer a question is usually equivalent to answering a new hypothesis without conflict with existing theory. Logic provides a way to prove whether a problem is true or false. The method of creating proofs is well known, so logic is a reliable way to answer questions. The logic programming system automates this process. Artificial intelligence has played an important role in the development of logic programming.
The monkey and banana problem is a well-known problem in the logic programming community. The computer must find a feasible way for the monkey to contact the banana, instead of the programmer specifying the path and method for the monkey to contact the banana. Logic programming creates a logical model that describes the world in a problem. The goal of logic programming is to create new statements about its models. Knowledge in the world is constantly expanding. Traditionally, we would state a problem as a single hypothesis. A logic programming program solves the problem by proving whether this assumption is true in the model.
Some areas that often use logic programming tools: expert systems, programs that generate a suggestion or answer from a huge model. The theorem is proved automatically, and the program generates some new theorems to extend the existing theories. The most commonly used logic programming language is Prolog, and Mercury is more suitable for large-scale solutions. [1]
As early as the 1970s, Robert Kovalsky and others put forward the basic idea that logic can be used as a programming language. The two distinct concepts of logic and program were unified and unified into one concept, and logic was born. programming. This is also the natural result of early automatic theorem proof and artificial intelligence development. Subsequently, logic programming has developed rapidly, especially the logic programming language based on first-order predicates, which corresponds to logical reasoning with calculations, and has rich expressiveness and non-deterministic characteristics. In theorem machine proofs, relational database systems, Program verification, modular program design, and non-monotonic reasoning are widely used. [1]
Prolog is based on the processing of first-order predicate calculus. Because of its simple grammar, rich expression, and unique non-procedural language, Prolog is very suitable for representing human thinking and reasoning rules. As a result, it won artificial intelligence And the broad interest of application developers. Especially in Western Europe and Japan, the Prolog language has been popularized in many application areas, such as relational databases, mathematical logic, abstract problem solving, natural language understanding, and expert systems. Japan also listed Prolog as its core language in its fifth-generation computer research project, which was proposed in 1979.
Prolog is actually a deductive reasoning technique based on reverse rules, but it has strict restrictions on the expression of rules and goals. Coupled with the simplicity of the deductive reasoning control mechanism itself, it is difficult to apply to complex application domains.
The basic component of the Prolog language is the Horn clause, which is expressed as follows: p; In the Prolog language, the Horn clause represents the three parts of the problem-solving description in reverse deductive reasoning in three forms: objective, rule, and fact. The target is represented by a Horn clause with only the left part: ; that is, in Prolog language, the target formula is limited to the conjunction expressed as an atomic formula, and cannot be any text and or shape. The rule is expressed as a typical Horn clause: p This is the normalized B rule used for reverse deductive reasoning, except that the left part of the rule is limited to the conjunction of atomic formulas, not any words and or shapes. Facts are represented as a collection of fact elements, and each fact element is represented as a Horn clause with only the right part, that is, a single atomic formula P. Implicit conjunctions between fact elements. As long as the three parts of the problem description are expressed in Prolog language, the inference mechanism supporting Prolog statements will automatically perform rule-based inverse deductive reasoning, and finally give the answer. Because the left part of the target and the rules are conjuncts of atomic formulas, and these atomic formulas can activate multiple rules (implicit or relations between these rules). Therefore, the AND or graph established by Prolog's deductive reasoning process has a situation where the AND or OR alternates layer by layer. With the downward expansion of the AND graph, a consistent solution graph will eventually be formed (searched), so that the reasoning succeeds; otherwise, the reasoning fails. Treat each atomic formula contained in the target as a sub-target. Whenever a rule activated by a sub-target is inserted into an OR graph, the atomic formula on the left of the rule becomes a new sub-target and then used to activate the new rule. With the activation of the rules and the generation of new sub-objectives, the AND graph is gradually expanded until the sub-objectives directly match the fact elements (atomic formulas). [2]
The syntax structure of Prolog language is quite simple, but it is very descriptive. For example, when facts and rules describe axioms of a certain discipline. Then the problem is the proposition to be proved; when the facts and rules describe certain data and relationships, then the problem is the data query; when the facts and rules describe certain rules of state change, then the problem is the target state. Therefore, Prolog language is an intelligent programming language.
Prolog programs do not have a specific running sequence. The running sequence of the program is completely based on the method of mathematical logic derivation (digestion method). It's not up to the programmer. Prolog is a descriptive language that describes a problem in a specific way, and then the computer automatically finds the answer to this problem. To give an extreme example: when the facts and rules are established, you only need to tell it a certain question, and it will automatically find the answer.
There are no if, case, for control flow statements in Prolog programs. Under normal circumstances, the programmer does not need to understand the running process of the program, but only needs to pay attention to whether the description of the program is comprehensive. However, Prolog also provides some methods to control the flow of the program, which are very different from those in other languages. [2]

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?