CS 6795 Semantic Web Techniques

Assignment 2


1) This is RDF metadata about our course, with student numbers and names changed:

<?xml version="1.0"?>

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

         xmlns:voc="http://www.unb.ca/vocabulary#" >

  <voc:University rdf:about="http://www.unb.ca/">

    <voc:name>University of New Brunswick</voc:name>


      <voc:Faculty rdf:about="http://www.unb.ca/fredericton/cs/">



          <voc:Gradcourse rdf:about="http://www.cs.unb.ca/~boley/cs6795swt/">

            <voc:name>Semantic Web Techniques</voc:name>

            <voc:instructor rdf:resource="http://www.cs.unb.ca/~boley/"/>

            <voc:student>Aaron Anders</voc:student>

            <voc:student>Brigit Bonmot</voc:student>

            <voc:student>Cesar Chalker</voc:student>






  <voc:Professor rdf:about="http://www.cs.unb.ca/~boley/">

    <voc:name>Harold Boley</voc:name>

    <voc:teaches rdf:resource="http://www.cs.unb.ca/~boley/cs6795swt/"/>




Draw, maybe using a tool, 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.: '.../cs/').
























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

artist(X) :- painter(X).

artist(X) :- actor(X), improvising(X).

painter(X) :- expressionist(X).




a) Give, and very briefly explain, the result of the query artist(sara):




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




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








3) Using Prolog or any other logic notation, give clauses that express that (1) path(X,Y) can be proved via connected(X,Y) and (2) path(X,Z) can be proved via (a) connected(X,Y) and (b), recursively, path(Y,Z). Add clauses that express that connected(X,Y) can be proved via directed(X,Y) or undirected(X,Y).

Add facts representing directed (arrow pointing from X to Y) or undirected (link between X and Y) arcs in a graph, mentioning at least a node, one of its directed- or undirected-reachable nodes, and one of its further reachable nodes. Show a query that asks for all of the known paths, and a derivation using at least one occurrence of the rule (2).

Hint: You can test your program and queries in any Prolog engine (variables are upper-cased) -- e.g. in SWI Prolog or XSB Prolog -- or in the OO jDREW engine, which uses POSL (variables are “?”-prefixed) -- via http://jdrew.org/oojdrew/1.0/oojdrew-1.0.jnlp.














4) Consider this definition of the predicate adjaceq (i.e., 'adjacent equals’):

Prolog syntax:


adjaceq([_|R]) :- adjaceq(R).


POSL syntax:


adjaceq([?|?R]) :- adjaceq(?R).


You can read the two clauses as follows:

  • adjaceq is true of a list whose first two elements are equal.
  • adjaceq is true of a list whose tail (all but the first element) is R if adjaceq is true of R.

Hint: As in Part 3), you can test your answers to the below queries in any Prolog engine (named variables are upper-cased) or in the OO jDREW POSL engine (named variables are “?”-prefixed); an anonymous variable is written as a stand-alone “_” (Prolog) or “?” (POSL).


Show the results of checking adjaceq of ground (variable-free) lists thus:


?- adjaceq([a,b,a,b]).





?- adjaceq([b,a,a,b]).





Show the results of enumerating adjaceqs of a non-ground list thus
(where each “; asks for another solution):


Prolog syntax:

?- adjaceq([a,M,b]).


POSL syntax:

?- adjaceq([a,?M,b]).



_____________ ;


_____________ ;



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 what happens when checking adjaceq of a ground list with three adjacent equal elements.






Maintained by Harold Boley