CS240A: Databases and Knowledge Bases
Fixpoint Semantics of Datalog
Carlo Zaniolo
Department of Computer Science
University of California, Los Angeles
WINTER 2002
Three Equivalent Semantics
1.
Model Theoretic: describing what facts hold true
because of the given facts and rules.
2.
Proof Theoretic: using SLD-resolution
3.
Fixpoint Semantics. Defined as the least fixpoint
of the transformation defined by the rules.
For positive programs (I.e., programs without negated
goals) all three semantics are-well defined and
equivalent. Here we will cover only 3.
For programs with negated goals things are more
complex, different semantics are possible and
equivalence might not hold any longer. Here we will only
consider stratified negation.
Example
anc(X, Y) parent(X, Y).
anc(X, Z) anc(X,Y), parent(Y,Z).
parent(X, Y) father(X, Y).
parent(X, Y) mother(X, Y).
mother(anne, silvia).
mother(silvia, marc).
A bottom-up derivation to derive facts that are true.
Step1: mother(anne, silvia), mother(silvia, marc).
Step2: mother(anne, silvia), mother(silvia, marc),
parent(anne, silvia), parent(silvia, marc).
Step3: those in step 2+ anc(anne, silvia), anc(silvia, marc).
Step4: those in step 3+ anc(anne, marc).
Step4: those in step 4 only---we have reached fixpoint.
Herbrand Universe and Ground Instance
of program P
The Herbrand Universe for P, denoted UP, is defined as the set
containing (1) the constants in P and (2) the terms recursively
constructed by letting the arguments of functions be elements in UP.
For the example program: UP = {anne, marc, silvia}.
Ground version a rule r: ground(r). This is the set of ground instances
of r --i.e., all the rules obtained by assigning to the variables in r, values
from the Herbrand universe UP.
E.g. from the previous program take: parent(X, Y) mother(X, Y).
Since there are 2 variables in this rule and UP = 3, then ground(r)
consists of 3 ×3 rules:
parent(anne, anne) mother(anne, anne).
parent(anne, marc) mother(anne, marc).
...
parent(silvia, silvia) mother(silvia, silvia).
Semantics of a positive program P as the least
fixpoint of its Immediate Consequence Operator TP
The ground version of a program P, denoted ground(P), is the set of
the ground instances of its rules:
ground(P) = { ground( r) | r P}
The Immediate Consequence Operator TP:
TP(I) = {A BP | $r A A1,...,A n ground(P), { A1,...,An } I }
The TP operator can be implemented using the relational algebra
equivalent of the relational rules.
The fixpoint equation: I = TP(I)
The solutions of this equations are called fixpoint for TP
When we have several solutions we can find the minimal ones and the
least ones (according to )
For a positive program P the least fixpoint of TP exists and is denoted
lfp(TP)
lfp(TP) defines the meaning of P.
Computation of TP
TP 0 ( I ) = I
Powers of TP :
TP n+1 ( I ) = TP ( TP n (I) )
Moreover, with w denoting the first limit ordinal, we define:
TPw (I) =
{T
n
(I) | n 0 }
Powers of TP starting from the empty set; I.e. from I =
Theorem: If P is a positive program; then lfp(TP) = TPw ()
NB: the monotonicity of TP is critical for the existence of
lfp(TP) and its efficient computation (next slide).
Computing TPw ()
Theorem: The successive powers of TP, form an
ascendingchain: I.e. TPn () TP n+1 ().
Proof by induction:
Base: = TP0 () TP1(),
Induction: If TPn-1 () TPn () then TPn () TPn+1 ()
Indeed, TPn() = TP ( TPn-1()) and TPn+1() = TP ( TPn())
And the conclusion follows from the monotonicity of TP
Corollaries: TPk() =
n k TPn ()
if TPk+1()= TPK () then TPK ()= TP ()w
Computation: start from the empty set, and repeat the
application of TP until no new atoms are obtained—I.e., the
n+1-th power is identical to the n-th one (if such condition
never occurs then we have an infinite computation).
© Copyright 2025 Paperzz