CS 6795 Semantic Web Techniques

Assignment 2


Syllabus
Assigns
Notes
Labs
Project
Resources

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:

 

<Implies>
  <head>
    <Atom>
      <Rel>own</Rel>
      <Var>person</Var>
      <Var>object</Var>
    </Atom>
  </head>
  <body>
    <And>
      <Atom>
        <Rel>buy</Rel>
        <Var>person</Var>
        <Var>merchant</Var>
        <Var>object</Var>
      </Atom>
      <Atom>
        <Rel>keep</Rel>
        <Var>person</Var>
        <Var>object</Var>
      </Atom>
    </And>
  </body>
</Implies>
 
<Implies>
  <head>
    <Atom>
      <Rel>buy</Rel>
      <Var>person</Var>
      <Var>merchant</Var>
      <Var>object</Var>
    </Atom>
  </head>
  <body>
    <Atom>
      <Rel>sell</Rel>
      <Var>merchant</Var>
      <Var>person</Var>
      <Var>object</Var>
    </Atom>
  </body>
</Implies>
 
<Atom>
  <op><Rel>keep</Rel></op>
  <Ind>Mary</Ind>
  <Ind>XMLBible</Ind>
</Atom>
 
<Atom>
  <op><Rel>sell</Rel></op>
  <Ind>John</Ind>
  <Ind>Mary</Ind>
  <Ind>XMLBible</Ind>
</Atom>

 

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:

<?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.home4many/john">

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

    <samfam:spouse rdf:resource="http://www.home4many/mary"/>

  </rdf:Description>

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

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

    <samfam:spouse rdf:resource="http://www.home4many/john"/>

  </rdf:Description>

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

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

    <samfam:father rdf:resource="http://www.home4many/john"/>

    <samfam:mother rdf:resource="http://www.home4many/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.

 

 

 

 

 

 

 

 

 

 


Maintained by Harold Boley