Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Concept Modeling with OWL and Clafer

by Michał Antkiewicz, http://gsd.uwaterloo.ca/mantkiew

OWL (Web Ontology Language) is a W3C standard for concept modeling in semantic web built on top of RDF and RDF Schema.

Clafer (CLAss, FEature, Relationship) is a "class modeling

language with first-class support for feature modeling" developed in Generative Software Development Lab @ University of Waterloo.

This presentation is an effort to understand:

  • what Clafer is, intuitively
  • differences in thinking when modeling with OWL and Clafer
  • how to translate the Pizza example from OWL to Clafer
  • modeling idioms used in both languages

It is not:

  • a detailed comparison between the two languages
  • trying to argue one is better than the other

1. (Not so formal) interpretation of Clafer model as UML class and object models

UML Object Model

UML Class Model

Clafer

<empty model>

UML Object Model

Clafer

UML Class Model

abstract Person

Head

Arm 2..2

Clafer

UML Object Model

UML Class Model

abstract Person

Head

Arm 2..2

Michal extends Person

UML Class Model

UML Object Model

Clafer

abstract Person

Head

Arm 2..2

owns -> Car *

abstract Car

Civic extends Car

Michal extends Person

[Civic in owns ]

2. OWL

UML Object Model

UML Class Model

Clafer

abstract Person

name -> String

Michal extends Person

[ name = "Michal" ]

Typical applications of modeling

OWL: classification

"Given an OWL metamodel and a set of individuals,

assign the individuals to appropriate classes."

Clafer: ???

Metamodeling, specialization, configuration, classification, ...

However, both languages can be used for a variety of applications

This presentation is an effort to understand

  • what clafer is, intuitively
  • differences in thinking when modeling in OWL and Clafer
  • how to translate the OWL Pizza example to Clafer
  • what are examples of modeling idioms

This presentation is NOT:

  • a detailed comparizon between OWL and Clafer
  • an evaluation of usability of both languages
  • trying to prove one is better of the other

The key differences are in the way of thinking about the modeled concepts.

Clafer

OWL

Individuals can belong to multiple classes.

No distinction between individuals and classes. Everything is a clafer, some are fully constrained (singletons). Clafers can inherit from at most one clafer.

How to characterize all instances of a concept?

How to divide all possible individuals into classes?

Class defined by restrictions on properties or set operations.

Concept defined by features that the instances can exhibit.

Pizza

xor PizzaBase

DeepPanBase ; ThinAndCrispyBase

PizzaTopping +

Declaration(Class(:Food))

Declaration(Class(:Pizza))

Declaration(Class(:PizzaBase))

Declaration(Class(:PizzaTopping))

SubClassOf(:Pizza :Food)

SubClassOf(:Pizza ObjectSomeValuesFrom(:hasBase :PizzaBase))

DisjointClasses(:Pizza :PizzaBase)

DisjointClasses(:Pizza :PizzaTopping)

SubClassOf(:PizzaBase :Food)

DisjointClasses(:PizzaBase :Pizza)

DisjointClasses(:PizzaBase :PizzaTopping)

SubClassOf(:PizzaTopping :Food)

DisjointClasses(:PizzaTopping :Pizza)

DisjointClasses(:PizzaTopping :PizzaBase)

Translation Notes:

  • translation is not looseless: in Clafer, properties are implicit with default names
  • no need to partition Food into Pizza, PizzaBase, and PizzaTopping
  • no multiple classification so no need to explicitly state disjointness
  • every child feature has an inverse "parent" property
  • types of properties (e.g., functional) expressed by cardinality

Declaration(ObjectProperty(:hasBase))

InverseObjectProperties(:hasBase :isBaseOf)

FunctionalObjectProperty(:hasBase)

InverseFunctionalObjectProperty(:hasBase)

ObjectPropertyDomain(:hasBase :Pizza)

ObjectPropertyRange(:hasBase :PizzaBase)

Declaration(ObjectProperty(:hasTopping))

InverseObjectProperties(:hasTopping :isToppingOf)

InverseFunctionalObjectProperty(:hasTopping)

ObjectPropertyDomain(:hasTopping :Pizza)

