CS 6795 Semantic Web Techniques

Assignment 2


Syllabus
Assigns
Notes
Labs
Project
Resources

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

  xmlns:samfam="http://samplefamily.org/elements/">

  <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:Description rdf:about="http://www.ourhomes/mary">

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

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

  </rdf:Description>

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

  </rdf:Description>

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

dualist(john).

biped(mary).

 

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

 

_______because____________________________________________________________________

 

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

 

_______because____________________________________________________________________

 

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,[gold,X,gold|R]).

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

 

POSL syntax:

goldmemgold(?X,[gold,?X,gold|?R]).

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?

 

_______because____________________________________________________________________

 

5) Consider the following RuleML 1.0 program:

 

<Implies>
  <then>
    <Atom>
      <Rel>trade</Rel>
      <Var>person</Var>
      <Var>object</Var>
    </Atom>
  </then>
  <if>
    <And>
      <Atom>
        <Rel>buy</Rel>
        <Var>person</Var>
        <Var>seller</Var>
        <Var>object</Var>
        <Var>buyprice</Var>
      </Atom>
      <Atom>
        <Rel>sell</Rel>
        <Var>person</Var>
        <Var>buyer</Var>
        <Var>object</Var>
        <Var>sellprice</Var>
      </Atom>
    </And>
  </if>
</Implies>
 
<Implies>
  <then>
    <Atom>
      <Rel>buy</Rel>
      <Var>person</Var>
      <Var>merchant</Var>
      <Var>object</Var>
      <Var>price</Var>
   </Atom>
  </then>
  <if>
    <Atom>
      <Rel>sell</Rel>
      <Var>merchant</Var>
      <Var>person</Var>
      <Var>object</Var>
      <Var>price</Var>
    </Atom>
  </if>
</Implies>
 
<Atom>
  <Rel>sell</Rel>
  <Ind>John</Ind>
  <Ind>Mary</Ind>
  <Ind>XMLBible</Ind>
  <Ind>20</Ind>
</Atom>
 
<Atom>
  <Rel>sell</Rel>
  <Ind>Mary</Ind>
  <Ind>Peter</Ind>
  <Ind>XMLBible</Ind>
  <Ind>22</Ind>
</Atom>

 

Write the corresponding Prolog program by just completing the six versions of "___":

 

trade(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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Maintained by Harold Boley