- 웹정보시스템 - OWL & SPARQL 2009. 12 Sang-goo Lee School of Computer Science & Engineering Seoul National University, Seoul, Korea Seoul National University Seoul, Korea Copyright 2008~2009 SNU. All rights reserved.
OWL & Description Logics
OWL Web Ontology Language (WOL? -> OWL) is built on top of RDF was designed to be interpreted by computers (not people) is a W3C Recommendation (standard) A richer ontology language relations between classes: e.g., disjointness cardinality: e.g., exactly one richer typing of properties characteristics of properties (e.g., symmetry) Three sublanguages OWL Lite - simplest OWL DL (includes OWL Lite) - constructs with restriction OWL Full (includes OWL DL) - full expressive power OWL & SPARQL - 3
OWL Basic Structure (OWL Lite) (In)Equality: equivalentclass, equivalentproperty, sameas, differentfrom, AllDifferent, distinctmembers, Property Characteristics: ObjectProperty, DatatypeProperty, inverseof, TransitiveProperty, SymmetricProperty, FunctionalProperty, InverseFunctionalProperty Property Restrictions: Restriction, onproperty, allvaluesfrom, somevaluesfrom, Restricted Cardinality: mincardinality (only 0 or 1), maxcardinality (only 0 or 1), cardinality (only 0 or 1) Header Information: Ontology, imports Class Intersection: intersectionof Versioning: versioninfo, priorversion, backwardcompatiblewith, incompatiblewith, DeprecatedClass, DeprecatedProperty Annotation Properties: rdfs:label, rdfs:comment, rdfs:seealso, rdfs:isdefinedby, AnnotationProperty, OntologyProperty Extended Structure (OWL DL & Full) Class Axioms: oneof, datarange, disjointwith, equivalentclass, rdfs:subclassof Boolean Combinations of Class Expressions: unionof, complementof, intersectionof Arbitrary Cardinality: mincardinality, maxcardinality, cardinality Filler Information: hasvalue OWL & SPARQL - 4
OWL Examples <owl:class rdf:about="#associateprofessor"> <owl:disjointwith rdf:resource="#professor"/> <owl:disjointwith rdf:resource="#assistantprofessor"/> </owl:class> <owl:class rdf:id="faculty"> <owl:equivalentclass rdf:resource="#academicstaffmember"/> </owl:class> <owl:objectproperty rdf:id="istaughtby"> <owl:domain rdf:resource="#course"/> <owl:range rdf:resource= "#academicstaffmember"/> <rdfs:subpropertyof rdf:resource="#involves"/> </owl:objectproperty> OWL & SPARQL - 5
OWL Examples (cont.) <owl:objectproperty rdf:id="teaches"> <rdfs:range rdf:resource="#course"/> <rdfs:domain rdf:resource= "#academicstaffmember"/> <owl:inverseof rdf:resource="#istaughtby"/> </owl:objectproperty> <owl:class rdf:about="#firstyearcourse"> <rdfs:subclassof> <owl:restriction> <owl:onproperty <owl:allvaluesfrom </owl:restriction> </rdfs:subclassof> </owl:class> rdf:resource="#istaughtby"/> rdf:resource="#professor"/> OWL & SPARQL - 6
Description Logics? A family of logic based Knowledge Representation formalisms Descendants of semantic networks and KL-ONE Describe domain in terms of concepts (classes), roles (relationships) and individuals Distinguished by: Formal semantics (typically model theoretic) Decidable fragments of FOL Provision of inference services Sound and complete decision procedures for key problems OWL & SPARQL - 7
DL Basics Concepts (unary predicates/formulae with one free variable) E.g., Person, Father, Mother Roles (binary predicates/formulae with two free variables) E.g., haschild, hashudband Individual names (constants) E.g., Alice, Bob, Cindy Subsumption (relations between concepts) E.g. Female Person Operators (for forming concepts and roles) And(Π), Or(U), Not ( ) Universal qualifier ( ), Existent qualifier( ) Number restriction :,, = Inverse role ( - ), transitive role ( + ), Role hierarchy OWL & SPARQL - 8
Example OWL & SPARQL - 9
Role example (Inverse Role) hasparent = haschild - hasparent(bob,alice) -> haschild(alice, Bob) (Transitive Role) ancestor + ancestor(bob,david), ancestor(david, Mack) -> ancestor(bob,mack) (Role Hierarchy) hasmother hasparent hasmother(bob,alice) -> hasparent(bob, Alice) HappyFather Father Π 1 haschild.woman Π 1 haschild.man OWL & SPARQL - 10
OWL as DL: Axioms [Ian Horrocks] OWL & SPARQL - 11
OWL as DL: Class Constructors [Ian Horrocks] OWL & SPARQL - 12
DL Knowledge Base Knowledge Base [Ian Horrocks] Tbox (schema) HappyFather Person Π 1 haschild.woman Π 1 haschild.man Abox (data) Happy-Father(Bob) Inference System Interface Tbox (terminology, taxonomy): a set of axioms describing structure of domain (i.e., a conceptual schema) ABox (membership assertions): a set of axioms describing a concrete situation (data), e.g.: John:HappyFather; <John,Mary>:hasChild Separation has no logical significance But may be conceptually and implementationally convenient OWL & SPARQL - 13
DL Knowledge Base Example Tbox (terminology, taxonomy) Abox (membership assertions) OWL & SPARQL - 14
Description Logic Family DLs are a family of logic based KR formalisms Particular languages mainly characterised by: Set of constructors for building complex concepts and roles from simpler ones Set of axioms for asserting facts about concepts, roles and individuals ALC (Attributive Language with Complements) is the smallest DL ALC ::= A C C D C D R.C R.C Constructors include booleans (and, or, not), and Restrictions on role successors OWL & SPARQL - 15
OWL Full, DL, Lite SHOIQ = OWL DL S =ALCR + : ALC with transitive role H = role hierarchy O = nominal, e.g, WeekEnd = {Saturday, Sunday} I = Inverse role Q = qualified number restriction e.g. 1 haschild.man N = number restriction e.g. 1 haschild OWL Lite = SHIF(D n ) F = functionality: ( 1 R) Complexity SHOIQ: NExpTime (adding transitive roles => undecidable: OWL full) SHIF: ExpTime OWL & SPARQL - 16
Triple store & SPARQL
Triples as Graph createtriplestore( seminar.db" ) addtriple (Person1 first-name Steve) addtriple (Person1 isa Organizer) addtriple (Person1 age 52) addtriple (Person2 first-name Jans) addtriple (Person2 isa Psychologist) addtriple (Person2 age 50) addtriple (Person3 first-name Craig) addtriple (Person3 isa SalesPerson) addtriple (Person3 age 32) addtriple (Person1 colleague-of Person2) addtriple (Person1 colleague-of Person3) addtriple (Person1 likes Pizza) addtriple ( Person3 neighbour-of Person1) addtriple ( Person3 neighbour-of Person2) [Franz, Inc., 2008] OWL & SPARQL - 18
Query the Graph (select (?xname?yname) (?x colleague-of?y) (?y neighbour-of?x) (?x first-name?xname) (?y first-name?yname)) [Franz, Inc., 2008] OWL & SPARQL - 19
Triple Store A system to provide a mechanism for persistent storage and access of RDF graphs. Persistent RDF storage Why? Relational model vs OO model vs RDF model Everything is modeled as triples => very flexible cf. relational model Simple cf. relational model, OO model Standards based cf. OO model OWL & SPARQL - 20
Triple Store Architectures In memory Internal data representation of graph Will not scale RDB based Built on top of a relational DB - easy implementation Not optimized for RDF graph RDF specific Specially designed storage system for RDF graphs Optimized but New (not mature) AllegroGraph, Sesame, Oracle 11g (?) Issues Scalability Language support: SPARQL Level of inference: RDFS, OWL (levels), Interoperability: APIs Relational-to-RDF mapping OWL & SPARQL - 21
Triple Store Benchmarks Lehigh University Benchmark (LUBM) Ontology: The benchmark ontology (named Univ-Bench) Data Generator(UBA): Tool to generate synthetic OWL data over the Univ-Bench ontology in the unit of a university Test Queries: 14 test queries Tester (UBT) : The test module Ontology Benchmark (UOBM) extends the LUBM benchmark in terms of inference and scalability testing UOBM ontology and data set Berlin SPARQL Benchmark (BSBM) designed along an e-commerce use case SPARQL and SQL version available SP 2 Bench a scalable RDF data generator a set of benchmark queries OWL & SPARQL - 22
SPARQL SPARQL is a query language and a protocol for accessing RDF designed by the W3C RDF Data Access Working Group. a W3C Recommendation: SPARQL Query Language for RDF, http://www.w3.org/tr/rdf-sparql-query/ SPARQL Query language can be used to get information from RDF graphs. It provides facilities to: extract information in the form of URIs, blank nodes, plain and typed literals. extract RDF subgraphs. construct new RDF graphs based on information in the queried graphs. OWL & SPARQL - 23
The Semantic Web Layer Tower OWL & SPARQL - 24
Basic Graph Pattern Triple Patterns Matching a triple pattern to a graph: bindings between variables and RDF Terms?book dc:title?title Data rdf:type rdf:type rdf:property Query SELECT?x?v WHERE {?x?x?v } Query Result x rdf:type v rdf:property OWL & SPARQL - 25
Basic Graph Pattern - Multiple Matches Data @prefix foaf: <http://xmlns.com/foaf/0.1/>. _:a foaf:name "Johnny Lee". _:a foaf:mbox <mailto:jlow@example.com>. _:b foaf:name "Peter Guy". _:b foaf:mbox <mailto:peter@example.org>. [ Written in Turtle format: Terse RDF Triple Language ] Query PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT?name?mbox WHERE {?x foaf:name?name.?x foaf:mbox?mbox } Query Result name "Johnny Lee " "Peter Guy" mbox <mailto:jlow@example.com> <mailto:peter@example.org> OWL & SPARQL - 26
Value Constraints @prefix dc: <http://purl.org/dc/elements/1.1/>. @prefix : <http://example.org/book/>. @prefix ns: <http://example.org/ns#>. :book1 dc:title "SPARQL Tutorial". :book1 ns:price 42. :book2 dc:title "The Semantic Web". :book2 ns:price 23. Query Data PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> SELECT?title?price WHERE {?x ns:price?price. FILTER?price < 30.?x dc:title?title. } title "The Semantic Web" 23 price Query Result OWL & SPARQL - 27
Optional graph patterns @prefix dc: <http://purl.org/dc/elements/1.1/>. Data @prefix : <http://example.org/book/>. @prefix ns: <http://example.org/ns#>. :book1 dc:title "SPARQL Tutorial". :book1 ns:price 42. :book2 dc:title "The Semantic Web". :book2 ns:price 23. PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> Query SELECT?title?price WHERE {?x dc:title?title. OPTIONAL {?x ns:price?price. title price FILTER?price < 30 }} SPARQL Tutorial "The Semantic Web" 23 Query Result OWL & SPARQL - 28
Order By PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT?name WHERE {?x foaf:name?name } ORDER BY?name PREFIX : http://example.org/ns# PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/xmlschema#> SELECT?name WHERE {?x foaf:name?name ; :empid?emp } ORDER BY DESC(?emp) OWL & SPARQL - 29
In XML Form [SPARQL Variable Binding Results XML Format] namex namey nicky "Alice" "Bob" "Alice" "Clare" "CT" <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparqlresults#"> <head> <variable name="namex"/> <variable name="namey"/> <variable name="nicky"/> </head> <results> <result> <binding name="namex"> <literal>alice</literal> </binding> <binding name="namey"> <literal>bob</literal> </binding> </result> <result> <binding name="namex"> <literal>alice</literal> </binding> <binding name="namey"> <literal>clare</literal> </binding> <binding name="nicky"> <literal>ct</literal> </binding> </result> </results> </sparql> OWL & SPARQL - 30
Query forms and Extensions Query forms SELECT: returns all, or a subset of the variables bound in a query pattern match CONSTRUCT: returns an RDF graph constructed by substituting variables in a set of triple templates DESCRIBE: returns an RDF graph that describes the resources found. ASK: returns whether a query pattern matches or not. Related specifications SPARQL Query Language for RDF http://www.w3.org/tr/rdf-sparql-query/ defines the syntax and semantics of the SPARQL query language for RDF SPARQL Protocol for RDF http://www.w3.org/tr/rdf-sparql-protocol/ defines the remote protocol for issuing SPARQL queries and receiving the results SPARQL Query Results XML Format http://www.w3.org/tr/rdf-sparql-xmlres/ defines an XML document format for representing the results of SPARQL queries OWL & SPARQL - 31
OWL & SPARQL Seoul National University Seoul, Korea Copyright 2008~2009 SNU. All rights reserved.