Semantic Technologies Autumn 2017 Coursework For return on 19 January 2018 (late submission: 2 February 2018) Electronic submission:.pdf and.owl files only 1. (6%) Consider the following XML document: <?xml version= 1.0 encoding= UTF-16?> <recipes > <recipe > <title >Beef Parmesan</title> <ingredient name= beef amount= 1.5 unit= pound /> <ingredient name= onion amount= 1 /> <ingredient name= green rings amount= 1 /> <preparation > <step >Boil pasta</step> </preparation> <comment >...</comment> <nutrition calories= 1167 fat= 23 carbohydrates= 45 protein= 32 /> </recipe>... </recipes> (a) Give a tree representation of this XML document. (b) Give XPath queries that can find the following in the document: The titles of all recipes. The titles of all recipes that use olive oil. The titles of all recipes with less than 500 calories. 2. (6%) Consider the following RDF document: <rdf:rdf xmlns:rdf= http://www.w3.org/1999/02/22-rdf-syntax-ns# xmlns:rdfs= http://www.w3.org/2000/01/rdf-schema# xmlns:lit= http://literature.org/# xml:base= http://literature.org/ > <rdf:description rdf:about= #Hamlet > <rdf:type rdf:resource= #drama /> </rdf:description> <rdf:description rdf:about= #Sonet96 > <rdf:type rdf:resource= #poem /> </rdf:description> 1
<rdf:description rdf:about= #wrote > <rdf:type rdf:resource= &rdf;property /> <rdf:domain rdf:resource= #writer /> <rdf:range rdf:resource= #literary content /> </rdf:description> <rdfs:class rdf:about= #poem > <rdfs:subclassof rdf:resource= #literary content /> </rdfs:class> <rdfs:class rdf:about= #drama > <rdfs:subclassof rdf:resource= #literary content /> </rdfs:class> <lit:poet rdf:about= #Shakespear > <lit:wrote rdf:resource= #Sonet96 /> <lit:wrote rdf:resource= #Hamlet /> <rdf:type rdf:resource= #playwright /> </lit:poet> </rdf:rdf> (a) Describe in English the content of this document. (b) Draw the graph representation of the document. (c) Explain which of the following can or cannot be represented in RDF/S: Poets and playwrights are writers. Poets write poems; playwrights write dramas. Poets do not write RDF documents. 3. (6%) Suppose an RDF document contains the triples such as: ex:book1 ex:hastitle Lord of the Rings. ex:book1 ex:writtenby ex:jrrtolkien. ex:book1 ex:publishedinyear 1954. ex:book1 ex:originallanguage ex:english. ex:book1 ex:hasgenre ex:fantasy. ex:book2 ex:hastitle O Alquimista. ex:book2 ex:writtenby ex:paulocoelho. ex:book2 ex:publishedinyear 1988. ex:book2 ex:originallanguage ex:portuguese. ex:jrrtolkien ex:hasnationality ex:british. ex:paulocoelho ex:hasnationality ex:brazilian. Give SPARQL queries to find: the titles of all books published by Tolkien between 1950 and 1965; the title and author of all books published by a Portuguese author or in the Portuguese language; 2
the title, author and, if available, the genre of all books published by a Portuguese author or in the Portuguese language. 4. (6%) (a) Represent the following information by means of RDF/S triples, using the Turtle syntax: Romeo thought that Juliet was dead. Somebody whose email address is paul@e.at plays tennis with the spouse of a colleague whose email addresses are keith@g.es and keith@i.com. Draw the graph representation of the RDF/S document. (b) Explain in English the meaning of the following SPARQL query: PREFIX foaf: http://xmlns.com/foaf/0.1 SELECT?m?n WHERE {?x foaf:mbox?m.?x foaf:knows?y.?z foaf:mbox keith@i.com.?z foaf:marriedto?y. OPTIONAL {?x foaf:name?n. } } 5. (15%) Suppose a relational database contains the following tables: BookTitles book id year title price 232 1944 Animal Farm 4.20 BookAuthors book id author id 232 4152 BookAttributes book id attribute code attribute value 232 2 Secker & Warburg 232 5 Distopia Here 2 is a code for publisher, 5 for literary genre, AuthorNames author id gender name 4152 0 George Orwell 0 for male, 1 for female; Give mappings populating the following: concepts: Author, MaleAuthor, FemaleAuthor, Book object properties: hasauthor (domain: Book, range: Author) data properties: publishedinyear (domain: Book, range: xsdˆˆ:integer), ispublishedby (range: xsdˆˆ:string), hasprice (range: xsdˆˆ:double) Give SPARQL queries that find: the titles of all books published by Oxford University Press and having both male and female authors; 3
the titles and the authors of all books published in 2015 (with information about the publisher if available). 6. (15%) Sketch a radio station ontology, which covers the items listed below in part (a) and provides sufficient concepts and roles for part (b). 1. Indicate hierarchies for both concepts (classes) and properties (roles). For concepts, indicate clearly which are self-standing, which are definable and which are modifiers. Introduce instances of concepts if required. For properties, define their domains and ranges, their inverses, and indicate whether they are (ir)reflexive, (a)symmetric, functional, inverse-functional or transitive. Items to be represented: programme, presenter, pop music, soap opera, album, news bulletin, DJ, rock music, time slot, single record, actor, song, producer, CD, radio station, classical music. 2. Define classes, using your ontology, for the items below (in the OWL functional-style or description logic syntax) or explain why they cannot be expressed in OWL: Newsreader. Programme directed by a woman. Classical music station. If the definition in English is ambiguous, paraphrase it so it is unambiguous and then express the disambiguated notion in OWL. 7. (12%) Represent the following fragments in OWL/XML and OWL/Turtle in the description logic ALC: (a) <owl:class rdf:id="duck"> <rdfs:subclassof> <owl:class rdf:about="#animal"/> </rdfs:subclassof> (b) <owl:class rdf:id="oldlady"> <owl:equivalentclass> <owl:class> <owl:intersectionof rdf:parsetype="collection"> <owl:class rdf:about="#female"/> <owl:class rdf:about="#person"/> <owl:class rdf:id="elderly"/> </owl:intersectionof> </owl:equivalentclass> <rdfs:subclassof> 4
<owl:class> <owl:intersectionof rdf:parsetype="collection"> <owl:restriction> <owl:onproperty> <owl:objectproperty rdf:about="#has_pet"/> </owl:onproperty> <owl:somevaluesfrom> <owl:class rdf:about="#animal"/> </owl:somevaluesfrom> </owl:restriction> <owl:restriction> <owl:allvaluesfrom rdf:resource="#cat"/> <owl:onproperty> <owl:objectproperty rdf:about="#has_pet"/> </owl:onproperty> </owl:restriction> </owl:intersectionof> </rdfs:subclassof> (c) :AmericanPizza rdf:type owl:class ; rdfs:subclassof :Pizza, [ rdf:type owl:restriction ; owl:onproperty :hastopping ; owl:somevaluesfrom :MozzarellaTopping ], [ rdf:type owl:restriction ; owl:onproperty :hastopping ; owl:somevaluesfrom :PepperoniTopping ], [ rdf:type owl:restriction ; owl:onproperty :hastopping ; owl:somevaluesfrom :TomatoTopping ]. 8. (10%) Consider the following small ontology written in OWL functional-style syntax: DisjointClasses(Animal Plant) ObjectPropertyDomain(eats Animal) EquivalentClasses(Herbivore ObjectAllValuesFrom(eats Plant)) EquivalentClasses(Carnivore ObjectAllValuesFrom(eats Animal)) EquivalentClasses(CarnivorousPlant ObjectIntersectionOf(Plant Carnivore)) (a) Write down DL equivalents of each of the axioms in the ontology. 5
(b) Enter the above ontology into Protégé, and use the reasoner to compute the class hierarchy. (c) Explain why Plant is a sub-class of both Herbivore and Carnivore. (d) This does not seem to be correct. Explain how you would improve the ontology in order to fix this problem. (e) Did your improvement reveal any other problem with the ontology? If so, how would you repair the problem? 9. (12%) Consider the ALC TBox T with the following axioms: (a) Translate T into English. Manager worksfor.employer, Manager manages.unit, Manager manages.department, Employer registeredat.taxoffice. (b) Define formally a model I of T in which the concept Manager is not empty. (c) Add the inclusion Unit Department to T. Is the resulting TBox T 1 satisfiable? Explain your answer. (d) Is the concept Manager satisfiable with respect to T 1? Explain your answer. 10. (12%) Consider the concept C = ( R. A R. B) R.(A B) (a) Transform concept C to an equivalent concept in negation normal form. (b) Prove that concept C is satisfiable by giving a model of C. To construct the model, apply the ALC tableau algorithm to the negation normal form of C obtained in (i). (c) Use the tableau algorithm to check whether the following subsumption holds: R.(A B) ( R. A) ( R.B). If it does not hold, give an interpretation witnessing this. 6