foundations of computational agents
This section expands the syntax for the propositional definite clause language. The syntax is based on normal mathematical notation for predicate symbols but follows Prolog’s convention for variables.
The syntax of Datalog is given by the following, where a word is a sequence of letters, digits, or an underscore (“”):
A logical variable is a word starting with an upper-case letter or with “_”. For example , , , , and are all variables.
A constant is a word that starts with a lower-case letter, or is a number constant or a string.
A predicate symbol is a word that starts with a lower-case letter. Constants and predicate symbols are distinguishable by their context in a knowledge base.
For example, , , , , and can be constants or predicate symbols, depending on the context; is a constant.
A term is either a variable or a constant.
For example , , , , or can be terms.
An atomic symbol, or simply an atom, is of the form or , where is a predicate symbol and each is a term. Each is called an argument to the predicate.
For example, , , , , , and can all be atoms. From context in the atom , the symbol is a predicate symbol and is a constant.
The notions of definite clause, rule, query, and knowledge base are the same as for propositional definite clauses but with the expanded definition of atom. The definitions are repeated here.
A definite clause is of the form
where is an atom, the head of the clause, and each is an atom. It can be read “ if and …and ”.
If , the clause is called a rule. is the body of the clause.
If the arrow can be omitted and the clause is called atomic clause or fact. An atomic clause has an empty body.
A knowledge base is a set of definite clauses.
A query is of the form
An expression is either a term, an atom, a definite clause, or a query.
In our examples, we will follow the Prolog convention that comments, which are ignored by the system, extend from a “%” to the end of the line.
The following is a knowledge base:
From context, , , , , and are constants; , , , , , , , , and are predicate symbols; and , , and are variables.
The first two clauses about Kim and Sam may make some intuitive sense, even though we have not explicitly provided any formal specification for the meaning of sentences of the definite clause language. However, regardless of the mnemonic names’ suggestiveness, as far as the computer is concerned, the first two clauses have no more meaning than the third. Meaning is provided only by virtue of a semantics.
An expression is ground if it does not contain any variables. For example, is ground, but is not ground.
The next section defines the semantics. We first consider ground expressions and then extend the semantics to include variables.