简体   繁体   中英

SWRL - using knowledge from classes

I want to use knowledge, which is modelled between classes. Eg I have modelled a car and a bus have 4 wheels, a bike 2 wheels. Now, I want to express that bike can tip (if you don't keep them in balance - incompetent driver). If I add an instance "CB450", subClassOf Bike, a rule should enable reasoning: . Way:

Type(Cb450,Bike) and has(Bike,TwoWheels) and can(TwoWheels,Tip) -> can (CB450,Tip)

I did not find any way to express this rule in SWRL, or Jena rules. Is there a possibility?

I know that it can be modelled differently, but I need to use class relations for rules in instances.

I use Protege 5.16 with pellet 2.3.1. See the example ontology below

Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>

Ontology: <http://www.semanticweb.org/vehicle>
ObjectProperty: <http://www.semanticweb.org/vehicle#has>
ObjectProperty: <http://www.semanticweb.org/vehicle#can>

Class: <http://www.semanticweb.org/vehicle#Car>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Vehicle>,
    <http://www.semanticweb.org/vehicle#has> some <http://www.semanticweb.org/vehicle#FourWheels>

Class: <http://www.semanticweb.org/vehicle#Vehicle>
Class: <http://www.semanticweb.org/vehicle#Bike>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Vehicle>,
    <http://www.semanticweb.org/vehicle#has> some     <http://www.semanticweb.org/vehicle#TwoWheels>

Class: <http://www.semanticweb.org/vehicle#FourWheels>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#TwoWheels>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#can> some        <http://www.semanticweb.org/vehicle#Tip>,
    <http://www.semanticweb.org/vehicle#Property>

Class: <http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#Tip>

SubClassOf: 
    <http://www.semanticweb.org/vehicle#Property>

Individual: <http://www.semanticweb.org/vehicle#CB450>

Types: 
    <http://www.semanticweb.org/vehicle#Bike>

Individual: <http://www.semanticweb.org/vehicle#Tip>

Types: 
    <http://www.semanticweb.org/vehicle#Tip>

Based on the way you have explained the problem it looks like "CB40" isn't a subclass of Bike but rather an individual of type Bike. So say you have a class Vehicle, a data property hasWheels on Vehicle and a boolean property canTip on Vehicle, you can write a SWRL rule as

Vehicle(?x) ^ hasWheels(?x, 2) -> canTip(?x, true)

which translates as "A vehicle with two wheels can tip over" . The ?x is any individual of the specified type. So if you create a class Bike as a subclass of Vehicle and an individual CB40 of that class and set all the relevant data properties a reasoner will assign the canTip property to true for CB40

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM