CS 6795 Semantic Web Techniques

Assignment 2


Syllabus
Assigns
Notes
Labs
Project
Resources

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:contains>

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

        <voc:name>FCS</voc:name>

        <voc:offers>

          <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:Gradcourse>

        </voc:offers>

      </voc:Faculty>

    </voc:contains>

  </voc:University>

  <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/"/>

  </voc:Professor>

</rdf:RDF>

 

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.: '.../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).

expressionist(sara).

actor(mary).

 

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

 

_______because____________________________________________________________________

 

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

 

_______because____________________________________________________________________

 

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 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 adjaceq (i.e., 'adjacent equals’):

Prolog syntax:

adjaceq([X,X|R]).

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

 

POSL syntax:

adjaceq([?X,?X|?R]).

adjaceq([?X|?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: 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 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