### Problem 1 (40 pts.)

Consider the global predicates in an integrated information system about the Stanford students.
student(S)
S is a student at Stanford.
office(S,O)
O is the office of S.
phone(S,P)
P is the phone of S.
major(S,M)
S is majoring in M.
A is the advisor of S.
machine(S,M)
M is the machine of S.
group(S,G)
G is the group of S.
Suppose there are five source, each providing one view:
``` phone-dir(S,O,P) :- student(S) & office(S,O) & phone(S,P) su-info(S,A,M) :- student(S) & advisor(S,A) & major(S,M) acad-info(S,M,G) :- student(S) & major(S,M) & group(S,G) cs-info(S,O,M) :- student(S) & major(S,cs) & office(S,O) & machine(S,M) ```
``` db-info(S,A,M,P) :- student(S) & major(S,cs) & group(S,db) & advisor(S,A) & machine(S,M) & phone(S,P). ```

``` ```

Note that cd and db are constants.
a)
Express each of the following queries in terms of the global predicates.
• What are Andrew's phone number and office?
• What are Ben's office, machine, and advisor, given that he is a student in computer science?
• What are Cindy's major, advisor, and group?
• What are Debbie's advisor, office, and phone number, given that she is majoring in computer science and is a member of the database group?
b)
Find all minimal solutions (in terms of the available views) to each of the queries from a).

### Problem 2 (30 pts.)

For this problem, suppose that the views from Problem 1 have the following binding patterns:
``` phone-dir(S,O,P) - fff. su-info(S,A,M) - bff. acad-info(S,M,G) - bbf. cs-info(S,O,M) - ffb or fbf. ```
``` db-info(S,A,M,P) - bfbf or bffb. ```
Find all minimal solutions (in terms of the adorned views) to each of the following queries:
• Find all the students that have a given advisor.
• Find all students that share a given office.
• Find all computer science students.
• Find the group that a given machine belongs to.

### Problem 3 (30 pts.)

Consider the following conjunctive queries:
``` Q1: p(X) :- arc(X,Y) & arc(Y,Z) & arc(Z,X) Q2: p(X) :- arc(X,W) & arc(Y,W) & arc(W,Z) & arc(Z,Y) & arc(Z,X) Q3: p(X) :- arc(X,X1) & arc(X1,X2) & arc(X2,X3) & arc(X3,X4) & arc(X4,X5) & arc(X5,X) Q4: ```
``` p(X) :- arc(X,Y) & arc(Y,X) & arc(X,Z). ```
a)
Minimize each query.
b)
Minimize their union.