cs345-1

cs345-1 - 1 Datalog Rules Programs Negation 2 Review of...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Datalog Rules Programs Negation 2 Review of Logical If-Then Rules h(X,) :- a(Y,) & b(Z,) & head body subgoal s The head is true if all the subgoals are true. 3 Terminology Head and subgoals are atoms . An atom consists of a predicate (lower case) applied to zero or more arguments (upper case letters or constants). 4 Semantics Predicates represent relations. An atom is true for given values of its variables iff the arguments form a tuple of the relation. Whenever an assignment of values to all variables makes all subgoals true, the rule asserts that the resulting head is also true. 5 Example We shall develop rules that describe what is necessary to make a file. The predicates/relations: source(F) = F is a source file. includes(F,G) = F #includes G . create(F,P,G) = F is created by applying process P to file G . 6 Example --- Continued Rules to define view req(X,Y) = file Y is required to create file X : req(F,F) :- source(F) req(F,G) :- includes(F,G) req(F,G) :- create(F,P,G) req(F,G) :- req(F,H) & req(H,G) G is required for F if there is some process P that creates F from G . G is required for F if there is some H such that H is required for F and G is required for H . 7 Why Not Just Use SQL? 1. Recursion is much easier to express in Datalog. Viz. last rule for req . 1. Rules express things that go on in both FROM and WHERE clauses, and let us state some general principles (e.g., containment of rules) that are almost impossible to state correctly in SQL. 8 IDB/EDB A predicate representing a stored relation is called EDB (extensional database). A predicate representing a view, i.e., a defined relation that does not exist in the database is called IDB (intesional database). Head is always IDB; subgoals may be IDB or EDB. 9 Datalog Programs A collection of rules is a (Datalog) program . Each program has a distinguished IDB predicate that represents the result of the program. E.g., req in our example. 10 Extensions 1. Negated subgoals. 2. Constants as arguments. 3. Arithmetic subgoals. 11 Negated Subgoals NOT in front of a subgoal means that an assignment of values to variables must make it false in order for the body to be true....
View Full Document

This document was uploaded on 01/06/2012.

Page1 / 47

cs345-1 - 1 Datalog Rules Programs Negation 2 Review of...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online