CSc 8710, Deductive Databases and Logic Programming
Fall 2008
Homework 3: Test Cases

------------------------------------------------------------------------
DRC WFF:
(exists S)(student(S,N) and (exists G)(enroll(S,'8710',G)))

Function term representation:
exists([s],and(atom(student,[s,n]),
               exists([g],atom(enroll,[s,"8710",g]))
              )
      )
------------------------------------------------------------------------
DRC WFF:
(exists S)(student(S,N) and
           not((exists C,M)(student(S,M) and course(C,'Database') and
                            not((exists G)(enroll(S,C,G)))
                           )
              )
          )
Function term representation:
exists([s],and(atom(student,[s,n]),
               not(exists([c,m],and(atom(student,[s,m]),
                                    and(atom(course,[c,"Database"]),
                                        not(exists([g],atom(enroll,[s,c,g])
                                                  )
                                           )
                                       )
                                   )
                         )
                  )
              )
      )
------------------------------------------------------------------------
DRC WFF:
(exists S)(student(S,N) and
           not((exists C,G)(enroll(S,C,G) and
                            not(course(C,'Database'))
                           )
              )
          )

Function term representation:
exists([s],and(atom(student,[s,n]),
               not(exists([c,g],and(atom(enroll,[s,c,g]),
                                    not(atom(course,[c,"Database"]))
                                   )
                         )
                  )
              )
      )
------------------------------------------------------------------------
(3) Find the directors such that EVERY actor has acted in at
   least one of his or her movies.

{ D | (exists Z)(movies(Z,D) and
        not((exists A,X,Y)(movies(X,D) and actors(Y,A) and
                           not((exists T)(actors(T,A) and movies(T,D))))))}

F =
exists([z],
 and(atom(movies,[z,d]),
   not(
     exists([a,x,y],
       and(atom(movies,[x,d]),
         and(atom(actors,[y,a]),
           not(
             exists([t],
               and(atom(actors,[t,a]),
                   atom(movies,[t,d])
               )
             )
           )
         )
       )
     )
   )
 )
)


--------------------------------------------------------------------------
(5) Find all pairs of actors who act in EXACTLY the same movies.

{ X,Y | (exists T1,T2)(actors(T1,X) and actors(T2,Y) and X<Y and
  not ((exists U,S)(actors(U,Y) and actors(S,X) and not (actors(S,Y)))) and
  not ((exists V,T)(actors(V,X) and actors(T,Y) and not (actors(T,X))))
)}

exists([t1,t2],
 and(atom(actors,[t1,x]),
   and(atom(actors,[t2,y]),
     and(atom(lt,[x,y]),
       and(
         not(
           exists([u,s],
             and(atom(actors,[u,y]),
               and(atom(actors,[s,x]), not(atom(actors,[s,y])))
             )
           )
         ),
         not(
           exists([v,t],
             and(atom(actors,[v,x]),
               and(atom(actors,[t,y]), not(atom(actors,[t,x])))
             )
           )
         )
       )
     )
   )
 )
)
--------------------------------------------------------------------

Page Maintained by raj@cs.gsu.edu