ObjectPropertyRange(:hasTopping :PizzaTopping)

Declaration(ObjectProperty(:isBaseOf))

InverseObjectProperties(:hasBase :isBaseOf)

FunctionalObjectProperty(:isBaseOf)

InverseFunctionalObjectProperty(:isBaseOf)

ObjectPropertyDomain(:isBaseOf :PizzaBase)

ObjectPropertyRange(:isBaseOf :Pizza)

Declaration(ObjectProperty(:isToppingOf))

InverseObjectProperties(:hasTopping :isToppingOf)

FunctionalObjectProperty(:isToppingOf)

ObjectPropertyDomain(:isToppingOf :PizzaTopping)

ObjectPropertyRange(:isToppingOf :Pizza)

3. Pizza example in OWL translation to Clafer

Can use both containment or sharing styles.

No containment semantics.

translation to Clafer

- 7 Kb

- 4 pages, 8pt in Word

- 630 words

- 256 lines

OWL functional syntax conversion

- predicates, 1 per line

- 73 Kb

- 20 pages, 8pt in Word

- 3694 words

- 1382 lines

Original file: pizza.owl

- XML

- 233 Kb

- 87 pages, 8pt in Word

- 10048 words

- 6750 lines

abstract Pizza

xor PizzaBase

DeepPanBase ; ThinAndCrispyBase

xor PizzaTopping +

MozzarellaTopping

TomatoTopping

MyThinMozzarellaPizza extends Pizza

[ ThinAndCrispyBase

MozzarellaTopping ]

abstract xor PizzaBase

DeepPanBase ; ThinAndCrispyBase

isBaseOf -> Pizza

[ isBaseOf.hasBase = this ]

abstract PizzaTopping

isToppingOf -> Pizza

[ isToppingOf.hasTopping = this ]

abstract Pizza

hasBase -> PizzaBase

hasTopping -> PizzaTopping +

MyPizzaBase extends PizzaBase

[ ThinAndCrispyBase ]

MyMozzarellaTopping extends PizzaTopping

[ MozzarellaTopping ]

MyThinMozzarellaPizza extends Pizza

[ hasBase = MyPizzaBase

MyMozzarellaTopping in hasTopping ]

Clafer syntax is extremely concise and provides good insight into the structure of the model.

Both OWL and functional syntaxes are human unusable: one has to use a tool.

Declaration(Class(:Country))

EquivalentClasses(:Country ObjectIntersectionOf(ObjectOneOf(:France :Italy :England :Germany :America) :DomainConcept))

OWL

Declaration(Class(:Spiciness))

EquivalentClasses(:Spiciness ObjectUnionOf(:Hot :Medium :Mild))

SubClassOf(:Spiciness :ValuePartition)

Declaration(NamedIndividual(:America))

ClassAssertion(:Country :America)

ClassAssertion(owl:Thing :America)

Declaration(NamedIndividual(:England))

ClassAssertion(:Country :England)

ClassAssertion(owl:Thing :England)

Declaration(NamedIndividual(:France))

ClassAssertion(:Country :France)

ClassAssertion(owl:Thing :France)

Declaration(NamedIndividual(:Germany))

ClassAssertion(:Country :Germany)

ClassAssertion(owl:Thing :Germany)

Declaration(NamedIndividual(:Italy))

ClassAssertion(:Country :Italy)

ClassAssertion(owl:Thing :Italy)

Declaration(Class(:Hot))

SubClassOf(:Hot :Spiciness)

DisjointClasses(:Hot :Medium)

DisjointClasses(:Hot :Mild)

Declaration(Class(:Mild))

SubClassOf(:Mild :Spiciness)

DisjointClasses(:Mild :Hot)

DisjointClasses(:Mild :Medium)

Declaration(Class(:Medium))

SubClassOf(:Medium :Spiciness)

DisjointClasses(:Medium :Hot)

DisjointClasses(:Medium :Mild)

Clafer

enum Country = America | England | France | Germany | Italy

enum Spiciness = Hot | Medium | Mild

<enum is a syntactic sugar for>

abstract Spiciness

Hot extends Spiciness

Medium extends Spiciness

Mild extends Spiciness

OWL

