0

I've been trying to define rules in my ontology to infer that if a person has friends who are friends amongst each other then all are friends, but if 1 or more are not friends to each other then my ontology will infer that they all, are not friends.

my diagram

Thank you

  • 1
    Your `isFriendWith(?y)` is missing a second variable if it wants to be a relation. – dhke Mar 21 '15 at 08:13

1 Answers1

1

You probably need to get your intended semantics straightened out a little bit more.

From what I gather, you want isFriendWith at least to be symmetric, i.e. when isFriendWith(bob, alice) then also isFriendWith(alice, bob).

Also, if you want to have friendsAll to have any meaning, isFriendWith cannot be transitive. This would also capture the natural meaning, as a friend of my friend is not necessarily my friend.

To elaborate: If isFriendWith where symmetric and transitive every friend of bob would automatically also be a friend of all of bob's friends (because isFriendWith(bob, alice) implies isFriendWith(alice, bob). From there on, with any isFriendWith(bob, carol) transitivity implies that isFriendWith(alice, carol). So if isFriendWith is symmetric and transitive, you get the clique automatically.

But as stated, this is probably not, what you want.

As for formulating this in SWRL, let's give it a try, shall we?

friendsAll is most likely reflexive, i.e. let's just assume everybody is his/her own friend. Now, we need an recursive rule that extends this set while still fulfilling the condition: "In this set, everybody is everybody's friend".

To include bob's friends, you would need to be able to quantify over isFriendWith and check if that any candidate friend of bob is also a friend of all other friends of bob. Since you cannot nest quantifiers in SWRL, I'm more or less sure, you cannot express that algorithm in the rule language alone. However, I maybe wrong here and there is a neat little trick hidden inside the semantics. It is not one that I know of, however and the need for quantifier nesting in the direct formulation leaves me believing that it is not possible.

It basically boils down to a well-known graph-theoretic problem: given a starting point bob friendsAll is the largest subset of bob's friends such that every everbody in the group is friends with everyone else, i.e. bob's Maximal Clique.

dhke
  • 15,008
  • 2
  • 39
  • 56
  • Very instructive. Would you add information about "cannot be transitive"? What might the second variable be? Also, would you elaborate on O(N2) v. a SWIRL rule. I believe you are saying that SWIRL cannot solve a cliques of fixed size. Would you explain why? – Jay Gray Mar 21 '15 at 13:00
  • 1
    As I said, your question does not even get the syntax right, so I'd suggest more research wrt. OWL/DL and SWRL Rules. – dhke Mar 21 '15 at 13:26
  • 1
    I didn't ask the SO question. I was reading your useful response and asking for clarification. TY for updated response. – Jay Gray Mar 21 '15 at 13:36
  • 1
    I'm sorry, I didn't read the username. Also see edited answer. – dhke Mar 21 '15 at 13:37
  • @dhke Thank you for your great response! Sorry I've not specified very clear my rules, I've defined that property to be symmetric. Transitive could be the solution but I cannot assume that Bob and Carol are friends because of Alice. And as you said there is a Clique problem!!. Could you please help me with this other issue? I have to add a description to this relationships. For example, A isFriendWith B -> "they were students in St Vicent" I want to assign one or more descriptions to this relationship. Do I have to define another IRI or blank node, one that represents the relationship?. – user3591709 Mar 21 '15 at 22:49
  • @user3591709: I think the latter warrants another SO question. What you want is to assign properties to a relation triple. That is only possible in RDF (via *reification*) not in OWL/DL and should be avoided if possible. If you really need the information, you probably need an intermediate `Friendship` object, much like an intermediate table in a relational database – dhke Mar 23 '15 at 07:05