Search results
Results From The WOW.Com Content Network
The syntax and semantics of Prolog, a programming language, are the sets of rules that define how a Prolog program is written and how it is interpreted, respectively.The rules are laid out in ISO standard ISO/IEC 13211 [1] although there are differences in the Prolog implementations.
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving and computational linguistics. [1] [2] [3]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: the program is a set of facts and rules, which define relations.
Prolog provides other features, in addition to cut, that do not have a logical interpretation. These include the built-in predicates assert and retract for destructively updating the state of the program during program execution. For example, the toy blocks world example above can be implemented without frame axioms using destructive change of ...
This is called a green cut operator.The ! tells the interpreter to stop looking for alternatives; however, if gotmoney(X) fails it will check the second rule. Although checking for gotmoney(X) in the second rule may appear redundant since Prolog's appearance is dependent on gotmoney(X) failing before, otherwise the second rule would not be evaluated in the first place.
In pure Prolog, normal DCG rules with no extra arguments on the functors, such as the previous example, can only express context-free grammars; there is only one argument on the left side of the production. However, context-sensitive grammars can also be expressed with DCGs, by providing extra arguments, such as in the following example:
Each such rule can be read as an implication: … meaning "If each is true, then is true". Logic programs compute the set of facts that are implied by their rules. Many implementations of Datalog, Prolog, and related languages add procedural features such as Prolog's cut operator or extra-logical features such as a foreign function interface.
Prolog (1972) stands for "PROgramming in LOGic." It was developed for natural language question answering, [12] using SL resolution [13] both to deduce answers to queries and to parse and generate natural language sentences. The building blocks of a Prolog program are facts and rules. Here is a simple example:
A rule is called ground if all of its atoms (head and body) are ground. A ground rule R 1 is a ground instance of another rule R 2 if R 1 is the result of a substitution of constants for all the variables in R 2. The Herbrand base of a Datalog program is the set of all ground atoms that can be made with the constants appearing in the program.