If X is the parent of Y and X is brother of Z then Z is the uncle of Y
uncle(Z,Y):-parent(X,Y),brother(X,Z).
Uncle definition
Adrian Giurca
Gerd Wagner
Sergey Lukichev
Uncle Rule
REWERSE I1 Rules Markup Language
2006-04-06
The succesor of a natural number is a natural number
natural_number(succ(N)):-natural_number(N).
Defining natural numbers
Adrian Giurca
Gerd Wagner
Sergey Lukichev
Successor Rule
2006-04-06
A customer is premium if their spending has been min 5000 euro in the previous year.
premium
`customer`
spending
`customer`
min 5000 euro
previous year
Adrian Giurca
Premium customer
http://www.ruleml.org/papers/tutorial-ruleml-20050513.html
2006-04-05
The discount for a customer buying a product is 7.5 percent if the customer is premium and the product is luxury.
discount
`customer`
`product`
7.5 percent
premium
`customer`
luxury
`product`
RuleML example in R2ML
Adrian Giurca
Give discount
http://www.ruleml.org/papers/tutorial-ruleml-20050513.html
2006-04-05
FORALL X,Y,Z X[ancestor->>Y] - X[father->Z] AND Z[ancestor->>Y].
A rule from ancestor definition in F-Logic
Adrian Giurca
http://www.ontoprise.de/content/e2/e29/e30/e490/e600/F-Logic_Tutorial_eng.pdf
2006-05-05
SQL View as derivation rule
Adrian Giurca
Gerd Wagner
Sergey Lukichev
SQL View Example
2006-04-07
If rental car is stored at the branch and it is not assigned to a rental and it is not scheduled for service, then rental car is available at the branch.
context Branch::availableCar: RentalCar derive:
self.storedCar -> select (c |
not oclIsKindOf(RentalCarScheduledForService)
and c.Rental --> isEmpty()
)
Sergey Lukichev
Gerd Wagner
Adrian Giurca
2006-04-07
If a rental car has more than 90 days or more than 5000 km since the last service then rental car is a rental car scheduled for service.
context RentalCar:: isScheduledForService:Boolean derive:
last_maintenance_date >=90 or service_reading>5000
Sergey Lukichev
Gerd Wagner
Gerd Wagner
2006-03-30
If a person is male and no bachelor then he is maried and a husband.
Marco Pehla
Gerd Wagner
2006-04-05
Any person who was some time in the last 2 months an employee of an organization which was some time in the last 2 months a W3C member may register.
Marco Pehla
Adrian Giurca
authentication
http://www.ruleml.org/0.9/exa/authenticate.ruleml
11-05-2006
may register
`any`
person
`any`
organization
`org`
employee in
`any`
`org`
last
month
2
member in
`org`
W3C
last
month
2
a simplified broker definition
Marco Pehla
Adrian Giurca
broker
http://www.ruleml.org/0.9/exa/broker.ruleml
24-05-2006
buy
`broker`
`prod`
want
customer-of-broker
`prod`
deal
`prod`
cost
prod
benefit-of-prod
A person owns an object if it buys the object from a merchant and the keeps it.
Marco Pehla
Adrian Giurca
own
http://www.ruleml.org/0.9/exa/own.ruleml
29-05-2006
own
`person`
`object`
buy
`person`
`merchant`
`object`
keep
`person`
`object`
If you want to review rule principles, you may have a look at the rule based system at http://www.cs.brandeis.edu .
Marco Pehla
Adrian Giurca
recommend
http://www.ruleml.org/0.9/exa/recommend.ruleml
30-05-2006
may look at
`you`
Rule-Based Systems
want to review
`you`
rule principles
want to review
fred
rule principles
If the order value is greater than 1000 and the customer type is not gold then give a 10% discount.
when {
IlrContext() from ?context;
evaluate(orderValue >=1000 and !(customerRating equals "Gold"));
}
then discount = 10
Sergey Lukichev
Gerd Wagner
2006-04-05
If the person age is less than 3 then send him a greeting.
(defrule welcome-toddlers "Give a special greeting to young children"
(< ( age ?person) 3) => (printout ?person "Hello, little one!" crlf))
Give a special greeting to young children
Adrian Giurca
Gerd Wagner
Sergey Lukichev
welcome-toddlers
REWERSE I1 Rules Markup Language
2006-03-30
If the person age is less than 3 then send him a greeting.
(defrule aRule (Person (name ?x))(Man (name ?y))
(hasSibling ?x ?y)(hasAge ?x ?a1)
(hasAge ?y ?a2)(test (> ?age2 ?age1))
=> (assert (hasOlderBrother ?x ?y))
Adrian Giurca
http://www.med.univ-rennes1.fr/~cgolb/Protege2005/SWRLJessOConnor.pdf
2006-05-05
If reservation date of a rental is 5 days in advance then give rental a 10 % discount.
Adrian Giurca
Gerd Wagner
2006-04-05
If rental is not a one way rental then return branch of rental must be the same as pick-up branch of a rental.
Sergey Lukichev
Gerd Wagner
Adrian Giurca
2006-03-30
Each additional driver of a rental must be a qualified driver
Sergey Lukichev
If customer returns a car and the car has more than 5000km from the last service then send the car to the service
on car_returned(car,customer)
if car.odometer_reading-car.lastservice.odometer_reading>5000
do service(car)
Send a car to service
Jens Dietrich
Gerd Wagner
Adrian Giurca
SendCar
REWERSE I1 Rules Markup Language
2006-04-05
On a car request, if the car is available then send approval and mark the ordered car as sold.
on productOrder(VW, customer)
if AvailableCar(VW)
do approveOrder(VW, customer)
Sergey Lukichev
Adrian Giurca