;; -*- Mode: Lisp; -*- ;;;; A simple domain theory for TGizmo ;;;; File name: tnst.lsp ;;;; modified: Thursday, February 14, 2008 at 11:25:16 by Ken Forbus ;;; Copyright (c) 1991-1993, Kenneth D. Forbus, Northwestern University, ;;; and Johan de Kleer, the Xerox Corporation. ;;; All rights reserved. ;;; See the file legal.txt for a paragraph stating scope of permission ;;; and disclaimer of warranty. The above copyright notice and that ;;; paragraph must be included in any separate copy of this file. (in-package :cl-user) (defentity (container ?can) (quantity (pressure ?can))) ;; at bottom (defentity (fluid-path ?path)) (defentity (heat-path ?path)) (defentity (physob ?phob) (quantity (heat ?phob)) (quantity (temperature ?phob)) (> (a (heat ?phob)) zero) (> (a (temperature ?phob)) zero) (qprop (temperature ?phob) (heat ?phob))) (defentity (temperature-source ?phob) (quantity (heat ?phob)) (quantity (temperature ?phob)) (> (a (heat ?phob)) zero) (> (a (temperature ?phob)) zero)) (defrule contained-stuff-existence ((container ?can)(phase ?st)(substance ?sub)) ;; Assume that every kind of substance can exist in ;; in every phase inside every container. (quantity ((amount-of ?sub ?st) ?can)) (>= (a ((amount-of ?sub ?st) ?can)) zero)) (defview (contained-stuff (c-s ?sub ?st ?can)) :individuals ((?can (container ?can) (substance ?sub) (phase ?st))) :quantity-conditions ((> (a ((amount-of ?sub ?st) ?can)) zero)) :relations ((only-during (exists (c-s ?sub ?st ?can))) (contained-stuff (c-s ?sub ?st ?can)) (quantity (tboil (c-s ?sub ?st ?can))) (> (a (tboil (c-s ?sub ?st ?can))) zero))) (defentity (contained-stuff (c-s ?sub liquid ?can)) (contained-liquid (c-s ?sub liquid ?can))) (defentity (contained-liquid (c-s ?sub liquid ?can)) (physob (c-s ?sub liquid ?can)) (quantity (level (c-s ?sub liquid ?can))) (qprop (level (c-s ?sub liquid ?can)) ((amount-of ?sub liquid) ?can)) (qprop (pressure ?can) (level (c-s ?sub liquid ?can)))) (defentity (contained-stuff (c-s ?sub gas ?can)) (contained-gas (c-s ?sub gas ?can))) (defentity (contained-gas (c-s ?sub gas ?can)) (physob (c-s ?sub gas ?can)) (qprop (pressure ?can) (temperature (c-s ?sub gas ?can))) (qprop (pressure ?can) ((amount-of ?sub gas) ?can))) ;;;; Flow processes (defprocess (heat-flow ?src ?path ?dst) :individuals ((?src (quantity (heat ?src))) (?path (heat-connection ?path ?src ?dst)) (?dst (quantity (heat ?dst)))) :preconditions ((heat-aligned ?path)) :quantity-conditions ((> (a (temperature ?src)) (a (temperature ?dst)))) :relations ((quantity (flow-rate ?self)) (> (a (flow-rate ?self)) zero) (qprop (flow-rate ?self) (temperature ?src)) (qprop- (flow-rate ?self) (temperature ?dst))) :influences ((i- (heat ?src) (flow-rate ?self)) (i+ (heat ?dst) (flow-rate ?self)))) (defprocess (fluid-flow (c-s ?sub ?st ?src) ?path ?dst) :individuals ((?src (container ?src) (substance ?sub) (phase ?st)) (?path (fluid-connection ?path ?src ?dst)) (?dst (container ?dst))) :preconditions ((aligned ?path)) :quantity-conditions ((> (a ((amount-of ?sub ?st) ?src)) zero) ;;; (> (a ((amount-of ?sub ?st) ?dst)) zero) ; simplification (> (a (pressure ?src)) (a (pressure ?dst)))) :relations ((quantity (flow-rate ?self)) (> (a (flow-rate ?self)) zero) (qprop (flow-rate ?self) (pressure ?src)) (qprop- (flow-rate ?self) (pressure ?dst))) :influences ((i- ((amount-of ?sub ?st) ?src) (flow-rate ?self)) (i+ ((amount-of ?sub ?st) ?dst) (flow-rate ?self)))) ;;;; Phase changes (defprocess (boiling (c-s ?sub liquid ?can) (heat-flow ?ht-src ?hpath (c-s ?sub liquid ?can))) :individuals ((?sub (substance ?sub)) (?can (container ?can) (contained-liquid (c-s ?sub liquid ?can))) (?hpath (heat-path ?hpath)) (?ht-src (heat-connection ?hpath ?ht-src (c-s ?sub liquid ?can)))) :quantity-conditions ((> (a ((amount-of ?sub liquid) ?can)) zero) (active (heat-flow ?ht-src ?hpath (c-s ?sub liquid ?can))) (>= (a (temperature (c-s ?sub liquid ?can))) (a (tboil (c-s ?sub liquid ?can))))) :relations ((quantity (generation-rate ?self)) (:implies (exists (c-s ?sub gas ?can)) (= (a (temperature (c-s ?sub gas ?can))) (a (temperature (c-s ?sub liquid ?can))))) (> (a (generation-rate ?self)) zero)) :influences ((i+ ((amount-of ?sub gas) ?can) (generation-rate ?self)) (i- ((amount-of ?sub liquid) ?can) (generation-rate ?self)) (i- (heat (c-s ?sub liquid ?can)) (flow-rate (heat-flow ?ht-src ?hpath (c-s ?sub liquid ?can))))))