Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 views
in Technique[技术] by (71.8m points)

rdf - How can I infer something transitively from two different properties in OWL?

I'm trying to make an ontology of my favourite fantasy world using Protege and OWL but I got stuck. I got 2 questions which I can't figure out myself. But first here's the setup:

In my fantasy world there are many races and each race is divided into many subfactions - each of them having different king, worshipping different God, etc.

Q1: What I want to be able to do is, knowing that a character A is from Faction B and B is a faction of Race C, then we should be able to infer that A is from race C.

Each faction may contain some named characters. I have expressed that with the following three classes:

  • Race
  • Faction
  • Character

And the following properties:

  • isOfRace - functional, inverse of containsFaction, domain=Faction, range=Race
  • containsFaction - inverse of isOfRace, domain=Race
  • isOfFaction - functional, inverse of containsCharacter, domain=Character, range=Faction
  • containsCharacter - inverse of isOfFaction, domain=Faction, range=Character

And I have added the properties to the respective classes. I know that generally speaking a Faction can have multiple properties of type "isOfRace" so if that's the case the inference engine wouldn't know which of these to consider the "true" race of the character but then again I have made the properties "isOfRace" and "isOfFaction" functional so the way I see it that shouldn't be a problem.

Q2: Q2 is relevant only if what I'm asking in Q1 is doable. Anyways, let's again lay out the setup:

Each faction can have multiple cities (and each city is owned by a faction) and each city is located on a continent. Each faction is also categorized by the opposing sides "Order" or "Chaos". Does OWL support a construct which represents the following:

A Faction isInConflict(transitive) with another Faction iff:

  1. Both of them have at least one city on the same continent
  2. They are of different alignments - e.g. one is "Order" and the other is "Chaos"

Or in other words can a property be inferred and if yes, how should I go in implementing the above restriction?

Thanks!

question from:https://stackoverflow.com/questions/65861112/how-can-i-infer-something-transitively-from-two-different-properties-in-owl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Before we dive into OWL, you can even use RDFS for this sort of thing, but without your custom properties:

ex:SomeFaction rdfs:subClassOf ex:SomeRace .

ex:SomePerson a ex:SomeFaction .

I do not like this approach however, since I view classes as something that describes the immutable essence and structure of entities, which at least factions certainly don't. It might also lead to conflicts in OWL, as some profiles do not allow treating a class as an individual, if you want to use it for other things.


Your issue is similar to trying to describe foaf:membershipClass with OWL, which is hard to do in general (maybe impossible without hacks). Describing it on a per-case basis is possible however:

[
  a owl:Restriction ;
  owl:onProperty ex:isOfFaction ;
  owl:hasValue ex:SomeFaction
] rdfs:subClassOf [
  a owl:Restriction ;
  owl:onProperty ex:hasRace ;
  owl:hasValue ex:SomeRace
]

This is basically an implication stating that any individual with a specific faction has a specific race.

However, I think you can use transitivity to your advantage here:

ex:isOfGroup a owl:TransitiveProperty .

ex:isOfRace rdfs:subPropertyOf ex:isOfGroup .
ex:isOfFaction rdfs:subPropertyOf ex:isOfGroup .

ex:SomeFaction ex:isOfRace ex:SomeRace .
ex:SomePerson ex:isOfFaction ex:SomeFaction .

We can infer that ex:SomePerson ex:isOfGroup ex:SomeRace.

With OWL 2, it is simplified to property chains:

[
  owl:propertyChainAxiom ( ex:isOfFaction ex:isOfRace )
] rdfs:subPropertyOf ex:hasRace .

The second question needs similar sort of reasoning. I will try to use OWL 2 since I doubt it is expressible in OWL 1.

ex:occupiesContinent owl:propertyChainAxiom ( ex:controlsCity ex:onContinent ) .
ex:occupiedByFaction owl:inverseOf ex:occupiesContinent .

ex:sharesContinentWith owl:propertyChainAxiom ( ex:occupiesContinent ex:occupiedByFaction ) .

ex:alignmentOf owl:inverseOf owl:hasAlignment .

ex:hasSameAlignment owl:propertyChainAxiom ( ex:hasAlignment ex:alignmentOf ) .

The issue with this is that we cannot model conjunction and negation of properties. We can use the example above to model enemies of a particular faction however:

[
  owl:intersectionOf (
    [
      a owl:Restriction ;
      owl:onProperty ex:sharesContinentWith ;
      owl:hasValue ex:SomeFaction
    ] [
      owl:complementOf [
        a owl:Restriction ;
        owl:onProperty ex:hasSameAlignment ;
        owl:hasValue ex:SomeFaction
      ]
    ]
  )
] owl:equivalentClass [
  a owl:Restriction ;
  owl:onProperty ex:isInConflict ;
  owl:hasValue ex:SomeFaction
] .

This says that any faction that shares the same continent with one specific faction and does not have the same alignment must be related to the faction is ex:isInConflict.

I am not sure if there is a better way, but I will update this answer if I find one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...