Declaration(Class(:Pizza))

SubClassOf(:Pizza :Food)

SubClassOf(:Pizza ObjectSomeValuesFrom(:hasBase :PizzaBase))

DisjointClasses(:Pizza :PizzaBase)

DisjointClasses(:Pizza :PizzaTopping)

Declaration(Class(:PizzaBase))

SubClassOf(:PizzaBase :Food)

DisjointClasses(:PizzaBase :Pizza)

DisjointClasses(:PizzaBase :PizzaTopping)

Declaration(Class(:PizzaTopping))

SubClassOf(:PizzaTopping :Food)

DisjointClasses(:PizzaTopping :Pizza)

DisjointClasses(:PizzaTopping :PizzaBase)

Declaration(Class(:ThinAndCrispyBase))

SubClassOf(:ThinAndCrispyBase :PizzaBase)

DisjointClasses(:ThinAndCrispyBase :DeepPanBase)

Declaration(Class(:DeepPanBase))

SubClassOf(:DeepPanBase :PizzaBase)

DisjointClasses(:DeepPanBase :ThinAndCrispyBase)

Declaration(ObjectProperty(:hasBase))

InverseObjectProperties(:hasBase :isBaseOf)

FunctionalObjectProperty(:hasBase)

InverseFunctionalObjectProperty(:hasBase)

ObjectPropertyDomain(:hasBase :Pizza)

ObjectPropertyRange(:hasBase :PizzaBase)

Declaration(ObjectProperty(:hasTopping))

InverseObjectProperties(:hasTopping :isToppingOf)

InverseFunctionalObjectProperty(:hasTopping)

ObjectPropertyDomain(:hasTopping :Pizza)

ObjectPropertyRange(:hasTopping :PizzaTopping)

Declaration(ObjectProperty(:isBaseOf))

InverseObjectProperties(:hasBase :isBaseOf)

FunctionalObjectProperty(:isBaseOf)

InverseFunctionalObjectProperty(:isBaseOf)

ObjectPropertyDomain(:isBaseOf :PizzaBase)

ObjectPropertyRange(:isBaseOf :Pizza)

Declaration(ObjectProperty(:isToppingOf))

InverseObjectProperties(:hasTopping :isToppingOf)

FunctionalObjectProperty(:isToppingOf)

ObjectPropertyDomain(:isToppingOf :PizzaTopping)

ObjectPropertyRange(:isToppingOf :Pizza)

Clafer

abstract Pizza

xor PizzaBase

DeepPanBase

ThinAndCrispyBase

PizzaTopping +

spiciness -> Spiciness ?

country -> Country ?

xor KindOfTopping

OWL

Clafer

PizzaTopping +

spiciness -> Spiciness ?

country -> Country ?

xor KindOfTopping

xor CheeseTopping

xor FishTopping

FruitTopping

xor HerbSpiceTopping

xor MeatTopping

NutTopping

SauceTopping

xor VegetableTopping

Declaration(Class(:CheeseTopping))

SubClassOf(:CheeseTopping :PizzaTopping)

DisjointClasses(:CheeseTopping :FishTopping)

DisjointClasses(:CheeseTopping :FruitTopping)

DisjointClasses(:CheeseTopping :HerbSpiceTopping)

DisjointClasses(:CheeseTopping :MeatTopping)

DisjointClasses(:CheeseTopping :NutTopping)

DisjointClasses(:CheeseTopping :SauceTopping)

DisjointClasses(:CheeseTopping :VegetableTopping)

Declaration(Class(:FishTopping))

SubClassOf(:FishTopping :PizzaTopping)

SubClassOf(:FishTopping ObjectSomeValuesFrom(:hasSpiciness :Mild))

DisjointClasses(:FishTopping :CheeseTopping)

DisjointClasses(:FishTopping :FruitTopping)

DisjointClasses(:FishTopping :HerbSpiceTopping)

DisjointClasses(:FishTopping :MeatTopping)

DisjointClasses(:FishTopping :NutTopping)

DisjointClasses(:FishTopping :SauceTopping)

DisjointClasses(:FishTopping :VegetableTopping)

<pattern repeats for each of other kinds of toppings>

....

OWL

Clafer

