fork download
  1. (defrule warm-blooded
  2. (animal ?x)
  3. (characteristic ?x warm-blooded)
  4. =>
  5. (assert (is-warm-blooded ?x)))
  6.  
  7. (defrule has-hair
  8. (animal ?x)
  9. (characteristic ?x has-hair)
  10. =>
  11. (assert (has-hair ?x)))
  12.  
  13. (defrule gives-birth-to-live-young
  14. (animal ?x)
  15. (characteristic ?x gives-birth-to-live-young)
  16. =>
  17. (assert (gives-birth-to-live-young ?x)))
  18.  
  19. (defrule mammal
  20. (is-warm-blooded ?x)
  21. (has-hair ?x)
  22. (gives-birth-to-live-young ?x)
  23. =>
  24. (printout t ?x " is a mammal." crlf))
  25.  
  26. (defrule not-mammal
  27. (animal ?x)
  28. (not (is-warm-blooded ?x))
  29. =>
  30. (printout t ?x " is not a mammal." crlf))
  31.  
  32. (deffacts initial-facts
  33. (animal dog)
  34. (characteristic dog warm-blooded)
  35. (characteristic dog has-hair)
  36. (characteristic dog gives-birth-to-live-young))
  37.  
  38. (reset)
  39. (run)
  40. (exit)
  41.  
Success #stdin #stdout 0.01s 5320KB
stdin
1
2
10
42
11
stdout
dog is a mammal.