oracle-samples / clara-examples

Example Clara Rules
Apache License 2.0
89 stars 32 forks source link

Issue 9: Add example that demonstrates truth maintenance #12

Closed WilliamParker closed 7 years ago

WilliamParker commented 7 years ago

Output of "lein run -m clara.examples" with this branch:

Shopping examples:
VIP shopping example:
10 % :vip discount???
Summer special and widget promotion example:
20 % :summer-special discount???
Free :lunch for promotion :free-lunch-with-gizmo
Free :widget for promotion :free-widget-month

JavaBean Shopping examples from Clojure:
Promotion: Awesome promotion for our favorite VIP!

JavaBean Shopping examples from Java:
Query result: DESCRIPTION: Awesome promotion for our favorite VIP!

Validation examples:
Failed validation:
Validation issue:  HVAC repairs must include a 27B-6 form.
Validation issue:  Insufficient time prior to due date of the large order.
Validation with appropriate client tier and paperwork.

Sensor examples:
Reducing speed of  #clara.examples.sensors.Device{:id 456, :location :room-1}
Reducing speed of  #clara.examples.sensors.Device{:id 123, :location :room-1}
ALERT: temperature of 130 at :room-1 in sector :sector-5
Increasing speed of  #clara.examples.sensors.Device{:id 123, :location :room-1}
Increasing speed of  #clara.examples.sensors.Device{:id 456, :location :room-1}

Discounts when a customer is both a NewCustomer and a ValuedCustomer:  ({:?order-id 1, :?amount 20} {:?order-id 1, :?amount 5} {:?order-id 1, :?amount 5})
Discounts when the customer is noted as new twice in the session:  ({:?order-id 1, :?amount 5} {:?order-id 1, :?amount 5})
Discounts when there is a CustomerAppreciationDay, but it does not match the CurrentDay:  ()
Discounts when an Order matches both branches of clojure.core/or :  ({:?order-id 3, :?amount 10})

Boolean expression examples:
Discounts when a customer is both a NewCustomer and a ValuedCustomer:  ({:?order-id 1, :?amount 20} {:?order-id 1, :?amount 5} {:?order-id 1, :?amount 5})
Discounts when the customer is noted as new twice in the session:  ({:?order-id 1, :?amount 5} {:?order-id 1, :?amount 5})
Discounts when there is a CustomerAppreciationDay, but it does not match the CurrentDay:  ()
Discounts when an Order matches both branches of clojure.core/or :  ({:?order-id 3, :?amount 10})

Fact type options examples:
Query result with a fact of type :temperature-reading :  ({:?good-weather false})
Query result with a custom ancestors function and a fact with a type that descends from :temperature-reading :  ({:?good-weather false})

Truth maintenance examples: 
Initial cold temperatures:  ({:?temperature -10} {:?temperature 20})
Initial local temperature records:  ({:?high 110, :?low -10, :?loc MCI} {:?high 90, :?low 20, :?loc LHR})
Initial locations that have never been below 0:  ({:?loc LHR})

Now add a temperature of -5 to LHR and a temperature of 115 to MCI
New cold temperatures:  ({:?temperature -10} {:?temperature 20} {:?temperature -5})
New local temperature records:  ({:?high 90, :?low -5, :?loc LHR} {:?high 115, :?low -10, :?loc MCI})
New locations that have never been below 0:  ()

Now we retract the temperature of -5 at LHR
Cold temperatures with this retraction:  ({:?temperature -10} {:?temperature 20})
Local temperature records with this retraction:  ({:?high 90, :?low 20, :?loc LHR} {:?high 115, :?low -10, :?loc MCI})
Locations that have never been below zero with this retraction:  ({:?loc LHR})
rbrush commented 7 years ago

LGTM