abstract Pizza

PizzaTopping +

spiciness -> Spiciness ?

country -> Country ?

xor KindOfTopping

xor CheeseTopping

[spiciness = Mild]

FourCheesesTopping

GoatsCheeseTopping

GorgonzolaTopping

MozzarellaTopping

[country = Italy]

ParmesanTopping

SubClassOf(:Food :DomainConcept)

Declaration(Class(:FourCheesesTopping))

SubClassOf(:FourCheesesTopping :CheeseTopping)

SubClassOf(:FourCheesesTopping ObjectSomeValuesFrom(:hasSpiciness :Mild))

DisjointClasses(:FourCheesesTopping :GoatsCheeseTopping)

DisjointClasses(:FourCheesesTopping :GorgonzolaTopping)

DisjointClasses(:FourCheesesTopping :MozzarellaTopping)

DisjointClasses(:FourCheesesTopping :ParmesanTopping)

Declaration(Class(:MozzarellaTopping))

SubClassOf(:MozzarellaTopping :CheeseTopping)

SubClassOf(:MozzarellaTopping ObjectSomeValuesFrom(:hasSpiciness :Mild))

SubClassOf(:MozzarellaTopping ObjectHasValue(:hasCountryOfOrigin :Italy))

DisjointClasses(:MozzarellaTopping :FourCheesesTopping)

DisjointClasses(:MozzarellaTopping :GoatsCheeseTopping)

DisjointClasses(:MozzarellaTopping :GorgonzolaTopping)

DisjointClasses(:MozzarellaTopping :ParmesanTopping)

<pattern repeats for each of other subclass of CheeseTopping>

....

OWL

Declaration(Class(:SpicyTopping))

EquivalentClasses(:SpicyTopping ObjectIntersectionOf(ObjectSomeValuesFrom(:hasSpiciness :Hot) :PizzaTopping))

Declaration(Class(:VegetarianTopping))

EquivalentClasses(:VegetarianTopping ObjectIntersectionOf(ObjectUnionOf(:CheeseTopping :FruitTopping

:HerbSpiceTopping :NutTopping :SauceTopping :VegetableTopping) :PizzaTopping))

Clafer

abstract Pizza

PizzaTopping +

spiciness -> Spiciness ?

country -> Country ?

...

SpicyTopping ?

[spiciness = Hot <=> SpicyTopping]

VegetarianTopping ?

[CheeseTopping || FruitTopping || HerbSpiceTopping || NutTopping || SauceTopping || VegetableTopping <=> VegetarianTopping]

OWL

Clafer

Declaration(Class(:CheeseyPizza))

EquivalentClasses(:CheeseyPizza ObjectIntersectionOf(ObjectSomeValuesFrom(:hasTopping :CheeseTopping) :Pizza))

Declaration(Class(:InterestingPizza))

EquivalentClasses(:InterestingPizza ObjectIntersectionOf(ObjectMinCardinality(3 :hasTopping) :Pizza))

Declaration(Class(:NonVegetarianPizza))

EquivalentClasses(:NonVegetarianPizza

ObjectIntersectionOf(ObjectComplementOf(:VegetarianPizza) :Pizza))

Declaration(Class(:RealItalianPizza))

EquivalentClasses(:RealItalianPizza

ObjectIntersectionOf(ObjectHasValue(:hasCountryOfOrigin :Italy) :Pizza))

Declaration(Class(:SpicyPizza))

EquivalentClasses(:SpicyPizza

ObjectIntersectionOf(ObjectSomeValuesFrom(:hasTopping :SpicyTopping) :Pizza))

abstract Pizza

CheeseyPizza ?

[ CheeseTopping <=> CheeseyPiza]

InterestingPizza ?

