Declarative semantics
In this section we will investigate the model-theoretic properties
of logic programs,
that is how a logic program P is related to the world it is
intended to describe.
Interpretations
\semindex{interpretations}
For giving an interpretation I to a logic program P
we have to define a domain of discourse D that contains
the individuals of the world about which our program speaks
and over which the variables occurring in our program range.
Formally, we then have to define an assignment that assigns to each constant
name a specific individual.
Moreover, we must define for each function-symbol f a corresponding
mapping and for each predicate-symbol p a relation on the domain D.
Finally, we must then define an assignment of variables
to bind variables to elements of D.
Models
\prologindex{models}
\semindex{models}
A given interpretation I is a model for a clause if
it makes the clause true.
Now, when is a clause true for a given interpretation?
A clause
[]
is true for an interpretation I if A is true
for I whenever are true for I.
To establish the truth of a literal, for example
[]
we must relate the constant 0 to its intended interpretation,
for which we take zero.
Likewise we assign the functional expression
the value one and check whether one is a natural number,
which is our interpretation of the predicate number.
Quantification
\semindex{quantification}
When variables occur in a literal the situation is slightly
more complicated.
Since we are not able to find a model for
a clause that contains free variables
we assume that each clause is universally quantified,
since clauses are meant to express general statements.
So, for example, the clause
[]
must be read as
[]
which generalizes the clause to hold for all X.
In order to establish the truth of the clause we have
to check for all elements of our domain, which are the natural
numbers in this case,
whether the clause holds when substituting this element for X.
An extra complication arises when variables occur in the body of
a clause that do not occur in the head of the clause.
For example, the clause
[]
stands for
[]
generalizing the clause to hold for all X and Y.
However, by another law of logic, this may be rewritten to
[]
where the variable Y that occurs only in the body of the
clause is existentially quantified.
This clause is
true when for each assignment to X the literal holds
whenever there is some assignment to Y that makes true.
Hence, a goal clause of the form
[]
must be read as being existentially quantified.
To establish the falsity of a goal clause containing variables
it suffices to find some assignment of values to variables that
makes G true.
Logical consequence
\semindex{logical consequence}
Having defined when a clause is true for a given interpretation
we may characterize a model of a program P
as an interpretation that makes each clause in P true.
If there exists a model for P we say that P is satisfiable.
We call a formula G a logical consequence of P if
every model of P is also a model of G.
This is equivalent to saying that G is a logical consequence of P,
if and only if is unsatisfiable, which is equivalent to saying
that there
is no interpretation that makes each clause in true.
Hence, if we have a goal with variables
then showing that is unsatisfiable is exactly
the same as showing that
is a logical consequence of P.
Herbrand models
\prologindex{Herbrand models}
\semindex{Herbrand interpretations}
\semindex{Herbrand models}
The basic problem that we are confronted with to establish that
a conjunction of literals G is a logical consequence of a
program P is to determine whether is unsatisfiable,
which amounts to showing that every interpretation of
is not a model!
Since there are arbitrarily many interpretations for each logical theory
this seems to be an infeasible task.
To manage the complexity of this task,
we restrict our attention to a much smaller and more convenient class
of interpretations, called Herbrand interpretations.\ftn{
After the logician Herbrand. See [Ro65].
}
As our domain of discourse we take the so-called
Herbrand universe of a program P which are all the ground terms
that can be constructed from the terms occurring in P.
\semindex{ground terms}
Ground terms are variable-free terms.
We construct these ground terms by substituting constants
and already-created ground terms for variables.
There may be infinitely many ground terms.
In case the program contains no constant we use an
arbitrary constant to construct the Herbrand universe.
\semindex{Herbrand universe}
As an example, the Herbrand universe of the program
\oprog{number}{
}
is the set
[]
consisting of all the terms representing natural numbers.
For defining the relations that correspond to the predicate-symbols
occurring in the program we introduce the so-called Herbrand base
which is the collection of all ground atoms that can be constructed
from the literals occurring in the program.
An atom is just a positive literal, that is a literal
without negation sign.
A ground atom is a variable-free atom.
These atoms may be regarded as representing all possible facts.
\semindex{Herbrand base}
The Herbrand base corresponding to the program above, defining the natural numbers, is
[]
containing all possible atoms that express that a term is a number.
A Herbrand model for a program P is a Herbrand interpretation
that is a model for P.
An important property of Herbrand models is that
if a program P has a model then P also has a Herbrand model,
since in a way Herbrand models are the least committing models.
Because of this property, showing that a collection
of clauses is unsatisfiable
reduces to the task of showing that
has no Herbrand model.
Answer substitutions
\prologindex{answer substitutions}
\semindex{answer substitutions}
When a goal G contains variables we are not only
interested in whether is unsatisfiable,
but also in what variables must be assigned to the variables to achieve this.
A substitution is a set of the form
that binds each variable to a value , for i ranging from 1 to k.
We say that is a ground substitution if each is a ground term.
When we apply a substitution to a conjunction of literals G,
which we write as , then each variable occurring in G is replaced
by the term .
Now, if we find a substitution for which
has no Herbrand model then accordingly we have proven that
is a logical consequence of P.
We call such a substitution a correct answer substitution.
In general there may be more than one such substitution.
From a logic programming point of view we are interested
in all these bindings since they represent the
output of evaluating a goal .
Fixed points
\semindex{fixed points}
A Herbrand interpretation of a program P may be thought of
simply as a subset of the Herbrand base for P,
since typically ground terms are assigned to themselves.
The Herbrand models of Horn clause programs have a very special property,
the so-called model intersection property that states:
if is the collection of Herbrand models for P then the intersection
is also a Herbrand model of P.
Moreover, is the smallest model satisfying P.
Herbrand models for programs consisting of general clauses do not have this property
since, intuitively, the occurrence of multiple positive literals in a clause
may give rise to multiple disjoint models.
\semindex{least model}
The least model represents all the positive information that can be derived
from a logic program P.
This intuition allows us to characterize the least model in a convenient way
by means of the so-called immediate consequence operator .
Let I stand for Herbrand interpretations, that is subsets of
the Herbrand base for a particular program P.
Then the immediate consequence operator is defined as
\semindex{\immediateconsequence}
- \smeq{
\= if is a ground instance of a clause in \\
\> P and
}
Applying to a Herbrand interpretation I results in
all the facts that can be derived by applying rules for
which the premises are contained in the given interpretation I.
We have that an interpretation I is a model of P whenever
, that is I is a model when I already contains
every fact that can be derived using I.
We are looking for the least I satisfying this property or, which amounts to the same,
for the least I satisfying , that is the least fixed point of .
The least fixed point of an operator that is associated with a logic program
P can intuitively be characterized by a bottom-up computation of all
the (given and derivable) facts contained in the program P,
that is by iterating the application of , starting with the empty
interpretation, until no more facts are added.
The interested reader is referred to [AvE82] for a more detailed treatment.
As a last remark, this bottom-up characterization of the declarative semantics
of a logic program P provides a link with the procedural
interpretation of P that characterizes how facts may be proven
in a top-down manner. See also [EK76].