KReS/KReSRuleLanguage

From STLab

Jump to: navigation, search
  • KReSRule Syntax
R := expr exprL
 
expr := suffix exprL
 
exprL := "." expr | ~
 
suffix := literal ( "=" | rule )
 
rule := "[" ruleDef "]"
 
ruleDef := atoms "->" atoms
 
atoms := atom atomsRest
 
atomsRest := "." atoms | ~
 
atom :=   classAtom
        | objectPropertyAtom
	| dataPropertyAtom
	| dataRangeAtom
	| sameAsAtom
	| differentFromAtom
 
classAtom := "is" "(" iObject "," iObject ")"
 
objectPropertyAtom := "has" "(" iObject "," iObject "," iObject ")"
 
dataPropertyAtom := "values" "(" iObject "," iObject "," dObject ")"
 
dataRangeAtom := "range" "(" iObject "," dObject ")"
 
sameAsAtom := "same" "(" iObject "," iObject ")"
 
differentFromAtom := "different" "(" iObject "," iObject ")"
 
iObject := variable | resource
 
dObject := String | double | int | float | boolean | variable
 
variable := "?" ([ "0"-"9","a"-"z","A"-"Z","-", "_"])+
 
resource :=   uri 
	    | literal ":" literal
 
uri := "<" ([ "0"-"9","a"-"z","A"-"Z","-", "_", ".", "#", ":", "/" ])+ ">"
 
literal := ([ "0"-"9","a"-"z","A"-"Z","-", "_"])+
  • Example: The following KReSRule code:
myOnt = <http://kres.iksproject.eu/myOnt.owl#> .
 
rule1[ has(myOnt:hasParent, ?x1, ?x2) . 
            has(<http://kres.iksproject.eu/myOnt.owl#hasSibling >, ?x2, ?x3) .
            has(myOnt:hasSex, ?x3, <http://kres.iksproject.eu/genders.owl#male>)
       ->
       has(myOnt:hasUncle ?x1, ?x3) ]

is equivalent to this SWRL

<swrl:Variable rdf:ID="x1"/>
<swrl:Variable rdf:ID="x2"/>
<swrl:Variable rdf:ID="x3"/>
<ruleml:Imp> 
  <ruleml:body rdf:parseType="Collection">
    <swrl:IndividualPropertyAtom> 
      <swrl:propertyPredicate rdf:resource="http://kres.iksproject.eu/myOnt.owl#hasParent"/> 
      <swrl:argument1 rdf:resource="#x1" />
      <swrl:argument2 rdf:resource="#x2" />
    </swrl:IndividualPropertyAtom>
    <swrl:IndividualPropertyAtom> 
      <swrl:propertyPredicate rdf:resource="http://kres.iksproject.eu/myOnt.owl#hasSibling"/> 
      <swrl:argument1 rdf:resource="#x2" />
      <swrl:argument2 rdf:resource="#x3" />
    </swrl:IndividualPropertyAtom>
    <swrl:IndividualPropertyAtom> 
      <swrl:propertyPredicate rdf:resource="http://kres.iksproject.eu/myOnt.owl#hasSex"/> 
      <swrl:argument1 rdf:resource="#x3" />
      <swrl:argument2 rdf:resource="http://kres.iksproject.eu/genders.owl#male" />
    </swrl:IndividualPropertyAtom>
  </ruleml:body>
  <ruleml:head rdf:parseType="Collection"> 
    <swrl:IndividualPropertyAtom> 
      <swrl:propertyPredicate rdf:resource="http://kres.iksproject.eu/myOnt.owl#hasUncle"/> 
      <swrl:argument1 rdf:resource="#x1" />
      <swrl:argument2 rdf:resource="#x3" />
    </swrl:IndividualPropertyAtom>
  </ruleml:head> 
</ruleml:Imp>
Personal tools