Reasonable Ontology Templates

Martin G. Skjæveland Henrik Forssell Johan W. Klüwer Daniel Lupp Evgenij Thorstensen Arild Waaler WOP2017 October 21, 2017 OTTR Reasonable Ontology Templates (OTTR) Introduction and plan for talk

Tools and methodology • A better way of constructing ontologies • OWL macros expressed in OWL • abstractions, encapsulation, clear interface • nested • template: parameters • h i 7→ O instance: arguments • h i 7→ Oarguments OWL serialisation • OWL reasoning • OTTR Leverage W3C stack and tools • Extensible framework for representing and transforming data • Demo • 2 / 8 (p1,..., pn) |{z}T | {z } name parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { :: z}|{

3 / 8 (p1,..., pn) |{z}T | {z } name parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { :: z}|{ O

3 / 8 (p1,..., pn) | {z } parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { :: z}|{ |{z}T O name

3 / 8 Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z}|{ (p1,..., pn) :: |{z}T | {z } O name parameters

3 / 8 D p .E, F(p ) v ∃ 2 3

Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, |{z}T | {z } { v } name parameters

Parameters can be any concept, role, or individual name or data value •

3 / 8 F(p3)

Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, D p2.E, |{z}T | {z } { v v ∃ } name parameters

Parameters can be any concept, role, or individual name or data value •

3 / 8 Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, D p2.E, F(p3) |{z}T | {z } { v v ∃ } name parameters

Parameters can be any concept, role, or individual name or data value •

3 / 8 Templates can be (non-cyclically) nested • Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, D p2.E, F(p3) |{z}T | {z } { v v ∃ } name parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

3 / 8 Instances are expanded recursively •

Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, D p2.E, F(p3), 2(p4,...) |{z}T | {z } { v v ∃ T } name parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3) T | {z } ⇒ { v v ∃ } arguments

Templates can be (non-cyclically) nested •

3 / 8 Ontology templates

Template: • head body z }| { z }| { (p1,..., pn) :: p1 C, D p2.E, F(p3), 2(p4,...) |{z}T | {z } { v v ∃ T } name parameters

Parameters can be any concept, role, or individual name or data value • Template instance: • 1 (p1, p2, p3) p1 C, D p2.E, F(p3), 2(...) T | {z } ⇒ { v v ∃ T } arguments

Templates can be (non-cyclically) nested • Instances are expanded recursively • 3 / 8 withVariables * 1

templateRef 1 index hasArgument 0..* TemplateInstance Argument value 1 withValues * [Resource]

OTTR OWL vocabulary

1 [Resource] variable hasParameter 0..* Template Parameter index 1 xsd:int

http://ns.ottr.xyz

4 / 8 withVariables * 1

templateRef

withValues *

OTTR OWL vocabulary

1 [Resource] variable hasParameter 0..* Template Parameter index 1

1 xsd:int index hasArgument 0..* TemplateInstance Argument value 1 [Resource]

http://ns.ottr.xyz

4 / 8 withVariables *

withValues *

OTTR OWL vocabulary

1 [Resource] variable hasParameter 0..* Template Parameter index 1 1

templateRef 1 xsd:int index hasArgument 0..* TemplateInstance Argument value 1 [Resource]

http://ns.ottr.xyz

4 / 8 OTTR OWL vocabulary

withVariables * 1 [Resource] variable hasParameter 0..* Template Parameter index 1 1

templateRef 1 xsd:int index hasArgument 0..* TemplateInstance Argument value 1 withValues * [Resource]

http://ns.ottr.xyz

4 / 8 • RDF macros • not only OWL PartOf (Hammer, Handle) • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ }

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ }

PartOf (Hammer, Handle)

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ }

PartOf (Hammer, Handle) ⇒ Hammer hasPart.Handle { v ∃ }

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args PartOf (Hammer, Handle) • multiple instances • Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ } ### head: a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part].

### body: :Part a owl:Class . :Whole a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:hasPart ; owl:someValuesFrom :Part].

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ } ### head: a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part].

