;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: solve-popcorn-example.lsp ;;;; System: ;;;; Author: Praveen Paritosh ;;;; Created: December 11, 2003 05:54:01 ;;;; Purpose: ;;;; --------------------------------------------------------------------------- ;;;; Modified: Friday, April 16, 2004 at 13:56:08 by paritosh ;;;; --------------------------------------------------------------------------- (in-package :common-lisp-user) ;; ** Popcorn Example ;; To Run the example ;; (fire::setup-solve-test-case *popcorn-suggestions* *popcorn-facts* :KB) ;; (multiple-value-setq (ans tree) (fire::solve *popcorn-query* :response :bindings)) ;; For more solutions ;; (fire::get-solution tree) (defparameter *popcorn-suggestions* '((defSuggestion VolumeStrategyForCount (CountContained ?container ?contained ?count) :subgoals ((volumeOfObject ?container ?v1) (volumeOfObject ?contained ?v2)) :result-step (evaluate ?count (QuotientFn ?v1 ?v2))) (defSuggestion VolumeFormulaForSphere (volumeOfObject ?obj ?vol) :test (shapeOfObject ?obj SphereShape) :subgoals ((radius ?obj ?radius)) :result-step (evaluate ?vol (TimesFn 4.187 ;;4/3*Pi (ExponentFn ?radius 3)))) (defSuggestion VolumeFormulaForRectangular3DShape (volumeOfObject ?obj ?vol) :test (shapeOfObject ?obj Rectangular3DShape) :subgoals ((heightOfObject ?obj ?h) (lengthOfObject ?obj ?l) (widthOfObject ?obj ?w)) :result-step (evaluate ?vol (TimesFn ?h ?l ?w))))) ;; Knowledge that must be around (defparameter *popcorn-facts* '((isa CS381ClassRoom ClassRoom) (shapeOfObject CS381ClassRoom Rectangular3DShape) (shapeOfObject Popcorn SphereShape) (heightOfObject CS381ClassRoom 3) (lengthOfObject CS381ClassRoom 15) (widthOfObject CS381ClassRoom 10) (radius Popcorn 0.02))) ;; Query (defparameter *popcorn-query* '(CountContained CS381ClassRoom Popcorn ?number)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; End of Code