;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: defsys.lsp ;;;; System: FIRE ;;;; Version: v1 ;;;; Author: Ken Forbus ;;;; Created: November 5, 2000 22:13:19 ;;;; Purpose: Define the Fire system ;;;; --------------------------------------------------------------------------- ;;;; Modified: Monday, May 31, 2004 at 15:00:30 by Kenneth Forbus ;;;; --------------------------------------------------------------------------- ;;;; ;;;; Integrated Reasoning Engine ;;;; (The F is for Fast/Flexible/TBD) (in-package :common-lisp-user) ;;;; Change Log ;;;; --------------------------------------------------------------------------- ;;;; 04/15/2004 ureel > Added conditional loading of Gizmo Fire subsystem. #-qrg (error "You must first load qrgsetup.lsp.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Define package ;; For loading legacy files, define the DTE-DB package. (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage :dte-db)) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage :fire (:use :common-lisp :common-lisp-user :qrg))) ;;Provide the ability to move data to a separate package in the future. (eval-when (:compile-toplevel :load-toplevel :execute) (unless (find-package :data) (rename-package (find-package :cl-user) :common-lisp-user ;keep name the same (append (package-nicknames (find-package :cl-user)) '(:data :d))))) (in-package :fire) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Load other modules used by the system (require :process) ;;; Ensure RDC package is defined (unless (find-package :rdc) (load-file (qrg::make-qrg-path) "rdc-bridge" :action :load-source)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Define system globals (defparameter *fire-version* "V1") (defparameter *fire-path* (make-qrg-path "FIRE" *fire-version*)) ;; Function to get fire path (works for running under executable or devel environment) (defun get-fire-path (&key (subdirs nil) (filename nil) (filetype nil)) (qrg::get-path :root-path *fire-path* :subdirs subdirs :filename filename :filetype filetype)) ;;;; Load system definitions for dependent systems #-unix (qrg:require-system (qrg:make-qrg-path "code-library" "lisp" "runtime-utils") :load-runtime-utils :runtime-utils :action :compile-if-newer :verbose t :force-load nil) (defparameter *ltre-version* "v7") (unless (find-package :ltre) (qrg::load-qrg-defsys (qrg:make-qrg-path "LTRE" *ltre-version*))) (unless (find-package :sme) (qrg::load-qrg-defsys (qrg:make-qrg-path "SME" "V4"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PackDoc stuff (eval-when (:load-toplevel :compile-toplevel :execute) (defmacro export-symbols (subpackage-name doc-string symbols) "Assigns a name and documentation to the group of symbols and exports them from the current package. If PackDoc has been loaded, subpackage documentation will also be generated." `(progn (export ,symbols) (when (member :packdoc *features*) (funcall (intern :subpackage-documentation :packdoc) ,subpackage-name ,symbols ,doc-string))))) #+packdoc (defun generate-fire-documentation (&key (output-path (qrg:append-qrg-path *fire-path* "docs")) (overwrite-files? t)) "Generates API documentation for FIRE in HTML format. Files are written to qrg/FIRE/V1/docs/ by default." (flet ((doc-path (filename) (qrg:make-full-file-spec output-path filename ".html"))) (packdoc:document-package-to-file :fire (doc-path :fire) :html nil t :block) #+common-graphics (cg:beep) :done)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Load the export file (qrg:load-file *fire-path* "export" :action :load-source) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Application files that must be shipped with the executable #-unix (ru:def-appfile "evalfns" "lsp" fire:*fire-path*) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; List the system's files (defparameter *fire-files* '("macros" ;; Macro definitions, must be loaded first (JE) "dte-stub" ;; Backwards compatibility for DTE KB flat files "defs" ;; Class definitions and globals "utils" ;; General utilities. "bdumper" ;; Binary Dumper Utility. ;; Structural cache: Contains structural information about predicates and collections "scache-defs" ;; Datastructures for structural cache "scache-update" ;; Incremental update of structural cache when KB changes "scache-ops" ;; Operations on the structural cache "scache-dumper" ;; Dumping the structural cache ;; Basic assertion making/checking, KB operations "make-exp" ;; Data abstraction for insulating code from particular KB predicates "kb-api-db" ;; Database component of KB API "kb-api-structural" ;; Structural computations part of KB API "expression-check" ;; Detects syntactic problems in expressions "gfr" ;; Grim Fact Reaper (currently a stub) ;; Reasoners "reasoner" ;; Reasoners provide the locus of activity for FIRE-based systems "sources" ;; Sources provide access to specialized resources. "pragmas" ;; Handling control information "ask-tell" ;; Simple queries, interface for access to reasoning soruces "structural" ;; ASK support for structural queries ;;; Analogical processing support "analogy-source" ;; Interface to analogy code. "sme-translation" ;; Conversion between FIRE and SME formats "analogy-summarization" ;; FIRE-specific code for summarizations "analogy-tests" ;; Unit tests of analogy code. "vocabulary" ;; Providing SME information about predicates from KB "dynamic-case-construction" ;; dynamic case construction methods "dgroup" ;; Creating SME dgroups from KB contents "cis" ;; Functions for loading CIs for an SME "content-vector" ;; Content vector support "case-library" ;; Case library support "case-library-dumper" ;; persistent storage for content vectors "macfac" ;; FIRE-internal implementation of MAC/FAC "minimal-ascension" ;; Support for tiered identicality in SME "reify-sme" ;; Lifts analogy results into LTRE. Base routines, -accessors for rest. "sme-accessors" ;; ask handlers for lifting SME results "macfac-accessors" ;; ask handlers for lifting MAC/FAC results ;; Loading knowledge base contents (including domain theories) "dt-loader" ;; Loading domain theories "loader" ;; Loading MELD files "knowledge-entry-api" ;; Support for metadata capture ;; Simple English output support "pidginize" ;; Pidginizing utility functions ;; Backchaining system "canonicalize" ;; Canonicalization "formulas" ;; Manipulating logical variables "clause-optimizer" ;; Finding orders of terms in queries "chainer" ;; Chainer construction "chainer-dumper" ;; "backward" ;; Definition of the backchaining algorithm "evaluate" ;; Support for queries that involve lisp evaluation "evaluate-handlers" ;; Automatically produced from evalfns.lsp, see evaluate.lsp "rulemacros" ;; Support for the RulemacroPredicates found in Cyc "344-utils" ;; shakedown uses them "shakedown" ;; Regression testing ;; Debugging #-runtime-system "debug" ;; Development support - ;; N.B. debug should always be last, so it can freely uses other FIRE modules )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; System loading functions (defun load-fire (&key (action :source-if-newer) (verbose t) (force-load nil) (gizmo nil)) ;; 20040415 ureel added gizmo keyword argument (when (or force-load (not (member :fire qrg:*modules-loaded*))) ;; Load systems FIRE depends on - note these are loaded before ;; FIRE code is loaded (when verbose (format t "~%Loading Systems FIRE depends on~%")) (qrg:require-system (make-qrg-path "Dbex" "v101") :load-dbex :dbex :action action :verbose verbose) (qrg:require-system (make-qrg-path "LTRE" *ltre-version*) :load-ltre :ltre :action action :verbose verbose :force-load force-load) (qrg:require-system (make-qrg-path "SME" "V4") :load-sme :sme :action action :verbose verbose :force-load force-load) (when verbose (format t "~%Loading FIRE code~%")) (qrg:load-files *fire-path* *fire-files* :action action :verbose verbose) (when gizmo (qrg::load-qrg-defsys "FIRE" *fire-version* "Gizmo") (user::load-gizmo-fire :action action :verbose verbose :force-load force-load)) (when (find-package :net.aserve) ;; Since these routines require allegroserve, only load them ;; when allegroserve is already around. (load-file *fire-path* "static-kb-browser" :action action :verbose verbose)) ;; Mark FIRE loaded (pushnew :fire qrg:*modules-loaded*) (pushnew :fire *features*) :done)) (defun load-fire-only (&key (action :source-if-newer)) (dolist (file *fire-files*) (load-file *fire-path* file :action action))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Loading GUI code ;;; These are split out because they are often optional. ;;; GUI code also tends to be less portable, so this enables ;;; someone doing a port to concentrate their efforts more easily. ;;; These haven't been tested under Linux, hence the #-'s. #-unix (defun load-fire-viewers (&key (action :source-if-newer) (verbose t) (force-load nil)) ;; Load Rbrowse (qrg:require-system (qrg:make-qrg-path "RBROWSE" "V1") :load-rbrowse :rbrowse :action action :verbose verbose :force-load force-load) ;;;; Shawn's code is buggy and needs conversion/simplification. (qrg:require-system (qrg:make-qrg-path "fire" *fire-version* "case-manager" "case-viewer") :load-case-viewer :fire-case-viewer :action action :verbose verbose :force-load force-load) :done) #-unix (defun load-kb-tools (&key (action :source-if-newer) (verbose t) (force-load nil)) ;; Loads the fancy KB flat-file loading and KB-checking tools. (when (or force-load (not (member :fire-kb-tools qrg:*modules-loaded*))) (require :process) (qrg:load-qrg-defsys "Code-Library" "Lisp" "GUI-Component-Library") (qrg:runtime-call :load-gui-components :gui-lib '(:animation-control) :action action :verbose t :force-load nil) (qrg:load-file *fire-path* "kb-tools" :action action :verbose verbose) (qrg:load-file *fire-path* "kb-loader" :action action :verbose verbose) (pushnew :fire-kb-tools *features*)) :done) ;;; What KDF uses for loading. Included to simplify testing #-unix (defun hack-fire (&key (action :source-if-newer)) (qrg::load-qrg-defsys "fire" "v1") (eval `(,(intern :load-fire (find-package :fire)) :action ,action)) (eval `(,(intern :load-fire-viewers (find-package :fire)) :action ,action)) (qrg::load-file (make-qrg-path "fire" "v1") "344-utils" :action :load-source)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; End of Code