;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: make-exp.lsp ;;;; System: FIRE qp-source ;;;; Version: 1.0 ;;;; Author: Jin Yan ;;;; Created: March 5, 2003 12:23:11 ;;;; Purpose: Defining GIZMO scenario ;;;; --------------------------------------------------------------------------- ;;;; Modified: Wednesday, January 14, 2004 at 21:37:06 by Jin Yan ;;;; --------------------------------------------------------------------------- ;;;JY: Note under Gizmo, both gizmo and state are defined as a struct. (in-package :fire) ;;; Qualitative Reasoning (defgeneric make-gizmo-reference (gizmo-or-id)) (defmethod make-gizmo-reference ((gizmo gizmo::gizmo)) ;; This is the WM version. The idea is to just get quickly to ;; the SME internals, and not build any new datastructures that we ;; don't have to. `(,(if (mixed-case?) 'data::QpAnalysisFn 'data::qp-analysis-fn) ,(gizmo::gizmo-id-number gizmo))) (defmethod make-gizmo-reference ((gizmo-id integer)) ;; This is the WM version. The idea is to just get quickly to ;; the SME internals, and not build any new datastructures that we ;; don't have to. `(,(if (mixed-case?) 'data::QpAnalysisFn 'data::qp-analysis-fn) ,gizmo-id)) (defun make-state-reference (state) `(,(if (mixed-case?) 'data::QpStateFn 'data::qp-state-fn) ,(gizmo::state-title state) ,(gizmo::gizmo-id-number (gizmo::state-gizmo state)))) ;;; produces: (QpStateFn ) (defun declare-QpAnalysis (gizmo) (make-isa (make-gizmo-reference gizmo) (if (mixed-case?) 'data::QpAnalysis 'data::qp-analysis))) (defun declare-QpState (state) (make-isa (make-state-reference state) (if (mixed-case?) 'data::QpState 'data::qp-state))) (defun declare-gizmo-state (state) `(,(if (mixed-case?) 'data::qpGizmoState 'data::qp-gizmo-state) ,(make-gizmo-reference (gizmo::state-gizmo state)) ,(make-state-reference state))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; declare properties of an individual state. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun declare-state-vs (state) `(,(if (mixed-case?) 'data::stateViewStructures 'data::state-view-structures) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-view-structure state)))) (defun declare-state-ps (state) `(,(if (mixed-case?) 'data::stateProcessStructures 'data::state-process-structures) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-process-structure state)))) (defun declare-state-ds-values (state) `(,(if (mixed-case?) 'data::stateDsValues 'data::state-ds-values) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::filtered-state-ds-values state)))) (defun declare-state-quantities (state) `(,(if (mixed-case?) 'data::stateQuantities 'data::state-quantities) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-quantities state)))) (defun declare-state-ineqls (state) `(,(if (mixed-case?) 'data::stateOrdinalRelations 'data::state-ordinal-relations) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-comparisons state)))) (defun declare-state-influences (state) `(,(if (mixed-case?) 'data::stateInfluences 'data::state-influences) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-influences state)))) ;;;(defun declare-state-influence-resolution (state) ;;; `(,(if (mixed-case?) 'data::stateInfluenceResolutions 'data::state-influence-resolutions) ;;; ,(make-state-reference state) ;;; ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) ;;; (gizmo::state-influences state)))) (defun declare-state-continuity-constraints (state) `(,(if (mixed-case?) 'data::stateContinuityConstraints 'data::state-continuity-constraints) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) ;;; (sort (mapcar #'(lambda (constraint) ;;; (format nil "~A <- ~A." ;;; (gizmo::lprinc-string (cdr constraint)) ;;; (car constraint))) (gizmo::state-next-constraints state)))) ;;; 'string<)))) (defun declare-state-assumptions (state) `(,(if (mixed-case?) 'data::stateAssumptions 'data::state-assumptions) ,(make-state-reference state) ,(cons (if (mixed-case?) 'data::TheList 'data::the-list) (gizmo::state-assumptions state)))) (defun declare-state-status (state) `(,(if (mixed-case?) 'data::stateStatus 'data::state-status) ,(make-state-reference state) ,(display-state-status state))) ;;transfered from function gizmo::show-state-status (defun display-state-status (state) (cond ((gizmo::dead-state? state) (list 'data::Dead=> (gizmo::state-death-reason state))) ((gizmo::state-subsumed? state) `('data::Subsumed=> ,(gizmo::state-subsumed-by state))) ((gizmo::state-subsumes state) `('data::Subsumes=> ,(gizmo::state-subsumes state))) (t 'data::Alive))) (defun make-transition-states (state) `(,(if (mixed-case?) 'data::qpStateTransitionTo 'data::qp-state-transition-to) ,(make-state-reference state) ,(mapcar 'make-state-reference (gizmo::state-next state)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;(defun make-genls (sub super) `(data::genls ,sub ,super)) (defun make-genls (sub super) (if (mixed-case?) `(data::genls ,(convert-to-cyc sub) ,(convert-to-cyc super)) `(data::genls ,sub ,super))) (defun make-isa (thing collection) `(data::isa ,thing ,collection)) ;;;(defun make-isa (thing collection) ;;; (if (mixed-case?) ;;; `(data::isa ,(convert-to-cyc thing) ,(convert-to-cyc collection)) ;;; `(data::isa thing collection))) (defun make-in-dt (fact &optional (dt *current-dt*)) `(,(if (mixed-case?) 'data::inDomainTheory 'data::in-domain-theory) ,dt ,fact)) (defun make-physical-quantity (qtype) (make-genls qtype (if (mixed-case?) 'data::PhysicalQuantity 'data::physical-quantity))) ;;;(defun make-qp-quantity (qp-quantity-fn) ;;; (if (mixed-case?) ;;; `(data::qpQuantity ,(convert-to-cyc qp-quantity-fn)) ;;; `(data::qp-quantity ,qp-quantity-fn))) (defun make-qp-quantity (qp-quantity-fn) (if (mixed-case?) `(data::qpQuantity ,qp-quantity-fn) `(data::qp-quantity ,qp-quantity-fn))) ;;;(defun make-qp-quantity-fn (qp-quantity-fn) ;;; (if (mixed-case?) ;;; `(data::QpQuantityFn ,(convert-to-cyc qp-quantity-fn)) ;;; `(data::qp-quantity-fn ,qp-quantity-fn))) (defun make-qp-quantity-fn (qp-quantity-fn) (if (mixed-case?) `(data::QpQuantityFn ,qp-quantity-fn) `(data::qp-quantity-fn ,qp-quantity-fn))) (defun make-arg-isa (position pred var) (case position (1 `(,(if (mixed-case?) 'data::arg1Isa 'data::arg1-isa) ,pred ,(var->collection var))) (2 `(,(if (mixed-case?) 'data::arg2Isa 'data::arg2-isa) ,pred ,(var->collection var))) (3 `(,(if (mixed-case?) 'data::arg3Isa 'data::arg3-isa) ,pred ,(var->collection var))))) (defun make-arity (predicate arity) `(data::arity ,predicate ,arity)) ;;;(defun make-attribute-declaration (constant) ;;; (make-isa (convert-to-cyc constant) ;;; (if (mixed-case?) 'data::Collection ;;; 'data::collection))) (defun make-attribute-declaration (constant) (make-isa constant (if (mixed-case?) 'data::Collection 'data::collection))) (defun make-qp-univ (fact) `(,(if (mixed-case?) 'data::qpUnivFact 'data::qp-univ-fact) ,(make-genls (cadr fact) (car fact)))) (defun make-qp-constant (constant) (if (mixed-case?) `(data::qpConstant ,constant) `(data::qp-constant ,constant))) (defun make-qp-relation (fact) `(,(if (mixed-case?) 'data::qpRelation 'data::qp-relation) ,fact)) (defun make-forAll (vars expr) `(data::forAll ,vars ,expr)) (defun make-pred (pred) `(data::isa ,pred ,(if (mixed-case?) 'data::Predicate 'data::predicate))) (defun make-relation-implies (ante conse) `(data::qpRelationImplies ,ante ,conse)) (defun make-entity-quantity (entity quantity) `(data::forAll (data::?x) (data::implies (data::isa data::?x ,entity) (data::isa ((data::qpQuantityFn ,quantity) data::?x) data::Quantity)))) ;;;(defun make-entity-subclass (entity super) ;;; `(data::qpEntitySubclass ,(convert-to-cyc entity) ;;; ,(convert-to-cyc super))) (defun make-entity-subclass (entity super) `(data::qpEntitySubclass ,entity ,super)) ;;;(defun make-mf-subclass (mf super) ;;; `(data::qpMFSubclass ,(convert-to-cyc mf) ;;; ,(convert-to-cyc super))) (defun make-mf-subclass (mf super) `(data::qpMFSubclass ,mf ,super)) ;;;(defun make-qp-entity (entity) ;;; (if (mixed-case?) ;;; `(data::qpEntity ,(convert-to-cyc entity)) ;;; `(data::qp-entity ,entity))) (defun make-qp-entity (entity) (if (mixed-case?) `(data::qpEntity ,entity) `(data::qp-entity ,entity))) (defun make-relation-subclass (predicate super) `(data::qpRelationSubclass ,predicate ,super)) (defun make-model-fragment (mf) (make-genls mf (if (mixed-case?) 'data::ModelFragment 'data::model-fragment))) ;;;(defun make-qp-mf (mf) ;;; `(,(if (mixed-case?) 'data::qpMF 'data::qp-mf) ;;; ,(if (mixed-case?) (convert-to-cyc mf) ;;; mf))) ;;;(defun make-qp-mf (mf) ;;; (if (mixed-case?) ;;; `(data::qpMF ,(convert-to-cyc mf)) ;;; `(data::qp-mf ,mf))) (defun make-qp-mf (mf) (if (mixed-case?) `(data::qpMF ,mf) `(data::qp-mf ,mf))) ;;;(defun make-qp-mf-participant (mf participant) ;;; (if (mixed-case?) ;;; `(data::qpMFParticipant ,(convert-to-cyc mf) ,(convert-to-cyc participant)) ;;; `(data::qp-mf-participant ,mf ,participant))) (defun make-qp-mf-participant (mf participant) (if (mixed-case?) `(data::qpMFParticipant ,mf ,participant) `(data::qp-mf-participant ,mf ,participant))) ;;;(defun make-qp-mf-participant-type (mf participant type) ;;; (if (mixed-case?) ;;; `(data::qpMFParticipantType ,(convert-to-cyc mf) ,(convert-to-cyc participant) ,(convert-to-cyc type)) ;;; `(data::qp-mf-participant-type ,mf ,participant ,type))) (defun make-qp-mf-participant-type (mf participant type) (if (mixed-case?) `(data::qpMFParticipantType ,mf ,participant ,type) `(data::qp-mf-participant-type ,mf ,participant ,type))) ;;;(defun make-qp-mf-participant-constraint (mf participant constraint) ;;; `(,(if (mixed-case?) 'data::qpMFParticipantConstraint 'data::qp-mf-participant-type) ;;; ,mf ,participant ,constraint)) ;;;(defun make-qp-mf-participant-constraint (mf participant constraint) ;;; (if (mixed-case?) ;;; `(data::qpMFParticipantConstraint ,(convert-to-cyc mf) ,(convert-to-cyc participant) ,(convert-to-cyc constraint)) ;;; `(data::qp-mf-participant-type ,mf ,participant ,constraint))) (defun make-qp-mf-participant-constraint (mf participant constraint) (if (mixed-case?) `(data::qpMFParticipantConstraint ,mf ,participant ,constraint) `(data::qp-mf-participant-type ,mf ,participant ,constraint))) ;;;(defun make-qp-mf-quantity (mf quantity) ;;; (if (mixed-case?) ;;; `(data::qpMFQuantity ,(convert-to-cyc mf) ,(convert-to-cyc quantity)) ;;; `(data::qp-mf-quantity ,mf ,quantity))) (defun make-qp-mf-quantity (mf quantity) (if (mixed-case?) `(data::qpMFQuantity ,mf ,quantity) `(data::qp-mf-quantity ,mf ,quantity))) ;;;(defun make-qp-mf-quantity-type (mf quantity type) ;;; (if (mixed-case?) ;;; `(data::qpMFQuantityType ,(convert-to-cyc mf) ,(convert-to-cyc quantity) ,(convert-to-cyc type)) ;;; `(data::qp-mf-quantity-type ,mf ,quantity ,type))) (defun make-qp-mf-quantity-type (mf quantity type) (if (mixed-case?) `(data::qpMFQuantityType ,mf ,quantity ,type) `(data::qp-mf-quantity-type ,mf ,quantity ,type))) ;;;(defun make-qp-mf-quantity-arguments (mf quantity arguments) ;;; (if (mixed-case?) ;;; `(data::qpMFQuantityArguments ,(convert-to-cyc mf) ,(convert-to-cyc quantity) ,(convert-to-cyc arguments)) ;;; `(data::qp-mf-quantity-arguments ,mf ,quantity ,arguments))) (defun make-qp-mf-quantity-arguments (mf quantity arguments) (if (mixed-case?) `(data::qpMFQuantityArguments ,mf ,quantity ,arguments) `(data::qp-mf-quantity-arguments ,mf ,quantity ,arguments))) ;;;(defun make-qp-mf-condition (mf condition) ;;; (if (mixed-case?) ;;; `(data::qpMFCondition ,(convert-to-cyc mf) ,(convert-to-cyc condition)) ;;; `(data::qp-mf-condition ,mf ,condition))) (defun make-qp-mf-condition (mf condition) (if (mixed-case?) `(data::qpMFCondition ,mf ,condition) `(data::qp-mf-condition ,mf ,condition))) ;;;(defun make-qp-mf-consequence (mf consequence) ;;; (if (mixed-case?) ;;; `(data::qpMFConsequence ,(convert-to-cyc mf) ,(convert-to-cyc consequence)) ;;; `(data::qp-mf-consequence ,mf ,consequence))) (defun make-qp-mf-consequence (mf consequence) (if (mixed-case?) `(data::qpMFConsequence ,mf ,consequence) `(data::qp-mf-consequence ,mf ,consequence)))