SlideShare a Scribd company logo
1 of 27
SPARQL-DL
Theory & Practice
Adriel Café
aac3@cin.ufpe.br
Summary
1. OWL Basics
2. SPARQL
3. SPARQL-DL
4. Comparison: SPARQL x SPARQL-DL
5. Reasoner's Support for DL
6. Practice
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Important
This document was based on W3C specifications
• http://w3.org/2001/sw/wiki/SPARQL-DL
• http://w3.org/TR/sparql11-query
• http://w3.org/TR/sparql11-overview
• http://w3.org/TR/rdf-sparql-query
• http://w3.org/TR/owl-guide
• http://w3.org/TR/owl-features
• http://w3.org/TR/owl-ref
• http://w3.org/TR/owl2-overview
• http://w3.org/TR/owl2-profiles
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
OWL Basics
Ontology Web Language
• Is an ontology language for the Semantic Web with formally defined
meaning
• Is a W3C standard since 2004
• Written in XML
• Derived from the DAML+OIL
• Developed as a vocabulary extension of RDF
• Provide classes, properties, individuals, data values and are stored as
Semantic Web documents
• OWL Tools
• OWL Syntax Converter (http://owl.cs.manchester.ac.uk/converter)
• OWL Validator (http://owl.cs.manchester.ac.uk/validator)
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
OWL 1
• Compatible with RDF
• Profiles
• OWL Full (Not DL)
• OWL DL (DL SHOIN(D))
• OWL Lite (DL SHIF(D))
OWL Versions
OWL 2
• Compatible with OWL 1 and RDF
• Profiles
• OWL 2 EL (DL EL++)
• OWL 2 QL (DL-Lite)
• OWL 2 RL (DLP)
• OWL 2 DL (DL SROIQ(D))
Is used informally to refer to ontologies
interpreted using the Direct Semantics
http://w3.org/TR/owl2-direct-semantics
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
OWL 2 Structure
http://w3.org/TR/owl2-overview/OWL2-structure2-800.png
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL
SPARQL Protocol and RDF Query Language
• Is a SQL-Like language for querying RDF data
• Is a protocol
• Is a W3C standard since 2008
• Queries consist of triple patterns, conjunctions, disjunctions, and optional
patterns
"SPARQL will make a huge difference“
(Berners-Lee, 2006)
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL in Semantic Web Stack
http://upload.wikimedia.org/wikipedia/en/3/37/Semantic-web-stack.png
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL Query Types
• SELECT
Returns all, or a subset of, the variables bound in a query pattern match.
• ASK
Returns a boolean indicating whether a query pattern matches or not.
• 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.
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name
FROM <http://xmlns.com/foaf/spec/index.rdf>
WHERE {
?x foaf:name ?name
}
ORDER BY ?name
LIMIT 5
OFFSET 10
Anatomy of a SPARQL Query
Triple patterns to be localized
Subject, Predicate and Object
Prefix label associated with an
IRI
Returns all possible bindings of
the provided variables
DISTINCT keyword removes
all redundant bindings
Data sources that should be
consulted
Solution sequences and
modifiers
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
RDF Definitions
• RDF Triple
Contains three components: subject, predicate and object
<http://com.ex/people#adrielcafe> <http://com.ex/contact#name> “Adriel Café"
• RDF Graph
Is a set of RDF triples
• Triple Pattern
Is like an RDF triple, but with the option of a variable in place of RDF terms (i.e.,
IRIs, literals or blank nodes) in the subject, predicate or object positions
?people <http://com.ex/contact#name> ?name
• Basic Graph Pattern (BGP)
Is a conjunction of a finite set of triple patterns
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL Subgraph Matching
• The SPARQL query processor will search for sets of triples that match
these triple patterns, binding the variables in the query to the
corresponding parts of each triple.
• Subgraph matching (a.k.a. simple entailment) considers only the graph
structure of RDF for computing query results
• Entailment Regimes
RDFS Entailment Regime, D-Entailment Regime, OWL 2 RDF-Based Semantics, OWL
2 Direct Semantics
“The main mechanism for computing query results in SPARQL is subgraph matching:
RDF triples in both the queried RDF data and the query pattern are interpreted as
nodes and edges of directed graphs, and the resulting query graph is matched to the
data graph using variables as wild cards.”
(Glimm; Krötzsch, 2010)
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL-DL
SPARQL Protocol and RDF Query Language – Description Logics
• Is a distinct subset of SPARQL
• Uses SPARQL syntax
• Is tailored to ontology specific questions
• Is not yet a W3C standard
• Quite expressive language which allows to mix TBox, RBox, and ABox
queries
• Fully aligned with the OWL 2 standard
• Settled on top of the OWL API
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
http://www.derivo.de/uploads/pics/SPARQL-DL_01.png
SPARQL-DL Abstract Syntax
• A SPARQL-DL query Q is a finite set of SPARQL-DL query atoms and the
query is interpreted as the conjunction of the elements in the set.
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Query Type of the query An example query
Q1 Standard TBox query SubClassOf(?c, ex:Student)
Q2 Standard ABox query
Type(?x, and(ex:Student, ex:Employee)),
PropertyValue(?x, ex:name, ?y)
Q3
ABox query with non-
distinguished variables
PropertyValue(?x, ex:hasPublication, _:y),
PropertyValue(:y, ex:publishedAt, _:z),
Type(_:z, not(ex:Workshop))
Q4 Mixed ABox/TBox query
Type(?x, ex:Student),
Type(?x, ?c),
SubClassOf(?c, ex:Employee),
Q5 Mixed ABox/RBox query
ObjectProperty(?p),
PropertyValue(ex:John, ?p, ?v)
(Parsia & Sirin, 2007)
SPARQL-DL Supported Query Patterns
Class(a)
Property(a)
Individual(a)
Type(a, b)
PropertyValue(a, b, c)
EquivalentClass(a, b)
SubClassOf(a, b)
EquivalentProperty(a, b)
SubPropertyOf(a, b)
InverseOf(a, b)
ObjectProperty(a)
DataProperty(a)
Functional(a)
InverseFunctional(a)
Transitive(a)
Symmetric(a)
Reflexive(a)
Irreflexive(a)
SameAs(a, b)
DisjointWith(a, b)
DifferentFrom(a, b)
ComplementOf(a, b)
Annotation(a, b, c)
StrictSubClassOf(a, b)
DirectSubClassOf(a, b)
DirectType(a, b)
StrictSubPropertyOf(a, b)
DirectSubPropertyOf(a, b)
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL-DL Syntax
• Query Types: ASK and SELECT
• Supports union-like statements called "OR WHERE“
• Primitives
• Variable: ?[a-zA-Z]+ (for example ?a, ?myVar)
• Full IRI: <http://example.com>
• Prefixed IRI: [the prefix]:[the suffix]
• Literal: "this is a literal" (escape the character " inside a literal with ")
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
SPARQL-DL Query Examples
SELECT ?c WHERE { Class(?c) }
SELECT ?x WHERE {
Transitive(?p),
PropertyValue(<http://example.com#myClass>, ?p, ?x)
}
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?i WHERE {
Type(?i, wine:PinotBlanc)
} OR WHERE {
Type(?i, wine:DryRedWine)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Query Comparison: SPARQL x SPARQL-DL
• SPARQL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine ?region WHERE {
?wine wine:locatedIn ?region
}
• SPARQL-DL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine ?region WHERE {
PropertyValue(?wine, wine:locatedIn, ?region)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Query Comparison: SPARQL x SPARQL-DL
• SPARQL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine ?flavor WHERE {
?wine wine:locatedIn wine:NewZealandRegion .
?wine wine:hasFlavor ?flavor
}
• SPARQL-DL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine ?flavor WHERE {
PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion),
PropertyValue(?wine, wine:hasFlavor, ?flavor)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Query Comparison: SPARQL x SPARQL-DL
• SPARQL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine WHERE {
{
?wine wine:locatedIn wine:NapaRegion
}
UNION
{
?wine wine:locatedIn wine:NewZealandRegion
}
}
• SPARQL-DL
PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine#
SELECT ?wine WHERE {
PropertyValue(?wine, wine:locatedIn, wine:NapaRegion)
} OR WHERE {
PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion )
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Reasoner's Support for DL
Pellet RacerPro FaCT++ HermiT
OWL-DL Support Yes Yes Yes Yes
OWL 2 Support Yes Yes Partially Yes
Supported
expressivity
SROIQ(D) SRIQ(D-) SROIQ(D) SHOIQ+
Reasoning
algorithm
Tableau Tableau Tableau Hypertableau
Rule Support
Yes (SWRL - DL Safe
Rules)
Yes (SWRL - not
fully supported) &
own rule format
No
Yes (SWRL - DL Safe
Rules)
Licensing
Free / open-source
& Non-Free/ closed-
source
Non-Free/ closed-
source
Free / open-source Free / open-source
Adapted from http://en.wikipedia.org/wiki/Semantic_reasoner
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Practice
• Eclipse IDE (Java Project)
http://eclipse.org
• OWL API
http://derivo.de/en/resources/owl-api.html
• SPARQL-DL API
http://derivo.de/en/resources/sparql-dl-api.html
• HermiT OWL Reasoner
http://hermit-reasoner.com
• Wine Ontology
http://krono.act.uji.es/Links/ontologies/wine.owl
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Practice
Queries
• Prefix
PREFIX wine: <http://krono.act.uji.es/Links/ontologies/wine.owl#>
• Query 1
SELECT ?class WHERE {
Class(?class)
}
• Query 2
SELECT ?subClass WHERE {
SubClassOf(?subClass, wine:Wine)
}
• Query 3
SELECT ?wine WHERE {
PropertyValue(?wine, wine:locatedIn, wine:GermanyRegion)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Practice
Queries
• Query 4
SELECT ?wine ?region WHERE {
PropertyValue(?wine, wine:locatedIn, ?region)
}
• Query 5
SELECT ?wine ?region WHERE {
Type(?wine, wine:Wine),
PropertyValue(?wine, wine:locatedIn, ?region)
}
• Query 6
SELECT ?wine ?flavor WHERE {
PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion),
PropertyValue(?wine, wine:hasFlavor, ?flavor)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Practice
Queries
• Query 7 (DISTINCT Keyword)
SELECT DISTINCT ?producer ?wine WHERE {
PropertyValue(?producer, wine:producesWine, ?wine)
}
• Query 8 (OR WHERE Statement)
SELECT ?wine WHERE {
Type(?wine, wine:PinotBlanc)
} OR WHERE {
Type(?wine, wine:DryRedWine)
}
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
Practice
OWL API + SPARQL-DL API + HermiT Reasoner
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
// Ontology
IRI ontIRI = IRI.create("http://krono.act.uji.es/Links/ontologies/wine.owl");
OWLOntologyManager ontManager = OWLManager.createOWLOntologyManager();
OWLOntology ont = ontManager.loadOntologyFromOntologyDocument(ontIRI);
// Reasoners
OWLReasoner rStructural = new StructuralReasonerFactory().createReasoner(ont);
OWLReasoner rHermit = new Reasoner.ReasonerFactory().createReasoner(ont);
// Query
QueryEngine queryEngine = QueryEngine.create(ontManager, rHermit);
Query query = Query.create(query1);
String result = queryEngine.execute(query).toString();
System.out.println(result);
References
• HORROCKS, I.; PEREZ-URBINA, H.; MOTIK, BORIS. Efficient Query Answering for OWL 2. 2009.
• HORROCKS, I.; PATEL-SCHNEIDER, P. F.; MCGUINNESS, D. L.; WELTY, C. A. OWL: a Description Logic
Based Ontology Language for the Semantic Web. 2007.
• HORROCKS, I.; KOLLIA, I.; GLIMM, B. SPARQL Query Answering over OWL Ontologies. 2011.
• KREMEN1, P.; SIRIN, E. SPARQL-DL Implementation Experience. 2008.
• PARSIA, B.; SIRIN, E. SPARQL-DL: SPARQL Query for OWL-DL. 2007.
• GLIMM, B.; KRÖTZSCH, M. SPARQL Beyond Subgraph Matching. 2010.
• GRAU, B. C.; HORROCKS, I.; MOTIK, B.; PARSIA, B.; PATEL-SCHNEIDER, P.; SATTLER, U. OWL 2: The
Next Step for OWL. 2008.
• DOMINGUE, J.; FENSEL, D.; HENDLER, J. A. Handbook of Semantic Web Technologies. 2011.
• ALLEMANG, D.; HENDLER J. A. Semantic Web for the Working Ontologist. 2011.
• ANTONIOU, G.; VAN HARMELEN, F. Semantic Web Primer. 2008.
• HEBELER, J.; FISHER, M.; BLACE, R.; PEREZ-LOPEZ, A.; DEAN, M. Semantic Web Programming. 2009.
SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>

More Related Content

What's hot

온톨로지 추론 개요
온톨로지 추론 개요온톨로지 추론 개요
온톨로지 추론 개요
Sang-Kyun Kim
 
온톨로지 개념 및 표현언어
온톨로지 개념 및 표현언어온톨로지 개념 및 표현언어
온톨로지 개념 및 표현언어
Dongbum Kim
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
Open Data Support
 

What's hot (20)

Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshell
 
ShEx vs SHACL
ShEx vs SHACLShEx vs SHACL
ShEx vs SHACL
 
Rdf In A Nutshell V1
Rdf In A Nutshell V1Rdf In A Nutshell V1
Rdf In A Nutshell V1
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
SHACL by example
SHACL by exampleSHACL by example
SHACL by example
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
온톨로지 추론 개요
온톨로지 추론 개요온톨로지 추론 개요
온톨로지 추론 개요
 
SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)
 
RDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic RepositoriesRDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic Repositories
 
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
 
SHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudSHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data Mud
 
온톨로지 개념 및 표현언어
온톨로지 개념 및 표현언어온톨로지 개념 및 표현언어
온톨로지 개념 및 표현언어
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
 
Inference on the Semantic Web
Inference on the Semantic WebInference on the Semantic Web
Inference on the Semantic Web
 
Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDF
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectives
 
RDFS In A Nutshell V1
RDFS In A Nutshell V1RDFS In A Nutshell V1
RDFS In A Nutshell V1
 
XSLT.ppt
XSLT.pptXSLT.ppt
XSLT.ppt
 

Similar to SPARQL-DL - Theory & Practice

A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic web
Marakana Inc.
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
Emanuele Della Valle
 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)
andyseaborne
 

Similar to SPARQL-DL - Theory & Practice (20)

A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic web
 
balloon Fusion: SPARQL Rewriting Based on Unified Co-Reference Information
balloon Fusion: SPARQL Rewriting Based on  Unified Co-Reference Informationballoon Fusion: SPARQL Rewriting Based on  Unified Co-Reference Information
balloon Fusion: SPARQL Rewriting Based on Unified Co-Reference Information
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)
 
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
 
The Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLThe Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQL
 
SPIN in Five Slides
SPIN in Five SlidesSPIN in Five Slides
SPIN in Five Slides
 
BioSD Tutorial 2014 Editition
BioSD Tutorial 2014 EdititionBioSD Tutorial 2014 Editition
BioSD Tutorial 2014 Editition
 
What;s Coming In SPARQL2?
What;s Coming In SPARQL2?What;s Coming In SPARQL2?
What;s Coming In SPARQL2?
 
Querying Linked Data
Querying Linked DataQuerying Linked Data
Querying Linked Data
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
 
Sparql a simple knowledge query
Sparql  a simple knowledge querySparql  a simple knowledge query
Sparql a simple knowledge query
 
SPARQL 1.1 Status
SPARQL 1.1 StatusSPARQL 1.1 Status
SPARQL 1.1 Status
 
Data Integration And Visualization
Data Integration And VisualizationData Integration And Visualization
Data Integration And Visualization
 
Sparql
SparqlSparql
Sparql
 
Sesam4 project presentation sparql - april 2011
Sesam4   project presentation sparql - april 2011Sesam4   project presentation sparql - april 2011
Sesam4 project presentation sparql - april 2011
 
Sesam4 project presentation sparql - april 2011
Sesam4   project presentation sparql - april 2011Sesam4   project presentation sparql - april 2011
Sesam4 project presentation sparql - april 2011
 
A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic Web
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Querying Linked Data with SPARQL (2010)
Querying Linked Data with SPARQL (2010)Querying Linked Data with SPARQL (2010)
Querying Linked Data with SPARQL (2010)
 

More from Adriel Café

More from Adriel Café (8)

Desenvolvendo aplicativos Android com Kotlin
Desenvolvendo aplicativos Android com KotlinDesenvolvendo aplicativos Android com Kotlin
Desenvolvendo aplicativos Android com Kotlin
 
Uma Arquitetura com Implementação para Integração Semântica de Ontologias e B...
Uma Arquitetura com Implementação para Integração Semântica de Ontologias e B...Uma Arquitetura com Implementação para Integração Semântica de Ontologias e B...
Uma Arquitetura com Implementação para Integração Semântica de Ontologias e B...
 
Desenvolvendo para Android com componentes Open Source
Desenvolvendo para Android com componentes Open SourceDesenvolvendo para Android com componentes Open Source
Desenvolvendo para Android com componentes Open Source
 
Gryphon Framework - Preliminary Results Feb-2014
Gryphon Framework - Preliminary Results Feb-2014Gryphon Framework - Preliminary Results Feb-2014
Gryphon Framework - Preliminary Results Feb-2014
 
Ontology integration - Heterogeneity, Techniques and more
Ontology integration - Heterogeneity, Techniques and moreOntology integration - Heterogeneity, Techniques and more
Ontology integration - Heterogeneity, Techniques and more
 
Mobile Apps Cross-Platform
Mobile Apps Cross-PlatformMobile Apps Cross-Platform
Mobile Apps Cross-Platform
 
FLISOL 2012 - Palestra "Introdução ao Desenvolvimento de Aplicações para o Si...
FLISOL 2012 - Palestra "Introdução ao Desenvolvimento de Aplicações para o Si...FLISOL 2012 - Palestra "Introdução ao Desenvolvimento de Aplicações para o Si...
FLISOL 2012 - Palestra "Introdução ao Desenvolvimento de Aplicações para o Si...
 
2º ETI - Minicurso "Desenvolvendo para Plataforma Android"
2º ETI - Minicurso "Desenvolvendo para Plataforma Android"2º ETI - Minicurso "Desenvolvendo para Plataforma Android"
2º ETI - Minicurso "Desenvolvendo para Plataforma Android"
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

SPARQL-DL - Theory & Practice

  • 1. SPARQL-DL Theory & Practice Adriel Café aac3@cin.ufpe.br
  • 2. Summary 1. OWL Basics 2. SPARQL 3. SPARQL-DL 4. Comparison: SPARQL x SPARQL-DL 5. Reasoner's Support for DL 6. Practice SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 3. Important This document was based on W3C specifications • http://w3.org/2001/sw/wiki/SPARQL-DL • http://w3.org/TR/sparql11-query • http://w3.org/TR/sparql11-overview • http://w3.org/TR/rdf-sparql-query • http://w3.org/TR/owl-guide • http://w3.org/TR/owl-features • http://w3.org/TR/owl-ref • http://w3.org/TR/owl2-overview • http://w3.org/TR/owl2-profiles SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 4. OWL Basics Ontology Web Language • Is an ontology language for the Semantic Web with formally defined meaning • Is a W3C standard since 2004 • Written in XML • Derived from the DAML+OIL • Developed as a vocabulary extension of RDF • Provide classes, properties, individuals, data values and are stored as Semantic Web documents • OWL Tools • OWL Syntax Converter (http://owl.cs.manchester.ac.uk/converter) • OWL Validator (http://owl.cs.manchester.ac.uk/validator) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 5. OWL 1 • Compatible with RDF • Profiles • OWL Full (Not DL) • OWL DL (DL SHOIN(D)) • OWL Lite (DL SHIF(D)) OWL Versions OWL 2 • Compatible with OWL 1 and RDF • Profiles • OWL 2 EL (DL EL++) • OWL 2 QL (DL-Lite) • OWL 2 RL (DLP) • OWL 2 DL (DL SROIQ(D)) Is used informally to refer to ontologies interpreted using the Direct Semantics http://w3.org/TR/owl2-direct-semantics SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 6. OWL 2 Structure http://w3.org/TR/owl2-overview/OWL2-structure2-800.png SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 7. SPARQL SPARQL Protocol and RDF Query Language • Is a SQL-Like language for querying RDF data • Is a protocol • Is a W3C standard since 2008 • Queries consist of triple patterns, conjunctions, disjunctions, and optional patterns "SPARQL will make a huge difference“ (Berners-Lee, 2006) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 8. SPARQL in Semantic Web Stack http://upload.wikimedia.org/wikipedia/en/3/37/Semantic-web-stack.png SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 9. SPARQL Query Types • SELECT Returns all, or a subset of, the variables bound in a query pattern match. • ASK Returns a boolean indicating whether a query pattern matches or not. • 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. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 10. PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://xmlns.com/foaf/spec/index.rdf> WHERE { ?x foaf:name ?name } ORDER BY ?name LIMIT 5 OFFSET 10 Anatomy of a SPARQL Query Triple patterns to be localized Subject, Predicate and Object Prefix label associated with an IRI Returns all possible bindings of the provided variables DISTINCT keyword removes all redundant bindings Data sources that should be consulted Solution sequences and modifiers SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 11. RDF Definitions • RDF Triple Contains three components: subject, predicate and object <http://com.ex/people#adrielcafe> <http://com.ex/contact#name> “Adriel Café" • RDF Graph Is a set of RDF triples • Triple Pattern Is like an RDF triple, but with the option of a variable in place of RDF terms (i.e., IRIs, literals or blank nodes) in the subject, predicate or object positions ?people <http://com.ex/contact#name> ?name • Basic Graph Pattern (BGP) Is a conjunction of a finite set of triple patterns SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 12. SPARQL Subgraph Matching • The SPARQL query processor will search for sets of triples that match these triple patterns, binding the variables in the query to the corresponding parts of each triple. • Subgraph matching (a.k.a. simple entailment) considers only the graph structure of RDF for computing query results • Entailment Regimes RDFS Entailment Regime, D-Entailment Regime, OWL 2 RDF-Based Semantics, OWL 2 Direct Semantics “The main mechanism for computing query results in SPARQL is subgraph matching: RDF triples in both the queried RDF data and the query pattern are interpreted as nodes and edges of directed graphs, and the resulting query graph is matched to the data graph using variables as wild cards.” (Glimm; Krötzsch, 2010) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 13. SPARQL-DL SPARQL Protocol and RDF Query Language – Description Logics • Is a distinct subset of SPARQL • Uses SPARQL syntax • Is tailored to ontology specific questions • Is not yet a W3C standard • Quite expressive language which allows to mix TBox, RBox, and ABox queries • Fully aligned with the OWL 2 standard • Settled on top of the OWL API SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> http://www.derivo.de/uploads/pics/SPARQL-DL_01.png
  • 14. SPARQL-DL Abstract Syntax • A SPARQL-DL query Q is a finite set of SPARQL-DL query atoms and the query is interpreted as the conjunction of the elements in the set. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> Query Type of the query An example query Q1 Standard TBox query SubClassOf(?c, ex:Student) Q2 Standard ABox query Type(?x, and(ex:Student, ex:Employee)), PropertyValue(?x, ex:name, ?y) Q3 ABox query with non- distinguished variables PropertyValue(?x, ex:hasPublication, _:y), PropertyValue(:y, ex:publishedAt, _:z), Type(_:z, not(ex:Workshop)) Q4 Mixed ABox/TBox query Type(?x, ex:Student), Type(?x, ?c), SubClassOf(?c, ex:Employee), Q5 Mixed ABox/RBox query ObjectProperty(?p), PropertyValue(ex:John, ?p, ?v) (Parsia & Sirin, 2007)
  • 15. SPARQL-DL Supported Query Patterns Class(a) Property(a) Individual(a) Type(a, b) PropertyValue(a, b, c) EquivalentClass(a, b) SubClassOf(a, b) EquivalentProperty(a, b) SubPropertyOf(a, b) InverseOf(a, b) ObjectProperty(a) DataProperty(a) Functional(a) InverseFunctional(a) Transitive(a) Symmetric(a) Reflexive(a) Irreflexive(a) SameAs(a, b) DisjointWith(a, b) DifferentFrom(a, b) ComplementOf(a, b) Annotation(a, b, c) StrictSubClassOf(a, b) DirectSubClassOf(a, b) DirectType(a, b) StrictSubPropertyOf(a, b) DirectSubPropertyOf(a, b) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 16. SPARQL-DL Syntax • Query Types: ASK and SELECT • Supports union-like statements called "OR WHERE“ • Primitives • Variable: ?[a-zA-Z]+ (for example ?a, ?myVar) • Full IRI: <http://example.com> • Prefixed IRI: [the prefix]:[the suffix] • Literal: "this is a literal" (escape the character " inside a literal with ") SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 17. SPARQL-DL Query Examples SELECT ?c WHERE { Class(?c) } SELECT ?x WHERE { Transitive(?p), PropertyValue(<http://example.com#myClass>, ?p, ?x) } PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?i WHERE { Type(?i, wine:PinotBlanc) } OR WHERE { Type(?i, wine:DryRedWine) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 18. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?region WHERE { ?wine wine:locatedIn ?region } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?region WHERE { PropertyValue(?wine, wine:locatedIn, ?region) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 19. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?flavor WHERE { ?wine wine:locatedIn wine:NewZealandRegion . ?wine wine:hasFlavor ?flavor } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?flavor WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion), PropertyValue(?wine, wine:hasFlavor, ?flavor) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 20. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine WHERE { { ?wine wine:locatedIn wine:NapaRegion } UNION { ?wine wine:locatedIn wine:NewZealandRegion } } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine WHERE { PropertyValue(?wine, wine:locatedIn, wine:NapaRegion) } OR WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion ) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 21. Reasoner's Support for DL Pellet RacerPro FaCT++ HermiT OWL-DL Support Yes Yes Yes Yes OWL 2 Support Yes Yes Partially Yes Supported expressivity SROIQ(D) SRIQ(D-) SROIQ(D) SHOIQ+ Reasoning algorithm Tableau Tableau Tableau Hypertableau Rule Support Yes (SWRL - DL Safe Rules) Yes (SWRL - not fully supported) & own rule format No Yes (SWRL - DL Safe Rules) Licensing Free / open-source & Non-Free/ closed- source Non-Free/ closed- source Free / open-source Free / open-source Adapted from http://en.wikipedia.org/wiki/Semantic_reasoner SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 22. Practice • Eclipse IDE (Java Project) http://eclipse.org • OWL API http://derivo.de/en/resources/owl-api.html • SPARQL-DL API http://derivo.de/en/resources/sparql-dl-api.html • HermiT OWL Reasoner http://hermit-reasoner.com • Wine Ontology http://krono.act.uji.es/Links/ontologies/wine.owl SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 23. Practice Queries • Prefix PREFIX wine: <http://krono.act.uji.es/Links/ontologies/wine.owl#> • Query 1 SELECT ?class WHERE { Class(?class) } • Query 2 SELECT ?subClass WHERE { SubClassOf(?subClass, wine:Wine) } • Query 3 SELECT ?wine WHERE { PropertyValue(?wine, wine:locatedIn, wine:GermanyRegion) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 24. Practice Queries • Query 4 SELECT ?wine ?region WHERE { PropertyValue(?wine, wine:locatedIn, ?region) } • Query 5 SELECT ?wine ?region WHERE { Type(?wine, wine:Wine), PropertyValue(?wine, wine:locatedIn, ?region) } • Query 6 SELECT ?wine ?flavor WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion), PropertyValue(?wine, wine:hasFlavor, ?flavor) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 25. Practice Queries • Query 7 (DISTINCT Keyword) SELECT DISTINCT ?producer ?wine WHERE { PropertyValue(?producer, wine:producesWine, ?wine) } • Query 8 (OR WHERE Statement) SELECT ?wine WHERE { Type(?wine, wine:PinotBlanc) } OR WHERE { Type(?wine, wine:DryRedWine) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 26. Practice OWL API + SPARQL-DL API + HermiT Reasoner SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> // Ontology IRI ontIRI = IRI.create("http://krono.act.uji.es/Links/ontologies/wine.owl"); OWLOntologyManager ontManager = OWLManager.createOWLOntologyManager(); OWLOntology ont = ontManager.loadOntologyFromOntologyDocument(ontIRI); // Reasoners OWLReasoner rStructural = new StructuralReasonerFactory().createReasoner(ont); OWLReasoner rHermit = new Reasoner.ReasonerFactory().createReasoner(ont); // Query QueryEngine queryEngine = QueryEngine.create(ontManager, rHermit); Query query = Query.create(query1); String result = queryEngine.execute(query).toString(); System.out.println(result);
  • 27. References • HORROCKS, I.; PEREZ-URBINA, H.; MOTIK, BORIS. Efficient Query Answering for OWL 2. 2009. • HORROCKS, I.; PATEL-SCHNEIDER, P. F.; MCGUINNESS, D. L.; WELTY, C. A. OWL: a Description Logic Based Ontology Language for the Semantic Web. 2007. • HORROCKS, I.; KOLLIA, I.; GLIMM, B. SPARQL Query Answering over OWL Ontologies. 2011. • KREMEN1, P.; SIRIN, E. SPARQL-DL Implementation Experience. 2008. • PARSIA, B.; SIRIN, E. SPARQL-DL: SPARQL Query for OWL-DL. 2007. • GLIMM, B.; KRÖTZSCH, M. SPARQL Beyond Subgraph Matching. 2010. • GRAU, B. C.; HORROCKS, I.; MOTIK, B.; PARSIA, B.; PATEL-SCHNEIDER, P.; SATTLER, U. OWL 2: The Next Step for OWL. 2008. • DOMINGUE, J.; FENSEL, D.; HENDLER, J. A. Handbook of Semantic Web Technologies. 2011. • ALLEMANG, D.; HENDLER J. A. Semantic Web for the Working Ontologist. 2011. • ANTONIOU, G.; VAN HARMELEN, F. Semantic Web Primer. 2008. • HEBELER, J.; FISHER, M.; BLACE, R.; PEREZ-LOPEZ, A.; DEAN, M. Semantic Web Programming. 2009. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>