(in-package 'USER) (cl-define-concept 'SINGLE-FOOD-MEAL-COURSE '(AND MEAL-COURSE (AT-MOST 1 food))) (defun wine-is-appropriate (ind) ;; Get the first course-drink (there is only 1--this is an attribute). ;; Get the first food. This is a little funny--it just checks to ;; see if the first food is consistent. Thus, we don't need to ;; check to see if the food role is closed before returning T. ;; We also don't need to see if course-drink is closed, because it ;; is an attribute, so if it has a filler, it is closed. ;; What you might really want is ;; - to see if all the foods are consistent: you would then only ;; return T if food was closed; or ;; - if any foods are consistent: if any is consistent, you would ;; return T, whether or not the role is closed. If none were ;; consistent, return '?. (let* ((course-drink (car (cl-fillers ind @course-drink))) (food (car (cl-fillers ind @food))) (food-appropriate-drink (when food (cl-all food @appropriate-drink))) ;; (cl1 (cl-ind-closed-role? ind @course-drink)) ;; not needed--see above. ;; (cl2 (cl-ind-closed-role? ind @food)) ;; not needed--see above. ) (if (and food course-drink) ;; cl-instance? returns T if the course-drink definitely ;; satisfies the food-appropriate-drink restriction; it ;; returns Nil otherwise. It doesn't make the distinction ;; between "definitely incompatible" and "currently unknown". ;; '? is the best thing to return if cl-instance? doesn't return T. ;; However, if something gets added to ;; the food-appropriate-drink restriction later on, (if (cl-instance? course-drink food-appropriate-drink) t '?) '?))) (cl-define-concept 'APPROPRIATE-SINGLE-FOOD-MEAL-COURSE '(AND SINGLE-FOOD-MEAL-COURSE (TEST-C wine-is-appropriate) ) ) ;;(cl-create-ind 'meal1 '(and single-food-meal-course (fills food lobster) ;; (fills course-drink forman-chardonnay))) ;;(cl-create-ind 'meal2 '(and single-food-meal-course (fills food beef-curry) ;; (fills course-drink TAYLOR-PORT))) ;;(cl-create-ind 'meal3 '(and single-food-meal-course (fills food beef-curry) ;; (fills course-drink VENTANA-CHENIN-BLANC)))