LISP


;;; This is one of the example programs from the textbook:
;;;
;;; Artificial Intelligence: 
;;; Structures and strategies for complex problem solving
;;;
;;; by George F. Luger and William A. Stubblefield
;;; 
;;; These programs are copyrighted by Benjamin/Cummings Publishers.
;;;
;;; We offer them for use, free of charge, for educational purposes only.
;;;
;;; Disclaimer: These programs are provided with no warranty whatsoever as to
;;; their correctness, reliability, or any other property.  We have written 
;;; them for specific educational purposes, and have made no effort
;;; to produce commercial quality computer programs.  Please do not expect 
;;; more of them then we have intended.
;;;

;;; This is the "trees" knowledge base for use with the logic programming 
;;; shell in section14.3 os the text.  The code for the shell is in the file
;;; logic-shell.lisp.

;;; It can tell you the type of 6 different plants: obj1, obj2, obj3,
;;;   obj4, obj5, and obj6.
;;;
;;; A sample query is: (kind obj4 (var x))


(setq *assertions* '(
   
   (rule
      if (and (size (var x) tall ) (woody (var x)))
      then (tree (var x)))

   (rule
      if (and (size (var x) small ) (woody (var x)))
      then (bush (var x)))

   (rule 
      if (and (tree (var x)) (evergreen (var x))(color (var x) blue))
      then (kind (var x) spruce))

   (rule 
      if (and (tree (var x)) (evergreen (var x))(color (var x) green))
      then (kind (var x) pine))

   (rule
      if (and (tree (var x)) (deciduous (var x)) (bears (var x) fruit))
      then (fruit-tree (var x)))

   (rule 
      if (and (fruit-tree (var x)) (color fruit red) (taste fruit sweet))
      then (kind (var x) apple-tree))

   (rule 
      if (and (fruit-tree (var x)) (color fruit yellow) (taste fruit sour))
      then (kind (var x) lemon-tree))

   (rule 
      if (and (bush (var x)) (flowering (var x)) (thorny (var x)))
      then (rose (var x)))

   (rule
      if (and (rose (var x)) (color (var x) red))
      then (kind (var x) american-beauty))

      (size obj1 tall)
      (woody obj1)
      (evergreen obj1)
      (color obj1 green)
      (size obj2 tall)
      (woody obj2)
      (evergreen obj2)
      (color obj2 blue)
      (size obj3 tall)
      (woody obj3)
      (evergreen obj3)
      (color obj3 blue)
      (size obj4 tall)
      (woody obj4)
      (evergreen obj4)
      (color obj4 blue)
      (size obj5 small)
      (woody obj5)
      (deciduous obj5)
      (flowering obj5)
      (thorny obj5)
      (color obj5 red)
      (size obj6 tall)
      (woody obj6)
      (deciduous obj6)
      (bears obj6 fruit)
      (color fruit red)
      (taste fruit sweet)
))


  

Close Window