CS 6795 Semantic Web Techniques Assignment 2 1) Consider the following Datalog program in Prolog syntax: deal(X) :- sale(X). deal(X) :- used(X), quality(X). sale(X) :- rest(X). rest(a). used(b).   a) Give, and very briefly explain, the result of the query deal(a):   __________________because______________________________________   b) Give, and very briefly explain, the result of the query deal(b):   __________________because______________________________________   c) Give the result(s) of the query deal(Y):             2) Using Prolog or any other logic notation, give a program that expresses that (1) ancestor(X,Y) can be proved via parent(X,Y) and (2) ancestor(X,Z) can be proved via parent(X,Y) and ancestor(Y,Z). Add facts representing two of the parent relations in your own family or in a fictitious family, mentioning you or a fictitious person, one of their parents, and one of his or her parents. Show a query that asks for all of the known ancestors, and a derivation using at least one occurrence of the rule (2). Hint: You can test your program and queries in your favorite Prolog engine (e.g., SWI Prolog) or by using OO jDREW as a POSL engine.                           3) Consider this definition of the predicate 'membadup' (i.e., 'member as an adjacent duplicate'): Prolog syntax: membadup(X,[X,X|R]). membadup(X,[Y|R]) :- membadup(X,R).   POSL syntax: membadup(?X,[?X,?X|?R]). membadup(?X,[?Y|?R]) :- membadup(?X,?R).   You can read the two clauses as follows: X is a membadup of a list whose first two elements are X followed by X. X is a membadup of a list whose tail (all but the first element) is R if X is a membadup of R. Hint: You can test your answers to the following in your favorite Prolog engine (e.g., SWI Prolog) or by using OO jDREW as a POSL engine.   Show the results of checking for a specific membadup thus:   ?- membadup(1,[1,2,2,3,3,3]).   _____________     ?- membadup(2,[1,2,2,3,3,3]).   _____________     Show the results of enumerating membadups of a list thus (where “;” asks for another solution):   Prolog syntax: ?- membadup(X,[1,2,2,3,3,3]).   POSL syntax: ?- membadup(?X,[1,2,2,3,3,3]).     _____________ ;   _____________ ;   _____________ ;   _____________ Briefly explain here the number of solutions found, e.g. by studying the expanded proof tree under “Solution:” in the GUI of OO jDREW.         4) Consider the following RuleML program:   ```  ``    ``      own``      person``      object``    ``  ``  ``    ``      ``        buy``        person``        merchant``        object``      ``      ``        keep``        person``        object``      ``    ``  ```` ````  ``    ``      buy``      person``      merchant``      object``    ``  ``  ``    ``      sell``      merchant``      person``      object``    ``  ```` ````  keep``  Mary``  XMLBible```` ````  sell``  John``  Mary``  XMLBible```   Write the corresponding Prolog program by just completing the six versions of "___":   own(Person,Object) :- _____________________________,                  ______________________.   buy(____________________) :- sell(____________________).     ________________________.   _____________________________________.   What would be implied by the program (write in here, e.g. using Prolog syntax)? Give a sketch of how this solution could be derived.                       5) This is RDF metadata about three fictitious people:       John Smith             Mary Smith             Barbara Smith           Draw the directed labeled graph (DLG) that constitutes the RDF diagram of this XML element (use space below). Hint: URLs, going into ovals or becoming arc labels, and texts, going into rectangles, may be arbitrarily shortened, as long as they remain unique (e.g.: '.../john' or just 'john'; 'John S' or just 'JS'); namespaces can be omitted.

Maintained by Harold Boley