Use OWL Restriction in SWRL Rule

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Use OWL Restriction in SWRL Rule

LuisBraga
Hi!

Is it possible to write swrl rules like Person(?p), Topic(?t) -> (researchTopics value ?t)(?p) ?

I know that I don't need to use a swrl rule to do this, but this is just an example. I will need to do something more complex, but based in this principle.

Thanks in advance,
Luís Braga
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

Martin O'Connor

The SWRL language allow this (cf. [1]) but I am not sure the editor in Protege 4 supports it. Protege 3 does not support
this syntax yet.

In general, you can always substitute a named class for the class expression

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLLanguageFAQ#nid8JP

On 5/30/2011 1:49 AM, Lukapt wrote:

> Hi!
>
> Is it possible to write swrl rules like Person(?p), Topic(?t) ->
> (researchTopics value ?t)(?p) ?
>
> I know that I don't need to use a swrl rule to do this, but this is just an
> example. I will need to do something more complex, but based in this
> principle.
>
> Thanks in advance,
> Luís Braga
>
> --
> View this message in context: http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Use-OWL-Restriction-in-SWRL-Rule-tp3560207p3560207.html
> Sent from the Protege OWL mailing list archive at Nabble.com.
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

LuisBraga
Thanks for your answer.

Could I do that even if the class expression contains variables?

After presenting the doubt, I examined the ontology swrl.owl.
From what I saw a ClassAtom must contain a predicate (an owl: Class) and an argument.

In this case the predicate is an anonymous class (an owl: Restriction). However I need this owl: Restriction contain variables, and do not know how to do it.

I've tried to implement this rule directly in xml. Here is an example a similar rule, without variables in the class expression:

Person(?p) -> (researchTopics value semanticWeb)(?p)

<swrl:Variable rdf:about="urn:swrl#p"/>
    <swrl:Imp>
        <swrl:body>
            <swrl:AtomList>
                <rdf:first>
                    <swrl:ClassAtom>
                        <swrl:classPredicate rdf:resource="http://myOntology#Person"/>
                        <swrl:argument1 rdf:resource="urn:swrl#p"/>
                    </swrl:ClassAtom>
                </rdf:first>
                <rdf:rest rdf:resource="&rdf;nil"/>
            </swrl:AtomList>
        </swrl:body>
        <swrl:head>
            <swrl:AtomList>
                <rdf:rest rdf:resource="&rdf;nil"/>
                <rdf:first>
                    <swrl:ClassAtom>
                        <swrl:classPredicate>
                            <owl:Restriction>
                                <owl:onProperty rdf:resource="http://myOntology#researchTopics"/>
                                <owl:hasValue rdf:resource="http://myOntology#semanticWeb"/>>
                            </owl:Restriction>
                        </swrl:classPredicate>
                        <swrl:argument1 rdf:resource="urn:swrl#p"/>
                    </swrl:ClassAtom>
                </rdf:first>
            </swrl:AtomList>
        </swrl:head>
    </swrl:Imp>

But what should I do to use a variable in the class expression, instead of a static expression?

Person(?p), Topic(?t) -> (researchTopics value ?t)(?p)
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

Thomas Russ
In reply to this post by Martin O'Connor
But can the OWL class expressions used in SWRL refer to query  
variables like in
    (researchTopics value ?t)
from the example below?  Or do they need to be constants?

On May 31, 2011, at 9:46 AM, Martin O'Connor wrote:

>
> The SWRL language allow this (cf. [1]) but I am not sure the editor  
> in Protege 4 supports it. Protege 3 does not support this syntax yet.
>
> In general, you can always substitute a named class for the class  
> expression
>
> Martin
>
> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLLanguageFAQ#nid8JP
>
> On 5/30/2011 1:49 AM, Lukapt wrote:
>> Hi!
>>
>> Is it possible to write swrl rules like Person(?p), Topic(?t) ->
>> (researchTopics value ?t)(?p) ?
>>
>> I know that I don't need to use a swrl rule to do this, but this is  
>> just an
>> example. I will need to do something more complex, but based in this
>> principle.
>>
>> Thanks in advance,
>> Luís Braga
>>
>> --
>> View this message in context: http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Use-OWL-Restriction-in-SWRL-Rule-tp3560207p3560207.html
>> Sent from the Protege OWL mailing list archive at Nabble.com.
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

Martin O'Connor
No - I don't think class expressions can refer to variables.

Martin

On 5/31/2011 2:01 PM, Thomas Russ wrote:

> But can the OWL class expressions used in SWRL refer to query variables like in
>    (researchTopics value ?t)
> from the example below?  Or do they need to be constants?
>
> On May 31, 2011, at 9:46 AM, Martin O'Connor wrote:
>
>>
>> The SWRL language allow this (cf. [1]) but I am not sure the editor in Protege 4 supports it. Protege 3 does not
>> support this syntax yet.
>>
>> In general, you can always substitute a named class for the class expression
>>
>> Martin
>>
>> [1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLLanguageFAQ#nid8JP
>>
>> On 5/30/2011 1:49 AM, Lukapt wrote:
>>> Hi!
>>>
>>> Is it possible to write swrl rules like Person(?p), Topic(?t) ->
>>> (researchTopics value ?t)(?p) ?
>>>
>>> I know that I don't need to use a swrl rule to do this, but this is just an
>>> example. I will need to do something more complex, but based in this
>>> principle.
>>>
>>> Thanks in advance,
>>> Luís Braga
>>>
>>> --
>>> View this message in context:
>>> http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Use-OWL-Restriction-in-SWRL-Rule-tp3560207p3560207.html
>>> Sent from the Protege OWL mailing list archive at Nabble.com.
>>> _______________________________________________
>>> protege-owl mailing list
>>> [hidden email]
>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

Thomas Russ
In reply to this post by LuisBraga

On May 30, 2011, at 1:49 AM, Lukapt wrote:

> Hi!
>
> Is it possible to write swrl rules like Person(?p), Topic(?t) ->
> (researchTopics value ?t)(?p) ?
>
> I know that I don't need to use a swrl rule to do this, but this is  
> just an
> example. I will need to do something more complex, but based in this
> principle.

I don't know if you can use variables in the class expression.  I  
would guess probably not, but I'm sure Martin O'Connor will give a  
definitive answer.

For your particular case, you can in effect make the inference work  
the other way.

As it is set up in your rule, you are asserting membership in a class  
which then forces a particular value for a property filler.  Instead,  
it would be possible and to my mind simpler to just make the base  
assertions that you need.  If you find that having a class defined  
based on that particular assertion, you can always define it and then  
have inference identify the individuals that satisfy the description.

So your example rule would become:
     Person(?p), Topic(?t) ->  researchTopics(?p,?t)

which should accomplish the same net effect.  Certainly using a value  
restriction from an anonymous class description doesn't make much  
sense, since there are easier ways to do that.  Some of the other  
restrictions such as cardinality restrictions would be more  
interesting, because you must use class descriptions to assert them.  
So, I don't think that you can build anything like

     pCount(?p, ?n) -> (p => ?n)(?p)

to turn the value of a property into a cardinality restriction.


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

LuisBraga
Thanks for your answers.

You're right Thomas, I don't need to use a restriction to do that. This was just a simple example. If I could use variables in class expressions it would solve my problem. In fact, what I need is a bit more complex.

Suppose that we have a domain ontology (let's say, ISWC.owl [1]), that is not temporally characterized. We want to add a temporal dimension, so we can say that, for instance, the concept of Project is something that occurs in some period of the universal timeline. Besides that, we must also be able to say that some relation holds during some period of time. For instance, let’s say that the relation "involvedInProject" between some Person and some Project is true during some period of time.

The next figure represents a very small excerpt of ISWC ontology, used as use case for this example.


Saying that an relation holds during some period could be achieved by adding one parameter to the relation: involvedInProject(Person,Project,TimeInterval).

But because OWL is about triples, only we have is binary predicates. To overcome this problem Noy and Rector developed an ontology pattern [2]. This is the pattern that we are currently considering to model n-ary relations in OWL.
So, according to this pattern, if we want to say that some Person is involded in some project during some period of time we should create a new class to represent the n-ary relation:
involvedInProject(Person,ProjectRelation).
hasValue(ProjectRelation,Project).
during(ProjectRelation,TimeInterval).

Proceeding similarly for the relation researchTopics(Person,Topic), we get the ontology presented in the next figure:


Now, suppose that we had previously defined that if some Person is involved in some Project, then that Person does research about the Topics that this Project is about.
This could be achieved through the following swrl rule:
iswc:Person(?person),
iswc:Project(?project),
iswc:Topic(?topic),
iswc:involvedInProject(?person,?project),
iswc:isAbout(?project,?topic)
        -> iswc:researchTopics(?person,?topic)

However, we changed the original ontology, adding the temporal dimension. In this particular case we probably want to change the swrl rule so it can infer the research topics of some Person during some TimeInterval based on his Project participation at some TimeInterval.
This could be achieved by making some changes to the original swrl rule, namely:
- get the time interval of the Person participation over project, searching through the new relation created to reflect n-ary predicates;
- create a new instance to play the role of reification;
- infer relations of the new instance.
iswc:Person(?person),
iswc:Project(?project),
iswc:Topic(?topic),
iswc:involvedInProject(?person,?projectRel),
iswc:hasValue(?projectRel,?project),
time:during(?projectRel,?timeInterval),
iswc:isAbout(?project,?topic),
swrlx:makeOWLThing(?personTopicRel,?topic)
        -> iswc:researchTopics(?person,?personTopicRel),
                iswc:hasValue(?personTopicRel,?topic),
                time:during(?personTopicRel,?timeInterval).
               
The problem is that reasoners such Pellet, Hermit or Fact++ doesn't allow the creation of new entities at reasoning time (because saffety reasons), so it's not possible to create the necessary structure for representing infered n-ary relations. We know that Jess reasoner use the built-in swrlx:makeOWLThing to create new anonymous instances at reasoning time, but unfortunatly it is a commercial reasoner.

Other way to achieve that could be using a class expression:
iswc:Person(?p),
iswc:Project(?proj),
time:TemporalRelation(?projectRel),
time:TimeInterval(?time),
iswc:Topic(?topic),
time:during(?projectRel, ?time),
iswc:involvedInProject(?p, ?projectRel),
iswc:isAbout(?proj, ?topic)
        -> iswc:researchTopics some
                (TemporalRelation and ((during value ?time) and (hasValue value ?topic)))(?p)

But as you and Martin said, this is not an option, because we can not use variables in class expressions.

I hope the explanation was not too confusing. I'm out of ideas right now.


[1] - http://annotation.semanticweb.org/iswc/iswc.owl
[2] - http://www.w3.org/TR/swbp-n-aryRelations/

Reply | Threaded
Open this post in threaded view
|

Re: Use OWL Restriction in SWRL Rule

Martin O'Connor
On 6/1/2011 3:19 AM, Lukapt wrote
>
> The problem is that reasoners such Pellet, Hermit or Fact++ doesn't allow
> the creation of new entities at reasoning time (because saffety reasons), so
> it's not possible to create the necessary structure for representing infered
> n-ary relations. We know that Jess reasoner use the built-in
> swrlx:makeOWLThing to create new anonymous instances at reasoning time, but
> unfortunatly it is a commercial reasoner.

The ability to 'create' individuals on the fly in SWRL is essential for many tasks (as you have discovered). However,
SWRL does not really support this creation in a convenient way. The use of the owl:someValuesFrom property restriction
provides a possible mechanism for doing this (as you are attempting) but it is very limited. (And for reasons of
DL-safety [1] current reasoners will not even do this much.)

So you are stuck with using the swrlx:makeOWLThing built-in [2], which is non standard. As you noted, this built-in is
currently only supported by the SWRLTab, which requires the commercial Jess back end for inference (though it is free
for academic and US government users). However, I hope to have an open source Drools back end available later this year.

BTW, there is also a temporal built-in library available in the SWRLTab, which may help you with temporal operations. In
addition to built-ins, it also provides a valid-time temporal model. Again, however, it is only supported in the SWRLTab
using the Jess back end.

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLLanguageFAQ#nid9VC
[2] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLExtensionsBuiltIns
[3] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTemporalBuiltIns
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03