Project Demo
In this part, we illustrate 3 examples, simple, medium, and difficult, respectively, to test our project.
Example1 (easy)
Rule 1(simple):
x is a person and y is a man ,x has sibling y,x's age is age1 and y's age is age2,and age2 is greater than age1.So we can get the result that x has an old brother y.
This is the input rule:
Person(?x) ^ Man(?y) ^ hasSibling(?x,?y) ^
hasAge(?x,?agel) ^ hasAge(?y,?age2)^
swrlb:greaterThan(?age2,?age 1)一>
hasOlderBrother(?x,?y)
x is a person and y is a man ,x has sibling y,x's age is age1 and y's age is age2,and age2 is greater than age1.So we can get the result that x has an old brother y.
This is the input rule:
Person(?x) ^ Man(?y) ^ hasSibling(?x,?y) ^
hasAge(?x,?agel) ^ hasAge(?y,?age2)^
swrlb:greaterThan(?age2,?age 1)一>
hasOlderBrother(?x,?y)
Example2 (medium)
Rule 2(medium):
Individuals under the age of 18 are a potential driver of a vehicle with a weight of less than 26,000 lbs in California if they possess an
out-of-state driver’s license and are visiting the state for less than 10 days.
This is the input rule:
Person(?p) ^ has_Driver_License(?p,?d) ^ issued_in_state_of(?d,?s) ^swrlb:notEqual(?s,"CA") ^ hasAge(?p,?g) ^
swrlb:lessThan(?g,18) ^ Number_of_Visiting_Days_in_CA(?p,?x) ^swrlb:lessThan(?x,10) ^ Car(?c) ^ has_weight_in_lbs(?c,?w) ^ swrlb:lessThan(?w,26000)→ Can_Drive(?p,?c)
Individuals under the age of 18 are a potential driver of a vehicle with a weight of less than 26,000 lbs in California if they possess an
out-of-state driver’s license and are visiting the state for less than 10 days.
This is the input rule:
Person(?p) ^ has_Driver_License(?p,?d) ^ issued_in_state_of(?d,?s) ^swrlb:notEqual(?s,"CA") ^ hasAge(?p,?g) ^
swrlb:lessThan(?g,18) ^ Number_of_Visiting_Days_in_CA(?p,?x) ^swrlb:lessThan(?x,10) ^ Car(?c) ^ has_weight_in_lbs(?c,?w) ^ swrlb:lessThan(?w,26000)→ Can_Drive(?p,?c)
Example3(difficult)
Rule 3(difficult):
A car has two gps,this rule is just testing an alert will be turned on or not by using gps1 and gps2 to measure the speed of the car and the distance between current position and traffic light whether it's enough to across the intersection.
This is the input rule:
Car(?car) ^ hasGPS(?car, ?gps1) ^ hasLongitude(?gps1, ?gps1Longitude) ^ hasLatitude(?gps1, ?gps1Latitude) ^ TrafficLight(?trafficLight) ^ hasSignal(?trafficLight, ?signal) ^ swrlb:equal(?signal, "Green") ^ hasGPS(?trafficLight, ?gps2) ^ hasLongitude(?gps2, ?gps2Longitude) ^ hasLatitude(?gps2, ?gps2Latitude) ^ gps:computeDistance(?gps1Longitude, ?gps1Latitude, ?gps2Longitude, ?gps2Latitude, ?distance) ^ swrlb:lessThan(?distance, 100) ^ hasSpeed(?car, ?carSpeed) ^ swrlb:divide(?carTime, ?distance, ?carSpeed) ^ hasRemainingTime(?trafficLight, ?remainingTime) ^ swrlb:greaterThan(?carTime, ?remainingTime) ^ swrlx:createOWLThing(?alert, "Alert") → Alert(?alert) ^ hasVehicle(?alert, ?car) ^ hasTrafficLight(?alert, ?trafficLight)
A car has two gps,this rule is just testing an alert will be turned on or not by using gps1 and gps2 to measure the speed of the car and the distance between current position and traffic light whether it's enough to across the intersection.
This is the input rule:
Car(?car) ^ hasGPS(?car, ?gps1) ^ hasLongitude(?gps1, ?gps1Longitude) ^ hasLatitude(?gps1, ?gps1Latitude) ^ TrafficLight(?trafficLight) ^ hasSignal(?trafficLight, ?signal) ^ swrlb:equal(?signal, "Green") ^ hasGPS(?trafficLight, ?gps2) ^ hasLongitude(?gps2, ?gps2Longitude) ^ hasLatitude(?gps2, ?gps2Latitude) ^ gps:computeDistance(?gps1Longitude, ?gps1Latitude, ?gps2Longitude, ?gps2Latitude, ?distance) ^ swrlb:lessThan(?distance, 100) ^ hasSpeed(?car, ?carSpeed) ^ swrlb:divide(?carTime, ?distance, ?carSpeed) ^ hasRemainingTime(?trafficLight, ?remainingTime) ^ swrlb:greaterThan(?carTime, ?remainingTime) ^ swrlx:createOWLThing(?alert, "Alert") → Alert(?alert) ^ hasVehicle(?alert, ?car) ^ hasTrafficLight(?alert, ?trafficLight)