

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSA PROBLEM SET Due in class Monday April Questions pts
p oints Consider the rule
qX eABX pA pB Supp ose the relation P for p contains the unary tuples f g and the tuples in the relation E for e are f g What is the value of the relation Q for q For each tuple of Q give a substitution of constants for variables that explains why that tuple is in Q p oints Exercise from PDKSI The following is a simplication of a calcu lation that must b e p erformed in an optimizing compiler We shall assume that all pro cedures of the hyp othetical language b eing compiled have a single parameter and an EDB relation par am P X says that X is the formal parameter of pro cedure P Another EDB predicate cal l s P Q Y says that pro cedure P calls pro cedure Q with actual parameter Y It is p ossible that Y is a lo cal variable of P the formal parameter of P or a constant For example the pro cedures in Figure A are characterized by the EDB facts par am p x cal l s p q a par am q y cal l s p q x cal l s q p y cal l s q q Write Datalog rules that compute the transitive closure of cal l s that is an IDB predicate cal l s star P Q Z that says when pro cedure P executes it results in a call to Q with argument Z p erhaps through a sequence of calls to pro cedures For example in the pro cedures of Figure A cal l s star p p a is true b ecause p calls q with argument a and q calls p with its own formal parameter as argument
pro cedure px local a call qa call qx end pro cedure qy call py call q end
Fig A Example program for Problem
p oints Exercise of PDKSI Supp ose we have EDB relations f r eq uents D r ink er B ar ser v es B ar B e er l ik es D r ink er B eer
The rst indicates the bars a drinker visits the second tells what b eers each bar serves and the last indicates which b eers each drinker likes to drink Dene the following predicates using safe Datalog rules
a happy D that is true if drinker D frequents at least one bar that serves a b eer he or she likes
b shoul dV isit D B if bar B serves a b eer drinker D likes
p oints Write each of the queries
a v er y H appy D if every bar that drinker D frequents serves at least one b eer he or she likes You may assume that every drinker frequents at least one bar b sad D if drinker D frequents no bar that serves a b eer he or she likes
In i domain relational calculus and ii tuple relational calculus For each of a and b p oints is awarded for getting the idea and p oints for rendering the idea correctly in DRC and TRC p oints Exercise from PDKSI
Consider the rules pXY qXY not rX rX sXY not tY rX sXY rY
a Determine the stratum of each predicate Is the program stratied b Supp ose the relations for the EDB predicates s t and q are resp ectively S fab bc cag T fa b cg and Q fab bc cd deg Find the stratied p erfect mo del for the IDB predicates p and r given this EDB c Find another minimal mo del for the rules and the EDB given in b