SlideShare a Scribd company logo
Processing OWL2 ontologies using Thea: An application of logic programmingMarch 2010Vangelis Vassiliadissemanticweb.gr1
Contents - OutlineWhy – MotivationContext: Semantic Web  Applications  ToolsOWL Tool survey – What we do with themModel, I/O (Parser / Serialisation), Query, Manipulate, Reasoning (Inference)What – can we do with TheaUse of Prolog as an application programming language (host language), rather than as an OWL reasoning engineGet OWL ontologies (ABOX + TBOx) in a prolog program.Use them: Query – Reason Script operationsBuild applicationsHow – ImplementationApplication examples - potential2
Motivation3Original 2000 stack2008 stack
OWL Tools4
Tool functionality5
Why Prolog?Fact database (Store)Thea uses Prolog as a host programming language, not as a reasoning system, butCan also be used as a Rule-based system. (Reason)SLD resolution, backward chaining.Declarative features, pattern matching (Query)Scripting language – (Manipulation)SWI-Prolog implementation, Semweb package, efficient RDF library (Parse – Serialize) (Load, Save)Http servers Own experience6
Thea projectProlog library, organized in modules.Depends heavily on SWI-prolog libraries RDF/XML parsing, serializations, http-clientDevelopment HistoryStarted 2004Version 0.5.5 (final for OWL1) in 2006 / SourceForgeMajor redesign for OWL2 in 2009 (presented in OWLED 2009) / GithubCirca 2000 downloads.OWL2 axioms as Prolog facts based on the OWL functional syntax.Extensions / libraries to support:java OWL APISWRLtranslation to DLPRL Reasoning (Forward and backward chaining)OWLLink – act as an OWLLink client.Small set of applications / demos Minimum documentation7
Library organisation8
OWL Functional-Style Syntax and Structural SpecificationOntology as a set of AxiomsAxiom := Declaration | ClassAxiom | ObjectPropertyAxiom | DataPropertyAxiom | HasKey | Assertion | AnnotationAxiomDeclaration := 'Declaration' '(' axiomAnnotations Entity ')‘Entity := 'Class' '(' Class ')' | 'Datatype' '(' Datatype ')' | 'ObjectProperty' '('  ObjectProperty ')' | 'DataProperty' '(' DataProperty ')' | 'AnnotationProperty' '(' AnnotationProperty ')' | 'NamedIndividual' '(' NamedIndividual ')‘ClassAxiom := SubClassOf | EquivalentClasses | DisjointClasses | DisjointUnionSubClassOf := 'SubClassOf' '(' axiomAnnotationssubClassExpressionsuperClassExpression ')‘ClassExpression := Class | ObjectIntersectionOf …ObjectIntersectionOf := 'IntersectionOf' '(' ClassExpressionClassExpression { ClassExpression } ')'9SubClassOf(’http://example.org#Human’ ’http://example.org#Mammal’).EquivalentClasses(forebrain_neuron IntersectionOf(neuronSomeValuesFrom(partOf forebrain)))
Thea model implementationAxioms  Extensional Prolog predicates / facts subClassOf(’http://example.org#Human’,’http://example.org#Mammal’).equivalentClasses([forebrain_neuron,                    intersectionOf([neuron, someValuesFrom(partof,forebrain)                                  ])                  ]).Expressions defined as Prolog termsLists for variable number arguments More programmatic convenience predicates (Intentional)axiom(A) :- classAxiom(A).axiom(A) :- propertyAxiom(A).…property(A) :- dataProperty(A).property(A) :- objectProperty(A).property(A) :- annotationProperty(A).ontologyAxiom(Ontology, Axiom)  (Extensional)relates Axioms to specific OntologyAnnotations not as axiom arguments but as separate facts: annotation(Axiom, AnnotationProperty, AnnotationValue)  (Extensional)10
Thea OWL Parser - Serializer11
Thea OWL Parser - Serializer12Parse: 	owl_parse_rdf(+URI,+Opts:list), owl_parse_xml(File,_Opts),        owl_parse_manchester_syntax_file(File,_Opts)options for imports, clear rdf graph, clear axioms owl_repository(URI, LocalURI)Implements  owl2_io:load_axioms_hook(File,[owl|mansyn|owlx],Opts)Serialise:	owl_generate_rdf(+FileName,+RDF_Load_Mode)Save Axioms as Prolog facts Load Axioms from Prolog files (consult).Possible extensions:Save and Load to/from external ‘OWL-aware’ databases: e.g. OWLgress
Query OWL ontologies13Simply use Prolog’s declarative pattern matching and symbol manipulation:Tbox:- class(X).:- subClassOf(X,Y).:- class(X), equivalentClasses(Set), select(X,Set,Equivalents).:- propertyDomain(Property,Domain).:- findall(X, subClassOf(Y,X),Superclasses).subclass(X,X).subclass(X,Y) :-	owl2_model:subClassOf(X,Z),subclass(Y,Z). (!cyclic graphs)Abox:- classAssertion(C,I).:- propertyAssertion(P,I,V).:- findall(I, classAssertion(C,I),Individuals).:- class(C),aggregate(count,I,classAssertion(C,I),Num).…
Manipulate OWL ontologies14Programmatic processing or scripting of ontologies for tasks that would be tedious and repetitive to do by hand:Enforce disjointUnion with exceptionssetof(X,(subClassOf(X,Y),		\+ annotationAssertion(status,X,unvetted)),     Xs),assert_axiom(disjointUnion(Y,Xs))Populate Abox: generate Axioms from external data: read(Stream, PVTerm), PVTerm :=.. [C,I|PVs],assert_axiom(classAssertion(C,I),forall(member(P-V,PVs), assert_axiom(propertyAssertion(P,I,V)),fail.Assumes Stream contains terms of the form: Class(IndividualID, Property1-Value1, …, PropertyN-ValueN).
Reasoning with OWL 15What is Inference?Broadly speaking, inference on the Semantic Web can be characterized by discovering new relationships. On the Semantic Web, data is modeled as a set of (named) relationships between resources. “Inference” means that automatic procedures can generate new relationships based on the data and based on some additional information in the form of a vocabulary, e.g., a set of rules. Whether the new relationships are explicitly added to the set of data, or are returned at query time, is an implementation issue.From (www.w3c.org) SW activityOWL ReasoningConsistency checkingHierarchy classification Individual classificationOWL (DL) vs.  Logic Programming theoretical issues Tableaux algorithms (satisfiability checking).Open world vs. Closed world assumptionNegation as Failure and MonotonicityUnique Name Assumption
Thea Reasoning options16
OWLAPI via jpl17JPL is a SWI library to use java from within SWI prolog:Jpl_new(+Class,  +Args, -Value)Jpl_call(+Class, +Method, +Args, -RetunrValue)Examplesusing OWLAPI to save files owl_parse_rdf('testfiles/Hydrology.owl'), % parse using prolog/theacreate_factory(Man,Fac),build_ontology(Man,Fac,Ont),save_ontology(Man,Ont,'file:///tmp/foo'). % save using owlapiUsing external pellet reasonercreate_reasoner(Man,pellet,Reasoner),create_factory(Man,Fac),build_ontology(Man,Fac,Ont),reasoner_classify(Reasoner,Man,Ont),save_ontology(Man,Ont,'file:///tmp/foo').writeln(classifying), reasoner_classify(Reasoner,Man,Ont), writeln(classified),class(C), writeln(c=C),reasoner_subClassOf(Reasoner,Fac,C,P), writeln(p=P).
OWL Link support18Client ApplicationOWL ReasonerRequestResponseXML based Interface based on OWL2 / XML* Successor to DIG, Tell* and Ask requests.Results translated to AxiomsExample:% owl_link(+ReasonerURL, +Request:list, -Response:list, +Options:list)…   tell('http://owllink.org/examples/KB_1',	    [subClassOf('B','A'), subClassOf('C','A'),	     equivalentClasses(['D','E']),	     classAssertion('A','iA'), subClassOf('C','A') ]),getAllClasses('http://owllink.org/examples/KB_1'),getEquivalentClasses('http://owllink.org/examples/KB_1','D'),setOfClasses([], [owl:Thing, C, B, E, A, D]), setOfClasses([], [E, D]),
Description Logic Programs19Grossof and Horrocs, define mapping rules between DL and LPExample  An ontology which contains the axioms:	subClassOf(cat, mammal).  	classAssertion(cat, mr_whiskers).  	inverseProperties(likes,liked_by).will be converted to a program such as:	mammal(X) :- cat(X).  	cat(mr_whiskers).	likes(X,Y) :- liked_by(Y,X).  	liked_by(X,Y) :- likes(Y,X).
Thea RL rule reasoning20RL Profile, RL/RDF rules:Scalable reasoning, trade full expressivity of the language for efficiency.Syntactic subset of OWL 2 which is amenable to implementation using rule-based technologies partial axiomatization of the OWL 2 RDF-Based Semantics in the form of first-order implications inspired by Description Logic ProgramsImplementationDeclarative rule definition (entailments): entails(Rule, AntecedentList, ConsequenttList) entails(prp-dom, [propertyDomain(P,C),propertyAssertion(P,X,_)],[classAssertion(C,X)]).entails(prp-rng, [propertyRange(P,C),propertyAssertion(P,_,Y)],[classAssertion(C,Y)]).Forward Chaining, Crude  non-optimized, Repeat cycle until nothing has been entailedforall((entails(Rule,Antecedants,Consequents),	     hold(Antecedants),member(Consequent,Consequents)),       assert_u(entailed(Consequent,Rule,Antecedants)).Backward Chaining %%	is_entailed(+Axiom,-Explanation) is nondet%	Axiom is entailed if either holds or is a consequent in an%	entails/3 rule and all the antecedants are entailed.Simulates tabling: If an Axiom has been entailed it is not tried again to revents endless loops for e.g.  s :- s, t.
SWRL implementation21Semantic Web Rules.To extend the set of OWL axioms to include Horn-like rules. It thus enables Horn-like rules to be combined with an OWL knowledge base. 	From (SWRL  submission spec)Thea implementationImplies/2 fact to hold rules: implies(?Antecedent:list(swrlAtom), ?Consequent:list(swrlAtom))Convert a prolog clause to SWRL ruleConvert an SWRL rule to OWL axioms?- prolog_clause_to_swrl_rule((hasUncle(X1,X3):-   hasParent(X1,X2),hasBrother(X2,X3)),SWRL),swrl_to_owl_axioms(SWRL,Axiom).X1 = v(1), X3 = v(2), X2 = v(3),SWRL = implies(['_d:hasParent'(v(1), v(3)), '_d:hasBrother'(v(3), v(2))], '_d:hasUncle'(v(1), v(2))),Axiom = [subPropertyOf(propertyChain(['_d:hasParent', '_d:hasBrother']), '_d:hasUncle')].
Comparison with other systemsSPARQLNo means of updating dataToo RDF-centric for querying complex TboxesLack of ability to name queries (as in relational views)Lack of aggregate queriesLack of programmabilityBut … extensions (SPARQL update)OPPL (DSL):Simple, SQL – likeIn Protégé…Thea offers a complete programming language.22
Comparison with OWLAPIOWLAPI: Full featured.Mature.Java API (OO language)Thea: declarative.offers bridge via JPL.easy scripting23Memory usageLoad time (secs)
Applications	OBO label generation (Bioinformatics)eLevator  (Product configuration)Open Calais (Semantic Web)Linked data (Semantic Web)24
ConsumersCustomersConfigurationEngine ServiceeLevatorCustomer PortalCustomer eServicesFinancial dataOrder statusOrder e-guideEnterprise SystemPLM, CRM, ERPAccounting…OrderEntryElevator Cabin configuration Modeling and VisualizationEnterpriseInternet25ASP / SaaS
Configuration Ontology26PartonomyTaxonomy
www.designyourlift.com27
Bioinformatics label generation28Challenges in OBO: maintaining consistent class labels that conform to community norms.
OWL + Prolog Definite Clause Grammars (DCGs)  to auto-generate labels or suggestions for labels. Example
OWL Class:	 length and qualityOf some (axon and partOf some pyramidal_neuron)
Derive label length of pyramidal neuron axon.
DCGterm(T) --> qual_expr(T) ; anat_expr(T).qual_expr(Q and qualityOf some A) --> qual(Q),[of],anat_expr(A).anat_expr(P and partOf some W) --> anat(W),anat_expr(P).anat_expr(A) --> anat(A).anat(A) --> {entailed(subClassOf(A,anatomical_entity)),            labelAnnotation_value(A,Label)}, [Label].qual(Q) --> {entailed(subClassOf(Q,quality)),            labelAnnotation_value(Q,Label)}, [Label].Non-determinisim of prolog to generate multiple values.
Useful for automatically generating labels to be  indexed for text search.
The same grammars used to parse controlled natural language expressions.Open Calais 29Web Service by Thomson Reuters. Analyses content (from URLs, or POSTed text) using NLP and semantic techniquesREST interface.Prolog Thea wrapperAccess service from within PrologAccess and process Calais ontology (Tbox) and returned entities (Abox) with TheaOpen CalaisServiceThea Open Calais clientLoad and Parse Ontology (OWL file)Post Content  (File, text or URL)RDF responseMarkup Elements(Entities, Relationships) and Metadata

More Related Content

ODP
Intro to The PHP SPL
PPTX
SPL: The Undiscovered Library - DataStructures
PDF
New SPL Features in PHP 5.3
PPTX
Bioinformatics p5-bioperl v2013-wim_vancriekinge
KEY
Spl Not A Bridge Too Far phpNW09
PPTX
Bioinformatica p6-bioperl
KEY
Metaprogramming in Haskell
KEY
Invertible-syntax 入門
Intro to The PHP SPL
SPL: The Undiscovered Library - DataStructures
New SPL Features in PHP 5.3
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Spl Not A Bridge Too Far phpNW09
Bioinformatica p6-bioperl
Metaprogramming in Haskell
Invertible-syntax 入門

What's hot (19)

PDF
PHP Language Trivia
PDF
PHP 7 – What changed internally? (Forum PHP 2015)
PDF
Introduction to Scala for Java Developers
ODP
JavaScript Web Development
PDF
Scala introduction
PDF
Google guava overview
PDF
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PDF
DBIx::Class introduction - 2010
PPTX
PHP Functions & Arrays
PDF
DBIx::Class beginners
PPTX
Practically Functional
PDF
PHP 7 – What changed internally?
PDF
PHP Unit 4 arrays
PPTX
Proposals for new function in Java SE 9 and beyond
PDF
Scripting3
KEY
(Parameterized) Roles
PPT
rtwerewr
PHP Language Trivia
PHP 7 – What changed internally? (Forum PHP 2015)
Introduction to Scala for Java Developers
JavaScript Web Development
Scala introduction
Google guava overview
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
DBIx::Class introduction - 2010
PHP Functions & Arrays
DBIx::Class beginners
Practically Functional
PHP 7 – What changed internally?
PHP Unit 4 arrays
Proposals for new function in Java SE 9 and beyond
Scripting3
(Parameterized) Roles
rtwerewr
Ad

Similar to Thea: Processing OWL Ontologies - An application of logic programming (20)

PPTX
BT02.pptx
PPT
Representing and Reasoning with Modular Ontologies (2007)
PDF
OWL 2 Overview
PDF
cade23-schneidsut-atp4owlfull-2011
PDF
Sw owl rules-proposal
PPT
Package-based Description Logics – Preliminary Results
PPT
A Distributed Tableau Algorithm for Package-based Description Logics
PPT
OWL briefing
PPT
Establishing a Bridge from Graph-based Modeling Languages to Ontology Languages
PDF
PAGOdA paper
PDF
POSH: The Prolog OWL Shell
PPTX
Relational Patterns in OWL and their application to OBO
PDF
The Rise of Approximate Ontology Reasoning: Is It Mainstream Yet? --- Revisit...
PPT
Representing and Reasoning with Modular Ontologies
PPTX
Semantic Modelling using Semantic Web Technology
PDF
INFERENCE BASED INTERPRETATION OF KEYWORD QUERIES FOR OWL ONTOLOGY
PPT
A Semantic Importing Approach to Knowledge Reuse from Multiple Ontologies
PDF
Challenge@RuleML2015 Datalog+, RuleML and OWL 2 - Formats and Translations f...
PPT
Modular Ontologies: the Package-based Description Logics Approach
PPT
Divide and Conquer Semantic Web with Modular
BT02.pptx
Representing and Reasoning with Modular Ontologies (2007)
OWL 2 Overview
cade23-schneidsut-atp4owlfull-2011
Sw owl rules-proposal
Package-based Description Logics – Preliminary Results
A Distributed Tableau Algorithm for Package-based Description Logics
OWL briefing
Establishing a Bridge from Graph-based Modeling Languages to Ontology Languages
PAGOdA paper
POSH: The Prolog OWL Shell
Relational Patterns in OWL and their application to OBO
The Rise of Approximate Ontology Reasoning: Is It Mainstream Yet? --- Revisit...
Representing and Reasoning with Modular Ontologies
Semantic Modelling using Semantic Web Technology
INFERENCE BASED INTERPRETATION OF KEYWORD QUERIES FOR OWL ONTOLOGY
A Semantic Importing Approach to Knowledge Reuse from Multiple Ontologies
Challenge@RuleML2015 Datalog+, RuleML and OWL 2 - Formats and Translations f...
Modular Ontologies: the Package-based Description Logics Approach
Divide and Conquer Semantic Web with Modular
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
cuic standard and advanced reporting.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
Empathic Computing: Creating Shared Understanding
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
cuic standard and advanced reporting.pdf
Big Data Technologies - Introduction.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25-Week II
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx

Thea: Processing OWL Ontologies - An application of logic programming

  • 1. Processing OWL2 ontologies using Thea: An application of logic programmingMarch 2010Vangelis Vassiliadissemanticweb.gr1
  • 2. Contents - OutlineWhy – MotivationContext: Semantic Web  Applications  ToolsOWL Tool survey – What we do with themModel, I/O (Parser / Serialisation), Query, Manipulate, Reasoning (Inference)What – can we do with TheaUse of Prolog as an application programming language (host language), rather than as an OWL reasoning engineGet OWL ontologies (ABOX + TBOx) in a prolog program.Use them: Query – Reason Script operationsBuild applicationsHow – ImplementationApplication examples - potential2
  • 6. Why Prolog?Fact database (Store)Thea uses Prolog as a host programming language, not as a reasoning system, butCan also be used as a Rule-based system. (Reason)SLD resolution, backward chaining.Declarative features, pattern matching (Query)Scripting language – (Manipulation)SWI-Prolog implementation, Semweb package, efficient RDF library (Parse – Serialize) (Load, Save)Http servers Own experience6
  • 7. Thea projectProlog library, organized in modules.Depends heavily on SWI-prolog libraries RDF/XML parsing, serializations, http-clientDevelopment HistoryStarted 2004Version 0.5.5 (final for OWL1) in 2006 / SourceForgeMajor redesign for OWL2 in 2009 (presented in OWLED 2009) / GithubCirca 2000 downloads.OWL2 axioms as Prolog facts based on the OWL functional syntax.Extensions / libraries to support:java OWL APISWRLtranslation to DLPRL Reasoning (Forward and backward chaining)OWLLink – act as an OWLLink client.Small set of applications / demos Minimum documentation7
  • 9. OWL Functional-Style Syntax and Structural SpecificationOntology as a set of AxiomsAxiom := Declaration | ClassAxiom | ObjectPropertyAxiom | DataPropertyAxiom | HasKey | Assertion | AnnotationAxiomDeclaration := 'Declaration' '(' axiomAnnotations Entity ')‘Entity := 'Class' '(' Class ')' | 'Datatype' '(' Datatype ')' | 'ObjectProperty' '(' ObjectProperty ')' | 'DataProperty' '(' DataProperty ')' | 'AnnotationProperty' '(' AnnotationProperty ')' | 'NamedIndividual' '(' NamedIndividual ')‘ClassAxiom := SubClassOf | EquivalentClasses | DisjointClasses | DisjointUnionSubClassOf := 'SubClassOf' '(' axiomAnnotationssubClassExpressionsuperClassExpression ')‘ClassExpression := Class | ObjectIntersectionOf …ObjectIntersectionOf := 'IntersectionOf' '(' ClassExpressionClassExpression { ClassExpression } ')'9SubClassOf(’http://example.org#Human’ ’http://example.org#Mammal’).EquivalentClasses(forebrain_neuron IntersectionOf(neuronSomeValuesFrom(partOf forebrain)))
  • 10. Thea model implementationAxioms  Extensional Prolog predicates / facts subClassOf(’http://example.org#Human’,’http://example.org#Mammal’).equivalentClasses([forebrain_neuron, intersectionOf([neuron, someValuesFrom(partof,forebrain) ]) ]).Expressions defined as Prolog termsLists for variable number arguments More programmatic convenience predicates (Intentional)axiom(A) :- classAxiom(A).axiom(A) :- propertyAxiom(A).…property(A) :- dataProperty(A).property(A) :- objectProperty(A).property(A) :- annotationProperty(A).ontologyAxiom(Ontology, Axiom) (Extensional)relates Axioms to specific OntologyAnnotations not as axiom arguments but as separate facts: annotation(Axiom, AnnotationProperty, AnnotationValue) (Extensional)10
  • 11. Thea OWL Parser - Serializer11
  • 12. Thea OWL Parser - Serializer12Parse: owl_parse_rdf(+URI,+Opts:list), owl_parse_xml(File,_Opts), owl_parse_manchester_syntax_file(File,_Opts)options for imports, clear rdf graph, clear axioms owl_repository(URI, LocalURI)Implements owl2_io:load_axioms_hook(File,[owl|mansyn|owlx],Opts)Serialise: owl_generate_rdf(+FileName,+RDF_Load_Mode)Save Axioms as Prolog facts Load Axioms from Prolog files (consult).Possible extensions:Save and Load to/from external ‘OWL-aware’ databases: e.g. OWLgress
  • 13. Query OWL ontologies13Simply use Prolog’s declarative pattern matching and symbol manipulation:Tbox:- class(X).:- subClassOf(X,Y).:- class(X), equivalentClasses(Set), select(X,Set,Equivalents).:- propertyDomain(Property,Domain).:- findall(X, subClassOf(Y,X),Superclasses).subclass(X,X).subclass(X,Y) :- owl2_model:subClassOf(X,Z),subclass(Y,Z). (!cyclic graphs)Abox:- classAssertion(C,I).:- propertyAssertion(P,I,V).:- findall(I, classAssertion(C,I),Individuals).:- class(C),aggregate(count,I,classAssertion(C,I),Num).…
  • 14. Manipulate OWL ontologies14Programmatic processing or scripting of ontologies for tasks that would be tedious and repetitive to do by hand:Enforce disjointUnion with exceptionssetof(X,(subClassOf(X,Y), \+ annotationAssertion(status,X,unvetted)), Xs),assert_axiom(disjointUnion(Y,Xs))Populate Abox: generate Axioms from external data: read(Stream, PVTerm), PVTerm :=.. [C,I|PVs],assert_axiom(classAssertion(C,I),forall(member(P-V,PVs), assert_axiom(propertyAssertion(P,I,V)),fail.Assumes Stream contains terms of the form: Class(IndividualID, Property1-Value1, …, PropertyN-ValueN).
  • 15. Reasoning with OWL 15What is Inference?Broadly speaking, inference on the Semantic Web can be characterized by discovering new relationships. On the Semantic Web, data is modeled as a set of (named) relationships between resources. “Inference” means that automatic procedures can generate new relationships based on the data and based on some additional information in the form of a vocabulary, e.g., a set of rules. Whether the new relationships are explicitly added to the set of data, or are returned at query time, is an implementation issue.From (www.w3c.org) SW activityOWL ReasoningConsistency checkingHierarchy classification Individual classificationOWL (DL) vs. Logic Programming theoretical issues Tableaux algorithms (satisfiability checking).Open world vs. Closed world assumptionNegation as Failure and MonotonicityUnique Name Assumption
  • 17. OWLAPI via jpl17JPL is a SWI library to use java from within SWI prolog:Jpl_new(+Class, +Args, -Value)Jpl_call(+Class, +Method, +Args, -RetunrValue)Examplesusing OWLAPI to save files owl_parse_rdf('testfiles/Hydrology.owl'), % parse using prolog/theacreate_factory(Man,Fac),build_ontology(Man,Fac,Ont),save_ontology(Man,Ont,'file:///tmp/foo'). % save using owlapiUsing external pellet reasonercreate_reasoner(Man,pellet,Reasoner),create_factory(Man,Fac),build_ontology(Man,Fac,Ont),reasoner_classify(Reasoner,Man,Ont),save_ontology(Man,Ont,'file:///tmp/foo').writeln(classifying), reasoner_classify(Reasoner,Man,Ont), writeln(classified),class(C), writeln(c=C),reasoner_subClassOf(Reasoner,Fac,C,P), writeln(p=P).
  • 18. OWL Link support18Client ApplicationOWL ReasonerRequestResponseXML based Interface based on OWL2 / XML* Successor to DIG, Tell* and Ask requests.Results translated to AxiomsExample:% owl_link(+ReasonerURL, +Request:list, -Response:list, +Options:list)… tell('http://owllink.org/examples/KB_1', [subClassOf('B','A'), subClassOf('C','A'), equivalentClasses(['D','E']), classAssertion('A','iA'), subClassOf('C','A') ]),getAllClasses('http://owllink.org/examples/KB_1'),getEquivalentClasses('http://owllink.org/examples/KB_1','D'),setOfClasses([], [owl:Thing, C, B, E, A, D]), setOfClasses([], [E, D]),
  • 19. Description Logic Programs19Grossof and Horrocs, define mapping rules between DL and LPExample An ontology which contains the axioms: subClassOf(cat, mammal). classAssertion(cat, mr_whiskers). inverseProperties(likes,liked_by).will be converted to a program such as: mammal(X) :- cat(X). cat(mr_whiskers). likes(X,Y) :- liked_by(Y,X). liked_by(X,Y) :- likes(Y,X).
  • 20. Thea RL rule reasoning20RL Profile, RL/RDF rules:Scalable reasoning, trade full expressivity of the language for efficiency.Syntactic subset of OWL 2 which is amenable to implementation using rule-based technologies partial axiomatization of the OWL 2 RDF-Based Semantics in the form of first-order implications inspired by Description Logic ProgramsImplementationDeclarative rule definition (entailments): entails(Rule, AntecedentList, ConsequenttList) entails(prp-dom, [propertyDomain(P,C),propertyAssertion(P,X,_)],[classAssertion(C,X)]).entails(prp-rng, [propertyRange(P,C),propertyAssertion(P,_,Y)],[classAssertion(C,Y)]).Forward Chaining, Crude non-optimized, Repeat cycle until nothing has been entailedforall((entails(Rule,Antecedants,Consequents), hold(Antecedants),member(Consequent,Consequents)), assert_u(entailed(Consequent,Rule,Antecedants)).Backward Chaining %% is_entailed(+Axiom,-Explanation) is nondet% Axiom is entailed if either holds or is a consequent in an% entails/3 rule and all the antecedants are entailed.Simulates tabling: If an Axiom has been entailed it is not tried again to revents endless loops for e.g. s :- s, t.
  • 21. SWRL implementation21Semantic Web Rules.To extend the set of OWL axioms to include Horn-like rules. It thus enables Horn-like rules to be combined with an OWL knowledge base. From (SWRL submission spec)Thea implementationImplies/2 fact to hold rules: implies(?Antecedent:list(swrlAtom), ?Consequent:list(swrlAtom))Convert a prolog clause to SWRL ruleConvert an SWRL rule to OWL axioms?- prolog_clause_to_swrl_rule((hasUncle(X1,X3):- hasParent(X1,X2),hasBrother(X2,X3)),SWRL),swrl_to_owl_axioms(SWRL,Axiom).X1 = v(1), X3 = v(2), X2 = v(3),SWRL = implies(['_d:hasParent'(v(1), v(3)), '_d:hasBrother'(v(3), v(2))], '_d:hasUncle'(v(1), v(2))),Axiom = [subPropertyOf(propertyChain(['_d:hasParent', '_d:hasBrother']), '_d:hasUncle')].
  • 22. Comparison with other systemsSPARQLNo means of updating dataToo RDF-centric for querying complex TboxesLack of ability to name queries (as in relational views)Lack of aggregate queriesLack of programmabilityBut … extensions (SPARQL update)OPPL (DSL):Simple, SQL – likeIn Protégé…Thea offers a complete programming language.22
  • 23. Comparison with OWLAPIOWLAPI: Full featured.Mature.Java API (OO language)Thea: declarative.offers bridge via JPL.easy scripting23Memory usageLoad time (secs)
  • 24. Applications OBO label generation (Bioinformatics)eLevator (Product configuration)Open Calais (Semantic Web)Linked data (Semantic Web)24
  • 25. ConsumersCustomersConfigurationEngine ServiceeLevatorCustomer PortalCustomer eServicesFinancial dataOrder statusOrder e-guideEnterprise SystemPLM, CRM, ERPAccounting…OrderEntryElevator Cabin configuration Modeling and VisualizationEnterpriseInternet25ASP / SaaS
  • 28. Bioinformatics label generation28Challenges in OBO: maintaining consistent class labels that conform to community norms.
  • 29. OWL + Prolog Definite Clause Grammars (DCGs) to auto-generate labels or suggestions for labels. Example
  • 30. OWL Class: length and qualityOf some (axon and partOf some pyramidal_neuron)
  • 31. Derive label length of pyramidal neuron axon.
  • 32. DCGterm(T) --> qual_expr(T) ; anat_expr(T).qual_expr(Q and qualityOf some A) --> qual(Q),[of],anat_expr(A).anat_expr(P and partOf some W) --> anat(W),anat_expr(P).anat_expr(A) --> anat(A).anat(A) --> {entailed(subClassOf(A,anatomical_entity)), labelAnnotation_value(A,Label)}, [Label].qual(Q) --> {entailed(subClassOf(Q,quality)), labelAnnotation_value(Q,Label)}, [Label].Non-determinisim of prolog to generate multiple values.
  • 33. Useful for automatically generating labels to be indexed for text search.
  • 34. The same grammars used to parse controlled natural language expressions.Open Calais 29Web Service by Thomson Reuters. Analyses content (from URLs, or POSTed text) using NLP and semantic techniquesREST interface.Prolog Thea wrapperAccess service from within PrologAccess and process Calais ontology (Tbox) and returned entities (Abox) with TheaOpen CalaisServiceThea Open Calais clientLoad and Parse Ontology (OWL file)Post Content (File, text or URL)RDF responseMarkup Elements(Entities, Relationships) and Metadata
  • 37. Linked dataUse URIs as names for things Use HTTP URIs so that people can look up those names. When someone looks up a URI, provide useful information, using the standards (RDF, SPARQL) Include links to other URIs. so that they can discover more things. 32
  • 38. Conclusions Status and Next stepsOWL2 support within PrologFull support of OWL2 structural syntaxEasy programmatic access to query and process Ontologies within Prolog.Import and export to different formatsModules for external reasoning supportNext StepsImprovements in efficiencyComplete modules (other I/Os, Reasoners etc)Complete documentationPortability (other Prolog systems)Use and feedback from the community… Applications33

Editor's Notes

  • #3: Why should I use it.
  • #6: http://www.mkbergman.com/862/the-sweet-compendium-of-ontology-building-tools/
  • #26: Innovation Pole – Central MacedoniaGnomon – ITI – Kleemann