CS157a
Chris Pollett
Oct 30, 2019
A|B --- 1|2 3|4then `R(1,2)` and `R(3,4)` are true atoms and `R(1,1)` is false. `R(1,z)` will return true if `z=2`, and otherwise, return false.
LongMovie(t,y) <- Movies(t,y,l,g,s,p) AND l ≥ 100is an example Datalog rule
LongMovie(t,y) <- Movies(t,y,l,_,_,_) AND l ≥ 100
LongMovie(t,y) <- Movies(t,y,l,_,_,_) , l ≥ 100
Father("bob", "tony") <-. //notice this rule has an empty body. // We view such a rule as a fact. Sometimes we just write: // Father("bob", "tony"). Father("tony", "john") <-. Ancestor(x,y) <- Father(x, y). Ancestor(x,z) <- Father(x, y), Father(y,z).
Ancestor(x,z) <- Father(x, y), Ancestor(y,z).This would be a valid Prolog rule, but we don't usually allow a predicate to appear on both sides of a rule in Datalog.
P(x,y) <- Q(x,z), NOT R(w,x,y), x < yis not safe because of how `y` occurs and how `w` occurs.
Post your solutions to the Oct 30 In-Class Exercise Thread.
A|B --- 1|2 1|2and `S(B,C)` is given by
B|C --- 2|3 4|5 4|5then we can compute `H` as
1|3 1|3by treating the two rows of `R` as distinct when trying to satisfy the clause.