Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS240A: Databases and Knowledge Bases Fixpoint Semantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles.

Similar presentations


Presentation on theme: "CS240A: Databases and Knowledge Bases Fixpoint Semantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles."— Presentation transcript:

1 CS240A: Databases and Knowledge Bases Fixpoint Semantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles WINTER 2002

2 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.

3 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.

4 Herbrand Universe and Ground Instance of program P  The Herbrand Universe for P, denoted U P, 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 U P. For the example program: U P = {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 U P.  E.g. from the previous program take: parent(X, Y)  mother(X, Y). Since there are 2 variables in this rule and U P = 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).

5 Semantics of a positive program P as the least fixpoint of its Immediate Consequence Operator T P  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 T P : T P ( I ) = {A  B P   r A  A 1,...,A n  ground(P), { A 1,...,A n }  I } The T P operator can be implemented using the relational algebra equivalent of the relational rules.  The fixpoint equation: I = T P ( I )  The solutions of this equations are called fixpoint for T P  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 T P exists and is denoted lfp(T P )  lfp(T P ) defines the meaning of P.

6 Computation of T P  Powers of T P : T P  0 ( I ) = I  T P  n+1 ( I ) = T P ( T P  n ( I ) )  Moreover, with  denoting the first limit ordinal, we define: T P   ( I ) =   { T  n ( I )  n  0 }  Powers of T P starting from the empty set; I.e. from I =  Theorem: If P is a positive program; then lfp(T P ) = T P   (  ) NB: the monotonicity of T P is critical for the existence of lfp(T P ) and its efficient computation (next slide).

7 Computing T P   (  ) Theorem: The successive powers of T P, form an ascending chain: I.e. T P  n (  )  T P  n+1 (  ). Proof by induction: Base:  = T P  0 (  )  T P  1 (  ), If Induction : If T P  n-1 (  )  T P  n (  ) then T P  n (  )  T P  n+1 (  ) Indeed, T P  n (  ) = T P ( T P  n-1 (  )) and T P  n+1 (  ) = T P ( T P  n (  )) And the conclusion follows from the monotonicity of T P Corollaries: T P  k (  ) =  n  k T P  n (  ) if T P  k+1 (  )= T P  K (  ) then T P  K (  )= T P (  )   Computation: start from the empty set, and repeat the application of T P 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).


Download ppt "CS240A: Databases and Knowledge Bases Fixpoint Semantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles."

Similar presentations


Ads by Google