Syntax and semantics of logic programming
Logic programming is a programming paradigm that includes languages based on formal logic, including Datalog and Prolog. This article describes the syntax and semantics of the purely declarative subset of these languages. Confusingly, the name "logic programming" also refers to a specific programming language that roughly corresponds to the declarative subset of Prolog. Unfortunately, the term must be used in both senses in this article.
Declarative logic programs consist entirely of rules of the form
H :- B1, ..., BN.
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. The formal semantics of such extensions are beyond the scope of this article.