70 likes | 182 Views
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. Model Theoretic : describing what facts hold true because of the given facts and rules.
E N D
CS240A: Databases and Knowledge BasesFixpointSemantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles WINTER 2002
Three Equivalent Semantics • Model Theoretic: describing what facts hold true because of the given facts and rules. • Proof Theoretic: using SLD-resolution • 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 Instanceof 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 • Powers of TP : TP 0 ( I ) = I ¼ 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 (Æ) Í TPn+1 (Æ). Proof by induction: Base:Æ = TP0 (Æ) Í TP1(Æ), Induction: IfTPn-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).