;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: attributes-isas.lsp ;;;; System: ;;;; Version: 1.0 ;;;; Author: Ken Forbus ;;;; Created: December 3, 2000 12:44:09 ;;;; Purpose: ;;;; --------------------------------------------------------------------------- ;;;; Modified: Wednesday, May 9, 2001 at 14:02:58 by forbus ;;;; --------------------------------------------------------------------------- (in-package :fire) ;;; (attributes->isas ) converts into a form that uses isa statements ;;; instead of attribute forms. ;;; (isas->attributes ) converts into a form that uses attributes instead ;;; of ISA statements. (defun attributes->isas (exp &key (kb *kb*)) (atr->isa exp kb)) (defun isas->attributes (exp &key (kb *kb*)) (isa->atr exp kb)) (defun atr->isa (exp kb) (cond ((null exp) nil) ((not (listp exp)) exp) ((= (length exp) 2) (multiple-value-bind (attribute? predicate) (attribute-predicate? (car exp) kb) (if attribute? (make-isa (cadr exp) predicate) exp))) (t (cons (atr->isa (car exp) kb) (mapcar #'(lambda (arg) (atr->isa arg kb)) (cdr exp)))))) (defun isa->atr (exp kb) (cond ((null exp) nil) ((not (listp exp)) exp) ((isa-statement? exp) (list (third exp) (cadr exp))) (t (cons (isa->atr (car exp) kb) (mapcar #'(lambda (arg) (isa->atr arg kb)) (cdr exp)))))) ;;;; --------------------------------------------------------------------------- ;;; END OF CODE