From: AAAI-83 Proceedings. Copyright ©1983, AAAI (www.aaai.org). All rights reserved.
THE
DENOTATIONAL
SEMANTICS
AS A PRODUCTION
J-L.
Lassez
and
OF HORN
SYSTEM
CLAUSES
M. Maher
Science
Dept. of Computer
University
of Melbourne
Parkville,
Victoria,
3052
Australia.
We show how one of Nilsson's
tenets
on rule-based
applied
to Horn clause
when
production
systems,
programs,
leads to a denotational
semantics.
This
formalism,
in turn
provides
a striking
illustration of a second Nilsson
tenet.
I
is a functional
semantics,
of a segment
of program
S
BSII over a set of states.
semanwe con-
II
A definite
clause
SEMANTICS
where A,
n > 0.
OF
programs,
which
PROLOG
programs
as
a
finite
is of
the
and
B,,, . . . . Bn are
HORN
CLAUSES
form the theore(Kowalski,
19791,
set
of
definite
form
A + B,,...,B
"Wffs representing
assertional
knowledge
about the problem
are separated
into two
rules and facts.
The rules
categories:
consist
of
those
assertions
given
in
they
implicational
form.
Typically
express
qeneral
knowledge
about a particular subject
area and are used as proThe facts are the asserduction
rules.
tions that are not expressed
as implications. Typically
they represent
specific
particular
knowledge
relevant
to
a
case.”
Australian
DENOTATIONAL
Horn clause
tical basis
for
can
be
defined
clauses.
We will consider
here two of Nilsson's
tenets
from
his "Principles
of Artificial
Intelligence"
The first
tenet
is fundamental
(Nilsson,
1982).
for
our
purpose,
allowing
us
to define
a Horn
clause
program
as consisting
only
of a set
of
the facts becoming
the input.
rules,
the
commutativity
The
concept
of decomposition
that
will
be
used
here
is the splitting
of the set of rules
(instead
of Nilsson's
splitting
of
the
initial
database>,
in such a way that the two resulting
programs
can be run separately.
3.
The function
assigned
to a recursive
definition is defined
as the Least fixedpoint
of a suitable operator.
by
links
that
is the
is a function
2.
The
definitions
of these
semantic
functions
are structured
in such a way that the meaning
of
any composite
phrase
is expressed
in terms of the
For exammeanings
of its immediate
constituents.
programming
languages
ple, in many conventional
as, ;s2n = as2n0as,n.
* This research
supported
ter Research
Board
tenet
"Under
certain
conditions
the order
in
which
a
set
of
applicable
rules
is
applied
to a database
is unimportant.
When
these
conditions
are satisfied,
a
improves
effiproduction
system
its
ciency by avoiding
needless
expansion
of
redundant
solution
paths."
Such
conditions may be commutativity
or decomposaNilsson
shows that
bility.
Furthermore,
cases
there
are
relationships
in some
between
commutative
production
systems
and decomposable
ones.
PRELIMINARIES
The three properties
of a denotational
tics CMcGettrick,
1980; Tennent
1981) that
sider here are the following:
1.
It
meaning
denoted
second
tion:
The
decomposi
ABSTRACT
atomic
n
formulae
and
where
Example:
pathCA,B)
pathCB,C)
pathCD,E)
pathCx,y)
pathCx,z)
+
+
C
t path(y,x)
+ path(x,y>,
pathCy,z)
The usual semantics
(van Emden
and Kowalski,
1976) of this program
is given as a set: the set
of all paths
in the graph which
is defined
by the
first three
clauses.
However
it is clear that the
nature of these three clauses
differs
from that of
the
remaining
two
- the
latter
express
general
properties
(symmetry
and transitivity>
whereas
the
former specify
one particular
graph.
Hence it is
Compu-
229
to separate
the two types of clauses:
the
(those
clauses
in implicational
form)
and
the others which represent
the initial
database
of
In the remainder
of this paper we conknowledge.
sider a program
to be the conjunction
of rules
in
database.
a set R, which takes as input an initial
natural
the semantics
of (van Emden
and Kowalski,
1976).
If the R.'s represent
sets of rules,
rather
than
theorem
is
still
then
this
individua I
rules,
valid,
provided
every
rule
in R is contained
in
some Ri.
rules
In (*> and in (van Emden and Kowalski,
1976)
the rules are applied
in parallel
to the database.
This parallelism
is not required
by the informal
Theorem
'1 shows
that
we can generate
semantics.
the rules
in a
the same set of facts by applying
completely
different
way. In fact Theorem
1 can be
generalized
to show that the order
of application
of the rules
is irrelevant,
provided
a condition
more closely
of fairness
is met, which corresponds
informal
semantics
(Lassez
and
Maher,
to
the
1983).
To a set
R of rules
we associate
a function
[fRll which
maps
a set of facts
into
the
set of
facts
which
can be immediately
deduced
from
the
first set by a single
application
of a rule
in R.
Thus
A E ITRD(I> iff
there
a clause
exists
B. f
and a substitution
8 such
{B+..,B,~}
G I.
B,,...,B,
that
in R
A = Bo6
and
the semantics
of the program
P is
the function
IfPllwhich maps an initial
database
I
into the set of all facts
which
can be deduced
from this database
by repeated
application
of the
So we have
rules
in R.
am(I)
=
The following
theorem
establishes
that if the
order
of application
of the two (not necessarily
disjoint)
sets of rules R,, and R, does not matter
(*I
J CERll+Id)kCI)
k=O
v
where
Id is the identity
function
and Cf+g)(X)
=
For simplicity
of expression
we will
f(X) u g(X).
write this as
aPD(I)
the
least
following
of
the
operator
T
If
corresponding
programs
In
this
case
can be
search
2--
CER,lI+Id)
then
aPD
If
and
o (ER211+ Id) = CER$l+Id)
o (ER,,lI+Id)
._.
((CR,D+IdJW
h
o
definitions
= ltP14 + BP,4
i
we
consider
IfP211 instead
condition
which
P to be
of
is
closures
of
ER,ll and
both
necessary
rules
(i.e.
then
and
we
lIP,lI
have
sufficient
decomposable
P,,...,P,.
Theorem
I t can be shown
these
am = EPln + ap,n.
L
p1
= IIRD + Id
1:
= a f?, A
=
that
clear
for
aPn
such
the
spaces
involved
being
in general
far smaller
than
the whole
search
space
for P, the construction
of
which necessitates
combinations
of rules from both
programs.
fixpro-
that properties
1 and 3 of denosemantics
are satisfied
by this definitational
which gives the semantion.
The second property,
tics of the whole program
in terms of the semantics of its components
(in this
case
rules),
is
This
theorem,
given
by
the
following
theorem.
which is a variant
of a theorem
of (Tarski,
1955>,
proved
in
(Lassez
and
Maher,
1983).
Let
is
rules
of R with
the
R,,---t Rn be the individual
Theorem
2
-Theorem
IfPB is the
least
fixedpoint
where r(f) = ERll o f + Id
is
P
SLD reso lution
(Apt and van Emden , 198ZJ
used
in parallel
for P,, and P 3fl the two
L
Proposition:
It
- then
they can even be applie d in pat-al lel
into two subprograms
ogram
P can be d ivided
and
= CaRR+Id)WCI>
Equivalently,
CPII can be defined
as
edpoint
of the functional
T by the
position
(Lassez
and Maher,
1983).
COMMUTATIVITY AND DECOMPOSITION
III
Informally
Rn n = (aP,n
._- o
0
...
0
am = ap,n
aPpw
+
ap2n
iff
ap,n 0 ap,n
L = aP2n o arp
UCRnll+Id)U)W
(Lassez
and Maher,
1983)
and results
ar e compa tible
3:
These
results
of
that
with
230
are
theorems
on closure
Ore
= ayn t ap2n
classical
related
to
The proofs
operators.
a
can
be
found
in
(Lassez
and
Maher,
1983).
REFERENCES
Examples:
Consider
R =
( N(x)
N(S(x))
= CRDtId.
Therefore
one
The hypo theses
R
and R2 be
1
of the theorems
do not require
disjoint
sets
of rules
as we
+ C(y,x)
f C(x,yl,
AttCx,c)
C(y,z)
6 AttCx,c),
Att(y,c)
+ C(x,y),
AttCy,c)
This
can be divided
into
two separate
prohave overlapping
sets of
which,
this time,
rules.
P
is
1
grams
C(x,y)
C(x,z)
AttCx,c)
and
P
2
+ C(y,xl
+ C(x,y),
+ CCx,y),
C(y,z)
Att(y,c)
is
C(x,y)
C(x,y)
+ C(y,x)
Att(x,c)
It
can
be
+ AttCx,c),
AttCy,c)
+ C(x,y),
AttCy,c)
verified
that
EPII =
BPID
We now have two simpler
programs
which
That
portion
of
cuted
in parallel.
space
caused
by the the unnecessary
between
the second
and third
rules
remainder
of
the
program)
van Emden,
M. H. and R. A. Kowalski,
"The
semantics
of predicate
logic
as a programming
language"
J-ACM 23:4 (1976) 733-742.
has been
can
+
Kowalski,
R.
North-Holland,
show in the next example.
A database
on military
personnel
is processed
by the following
program
P.
The data is of the type: CCX,Y)
(that
is X is in
(X sleeps
in
the same company
as Y), AttCX,B052)
barrack
0521, Att(X,C.SMITH)
(X’s
commanding
officer
is Captain
Smith),
.. .
Each
attribute
is
characteristic
of a company
and associated
to all
its members.
C(x,y>
C(x,z)
C(x,y)
C21
C31
can
break
the
connection
between
the
two rules
and
perform
SLD resolution
on each of them separately.
That is for a given A E HB we look
simultaneously
in parallel
for successors
only and for predecesonly.
Without
this
split,
SLD
resolution
sors
would
search
alternatively
for
predecessors
and
successors
creating
a search space "exponentially*'
larger than the two preceding
ones.
that
Apt, K. R. and M. H. van Emden,
"Contribuof
logic
programming*'
to the
theory
tions
-J ACM 29:3 (1982) 841-862.
+ N(S(x)),
+ N(x) }
where
the
Herbrand
Base
HB is
( NC S"(O)
) :
One
n=O,l ,...
} We call
S the successor
function.
verifies
easily
that
CltR,D+Id)
o
CCR23+Id)
=
C6R2D+Id> o CBR,D+Id)
Cl1
EP2D.
be exe-
the
search
interactions
of P (via the
discarded.
231
A.
Loqic
for
Solving
Problem
1979.
J-L.
and
M.
Maher,
*‘Closures
and
in
the
semantics
of
programming
Also
logic”
Theor.
Comput.
Sci. (to appear).
Report
83/3,
Dept.
of
Computer
Technical
Science,
University
of Melbourne,
1983.
C41
Lassez,
fairness
C51
McGettrick,
A.
min q Lanquaqes.
1980.
C61
Nilsson,
N.
Intelligence.
D.
The Definition
of ProqramCambridge
University
Press,
Principles
J.
Springer
Verlag,
of
lattice-theoretical
A. “A
its
applications”
and
(19551, 285-309.
C71
Tarski,
theorem
5
dMath
C81
Tennent,
Lanquaqes.
R.
D.
Principles
of
Prentice-Hall,
1981.
Artificial
1982.
fixpoint
Pacific
J.
Proqramming