### body: :Part a owl:Class . :Whole a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:hasPart ; owl:someValuesFrom :Part].

PartOf (Hammer, Handle)

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ } ### head: a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part].

### body: :Part a owl:Class . :Whole a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:hasPart ; owl:someValuesFrom :Part].

PartOf (Hammer, Handle) [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle].

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: Whole hasPart.Part { v ∃ } ### head: a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part]. ## ottr:withVariables ( :Whole :Part).

### body: :Part a owl:Class . :Whole a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:hasPart ; owl:someValuesFrom :Part].

PartOf (Hammer, Handle) [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle]. ## ottr:withValues ( ex:Hammer ex:Handle).

5 / 8 • RDF macros • not only OWL • use for LOD • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: SubSomeValuesFrom(Whole, hasPart, Part) { } ### head: a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part]. ## ottr:withVariables ( :Whole :Part).

### body: [] ottr:templateRef ottr-owl:SubSomeValuesFrom; ottr:withValues ( :Whole ex:hasPart :Part).

PartOf (Hammer, Handle) [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle]. ## ottr:withValues ( ex:Hammer ex:Handle).

5 / 8 • Expansion: • copy template graph • paragraph 7→ argument • recurse • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: SubSomeValuesFrom(Whole, hasPart, Part) { } • RDF macros ### head: • not only OWL a ottr:Template ; • use for LOD ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], [ ottr:index 2; ottr:variable :Part]. ## ottr:withVariables ( :Whole :Part).

### body: [] ottr:templateRef ottr-owl:SubSomeValuesFrom; ottr:withValues ( :Whole ex:hasPart :Part).

PartOf (Hammer, Handle) [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle]. ## ottr:withValues ( ex:Hammer ex:Handle).

5 / 8 • Arguments • any RDF resource • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args • multiple instances

• Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: SubSomeValuesFrom(Whole, hasPart, Part) { } • RDF macros ### head: • not only OWL a ottr:Template ; • use for LOD ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], • Expansion: [ ottr:index 2; ottr:variable :Part]. • copy template graph ## ottr:withVariables ( :Whole :Part). • paragraph 7→ argument • recurse ### body: [] ottr:templateRef ottr-owl:SubSomeValuesFrom; ottr:withValues ( :Whole ex:hasPart :Part).

PartOf (Hammer, Handle) [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle]. ## ottr:withValues ( ex:Hammer ex:Handle).

5 / 8 • Reasoning • body • head • expanded • instantiated

PartOf (Whole, Part) :: SubSomeValuesFrom(Whole, hasPart, Part) { } • RDF macros ### head: • not only OWL a ottr:Template ; • use for LOD ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], • Expansion: [ ottr:index 2; ottr:variable :Part]. • copy template graph ## ottr:withVariables ( :Whole :Part). • paragraph 7→ argument • recurse ### body: • Arguments [] ottr:templateRef ottr-owl:SubSomeValuesFrom; • any RDF resource ottr:withValues ( :Whole ex:hasPart :Part). • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args PartOf (Hammer, Handle) • multiple instances [] ottr:templateRef ; ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], [ ottr:index 2; ottr:value ex:Handle]. ## ottr:withValues ( ex:Hammer ex:Handle).

5 / 8 PartOf (Whole, Part) :: SubSomeValuesFrom(Whole, hasPart, Part) { } • RDF macros ### head: • not only OWL a ottr:Template ; • use for LOD ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], • Expansion: [ ottr:index 2; ottr:variable :Part]. • copy template graph ## ottr:withVariables ( :Whole :Part). • paragraph 7→ argument • recurse ### body: • Arguments [] ottr:templateRef ottr-owl:SubSomeValuesFrom; • any RDF resource ottr:withValues ( :Whole ex:hasPart :Part). • incl. e.g., RDF(S)/OWL voc. • template IRIs • lists • variable-length args PartOf (Hammer, Handle) • multiple instances [] ottr:templateRef ; • Reasoning ottr:hasArgument [ ottr:index 1; ottr:value ex:Hammer], • body • [ ottr:index 2; ottr:value ex:Handle]. head • expanded ## ottr:withValues ( ex:Hammer ex:Handle). • instantiated

