简体   繁体   中英

How do I use the cardinality constraint to link a class to a instance in protege?

For example, all individuals from class A can only be used at one location B -- an instance. I'd like to put 'Class A' be used at (only/exact 1) [location B]. But it seems that this constraint can only be held in between classes. How can I do it without creating an empty class of the instance "location B"?

Thanks.

If you want to say that all instances of class A are located at instance B and only at B , you can do this with the following (Turtle syntax):

:A  a  owl:Class;
  rdfs:subClassOf  [
    a  owl:Restriction;
    owl:allValuesFrom  [
      a  owl:Class;
      owl:oneOf  ( :B )
    ]
  ], [
    a  owl:Restriction;
    owl:onProperty  :location;
    owl:hasValue  :B
  ] .

Note, however, that the thing named B may be known by other names, so if you know that:

:x  a  :A;
   :location  :C, :D .

then you can conclude that C and D are two other names for the thing named B . If you would like this to be detected as a mistake or error, you could make explicit that C and D are naming different things than B :

:B  owl:differentFrom  :C, :D .

or you can use a constraint language like SHACL, or you may rely on the unique name assumption (UNA) for your reasoning procedure (however, standard OWL does not make the UNA, so you cannot expect that external data conform to this assumption).

Note, too, that if you would like to describe a constraint on the data such as that when some entity is known to be an instance of A then there must be, in the data, the statement that it is located in B , you need to use a constraint language like SHACL (that describes how data ought to be shaped), not a knowledge representation language like OWL (that describes how the world is ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM