protege DataProperties compare - owl

I have defined a class named "accelerate", set "Equivalent To" function as follow:
currentSpeed some xds:int [ < minSpeed ]
currentSpeed and minSpeed are DataProperties, and these value are assignmented by instance,
for example, create instance currentSpeed=25 minSpeed=30, compare them we know, currentSpeed is less than minSpeed, so I want protege can infer accelerate.
however it does not work, please help me.

Open protege swrltab
Add rule:
car(?c) ^ currentSpeed(?c, ?x) ^ minSpeed(?c, ?y) ^ swrlb: greaterThan(?y, ?x) -> accelerate(?c)

Related

SWRL Rules with data property values and range

I am writing a SWRL rule in OWL which can infer if a person is of driving age or not.
Person(?p), xsd:int[>= "18"^^xsd:int <= "65"^^xsd:int](?age), hasAge(?p, ?age) -> isDriverAge(?p, "True"xsd:Boolean)
It gives me Unexpected Character '[' error
I saw similar syntax for Object Property (found here: https://dior.ics.muni.cz/~makub/owl/ ) but that is also not working when I tweaked my ontology as per this code:
Person(?p), int[>= 18 , <= 65](?age), hasAge(?p, ?age) -> hasDriverAge(?p, True)
If you know the answer, could you please also provide me a resource which I can refer to write these rules. I don't want to keep coming back to stack and eat up other dev's time. Thanks

How to infer an object property based on data properties?

I'm a protégé newbie and did the pizza tutorial and read the 101 documentation. I'm trying to model a ontology like the following picture:
I have a person who has a style. The style can be a style_active or style_passive.
This style is determined by a index of two data properties:
ind_passive and ind_active, the bigger value should infer the style.
I had to create two individuals: style_active and style_passive, because they must be individuals to be assigned to the object property has_style.
How to infer the value of has_style object property based on ind_passive and ind_active data properties? Using a reasoner?
Is something wrong with this model?
I suceed in calculate the value of style object property based on two swrl rules. It does not work with a reasoner like HermiT (default in Protégé 5.5), but works in SWRLTab, that uses Drools.
The rules I used:
Name: Passive
Rule: Person(?p) ^ ind_passive(?p, ?ip) ^ ind_active(?p, ?ia) ^ swrlb:greaterThan(?ip, ?ia) -> has_style(?p, style_passive)
Name: Active
Rule: Person(?p) ^ ind_passive(?p, ?ip) ^ ind_active(?p, ?ia) ^ swrlb:greaterThan(?ia, ?ip) -> has_style(?p, style_active)
The reasoner Hermit could not be enabled after using this rules, because it does not supports "built-in atoms", like swrlb:greaterThan.

SWRL - Unable to substract date time by duration

I'm trying to implement a rule that substract 1 years to a datetime and asign it to a data property using only SWRL
I've got an entity Product which got a data property creationDate equal to 2019-07-15T00:00:00.
My SWRL rule is the following :
Product(?p) ^ creationDate(?p, ?cd) ^ swrlb:yearMonthDuration(?dur, 1, 0)
^ swrlb:subtractYearMonthDurationFromDateTime(?result, ?cd, ?dur)
-> Product(?p) ^ yearBeforeCreation(?p, ?result)
I expect to get yearBeforeCreation equal to 2018-07-15T00:00:00
Right now I've tried the SWRL with Pellet and Drools
Thanks for your help !
I manage to make my SWRL work, look like it was something with protege. I've close/open, rewrite my rule and it work.

OWL-API: making a set of individuals equivalent to owl:Thing

I'm trying to add an equivalent axiom of the following form:
owl:Thing EquivalentTo {individual1, indivdual2, ... individualN}
Below is how I'm trying to add the axiom:
String individualSet = "{a, b, c, d}"
OWLAxiom a = df.getOWLEquivalentClassesAxiom(df.getOWLClass(individualSet), df.getOWLThing());
manager.addAxiom(ontology, a);
The problem is that this actually creates an extra class with the name "{a, b, c, d}", which prevents a reasoner from making right conclusions as intended.
In Protege, I can add this type of Equivalent To axiom without resulting in an extra class... How can I do the same with OWL-API?
I figured it out. I had to use OWLObjectOneOf to compose a set of individuals and make that equivalent to owl:Thing.

SWRL for choosing the right value?

I'm trying to create an ontology of latin squares and make the reasoner solve it (starting with a simple 2x2 square and going from there) without much success.
The major problem I'm having is writing a rule in a way that sees what values are missing from the square.
I'm using dataProperty hasValue as an integer.
Something like:
Cell(?cell1) ^ hasValue(?cell1,?number1) ^
Cell(?cell2) ^ hasValue(?cell2,?number2) ^
Cell(?cell3) ^ hasValue(?cell3,?number3) ^
Cell(?cell4) ^ differentFrom(?number1, ?number2)
=>
hasValue(?Cell4,"desired result")
Thanks in advance.

Resources