;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; ------------------------------------------------------------------------- ;;;; File name: kappa-tests.lsp ;;;; System: Companions ;;;; Author: Tom Hinrichs ;;;; Created: November 7, 2003 09:13:21 ;;;; Purpose: test quantification scoping ;;;; Modified: Wednesday, November 12, 2003 at 15:38:31 by hinrichs ;;;; ------------------------------------------------------------------------- (in-package :cl-user) (defun fire::kappa-test-reasoner (&optional (title "Kappa backchaining test")) (unless (fire::open-kb? fire::*kb*) (setf fire::*kb* nil) ;; Clear the clause indexes by creating a new kb (fire::make-qrg-darpa-kb) ;; Set up KB (setq r (fire::make-reasoner title)) (fire::in-reasoner data::r) (fire::add-eval-source r) (load-file fire:*fire-path* "evalfns")) ; support FunctionToArg (setf (fire::clause-indexes fire::*kb*) nil)) (defun test-kappa1 () (fire::kappa-test-reasoner) (fire::create-clause-index-from-axioms "Kappa Test1" '((implies (isa ?PRODUCT ProductType) (positivelyDependsOn ?PRODUCT basicPriceForType (Kappa (?ITEM ?RATE) (demandRate America ?ITEM ?RATE)))))) (fire::add-clause-index-to-reasoner "Kappa Test1" fire::*reasoner*) (ltre::assume! '(isa DuctTape ProductType) :classic) (ltre::assume! '(holdsIn (AlertLevelFn Orange) ; <- This needs to be a temporal object! (demandRate America DuctTape (MediumAmountFn Rate))) :classic) (ltre::assume! '(holdsIn (AlertLevelFn Red) (demandRate America DuctTape (HighAmountFn Rate))) :classic) ) ;;; Want to set this up so we can ask what will happen to the price of DuctTape ;;; when the AlertLevel goes from Orange to Red... #|| "(negativelyDependsOn ?SET ?DEP-SLOT ?INDEP-SLOT) means that the values for ?DEP-SLOT are negatively dependent on the values for ?INDEP-SLOT, for elements of ?SET. In other words, if the value for ?INDEP-SLOT is high for an arbitrary element of ?SET, then the value for ?DEP-SLOT will be low (and vice versa: high if low)." (implies (isa ?PRODUCT ProductType) (negativelyDependsOn ?PRODUCT basicPriceForType (Kappa (?ITEM ?RATE) (supplyRate PlanetEarth ?ITEM ?RATE)))) ;;; Note: There is no lambda, but it can be faked with FunctionToArg and Kappa. E.g.: ;;; (FunctionToArg 2 (Kappa (?PERSON ?NAME) (and (father ?PERSON ?FATHER) (lastName ?FATHER ?NAME)))) ;;; is the function to return a person's father's last name. ;;; Note: FunctinToArg is implemented in the evalfns of the eval-source. ||# (defun trace-bc () (trace fire::do-query fire::query-clause fire::explore-other-terms fire:ask fire::use-single-term-clause fire::applicable-clauses fire::do-existential-query fire::do-universal-query) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; End of Code