CS 6795 Semantic Web Techniques

Assignment 2


1) This is RDF metadata about four fictitious people:

<?xml version="1.0"?>

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"


  <rdf:Description rdf:about="http://www.ourhomes/john">

    <samfam:name>John Smith</samfam:name>

    <samfam:sibling rdf:resource="http://www.ourhomes/mary"/>


  <rdf:Description rdf:about="http://www.ourhomes/mary">

    <samfam:name>Mary Smith</samfam:name>

    <samfam:sibling rdf:resource="http://www.ourhomes/john"/>


  <rdf:Description rdf:about="http://www.ourhomes/babs">

    <samfam:name>Barbara Smith</samfam:name>

    <samfam:child rdf:resource="http://www.ourhomes/john"/>

    <samfam:child rdf:resource="http://www.ourhomes/mary"/>


  <rdf:Description rdf:about="http://www.ourhomes/herb">

    <samfam:name>Herbert Smith</samfam:name>

    <samfam:child rdf:resource="http://www.ourhomes/john"/>

    <samfam:child rdf:resource="http://www.ourhomes/mary"/>



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.















2) Consider the following Datalog program in Prolog syntax defining a unary predicate or relation human:

human(X) :- philosopher(X).

human(X) :- featherless(X), biped(X).

philosopher(X) :- dualist(X).




a) Give, and very briefly explain, the result of the query human(john):




b) Give, and very briefly explain, the result of the query human(mary):




c) Give the result(s) of the query human(Y):








3) Using Prolog or any other logic notation, give a program that expresses that (1) ride(X,Y) can be proved via train(X,Y) or bus(X,Y) and (2) ride(X,Z) can be proved via (a) train(X,Y) or bus(X,Y) and (b), recursively, ride(Y,Z).

Add facts representing train or bus relations in a real or fictitious region, mentioning a place, one of its train- or bus-reachable places, and one of its further reachable places. Show a query that asks for all of the known rides, and a derivation using at least one occurrence of the rule (2).

Hints: Consider to introduce an auxiliary relation for direct rides. You can test your program and queries in the SWI Prolog engine (variables are upper-cased) or in the OO jDREW POSL engine (variables are “?”-prefixed).














4) Consider this definition of the predicate goldmemgold (i.e., 'member surrounded by gold'):

Prolog syntax:


goldmemgold(X,[Y|R]) :- goldmemgold(X,R).


POSL syntax:


goldmemgold(?X,[?Y|?R]) :- goldmemgold(?X,?R).


You can read the two clauses as follows:

  • X is a goldmemgold of a list whose first three elements are gold followed X followed by gold.
  • X is a goldmemgold of a list whose tail (all but the first element) is R if X is a goldmemgold of R.

Hint: You can test your answers to the following in the SWI Prolog engine (variables are upper-cased) or in the OO jDREW POSL engine (variables are “?”-prefixed).


Show the results of checking for a specific goldmemgold thus:


?- goldmemgold(john,[john,gold,mary,gold,peter,gold]).





?- goldmemgold(mary,[john,gold,mary,gold,peter,gold]).





Show the results of enumerating goldmemgolds of a list thus
(where “; asks for another solution):


Prolog syntax:

?- goldmemgold(X,[john,gold,mary,gold,peter,gold]).


POSL syntax:

?- goldmemgold(?X,[john,gold,mary,gold,peter,gold]).



_____________ ;



Briefly explain here the number of solutions found, e.g. by studying the expanded proof tree
under “Solution:” in the GUI of OO jDREW.








Briefly explain if it has any effect on the number of solutions that john, mary, and peter ‘share’ some gold?















Maintained by Harold Boley