pOTTR: Incrementally building a template library
Table of Contents
Incrementally building a template library
A top-down modelling approach for building template libraries.
- Authors
- Daniel Lupp
- Issues
- https://gitlab.com/ottr/language/pOTTR/issues
1. Introduction
In this chapter will incrementally build a set of templates that model the domain of mobile phone with the goal of representing the design of the phone, i.e., which parts different models of phone consist of, and the specific parts a specific phone (individual) consists of.
The reader should know the basics of OTTR.
In this chapter you will learn:
- How to incrementally build a template library using a top-down modelling approach
- How to use base templates as a design and validation tool while modelling
- How to refine high-level templates into more precise, reusable definitions
- How to populate a template library with concrete instances
1.1. Prefixes
The following prefixes are used throughout the document, and may be used in the text input areas of the interactive examples without declaration.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix dbp: <http://dbpedia.org/ontology/> . @prefix ex: <http://example.com/ns#> . @prefix ottr: <http://ns.ottr.xyz/0.4/> . @prefix ax: <http://tpl.ottr.xyz/owl/axiom/0.1/> . @prefix rstr: <http://tpl.ottr.xyz/owl/restriction/0.1/> .
2. Defining core patterns
Creating a signature
Based on the following instances, write a suitable signature for
the template ex:Phone. Ignore for now that it is a base
template, in the following exercises we will define it in more
detail.
Extending the signature to a template
Use the templates below as well as existing OWL templates to
create the ex:Phone template. Use ex:ConsistsOf as a black box
(this template will be defined in the next exercise).
Solution
ex:Phone[owl:Class ?name, NEList<owl:Class> ?components, ? xsd:string ?label] :: {
ax:SubClassOf(?name, ex:Phone),
ottr:Triple(?name, rdfs:label, ?label),
ex:ConsistsOf(?name, ?components)
}.
3. Refining incrementally
Add ConsistsOf
Use the ex:HasComponents and ex:OnlyComponents templates below
to define the ex:ConsistsOf template. We will define
ex:HasComponents and ex:OnlyComponents in the next exercise.
Solution
ex:ConsistsOf[owl:Class ?item, NEList<owl:Class> ?components] :: {
ex:HasComponents(?item, ?components),
ex:OnlyComponents(?item, ?components)
}.
Add HasComponents and OnlyComponents
Use ex:HasComponent below as well as existing OWL and RDFS
templates to define ex:HasComponents and
ex:OnlyComponents. (Hint: look at rstr:ObjectUnionOf and
ax:SubObjectAllValuesFrom).
Solution
ex:HasComponents[owl:Class ?item, NEList<owl:Class> ?components] :: {
cross | ex:HasComponent(?item, ++?components)
}.
ex:OnlyComponents[owl:Class ?item, NEList<owl:Class> ?components] :: {
rstr:ObjectUnionOf(_:b, ?components),
ax:SubObjectAllValuesFrom(?item, ex:hasComponent, _:b)
}.
4. Instantiation
Add PhoneInstance
Now we are going to create a template for populating phone
classes: ex:PhoneInstance. Define the template
ex:PhoneInstance below.
Solution
ex:PhoneInstance[owl:NamedIndividual ?phoneInstance, owl:Class ?phone, NEList<owl:NamedIndividual> ?components] :: {
ottr:Triple(?phoneInstance, rdf:type, ?phone),
cross | ottr:Triple(?phoneInstance, ex:hasComponent, ++?components)
}.
Instantiation
Create one or more new phone classes and populate them with specific phones.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix dbp: <http://dbpedia.org/ontology/> . @prefix ex: <http://example.com/ns#> . @prefix ottr: <http://ns.ottr.xyz/0.4/> . @prefix ax: <http://tpl.ottr.xyz/owl/axiom/0.1/> . @prefix rstr: <http://tpl.ottr.xyz/owl/restriction/0.1/> . ex:Phone(ex:Nokia3310, (ex:Screen, ex:HardCase, ex:CPU), "indestructible"^^xsd:string). ex:Phone(ex:SamsungS9, (ex:CurvedScreen, ex:FastCPU), none). ex:Phone(ex:iPhone8, (ex:RetinaScreen, ex:OtherFastCPU, ex:FPReader), "iphone"^^xsd:string).
5. Appendix
5.1. WebLutra
The web application that drives the interactive examples in this primer, called WebLutra, uses Lutra, the reference application for OTTR. Both applications are open source and available at http://gitlab.com/ottr/lutra/lutra. If you experience errors or have suggestions for improvements, please take a look at existing issues or file a new issue: http://gitlab.com/ottr/lutra/lutra/issues