5 / 8 head instance head format lifting & lowering body format XML, XSLx XSD+SAWSDL XSLT OWL OTTRs (RDF) (SHACL, ShEx) SPARQL OWL

All formats generated from templates!

Extensible framework

lifting

head body z }| { z}|{ (p1,..., pn) :: T O lowering

6 / 8 Extensible framework

lifting

head body z }| { z}|{ (p1,..., pn) :: T O lowering

head instance head format lifting & lowering body format XML, XSLx XSD+SAWSDL XSLT OWL OTTRs (RDF) (SHACL, ShEx) SPARQL OWL

All formats generated from templates!

6 / 8 CLI java tool • OTTR vocabulary: • http://ns.ottr.xyz Library of OTTRs: • http://library.ottr.xyz Online web application: • http://osl.ottr.xyz Git: • http://gitlab.com/ottr/ ISWC Poster •

Resources

http://www.ottr.xyz •

7 / 8 OTTR vocabulary: • http://ns.ottr.xyz Library of OTTRs: • http://library.ottr.xyz Online web application: • http://osl.ottr.xyz Git: • http://gitlab.com/ottr/ ISWC Poster •

Resources

http://www.ottr.xyz • CLI java tool •

7 / 8 Library of OTTRs: • http://library.ottr.xyz Online web application: • http://osl.ottr.xyz Git: • http://gitlab.com/ottr/ ISWC Poster •

Resources

http://www.ottr.xyz • CLI java tool • OTTR vocabulary: • http://ns.ottr.xyz

7 / 8 Online web application: • http://osl.ottr.xyz Git: • http://gitlab.com/ottr/ ISWC Poster •

Resources

http://www.ottr.xyz • CLI java tool • OTTR vocabulary: • http://ns.ottr.xyz Library of OTTRs: • http://library.ottr.xyz

7 / 8 Git: • http://gitlab.com/ottr/ ISWC Poster •

Resources

http://www.ottr.xyz • CLI java tool • OTTR vocabulary: • http://ns.ottr.xyz Library of OTTRs: • http://library.ottr.xyz Online web application: • http://osl.ottr.xyz

7 / 8 ISWC Poster •

Resources

http://www.ottr.xyz • CLI java tool • OTTR vocabulary: • http://ns.ottr.xyz Library of OTTRs: • http://library.ottr.xyz Online web application: • http://osl.ottr.xyz Git: • http://gitlab.com/ottr/

7 / 8 Resources

http://www.ottr.xyz Reasonable Ontology Templates Martin G. Skjæveland1 Henrik Forssell1 Johan W. Klüwer2 Daniel P. Lupp1 Evgenij Thorstensen1 Arild Waaler1 • 1Department of Informatics, University of Oslo, 2DNV GL, Norway CLI java tool • Overview OTTR OWL Vocabulary: http://ns.ottr.xyz Examples Modular macros for OWL/RDF — in OWL/RDF withVariables * Terse input and iterations with lists + use of 3 “official” OTTRs: • 1 [Resource] • Good for ontology construction and maintenance variable a ottr:Template ; • hasParameter 0..* Clear interface, consistent pattern use, hide complexity Template ottr:withVariables ( :pizza ( :toppings ) ). • Parameter index OTTR vocabulary: 1 Reasoning support 1 ### body: • DRY — don’t repeat yourself templateRef 1 xsd:int :pizza rdfs:subClassOf p:NamedPizza. • • index hasArgument 0..* [] ottr:templateRef ottr-owl:SubObjectSomeValuesFrom ; Leverage W3C stack and tools TemplateInstance Argument http://ns.ottr.xyz value ottr:hasArgument [ ottr:index 1; ottr:value :pizza], • 1 Implementation, OWL vocabulary, and template withValues * [ ottr:index 2; ottr:value p:hasTopping], • [Resource] library available at http://ottr.xyz [ ottr:index 3; ottr:eachValue ( :toppings ) ]. [] ottr:templateRef ottr-owl:SubObjectAllValuesFrom ; ottr:withValues ( :pizza p:hasTopping _:alltoppings ) . Examples Library of OTTRs: [] ottr:templateRef ottr-owl:ObjectUnionOf ; Preliminaries ottr:withValues ( _:alltoppings ( :toppings ) ). Template PartOf (Whole, Part) :: Whole hasPart.Part • An (ontology) template has a head and a body: • { v ∃ } The instance • serialised with OTTR vocabulary: • http://library.ottr.xyz head body NamedPizza(Napoletana, ### head: (p1,..., pn) :: Tomato, Mozzarella, Olive, Caper, Anchovies ) T O a ottr:Template ; h i name parameters ottr:hasParameter [ ottr:index 1; ottr:variable :Whole], . . . expands to: [ ottr:index 2; ottr:variable :Part]. Napoletana NamedPizza A template instance (a1,..., an) specifies a substitution of the v • T ## or: ottr:withVariables ( :Whole :Part). Napoletana hasTopping.(Tomato Mozzarella ...) template’s parameters in the body with the instance’s arguments. Online web application: ### body: v ∀ t t Napoletana hasTopping.Tomato The template body is a regular ontology that can contain :Part a owl:Class . v ∃ • Napoletana hasTopping.Mozzarella • template instances and where parameters may be used as :Whole a owl:Class ; v ∃ Napoletana hasTopping.... http://osl.ottr.xyz placeholders for concepts, roles, individuals and data values. rdfs:subClassOf [ a owl:Restriction ; v ∃ A template instance is expanded by recursively replacing owl:onProperty ex:hasPart ; owl:someValuesFrom :Part]. • template instances with substituted template bodies. Template instance PartOf (Hammer, Handle) • serialised with OTTR vocabulary: Future Work [] ottr:templateRef ; Large-scale evaluation • Git: Extensible Framework ottr:hasArgument [ ottr:index 1; ottr:value :Hammer], —prototype successfully tested in industry [ ottr:index 2; ottr:value :Handle]. Language design and extensions lifting • • (p ,..., p ) ## or: ottr:withValues ( ex:Hammer ex:Handle). T 1 n Support template pre-conditions http://gitlab.com/ottr/ lowering O . . . expands to • —with also template head as ontology • :Handle a owl:Class . Methods for template library maintenance Bulk data formats: XLSx, XML (XSD + SAWSDL), RDF, OWL • • :Hammer a owl:Class ; — with ontology interrelationships Bulk lifting and lowering transformations: XSLT, SPARQL rdfs:subClassOf [ a owl:Restriction ; • Protégé plugin owl:onProperty ex:hasPart; owl:someValuesFrom :Handle]. • Template-based visualisations ISWC Poster • • Poster by Martin G. Skjæveland and Daniel P. Lupp

7 / 8 Large-scale evaluation • Further development of templates and tools • Theory for structuring a library templates, e.g., what is a subtemplate? • Template library maintenance • Ontology as pre-condition: template heads as ontologies too • Protege plugin • Excel plugin •

The Future and Future work

Engineering ontologies using only OTTR templates • API for OWL (— or AI for OWL) • Ontology experts construct OTTRs • “Knowledge engineers” combine OTTRs to user-facing templates • Domain experts use tabular format •

8 / 8 The Future and Future work

Engineering ontologies using only OTTR templates • API for OWL (— or AI for OWL) • Ontology experts construct OTTRs • “Knowledge engineers” combine OTTRs to user-facing templates • Domain experts use tabular format • Large-scale evaluation • Further development of templates and tools • Theory for structuring a library templates, e.g., what is a subtemplate? • Template library maintenance • Ontology as pre-condition: template heads as ontologies too • Protege plugin • Excel plugin •

8 / 8