;;; -*- Mode:Lisp; Package:ONTOLINGUA-USER; Syntax:COMMON-LISP; Base:10 -*-

;;; (c) 1993, 1994 Greg Olsen and Thomas Gruber

(in-package "ONTOLINGUA-USER")

    (component-assemblies parametric-constraints)
  "This theory combines components and constraints.
Components are associated with constraints by the binary relation
has-constraint.  Constraint satisfaction
is the application of these constraints to components using
satisfies-constraint.  A valid-component is a component for which
all of its constraints are satisfied, and all of its subcomponents
are valid components.  Parameters are associated with components
via unary functions called parameter-slot's."
  :issues ("(c) 1994 Thomas R. Gruber and Gregory R. Olsen"))

(in-theory 'components-with-constraints)

(define-relation HAS-CONSTRAINT (?component ?constraint)
  "To say a component has a constraint means that the constraint
has been associated with the component.  The constraint holds
for the component iff it is a satisfied constraint of the component."
  :def (and (component ?component)
            (object-constraint ?constraint)))

(define-relation CONSTRAINT-ON (?constraint ?component)
  "Constraint-on is the inverse of has-constraint: it maps constraint
objects to the components to which they have been applied."
  :iff-def (has-constraint ?component ?constraint))

(define-relation USED-IN-CONSTRAINT (?parameter-slot ?constraint)
  "Maps an parameter-slot to those constraints in which is it used
as a function.  For human convenience."
  :def (and (parameter-slot ?parameter-slot)
	    (constraint ?constraint)))

(define-class VALID-COMPONENT (?component)
  "A component is 'configured' or fully specified if all of its
constraints are satisfied and all of its subparts are also configured.
By definition, there exist values for all the parameters of a component.
Whether an agent can tell you what the values of parameters are
is not part of the definition of configured component.
Knowing all the constraints associated with a component will
require making a closed world assumption on the has-constraint slot."

  :iff-def (and (component ?component)
		(forall ?constraint
		   (=> (has-constraint ?component ?constraint)
		       (satisfies-constraint ?component ?constraint)))
		(forall ?part-slot
		   (=> (has-subcomponent ?component ?part-slot)
		       (valid-component (value ?part-slot ?component))))))

(define-relation HAS-PARAMETER-SLOT (?component ?parameter-slot)
  "A component has an parameter if the parameter value is given by a
unary function, called an parameter-slot, that is defined for
that component.  Calling a slot an parameter-slot means that it is
a design parameter: it will need to be assigned a value and
may be mentioned in constraints.  The parameter slot must
have a value."

  :def (and (component ?component)
            (parameter-slot ?parameter-slot)
	    (value-cardinality ?component ?parameter-slot 1))

  :issues ("The parameter is not reified as an object with a
            slot for its value.  Instead, it's just a named
            slot.  Since the slot is a function, and function
            constants can be used as terms in KIF, then one can 
            still describe properties of an parameter as such."
	   ("The value-cardinality spec says that each
             parameter must have exactly one value
             per component.  What does this mean for
             parameters that are not constants, i.e., those
             that are computed from other values via constraints?"
	    "If someone asserts that component C has-parameter-slot A,
             then this spec says that there exists a value for
             the function A applied to C.  It does not say that
             any particular agent knows what that value is."
	    (:formerly-called has-attribute)
	    (:see-also VALID-DESIGN))))

(define-relation PARAMETER-SLOT-OF (?parameter-slot ?component)
  "Parameter-slot-of is the inverse of has-parameter-slot:
it maps parameter slots to the components to which they have been applied."
  :iff-def (has-parameter-slot ?component ?parameter-slot)
  :issues ((:formerly-called attribute-of)))

(define-class PARAMETER-SLOT (?unary-function)
  "An parameter slot is a unary function from COMPONENTs
to parameter values.  There is no intermediate parameter object
when using parameter slots, since the function itself serves as
the name of the parameter."
  :def (and (unary-function ?unary-function)
            (domain ?unary-function component))
  :issues  ((:formerly-called attribute-slot)))

This Lisp-to-HTML translation was brought to you by
François Gerbaux and Tom Gruber