Datalog is a logic-based programming language. It is a restricted form of the logic of the Horn clause in the first-level predicate logic. Only variables or constants can be used as the self-variable of the predicate, and functions cannot be used as the self-variable of the predicate. Datalog statements are composed of facts and rules. Like Prolog, Datalog statements can perform deductive reasoning on the knowledge base, that is, based on known facts
Datalog is a logic-based programming language. It is a restricted form of the logic of the Horn clause in the first-level predicate logic. Only variables or constants can be used as the self-variable of the predicate, and functions cannot be used as the self-variable of the predicate. Datalog statements are composed of facts and rules. Like Prolog, Datalog statements can perform deductive reasoning on the knowledge base, that is, based on known facts
Datalog is a logic-based programming language. It is a restricted form of the logic of the Horn clause in the first-level predicate logic. Only variables or constants can be used as the self-variable of the predicate, and functions cannot be used as the self-variable of the predicate. Datalog statements are composed of facts and rules. Like Prolog, Datalog statements can perform deductive reasoning on the knowledge base, that is, new facts can be obtained from known facts based on followed reasoning. A Datalog rule consists of the following three parts:
(1) Rule header P
(2) implication Symbol:-(it can be read as if, indicating a logical relationship rather than an operator number)
(3) Rule body, that is, one or more sub-targets P1, P2 ,..., Pn, which is equivalent to AND connection between sub-targets. The rule description is: Check all possible values of the variables in the rule. When these variables make all the child targets in the rule body true, the rule header is true.
Ex.
P:-P1, P2 ,..., Pn // If P1, P2 ,... If Pn is true, P is true.
Fig. Association of several logicmodels
1. Level 1 Predicate Logic
Level 1 Predicate Logic, also known as Level 1 predicate calculus, is developed based on the Proposition Logic. In 1879, German mathematician freger first introduced the concept of quantifiers, thus establishing the first-order predicate logic. The main difference between the first-order predicate logic and the Proposition Logic was increased twice, make atomic companies parametric to achieve a type-1 multi-meaning.
The main components of level 1 predicate logic: individual, predicates, and quantifiers
Individual: a definite individual is called a variable, and an uncertain individual is called a constant element.
Predicate: The Language component that represents an individual's nature or relationship in a statement.
Quantifiers: A method to constrain the variable element. They are full-name quantifiers and existing quantifiers.
2. Sub-statement Logic
The predicates that do not contain any connected words are called atomic formulas, while the negation of atoms or atoms is collectively referred to as Literal ). In logic programming, clauses are usually written as the implication from the body to the header. In the simplest case, the body part is the combination of text and the header is a single text. If B1 ,... Bm is the text in the clause body, while H1 ,..., Hn is the heavy text in the clause header. The clause is usually written as follows:
H1 ,... Hn:-B1 ,..., Bm
3. logic of the Horn clause
Statement B? A1 ,... Both An and B Branch have only one clause of positive text B, which is called a subsentence. The clause without positive text appears, such? A1 ,... An is called a target clause. A definite clause and a target clause are collectively referred to as a Horn clause, that is, a clause containing at most one positive text. It was proposed by the logistician Horn in 1951, so it is called the Horn clause.
The Union of the Horn clause is the Union paradigm, also known as the Horn Formula. The following is an example of the Horn clause:
In fact, Prolog is a practical advanced programming language for AI based on the principles of the collection of Horn clauses. Prolog is both a programming language and a logic system. It is a descriptive language.
Datalog syntax
The meaning of the Datalog program is defined in a pure declarative manner, while Prolog has more Procedural Semantics. Although there may be many ways to express knowledge, the data logic formula is the most similar to human thinking, and thus the most intuitive expression of knowledge.
Link: for example, father (x, y). Link father describes that x is the father of y.
Rule: has the following forms: P:-P1, P2 ,..., Pn, which means that if P1, P2 ,... Pn (rule body) is true, so P (Rule header Head) is also true. Rules are based on the amount of text.
Fact: it is an atomic formula that represents the fact that is always true and is the basis of all reasoning. However, when the rule body is empty, the rule becomes a fact. For example, the fact that father (john, lucy) indicates that john is lucy's father.
Positive literal: p (t1, t2, t3) indicates contain fact p (t1, t2, t3)
Negative literal: not p (t1, t2, t3) indicates that the fact p (t1, t2, t3) is not included)
Query: Use "?" -"Indicates