Daraan
Daraan

Reputation: 3947

How to model an exclusive or in OWL?

I OWL I want to model the case where for a certain class only one or the other subclass is allowed. I want to model a restriction that allows for a property to be only linked like (A XOR B) OR (some general superclass) for multiple instances

X p A1 .
X p A2 .
X p M . # OK

Y p K .
Y p A3 .
Y p B1 . #Not ok, A and B linked.

A concrete example:

I have a class cart, and each cart has exactly n Seats.

There are two types of seats available (adult, child) as well as a unspecified amount of other Parts, which is the superclass of Seats. Linked are they all via a :hasPart relationship.

:Cart a owl:Class .
:Part o owl:Class .
:hasPart a owl:ObjectProperty;
:rdfs:domain :Part .

:Seat a owl:Class ; rdfs:subClassOf :Part .
:AdultSeat a owlClass; rdfs:subClassOf :Seat .
:ChildSeat a owlClass; rdfs:subClassOf :Seat .

[a owl:AllDisjointClasses; owl:members ( <all leaf classes> )]

# some other parts

With OWL I want to now model that a cart can either have AdultSeats xor ChildSeats.

I think I need two opposite restrictions that model <minCardinality of SeatA to 1 & maxCardinality of SeatB to 0>. I am still working out how to formulate these two cases.

However, given that I have them I still wonder how I can restrict :hasPart to one of these cases and still allow linking other parts.

Upvotes: 0

Views: 79

Answers (1)

Daraan
Daraan

Reputation: 3947

To get to (A XOR B) OR <something not A OR B> one can work with the complement. To reach an explicit XOR one would intersect over A OR B again, depending on the situation this could be done in multiple ways.

:Cart rdfs:subClassOf [
    a owl:Class;
    owl:complementOf [
        a owl:Class;
        owl:unionOf (
            [a owl:Restriction  
             owl:onProperty :hasPart;
             owl:minQualifiedCardinality 1;
             owl:onClass AdultSeat ]
             
            [a owl:Restriction  
             owl:onProperty :hasPart;
             owl:minQualifiedCardinality 1;
             owl:onClass ChildSeat ]
        )
    ]
]
#  this statement could look differently or worked into the above with an intersection.
:Cart rdfs:subClassOf [
   a owl:Restriction;
   owl:onProperty :hasPart;
   owl:qualifiedCardinality n; 
   owl:onClass [
       a owl:Class;
       owl:unionOf (
       ChildSeat AdultSeat) #  in my case I could work with Seat but this is more general
   ] .
].

My old idea was to model the XOR explicit as (A and not B) OR (notA and B) which yields, still wondering if there is a shorter way as it looks cumbersome.

:Cart rdfs:subClassOf [ 
    a owl:Class;
    owl:disjointUnionOf ( #maybe just normal union 
    # ChildSeats and no adult seats
    [a owl:Class;
     owl:intersectionOf (
         [a owl:Restriction;
         owl:onProperty :hasPart;
         owl:qualifiedCardinality 0;
         owl:onClass AdultSeat]
         
         [a owl:Restriction;
         owl:onProperty :hasPart;
         owl:minCardinality 1;
         owl:onClass ChildSeat ]
         )
     ]

    # Or Has adult seat and no ChildSeat
    [a owl:Class;
     owl:intersectionOf (
         [a owl:Restriction;
         owl:onProperty :hasPart;
         owl:qualifiedCardinality 0;
         owl:onClass ChildSeat]
         
         [a owl:Restriction;
         owl:onProperty :hasPart;
         owl:minCardinality 1;
         owl:onClass AdultSeat ]
         )
     ]
] .

Upvotes: 0

Related Questions