[ # PizzaTopping >= 3 <=> InterestingPizza ]

NonVegetarianPizza ?

[ ~ VegetarianPizza <=> NonVegetarianPizza]

RealItalianPizza ?

[ country == Italy && ThinAndCrispyBase <=> RealItalianPizza]

SpicyPizza ?

[ SpicyTopping <=> SpicyPizza]

OWL

Declaration(Class(:ThinAndCrispyPizza))

EquivalentClasses(:ThinAndCrispyPizza

ObjectIntersectionOf(ObjectAllValuesFrom(:hasBase :ThinAndCrispyBase) :Pizza))

Declaration(Class(:VegetarianPizza))

EquivalentClasses(:VegetarianPizza

ObjectIntersectionOf(:Pizza ObjectComplementOf(ObjectSomeValuesFrom(:hasTopping :FishTopping)) ObjectComplementOf(ObjectSomeValuesFrom(:hasTopping :MeatTopping))))

DisjointClasses(:VegetarianPizza :NonVegetarianPizza)

Declaration(Class(:VegetarianPizzaEquivalent1))

EquivalentClasses(:VegetarianPizzaEquivalent1

ObjectIntersectionOf(ObjectAllValuesFrom(:hasTopping :VegetarianTopping) :Pizza))

Clafer

abstract Pizza

...

ThinAndCrispyPizza ?

[ ThinAndCrispyBase <=> ThinAndCrispyPizza]

VegetarianPizza ?

[ ~ FishTopping && ~ MeatTopping <=> VegetarianPizza ]

VegetarianPizzaEquivalent1 ?

[ all p : PizzaToping | p.VegetarianTopping <=>

VegetarianPizzaEquivalent1 ]

OWL

DisjointClasses(:Veneziana :Giardiniera)

DisjointClasses(:Veneziana :LaReine)

DisjointClasses(:Veneziana :Margherita)

DisjointClasses(:Veneziana :Mushroom)

DisjointClasses(:Veneziana :Napoletana)

DisjointClasses(:Veneziana :Parmense)

DisjointClasses(:Veneziana :PolloAdAstra)

DisjointClasses(:Veneziana :PrinceCarlo)

DisjointClasses(:Veneziana :QuattroFormaggi)

DisjointClasses(:Veneziana :Rosa)

DisjointClasses(:Veneziana :Siciliana)

DisjointClasses(:Veneziana :SloppyGiuseppe)

DisjointClasses(:Veneziana :Soho)

DisjointClasses(:Veneziana :UnclosedPizza)

Declaration(Class(:Veneziana))

AnnotationAssertion(rdfs:label :Veneziana "Veneziana"@pt)

SubClassOf(:Veneziana :NamedPizza)

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :CaperTopping))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :MozzarellaTopping))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :OliveTopping))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :OnionTopping))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :PineKernels))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :SultanaTopping))

SubClassOf(:Veneziana ObjectSomeValuesFrom(:hasTopping :TomatoTopping))

SubClassOf(:Veneziana

ObjectAllValuesFrom(:hasTopping ObjectUnionOf(:CaperTopping :MozzarellaTopping :OliveTopping :OnionTopping :PineKernels :SultanaTopping :TomatoTopping)))

SubClassOf(:Veneziana ObjectHasValue(:hasCountryOfOrigin :Italy))

DisjointClasses(:Veneziana :American)

DisjointClasses(:Veneziana :AmericanHot)

DisjointClasses(:Veneziana :Cajun)

DisjointClasses(:Veneziana :Capricciosa)

DisjointClasses(:Veneziana :Caprina)

DisjointClasses(:Veneziana :Fiorentina)

DisjointClasses(:Veneziana :FourSeasons)

DisjointClasses(:Veneziana :FruttiDiMare)

DisjointClasses(:Veneziana :Giardiniera)

abstract Veneziana extends Pizza

[ country = Italy

CaperTopping

MozzarellaTopping

OliveTopping

OnionTopping

PineKernels

SultanaTopping

TomatoTopping ]

MyVeneziana extends Veneziana

[ ThinAndCrispyBase

GarlicTopping ]

Clafer

Declaration(NamedIndividual(:MyVeneziana))

ClassAssertion(:Veneziana :MyVeneziana)

<need to choose base and garlic topping>

Further resources:

  • complete Pizza clafer model (pizza.cfr)
  • semantics of the model given by translation to Alloy (pizza.als)

Visit http://gsd.uwaterloo.ca/node/289

Paper about Clafer accepted at SLE'10

Visit http://gsd.uwaterloo.ca/node/292

Learn more about creating dynamic, engaging presentations with Prezi